@dxos/assistant-toolkit 0.8.4-main.3c1ae3b → 0.8.4-main.3fbcb4aa9b
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/neutral/add-artifact-ZUJ5DMSY.mjs +30 -0
- package/dist/lib/neutral/add-artifact-ZUJ5DMSY.mjs.map +7 -0
- package/dist/lib/neutral/agent-5NIKAYUK.mjs +65 -0
- package/dist/lib/neutral/agent-5NIKAYUK.mjs.map +7 -0
- package/dist/lib/neutral/chunk-246ACKSH.mjs +100 -0
- package/dist/lib/neutral/chunk-246ACKSH.mjs.map +7 -0
- package/dist/lib/neutral/chunk-EJAQUAKM.mjs +73 -0
- package/dist/lib/neutral/chunk-EJAQUAKM.mjs.map +7 -0
- package/dist/lib/neutral/chunk-FIGO6CA6.mjs +140 -0
- package/dist/lib/neutral/chunk-FIGO6CA6.mjs.map +7 -0
- package/dist/lib/neutral/chunk-GV66MKAQ.mjs +60 -0
- package/dist/lib/neutral/chunk-GV66MKAQ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-IKBIORQX.mjs +332 -0
- package/dist/lib/neutral/chunk-IKBIORQX.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/neutral/chunk-KGU725LW.mjs +29 -0
- package/dist/lib/neutral/chunk-KGU725LW.mjs.map +7 -0
- package/dist/lib/neutral/chunk-NR3GTWRC.mjs +53 -0
- package/dist/lib/neutral/chunk-NR3GTWRC.mjs.map +7 -0
- package/dist/lib/neutral/chunk-P4ZMYO4K.mjs +294 -0
- package/dist/lib/neutral/chunk-P4ZMYO4K.mjs.map +7 -0
- package/dist/lib/neutral/chunk-QO5SU37C.mjs +70 -0
- package/dist/lib/neutral/chunk-QO5SU37C.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ROMZO4CB.mjs +108 -0
- package/dist/lib/neutral/chunk-ROMZO4CB.mjs.map +7 -0
- package/dist/lib/neutral/chunk-TO5IX24K.mjs +67 -0
- package/dist/lib/neutral/chunk-TO5IX24K.mjs.map +7 -0
- package/dist/lib/neutral/chunk-WLR3BGO4.mjs +25 -0
- package/dist/lib/neutral/chunk-WLR3BGO4.mjs.map +7 -0
- package/dist/lib/neutral/chunk-XUF53B6B.mjs +75 -0
- package/dist/lib/neutral/chunk-XUF53B6B.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ZFXLTBZG.mjs +73 -0
- package/dist/lib/neutral/chunk-ZFXLTBZG.mjs.map +7 -0
- package/dist/lib/neutral/context-add-VB7AOY3G.mjs +22 -0
- package/dist/lib/neutral/context-add-VB7AOY3G.mjs.map +7 -0
- package/dist/lib/neutral/context-remove-VCM3VPSO.mjs +22 -0
- package/dist/lib/neutral/context-remove-VCM3VPSO.mjs.map +7 -0
- package/dist/lib/neutral/create-project-EIF4OJMY.mjs +35 -0
- package/dist/lib/neutral/create-project-EIF4OJMY.mjs.map +7 -0
- package/dist/lib/neutral/delete-J3PMWP7Z.mjs +19 -0
- package/dist/lib/neutral/delete-J3PMWP7Z.mjs.map +7 -0
- package/dist/lib/neutral/enable-blueprints-LBDZH2CY.mjs +47 -0
- package/dist/lib/neutral/enable-blueprints-LBDZH2CY.mjs.map +7 -0
- package/dist/lib/neutral/fetch-KHMHV7JR.mjs +16 -0
- package/dist/lib/neutral/fetch-KHMHV7JR.mjs.map +7 -0
- package/dist/lib/neutral/fetch-messages-QOBBCTGC.mjs +139 -0
- package/dist/lib/neutral/fetch-messages-QOBBCTGC.mjs.map +7 -0
- package/dist/lib/neutral/get-context-TN7X7U2H.mjs +35 -0
- package/dist/lib/neutral/get-context-TN7X7U2H.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +916 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/neutral/load-ALP3TK2E.mjs +17 -0
- package/dist/lib/neutral/load-ALP3TK2E.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/object-create-Z57Y3X6Y.mjs +35 -0
- package/dist/lib/neutral/object-create-Z57Y3X6Y.mjs.map +7 -0
- package/dist/lib/neutral/object-delete-X53LS37B.mjs +18 -0
- package/dist/lib/neutral/object-delete-X53LS37B.mjs.map +7 -0
- package/dist/lib/neutral/object-update-GVKSBR7T.mjs +28 -0
- package/dist/lib/neutral/object-update-GVKSBR7T.mjs.map +7 -0
- package/dist/lib/neutral/project-HPHTZ2CI.mjs +23 -0
- package/dist/lib/neutral/project-HPHTZ2CI.mjs.map +7 -0
- package/dist/lib/neutral/project-rules-IVDHKSKI.mjs +78 -0
- package/dist/lib/neutral/project-rules-IVDHKSKI.mjs.map +7 -0
- package/dist/lib/neutral/prompt-Y7NN7M5D.mjs +170 -0
- package/dist/lib/neutral/prompt-Y7NN7M5D.mjs.map +7 -0
- package/dist/lib/neutral/qualifier-VDOY5CWU.mjs +88 -0
- package/dist/lib/neutral/qualifier-VDOY5CWU.mjs.map +7 -0
- package/dist/lib/neutral/query-PPJU5622.mjs +70 -0
- package/dist/lib/neutral/query-PPJU5622.mjs.map +7 -0
- package/dist/lib/neutral/query-U56GNEV6.mjs +32 -0
- package/dist/lib/neutral/query-U56GNEV6.mjs.map +7 -0
- package/dist/lib/neutral/query-blueprints-KXADGHSA.mjs +16 -0
- package/dist/lib/neutral/query-blueprints-KXADGHSA.mjs.map +7 -0
- package/dist/lib/neutral/relation-create-XJ2IX6X3.mjs +34 -0
- package/dist/lib/neutral/relation-create-XJ2IX6X3.mjs.map +7 -0
- package/dist/lib/neutral/relation-delete-EP4KXAFL.mjs +18 -0
- package/dist/lib/neutral/relation-delete-EP4KXAFL.mjs.map +7 -0
- package/dist/lib/neutral/save-GWAPLT3Z.mjs +23 -0
- package/dist/lib/neutral/save-GWAPLT3Z.mjs.map +7 -0
- package/dist/lib/neutral/schema-add-Z5CY6P24.mjs +24 -0
- package/dist/lib/neutral/schema-add-Z5CY6P24.mjs.map +7 -0
- package/dist/lib/neutral/schema-list-W326VPVX.mjs +38 -0
- package/dist/lib/neutral/schema-list-W326VPVX.mjs.map +7 -0
- package/dist/lib/neutral/sync-issues-4YE5XAK5.mjs +167 -0
- package/dist/lib/neutral/sync-issues-4YE5XAK5.mjs.map +7 -0
- package/dist/lib/neutral/sync-triggers-CDMJVW6E.mjs +136 -0
- package/dist/lib/neutral/sync-triggers-CDMJVW6E.mjs.map +7 -0
- package/dist/lib/neutral/tag-add-VNIIOVJA.mjs +19 -0
- package/dist/lib/neutral/tag-add-VNIIOVJA.mjs.map +7 -0
- package/dist/lib/neutral/tag-remove-6R2R27W3.mjs +19 -0
- package/dist/lib/neutral/tag-remove-6R2R27W3.mjs.map +7 -0
- package/dist/lib/neutral/testing/index.mjs +76 -0
- package/dist/lib/neutral/testing/index.mjs.map +7 -0
- package/dist/lib/neutral/update-blueprints-N2AK2VUR.mjs +16 -0
- package/dist/lib/neutral/update-blueprints-N2AK2VUR.mjs.map +7 -0
- package/dist/lib/neutral/update-tasks-H7SWIFQL.mjs +46 -0
- package/dist/lib/neutral/update-tasks-H7SWIFQL.mjs.map +7 -0
- package/dist/types/src/blueprints/automation/blueprint.d.ts +4 -0
- package/dist/types/src/blueprints/automation/blueprint.d.ts.map +1 -0
- package/dist/types/src/blueprints/automation/index.d.ts +2 -0
- package/dist/types/src/blueprints/automation/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/blueprint-manager/blueprint.d.ts +4 -0
- package/dist/types/src/blueprints/blueprint-manager/blueprint.d.ts.map +1 -0
- package/dist/types/src/blueprints/blueprint-manager/blueprint.test.d.ts +2 -0
- package/dist/types/src/blueprints/blueprint-manager/blueprint.test.d.ts.map +1 -0
- package/dist/types/src/blueprints/blueprint-manager/functions/definitions.d.ts +63 -0
- package/dist/types/src/blueprints/blueprint-manager/functions/definitions.d.ts.map +1 -0
- package/dist/types/src/blueprints/blueprint-manager/functions/enable-blueprints.d.ts +37 -0
- package/dist/types/src/blueprints/blueprint-manager/functions/enable-blueprints.d.ts.map +1 -0
- package/dist/types/src/blueprints/blueprint-manager/functions/index.d.ts +4 -0
- package/dist/types/src/blueprints/blueprint-manager/functions/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/blueprint-manager/functions/query-blueprints.d.ts +28 -0
- package/dist/types/src/blueprints/blueprint-manager/functions/query-blueprints.d.ts.map +1 -0
- package/dist/types/src/blueprints/blueprint-manager/functions/update-blueprints.d.ts +4 -0
- package/dist/types/src/blueprints/blueprint-manager/functions/update-blueprints.d.ts.map +1 -0
- package/dist/types/src/blueprints/blueprint-manager/index.d.ts +3 -0
- package/dist/types/src/blueprints/blueprint-manager/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/browser/blueprint.d.ts +4 -0
- package/dist/types/src/blueprints/browser/blueprint.d.ts.map +1 -0
- package/dist/types/src/blueprints/browser/blueprint.test.d.ts +2 -0
- package/dist/types/src/blueprints/browser/blueprint.test.d.ts.map +1 -0
- package/dist/types/src/blueprints/browser/index.d.ts +2 -0
- package/dist/types/src/blueprints/browser/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/database/blueprint.d.ts +4 -0
- package/dist/types/src/blueprints/database/blueprint.d.ts.map +1 -0
- package/dist/types/src/blueprints/database/blueprint.test.d.ts +2 -0
- package/dist/types/src/blueprints/database/blueprint.test.d.ts.map +1 -0
- package/dist/types/src/blueprints/database/functions/context-add.d.ts +7 -0
- package/dist/types/src/blueprints/database/functions/context-add.d.ts.map +1 -0
- package/dist/types/src/blueprints/database/functions/context-remove.d.ts +7 -0
- package/dist/types/src/blueprints/database/functions/context-remove.d.ts.map +1 -0
- package/dist/types/src/blueprints/database/functions/definitions.d.ts +59 -0
- package/dist/types/src/blueprints/database/functions/definitions.d.ts.map +1 -0
- package/dist/types/src/blueprints/database/functions/index.d.ts +4 -0
- package/dist/types/src/blueprints/database/functions/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/database/functions/load.d.ts +7 -0
- package/dist/types/src/blueprints/database/functions/load.d.ts.map +1 -0
- package/dist/types/src/blueprints/database/functions/object-create.d.ts +8 -0
- package/dist/types/src/blueprints/database/functions/object-create.d.ts.map +1 -0
- package/dist/types/src/blueprints/database/functions/object-delete.d.ts +7 -0
- package/dist/types/src/blueprints/database/functions/object-delete.d.ts.map +1 -0
- package/dist/types/src/blueprints/database/functions/object-update.d.ts +10 -0
- package/dist/types/src/blueprints/database/functions/object-update.d.ts.map +1 -0
- package/dist/types/src/blueprints/database/functions/query.d.ts +13 -0
- package/dist/types/src/blueprints/database/functions/query.d.ts.map +1 -0
- package/dist/types/src/blueprints/database/functions/relation-create.d.ts +10 -0
- package/dist/types/src/blueprints/database/functions/relation-create.d.ts.map +1 -0
- package/dist/types/src/blueprints/database/functions/relation-delete.d.ts +7 -0
- package/dist/types/src/blueprints/database/functions/relation-delete.d.ts.map +1 -0
- package/dist/types/src/blueprints/database/functions/schema-add.d.ts +9 -0
- package/dist/types/src/blueprints/database/functions/schema-add.d.ts.map +1 -0
- package/dist/types/src/blueprints/database/functions/schema-list.d.ts +7 -0
- package/dist/types/src/blueprints/database/functions/schema-list.d.ts.map +1 -0
- package/dist/types/src/blueprints/database/functions/tag-add.d.ts +8 -0
- package/dist/types/src/blueprints/database/functions/tag-add.d.ts.map +1 -0
- package/dist/types/src/blueprints/database/functions/tag-remove.d.ts +8 -0
- package/dist/types/src/blueprints/database/functions/tag-remove.d.ts.map +1 -0
- package/dist/types/src/blueprints/database/index.d.ts +3 -0
- package/dist/types/src/blueprints/database/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/discord/blueprint.d.ts +4 -0
- package/dist/types/src/blueprints/discord/blueprint.d.ts.map +1 -0
- package/dist/types/src/blueprints/discord/functions/definitions.d.ts +15 -0
- package/dist/types/src/blueprints/discord/functions/definitions.d.ts.map +1 -0
- package/dist/types/src/{functions/discord → blueprints/discord/functions}/fetch-messages.d.ts +3 -2
- package/dist/types/src/blueprints/discord/functions/fetch-messages.d.ts.map +1 -0
- package/dist/types/src/blueprints/discord/functions/fetch-messages.test.d.ts.map +1 -0
- package/dist/types/src/blueprints/discord/functions/index.d.ts +4 -0
- package/dist/types/src/blueprints/discord/functions/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/discord/index.d.ts +2 -2
- package/dist/types/src/blueprints/discord/index.d.ts.map +1 -1
- package/dist/types/src/blueprints/github/functions/definitions.d.ts +7 -0
- package/dist/types/src/blueprints/github/functions/definitions.d.ts.map +1 -0
- package/dist/types/src/blueprints/github/functions/fetch-prs.d.ts +8 -0
- package/dist/types/src/blueprints/github/functions/fetch-prs.d.ts.map +1 -0
- package/dist/types/src/blueprints/github/functions/index.d.ts +4 -0
- package/dist/types/src/blueprints/github/functions/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/github/index.d.ts +2 -0
- package/dist/types/src/blueprints/github/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/index.d.ts +11 -6
- package/dist/types/src/blueprints/index.d.ts.map +1 -1
- package/dist/types/src/blueprints/linear/blueprint.d.ts +4 -0
- package/dist/types/src/blueprints/linear/blueprint.d.ts.map +1 -0
- package/dist/types/src/blueprints/linear/functions/definitions.d.ts +6 -0
- package/dist/types/src/blueprints/linear/functions/definitions.d.ts.map +1 -0
- package/dist/types/src/blueprints/linear/functions/index.d.ts +4 -0
- package/dist/types/src/blueprints/linear/functions/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/linear/functions/linear.test.d.ts.map +1 -0
- package/dist/types/src/blueprints/linear/functions/sync-issues.d.ts +10 -0
- package/dist/types/src/blueprints/linear/functions/sync-issues.d.ts.map +1 -0
- package/dist/types/src/blueprints/linear/index.d.ts +2 -2
- package/dist/types/src/blueprints/linear/index.d.ts.map +1 -1
- package/dist/types/src/blueprints/memory/blueprint.d.ts +4 -0
- package/dist/types/src/blueprints/memory/blueprint.d.ts.map +1 -0
- package/dist/types/src/blueprints/memory/blueprint.test.d.ts +2 -0
- package/dist/types/src/blueprints/memory/blueprint.test.d.ts.map +1 -0
- package/dist/types/src/blueprints/memory/functions/definitions.d.ts +17 -0
- package/dist/types/src/blueprints/memory/functions/definitions.d.ts.map +1 -0
- package/dist/types/src/blueprints/memory/functions/delete.d.ts +10 -0
- package/dist/types/src/blueprints/memory/functions/delete.d.ts.map +1 -0
- package/dist/types/src/blueprints/memory/functions/index.d.ts +4 -0
- package/dist/types/src/blueprints/memory/functions/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/memory/functions/query.d.ts +8 -0
- package/dist/types/src/blueprints/memory/functions/query.d.ts.map +1 -0
- package/dist/types/src/blueprints/memory/functions/save.d.ts +8 -0
- package/dist/types/src/blueprints/memory/functions/save.d.ts.map +1 -0
- package/dist/types/src/blueprints/memory/index.d.ts +3 -0
- package/dist/types/src/blueprints/memory/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/planning/blueprint.d.ts +4 -0
- package/dist/types/src/blueprints/planning/blueprint.d.ts.map +1 -0
- package/dist/types/src/blueprints/planning/functions/definitions.d.ts +11 -0
- package/dist/types/src/blueprints/planning/functions/definitions.d.ts.map +1 -0
- package/dist/types/src/blueprints/planning/functions/index.d.ts +4 -0
- package/dist/types/src/blueprints/planning/functions/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/planning/functions/update-tasks.d.ts +11 -0
- package/dist/types/src/blueprints/planning/functions/update-tasks.d.ts.map +1 -0
- package/dist/types/src/blueprints/planning/index.d.ts +2 -2
- package/dist/types/src/blueprints/planning/index.d.ts.map +1 -1
- package/dist/types/src/blueprints/project/blueprint.d.ts +4 -0
- package/dist/types/src/blueprints/project/blueprint.d.ts.map +1 -0
- package/dist/types/src/blueprints/project/blueprint.test.d.ts +2 -0
- package/dist/types/src/blueprints/project/blueprint.test.d.ts.map +1 -0
- package/dist/types/src/blueprints/project/functions/add-artifact.d.ts +8 -0
- package/dist/types/src/blueprints/project/functions/add-artifact.d.ts.map +1 -0
- package/dist/types/src/blueprints/project/functions/agent.d.ts +4 -0
- package/dist/types/src/blueprints/project/functions/agent.d.ts.map +1 -0
- package/dist/types/src/blueprints/project/functions/definitions.d.ts +158 -0
- package/dist/types/src/blueprints/project/functions/definitions.d.ts.map +1 -0
- package/dist/types/src/blueprints/project/functions/get-context.d.ts +15 -0
- package/dist/types/src/blueprints/project/functions/get-context.d.ts.map +1 -0
- package/dist/types/src/blueprints/project/functions/index.d.ts +4 -0
- package/dist/types/src/blueprints/project/functions/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/project/functions/qualifier.d.ts +73 -0
- package/dist/types/src/blueprints/project/functions/qualifier.d.ts.map +1 -0
- package/dist/types/src/blueprints/project/index.d.ts +3 -0
- package/dist/types/src/blueprints/project/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/project-wizard/blueprint.d.ts +4 -0
- package/dist/types/src/blueprints/project-wizard/blueprint.d.ts.map +1 -0
- package/dist/types/src/blueprints/project-wizard/functions/create-project.d.ts +51 -0
- package/dist/types/src/blueprints/project-wizard/functions/create-project.d.ts.map +1 -0
- package/dist/types/src/blueprints/project-wizard/functions/definitions.d.ts +96 -0
- package/dist/types/src/blueprints/project-wizard/functions/definitions.d.ts.map +1 -0
- package/dist/types/src/blueprints/project-wizard/functions/index.d.ts +4 -0
- package/dist/types/src/blueprints/project-wizard/functions/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/project-wizard/functions/project-rules.d.ts +4 -0
- package/dist/types/src/blueprints/project-wizard/functions/project-rules.d.ts.map +1 -0
- package/dist/types/src/blueprints/project-wizard/functions/sync-triggers.d.ts +48 -0
- package/dist/types/src/blueprints/project-wizard/functions/sync-triggers.d.ts.map +1 -0
- package/dist/types/src/blueprints/project-wizard/index.d.ts +3 -0
- package/dist/types/src/blueprints/project-wizard/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/testing.d.ts +9 -5
- package/dist/types/src/blueprints/testing.d.ts.map +1 -1
- package/dist/types/src/blueprints/websearch/blueprint.d.ts +4 -0
- package/dist/types/src/blueprints/websearch/blueprint.d.ts.map +1 -0
- package/dist/types/src/blueprints/websearch/blueprint.test.d.ts +2 -0
- package/dist/types/src/blueprints/websearch/blueprint.test.d.ts.map +1 -0
- package/dist/types/src/blueprints/websearch/functions/definitions.d.ts +5 -0
- package/dist/types/src/blueprints/websearch/functions/definitions.d.ts.map +1 -0
- package/dist/types/src/blueprints/websearch/functions/fetch.d.ts +6 -0
- package/dist/types/src/blueprints/websearch/functions/fetch.d.ts.map +1 -0
- package/dist/types/src/blueprints/websearch/functions/index.d.ts +4 -0
- package/dist/types/src/blueprints/websearch/functions/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/websearch/index.d.ts +3 -3
- package/dist/types/src/blueprints/websearch/index.d.ts.map +1 -1
- package/dist/types/src/blueprints/websearch/{websearch-toolkit.d.ts → toolkit.d.ts} +3 -1
- package/dist/types/src/blueprints/websearch/toolkit.d.ts.map +1 -0
- package/dist/types/src/crud/graph.d.ts +11 -9
- package/dist/types/src/crud/graph.d.ts.map +1 -1
- package/dist/types/src/errors.d.ts +41 -0
- package/dist/types/src/errors.d.ts.map +1 -0
- package/dist/types/src/functions/agent/definitions.d.ts +62 -0
- package/dist/types/src/functions/agent/definitions.d.ts.map +1 -0
- package/dist/types/src/functions/agent/index.d.ts +3 -4
- package/dist/types/src/functions/agent/index.d.ts.map +1 -1
- package/dist/types/src/functions/agent/prompt.d.ts +2 -7
- package/dist/types/src/functions/agent/prompt.d.ts.map +1 -1
- package/dist/types/src/functions/agent/prompt.test.d.ts +2 -0
- package/dist/types/src/functions/agent/prompt.test.d.ts.map +1 -0
- package/dist/types/src/functions/index.d.ts +0 -6
- package/dist/types/src/functions/index.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/sync/sync.d.ts +2 -2
- package/dist/types/src/sync/sync.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +2 -1
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/plugins.d.ts +19 -0
- package/dist/types/src/testing/plugins.d.ts.map +1 -0
- package/dist/types/src/toolkits/WebToolkit.d.ts +38 -0
- package/dist/types/src/toolkits/WebToolkit.d.ts.map +1 -0
- package/dist/types/src/toolkits/index.d.ts +1 -2
- package/dist/types/src/toolkits/index.d.ts.map +1 -1
- package/dist/types/src/types/Agent.d.ts +77 -0
- package/dist/types/src/types/Agent.d.ts.map +1 -0
- package/dist/types/src/types/Chat.d.ts +56 -0
- package/dist/types/src/types/Chat.d.ts.map +1 -0
- package/dist/types/src/types/McpServer.d.ts +21 -0
- package/dist/types/src/types/McpServer.d.ts.map +1 -0
- package/dist/types/src/types/Memory.d.ts +12 -0
- package/dist/types/src/types/Memory.d.ts.map +1 -0
- package/dist/types/src/types/Plan.d.ts +89 -0
- package/dist/types/src/types/Plan.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +6 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/src/util/graphql.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +45 -40
- package/src/blueprints/automation/blueprint.ts +105 -0
- package/src/blueprints/automation/index.ts +5 -0
- package/src/blueprints/blueprint-manager/blueprint.conversations.json +1 -0
- package/src/blueprints/blueprint-manager/blueprint.test.ts +198 -0
- package/src/blueprints/blueprint-manager/blueprint.ts +49 -0
- package/src/blueprints/blueprint-manager/functions/definitions.ts +57 -0
- package/src/blueprints/blueprint-manager/functions/enable-blueprints.ts +43 -0
- package/src/blueprints/blueprint-manager/functions/index.ts +13 -0
- package/src/blueprints/blueprint-manager/functions/query-blueprints.ts +18 -0
- package/src/blueprints/blueprint-manager/functions/update-blueprints.ts +18 -0
- package/src/blueprints/blueprint-manager/index.ts +6 -0
- package/src/blueprints/browser/blueprint.test.ts +61 -0
- package/src/blueprints/browser/blueprint.ts +40 -0
- package/src/blueprints/browser/index.ts +5 -0
- package/src/blueprints/database/blueprint.conversations.json +1 -0
- package/src/blueprints/database/blueprint.test.ts +531 -0
- package/src/blueprints/database/blueprint.ts +66 -0
- package/src/blueprints/database/functions/context-add.ts +24 -0
- package/src/blueprints/database/functions/context-remove.ts +24 -0
- package/src/blueprints/database/functions/definitions.ts +318 -0
- package/src/blueprints/database/functions/index.ts +23 -0
- package/src/blueprints/database/functions/load.ts +19 -0
- package/src/blueprints/database/functions/object-create.ts +38 -0
- package/src/blueprints/database/functions/object-delete.ts +20 -0
- package/src/blueprints/database/functions/object-update.ts +30 -0
- package/src/blueprints/database/functions/query.ts +64 -0
- package/src/blueprints/database/functions/relation-create.ts +34 -0
- package/src/blueprints/database/functions/relation-delete.ts +21 -0
- package/src/blueprints/database/functions/schema-add.ts +28 -0
- package/src/blueprints/database/functions/schema-list.ts +33 -0
- package/src/blueprints/database/functions/tag-add.ts +21 -0
- package/src/blueprints/database/functions/tag-remove.ts +21 -0
- package/src/blueprints/database/index.ts +21 -0
- package/src/blueprints/discord/blueprint.ts +41 -0
- package/src/blueprints/discord/functions/definitions.ts +70 -0
- package/src/blueprints/discord/functions/fetch-messages.test.ts +45 -0
- package/src/blueprints/discord/functions/fetch-messages.ts +198 -0
- package/src/blueprints/discord/functions/index.ts +9 -0
- package/src/blueprints/discord/index.ts +2 -3
- package/src/blueprints/github/functions/definitions.ts +26 -0
- package/src/blueprints/github/functions/fetch-prs.ts +24 -0
- package/src/blueprints/github/functions/index.ts +9 -0
- package/src/blueprints/github/index.ts +5 -0
- package/src/blueprints/index.ts +11 -6
- package/src/blueprints/linear/blueprint.ts +42 -0
- package/src/blueprints/linear/functions/definitions.ts +23 -0
- package/src/blueprints/linear/functions/index.ts +9 -0
- package/src/blueprints/linear/functions/linear.test.ts +58 -0
- package/src/{functions/linear → blueprints/linear/functions}/sync-issues.ts +37 -44
- package/src/blueprints/linear/index.ts +2 -3
- package/src/blueprints/memory/blueprint.conversations.json +1 -0
- package/src/blueprints/memory/blueprint.test.ts +139 -0
- package/src/blueprints/memory/blueprint.ts +41 -0
- package/src/blueprints/memory/functions/definitions.ts +68 -0
- package/src/blueprints/memory/functions/delete.ts +20 -0
- package/src/blueprints/memory/functions/index.ts +13 -0
- package/src/blueprints/memory/functions/query.ts +32 -0
- package/src/blueprints/memory/functions/save.ts +20 -0
- package/src/blueprints/memory/index.ts +6 -0
- package/src/blueprints/planning/blueprint.ts +24 -0
- package/src/blueprints/planning/functions/definitions.ts +137 -0
- package/src/blueprints/planning/functions/index.ts +9 -0
- package/src/blueprints/planning/functions/update-tasks.ts +45 -0
- package/src/blueprints/planning/index.ts +3 -4
- package/src/blueprints/project/blueprint.conversations.json +1 -0
- package/src/blueprints/project/blueprint.test.ts +714 -0
- package/src/blueprints/project/blueprint.ts +64 -0
- package/src/blueprints/project/functions/add-artifact.ts +30 -0
- package/src/blueprints/project/functions/agent.ts +69 -0
- package/src/blueprints/project/functions/definitions.ts +92 -0
- package/src/blueprints/project/functions/get-context.ts +46 -0
- package/src/blueprints/project/functions/index.ts +14 -0
- package/src/blueprints/project/functions/qualifier.ts +90 -0
- package/src/blueprints/project/index.ts +6 -0
- package/src/blueprints/project-wizard/blueprint.ts +52 -0
- package/src/blueprints/project-wizard/functions/create-project.ts +32 -0
- package/src/blueprints/project-wizard/functions/definitions.ts +63 -0
- package/src/blueprints/project-wizard/functions/index.ts +13 -0
- package/src/blueprints/project-wizard/functions/project-rules.ts +77 -0
- package/src/blueprints/project-wizard/functions/sync-triggers.ts +158 -0
- package/src/blueprints/project-wizard/index.ts +6 -0
- package/src/blueprints/testing.ts +23 -8
- package/src/blueprints/websearch/blueprint.conversations.json +1 -0
- package/src/blueprints/websearch/blueprint.test.ts +39 -0
- package/src/blueprints/websearch/blueprint.ts +30 -0
- package/src/blueprints/websearch/functions/definitions.ts +25 -0
- package/src/blueprints/websearch/functions/fetch.ts +18 -0
- package/src/blueprints/websearch/functions/index.ts +9 -0
- package/src/blueprints/websearch/index.ts +3 -4
- package/src/blueprints/websearch/{websearch-toolkit.ts → toolkit.ts} +6 -1
- package/src/crud/graph.test.ts +12 -38
- package/src/crud/graph.ts +15 -18
- package/src/errors.ts +25 -0
- package/src/functions/READ_THIS.md +5 -0
- package/src/functions/agent/definitions.ts +56 -0
- package/src/functions/agent/index.ts +3 -5
- package/src/functions/agent/prompt.conversations.json +1 -0
- package/src/functions/agent/prompt.test.ts +81 -0
- package/src/functions/agent/prompt.ts +212 -105
- package/src/functions/index.ts +0 -6
- package/src/index.ts +2 -2
- package/src/sync/sync.ts +51 -30
- package/src/testing/index.ts +2 -1
- package/src/testing/plugins.tsx +79 -0
- package/src/toolkits/WebToolkit.ts +33 -0
- package/src/toolkits/index.ts +1 -2
- package/src/types/Agent.ts +240 -0
- package/src/types/Chat.ts +63 -0
- package/src/types/McpServer.ts +37 -0
- package/src/types/Memory.ts +24 -0
- package/src/types/Plan.ts +110 -0
- package/src/types/index.ts +9 -0
- package/dist/lib/browser/index.mjs +0 -2789
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/node-esm/index.mjs +0 -2790
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/types/src/blueprints/design/design-blueprint.d.ts +0 -4
- package/dist/types/src/blueprints/design/design-blueprint.d.ts.map +0 -1
- package/dist/types/src/blueprints/design/design-blueprint.test.d.ts +0 -2
- package/dist/types/src/blueprints/design/design-blueprint.test.d.ts.map +0 -1
- package/dist/types/src/blueprints/design/index.d.ts +0 -3
- package/dist/types/src/blueprints/design/index.d.ts.map +0 -1
- package/dist/types/src/blueprints/discord/discord-blueprint.d.ts +0 -19
- package/dist/types/src/blueprints/discord/discord-blueprint.d.ts.map +0 -1
- package/dist/types/src/blueprints/linear/linear-blueprint.d.ts +0 -19
- package/dist/types/src/blueprints/linear/linear-blueprint.d.ts.map +0 -1
- package/dist/types/src/blueprints/planning/planning-blueprint.d.ts +0 -4
- package/dist/types/src/blueprints/planning/planning-blueprint.d.ts.map +0 -1
- package/dist/types/src/blueprints/planning/planning-blueprint.test.d.ts +0 -2
- package/dist/types/src/blueprints/planning/planning-blueprint.test.d.ts.map +0 -1
- package/dist/types/src/blueprints/research/index.d.ts +0 -3
- package/dist/types/src/blueprints/research/index.d.ts.map +0 -1
- package/dist/types/src/blueprints/research/research-blueprint.d.ts +0 -4
- package/dist/types/src/blueprints/research/research-blueprint.d.ts.map +0 -1
- package/dist/types/src/blueprints/research/research-blueprint.test.d.ts +0 -2
- package/dist/types/src/blueprints/research/research-blueprint.test.d.ts.map +0 -1
- package/dist/types/src/blueprints/websearch/websearch-blueprint.d.ts +0 -4
- package/dist/types/src/blueprints/websearch/websearch-blueprint.d.ts.map +0 -1
- package/dist/types/src/blueprints/websearch/websearch-toolkit.d.ts.map +0 -1
- package/dist/types/src/experimental/feed.test.d.ts +0 -2
- package/dist/types/src/experimental/feed.test.d.ts.map +0 -1
- package/dist/types/src/functions/discord/fetch-messages.d.ts.map +0 -1
- package/dist/types/src/functions/discord/fetch-messages.test.d.ts.map +0 -1
- package/dist/types/src/functions/discord/index.d.ts +0 -12
- package/dist/types/src/functions/discord/index.d.ts.map +0 -1
- package/dist/types/src/functions/document/index.d.ts +0 -13
- package/dist/types/src/functions/document/index.d.ts.map +0 -1
- package/dist/types/src/functions/document/read.d.ts +0 -7
- package/dist/types/src/functions/document/read.d.ts.map +0 -1
- package/dist/types/src/functions/document/update.d.ts +0 -6
- package/dist/types/src/functions/document/update.d.ts.map +0 -1
- package/dist/types/src/functions/entity-extraction/entity-extraction.d.ts +0 -172
- package/dist/types/src/functions/entity-extraction/entity-extraction.d.ts.map +0 -1
- package/dist/types/src/functions/entity-extraction/entity-extraction.test.d.ts +0 -2
- package/dist/types/src/functions/entity-extraction/entity-extraction.test.d.ts.map +0 -1
- package/dist/types/src/functions/entity-extraction/index.d.ts +0 -173
- package/dist/types/src/functions/entity-extraction/index.d.ts.map +0 -1
- package/dist/types/src/functions/exa/exa.d.ts +0 -5
- package/dist/types/src/functions/exa/exa.d.ts.map +0 -1
- package/dist/types/src/functions/exa/index.d.ts +0 -3
- package/dist/types/src/functions/exa/index.d.ts.map +0 -1
- package/dist/types/src/functions/exa/mock.d.ts +0 -5
- package/dist/types/src/functions/exa/mock.d.ts.map +0 -1
- package/dist/types/src/functions/github/fetch-prs.d.ts +0 -6
- package/dist/types/src/functions/github/fetch-prs.d.ts.map +0 -1
- package/dist/types/src/functions/linear/index.d.ts +0 -9
- package/dist/types/src/functions/linear/index.d.ts.map +0 -1
- package/dist/types/src/functions/linear/linear.test.d.ts.map +0 -1
- package/dist/types/src/functions/linear/sync-issues.d.ts +0 -12
- package/dist/types/src/functions/linear/sync-issues.d.ts.map +0 -1
- package/dist/types/src/functions/research/document-create.d.ts +0 -9
- package/dist/types/src/functions/research/document-create.d.ts.map +0 -1
- package/dist/types/src/functions/research/index.d.ts +0 -21
- package/dist/types/src/functions/research/index.d.ts.map +0 -1
- package/dist/types/src/functions/research/research-graph.d.ts +0 -19
- package/dist/types/src/functions/research/research-graph.d.ts.map +0 -1
- package/dist/types/src/functions/research/research.d.ts +0 -14
- package/dist/types/src/functions/research/research.d.ts.map +0 -1
- package/dist/types/src/functions/research/research.test.d.ts +0 -2
- package/dist/types/src/functions/research/research.test.d.ts.map +0 -1
- package/dist/types/src/functions/research/types.d.ts +0 -6
- package/dist/types/src/functions/research/types.d.ts.map +0 -1
- package/dist/types/src/functions/tasks/index.d.ts +0 -15
- package/dist/types/src/functions/tasks/index.d.ts.map +0 -1
- package/dist/types/src/functions/tasks/read.d.ts +0 -7
- package/dist/types/src/functions/tasks/read.d.ts.map +0 -1
- package/dist/types/src/functions/tasks/task-list.d.ts +0 -74
- package/dist/types/src/functions/tasks/task-list.d.ts.map +0 -1
- package/dist/types/src/functions/tasks/task-list.test.d.ts +0 -2
- package/dist/types/src/functions/tasks/task-list.test.d.ts.map +0 -1
- package/dist/types/src/functions/tasks/update.d.ts +0 -9
- package/dist/types/src/functions/tasks/update.d.ts.map +0 -1
- package/dist/types/src/plugins.d.ts +0 -19
- package/dist/types/src/plugins.d.ts.map +0 -1
- package/dist/types/src/testing/data/exa-search-1748337321991.d.ts +0 -38
- package/dist/types/src/testing/data/exa-search-1748337321991.d.ts.map +0 -1
- package/dist/types/src/testing/data/exa-search-1748337331526.d.ts +0 -37
- package/dist/types/src/testing/data/exa-search-1748337331526.d.ts.map +0 -1
- package/dist/types/src/testing/data/exa-search-1748337344119.d.ts +0 -58
- package/dist/types/src/testing/data/exa-search-1748337344119.d.ts.map +0 -1
- package/dist/types/src/testing/data/index.d.ts +0 -3
- package/dist/types/src/testing/data/index.d.ts.map +0 -1
- package/dist/types/src/toolkits/AssistantToolkit.d.ts +0 -17
- package/dist/types/src/toolkits/AssistantToolkit.d.ts.map +0 -1
- package/dist/types/src/toolkits/AssistantToolkit.test.d.ts +0 -2
- package/dist/types/src/toolkits/AssistantToolkit.test.d.ts.map +0 -1
- package/dist/types/src/toolkits/SystemToolkit.d.ts +0 -67
- package/dist/types/src/toolkits/SystemToolkit.d.ts.map +0 -1
- package/src/blueprints/design/design-blueprint.test.ts +0 -105
- package/src/blueprints/design/design-blueprint.ts +0 -33
- package/src/blueprints/design/index.ts +0 -7
- package/src/blueprints/discord/discord-blueprint.ts +0 -34
- package/src/blueprints/linear/linear-blueprint.ts +0 -35
- package/src/blueprints/planning/planning-blueprint.test.ts +0 -126
- package/src/blueprints/planning/planning-blueprint.ts +0 -98
- package/src/blueprints/research/index.ts +0 -7
- package/src/blueprints/research/research-blueprint.test.ts +0 -7
- package/src/blueprints/research/research-blueprint.ts +0 -53
- package/src/blueprints/websearch/websearch-blueprint.ts +0 -20
- package/src/experimental/feed.test.ts +0 -111
- package/src/functions/discord/fetch-messages.test.ts +0 -58
- package/src/functions/discord/fetch-messages.ts +0 -252
- package/src/functions/discord/index.ts +0 -9
- package/src/functions/document/index.ts +0 -12
- package/src/functions/document/read.ts +0 -30
- package/src/functions/document/update.ts +0 -31
- package/src/functions/entity-extraction/entity-extraction.conversations.json +0 -1
- package/src/functions/entity-extraction/entity-extraction.test.ts +0 -93
- package/src/functions/entity-extraction/entity-extraction.ts +0 -174
- package/src/functions/entity-extraction/index.ts +0 -9
- package/src/functions/exa/exa.ts +0 -37
- package/src/functions/exa/index.ts +0 -6
- package/src/functions/exa/mock.ts +0 -71
- package/src/functions/github/fetch-prs.ts +0 -30
- package/src/functions/linear/index.ts +0 -9
- package/src/functions/linear/linear.test.ts +0 -84
- package/src/functions/research/document-create.ts +0 -76
- package/src/functions/research/index.ts +0 -14
- package/src/functions/research/research-graph.ts +0 -49
- package/src/functions/research/research-instructions.tpl +0 -106
- package/src/functions/research/research.conversations.json +0 -1
- package/src/functions/research/research.test.ts +0 -175
- package/src/functions/research/research.ts +0 -191
- package/src/functions/research/types.ts +0 -26
- package/src/functions/tasks/index.ts +0 -11
- package/src/functions/tasks/read.ts +0 -35
- package/src/functions/tasks/task-list.test.ts +0 -99
- package/src/functions/tasks/task-list.ts +0 -165
- package/src/functions/tasks/update.ts +0 -53
- package/src/plugins.tsx +0 -68
- package/src/testing/data/exa-search-1748337321991.ts +0 -131
- package/src/testing/data/exa-search-1748337331526.ts +0 -144
- package/src/testing/data/exa-search-1748337344119.ts +0 -133
- package/src/testing/data/index.ts +0 -11
- package/src/toolkits/AssistantToolkit.conversations.json +0 -1
- package/src/toolkits/AssistantToolkit.test.ts +0 -90
- package/src/toolkits/AssistantToolkit.ts +0 -47
- package/src/toolkits/SystemToolkit.ts +0 -231
- /package/dist/types/src/{functions/discord → blueprints/discord/functions}/fetch-messages.test.d.ts +0 -0
- /package/dist/types/src/{functions/linear → blueprints/linear/functions}/linear.test.d.ts +0 -0
package/src/crud/graph.ts
CHANGED
|
@@ -13,6 +13,8 @@ import * as SchemaAST from 'effect/SchemaAST';
|
|
|
13
13
|
|
|
14
14
|
import { Entity, Filter, Obj, Query, Type } from '@dxos/echo';
|
|
15
15
|
import { Database } from '@dxos/echo';
|
|
16
|
+
import { type Queue } from '@dxos/echo-db';
|
|
17
|
+
import { isEncodedReference } from '@dxos/echo-protocol';
|
|
16
18
|
import {
|
|
17
19
|
ReferenceAnnotationId,
|
|
18
20
|
RelationSourceDXNId,
|
|
@@ -23,8 +25,6 @@ import {
|
|
|
23
25
|
getTypeAnnotation,
|
|
24
26
|
getTypeIdentifierAnnotation,
|
|
25
27
|
} from '@dxos/echo/internal';
|
|
26
|
-
import { type EchoDatabase, type Queue } from '@dxos/echo-db';
|
|
27
|
-
import { isEncodedReference } from '@dxos/echo-protocol';
|
|
28
28
|
import { mapAst } from '@dxos/effect';
|
|
29
29
|
import { ContextQueueService } from '@dxos/functions';
|
|
30
30
|
import { DXN, ObjectId } from '@dxos/keys';
|
|
@@ -40,7 +40,7 @@ export const Subgraph = Schema.Struct({
|
|
|
40
40
|
export interface Subgraph extends Schema.Schema.Type<typeof Subgraph> {}
|
|
41
41
|
|
|
42
42
|
export type RelatedSchema = {
|
|
43
|
-
schema:
|
|
43
|
+
schema: Type.AnyEntity;
|
|
44
44
|
kind: 'reference' | 'relation';
|
|
45
45
|
};
|
|
46
46
|
|
|
@@ -51,12 +51,9 @@ export type RelatedSchema = {
|
|
|
51
51
|
* @param schema
|
|
52
52
|
* @returns
|
|
53
53
|
*/
|
|
54
|
-
export const findRelatedSchema = async (
|
|
55
|
-
db: EchoDatabase,
|
|
56
|
-
anchor: Schema.Schema.AnyNoContext,
|
|
57
|
-
): Promise<RelatedSchema[]> => {
|
|
54
|
+
export const findRelatedSchema = async (db: Database.Database, anchor: Type.AnyEntity): Promise<RelatedSchema[]> => {
|
|
58
55
|
// TODO(dmaretskyi): Query stored schemas.
|
|
59
|
-
const allSchemas =
|
|
56
|
+
const allSchemas = await db.graph.schemaRegistry.query().run();
|
|
60
57
|
|
|
61
58
|
// TODO(dmaretskyi): Also do references.
|
|
62
59
|
return allSchemas
|
|
@@ -72,8 +69,8 @@ export const findRelatedSchema = async (
|
|
|
72
69
|
})
|
|
73
70
|
.map(
|
|
74
71
|
(schema): RelatedSchema => ({
|
|
75
|
-
schema,
|
|
76
72
|
kind: 'relation',
|
|
73
|
+
schema,
|
|
77
74
|
}),
|
|
78
75
|
);
|
|
79
76
|
};
|
|
@@ -82,7 +79,7 @@ export const findRelatedSchema = async (
|
|
|
82
79
|
* Non-strict DXN comparison.
|
|
83
80
|
* Returns true if the DXN could be resolved to the schema.
|
|
84
81
|
*/
|
|
85
|
-
const isSchemaAddressableByDxn = (schema:
|
|
82
|
+
const isSchemaAddressableByDxn = (schema: Type.AnyEntity, dxn: DXN): boolean => {
|
|
86
83
|
if (getTypeIdentifierAnnotation(schema) === dxn.toString()) {
|
|
87
84
|
return true;
|
|
88
85
|
}
|
|
@@ -115,7 +112,7 @@ export const LocalSearchToolkit = Toolkit.make(
|
|
|
115
112
|
|
|
116
113
|
export const LocalSearchHandler = LocalSearchToolkit.toLayer({
|
|
117
114
|
search_local_search: Effect.fn(function* ({ query }) {
|
|
118
|
-
const objects = yield* Database.
|
|
115
|
+
const objects = yield* Database.runQuery(Query.select(Filter.text(query, { type: 'vector' })));
|
|
119
116
|
const results = [...objects];
|
|
120
117
|
|
|
121
118
|
const option = yield* Effect.serviceOption(ContextQueueService);
|
|
@@ -139,14 +136,14 @@ export const LocalSearchHandler = LocalSearchToolkit.toLayer({
|
|
|
139
136
|
class GraphWriterSchema extends Context.Tag('@dxos/assistant/GraphWriterSchema')<
|
|
140
137
|
GraphWriterSchema,
|
|
141
138
|
{
|
|
142
|
-
schema:
|
|
139
|
+
schema: Type.AnyEntity[];
|
|
143
140
|
}
|
|
144
141
|
>() {}
|
|
145
142
|
|
|
146
143
|
/**
|
|
147
144
|
* Forms typed objects that can be written to the graph database.
|
|
148
145
|
*/
|
|
149
|
-
export const makeGraphWriterToolkit = ({ schema }: { schema:
|
|
146
|
+
export const makeGraphWriterToolkit = ({ schema }: { schema: Type.AnyEntity[] }) => {
|
|
150
147
|
return Toolkit.make(
|
|
151
148
|
Tool.make('graph_writer', {
|
|
152
149
|
description: 'Write to the local graph database',
|
|
@@ -176,7 +173,7 @@ export const makeGraphWriterHandler = (
|
|
|
176
173
|
const { db } = yield* Database.Service;
|
|
177
174
|
const { queue } = yield* ContextQueueService;
|
|
178
175
|
const data = yield* Effect.promise(() => sanitizeObjects(schema, input as any, db, queue));
|
|
179
|
-
yield* Effect.promise(() => queue.append(data as Obj.
|
|
176
|
+
yield* Effect.promise(() => queue.append(data as Obj.Unknown[]));
|
|
180
177
|
|
|
181
178
|
const dxns = data.map((obj) => Obj.getDXN(obj));
|
|
182
179
|
onAppend?.(dxns);
|
|
@@ -188,7 +185,7 @@ export const makeGraphWriterHandler = (
|
|
|
188
185
|
/**
|
|
189
186
|
* Create a schema for structured data extraction.
|
|
190
187
|
*/
|
|
191
|
-
export const createExtractionSchema = (types:
|
|
188
|
+
export const createExtractionSchema = (types: Type.AnyEntity[]) => {
|
|
192
189
|
return Schema.Struct({
|
|
193
190
|
...Object.fromEntries(
|
|
194
191
|
types.map(preprocessSchema).map((schema, index) => [
|
|
@@ -201,18 +198,18 @@ export const createExtractionSchema = (types: Schema.Schema.AnyNoContext[]) => {
|
|
|
201
198
|
});
|
|
202
199
|
};
|
|
203
200
|
|
|
204
|
-
export const getSanitizedSchemaName = (schema:
|
|
201
|
+
export const getSanitizedSchemaName = (schema: Type.AnyEntity) => {
|
|
205
202
|
return Type.getDXN(schema)!
|
|
206
203
|
.asTypeDXN()!
|
|
207
204
|
.type.replaceAll(/[^a-zA-Z0-9]+/g, '_');
|
|
208
205
|
};
|
|
209
206
|
|
|
210
207
|
export const sanitizeObjects = async (
|
|
211
|
-
types:
|
|
208
|
+
types: Type.AnyEntity[],
|
|
212
209
|
data: Record<string, readonly unknown[]>,
|
|
213
210
|
db: Database.Database,
|
|
214
211
|
queue?: Queue,
|
|
215
|
-
): Promise<Obj.
|
|
212
|
+
): Promise<Obj.Unknown[]> => {
|
|
216
213
|
const entries = types
|
|
217
214
|
.map(
|
|
218
215
|
(type) =>
|
package/src/errors.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { BaseError } from '@dxos/errors';
|
|
6
|
+
import { DXN } from '@dxos/keys';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Agent could not execute prompt.
|
|
10
|
+
*/
|
|
11
|
+
export class PromptError extends BaseError.extend('PromptError') {
|
|
12
|
+
constructor(
|
|
13
|
+
message: string,
|
|
14
|
+
context: {
|
|
15
|
+
description?: string;
|
|
16
|
+
prompt?: DXN.String;
|
|
17
|
+
chat?: DXN.String;
|
|
18
|
+
},
|
|
19
|
+
) {
|
|
20
|
+
super({
|
|
21
|
+
message,
|
|
22
|
+
context,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { AiService, OpaqueToolkit, ModelName } from '@dxos/ai';
|
|
8
|
+
import { Routine, Trace, Operation, OperationRegistry } from '@dxos/compute';
|
|
9
|
+
import { Database, Feed, Ref } from '@dxos/echo';
|
|
10
|
+
import { Text } from '@dxos/schema';
|
|
11
|
+
|
|
12
|
+
import * as Chat from '../../types/Chat';
|
|
13
|
+
|
|
14
|
+
// TODO(dmaretskyi): Rename to RunRoutine.
|
|
15
|
+
export const AgentPrompt = Operation.make({
|
|
16
|
+
meta: {
|
|
17
|
+
key: 'org.dxos.function.prompt',
|
|
18
|
+
name: 'Run Routine',
|
|
19
|
+
description: 'Agentic worker that executes a provided prompt using blueprints and tools.',
|
|
20
|
+
},
|
|
21
|
+
input: Schema.Struct({
|
|
22
|
+
prompt: Ref.Ref(Routine.Routine),
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* When set, runs in this chat (history, queue, and bound context). Routine blueprints and context objects are merged into the conversation for this request.
|
|
26
|
+
*/
|
|
27
|
+
chat: Schema.optional(Ref.Ref(Chat.Chat)),
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @default @anthropic/claude-opus-4-6
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
model: Schema.optional(ModelName),
|
|
34
|
+
/**
|
|
35
|
+
* Input object or data.
|
|
36
|
+
* References get auto-resolved.
|
|
37
|
+
*/
|
|
38
|
+
input: Schema.Any.pipe(Schema.annotations({ title: 'Input' })),
|
|
39
|
+
|
|
40
|
+
systemInstructions: Schema.optional(Schema.String).annotations({
|
|
41
|
+
description: 'Additional system instructions to add to the system prompt.',
|
|
42
|
+
}),
|
|
43
|
+
}),
|
|
44
|
+
output: Schema.Any,
|
|
45
|
+
// ECHO types that the handler loads via Database.load(). Declaring them here ensures the
|
|
46
|
+
// runtime registers their schema before remote invocation (e.g. via the EDGE function service).
|
|
47
|
+
types: [Routine.Routine, Text.Text, Feed.Feed, Chat.Chat],
|
|
48
|
+
services: [
|
|
49
|
+
AiService.AiService,
|
|
50
|
+
Database.Service,
|
|
51
|
+
Feed.FeedService,
|
|
52
|
+
OpaqueToolkit.OpaqueToolkitProvider,
|
|
53
|
+
OperationRegistry.Service,
|
|
54
|
+
Trace.TraceService,
|
|
55
|
+
],
|
|
56
|
+
}).pipe(Operation.intrinsic);
|
|
@@ -2,10 +2,8 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { OperationHandlerSet } from '@dxos/compute';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
export * from './definitions';
|
|
8
8
|
|
|
9
|
-
export
|
|
10
|
-
export const prompt: FunctionDefinition.Any = prompt$; // TODO(burdon): Temp fix for TS error.
|
|
11
|
-
}
|
|
9
|
+
export const AgentHandlers = OperationHandlerSet.lazy(() => import('./prompt'));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"conversations":[{"parameters":{"model":"@anthropic/claude-opus-4-6","stream":true,"tools":[{"name":"completeJob","inputSchema":{"type":"object","required":[],"properties":{"success":{"$id":"/schemas/any","title":"any"},"failure":{"type":"object","required":["message"],"properties":{"message":{"type":"string","description":"Short message describing the error."},"description":{"type":"string","description":"Optional longer message describing in detail what went wrong"}},"additionalProperties":false}},"additionalProperties":false}}]},"prompt":{"content":[{"role":"system","content":"You are an agent running in the non-interactive mode.\nThe user is unable to see what you are doing, and cannot answer any questions.\nDo not ask questions.\nComplete the task before you, and at the end call [completeJob] with the output.\nIf you are unable to complete the task, call [completeJob] with the failure reason.\nIf no output is required, call [completeJob] with an empty object: {}\nDo not stop until you call [completeJob].","options":{}},{"role":"user","content":"Reply with a single word: ack.\n<input>{}</input>","options":{"anthropic":{"cacheControl":{"ttl":"5m","type":"ephemeral"}}}}]},"response":[{"type":"response-metadata","id":"msg_01BNfgUBNqETGfNka6Y58SUS","modelId":"claude-opus-4-6","timestamp":"1970-01-01T00:00:00.000Z","metadata":{}},{"type":"reasoning-start","id":"0","metadata":{}},{"type":"reasoning-delta","id":"0","delta":"The","metadata":{}},{"type":"reasoning-delta","id":"0","delta":" user wants me to reply with a single word \"ack\" and complete the job.","metadata":{}},{"type":"reasoning-delta","id":"0","delta":"","metadata":{"anthropic":{"type":"thinking","signature":"EoQCClkIDRgCKkDmvWuElJmvgQqKv/OM8h45Qm9vFiau8OtHTiKeFGzABfFt5k5Oc9XiWXg1jeCrSXFmAcI3XEaKXp6jF8PCj/O0Mg9jbGF1ZGUtb3B1cy00LTY4ABIMidROWDebGP+ji8voGgyiyrnCLJU9DZTeWc0iMJ5ewfC96fa6DHSOj+APcM0VyN0tJiYPjIJI7DxYTiu277zCDVNdAUxNb/k45dQGripZikOeASjJaTuovSm8Ni01mepSojCietSMDfM1xBLbnyPHKxucO7akJRwDczuw8req/NjtOhY492FCt1lagajkZq8/rsICFxutxbPXyHXSY04cd/2+oY9cRAQYAQ=="}}},{"type":"reasoning-end","id":"0","metadata":{}},{"type":"tool-params-start","id":"toolu_01VQiUHtyF77TZd49DrKhnPR","name":"completeJob","providerExecuted":false,"metadata":{}},{"type":"tool-params-delta","id":"toolu_01VQiUHtyF77TZd49DrKhnPR","delta":"","metadata":{}},{"type":"tool-params-delta","id":"toolu_01VQiUHtyF77TZd49DrKhnPR","delta":"{\"success","metadata":{}},{"type":"tool-params-delta","id":"toolu_01VQiUHtyF77TZd49DrKhnPR","delta":"\": \"ack\"}","metadata":{}},{"type":"tool-params-end","id":"toolu_01VQiUHtyF77TZd49DrKhnPR","metadata":{}},{"type":"finish","reason":"tool-calls","usage":{"inputTokens":757,"outputTokens":89,"totalTokens":846},"metadata":{"anthropic":{"usage":{"cache_creation":{"ephemeral_1h_input_tokens":0,"ephemeral_5m_input_tokens":0},"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"input_tokens":757,"output_tokens":9,"server_tool_use":null,"service_tier":"standard"}}}}]},{"parameters":{"model":"@anthropic/claude-opus-4-6","stream":true,"tools":[{"name":"completeJob","inputSchema":{"type":"object","required":[],"properties":{"success":{"$id":"/schemas/any","title":"any"},"failure":{"type":"object","required":["message"],"properties":{"message":{"type":"string","description":"Short message describing the error."},"description":{"type":"string","description":"Optional longer message describing in detail what went wrong"}},"additionalProperties":false}},"additionalProperties":false}}]},"prompt":{"content":[{"role":"system","content":"You are an agent running in the non-interactive mode.\nThe user is unable to see what you are doing, and cannot answer any questions.\nDo not ask questions.\nComplete the task before you, and at the end call [completeJob] with the output.\nIf you are unable to complete the task, call [completeJob] with the failure reason.\nIf no output is required, call [completeJob] with an empty object: {}\nDo not stop until you call [completeJob].","options":{}},{"role":"user","content":"Reply with a single word: ack.\n<input>{}</input>","options":{}},{"role":"assistant","content":[{"type":"reasoning","text":"The user wants me to reply with a single word \"ack\" and complete the job.","options":{}},{"type":"tool-call","id":"toolu_01VQiUHtyF77TZd49DrKhnPR","name":"completeJob","params":{"success":"ack"},"providerExecuted":false,"options":{}}],"options":{}},{"role":"tool","content":[{"type":"tool-result","id":"toolu_01VQiUHtyF77TZd49DrKhnPR","name":"completeJob","isFailure":false,"result":{},"providerExecuted":false,"options":{}}],"options":{"anthropic":{"cacheControl":{"ttl":"5m","type":"ephemeral"}}}}]},"response":[{"type":"response-metadata","id":"msg_017Q7gpzDqQTqmKWouYU2oKt","modelId":"claude-opus-4-6","timestamp":"1970-01-01T00:00:00.000Z","metadata":{}},{"type":"finish","reason":"stop","usage":{"inputTokens":824,"outputTokens":2,"totalTokens":826},"metadata":{"anthropic":{"usage":{"cache_creation":{"ephemeral_1h_input_tokens":0,"ephemeral_5m_input_tokens":0},"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"input_tokens":824,"output_tokens":2,"server_tool_use":null,"service_tier":"standard"}}}}]}]}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { describe, expect, it } from '@effect/vitest';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
|
|
8
|
+
import { ContextBinding } from '@dxos/assistant';
|
|
9
|
+
import { Routine, Operation, OperationHandlerSet } from '@dxos/compute';
|
|
10
|
+
import { Database, Feed, Obj, Ref } from '@dxos/echo';
|
|
11
|
+
import { TestHelpers } from '@dxos/effect/testing';
|
|
12
|
+
import { QueueService } from '@dxos/functions';
|
|
13
|
+
import { AssistantTestLayer } from '@dxos/functions-runtime/testing';
|
|
14
|
+
import { ObjectId } from '@dxos/keys';
|
|
15
|
+
import { Text } from '@dxos/schema';
|
|
16
|
+
import { Message } from '@dxos/types';
|
|
17
|
+
|
|
18
|
+
import * as Chat from '../../types/Chat';
|
|
19
|
+
import { AgentPrompt } from './definitions';
|
|
20
|
+
import defaultAgentPrompt from './prompt';
|
|
21
|
+
|
|
22
|
+
ObjectId.dangerouslyDisableRandomness();
|
|
23
|
+
|
|
24
|
+
const operationHandlerSet = OperationHandlerSet.make(defaultAgentPrompt);
|
|
25
|
+
|
|
26
|
+
const TestLayer = AssistantTestLayer({
|
|
27
|
+
operationHandlers: operationHandlerSet,
|
|
28
|
+
types: [Chat.Chat, Message.Message, ContextBinding, Text.Text],
|
|
29
|
+
aiServicePreset: 'edge-remote',
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const countQueueMessages = (queue: { queryObjects: () => Promise<Obj.Unknown[]> }) =>
|
|
33
|
+
Effect.promise(async () => {
|
|
34
|
+
const items = await queue.queryObjects();
|
|
35
|
+
return items.filter(Obj.instanceOf(Message.Message)).length;
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
describe('Agent prompt', () => {
|
|
39
|
+
it.effect(
|
|
40
|
+
'chat mode appends assistant messages to the chat queue',
|
|
41
|
+
Effect.fnUntraced(
|
|
42
|
+
function* (_) {
|
|
43
|
+
const feed = yield* Database.add(Feed.make());
|
|
44
|
+
const queueDxn = Feed.getQueueDxn(feed)!;
|
|
45
|
+
const queue = yield* QueueService.getQueue<Message.Message | ContextBinding>(queueDxn);
|
|
46
|
+
const messageCountBefore = yield* countQueueMessages(queue);
|
|
47
|
+
|
|
48
|
+
const chat = yield* Database.add(
|
|
49
|
+
Chat.make({
|
|
50
|
+
feed: Ref.make(feed),
|
|
51
|
+
}),
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const prompt = yield* Database.add(
|
|
55
|
+
Routine.make({
|
|
56
|
+
name: 'chat-mode-test',
|
|
57
|
+
instructions: 'Reply with a single word: ack.',
|
|
58
|
+
blueprints: [],
|
|
59
|
+
context: [],
|
|
60
|
+
}),
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
yield* Database.flush();
|
|
64
|
+
|
|
65
|
+
const result = yield* Operation.invoke(AgentPrompt, {
|
|
66
|
+
prompt: Ref.make(prompt),
|
|
67
|
+
input: {},
|
|
68
|
+
chat: Ref.make(chat),
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const messageCountAfter = yield* countQueueMessages(queue);
|
|
72
|
+
|
|
73
|
+
expect(messageCountAfter).toBeGreaterThan(messageCountBefore);
|
|
74
|
+
expect(result).toBe('ack');
|
|
75
|
+
},
|
|
76
|
+
Effect.provide(TestLayer),
|
|
77
|
+
TestHelpers.provideTestContext,
|
|
78
|
+
),
|
|
79
|
+
{ timeout: 60_000 },
|
|
80
|
+
);
|
|
81
|
+
});
|
|
@@ -2,116 +2,223 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import * as Tool from '@effect/ai/Tool';
|
|
6
|
+
import * as Toolkit from '@effect/ai/Toolkit';
|
|
5
7
|
import * as Array from 'effect/Array';
|
|
8
|
+
import * as Deferred from 'effect/Deferred';
|
|
6
9
|
import * as Effect from 'effect/Effect';
|
|
7
10
|
import * as Function from 'effect/Function';
|
|
8
|
-
import * as
|
|
11
|
+
import * as Layer from 'effect/Layer';
|
|
9
12
|
import * as Option from 'effect/Option';
|
|
10
13
|
import * as Schema from 'effect/Schema';
|
|
11
14
|
|
|
12
|
-
import { AiService,
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
import { AiService, OpaqueToolkit, ModelName } from '@dxos/ai';
|
|
16
|
+
import {
|
|
17
|
+
AiSession,
|
|
18
|
+
getOperationFromTool,
|
|
19
|
+
makeToolExecutionService,
|
|
20
|
+
makeToolResolverFromOperations,
|
|
21
|
+
} from '@dxos/assistant';
|
|
22
|
+
import { Template, Trace, Operation } from '@dxos/compute';
|
|
23
|
+
import { Database, Feed, Obj, Ref } from '@dxos/echo';
|
|
24
|
+
import { acquireReleaseResource } from '@dxos/effect';
|
|
25
|
+
import { invariant } from '@dxos/invariant';
|
|
18
26
|
import { log } from '@dxos/log';
|
|
27
|
+
import { trim } from '@dxos/util';
|
|
19
28
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
29
|
+
import { PromptError } from '../../errors';
|
|
30
|
+
import * as Chat from '../../types/Chat';
|
|
31
|
+
import { AgentPrompt } from './definitions';
|
|
32
|
+
|
|
33
|
+
const DEFAULT_MODEL: ModelName = '@anthropic/claude-opus-4-6';
|
|
34
|
+
|
|
35
|
+
export default AgentPrompt.pipe(
|
|
36
|
+
Operation.withHandler(
|
|
37
|
+
Effect.fnUntraced(
|
|
38
|
+
function* (data) {
|
|
39
|
+
log.info('processing input', { input: data.input });
|
|
40
|
+
|
|
41
|
+
const input = yield* Ref.isRef(data.input)
|
|
42
|
+
? Database.load(data.input).pipe(Effect.map(Obj.toJSON))
|
|
43
|
+
: Effect.succeed(data.input);
|
|
44
|
+
|
|
45
|
+
yield* Database.flush();
|
|
46
|
+
const prompt = yield* Database.load(data.prompt);
|
|
47
|
+
yield* Trace.emitStatus(`Running ${prompt.id}`);
|
|
48
|
+
|
|
49
|
+
log.info('starting agent', { prompt: prompt.id, input });
|
|
50
|
+
|
|
51
|
+
const blueprints = yield* Function.pipe(
|
|
52
|
+
prompt.blueprints,
|
|
53
|
+
Effect.forEach(Database.loadOption),
|
|
54
|
+
Effect.map(Array.filter(Option.isSome)),
|
|
55
|
+
Effect.map(Array.map((option) => option.value)),
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const objects = yield* Function.pipe(
|
|
59
|
+
prompt.context,
|
|
60
|
+
Effect.forEach(Database.loadOption),
|
|
61
|
+
Effect.map(Array.filter(Option.isSome)),
|
|
62
|
+
Effect.map(Array.map((option) => option.value)),
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const promptInstructions = yield* Database.load(prompt.instructions.source);
|
|
66
|
+
let promptText = Template.process(promptInstructions.content, input);
|
|
67
|
+
|
|
68
|
+
if (input !== undefined) {
|
|
69
|
+
promptText += `\n<input>${JSON.stringify(input)}</input>`;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
let systemText = trim`
|
|
73
|
+
You are an agent running in the non-interactive mode.
|
|
74
|
+
The user is unable to see what you are doing, and cannot answer any questions.
|
|
75
|
+
Do not ask questions.
|
|
76
|
+
Complete the task before you, and at the end call [completeJob] with the output.
|
|
77
|
+
If you are unable to complete the task, call [completeJob] with the failure reason.
|
|
78
|
+
If no output is required, call [completeJob] with an empty object: {}
|
|
79
|
+
Do not stop until you call [completeJob].
|
|
80
|
+
`;
|
|
81
|
+
if (data.systemInstructions) {
|
|
82
|
+
systemText += `\n\n${data.systemInstructions}`;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const modelLayer = AiService.model(data.model ?? DEFAULT_MODEL);
|
|
86
|
+
|
|
87
|
+
let feed: Feed.Feed;
|
|
88
|
+
if (data.chat) {
|
|
89
|
+
const chat = yield* Database.load(data.chat);
|
|
90
|
+
invariant(Obj.instanceOf(Chat.Chat, chat), 'Expected Chat object.');
|
|
91
|
+
feed = yield* Database.load(chat.feed);
|
|
92
|
+
} else {
|
|
93
|
+
feed = yield* Database.add(Feed.make());
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const resultSink = yield* Deferred.make<unknown, PromptError>();
|
|
97
|
+
const promptToolkit = makePromptAgentToolkit({
|
|
98
|
+
output: Schema.Any, // TODO(dmaretskyi): Use prompt's output schema.
|
|
99
|
+
resultSink,
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
const runtime = yield* Effect.runtime<Feed.FeedService>();
|
|
103
|
+
const session = yield* acquireReleaseResource(() => new AiSession({ feed, runtime }));
|
|
104
|
+
|
|
105
|
+
yield* Effect.promise(() =>
|
|
106
|
+
session.context.bind({
|
|
107
|
+
blueprints: blueprints.map((blueprint) => Ref.make(blueprint)),
|
|
108
|
+
objects: objects.map((object) => Ref.make(object as Obj.Unknown)),
|
|
109
|
+
}),
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
yield* session
|
|
113
|
+
.createRequest({
|
|
114
|
+
prompt: promptText,
|
|
115
|
+
system: systemText,
|
|
116
|
+
toolkit: promptToolkit,
|
|
117
|
+
})
|
|
118
|
+
.pipe(
|
|
119
|
+
Effect.provide(
|
|
120
|
+
Layer.mergeAll(modelLayer, ToolExecutionService({ feed }), makeToolResolverFromOperations()),
|
|
121
|
+
),
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
return yield* Deferred.poll(resultSink).pipe(
|
|
125
|
+
Effect.flatten,
|
|
126
|
+
Effect.flatten,
|
|
127
|
+
Effect.catchTag('NoSuchElementException', () =>
|
|
128
|
+
Effect.gen(function* () {
|
|
129
|
+
yield* session
|
|
130
|
+
.createRequest({
|
|
131
|
+
prompt: 'You must signal task completion by calling [completeJob] with the output or failure reason.',
|
|
132
|
+
system: systemText,
|
|
133
|
+
toolkit: promptToolkit,
|
|
134
|
+
})
|
|
135
|
+
.pipe(
|
|
136
|
+
Effect.provide(
|
|
137
|
+
Layer.mergeAll(modelLayer, ToolExecutionService({ feed }), makeToolResolverFromOperations()),
|
|
138
|
+
),
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
return yield* Deferred.poll(resultSink).pipe(
|
|
142
|
+
Effect.flatten,
|
|
143
|
+
Effect.flatten,
|
|
144
|
+
Effect.catchTag('NoSuchElementException', () =>
|
|
145
|
+
Effect.fail(new PromptError('Agent did not signal task completion.', {})),
|
|
146
|
+
),
|
|
147
|
+
);
|
|
148
|
+
}),
|
|
149
|
+
),
|
|
150
|
+
);
|
|
151
|
+
},
|
|
152
|
+
Effect.tapBoth({
|
|
153
|
+
onSuccess: () => Database.flush(),
|
|
154
|
+
onFailure: () => Database.flush(),
|
|
155
|
+
}),
|
|
156
|
+
Effect.scoped,
|
|
157
|
+
),
|
|
158
|
+
),
|
|
159
|
+
Operation.opaqueHandler,
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
const makePromptAgentToolkit = (options: {
|
|
163
|
+
output: Schema.Schema.Any;
|
|
164
|
+
resultSink: Deferred.Deferred<unknown, PromptError>;
|
|
165
|
+
}) => {
|
|
166
|
+
class PromptAgentToolkit extends Toolkit.make(
|
|
167
|
+
Tool.make('completeJob', {
|
|
168
|
+
parameters: {
|
|
169
|
+
success: Schema.optional(Schema.Any), // TODO(dmaretskyi): Pipe output schema here.
|
|
170
|
+
failure: Schema.optional(
|
|
171
|
+
Schema.Struct({
|
|
172
|
+
message: Schema.String.annotations({
|
|
173
|
+
description: 'Short message describing the error.',
|
|
174
|
+
}),
|
|
175
|
+
description: Schema.optional(Schema.String).annotations({
|
|
176
|
+
description: 'Optional longer message describing in detail what went wrong',
|
|
177
|
+
}),
|
|
178
|
+
}),
|
|
179
|
+
),
|
|
180
|
+
},
|
|
181
|
+
}),
|
|
182
|
+
) {}
|
|
183
|
+
const layer = PromptAgentToolkit.toLayer({
|
|
184
|
+
completeJob: Effect.fnUntraced(function* (result) {
|
|
185
|
+
if (result.failure) {
|
|
186
|
+
yield* Deferred.fail(
|
|
187
|
+
options.resultSink,
|
|
188
|
+
new PromptError(result.failure.message, {
|
|
189
|
+
description: result.failure.description,
|
|
190
|
+
}),
|
|
191
|
+
);
|
|
192
|
+
} else {
|
|
193
|
+
yield* Deferred.succeed(options.resultSink, result.success);
|
|
194
|
+
}
|
|
195
|
+
}),
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
return OpaqueToolkit.make(PromptAgentToolkit, layer);
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
interface ToolExecutionServiceOptions {
|
|
202
|
+
feed: Feed.Feed;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const ToolExecutionService = ({ feed }: ToolExecutionServiceOptions) =>
|
|
206
|
+
Layer.unwrapEffect(
|
|
207
|
+
Effect.gen(function* () {
|
|
208
|
+
const operationInvoker = yield* Operation.Service;
|
|
209
|
+
return makeToolExecutionService({
|
|
210
|
+
invoke: (tool, input) =>
|
|
211
|
+
Effect.gen(function* () {
|
|
212
|
+
const operationDef = getOperationFromTool(tool).pipe(Option.getOrThrow);
|
|
213
|
+
log('invoking operation', { operationDef, input });
|
|
214
|
+
const result = yield* operationInvoker
|
|
215
|
+
.invoke(operationDef, input, {
|
|
216
|
+
conversation: Obj.getDXN(feed).toString(),
|
|
217
|
+
})
|
|
218
|
+
.pipe(Effect.orDie);
|
|
219
|
+
log('result', { result });
|
|
220
|
+
return result;
|
|
221
|
+
}),
|
|
222
|
+
});
|
|
223
|
+
}),
|
|
224
|
+
);
|