@dxos/assistant-toolkit 0.14.0 → 0.16.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 (77) hide show
  1. package/dist/lib/AgentOperation.mjs +1 -55
  2. package/dist/lib/Memory.mjs +1 -19
  3. package/dist/lib/chunk-AgentOperation.mjs +55 -0
  4. package/dist/lib/chunk-AgentOperation.mjs.map +1 -0
  5. package/dist/lib/chunk-AgentOperationHandlerSet.mjs +8 -0
  6. package/dist/lib/chunk-AgentOperationHandlerSet.mjs.map +1 -0
  7. package/dist/lib/chunk-AgentSkill.mjs +46 -0
  8. package/dist/lib/chunk-AgentSkill.mjs.map +1 -0
  9. package/dist/lib/chunk-AlarmSkill.mjs +31 -0
  10. package/dist/lib/chunk-AlarmSkill.mjs.map +1 -0
  11. package/dist/lib/chunk-AutomationSkill.mjs +100 -0
  12. package/dist/lib/chunk-AutomationSkill.mjs.map +1 -0
  13. package/dist/lib/chunk-BrowserSkill.mjs +30 -0
  14. package/dist/lib/chunk-BrowserSkill.mjs.map +1 -0
  15. package/dist/lib/chunk-ChatContextSkill.mjs +31 -0
  16. package/dist/lib/chunk-ChatContextSkill.mjs.map +1 -0
  17. package/dist/lib/chunk-DelegationSkill.mjs +32 -0
  18. package/dist/lib/chunk-DelegationSkill.mjs.map +1 -0
  19. package/dist/lib/chunk-DelegationStrategy.mjs +2 -2
  20. package/dist/lib/chunk-DelegationStrategy.mjs.map +1 -1
  21. package/dist/lib/chunk-Memory.mjs +19 -0
  22. package/dist/lib/chunk-Memory.mjs.map +1 -0
  23. package/dist/lib/chunk-MemorySkill.mjs +39 -0
  24. package/dist/lib/chunk-MemorySkill.mjs.map +1 -0
  25. package/dist/lib/chunk-PlanningSkill.mjs +47 -0
  26. package/dist/lib/chunk-PlanningSkill.mjs.map +1 -0
  27. package/dist/lib/chunk-SkillManagerSkill.mjs +47 -0
  28. package/dist/lib/chunk-SkillManagerSkill.mjs.map +1 -0
  29. package/dist/lib/chunk-SlashCommand.mjs +41 -0
  30. package/dist/lib/{ns/SlashCommand.mjs.map → chunk-SlashCommand.mjs.map} +1 -1
  31. package/dist/lib/chunk-WebSearchSkill.mjs.map +1 -1
  32. package/dist/lib/chunk-operations.mjs.map +1 -1
  33. package/dist/lib/chunk-operations2.mjs.map +1 -1
  34. package/dist/lib/chunk-operations3.mjs.map +1 -1
  35. package/dist/lib/chunk-operations4.mjs +1 -1
  36. package/dist/lib/chunk-operations4.mjs.map +1 -1
  37. package/dist/lib/chunk-operations5.mjs.map +1 -1
  38. package/dist/lib/chunk-operations7.mjs.map +1 -1
  39. package/dist/lib/chunk-operations8.mjs +1 -1
  40. package/dist/lib/chunk-query.mjs +1 -1
  41. package/dist/lib/chunk-query.mjs.map +1 -1
  42. package/dist/lib/chunk-run-instructions.mjs +1 -1
  43. package/dist/lib/chunk-run-instructions.mjs.map +1 -1
  44. package/dist/lib/chunk-save.mjs +1 -1
  45. package/dist/lib/chunk-save.mjs.map +1 -1
  46. package/dist/lib/index.mjs +13 -13
  47. package/dist/lib/ns/AgentOperationHandlerSet.mjs +2 -8
  48. package/dist/lib/ns/AgentSkill.mjs +2 -45
  49. package/dist/lib/ns/AlarmSkill.mjs +3 -31
  50. package/dist/lib/ns/AutomationSkill.mjs +1 -100
  51. package/dist/lib/ns/BrowserSkill.mjs +1 -30
  52. package/dist/lib/ns/ChatContextSkill.mjs +3 -31
  53. package/dist/lib/ns/DelegationSkill.mjs +3 -32
  54. package/dist/lib/ns/DelegationStrategy.mjs +1 -2
  55. package/dist/lib/ns/MemorySkill.mjs +3 -39
  56. package/dist/lib/ns/PlanningSkill.mjs +3 -47
  57. package/dist/lib/ns/SkillManagerSkill.mjs +3 -47
  58. package/dist/lib/ns/SlashCommand.mjs +1 -41
  59. package/dist/lib/ns/WebSearchSkill.mjs +1 -2
  60. package/dist/lib/testing.mjs +1 -1
  61. package/dist/lib/testing.mjs.map +1 -1
  62. package/dist/types/src/skills/agent/operations/definitions.d.ts +1 -0
  63. package/dist/types/src/skills/agent/operations/definitions.d.ts.map +1 -1
  64. package/dist/types/tsconfig.tsbuildinfo +1 -1
  65. package/package.json +28 -28
  66. package/dist/lib/AgentOperation.mjs.map +0 -1
  67. package/dist/lib/Memory.mjs.map +0 -1
  68. package/dist/lib/ns/AgentOperationHandlerSet.mjs.map +0 -1
  69. package/dist/lib/ns/AgentSkill.mjs.map +0 -1
  70. package/dist/lib/ns/AlarmSkill.mjs.map +0 -1
  71. package/dist/lib/ns/AutomationSkill.mjs.map +0 -1
  72. package/dist/lib/ns/BrowserSkill.mjs.map +0 -1
  73. package/dist/lib/ns/ChatContextSkill.mjs.map +0 -1
  74. package/dist/lib/ns/DelegationSkill.mjs.map +0 -1
  75. package/dist/lib/ns/MemorySkill.mjs.map +0 -1
  76. package/dist/lib/ns/PlanningSkill.mjs.map +0 -1
  77. package/dist/lib/ns/SkillManagerSkill.mjs.map +0 -1
@@ -1,55 +1 @@
1
- import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
2
- import * as Chat from "@dxos/assistant/Chat";
3
- import * as Instructions from "@dxos/compute/Instructions";
4
- import { Database, Feed, Ref, Registry } from "@dxos/echo";
5
- import { DXN as DXN$1 } from "@dxos/keys";
6
- import * as Schema from "effect/Schema";
7
- import * as Operation from "@dxos/compute/Operation";
8
- import { AiService, OpaqueToolkit } from "@dxos/ai";
9
- import * as Trace from "@dxos/compute/Trace";
10
- import { Text } from "@dxos/schema";
11
- //#region src/types/AgentOperation.ts
12
- var AgentOperation_exports = /* @__PURE__ */ __exportAll({ RunInstructions: () => RunInstructions });
13
- var RunInstructions = Operation.make({
14
- meta: {
15
- key: DXN$1.make("org.dxos.operation.assistantToolkit.runInstructions"),
16
- name: "Run Instructions",
17
- description: "Agentic worker that executes a provided prompt using skills and tools.",
18
- icon: "ph--brain--regular"
19
- },
20
- input: Schema.Struct({
21
- instructions: Ref.Ref(Instructions.Instructions),
22
- /**
23
- * Input object or data.
24
- * References get auto-resolved.
25
- */
26
- input: Schema.Any.pipe(Schema.annotate({ title: "Input" })),
27
- /**
28
- * When set, runs in this chat (history, queue, and bound context). Routine skills and context objects are merged into the conversation for this request.
29
- */
30
- chat: Schema.optional(Ref.Ref(Chat.Chat)),
31
- /**
32
- * @default `dxn:com.anthropic.model.claude-opus-5.default`.
33
- */
34
- model: Schema.optional(DXN$1.Schema),
35
- systemInstructions: Schema.optional(Schema.String).annotate({ description: "Additional system instructions to add to the system prompt." })
36
- }),
37
- output: Schema.Any,
38
- types: [
39
- Instructions.Instructions,
40
- Text.Text,
41
- Feed.Feed,
42
- Chat.Chat
43
- ],
44
- services: [
45
- AiService.AiService,
46
- Database.Service,
47
- OpaqueToolkit.OpaqueToolkitProvider,
48
- Registry.Service,
49
- Trace.TraceService
50
- ]
51
- });
52
- //#endregion
53
- export { RunInstructions, AgentOperation_exports as t };
54
-
55
- //# sourceMappingURL=AgentOperation.mjs.map
1
+ export { n as RunInstructions } from "./chunk-AgentOperation.mjs";
@@ -1,19 +1 @@
1
- import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
2
- import { Annotation, DXN, Type } from "@dxos/echo";
3
- import * as Schema from "effect/Schema";
4
- //#region src/types/Memory.ts
5
- var Memory_exports = /* @__PURE__ */ __exportAll({ Memory: () => Memory });
6
- /**
7
- * Unit of knowledge generated by an agent.
8
- */
9
- var Memory = class extends Type.makeObject(DXN.make("org.dxos.type.memory", "0.1.0"))(Schema.Struct({
10
- title: Schema.String,
11
- content: Schema.String
12
- }).pipe(Annotation.LabelAnnotation.set(["title"]), Annotation.IconAnnotation.set({
13
- icon: "ph--brain--regular",
14
- hue: "pink"
15
- }))) {};
16
- //#endregion
17
- export { Memory, Memory_exports as t };
18
-
19
- //# sourceMappingURL=Memory.mjs.map
1
+ export { t as Memory } from "./chunk-Memory.mjs";
@@ -0,0 +1,55 @@
1
+ import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
2
+ import * as Chat from "@dxos/assistant/Chat";
3
+ import * as Instructions from "@dxos/compute/Instructions";
4
+ import { Database, Feed, Ref, Registry } from "@dxos/echo";
5
+ import { DXN as DXN$1 } from "@dxos/keys";
6
+ import * as Schema from "effect/Schema";
7
+ import * as Operation from "@dxos/compute/Operation";
8
+ import { AiService, OpaqueToolkit } from "@dxos/ai";
9
+ import * as Trace from "@dxos/compute/Trace";
10
+ import { Text } from "@dxos/schema";
11
+ //#region src/types/AgentOperation.ts
12
+ var AgentOperation_exports = /* @__PURE__ */ __exportAll({ RunInstructions: () => RunInstructions });
13
+ var RunInstructions = Operation.make({
14
+ meta: {
15
+ key: DXN$1.make("org.dxos.operation.assistantToolkit.runInstructions"),
16
+ name: "Run Instructions",
17
+ description: "Agentic worker that executes a provided prompt using skills and tools.",
18
+ icon: "ph--brain--regular"
19
+ },
20
+ input: Schema.Struct({
21
+ instructions: Ref.Ref(Instructions.Instructions),
22
+ /**
23
+ * Input object or data.
24
+ * References get auto-resolved.
25
+ */
26
+ input: Schema.Any.pipe(Schema.annotate({ title: "Input" })),
27
+ /**
28
+ * When set, runs in this chat (history, queue, and bound context). Routine skills and context objects are merged into the conversation for this request.
29
+ */
30
+ chat: Schema.optional(Ref.Ref(Chat.Chat)),
31
+ /**
32
+ * @default `dxn:com.anthropic.model.claude-opus-5.default`.
33
+ */
34
+ model: Schema.optional(DXN$1.Schema),
35
+ systemInstructions: Schema.optional(Schema.String).annotate({ description: "Additional system instructions to add to the system prompt." })
36
+ }),
37
+ output: Schema.Any,
38
+ types: [
39
+ Instructions.Instructions,
40
+ Text.Text,
41
+ Feed.Feed,
42
+ Chat.Chat
43
+ ],
44
+ services: [
45
+ AiService.AiService,
46
+ Database.Service,
47
+ OpaqueToolkit.OpaqueToolkitProvider,
48
+ Registry.Service,
49
+ Trace.TraceService
50
+ ]
51
+ });
52
+ //#endregion
53
+ export { RunInstructions as n, AgentOperation_exports as t };
54
+
55
+ //# sourceMappingURL=chunk-AgentOperation.mjs.map
@@ -0,0 +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"}
@@ -0,0 +1,8 @@
1
+ import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
2
+ import { t as AgentHandlers } from "./chunk-operations8.mjs";
3
+ //#region src/AgentOperationHandlerSet.ts
4
+ var AgentOperationHandlerSet_exports = /* @__PURE__ */ __exportAll({ handlers: () => AgentHandlers });
5
+ //#endregion
6
+ export { AgentOperationHandlerSet_exports as t };
7
+
8
+ //# sourceMappingURL=chunk-AgentOperationHandlerSet.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-AgentOperationHandlerSet.mjs","names":[],"sources":["../../src/AgentOperationHandlerSet.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nexport { AgentHandlers as handlers } from './operations/index.ts';\n"],"mappings":""}
@@ -0,0 +1,46 @@
1
+ import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
2
+ import { a as definitions_exports, t as AgentSkillHandlers } from "./chunk-operations7.mjs";
3
+ import { trim } from "@dxos/util";
4
+ import * as Skill from "@dxos/compute/Skill";
5
+ import * as Template from "@dxos/compute/Template";
6
+ //#region src/skills/agent/AgentSkill.ts
7
+ var AgentSkill_exports = /* @__PURE__ */ __exportAll({
8
+ Handlers: () => AgentSkillHandlers,
9
+ Operations: () => definitions_exports,
10
+ key: () => key,
11
+ make: () => make
12
+ });
13
+ var key = "org.dxos.skill.agent";
14
+ /**
15
+ * Creates the Agent skill. This is a function to avoid circular dependency issues.
16
+ */
17
+ var make = () => Skill.make({
18
+ key,
19
+ name: "Agent skill",
20
+ instructions: Template.make({
21
+ source: trim`
22
+ You work on an agent. Each agent has instructions - the goal of the agent.
23
+ The agent plan shows the current progress of the agent.
24
+
25
+ {{#with agent}}
26
+ <agent id="{{id}}" name="{{name}}">
27
+ <instructions>
28
+ {{instructions}}
29
+ </instructions>
30
+ <plan>
31
+ {{plan}}
32
+ </plan>
33
+ </agent>
34
+ {{/with}}
35
+ `,
36
+ inputs: [{
37
+ name: "agent",
38
+ kind: "operation",
39
+ operation: "org.dxos.operation.assistantToolkit.getContext"
40
+ }]
41
+ })
42
+ });
43
+ //#endregion
44
+ export { key as n, make as r, AgentSkill_exports as t };
45
+
46
+ //# sourceMappingURL=chunk-AgentSkill.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-AgentSkill.mjs","names":[],"sources":["../../src/skills/agent/AgentSkill.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\nexport const key = 'org.dxos.skill.agent';\n\n/**\n * Creates the Agent skill. This is a function to avoid circular dependency issues.\n */\nexport const make = () =>\n Skill.make({\n key,\n name: 'Agent skill',\n instructions: Template.make({\n source: trim`\n You work on an agent. Each agent has instructions - the goal of the agent.\n The agent plan shows the current progress of the agent.\n\n {{#with agent}}\n <agent id=\"{{id}}\" name=\"{{name}}\">\n <instructions>\n {{instructions}}\n </instructions>\n <plan>\n {{plan}}\n </plan>\n </agent>\n {{/with}}\n `,\n inputs: [\n {\n name: 'agent',\n kind: 'operation',\n operation: 'org.dxos.operation.assistantToolkit.getContext',\n },\n ],\n }),\n });\n\nexport { AgentSkillHandlers as Handlers } from './operations/index.ts';\nexport * as Operations from './operations/definitions.ts';\n"],"mappings":";;;;;;;;;;;;AAUA,IAAa,MAAM;;;;AAKnB,IAAa,aACX,MAAM,KAAK;CACT;CACA,MAAM;CACN,cAAc,SAAS,KAAK;EAC1B,QAAQ,IAAI;;;;;;;;;;;;;;;EAeZ,QAAQ,CACN;GACE,MAAM;GACN,MAAM;GACN,WAAW;EACb,CACF;CACF,CAAC;AACH,CAAC"}
@@ -0,0 +1,31 @@
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";
3
+ import { Ref } from "@dxos/echo";
4
+ import { trim } from "@dxos/util";
5
+ import * as Skill from "@dxos/compute/Skill";
6
+ import { Text } from "@dxos/schema";
7
+ //#region src/skills/alarm/AlarmSkill.ts
8
+ var AlarmSkill_exports = /* @__PURE__ */ __exportAll({
9
+ Handlers: () => AlarmHandlers,
10
+ Operations: () => definitions_exports,
11
+ key: () => key,
12
+ make: () => make
13
+ });
14
+ var key = "org.dxos.skill.alarm";
15
+ var instructions = trim`
16
+ You can schedule an alarm to wake yourself up in the future and continue working.
17
+ When the alarm fires you receive a prompt carrying any reminder you set.
18
+ Read the current time before computing an absolute wake time.
19
+ `;
20
+ var make = () => Skill.make({
21
+ key,
22
+ name: "Alarm",
23
+ description: "Schedule a self-wake and inspect the current time.",
24
+ agentCanEnable: true,
25
+ instructions: { source: Ref.make(Text.make({ content: instructions })) },
26
+ tools: Skill.toolDefinitions({ operations: [SetAlarm, GetCurrentDate] })
27
+ });
28
+ //#endregion
29
+ export { key as n, make as r, AlarmSkill_exports as t };
30
+
31
+ //# sourceMappingURL=chunk-AlarmSkill.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-AlarmSkill.mjs","names":[],"sources":["../../src/skills/alarm/AlarmSkill.ts"],"sourcesContent":["//\n// Copyright 2026 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\nimport { GetCurrentDate, SetAlarm } from './operations/definitions.ts';\n\nexport const key = 'org.dxos.skill.alarm';\n\nconst instructions = trim`\n You can schedule an alarm to wake yourself up in the future and continue working.\n When the alarm fires you receive a prompt carrying any reminder you set.\n Read the current time before computing an absolute wake time.\n`;\n\nexport const make = () =>\n Skill.make({\n key,\n name: 'Alarm',\n description: 'Schedule a self-wake and inspect the current time.',\n agentCanEnable: true,\n instructions: {\n source: Ref.make(Text.make({ content: instructions })),\n },\n tools: Skill.toolDefinitions({ operations: [SetAlarm, GetCurrentDate] }),\n });\n\nexport { AlarmHandlers as Handlers } from './operations/index.ts';\nexport * as Operations from './operations/definitions.ts';\n"],"mappings":";;;;;;;;;;;;;AAaA,IAAa,MAAM;AAEnB,IAAM,eAAe,IAAI;;;;;AAMzB,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,OAAO,MAAM,gBAAgB,EAAE,YAAY,CAAC,UAAU,cAAc,EAAE,CAAC;AACzE,CAAC"}
@@ -0,0 +1,100 @@
1
+ import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
2
+ import { Ref, Type } from "@dxos/echo";
3
+ import { trim } from "@dxos/util";
4
+ import * as Skill from "@dxos/compute/Skill";
5
+ import * as Operation from "@dxos/compute/Operation";
6
+ import { Text } from "@dxos/schema";
7
+ import * as Trigger from "@dxos/compute/Trigger";
8
+ //#region src/skills/automation/AutomationSkill.ts
9
+ var AutomationSkill_exports = /* @__PURE__ */ __exportAll({
10
+ key: () => key,
11
+ make: () => make
12
+ });
13
+ var key = "org.dxos.skill.automation";
14
+ var instructions = trim`
15
+ Automation allows you to automatically initiate actions based on events.
16
+ Automations are configured by creating a trigger that references a function.
17
+ Whenever event that matches the trigger occurs, the function is invoked.
18
+
19
+ ## Configuration
20
+
21
+ Triggers are configured by the properties of the Trigger object.
22
+ - enabled: Must be true for trigger to run.
23
+ - spec: Events that the trigger matches.
24
+ - function: Ref to a ${Type.getTypename(Operation.PersistentOperation)} object that will be invoked. Query the functions present in the space first, and reference them in the trigger.
25
+ - input: The spec of the input data that will be passed to the function.
26
+
27
+ ## Input patterns
28
+
29
+ Input to the invoked function is defined by the input property of the Trigger object.
30
+ It's an object that supports constants or template strings.
31
+
32
+ Example:
33
+
34
+ {
35
+ item: '{{event.item}}',
36
+ instructions: 'Summarize and perform entity-extraction'
37
+ mailbox: { '/': 'echo://AAA/ZZZ' }
38
+ }
39
+
40
+ ## Trigger kinds
41
+
42
+ - Timer: Triggered by a cron schedule.
43
+ - Queue: Subscribes and processes items begginging to end.
44
+ Note: queues are the same as feeds. The queue EID should be of form: echo://<space-id>/<queue-id>.
45
+ - Subscription: Subscribes and processes database items based on a query.
46
+
47
+ Avoid: email and webhook triggers.
48
+
49
+ ## Editing triggers
50
+
51
+ Triggers are represented as objects of type ${Type.getTypename(Trigger.Trigger)}.
52
+ You need access to the Database skill to manipulate triggers.
53
+ Read trigger schema before manipulating triggers.
54
+ Having a Trigger object in the database is enough to setup an automation.
55
+
56
+ ## Examples
57
+
58
+ Timer:
59
+
60
+ {
61
+ "function": { "/": "echo://AAA/ZZZ" },
62
+ "enabled": true,
63
+ "spec": {
64
+ "kind": "timer",
65
+ "cron": "*/5 * * * *"
66
+ }
67
+ }
68
+
69
+ Queue:
70
+
71
+ {
72
+ "function": { "/": "echo://AAA/ZZZ" },
73
+ "enabled": true,
74
+ "spec": {
75
+ "kind": "queue",
76
+ "queue": "echo://XXX/YYY"
77
+ }
78
+ }
79
+
80
+ Subscription:
81
+
82
+ {
83
+ "function": { "/": "echo://AAA/ZZZ" },
84
+ "enabled": true,
85
+ "spec": {
86
+ "kind": "subscription",
87
+ "query": { "ast": { "type": "select", "filter": { "type": "object", "typename": "dxn:org.dxos.type.person" } } }
88
+ }
89
+ }
90
+ `;
91
+ var make = () => Skill.make({
92
+ key,
93
+ name: "Triggers",
94
+ description: "Trigger management and automation.",
95
+ instructions: { source: Ref.make(Text.make({ content: instructions })) }
96
+ });
97
+ //#endregion
98
+ export { key as n, make as r, AutomationSkill_exports as t };
99
+
100
+ //# sourceMappingURL=chunk-AutomationSkill.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-AutomationSkill.mjs","names":[],"sources":["../../src/skills/automation/AutomationSkill.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 Trigger from '@dxos/compute/Trigger';\nimport { Ref, Type } from '@dxos/echo';\nimport { Text } from '@dxos/schema';\nimport { trim } from '@dxos/util';\n\nexport const key = 'org.dxos.skill.automation';\n\nconst instructions = trim`\n Automation allows you to automatically initiate actions based on events.\n Automations are configured by creating a trigger that references a function.\n Whenever event that matches the trigger occurs, the function is invoked.\n\n ## Configuration\n\n Triggers are configured by the properties of the Trigger object.\n - enabled: Must be true for trigger to run.\n - spec: Events that the trigger matches.\n - function: Ref to a ${Type.getTypename(Operation.PersistentOperation)} object that will be invoked. Query the functions present in the space first, and reference them in the trigger.\n - input: The spec of the input data that will be passed to the function.\n\n ## Input patterns\n\n Input to the invoked function is defined by the input property of the Trigger object.\n It's an object that supports constants or template strings.\n\n Example:\n\n {\n item: '{{event.item}}',\n instructions: 'Summarize and perform entity-extraction'\n mailbox: { '/': 'echo://AAA/ZZZ' }\n }\n\n ## Trigger kinds\n\n - Timer: Triggered by a cron schedule.\n - Queue: Subscribes and processes items begginging to end.\n Note: queues are the same as feeds. The queue EID should be of form: echo://<space-id>/<queue-id>.\n - Subscription: Subscribes and processes database items based on a query.\n\n Avoid: email and webhook triggers.\n\n ## Editing triggers\n\n Triggers are represented as objects of type ${Type.getTypename(Trigger.Trigger)}.\n You need access to the Database skill to manipulate triggers.\n Read trigger schema before manipulating triggers.\n Having a Trigger object in the database is enough to setup an automation. \n\n ## Examples\n\n Timer:\n\n {\n \"function\": { \"/\": \"echo://AAA/ZZZ\" },\n \"enabled\": true,\n \"spec\": {\n \"kind\": \"timer\",\n \"cron\": \"*/5 * * * *\"\n }\n }\n\n Queue:\n\n {\n \"function\": { \"/\": \"echo://AAA/ZZZ\" },\n \"enabled\": true,\n \"spec\": {\n \"kind\": \"queue\",\n \"queue\": \"echo://XXX/YYY\"\n }\n }\n\n Subscription:\n\n {\n \"function\": { \"/\": \"echo://AAA/ZZZ\" },\n \"enabled\": true,\n \"spec\": {\n \"kind\": \"subscription\",\n \"query\": { \"ast\": { \"type\": \"select\", \"filter\": { \"type\": \"object\", \"typename\": \"dxn:org.dxos.type.person\" } } }\n }\n }\n`;\n\nexport const make = () =>\n Skill.make({\n key,\n name: 'Triggers',\n description: 'Trigger management and automation.',\n instructions: {\n source: Ref.make(Text.make({ content: instructions })),\n },\n });\n"],"mappings":";;;;;;;;;;;;AAaA,IAAa,MAAM;AAEnB,IAAM,eAAe,IAAI;;;;;;;;;;yBAUA,KAAK,YAAY,UAAU,mBAAmB,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;gDA2BzB,KAAK,YAAY,QAAQ,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyClF,IAAa,aACX,MAAM,KAAK;CACT;CACA,MAAM;CACN,aAAa;CACb,cAAc,EACZ,QAAQ,IAAI,KAAK,KAAK,KAAK,EAAE,SAAS,aAAa,CAAC,CAAC,EACvD;AACF,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
2
+ import { Ref } from "@dxos/echo";
3
+ import { trim } from "@dxos/util";
4
+ import * as Skill from "@dxos/compute/Skill";
5
+ import { Text } from "@dxos/schema";
6
+ //#region src/skills/browser/BrowserSkill.ts
7
+ var BrowserSkill_exports = /* @__PURE__ */ __exportAll({
8
+ key: () => key,
9
+ make: () => make
10
+ });
11
+ var key = "org.dxos.skill.browser";
12
+ var instructions = trim`
13
+ You are able to connect and use a virtual browser with persistent session.
14
+ Browser tools are provided via MCP.
15
+ `;
16
+ var make = () => Skill.make({
17
+ key,
18
+ name: "Browser",
19
+ description: "Access to a real isolated browser.",
20
+ 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
+ }]
26
+ });
27
+ //#endregion
28
+ export { key as n, make as r, BrowserSkill_exports as t };
29
+
30
+ //# sourceMappingURL=chunk-BrowserSkill.mjs.map
@@ -0,0 +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"}
@@ -0,0 +1,31 @@
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";
3
+ import { Ref } from "@dxos/echo";
4
+ import { trim } from "@dxos/util";
5
+ import * as Skill from "@dxos/compute/Skill";
6
+ import { Text } from "@dxos/schema";
7
+ //#region src/skills/chat-context/ChatContextSkill.ts
8
+ var ChatContextSkill_exports = /* @__PURE__ */ __exportAll({
9
+ Handlers: () => ChatContextHandlers,
10
+ Operations: () => definitions_exports,
11
+ key: () => key,
12
+ make: () => make
13
+ });
14
+ var key = "org.dxos.skill.chatContext";
15
+ var instructions = trim`
16
+ You can bind objects into the chat's context so later turns can see them, and unbind them again.
17
+ Reading and writing the objects themselves — including types, relations and tags — is the
18
+ Database skill's job (plugin-space).
19
+ `;
20
+ var make = () => Skill.make({
21
+ key,
22
+ name: "Chat context",
23
+ description: "Bind objects into the chat's context, and unbind them.",
24
+ agentCanEnable: true,
25
+ instructions: { source: Ref.make(Text.make({ content: instructions })) },
26
+ tools: Skill.toolDefinitions({ operations: [ContextAdd, ContextRemove] })
27
+ });
28
+ //#endregion
29
+ export { key as n, make as r, ChatContextSkill_exports as t };
30
+
31
+ //# sourceMappingURL=chunk-ChatContextSkill.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-ChatContextSkill.mjs","names":[],"sources":["../../src/skills/chat-context/ChatContextSkill.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\nimport { ContextAdd, ContextRemove } from './operations/definitions.ts';\n\nexport const key = 'org.dxos.skill.chatContext';\n\nconst instructions = trim`\n You can bind objects into the chat's context so later turns can see them, and unbind them again.\n Reading and writing the objects themselves — including types, relations and tags — is the\n Database skill's job (plugin-space).\n`;\n\nexport const make = () =>\n Skill.make({\n key,\n name: 'Chat context',\n description: \"Bind objects into the chat's context, and unbind them.\",\n agentCanEnable: true,\n instructions: {\n source: Ref.make(Text.make({ content: instructions })),\n },\n tools: Skill.toolDefinitions({\n operations: [ContextAdd, ContextRemove],\n }),\n });\n\nexport { ChatContextHandlers as Handlers } from './operations/index.ts';\nexport * as Operations from './operations/definitions.ts';\n"],"mappings":";;;;;;;;;;;;;AAaA,IAAa,MAAM;AAEnB,IAAM,eAAe,IAAI;;;;;AAMzB,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,OAAO,MAAM,gBAAgB,EAC3B,YAAY,CAAC,YAAY,aAAa,EACxC,CAAC;AACH,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
2
+ import { i as definitions_exports, n as DelegateTask, r as DelegateTasks, t as DelegationSkillHandlers } from "./chunk-operations.mjs";
3
+ import { trim } from "@dxos/util";
4
+ import * as Skill from "@dxos/compute/Skill";
5
+ import * as Template from "@dxos/compute/Template";
6
+ //#region src/skills/delegation/DelegationSkill.ts
7
+ var DelegationSkill_exports = /* @__PURE__ */ __exportAll({
8
+ Handlers: () => DelegationSkillHandlers,
9
+ Operations: () => definitions_exports,
10
+ key: () => key,
11
+ make: () => make
12
+ });
13
+ var key = "org.dxos.skill.delegation";
14
+ var make = () => Skill.make({
15
+ key,
16
+ name: "Delegation",
17
+ description: "Delegates work to sub-agents and tracks it as plan tasks.",
18
+ tools: Skill.toolDefinitions({ operations: [DelegateTask, DelegateTasks] }),
19
+ instructions: Template.make({ source: trim`
20
+ {{! Delegation }}
21
+
22
+ Delegate existing checklist tasks with the delegate-tasks tool, selecting by 1-based
23
+ ordinal or exact title; delegate-task creates a NEW task from a title. When unsure what
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.
27
+ ` })
28
+ });
29
+ //#endregion
30
+ export { key as n, make as r, DelegationSkill_exports as t };
31
+
32
+ //# sourceMappingURL=chunk-DelegationSkill.mjs.map
@@ -0,0 +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,7 +1,7 @@
1
1
  import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
2
2
  import { n as ToolkitError } from "./chunk-errors.mjs";
3
- import { key } from "./ns/DelegationSkill.mjs";
4
- import { RunInstructions } from "./AgentOperation.mjs";
3
+ import { n as key } from "./chunk-DelegationSkill.mjs";
4
+ 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";
@@ -1 +1 @@
1
- {"version":3,"file":"chunk-DelegationStrategy.mjs","names":[],"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,EAAA,CACI,QAAQ,OAAqB,OAAO,OAAO,QAAQ;AAChE;;;;;;;AAQA,IAAa,kBAAkB,SAC7B,KAAK,UAAU,SAAS,eAAe,KAAK,SAAS,YAAY,KAAA;;;;;;;;AASnE,IAAM,oBACJ,MACA,cAEA,OAAO,IAAI,aAAa;CACtB,MAAM,QAAQ,OAAO,KAAK,UAAU,IAAI;CAExC,OAAO,MAAM,QACV,SACC,eAAe,IAAI,MA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AK,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 } 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/deleg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2
+ import { Annotation, DXN, Type } from "@dxos/echo";
3
+ import * as Schema from "effect/Schema";
4
+ //#region src/types/Memory.ts
5
+ var Memory_exports = /* @__PURE__ */ __exportAll({ Memory: () => Memory });
6
+ /**
7
+ * Unit of knowledge generated by an agent.
8
+ */
9
+ var Memory = class extends Type.makeObject(DXN.make("org.dxos.type.memory", "0.1.0"))(Schema.Struct({
10
+ title: Schema.String,
11
+ content: Schema.String
12
+ }).pipe(Annotation.LabelAnnotation.set(["title"]), Annotation.IconAnnotation.set({
13
+ icon: "ph--brain--regular",
14
+ hue: "pink"
15
+ }))) {};
16
+ //#endregion
17
+ export { Memory_exports as n, Memory as t };
18
+
19
+ //# sourceMappingURL=chunk-Memory.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-Memory.mjs","names":[],"sources":["../../src/types/Memory.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Schema from 'effect/Schema';\n\nimport { Annotation, DXN, Type } from '@dxos/echo';\n\n/**\n * Unit of knowledge generated by an agent.\n */\nexport class Memory extends Type.makeObject<Memory>(DXN.make('org.dxos.type.memory', '0.1.0'))(\n Schema.Struct({\n title: Schema.String,\n content: Schema.String,\n }).pipe(\n Annotation.LabelAnnotation.set(['title']),\n Annotation.IconAnnotation.set({ icon: 'ph--brain--regular', hue: 'pink' }),\n ),\n) {}\n"],"mappings":";;;;;;;;AAaA,IAAa,SAAb,cAA4B,KAAK,WAAmB,IAAI,KAAK,wBAAwB,OAAO,CAAC,CAAC,CAC5F,OAAO,OAAO;CACZ,OAAO,OAAO;CACd,SAAS,OAAO;AAClB,CAAC,CAAC,CAAC,KACD,WAAW,gBAAgB,IAAI,CAAC,OAAO,CAAC,GACxC,WAAW,eAAe,IAAI;CAAE,MAAM;CAAsB,KAAK;AAAO,CAAC,CAC3E,CACF,CAAC,CAAC,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
2
+ import { a as definitions_exports, i as SaveMemory, n as DeleteMemory, r as QueryMemories, t as MemoryHandlers } from "./chunk-operations4.mjs";
3
+ import { Ref } from "@dxos/echo";
4
+ import { trim } from "@dxos/util";
5
+ import * as Skill from "@dxos/compute/Skill";
6
+ import { Text } from "@dxos/schema";
7
+ //#region src/skills/memory/MemorySkill.ts
8
+ var MemorySkill_exports = /* @__PURE__ */ __exportAll({
9
+ Handlers: () => MemoryHandlers,
10
+ Operations: () => definitions_exports,
11
+ key: () => key,
12
+ make: () => make
13
+ });
14
+ var key = "org.dxos.skill.memory";
15
+ var instructions = trim`
16
+ You have the ability to save and recall memories.
17
+ Memories are persistent knowledge units stored in the database.
18
+ Use memories to remember facts, user preferences, decisions, and any knowledge that should persist across conversations.
19
+
20
+ When the user asks you to remember something, save it as a memory with a descriptive title.
21
+ When the user asks about something you might have stored, query your memories first.
22
+ You can also delete outdated or incorrect memories.
23
+ `;
24
+ var make = () => Skill.make({
25
+ key,
26
+ name: "Memory",
27
+ description: "Persistent memory storage and retrieval.",
28
+ agentCanEnable: true,
29
+ instructions: { source: Ref.make(Text.make({ content: instructions })) },
30
+ tools: Skill.toolDefinitions({ operations: [
31
+ SaveMemory,
32
+ QueryMemories,
33
+ DeleteMemory
34
+ ] })
35
+ });
36
+ //#endregion
37
+ export { key as n, make as r, MemorySkill_exports as t };
38
+
39
+ //# sourceMappingURL=chunk-MemorySkill.mjs.map