@skilder-ai/runtime 0.9.13 → 0.9.15

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 CHANGED
@@ -138958,6 +138958,32 @@ var WorkspaceRole = /* @__PURE__ */ ((WorkspaceRole2) => {
138958
138958
  return WorkspaceRole2;
138959
138959
  })(WorkspaceRole || {});
138960
138960
 
138961
+ // ../common/src/types/skill-catalog.ts
138962
+ function resolveEffectiveSkill(entry, userId) {
138963
+ const draft = entry.draft;
138964
+ if (!draft || !userId || draft.authorId !== userId) return entry;
138965
+ return {
138966
+ id: entry.id,
138967
+ name: draft.name,
138968
+ description: draft.description,
138969
+ instructions: draft.instructions,
138970
+ toolNames: draft.toolNames,
138971
+ related: draft.related
138972
+ };
138973
+ }
138974
+ function resolveEffectiveHat(entry, userId) {
138975
+ const draft = entry.draft;
138976
+ if (!draft || !userId || draft.authorId !== userId) return entry;
138977
+ return {
138978
+ id: entry.id,
138979
+ name: draft.name,
138980
+ description: draft.description,
138981
+ instructions: draft.instructions,
138982
+ color: draft.color,
138983
+ skillIds: draft.skillIds
138984
+ };
138985
+ }
138986
+
138961
138987
  // ../common/src/utils/parse-script-args.ts
138962
138988
  function parseScriptArgs(argsString) {
138963
138989
  const args = [];
@@ -144263,11 +144289,15 @@ var FileService = class FileService2 extends LifecycleService {
144263
144289
  this.logger.info("File service stopped");
144264
144290
  }
144265
144291
  getEnvVars() {
144266
- return {
144292
+ const env = {
144267
144293
  SKILDER_WORKING_DIR: this.workingDir,
144268
144294
  SKILDER_ALLOWED_PATHS: this.allowedPaths.join(":"),
144269
144295
  SKILDER_MAX_FILE_SIZE_MB: String(this.maxFileSizeMB)
144270
144296
  };
144297
+ if (process.env.SKILDER_BACKEND_URL) {
144298
+ env.SKILDER_BACKEND_URL = process.env.SKILDER_BACKEND_URL;
144299
+ }
144300
+ return env;
144271
144301
  }
144272
144302
  /**
144273
144303
  * Resolve a relative path under the working dir for transient files written
@@ -145257,55 +145287,6 @@ SkillContentService = __decorate12([
145257
145287
  __metadata12("design:paramtypes", [typeof (_a35 = typeof LoggerService !== "undefined" && LoggerService) === "function" ? _a35 : Object])
145258
145288
  ], SkillContentService);
145259
145289
 
145260
- // src/services/static-tools/init-skilder.handler.ts
145261
- function buildInitSkilderResponse(ctx) {
145262
- const catalog = ctx.catalog;
145263
- if (!catalog || catalog.hats.length === 0) {
145264
- return [
145265
- "# Welcome to Skilder",
145266
- "",
145267
- "No hats are configured for this session.",
145268
- "",
145269
- "Skilder provides specialized skills and tools to help you accomplish tasks."
145270
- ].join("\n");
145271
- }
145272
- const lines = [];
145273
- lines.push("# Welcome to Skilder");
145274
- lines.push("");
145275
- lines.push("Skilder provides specialized skills and resources. Hats are the entry point \u2014 learn a hat first, then learn individual skills to unlock their tools.");
145276
- lines.push("");
145277
- lines.push("## Available Hats");
145278
- lines.push("");
145279
- lines.push("You MUST learn a hat before doing anything else. Hats are the only entry point.");
145280
- lines.push("");
145281
- for (const hat of catalog.hats) {
145282
- lines.push(`### ${hat.name}`);
145283
- if (hat.description) {
145284
- lines.push(hat.description);
145285
- }
145286
- lines.push("");
145287
- lines.push(`**Learn this hat:** \`learn --path "/hats/${hat.name}"\``);
145288
- lines.push("");
145289
- }
145290
- return lines.join("\n");
145291
- }
145292
- async function handleInitSkilder(_args, ctx) {
145293
- if (!ctx.catalog) {
145294
- ctx.logger.warn(
145295
- { userId: ctx.identity.id },
145296
- "init_skilder called with null catalog \u2014 catalog may not have loaded yet"
145297
- );
145298
- } else if (ctx.catalog.hats.length === 0) {
145299
- ctx.logger.warn(
145300
- { userId: ctx.identity.id, skillCount: ctx.catalog.skills.length },
145301
- "init_skilder called with no hats in catalog"
145302
- );
145303
- }
145304
- return {
145305
- response: { content: [{ type: "text", text: buildInitSkilderResponse(ctx) }] }
145306
- };
145307
- }
145308
-
145309
145290
  // src/services/static-tools/types.ts
145310
145291
  function errorResult(text2, skillIds) {
145311
145292
  return {
@@ -145315,6 +145296,15 @@ function errorResult(text2, skillIds) {
145315
145296
  }
145316
145297
 
145317
145298
  // src/services/static-tools/learn.handler.ts
145299
+ function effectiveSkills(ctx) {
145300
+ return (ctx.catalog?.skills ?? []).map((s) => resolveEffectiveSkill(s, ctx.identity.id));
145301
+ }
145302
+ function effectiveHats(ctx) {
145303
+ return (ctx.catalog?.hats ?? []).map((h2) => resolveEffectiveHat(h2, ctx.identity.id));
145304
+ }
145305
+ function wearableHats(ctx) {
145306
+ return effectiveHats(ctx).filter((h2) => h2.skillIds.length > 0);
145307
+ }
145318
145308
  function appendReferencedResources(lines, mentions, related, skillName) {
145319
145309
  if (mentions.length === 0) return;
145320
145310
  lines.push("## Resources");
@@ -145393,13 +145383,14 @@ function formatSkillDetails(skill, ctx) {
145393
145383
  return lines;
145394
145384
  }
145395
145385
  function handleLearnSkill(skillName, ctx) {
145386
+ const skills = effectiveSkills(ctx);
145396
145387
  if (!skillName) {
145397
- const availableSkills = ctx.catalog?.skills.map((s) => s.name).join(", ") || "none";
145388
+ const availableSkills = skills.map((s) => s.name).join(", ") || "none";
145398
145389
  return errorResult(`Error: skill_name is required. Available skills: ${availableSkills}`);
145399
145390
  }
145400
- const skill = ctx.catalog?.skills.find((s) => s.name === skillName);
145391
+ const skill = skills.find((s) => s.name === skillName);
145401
145392
  if (!skill) {
145402
- const availableSkills = ctx.catalog?.skills.map((s) => s.name).join(", ") || "none";
145393
+ const availableSkills = skills.map((s) => s.name).join(", ") || "none";
145403
145394
  return errorResult(`Error: Skill "${skillName}" not found. Available skills: ${availableSkills}`);
145404
145395
  }
145405
145396
  const lines = [];
@@ -145415,13 +145406,16 @@ function handleGetHat(hatName, ctx) {
145415
145406
  if (!ctx.catalog) {
145416
145407
  return errorResult("Error: Skill catalog not yet loaded. Please try again.");
145417
145408
  }
145409
+ const hats = effectiveHats(ctx);
145418
145410
  if (!hatName) {
145419
- const availableHats = ctx.catalog.hats.map((h2) => h2.name).join(", ") || "none";
145411
+ const availableHats = wearableHats(ctx).map((h2) => h2.name).join(", ") || "none";
145420
145412
  return errorResult(`Error: hat_name is required. Available hats: ${availableHats}`);
145421
145413
  }
145422
- const hat = ctx.catalog.hats.find((h2) => h2.name === hatName);
145414
+ const hat = hats.find((h2) => h2.name === hatName);
145423
145415
  if (!hat) {
145424
- const hidden = ctx.catalog.hiddenHats?.find((h2) => h2.name === hatName);
145416
+ const hidden = ctx.catalog.hiddenHats?.find(
145417
+ (h2) => h2.name === hatName || h2.draftAuthorId != null && h2.draftAuthorId === ctx.identity.id && h2.draftName === hatName
145418
+ );
145425
145419
  if (hidden?.reason === "no-skills") {
145426
145420
  return errorResult(
145427
145421
  `The hat "${hatName}" exists but has no skills yet, so it can't be worn. Add at least one skill to it (add-skill-to-hat), then learn it. Do not create it again.`
@@ -145432,13 +145426,19 @@ function handleGetHat(hatName, ctx) {
145432
145426
  `The hat "${hatName}" exists but is disabled, so it can't be worn. Enable it first, then learn it. Do not create it again.`
145433
145427
  );
145434
145428
  }
145435
- const availableHats = ctx.catalog.hats.map((h2) => h2.name).join(", ") || "none";
145429
+ const availableHats = wearableHats(ctx).map((h2) => h2.name).join(", ") || "none";
145436
145430
  return errorResult(`Error: Hat "${hatName}" not found. Available hats: ${availableHats}`);
145437
145431
  }
145432
+ if (hat.skillIds.length === 0) {
145433
+ return errorResult(
145434
+ `The hat "${hatName}" exists but has no skills yet, so it can't be worn. Add at least one skill to it (add-skill-to-hat), then learn it. Do not create it again.`
145435
+ );
145436
+ }
145437
+ const effectiveSkillList = effectiveSkills(ctx);
145438
145438
  const skills = [];
145439
145439
  const missingSkillIds = [];
145440
145440
  for (const skillId of hat.skillIds) {
145441
- const skill = ctx.catalog.skills.find((s) => s.id === skillId);
145441
+ const skill = effectiveSkillList.find((s) => s.id === skillId);
145442
145442
  if (skill) {
145443
145443
  skills.push(skill);
145444
145444
  } else {
@@ -145491,9 +145491,10 @@ function handleGetHat(hatName, ctx) {
145491
145491
  };
145492
145492
  }
145493
145493
  async function handleGetRelated(skillName, resourceName, ctx) {
145494
- const skill = ctx.catalog?.skills.find((s) => s.name === skillName);
145494
+ const skills = effectiveSkills(ctx);
145495
+ const skill = skills.find((s) => s.name === skillName);
145495
145496
  if (!skill) {
145496
- const availableSkills = ctx.catalog?.skills.map((s) => s.name).join(", ") || "none";
145497
+ const availableSkills = skills.map((s) => s.name).join(", ") || "none";
145497
145498
  return errorResult(`Error: Skill "${skillName}" not found. Available skills: ${availableSkills}`);
145498
145499
  }
145499
145500
  const item = skill.related.find((r2) => {
@@ -145600,6 +145601,56 @@ Usage examples:
145600
145601
  }
145601
145602
  }
145602
145603
 
145604
+ // src/services/static-tools/init-skilder.handler.ts
145605
+ function buildInitSkilderResponse(ctx) {
145606
+ const catalog = ctx.catalog;
145607
+ const wearable = wearableHats(ctx);
145608
+ if (!catalog || wearable.length === 0) {
145609
+ return [
145610
+ "# Welcome to Skilder",
145611
+ "",
145612
+ "No hats are configured for this session.",
145613
+ "",
145614
+ "Skilder provides specialized skills and tools to help you accomplish tasks."
145615
+ ].join("\n");
145616
+ }
145617
+ const lines = [];
145618
+ lines.push("# Welcome to Skilder");
145619
+ lines.push("");
145620
+ lines.push("Skilder provides specialized skills and resources. Hats are the entry point \u2014 learn a hat first, then learn individual skills to unlock their tools.");
145621
+ lines.push("");
145622
+ lines.push("## Available Hats");
145623
+ lines.push("");
145624
+ lines.push("You MUST learn a hat before doing anything else. Hats are the only entry point.");
145625
+ lines.push("");
145626
+ for (const hat of wearable) {
145627
+ lines.push(`### ${hat.name}`);
145628
+ if (hat.description) {
145629
+ lines.push(hat.description);
145630
+ }
145631
+ lines.push("");
145632
+ lines.push(`**Learn this hat:** \`learn --path "/hats/${hat.name}"\``);
145633
+ lines.push("");
145634
+ }
145635
+ return lines.join("\n");
145636
+ }
145637
+ async function handleInitSkilder(_args, ctx) {
145638
+ if (!ctx.catalog) {
145639
+ ctx.logger.warn(
145640
+ { userId: ctx.identity.id },
145641
+ "init_skilder called with null catalog \u2014 catalog may not have loaded yet"
145642
+ );
145643
+ } else if (wearableHats(ctx).length === 0) {
145644
+ ctx.logger.warn(
145645
+ { userId: ctx.identity.id, skillCount: ctx.catalog.skills.length },
145646
+ "init_skilder called with no hats in catalog"
145647
+ );
145648
+ }
145649
+ return {
145650
+ response: { content: [{ type: "text", text: buildInitSkilderResponse(ctx) }] }
145651
+ };
145652
+ }
145653
+
145603
145654
  // src/services/static-tools/execute-script.handler.ts
145604
145655
  async function handleExecuteScript(args, ctx) {
145605
145656
  if (!ctx.scriptService) {
@@ -145827,9 +145878,10 @@ For learning skills, use the \`learn\` tool instead.
145827
145878
  For executing scripts, use the \`execute_script\` tool.`
145828
145879
  );
145829
145880
  }
145830
- const skill = deps.catalog?.skills.find((s) => s.name === parsedPath.skillName);
145881
+ const skills = (deps.catalog?.skills ?? []).map((s) => resolveEffectiveSkill(s, deps.userId));
145882
+ const skill = skills.find((s) => s.name === parsedPath.skillName);
145831
145883
  if (!skill) {
145832
- const availableSkills = deps.catalog?.skills.map((s) => s.name).join(", ") || "none";
145884
+ const availableSkills = skills.map((s) => s.name).join(", ") || "none";
145833
145885
  throw new DownloadAssetError(
145834
145886
  `Error: Skill "${parsedPath.skillName}" not found. Available skills: ${availableSkills}`
145835
145887
  );
@@ -146347,11 +146399,12 @@ var _e2;
146347
146399
  var _f;
146348
146400
  var _g;
146349
146401
  var _h;
146350
- function buildSkillToolMap(catalog) {
146402
+ function buildSkillToolMap(catalog, userId) {
146351
146403
  const map4 = /* @__PURE__ */ new Map();
146352
146404
  if (!catalog)
146353
146405
  return map4;
146354
- for (const skill of catalog.skills) {
146406
+ for (const entry of catalog.skills) {
146407
+ const skill = resolveEffectiveSkill(entry, userId);
146355
146408
  for (const toolName of skill.toolNames) {
146356
146409
  map4.set(toolName, skill.id);
146357
146410
  }
@@ -146852,7 +146905,7 @@ Examples:
146852
146905
  natsService: this.natsService,
146853
146906
  scriptService: this.scriptService,
146854
146907
  getTools: () => this.tools.getValue(),
146855
- skillToolMap: buildSkillToolMap(catalog),
146908
+ skillToolMap: buildSkillToolMap(catalog, this.identity.id),
146856
146909
  fileService: this.fileService,
146857
146910
  delegateService: this.delegateService,
146858
146911
  skillContentService: this.skillContentService,
@@ -155387,7 +155440,7 @@ ${result.stdout}
155387
155440
  throw new Error("Invalid assets/download params: expected { path: string }");
155388
155441
  }
155389
155442
  const { path: path6 } = params;
155390
- return this.handleScriptDownloadAsset(path6, workspaceId, userKey);
155443
+ return this.handleScriptDownloadAsset(path6, workspaceId, userId, userKey);
155391
155444
  }
155392
155445
  default:
155393
155446
  throw new Error(`Unknown script IPC method: ${method}`);
@@ -155399,7 +155452,7 @@ ${result.stdout}
155399
155452
  * `@skilder-asset:/` URI. Errors propagate as JSON-RPC errors so the SDK
155400
155453
  * surfaces them as rejected promises.
155401
155454
  */
155402
- async handleScriptDownloadAsset(path6, workspaceId, userKey) {
155455
+ async handleScriptDownloadAsset(path6, workspaceId, userId, userKey) {
155403
155456
  let catalog = null;
155404
155457
  if (!this.runtimeCatalogService) {
155405
155458
  this.logger.error({ workspaceId, event: "runtime_catalog_service_unavailable" }, "RuntimeCatalogService not injected \u2014 script asset downloads cannot resolve skills");
@@ -155414,6 +155467,7 @@ ${result.stdout}
155414
155467
  catalog,
155415
155468
  fileService: this.fileService,
155416
155469
  userKey,
155470
+ userId,
155417
155471
  logger: this.logger
155418
155472
  });
155419
155473
  return { assetPath: result.assetPath };