@anuma/sdk 6.26.2 → 6.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/expo/index.cjs +223 -216
- package/dist/expo/index.d.mts +29 -1
- package/dist/expo/index.d.ts +29 -1
- package/dist/expo/index.mjs +220 -216
- package/dist/react/index.cjs +153 -110
- package/dist/react/index.mjs +151 -110
- package/dist/server/index.cjs +66 -1
- package/dist/server/index.mjs +66 -1
- package/dist/tools/index.cjs +1191 -1204
- package/dist/tools/index.d.mts +27 -47
- package/dist/tools/index.d.ts +27 -47
- package/dist/tools/index.mjs +1190 -1204
- package/package.json +1 -1
package/dist/server/index.mjs
CHANGED
|
@@ -21672,6 +21672,30 @@ function isSupportedMediaType(mimeType) {
|
|
|
21672
21672
|
var import_watermelondb20 = __toESM(require_watermelondb());
|
|
21673
21673
|
|
|
21674
21674
|
// src/lib/storage/mcpImages.ts
|
|
21675
|
+
var IMAGE_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
21676
|
+
"AnumaMediaMCP-anuma_create_image",
|
|
21677
|
+
"anuma_create_image",
|
|
21678
|
+
// Deprecated anuma-image-mcp tools, retained so images in already-stored
|
|
21679
|
+
// conversations still re-materialize on replay.
|
|
21680
|
+
"AnumaImageMCP-generate_cloud_image",
|
|
21681
|
+
"AnumaImageMCP-edit_cloud_image",
|
|
21682
|
+
"generate_cloud_image",
|
|
21683
|
+
"edit_cloud_image"
|
|
21684
|
+
]);
|
|
21685
|
+
function toolOutputForModel(name, output) {
|
|
21686
|
+
if (!name || !IMAGE_TOOL_NAMES.has(name)) return output;
|
|
21687
|
+
try {
|
|
21688
|
+
const {
|
|
21689
|
+
imageUrl: _imageUrl,
|
|
21690
|
+
url: _url,
|
|
21691
|
+
output_images: _outputImages,
|
|
21692
|
+
...rest
|
|
21693
|
+
} = JSON.parse(output);
|
|
21694
|
+
return JSON.stringify(rest);
|
|
21695
|
+
} catch {
|
|
21696
|
+
return output;
|
|
21697
|
+
}
|
|
21698
|
+
}
|
|
21675
21699
|
var VIDEO_EXTENSIONS = ["mp4", "webm", "mov"];
|
|
21676
21700
|
var VIDEO_EXTENSION_RE = new RegExp(`\\.(${VIDEO_EXTENSIONS.join("|")})(?:[?#]|$)`, "i");
|
|
21677
21701
|
function videoExtensionOf(value) {
|
|
@@ -35349,6 +35373,40 @@ function extractLastUserText(messages) {
|
|
|
35349
35373
|
function isToolErrorResult(result) {
|
|
35350
35374
|
return result !== null && typeof result === "object" && "error" in result && typeof result.error === "string";
|
|
35351
35375
|
}
|
|
35376
|
+
function serverToolCallMessages(events, messages, skipIds) {
|
|
35377
|
+
const seen = new Set(skipIds);
|
|
35378
|
+
for (const m of messages) {
|
|
35379
|
+
if (m.tool_call_id) seen.add(m.tool_call_id);
|
|
35380
|
+
for (const tc of m.tool_calls ?? []) if (tc.id) seen.add(tc.id);
|
|
35381
|
+
}
|
|
35382
|
+
const executed = [];
|
|
35383
|
+
for (const event of events ?? []) {
|
|
35384
|
+
if (!event.id || event.output === void 0 || event.output === null || seen.has(event.id)) {
|
|
35385
|
+
continue;
|
|
35386
|
+
}
|
|
35387
|
+
seen.add(event.id);
|
|
35388
|
+
executed.push(event);
|
|
35389
|
+
}
|
|
35390
|
+
if (executed.length === 0) return [];
|
|
35391
|
+
return [
|
|
35392
|
+
{
|
|
35393
|
+
role: "assistant",
|
|
35394
|
+
content: void 0,
|
|
35395
|
+
tool_calls: executed.map((event) => ({
|
|
35396
|
+
id: event.id,
|
|
35397
|
+
type: "function",
|
|
35398
|
+
function: { name: event.name, arguments: event.arguments }
|
|
35399
|
+
}))
|
|
35400
|
+
},
|
|
35401
|
+
...executed.map(
|
|
35402
|
+
(event) => ({
|
|
35403
|
+
role: "tool",
|
|
35404
|
+
tool_call_id: event.id,
|
|
35405
|
+
content: [{ type: "text", text: toolOutputForModel(event.name, event.output ?? "") }]
|
|
35406
|
+
})
|
|
35407
|
+
)
|
|
35408
|
+
];
|
|
35409
|
+
}
|
|
35352
35410
|
function getToolName(tool) {
|
|
35353
35411
|
const func = tool.function;
|
|
35354
35412
|
const nestedName = func?.name;
|
|
@@ -36118,7 +36176,14 @@ Executing tool: ${toolInfo}
|
|
|
36118
36176
|
}
|
|
36119
36177
|
}))
|
|
36120
36178
|
};
|
|
36121
|
-
const toolResultMessages = [
|
|
36179
|
+
const toolResultMessages = [
|
|
36180
|
+
...serverToolCallMessages(
|
|
36181
|
+
currentAccumulator.toolCallEvents,
|
|
36182
|
+
currentMessages,
|
|
36183
|
+
new Set(toolCallsToExecute.map((tc) => tc.id))
|
|
36184
|
+
),
|
|
36185
|
+
assistantMessage
|
|
36186
|
+
];
|
|
36122
36187
|
for (const execResult of continueResults) {
|
|
36123
36188
|
const resultContent = execResult.error ? `Error: ${execResult.error}` : safeJsonStringify(execResult.result);
|
|
36124
36189
|
toolResultMessages.push({
|