@skilder-ai/runtime 0.8.0 → 0.8.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/index.js +206 -82
- package/dist/index.js.map +3 -3
- package/dist/script-sdk-bundle.cjs +11 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -44938,7 +44938,7 @@ var require_core2 = __commonJS({
|
|
|
44938
44938
|
};
|
|
44939
44939
|
var MAX_EXPRESSION = 200;
|
|
44940
44940
|
function requiredOptions(o) {
|
|
44941
|
-
var _a51, _b39, _c11, _d8, _e7, _f3, _g6, _h2, _j2, _k3, _l, _m, _o2, _p2, _q2,
|
|
44941
|
+
var _a51, _b39, _c11, _d8, _e7, _f3, _g6, _h2, _j2, _k3, _l, _m, _o2, _p2, _q2, _r2, _s, _t, _u, _v, _w, _x, _y, _z, _0;
|
|
44942
44942
|
const s = o.strict;
|
|
44943
44943
|
const _optz = (_a51 = o.code) === null || _a51 === void 0 ? void 0 : _a51.optimize;
|
|
44944
44944
|
const optimize = _optz === true || _optz === void 0 ? 1 : _optz || 0;
|
|
@@ -44952,7 +44952,7 @@ var require_core2 = __commonJS({
|
|
|
44952
44952
|
strictRequired: (_p2 = (_o2 = o.strictRequired) !== null && _o2 !== void 0 ? _o2 : s) !== null && _p2 !== void 0 ? _p2 : false,
|
|
44953
44953
|
code: o.code ? { ...o.code, optimize, regExp } : { optimize, regExp },
|
|
44954
44954
|
loopRequired: (_q2 = o.loopRequired) !== null && _q2 !== void 0 ? _q2 : MAX_EXPRESSION,
|
|
44955
|
-
loopEnum: (
|
|
44955
|
+
loopEnum: (_r2 = o.loopEnum) !== null && _r2 !== void 0 ? _r2 : MAX_EXPRESSION,
|
|
44956
44956
|
meta: (_s = o.meta) !== null && _s !== void 0 ? _s : true,
|
|
44957
44957
|
messages: (_t = o.messages) !== null && _t !== void 0 ? _t : true,
|
|
44958
44958
|
inlineRefs: (_u = o.inlineRefs) !== null && _u !== void 0 ? _u : true,
|
|
@@ -125384,7 +125384,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
125384
125384
|
};
|
|
125385
125385
|
}
|
|
125386
125386
|
async doGenerate(options) {
|
|
125387
|
-
var _a51, _b39, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m, _n, _o2, _p2, _q2,
|
|
125387
|
+
var _a51, _b39, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m, _n, _o2, _p2, _q2, _r2, _s, _t, _u, _v, _w, _x, _y;
|
|
125388
125388
|
const {
|
|
125389
125389
|
args: body,
|
|
125390
125390
|
warnings,
|
|
@@ -125686,7 +125686,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
125686
125686
|
}
|
|
125687
125687
|
case "mcp_approval_request": {
|
|
125688
125688
|
const approvalRequestId = (_q2 = part.approval_request_id) != null ? _q2 : part.id;
|
|
125689
|
-
const dummyToolCallId = (_t = (_s = (
|
|
125689
|
+
const dummyToolCallId = (_t = (_s = (_r2 = this.config).generateId) == null ? void 0 : _s.call(_r2)) != null ? _t : generateId();
|
|
125690
125690
|
const toolName = `mcp.${part.name}`;
|
|
125691
125691
|
content.push({
|
|
125692
125692
|
type: "tool-call",
|
|
@@ -125867,7 +125867,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
125867
125867
|
controller.enqueue({ type: "stream-start", warnings });
|
|
125868
125868
|
},
|
|
125869
125869
|
transform(chunk, controller) {
|
|
125870
|
-
var _a51, _b39, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m, _n, _o2, _p2, _q2,
|
|
125870
|
+
var _a51, _b39, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m, _n, _o2, _p2, _q2, _r2, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F;
|
|
125871
125871
|
if (options.includeRawChunks) {
|
|
125872
125872
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
125873
125873
|
}
|
|
@@ -126515,7 +126515,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
126515
126515
|
} else if (isResponseFinishedChunk(value)) {
|
|
126516
126516
|
finishReason = {
|
|
126517
126517
|
unified: mapOpenAIResponseFinishReason({
|
|
126518
|
-
finishReason: (
|
|
126518
|
+
finishReason: (_r2 = value.response.incomplete_details) == null ? void 0 : _r2.reason,
|
|
126519
126519
|
hasFunctionCall
|
|
126520
126520
|
}),
|
|
126521
126521
|
raw: (_t = (_s = value.response.incomplete_details) == null ? void 0 : _s.reason) != null ? _t : void 0
|
|
@@ -128694,7 +128694,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
128694
128694
|
cacheControlValidator,
|
|
128695
128695
|
toolNameMapping
|
|
128696
128696
|
}) {
|
|
128697
|
-
var _a51, _b39, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m, _n, _o2, _p2, _q2,
|
|
128697
|
+
var _a51, _b39, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m, _n, _o2, _p2, _q2, _r2;
|
|
128698
128698
|
const betas = /* @__PURE__ */ new Set();
|
|
128699
128699
|
const blocks = groupIntoBlocks(prompt);
|
|
128700
128700
|
const validator = cacheControlValidator || new CacheControlValidator();
|
|
@@ -129289,7 +129289,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
129289
129289
|
tool_use_id: part.toolCallId,
|
|
129290
129290
|
content: {
|
|
129291
129291
|
type: "web_fetch_tool_result_error",
|
|
129292
|
-
error_code: (
|
|
129292
|
+
error_code: (_r2 = errorValue.errorCode) != null ? _r2 : "unknown"
|
|
129293
129293
|
},
|
|
129294
129294
|
cache_control: cacheControl
|
|
129295
129295
|
});
|
|
@@ -143749,6 +143749,14 @@ var __param7 = function(paramIndex, decorator) {
|
|
|
143749
143749
|
};
|
|
143750
143750
|
};
|
|
143751
143751
|
var _a29;
|
|
143752
|
+
var AssetTooLargeError = class extends Error {
|
|
143753
|
+
constructor(bufferBytes, maxBytes) {
|
|
143754
|
+
super(`Buffer size ${bufferBytes} bytes exceeds maximum ${maxBytes} bytes`);
|
|
143755
|
+
this.bufferBytes = bufferBytes;
|
|
143756
|
+
this.maxBytes = maxBytes;
|
|
143757
|
+
this.name = "AssetTooLargeError";
|
|
143758
|
+
}
|
|
143759
|
+
};
|
|
143752
143760
|
var FileService = class FileService2 extends Service {
|
|
143753
143761
|
constructor(loggerService) {
|
|
143754
143762
|
super();
|
|
@@ -143877,6 +143885,10 @@ var FileService = class FileService2 extends Service {
|
|
|
143877
143885
|
* Returns the absolute path to the cached file.
|
|
143878
143886
|
*/
|
|
143879
143887
|
async cacheAsset(assetPath, buffer) {
|
|
143888
|
+
const maxBytes = this.maxFileSizeMB * 1024 * 1024;
|
|
143889
|
+
if (buffer.length > maxBytes) {
|
|
143890
|
+
throw new AssetTooLargeError(buffer.length, maxBytes);
|
|
143891
|
+
}
|
|
143880
143892
|
return writeAssetCache(assetPath, buffer, this.getFileConfig());
|
|
143881
143893
|
}
|
|
143882
143894
|
/**
|
|
@@ -145228,30 +145240,26 @@ ${JSON.stringify(toolConfig.inputSchema, null, 2)}`
|
|
|
145228
145240
|
}
|
|
145229
145241
|
|
|
145230
145242
|
// src/services/static-tools/download-asset.handler.ts
|
|
145231
|
-
|
|
145232
|
-
|
|
145233
|
-
|
|
145234
|
-
|
|
145235
|
-
|
|
145236
|
-
|
|
145237
|
-
Usage: download_asset --path "/Skill Name/filename.ext"
|
|
145238
|
-
|
|
145239
|
-
Examples:
|
|
145240
|
-
- \`download_asset --path "/Data Processing/template.xlsx"\`
|
|
145241
|
-
- \`download_asset --path "/Reports/logo.png"\``
|
|
145242
|
-
);
|
|
145243
|
+
var DownloadAssetError = class extends Error {
|
|
145244
|
+
constructor(userMessage, skillId) {
|
|
145245
|
+
super(userMessage);
|
|
145246
|
+
this.userMessage = userMessage;
|
|
145247
|
+
this.skillId = skillId;
|
|
145248
|
+
this.name = "DownloadAssetError";
|
|
145243
145249
|
}
|
|
145250
|
+
};
|
|
145251
|
+
async function downloadSkillAsset(path4, deps) {
|
|
145244
145252
|
let parsedPath;
|
|
145245
145253
|
try {
|
|
145246
145254
|
parsedPath = parsePath(path4);
|
|
145247
145255
|
} catch (error48) {
|
|
145248
145256
|
if (error48 instanceof PathParseError) {
|
|
145249
|
-
|
|
145257
|
+
throw new DownloadAssetError(`Error: Invalid path "${path4}". ${error48.message}`);
|
|
145250
145258
|
}
|
|
145251
145259
|
throw error48;
|
|
145252
145260
|
}
|
|
145253
145261
|
if (parsedPath.type !== "resource") {
|
|
145254
|
-
|
|
145262
|
+
throw new DownloadAssetError(
|
|
145255
145263
|
`Error: download_asset requires a resource path.
|
|
145256
145264
|
|
|
145257
145265
|
Expected format: \`/Skill Name/filename.ext\`
|
|
@@ -145261,10 +145269,10 @@ For learning skills, use the \`learn\` tool instead.
|
|
|
145261
145269
|
For executing scripts, use the \`execute_script\` tool.`
|
|
145262
145270
|
);
|
|
145263
145271
|
}
|
|
145264
|
-
const skill =
|
|
145272
|
+
const skill = deps.catalog?.skills.find((s) => s.name === parsedPath.skillName);
|
|
145265
145273
|
if (!skill) {
|
|
145266
|
-
const availableSkills =
|
|
145267
|
-
|
|
145274
|
+
const availableSkills = deps.catalog?.skills.map((s) => s.name).join(", ") || "none";
|
|
145275
|
+
throw new DownloadAssetError(
|
|
145268
145276
|
`Error: Skill "${parsedPath.skillName}" not found. Available skills: ${availableSkills}`
|
|
145269
145277
|
);
|
|
145270
145278
|
}
|
|
@@ -145278,76 +145286,146 @@ For executing scripts, use the \`execute_script\` tool.`
|
|
|
145278
145286
|
if (!item) {
|
|
145279
145287
|
const downloadableItems = skill.related.filter((r2) => r2.class === "downloadable");
|
|
145280
145288
|
const availableItems = downloadableItems.map((r2) => r2.path ? `${r2.path}/${r2.name}` : r2.name).join(", ") || "none";
|
|
145281
|
-
|
|
145289
|
+
throw new DownloadAssetError(
|
|
145282
145290
|
`Error: Resource "${parsedPath.resourceName}" not found in skill "${skill.name}". Available downloadable assets: ${availableItems}`
|
|
145283
145291
|
);
|
|
145284
145292
|
}
|
|
145285
145293
|
if (item.class !== "downloadable") {
|
|
145286
145294
|
if (item.class === "learnable") {
|
|
145287
|
-
|
|
145295
|
+
throw new DownloadAssetError(
|
|
145288
145296
|
`Error: "${item.name}" is a learnable text resource, not a downloadable asset. Use \`learn\` to read it.
|
|
145289
145297
|
|
|
145290
145298
|
To access this resource:
|
|
145291
145299
|
\`learn --path "/${skill.name}/${parsedPath.resourceName}"\``,
|
|
145292
|
-
|
|
145300
|
+
skill.id
|
|
145293
145301
|
);
|
|
145294
145302
|
}
|
|
145295
145303
|
if (item.class === "executable") {
|
|
145296
|
-
|
|
145304
|
+
throw new DownloadAssetError(
|
|
145297
145305
|
`Error: "${item.name}" is an executable script, not a downloadable asset. Use \`execute_script\` to run it.
|
|
145298
145306
|
|
|
145299
145307
|
To execute this script:
|
|
145300
145308
|
\`execute_script --path "/${skill.name}/${parsedPath.resourceName}"\``,
|
|
145301
|
-
|
|
145309
|
+
skill.id
|
|
145302
145310
|
);
|
|
145303
145311
|
}
|
|
145304
|
-
|
|
145312
|
+
throw new DownloadAssetError(
|
|
145305
145313
|
`Error: "${item.name}" has an unsupported resource class "${item.class}" and cannot be downloaded.`,
|
|
145306
|
-
|
|
145314
|
+
skill.id
|
|
145307
145315
|
);
|
|
145308
145316
|
}
|
|
145309
|
-
if (!
|
|
145310
|
-
|
|
145317
|
+
if (!deps.fileService) {
|
|
145318
|
+
deps.logger.error(
|
|
145319
|
+
{ skillId: skill.id, assetId: item.id },
|
|
145320
|
+
"FileService not injected \u2014 cannot download assets"
|
|
145321
|
+
);
|
|
145322
|
+
throw new DownloadAssetError(
|
|
145311
145323
|
"Error: File service is not available. Cannot download assets in this runtime configuration.",
|
|
145312
|
-
|
|
145324
|
+
skill.id
|
|
145325
|
+
);
|
|
145326
|
+
}
|
|
145327
|
+
if (!deps.skillContentService) {
|
|
145328
|
+
deps.logger.error(
|
|
145329
|
+
{ skillId: skill.id, assetId: item.id },
|
|
145330
|
+
"SkillContentService not injected \u2014 cannot download assets"
|
|
145331
|
+
);
|
|
145332
|
+
throw new DownloadAssetError(
|
|
145333
|
+
"Error: Content service is not available. Cannot download assets in this runtime configuration.",
|
|
145334
|
+
skill.id
|
|
145313
145335
|
);
|
|
145314
145336
|
}
|
|
145337
|
+
if (!deps.userKey) {
|
|
145338
|
+
deps.logger.error(
|
|
145339
|
+
{ skillId: skill.id, assetId: item.id },
|
|
145340
|
+
"userKey missing \u2014 cannot authenticate asset download"
|
|
145341
|
+
);
|
|
145342
|
+
throw new DownloadAssetError(
|
|
145343
|
+
"Error: Authentication is not available. Cannot download assets without a valid user key.",
|
|
145344
|
+
skill.id
|
|
145345
|
+
);
|
|
145346
|
+
}
|
|
145347
|
+
let rawContent;
|
|
145315
145348
|
try {
|
|
145316
|
-
|
|
145317
|
-
|
|
145318
|
-
|
|
145319
|
-
|
|
145320
|
-
|
|
145321
|
-
|
|
145322
|
-
|
|
145323
|
-
|
|
145324
|
-
|
|
145325
|
-
|
|
145326
|
-
|
|
145327
|
-
|
|
145328
|
-
|
|
145329
|
-
|
|
145330
|
-
|
|
145331
|
-
|
|
145332
|
-
|
|
145333
|
-
|
|
145334
|
-
|
|
145335
|
-
|
|
145336
|
-
|
|
145337
|
-
|
|
145338
|
-
|
|
145339
|
-
|
|
145340
|
-
|
|
145341
|
-
|
|
145342
|
-
|
|
145349
|
+
rawContent = await deps.skillContentService.getContent(item.id, deps.userKey);
|
|
145350
|
+
} catch (error48) {
|
|
145351
|
+
deps.logger.error({ err: error48, assetName: item.name, assetId: item.id }, "Failed to download skill asset");
|
|
145352
|
+
throw new DownloadAssetError(
|
|
145353
|
+
`Error: Failed to download asset "${item.name}". Please try again. If the issue persists, verify that the Skilder backend is running and your authentication is valid.`,
|
|
145354
|
+
skill.id
|
|
145355
|
+
);
|
|
145356
|
+
}
|
|
145357
|
+
if (rawContent == null) {
|
|
145358
|
+
deps.logger.error(
|
|
145359
|
+
{ assetName: item.name, assetId: item.id },
|
|
145360
|
+
"skillContentService.getContent returned null/undefined"
|
|
145361
|
+
);
|
|
145362
|
+
throw new DownloadAssetError(
|
|
145363
|
+
`Error: No content found for asset "${item.name}". The resource may be unavailable.`,
|
|
145364
|
+
skill.id
|
|
145365
|
+
);
|
|
145366
|
+
}
|
|
145367
|
+
const buffer = Buffer.from(rawContent, "base64");
|
|
145368
|
+
const assetPath = generateSkilderAssetPath(item.id, item.name);
|
|
145369
|
+
try {
|
|
145370
|
+
await deps.fileService.cacheAsset(assetPath, buffer);
|
|
145371
|
+
} catch (writeError) {
|
|
145372
|
+
deps.logger.error(
|
|
145373
|
+
{ err: writeError, assetName: item.name, assetId: item.id },
|
|
145374
|
+
"Failed to write downloaded asset to disk"
|
|
145375
|
+
);
|
|
145376
|
+
if (writeError instanceof AssetTooLargeError) {
|
|
145377
|
+
const maxMB = Math.floor(writeError.maxBytes / (1024 * 1024));
|
|
145378
|
+
throw new DownloadAssetError(
|
|
145379
|
+
`Error: Asset "${item.name}" is too large to download (${writeError.bufferBytes} bytes exceeds the ${maxMB}MB limit). Consider requesting a smaller version or processing the data differently.`,
|
|
145380
|
+
skill.id
|
|
145343
145381
|
);
|
|
145344
145382
|
}
|
|
145383
|
+
throw new DownloadAssetError(
|
|
145384
|
+
`Error: Failed to write asset "${item.name}" to disk. Please try again.`,
|
|
145385
|
+
skill.id
|
|
145386
|
+
);
|
|
145387
|
+
}
|
|
145388
|
+
const itemMimetype = item.mimetype;
|
|
145389
|
+
if (!itemMimetype) {
|
|
145390
|
+
deps.logger.warn(
|
|
145391
|
+
{ skillId: skill.id, assetId: item.id, assetName: item.name },
|
|
145392
|
+
"Downloadable item missing mimetype in catalog"
|
|
145393
|
+
);
|
|
145394
|
+
}
|
|
145395
|
+
return {
|
|
145396
|
+
assetPath,
|
|
145397
|
+
itemName: item.name,
|
|
145398
|
+
mimetype: itemMimetype ?? "unknown",
|
|
145399
|
+
skillId: skill.id
|
|
145400
|
+
};
|
|
145401
|
+
}
|
|
145402
|
+
async function handleDownloadAsset(args, ctx) {
|
|
145403
|
+
const path4 = args.path;
|
|
145404
|
+
if (!path4) {
|
|
145405
|
+
return errorResult(
|
|
145406
|
+
`Error: path is required.
|
|
145407
|
+
|
|
145408
|
+
Usage: download_asset --path "/Skill Name/filename.ext"
|
|
145409
|
+
|
|
145410
|
+
Examples:
|
|
145411
|
+
- \`download_asset --path "/Data Processing/template.xlsx"\`
|
|
145412
|
+
- \`download_asset --path "/Reports/logo.png"\``
|
|
145413
|
+
);
|
|
145414
|
+
}
|
|
145415
|
+
try {
|
|
145416
|
+
const { assetPath, itemName, mimetype, skillId } = await downloadSkillAsset(path4, {
|
|
145417
|
+
catalog: ctx.catalog,
|
|
145418
|
+
fileService: ctx.fileService,
|
|
145419
|
+
skillContentService: ctx.skillContentService,
|
|
145420
|
+
userKey: ctx.identity.userKey,
|
|
145421
|
+
logger: ctx.logger
|
|
145422
|
+
});
|
|
145345
145423
|
return {
|
|
145346
145424
|
response: {
|
|
145347
145425
|
content: [
|
|
145348
145426
|
{
|
|
145349
145427
|
type: "text",
|
|
145350
|
-
text: `Successfully downloaded "${
|
|
145428
|
+
text: `Successfully downloaded "${itemName}" (${mimetype}).
|
|
145351
145429
|
|
|
145352
145430
|
**Local path:** \`${assetPath}\`
|
|
145353
145431
|
|
|
@@ -145355,15 +145433,13 @@ This file can be used with other file I/O tools that accept \`@skilder-asset:/\`
|
|
|
145355
145433
|
}
|
|
145356
145434
|
]
|
|
145357
145435
|
},
|
|
145358
|
-
skillIds: [
|
|
145436
|
+
skillIds: [skillId]
|
|
145359
145437
|
};
|
|
145360
145438
|
} catch (error48) {
|
|
145361
|
-
|
|
145362
|
-
|
|
145363
|
-
|
|
145364
|
-
|
|
145365
|
-
[skill.id]
|
|
145366
|
-
);
|
|
145439
|
+
if (error48 instanceof DownloadAssetError) {
|
|
145440
|
+
return errorResult(error48.userMessage, error48.skillId ? [error48.skillId] : void 0);
|
|
145441
|
+
}
|
|
145442
|
+
throw error48;
|
|
145367
145443
|
}
|
|
145368
145444
|
}
|
|
145369
145445
|
|
|
@@ -149775,26 +149851,28 @@ var ScriptExecutorService = class ScriptExecutorService2 {
|
|
|
149775
149851
|
}
|
|
149776
149852
|
});
|
|
149777
149853
|
let currentTimeout = timeout2;
|
|
149854
|
+
let lastExtendingMethod;
|
|
149778
149855
|
let timeoutId = setTimeout(() => {
|
|
149779
149856
|
killed = true;
|
|
149780
149857
|
child.kill("SIGKILL");
|
|
149781
|
-
this.logger.warn({ timeout: currentTimeout }, "Interactive script timed out");
|
|
149858
|
+
this.logger.warn({ timeout: currentTimeout, method: lastExtendingMethod }, "Interactive script timed out");
|
|
149782
149859
|
}, currentTimeout);
|
|
149783
|
-
const resetTimeout = (extraMs) => {
|
|
149860
|
+
const resetTimeout = (extraMs, method) => {
|
|
149784
149861
|
clearTimeout(timeoutId);
|
|
149785
149862
|
const elapsed = Date.now() - totalStartTime;
|
|
149786
149863
|
const remaining = Math.min(extraMs, MAX_INTERACTIVE_SCRIPT_TIMEOUT_MS - elapsed);
|
|
149787
149864
|
if (remaining <= 0) {
|
|
149788
149865
|
killed = true;
|
|
149789
149866
|
child.kill("SIGKILL");
|
|
149790
|
-
this.logger.warn("Interactive script exceeded max total timeout");
|
|
149867
|
+
this.logger.warn({ method }, "Interactive script exceeded max total timeout");
|
|
149791
149868
|
return;
|
|
149792
149869
|
}
|
|
149870
|
+
lastExtendingMethod = method;
|
|
149793
149871
|
currentTimeout = remaining;
|
|
149794
149872
|
timeoutId = setTimeout(() => {
|
|
149795
149873
|
killed = true;
|
|
149796
149874
|
child.kill("SIGKILL");
|
|
149797
|
-
this.logger.warn({ timeout: currentTimeout }, "Interactive script timed out");
|
|
149875
|
+
this.logger.warn({ timeout: currentTimeout, method: lastExtendingMethod }, "Interactive script timed out");
|
|
149798
149876
|
}, currentTimeout);
|
|
149799
149877
|
};
|
|
149800
149878
|
const safeWrite = (data) => {
|
|
@@ -149842,9 +149920,9 @@ var ScriptExecutorService = class ScriptExecutorService2 {
|
|
|
149842
149920
|
(async () => {
|
|
149843
149921
|
try {
|
|
149844
149922
|
if (msg.method === "delegate") {
|
|
149845
|
-
resetTimeout(DELEGATE_GENERATE_TEXT_TIMEOUT_MS + timeout2);
|
|
149846
|
-
} else if (msg.method === "tools/call") {
|
|
149847
|
-
resetTimeout(toolCallTimeout + timeout2);
|
|
149923
|
+
resetTimeout(DELEGATE_GENERATE_TEXT_TIMEOUT_MS + timeout2, msg.method);
|
|
149924
|
+
} else if (msg.method === "tools/call" || msg.method === "assets/download") {
|
|
149925
|
+
resetTimeout(toolCallTimeout + timeout2, msg.method);
|
|
149848
149926
|
}
|
|
149849
149927
|
const result = await onRequest(msg.method, msg.params);
|
|
149850
149928
|
writeResponse(msg.id, result);
|
|
@@ -153091,6 +153169,7 @@ var _k;
|
|
|
153091
153169
|
var _o;
|
|
153092
153170
|
var _p;
|
|
153093
153171
|
var _q;
|
|
153172
|
+
var _r;
|
|
153094
153173
|
var GET_SKILL_RELATED_QUERY = `
|
|
153095
153174
|
query GetSkillRelated($id: ID!) {
|
|
153096
153175
|
skillRelated(id: $id) {
|
|
@@ -153131,7 +153210,7 @@ function formatScriptError(stderr, exitCode) {
|
|
|
153131
153210
|
return result;
|
|
153132
153211
|
}
|
|
153133
153212
|
var ToolService = class ToolService2 extends Service {
|
|
153134
|
-
constructor(loggerService, natsService, cacheService, authService, healthService, toolServerServiceFactory, oauthTokenService, oauthClientInfoService, mcpStdioService, fileService, runtimeExecutionId, scriptExecutorService, delegateService, scriptService, runtimeCatalogService, dynamicToolRouter, runtimeBusService) {
|
|
153213
|
+
constructor(loggerService, natsService, cacheService, authService, healthService, toolServerServiceFactory, oauthTokenService, oauthClientInfoService, mcpStdioService, fileService, runtimeExecutionId, scriptExecutorService, delegateService, scriptService, skillContentService, runtimeCatalogService, dynamicToolRouter, runtimeBusService) {
|
|
153135
153214
|
super();
|
|
153136
153215
|
this.loggerService = loggerService;
|
|
153137
153216
|
this.natsService = natsService;
|
|
@@ -153146,6 +153225,7 @@ var ToolService = class ToolService2 extends Service {
|
|
|
153146
153225
|
this.scriptExecutorService = scriptExecutorService;
|
|
153147
153226
|
this.delegateService = delegateService;
|
|
153148
153227
|
this.scriptService = scriptService;
|
|
153228
|
+
this.skillContentService = skillContentService;
|
|
153149
153229
|
this.runtimeCatalogService = runtimeCatalogService;
|
|
153150
153230
|
this.dynamicToolRouter = dynamicToolRouter;
|
|
153151
153231
|
this.runtimeBusService = runtimeBusService;
|
|
@@ -154088,10 +154168,52 @@ ${cleanError}` : cleanError;
|
|
|
154088
154168
|
const combinedPath = Array.isArray(scriptArgs) && scriptArgs.length > 0 ? `${path4} ${scriptArgs.join(" ")}` : path4;
|
|
154089
154169
|
return this.handleScriptExecuteFromSdk(combinedPath, workspaceId, userId, userKey, runtimeId, delegateDepth);
|
|
154090
154170
|
}
|
|
154171
|
+
case "assets/download": {
|
|
154172
|
+
if (!params || typeof params !== "object" || typeof params.path !== "string") {
|
|
154173
|
+
throw new Error("Invalid assets/download params: expected { path: string }");
|
|
154174
|
+
}
|
|
154175
|
+
const { path: path4 } = params;
|
|
154176
|
+
return this.handleScriptDownloadAsset(path4, workspaceId, userKey);
|
|
154177
|
+
}
|
|
154091
154178
|
default:
|
|
154092
154179
|
throw new Error(`Unknown script IPC method: ${method}`);
|
|
154093
154180
|
}
|
|
154094
154181
|
}
|
|
154182
|
+
/**
|
|
154183
|
+
* Handle an asset download request from a TypeScript script via JSON-RPC IPC.
|
|
154184
|
+
* Resolves the skill path, fetches and caches the asset, and returns its
|
|
154185
|
+
* `@skilder-asset:/` URI. Errors propagate as JSON-RPC errors so the SDK
|
|
154186
|
+
* surfaces them as rejected promises.
|
|
154187
|
+
*/
|
|
154188
|
+
async handleScriptDownloadAsset(path4, workspaceId, userKey) {
|
|
154189
|
+
let catalog = null;
|
|
154190
|
+
if (!this.runtimeCatalogService) {
|
|
154191
|
+
this.logger.error({ workspaceId, event: "runtime_catalog_service_unavailable" }, "RuntimeCatalogService not injected \u2014 script asset downloads cannot resolve skills");
|
|
154192
|
+
} else {
|
|
154193
|
+
catalog = this.runtimeCatalogService.getCatalog(workspaceId) ?? null;
|
|
154194
|
+
if (!catalog) {
|
|
154195
|
+
this.logger.warn({ workspaceId, event: "runtime_catalog_not_loaded" }, "No catalog loaded for workspace \u2014 script asset download will fail to resolve skill");
|
|
154196
|
+
}
|
|
154197
|
+
}
|
|
154198
|
+
try {
|
|
154199
|
+
const result = await downloadSkillAsset(path4, {
|
|
154200
|
+
catalog,
|
|
154201
|
+
fileService: this.fileService,
|
|
154202
|
+
skillContentService: this.skillContentService,
|
|
154203
|
+
userKey,
|
|
154204
|
+
logger: this.logger
|
|
154205
|
+
});
|
|
154206
|
+
return { assetPath: result.assetPath };
|
|
154207
|
+
} catch (error48) {
|
|
154208
|
+
if (error48 instanceof DownloadAssetError) {
|
|
154209
|
+
this.logger.warn({ skillId: error48.skillId, path: path4, event: "script_download_asset_failed" }, "Script asset download failed");
|
|
154210
|
+
const wrapped = new Error(error48.userMessage);
|
|
154211
|
+
wrapped.cause = error48;
|
|
154212
|
+
throw wrapped;
|
|
154213
|
+
}
|
|
154214
|
+
throw error48;
|
|
154215
|
+
}
|
|
154216
|
+
}
|
|
154095
154217
|
/**
|
|
154096
154218
|
* Handle a script execute request from a TypeScript script via JSON-RPC IPC.
|
|
154097
154219
|
* Resolves the path and routes execution using ScriptService.
|
|
@@ -154351,13 +154473,15 @@ ToolService = __decorate25([
|
|
|
154351
154473
|
__param21(12, se()),
|
|
154352
154474
|
__param21(13, U(ScriptService)),
|
|
154353
154475
|
__param21(13, se()),
|
|
154354
|
-
__param21(14, U(
|
|
154476
|
+
__param21(14, U(SkillContentService)),
|
|
154355
154477
|
__param21(14, se()),
|
|
154356
|
-
__param21(15, U(
|
|
154478
|
+
__param21(15, U(RuntimeCatalogService)),
|
|
154357
154479
|
__param21(15, se()),
|
|
154358
|
-
__param21(16, U(
|
|
154480
|
+
__param21(16, U(DynamicToolRouter)),
|
|
154359
154481
|
__param21(16, se()),
|
|
154360
|
-
|
|
154482
|
+
__param21(17, U(RuntimeBusService)),
|
|
154483
|
+
__param21(17, se()),
|
|
154484
|
+
__metadata24("design:paramtypes", [typeof (_a49 = typeof LoggerService !== "undefined" && LoggerService) === "function" ? _a49 : Object, typeof (_b37 = typeof NatsService !== "undefined" && NatsService) === "function" ? _b37 : Object, typeof (_c9 = typeof NatsCacheService !== "undefined" && NatsCacheService) === "function" ? _c9 : Object, typeof (_d6 = typeof AuthService !== "undefined" && AuthService) === "function" ? _d6 : Object, typeof (_e6 = typeof HealthService !== "undefined" && HealthService) === "function" ? _e6 : Object, Object, typeof (_f2 = typeof OAuthTokenService !== "undefined" && OAuthTokenService) === "function" ? _f2 : Object, typeof (_g5 = typeof OAuthClientInfoService !== "undefined" && OAuthClientInfoService) === "function" ? _g5 : Object, Object, typeof (_j = typeof FileService !== "undefined" && FileService) === "function" ? _j : Object, String, typeof (_k = typeof ScriptExecutorService !== "undefined" && ScriptExecutorService) === "function" ? _k : Object, Object, Object, typeof (_o = typeof SkillContentService !== "undefined" && SkillContentService) === "function" ? _o : Object, typeof (_p = typeof RuntimeCatalogService !== "undefined" && RuntimeCatalogService) === "function" ? _p : Object, typeof (_q = typeof DynamicToolRouter !== "undefined" && DynamicToolRouter) === "function" ? _q : Object, typeof (_r = typeof RuntimeBusService !== "undefined" && RuntimeBusService) === "function" ? _r : Object])
|
|
154361
154485
|
], ToolService);
|
|
154362
154486
|
|
|
154363
154487
|
// src/services/runtime.main.service.ts
|