@skilder-ai/runtime 0.4.6 → 0.4.8

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
@@ -114749,6 +114749,7 @@ var SkillService = class SkillService2 extends Service {
114749
114749
  this.name = "skill";
114750
114750
  this.tools = new import_rxjs.BehaviorSubject(null);
114751
114751
  this.cacheSubscriptions = [];
114752
+ this.composition = null;
114752
114753
  this.toolMapping = /* @__PURE__ */ new Map();
114753
114754
  this.logger = this.loggerService.getLogger(`${this.name}`);
114754
114755
  }
@@ -114781,6 +114782,7 @@ var SkillService = class SkillService2 extends Service {
114781
114782
  if (message instanceof UserListToolsPublish) {
114782
114783
  const smartSkillTools = message.data.smartSkillTools?.map((tool2) => this.parseSmartSkillTool(tool2)) ?? [];
114783
114784
  const mcpTools = message.data.mcpTools.map((tool2) => this.parseMcpTool(tool2));
114785
+ this.composition = message.data.composition ?? null;
114784
114786
  this.tools.next([this.prepareInitTool(), ...smartSkillTools, ...mcpTools]);
114785
114787
  this.logger.debug(`Received ${smartSkillTools.length} smart skill tools and ${mcpTools.length} mcp tools for user ${this.identity.id}`);
114786
114788
  } else if (message instanceof ErrorResponse) {
@@ -114858,12 +114860,13 @@ var SkillService = class SkillService2 extends Service {
114858
114860
  throw new Error(`Tool ${name16} not found`);
114859
114861
  }
114860
114862
  if (toolConfig._meta.type === "init") {
114861
- this.logger.debug(`Handling init_skill call for skill ${this.identity.id}`);
114863
+ this.logger.debug(`Handling init_skill call for user ${this.identity.id}`);
114864
+ const responseText = this.buildInitResponse(args.original_prompt);
114862
114865
  return {
114863
114866
  content: [
114864
114867
  {
114865
114868
  type: "text",
114866
- text: "This is the initial message from the skill"
114869
+ text: responseText
114867
114870
  }
114868
114871
  ]
114869
114872
  };
@@ -114901,6 +114904,86 @@ var SkillService = class SkillService2 extends Service {
114901
114904
  getIdentity() {
114902
114905
  return this.identity;
114903
114906
  }
114907
+ /**
114908
+ * Build the init_skill response with hierarchical hat/skill/tool information
114909
+ */
114910
+ buildInitResponse(originalPrompt) {
114911
+ const composition = this.composition;
114912
+ if (!composition || composition.hats.length === 0 && composition.skills.length === 0) {
114913
+ const lines2 = ["# Session Context", "", "No skills or hats are configured for this session."];
114914
+ if (originalPrompt) {
114915
+ lines2.push("", "---", "", "## User Request", originalPrompt);
114916
+ }
114917
+ return lines2.join("\n");
114918
+ }
114919
+ const lines = [];
114920
+ lines.push("# Session Context");
114921
+ lines.push("");
114922
+ lines.push("Below are the skills and hats available to you in this session.");
114923
+ lines.push("");
114924
+ if (composition.hats.length > 0) {
114925
+ lines.push("## Hats");
114926
+ lines.push("");
114927
+ for (const hat of composition.hats) {
114928
+ lines.push(`### ${hat.name}`);
114929
+ if (hat.description) {
114930
+ lines.push(hat.description);
114931
+ }
114932
+ if (hat.instructions) {
114933
+ lines.push("");
114934
+ lines.push("**Instructions:**");
114935
+ lines.push(hat.instructions);
114936
+ }
114937
+ lines.push("");
114938
+ lines.push("**Skills in this hat:**");
114939
+ for (const skillId of hat.skillIds) {
114940
+ const skill = composition.skills.find((s) => s.id === skillId);
114941
+ if (skill) {
114942
+ lines.push(`- **${skill.name}**${skill.description ? `: ${skill.description}` : ""}`);
114943
+ if (skill.instructions) {
114944
+ lines.push(` - Instructions: ${skill.instructions}`);
114945
+ }
114946
+ if (skill.toolNames.length > 0) {
114947
+ lines.push(` - Tools: ${skill.toolNames.join(", ")}`);
114948
+ }
114949
+ }
114950
+ }
114951
+ lines.push("");
114952
+ }
114953
+ }
114954
+ if (composition.orphanSkillIds.length > 0) {
114955
+ lines.push("## Additional Skills");
114956
+ lines.push("");
114957
+ lines.push("The following skills are available but not assigned to any hat:");
114958
+ lines.push("");
114959
+ for (const skillId of composition.orphanSkillIds) {
114960
+ const skill = composition.skills.find((s) => s.id === skillId);
114961
+ if (skill) {
114962
+ lines.push(`### ${skill.name}`);
114963
+ if (skill.description) {
114964
+ lines.push(skill.description);
114965
+ }
114966
+ if (skill.instructions) {
114967
+ lines.push("");
114968
+ lines.push("**Instructions:**");
114969
+ lines.push(skill.instructions);
114970
+ }
114971
+ if (skill.toolNames.length > 0) {
114972
+ lines.push("");
114973
+ lines.push(`**Tools:** ${skill.toolNames.join(", ")}`);
114974
+ }
114975
+ lines.push("");
114976
+ }
114977
+ }
114978
+ }
114979
+ if (originalPrompt) {
114980
+ lines.push("---");
114981
+ lines.push("");
114982
+ lines.push("## User Request");
114983
+ lines.push(originalPrompt);
114984
+ }
114985
+ return lines.join("\n");
114986
+ }
114904
114987
  };
114905
114988
  SkillService = __decorate8([
114906
114989
  W(),