decord/source/922_extractPromptResultAttributes.js

161 lines
5.8 KiB
JavaScript
Raw Normal View History

2026-07-20 16:05:17 +00:00
// Module ID: 922
2026-07-25 08:10:48 +00:00
// Function ID: 10070
2026-07-20 16:05:17 +00:00
// Name: extractPromptResultAttributes
2026-07-23 10:11:24 +00:00
// Dependencies: [57, 77, 916, 912]
2026-07-20 16:05:17 +00:00
// Exports: extractPromptResultAttributes, extractToolResultAttributes
// Module 922 (extractPromptResultAttributes)
2026-07-23 10:11:24 +00:00
import _slicedToArray from "_slicedToArray";
import _defineProperty from "_defineProperty";
2026-07-20 16:05:17 +00:00
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
export const extractPromptResultAttributes = function extractPromptResultAttributes(description, recordOutputs) {
2026-07-23 10:11:24 +00:00
let _defineProperty;
let _slicedToArray;
let obj = {};
2026-07-20 16:05:17 +00:00
if (obj2.isValidContentItem(description)) {
let tmp = recordOutputs;
if (recordOutputs) {
tmp = "string" === typeof description.description;
}
if (tmp) {
2026-07-23 10:11:24 +00:00
obj[obj(messages[2]).MCP_PROMPT_RESULT_DESCRIPTION_ATTRIBUTE] = description.description;
2026-07-20 16:05:17 +00:00
}
const _Array = Array;
if (Array.isArray(description.messages)) {
2026-07-23 10:11:24 +00:00
obj[obj(messages[2]).MCP_PROMPT_RESULT_MESSAGE_COUNT_ATTRIBUTE] = description.messages.length;
2026-07-20 16:05:17 +00:00
if (recordOutputs) {
2026-07-23 10:11:24 +00:00
messages = description.messages;
2026-07-20 16:05:17 +00:00
function _loop2() {
2026-07-23 10:11:24 +00:00
obj = obj(messages[3]);
2026-07-20 16:05:17 +00:00
if (obj.isValidContentItem(closure_3)) {
let str = "mcp.prompt.result";
if (1 !== messages.length) {
const _HermesInternal = HermesInternal;
str = "mcp.prompt.result." + closure_2;
}
const role = closure_3.role;
if ("string" !== typeof role) {
if (obj2.isValidContentItem(closure_3.content)) {
let text = closure_3.content;
if ("string" === typeof text.text) {
if (1 === messages.length) {
const _HermesInternal5 = HermesInternal;
let combined = "" + str + ".message_content";
} else {
const _HermesInternal4 = HermesInternal;
combined = "" + str + ".content";
}
text = text.text;
obj[combined] = text;
}
}
} else {
if (1 === messages.length) {
const _HermesInternal3 = HermesInternal;
let combined1 = "" + str + ".message_" + "role";
} else {
const _HermesInternal2 = HermesInternal;
combined1 = "" + str + "." + "role";
}
obj[combined1] = role;
}
} else {
return 1;
}
}
const entries = messages.entries();
const tmp9 = entries[Symbol.iterator]();
while (tmp9 !== undefined) {
2026-07-23 10:11:24 +00:00
let tmp12 = _slicedToArray;
let tmp13 = _slicedToArray(tmp10, 2);
[_slicedToArray, _defineProperty] = tmp13;
2026-07-20 16:05:17 +00:00
let tmp14 = _loop2;
let _loop2Result = _loop2();
2026-07-23 10:11:24 +00:00
continue;
2026-07-20 16:05:17 +00:00
}
}
}
return obj;
} else {
return obj;
}
2026-07-23 10:11:24 +00:00
obj2 = obj(messages[3]);
2026-07-20 16:05:17 +00:00
};
export const extractToolResultAttributes = function extractToolResultAttributes(content, recordOutputs) {
2026-07-23 10:11:24 +00:00
let obj = require(912) /* isJsonRpcNotification */;
2026-07-20 16:05:17 +00:00
if (obj.isValidContentItem(content)) {
const _Array = Array;
if (Array.isArray(content.content)) {
2026-07-23 10:11:24 +00:00
obj = (function buildAllContentItemAttributes(content, recordOutputs) {
let closure_3;
let closure_4;
let closure_0 = content;
let closure_1 = recordOutputs;
const tmp = outer1_3({}, outer1_0(outer1_1[2]).MCP_TOOL_RESULT_CONTENT_COUNT_ATTRIBUTE, content.length);
let closure_2 = tmp;
2026-07-20 16:05:17 +00:00
function _loop() {
if (obj.isValidContentItem(closure_4)) {
let str = "mcp.tool.result";
2026-07-23 10:11:24 +00:00
if (1 !== str.length) {
let _HermesInternal = HermesInternal;
2026-07-20 16:05:17 +00:00
str = "mcp.tool.result." + closure_3;
}
if ("string" === typeof closure_4.type) {
const _HermesInternal2 = HermesInternal;
2026-07-23 10:11:24 +00:00
closure_2["" + str + ".content_type"] = closure_4.type;
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
if (closure_1) {
2026-07-20 16:05:17 +00:00
function safeSet(mime_type, mimeType) {
if ("string" === typeof mimeType) {
const _HermesInternal = HermesInternal;
2026-07-23 10:11:24 +00:00
outer1_2["" + "" + "." + mime_type] = mimeType;
2026-07-20 16:05:17 +00:00
}
}
safeSet("mime_type", closure_4.mimeType);
safeSet("uri", closure_4.uri);
safeSet("name", closure_4.name);
if ("string" === typeof closure_4.text) {
const _HermesInternal3 = HermesInternal;
2026-07-23 10:11:24 +00:00
closure_2["" + str + ".content"] = closure_4.text;
2026-07-20 16:05:17 +00:00
}
if ("string" === typeof closure_4.data) {
const _HermesInternal4 = HermesInternal;
2026-07-23 10:11:24 +00:00
closure_2["" + str + ".data_size"] = closure_4.data.length;
2026-07-20 16:05:17 +00:00
}
const resource = closure_4.resource;
if (obj2.isValidContentItem(resource)) {
safeSet("resource_uri", resource.uri);
safeSet("resource_mime_type", resource.mimeType);
}
2026-07-23 10:11:24 +00:00
obj2 = outer2_0(outer2_1[3]);
2026-07-20 16:05:17 +00:00
}
} else {
return 1;
}
2026-07-23 10:11:24 +00:00
obj = outer2_0(outer2_1[3]);
2026-07-20 16:05:17 +00:00
}
const entries = content.entries();
while (tmp3 !== undefined) {
2026-07-23 10:11:24 +00:00
let tmp5 = outer1_2;
let tmp6 = outer1_2(tmp4, 2);
2026-07-20 16:05:17 +00:00
[closure_3, closure_4] = tmp6;
let tmp7 = _loop;
let _loopResult = _loop();
2026-07-23 10:11:24 +00:00
continue;
2026-07-20 16:05:17 +00:00
}
return tmp;
2026-07-23 10:11:24 +00:00
})(content.content, recordOutputs);
2026-07-20 16:05:17 +00:00
} else {
obj = {};
}
if ("boolean" === typeof content.isError) {
2026-07-23 10:11:24 +00:00
obj[require(916).MCP_TOOL_RESULT_IS_ERROR_ATTRIBUTE] = content.isError;
2026-07-20 16:05:17 +00:00
}
return obj;
} else {
return {};
}
};