@dxos/assistant-toolkit 0.12.0-next-73daef452f1464b62efdbca75fb0067c1066f264 → 0.14.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.
- package/dist/lib/AgentOperation.mjs +13 -11
- package/dist/lib/AgentOperation.mjs.map +1 -1
- package/dist/lib/Memory.mjs +2 -2
- package/dist/lib/Memory.mjs.map +1 -1
- package/dist/lib/chunk-DelegationStrategy.mjs +218 -0
- package/dist/lib/chunk-DelegationStrategy.mjs.map +1 -0
- package/dist/lib/chunk-WebSearchSkill.mjs +61 -0
- package/dist/lib/chunk-WebSearchSkill.mjs.map +1 -0
- package/dist/lib/chunk-ask-question.mjs +95 -0
- package/dist/lib/chunk-ask-question.mjs.map +1 -0
- package/dist/lib/chunk-context-add.mjs +3 -3
- package/dist/lib/chunk-context-add.mjs.map +1 -1
- package/dist/lib/chunk-context-remove.mjs +3 -3
- package/dist/lib/chunk-context-remove.mjs.map +1 -1
- package/dist/lib/chunk-delegate-task.mjs +13 -14
- package/dist/lib/chunk-delegate-task.mjs.map +1 -1
- package/dist/lib/chunk-delegate-tasks.mjs +15 -14
- package/dist/lib/chunk-delegate-tasks.mjs.map +1 -1
- package/dist/lib/chunk-delete.mjs +3 -3
- package/dist/lib/chunk-delete.mjs.map +1 -1
- package/dist/lib/chunk-enable-skills.mjs +4 -4
- package/dist/lib/chunk-enable-skills.mjs.map +1 -1
- package/dist/lib/chunk-errors.mjs +28 -0
- package/dist/lib/chunk-errors.mjs.map +1 -0
- package/dist/lib/chunk-fetch.mjs +9 -5
- package/dist/lib/chunk-fetch.mjs.map +1 -1
- package/dist/lib/chunk-get-context.mjs +14 -19
- package/dist/lib/chunk-get-context.mjs.map +1 -1
- package/dist/lib/chunk-get-current-date.mjs +2 -2
- package/dist/lib/chunk-get-current-date.mjs.map +1 -1
- package/dist/lib/chunk-operations.mjs +6 -357
- package/dist/lib/chunk-operations.mjs.map +1 -1
- package/dist/lib/chunk-operations2.mjs +55 -0
- package/dist/lib/chunk-operations2.mjs.map +1 -0
- package/dist/lib/chunk-operations3.mjs +111 -0
- package/dist/lib/chunk-operations3.mjs.map +1 -0
- package/dist/lib/chunk-operations4.mjs +73 -0
- package/dist/lib/chunk-operations4.mjs.map +1 -0
- package/dist/lib/chunk-operations5.mjs +48 -0
- package/dist/lib/chunk-operations5.mjs.map +1 -0
- package/dist/lib/chunk-operations6.mjs +49 -0
- package/dist/lib/chunk-operations6.mjs.map +1 -0
- package/dist/lib/chunk-operations7.mjs +84 -0
- package/dist/lib/chunk-operations7.mjs.map +1 -0
- package/dist/lib/chunk-operations8.mjs +9 -0
- package/dist/lib/chunk-operations8.mjs.map +1 -0
- package/dist/lib/chunk-plan-reminder.mjs +25 -28
- package/dist/lib/chunk-plan-reminder.mjs.map +1 -1
- package/dist/lib/chunk-query-skills.mjs +3 -3
- package/dist/lib/chunk-query-skills.mjs.map +1 -1
- package/dist/lib/chunk-query.mjs +3 -3
- package/dist/lib/chunk-query.mjs.map +1 -1
- package/dist/lib/chunk-relay.mjs +17 -17
- package/dist/lib/chunk-relay.mjs.map +1 -1
- package/dist/lib/chunk-run-instructions.mjs +18 -17
- package/dist/lib/chunk-run-instructions.mjs.map +1 -1
- package/dist/lib/chunk-save.mjs +3 -3
- package/dist/lib/chunk-save.mjs.map +1 -1
- package/dist/lib/chunk-set-alarm.mjs +3 -3
- package/dist/lib/chunk-set-alarm.mjs.map +1 -1
- package/dist/lib/chunk-sync-automation.mjs +7 -9
- package/dist/lib/chunk-sync-automation.mjs.map +1 -1
- package/dist/lib/chunk-update-tasks.mjs +96 -20
- package/dist/lib/chunk-update-tasks.mjs.map +1 -1
- package/dist/lib/index.mjs +15 -629
- package/dist/lib/ns/AgentOperationHandlerSet.mjs +8 -0
- package/dist/lib/ns/AgentOperationHandlerSet.mjs.map +1 -0
- package/dist/lib/{chunk-agent.mjs → ns/AgentSkill.mjs} +14 -11
- package/dist/lib/ns/AgentSkill.mjs.map +1 -0
- package/dist/lib/ns/AlarmSkill.mjs +31 -0
- package/dist/lib/ns/AlarmSkill.mjs.map +1 -0
- package/dist/lib/ns/AutomationSkill.mjs +100 -0
- package/dist/lib/ns/AutomationSkill.mjs.map +1 -0
- package/dist/lib/ns/BrowserSkill.mjs +30 -0
- package/dist/lib/ns/BrowserSkill.mjs.map +1 -0
- package/dist/lib/ns/ChatContextSkill.mjs +31 -0
- package/dist/lib/ns/ChatContextSkill.mjs.map +1 -0
- package/dist/lib/ns/DelegationSkill.mjs +32 -0
- package/dist/lib/ns/DelegationSkill.mjs.map +1 -0
- package/dist/lib/ns/DelegationStrategy.mjs +2 -0
- package/dist/lib/ns/MemorySkill.mjs +39 -0
- package/dist/lib/ns/MemorySkill.mjs.map +1 -0
- package/dist/lib/ns/PlanningSkill.mjs +47 -0
- package/dist/lib/ns/PlanningSkill.mjs.map +1 -0
- package/dist/lib/ns/SkillManagerSkill.mjs +47 -0
- package/dist/lib/ns/SkillManagerSkill.mjs.map +1 -0
- package/dist/lib/ns/SlashCommand.mjs +41 -0
- package/dist/lib/ns/SlashCommand.mjs.map +1 -0
- package/dist/lib/ns/WebSearchSkill.mjs +2 -0
- package/dist/lib/testing.mjs +24 -18
- package/dist/lib/testing.mjs.map +1 -1
- package/dist/types/src/AgentOperationHandlerSet.d.ts +2 -0
- package/dist/types/src/AgentOperationHandlerSet.d.ts.map +1 -0
- package/dist/types/src/DelegationStrategy.d.ts +2 -0
- package/dist/types/src/DelegationStrategy.d.ts.map +1 -0
- package/dist/types/src/SlashCommand.d.ts +2 -0
- package/dist/types/src/SlashCommand.d.ts.map +1 -0
- package/dist/types/src/commands.d.ts +1 -1
- package/dist/types/src/commands.d.ts.map +1 -1
- package/dist/types/src/errors.d.ts +40 -12
- package/dist/types/src/errors.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +5 -6
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/operations/complete-job-tool.d.ts +2 -2
- package/dist/types/src/operations/complete-job-tool.d.ts.map +1 -1
- package/dist/types/src/operations/index.d.ts +0 -1
- package/dist/types/src/operations/index.d.ts.map +1 -1
- package/dist/types/src/operations/run-instructions.d.ts.map +1 -1
- package/dist/types/src/skills/agent/AgentSkill.d.ts +9 -0
- package/dist/types/src/skills/agent/AgentSkill.d.ts.map +1 -0
- package/dist/types/src/skills/agent/index.d.ts +1 -2
- package/dist/types/src/skills/agent/index.d.ts.map +1 -1
- package/dist/types/src/skills/agent/operations/definitions.d.ts +14 -7
- package/dist/types/src/skills/agent/operations/definitions.d.ts.map +1 -1
- package/dist/types/src/skills/agent/operations/get-context.d.ts.map +1 -1
- package/dist/types/src/skills/agent/operations/index.d.ts +1 -1
- package/dist/types/src/skills/agent/operations/index.d.ts.map +1 -1
- package/dist/types/src/skills/agent/operations/relay.d.ts +1 -1
- package/dist/types/src/skills/agent/operations/relay.d.ts.map +1 -1
- package/dist/types/src/skills/{agent-wizard → agent}/operations/sync-automation.d.ts +1 -1
- package/dist/types/src/skills/agent/operations/sync-automation.d.ts.map +1 -0
- package/dist/types/src/skills/agent/operations/sync-automation.test.d.ts.map +1 -0
- package/dist/types/src/skills/alarm/AlarmSkill.d.ts +6 -0
- package/dist/types/src/skills/alarm/AlarmSkill.d.ts.map +1 -0
- package/dist/types/src/skills/alarm/index.d.ts +1 -2
- package/dist/types/src/skills/alarm/index.d.ts.map +1 -1
- package/dist/types/src/skills/alarm/operations/index.d.ts +1 -1
- package/dist/types/src/skills/alarm/operations/index.d.ts.map +1 -1
- package/dist/types/src/skills/automation/AutomationSkill.d.ts +4 -0
- package/dist/types/src/skills/automation/AutomationSkill.d.ts.map +1 -0
- package/dist/types/src/skills/automation/index.d.ts +1 -1
- package/dist/types/src/skills/automation/index.d.ts.map +1 -1
- package/dist/types/src/skills/browser/BrowserSkill.d.ts +4 -0
- package/dist/types/src/skills/browser/BrowserSkill.d.ts.map +1 -0
- package/dist/types/src/skills/browser/index.d.ts +1 -1
- package/dist/types/src/skills/browser/index.d.ts.map +1 -1
- package/dist/types/src/skills/chat-context/ChatContextSkill.d.ts +6 -0
- package/dist/types/src/skills/chat-context/ChatContextSkill.d.ts.map +1 -0
- package/dist/types/src/skills/chat-context/index.d.ts +1 -2
- package/dist/types/src/skills/chat-context/index.d.ts.map +1 -1
- package/dist/types/src/skills/chat-context/operations/index.d.ts +1 -1
- package/dist/types/src/skills/chat-context/operations/index.d.ts.map +1 -1
- package/dist/types/src/skills/delegation/DelegationSkill.d.ts +6 -0
- package/dist/types/src/skills/delegation/DelegationSkill.d.ts.map +1 -0
- package/dist/types/src/skills/delegation/index.d.ts +1 -2
- package/dist/types/src/skills/delegation/index.d.ts.map +1 -1
- package/dist/types/src/skills/delegation/operations/delegate-task.d.ts +3 -3
- package/dist/types/src/skills/delegation/operations/delegate-task.d.ts.map +1 -1
- package/dist/types/src/skills/delegation/operations/delegate-tasks.d.ts +1 -1
- package/dist/types/src/skills/delegation/operations/delegate-tasks.d.ts.map +1 -1
- package/dist/types/src/skills/delegation/operations/index.d.ts +1 -1
- package/dist/types/src/skills/delegation/operations/index.d.ts.map +1 -1
- package/dist/types/src/skills/index.d.ts +10 -11
- package/dist/types/src/skills/index.d.ts.map +1 -1
- package/dist/types/src/skills/memory/MemorySkill.d.ts +6 -0
- package/dist/types/src/skills/memory/MemorySkill.d.ts.map +1 -0
- package/dist/types/src/skills/memory/index.d.ts +1 -2
- package/dist/types/src/skills/memory/index.d.ts.map +1 -1
- package/dist/types/src/skills/memory/operations/definitions.d.ts +2 -2
- package/dist/types/src/skills/memory/operations/definitions.d.ts.map +1 -1
- package/dist/types/src/skills/memory/operations/delete.d.ts +1 -1
- package/dist/types/src/skills/memory/operations/index.d.ts +1 -1
- package/dist/types/src/skills/memory/operations/index.d.ts.map +1 -1
- package/dist/types/src/skills/planning/PlanningSkill.d.ts +6 -0
- package/dist/types/src/skills/planning/PlanningSkill.d.ts.map +1 -0
- package/dist/types/src/skills/planning/index.d.ts +1 -2
- package/dist/types/src/skills/planning/index.d.ts.map +1 -1
- package/dist/types/src/skills/planning/operations/ask-question.d.ts +17 -0
- package/dist/types/src/skills/planning/operations/ask-question.d.ts.map +1 -0
- package/dist/types/src/skills/planning/operations/ask-question.test.d.ts +2 -0
- package/dist/types/src/skills/planning/operations/ask-question.test.d.ts.map +1 -0
- package/dist/types/src/skills/planning/operations/definitions.d.ts +34 -4
- package/dist/types/src/skills/planning/operations/definitions.d.ts.map +1 -1
- package/dist/types/src/skills/planning/operations/index.d.ts +1 -1
- package/dist/types/src/skills/planning/operations/index.d.ts.map +1 -1
- package/dist/types/src/skills/planning/operations/plan-reminder.d.ts +1 -1
- package/dist/types/src/skills/planning/operations/plan-reminder.d.ts.map +1 -1
- package/dist/types/src/skills/planning/operations/update-tasks.d.ts +15 -2
- package/dist/types/src/skills/planning/operations/update-tasks.d.ts.map +1 -1
- package/dist/types/src/skills/planning/operations/update-tasks.model.test.d.ts +2 -0
- package/dist/types/src/skills/planning/operations/update-tasks.model.test.d.ts.map +1 -0
- package/dist/types/src/skills/planning/skill.test.d.ts +2 -0
- package/dist/types/src/skills/planning/skill.test.d.ts.map +1 -0
- package/dist/types/src/skills/skill-manager/SkillManagerSkill.d.ts +6 -0
- package/dist/types/src/skills/skill-manager/SkillManagerSkill.d.ts.map +1 -0
- package/dist/types/src/skills/skill-manager/index.d.ts +1 -2
- package/dist/types/src/skills/skill-manager/index.d.ts.map +1 -1
- package/dist/types/src/skills/skill-manager/operations/index.d.ts +1 -1
- package/dist/types/src/skills/skill-manager/operations/index.d.ts.map +1 -1
- package/dist/types/src/skills/websearch/WebSearchSkill.d.ts +7 -0
- package/dist/types/src/skills/websearch/WebSearchSkill.d.ts.map +1 -0
- package/dist/types/src/skills/websearch/index.d.ts +1 -3
- package/dist/types/src/skills/websearch/index.d.ts.map +1 -1
- package/dist/types/src/skills/websearch/operations/fetch.d.ts +31 -0
- package/dist/types/src/skills/websearch/operations/fetch.d.ts.map +1 -1
- package/dist/types/src/skills/websearch/operations/index.d.ts +1 -1
- package/dist/types/src/skills/websearch/operations/index.d.ts.map +1 -1
- package/dist/types/src/skills/websearch/toolkit.d.ts +2 -2
- package/dist/types/src/skills/websearch/toolkit.d.ts.map +1 -1
- package/dist/types/src/supervisor/delegation-strategy.d.ts +8 -0
- package/dist/types/src/supervisor/delegation-strategy.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +3 -3
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/operations.d.ts.map +1 -1
- package/dist/types/src/{operations/definitions.d.ts → types/AgentOperation.d.ts} +2 -2
- package/dist/types/src/types/AgentOperation.d.ts.map +1 -0
- package/dist/types/src/types/Memory.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +2 -4
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +99 -48
- package/src/AgentOperationHandlerSet.ts +7 -0
- package/src/DelegationStrategy.ts +7 -0
- package/src/SlashCommand.ts +7 -0
- package/src/commands.test.ts +1 -1
- package/src/commands.ts +1 -2
- package/src/errors.ts +8 -7
- package/src/index.ts +5 -6
- package/src/operations/complete-job-tool.test.ts +2 -2
- package/src/operations/complete-job-tool.ts +1 -1
- package/src/operations/index.ts +2 -4
- package/src/operations/run-instructions.model.test.ts +5 -5
- package/src/operations/run-instructions.test.ts +7 -7
- package/src/operations/run-instructions.ts +9 -9
- package/src/operations/skill-resolution.test.ts +4 -3
- package/src/skills/agent/{skill.ts → AgentSkill.ts} +7 -10
- package/src/skills/agent/index.ts +2 -3
- package/src/skills/agent/operations/definitions.ts +37 -5
- package/src/skills/agent/operations/get-context.test.ts +7 -9
- package/src/skills/agent/operations/get-context.ts +9 -12
- package/src/skills/agent/operations/index.ts +5 -4
- package/src/skills/agent/operations/relay.test.ts +6 -6
- package/src/skills/agent/operations/relay.ts +12 -12
- package/src/skills/{agent-wizard → agent}/operations/sync-automation.test.ts +8 -9
- package/src/skills/{agent-wizard → agent}/operations/sync-automation.ts +2 -5
- package/src/skills/alarm/{skill.ts → AlarmSkill.ts} +8 -10
- package/src/skills/alarm/index.ts +1 -2
- package/src/skills/alarm/operations/definitions.ts +1 -1
- package/src/skills/alarm/operations/get-current-date.ts +1 -1
- package/src/skills/alarm/operations/index.ts +4 -4
- package/src/skills/alarm/operations/set-alarm.ts +2 -2
- package/src/skills/alarm/skill.test.ts +6 -6
- package/src/skills/automation/{skill.ts → AutomationSkill.ts} +5 -10
- package/src/skills/automation/index.ts +1 -1
- package/src/skills/browser/{skill.ts → BrowserSkill.ts} +5 -10
- package/src/skills/browser/index.ts +1 -1
- package/src/skills/browser/skill.test.ts +3 -3
- package/src/skills/chat-context/{skill.ts → ChatContextSkill.ts} +8 -10
- package/src/skills/chat-context/chat-context.test.ts +3 -3
- package/src/skills/chat-context/index.ts +2 -3
- package/src/skills/chat-context/operations/context-add.test.ts +2 -2
- package/src/skills/chat-context/operations/context-add.ts +1 -1
- package/src/skills/chat-context/operations/context-remove.test.ts +2 -2
- package/src/skills/chat-context/operations/context-remove.ts +1 -1
- package/src/skills/chat-context/operations/index.ts +4 -4
- package/src/skills/delegation/{skill.ts → DelegationSkill.ts} +8 -10
- package/src/skills/delegation/index.ts +1 -2
- package/src/skills/delegation/operations/delegate-task.test.ts +27 -31
- package/src/skills/delegation/operations/delegate-task.ts +10 -10
- package/src/skills/delegation/operations/delegate-tasks.ts +13 -9
- package/src/skills/delegation/operations/index.ts +4 -4
- package/src/skills/index.ts +10 -11
- package/src/skills/memory/{skill.ts → MemorySkill.ts} +8 -10
- package/src/skills/memory/index.ts +1 -2
- package/src/skills/memory/operations/definitions.ts +2 -2
- package/src/skills/memory/operations/delete.test.ts +6 -6
- package/src/skills/memory/operations/delete.ts +1 -1
- package/src/skills/memory/operations/index.ts +5 -5
- package/src/skills/memory/operations/query.test.ts +6 -6
- package/src/skills/memory/operations/query.ts +4 -4
- package/src/skills/memory/operations/save.test.ts +4 -4
- package/src/skills/memory/operations/save.ts +3 -3
- package/src/skills/memory/skill.test.ts +17 -13
- package/src/skills/planning/{skill.ts → PlanningSkill.ts} +16 -13
- package/src/skills/planning/index.ts +1 -2
- package/src/skills/planning/operations/ask-question.test.ts +251 -0
- package/src/skills/planning/operations/ask-question.ts +123 -0
- package/src/skills/planning/operations/definitions.ts +72 -8
- package/src/skills/planning/operations/index.ts +5 -4
- package/src/skills/planning/operations/plan-reminder.test.ts +7 -11
- package/src/skills/planning/operations/plan-reminder.ts +21 -24
- package/src/skills/planning/operations/update-tasks.md +41 -38
- package/src/skills/planning/operations/update-tasks.model.test.ts +118 -0
- package/src/skills/planning/operations/update-tasks.test.ts +207 -45
- package/src/skills/planning/operations/update-tasks.ts +119 -20
- package/src/skills/planning/skill.test.ts +130 -0
- package/src/skills/skill-manager/{skill.ts → SkillManagerSkill.ts} +8 -10
- package/src/skills/skill-manager/index.ts +1 -2
- package/src/skills/skill-manager/operations/definitions.ts +1 -1
- package/src/skills/skill-manager/operations/enable-skills.ts +1 -1
- package/src/skills/skill-manager/operations/index.ts +4 -4
- package/src/skills/skill-manager/operations/query-skills.ts +1 -1
- package/src/skills/skill-manager/skill.test.ts +4 -4
- package/src/skills/websearch/{skill.ts → WebSearchSkill.ts} +10 -11
- package/src/skills/websearch/index.ts +2 -4
- package/src/skills/websearch/operations/fetch.ts +10 -3
- package/src/skills/websearch/operations/index.ts +5 -3
- package/src/skills/websearch/skill.test.ts +3 -3
- package/src/skills/websearch/toolkit.ts +1 -1
- package/src/supervisor/delegation-strategy.test.ts +151 -24
- package/src/supervisor/delegation-strategy.ts +59 -53
- package/src/sync/sync.test.ts +1 -1
- package/src/testing/index.ts +3 -3
- package/src/testing/operations.ts +12 -13
- package/src/testing/plugins.tsx +4 -4
- package/src/types/Agent.test.ts +31 -3
- package/src/{operations/definitions.ts → types/AgentOperation.ts} +4 -3
- package/src/types/Chat.test.ts +166 -13
- package/src/types/Memory.ts +2 -1
- package/src/types/index.ts +2 -4
- package/dist/lib/Agent.mjs +0 -180
- package/dist/lib/Agent.mjs.map +0 -1
- package/dist/lib/Chat.mjs +0 -2
- package/dist/lib/McpServer.mjs +0 -27
- package/dist/lib/McpServer.mjs.map +0 -1
- package/dist/lib/chunk-Chat.mjs +0 -213
- package/dist/lib/chunk-Chat.mjs.map +0 -1
- package/dist/lib/chunk-agent-rules.mjs +0 -71
- package/dist/lib/chunk-agent-rules.mjs.map +0 -1
- package/dist/lib/chunk-agent.mjs.map +0 -1
- package/dist/lib/chunk-create-agent.mjs +0 -25
- package/dist/lib/chunk-create-agent.mjs.map +0 -1
- package/dist/lib/chunk-definitions.mjs +0 -24
- package/dist/lib/chunk-definitions.mjs.map +0 -1
- package/dist/lib/chunk-types.mjs +0 -4
- package/dist/lib/index.mjs.map +0 -1
- package/dist/types/src/operations/definitions.d.ts.map +0 -1
- package/dist/types/src/skills/agent/skill.d.ts +0 -4
- package/dist/types/src/skills/agent/skill.d.ts.map +0 -1
- package/dist/types/src/skills/agent-wizard/index.d.ts +0 -3
- package/dist/types/src/skills/agent-wizard/index.d.ts.map +0 -1
- package/dist/types/src/skills/agent-wizard/operations/agent-rules.d.ts +0 -4
- package/dist/types/src/skills/agent-wizard/operations/agent-rules.d.ts.map +0 -1
- package/dist/types/src/skills/agent-wizard/operations/create-agent.d.ts +0 -11
- package/dist/types/src/skills/agent-wizard/operations/create-agent.d.ts.map +0 -1
- package/dist/types/src/skills/agent-wizard/operations/definitions.d.ts +0 -17
- package/dist/types/src/skills/agent-wizard/operations/definitions.d.ts.map +0 -1
- package/dist/types/src/skills/agent-wizard/operations/index.d.ts +0 -4
- package/dist/types/src/skills/agent-wizard/operations/index.d.ts.map +0 -1
- package/dist/types/src/skills/agent-wizard/operations/sync-automation.d.ts.map +0 -1
- package/dist/types/src/skills/agent-wizard/operations/sync-automation.test.d.ts.map +0 -1
- package/dist/types/src/skills/agent-wizard/skill.d.ts +0 -4
- package/dist/types/src/skills/agent-wizard/skill.d.ts.map +0 -1
- package/dist/types/src/skills/alarm/skill.d.ts +0 -4
- package/dist/types/src/skills/alarm/skill.d.ts.map +0 -1
- package/dist/types/src/skills/automation/skill.d.ts +0 -4
- package/dist/types/src/skills/automation/skill.d.ts.map +0 -1
- package/dist/types/src/skills/browser/skill.d.ts +0 -4
- package/dist/types/src/skills/browser/skill.d.ts.map +0 -1
- package/dist/types/src/skills/chat-context/skill.d.ts +0 -4
- package/dist/types/src/skills/chat-context/skill.d.ts.map +0 -1
- package/dist/types/src/skills/delegation/skill.d.ts +0 -4
- package/dist/types/src/skills/delegation/skill.d.ts.map +0 -1
- package/dist/types/src/skills/memory/skill.d.ts +0 -4
- package/dist/types/src/skills/memory/skill.d.ts.map +0 -1
- package/dist/types/src/skills/planning/skill.d.ts +0 -4
- package/dist/types/src/skills/planning/skill.d.ts.map +0 -1
- package/dist/types/src/skills/skill-manager/skill.d.ts +0 -4
- package/dist/types/src/skills/skill-manager/skill.d.ts.map +0 -1
- package/dist/types/src/skills/websearch/skill.d.ts +0 -4
- package/dist/types/src/skills/websearch/skill.d.ts.map +0 -1
- package/dist/types/src/supervisor/index.d.ts +0 -2
- package/dist/types/src/supervisor/index.d.ts.map +0 -1
- package/dist/types/src/sync/index.d.ts +0 -2
- package/dist/types/src/sync/index.d.ts.map +0 -1
- package/dist/types/src/types/Agent.d.ts +0 -59
- package/dist/types/src/types/Agent.d.ts.map +0 -1
- package/dist/types/src/types/Chat.d.ts +0 -83
- package/dist/types/src/types/Chat.d.ts.map +0 -1
- package/dist/types/src/types/McpServer.d.ts +0 -21
- package/dist/types/src/types/McpServer.d.ts.map +0 -1
- package/src/skills/agent-wizard/index.ts +0 -6
- package/src/skills/agent-wizard/operations/agent-rules.ts +0 -77
- package/src/skills/agent-wizard/operations/create-agent.ts +0 -31
- package/src/skills/agent-wizard/operations/definitions.ts +0 -81
- package/src/skills/agent-wizard/operations/index.ts +0 -16
- package/src/skills/agent-wizard/skill.ts +0 -53
- package/src/supervisor/index.ts +0 -5
- package/src/sync/index.ts +0 -5
- package/src/types/Agent.ts +0 -251
- package/src/types/Chat.ts +0 -244
- package/src/types/McpServer.ts +0 -30
- /package/dist/types/src/skills/{agent-wizard → agent}/operations/sync-automation.test.d.ts +0 -0
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
4
|
-
import { AiService, OpaqueToolkit } from "@dxos/ai";
|
|
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";
|
|
5
4
|
import { Database, Feed, Ref, Registry } from "@dxos/echo";
|
|
6
5
|
import { DXN as DXN$1 } from "@dxos/keys";
|
|
7
|
-
import * as
|
|
8
|
-
import
|
|
6
|
+
import * as Schema from "effect/Schema";
|
|
7
|
+
import * as Operation from "@dxos/compute/Operation";
|
|
8
|
+
import { AiService, OpaqueToolkit } from "@dxos/ai";
|
|
9
9
|
import * as Trace from "@dxos/compute/Trace";
|
|
10
|
-
|
|
10
|
+
import { Text } from "@dxos/schema";
|
|
11
|
+
//#region src/types/AgentOperation.ts
|
|
12
|
+
var AgentOperation_exports = /* @__PURE__ */ __exportAll({ RunInstructions: () => RunInstructions });
|
|
11
13
|
var RunInstructions = Operation.make({
|
|
12
14
|
meta: {
|
|
13
15
|
key: DXN$1.make("org.dxos.operation.assistantToolkit.runInstructions"),
|
|
@@ -25,9 +27,9 @@ var RunInstructions = Operation.make({
|
|
|
25
27
|
/**
|
|
26
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.
|
|
27
29
|
*/
|
|
28
|
-
chat: Schema.optional(Ref.Ref(Chat)),
|
|
30
|
+
chat: Schema.optional(Ref.Ref(Chat.Chat)),
|
|
29
31
|
/**
|
|
30
|
-
* @default dxn:com.anthropic.model.claude-opus-
|
|
32
|
+
* @default `dxn:com.anthropic.model.claude-opus-5.default`.
|
|
31
33
|
*/
|
|
32
34
|
model: Schema.optional(DXN$1.Schema),
|
|
33
35
|
systemInstructions: Schema.optional(Schema.String).annotate({ description: "Additional system instructions to add to the system prompt." })
|
|
@@ -37,7 +39,7 @@ var RunInstructions = Operation.make({
|
|
|
37
39
|
Instructions.Instructions,
|
|
38
40
|
Text.Text,
|
|
39
41
|
Feed.Feed,
|
|
40
|
-
Chat
|
|
42
|
+
Chat.Chat
|
|
41
43
|
],
|
|
42
44
|
services: [
|
|
43
45
|
AiService.AiService,
|
|
@@ -48,6 +50,6 @@ var RunInstructions = Operation.make({
|
|
|
48
50
|
]
|
|
49
51
|
});
|
|
50
52
|
//#endregion
|
|
51
|
-
export { RunInstructions };
|
|
53
|
+
export { RunInstructions, AgentOperation_exports as t };
|
|
52
54
|
|
|
53
55
|
//# sourceMappingURL=AgentOperation.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentOperation.mjs","names":[],"sources":["../../src/
|
|
1
|
+
{"version":3,"file":"AgentOperation.mjs","names":[],"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,KAAK,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,SAAS,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"}
|
package/dist/lib/Memory.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
|
|
2
|
-
import * as Schema from "effect/Schema";
|
|
3
2
|
import { Annotation, DXN, Type } from "@dxos/echo";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
4
4
|
//#region src/types/Memory.ts
|
|
5
5
|
var Memory_exports = /* @__PURE__ */ __exportAll({ Memory: () => Memory });
|
|
6
6
|
/**
|
|
@@ -12,7 +12,7 @@ var Memory = class extends Type.makeObject(DXN.make("org.dxos.type.memory", "0.1
|
|
|
12
12
|
}).pipe(Annotation.LabelAnnotation.set(["title"]), Annotation.IconAnnotation.set({
|
|
13
13
|
icon: "ph--brain--regular",
|
|
14
14
|
hue: "pink"
|
|
15
|
-
})
|
|
15
|
+
}))) {};
|
|
16
16
|
//#endregion
|
|
17
17
|
export { Memory, Memory_exports as t };
|
|
18
18
|
|
package/dist/lib/Memory.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Memory.mjs","names":[],"sources":["../../src/types/Memory.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\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
|
|
1
|
+
{"version":3,"file":"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,218 @@
|
|
|
1
|
+
import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
|
|
2
|
+
import { n as ToolkitError } from "./chunk-errors.mjs";
|
|
3
|
+
import { key } from "./ns/DelegationSkill.mjs";
|
|
4
|
+
import { RunInstructions } from "./AgentOperation.mjs";
|
|
5
|
+
import * as Cause from "effect/Cause";
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
import * as Exit from "effect/Exit";
|
|
8
|
+
import { AiContext } from "@dxos/assistant";
|
|
9
|
+
import * as Agent from "@dxos/assistant/Agent";
|
|
10
|
+
import * as Chat from "@dxos/assistant/Chat";
|
|
11
|
+
import { OperationProcess } from "@dxos/compute-runtime";
|
|
12
|
+
import * as Instructions from "@dxos/compute/Instructions";
|
|
13
|
+
import * as Process from "@dxos/compute/Process";
|
|
14
|
+
import { Database, Feed, Filter, Obj, Query, Ref } from "@dxos/echo";
|
|
15
|
+
import * as EffectEx from "@dxos/effect/EffectEx";
|
|
16
|
+
import { EID, EntityId } from "@dxos/keys";
|
|
17
|
+
import { log } from "@dxos/log";
|
|
18
|
+
import { Message, Task } from "@dxos/types";
|
|
19
|
+
import { trim } from "@dxos/util";
|
|
20
|
+
//#region src/supervisor/delegation-strategy.ts
|
|
21
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/core/compute/assistant-toolkit/src/supervisor/delegation-strategy.ts";
|
|
22
|
+
/**
|
|
23
|
+
* Normalizes an LLM-reported artifact reference (bare entity id or full ECHO URI) to a
|
|
24
|
+
* fully-qualified ref in the current space. Not resolved here — it resolves lazily when read.
|
|
25
|
+
*/
|
|
26
|
+
var resolveArtifactRef = (id) => Effect.gen(function* () {
|
|
27
|
+
const parsed = EID.tryParse(id);
|
|
28
|
+
const candidate = (parsed ? EID.getEntityId(parsed) : void 0) ?? id;
|
|
29
|
+
if (!EntityId.isValid(candidate)) return yield* Effect.fail(new ToolkitError({ message: `Invalid artifact id: ${id}` }));
|
|
30
|
+
const { db } = yield* Database.Service;
|
|
31
|
+
return db.makeRef(EID.make({
|
|
32
|
+
spaceId: db.spaceId,
|
|
33
|
+
entityId: candidate
|
|
34
|
+
}));
|
|
35
|
+
});
|
|
36
|
+
/**
|
|
37
|
+
* Renders a sub-agent result for inclusion in a notification message.
|
|
38
|
+
*/
|
|
39
|
+
var formatResult = (value) => typeof value === "string" ? value : JSON.stringify(value);
|
|
40
|
+
/**
|
|
41
|
+
* Extracts artifact ids a sub-agent reported in its result (see the synthesized instructions
|
|
42
|
+
* instructions). Tolerates the result being a string, or an object with `artifactIds`/`artifactId`.
|
|
43
|
+
*/
|
|
44
|
+
var extractArtifactIds = (value) => {
|
|
45
|
+
if (typeof value !== "object" || value === null) return [];
|
|
46
|
+
const record = value;
|
|
47
|
+
return (Array.isArray(record.artifactIds) ? record.artifactIds : typeof record.artifactId === "string" ? [record.artifactId] : []).filter((id) => typeof id === "string");
|
|
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
|
+
*/
|
|
63
|
+
var findPendingTasks = (chat, activeIds) => Effect.gen(function* () {
|
|
64
|
+
const tasks = yield* Chat.loadTasks(chat);
|
|
65
|
+
return tasks.filter((task) => isSubAgentTask(task) && (task.status ?? "todo") === "todo" && !activeIds.has(task.id) && Task.isTaskReady(tasks, task));
|
|
66
|
+
});
|
|
67
|
+
/**
|
|
68
|
+
* Fails agent tasks stuck in `started` with no live process — a crashed or never-exited
|
|
69
|
+
* sub-agent (e.g. the host reloaded mid-run) must not wedge the task or the delegation loop.
|
|
70
|
+
*/
|
|
71
|
+
var sweepOrphanedTasks = (chat, activeIds) => Effect.gen(function* () {
|
|
72
|
+
const orphans = (yield* Chat.loadTasks(chat)).filter((task) => isSubAgentTask(task) && task.status === "started" && !activeIds.has(task.id));
|
|
73
|
+
if (orphans.length === 0) return;
|
|
74
|
+
for (const task of orphans) {
|
|
75
|
+
log.warn("orphaned delegated task failed", {
|
|
76
|
+
taskId: task.id,
|
|
77
|
+
title: task.title
|
|
78
|
+
}, {
|
|
79
|
+
"~LogMeta": "~LogMeta",
|
|
80
|
+
F: __dxlog_file,
|
|
81
|
+
L: 115,
|
|
82
|
+
S: this
|
|
83
|
+
});
|
|
84
|
+
Obj.update(task, (task) => {
|
|
85
|
+
task.status = "failed";
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
yield* Database.flush();
|
|
89
|
+
});
|
|
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
|
+
var failHeldTasks = (chat, cause) => Effect.gen(function* () {
|
|
96
|
+
const held = (yield* Chat.loadTasks(chat)).filter((task) => Task.isAgentWorking(task) && !isSubAgentTask(task));
|
|
97
|
+
if (held.length === 0) return;
|
|
98
|
+
const reason = Cause.prettyErrors(cause).map((error) => error.message).join("; ");
|
|
99
|
+
log.warn("agent turn failed; failing held tasks", {
|
|
100
|
+
chatId: chat.id,
|
|
101
|
+
cause: Cause.pretty(cause)
|
|
102
|
+
}, {
|
|
103
|
+
"~LogMeta": "~LogMeta",
|
|
104
|
+
F: __dxlog_file,
|
|
105
|
+
L: 139,
|
|
106
|
+
S: this
|
|
107
|
+
});
|
|
108
|
+
for (const task of held) Task.setStatus(task, "failed", {
|
|
109
|
+
actor: {
|
|
110
|
+
role: "assistant",
|
|
111
|
+
subject: Ref.make(chat)
|
|
112
|
+
},
|
|
113
|
+
description: `The agent's request failed${reason ? `: ${reason}` : "."}`
|
|
114
|
+
});
|
|
115
|
+
yield* Database.flush();
|
|
116
|
+
});
|
|
117
|
+
/**
|
|
118
|
+
* 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
|
|
120
|
+
* `RunInstructions`), marked started at spawn; on exit the task is marked done/failed and a
|
|
121
|
+
* templated message is posted back to the conversation, whose turn re-runs this reconcile — so a
|
|
122
|
+
* batch of delegated tasks drains in dependency order without further prompting.
|
|
123
|
+
*/
|
|
124
|
+
var makeDelegationStrategy = () => ({
|
|
125
|
+
reconcile: (chat, activeIds) => Effect.gen(function* () {
|
|
126
|
+
yield* sweepOrphanedTasks(chat, activeIds);
|
|
127
|
+
const pending = yield* findPendingTasks(chat, activeIds);
|
|
128
|
+
if (pending.length === 0) return [];
|
|
129
|
+
const feed = yield* Database.load(chat.feed).pipe(Effect.orDie);
|
|
130
|
+
const skills = (yield* Effect.gen(function* () {
|
|
131
|
+
const runtime = yield* Effect.context();
|
|
132
|
+
return (yield* EffectEx.acquireReleaseResource(() => new AiContext.Binder({
|
|
133
|
+
feed,
|
|
134
|
+
runtime
|
|
135
|
+
}))).getSkills().filter((skill) => Obj.getMeta(skill).key !== key);
|
|
136
|
+
}).pipe(Effect.scoped)).map((skill) => Ref.make(skill));
|
|
137
|
+
const delegations = [];
|
|
138
|
+
for (const task of pending) {
|
|
139
|
+
const instructions = yield* Database.add(Instructions.make({
|
|
140
|
+
name: task.title,
|
|
141
|
+
text: trim`
|
|
142
|
+
Complete the following task and report the result concisely.
|
|
143
|
+
|
|
144
|
+
If you create any documents or artifacts, call completeJob with a JSON object of the
|
|
145
|
+
form { "summary": string, "artifactIds": string[] }, where artifactIds are the exact
|
|
146
|
+
ids returned by the tools that created them. Otherwise return a short summary string.
|
|
147
|
+
|
|
148
|
+
Task: ${task.title}
|
|
149
|
+
`,
|
|
150
|
+
skills
|
|
151
|
+
}));
|
|
152
|
+
Obj.update(task, (task) => {
|
|
153
|
+
task.status = "started";
|
|
154
|
+
});
|
|
155
|
+
delegations.push({
|
|
156
|
+
id: task.id,
|
|
157
|
+
spawn: Effect.gen(function* () {
|
|
158
|
+
return (yield* Process.spawn(OperationProcess.make(RunInstructions), {
|
|
159
|
+
instructions: Ref.make(instructions),
|
|
160
|
+
input: {}
|
|
161
|
+
})).pid;
|
|
162
|
+
})
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
yield* Database.flush();
|
|
166
|
+
return delegations;
|
|
167
|
+
}),
|
|
168
|
+
onTurnFailed: failHeldTasks,
|
|
169
|
+
onComplete: (chat, id, exit) => Effect.gen(function* () {
|
|
170
|
+
const agent = yield* Agent.loadForChat(chat);
|
|
171
|
+
let title = id;
|
|
172
|
+
const task = (yield* Database.query(Query.select(Filter.id(id))).run.pipe(Effect.orElseSucceed(() => []))).find((candidate) => Obj.instanceOf(Task.Task, candidate));
|
|
173
|
+
if (task) {
|
|
174
|
+
Obj.update(task, (task) => {
|
|
175
|
+
task.status = Exit.isSuccess(exit) ? "done" : "failed";
|
|
176
|
+
});
|
|
177
|
+
title = task.title;
|
|
178
|
+
}
|
|
179
|
+
const artifactRefs = [];
|
|
180
|
+
if (agent && Exit.isSuccess(exit)) for (const artifactId of extractArtifactIds(exit.value)) {
|
|
181
|
+
const ref = yield* resolveArtifactRef(artifactId).pipe(Effect.orElseSucceed(() => void 0));
|
|
182
|
+
if (ref) artifactRefs.push(ref);
|
|
183
|
+
}
|
|
184
|
+
if (Exit.isFailure(exit)) log.warn("sub-agent failed", {
|
|
185
|
+
taskId: id,
|
|
186
|
+
title,
|
|
187
|
+
cause: Cause.pretty(exit.cause)
|
|
188
|
+
}, {
|
|
189
|
+
"~LogMeta": "~LogMeta",
|
|
190
|
+
F: __dxlog_file,
|
|
191
|
+
L: 254,
|
|
192
|
+
S: this
|
|
193
|
+
});
|
|
194
|
+
const failureSummary = Exit.isFailure(exit) ? Cause.prettyErrors(exit.cause).map((error) => error.message).join("; ") : void 0;
|
|
195
|
+
const blocks = [{
|
|
196
|
+
_tag: "text",
|
|
197
|
+
text: Exit.isSuccess(exit) ? `The sub-agent completed "${title}".${artifactRefs.length === 0 ? ` ${formatResult(exit.value)}` : ""}` : `The sub-agent failed to complete "${title}": ${failureSummary || "unknown error"}`
|
|
198
|
+
}, ...artifactRefs.map((reference) => ({
|
|
199
|
+
_tag: "reference",
|
|
200
|
+
reference
|
|
201
|
+
}))];
|
|
202
|
+
const feed = yield* Database.load(chat.feed).pipe(Effect.orDie);
|
|
203
|
+
yield* Feed.append(feed, [Message.make({
|
|
204
|
+
sender: "assistant",
|
|
205
|
+
blocks
|
|
206
|
+
})]);
|
|
207
|
+
})
|
|
208
|
+
});
|
|
209
|
+
//#endregion
|
|
210
|
+
//#region src/DelegationStrategy.ts
|
|
211
|
+
var DelegationStrategy_exports = /* @__PURE__ */ __exportAll({
|
|
212
|
+
isSubAgentTask: () => isSubAgentTask,
|
|
213
|
+
make: () => makeDelegationStrategy
|
|
214
|
+
});
|
|
215
|
+
//#endregion
|
|
216
|
+
export { isSubAgentTask as n, makeDelegationStrategy as r, DelegationStrategy_exports as t };
|
|
217
|
+
|
|
218
|
+
//# sourceMappingURL=chunk-DelegationStrategy.mjs.map
|
|
@@ -0,0 +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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
+
import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
|
|
2
|
+
import { Ref } from "@dxos/echo";
|
|
3
|
+
import { DXN as DXN$1 } from "@dxos/keys";
|
|
4
|
+
import { trim } from "@dxos/util";
|
|
5
|
+
import * as Skill from "@dxos/compute/Skill";
|
|
6
|
+
import * as Schema from "effect/Schema";
|
|
7
|
+
import * as Operation from "@dxos/compute/Operation";
|
|
8
|
+
import * as OperationHandlerSet from "@dxos/compute/OperationHandlerSet";
|
|
9
|
+
import { OpaqueToolkit } from "@dxos/ai";
|
|
10
|
+
import { Text } from "@dxos/schema";
|
|
11
|
+
import * as Toolkit from "effect/ai/Toolkit";
|
|
12
|
+
import * as Layer from "effect/Layer";
|
|
13
|
+
import { AnthropicWebSearchTool } from "@dxos/ai/resolvers";
|
|
14
|
+
//#region src/skills/websearch/operations/definitions.ts
|
|
15
|
+
var definitions_exports = /* @__PURE__ */ __exportAll({ Fetch: () => Fetch });
|
|
16
|
+
var Fetch = Operation.make({
|
|
17
|
+
meta: {
|
|
18
|
+
key: DXN$1.make("org.dxos.operation.assistantToolkit.fetch"),
|
|
19
|
+
name: "Fetch web page",
|
|
20
|
+
icon: "ph--globe-simple--regular",
|
|
21
|
+
description: trim`
|
|
22
|
+
Fetches the content of a web page and returns the HTML.
|
|
23
|
+
Use this to get the content of a web page.
|
|
24
|
+
`
|
|
25
|
+
},
|
|
26
|
+
input: Schema.Struct({ url: Schema.String.annotate({ description: "The URL of the web page to fetch." }) }),
|
|
27
|
+
output: Schema.String
|
|
28
|
+
});
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/skills/websearch/toolkit.ts
|
|
31
|
+
var WebSearchToolkit = Toolkit.make(AnthropicWebSearchTool);
|
|
32
|
+
var WebSearchToolkitOpaque = OpaqueToolkit.make(WebSearchToolkit, Layer.empty);
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/skills/websearch/operations/index.ts
|
|
35
|
+
var WebSearchHandlers = OperationHandlerSet.lazy([Fetch.pipe(Operation.lazyHandler(() => import("./chunk-fetch.mjs")))]);
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/skills/websearch/WebSearchSkill.ts
|
|
38
|
+
var WebSearchSkill_exports = /* @__PURE__ */ __exportAll({
|
|
39
|
+
Handlers: () => WebSearchHandlers,
|
|
40
|
+
Operations: () => definitions_exports,
|
|
41
|
+
Toolkit: () => WebSearchToolkit,
|
|
42
|
+
ToolkitOpaque: () => WebSearchToolkitOpaque,
|
|
43
|
+
key: () => key,
|
|
44
|
+
make: () => make
|
|
45
|
+
});
|
|
46
|
+
var key = "org.dxos.skill.webSearch";
|
|
47
|
+
var make = () => Skill.make({
|
|
48
|
+
key,
|
|
49
|
+
name: "Web Search",
|
|
50
|
+
description: "Search the web.",
|
|
51
|
+
agentCanEnable: true,
|
|
52
|
+
instructions: { source: Ref.make(Text.make()) },
|
|
53
|
+
tools: Skill.toolDefinitions({
|
|
54
|
+
operations: [Fetch],
|
|
55
|
+
tools: [WebSearchToolkit.tools.AnthropicWebSearch.name]
|
|
56
|
+
})
|
|
57
|
+
});
|
|
58
|
+
//#endregion
|
|
59
|
+
export { WebSearchToolkit as a, definitions_exports as c, WebSearchHandlers as i, key as n, WebSearchToolkitOpaque as o, make as r, Fetch as s, WebSearchSkill_exports as t };
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=chunk-WebSearchSkill.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-WebSearchSkill.mjs","names":[],"sources":["../../src/skills/websearch/operations/definitions.ts","../../src/skills/websearch/toolkit.ts","../../src/skills/websearch/operations/index.ts","../../src/skills/websearch/WebSearchSkill.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport * as Operation from '@dxos/compute/Operation';\nimport { DXN } from '@dxos/keys';\nimport { trim } from '@dxos/util';\n\nexport const Fetch = Operation.make({\n meta: {\n key: DXN.make('org.dxos.operation.assistantToolkit.fetch'),\n name: 'Fetch web page',\n icon: 'ph--globe-simple--regular',\n description: trim`\n Fetches the content of a web page and returns the HTML. \n Use this to get the content of a web page.\n `,\n },\n input: Schema.Struct({\n url: Schema.String.annotate({\n description: 'The URL of the web page to fetch.',\n }),\n }),\n output: Schema.String,\n});\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Toolkit from 'effect/ai/Toolkit';\nimport * as Layer from 'effect/Layer';\n\nimport { OpaqueToolkit } from '@dxos/ai';\nimport { AnthropicWebSearchTool } from '@dxos/ai/resolvers';\n\nexport const WebSearchToolkit = Toolkit.make(AnthropicWebSearchTool);\n\nexport const WebSearchToolkitOpaque = OpaqueToolkit.make(WebSearchToolkit, Layer.empty);\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Operation from '@dxos/compute/Operation';\nimport * as OperationHandlerSet from '@dxos/compute/OperationHandlerSet';\n\nimport { Fetch } from './definitions.ts';\n\nexport * as WebSearchOperations from './definitions.ts';\n\nexport const WebSearchHandlers = OperationHandlerSet.lazy([\n Fetch.pipe(Operation.lazyHandler(() => import('./fetch.ts'))),\n]);\n","//\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';\n\nimport { Fetch } from './operations/definitions.ts';\nimport { WebSearchToolkit } from './toolkit.ts';\n\nexport const key = 'org.dxos.skill.webSearch';\n\nexport const make = () =>\n Skill.make({\n key,\n name: 'Web Search',\n description: 'Search the web.',\n agentCanEnable: true,\n instructions: {\n source: Ref.make(Text.make()),\n },\n tools: Skill.toolDefinitions({ operations: [Fetch], tools: [WebSearchToolkit.tools.AnthropicWebSearch.name] }),\n });\n\nexport { WebSearchHandlers as Handlers } from './operations/index.ts';\nexport * as Operations from './operations/definitions.ts';\nexport { WebSearchToolkit as Toolkit, WebSearchToolkitOpaque as ToolkitOpaque } from './toolkit.ts';\n"],"mappings":";;;;;;;;;;;;;;;AAUA,IAAa,QAAQ,UAAU,KAAK;CAClC,MAAM;EACJ,KAAK,MAAI,KAAK,2CAA2C;EACzD,MAAM;EACN,MAAM;EACN,aAAa,IAAI;;;;CAInB;CACA,OAAO,OAAO,OAAO,EACnB,KAAK,OAAO,OAAO,SAAS,EAC1B,aAAa,oCACf,CAAC,EACH,CAAC;CACD,QAAQ,OAAO;AACjB,CAAC;;;AChBD,IAAa,mBAAmB,QAAQ,KAAK,sBAAsB;AAEnE,IAAa,yBAAyB,cAAc,KAAK,kBAAkB,MAAM,KAAK;;;ACDtF,IAAa,oBAAoB,oBAAoB,KAAK,CACxD,MAAM,KAAK,UAAU,kBAAkB,OAAO,oBAAa,CAAC,CAC9D,CAAC;;;;;;;;;;;ACAD,IAAa,MAAM;AAEnB,IAAa,aACX,MAAM,KAAK;CACT;CACA,MAAM;CACN,aAAa;CACb,gBAAgB;CAChB,cAAc,EACZ,QAAQ,IAAI,KAAK,KAAK,KAAK,CAAC,EAC9B;CACA,OAAO,MAAM,gBAAgB;EAAE,YAAY,CAAC,KAAK;EAAG,OAAO,CAAC,iBAAiB,MAAM,mBAAmB,IAAI;CAAE,CAAC;AAC/G,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { n as AskQuestion } from "./chunk-operations3.mjs";
|
|
2
|
+
import { selfActor } from "./chunk-update-tasks.mjs";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import { Harness } from "@dxos/assistant";
|
|
5
|
+
import * as Chat from "@dxos/assistant/Chat";
|
|
6
|
+
import { Database, Ref } from "@dxos/echo";
|
|
7
|
+
import { Task } from "@dxos/types";
|
|
8
|
+
import { trim } from "@dxos/util";
|
|
9
|
+
import * as Operation from "@dxos/compute/Operation";
|
|
10
|
+
import * as Trace from "@dxos/compute/Trace";
|
|
11
|
+
//#region src/skills/planning/operations/ask-question.ts
|
|
12
|
+
/**
|
|
13
|
+
* Files a question on a checklist task and blocks the task on it.
|
|
14
|
+
*
|
|
15
|
+
* The task is matched by title: the question has to name the task in words the reader recognizes,
|
|
16
|
+
* and the title is the only part of a task the person answering ever sees. Two tasks sharing one
|
|
17
|
+
* title are refused rather than guessed between — blocking the wrong one would leave the right one
|
|
18
|
+
* looking live while nothing advances it.
|
|
19
|
+
*
|
|
20
|
+
* The question lands in the task's own history, so it cannot be separated from the work it blocks.
|
|
21
|
+
* The task is set `blocked` alongside it — otherwise the checklist reads as work in progress that
|
|
22
|
+
* nothing is advancing — and the entry carries the conversation ref, without which the answer has
|
|
23
|
+
* no session to resume.
|
|
24
|
+
*/
|
|
25
|
+
var ask_question_default = AskQuestion.pipe(Operation.withHandler(Effect.fnUntraced(function* ({ task: title, question: text, context, options }) {
|
|
26
|
+
const chat = yield* Harness.getChat;
|
|
27
|
+
const matches = (yield* Chat.loadTasks(chat)).filter((candidate) => candidate.title === title.trim());
|
|
28
|
+
if (matches.length > 1) return trim`
|
|
29
|
+
"${title.trim()}" is the title of ${matches.length} tasks on this conversation's checklist, so
|
|
30
|
+
nothing was filed — blocking the wrong one would leave the right one looking live. Give the
|
|
31
|
+
tasks distinct titles with update-tasks, then ask again.
|
|
32
|
+
|
|
33
|
+
<checklist>
|
|
34
|
+
${yield* Chat.formatChecklist(chat)}
|
|
35
|
+
</checklist>
|
|
36
|
+
`;
|
|
37
|
+
const [task] = matches;
|
|
38
|
+
if (!task) return trim`
|
|
39
|
+
No task titled "${title.trim()}" is on this conversation's checklist, so no question was asked.
|
|
40
|
+
Ask again naming one of these exactly, or add the task first with update-tasks.
|
|
41
|
+
|
|
42
|
+
<checklist>
|
|
43
|
+
${yield* Chat.formatChecklist(chat)}
|
|
44
|
+
</checklist>
|
|
45
|
+
`;
|
|
46
|
+
if (Task.getPendingQuestions(task.history).length > 0) return trim`
|
|
47
|
+
"${task.title}" already has an unanswered question, so nothing was filed. Wait for it to be
|
|
48
|
+
answered rather than asking again.
|
|
49
|
+
|
|
50
|
+
<checklist>
|
|
51
|
+
${yield* Chat.formatChecklist(chat)}
|
|
52
|
+
</checklist>
|
|
53
|
+
`;
|
|
54
|
+
if (text.trim() === "") return "The question is empty, so nothing was filed. Ask again with the question written out.";
|
|
55
|
+
const question = Task.ask(task, {
|
|
56
|
+
text,
|
|
57
|
+
...context ? { context } : {},
|
|
58
|
+
...options && options.length > 0 ? { options: options.map(({ title, description }) => ({
|
|
59
|
+
title,
|
|
60
|
+
...description ? { description } : {}
|
|
61
|
+
})) } : {},
|
|
62
|
+
conversation: Ref.make(chat),
|
|
63
|
+
actor: yield* selfActor(chat)
|
|
64
|
+
});
|
|
65
|
+
const previousStatus = task.status;
|
|
66
|
+
Task.setStatus(task, "blocked");
|
|
67
|
+
if (task.status !== void 0 && task.status !== previousStatus) yield* Trace.write(Trace.TaskStatusChanged, {
|
|
68
|
+
taskId: task.id,
|
|
69
|
+
title: task.title,
|
|
70
|
+
status: task.status,
|
|
71
|
+
...previousStatus ? { previousStatus } : {}
|
|
72
|
+
});
|
|
73
|
+
yield* Trace.write(Trace.QuestionAsked, {
|
|
74
|
+
questionId: question.id,
|
|
75
|
+
text: question.text,
|
|
76
|
+
taskId: task.id,
|
|
77
|
+
options: question.options?.length ?? 0
|
|
78
|
+
});
|
|
79
|
+
yield* Database.flush();
|
|
80
|
+
return trim`
|
|
81
|
+
Question filed on "${task.title}", which is now blocked. Stop here and end your turn — you are
|
|
82
|
+
sent a message when it is answered, and you read the answer back off the task's history.
|
|
83
|
+
Show the reader the question by emitting this line verbatim, on its own:
|
|
84
|
+
|
|
85
|
+
<surface role="question">{"task":"${task.id}","question":"${question.id}"}</surface>
|
|
86
|
+
|
|
87
|
+
<checklist>
|
|
88
|
+
${yield* Chat.formatChecklist(chat)}
|
|
89
|
+
</checklist>
|
|
90
|
+
`;
|
|
91
|
+
})), Operation.opaqueHandler);
|
|
92
|
+
//#endregion
|
|
93
|
+
export { ask_question_default as default };
|
|
94
|
+
|
|
95
|
+
//# sourceMappingURL=chunk-ask-question.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-ask-question.mjs","names":[],"sources":["../../src/skills/planning/operations/ask-question.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Harness } from '@dxos/assistant';\nimport * as Chat from '@dxos/assistant/Chat';\nimport * as Operation from '@dxos/compute/Operation';\nimport * as Trace from '@dxos/compute/Trace';\nimport { Database, Ref } from '@dxos/echo';\nimport { Task } from '@dxos/types';\nimport { trim } from '@dxos/util';\n\nimport { AskQuestion } from './definitions.ts';\nimport { selfActor } from './update-tasks.ts';\n\n/**\n * Files a question on a checklist task and blocks the task on it.\n *\n * The task is matched by title: the question has to name the task in words the reader recognizes,\n * and the title is the only part of a task the person answering ever sees. Two tasks sharing one\n * title are refused rather than guessed between — blocking the wrong one would leave the right one\n * looking live while nothing advances it.\n *\n * The question lands in the task's own history, so it cannot be separated from the work it blocks.\n * The task is set `blocked` alongside it — otherwise the checklist reads as work in progress that\n * nothing is advancing — and the entry carries the conversation ref, without which the answer has\n * no session to resume.\n */\nexport default AskQuestion.pipe(\n Operation.withHandler(\n Effect.fnUntraced(function* ({ task: title, question: text, context, options }) {\n const chat = yield* Harness.getChat;\n\n const tasks = yield* Chat.loadTasks(chat);\n const matches = tasks.filter((candidate) => candidate.title === title.trim());\n if (matches.length > 1) {\n return trim`\n \"${title.trim()}\" is the title of ${matches.length} tasks on this conversation's checklist, so\n nothing was filed — blocking the wrong one would leave the right one looking live. Give the\n tasks distinct titles with update-tasks, then ask again.\n\n <checklist>\n ${yield* Chat.formatChecklist(chat)}\n </checklist>\n `;\n }\n const [task] = matches;\n if (!task) {\n // Not a failure: the model gets the checklist back and re-reads the title it should have used.\n return trim`\n No task titled \"${title.trim()}\" is on this conversation's checklist, so no question was asked.\n Ask again naming one of these exactly, or add the task first with update-tasks.\n\n <checklist>\n ${yield* Chat.formatChecklist(chat)}\n </checklist>\n `;\n }\n\n // A retried tool call must not file a second question: the reader would have two to answer\n // where only the first resumes anything cleanly, and the second answer would wake the same\n // chat again.\n if (Task.getPendingQuestions(task.history).length > 0) {\n return trim`\n \"${task.title}\" already has an unanswered question, so nothing was filed. Wait for it to be\n answered rather than asking again.\n\n <checklist>\n ${yield* Chat.formatChecklist(chat)}\n </checklist>\n `;\n }\n\n // A result, not a failure, as every refusal here: the model rewrites the question and asks again.\n if (text.trim() === '') {\n return 'The question is empty, so nothing was filed. Ask again with the question written out.';\n }\n\n const question = Task.ask(task, {\n text,\n ...(context ? { context } : {}),\n ...(options && options.length > 0\n ? { options: options.map(({ title, description }) => ({ title, ...(description ? { description } : {}) })) }\n : {}),\n conversation: Ref.make(chat),\n actor: yield* selfActor(chat),\n });\n\n const previousStatus = task.status;\n Task.setStatus(task, 'blocked');\n if (task.status !== undefined && task.status !== previousStatus) {\n yield* Trace.write(Trace.TaskStatusChanged, {\n taskId: task.id,\n title: task.title,\n status: task.status,\n ...(previousStatus ? { previousStatus } : {}),\n });\n }\n yield* Trace.write(Trace.QuestionAsked, {\n questionId: question.id,\n text: question.text,\n taskId: task.id,\n options: question.options?.length ?? 0,\n });\n yield* Database.flush();\n\n return trim`\n Question filed on \"${task.title}\", which is now blocked. Stop here and end your turn — you are\n sent a message when it is answered, and you read the answer back off the task's history.\n Show the reader the question by emitting this line verbatim, on its own:\n\n <surface role=\"question\">{\"task\":\"${task.id}\",\"question\":\"${question.id}\"}</surface>\n\n <checklist>\n ${yield* Chat.formatChecklist(chat)}\n </checklist>\n `;\n }),\n ),\n Operation.opaqueHandler,\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA8BA,IAAA,uBAAe,YAAY,KACzB,UAAU,YACR,OAAO,WAAW,WAAW,EAAE,MAAM,OAAO,UAAU,MAAM,SAAS,WAAW;CAC9E,MAAM,OAAO,OAAO,QAAQ;CAG5B,MAAM,WAAU,OADK,KAAK,UAAU,IAAI,EAAA,CAClB,QAAQ,cAAc,UAAU,UAAU,MAAM,KAAK,CAAC;CAC5E,IA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G,gBAAgB,SAAS,GAAG;;;UAGtE,OAAO,KAAK,gBAAgB,IAAI,EAAC;;;AAGvC,CAAC,CACH,GACA,UAAU,aACZ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import * as Operation from "@dxos/compute/Operation";
|
|
3
|
-
import { Harness } from "@dxos/assistant";
|
|
1
|
+
import { n as ContextAdd } from "./chunk-operations5.mjs";
|
|
4
2
|
import * as Effect from "effect/Effect";
|
|
3
|
+
import { Harness } from "@dxos/assistant";
|
|
4
|
+
import * as Operation from "@dxos/compute/Operation";
|
|
5
5
|
//#region src/skills/chat-context/operations/context-add.ts
|
|
6
6
|
var context_add_default = ContextAdd.pipe(Operation.withHandler(Effect.fn(function* ({ obj }) {
|
|
7
7
|
const sessionBinder = yield* Harness.binder;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunk-context-add.mjs","names":[],"sources":["../../src/skills/chat-context/operations/context-add.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Harness } from '@dxos/assistant';\nimport * as Operation from '@dxos/compute/Operation';\n\nimport { ContextAdd } from './definitions';\n\nexport default ContextAdd.pipe(\n Operation.withHandler(\n Effect.fn(function* ({ obj }) {\n const sessionBinder = yield* Harness.binder;\n yield* Effect.promise(() =>\n sessionBinder.bind({\n skills: [],\n objects: [obj],\n }),\n );\n }),\n ),\n);\n"],"mappings":";;;;;AAWA,IAAA,sBAAe,WAAW,KACxB,UAAU,YACR,OAAO,GAAG,WAAW,EAAE,OAAO;CAC5B,MAAM,gBAAgB,OAAO,QAAQ;CACrC,OAAO,OAAO,cACZ,cAAc,KAAK;EACjB,QAAQ,CAAC;EACT,SAAS,CAAC,GAAG;CACf,CAAC,CACH;AACF,CAAC,CACH,CACF"}
|
|
1
|
+
{"version":3,"file":"chunk-context-add.mjs","names":[],"sources":["../../src/skills/chat-context/operations/context-add.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Harness } from '@dxos/assistant';\nimport * as Operation from '@dxos/compute/Operation';\n\nimport { ContextAdd } from './definitions.ts';\n\nexport default ContextAdd.pipe(\n Operation.withHandler(\n Effect.fn(function* ({ obj }) {\n const sessionBinder = yield* Harness.binder;\n yield* Effect.promise(() =>\n sessionBinder.bind({\n skills: [],\n objects: [obj],\n }),\n );\n }),\n ),\n);\n"],"mappings":";;;;;AAWA,IAAA,sBAAe,WAAW,KACxB,UAAU,YACR,OAAO,GAAG,WAAW,EAAE,OAAO;CAC5B,MAAM,gBAAgB,OAAO,QAAQ;CACrC,OAAO,OAAO,cACZ,cAAc,KAAK;EACjB,QAAQ,CAAC;EACT,SAAS,CAAC,GAAG;CACf,CAAC,CACH;AACF,CAAC,CACH,CACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import * as Operation from "@dxos/compute/Operation";
|
|
3
|
-
import { Harness } from "@dxos/assistant";
|
|
1
|
+
import { r as ContextRemove } from "./chunk-operations5.mjs";
|
|
4
2
|
import * as Effect from "effect/Effect";
|
|
3
|
+
import { Harness } from "@dxos/assistant";
|
|
4
|
+
import * as Operation from "@dxos/compute/Operation";
|
|
5
5
|
//#region src/skills/chat-context/operations/context-remove.ts
|
|
6
6
|
var context_remove_default = ContextRemove.pipe(Operation.withHandler(Effect.fn(function* ({ obj }) {
|
|
7
7
|
const sessionBinder = yield* Harness.binder;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunk-context-remove.mjs","names":[],"sources":["../../src/skills/chat-context/operations/context-remove.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Harness } from '@dxos/assistant';\nimport * as Operation from '@dxos/compute/Operation';\n\nimport { ContextRemove } from './definitions';\n\nexport default ContextRemove.pipe(\n Operation.withHandler(\n Effect.fn(function* ({ obj }) {\n const sessionBinder = yield* Harness.binder;\n yield* Effect.promise(() =>\n sessionBinder.unbind({\n skills: [],\n objects: [obj],\n }),\n );\n }),\n ),\n);\n"],"mappings":";;;;;AAWA,IAAA,yBAAe,cAAc,KAC3B,UAAU,YACR,OAAO,GAAG,WAAW,EAAE,OAAO;CAC5B,MAAM,gBAAgB,OAAO,QAAQ;CACrC,OAAO,OAAO,cACZ,cAAc,OAAO;EACnB,QAAQ,CAAC;EACT,SAAS,CAAC,GAAG;CACf,CAAC,CACH;AACF,CAAC,CACH,CACF"}
|
|
1
|
+
{"version":3,"file":"chunk-context-remove.mjs","names":[],"sources":["../../src/skills/chat-context/operations/context-remove.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Harness } from '@dxos/assistant';\nimport * as Operation from '@dxos/compute/Operation';\n\nimport { ContextRemove } from './definitions.ts';\n\nexport default ContextRemove.pipe(\n Operation.withHandler(\n Effect.fn(function* ({ obj }) {\n const sessionBinder = yield* Harness.binder;\n yield* Effect.promise(() =>\n sessionBinder.unbind({\n skills: [],\n objects: [obj],\n }),\n );\n }),\n ),\n);\n"],"mappings":";;;;;AAWA,IAAA,yBAAe,cAAc,KAC3B,UAAU,YACR,OAAO,GAAG,WAAW,EAAE,OAAO;CAC5B,MAAM,gBAAgB,OAAO,QAAQ;CACrC,OAAO,OAAO,cACZ,cAAc,OAAO;EACnB,QAAQ,CAAC;EACT,SAAS,CAAC,GAAG;CACf,CAAC,CACH;AACF,CAAC,CACH,CACF"}
|
|
@@ -1,32 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./chunk-
|
|
3
|
-
import
|
|
1
|
+
import { n as ToolkitError } from "./chunk-errors.mjs";
|
|
2
|
+
import { n as DelegateTask } from "./chunk-operations.mjs";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import { Harness } from "@dxos/assistant";
|
|
5
|
+
import * as Chat from "@dxos/assistant/Chat";
|
|
6
|
+
import { Database } from "@dxos/echo";
|
|
4
7
|
import { trim } from "@dxos/util";
|
|
5
8
|
import * as Operation from "@dxos/compute/Operation";
|
|
6
|
-
import { Database } from "@dxos/echo";
|
|
7
|
-
import * as Effect from "effect/Effect";
|
|
8
|
-
import { TaskSet } from "@dxos/types";
|
|
9
9
|
//#region src/skills/delegation/operations/delegate-task.ts
|
|
10
10
|
/**
|
|
11
|
-
* Delegation is the promotion moment: the unit of work becomes a durable `Task`
|
|
12
|
-
* conversation's
|
|
11
|
+
* Delegation is the promotion moment: the unit of work becomes a durable `Task` on the
|
|
12
|
+
* conversation's checklist assigned to an agent (`role: 'assistant'`), which the supervisor's
|
|
13
13
|
* reconcile loop picks up and marks done/failed on completion (see the delegation strategy).
|
|
14
14
|
*/
|
|
15
15
|
var handler = DelegateTask.pipe(Operation.withHandler(Effect.fn(function* ({ title }) {
|
|
16
|
-
if (title.length === 0) return yield* Effect.fail(
|
|
17
|
-
const chat = yield*
|
|
18
|
-
const taskSet = yield* ensureTaskSet(chat);
|
|
16
|
+
if (title.length === 0) return yield* Effect.fail(new ToolkitError({ message: "Provide a non-empty task title." }));
|
|
17
|
+
const chat = yield* Harness.getChat;
|
|
19
18
|
const { db } = yield* Database.Service;
|
|
20
|
-
const task =
|
|
19
|
+
const task = Chat.addTask(db, chat, title, {
|
|
21
20
|
status: "todo",
|
|
22
21
|
assignee: { role: "assistant" }
|
|
23
22
|
});
|
|
24
23
|
yield* Database.flush();
|
|
25
24
|
return trim`
|
|
26
25
|
Delegated "${task.title}" as a queued agent task (id: ${task.id}).
|
|
27
|
-
|
|
26
|
+
|
|
28
27
|
<checklist>
|
|
29
|
-
${yield* formatChecklist(chat)}
|
|
28
|
+
${yield* Chat.formatChecklist(chat)}
|
|
30
29
|
</checklist>
|
|
31
30
|
`;
|
|
32
31
|
})));
|