@dxos/assistant-toolkit 0.16.0 → 0.17.0

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.
Files changed (215) hide show
  1. package/dist/lib/chunk-AgentOperation.mjs +5 -1
  2. package/dist/lib/chunk-AgentOperation.mjs.map +1 -1
  3. package/dist/lib/chunk-AgentOperationHandlerSet.mjs +1 -1
  4. package/dist/lib/chunk-AgentSkill.mjs +1 -1
  5. package/dist/lib/chunk-AlarmSkill.mjs +1 -1
  6. package/dist/lib/chunk-BrowserSkill.mjs +4 -6
  7. package/dist/lib/chunk-BrowserSkill.mjs.map +1 -1
  8. package/dist/lib/chunk-ChatContextSkill.mjs +1 -1
  9. package/dist/lib/chunk-DelegationSkill.mjs +2 -2
  10. package/dist/lib/chunk-DelegationSkill.mjs.map +1 -1
  11. package/dist/lib/chunk-DelegationStrategy.mjs +16 -30
  12. package/dist/lib/chunk-DelegationStrategy.mjs.map +1 -1
  13. package/dist/lib/chunk-PlanningSkill.mjs +12 -10
  14. package/dist/lib/chunk-PlanningSkill.mjs.map +1 -1
  15. package/dist/lib/chunk-SkillManagerSkill.mjs +62 -7
  16. package/dist/lib/chunk-SkillManagerSkill.mjs.map +1 -1
  17. package/dist/lib/chunk-SlashCommand.mjs +2 -2
  18. package/dist/lib/chunk-SlashCommand.mjs.map +1 -1
  19. package/dist/lib/chunk-add-mcp-connection.mjs +58 -0
  20. package/dist/lib/chunk-add-mcp-connection.mjs.map +1 -0
  21. package/dist/lib/chunk-ask-question.mjs.map +1 -1
  22. package/dist/lib/chunk-catalog.mjs +86 -0
  23. package/dist/lib/chunk-catalog.mjs.map +1 -0
  24. package/dist/lib/chunk-context-add.mjs +1 -1
  25. package/dist/lib/chunk-context-remove.mjs +1 -1
  26. package/dist/lib/chunk-delegate-task.mjs +2 -2
  27. package/dist/lib/chunk-delegate-task.mjs.map +1 -1
  28. package/dist/lib/chunk-delegate-tasks.mjs +2 -8
  29. package/dist/lib/chunk-delegate-tasks.mjs.map +1 -1
  30. package/dist/lib/chunk-enable-skills.mjs +1 -1
  31. package/dist/lib/chunk-get-context.mjs +1 -1
  32. package/dist/lib/chunk-get-current-date.mjs +1 -1
  33. package/dist/lib/chunk-mcp-connections.mjs +26 -0
  34. package/dist/lib/chunk-mcp-connections.mjs.map +1 -0
  35. package/dist/lib/chunk-operations.mjs +2 -2
  36. package/dist/lib/chunk-operations.mjs.map +1 -1
  37. package/dist/lib/chunk-operations2.mjs +144 -9
  38. package/dist/lib/chunk-operations2.mjs.map +1 -1
  39. package/dist/lib/chunk-operations3.mjs +6 -5
  40. package/dist/lib/chunk-operations3.mjs.map +1 -1
  41. package/dist/lib/chunk-operations4.mjs +30 -55
  42. package/dist/lib/chunk-operations4.mjs.map +1 -1
  43. package/dist/lib/chunk-operations5.mjs +28 -27
  44. package/dist/lib/chunk-operations5.mjs.map +1 -1
  45. package/dist/lib/chunk-operations6.mjs +64 -29
  46. package/dist/lib/chunk-operations6.mjs.map +1 -1
  47. package/dist/lib/chunk-operations7.mjs +4 -79
  48. package/dist/lib/chunk-operations7.mjs.map +1 -1
  49. package/dist/lib/chunk-plan-reminder.mjs +7 -12
  50. package/dist/lib/chunk-plan-reminder.mjs.map +1 -1
  51. package/dist/lib/chunk-query-mcp-connections.mjs +16 -0
  52. package/dist/lib/chunk-query-mcp-connections.mjs.map +1 -0
  53. package/dist/lib/chunk-query-operations.mjs +23 -0
  54. package/dist/lib/chunk-query-operations.mjs.map +1 -0
  55. package/dist/lib/chunk-query-skills.mjs +23 -3
  56. package/dist/lib/chunk-query-skills.mjs.map +1 -1
  57. package/dist/lib/chunk-query-types.mjs +24 -0
  58. package/dist/lib/chunk-query-types.mjs.map +1 -0
  59. package/dist/lib/chunk-relay.mjs +1 -1
  60. package/dist/lib/chunk-run-instructions.mjs +14 -10
  61. package/dist/lib/chunk-run-instructions.mjs.map +1 -1
  62. package/dist/lib/chunk-set-alarm.mjs +1 -1
  63. package/dist/lib/chunk-set-mcp-connection.mjs +18 -0
  64. package/dist/lib/chunk-set-mcp-connection.mjs.map +1 -0
  65. package/dist/lib/chunk-sync-automation.mjs +1 -1
  66. package/dist/lib/chunk-update-tasks.mjs +20 -3
  67. package/dist/lib/chunk-update-tasks.mjs.map +1 -1
  68. package/dist/lib/index.mjs +1 -3
  69. package/dist/lib/ns/AgentOperationHandlerSet.mjs +1 -1
  70. package/dist/lib/ns/AgentSkill.mjs +1 -1
  71. package/dist/lib/ns/AlarmSkill.mjs +1 -1
  72. package/dist/lib/ns/ChatContextSkill.mjs +1 -1
  73. package/dist/lib/ns/PlanningSkill.mjs +2 -2
  74. package/dist/lib/ns/SkillManagerSkill.mjs +3 -3
  75. package/dist/lib/testing.mjs +7 -10
  76. package/dist/lib/testing.mjs.map +1 -1
  77. package/dist/types/src/commands.d.ts +10 -0
  78. package/dist/types/src/commands.d.ts.map +1 -1
  79. package/dist/types/src/operations/run-instructions.d.ts.map +1 -1
  80. package/dist/types/src/skills/browser/BrowserSkill.d.ts.map +1 -1
  81. package/dist/types/src/skills/delegation/operations/delegate-task.d.ts +1 -1
  82. package/dist/types/src/skills/delegation/operations/delegate-tasks.d.ts +0 -6
  83. package/dist/types/src/skills/delegation/operations/delegate-tasks.d.ts.map +1 -1
  84. package/dist/types/src/skills/index.d.ts +0 -1
  85. package/dist/types/src/skills/index.d.ts.map +1 -1
  86. package/dist/types/src/skills/planning/PlanningSkill.d.ts +3 -0
  87. package/dist/types/src/skills/planning/PlanningSkill.d.ts.map +1 -1
  88. package/dist/types/src/skills/planning/operations/definitions.d.ts +3 -1
  89. package/dist/types/src/skills/planning/operations/definitions.d.ts.map +1 -1
  90. package/dist/types/src/skills/planning/operations/plan-reminder.d.ts +6 -5
  91. package/dist/types/src/skills/planning/operations/plan-reminder.d.ts.map +1 -1
  92. package/dist/types/src/skills/planning/operations/update-tasks.d.ts +1 -1
  93. package/dist/types/src/skills/planning/operations/update-tasks.d.ts.map +1 -1
  94. package/dist/types/src/skills/skill-manager/SkillManagerSkill.d.ts +7 -0
  95. package/dist/types/src/skills/skill-manager/SkillManagerSkill.d.ts.map +1 -1
  96. package/dist/types/src/skills/skill-manager/lookup.test.d.ts +2 -0
  97. package/dist/types/src/skills/skill-manager/lookup.test.d.ts.map +1 -0
  98. package/dist/types/src/skills/skill-manager/operations/add-mcp-connection.d.ts +19 -0
  99. package/dist/types/src/skills/skill-manager/operations/add-mcp-connection.d.ts.map +1 -0
  100. package/dist/types/src/skills/skill-manager/operations/catalog.d.ts +36 -0
  101. package/dist/types/src/skills/skill-manager/operations/catalog.d.ts.map +1 -0
  102. package/dist/types/src/skills/skill-manager/operations/definitions.d.ts +116 -1
  103. package/dist/types/src/skills/skill-manager/operations/definitions.d.ts.map +1 -1
  104. package/dist/types/src/skills/skill-manager/operations/index.d.ts.map +1 -1
  105. package/dist/types/src/skills/skill-manager/operations/mcp-connections.d.ts +15 -0
  106. package/dist/types/src/skills/skill-manager/operations/mcp-connections.d.ts.map +1 -0
  107. package/dist/types/src/skills/skill-manager/operations/query-mcp-connections.d.ts +11 -0
  108. package/dist/types/src/skills/skill-manager/operations/query-mcp-connections.d.ts.map +1 -0
  109. package/dist/types/src/skills/skill-manager/operations/query-operations.d.ts +17 -0
  110. package/dist/types/src/skills/skill-manager/operations/query-operations.d.ts.map +1 -0
  111. package/dist/types/src/skills/skill-manager/operations/query-skills.d.ts +20 -2
  112. package/dist/types/src/skills/skill-manager/operations/query-skills.d.ts.map +1 -1
  113. package/dist/types/src/skills/skill-manager/operations/query-types.d.ts +13 -0
  114. package/dist/types/src/skills/skill-manager/operations/query-types.d.ts.map +1 -0
  115. package/dist/types/src/skills/skill-manager/operations/set-mcp-connection.d.ts +14 -0
  116. package/dist/types/src/skills/skill-manager/operations/set-mcp-connection.d.ts.map +1 -0
  117. package/dist/types/src/supervisor/delegation-strategy.d.ts +2 -7
  118. package/dist/types/src/supervisor/delegation-strategy.d.ts.map +1 -1
  119. package/dist/types/src/testing/operations.d.ts.map +1 -1
  120. package/dist/types/src/types/AgentOperation.d.ts +2 -1
  121. package/dist/types/src/types/AgentOperation.d.ts.map +1 -1
  122. package/dist/types/src/types/index.d.ts +0 -1
  123. package/dist/types/src/types/index.d.ts.map +1 -1
  124. package/dist/types/tsconfig.tsbuildinfo +1 -1
  125. package/package.json +32 -40
  126. package/src/commands.test.ts +4 -0
  127. package/src/commands.ts +12 -2
  128. package/src/operations/run-instructions.test.ts +12 -6
  129. package/src/operations/run-instructions.ts +12 -2
  130. package/src/skills/browser/BrowserSkill.ts +3 -8
  131. package/src/skills/chat-context/operations/context-add.test.ts +6 -4
  132. package/src/skills/chat-context/operations/context-remove.test.ts +6 -4
  133. package/src/skills/delegation/DelegationSkill.ts +2 -2
  134. package/src/skills/delegation/operations/definitions.ts +2 -2
  135. package/src/skills/delegation/operations/delegate-task.test.ts +1 -2
  136. package/src/skills/delegation/operations/delegate-task.ts +2 -2
  137. package/src/skills/delegation/operations/delegate-tasks.ts +2 -8
  138. package/src/skills/index.ts +0 -1
  139. package/src/skills/planning/PlanningSkill.ts +8 -12
  140. package/src/skills/planning/operations/definitions.ts +5 -4
  141. package/src/skills/planning/operations/plan-reminder.test.ts +9 -15
  142. package/src/skills/planning/operations/plan-reminder.ts +7 -13
  143. package/src/skills/planning/operations/update-tasks.md +7 -5
  144. package/src/skills/planning/operations/update-tasks.model.test.ts +2 -2
  145. package/src/skills/planning/operations/update-tasks.test.ts +110 -10
  146. package/src/skills/planning/operations/update-tasks.ts +22 -10
  147. package/src/skills/planning/skill.test.ts +9 -7
  148. package/src/skills/skill-manager/SkillManagerSkill.ts +71 -5
  149. package/src/skills/skill-manager/lookup.test.ts +308 -0
  150. package/src/skills/skill-manager/operations/add-mcp-connection.ts +83 -0
  151. package/src/skills/skill-manager/operations/catalog.ts +140 -0
  152. package/src/skills/skill-manager/operations/definitions.ts +168 -6
  153. package/src/skills/skill-manager/operations/index.ts +14 -1
  154. package/src/skills/skill-manager/operations/mcp-connections.ts +29 -0
  155. package/src/skills/skill-manager/operations/query-mcp-connections.ts +22 -0
  156. package/src/skills/skill-manager/operations/query-operations.ts +50 -0
  157. package/src/skills/skill-manager/operations/query-skills.ts +43 -3
  158. package/src/skills/skill-manager/operations/query-types.ts +32 -0
  159. package/src/skills/skill-manager/operations/set-mcp-connection.ts +28 -0
  160. package/src/skills/skill-manager/skill.test.ts +172 -9
  161. package/src/supervisor/delegation-strategy.test.ts +55 -4
  162. package/src/supervisor/delegation-strategy.ts +13 -28
  163. package/src/testing/operations.ts +2 -6
  164. package/src/types/AgentOperation.ts +6 -1
  165. package/src/types/index.ts +0 -1
  166. package/dist/lib/Memory.mjs +0 -1
  167. package/dist/lib/chunk-Memory.mjs +0 -19
  168. package/dist/lib/chunk-Memory.mjs.map +0 -1
  169. package/dist/lib/chunk-MemorySkill.mjs +0 -39
  170. package/dist/lib/chunk-MemorySkill.mjs.map +0 -1
  171. package/dist/lib/chunk-delete.mjs +0 -14
  172. package/dist/lib/chunk-delete.mjs.map +0 -1
  173. package/dist/lib/chunk-operations8.mjs +0 -9
  174. package/dist/lib/chunk-operations8.mjs.map +0 -1
  175. package/dist/lib/chunk-query.mjs +0 -18
  176. package/dist/lib/chunk-query.mjs.map +0 -1
  177. package/dist/lib/chunk-save.mjs +0 -17
  178. package/dist/lib/chunk-save.mjs.map +0 -1
  179. package/dist/lib/ns/MemorySkill.mjs +0 -3
  180. package/dist/types/src/skills/memory/MemorySkill.d.ts +0 -6
  181. package/dist/types/src/skills/memory/MemorySkill.d.ts.map +0 -1
  182. package/dist/types/src/skills/memory/index.d.ts +0 -2
  183. package/dist/types/src/skills/memory/index.d.ts.map +0 -1
  184. package/dist/types/src/skills/memory/operations/definitions.d.ts +0 -15
  185. package/dist/types/src/skills/memory/operations/definitions.d.ts.map +0 -1
  186. package/dist/types/src/skills/memory/operations/delete.d.ts +0 -7
  187. package/dist/types/src/skills/memory/operations/delete.d.ts.map +0 -1
  188. package/dist/types/src/skills/memory/operations/delete.test.d.ts +0 -2
  189. package/dist/types/src/skills/memory/operations/delete.test.d.ts.map +0 -1
  190. package/dist/types/src/skills/memory/operations/index.d.ts +0 -4
  191. package/dist/types/src/skills/memory/operations/index.d.ts.map +0 -1
  192. package/dist/types/src/skills/memory/operations/query.d.ts +0 -8
  193. package/dist/types/src/skills/memory/operations/query.d.ts.map +0 -1
  194. package/dist/types/src/skills/memory/operations/query.test.d.ts +0 -2
  195. package/dist/types/src/skills/memory/operations/query.test.d.ts.map +0 -1
  196. package/dist/types/src/skills/memory/operations/save.d.ts +0 -8
  197. package/dist/types/src/skills/memory/operations/save.d.ts.map +0 -1
  198. package/dist/types/src/skills/memory/operations/save.test.d.ts +0 -2
  199. package/dist/types/src/skills/memory/operations/save.test.d.ts.map +0 -1
  200. package/dist/types/src/skills/memory/skill.test.d.ts +0 -2
  201. package/dist/types/src/skills/memory/skill.test.d.ts.map +0 -1
  202. package/dist/types/src/types/Memory.d.ts +0 -12
  203. package/dist/types/src/types/Memory.d.ts.map +0 -1
  204. package/src/skills/memory/MemorySkill.ts +0 -39
  205. package/src/skills/memory/index.ts +0 -5
  206. package/src/skills/memory/operations/definitions.ts +0 -72
  207. package/src/skills/memory/operations/delete.test.ts +0 -37
  208. package/src/skills/memory/operations/delete.ts +0 -20
  209. package/src/skills/memory/operations/index.ts +0 -16
  210. package/src/skills/memory/operations/query.test.ts +0 -76
  211. package/src/skills/memory/operations/query.ts +0 -32
  212. package/src/skills/memory/operations/save.test.ts +0 -43
  213. package/src/skills/memory/operations/save.ts +0 -20
  214. package/src/skills/memory/skill.test.ts +0 -147
  215. package/src/types/Memory.ts +0 -22
@@ -5,7 +5,9 @@ import { Database, Feed, Ref, Registry } from "@dxos/echo";
5
5
  import { DXN as DXN$1 } from "@dxos/keys";
6
6
  import * as Schema from "effect/Schema";
7
7
  import * as Operation from "@dxos/compute/Operation";
8
+ import { mcpServerTypes } from "@dxos/agent-runtime/mcp-server-types";
8
9
  import { AiService, OpaqueToolkit } from "@dxos/ai";
10
+ import * as Credential from "@dxos/compute/Credential";
9
11
  import * as Trace from "@dxos/compute/Trace";
10
12
  import { Text } from "@dxos/schema";
11
13
  //#region src/types/AgentOperation.ts
@@ -39,10 +41,12 @@ var RunInstructions = Operation.make({
39
41
  Instructions.Instructions,
40
42
  Text.Text,
41
43
  Feed.Feed,
42
- Chat.Chat
44
+ Chat.Chat,
45
+ ...mcpServerTypes
43
46
  ],
44
47
  services: [
45
48
  AiService.AiService,
49
+ Credential.CredentialsService,
46
50
  Database.Service,
47
51
  OpaqueToolkit.OpaqueToolkitProvider,
48
52
  Registry.Service,
@@ -1 +1 @@
1
- {"version":3,"file":"chunk-AgentOperation.mjs","names":["DXN"],"sources":["../../src/types/AgentOperation.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Schema from 'effect/Schema';\n\nimport { AiService, OpaqueToolkit } from '@dxos/ai';\nimport * as Chat from '@dxos/assistant/Chat';\nimport * as Instructions from '@dxos/compute/Instructions';\nimport * as Operation from '@dxos/compute/Operation';\nimport * as Trace from '@dxos/compute/Trace';\nimport { Database, Feed, Ref, Registry } from '@dxos/echo';\nimport { DXN } from '@dxos/keys';\nimport { Text } from '@dxos/schema';\n\nexport const RunInstructions = Operation.make({\n meta: {\n key: DXN.make('org.dxos.operation.assistantToolkit.runInstructions'),\n name: 'Run Instructions',\n description: 'Agentic worker that executes a provided prompt using skills and tools.',\n icon: 'ph--brain--regular',\n },\n input: Schema.Struct({\n instructions: Ref.Ref(Instructions.Instructions),\n\n /**\n * Input object or data.\n * References get auto-resolved.\n */\n input: Schema.Any.pipe(Schema.annotate({ title: 'Input' })),\n\n /**\n * When set, runs in this chat (history, queue, and bound context). Routine skills and context objects are merged into the conversation for this request.\n */\n chat: Schema.optional(Ref.Ref(Chat.Chat)),\n\n /**\n * @default `dxn:com.anthropic.model.claude-opus-5.default`.\n */\n model: Schema.optional(DXN.Schema),\n\n systemInstructions: Schema.optional(Schema.String).annotate({\n description: 'Additional system instructions to add to the system prompt.',\n }),\n }),\n output: Schema.Any,\n // ECHO types that the handler loads via Database.load(). Declaring them here ensures the\n // runtime registers their schema before remote invocation (e.g. via the EDGE function service).\n types: [Instructions.Instructions, Text.Text, Feed.Feed, Chat.Chat],\n services: [\n AiService.AiService,\n Database.Service,\n OpaqueToolkit.OpaqueToolkitProvider,\n Registry.Service,\n Trace.TraceService,\n ],\n});\n"],"mappings":";;;;;;;;;;;;AAiBA,IAAa,kBAAkB,UAAU,KAAK;CAC5C,MAAM;EACJ,KAAKA,MAAI,KAAK,qDAAqD;EACnE,MAAM;EACN,aAAa;EACb,MAAM;CACR;CACA,OAAO,OAAO,OAAO;EACnB,cAAc,IAAI,IAAI,aAAa,YAAY;;;;;EAM/C,OAAO,OAAO,IAAI,KAAK,OAAO,SAAS,EAAE,OAAO,QAAQ,CAAC,CAAC;;;;EAK1D,MAAM,OAAO,SAAS,IAAI,IAAI,KAAK,IAAI,CAAC;;;;EAKxC,OAAO,OAAO,SAASA,MAAI,MAAM;EAEjC,oBAAoB,OAAO,SAAS,OAAO,MAAM,CAAC,CAAC,SAAS,EAC1D,aAAa,8DACf,CAAC;CACH,CAAC;CACD,QAAQ,OAAO;CAGf,OAAO;EAAC,aAAa;EAAc,KAAK;EAAM,KAAK;EAAM,KAAK;CAAI;CAClE,UAAU;EACR,UAAU;EACV,SAAS;EACT,cAAc;EACd,SAAS;EACT,MAAM;CACR;AACF,CAAC"}
1
+ {"version":3,"file":"chunk-AgentOperation.mjs","names":["DXN"],"sources":["../../src/types/AgentOperation.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Schema from 'effect/Schema';\n\nimport { mcpServerTypes } from '@dxos/agent-runtime/mcp-server-types';\nimport { AiService, OpaqueToolkit } from '@dxos/ai';\nimport * as Chat from '@dxos/assistant/Chat';\nimport * as Credential from '@dxos/compute/Credential';\nimport * as Instructions from '@dxos/compute/Instructions';\nimport * as Operation from '@dxos/compute/Operation';\nimport * as Trace from '@dxos/compute/Trace';\nimport { Database, Feed, Ref, Registry } from '@dxos/echo';\nimport { DXN } from '@dxos/keys';\nimport { Text } from '@dxos/schema';\n\nexport const RunInstructions = Operation.make({\n meta: {\n key: DXN.make('org.dxos.operation.assistantToolkit.runInstructions'),\n name: 'Run Instructions',\n description: 'Agentic worker that executes a provided prompt using skills and tools.',\n icon: 'ph--brain--regular',\n },\n input: Schema.Struct({\n instructions: Ref.Ref(Instructions.Instructions),\n\n /**\n * Input object or data.\n * References get auto-resolved.\n */\n input: Schema.Any.pipe(Schema.annotate({ title: 'Input' })),\n\n /**\n * When set, runs in this chat (history, queue, and bound context). Routine skills and context objects are merged into the conversation for this request.\n */\n chat: Schema.optional(Ref.Ref(Chat.Chat)),\n\n /**\n * @default `dxn:com.anthropic.model.claude-opus-5.default`.\n */\n model: Schema.optional(DXN.Schema),\n\n systemInstructions: Schema.optional(Schema.String).annotate({\n description: 'Additional system instructions to add to the system prompt.',\n }),\n }),\n output: Schema.Any,\n // ECHO types that the handler loads via Database.load(). Declaring them here ensures the\n // runtime registers their schema before remote invocation (e.g. via the EDGE function service).\n // `mcpServerTypes` are read each step to connect the space's MCP servers.\n types: [Instructions.Instructions, Text.Text, Feed.Feed, Chat.Chat, ...mcpServerTypes],\n services: [\n AiService.AiService,\n // Resolves an MCP connection's key.\n Credential.CredentialsService,\n Database.Service,\n OpaqueToolkit.OpaqueToolkitProvider,\n Registry.Service,\n Trace.TraceService,\n ],\n});\n"],"mappings":";;;;;;;;;;;;;;AAmBA,IAAa,kBAAkB,UAAU,KAAK;CAC5C,MAAM;EACJ,KAAKA,MAAI,KAAK,qDAAqD;EACnE,MAAM;EACN,aAAa;EACb,MAAM;CACR;CACA,OAAO,OAAO,OAAO;EACnB,cAAc,IAAI,IAAI,aAAa,YAAY;;;;;EAM/C,OAAO,OAAO,IAAI,KAAK,OAAO,SAAS,EAAE,OAAO,QAAQ,CAAC,CAAC;;;;EAK1D,MAAM,OAAO,SAAS,IAAI,IAAI,KAAK,IAAI,CAAC;;;;EAKxC,OAAO,OAAO,SAASA,MAAI,MAAM;EAEjC,oBAAoB,OAAO,SAAS,OAAO,MAAM,CAAC,CAAC,SAAS,EAC1D,aAAa,8DACf,CAAC;CACH,CAAC;CACD,QAAQ,OAAO;CAIf,OAAO;EAAC,aAAa;EAAc,KAAK;EAAM,KAAK;EAAM,KAAK;EAAM,GAAG;CAAc;CACrF,UAAU;EACR,UAAU;EAEV,WAAW;EACX,SAAS;EACT,cAAc;EACd,SAAS;EACT,MAAM;CACR;AACF,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
2
- import { t as AgentHandlers } from "./chunk-operations8.mjs";
2
+ import { t as AgentHandlers } from "./chunk-operations7.mjs";
3
3
  //#region src/AgentOperationHandlerSet.ts
4
4
  var AgentOperationHandlerSet_exports = /* @__PURE__ */ __exportAll({ handlers: () => AgentHandlers });
5
5
  //#endregion
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
2
- import { a as definitions_exports, t as AgentSkillHandlers } from "./chunk-operations7.mjs";
2
+ import { a as definitions_exports, t as AgentSkillHandlers } from "./chunk-operations6.mjs";
3
3
  import { trim } from "@dxos/util";
4
4
  import * as Skill from "@dxos/compute/Skill";
5
5
  import * as Template from "@dxos/compute/Template";
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
2
- import { i as definitions_exports, n as GetCurrentDate, r as SetAlarm, t as AlarmHandlers } from "./chunk-operations6.mjs";
2
+ import { i as definitions_exports, n as GetCurrentDate, r as SetAlarm, t as AlarmHandlers } from "./chunk-operations5.mjs";
3
3
  import { Ref } from "@dxos/echo";
4
4
  import { trim } from "@dxos/util";
5
5
  import * as Skill from "@dxos/compute/Skill";
@@ -11,18 +11,16 @@ var BrowserSkill_exports = /* @__PURE__ */ __exportAll({
11
11
  var key = "org.dxos.skill.browser";
12
12
  var instructions = trim`
13
13
  You are able to connect and use a virtual browser with persistent session.
14
- Browser tools are provided via MCP.
14
+ Browser tools come from the built-in Browser MCP server (\`org.dxos.mcp.browser\`), not from this
15
+ skill, and it is off until turned on. When you need them, turn it on with the Skill Manager's
16
+ set-mcp-connection; they are available from your next step.
15
17
  `;
16
18
  var make = () => Skill.make({
17
19
  key,
18
20
  name: "Browser",
19
21
  description: "Access to a real isolated browser.",
20
22
  agentCanEnable: true,
21
- instructions: { source: Ref.make(Text.make({ content: instructions })) },
22
- mcpServers: [{
23
- url: "https://playwright-mcp-example.dxos.workers.dev/sse",
24
- protocol: "sse"
25
- }]
23
+ instructions: { source: Ref.make(Text.make({ content: instructions })) }
26
24
  });
27
25
  //#endregion
28
26
  export { key as n, make as r, BrowserSkill_exports as t };
@@ -1 +1 @@
1
- {"version":3,"file":"chunk-BrowserSkill.mjs","names":[],"sources":["../../src/skills/browser/BrowserSkill.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Skill from '@dxos/compute/Skill';\nimport { Ref } from '@dxos/echo';\nimport { Text } from '@dxos/schema';\nimport { trim } from '@dxos/util';\n\nexport const key = 'org.dxos.skill.browser';\n\nconst instructions = trim`\n You are able to connect and use a virtual browser with persistent session.\n Browser tools are provided via MCP.\n`;\n\nexport const make = () =>\n Skill.make({\n key,\n name: 'Browser',\n description: 'Access to a real isolated browser.',\n agentCanEnable: true,\n instructions: {\n source: Ref.make(Text.make({ content: instructions })),\n },\n mcpServers: [\n {\n // https://dash.cloudflare.com/950816f3f59b079880a1ae33fb0ec320/workers/services/view/playwright-mcp-example/production\n url: 'https://playwright-mcp-example.dxos.workers.dev/sse',\n protocol: 'sse',\n },\n ],\n });\n"],"mappings":";;;;;;;;;;AAWA,IAAa,MAAM;AAEnB,IAAM,eAAe,IAAI;;;;AAKzB,IAAa,aACX,MAAM,KAAK;CACT;CACA,MAAM;CACN,aAAa;CACb,gBAAgB;CAChB,cAAc,EACZ,QAAQ,IAAI,KAAK,KAAK,KAAK,EAAE,SAAS,aAAa,CAAC,CAAC,EACvD;CACA,YAAY,CACV;EAEE,KAAK;EACL,UAAU;CACZ,CACF;AACF,CAAC"}
1
+ {"version":3,"file":"chunk-BrowserSkill.mjs","names":[],"sources":["../../src/skills/browser/BrowserSkill.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Skill from '@dxos/compute/Skill';\nimport { Ref } from '@dxos/echo';\nimport { Text } from '@dxos/schema';\nimport { trim } from '@dxos/util';\n\nexport const key = 'org.dxos.skill.browser';\n\nconst instructions = trim`\n You are able to connect and use a virtual browser with persistent session.\n Browser tools come from the built-in Browser MCP server (\\`org.dxos.mcp.browser\\`), not from this\n skill, and it is off until turned on. When you need them, turn it on with the Skill Manager's\n set-mcp-connection; they are available from your next step.\n`;\n\nexport const make = () =>\n Skill.make({\n key,\n name: 'Browser',\n description: 'Access to a real isolated browser.',\n agentCanEnable: true,\n instructions: {\n source: Ref.make(Text.make({ content: instructions })),\n },\n });\n"],"mappings":";;;;;;;;;;AAWA,IAAa,MAAM;AAEnB,IAAM,eAAe,IAAI;;;;;;AAOzB,IAAa,aACX,MAAM,KAAK;CACT;CACA,MAAM;CACN,aAAa;CACb,gBAAgB;CAChB,cAAc,EACZ,QAAQ,IAAI,KAAK,KAAK,KAAK,EAAE,SAAS,aAAa,CAAC,CAAC,EACvD;AACF,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
2
- import { i as definitions_exports, n as ContextAdd, r as ContextRemove, t as ChatContextHandlers } from "./chunk-operations5.mjs";
2
+ import { i as definitions_exports, n as ContextAdd, r as ContextRemove, t as ChatContextHandlers } from "./chunk-operations4.mjs";
3
3
  import { Ref } from "@dxos/echo";
4
4
  import { trim } from "@dxos/util";
5
5
  import * as Skill from "@dxos/compute/Skill";
@@ -22,8 +22,8 @@ var make = () => Skill.make({
22
22
  Delegate existing checklist tasks with the delegate-tasks tool, selecting by 1-based
23
23
  ordinal or exact title; delegate-task creates a NEW task from a title. When unsure what
24
24
  the checklist holds, read it first (get-agent-context when available). Delegated tasks
25
- run in the background once their dependencies are done, and each result is reported back
26
- to the conversation.
25
+ run in the background once their dependencies are done or in review, and each result is
26
+ reported back to the conversation.
27
27
  ` })
28
28
  });
29
29
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"chunk-DelegationSkill.mjs","names":[],"sources":["../../src/skills/delegation/DelegationSkill.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Skill from '@dxos/compute/Skill';\nimport * as Template from '@dxos/compute/Template';\nimport { trim } from '@dxos/util';\n\nimport { DelegateTask, DelegateTasks } from './operations/definitions.ts';\n\nexport const key = 'org.dxos.skill.delegation';\n\nexport const make = () =>\n Skill.make({\n key,\n name: 'Delegation',\n description: 'Delegates work to sub-agents and tracks it as plan tasks.',\n tools: Skill.toolDefinitions({ operations: [DelegateTask, DelegateTasks] }),\n instructions: Template.make({\n source: trim`\n {{! Delegation }}\n\n Delegate existing checklist tasks with the delegate-tasks tool, selecting by 1-based\n ordinal or exact title; delegate-task creates a NEW task from a title. When unsure what\n the checklist holds, read it first (get-agent-context when available). Delegated tasks\n run in the background once their dependencies are done, and each result is reported back\n to the conversation.\n `,\n }),\n });\n\nexport { DelegationSkillHandlers as Handlers } from './operations/index.ts';\nexport * as Operations from './operations/definitions.ts';\n"],"mappings":";;;;;;;;;;;;AAYA,IAAa,MAAM;AAEnB,IAAa,aACX,MAAM,KAAK;CACT;CACA,MAAM;CACN,aAAa;CACb,OAAO,MAAM,gBAAgB,EAAE,YAAY,CAAC,cAAc,aAAa,EAAE,CAAC;CAC1E,cAAc,SAAS,KAAK,EAC1B,QAAQ,IAAI;;;;;;;;QASd,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"chunk-DelegationSkill.mjs","names":[],"sources":["../../src/skills/delegation/DelegationSkill.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Skill from '@dxos/compute/Skill';\nimport * as Template from '@dxos/compute/Template';\nimport { trim } from '@dxos/util';\n\nimport { DelegateTask, DelegateTasks } from './operations/definitions.ts';\n\nexport const key = 'org.dxos.skill.delegation';\n\nexport const make = () =>\n Skill.make({\n key,\n name: 'Delegation',\n description: 'Delegates work to sub-agents and tracks it as plan tasks.',\n tools: Skill.toolDefinitions({ operations: [DelegateTask, DelegateTasks] }),\n instructions: Template.make({\n source: trim`\n {{! Delegation }}\n\n Delegate existing checklist tasks with the delegate-tasks tool, selecting by 1-based\n ordinal or exact title; delegate-task creates a NEW task from a title. When unsure what\n the checklist holds, read it first (get-agent-context when available). Delegated tasks\n run in the background once their dependencies are done or in review, and each result is\n reported back to the conversation.\n `,\n }),\n });\n\nexport { DelegationSkillHandlers as Handlers } from './operations/index.ts';\nexport * as Operations from './operations/definitions.ts';\n"],"mappings":";;;;;;;;;;;;AAYA,IAAa,MAAM;AAEnB,IAAa,aACX,MAAM,KAAK;CACT;CACA,MAAM;CACN,aAAa;CACb,OAAO,MAAM,gBAAgB,EAAE,YAAY,CAAC,cAAc,aAAa,EAAE,CAAC;CAC1E,cAAc,SAAS,KAAK,EAC1B,QAAQ,IAAI;;;;;;;;QASd,CAAC;AACH,CAAC"}
@@ -5,13 +5,13 @@ import { n as RunInstructions } from "./chunk-AgentOperation.mjs";
5
5
  import * as Cause from "effect/Cause";
6
6
  import * as Effect from "effect/Effect";
7
7
  import * as Exit from "effect/Exit";
8
- import { AiContext } from "@dxos/assistant";
8
+ import { AiContext, TrajectoryStore } from "@dxos/assistant";
9
9
  import * as Agent from "@dxos/assistant/Agent";
10
10
  import * as Chat from "@dxos/assistant/Chat";
11
11
  import { OperationProcess } from "@dxos/compute-runtime";
12
12
  import * as Instructions from "@dxos/compute/Instructions";
13
13
  import * as Process from "@dxos/compute/Process";
14
- import { Database, Feed, Filter, Obj, Query, Ref } from "@dxos/echo";
14
+ import { Database, Filter, Obj, Query, Ref } from "@dxos/echo";
15
15
  import * as EffectEx from "@dxos/effect/EffectEx";
16
16
  import { EID, EntityId } from "@dxos/keys";
17
17
  import { log } from "@dxos/log";
@@ -46,20 +46,8 @@ var extractArtifactIds = (value) => {
46
46
  const record = value;
47
47
  return (Array.isArray(record.artifactIds) ? record.artifactIds : typeof record.artifactId === "string" ? [record.artifactId] : []).filter((id) => typeof id === "string");
48
48
  };
49
- /**
50
- * A task handed to a sub-agent by the delegation verbs, which assign `{ role: 'assistant' }` and
51
- * nothing else. An assistant assignee carrying a `subject` names a concrete session that owns the
52
- * task — the conversation's own agent starting it from the planning tool, or a remote session —
53
- * so it is that session's work, not a spawn request for the supervisor.
54
- */
55
- var isSubAgentTask = (task) => task.assignee?.role === "assistant" && task.assignee.subject === void 0;
56
- /**
57
- * The durable agent tasks awaiting a sub-agent for this conversation: queued (`todo`) tasks of
58
- * the chat's checklist whose assignee is an agent, all of whose dependencies are done. Ordinary
59
- * (unassigned) tasks are never spawned — delegation happens only through the delegation verbs.
60
- * `started` always means a live process (set at spawn), so a started agent task with no process
61
- * is an orphan — {@link sweepOrphanedTasks}.
62
- */
49
+ /** A task handed to a sub-agent by the delegation verbs (see `Task.isSubAgentRequest`). */
50
+ var isSubAgentTask = (task) => Task.isSubAgentRequest(Task.worker(task));
63
51
  var findPendingTasks = (chat, activeIds) => Effect.gen(function* () {
64
52
  const tasks = yield* Chat.loadTasks(chat);
65
53
  return tasks.filter((task) => isSubAgentTask(task) && (task.status ?? "todo") === "todo" && !activeIds.has(task.id) && Task.isTaskReady(tasks, task));
@@ -78,7 +66,7 @@ var sweepOrphanedTasks = (chat, activeIds) => Effect.gen(function* () {
78
66
  }, {
79
67
  "~LogMeta": "~LogMeta",
80
68
  F: __dxlog_file,
81
- L: 115,
69
+ L: 102,
82
70
  S: this
83
71
  });
84
72
  Obj.update(task, (task) => {
@@ -87,13 +75,13 @@ var sweepOrphanedTasks = (chat, activeIds) => Effect.gen(function* () {
87
75
  }
88
76
  yield* Database.flush();
89
77
  });
90
- /**
91
- * Fails the tasks the conversation's own agent holds when its turn fails — a model error ends the
92
- * process before any reconcile, so a task left `started` would read as underway indefinitely.
93
- * Sub-agent tasks are left to their own process's exit, which may still succeed.
94
- */
95
78
  var failHeldTasks = (chat, cause) => Effect.gen(function* () {
96
- const held = (yield* Chat.loadTasks(chat)).filter((task) => Task.isAgentWorking(task) && !isSubAgentTask(task));
79
+ const agent = yield* Agent.loadForChat(chat);
80
+ const selves = new Set(agent ? [chat.id, agent.id] : [chat.id]);
81
+ const held = (yield* Chat.loadTasks(chat)).filter((task) => {
82
+ const worker = Task.refEntityId(Task.worker(task)?.subject);
83
+ return Task.isAgentWorking(task) && worker !== void 0 && selves.has(worker);
84
+ });
97
85
  if (held.length === 0) return;
98
86
  const reason = Cause.prettyErrors(cause).map((error) => error.message).join("; ");
99
87
  log.warn("agent turn failed; failing held tasks", {
@@ -102,7 +90,7 @@ var failHeldTasks = (chat, cause) => Effect.gen(function* () {
102
90
  }, {
103
91
  "~LogMeta": "~LogMeta",
104
92
  F: __dxlog_file,
105
- L: 139,
93
+ L: 126,
106
94
  S: this
107
95
  });
108
96
  for (const task of held) Task.setStatus(task, "failed", {
@@ -116,7 +104,7 @@ var failHeldTasks = (chat, cause) => Effect.gen(function* () {
116
104
  });
117
105
  /**
118
106
  * Supervisor behaviour for the conversational agent: after each turn, every queued agent task
119
- * whose dependencies are done is run by a sub-agent (a synthesized minimal `Routine` executed via
107
+ * whose dependencies are finished is run by a sub-agent (a synthesized minimal `Routine` executed via
120
108
  * `RunInstructions`), marked started at spawn; on exit the task is marked done/failed and a
121
109
  * templated message is posted back to the conversation, whose turn re-runs this reconcile — so a
122
110
  * batch of delegated tasks drains in dependency order without further prompting.
@@ -171,9 +159,7 @@ var makeDelegationStrategy = () => ({
171
159
  let title = id;
172
160
  const task = (yield* Database.query(Query.select(Filter.id(id))).run.pipe(Effect.orElseSucceed(() => []))).find((candidate) => Obj.instanceOf(Task.Task, candidate));
173
161
  if (task) {
174
- Obj.update(task, (task) => {
175
- task.status = Exit.isSuccess(exit) ? "done" : "failed";
176
- });
162
+ Task.setStatus(task, Exit.isSuccess(exit) ? "done" : "failed");
177
163
  title = task.title;
178
164
  }
179
165
  const artifactRefs = [];
@@ -188,7 +174,7 @@ var makeDelegationStrategy = () => ({
188
174
  }, {
189
175
  "~LogMeta": "~LogMeta",
190
176
  F: __dxlog_file,
191
- L: 254,
177
+ L: 239,
192
178
  S: this
193
179
  });
194
180
  const failureSummary = Exit.isFailure(exit) ? Cause.prettyErrors(exit.cause).map((error) => error.message).join("; ") : void 0;
@@ -200,7 +186,7 @@ var makeDelegationStrategy = () => ({
200
186
  reference
201
187
  }))];
202
188
  const feed = yield* Database.load(chat.feed).pipe(Effect.orDie);
203
- yield* Feed.append(feed, [Message.make({
189
+ yield* TrajectoryStore.appendMessages(feed, [Message.make({
204
190
  sender: "assistant",
205
191
  blocks
206
192
  })]);
@@ -1 +1 @@
1
- {"version":3,"file":"chunk-DelegationStrategy.mjs","names":["DelegationSkill.key","AgentOperation.RunInstructions"],"sources":["../../src/supervisor/delegation-strategy.ts","../../src/DelegationStrategy.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Cause from 'effect/Cause';\nimport * as Effect from 'effect/Effect';\nimport * as Exit from 'effect/Exit';\n\nimport { type Delegation, type DelegationStrategy } from '@dxos/agent-runtime';\nimport { AiContext } from '@dxos/assistant';\nimport * as Agent from '@dxos/assistant/Agent';\nimport * as Chat from '@dxos/assistant/Chat';\nimport { OperationProcess } from '@dxos/compute-runtime';\nimport * as Instructions from '@dxos/compute/Instructions';\nimport * as Process from '@dxos/compute/Process';\nimport { Database, Feed, Filter, Obj, Query, Ref } from '@dxos/echo';\nimport * as EffectEx from '@dxos/effect/EffectEx';\nimport { EID, EntityId } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { Message, Task } from '@dxos/types';\nimport { trim } from '@dxos/util';\n\nimport { ToolkitError } from '../errors.ts';\nimport * as DelegationSkill from '../skills/delegation/DelegationSkill.ts';\nimport * as AgentOperation from '../types/AgentOperation.ts';\n\n/**\n * Normalizes an LLM-reported artifact reference (bare entity id or full ECHO URI) to a\n * fully-qualified ref in the current space. Not resolved here — it resolves lazily when read.\n */\nconst resolveArtifactRef = (id: string): Effect.Effect<Ref.Ref<Obj.Unknown>, Error, Database.Service> =>\n Effect.gen(function* () {\n const parsed = EID.tryParse(id);\n const candidate = (parsed ? EID.getEntityId(parsed) : undefined) ?? id;\n if (!EntityId.isValid(candidate)) {\n // Malformed LLM-reported id: fail so the caller's `orElseSucceed` drops it.\n return yield* Effect.fail(new ToolkitError({ message: `Invalid artifact id: ${id}` }));\n }\n const { db } = yield* Database.Service;\n return db.makeRef<Obj.Unknown>(EID.make({ spaceId: db.spaceId, entityId: candidate }));\n });\n\n/**\n * Renders a sub-agent result for inclusion in a notification message.\n */\nconst formatResult = (value: unknown): string => (typeof value === 'string' ? value : JSON.stringify(value));\n\n/**\n * Extracts artifact ids a sub-agent reported in its result (see the synthesized instructions\n * instructions). Tolerates the result being a string, or an object with `artifactIds`/`artifactId`.\n */\nconst extractArtifactIds = (value: unknown): string[] => {\n if (typeof value !== 'object' || value === null) {\n return [];\n }\n\n const record = value as { artifactIds?: unknown; artifactId?: unknown };\n const ids = Array.isArray(record.artifactIds)\n ? record.artifactIds\n : typeof record.artifactId === 'string'\n ? [record.artifactId]\n : [];\n return ids.filter((id): id is string => typeof id === 'string');\n};\n\n/**\n * A task handed to a sub-agent by the delegation verbs, which assign `{ role: 'assistant' }` and\n * nothing else. An assistant assignee carrying a `subject` names a concrete session that owns the\n * task — the conversation's own agent starting it from the planning tool, or a remote session —\n * so it is that session's work, not a spawn request for the supervisor.\n */\nexport const isSubAgentTask = (task: Task.Task): boolean =>\n task.assignee?.role === 'assistant' && task.assignee.subject === undefined;\n\n/**\n * The durable agent tasks awaiting a sub-agent for this conversation: queued (`todo`) tasks of\n * the chat's checklist whose assignee is an agent, all of whose dependencies are done. Ordinary\n * (unassigned) tasks are never spawned — delegation happens only through the delegation verbs.\n * `started` always means a live process (set at spawn), so a started agent task with no process\n * is an orphan — {@link sweepOrphanedTasks}.\n */\nconst findPendingTasks = (\n chat: Chat.Chat,\n activeIds: ReadonlySet<string>,\n): Effect.Effect<Task.Task[], never, Database.Service> =>\n Effect.gen(function* () {\n const tasks = yield* Chat.loadTasks(chat);\n // The chat's `tasks` array is flat, so a delegated sub-task is found without descending.\n return tasks.filter(\n (task) =>\n isSubAgentTask(task) &&\n (task.status ?? 'todo') === 'todo' &&\n !activeIds.has(task.id) &&\n Task.isTaskReady(tasks, task),\n );\n });\n\n/**\n * Fails agent tasks stuck in `started` with no live process — a crashed or never-exited\n * sub-agent (e.g. the host reloaded mid-run) must not wedge the task or the delegation loop.\n */\nconst sweepOrphanedTasks = (\n chat: Chat.Chat,\n activeIds: ReadonlySet<string>,\n): Effect.Effect<void, never, Database.Service> =>\n Effect.gen(function* () {\n const tasks = yield* Chat.loadTasks(chat);\n const orphans = tasks.filter(\n (task) => isSubAgentTask(task) && task.status === 'started' && !activeIds.has(task.id),\n );\n if (orphans.length === 0) {\n return;\n }\n for (const task of orphans) {\n log.warn('orphaned delegated task failed', { taskId: task.id, title: task.title });\n Obj.update(task, (task) => {\n task.status = 'failed';\n });\n }\n yield* Database.flush();\n });\n\n/**\n * Fails the tasks the conversation's own agent holds when its turn fails — a model error ends the\n * process before any reconcile, so a task left `started` would read as underway indefinitely.\n * Sub-agent tasks are left to their own process's exit, which may still succeed.\n */\nconst failHeldTasks = (chat: Chat.Chat, cause: Cause.Cause<unknown>): Effect.Effect<void, never, Database.Service> =>\n Effect.gen(function* () {\n const held = (yield* Chat.loadTasks(chat)).filter((task) => Task.isAgentWorking(task) && !isSubAgentTask(task));\n if (held.length === 0) {\n return;\n }\n\n // The reader sees the error message; the full cause goes to the log.\n const reason = Cause.prettyErrors(cause)\n .map((error) => error.message)\n .join('; ');\n log.warn('agent turn failed; failing held tasks', { chatId: chat.id, cause: Cause.pretty(cause) });\n for (const task of held) {\n Task.setStatus(task, 'failed', {\n actor: { role: 'assistant', subject: Ref.make(chat) },\n description: `The agent's request failed${reason ? `: ${reason}` : '.'}`,\n });\n }\n yield* Database.flush();\n });\n\n/**\n * Supervisor behaviour for the conversational agent: after each turn, every queued agent task\n * whose dependencies are done is run by a sub-agent (a synthesized minimal `Routine` executed via\n * `RunInstructions`), marked started at spawn; on exit the task is marked done/failed and a\n * templated message is posted back to the conversation, whose turn re-runs this reconcile — so a\n * batch of delegated tasks drains in dependency order without further prompting.\n */\nexport const makeDelegationStrategy = (): DelegationStrategy => ({\n reconcile: (chat, activeIds) =>\n Effect.gen(function* () {\n yield* sweepOrphanedTasks(chat, activeIds);\n const pending = yield* findPendingTasks(chat, activeIds);\n if (pending.length === 0) {\n return [];\n }\n\n // Sub-agents inherit the supervisor's bound skills (so they have the same tools/\n // capabilities), minus the delegation skill itself — otherwise a sub-agent could\n // recursively delegate. Resolved from the conversation's AiContext bindings.\n const feed = yield* Database.load(chat.feed).pipe(Effect.orDie);\n const inheritedSkills = yield* Effect.gen(function* () {\n const runtime = yield* Effect.context<Database.Service>();\n const binder = yield* EffectEx.acquireReleaseResource(() => new AiContext.Binder({ feed, runtime }));\n return binder.getSkills().filter((skill) => Obj.getMeta(skill).key !== DelegationSkill.key);\n }).pipe(Effect.scoped);\n const skills = inheritedSkills.map((skill) => Ref.make(skill));\n\n const delegations: Delegation[] = [];\n for (const task of pending) {\n // Synthesize a minimal instructions whose goal is the task; the sub-agent runs it via RunInstructions\n // with the inherited skills bound.\n const instructions = yield* Database.add(\n Instructions.make({\n name: task.title,\n text: trim`\n Complete the following task and report the result concisely.\n\n If you create any documents or artifacts, call completeJob with a JSON object of the\n form { \"summary\": string, \"artifactIds\": string[] }, where artifactIds are the exact\n ids returned by the tools that created them. Otherwise return a short summary string.\n\n Task: ${task.title}\n `,\n skills,\n }),\n );\n\n // Started is stamped when the delegation is handed to the runtime — never by the\n // delegation verbs — so `started` always means a spawning/live sub-agent and an orphaned\n // `started` is detectable (see the sweep).\n Obj.update(task, (task) => {\n task.status = 'started';\n });\n\n delegations.push({\n id: task.id,\n spawn: Effect.gen(function* () {\n // The task ↔ process mapping lives runtime-side (the supervisor's activeIds keyed by\n // task id) — nothing is stamped on the durable task.\n const handle = yield* Process.spawn(OperationProcess.make(AgentOperation.RunInstructions), {\n instructions: Ref.make(instructions),\n input: {},\n });\n return handle.pid;\n }),\n });\n }\n yield* Database.flush();\n return delegations;\n }),\n\n onTurnFailed: failHeldTasks,\n\n onComplete: (chat, id, exit) =>\n Effect.gen(function* () {\n const agent = yield* Agent.loadForChat(chat);\n\n // Resolve the durable task by its id and record the outcome directly on it — the task set\n // is the working surface, so there is no separate mirror to reconcile.\n let title = id;\n const tasks = yield* Database.query(Query.select(Filter.id(id))).run.pipe(Effect.orElseSucceed(() => []));\n const task = tasks.find((candidate): candidate is Task.Task => Obj.instanceOf(Task.Task, candidate));\n if (task) {\n Obj.update(task, (task) => {\n task.status = Exit.isSuccess(exit) ? 'done' : 'failed';\n });\n title = task.title;\n }\n\n // Surface any artifacts the sub-agent produced as inline reference blocks in the notification\n // message, so follow-up turns can reference them (durable filing belongs to the project's\n // collection — the agent stores no artifacts).\n const artifactRefs: Ref.Ref<Obj.Unknown>[] = [];\n if (agent && Exit.isSuccess(exit)) {\n for (const artifactId of extractArtifactIds(exit.value)) {\n const ref = yield* resolveArtifactRef(artifactId).pipe(Effect.orElseSucceed(() => undefined));\n if (ref) {\n artifactRefs.push(ref);\n }\n }\n }\n\n // The full cause (with stack traces) goes to the log; the conversation gets the error\n // messages only, so delegation errors stay debuggable without dumping a stack in the chat.\n if (Exit.isFailure(exit)) {\n log.warn('sub-agent failed', { taskId: id, title, cause: Cause.pretty(exit.cause) });\n }\n const failureSummary = Exit.isFailure(exit)\n ? Cause.prettyErrors(exit.cause)\n .map((error) => error.message)\n .join('; ')\n : undefined;\n\n const text = Exit.isSuccess(exit)\n ? `The sub-agent completed \"${title}\".${artifactRefs.length === 0 ? ` ${formatResult(exit.value)}` : ''}`\n : `The sub-agent failed to complete \"${title}\": ${failureSummary || 'unknown error'}`;\n\n // Embed each produced artifact as a `reference` block — the chat renders these as a dx-anchor\n // tag with an inline object preview, rather than a raw `echo://` URI in the text.\n const blocks = [\n { _tag: 'text' as const, text },\n ...artifactRefs.map((reference) => ({ _tag: 'reference' as const, reference })),\n ];\n\n const feed = yield* Database.load(chat.feed).pipe(Effect.orDie);\n yield* Feed.append(feed, [Message.make({ sender: 'assistant', blocks })]);\n }),\n});\n","//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nexport { isSubAgentTask, makeDelegationStrategy as make } from './supervisor/delegation-strategy.ts';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,IAAM,sBAAsB,OAC1B,OAAO,IAAI,aAAa;CACtB,MAAM,SAAS,IAAI,SAAS,EAAE;CAC9B,MAAM,aAAa,SAAS,IAAI,YAAY,MAAM,IAAI,KAAA,MAAc;CACpE,IAAI,CAAC,SAAS,QAAQ,SAAS,GAE7B,OAAO,OAAO,OAAO,KAAK,IAAI,aAAa,EAAE,SAAS,wBAAwB,KAAK,CAAC,CAAC;CAEvF,MAAM,EAAE,OAAO,OAAO,SAAS;CAC/B,OAAO,GAAG,QAAqB,IAAI,KAAK;EAAE,SAAS,GAAG;EAAS,UAAU;CAAU,CAAC,CAAC;AACvF,CAAC;;;;AAKH,IAAM,gBAAgB,UAA4B,OAAO,UAAU,WAAW,QAAQ,KAAK,UAAU,KAAK;;;;;AAM1G,IAAM,sBAAsB,UAA6B;CACvD,IAAI,OAAO,UAAU,YAAY,UAAU,MACzC,OAAO,CAAC;CAGV,MAAM,SAAS;CAMf,QALY,MAAM,QAAQ,OAAO,WAAW,IACxC,OAAO,cACP,OAAO,OAAO,eAAe,WAC3B,CAAC,OAAO,UAAU,IAClB,CAAC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AAS,CACb;GAAE,MAAM;GAAiB,MAPd,KAAK,UAAU,IAAI,IAC5B,4BAA4B,MAAM,IAAI,aAAa,WAAW,IAAI,IAAI,aAAa,KAAK,KAAK,MAAM,OACnG,qCAAqC,MAAM,KAAK,kBAAkB;EAKtC,GAC9B,GAAG,aAAa,KAAK,eAAe;GAAE,MAAM;GAAsB;EAAU,EAAE,CAChF;EAEA,MAAM,OAAO,OAAO,SAAS,KAAK,KAAK,IAAI,CAAC,CAAC,KAAK,OAAO,KAAK;EAC9D,OAAO,KAAK,OAAO,MAAM,CAAC,QAAQ,KAAK;GAAE,QAAQ;GAAa;EAAO,CAAC,CAAC,CAAC;CAC1E,CAAC;AACL"}
1
+ {"version":3,"file":"chunk-DelegationStrategy.mjs","names":["DelegationSkill.key","AgentOperation.RunInstructions"],"sources":["../../src/supervisor/delegation-strategy.ts","../../src/DelegationStrategy.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Cause from 'effect/Cause';\nimport * as Effect from 'effect/Effect';\nimport * as Exit from 'effect/Exit';\n\nimport { type Delegation, type DelegationStrategy } from '@dxos/agent-runtime';\nimport { AiContext, TrajectoryStore } from '@dxos/assistant';\nimport * as Agent from '@dxos/assistant/Agent';\nimport * as Chat from '@dxos/assistant/Chat';\nimport { OperationProcess } from '@dxos/compute-runtime';\nimport * as Instructions from '@dxos/compute/Instructions';\nimport * as Process from '@dxos/compute/Process';\nimport { Database, Filter, Obj, Query, Ref } from '@dxos/echo';\nimport * as EffectEx from '@dxos/effect/EffectEx';\nimport { EID, EntityId } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { Message, Task } from '@dxos/types';\nimport { trim } from '@dxos/util';\n\nimport { ToolkitError } from '../errors.ts';\nimport * as DelegationSkill from '../skills/delegation/DelegationSkill.ts';\nimport * as AgentOperation from '../types/AgentOperation.ts';\n\n/**\n * Normalizes an LLM-reported artifact reference (bare entity id or full ECHO URI) to a\n * fully-qualified ref in the current space. Not resolved here — it resolves lazily when read.\n */\nconst resolveArtifactRef = (id: string): Effect.Effect<Ref.Ref<Obj.Unknown>, Error, Database.Service> =>\n Effect.gen(function* () {\n const parsed = EID.tryParse(id);\n const candidate = (parsed ? EID.getEntityId(parsed) : undefined) ?? id;\n if (!EntityId.isValid(candidate)) {\n // Malformed LLM-reported id: fail so the caller's `orElseSucceed` drops it.\n return yield* Effect.fail(new ToolkitError({ message: `Invalid artifact id: ${id}` }));\n }\n const { db } = yield* Database.Service;\n return db.makeRef<Obj.Unknown>(EID.make({ spaceId: db.spaceId, entityId: candidate }));\n });\n\n/**\n * Renders a sub-agent result for inclusion in a notification message.\n */\nconst formatResult = (value: unknown): string => (typeof value === 'string' ? value : JSON.stringify(value));\n\n/**\n * Extracts artifact ids a sub-agent reported in its result (see the synthesized instructions\n * instructions). Tolerates the result being a string, or an object with `artifactIds`/`artifactId`.\n */\nconst extractArtifactIds = (value: unknown): string[] => {\n if (typeof value !== 'object' || value === null) {\n return [];\n }\n\n const record = value as { artifactIds?: unknown; artifactId?: unknown };\n const ids = Array.isArray(record.artifactIds)\n ? record.artifactIds\n : typeof record.artifactId === 'string'\n ? [record.artifactId]\n : [];\n return ids.filter((id): id is string => typeof id === 'string');\n};\n\n/** A task handed to a sub-agent by the delegation verbs (see `Task.isSubAgentRequest`). */\nexport const isSubAgentTask = (task: Task.Task): boolean => Task.isSubAgentRequest(Task.worker(task));\n\nconst findPendingTasks = (\n chat: Chat.Chat,\n activeIds: ReadonlySet<string>,\n): Effect.Effect<Task.Task[], never, Database.Service> =>\n Effect.gen(function* () {\n const tasks = yield* Chat.loadTasks(chat);\n // The chat's `tasks` array is flat, so a delegated sub-task is found without descending.\n return tasks.filter(\n (task) =>\n isSubAgentTask(task) &&\n (task.status ?? 'todo') === 'todo' &&\n !activeIds.has(task.id) &&\n Task.isTaskReady(tasks, task),\n );\n });\n\n/**\n * Fails agent tasks stuck in `started` with no live process — a crashed or never-exited\n * sub-agent (e.g. the host reloaded mid-run) must not wedge the task or the delegation loop.\n */\nconst sweepOrphanedTasks = (\n chat: Chat.Chat,\n activeIds: ReadonlySet<string>,\n): Effect.Effect<void, never, Database.Service> =>\n Effect.gen(function* () {\n const tasks = yield* Chat.loadTasks(chat);\n const orphans = tasks.filter(\n (task) => isSubAgentTask(task) && task.status === 'started' && !activeIds.has(task.id),\n );\n if (orphans.length === 0) {\n return;\n }\n for (const task of orphans) {\n log.warn('orphaned delegated task failed', { taskId: task.id, title: task.title });\n Obj.update(task, (task) => {\n task.status = 'failed';\n });\n }\n yield* Database.flush();\n });\n\nconst failHeldTasks = (chat: Chat.Chat, cause: Cause.Cause<unknown>): Effect.Effect<void, never, Database.Service> =>\n Effect.gen(function* () {\n const agent = yield* Agent.loadForChat(chat);\n const selves = new Set(agent ? [chat.id, agent.id] : [chat.id]);\n const held = (yield* Chat.loadTasks(chat)).filter((task) => {\n const worker = Task.refEntityId(Task.worker(task)?.subject);\n return Task.isAgentWorking(task) && worker !== undefined && selves.has(worker);\n });\n if (held.length === 0) {\n return;\n }\n\n // The reader sees the error message; the full cause goes to the log.\n const reason = Cause.prettyErrors(cause)\n .map((error) => error.message)\n .join('; ');\n log.warn('agent turn failed; failing held tasks', { chatId: chat.id, cause: Cause.pretty(cause) });\n for (const task of held) {\n Task.setStatus(task, 'failed', {\n actor: { role: 'assistant', subject: Ref.make(chat) },\n description: `The agent's request failed${reason ? `: ${reason}` : '.'}`,\n });\n }\n yield* Database.flush();\n });\n\n/**\n * Supervisor behaviour for the conversational agent: after each turn, every queued agent task\n * whose dependencies are finished is run by a sub-agent (a synthesized minimal `Routine` executed via\n * `RunInstructions`), marked started at spawn; on exit the task is marked done/failed and a\n * templated message is posted back to the conversation, whose turn re-runs this reconcile — so a\n * batch of delegated tasks drains in dependency order without further prompting.\n */\nexport const makeDelegationStrategy = (): DelegationStrategy => ({\n reconcile: (chat, activeIds) =>\n Effect.gen(function* () {\n yield* sweepOrphanedTasks(chat, activeIds);\n const pending = yield* findPendingTasks(chat, activeIds);\n if (pending.length === 0) {\n return [];\n }\n\n // Sub-agents inherit the supervisor's bound skills (so they have the same tools/\n // capabilities), minus the delegation skill itself — otherwise a sub-agent could\n // recursively delegate. Resolved from the conversation's AiContext bindings.\n const feed = yield* Database.load(chat.feed).pipe(Effect.orDie);\n const inheritedSkills = yield* Effect.gen(function* () {\n const runtime = yield* Effect.context<Database.Service>();\n const binder = yield* EffectEx.acquireReleaseResource(() => new AiContext.Binder({ feed, runtime }));\n return binder.getSkills().filter((skill) => Obj.getMeta(skill).key !== DelegationSkill.key);\n }).pipe(Effect.scoped);\n const skills = inheritedSkills.map((skill) => Ref.make(skill));\n\n const delegations: Delegation[] = [];\n for (const task of pending) {\n // Synthesize a minimal instructions whose goal is the task; the sub-agent runs it via RunInstructions\n // with the inherited skills bound.\n const instructions = yield* Database.add(\n Instructions.make({\n name: task.title,\n text: trim`\n Complete the following task and report the result concisely.\n\n If you create any documents or artifacts, call completeJob with a JSON object of the\n form { \"summary\": string, \"artifactIds\": string[] }, where artifactIds are the exact\n ids returned by the tools that created them. Otherwise return a short summary string.\n\n Task: ${task.title}\n `,\n skills,\n }),\n );\n\n // Started is stamped when the delegation is handed to the runtime — never by the\n // delegation verbs — so `started` always means a spawning/live sub-agent and an orphaned\n // `started` is detectable (see the sweep).\n Obj.update(task, (task) => {\n task.status = 'started';\n });\n\n delegations.push({\n id: task.id,\n spawn: Effect.gen(function* () {\n // The task ↔ process mapping lives runtime-side (the supervisor's activeIds keyed by\n // task id) — nothing is stamped on the durable task.\n const handle = yield* Process.spawn(OperationProcess.make(AgentOperation.RunInstructions), {\n instructions: Ref.make(instructions),\n input: {},\n });\n return handle.pid;\n }),\n });\n }\n yield* Database.flush();\n return delegations;\n }),\n\n onTurnFailed: failHeldTasks,\n\n onComplete: (chat, id, exit) =>\n Effect.gen(function* () {\n const agent = yield* Agent.loadForChat(chat);\n\n // Resolve the durable task by its id and record the outcome directly on it — the task set\n // is the working surface, so there is no separate mirror to reconcile.\n let title = id;\n const tasks = yield* Database.query(Query.select(Filter.id(id))).run.pipe(Effect.orElseSucceed(() => []));\n const task = tasks.find((candidate): candidate is Task.Task => Obj.instanceOf(Task.Task, candidate));\n if (task) {\n Task.setStatus(task, Exit.isSuccess(exit) ? 'done' : 'failed');\n title = task.title;\n }\n\n // Surface any artifacts the sub-agent produced as inline reference blocks in the notification\n // message, so follow-up turns can reference them (durable filing belongs to the project's\n // collection — the agent stores no artifacts).\n const artifactRefs: Ref.Ref<Obj.Unknown>[] = [];\n if (agent && Exit.isSuccess(exit)) {\n for (const artifactId of extractArtifactIds(exit.value)) {\n const ref = yield* resolveArtifactRef(artifactId).pipe(Effect.orElseSucceed(() => undefined));\n if (ref) {\n artifactRefs.push(ref);\n }\n }\n }\n\n // The full cause (with stack traces) goes to the log; the conversation gets the error\n // messages only, so delegation errors stay debuggable without dumping a stack in the chat.\n if (Exit.isFailure(exit)) {\n log.warn('sub-agent failed', { taskId: id, title, cause: Cause.pretty(exit.cause) });\n }\n const failureSummary = Exit.isFailure(exit)\n ? Cause.prettyErrors(exit.cause)\n .map((error) => error.message)\n .join('; ')\n : undefined;\n\n const text = Exit.isSuccess(exit)\n ? `The sub-agent completed \"${title}\".${artifactRefs.length === 0 ? ` ${formatResult(exit.value)}` : ''}`\n : `The sub-agent failed to complete \"${title}\": ${failureSummary || 'unknown error'}`;\n\n // Embed each produced artifact as a `reference` block — the chat renders these as a dx-anchor\n // tag with an inline object preview, rather than a raw `echo://` URI in the text.\n const blocks = [\n { _tag: 'text' as const, text },\n ...artifactRefs.map((reference) => ({ _tag: 'reference' as const, reference })),\n ];\n\n const feed = yield* Database.load(chat.feed).pipe(Effect.orDie);\n yield* TrajectoryStore.appendMessages(feed, [Message.make({ sender: 'assistant', blocks })]);\n }),\n});\n","//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nexport { isSubAgentTask, makeDelegationStrategy as make } from './supervisor/delegation-strategy.ts';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;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,CAAC,QAAQ,KAAK;GAAE,QAAQ;GAAa;EAAO,CAAC,CAAC,CAAC;CAC7F,CAAC;AACL"}
@@ -1,14 +1,13 @@
1
1
  import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
2
2
  import { a as definitions_exports, i as UpdateTasks, n as AskQuestion, r as PlanReminder, t as PlanningHandlers } from "./chunk-operations3.mjs";
3
- import { Ref } from "@dxos/echo";
4
3
  import { trim } from "@dxos/util";
5
4
  import * as Skill from "@dxos/compute/Skill";
6
5
  import * as Template from "@dxos/compute/Template";
7
- import * as Operation from "@dxos/compute/Operation";
8
6
  //#region src/skills/planning/PlanningSkill.ts
9
7
  var PlanningSkill_exports = /* @__PURE__ */ __exportAll({
10
8
  Handlers: () => PlanningHandlers,
11
9
  Operations: () => definitions_exports,
10
+ hooks: () => hooks,
12
11
  key: () => key,
13
12
  make: () => make
14
13
  });
@@ -29,19 +28,22 @@ var make = () => Skill.make({
29
28
  numbered list, and each line carries the task's ref.
30
29
  Track your work with update-tasks: address an existing task by its ref, set create only to
31
30
  make a new one, keep exactly one task started at a time, and mark a task done as soon as it
32
- completes. Starting a task assigns it to you.
31
+ completes. Starting a task makes you the agent working it.
33
32
  Do only what the user asked: if they name a specific task or subset, complete exactly
34
33
  that and stop — never start unrequested tasks on your own.
35
34
  A task that already exists elsewhere (a project's task, a sub-task of one you were given) is
36
35
  worked through its own ref — never recreate it with create. assign puts it on this checklist
37
- and makes you its assignee; unassign takes it off and clears the assignee, never deleting it.
38
- ` }),
39
- hooks: [{
40
- spec: { _tag: "end-request" },
41
- function: Ref.make(Operation.serialize(PlanReminder))
42
- }]
36
+ with you working it; unassign takes it off, never deleting it.
37
+ ` })
43
38
  });
39
+ /** At the end of every request, reminds the agent to keep working while its plan has open tasks. */
40
+ var hooks = [{
41
+ key: "org.dxos.hook.planning.planReminder",
42
+ event: "end-request",
43
+ skill: key,
44
+ operation: PlanReminder
45
+ }];
44
46
  //#endregion
45
- export { key as n, make as r, PlanningSkill_exports as t };
47
+ export { make as i, hooks as n, key as r, PlanningSkill_exports as t };
46
48
 
47
49
  //# sourceMappingURL=chunk-PlanningSkill.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"chunk-PlanningSkill.mjs","names":[],"sources":["../../src/skills/planning/PlanningSkill.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Operation from '@dxos/compute/Operation';\nimport * as Skill from '@dxos/compute/Skill';\nimport * as Template from '@dxos/compute/Template';\nimport { Ref } from '@dxos/echo';\nimport { trim } from '@dxos/util';\n\nimport { AskQuestion, PlanReminder, UpdateTasks } from './operations/definitions.ts';\n\nexport const key = 'org.dxos.skill.planning';\n\nexport const make = () =>\n Skill.make({\n key,\n name: 'Planning',\n description: 'Plans and tracks complex tasks using artifacts.',\n agentCanEnable: true,\n tools: Skill.toolDefinitions({ operations: [UpdateTasks, AskQuestion] }),\n instructions: Template.make({\n source: trim`\n {{! Planning }}\n\n The conversation has a durable, numbered task checklist that you cannot see directly.\n Before answering any question about tasks — or acting on a task referenced by number or\n title — read the current checklist first (call the get-agent-context tool when available;\n otherwise the update-tasks result echoes it). Ordinals like \"task 1\" refer to that\n numbered list, and each line carries the task's ref.\n Track your work with update-tasks: address an existing task by its ref, set create only to\n make a new one, keep exactly one task started at a time, and mark a task done as soon as it\n completes. Starting a task assigns it to you.\n Do only what the user asked: if they name a specific task or subset, complete exactly\n that and stop — never start unrequested tasks on your own.\n A task that already exists elsewhere (a project's task, a sub-task of one you were given) is\n worked through its own ref — never recreate it with create. assign puts it on this checklist\n and makes you its assignee; unassign takes it off and clears the assignee, never deleting it.\n `,\n }),\n // At the end of every request, remind the agent to keep working while its plan has open tasks.\n // The reminder enqueues onto the owning host (Tier B), which keeps the process alive.\n hooks: [\n {\n spec: { _tag: 'end-request' },\n function: Ref.make(Operation.serialize(PlanReminder)),\n },\n ],\n });\n\nexport { PlanningHandlers as Handlers } from './operations/index.ts';\nexport * as Operations from './operations/definitions.ts';\n"],"mappings":";;;;;;;;;;;;;;AAcA,IAAa,MAAM;AAEnB,IAAa,aACX,MAAM,KAAK;CACT;CACA,MAAM;CACN,aAAa;CACb,gBAAgB;CAChB,OAAO,MAAM,gBAAgB,EAAE,YAAY,CAAC,aAAa,WAAW,EAAE,CAAC;CACvE,cAAc,SAAS,KAAK,EAC1B,QAAQ,IAAI;;;;;;;;;;;;;;;;QAiBd,CAAC;CAGD,OAAO,CACL;EACE,MAAM,EAAE,MAAM,cAAc;EAC5B,UAAU,IAAI,KAAK,UAAU,UAAU,YAAY,CAAC;CACtD,CACF;AACF,CAAC"}
1
+ {"version":3,"file":"chunk-PlanningSkill.mjs","names":[],"sources":["../../src/skills/planning/PlanningSkill.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport type * as Hook from '@dxos/compute/Hook';\nimport * as Skill from '@dxos/compute/Skill';\nimport * as Template from '@dxos/compute/Template';\nimport { trim } from '@dxos/util';\n\nimport { AskQuestion, PlanReminder, UpdateTasks } from './operations/definitions.ts';\n\nexport const key = 'org.dxos.skill.planning';\n\nexport const make = () =>\n Skill.make({\n key,\n name: 'Planning',\n description: 'Plans and tracks complex tasks using artifacts.',\n agentCanEnable: true,\n tools: Skill.toolDefinitions({ operations: [UpdateTasks, AskQuestion] }),\n instructions: Template.make({\n source: trim`\n {{! Planning }}\n\n The conversation has a durable, numbered task checklist that you cannot see directly.\n Before answering any question about tasks — or acting on a task referenced by number or\n title — read the current checklist first (call the get-agent-context tool when available;\n otherwise the update-tasks result echoes it). Ordinals like \"task 1\" refer to that\n numbered list, and each line carries the task's ref.\n Track your work with update-tasks: address an existing task by its ref, set create only to\n make a new one, keep exactly one task started at a time, and mark a task done as soon as it\n completes. Starting a task makes you the agent working it.\n Do only what the user asked: if they name a specific task or subset, complete exactly\n that and stop — never start unrequested tasks on your own.\n A task that already exists elsewhere (a project's task, a sub-task of one you were given) is\n worked through its own ref — never recreate it with create. assign puts it on this checklist\n with you working it; unassign takes it off, never deleting it.\n `,\n }),\n });\n\n/** At the end of every request, reminds the agent to keep working while its plan has open tasks. */\nexport const hooks: Hook.Declaration[] = [\n { key: 'org.dxos.hook.planning.planReminder', event: 'end-request', skill: key, operation: PlanReminder },\n];\n\nexport { PlanningHandlers as Handlers } from './operations/index.ts';\nexport * as Operations from './operations/definitions.ts';\n"],"mappings":";;;;;;;;;;;;;AAaA,IAAa,MAAM;AAEnB,IAAa,aACX,MAAM,KAAK;CACT;CACA,MAAM;CACN,aAAa;CACb,gBAAgB;CAChB,OAAO,MAAM,gBAAgB,EAAE,YAAY,CAAC,aAAa,WAAW,EAAE,CAAC;CACvE,cAAc,SAAS,KAAK,EAC1B,QAAQ,IAAI;;;;;;;;;;;;;;;;QAiBd,CAAC;AACH,CAAC;;AAGH,IAAa,QAA4B,CACvC;CAAE,KAAK;CAAuC,OAAO;CAAe,OAAO;CAAK,WAAW;AAAa,CAC1G"}
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
2
- import { i as definitions_exports, n as EnableSkills, r as QuerySkills, t as SkillManagerHandlers } from "./chunk-operations2.mjs";
2
+ import { a as QueryOperations, c as SetMcpConnection, i as QueryMcpConnections, l as definitions_exports, n as AddMcpConnection, o as QuerySkills, r as EnableSkills, s as QueryTypes, t as SkillManagerHandlers } from "./chunk-operations2.mjs";
3
3
  import { DXN } from "@dxos/keys";
4
4
  import { trim } from "@dxos/util";
5
5
  import * as Skill from "@dxos/compute/Skill";
@@ -9,13 +9,25 @@ var SkillManagerSkill_exports = /* @__PURE__ */ __exportAll({
9
9
  Handlers: () => SkillManagerHandlers,
10
10
  Operations: () => definitions_exports,
11
11
  key: () => key,
12
- make: () => make
12
+ make: () => make,
13
+ makeForCodeMode: () => makeForCodeMode
13
14
  });
14
15
  var key = "org.dxos.skill.skillManager";
16
+ var name = "Skill Manager";
17
+ var description = "Query and enable skills, their operations, types and MCP servers in the current conversation.";
18
+ var tools = Skill.toolDefinitions({ operations: [
19
+ QuerySkills,
20
+ EnableSkills,
21
+ QueryOperations,
22
+ QueryTypes,
23
+ AddMcpConnection,
24
+ QueryMcpConnections,
25
+ SetMcpConnection
26
+ ] });
15
27
  var make = () => Skill.make({
16
28
  key,
17
- name: "Skill Manager",
18
- description: "Query and enable skills in the current conversation.",
29
+ name,
30
+ description,
19
31
  instructions: Template.make({
20
32
  source: trim`
21
33
  The list below is the current set of available skills — it is rendered fresh into this prompt,
@@ -25,13 +37,25 @@ var make = () => Skill.make({
25
37
 
26
38
  <available_skills>
27
39
  {{#each skills}}
28
- - {{key}} "{{name}}"{{#if description}} -- {{description}}{{/if}}{{#if agentCanEnable}} [agent-can-enable]{{/if}}
40
+ - {{key}} "{{name}}"{{#if description}} -- {{description}}{{/if}}{{#if enabled}} [enabled]{{/if}}{{#if agentCanEnable}} [agent-can-enable]{{/if}}
29
41
  {{/each}}
30
42
  </available_skills>
31
43
 
32
44
  NOTE: A skill's tools only appear once it is enabled. Skills already enabled in this
33
45
  conversation expose their tools to you directly — do not re-enable a skill whose tools you
34
46
  can already see.
47
+
48
+ When the task needs a tool you do not have, do not work around it with other tools: call
49
+ [query-operations] with a \`query\` describing what it does (e.g. "link task to feature"). Each
50
+ operation it returns names the skill that provides it; enable that skill. [query-types] lists
51
+ the registered types, and with \`typenames\` their fields.
52
+
53
+ Connections to services can also give you their MCP servers' tools. A space's connections are
54
+ on unless this conversation turned them off; the built-in servers Composer ships are off until
55
+ turned on. Use [query-mcp-connections] to see which are off, and [set-mcp-connection] to turn
56
+ one on when you need its tools; they are available from your next step. A connection is not a
57
+ skill, and enabling a skill does not turn its server on.
58
+ To use an MCP server the space has no connection for, add it with [add-mcp-connection].
35
59
  `,
36
60
  inputs: [{
37
61
  name: "skills",
@@ -39,9 +63,40 @@ var make = () => Skill.make({
39
63
  operation: DXN.getName(QuerySkills.meta.key)
40
64
  }]
41
65
  }),
42
- tools: Skill.toolDefinitions({ operations: [QuerySkills, EnableSkills] })
66
+ tools
67
+ });
68
+ /**
69
+ * The skill as code mode states it: the lookups and `enableSkills`, called from code, and instructions that list
70
+ * nothing. Code mode states the conversation's enabled skills beside it; these are how the model finds every other
71
+ * skill, operation and type. Its MCP connection operations are left out: they are an enabled skill's to give, as under
72
+ * tool calling, so a conversation that does not bind the Skill Manager cannot add or turn on an MCP server.
73
+ */
74
+ var makeForCodeMode = () => Skill.make({
75
+ key,
76
+ name,
77
+ description,
78
+ instructions: Template.make({ source: trim`
79
+ The skills enabled in this conversation are stated in this prompt, with their operations. Every other skill,
80
+ its operations and the workspace's types are found with the Skill Manager's operations, which the Operations
81
+ section lists with the code that calls each.
82
+
83
+ - Query skills lists the skills, each saying whether it is enabled here and whether you may enable it;
84
+ passing keys in \`keys\` gives a skill's instructions and operations.
85
+ - Query operations searches the operations of the skills you can use by what they do (\`query\`), or lists
86
+ one skill's (\`skill\`). Look an operation up by passing its key in \`keys\` before calling it: that gives
87
+ its input. Call it the way the Operations section calls the stated ones, by its \`key\` or its \`tool\` name.
88
+ - An operation whose skill is not enabled cannot be called yet. Enable the skill with Enable skills (only one
89
+ you may enable); its instructions and operations are stated from your next eval call.
90
+ - Query types searches the registered types (\`query\`); pass \`typenames\` to get their fields.
91
+ ` }),
92
+ tools: Skill.toolDefinitions({ operations: [
93
+ QuerySkills,
94
+ EnableSkills,
95
+ QueryOperations,
96
+ QueryTypes
97
+ ] })
43
98
  });
44
99
  //#endregion
45
- export { key as n, make as r, SkillManagerSkill_exports as t };
100
+ export { makeForCodeMode as i, key as n, make as r, SkillManagerSkill_exports as t };
46
101
 
47
102
  //# sourceMappingURL=chunk-SkillManagerSkill.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"chunk-SkillManagerSkill.mjs","names":[],"sources":["../../src/skills/skill-manager/SkillManagerSkill.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Skill from '@dxos/compute/Skill';\nimport * as Template from '@dxos/compute/Template';\nimport { DXN } from '@dxos/keys';\nimport { trim } from '@dxos/util';\n\nimport { EnableSkills, QuerySkills } from './operations/definitions.ts';\n\nexport const key = 'org.dxos.skill.skillManager';\n\nexport const make = () =>\n Skill.make({\n key,\n name: 'Skill Manager',\n description: 'Query and enable skills in the current conversation.',\n instructions: Template.make({\n source: trim`\n The list below is the current set of available skills — it is rendered fresh into this prompt,\n so do NOT call [query-skills] to obtain it. Call [enable-skills] directly with the keys you\n need; only skills marked [agent-can-enable] can be enabled by the agent.\n Reach for [query-skills] only to re-read the list after something has changed it.\n\n <available_skills>\n {{#each skills}}\n - {{key}} \"{{name}}\"{{#if description}} -- {{description}}{{/if}}{{#if agentCanEnable}} [agent-can-enable]{{/if}}\n {{/each}}\n </available_skills>\n\n NOTE: A skill's tools only appear once it is enabled. Skills already enabled in this\n conversation expose their tools to you directly — do not re-enable a skill whose tools you\n can already see.\n `,\n inputs: [\n {\n name: 'skills',\n kind: 'operation',\n operation: DXN.getName(QuerySkills.meta.key),\n },\n ],\n }),\n tools: Skill.toolDefinitions({ operations: [QuerySkills, EnableSkills] }),\n });\n\nexport { SkillManagerHandlers as Handlers } from './operations/index.ts';\nexport * as Operations from './operations/definitions.ts';\n"],"mappings":";;;;;;;;;;;;;AAaA,IAAa,MAAM;AAEnB,IAAa,aACX,MAAM,KAAK;CACT;CACA,MAAM;CACN,aAAa;CACb,cAAc,SAAS,KAAK;EAC1B,QAAQ,IAAI;;;;;;;;;;;;;;;;EAgBZ,QAAQ,CACN;GACE,MAAM;GACN,MAAM;GACN,WAAW,IAAI,QAAQ,YAAY,KAAK,GAAG;EAC7C,CACF;CACF,CAAC;CACD,OAAO,MAAM,gBAAgB,EAAE,YAAY,CAAC,aAAa,YAAY,EAAE,CAAC;AAC1E,CAAC"}
1
+ {"version":3,"file":"chunk-SkillManagerSkill.mjs","names":[],"sources":["../../src/skills/skill-manager/SkillManagerSkill.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Skill from '@dxos/compute/Skill';\nimport * as Template from '@dxos/compute/Template';\nimport { DXN } from '@dxos/keys';\nimport { trim } from '@dxos/util';\n\nimport {\n AddMcpConnection,\n EnableSkills,\n QueryMcpConnections,\n QueryOperations,\n QuerySkills,\n QueryTypes,\n SetMcpConnection,\n} from './operations/definitions.ts';\n\nexport const key = 'org.dxos.skill.skillManager';\n\nconst name = 'Skill Manager';\n\nconst description = 'Query and enable skills, their operations, types and MCP servers in the current conversation.';\n\nconst tools = Skill.toolDefinitions({\n operations: [\n QuerySkills,\n EnableSkills,\n QueryOperations,\n QueryTypes,\n AddMcpConnection,\n QueryMcpConnections,\n SetMcpConnection,\n ],\n});\n\nexport const make = () =>\n Skill.make({\n key,\n name,\n description,\n instructions: Template.make({\n source: trim`\n The list below is the current set of available skills — it is rendered fresh into this prompt,\n so do NOT call [query-skills] to obtain it. Call [enable-skills] directly with the keys you\n need; only skills marked [agent-can-enable] can be enabled by the agent.\n Reach for [query-skills] only to re-read the list after something has changed it.\n\n <available_skills>\n {{#each skills}}\n - {{key}} \"{{name}}\"{{#if description}} -- {{description}}{{/if}}{{#if enabled}} [enabled]{{/if}}{{#if agentCanEnable}} [agent-can-enable]{{/if}}\n {{/each}}\n </available_skills>\n\n NOTE: A skill's tools only appear once it is enabled. Skills already enabled in this\n conversation expose their tools to you directly — do not re-enable a skill whose tools you\n can already see.\n\n When the task needs a tool you do not have, do not work around it with other tools: call\n [query-operations] with a \\`query\\` describing what it does (e.g. \"link task to feature\"). Each\n operation it returns names the skill that provides it; enable that skill. [query-types] lists\n the registered types, and with \\`typenames\\` their fields.\n\n Connections to services can also give you their MCP servers' tools. A space's connections are\n on unless this conversation turned them off; the built-in servers Composer ships are off until\n turned on. Use [query-mcp-connections] to see which are off, and [set-mcp-connection] to turn\n one on when you need its tools; they are available from your next step. A connection is not a\n skill, and enabling a skill does not turn its server on.\n To use an MCP server the space has no connection for, add it with [add-mcp-connection].\n `,\n inputs: [\n {\n name: 'skills',\n kind: 'operation',\n operation: DXN.getName(QuerySkills.meta.key),\n },\n ],\n }),\n tools,\n });\n\n/**\n * The skill as code mode states it: the lookups and `enableSkills`, called from code, and instructions that list\n * nothing. Code mode states the conversation's enabled skills beside it; these are how the model finds every other\n * skill, operation and type. Its MCP connection operations are left out: they are an enabled skill's to give, as under\n * tool calling, so a conversation that does not bind the Skill Manager cannot add or turn on an MCP server.\n */\nexport const makeForCodeMode = () =>\n Skill.make({\n key,\n name,\n description,\n instructions: Template.make({\n source: trim`\n The skills enabled in this conversation are stated in this prompt, with their operations. Every other skill,\n its operations and the workspace's types are found with the Skill Manager's operations, which the Operations\n section lists with the code that calls each.\n\n - Query skills lists the skills, each saying whether it is enabled here and whether you may enable it;\n passing keys in \\`keys\\` gives a skill's instructions and operations.\n - Query operations searches the operations of the skills you can use by what they do (\\`query\\`), or lists\n one skill's (\\`skill\\`). Look an operation up by passing its key in \\`keys\\` before calling it: that gives\n its input. Call it the way the Operations section calls the stated ones, by its \\`key\\` or its \\`tool\\` name.\n - An operation whose skill is not enabled cannot be called yet. Enable the skill with Enable skills (only one\n you may enable); its instructions and operations are stated from your next eval call.\n - Query types searches the registered types (\\`query\\`); pass \\`typenames\\` to get their fields.\n `,\n }),\n tools: Skill.toolDefinitions({ operations: [QuerySkills, EnableSkills, QueryOperations, QueryTypes] }),\n });\n\nexport { SkillManagerHandlers as Handlers } from './operations/index.ts';\nexport * as Operations from './operations/definitions.ts';\n"],"mappings":";;;;;;;;;;;;;;AAqBA,IAAa,MAAM;AAEnB,IAAM,OAAO;AAEb,IAAM,cAAc;AAEpB,IAAM,QAAQ,MAAM,gBAAgB,EAClC,YAAY;CACV;CACA;CACA;CACA;CACA;CACA;CACA;AACF,EACF,CAAC;AAED,IAAa,aACX,MAAM,KAAK;CACT;CACA;CACA;CACA,cAAc,SAAS,KAAK;EAC1B,QAAQ,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4BZ,QAAQ,CACN;GACE,MAAM;GACN,MAAM;GACN,WAAW,IAAI,QAAQ,YAAY,KAAK,GAAG;EAC7C,CACF;CACF,CAAC;CACD;AACF,CAAC;;;;;;;AAQH,IAAa,wBACX,MAAM,KAAK;CACT;CACA;CACA;CACA,cAAc,SAAS,KAAK,EAC1B,QAAQ,IAAI;;;;;;;;;;;;;QAcd,CAAC;CACD,OAAO,MAAM,gBAAgB,EAAE,YAAY;EAAC;EAAa;EAAc;EAAiB;CAAU,EAAE,CAAC;AACvG,CAAC"}
@@ -22,11 +22,11 @@ var parseTaskSelectors = (args) => {
22
22
  */
23
23
  var resolveSlashCommand = (text, commands) => {
24
24
  if (!text.startsWith("/")) return;
25
- const [name, ...rest] = text.split(/\s+/);
25
+ const [name] = text.split(/\s/, 1);
26
26
  const command = commands.find((candidate) => candidate.command === name);
27
27
  return command ? {
28
28
  command,
29
- args: rest.join(" ")
29
+ args: text.slice(name.length).trim()
30
30
  } : void 0;
31
31
  };
32
32
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"chunk-SlashCommand.mjs","names":[],"sources":["../../src/commands.ts","../../src/SlashCommand.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Chat from '@dxos/assistant/Chat';\nimport * as Operation from '@dxos/compute/Operation';\nimport { type Database } from '@dxos/echo';\n\n/**\n * A deterministic prompt shortcut: a leading `/command args` line runs an operation directly, with\n * no model in the loop. The commands live with the verbs they invoke, so this module stays\n * operation-agnostic — the parse and the shape are all a prompt editor or a chat needs.\n */\nexport type SlashCommand = {\n /** Including the leading slash, e.g. `/task:run`. */\n command: string;\n /** Description surfaced in the prompt's completion list. */\n description: string;\n /** Runs the command; an Error describes correct usage, and is shown rather than thrown. */\n execute: (args: string, context: SlashCommandContext) => Promise<SlashCommandResult | Error>;\n};\n\n/** `invoke` is the caller's own invoker, so a command's effect goes through the verb itself. */\nexport type SlashCommandContext = {\n db: Database.Database;\n chat: Chat.Chat;\n invoke: OperationInvoke;\n};\n\n/** `OperationService['invokePromise']`, so the operation's input and output types survive the call. */\nexport type OperationInvoke = Operation.OperationService['invokePromise'];\n\nexport type SlashCommandResult = {\n /** One line for the transcript, so a command's effect is visible in the conversation. */\n summary?: string;\n /**\n * Prompt sent to the model after execution. Needed when the effect is driven by the supervisor\n * loop (delegation spawns on the post-turn reconcile), so the command must wake the\n * conversation; omitted when the result is already visible.\n */\n followUp?: string;\n};\n\n/** A task named by its 1-based position in the set, or by its exact title. */\nexport type TaskSelector = { ordinal: number } | { title: string };\n\n/**\n * `1 3`, `1,3`, or titles. Quoting is what makes a title unambiguous — a title is often several\n * words (`\"Draft release notes\"`) and may itself be a number (`\"123\"`), neither of which a bare\n * whitespace split can express.\n */\nexport const parseTaskSelectors = (args: string): TaskSelector[] => {\n const selectors: TaskSelector[] = [];\n // Quoted run, or a bare run of anything but whitespace and commas.\n const tokens = args.matchAll(/\"([^\"]*)\"|'([^']*)'|([^\\s,]+)/g);\n for (const [, doubleQuoted, singleQuoted, bare] of tokens) {\n const quoted = doubleQuoted ?? singleQuoted;\n if (quoted !== undefined) {\n if (quoted.length > 0) {\n selectors.push({ title: quoted });\n }\n } else if (bare !== undefined) {\n selectors.push(/^\\d+$/.test(bare) ? { ordinal: Number(bare) } : { title: bare });\n }\n }\n return selectors;\n};\n\n/**\n * Resolves a prompt into one of `commands`: `undefined` when the text is not a known command (it\n * falls through to the model).\n */\nexport const resolveSlashCommand = (\n text: string,\n commands: readonly SlashCommand[],\n): { command: SlashCommand; args: string } | undefined => {\n if (!text.startsWith('/')) {\n return undefined;\n }\n const [name, ...rest] = text.split(/\\s+/);\n const command = commands.find((candidate) => candidate.command === name);\n return command ? { command, args: rest.join(' ') } : undefined;\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nexport * from './commands.ts';\n"],"mappings":";;;;;;;AAmDA,IAAa,sBAAsB,SAAiC;CAClE,MAAM,YAA4B,CAAC;CAEnC,MAAM,SAAS,KAAK,SAAS,gCAAgC;CAC7D,KAAK,MAAM,GAAG,cAAc,cAAc,SAAS,QAAQ;EACzD,MAAM,SAAS,gBAAgB;EAC/B,IAAI,WAAW,KAAA,GACT;OAAA,OAAO,SAAS,GAClB,UAAU,KAAK,EAAE,OAAO,OAAO,CAAC;EAAA,OAE7B,IAAI,SAAS,KAAA,GAClB,UAAU,KAAK,QAAQ,KAAK,IAAI,IAAI,EAAE,SAAS,OAAO,IAAI,EAAE,IAAI,EAAE,OAAO,KAAK,CAAC;CAEnF;CACA,OAAO;AACT;;;;;AAMA,IAAa,uBACX,MACA,aACwD;CACxD,IAAI,CAAC,KAAK,WAAW,GAAG,GACtB;CAEF,MAAM,CAAC,MAAM,GAAG,QAAQ,KAAK,MAAM,KAAK;CACxC,MAAM,UAAU,SAAS,MAAM,cAAc,UAAU,YAAY,IAAI;CACvE,OAAO,UAAU;EAAE;EAAS,MAAM,KAAK,KAAK,GAAG;CAAE,IAAI,KAAA;AACvD"}
1
+ {"version":3,"file":"chunk-SlashCommand.mjs","names":[],"sources":["../../src/commands.ts","../../src/SlashCommand.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport { type AiContext } from '@dxos/assistant';\nimport * as Chat from '@dxos/assistant/Chat';\nimport * as Operation from '@dxos/compute/Operation';\nimport { type Database } from '@dxos/echo';\n\n/**\n * A deterministic prompt shortcut: a leading `/command args` line runs an operation directly, with\n * no model in the loop. The commands live with the verbs they invoke, so this module stays\n * operation-agnostic — the parse and the shape are all a prompt editor or a chat needs.\n */\nexport type SlashCommand = {\n /** Including the leading slash, e.g. `/task:run`. */\n command: string;\n /** Description surfaced in the prompt's completion list. */\n description: string;\n /** Changes only the chat object itself, so it runs on a chat not yet stored (a companion's) and leaves it unstored. */\n chatOnly?: boolean;\n /** Runs the command; an Error describes correct usage, and is shown rather than thrown. */\n execute: (args: string, context: SlashCommandContext) => Promise<SlashCommandResult | Error>;\n};\n\n/** `invoke` is the caller's own invoker, so a command's effect goes through the verb itself. */\nexport type SlashCommandContext = {\n db: Database.Database;\n chat: Chat.Chat;\n invoke: OperationInvoke;\n /** The conversation's bindings, for a command that changes what is in context (e.g. loading a skill). */\n binder?: AiContext.Binder;\n};\n\n/** `OperationService['invokePromise']`, so the operation's input and output types survive the call. */\nexport type OperationInvoke = Operation.OperationService['invokePromise'];\n\nexport type SlashCommandResult = {\n /** One line for the transcript, so a command's effect is visible in the conversation. */\n summary?: string;\n /**\n * Prompt sent to the model after execution. Needed when the effect is driven by the supervisor\n * loop (delegation spawns on the post-turn reconcile), so the command must wake the\n * conversation; omitted when the result is already visible.\n */\n followUp?: string;\n /**\n * The reader's own message, sent after the command the way a typed prompt is: queued behind a\n * running turn, its mentions bound (e.g. the text after a skill command).\n */\n prompt?: string;\n};\n\n/** A task named by its 1-based position in the set, or by its exact title. */\nexport type TaskSelector = { ordinal: number } | { title: string };\n\n/**\n * `1 3`, `1,3`, or titles. Quoting is what makes a title unambiguous — a title is often several\n * words (`\"Draft release notes\"`) and may itself be a number (`\"123\"`), neither of which a bare\n * whitespace split can express.\n */\nexport const parseTaskSelectors = (args: string): TaskSelector[] => {\n const selectors: TaskSelector[] = [];\n // Quoted run, or a bare run of anything but whitespace and commas.\n const tokens = args.matchAll(/\"([^\"]*)\"|'([^']*)'|([^\\s,]+)/g);\n for (const [, doubleQuoted, singleQuoted, bare] of tokens) {\n const quoted = doubleQuoted ?? singleQuoted;\n if (quoted !== undefined) {\n if (quoted.length > 0) {\n selectors.push({ title: quoted });\n }\n } else if (bare !== undefined) {\n selectors.push(/^\\d+$/.test(bare) ? { ordinal: Number(bare) } : { title: bare });\n }\n }\n return selectors;\n};\n\n/**\n * Resolves a prompt into one of `commands`: `undefined` when the text is not a known command (it\n * falls through to the model).\n */\nexport const resolveSlashCommand = (\n text: string,\n commands: readonly SlashCommand[],\n): { command: SlashCommand; args: string } | undefined => {\n if (!text.startsWith('/')) {\n return undefined;\n }\n const [name] = text.split(/\\s/, 1);\n const command = commands.find((candidate) => candidate.command === name);\n return command ? { command, args: text.slice(name.length).trim() } : undefined;\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nexport * from './commands.ts';\n"],"mappings":";;;;;;;AA6DA,IAAa,sBAAsB,SAAiC;CAClE,MAAM,YAA4B,CAAC;CAEnC,MAAM,SAAS,KAAK,SAAS,gCAAgC;CAC7D,KAAK,MAAM,GAAG,cAAc,cAAc,SAAS,QAAQ;EACzD,MAAM,SAAS,gBAAgB;EAC/B,IAAI,WAAW,KAAA,GACT;OAAA,OAAO,SAAS,GAClB,UAAU,KAAK,EAAE,OAAO,OAAO,CAAC;EAAA,OAE7B,IAAI,SAAS,KAAA,GAClB,UAAU,KAAK,QAAQ,KAAK,IAAI,IAAI,EAAE,SAAS,OAAO,IAAI,EAAE,IAAI,EAAE,OAAO,KAAK,CAAC;CAEnF;CACA,OAAO;AACT;;;;;AAMA,IAAa,uBACX,MACA,aACwD;CACxD,IAAI,CAAC,KAAK,WAAW,GAAG,GACtB;CAEF,MAAM,CAAC,QAAQ,KAAK,MAAM,MAAM,CAAC;CACjC,MAAM,UAAU,SAAS,MAAM,cAAc,UAAU,YAAY,IAAI;CACvE,OAAO,UAAU;EAAE;EAAS,MAAM,KAAK,MAAM,KAAK,MAAM,CAAC,CAAC,KAAK;CAAE,IAAI,KAAA;AACvE"}