@dxos/assistant-toolkit 0.8.4-main.bc674ce → 0.8.4-main.bcb3aa67d6
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-OBP4D5RN.mjs +30 -0
- package/dist/lib/neutral/add-artifact-OBP4D5RN.mjs.map +7 -0
- package/dist/lib/neutral/agent-27Z7BESA.mjs +95 -0
- package/dist/lib/neutral/agent-27Z7BESA.mjs.map +7 -0
- package/dist/lib/neutral/chunk-2NKPVOXM.mjs +267 -0
- package/dist/lib/neutral/chunk-2NKPVOXM.mjs.map +7 -0
- package/dist/lib/neutral/chunk-3ZUJIEFV.mjs +184 -0
- package/dist/lib/neutral/chunk-3ZUJIEFV.mjs.map +7 -0
- package/dist/lib/neutral/chunk-4QGZEDWS.mjs +140 -0
- package/dist/lib/neutral/chunk-4QGZEDWS.mjs.map +7 -0
- package/dist/lib/neutral/chunk-6FL4C6KD.mjs +86 -0
- package/dist/lib/neutral/chunk-6FL4C6KD.mjs.map +7 -0
- package/dist/lib/neutral/chunk-6IAJ2JI5.mjs +54 -0
- package/dist/lib/neutral/chunk-6IAJ2JI5.mjs.map +7 -0
- package/dist/lib/neutral/chunk-AGG6OZNB.mjs +74 -0
- package/dist/lib/neutral/chunk-AGG6OZNB.mjs.map +7 -0
- package/dist/lib/neutral/chunk-AKMBURAD.mjs +320 -0
- package/dist/lib/neutral/chunk-AKMBURAD.mjs.map +7 -0
- package/dist/lib/neutral/chunk-BO4ZVH7M.mjs +73 -0
- package/dist/lib/neutral/chunk-BO4ZVH7M.mjs.map +7 -0
- package/dist/lib/neutral/chunk-CJUCONUJ.mjs +99 -0
- package/dist/lib/neutral/chunk-CJUCONUJ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-GAJ6MKJX.mjs +363 -0
- package/dist/lib/neutral/chunk-GAJ6MKJX.mjs.map +7 -0
- package/dist/lib/neutral/chunk-HEFG73F2.mjs +53 -0
- package/dist/lib/neutral/chunk-HEFG73F2.mjs.map +7 -0
- package/dist/lib/neutral/chunk-HZM3HNAS.mjs +78 -0
- package/dist/lib/neutral/chunk-HZM3HNAS.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ILZ2ODWC.mjs +95 -0
- package/dist/lib/neutral/chunk-ILZ2ODWC.mjs.map +7 -0
- package/dist/lib/neutral/chunk-IQNOIB23.mjs +58 -0
- package/dist/lib/neutral/chunk-IQNOIB23.mjs.map +7 -0
- package/dist/lib/neutral/chunk-KWZG4QBN.mjs +685 -0
- package/dist/lib/neutral/chunk-KWZG4QBN.mjs.map +7 -0
- package/dist/lib/neutral/chunk-LI6VMCJW.mjs +27 -0
- package/dist/lib/neutral/chunk-LI6VMCJW.mjs.map +7 -0
- package/dist/lib/neutral/chunk-MEZ4UFR6.mjs +25 -0
- package/dist/lib/neutral/chunk-MEZ4UFR6.mjs.map +7 -0
- package/dist/lib/neutral/chunk-VBSCQN37.mjs +52 -0
- package/dist/lib/neutral/chunk-VBSCQN37.mjs.map +7 -0
- package/dist/lib/neutral/chunk-VDEDVOS6.mjs +39 -0
- package/dist/lib/neutral/chunk-VDEDVOS6.mjs.map +7 -0
- package/dist/lib/neutral/chunk-YBTLIXQK.mjs +29 -0
- package/dist/lib/neutral/chunk-YBTLIXQK.mjs.map +7 -0
- package/dist/lib/neutral/context-add-U5LSEQLG.mjs +22 -0
- package/dist/lib/neutral/context-add-U5LSEQLG.mjs.map +7 -0
- package/dist/lib/neutral/context-remove-3YGXLVRA.mjs +22 -0
- package/dist/lib/neutral/context-remove-3YGXLVRA.mjs.map +7 -0
- package/dist/lib/neutral/create-P6I22VS5.mjs +23 -0
- package/dist/lib/neutral/create-P6I22VS5.mjs.map +7 -0
- package/dist/lib/neutral/create-project-YEDZU75J.mjs +34 -0
- package/dist/lib/neutral/create-project-YEDZU75J.mjs.map +7 -0
- package/dist/lib/neutral/delete-LHMZDJFA.mjs +19 -0
- package/dist/lib/neutral/delete-LHMZDJFA.mjs.map +7 -0
- package/dist/lib/neutral/document-create-53ZVNGFR.mjs +57 -0
- package/dist/lib/neutral/document-create-53ZVNGFR.mjs.map +7 -0
- package/dist/lib/neutral/enable-blueprints-Q5NXGX2G.mjs +48 -0
- package/dist/lib/neutral/enable-blueprints-Q5NXGX2G.mjs.map +7 -0
- package/dist/lib/neutral/entity-extraction-CFXRZWZK.mjs +196 -0
- package/dist/lib/neutral/entity-extraction-CFXRZWZK.mjs.map +7 -0
- package/dist/lib/neutral/exa-P4G3DCYB.mjs +28 -0
- package/dist/lib/neutral/exa-P4G3DCYB.mjs.map +7 -0
- package/dist/lib/neutral/fetch-TLKREIZA.mjs +16 -0
- package/dist/lib/neutral/fetch-TLKREIZA.mjs.map +7 -0
- package/dist/lib/neutral/fetch-messages-AFX7ZAVE.mjs +154 -0
- package/dist/lib/neutral/fetch-messages-AFX7ZAVE.mjs.map +7 -0
- package/dist/lib/neutral/get-context-MKM4CEGH.mjs +35 -0
- package/dist/lib/neutral/get-context-MKM4CEGH.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +248 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/neutral/load-KHLICMGJ.mjs +17 -0
- package/dist/lib/neutral/load-KHLICMGJ.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/{browser/index.mjs → neutral/mock-JSY4GY77.mjs} +23 -2347
- package/dist/lib/neutral/mock-JSY4GY77.mjs.map +7 -0
- package/dist/lib/neutral/object-create-7J7D53FT.mjs +43 -0
- package/dist/lib/neutral/object-create-7J7D53FT.mjs.map +7 -0
- package/dist/lib/neutral/object-delete-QFXUHJ2D.mjs +18 -0
- package/dist/lib/neutral/object-delete-QFXUHJ2D.mjs.map +7 -0
- package/dist/lib/neutral/object-update-C73HRM5F.mjs +28 -0
- package/dist/lib/neutral/object-update-C73HRM5F.mjs.map +7 -0
- package/dist/lib/neutral/project-rules-ZVV4TFOQ.mjs +77 -0
- package/dist/lib/neutral/project-rules-ZVV4TFOQ.mjs.map +7 -0
- package/dist/lib/neutral/prompt-J2XSDAWH.mjs +138 -0
- package/dist/lib/neutral/prompt-J2XSDAWH.mjs.map +7 -0
- package/dist/lib/neutral/qualifier-WRYRVSET.mjs +104 -0
- package/dist/lib/neutral/qualifier-WRYRVSET.mjs.map +7 -0
- package/dist/lib/neutral/query-FUFKLAN2.mjs +66 -0
- package/dist/lib/neutral/query-FUFKLAN2.mjs.map +7 -0
- package/dist/lib/neutral/query-U4LWIBNG.mjs +32 -0
- package/dist/lib/neutral/query-U4LWIBNG.mjs.map +7 -0
- package/dist/lib/neutral/query-blueprints-Y5CXJLCT.mjs +17 -0
- package/dist/lib/neutral/query-blueprints-Y5CXJLCT.mjs.map +7 -0
- package/dist/lib/neutral/read-JJN7YXHI.mjs +19 -0
- package/dist/lib/neutral/read-JJN7YXHI.mjs.map +7 -0
- package/dist/lib/neutral/relation-create-YWV2TUKS.mjs +42 -0
- package/dist/lib/neutral/relation-create-YWV2TUKS.mjs.map +7 -0
- package/dist/lib/neutral/relation-delete-JGGA4CYQ.mjs +18 -0
- package/dist/lib/neutral/relation-delete-JGGA4CYQ.mjs.map +7 -0
- package/dist/lib/neutral/research-UBK6ZGX7.mjs +109 -0
- package/dist/lib/neutral/research-UBK6ZGX7.mjs.map +7 -0
- package/dist/lib/neutral/save-JZ73KUMA.mjs +23 -0
- package/dist/lib/neutral/save-JZ73KUMA.mjs.map +7 -0
- package/dist/lib/neutral/schema-add-7WKPPKW4.mjs +24 -0
- package/dist/lib/neutral/schema-add-7WKPPKW4.mjs.map +7 -0
- package/dist/lib/neutral/schema-list-MIAIKERK.mjs +30 -0
- package/dist/lib/neutral/schema-list-MIAIKERK.mjs.map +7 -0
- package/dist/lib/neutral/sync-issues-FIRE3XR6.mjs +179 -0
- package/dist/lib/neutral/sync-issues-FIRE3XR6.mjs.map +7 -0
- package/dist/lib/neutral/tag-add-IKD4ADDM.mjs +19 -0
- package/dist/lib/neutral/tag-add-IKD4ADDM.mjs.map +7 -0
- package/dist/lib/neutral/tag-remove-PCSKCFT2.mjs +19 -0
- package/dist/lib/neutral/tag-remove-PCSKCFT2.mjs.map +7 -0
- package/dist/lib/neutral/testing/index.mjs +81 -0
- package/dist/lib/neutral/testing/index.mjs.map +7 -0
- package/dist/lib/neutral/update-HZ7A3ZA5.mjs +20 -0
- package/dist/lib/neutral/update-HZ7A3ZA5.mjs.map +7 -0
- package/dist/lib/neutral/update-tasks-TZ65WZ44.mjs +46 -0
- package/dist/lib/neutral/update-tasks-TZ65WZ44.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 +59 -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 +36 -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/{design/design-blueprint.d.ts → blueprint-manager/functions/query-blueprints.d.ts} +13 -4
- package/dist/types/src/blueprints/blueprint-manager/functions/query-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 +58 -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 +11 -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/design/blueprint.d.ts +4 -0
- package/dist/types/src/blueprints/design/blueprint.d.ts.map +1 -0
- package/dist/types/src/blueprints/design/blueprint.test.d.ts +2 -0
- package/dist/types/src/blueprints/design/blueprint.test.d.ts.map +1 -0
- package/dist/types/src/blueprints/design/index.d.ts +1 -2
- package/dist/types/src/blueprints/design/index.d.ts.map +1 -1
- 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 +16 -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 +4 -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 +8 -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 +9 -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 +14 -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 +7 -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 +11 -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/markdown/blueprint.d.ts +4 -0
- package/dist/types/src/blueprints/markdown/blueprint.d.ts.map +1 -0
- package/dist/types/src/blueprints/markdown/functions/create.d.ts +8 -0
- package/dist/types/src/blueprints/markdown/functions/create.d.ts.map +1 -0
- package/dist/types/src/blueprints/markdown/functions/definitions.d.ts +45 -0
- package/dist/types/src/blueprints/markdown/functions/definitions.d.ts.map +1 -0
- package/dist/types/src/blueprints/markdown/functions/index.d.ts +4 -0
- package/dist/types/src/blueprints/markdown/functions/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/markdown/functions/read.d.ts +17 -0
- package/dist/types/src/blueprints/markdown/functions/read.d.ts.map +1 -0
- package/dist/types/src/blueprints/markdown/functions/update.d.ts +16 -0
- package/dist/types/src/blueprints/markdown/functions/update.d.ts.map +1 -0
- package/dist/types/src/blueprints/markdown/index.d.ts +3 -0
- package/dist/types/src/blueprints/markdown/index.d.ts.map +1 -0
- 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/planning-old/blueprint.d.ts +4 -0
- package/dist/types/src/blueprints/planning-old/blueprint.d.ts.map +1 -0
- package/dist/types/src/blueprints/planning-old/blueprint.test.d.ts +2 -0
- package/dist/types/src/blueprints/planning-old/blueprint.test.d.ts.map +1 -0
- package/dist/types/src/blueprints/planning-old/functions/definitions.d.ts +31 -0
- package/dist/types/src/blueprints/planning-old/functions/definitions.d.ts.map +1 -0
- package/dist/types/src/blueprints/planning-old/functions/index.d.ts +4 -0
- package/dist/types/src/blueprints/planning-old/functions/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/planning-old/functions/read.d.ts +17 -0
- package/dist/types/src/blueprints/planning-old/functions/read.d.ts.map +1 -0
- package/dist/types/src/blueprints/planning-old/functions/task-list.d.ts.map +1 -0
- package/dist/types/src/blueprints/planning-old/functions/task-list.test.d.ts.map +1 -0
- package/dist/types/src/blueprints/planning-old/functions/update.d.ts +19 -0
- package/dist/types/src/blueprints/planning-old/functions/update.d.ts.map +1 -0
- package/dist/types/src/blueprints/planning-old/index.d.ts +3 -0
- package/dist/types/src/blueprints/planning-old/index.d.ts.map +1 -0
- 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 +150 -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 +69 -0
- package/dist/types/src/blueprints/project/functions/qualifier.d.ts.map +1 -0
- package/dist/types/src/blueprints/project/index.d.ts +4 -0
- package/dist/types/src/blueprints/project/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/project/sync-triggers.d.ts +11 -0
- package/dist/types/src/blueprints/project/sync-triggers.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 +48 -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 +49 -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/index.d.ts +3 -0
- package/dist/types/src/blueprints/project-wizard/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/research/blueprint.d.ts +4 -0
- package/dist/types/src/blueprints/research/blueprint.d.ts.map +1 -0
- package/dist/types/src/blueprints/research/blueprint.test.d.ts +2 -0
- package/dist/types/src/blueprints/research/blueprint.test.d.ts.map +1 -0
- package/dist/types/src/blueprints/research/functions/definitions.d.ts +21 -0
- package/dist/types/src/blueprints/research/functions/definitions.d.ts.map +1 -0
- package/dist/types/src/blueprints/research/functions/document-create.d.ts +12 -0
- package/dist/types/src/blueprints/research/functions/document-create.d.ts.map +1 -0
- package/dist/types/src/blueprints/research/functions/index.d.ts +4 -0
- package/dist/types/src/blueprints/research/functions/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/research/functions/research.d.ts +18 -0
- package/dist/types/src/blueprints/research/functions/research.d.ts.map +1 -0
- package/dist/types/src/blueprints/research/functions/research.test.d.ts.map +1 -0
- package/dist/types/src/blueprints/research/index.d.ts +3 -2
- package/dist/types/src/blueprints/research/index.d.ts.map +1 -1
- package/dist/types/src/blueprints/research/types/ResearchGraph.d.ts +24 -0
- package/dist/types/src/blueprints/research/types/ResearchGraph.d.ts.map +1 -0
- package/dist/types/src/blueprints/research/types/index.d.ts +7 -0
- package/dist/types/src/blueprints/research/types/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/testing.d.ts +16 -4
- 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 +6 -6
- package/dist/types/src/crud/graph.d.ts.map +1 -1
- package/dist/types/src/functions/agent/definitions.d.ts +101 -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 +34 -8
- 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/entity-extraction/definitions.d.ts +182 -0
- package/dist/types/src/functions/entity-extraction/definitions.d.ts.map +1 -0
- package/dist/types/src/functions/entity-extraction/entity-extraction.d.ts +2 -172
- package/dist/types/src/functions/entity-extraction/entity-extraction.d.ts.map +1 -1
- package/dist/types/src/functions/entity-extraction/index.d.ts +3 -174
- package/dist/types/src/functions/entity-extraction/index.d.ts.map +1 -1
- package/dist/types/src/functions/exa/definitions.d.ts +9 -0
- package/dist/types/src/functions/exa/definitions.d.ts.map +1 -0
- package/dist/types/src/functions/exa/exa.d.ts +4 -2
- package/dist/types/src/functions/exa/exa.d.ts.map +1 -1
- package/dist/types/src/functions/exa/index.d.ts +3 -2
- package/dist/types/src/functions/exa/index.d.ts.map +1 -1
- package/dist/types/src/functions/exa/mock.d.ts +3 -2
- package/dist/types/src/functions/exa/mock.d.ts.map +1 -1
- package/dist/types/src/functions/index.d.ts +1 -5
- package/dist/types/src/functions/index.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +1 -0
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/plugins.d.ts.map +1 -1
- 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/Chat.d.ts +52 -0
- package/dist/types/src/types/Chat.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 +86 -0
- package/dist/types/src/types/Plan.d.ts.map +1 -0
- package/dist/types/src/types/Project.d.ts +73 -0
- package/dist/types/src/types/Project.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +5 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +39 -43
- package/src/blueprints/automation/blueprint.ts +109 -0
- package/src/blueprints/automation/index.ts +5 -0
- package/src/blueprints/blueprint-manager/blueprint.test.ts +130 -0
- package/src/blueprints/blueprint-manager/blueprint.ts +49 -0
- package/src/blueprints/blueprint-manager/functions/definitions.ts +46 -0
- package/src/blueprints/blueprint-manager/functions/enable-blueprints.ts +44 -0
- package/src/blueprints/blueprint-manager/functions/index.ts +12 -0
- package/src/blueprints/blueprint-manager/functions/query-blueprints.ts +19 -0
- package/src/blueprints/blueprint-manager/index.ts +6 -0
- package/src/blueprints/browser/blueprint.conversations.json +1 -0
- package/src/blueprints/browser/blueprint.test.ts +64 -0
- package/src/blueprints/browser/blueprint.ts +41 -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 +343 -0
- package/src/blueprints/database/blueprint.ts +67 -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 +301 -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 +56 -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 +27 -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/design/{design-blueprint.test.ts → blueprint.test.ts} +14 -22
- package/src/blueprints/design/{design-blueprint.ts → blueprint.ts} +21 -11
- package/src/blueprints/design/index.ts +1 -3
- package/src/blueprints/discord/blueprint.ts +42 -0
- package/src/blueprints/discord/functions/definitions.ts +71 -0
- package/src/{functions/discord → blueprints/discord/functions}/fetch-messages.test.ts +6 -8
- package/src/blueprints/discord/functions/fetch-messages.ts +199 -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 +27 -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 +14 -6
- package/src/blueprints/linear/blueprint.ts +43 -0
- package/src/blueprints/linear/functions/definitions.ts +24 -0
- package/src/blueprints/linear/functions/index.ts +9 -0
- package/src/blueprints/linear/functions/linear.test.ts +60 -0
- package/src/{functions/linear → blueprints/linear/functions}/sync-issues.ts +37 -45
- package/src/blueprints/linear/index.ts +2 -3
- package/src/blueprints/markdown/blueprint.ts +36 -0
- package/src/blueprints/markdown/functions/create.ts +20 -0
- package/src/blueprints/markdown/functions/definitions.ts +80 -0
- package/src/blueprints/markdown/functions/index.ts +13 -0
- package/src/blueprints/markdown/functions/read.ts +22 -0
- package/src/blueprints/markdown/functions/update.ts +22 -0
- package/src/blueprints/markdown/index.ts +11 -0
- package/src/blueprints/memory/blueprint.conversations.json +1 -0
- package/src/blueprints/memory/blueprint.test.ts +139 -0
- package/src/blueprints/memory/blueprint.ts +42 -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 +25 -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/{planning/planning-blueprint.test.ts → planning-old/blueprint.test.ts} +14 -18
- package/src/blueprints/{planning/planning-blueprint.ts → planning-old/blueprint.ts} +21 -11
- package/src/blueprints/planning-old/functions/definitions.ts +53 -0
- package/src/blueprints/planning-old/functions/index.ts +12 -0
- package/src/blueprints/planning-old/functions/read.ts +24 -0
- package/src/blueprints/planning-old/functions/update.ts +31 -0
- package/src/blueprints/planning-old/index.ts +6 -0
- package/src/blueprints/project/blueprint.conversations.json +1 -0
- package/src/{initiative/initiative.test.ts → blueprints/project/blueprint.test.ts} +149 -47
- package/src/blueprints/project/blueprint.ts +65 -0
- package/src/blueprints/project/functions/add-artifact.ts +30 -0
- package/src/blueprints/project/functions/agent.ts +75 -0
- package/src/blueprints/project/functions/definitions.ts +91 -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 +7 -0
- package/src/blueprints/project/sync-triggers.ts +149 -0
- package/src/blueprints/project-wizard/blueprint.ts +43 -0
- package/src/blueprints/project-wizard/functions/create-project.ts +33 -0
- package/src/blueprints/project-wizard/functions/definitions.ts +48 -0
- package/src/blueprints/project-wizard/functions/index.ts +12 -0
- package/src/blueprints/project-wizard/functions/project-rules.ts +76 -0
- package/src/blueprints/project-wizard/index.ts +6 -0
- package/src/blueprints/research/{research-blueprint.ts → blueprint.ts} +22 -12
- package/src/blueprints/research/functions/definitions.ts +87 -0
- package/src/blueprints/research/functions/document-create.ts +50 -0
- package/src/blueprints/research/functions/index.ts +12 -0
- package/src/{functions/research → blueprints/research/functions}/research-instructions.tpl +5 -5
- package/src/blueprints/research/functions/research.conversations.json +1 -0
- package/src/blueprints/research/functions/research.test.ts +152 -0
- package/src/blueprints/research/functions/research.ts +138 -0
- package/src/blueprints/research/index.ts +3 -3
- package/src/blueprints/research/types/ResearchGraph.ts +62 -0
- package/src/{functions/research/types.ts → blueprints/research/types/index.ts} +12 -6
- package/src/blueprints/testing.ts +34 -5
- package/src/blueprints/websearch/blueprint.conversations.json +1 -0
- package/src/blueprints/websearch/blueprint.test.ts +39 -0
- package/src/blueprints/websearch/blueprint.ts +31 -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 -5
- package/src/blueprints/websearch/{websearch-toolkit.ts → toolkit.ts} +4 -0
- package/src/crud/graph.test.ts +2 -2
- package/src/crud/graph.ts +9 -9
- package/src/functions/READ_THIS.md +5 -0
- package/src/functions/agent/definitions.ts +53 -0
- package/src/functions/agent/index.ts +3 -5
- package/src/functions/agent/prompt.test.ts +144 -0
- package/src/functions/agent/prompt.ts +122 -104
- package/src/functions/entity-extraction/definitions.ts +44 -0
- package/src/functions/entity-extraction/entity-extraction.conversations.json +1 -6597
- package/src/functions/entity-extraction/entity-extraction.test.ts +13 -30
- package/src/functions/entity-extraction/entity-extraction.ts +68 -92
- package/src/functions/entity-extraction/index.ts +4 -4
- package/src/functions/exa/definitions.ts +37 -0
- package/src/functions/exa/exa.ts +22 -27
- package/src/functions/exa/index.ts +8 -2
- package/src/functions/exa/mock.ts +28 -37
- package/src/functions/index.ts +1 -5
- package/src/index.ts +2 -1
- package/src/sync/sync.ts +2 -2
- package/src/testing/index.ts +1 -0
- package/src/testing/plugins.tsx +28 -19
- package/src/toolkits/WebToolkit.ts +33 -0
- package/src/toolkits/index.ts +1 -2
- package/src/types/Chat.ts +62 -0
- package/src/types/Memory.ts +23 -0
- package/src/types/Plan.ts +110 -0
- package/src/types/Project.ts +208 -0
- package/src/types/index.ts +8 -0
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/testing/index.mjs +0 -43
- package/dist/lib/browser/testing/index.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +0 -11
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -2881
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/testing/index.mjs +0 -44
- package/dist/lib/node-esm/testing/index.mjs.map +0 -7
- 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/discord/discord-blueprint.d.ts +0 -18
- package/dist/types/src/blueprints/discord/discord-blueprint.d.ts.map +0 -1
- package/dist/types/src/blueprints/linear/linear-blueprint.d.ts +0 -18
- package/dist/types/src/blueprints/linear/linear-blueprint.d.ts.map +0 -1
- package/dist/types/src/blueprints/planning/planning-blueprint.d.ts +0 -18
- 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/research-blueprint.d.ts +0 -18
- 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 -18
- 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/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.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.map +0 -1
- 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/initiative/Initiative.d.ts +0 -84
- package/dist/types/src/initiative/Initiative.d.ts.map +0 -1
- package/dist/types/src/initiative/InitiativeSchema.d.ts +0 -19
- package/dist/types/src/initiative/InitiativeSchema.d.ts.map +0 -1
- package/dist/types/src/initiative/functions/agent.d.ts +0 -37
- package/dist/types/src/initiative/functions/agent.d.ts.map +0 -1
- package/dist/types/src/initiative/functions/getContext.d.ts +0 -17
- package/dist/types/src/initiative/functions/getContext.d.ts.map +0 -1
- package/dist/types/src/initiative/functions/index.d.ts +0 -4
- package/dist/types/src/initiative/functions/index.d.ts.map +0 -1
- package/dist/types/src/initiative/functions/update.d.ts +0 -7
- package/dist/types/src/initiative/functions/update.d.ts.map +0 -1
- package/dist/types/src/initiative/index.d.ts +0 -1
- package/dist/types/src/initiative/index.d.ts.map +0 -1
- package/dist/types/src/initiative/initiative.test.d.ts +0 -2
- package/dist/types/src/initiative/initiative.test.d.ts.map +0 -1
- package/dist/types/src/toolkits/AssistantToolkit.d.ts +0 -43
- 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 -99
- package/dist/types/src/toolkits/SystemToolkit.d.ts.map +0 -1
- package/src/blueprints/discord/discord-blueprint.ts +0 -32
- package/src/blueprints/linear/linear-blueprint.ts +0 -33
- package/src/blueprints/websearch/websearch-blueprint.ts +0 -18
- package/src/experimental/feed.test.ts +0 -111
- 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 -33
- package/src/functions/github/fetch-prs.ts +0 -31
- 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.conversations.json +0 -1
- package/src/functions/research/research.test.ts +0 -171
- package/src/functions/research/research.ts +0 -189
- package/src/functions/tasks/index.ts +0 -11
- package/src/functions/tasks/read.ts +0 -35
- package/src/functions/tasks/update.ts +0 -53
- package/src/initiative/Initiative.ts +0 -99
- package/src/initiative/InitiativeSchema.ts +0 -37
- package/src/initiative/functions/agent.ts +0 -57
- package/src/initiative/functions/getContext.ts +0 -74
- package/src/initiative/functions/index.ts +0 -7
- package/src/initiative/functions/update.ts +0 -63
- package/src/initiative/index.ts +0 -3
- package/src/initiative/initiative.conversations.json +0 -1
- package/src/toolkits/AssistantToolkit.conversations.json +0 -1
- package/src/toolkits/AssistantToolkit.test.ts +0 -94
- package/src/toolkits/AssistantToolkit.ts +0 -70
- package/src/toolkits/SystemToolkit.ts +0 -299
- /package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs +0 -0
- /package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs.map +0 -0
- /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/dist/types/src/{functions/tasks → blueprints/planning-old/functions}/task-list.d.ts +0 -0
- /package/dist/types/src/{functions/tasks → blueprints/planning-old/functions}/task-list.test.d.ts +0 -0
- /package/dist/types/src/{functions/research → blueprints/research/functions}/research.test.d.ts +0 -0
- /package/src/{functions/tasks → blueprints/planning-old/functions}/task-list.test.ts +0 -0
- /package/src/{functions/tasks → blueprints/planning-old/functions}/task-list.ts +0 -0
- /package/src/blueprints/research/{research-blueprint.test.ts → blueprint.test.ts} +0 -0
|
@@ -1,819 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
|
|
5
|
-
// src/blueprints/design/design-blueprint.ts
|
|
6
|
-
import { ToolId } from "@dxos/ai";
|
|
7
|
-
import { Blueprint } from "@dxos/blueprints";
|
|
8
|
-
import { Ref as Ref6 } from "@dxos/echo";
|
|
9
|
-
import { Text as Text2 } from "@dxos/schema";
|
|
10
|
-
import { trim as trim5 } from "@dxos/util";
|
|
11
|
-
|
|
12
|
-
// src/functions/agent/prompt.ts
|
|
13
|
-
import * as Array2 from "effect/Array";
|
|
14
|
-
import * as Effect from "effect/Effect";
|
|
15
|
-
import * as Function from "effect/Function";
|
|
16
|
-
import * as Match from "effect/Match";
|
|
17
|
-
import * as Option from "effect/Option";
|
|
18
|
-
import * as Schema from "effect/Schema";
|
|
19
|
-
import { AiService, ConsolePrinter, ModelName } from "@dxos/ai";
|
|
20
|
-
import { AiSession, GenerationObserver, createToolkit } from "@dxos/assistant";
|
|
21
|
-
import { Prompt, Template } from "@dxos/blueprints";
|
|
22
|
-
import { Obj, Ref, Type } from "@dxos/echo";
|
|
23
|
-
import { Database } from "@dxos/echo";
|
|
24
|
-
import { TracingService, defineFunction } from "@dxos/functions";
|
|
25
|
-
import { log } from "@dxos/log";
|
|
26
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/core/assistant-toolkit/src/functions/agent/prompt.ts";
|
|
27
|
-
var DEFAULT_MODEL = "@anthropic/claude-opus-4-0";
|
|
28
|
-
var prompt_default = defineFunction({
|
|
29
|
-
key: "dxos.org/function/prompt",
|
|
30
|
-
name: "Agent",
|
|
31
|
-
description: "Agentic worker that executes a provided prompt using blueprints and tools.",
|
|
32
|
-
inputSchema: Schema.Struct({
|
|
33
|
-
prompt: Type.Ref(Prompt.Prompt),
|
|
34
|
-
systemPrompt: Type.Ref(Prompt.Prompt).pipe(Schema.optional),
|
|
35
|
-
/**
|
|
36
|
-
* @default @anthropic/claude-opus-4-0
|
|
37
|
-
*/
|
|
38
|
-
model: Schema.optional(ModelName),
|
|
39
|
-
/**
|
|
40
|
-
* Input object or data.
|
|
41
|
-
* References get auto-resolved.
|
|
42
|
-
*/
|
|
43
|
-
input: Schema.Any.pipe(Schema.annotations({
|
|
44
|
-
title: "Input"
|
|
45
|
-
}))
|
|
46
|
-
}),
|
|
47
|
-
outputSchema: Schema.Any,
|
|
48
|
-
handler: Effect.fnUntraced(function* ({ data }) {
|
|
49
|
-
log.info("processing input", {
|
|
50
|
-
input: data.input
|
|
51
|
-
}, {
|
|
52
|
-
F: __dxlog_file,
|
|
53
|
-
L: 41,
|
|
54
|
-
S: this,
|
|
55
|
-
C: (f, a) => f(...a)
|
|
56
|
-
});
|
|
57
|
-
const input = yield* Match.value(data.input).pipe(Match.when((value2) => Ref.isRef(value2), Effect.fnUntraced(function* (ref) {
|
|
58
|
-
const object = yield* Database.Service.load(ref);
|
|
59
|
-
return Obj.toJSON(object);
|
|
60
|
-
})), Match.orElse(() => Effect.succeed(data.input)));
|
|
61
|
-
yield* Database.Service.flush({
|
|
62
|
-
indexes: true
|
|
63
|
-
});
|
|
64
|
-
const prompt = yield* Database.Service.load(data.prompt);
|
|
65
|
-
const systemPrompt = data.systemPrompt ? yield* Database.Service.load(data.systemPrompt) : void 0;
|
|
66
|
-
yield* TracingService.emitStatus({
|
|
67
|
-
message: `Running ${prompt.id}`
|
|
68
|
-
});
|
|
69
|
-
log.info("starting agent", {
|
|
70
|
-
prompt: prompt.id,
|
|
71
|
-
input
|
|
72
|
-
}, {
|
|
73
|
-
F: __dxlog_file,
|
|
74
|
-
L: 71,
|
|
75
|
-
S: this,
|
|
76
|
-
C: (f, a) => f(...a)
|
|
77
|
-
});
|
|
78
|
-
const blueprints = yield* Function.pipe(prompt.blueprints, Array2.appendAll(systemPrompt?.blueprints ?? []), Effect.forEach(Database.Service.loadOption), Effect.map(Array2.filter(Option.isSome)), Effect.map(Array2.map((option) => option.value)));
|
|
79
|
-
const toolkit = yield* createToolkit({
|
|
80
|
-
blueprints
|
|
81
|
-
});
|
|
82
|
-
const objects = yield* Function.pipe(prompt.context, Array2.appendAll(systemPrompt?.context ?? []), Effect.forEach(Database.Service.loadOption), Effect.map(Array2.filter(Option.isSome)), Effect.map(Array2.map((option) => option.value)));
|
|
83
|
-
const promptInstructions = yield* Database.Service.load(prompt.instructions.source);
|
|
84
|
-
const promptText = Template.process(promptInstructions.content, input);
|
|
85
|
-
const systemInstructions = systemPrompt ? yield* Database.Service.load(systemPrompt.instructions.source) : void 0;
|
|
86
|
-
const systemText = systemInstructions ? Template.process(systemInstructions.content, {}) : void 0;
|
|
87
|
-
const session = new AiSession();
|
|
88
|
-
const result = yield* session.run({
|
|
89
|
-
prompt: promptText,
|
|
90
|
-
system: systemText,
|
|
91
|
-
blueprints,
|
|
92
|
-
objects,
|
|
93
|
-
toolkit,
|
|
94
|
-
observer: GenerationObserver.fromPrinter(new ConsolePrinter({
|
|
95
|
-
tag: "agent"
|
|
96
|
-
}))
|
|
97
|
-
}).pipe(Effect.provide(AiService.model(data.model ?? DEFAULT_MODEL)));
|
|
98
|
-
const lastBlock = result.at(-1)?.blocks.filter((block) => block._tag === "text").at(-1);
|
|
99
|
-
return {
|
|
100
|
-
note: lastBlock?.text
|
|
101
|
-
};
|
|
102
|
-
})
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
// src/functions/agent/index.ts
|
|
106
|
-
(function(Agent2) {
|
|
107
|
-
Agent2.prompt = prompt_default;
|
|
108
|
-
})(Agent || (Agent = {}));
|
|
109
|
-
var Agent;
|
|
110
|
-
|
|
111
|
-
// src/functions/discord/fetch-messages.ts
|
|
112
|
-
import * as FetchHttpClient from "@effect/platform/FetchHttpClient";
|
|
113
|
-
import { DiscordConfig, DiscordREST, DiscordRESTMemoryLive } from "dfx";
|
|
114
|
-
import * as Array3 from "effect/Array";
|
|
115
|
-
import * as Effect2 from "effect/Effect";
|
|
116
|
-
import * as Function2 from "effect/Function";
|
|
117
|
-
import * as Layer from "effect/Layer";
|
|
118
|
-
import * as Option2 from "effect/Option";
|
|
119
|
-
import * as Schema2 from "effect/Schema";
|
|
120
|
-
import { Obj as Obj2 } from "@dxos/echo";
|
|
121
|
-
import { CredentialsService, TracingService as TracingService2, defineFunction as defineFunction2 } from "@dxos/functions";
|
|
122
|
-
import { log as log2 } from "@dxos/log";
|
|
123
|
-
import { Message } from "@dxos/types";
|
|
124
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/core/assistant-toolkit/src/functions/discord/fetch-messages.ts";
|
|
125
|
-
var TimeRange = class extends Schema2.String.pipe(Schema2.pattern(/\d+(s|m|h|d)/)).annotations({
|
|
126
|
-
description: "Time range. 1d - 1 day, 2h - 2 hours, 30m - 30 minutes, 15s - 15 seconds.",
|
|
127
|
-
examples: [
|
|
128
|
-
"1d",
|
|
129
|
-
"2h",
|
|
130
|
-
"30m",
|
|
131
|
-
"15s"
|
|
132
|
-
]
|
|
133
|
-
}) {
|
|
134
|
-
static toSeconds(timeRange) {
|
|
135
|
-
const match = timeRange.match(/(\d+)(s|m|h|d)/);
|
|
136
|
-
if (!match) {
|
|
137
|
-
throw new Error(`Invalid time range: ${timeRange}`);
|
|
138
|
-
}
|
|
139
|
-
const [_, amount, unit] = match;
|
|
140
|
-
switch (unit) {
|
|
141
|
-
case "s":
|
|
142
|
-
return Number(amount);
|
|
143
|
-
case "m":
|
|
144
|
-
return Number(amount) * 60;
|
|
145
|
-
case "h":
|
|
146
|
-
return Number(amount) * 60 * 60;
|
|
147
|
-
case "d":
|
|
148
|
-
return Number(amount) * 24 * 60 * 60;
|
|
149
|
-
default:
|
|
150
|
-
throw new Error(`Invalid time range unit: ${unit}`);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
var DiscordConfigFromCredential = Layer.unwrapEffect(Effect2.gen(function* () {
|
|
155
|
-
return DiscordConfig.layer({
|
|
156
|
-
token: yield* CredentialsService.getApiKey({
|
|
157
|
-
service: "discord.com"
|
|
158
|
-
}),
|
|
159
|
-
rest: {
|
|
160
|
-
baseUrl: "https://api-proxy.dxos.workers.dev/discord.com/api/v10"
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
}));
|
|
164
|
-
var DEFAULT_AFTER = 1704067200;
|
|
165
|
-
var DEFAULT_LIMIT = 500;
|
|
166
|
-
var DEFAULT_IGNORE_USERNAMES = [
|
|
167
|
-
"GitHub",
|
|
168
|
-
"Needle"
|
|
169
|
-
];
|
|
170
|
-
var fetch_messages_default = defineFunction2({
|
|
171
|
-
key: "dxos.org/function/fetch-discord-messages",
|
|
172
|
-
name: "Sync Discord messages",
|
|
173
|
-
inputSchema: Schema2.Struct({
|
|
174
|
-
serverId: Schema2.String.annotations({
|
|
175
|
-
description: "The ID of the server to fetch messages from."
|
|
176
|
-
}),
|
|
177
|
-
channelId: Schema2.optional(Schema2.String).annotations({
|
|
178
|
-
description: "The ID of the channel to fetch messages from. Will crawl all channels from the server if not specified."
|
|
179
|
-
}),
|
|
180
|
-
after: Schema2.optional(Schema2.Number).annotations({
|
|
181
|
-
description: "Fetch messages that were sent after a given date. Unix timestamp in seconds. Exclusive with `last`."
|
|
182
|
-
}),
|
|
183
|
-
last: TimeRange.annotations({
|
|
184
|
-
description: 'Time range to fetch most recent messages. Specifies the range in the past, from now. "1d" would fetch messages from the last 24 hours.'
|
|
185
|
-
}),
|
|
186
|
-
limit: Schema2.optional(Schema2.Number).annotations({
|
|
187
|
-
description: "The maximum number of messages to fetch."
|
|
188
|
-
}),
|
|
189
|
-
pageSize: Schema2.optional(Schema2.Number).annotations({
|
|
190
|
-
description: "The number of messages to fetch per page."
|
|
191
|
-
}),
|
|
192
|
-
ignoreUsernames: Schema2.optional(Schema2.Array(Schema2.String)).annotations({
|
|
193
|
-
description: "Exclude messages from these usernames."
|
|
194
|
-
})
|
|
195
|
-
}),
|
|
196
|
-
handler: Effect2.fnUntraced(function* ({ data: { serverId, channelId, after, last: last2, pageSize = 100, limit = DEFAULT_LIMIT, ignoreUsernames = DEFAULT_IGNORE_USERNAMES } }) {
|
|
197
|
-
if (!after && !last2) {
|
|
198
|
-
throw new Error("cannot specify both `after` and `last`");
|
|
199
|
-
}
|
|
200
|
-
const afterTs = last2 ? Date.now() / 1e3 - TimeRange.toSeconds(last2) : after ?? DEFAULT_AFTER;
|
|
201
|
-
const rest = yield* DiscordREST;
|
|
202
|
-
let channels = [];
|
|
203
|
-
channels.push(...yield* rest.listGuildChannels(serverId));
|
|
204
|
-
const { threads: guildThreads } = yield* rest.getActiveGuildThreads(serverId);
|
|
205
|
-
channels.push(...guildThreads);
|
|
206
|
-
if (channelId) {
|
|
207
|
-
channels = channels.filter((channel) => channel.id === channelId);
|
|
208
|
-
}
|
|
209
|
-
if (channels.length === 0) {
|
|
210
|
-
throw new Error("no channels found");
|
|
211
|
-
}
|
|
212
|
-
for (const channel of channels) {
|
|
213
|
-
log2.info("channel", {
|
|
214
|
-
id: channel.id,
|
|
215
|
-
name: "name" in channel ? channel.name : void 0
|
|
216
|
-
}, {
|
|
217
|
-
F: __dxlog_file2,
|
|
218
|
-
L: 136,
|
|
219
|
-
S: this,
|
|
220
|
-
C: (f, a) => f(...a)
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
yield* TracingService2.emitStatus({
|
|
224
|
-
message: `Will fetch from channels: ${channels.length}`
|
|
225
|
-
});
|
|
226
|
-
const threads = yield* Effect2.forEach(channels, Effect2.fnUntraced(function* (channel) {
|
|
227
|
-
const allMessages = [];
|
|
228
|
-
let lastMessage = Option2.none();
|
|
229
|
-
while (true) {
|
|
230
|
-
const { id: lastId = void 0 } = Function2.pipe(lastMessage, Option2.map(Obj2.getKeys("discord.com")), Option2.flatMap(Option2.fromIterable), Option2.getOrElse(() => ({
|
|
231
|
-
id: void 0
|
|
232
|
-
})));
|
|
233
|
-
const options = {
|
|
234
|
-
after: !lastId ? `${generateSnowflake(afterTs)}` : lastId,
|
|
235
|
-
limit: pageSize
|
|
236
|
-
};
|
|
237
|
-
log2.info("fetching messages", {
|
|
238
|
-
lastId,
|
|
239
|
-
afterTs,
|
|
240
|
-
afterSnowflake: options.after,
|
|
241
|
-
after: parseSnowflake(options.after),
|
|
242
|
-
limit: options.limit
|
|
243
|
-
}, {
|
|
244
|
-
F: __dxlog_file2,
|
|
245
|
-
L: 159,
|
|
246
|
-
S: this,
|
|
247
|
-
C: (f, a) => f(...a)
|
|
248
|
-
});
|
|
249
|
-
const messages = yield* rest.listMessages(channel.id, options).pipe(Effect2.map(Array3.map(makeMessage)), Effect2.map(Array3.reverse), Effect2.catchTag("ErrorResponse", (err) => err.cause.code === 50001 ? Effect2.succeed([]) : Effect2.fail(err)));
|
|
250
|
-
if (messages.length > 0) {
|
|
251
|
-
lastMessage = Option2.fromNullable(messages.at(-1));
|
|
252
|
-
allMessages.push(...messages);
|
|
253
|
-
} else {
|
|
254
|
-
break;
|
|
255
|
-
}
|
|
256
|
-
yield* TracingService2.emitStatus({
|
|
257
|
-
message: `Fetched messages: ${allMessages.length}`
|
|
258
|
-
});
|
|
259
|
-
if (allMessages.length >= limit) {
|
|
260
|
-
break;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
return {
|
|
264
|
-
discordChannelId: channel.id,
|
|
265
|
-
name: "name" in channel ? channel.name ?? void 0 : void 0,
|
|
266
|
-
messages: allMessages.filter((message) => !message.sender.name || !ignoreUsernames.includes(message.sender.name)).filter((message) => message.blocks.some((block) => block._tag === "text" && block.text.trim().length > 0))
|
|
267
|
-
};
|
|
268
|
-
}), {
|
|
269
|
-
concurrency: 10
|
|
270
|
-
});
|
|
271
|
-
return threads.filter((thread) => thread.messages.length > 0).map(serializeThread).join("\n");
|
|
272
|
-
}, Effect2.provide(DiscordRESTMemoryLive.pipe(Layer.provideMerge(DiscordConfigFromCredential)).pipe(Layer.provide(FetchHttpClient.layer))), Effect2.orDie)
|
|
273
|
-
});
|
|
274
|
-
var generateSnowflake = (unixTimestamp) => {
|
|
275
|
-
const discordEpoch = 1420070400000n;
|
|
276
|
-
return BigInt(unixTimestamp * 1e3) - discordEpoch << 22n;
|
|
277
|
-
};
|
|
278
|
-
var parseSnowflake = (snowflake) => {
|
|
279
|
-
const discordEpoch = 1420070400000n;
|
|
280
|
-
return new Date(Number((BigInt(snowflake) >> 22n) + discordEpoch));
|
|
281
|
-
};
|
|
282
|
-
var makeMessage = (message) => Obj2.make(Message.Message, {
|
|
283
|
-
[Obj2.Meta]: {
|
|
284
|
-
keys: [
|
|
285
|
-
{
|
|
286
|
-
id: message.id,
|
|
287
|
-
source: "discord.com"
|
|
288
|
-
},
|
|
289
|
-
{
|
|
290
|
-
id: message.channel_id,
|
|
291
|
-
source: "discord.com/thread"
|
|
292
|
-
}
|
|
293
|
-
]
|
|
294
|
-
},
|
|
295
|
-
sender: {
|
|
296
|
-
name: message.author.username
|
|
297
|
-
},
|
|
298
|
-
created: message.timestamp,
|
|
299
|
-
blocks: [
|
|
300
|
-
{
|
|
301
|
-
_tag: "text",
|
|
302
|
-
text: message.content
|
|
303
|
-
}
|
|
304
|
-
]
|
|
305
|
-
});
|
|
306
|
-
var serializeThread = (thread) => {
|
|
307
|
-
return `<thread id=${thread.discordChannelId} name=${thread.name ?? ""}>
|
|
308
|
-
${thread.messages.map((message) => ` ${message.sender.name}: ${message.blocks.filter((block) => block._tag === "text").map((block) => block.text).join(" ")}`).join("\n")}
|
|
309
|
-
</thread>`;
|
|
310
|
-
};
|
|
311
|
-
|
|
312
|
-
// src/functions/discord/index.ts
|
|
313
|
-
(function(Discord2) {
|
|
314
|
-
Discord2.fetch = fetch_messages_default;
|
|
315
|
-
})(Discord || (Discord = {}));
|
|
316
|
-
var Discord;
|
|
317
|
-
|
|
318
|
-
// src/functions/document/read.ts
|
|
319
|
-
import * as Effect3 from "effect/Effect";
|
|
320
|
-
import * as Schema3 from "effect/Schema";
|
|
321
|
-
import { ArtifactId } from "@dxos/assistant";
|
|
322
|
-
import { Database as Database2 } from "@dxos/echo";
|
|
323
|
-
import { defineFunction as defineFunction3 } from "@dxos/functions";
|
|
324
|
-
import { Markdown } from "@dxos/plugin-markdown/types";
|
|
325
|
-
var read_default = defineFunction3({
|
|
326
|
-
key: "dxos.org/function/markdown/read",
|
|
327
|
-
name: "Read markdown document",
|
|
328
|
-
description: "Read markdown document.",
|
|
329
|
-
inputSchema: Schema3.Struct({
|
|
330
|
-
id: ArtifactId.annotations({
|
|
331
|
-
description: "The ID of the document to read."
|
|
332
|
-
})
|
|
333
|
-
}),
|
|
334
|
-
outputSchema: Schema3.Struct({
|
|
335
|
-
content: Schema3.String
|
|
336
|
-
}),
|
|
337
|
-
handler: Effect3.fn(function* ({ data: { id } }) {
|
|
338
|
-
const doc = yield* Database2.Service.resolve(ArtifactId.toDXN(id), Markdown.Document);
|
|
339
|
-
const { content } = yield* Database2.Service.load(doc.content);
|
|
340
|
-
return {
|
|
341
|
-
content
|
|
342
|
-
};
|
|
343
|
-
})
|
|
344
|
-
});
|
|
345
|
-
|
|
346
|
-
// src/functions/document/update.ts
|
|
347
|
-
import * as Effect4 from "effect/Effect";
|
|
348
|
-
import * as Schema4 from "effect/Schema";
|
|
349
|
-
import { ArtifactId as ArtifactId2 } from "@dxos/assistant";
|
|
350
|
-
import { Database as Database3, Obj as Obj3 } from "@dxos/echo";
|
|
351
|
-
import { defineFunction as defineFunction4 } from "@dxos/functions";
|
|
352
|
-
import { Markdown as Markdown2 } from "@dxos/plugin-markdown/types";
|
|
353
|
-
var update_default = defineFunction4({
|
|
354
|
-
key: "dxos.org/function/markdown/update",
|
|
355
|
-
name: "Update markdown",
|
|
356
|
-
description: "Updates the entire contents of the markdown document.",
|
|
357
|
-
inputSchema: Schema4.Struct({
|
|
358
|
-
id: ArtifactId2.annotations({
|
|
359
|
-
description: "The ID of the document to write."
|
|
360
|
-
}),
|
|
361
|
-
content: Schema4.String.annotations({
|
|
362
|
-
description: "New content to write to the document."
|
|
363
|
-
})
|
|
364
|
-
}),
|
|
365
|
-
outputSchema: Schema4.Void,
|
|
366
|
-
handler: Effect4.fn(function* ({ data: { id, content } }) {
|
|
367
|
-
const doc = yield* Database3.Service.resolve(ArtifactId2.toDXN(id), Markdown2.Document);
|
|
368
|
-
const text = yield* Database3.Service.load(doc.content);
|
|
369
|
-
Obj3.change(text, (t) => {
|
|
370
|
-
t.content = content;
|
|
371
|
-
});
|
|
372
|
-
})
|
|
373
|
-
});
|
|
374
|
-
|
|
375
|
-
// src/functions/document/index.ts
|
|
376
|
-
(function(Document2) {
|
|
377
|
-
Document2.read = read_default;
|
|
378
|
-
Document2.update = update_default;
|
|
379
|
-
})(Document || (Document = {}));
|
|
380
|
-
var Document;
|
|
381
|
-
|
|
382
|
-
// src/functions/entity-extraction/entity-extraction.ts
|
|
383
|
-
import * as Toolkit3 from "@effect/ai/Toolkit";
|
|
384
|
-
import * as Effect11 from "effect/Effect";
|
|
385
|
-
import * as Layer4 from "effect/Layer";
|
|
386
|
-
import * as Predicate from "effect/Predicate";
|
|
387
|
-
import * as Schema11 from "effect/Schema";
|
|
388
|
-
import { AiService as AiService3 } from "@dxos/ai";
|
|
389
|
-
import { AiSession as AiSession3, makeToolExecutionServiceFromFunctions as makeToolExecutionServiceFromFunctions2, makeToolResolverFromFunctions as makeToolResolverFromFunctions2 } from "@dxos/assistant";
|
|
390
|
-
import { Filter as Filter2, Obj as Obj8, Ref as Ref3, Type as Type4 } from "@dxos/echo";
|
|
391
|
-
import { Database as Database8 } from "@dxos/echo";
|
|
392
|
-
import { defineFunction as defineFunction9 } from "@dxos/functions";
|
|
393
|
-
import { FunctionInvocationServiceLayerTest } from "@dxos/functions-runtime/testing";
|
|
394
|
-
import { log as log5 } from "@dxos/log";
|
|
395
|
-
import { LegacyOrganization as LegacyOrganization2, Message as Message2, Organization, Person as Person2 } from "@dxos/types";
|
|
396
|
-
import { trim as trim4 } from "@dxos/util";
|
|
397
|
-
|
|
398
|
-
// src/crud/graph.ts
|
|
399
|
-
import * as Tool from "@effect/ai/Tool";
|
|
400
|
-
import * as Toolkit from "@effect/ai/Toolkit";
|
|
401
|
-
import * as Context from "effect/Context";
|
|
402
|
-
import * as Effect5 from "effect/Effect";
|
|
403
|
-
import * as Function3 from "effect/Function";
|
|
404
|
-
import * as Option3 from "effect/Option";
|
|
405
|
-
import * as Schema5 from "effect/Schema";
|
|
406
|
-
import * as SchemaAST from "effect/SchemaAST";
|
|
407
|
-
import { Entity, Filter, Obj as Obj4, Query, Type as Type2 } from "@dxos/echo";
|
|
408
|
-
import { Database as Database4 } from "@dxos/echo";
|
|
409
|
-
import { ReferenceAnnotationId, RelationSourceDXNId, RelationSourceId, RelationTargetDXNId, RelationTargetId, createObject, getTypeAnnotation, getTypeIdentifierAnnotation } from "@dxos/echo/internal";
|
|
410
|
-
import { isEncodedReference } from "@dxos/echo-protocol";
|
|
411
|
-
import { mapAst } from "@dxos/effect";
|
|
412
|
-
import { ContextQueueService } from "@dxos/functions";
|
|
413
|
-
import { DXN, ObjectId } from "@dxos/keys";
|
|
414
|
-
import { log as log3 } from "@dxos/log";
|
|
415
|
-
import { deepMapValues, isNonNullable, trim } from "@dxos/util";
|
|
416
|
-
var __dxlog_file3 = "/__w/dxos/dxos/packages/core/assistant-toolkit/src/crud/graph.ts";
|
|
417
|
-
var Subgraph = Schema5.Struct({
|
|
418
|
-
/** Objects and relations. */
|
|
419
|
-
objects: Schema5.Array(Schema5.Any)
|
|
420
|
-
});
|
|
421
|
-
var findRelatedSchema = async (db, anchor) => {
|
|
422
|
-
const allSchemas = await db.graph.schemaRegistry.query().run();
|
|
423
|
-
return allSchemas.filter((schema) => {
|
|
424
|
-
if (getTypeAnnotation(schema)?.kind !== Entity.Kind.Relation) {
|
|
425
|
-
return false;
|
|
426
|
-
}
|
|
427
|
-
return isSchemaAddressableByDxn(anchor, DXN.parse(getTypeAnnotation(schema).sourceSchema)) || isSchemaAddressableByDxn(anchor, DXN.parse(getTypeAnnotation(schema).targetSchema));
|
|
428
|
-
}).map((schema) => ({
|
|
429
|
-
kind: "relation",
|
|
430
|
-
schema
|
|
431
|
-
}));
|
|
432
|
-
};
|
|
433
|
-
var isSchemaAddressableByDxn = (schema, dxn) => {
|
|
434
|
-
if (getTypeIdentifierAnnotation(schema) === dxn.toString()) {
|
|
435
|
-
return true;
|
|
436
|
-
}
|
|
437
|
-
const t = dxn.asTypeDXN();
|
|
438
|
-
if (t) {
|
|
439
|
-
return t.type === Type2.getTypename(schema);
|
|
440
|
-
}
|
|
441
|
-
return false;
|
|
442
|
-
};
|
|
443
|
-
var LocalSearchToolkit = Toolkit.make(Tool.make("search_local_search", {
|
|
444
|
-
description: "Search the local database for information using a vector index",
|
|
445
|
-
parameters: {
|
|
446
|
-
query: Schema5.String.annotations({
|
|
447
|
-
description: "The query to search for. Could be a question or a topic or a set of keywords."
|
|
448
|
-
})
|
|
449
|
-
},
|
|
450
|
-
success: Schema5.Unknown,
|
|
451
|
-
failure: Schema5.Never,
|
|
452
|
-
dependencies: [
|
|
453
|
-
Database4.Service
|
|
454
|
-
]
|
|
455
|
-
}));
|
|
456
|
-
var LocalSearchHandler = LocalSearchToolkit.toLayer({
|
|
457
|
-
search_local_search: Effect5.fn(function* ({ query }) {
|
|
458
|
-
const objects = yield* Database4.Service.runQuery(Query.select(Filter.text(query, {
|
|
459
|
-
type: "vector"
|
|
460
|
-
})));
|
|
461
|
-
const results = [
|
|
462
|
-
...objects
|
|
463
|
-
];
|
|
464
|
-
const option = yield* Effect5.serviceOption(ContextQueueService);
|
|
465
|
-
if (Option3.isSome(option)) {
|
|
466
|
-
const queueObjects = yield* Effect5.promise(() => option.value.queue.queryObjects());
|
|
467
|
-
results.push(...queueObjects);
|
|
468
|
-
}
|
|
469
|
-
return trim`
|
|
470
|
-
<local_context>
|
|
471
|
-
${JSON.stringify(results, null, 2)}
|
|
472
|
-
</local_context>
|
|
473
|
-
`;
|
|
474
|
-
})
|
|
475
|
-
});
|
|
476
|
-
var GraphWriterSchema = class extends Context.Tag("@dxos/assistant/GraphWriterSchema")() {
|
|
477
|
-
};
|
|
478
|
-
var makeGraphWriterToolkit = ({ schema }) => {
|
|
479
|
-
return Toolkit.make(Tool.make("graph_writer", {
|
|
480
|
-
description: "Write to the local graph database",
|
|
481
|
-
parameters: createExtractionSchema(schema).fields,
|
|
482
|
-
success: Schema5.Unknown,
|
|
483
|
-
failure: Schema5.Never,
|
|
484
|
-
dependencies: [
|
|
485
|
-
Database4.Service,
|
|
486
|
-
ContextQueueService
|
|
487
|
-
]
|
|
488
|
-
}).annotateContext(Context.make(GraphWriterSchema, {
|
|
489
|
-
schema
|
|
490
|
-
})));
|
|
491
|
-
};
|
|
492
|
-
var makeGraphWriterHandler = (toolkit, { onAppend } = {}) => {
|
|
493
|
-
const { schema } = Context.get(toolkit.tools.graph_writer.annotations, GraphWriterSchema);
|
|
494
|
-
return toolkit.toLayer({
|
|
495
|
-
graph_writer: Effect5.fn(function* (input) {
|
|
496
|
-
const { db } = yield* Database4.Service;
|
|
497
|
-
const { queue } = yield* ContextQueueService;
|
|
498
|
-
const data = yield* Effect5.promise(() => sanitizeObjects(schema, input, db, queue));
|
|
499
|
-
yield* Effect5.promise(() => queue.append(data));
|
|
500
|
-
const dxns = data.map((obj) => Obj4.getDXN(obj));
|
|
501
|
-
onAppend?.(dxns);
|
|
502
|
-
return dxns;
|
|
503
|
-
})
|
|
504
|
-
});
|
|
505
|
-
};
|
|
506
|
-
var createExtractionSchema = (types) => {
|
|
507
|
-
return Schema5.Struct({
|
|
508
|
-
...Object.fromEntries(types.map(preprocessSchema).map((schema, index) => [
|
|
509
|
-
`objects_${getSanitizedSchemaName(types[index])}`,
|
|
510
|
-
Schema5.optional(Schema5.Array(schema)).annotations({
|
|
511
|
-
description: `The objects of type: ${Type2.getDXN(types[index])?.asTypeDXN().type}. ${SchemaAST.getDescriptionAnnotation(types[index].ast).pipe(Option3.getOrElse(() => ""))}`
|
|
512
|
-
})
|
|
513
|
-
]))
|
|
514
|
-
});
|
|
515
|
-
};
|
|
516
|
-
var getSanitizedSchemaName = (schema) => {
|
|
517
|
-
return Type2.getDXN(schema).asTypeDXN().type.replaceAll(/[^a-zA-Z0-9]+/g, "_");
|
|
518
|
-
};
|
|
519
|
-
var sanitizeObjects = async (types, data, db, queue) => {
|
|
520
|
-
const entries = types.map((type) => data[`objects_${getSanitizedSchemaName(type)}`]?.map((object) => ({
|
|
521
|
-
data: object,
|
|
522
|
-
schema: type
|
|
523
|
-
})) ?? []).flat();
|
|
524
|
-
const idMap = /* @__PURE__ */ new Map();
|
|
525
|
-
const existingIds = /* @__PURE__ */ new Set();
|
|
526
|
-
const enitties = /* @__PURE__ */ new Map();
|
|
527
|
-
const resolveId = (id) => {
|
|
528
|
-
if (ObjectId.isValid(id)) {
|
|
529
|
-
existingIds.add(id);
|
|
530
|
-
return DXN.fromLocalObjectId(id);
|
|
531
|
-
}
|
|
532
|
-
const mappedId = idMap.get(id);
|
|
533
|
-
if (mappedId) {
|
|
534
|
-
return DXN.fromLocalObjectId(mappedId);
|
|
535
|
-
}
|
|
536
|
-
return void 0;
|
|
537
|
-
};
|
|
538
|
-
const res = entries.map((entry) => {
|
|
539
|
-
if (ObjectId.isValid(entry.data.id)) {
|
|
540
|
-
return entry;
|
|
541
|
-
}
|
|
542
|
-
idMap.set(entry.data.id, ObjectId.random());
|
|
543
|
-
entry.data.id = idMap.get(entry.data.id);
|
|
544
|
-
return entry;
|
|
545
|
-
}).map((entry) => {
|
|
546
|
-
const data2 = deepMapValues(entry.data, (value2, recurse) => {
|
|
547
|
-
if (isEncodedReference(value2)) {
|
|
548
|
-
const ref = value2["/"];
|
|
549
|
-
const id = resolveId(ref);
|
|
550
|
-
if (id) {
|
|
551
|
-
return {
|
|
552
|
-
"/": id.toString()
|
|
553
|
-
};
|
|
554
|
-
} else {
|
|
555
|
-
return {
|
|
556
|
-
"/": `search:?q=${encodeURIComponent(ref)}`
|
|
557
|
-
};
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
return recurse(value2);
|
|
561
|
-
});
|
|
562
|
-
if (Entity.getKind(entry.schema) === "relation") {
|
|
563
|
-
const sourceDxn = resolveId(data2.source);
|
|
564
|
-
if (!sourceDxn) {
|
|
565
|
-
log3.warn("source not found", {
|
|
566
|
-
source: data2.source
|
|
567
|
-
}, {
|
|
568
|
-
F: __dxlog_file3,
|
|
569
|
-
L: 273,
|
|
570
|
-
S: void 0,
|
|
571
|
-
C: (f, a) => f(...a)
|
|
572
|
-
});
|
|
573
|
-
}
|
|
574
|
-
const targetDxn = resolveId(data2.target);
|
|
575
|
-
if (!targetDxn) {
|
|
576
|
-
log3.warn("target not found", {
|
|
577
|
-
target: data2.target
|
|
578
|
-
}, {
|
|
579
|
-
F: __dxlog_file3,
|
|
580
|
-
L: 277,
|
|
581
|
-
S: void 0,
|
|
582
|
-
C: (f, a) => f(...a)
|
|
583
|
-
});
|
|
584
|
-
}
|
|
585
|
-
delete data2.source;
|
|
586
|
-
delete data2.target;
|
|
587
|
-
data2[RelationSourceDXNId] = sourceDxn;
|
|
588
|
-
data2[RelationTargetDXNId] = targetDxn;
|
|
589
|
-
}
|
|
590
|
-
return {
|
|
591
|
-
data: data2,
|
|
592
|
-
schema: entry.schema
|
|
593
|
-
};
|
|
594
|
-
}).filter((object) => !existingIds.has(object.data.id));
|
|
595
|
-
const dbObjects = await db.query(Query.select(Filter.id(...existingIds))).run();
|
|
596
|
-
const queueObjects = await queue?.getObjectsById([
|
|
597
|
-
...existingIds
|
|
598
|
-
]) ?? [];
|
|
599
|
-
const objects = [
|
|
600
|
-
...dbObjects,
|
|
601
|
-
...queueObjects
|
|
602
|
-
].filter(isNonNullable);
|
|
603
|
-
log3.info("objects", {
|
|
604
|
-
dbObjects,
|
|
605
|
-
queueObjects,
|
|
606
|
-
existingIds
|
|
607
|
-
}, {
|
|
608
|
-
F: __dxlog_file3,
|
|
609
|
-
L: 298,
|
|
610
|
-
S: void 0,
|
|
611
|
-
C: (f, a) => f(...a)
|
|
612
|
-
});
|
|
613
|
-
const missing = Array.from(existingIds).filter((id) => !objects.some((object) => object.id === id));
|
|
614
|
-
if (missing.length > 0) {
|
|
615
|
-
throw new Error(`Object IDs do not point to existing objects: ${missing.join(", ")}`);
|
|
616
|
-
}
|
|
617
|
-
return res.flatMap(({ data: data2, schema }) => {
|
|
618
|
-
let skip = false;
|
|
619
|
-
if (RelationSourceDXNId in data2) {
|
|
620
|
-
const id = data2[RelationSourceDXNId].asEchoDXN()?.echoId;
|
|
621
|
-
const obj = objects.find((object) => object.id === id) ?? enitties.get(id);
|
|
622
|
-
if (obj) {
|
|
623
|
-
delete data2[RelationSourceDXNId];
|
|
624
|
-
data2[RelationSourceId] = obj;
|
|
625
|
-
} else {
|
|
626
|
-
skip = true;
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
if (RelationTargetDXNId in data2) {
|
|
630
|
-
const id = data2[RelationTargetDXNId].asEchoDXN()?.echoId;
|
|
631
|
-
const obj = objects.find((object) => object.id === id) ?? enitties.get(id);
|
|
632
|
-
if (obj) {
|
|
633
|
-
delete data2[RelationTargetDXNId];
|
|
634
|
-
data2[RelationTargetId] = obj;
|
|
635
|
-
} else {
|
|
636
|
-
skip = true;
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
if (!skip) {
|
|
640
|
-
const obj = createObject(schema, data2);
|
|
641
|
-
enitties.set(obj.id, obj);
|
|
642
|
-
return [
|
|
643
|
-
obj
|
|
644
|
-
];
|
|
645
|
-
}
|
|
646
|
-
return [];
|
|
647
|
-
});
|
|
648
|
-
};
|
|
649
|
-
var SoftRef = Schema5.Struct({
|
|
650
|
-
"/": Schema5.String
|
|
651
|
-
}).annotations({
|
|
652
|
-
description: "Reference to another object."
|
|
653
|
-
});
|
|
654
|
-
var preprocessSchema = (schema) => {
|
|
655
|
-
const isRelationSchema = Entity.getKind(schema) === "relation";
|
|
656
|
-
const go = (ast, visited = /* @__PURE__ */ new Set()) => {
|
|
657
|
-
if (visited.has(ast)) {
|
|
658
|
-
return ast;
|
|
659
|
-
}
|
|
660
|
-
visited.add(ast);
|
|
661
|
-
if (SchemaAST.getAnnotation(ast, ReferenceAnnotationId).pipe(Option3.isSome)) {
|
|
662
|
-
return SoftRef.ast;
|
|
663
|
-
}
|
|
664
|
-
return mapAst(ast, (child) => go(child, visited));
|
|
665
|
-
};
|
|
666
|
-
return Schema5.make(mapAst(schema.ast, (ast) => go(ast))).pipe(Schema5.omit("id"), Schema5.extend(Schema5.Struct({
|
|
667
|
-
id: Schema5.String.annotations({
|
|
668
|
-
description: "The id of this object. Come up with a unique id based on your judgement."
|
|
669
|
-
})
|
|
670
|
-
})), isRelationSchema ? Schema5.extend(Schema5.Struct({
|
|
671
|
-
source: Schema5.String.annotations({
|
|
672
|
-
description: "The id of the source object for this relation."
|
|
673
|
-
}),
|
|
674
|
-
target: Schema5.String.annotations({
|
|
675
|
-
description: "The id of the target object for this relation."
|
|
676
|
-
})
|
|
677
|
-
})) : Function3.identity);
|
|
678
|
-
};
|
|
679
|
-
|
|
680
|
-
// src/functions/research/document-create.ts
|
|
681
|
-
import * as Effect6 from "effect/Effect";
|
|
682
|
-
import * as Schema6 from "effect/Schema";
|
|
683
|
-
import { ArtifactId as ArtifactId3 } from "@dxos/assistant";
|
|
684
|
-
import { Obj as Obj5, Relation } from "@dxos/echo";
|
|
685
|
-
import { Database as Database5 } from "@dxos/echo";
|
|
686
|
-
import { TracingService as TracingService3, defineFunction as defineFunction5 } from "@dxos/functions";
|
|
687
|
-
import { log as log4 } from "@dxos/log";
|
|
688
|
-
import { Markdown as Markdown3 } from "@dxos/plugin-markdown/types";
|
|
689
|
-
import { HasSubject } from "@dxos/types";
|
|
690
|
-
import { trim as trim2 } from "@dxos/util";
|
|
691
|
-
var __dxlog_file4 = "/__w/dxos/dxos/packages/core/assistant-toolkit/src/functions/research/document-create.ts";
|
|
692
|
-
var document_create_default = defineFunction5({
|
|
693
|
-
key: "dxos.org/function/research/document-create",
|
|
694
|
-
name: "Create research document",
|
|
695
|
-
description: "Creates a note summarizing the research.",
|
|
696
|
-
inputSchema: Schema6.Struct({
|
|
697
|
-
subject: ArtifactId3.annotations({
|
|
698
|
-
description: trim2`
|
|
699
|
-
ID of the object (organization, contact, etc.) for which the research was performed.
|
|
700
|
-
`
|
|
701
|
-
}),
|
|
702
|
-
name: Schema6.String.annotations({
|
|
703
|
-
description: "Name of the document."
|
|
704
|
-
}),
|
|
705
|
-
content: Schema6.String.annotations({
|
|
706
|
-
description: trim2`
|
|
707
|
-
Content of the note.
|
|
708
|
-
Supports (and are prefered) references to research objects using @ syntax and <object> tags (refer to research blueprint instructions).
|
|
709
|
-
`
|
|
710
|
-
})
|
|
711
|
-
}),
|
|
712
|
-
outputSchema: Schema6.Struct({
|
|
713
|
-
document: ArtifactId3.annotations({
|
|
714
|
-
description: "DXN of the created document."
|
|
715
|
-
})
|
|
716
|
-
}),
|
|
717
|
-
handler: Effect6.fnUntraced(function* ({ data: { subject, name, content } }) {
|
|
718
|
-
log4.info("Creating research document", {
|
|
719
|
-
subject,
|
|
720
|
-
name,
|
|
721
|
-
content
|
|
722
|
-
}, {
|
|
723
|
-
F: __dxlog_file4,
|
|
724
|
-
L: 43,
|
|
725
|
-
S: this,
|
|
726
|
-
C: (f, a) => f(...a)
|
|
727
|
-
});
|
|
728
|
-
yield* Database5.Service.flush({
|
|
729
|
-
indexes: true
|
|
730
|
-
});
|
|
731
|
-
yield* TracingService3.emitStatus({
|
|
732
|
-
message: "Creating research document..."
|
|
733
|
-
});
|
|
734
|
-
const target = yield* Database5.Service.resolve(ArtifactId3.toDXN(subject));
|
|
735
|
-
const object = yield* Database5.Service.add(Markdown3.make({
|
|
736
|
-
name,
|
|
737
|
-
content
|
|
738
|
-
}));
|
|
739
|
-
yield* Database5.Service.add(Relation.make(HasSubject.HasSubject, {
|
|
740
|
-
[Relation.Source]: object,
|
|
741
|
-
[Relation.Target]: target,
|
|
742
|
-
completedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
743
|
-
}));
|
|
744
|
-
yield* Database5.Service.flush({
|
|
745
|
-
indexes: true
|
|
746
|
-
});
|
|
747
|
-
log4.info("Created research document", {
|
|
748
|
-
subject,
|
|
749
|
-
object
|
|
750
|
-
}, {
|
|
751
|
-
F: __dxlog_file4,
|
|
752
|
-
L: 70,
|
|
753
|
-
S: this,
|
|
754
|
-
C: (f, a) => f(...a)
|
|
755
|
-
});
|
|
756
|
-
return {
|
|
757
|
-
document: Obj5.getDXN(object).toString()
|
|
758
|
-
};
|
|
759
|
-
})
|
|
760
|
-
});
|
|
761
|
-
|
|
762
|
-
// src/functions/research/research.ts
|
|
763
|
-
import * as Toolkit2 from "@effect/ai/Toolkit";
|
|
764
|
-
import * as AnthropicTool from "@effect/ai-anthropic/AnthropicTool";
|
|
765
|
-
import * as Array6 from "effect/Array";
|
|
766
|
-
import * as Effect10 from "effect/Effect";
|
|
767
|
-
import * as Function4 from "effect/Function";
|
|
768
|
-
import * as Layer3 from "effect/Layer";
|
|
769
|
-
import * as Option4 from "effect/Option";
|
|
770
|
-
import * as Schema10 from "effect/Schema";
|
|
771
|
-
import * as String10 from "effect/String";
|
|
772
|
-
import { AiService as AiService2, ConsolePrinter as ConsolePrinter2 } from "@dxos/ai";
|
|
773
|
-
import { AiSession as AiSession2, GenerationObserver as GenerationObserver2, createToolkit as createToolkit2, makeToolExecutionServiceFromFunctions, makeToolResolverFromFunctions } from "@dxos/assistant";
|
|
774
|
-
import { Template as Template2 } from "@dxos/blueprints";
|
|
775
|
-
import { Entity as Entity2, Obj as Obj7 } from "@dxos/echo";
|
|
776
|
-
import { Database as Database7 } from "@dxos/echo";
|
|
777
|
-
import { TracingService as TracingService4, defineFunction as defineFunction8 } from "@dxos/functions";
|
|
778
|
-
import { FunctionInvocationServiceLayerTestMocked } from "@dxos/functions-runtime/testing";
|
|
779
|
-
import { Person } from "@dxos/types";
|
|
780
|
-
import { trim as trim3 } from "@dxos/util";
|
|
781
|
-
|
|
782
|
-
// src/functions/exa/exa.ts
|
|
783
|
-
import * as Effect7 from "effect/Effect";
|
|
784
|
-
import * as Schema7 from "effect/Schema";
|
|
785
|
-
import Exa from "exa-js";
|
|
786
|
-
import { CredentialsService as CredentialsService2, defineFunction as defineFunction6 } from "@dxos/functions";
|
|
787
|
-
var exa_default = defineFunction6({
|
|
788
|
-
key: "dxos.org/function/exa",
|
|
789
|
-
name: "Exa",
|
|
790
|
-
description: "Search the web for information",
|
|
791
|
-
inputSchema: Schema7.Struct({
|
|
792
|
-
query: Schema7.String.annotations({
|
|
793
|
-
description: "The query to search for."
|
|
794
|
-
})
|
|
795
|
-
}),
|
|
796
|
-
outputSchema: Schema7.Unknown,
|
|
797
|
-
handler: Effect7.fnUntraced(function* ({ data: { query } }) {
|
|
798
|
-
const credential = yield* CredentialsService2.getCredential({
|
|
799
|
-
service: "exa.ai"
|
|
800
|
-
});
|
|
801
|
-
const exa = new Exa(credential.apiKey);
|
|
802
|
-
const context = yield* Effect7.promise(async () => exa.searchAndContents(query, {
|
|
803
|
-
type: "auto",
|
|
804
|
-
text: {
|
|
805
|
-
maxCharacters: 3e3
|
|
806
|
-
},
|
|
807
|
-
livecrawl: "always"
|
|
808
|
-
}));
|
|
809
|
-
return context;
|
|
810
|
-
})
|
|
811
|
-
});
|
|
2
|
+
ExaMock
|
|
3
|
+
} from "./chunk-VDEDVOS6.mjs";
|
|
4
|
+
import "./chunk-J5LGTIGS.mjs";
|
|
812
5
|
|
|
813
6
|
// src/functions/exa/mock.ts
|
|
814
|
-
import * as
|
|
815
|
-
import
|
|
816
|
-
import { defineFunction as defineFunction7 } from "@dxos/functions";
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
import { Operation } from "@dxos/operation";
|
|
817
9
|
|
|
818
10
|
// src/functions/exa/data/exa-search-1748337321991.ts
|
|
819
11
|
var exa_search_1748337321991_default = {
|
|
@@ -1325,33 +517,22 @@ var SEARCH_RESULTS = [
|
|
|
1325
517
|
];
|
|
1326
518
|
|
|
1327
519
|
// src/functions/exa/mock.ts
|
|
1328
|
-
var mock_default =
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
}
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
const
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
return current;
|
|
1345
|
-
}
|
|
1346
|
-
const dist1 = levenshteinDistance(query, current.autopromptString);
|
|
1347
|
-
const dist2 = levenshteinDistance(query, closest.autopromptString || "");
|
|
1348
|
-
const weight1 = dist1 / Math.max(query.length, current.autopromptString.length);
|
|
1349
|
-
const weight2 = dist2 / Math.max(query.length, closest.autopromptString?.length || 0);
|
|
1350
|
-
return weight1 < weight2 ? current : closest;
|
|
1351
|
-
}, null);
|
|
1352
|
-
return result;
|
|
1353
|
-
})
|
|
1354
|
-
});
|
|
520
|
+
var mock_default = ExaMock.pipe(Operation.withHandler(Effect.fnUntraced(function* ({ query }) {
|
|
521
|
+
const result = SEARCH_RESULTS.reduce((closest, current) => {
|
|
522
|
+
if (!current.autopromptString) {
|
|
523
|
+
return closest;
|
|
524
|
+
}
|
|
525
|
+
if (!closest) {
|
|
526
|
+
return current;
|
|
527
|
+
}
|
|
528
|
+
const dist1 = levenshteinDistance(query, current.autopromptString);
|
|
529
|
+
const dist2 = levenshteinDistance(query, closest.autopromptString || "");
|
|
530
|
+
const weight1 = dist1 / Math.max(query.length, current.autopromptString.length);
|
|
531
|
+
const weight2 = dist2 / Math.max(query.length, closest.autopromptString?.length || 0);
|
|
532
|
+
return weight1 < weight2 ? current : closest;
|
|
533
|
+
}, null);
|
|
534
|
+
return result;
|
|
535
|
+
})));
|
|
1355
536
|
var levenshteinDistance = (str1, str2) => {
|
|
1356
537
|
const m = str1.length;
|
|
1357
538
|
const n = str2.length;
|
|
@@ -1369,1512 +550,7 @@ var levenshteinDistance = (str1, str2) => {
|
|
|
1369
550
|
}
|
|
1370
551
|
return dp[m][n];
|
|
1371
552
|
};
|
|
1372
|
-
|
|
1373
|
-
// src/functions/research/research-graph.ts
|
|
1374
|
-
import * as Effect9 from "effect/Effect";
|
|
1375
|
-
import * as Layer2 from "effect/Layer";
|
|
1376
|
-
import * as Schema9 from "effect/Schema";
|
|
1377
|
-
import { Obj as Obj6, Query as Query2, Ref as Ref2, Type as Type3 } from "@dxos/echo";
|
|
1378
|
-
import { Database as Database6 } from "@dxos/echo";
|
|
1379
|
-
import { SystemTypeAnnotation } from "@dxos/echo/internal";
|
|
1380
|
-
import { Queue } from "@dxos/echo-db";
|
|
1381
|
-
import { ContextQueueService as ContextQueueService2, QueueService } from "@dxos/functions";
|
|
1382
|
-
var ResearchGraph = Schema9.Struct({
|
|
1383
|
-
queue: Type3.Ref(Queue)
|
|
1384
|
-
}).pipe(Type3.object({
|
|
1385
|
-
typename: "dxos.org/type/ResearchGraph",
|
|
1386
|
-
version: "0.1.0"
|
|
1387
|
-
}), SystemTypeAnnotation.set(true));
|
|
1388
|
-
var queryResearchGraph = Effect9.fn("queryResearchGraph")(function* () {
|
|
1389
|
-
const objects = yield* Database6.Service.runQuery(Query2.type(ResearchGraph));
|
|
1390
|
-
return objects.at(0);
|
|
1391
|
-
});
|
|
1392
|
-
var createResearchGraph = Effect9.fn("createResearchGraph")(function* () {
|
|
1393
|
-
const queue = yield* QueueService.createQueue();
|
|
1394
|
-
return yield* Database6.Service.add(Obj6.make(ResearchGraph, {
|
|
1395
|
-
queue: Ref2.fromDXN(queue.dxn)
|
|
1396
|
-
}));
|
|
1397
|
-
});
|
|
1398
|
-
var contextQueueLayerFromResearchGraph = Layer2.unwrapEffect(Effect9.gen(function* () {
|
|
1399
|
-
const researchGraph = (yield* queryResearchGraph()) ?? (yield* createResearchGraph());
|
|
1400
|
-
const researchQueue = yield* Database6.Service.load(researchGraph.queue);
|
|
1401
|
-
return ContextQueueService2.layer(researchQueue);
|
|
1402
|
-
}));
|
|
1403
|
-
|
|
1404
|
-
// raw-loader:/__w/dxos/dxos/packages/core/assistant-toolkit/src/functions/research/research-instructions.tpl?raw
|
|
1405
|
-
var research_instructions_default = "You are the Research Agent.\n\nThe Research Agent is an expert assistant that conducts in-depth research using real-time web search.\nThe Research Agent outputs results in a structured format matching the schema provided.\n\nThe Research Agent is equipped with the ability to:\n\n- Generate precise and effective search queries \n- Request web pages by query.\n- Synthesize accurate, clear, and structured answers using reliable information from the retrieved content\n{{#if entityExtraction}}\n- Search the local database for information using a vector index (through a `local_search` tool)\n{{/if}}\n\nThe Research Agent always follows these principles:\n\n- Relevance First: The Research Agent only returns facts supported by content in retrieved web pages. The Research Agent never fabricates or guesses information.\n- Summarize, Don't Copy: The Research Agent synthesizes and rephrases content in its own words. The Research Agent quotes only when necessary.\n- Multiple Sources: The Research Agent cross-references at least 2 sources before drawing conclusions, unless the information is directly stated and non-controversial.\n- Transparency: The Research Agent mentions which sources were used and explains how it arrived at conclusions.\n- Accuracy Over Brevity: The Research Agent prefers detailed, technically accurate explanations over shallow summaries.\n- The Research Agent admits uncertainty rather than misleading.\n{{#if entityExtraction}}\n- The Research Agent picks the most concrete schema types for extracted information.\n- The Research Agent fills schema fields completely with information it is confident about, and omits fields it is not confident about.\n- When outputting results, the Research Agent adds extra data that fits the schema even if not directly related to the user's question.\n- The Research Agent creates relations and references between new objects found and what's already in the database.\n- The Research Agent does not create objects that are already in the database.\n- The Research Agent re-uses existing object IDs as references when enriching existing objects.\n- The Research Agent ALWAYS calls the `graph_writer` at the end to save the data. This conversation will be deleted, so only the data written to the graph will be preserved.\n{{/if}}\n\nThe Research Agent may be asked for:\n\n- Technical explanations\n- Literature reviews \n- Comparisons\n- Emerging trends\n- Implementation strategies\n\nThe Research Agent begins by interpreting the user's request, then:\n\nThe Research Agent breaks it into sub-questions (if applicable).\n\nFor each sub-question, the Research Agent generates a clear, concise web search query.\n\nThe Research Agent extracts and synthesizes relevant answers.\n\nThe Research Agent's output includes:\n\n- A clear, structured answer to the user's question\n- A citation list or link list of sources used\n\nOptionally, the Research Agent provides follow-up suggestions or questions for deeper inquiry.\n\nHere's how the Research Agent operates:\n\n1. The Research Agent analyzes the user's request and identifies key topics to search for (3 or more), printing them out.\n2. The Research Agent performs a web search for each topic.\n3. The Research Agent reads and analyzes results, cross references information from multiple sources, and represents conflicting information as ranges of possible values.\n\n{{#if entityExtraction}}\n4. The Research Agent searches the local database for information using a vector index that might link to the user's question.\n6. The Research Agent creates relations and references between new objects and existing database objects when related, using existing object IDs as references.\n7. The Research Agent selects the most concrete schema types for extracted information, using multiple types as needed, and prints its decision and reasoning.\n5. The Research Agent creates a clear, structured answer to the user's question.\n8. The Research Agent submits results using the specific schema.\n{{/if}}\n\n{{#if entityExtraction}}\nIMPORTANT:\n- The Research Agent always runs the `local_search` tool to search the local database at least once before submitting results.\n- The Research Agent does not create objects that already exist in the database.\n- Ids that are not in the database are human-readable strings like `ivan_zhao_1`.\n{{/if}}\n\nStatus reporting:\n\nThe Research Agent reports its status frequently using the `<status>` tags: <status>Searching for Google Founders</status>\nThe Research Agent reports its status in-between each tool call and before submitting results.\n\n{{#if entityExtraction}}\n<example>\n\nBased on my research, I can now provide information about Google and it's founders.\n\nThe following objects are already in the database, I will not submit them again, but I'll re-use their IDs as references:\n\n- 01JWRDEHPB5TT2JQQQC15038BT Google\n- 01JWRDEHPA14CYW2NW9FAH6DJJ Larry Page\n- 01JWRDEHPBN0BBJP57B9S108W6 Sergey Brin\n\nI will use the following schema to construct new objects:\n\n- type:dxos.org/type/Organization for Alphabet Inc.\n- type:dxos.org/type/Person for Ivan Zhao\n- type:dxos.org/type/Person for Simon Last\n- dxn:type:dxos.org/relation/Employer for Ivan's employer\n- dxn:type:dxos.org/relation/Employer for Simon's employer\n\n<status>Formatting results</status>\n\n</example>\n{{/if}}\n\nLast content block is the full research note -- the result of the research.\n";
|
|
1406
|
-
|
|
1407
|
-
// src/functions/research/types.ts
|
|
1408
|
-
import { Text } from "@dxos/schema";
|
|
1409
|
-
import { Event, HasConnection, HasRelationship, LegacyOrganization, LegacyPerson, Project, Task } from "@dxos/types";
|
|
1410
|
-
var ResearchDataTypes = [
|
|
1411
|
-
// Objects
|
|
1412
|
-
Event.Event,
|
|
1413
|
-
LegacyOrganization,
|
|
1414
|
-
Task.Task,
|
|
1415
|
-
Text.Text,
|
|
1416
|
-
// Relations
|
|
1417
|
-
// TODO(wittjosiah): Until views (e.g., Table) support relations this needs to be expressed via organization ref.
|
|
1418
|
-
// Employer.Employer,
|
|
1419
|
-
LegacyPerson,
|
|
1420
|
-
Project.Project,
|
|
1421
|
-
HasRelationship.HasRelationship,
|
|
1422
|
-
HasConnection.HasConnection
|
|
1423
|
-
];
|
|
1424
|
-
|
|
1425
|
-
// src/functions/research/research.ts
|
|
1426
|
-
var research_default = defineFunction8({
|
|
1427
|
-
key: "dxos.org/function/research",
|
|
1428
|
-
name: "Research",
|
|
1429
|
-
description: trim3`
|
|
1430
|
-
Search the web to research information about the given subject.
|
|
1431
|
-
Inserts structured data into the research graph.
|
|
1432
|
-
Creates a research summary and returns the objects created.
|
|
1433
|
-
`,
|
|
1434
|
-
inputSchema: Schema10.Struct({
|
|
1435
|
-
query: Schema10.String.annotations({
|
|
1436
|
-
description: trim3`
|
|
1437
|
-
The search query.
|
|
1438
|
-
If doing research on an object then load it first and pass it as JSON.
|
|
1439
|
-
`
|
|
1440
|
-
}),
|
|
1441
|
-
instructions: Schema10.optional(Schema10.String).annotations({
|
|
1442
|
-
description: trim3`
|
|
1443
|
-
The instructions for the research agent.
|
|
1444
|
-
`
|
|
1445
|
-
}),
|
|
1446
|
-
// TOOD(burdon): Move to context.
|
|
1447
|
-
mockSearch: Schema10.optional(Schema10.Boolean).annotations({
|
|
1448
|
-
description: "Whether to use the mock search tool.",
|
|
1449
|
-
default: false
|
|
1450
|
-
}),
|
|
1451
|
-
entityExtraction: Schema10.optional(Schema10.Boolean).annotations({
|
|
1452
|
-
description: trim3`
|
|
1453
|
-
Whether to extract structured entities from the research.
|
|
1454
|
-
Experimental feature only enable if user explicitly requests it.
|
|
1455
|
-
`,
|
|
1456
|
-
default: false
|
|
1457
|
-
})
|
|
1458
|
-
}),
|
|
1459
|
-
outputSchema: Schema10.Struct({
|
|
1460
|
-
document: Schema10.optional(Schema10.String).annotations({
|
|
1461
|
-
description: "The generated research document."
|
|
1462
|
-
}),
|
|
1463
|
-
objects: Schema10.Array(Schema10.Unknown).annotations({
|
|
1464
|
-
description: "Structured objects created during the research process."
|
|
1465
|
-
})
|
|
1466
|
-
}),
|
|
1467
|
-
handler: Effect10.fnUntraced(function* ({ data: { query, instructions: instructions6, mockSearch = false, entityExtraction = false } }) {
|
|
1468
|
-
if (mockSearch) {
|
|
1469
|
-
const mockPerson = yield* Database7.Service.add(Obj7.make(Person.Person, {
|
|
1470
|
-
preferredName: "John Doe",
|
|
1471
|
-
emails: [
|
|
1472
|
-
{
|
|
1473
|
-
value: "john.doe@example.com"
|
|
1474
|
-
}
|
|
1475
|
-
],
|
|
1476
|
-
phoneNumbers: [
|
|
1477
|
-
{
|
|
1478
|
-
value: "123-456-7890"
|
|
1479
|
-
}
|
|
1480
|
-
]
|
|
1481
|
-
}));
|
|
1482
|
-
return {
|
|
1483
|
-
document: trim3`
|
|
1484
|
-
The research ran in test-mode and was mocked. Proceed as usual.
|
|
1485
|
-
We reference John Doe to test reference: ${Obj7.getDXN(mockPerson)}
|
|
1486
|
-
`,
|
|
1487
|
-
objects: [
|
|
1488
|
-
Obj7.toJSON(mockPerson)
|
|
1489
|
-
]
|
|
1490
|
-
};
|
|
1491
|
-
}
|
|
1492
|
-
yield* Database7.Service.flush({
|
|
1493
|
-
indexes: true
|
|
1494
|
-
});
|
|
1495
|
-
yield* TracingService4.emitStatus({
|
|
1496
|
-
message: "Starting research..."
|
|
1497
|
-
});
|
|
1498
|
-
const NativeWebSearch = Toolkit2.make(AnthropicTool.WebSearch_20250305({}));
|
|
1499
|
-
let toolkit = NativeWebSearch;
|
|
1500
|
-
let handlers = Layer3.empty;
|
|
1501
|
-
const objectDXNs = [];
|
|
1502
|
-
if (entityExtraction) {
|
|
1503
|
-
const GraphWriterToolkit = makeGraphWriterToolkit({
|
|
1504
|
-
schema: ResearchDataTypes
|
|
1505
|
-
});
|
|
1506
|
-
const GraphWriterHandler = makeGraphWriterHandler(GraphWriterToolkit, {
|
|
1507
|
-
onAppend: (dxns) => objectDXNs.push(...dxns)
|
|
1508
|
-
});
|
|
1509
|
-
toolkit = Toolkit2.merge(toolkit, LocalSearchToolkit, GraphWriterToolkit);
|
|
1510
|
-
handlers = Layer3.mergeAll(handlers, LocalSearchHandler, GraphWriterHandler).pipe(Layer3.provide(contextQueueLayerFromResearchGraph));
|
|
1511
|
-
}
|
|
1512
|
-
const finishedToolkit = yield* createToolkit2({
|
|
1513
|
-
toolkit
|
|
1514
|
-
}).pipe(Effect10.provide(handlers));
|
|
1515
|
-
const session = new AiSession2();
|
|
1516
|
-
const result = yield* session.run({
|
|
1517
|
-
prompt: query,
|
|
1518
|
-
system: join(Template2.process(research_instructions_default, {
|
|
1519
|
-
entityExtraction
|
|
1520
|
-
}), instructions6 && `<instructions>${instructions6}</instructions>`),
|
|
1521
|
-
toolkit: finishedToolkit,
|
|
1522
|
-
observer: GenerationObserver2.fromPrinter(new ConsolePrinter2({
|
|
1523
|
-
tag: "research"
|
|
1524
|
-
}))
|
|
1525
|
-
});
|
|
1526
|
-
const objects = yield* Effect10.forEach(objectDXNs, (dxn) => Database7.Service.resolve(dxn)).pipe(Effect10.map(Array6.map((obj) => Entity2.toJSON(obj))));
|
|
1527
|
-
return {
|
|
1528
|
-
document: extractLastTextBlock(result),
|
|
1529
|
-
objects
|
|
1530
|
-
};
|
|
1531
|
-
}, Effect10.provide(Layer3.mergeAll(
|
|
1532
|
-
AiService2.model("@anthropic/claude-sonnet-4-0"),
|
|
1533
|
-
// TODO(dmaretskyi): Extract.
|
|
1534
|
-
makeToolResolverFromFunctions([
|
|
1535
|
-
exa_default,
|
|
1536
|
-
mock_default
|
|
1537
|
-
], Toolkit2.make()),
|
|
1538
|
-
makeToolExecutionServiceFromFunctions(Toolkit2.make(), Layer3.empty)
|
|
1539
|
-
).pipe(Layer3.provide(
|
|
1540
|
-
// TODO(dmaretskyi): This should be provided by environment.
|
|
1541
|
-
Layer3.mergeAll(FunctionInvocationServiceLayerTestMocked({
|
|
1542
|
-
functions: [
|
|
1543
|
-
exa_default,
|
|
1544
|
-
mock_default
|
|
1545
|
-
]
|
|
1546
|
-
}))
|
|
1547
|
-
))))
|
|
1548
|
-
});
|
|
1549
|
-
var join = (...strings) => strings.filter(Boolean).join("\n\n");
|
|
1550
|
-
var extractLastTextBlock = (result) => {
|
|
1551
|
-
return Function4.pipe(result, Array6.last, Option4.map(Function4.flow((_) => _.blocks, Array6.reverse, Array6.dropWhile((_) => _._tag === "summary"), Array6.takeWhile((_) => _._tag === "text"), Array6.reverse, Array6.map((_) => _.text), Array6.reduce("", String10.concat))), Option4.getOrElse(() => ""));
|
|
1552
|
-
};
|
|
1553
|
-
|
|
1554
|
-
// src/functions/research/index.ts
|
|
1555
|
-
(function(Research2) {
|
|
1556
|
-
Research2.create = document_create_default;
|
|
1557
|
-
Research2.research = research_default;
|
|
1558
|
-
})(Research || (Research = {}));
|
|
1559
|
-
var Research;
|
|
1560
|
-
|
|
1561
|
-
// src/functions/entity-extraction/entity-extraction.ts
|
|
1562
|
-
var __dxlog_file5 = "/__w/dxos/dxos/packages/core/assistant-toolkit/src/functions/entity-extraction/entity-extraction.ts";
|
|
1563
|
-
var entity_extraction_default = defineFunction9({
|
|
1564
|
-
key: "dxos.org/functions/entity-extraction",
|
|
1565
|
-
name: "Entity Extraction",
|
|
1566
|
-
description: "Extracts entities from emails and transcripts.",
|
|
1567
|
-
inputSchema: Schema11.Struct({
|
|
1568
|
-
source: Message2.Message.annotations({
|
|
1569
|
-
description: "Email or transcript to extract entities from."
|
|
1570
|
-
}),
|
|
1571
|
-
// TODO(dmaretskyi): Consider making this an array of blueprints instead.
|
|
1572
|
-
instructions: Schema11.optional(Schema11.String).annotations({
|
|
1573
|
-
description: "Instructions extraction process."
|
|
1574
|
-
})
|
|
1575
|
-
}),
|
|
1576
|
-
outputSchema: Schema11.Struct({
|
|
1577
|
-
entities: Schema11.optional(Schema11.Array(Type4.Obj).annotations({
|
|
1578
|
-
description: "Extracted entities."
|
|
1579
|
-
}))
|
|
1580
|
-
}),
|
|
1581
|
-
handler: Effect11.fnUntraced(function* ({ data: { source: message, instructions: instructions6 } }) {
|
|
1582
|
-
const tags = Obj8.getMeta(message)?.tags;
|
|
1583
|
-
const contact = yield* extractContact(message.sender, tags);
|
|
1584
|
-
let organization = null;
|
|
1585
|
-
if (contact && !contact.organization) {
|
|
1586
|
-
const created = [];
|
|
1587
|
-
const GraphWriterToolkit = makeGraphWriterToolkit({
|
|
1588
|
-
schema: [
|
|
1589
|
-
LegacyOrganization2
|
|
1590
|
-
]
|
|
1591
|
-
}).pipe();
|
|
1592
|
-
const GraphWriterHandler = makeGraphWriterHandler(GraphWriterToolkit, {
|
|
1593
|
-
onAppend: (dxns) => created.push(...dxns)
|
|
1594
|
-
});
|
|
1595
|
-
const toolkit = yield* GraphWriterToolkit.pipe(Effect11.provide(GraphWriterHandler.pipe(Layer4.provide(contextQueueLayerFromResearchGraph))));
|
|
1596
|
-
yield* new AiSession3().run({
|
|
1597
|
-
system: trim4`
|
|
1598
|
-
Extract the sender's organization from the email. If you are not sure, do nothing.
|
|
1599
|
-
The extracted organization URL must match the sender's email domain.
|
|
1600
|
-
${instructions6 ? "<user_intructions>" + instructions6 + "</user_intructions>" : ""},
|
|
1601
|
-
`,
|
|
1602
|
-
prompt: JSON.stringify({
|
|
1603
|
-
source: message,
|
|
1604
|
-
contact
|
|
1605
|
-
}),
|
|
1606
|
-
toolkit
|
|
1607
|
-
});
|
|
1608
|
-
if (created.length > 1) {
|
|
1609
|
-
throw new Error("Multiple organizations created");
|
|
1610
|
-
} else if (created.length === 1) {
|
|
1611
|
-
organization = yield* Database8.Service.resolve(created[0], Organization.Organization);
|
|
1612
|
-
Obj8.change(organization, (org) => {
|
|
1613
|
-
const meta = Obj8.getMeta(org);
|
|
1614
|
-
meta.tags ??= [];
|
|
1615
|
-
meta.tags.push(...tags ?? []);
|
|
1616
|
-
});
|
|
1617
|
-
Obj8.change(contact, (c) => {
|
|
1618
|
-
c.organization = Ref3.make(organization);
|
|
1619
|
-
});
|
|
1620
|
-
}
|
|
1621
|
-
}
|
|
1622
|
-
return {
|
|
1623
|
-
entities: [
|
|
1624
|
-
contact,
|
|
1625
|
-
organization
|
|
1626
|
-
].filter(Predicate.isNotNullable)
|
|
1627
|
-
};
|
|
1628
|
-
}, Effect11.provide(Layer4.mergeAll(AiService3.model("@anthropic/claude-sonnet-4-0"), makeToolResolverFromFunctions2([], Toolkit3.make()), makeToolExecutionServiceFromFunctions2(Toolkit3.make(), Layer4.empty)).pipe(Layer4.provide(
|
|
1629
|
-
// TODO(dmaretskyi): This should be provided by environment.
|
|
1630
|
-
Layer4.mergeAll(FunctionInvocationServiceLayerTest())
|
|
1631
|
-
))))
|
|
1632
|
-
});
|
|
1633
|
-
var extractContact = Effect11.fn("extractContact")(function* (actor, tags) {
|
|
1634
|
-
const name = actor.name;
|
|
1635
|
-
const email = actor.email;
|
|
1636
|
-
if (!email) {
|
|
1637
|
-
log5.warn("email is required for contact extraction", {
|
|
1638
|
-
actor
|
|
1639
|
-
}, {
|
|
1640
|
-
F: __dxlog_file5,
|
|
1641
|
-
L: 112,
|
|
1642
|
-
S: this,
|
|
1643
|
-
C: (f, a) => f(...a)
|
|
1644
|
-
});
|
|
1645
|
-
return void 0;
|
|
1646
|
-
}
|
|
1647
|
-
const existingContacts = yield* Database8.Service.runQuery(Filter2.type(Person2.Person));
|
|
1648
|
-
const existingContact = existingContacts.find((contact) => contact.emails?.some((contactEmail) => contactEmail.value === email));
|
|
1649
|
-
if (existingContact) {
|
|
1650
|
-
log5.info("Contact already exists", {
|
|
1651
|
-
email,
|
|
1652
|
-
existingContact
|
|
1653
|
-
}, {
|
|
1654
|
-
F: __dxlog_file5,
|
|
1655
|
-
L: 125,
|
|
1656
|
-
S: this,
|
|
1657
|
-
C: (f, a) => f(...a)
|
|
1658
|
-
});
|
|
1659
|
-
return existingContact;
|
|
1660
|
-
}
|
|
1661
|
-
const newContact = Obj8.make(Person2.Person, {
|
|
1662
|
-
...tags ? {
|
|
1663
|
-
[Obj8.Meta]: {
|
|
1664
|
-
tags: [
|
|
1665
|
-
...tags
|
|
1666
|
-
]
|
|
1667
|
-
}
|
|
1668
|
-
} : {},
|
|
1669
|
-
emails: [
|
|
1670
|
-
{
|
|
1671
|
-
value: email
|
|
1672
|
-
}
|
|
1673
|
-
]
|
|
1674
|
-
});
|
|
1675
|
-
yield* Database8.Service.add(newContact);
|
|
1676
|
-
if (name) {
|
|
1677
|
-
Obj8.change(newContact, (c) => {
|
|
1678
|
-
c.fullName = name;
|
|
1679
|
-
});
|
|
1680
|
-
}
|
|
1681
|
-
const emailDomain = email.split("@")[1]?.toLowerCase();
|
|
1682
|
-
if (!emailDomain) {
|
|
1683
|
-
log5.warn("Invalid email format, cannot extract domain", {
|
|
1684
|
-
email
|
|
1685
|
-
}, {
|
|
1686
|
-
F: __dxlog_file5,
|
|
1687
|
-
L: 143,
|
|
1688
|
-
S: this,
|
|
1689
|
-
C: (f, a) => f(...a)
|
|
1690
|
-
});
|
|
1691
|
-
return newContact;
|
|
1692
|
-
}
|
|
1693
|
-
log5.info("extracted email domain", {
|
|
1694
|
-
emailDomain
|
|
1695
|
-
}, {
|
|
1696
|
-
F: __dxlog_file5,
|
|
1697
|
-
L: 147,
|
|
1698
|
-
S: this,
|
|
1699
|
-
C: (f, a) => f(...a)
|
|
1700
|
-
});
|
|
1701
|
-
const existingOrganisations = yield* Database8.Service.runQuery(Filter2.type(Organization.Organization));
|
|
1702
|
-
const matchingOrg = existingOrganisations.find((org) => {
|
|
1703
|
-
if (org.website) {
|
|
1704
|
-
try {
|
|
1705
|
-
const websiteUrl = org.website.startsWith("http://") || org.website.startsWith("https://") ? org.website : `https://${org.website}`;
|
|
1706
|
-
const websiteDomain = new URL(websiteUrl).hostname.toLowerCase();
|
|
1707
|
-
return websiteDomain === emailDomain || websiteDomain.endsWith(`.${emailDomain}`) || emailDomain.endsWith(`.${websiteDomain}`);
|
|
1708
|
-
} catch (e) {
|
|
1709
|
-
log5.warn("Error parsing website URL", {
|
|
1710
|
-
website: org.website,
|
|
1711
|
-
error: e
|
|
1712
|
-
}, {
|
|
1713
|
-
F: __dxlog_file5,
|
|
1714
|
-
L: 165,
|
|
1715
|
-
S: this,
|
|
1716
|
-
C: (f, a) => f(...a)
|
|
1717
|
-
});
|
|
1718
|
-
return false;
|
|
1719
|
-
}
|
|
1720
|
-
}
|
|
1721
|
-
return false;
|
|
1722
|
-
});
|
|
1723
|
-
if (matchingOrg) {
|
|
1724
|
-
log5.info("found matching organization", {
|
|
1725
|
-
organization: matchingOrg
|
|
1726
|
-
}, {
|
|
1727
|
-
F: __dxlog_file5,
|
|
1728
|
-
L: 176,
|
|
1729
|
-
S: this,
|
|
1730
|
-
C: (f, a) => f(...a)
|
|
1731
|
-
});
|
|
1732
|
-
Obj8.change(newContact, (c) => {
|
|
1733
|
-
c.organization = Ref3.make(matchingOrg);
|
|
1734
|
-
});
|
|
1735
|
-
}
|
|
1736
|
-
return newContact;
|
|
1737
|
-
});
|
|
1738
|
-
|
|
1739
|
-
// src/functions/entity-extraction/index.ts
|
|
1740
|
-
(function(EntityExtraction2) {
|
|
1741
|
-
EntityExtraction2.extract = entity_extraction_default;
|
|
1742
|
-
})(EntityExtraction || (EntityExtraction = {}));
|
|
1743
|
-
var EntityExtraction;
|
|
1744
|
-
|
|
1745
|
-
// src/functions/linear/sync-issues.ts
|
|
1746
|
-
import * as FetchHttpClient2 from "@effect/platform/FetchHttpClient";
|
|
1747
|
-
import * as HttpClient from "@effect/platform/HttpClient";
|
|
1748
|
-
import * as Array9 from "effect/Array";
|
|
1749
|
-
import * as Effect13 from "effect/Effect";
|
|
1750
|
-
import * as Function5 from "effect/Function";
|
|
1751
|
-
import * as Schema12 from "effect/Schema";
|
|
1752
|
-
import { Filter as Filter4, Obj as Obj10, Query as Query4, Ref as Ref5 } from "@dxos/echo";
|
|
1753
|
-
import { Database as Database10 } from "@dxos/echo";
|
|
1754
|
-
import { CredentialsService as CredentialsService3, defineFunction as defineFunction10, withAuthorization } from "@dxos/functions";
|
|
1755
|
-
import { log as log7 } from "@dxos/log";
|
|
1756
|
-
import { Person as Person3, Project as Project2, Task as Task2 } from "@dxos/types";
|
|
1757
|
-
|
|
1758
|
-
// src/sync/sync.ts
|
|
1759
|
-
import * as Effect12 from "effect/Effect";
|
|
1760
|
-
import { Filter as Filter3, Obj as Obj9, Query as Query3, Ref as Ref4 } from "@dxos/echo";
|
|
1761
|
-
import { Database as Database9 } from "@dxos/echo";
|
|
1762
|
-
import { failedInvariant } from "@dxos/invariant";
|
|
1763
|
-
import { log as log6 } from "@dxos/log";
|
|
1764
|
-
var __dxlog_file6 = "/__w/dxos/dxos/packages/core/assistant-toolkit/src/sync/sync.ts";
|
|
1765
|
-
var syncObjects = Effect12.fn("syncObjects")(function* (objs, { foreignKeyId }) {
|
|
1766
|
-
return yield* Effect12.forEach(objs, Effect12.fnUntraced(function* (obj) {
|
|
1767
|
-
for (const key of Object.keys(obj)) {
|
|
1768
|
-
if (typeof key !== "string" || key === "id") continue;
|
|
1769
|
-
if (!Ref4.isRef(obj[key])) continue;
|
|
1770
|
-
const ref = obj[key];
|
|
1771
|
-
if (!ref.target) continue;
|
|
1772
|
-
if (Obj9.getDXN(ref.target).isLocalObjectId()) {
|
|
1773
|
-
const [target] = yield* syncObjects([
|
|
1774
|
-
ref.target
|
|
1775
|
-
], {
|
|
1776
|
-
foreignKeyId
|
|
1777
|
-
});
|
|
1778
|
-
obj[key] = Ref4.make(target);
|
|
1779
|
-
}
|
|
1780
|
-
}
|
|
1781
|
-
const schema = Obj9.getSchema(obj) ?? failedInvariant("No schema.");
|
|
1782
|
-
const foreignId = Obj9.getKeys(obj, foreignKeyId)[0]?.id ?? failedInvariant("No foreign key.");
|
|
1783
|
-
const [existing] = yield* Database9.Service.runQuery(Query3.select(Filter3.foreignKeys(schema, [
|
|
1784
|
-
{
|
|
1785
|
-
source: foreignKeyId,
|
|
1786
|
-
id: foreignId
|
|
1787
|
-
}
|
|
1788
|
-
])));
|
|
1789
|
-
log6("sync object", {
|
|
1790
|
-
type: Obj9.getTypename(obj),
|
|
1791
|
-
foreignId,
|
|
1792
|
-
existing: existing ? Obj9.getDXN(existing) : void 0
|
|
1793
|
-
}, {
|
|
1794
|
-
F: __dxlog_file6,
|
|
1795
|
-
L: 48,
|
|
1796
|
-
S: this,
|
|
1797
|
-
C: (f, a) => f(...a)
|
|
1798
|
-
});
|
|
1799
|
-
if (!existing) {
|
|
1800
|
-
yield* Database9.Service.add(obj);
|
|
1801
|
-
return obj;
|
|
1802
|
-
} else {
|
|
1803
|
-
copyObjectData(existing, obj);
|
|
1804
|
-
return existing;
|
|
1805
|
-
}
|
|
1806
|
-
}), {
|
|
1807
|
-
concurrency: 1
|
|
1808
|
-
});
|
|
1809
|
-
});
|
|
1810
|
-
var copyObjectData = (existing, newObj) => {
|
|
1811
|
-
Obj9.change(existing, (obj) => {
|
|
1812
|
-
for (const key of Object.keys(newObj)) {
|
|
1813
|
-
if (typeof key !== "string" || key === "id") continue;
|
|
1814
|
-
if (typeof newObj[key] !== "string" && typeof newObj[key] !== "number" && typeof newObj[key] !== "boolean" && !Ref4.isRef(newObj[key])) continue;
|
|
1815
|
-
obj[key] = newObj[key];
|
|
1816
|
-
}
|
|
1817
|
-
for (const key of Object.keys(obj)) {
|
|
1818
|
-
if (typeof key !== "string" || key === "id") continue;
|
|
1819
|
-
if (!(key in newObj)) {
|
|
1820
|
-
delete obj[key];
|
|
1821
|
-
}
|
|
1822
|
-
}
|
|
1823
|
-
for (const foreignKey of Obj9.getMeta(newObj).keys) {
|
|
1824
|
-
Obj9.deleteKeys(obj, foreignKey.source);
|
|
1825
|
-
Obj9.getMeta(obj).keys.push({
|
|
1826
|
-
...foreignKey
|
|
1827
|
-
});
|
|
1828
|
-
}
|
|
1829
|
-
});
|
|
1830
|
-
};
|
|
1831
|
-
|
|
1832
|
-
// src/util/graphql.ts
|
|
1833
|
-
import * as HttpBody from "@effect/platform/HttpBody";
|
|
1834
|
-
var graphqlRequestBody = (query, variables = {}) => HttpBody.json({
|
|
1835
|
-
query,
|
|
1836
|
-
variables
|
|
1837
|
-
});
|
|
1838
|
-
|
|
1839
|
-
// src/functions/linear/sync-issues.ts
|
|
1840
|
-
var __dxlog_file7 = "/__w/dxos/dxos/packages/core/assistant-toolkit/src/functions/linear/sync-issues.ts";
|
|
1841
|
-
var queryIssues = `
|
|
1842
|
-
query Issues($teamId: String!, $after: DateTimeOrDuration!) {
|
|
1843
|
-
team(id: $teamId) {
|
|
1844
|
-
id
|
|
1845
|
-
name
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
issues(last: 150, orderBy: updatedAt, filter: {
|
|
1849
|
-
updatedAt: { gt: $after }
|
|
1850
|
-
}) {
|
|
1851
|
-
edges {
|
|
1852
|
-
node {
|
|
1853
|
-
id
|
|
1854
|
-
title
|
|
1855
|
-
createdAt
|
|
1856
|
-
updatedAt
|
|
1857
|
-
description
|
|
1858
|
-
assignee { id, name }
|
|
1859
|
-
state {
|
|
1860
|
-
name
|
|
1861
|
-
}
|
|
1862
|
-
project {
|
|
1863
|
-
id
|
|
1864
|
-
name
|
|
1865
|
-
}
|
|
1866
|
-
}
|
|
1867
|
-
cursor
|
|
1868
|
-
}
|
|
1869
|
-
pageInfo {
|
|
1870
|
-
hasNextPage
|
|
1871
|
-
endCursor
|
|
1872
|
-
}
|
|
1873
|
-
}
|
|
1874
|
-
}
|
|
1875
|
-
}
|
|
1876
|
-
`;
|
|
1877
|
-
var LINEAR_ID_KEY = "linear.app/id";
|
|
1878
|
-
var LINEAR_TEAM_ID_KEY = "linear.app/teamId";
|
|
1879
|
-
var LINEAR_UPDATED_AT_KEY = "linear.app/updatedAt";
|
|
1880
|
-
var sync_issues_default = defineFunction10({
|
|
1881
|
-
key: "dxos.org/function/linear/sync-issues",
|
|
1882
|
-
name: "Linear",
|
|
1883
|
-
description: "Sync issues from Linear.",
|
|
1884
|
-
inputSchema: Schema12.Struct({
|
|
1885
|
-
team: Schema12.String.annotations({
|
|
1886
|
-
description: "Linear team id."
|
|
1887
|
-
})
|
|
1888
|
-
}),
|
|
1889
|
-
handler: Effect13.fnUntraced(function* ({ data }) {
|
|
1890
|
-
const credential = yield* CredentialsService3.getCredential({
|
|
1891
|
-
service: "linear.app"
|
|
1892
|
-
});
|
|
1893
|
-
const client = yield* HttpClient.HttpClient.pipe(Effect13.map(withAuthorization(credential.apiKey)));
|
|
1894
|
-
const after = yield* getLatestUpdateTimestamp(data.team, Task2.Task);
|
|
1895
|
-
log7.info("will fetch", {
|
|
1896
|
-
after
|
|
1897
|
-
}, {
|
|
1898
|
-
F: __dxlog_file7,
|
|
1899
|
-
L: 93,
|
|
1900
|
-
S: this,
|
|
1901
|
-
C: (f, a) => f(...a)
|
|
1902
|
-
});
|
|
1903
|
-
const response = yield* client.post("https://api.linear.app/graphql", {
|
|
1904
|
-
body: yield* graphqlRequestBody(queryIssues, {
|
|
1905
|
-
teamId: data.team,
|
|
1906
|
-
after
|
|
1907
|
-
})
|
|
1908
|
-
});
|
|
1909
|
-
const json2 = yield* response.json;
|
|
1910
|
-
const tasks = json2.data.team.issues.edges.map((edge) => mapLinearIssue(edge.node, {
|
|
1911
|
-
teamId: data.team
|
|
1912
|
-
}));
|
|
1913
|
-
log7.info("Fetched tasks", {
|
|
1914
|
-
count: tasks.length
|
|
1915
|
-
}, {
|
|
1916
|
-
F: __dxlog_file7,
|
|
1917
|
-
L: 106,
|
|
1918
|
-
S: this,
|
|
1919
|
-
C: (f, a) => f(...a)
|
|
1920
|
-
});
|
|
1921
|
-
return {
|
|
1922
|
-
objects: yield* syncObjects(tasks, {
|
|
1923
|
-
foreignKeyId: LINEAR_ID_KEY
|
|
1924
|
-
}),
|
|
1925
|
-
syncComplete: tasks.length < 150
|
|
1926
|
-
};
|
|
1927
|
-
}, Effect13.provide(FetchHttpClient2.layer))
|
|
1928
|
-
});
|
|
1929
|
-
var getLatestUpdateTimestamp = Effect13.fnUntraced(function* (teamId, dataType) {
|
|
1930
|
-
const existingTasks = yield* Database10.Service.runQuery(Query4.type(dataType).select(Filter4.foreignKeys(dataType, [
|
|
1931
|
-
{
|
|
1932
|
-
source: LINEAR_TEAM_ID_KEY,
|
|
1933
|
-
id: teamId
|
|
1934
|
-
}
|
|
1935
|
-
])));
|
|
1936
|
-
return Function5.pipe(existingTasks, Array9.map((task) => Obj10.getKeys(task, LINEAR_UPDATED_AT_KEY).at(0)?.id), Array9.filter((x) => x !== void 0), Array9.reduce("2025-01-01T00:00:00.000Z", (acc, x) => x > acc ? x : acc));
|
|
1937
|
-
});
|
|
1938
|
-
var mapLinearPerson = (person, { teamId }) => Obj10.make(Person3.Person, {
|
|
1939
|
-
[Obj10.Meta]: {
|
|
1940
|
-
keys: [
|
|
1941
|
-
{
|
|
1942
|
-
id: person.id,
|
|
1943
|
-
source: LINEAR_ID_KEY
|
|
1944
|
-
},
|
|
1945
|
-
{
|
|
1946
|
-
id: teamId,
|
|
1947
|
-
source: LINEAR_TEAM_ID_KEY
|
|
1948
|
-
}
|
|
1949
|
-
]
|
|
1950
|
-
},
|
|
1951
|
-
nickname: person.name
|
|
1952
|
-
});
|
|
1953
|
-
var mapLinearIssue = (issue, { teamId }) => Obj10.make(Task2.Task, {
|
|
1954
|
-
[Obj10.Meta]: {
|
|
1955
|
-
keys: [
|
|
1956
|
-
{
|
|
1957
|
-
id: issue.id,
|
|
1958
|
-
source: LINEAR_ID_KEY
|
|
1959
|
-
},
|
|
1960
|
-
{
|
|
1961
|
-
id: issue.updatedAt,
|
|
1962
|
-
source: LINEAR_UPDATED_AT_KEY
|
|
1963
|
-
},
|
|
1964
|
-
{
|
|
1965
|
-
id: teamId,
|
|
1966
|
-
source: LINEAR_TEAM_ID_KEY
|
|
1967
|
-
}
|
|
1968
|
-
]
|
|
1969
|
-
},
|
|
1970
|
-
title: issue.title ?? void 0,
|
|
1971
|
-
description: issue.description ?? void 0,
|
|
1972
|
-
assigned: !issue.assignee ? void 0 : Ref5.make(mapLinearPerson(issue.assignee, {
|
|
1973
|
-
teamId
|
|
1974
|
-
})),
|
|
1975
|
-
// TODO(dmaretskyi): Sync those (+ linear team as org?).
|
|
1976
|
-
// state: issue.state.name,
|
|
1977
|
-
project: !issue.project ? void 0 : Ref5.make(Project2.make({
|
|
1978
|
-
[Obj10.Meta]: {
|
|
1979
|
-
keys: [
|
|
1980
|
-
{
|
|
1981
|
-
id: issue.project.id,
|
|
1982
|
-
source: LINEAR_ID_KEY
|
|
1983
|
-
},
|
|
1984
|
-
{
|
|
1985
|
-
id: teamId,
|
|
1986
|
-
source: LINEAR_TEAM_ID_KEY
|
|
1987
|
-
}
|
|
1988
|
-
]
|
|
1989
|
-
},
|
|
1990
|
-
name: issue.project.name
|
|
1991
|
-
}))
|
|
1992
|
-
});
|
|
1993
|
-
|
|
1994
|
-
// src/functions/linear/index.ts
|
|
1995
|
-
(function(Linear2) {
|
|
1996
|
-
Linear2.sync = sync_issues_default;
|
|
1997
|
-
})(Linear || (Linear = {}));
|
|
1998
|
-
var Linear;
|
|
1999
|
-
|
|
2000
|
-
// src/functions/tasks/read.ts
|
|
2001
|
-
import * as Effect14 from "effect/Effect";
|
|
2002
|
-
import * as Schema13 from "effect/Schema";
|
|
2003
|
-
import { ArtifactId as ArtifactId4 } from "@dxos/assistant";
|
|
2004
|
-
import { Database as Database11 } from "@dxos/echo";
|
|
2005
|
-
import { defineFunction as defineFunction11 } from "@dxos/functions";
|
|
2006
|
-
import { Markdown as Markdown4 } from "@dxos/plugin-markdown/types";
|
|
2007
|
-
var read_default2 = defineFunction11({
|
|
2008
|
-
key: "dxos.org/function/markdown/read-tasks",
|
|
2009
|
-
name: "Read",
|
|
2010
|
-
description: "Read markdown tasks.",
|
|
2011
|
-
inputSchema: Schema13.Struct({
|
|
2012
|
-
id: ArtifactId4.annotations({
|
|
2013
|
-
description: "The ID of the document to read."
|
|
2014
|
-
})
|
|
2015
|
-
}),
|
|
2016
|
-
outputSchema: Schema13.Struct({
|
|
2017
|
-
content: Schema13.String
|
|
2018
|
-
}),
|
|
2019
|
-
handler: Effect14.fn(function* ({ data: { id } }) {
|
|
2020
|
-
const doc = yield* Database11.Service.resolve(ArtifactId4.toDXN(id), Markdown4.Document);
|
|
2021
|
-
const { content } = yield* Database11.Service.load(doc.content);
|
|
2022
|
-
const lines = content.split("\n");
|
|
2023
|
-
const len = String(lines.length).length;
|
|
2024
|
-
const numbered = lines.map((line, i) => `${String(i + 1).padStart(len, " ")}. ${line}`).join("\n");
|
|
2025
|
-
return {
|
|
2026
|
-
content: numbered
|
|
2027
|
-
};
|
|
2028
|
-
})
|
|
2029
|
-
});
|
|
2030
|
-
|
|
2031
|
-
// src/functions/tasks/update.ts
|
|
2032
|
-
import * as Effect15 from "effect/Effect";
|
|
2033
|
-
import * as Schema14 from "effect/Schema";
|
|
2034
|
-
import { ArtifactId as ArtifactId5 } from "@dxos/assistant";
|
|
2035
|
-
import { Database as Database12 } from "@dxos/echo";
|
|
2036
|
-
import { defineFunction as defineFunction12 } from "@dxos/functions";
|
|
2037
|
-
import { Markdown as Markdown5 } from "@dxos/plugin-markdown/types";
|
|
2038
|
-
|
|
2039
|
-
// src/functions/tasks/task-list.ts
|
|
2040
|
-
var MarkdownTasks = class {
|
|
2041
|
-
_lineEndings;
|
|
2042
|
-
_content;
|
|
2043
|
-
constructor(initialContent = "") {
|
|
2044
|
-
this._lineEndings = initialContent.includes("\r\n") ? "\r\n" : "\n";
|
|
2045
|
-
this._content = initialContent ? initialContent.split(this._lineEndings) : [];
|
|
2046
|
-
}
|
|
2047
|
-
/**
|
|
2048
|
-
* Get the current document content with line numbers prefixed.
|
|
2049
|
-
*/
|
|
2050
|
-
getNumberedContent() {
|
|
2051
|
-
return this._content.map((line, index) => `${(index + 1).toString().padStart(3, " ")}\u2192${line}`).join(this._lineEndings);
|
|
2052
|
-
}
|
|
2053
|
-
/**
|
|
2054
|
-
* Get the raw document content without line numbers.
|
|
2055
|
-
*/
|
|
2056
|
-
getRawContent() {
|
|
2057
|
-
return this._content.join(this._lineEndings);
|
|
2058
|
-
}
|
|
2059
|
-
/**
|
|
2060
|
-
* Insert a new task at the specified line number (1-based).
|
|
2061
|
-
* Indentation level determines hierarchy (0, 2, 4, 6 spaces etc.)
|
|
2062
|
-
*/
|
|
2063
|
-
insertTask(lineNumber, taskText, completed = false, indent = 0) {
|
|
2064
|
-
const indentStr = " ".repeat(indent);
|
|
2065
|
-
const taskLine = completed ? `${indentStr}- [x] ${taskText}` : `${indentStr}- [ ] ${taskText}`;
|
|
2066
|
-
const insertIndex = Math.max(0, Math.min(lineNumber - 1, this._content.length));
|
|
2067
|
-
this._content.splice(insertIndex, 0, taskLine);
|
|
2068
|
-
}
|
|
2069
|
-
/**
|
|
2070
|
-
* Delete a task at the specified line number (1-based).
|
|
2071
|
-
*/
|
|
2072
|
-
deleteTask(lineNumber) {
|
|
2073
|
-
if (lineNumber < 1 || lineNumber > this._content.length) {
|
|
2074
|
-
return false;
|
|
2075
|
-
}
|
|
2076
|
-
this._content.splice(lineNumber - 1, 1);
|
|
2077
|
-
return true;
|
|
2078
|
-
}
|
|
2079
|
-
/**
|
|
2080
|
-
* Update the text of a task at the specified line number (1-based).
|
|
2081
|
-
*/
|
|
2082
|
-
updateTaskText(lineNumber, newText) {
|
|
2083
|
-
if (lineNumber < 1 || lineNumber > this._content.length) {
|
|
2084
|
-
return false;
|
|
2085
|
-
}
|
|
2086
|
-
const currentLine = this._content[lineNumber - 1];
|
|
2087
|
-
const taskMatch = currentLine.match(/^(\s*- \[[x ]\] )(.*)$/);
|
|
2088
|
-
if (taskMatch) {
|
|
2089
|
-
this._content[lineNumber - 1] = `${taskMatch[1]}${newText}`;
|
|
2090
|
-
return true;
|
|
2091
|
-
}
|
|
2092
|
-
return false;
|
|
2093
|
-
}
|
|
2094
|
-
/**
|
|
2095
|
-
* Mark a task as complete or incomplete at the specified line number (1-based).
|
|
2096
|
-
*/
|
|
2097
|
-
toggleTaskCompletion(lineNumber, completed) {
|
|
2098
|
-
if (lineNumber < 1 || lineNumber > this._content.length) {
|
|
2099
|
-
return false;
|
|
2100
|
-
}
|
|
2101
|
-
const currentLine = this._content[lineNumber - 1];
|
|
2102
|
-
const taskMatch = currentLine.match(/^(\s*- \[)([x ])(.*)$/);
|
|
2103
|
-
if (taskMatch) {
|
|
2104
|
-
const isCurrentlyComplete = taskMatch[2] === "x";
|
|
2105
|
-
const newStatus = completed !== void 0 ? completed : !isCurrentlyComplete;
|
|
2106
|
-
const statusChar = newStatus ? "x" : " ";
|
|
2107
|
-
this._content[lineNumber - 1] = `${taskMatch[1]}${statusChar}${taskMatch[3]}`;
|
|
2108
|
-
return true;
|
|
2109
|
-
}
|
|
2110
|
-
return false;
|
|
2111
|
-
}
|
|
2112
|
-
/**
|
|
2113
|
-
* Change the indentation level of a task (for hierarchy).
|
|
2114
|
-
*/
|
|
2115
|
-
setTaskIndent(lineNumber, indent) {
|
|
2116
|
-
if (lineNumber < 1 || lineNumber > this._content.length) {
|
|
2117
|
-
return false;
|
|
2118
|
-
}
|
|
2119
|
-
const currentLine = this._content[lineNumber - 1];
|
|
2120
|
-
const taskMatch = currentLine.match(/^\s*- (\[[x ]\] .*)$/);
|
|
2121
|
-
if (taskMatch) {
|
|
2122
|
-
const indentStr = " ".repeat(indent);
|
|
2123
|
-
this._content[lineNumber - 1] = `${indentStr}- ${taskMatch[1]}`;
|
|
2124
|
-
return true;
|
|
2125
|
-
}
|
|
2126
|
-
return false;
|
|
2127
|
-
}
|
|
2128
|
-
/**
|
|
2129
|
-
* Get the total number of lines in the document.
|
|
2130
|
-
*/
|
|
2131
|
-
getLineCount() {
|
|
2132
|
-
return this._content.length;
|
|
2133
|
-
}
|
|
2134
|
-
/**
|
|
2135
|
-
* Apply multiple operations atomically.
|
|
2136
|
-
*/
|
|
2137
|
-
applyOperations(operations) {
|
|
2138
|
-
const sortedOps = [
|
|
2139
|
-
...operations
|
|
2140
|
-
].sort((a, b) => {
|
|
2141
|
-
const aLine = "lineNumber" in a ? a.lineNumber : 0;
|
|
2142
|
-
const bLine = "lineNumber" in b ? b.lineNumber : 0;
|
|
2143
|
-
return bLine - aLine;
|
|
2144
|
-
});
|
|
2145
|
-
for (const op of sortedOps) {
|
|
2146
|
-
switch (op.type) {
|
|
2147
|
-
case "insertTask":
|
|
2148
|
-
this.insertTask(op.lineNumber, op.text, op.completed, op.indent);
|
|
2149
|
-
break;
|
|
2150
|
-
case "deleteTask":
|
|
2151
|
-
this.deleteTask(op.lineNumber);
|
|
2152
|
-
break;
|
|
2153
|
-
case "updateTaskText":
|
|
2154
|
-
this.updateTaskText(op.lineNumber, op.text);
|
|
2155
|
-
break;
|
|
2156
|
-
case "toggleTaskCompletion":
|
|
2157
|
-
this.toggleTaskCompletion(op.lineNumber, op.completed);
|
|
2158
|
-
break;
|
|
2159
|
-
case "setTaskIndent":
|
|
2160
|
-
this.setTaskIndent(op.lineNumber, op.indent);
|
|
2161
|
-
break;
|
|
2162
|
-
}
|
|
2163
|
-
}
|
|
2164
|
-
}
|
|
2165
|
-
};
|
|
2166
|
-
|
|
2167
|
-
// src/functions/tasks/update.ts
|
|
2168
|
-
var update_default2 = defineFunction12({
|
|
2169
|
-
key: "dxos.org/function/markdown/update-tasks",
|
|
2170
|
-
name: "Update markdown",
|
|
2171
|
-
description: "Creates and updates tasks in markdown documents.",
|
|
2172
|
-
inputSchema: Schema14.Struct({
|
|
2173
|
-
id: ArtifactId5.annotations({
|
|
2174
|
-
description: "The ID of the document to update."
|
|
2175
|
-
}),
|
|
2176
|
-
operations: Schema14.optional(Schema14.Array(Schema14.Any.annotations({
|
|
2177
|
-
description: "Task operations to apply."
|
|
2178
|
-
})))
|
|
2179
|
-
}),
|
|
2180
|
-
outputSchema: Schema14.Struct({
|
|
2181
|
-
content: Schema14.String,
|
|
2182
|
-
numberedContent: Schema14.String.annotations({
|
|
2183
|
-
description: "Content with line numbers for agent reference."
|
|
2184
|
-
})
|
|
2185
|
-
}),
|
|
2186
|
-
handler: Effect15.fn(function* ({ data: { id, operations = [] } }) {
|
|
2187
|
-
const doc = yield* Database12.Service.resolve(ArtifactId5.toDXN(id), Markdown5.Document);
|
|
2188
|
-
const { content } = yield* Database12.Service.load(doc.content);
|
|
2189
|
-
const taskManager = new MarkdownTasks(content);
|
|
2190
|
-
if (operations.length > 0) {
|
|
2191
|
-
taskManager.applyOperations(operations);
|
|
2192
|
-
}
|
|
2193
|
-
return {
|
|
2194
|
-
content: taskManager.getRawContent(),
|
|
2195
|
-
numberedContent: taskManager.getNumberedContent()
|
|
2196
|
-
};
|
|
2197
|
-
})
|
|
2198
|
-
});
|
|
2199
|
-
|
|
2200
|
-
// src/functions/tasks/index.ts
|
|
2201
|
-
(function(Tasks2) {
|
|
2202
|
-
Tasks2.read = read_default2;
|
|
2203
|
-
Tasks2.update = update_default2;
|
|
2204
|
-
})(Tasks || (Tasks = {}));
|
|
2205
|
-
var Tasks;
|
|
2206
|
-
|
|
2207
|
-
// src/blueprints/design/design-blueprint.ts
|
|
2208
|
-
var instructions = trim5`
|
|
2209
|
-
You manage a design spec based on the conversation.
|
|
2210
|
-
The design spec is a markdown document that is used to record the tasks.
|
|
2211
|
-
The design spec document follows a hierarchical structure, with nested markdown bulleted sections.
|
|
2212
|
-
Use the appropriate tools to read and write the design spec document.
|
|
2213
|
-
Maintain the document so that it can convey all relevant points from the conversation.
|
|
2214
|
-
When replying to the user, be terse with your comments about design doc handling.
|
|
2215
|
-
Do not announce when you read or write the design spec document.
|
|
2216
|
-
`;
|
|
2217
|
-
var blueprint = Blueprint.make({
|
|
2218
|
-
key: "dxos.org/blueprint/design",
|
|
2219
|
-
name: "Design Spec",
|
|
2220
|
-
description: "Preserve the conversation in the design spec.",
|
|
2221
|
-
instructions: {
|
|
2222
|
-
source: Ref6.make(Text2.make(instructions))
|
|
2223
|
-
},
|
|
2224
|
-
tools: [
|
|
2225
|
-
Document.read,
|
|
2226
|
-
Document.update
|
|
2227
|
-
].map((fn9) => ToolId.make(fn9.key))
|
|
2228
|
-
});
|
|
2229
|
-
|
|
2230
|
-
// src/blueprints/design/index.ts
|
|
2231
|
-
var design_default = blueprint;
|
|
2232
|
-
|
|
2233
|
-
// src/blueprints/discord/discord-blueprint.ts
|
|
2234
|
-
import { ToolId as ToolId2 } from "@dxos/ai";
|
|
2235
|
-
import { Blueprint as Blueprint2 } from "@dxos/blueprints";
|
|
2236
|
-
import { Ref as Ref7 } from "@dxos/echo";
|
|
2237
|
-
import { Text as Text3 } from "@dxos/schema";
|
|
2238
|
-
import { trim as trim6 } from "@dxos/util";
|
|
2239
|
-
var instructions2 = trim6`
|
|
2240
|
-
You are able to fetch messages from Discord servers.
|
|
2241
|
-
|
|
2242
|
-
Known servers:
|
|
2243
|
-
|
|
2244
|
-
DXOS serverId: 837138313172353095
|
|
2245
|
-
`;
|
|
2246
|
-
var blueprint2 = Blueprint2.make({
|
|
2247
|
-
key: "dxos.org/blueprint/discord",
|
|
2248
|
-
name: "Discord",
|
|
2249
|
-
description: "Discord integration.",
|
|
2250
|
-
instructions: {
|
|
2251
|
-
source: Ref7.make(Text3.make(instructions2))
|
|
2252
|
-
},
|
|
2253
|
-
tools: [
|
|
2254
|
-
ToolId2.make(Discord.fetch.key)
|
|
2255
|
-
]
|
|
2256
|
-
});
|
|
2257
|
-
|
|
2258
|
-
// src/blueprints/discord/index.ts
|
|
2259
|
-
var discord_default = blueprint2;
|
|
2260
|
-
|
|
2261
|
-
// src/blueprints/linear/linear-blueprint.ts
|
|
2262
|
-
import { ToolId as ToolId3 } from "@dxos/ai";
|
|
2263
|
-
import { Blueprint as Blueprint3 } from "@dxos/blueprints";
|
|
2264
|
-
import { Ref as Ref8 } from "@dxos/echo";
|
|
2265
|
-
import { Text as Text4 } from "@dxos/schema";
|
|
2266
|
-
import { trim as trim7 } from "@dxos/util";
|
|
2267
|
-
var instructions3 = trim7`
|
|
2268
|
-
You are able to sync Linear workspaces.
|
|
2269
|
-
Sometimes sync does not complete in one go and you need to call the function again.
|
|
2270
|
-
|
|
2271
|
-
Known workspaces:
|
|
2272
|
-
|
|
2273
|
-
DXOS teamId: 1127c63a-6f77-4725-9229-50f6cd47321c
|
|
2274
|
-
`;
|
|
2275
|
-
var blueprint3 = Blueprint3.make({
|
|
2276
|
-
key: "dxos.org/blueprint/linear",
|
|
2277
|
-
name: "Linear",
|
|
2278
|
-
description: "Syncs Linear workspaces.",
|
|
2279
|
-
instructions: {
|
|
2280
|
-
source: Ref8.make(Text4.make(instructions3))
|
|
2281
|
-
},
|
|
2282
|
-
tools: [
|
|
2283
|
-
Linear.sync
|
|
2284
|
-
].map((tool) => ToolId3.make(tool.key))
|
|
2285
|
-
});
|
|
2286
|
-
|
|
2287
|
-
// src/blueprints/linear/index.ts
|
|
2288
|
-
var linear_default = blueprint3;
|
|
2289
|
-
|
|
2290
|
-
// src/blueprints/planning/planning-blueprint.ts
|
|
2291
|
-
import { ToolId as ToolId4 } from "@dxos/ai";
|
|
2292
|
-
import { Blueprint as Blueprint4 } from "@dxos/blueprints";
|
|
2293
|
-
import { Ref as Ref9 } from "@dxos/echo";
|
|
2294
|
-
import { Text as Text5 } from "@dxos/schema";
|
|
2295
|
-
import { trim as trim8 } from "@dxos/util";
|
|
2296
|
-
var instructions4 = trim8`
|
|
2297
|
-
You are a task management agent that maintains hierarchical task lists where each line is a task.
|
|
2298
|
-
|
|
2299
|
-
## Document Format
|
|
2300
|
-
You will receive task lists with line numbers prefixed like:
|
|
2301
|
-
|
|
2302
|
-
${"```"}
|
|
2303
|
-
1. - [ ] First main task
|
|
2304
|
-
2. - [ ] Subtask 1: Research phase
|
|
2305
|
-
3. - [x] Literature review
|
|
2306
|
-
4. - [ ] Stakeholder interviews
|
|
2307
|
-
5. - [ ] Subtask 2: Implementation
|
|
2308
|
-
6. - [ ] Setup infrastructure
|
|
2309
|
-
7. - [ ] Write core functionality
|
|
2310
|
-
8. - [ ] Another main task
|
|
2311
|
-
${"```"}
|
|
2312
|
-
|
|
2313
|
-
## Task Hierarchy
|
|
2314
|
-
- 0 spaces: Top-level tasks
|
|
2315
|
-
- 2 spaces: First-level subtasks
|
|
2316
|
-
- 4 spaces: Second-level subtasks
|
|
2317
|
-
- 6 spaces: Third-level subtasks (and so on)
|
|
2318
|
-
|
|
2319
|
-
## Available Operations
|
|
2320
|
-
You can modify the task list using these operations:
|
|
2321
|
-
|
|
2322
|
-
1. **insertTask(lineNumber, text, completed?, indent?)** - Insert a new task
|
|
2323
|
-
2. **deleteTask(lineNumber)** - Delete a task
|
|
2324
|
-
3. **updateTaskText(lineNumber, text)** - Change task description
|
|
2325
|
-
4. **toggleTaskCompletion(lineNumber, completed?)** - Mark task complete/incomplete
|
|
2326
|
-
5. **setTaskIndent(lineNumber, indent)** - Change task hierarchy level
|
|
2327
|
-
|
|
2328
|
-
## Examples
|
|
2329
|
-
|
|
2330
|
-
### Example 1: Adding a subtask
|
|
2331
|
-
**User:** "Add a subtask 'Code review' under the task on line 1"
|
|
2332
|
-
**Response:** \`insertTask(2, "Code review", false, 2)\`
|
|
2333
|
-
|
|
2334
|
-
### Example 2: Marking a task complete
|
|
2335
|
-
**User:** "Mark the task on line 3 as complete"
|
|
2336
|
-
**Response:** \`toggleTaskCompletion(3, true)\`
|
|
2337
|
-
|
|
2338
|
-
### Example 3: Updating task text
|
|
2339
|
-
**User:** "Change the task on line 5 to 'Backend implementation'"
|
|
2340
|
-
**Response:** \`updateTaskText(5, "Backend implementation")\`
|
|
2341
|
-
|
|
2342
|
-
### Example 4: Creating a task hierarchy
|
|
2343
|
-
**User:** "Add a main task 'Testing phase' with two subtasks"
|
|
2344
|
-
**Response:**
|
|
2345
|
-
\`\`\`
|
|
2346
|
-
insertTask(999, "Testing phase", false, 0)
|
|
2347
|
-
insertTask(999, "Unit tests", false, 2)
|
|
2348
|
-
insertTask(999, "Integration tests", false, 2)
|
|
2349
|
-
\`\`\`
|
|
2350
|
-
|
|
2351
|
-
### Example 5: Reorganizing hierarchy
|
|
2352
|
-
**User:** "Move the task on line 4 to be a main task (top level)"
|
|
2353
|
-
**Response:** \`setTaskIndent(4, 0)\`
|
|
2354
|
-
|
|
2355
|
-
### Example 6: Adding nested subtasks
|
|
2356
|
-
**User:** "Add a sub-subtask 'Write test cases' under line 6"
|
|
2357
|
-
**Response:** \`insertTask(7, "Write test cases", false, 4)\`
|
|
2358
|
-
|
|
2359
|
-
## Guidelines
|
|
2360
|
-
- Always reference line numbers from the numbered document you receive
|
|
2361
|
-
- Use line number 999 to append to the end of the document
|
|
2362
|
-
- Maintain logical hierarchy (subtasks should be indented under their parent)
|
|
2363
|
-
- Use appropriate indentation levels (0, 2, 4, 6, etc. spaces)
|
|
2364
|
-
- When creating subtasks, consider the parent task's completion status
|
|
2365
|
-
- Be precise with task descriptions and hierarchy levels
|
|
2366
|
-
`;
|
|
2367
|
-
var blueprint4 = Blueprint4.make({
|
|
2368
|
-
key: "dxos.org/blueprint/planning",
|
|
2369
|
-
name: "Planning",
|
|
2370
|
-
description: "Plans and tracks complex tasks with artifact management.",
|
|
2371
|
-
instructions: {
|
|
2372
|
-
source: Ref9.make(Text5.make(instructions4))
|
|
2373
|
-
},
|
|
2374
|
-
tools: [
|
|
2375
|
-
Tasks.read,
|
|
2376
|
-
Tasks.update
|
|
2377
|
-
].map((fn9) => ToolId4.make(fn9.key))
|
|
2378
|
-
});
|
|
2379
|
-
|
|
2380
|
-
// src/blueprints/planning/index.ts
|
|
2381
|
-
var planning_default = blueprint4;
|
|
2382
|
-
|
|
2383
|
-
// src/blueprints/research/research-blueprint.ts
|
|
2384
|
-
import { ToolId as ToolId5 } from "@dxos/ai";
|
|
2385
|
-
import { Blueprint as Blueprint5 } from "@dxos/blueprints";
|
|
2386
|
-
import { Ref as Ref10 } from "@dxos/echo";
|
|
2387
|
-
import { Text as Text6 } from "@dxos/schema";
|
|
2388
|
-
import { trim as trim9 } from "@dxos/util";
|
|
2389
|
-
var instructions5 = trim9`
|
|
2390
|
-
{{! Research }}
|
|
2391
|
-
|
|
2392
|
-
You are an analyst that does research tasks using tools that scrape the web and create structured data.
|
|
2393
|
-
Structured data extraction is an experimental feature -- only enable it if the user explicitly requests it in the prompt.
|
|
2394
|
-
Prefer updating existing notes instead of creating new ones.
|
|
2395
|
-
|
|
2396
|
-
<strcutured_mode>
|
|
2397
|
-
When you are done, reply with the created objects.
|
|
2398
|
-
Do not print the data, instead reply with inline references to the created objects.
|
|
2399
|
-
Those will be later substituted with the pills representing the created objects.
|
|
2400
|
-
Print the rest of the created objects as block references after the main note.
|
|
2401
|
-
|
|
2402
|
-
<example>
|
|
2403
|
-
Based on my research, Google was founded by @dxn:queue:data:B6INSIBY3CBEF4M5VZRYBCMAHQMPYK5AJ:01K24XMVHSZHS97SG1VTVQDM5Z:01K24XPK464FSCKVQJAB2H662M and @dxn:queue:data:B6INSIBY3CBEF4M5VZRYBCMAHQMPYK5AJ:01K24XMVHSZHS97SG1VTVQDM5Z:01K24XPK46K31DDW62PBW9H2ZQ
|
|
2404
|
-
|
|
2405
|
-
<object><dxn>dxn:queue:data:B6INSIBY3CBEF4M5VZRYBCMAHQMPYK5AJ:01K24XMVHSZHS97SG1VTVQDM5Z:01K24XPK464FSCKVQJAB2H662M</dxn></object>
|
|
2406
|
-
<object><dxn>dxn:queue:data:B6INSIBY3CBEF4M5VZRYBCMAHQMPYK5AJ:01K24XMVHSZHS97SG1VTVQDM5Z:01K24XPK46K31DDW62PBW9H2ZQ</dxn></object>
|
|
2407
|
-
<object><dxn>dxn:queue:data:B6INSIBY3CBEF4M5VZRYBCMAHQMPYK5AJ:01K24XMVHSZHS97SG1VTVQDM5Z:01K24XPK46K31DDW62PBW92333</dxn></object>
|
|
2408
|
-
</example>
|
|
2409
|
-
</structured_mode>
|
|
2410
|
-
|
|
2411
|
-
<unstructured_mode>
|
|
2412
|
-
Reply normally with the text mode of the result of your research.
|
|
2413
|
-
</unstructured_mode>
|
|
2414
|
-
`;
|
|
2415
|
-
var blueprint5 = Blueprint5.make({
|
|
2416
|
-
key: "dxos.org/blueprint/research",
|
|
2417
|
-
name: "Research",
|
|
2418
|
-
description: "Researches the web and creates structured data.",
|
|
2419
|
-
instructions: {
|
|
2420
|
-
source: Ref10.make(Text6.make(instructions5))
|
|
2421
|
-
},
|
|
2422
|
-
tools: [
|
|
2423
|
-
Research.create,
|
|
2424
|
-
Research.research
|
|
2425
|
-
].map((fn9) => ToolId5.make(fn9.key))
|
|
2426
|
-
});
|
|
2427
|
-
|
|
2428
|
-
// src/blueprints/research/index.ts
|
|
2429
|
-
var research_default2 = blueprint5;
|
|
2430
|
-
|
|
2431
|
-
// src/blueprints/websearch/websearch-blueprint.ts
|
|
2432
|
-
import { ToolId as ToolId6 } from "@dxos/ai";
|
|
2433
|
-
import { Blueprint as Blueprint6 } from "@dxos/blueprints";
|
|
2434
|
-
import { Ref as Ref11 } from "@dxos/echo";
|
|
2435
|
-
import { Text as Text7 } from "@dxos/schema";
|
|
2436
|
-
var blueprint6 = Blueprint6.make({
|
|
2437
|
-
key: "dxos.org/blueprint/web-search",
|
|
2438
|
-
name: "Web Search",
|
|
2439
|
-
description: "Search the web.",
|
|
2440
|
-
instructions: {
|
|
2441
|
-
source: Ref11.make(Text7.make())
|
|
2442
|
-
},
|
|
2443
|
-
tools: [
|
|
2444
|
-
ToolId6.make("AnthropicWebSearch")
|
|
2445
|
-
]
|
|
2446
|
-
});
|
|
2447
|
-
|
|
2448
|
-
// src/blueprints/websearch/websearch-toolkit.ts
|
|
2449
|
-
import * as Toolkit4 from "@effect/ai/Toolkit";
|
|
2450
|
-
import * as AnthropicTool2 from "@effect/ai-anthropic/AnthropicTool";
|
|
2451
|
-
var WebSearchToolkit = Toolkit4.make(AnthropicTool2.WebSearch_20250305({}));
|
|
2452
|
-
|
|
2453
|
-
// src/blueprints/websearch/index.ts
|
|
2454
|
-
var websearch_default = blueprint6;
|
|
2455
|
-
|
|
2456
|
-
// src/toolkits/AssistantToolkit.ts
|
|
2457
|
-
var AssistantToolkit_exports = {};
|
|
2458
|
-
__export(AssistantToolkit_exports, {
|
|
2459
|
-
AssistantToolkit: () => AssistantToolkit,
|
|
2460
|
-
layer: () => layer3,
|
|
2461
|
-
tools: () => tools
|
|
2462
|
-
});
|
|
2463
|
-
import * as Tool2 from "@effect/ai/Tool";
|
|
2464
|
-
import * as Toolkit5 from "@effect/ai/Toolkit";
|
|
2465
|
-
import * as Effect16 from "effect/Effect";
|
|
2466
|
-
import * as Record from "effect/Record";
|
|
2467
|
-
import * as Schema15 from "effect/Schema";
|
|
2468
|
-
import { AiContextService, ArtifactId as ArtifactId6 } from "@dxos/assistant";
|
|
2469
|
-
import { Database as Database13 } from "@dxos/echo";
|
|
2470
|
-
import { trim as trim10 } from "@dxos/util";
|
|
2471
|
-
var AssistantToolkit = Toolkit5.make(Tool2.make("context-add", {
|
|
2472
|
-
description: trim10`
|
|
2473
|
-
Adds the object to the chat context.
|
|
2474
|
-
`,
|
|
2475
|
-
parameters: {
|
|
2476
|
-
id: ArtifactId6.annotations({
|
|
2477
|
-
description: "The ID of the document to add."
|
|
2478
|
-
})
|
|
2479
|
-
},
|
|
2480
|
-
success: Schema15.Void,
|
|
2481
|
-
failure: Schema15.Never,
|
|
2482
|
-
dependencies: [
|
|
2483
|
-
AiContextService,
|
|
2484
|
-
Database13.Service
|
|
2485
|
-
]
|
|
2486
|
-
}), Tool2.make("context-remove", {
|
|
2487
|
-
description: trim10`
|
|
2488
|
-
Removes the object from the chat context.
|
|
2489
|
-
`,
|
|
2490
|
-
parameters: {
|
|
2491
|
-
id: ArtifactId6.annotations({
|
|
2492
|
-
description: "The ID of the document to remove."
|
|
2493
|
-
})
|
|
2494
|
-
},
|
|
2495
|
-
success: Schema15.Void,
|
|
2496
|
-
failure: Schema15.Never,
|
|
2497
|
-
dependencies: [
|
|
2498
|
-
AiContextService,
|
|
2499
|
-
Database13.Service
|
|
2500
|
-
]
|
|
2501
|
-
}));
|
|
2502
|
-
var tools = Record.keys(AssistantToolkit.tools);
|
|
2503
|
-
var layer3 = () => AssistantToolkit.toLayer({
|
|
2504
|
-
["context-add"]: Effect16.fnUntraced(function* ({ id }) {
|
|
2505
|
-
const { binder } = yield* AiContextService;
|
|
2506
|
-
const { db } = yield* Database13.Service;
|
|
2507
|
-
const ref = db.makeRef(ArtifactId6.toDXN(id, db.spaceId));
|
|
2508
|
-
yield* Effect16.promise(() => binder.bind({
|
|
2509
|
-
blueprints: [],
|
|
2510
|
-
objects: [
|
|
2511
|
-
ref
|
|
2512
|
-
]
|
|
2513
|
-
}));
|
|
2514
|
-
}),
|
|
2515
|
-
["context-remove"]: Effect16.fnUntraced(function* ({ id }) {
|
|
2516
|
-
const { binder } = yield* AiContextService;
|
|
2517
|
-
const { db } = yield* Database13.Service;
|
|
2518
|
-
const ref = db.makeRef(ArtifactId6.toDXN(id, db.spaceId));
|
|
2519
|
-
yield* Effect16.promise(() => binder.unbind({
|
|
2520
|
-
blueprints: [],
|
|
2521
|
-
objects: [
|
|
2522
|
-
ref
|
|
2523
|
-
]
|
|
2524
|
-
}));
|
|
2525
|
-
})
|
|
2526
|
-
});
|
|
2527
|
-
|
|
2528
|
-
// src/toolkits/SystemToolkit.ts
|
|
2529
|
-
var SystemToolkit_exports = {};
|
|
2530
|
-
__export(SystemToolkit_exports, {
|
|
2531
|
-
SystemToolkit: () => SystemToolkit,
|
|
2532
|
-
layer: () => layer4,
|
|
2533
|
-
tools: () => tools2
|
|
2534
|
-
});
|
|
2535
|
-
import * as Tool3 from "@effect/ai/Tool";
|
|
2536
|
-
import * as Toolkit6 from "@effect/ai/Toolkit";
|
|
2537
|
-
import * as Effect17 from "effect/Effect";
|
|
2538
|
-
import * as Record2 from "effect/Record";
|
|
2539
|
-
import * as Schema16 from "effect/Schema";
|
|
2540
|
-
import { ArtifactId as ArtifactId7 } from "@dxos/assistant";
|
|
2541
|
-
import { DXN as DXN2, Database as Database14, Entity as Entity3, Filter as Filter5, Obj as Obj11, Relation as Relation2, Tag as Tag2, Type as Type5 } from "@dxos/echo";
|
|
2542
|
-
import { invariant } from "@dxos/invariant";
|
|
2543
|
-
import { trim as trim11 } from "@dxos/util";
|
|
2544
|
-
var __dxlog_file8 = "/__w/dxos/dxos/packages/core/assistant-toolkit/src/toolkits/SystemToolkit.ts";
|
|
2545
|
-
var SystemToolkit = Toolkit6.make(
|
|
2546
|
-
//
|
|
2547
|
-
// Schema
|
|
2548
|
-
//
|
|
2549
|
-
Tool3.make("schema-list", {
|
|
2550
|
-
description: trim11`
|
|
2551
|
-
Lists schemas definitions.
|
|
2552
|
-
`,
|
|
2553
|
-
parameters: {
|
|
2554
|
-
// TODO(wittjosiah): Remove this once parameter-less tools are fixed.
|
|
2555
|
-
limit: Schema16.Number
|
|
2556
|
-
},
|
|
2557
|
-
// TODO(dmaretskyi): Effect returns ({ result, encodedResult })
|
|
2558
|
-
success: Schema16.Any,
|
|
2559
|
-
failure: Schema16.Never,
|
|
2560
|
-
dependencies: [
|
|
2561
|
-
Database14.Service
|
|
2562
|
-
]
|
|
2563
|
-
}),
|
|
2564
|
-
Tool3.make("schema-add", {
|
|
2565
|
-
description: trim11`
|
|
2566
|
-
Adds a schema to the space.
|
|
2567
|
-
The name will be used when displayed to the user.
|
|
2568
|
-
The typename must be in the format of "example.com/type/Type".
|
|
2569
|
-
`,
|
|
2570
|
-
parameters: {
|
|
2571
|
-
name: Schema16.String,
|
|
2572
|
-
typename: Schema16.String,
|
|
2573
|
-
jsonSchema: Schema16.Any
|
|
2574
|
-
},
|
|
2575
|
-
success: Schema16.Any,
|
|
2576
|
-
failure: Schema16.Never,
|
|
2577
|
-
dependencies: [
|
|
2578
|
-
Database14.Service
|
|
2579
|
-
]
|
|
2580
|
-
}),
|
|
2581
|
-
//
|
|
2582
|
-
// Query
|
|
2583
|
-
//
|
|
2584
|
-
Tool3.make("query", {
|
|
2585
|
-
description: trim11`
|
|
2586
|
-
Queries objects in the space.
|
|
2587
|
-
Get the typename from the schema-list tool.
|
|
2588
|
-
`,
|
|
2589
|
-
parameters: {
|
|
2590
|
-
typename: Schema16.String
|
|
2591
|
-
},
|
|
2592
|
-
success: Schema16.Any,
|
|
2593
|
-
failure: Schema16.Never,
|
|
2594
|
-
dependencies: [
|
|
2595
|
-
Database14.Service
|
|
2596
|
-
]
|
|
2597
|
-
}),
|
|
2598
|
-
//
|
|
2599
|
-
// Objects
|
|
2600
|
-
//
|
|
2601
|
-
Tool3.make("object-create", {
|
|
2602
|
-
description: trim11`
|
|
2603
|
-
Creates a new object and adds it to the current space.
|
|
2604
|
-
Get the schema from the schema-list tool and ensure that the data matches the corresponding schema.
|
|
2605
|
-
`,
|
|
2606
|
-
parameters: {
|
|
2607
|
-
typename: Schema16.String,
|
|
2608
|
-
data: Schema16.Any
|
|
2609
|
-
},
|
|
2610
|
-
success: Schema16.Any,
|
|
2611
|
-
failure: Schema16.Never,
|
|
2612
|
-
dependencies: [
|
|
2613
|
-
Database14.Service
|
|
2614
|
-
]
|
|
2615
|
-
}),
|
|
2616
|
-
Tool3.make("object-delete", {
|
|
2617
|
-
description: trim11`
|
|
2618
|
-
Deletes the object.
|
|
2619
|
-
`,
|
|
2620
|
-
parameters: {
|
|
2621
|
-
id: ArtifactId7.annotations({
|
|
2622
|
-
description: "The ID of the object."
|
|
2623
|
-
})
|
|
2624
|
-
},
|
|
2625
|
-
success: Schema16.Any,
|
|
2626
|
-
failure: Schema16.Never,
|
|
2627
|
-
dependencies: [
|
|
2628
|
-
Database14.Service
|
|
2629
|
-
]
|
|
2630
|
-
}),
|
|
2631
|
-
Tool3.make("object-update", {
|
|
2632
|
-
description: trim11`
|
|
2633
|
-
Updates the object properties.
|
|
2634
|
-
`,
|
|
2635
|
-
parameters: {
|
|
2636
|
-
id: ArtifactId7.annotations({
|
|
2637
|
-
description: "The ID of the object."
|
|
2638
|
-
}),
|
|
2639
|
-
properties: Schema16.Record({
|
|
2640
|
-
key: Schema16.String,
|
|
2641
|
-
value: Schema16.Any
|
|
2642
|
-
})
|
|
2643
|
-
},
|
|
2644
|
-
success: Schema16.Any,
|
|
2645
|
-
failure: Schema16.Never,
|
|
2646
|
-
dependencies: [
|
|
2647
|
-
Database14.Service
|
|
2648
|
-
]
|
|
2649
|
-
}),
|
|
2650
|
-
//
|
|
2651
|
-
// Relations
|
|
2652
|
-
//
|
|
2653
|
-
Tool3.make("relation-create", {
|
|
2654
|
-
description: trim11`
|
|
2655
|
-
Creates a new relation and adds it to the current space.
|
|
2656
|
-
Get the schema from the schema-list tool and ensure that the data matches the corresponding schema.
|
|
2657
|
-
`,
|
|
2658
|
-
parameters: {
|
|
2659
|
-
typename: Schema16.String,
|
|
2660
|
-
source: ArtifactId7.annotations({
|
|
2661
|
-
description: "The ID of the source object."
|
|
2662
|
-
}),
|
|
2663
|
-
target: ArtifactId7.annotations({
|
|
2664
|
-
description: "The ID of the target object."
|
|
2665
|
-
}),
|
|
2666
|
-
data: Schema16.Any.annotations({
|
|
2667
|
-
description: "The data to be stored in the relation."
|
|
2668
|
-
})
|
|
2669
|
-
},
|
|
2670
|
-
success: Schema16.Any,
|
|
2671
|
-
failure: Schema16.Never,
|
|
2672
|
-
dependencies: [
|
|
2673
|
-
Database14.Service
|
|
2674
|
-
]
|
|
2675
|
-
}),
|
|
2676
|
-
Tool3.make("relation-delete", {
|
|
2677
|
-
description: trim11`
|
|
2678
|
-
Deletes the relation.
|
|
2679
|
-
`,
|
|
2680
|
-
parameters: {
|
|
2681
|
-
id: ArtifactId7.annotations({
|
|
2682
|
-
description: "The ID of the relation."
|
|
2683
|
-
})
|
|
2684
|
-
},
|
|
2685
|
-
success: Schema16.Any,
|
|
2686
|
-
failure: Schema16.Never,
|
|
2687
|
-
dependencies: [
|
|
2688
|
-
Database14.Service
|
|
2689
|
-
]
|
|
2690
|
-
}),
|
|
2691
|
-
//
|
|
2692
|
-
// Tags
|
|
2693
|
-
//
|
|
2694
|
-
Tool3.make("tag-add", {
|
|
2695
|
-
description: trim11`
|
|
2696
|
-
Adds a tag to an object.
|
|
2697
|
-
Tags are objects of type ${Tag2.Tag.typename}.
|
|
2698
|
-
`,
|
|
2699
|
-
parameters: {
|
|
2700
|
-
tagId: ArtifactId7.annotations({
|
|
2701
|
-
description: "The ID of the tag."
|
|
2702
|
-
}),
|
|
2703
|
-
objectId: ArtifactId7.annotations({
|
|
2704
|
-
description: "The ID of the object."
|
|
2705
|
-
})
|
|
2706
|
-
},
|
|
2707
|
-
success: Schema16.Any,
|
|
2708
|
-
failure: Schema16.Never,
|
|
2709
|
-
dependencies: [
|
|
2710
|
-
Database14.Service
|
|
2711
|
-
]
|
|
2712
|
-
}),
|
|
2713
|
-
Tool3.make("tag-remove", {
|
|
2714
|
-
description: trim11`
|
|
2715
|
-
Removes a tag from an object.
|
|
2716
|
-
Tags are objects of type ${Tag2.Tag.typename}.
|
|
2717
|
-
`,
|
|
2718
|
-
parameters: {
|
|
2719
|
-
tagId: ArtifactId7.annotations({
|
|
2720
|
-
description: "The ID of the tag."
|
|
2721
|
-
}),
|
|
2722
|
-
objectId: ArtifactId7.annotations({
|
|
2723
|
-
description: "The ID of the object."
|
|
2724
|
-
})
|
|
2725
|
-
},
|
|
2726
|
-
success: Schema16.Any,
|
|
2727
|
-
failure: Schema16.Never,
|
|
2728
|
-
dependencies: [
|
|
2729
|
-
Database14.Service
|
|
2730
|
-
]
|
|
2731
|
-
})
|
|
2732
|
-
);
|
|
2733
|
-
var tools2 = Record2.keys(SystemToolkit.tools);
|
|
2734
|
-
var layer4 = () => SystemToolkit.toLayer({
|
|
2735
|
-
["schema-list"]: Effect17.fnUntraced(function* () {
|
|
2736
|
-
const { db } = yield* Database14.Service;
|
|
2737
|
-
const schema = yield* Effect17.promise(() => db.schemaRegistry.query({
|
|
2738
|
-
location: [
|
|
2739
|
-
"database",
|
|
2740
|
-
"runtime"
|
|
2741
|
-
]
|
|
2742
|
-
}).run());
|
|
2743
|
-
return schema.map((schema2) => {
|
|
2744
|
-
const meta = Type5.getMeta(schema2);
|
|
2745
|
-
return {
|
|
2746
|
-
typename: Type5.getTypename(schema2),
|
|
2747
|
-
jsonSchema: Type5.toJsonSchema(schema2),
|
|
2748
|
-
kind: meta?.sourceSchema ? "relation" : "record"
|
|
2749
|
-
};
|
|
2750
|
-
});
|
|
2751
|
-
}),
|
|
2752
|
-
["schema-add"]: Effect17.fnUntraced(function* ({ name, typename, jsonSchema }) {
|
|
2753
|
-
const { db } = yield* Database14.Service;
|
|
2754
|
-
yield* Effect17.promise(() => db.schemaRegistry.register([
|
|
2755
|
-
{
|
|
2756
|
-
typename,
|
|
2757
|
-
version: "0.1.0",
|
|
2758
|
-
jsonSchema,
|
|
2759
|
-
name
|
|
2760
|
-
}
|
|
2761
|
-
]));
|
|
2762
|
-
}),
|
|
2763
|
-
["query"]: Effect17.fnUntraced(function* ({ typename }) {
|
|
2764
|
-
const objects = yield* Database14.Service.runQuery(Filter5.typename(typename));
|
|
2765
|
-
return objects;
|
|
2766
|
-
}),
|
|
2767
|
-
["object-create"]: Effect17.fnUntraced(function* ({ typename, data }) {
|
|
2768
|
-
const { db } = yield* Database14.Service;
|
|
2769
|
-
const schema = yield* Effect17.promise(() => db.schemaRegistry.query({
|
|
2770
|
-
typename,
|
|
2771
|
-
location: [
|
|
2772
|
-
"database",
|
|
2773
|
-
"runtime"
|
|
2774
|
-
]
|
|
2775
|
-
}).first());
|
|
2776
|
-
invariant(Type5.isObjectSchema(schema), "Schema is not an object schema", {
|
|
2777
|
-
F: __dxlog_file8,
|
|
2778
|
-
L: 238,
|
|
2779
|
-
S: this,
|
|
2780
|
-
A: [
|
|
2781
|
-
"Type.isObjectSchema(schema)",
|
|
2782
|
-
"'Schema is not an object schema'"
|
|
2783
|
-
]
|
|
2784
|
-
});
|
|
2785
|
-
const object = db.add(Obj11.make(schema, data));
|
|
2786
|
-
return object;
|
|
2787
|
-
}),
|
|
2788
|
-
["object-delete"]: Effect17.fnUntraced(function* ({ id }) {
|
|
2789
|
-
const { db } = yield* Database14.Service;
|
|
2790
|
-
const object = yield* Database14.Service.resolve(DXN2.parse(id));
|
|
2791
|
-
db.remove(object);
|
|
2792
|
-
return object;
|
|
2793
|
-
}),
|
|
2794
|
-
["object-update"]: Effect17.fnUntraced(function* ({ id, properties }) {
|
|
2795
|
-
const object = yield* Database14.Service.resolve(DXN2.parse(id));
|
|
2796
|
-
Entity3.change(object, (obj) => {
|
|
2797
|
-
for (const [key, value2] of Object.entries(properties)) {
|
|
2798
|
-
obj[key] = value2;
|
|
2799
|
-
}
|
|
2800
|
-
});
|
|
2801
|
-
return object;
|
|
2802
|
-
}),
|
|
2803
|
-
["relation-create"]: Effect17.fnUntraced(function* ({ typename, source, target, data }) {
|
|
2804
|
-
const { db } = yield* Database14.Service;
|
|
2805
|
-
const schema = yield* Effect17.promise(() => db.schemaRegistry.query({
|
|
2806
|
-
typename,
|
|
2807
|
-
location: [
|
|
2808
|
-
"database",
|
|
2809
|
-
"runtime"
|
|
2810
|
-
]
|
|
2811
|
-
}).first());
|
|
2812
|
-
invariant(Type5.isRelationSchema(schema), "Schema is not a relation schema", {
|
|
2813
|
-
F: __dxlog_file8,
|
|
2814
|
-
L: 267,
|
|
2815
|
-
S: this,
|
|
2816
|
-
A: [
|
|
2817
|
-
"Type.isRelationSchema(schema)",
|
|
2818
|
-
"'Schema is not a relation schema'"
|
|
2819
|
-
]
|
|
2820
|
-
});
|
|
2821
|
-
const sourceObj = yield* Database14.Service.resolve(DXN2.parse(source));
|
|
2822
|
-
const targetObj = yield* Database14.Service.resolve(DXN2.parse(target));
|
|
2823
|
-
const relation = db.add(Relation2.make(schema, {
|
|
2824
|
-
[Relation2.Source]: sourceObj,
|
|
2825
|
-
[Relation2.Target]: targetObj,
|
|
2826
|
-
...data
|
|
2827
|
-
}));
|
|
2828
|
-
return relation;
|
|
2829
|
-
}),
|
|
2830
|
-
["relation-delete"]: Effect17.fnUntraced(function* ({ id }) {
|
|
2831
|
-
const { db } = yield* Database14.Service;
|
|
2832
|
-
const relation = yield* Database14.Service.resolve(DXN2.parse(id));
|
|
2833
|
-
db.remove(relation);
|
|
2834
|
-
return relation;
|
|
2835
|
-
}),
|
|
2836
|
-
["tag-add"]: Effect17.fnUntraced(function* ({ tagId, objectId }) {
|
|
2837
|
-
const object = yield* Database14.Service.resolve(DXN2.parse(objectId));
|
|
2838
|
-
Entity3.change(object, (obj) => Entity3.addTag(obj, DXN2.parse(tagId).toString()));
|
|
2839
|
-
return object;
|
|
2840
|
-
}),
|
|
2841
|
-
["tag-remove"]: Effect17.fnUntraced(function* ({ tagId, objectId }) {
|
|
2842
|
-
const object = yield* Database14.Service.resolve(DXN2.parse(objectId));
|
|
2843
|
-
Entity3.change(object, (obj) => Entity3.removeTag(obj, DXN2.parse(tagId).toString()));
|
|
2844
|
-
return object;
|
|
2845
|
-
})
|
|
2846
|
-
});
|
|
2847
553
|
export {
|
|
2848
|
-
|
|
2849
|
-
AssistantToolkit_exports as AssistantToolkit,
|
|
2850
|
-
design_default as DesignBlueprint,
|
|
2851
|
-
Discord,
|
|
2852
|
-
discord_default as DiscordBlueprint,
|
|
2853
|
-
Document,
|
|
2854
|
-
EntityExtraction,
|
|
2855
|
-
Linear,
|
|
2856
|
-
linear_default as LinearBlueprint,
|
|
2857
|
-
LocalSearchHandler,
|
|
2858
|
-
LocalSearchToolkit,
|
|
2859
|
-
planning_default as PlanningBlueprint,
|
|
2860
|
-
Research,
|
|
2861
|
-
research_default2 as ResearchBlueprint,
|
|
2862
|
-
ResearchDataTypes,
|
|
2863
|
-
ResearchGraph,
|
|
2864
|
-
Subgraph,
|
|
2865
|
-
SystemToolkit_exports as SystemToolkit,
|
|
2866
|
-
Tasks,
|
|
2867
|
-
websearch_default as WebSearchBlueprint,
|
|
2868
|
-
WebSearchToolkit,
|
|
2869
|
-
contextQueueLayerFromResearchGraph,
|
|
2870
|
-
createExtractionSchema,
|
|
2871
|
-
createResearchGraph,
|
|
2872
|
-
findRelatedSchema,
|
|
2873
|
-
getSanitizedSchemaName,
|
|
2874
|
-
makeGraphWriterHandler,
|
|
2875
|
-
makeGraphWriterToolkit,
|
|
2876
|
-
queryResearchGraph,
|
|
2877
|
-
sanitizeObjects,
|
|
2878
|
-
syncObjects
|
|
554
|
+
mock_default as default
|
|
2879
555
|
};
|
|
2880
|
-
//# sourceMappingURL=
|
|
556
|
+
//# sourceMappingURL=mock-JSY4GY77.mjs.map
|