@dxos/plugin-automation 0.7.4-staging.f7e8224 → 0.7.5-main.937ce75

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/lib/browser/{AssistantPanel-N3QSALKY.mjs → AssistantPanel-32FH2RA6.mjs} +2 -4
  2. package/dist/lib/browser/{AssistantPanel-N3QSALKY.mjs.map → AssistantPanel-32FH2RA6.mjs.map} +2 -2
  3. package/dist/lib/browser/{AutomationPanel-AQMN2CQR.mjs → AutomationPanel-6FUIFUQJ.mjs} +49 -26
  4. package/dist/lib/browser/AutomationPanel-6FUIFUQJ.mjs.map +7 -0
  5. package/dist/lib/browser/{chunk-7KB4UMXO.mjs → chunk-DN5M2QL5.mjs} +3 -3
  6. package/dist/lib/browser/{chunk-7KB4UMXO.mjs.map → chunk-DN5M2QL5.mjs.map} +2 -2
  7. package/dist/lib/browser/index.mjs +29 -40
  8. package/dist/lib/browser/index.mjs.map +3 -3
  9. package/dist/lib/browser/meta.json +1 -1
  10. package/dist/lib/browser/types/index.mjs +1 -1
  11. package/dist/lib/node/{AssistantPanel-RIA4TI3B.cjs → AssistantPanel-XANI7YNV.cjs} +5 -7
  12. package/dist/lib/node/{AssistantPanel-RIA4TI3B.cjs.map → AssistantPanel-XANI7YNV.cjs.map} +2 -2
  13. package/dist/lib/node/{AutomationPanel-HZS5WKI5.cjs → AutomationPanel-2UGSAIXU.cjs} +54 -31
  14. package/dist/lib/node/AutomationPanel-2UGSAIXU.cjs.map +7 -0
  15. package/dist/lib/node/{chunk-CUCUWUAF.cjs → chunk-NIL4TP6U.cjs} +5 -5
  16. package/dist/lib/node/{chunk-CUCUWUAF.cjs.map → chunk-NIL4TP6U.cjs.map} +2 -2
  17. package/dist/lib/node/index.cjs +57 -68
  18. package/dist/lib/node/index.cjs.map +3 -3
  19. package/dist/lib/node/meta.json +1 -1
  20. package/dist/lib/node/types/index.cjs +6 -6
  21. package/dist/lib/node/types/index.cjs.map +1 -1
  22. package/dist/lib/node-esm/{AssistantPanel-72YH43CH.mjs → AssistantPanel-5M6O6JV7.mjs} +2 -4
  23. package/dist/lib/node-esm/{AssistantPanel-72YH43CH.mjs.map → AssistantPanel-5M6O6JV7.mjs.map} +2 -2
  24. package/dist/lib/node-esm/{AutomationPanel-JUHOWQWW.mjs → AutomationPanel-72C2JRLV.mjs} +49 -26
  25. package/dist/lib/node-esm/AutomationPanel-72C2JRLV.mjs.map +7 -0
  26. package/dist/lib/node-esm/{chunk-23LY7DYS.mjs → chunk-GCHXTXVT.mjs} +3 -3
  27. package/dist/lib/node-esm/{chunk-23LY7DYS.mjs.map → chunk-GCHXTXVT.mjs.map} +2 -2
  28. package/dist/lib/node-esm/index.mjs +29 -40
  29. package/dist/lib/node-esm/index.mjs.map +3 -3
  30. package/dist/lib/node-esm/meta.json +1 -1
  31. package/dist/lib/node-esm/types/index.mjs +1 -1
  32. package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
  33. package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +1 -1
  34. package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
  35. package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts.map +1 -1
  36. package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
  37. package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +1 -1
  38. package/dist/types/src/components/index.d.ts +1 -1
  39. package/dist/types/src/components/index.d.ts.map +1 -1
  40. package/dist/types/src/hooks/email.d.ts.map +1 -1
  41. package/dist/types/src/hooks/invocation-handler.d.ts.map +1 -1
  42. package/dist/types/src/translations.d.ts +1 -0
  43. package/dist/types/src/translations.d.ts.map +1 -1
  44. package/dist/types/src/types/schema.d.ts +31 -39
  45. package/dist/types/src/types/schema.d.ts.map +1 -1
  46. package/dist/types/tsconfig.tsbuildinfo +1 -0
  47. package/package.json +38 -38
  48. package/src/AutomationPlugin.tsx +20 -22
  49. package/src/components/AssistantPanel/AssistantPanel.tsx +1 -1
  50. package/src/components/AutomationPanel/AutomationPanel.stories.tsx +1 -2
  51. package/src/components/AutomationPanel/AutomationPanel.tsx +61 -29
  52. package/src/components/PromptEditor/PromptEditor.stories.tsx +3 -3
  53. package/src/components/TriggerEditor/TriggerEditor.stories.tsx +1 -2
  54. package/src/components/TriggerEditor/TriggerEditor.tsx +9 -3
  55. package/src/hooks/email.ts +2 -2
  56. package/src/hooks/invocation-handler.ts +2 -2
  57. package/src/translations.ts +1 -0
  58. package/src/types/schema.ts +2 -2
  59. package/dist/lib/browser/AutomationPanel-AQMN2CQR.mjs.map +0 -7
  60. package/dist/lib/node/AutomationPanel-HZS5WKI5.cjs.map +0 -7
  61. package/dist/lib/node-esm/AutomationPanel-JUHOWQWW.mjs.map +0 -7
@@ -1 +1 @@
1
- {"inputs":{"packages/plugins/experimental/plugin-automation/src/components/AssistantPanel/system-instructions.ts":{"bytes":16049,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/react-client/echo","kind":"import-statement","external":true}],"format":"esm"},"packages/plugins/experimental/plugin-automation/src/meta.ts":{"bytes":1626,"imports":[],"format":"esm"},"packages/plugins/experimental/plugin-automation/src/components/AssistantPanel/AssistantPanel.tsx":{"bytes":28076,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/assistant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/react-client","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-syntax-highlighter","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"packages/plugins/experimental/plugin-automation/src/components/AssistantPanel/system-instructions.ts","kind":"import-statement","original":"./system-instructions"},{"path":"packages/plugins/experimental/plugin-automation/src/meta.ts","kind":"import-statement","original":"../../meta"}],"format":"esm"},"packages/plugins/experimental/plugin-automation/src/components/AssistantPanel/index.ts":{"bytes":739,"imports":[{"path":"packages/plugins/experimental/plugin-automation/src/components/AssistantPanel/AssistantPanel.tsx","kind":"import-statement","original":"./AssistantPanel"}],"format":"esm"},"packages/plugins/experimental/plugin-automation/src/components/TriggerEditor/TriggerEditor.tsx":{"bytes":7188,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/plugin-script/types","kind":"import-statement","external":true},{"path":"@dxos/react-client/echo","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-form","kind":"import-statement","external":true},{"path":"packages/plugins/experimental/plugin-automation/src/meta.ts","kind":"import-statement","original":"../../meta"}],"format":"esm"},"packages/plugins/experimental/plugin-automation/src/components/TriggerEditor/index.ts":{"bytes":557,"imports":[{"path":"packages/plugins/experimental/plugin-automation/src/components/TriggerEditor/TriggerEditor.tsx","kind":"import-statement","original":"./TriggerEditor"}],"format":"esm"},"packages/plugins/experimental/plugin-automation/src/components/AutomationPanel/AutomationPanel.tsx":{"bytes":16837,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/plugin-script","kind":"import-statement","external":true},{"path":"@dxos/react-client","kind":"import-statement","external":true},{"path":"@dxos/react-client/echo","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-list","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"packages/plugins/experimental/plugin-automation/src/meta.ts","kind":"import-statement","original":"../../meta"},{"path":"packages/plugins/experimental/plugin-automation/src/components/TriggerEditor/index.ts","kind":"import-statement","original":"../TriggerEditor"}],"format":"esm"},"packages/plugins/experimental/plugin-automation/src/components/AutomationPanel/index.ts":{"bytes":751,"imports":[{"path":"packages/plugins/experimental/plugin-automation/src/components/AutomationPanel/AutomationPanel.tsx","kind":"import-statement","original":"./AutomationPanel"}],"format":"esm"},"packages/plugins/experimental/plugin-automation/src/components/index.ts":{"bytes":1078,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"packages/plugins/experimental/plugin-automation/src/components/AssistantPanel/index.ts","kind":"dynamic-import","original":"./AssistantPanel"},{"path":"packages/plugins/experimental/plugin-automation/src/components/AutomationPanel/index.ts","kind":"dynamic-import","original":"./AutomationPanel"}],"format":"esm"},"packages/plugins/experimental/plugin-automation/src/translations.ts":{"bytes":4459,"imports":[{"path":"packages/plugins/experimental/plugin-automation/src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"},"packages/plugins/experimental/plugin-automation/src/types/schema.ts":{"bytes":4248,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"format":"esm"},"packages/plugins/experimental/plugin-automation/src/types/types.ts":{"bytes":1464,"imports":[],"format":"esm"},"packages/plugins/experimental/plugin-automation/src/types/index.ts":{"bytes":604,"imports":[{"path":"packages/plugins/experimental/plugin-automation/src/types/schema.ts","kind":"import-statement","original":"./schema"},{"path":"packages/plugins/experimental/plugin-automation/src/types/types.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"packages/plugins/experimental/plugin-automation/src/AutomationPlugin.tsx":{"bytes":29269,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/plugin-client","kind":"import-statement","external":true},{"path":"@dxos/plugin-graph","kind":"import-statement","external":true},{"path":"@dxos/plugin-space","kind":"import-statement","external":true},{"path":"@dxos/react-client/echo","kind":"import-statement","external":true},{"path":"@dxos/react-ui-form","kind":"import-statement","external":true},{"path":"packages/plugins/experimental/plugin-automation/src/components/index.ts","kind":"import-statement","original":"./components"},{"path":"packages/plugins/experimental/plugin-automation/src/meta.ts","kind":"import-statement","original":"./meta"},{"path":"packages/plugins/experimental/plugin-automation/src/translations.ts","kind":"import-statement","original":"./translations"},{"path":"packages/plugins/experimental/plugin-automation/src/types/index.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"packages/plugins/experimental/plugin-automation/src/presets.ts":{"bytes":19268,"imports":[{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"packages/plugins/experimental/plugin-automation/src/types/index.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"packages/plugins/experimental/plugin-automation/src/index.ts":{"bytes":1109,"imports":[{"path":"packages/plugins/experimental/plugin-automation/src/AutomationPlugin.tsx","kind":"import-statement","original":"./AutomationPlugin"},{"path":"packages/plugins/experimental/plugin-automation/src/AutomationPlugin.tsx","kind":"import-statement","original":"./AutomationPlugin"},{"path":"packages/plugins/experimental/plugin-automation/src/components/index.ts","kind":"import-statement","original":"./components"},{"path":"packages/plugins/experimental/plugin-automation/src/presets.ts","kind":"import-statement","original":"./presets"},{"path":"packages/plugins/experimental/plugin-automation/src/types/index.ts","kind":"import-statement","original":"./types"}],"format":"esm"}},"outputs":{"packages/plugins/experimental/plugin-automation/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":23857},"packages/plugins/experimental/plugin-automation/dist/lib/node/index.cjs":{"imports":[{"path":"packages/plugins/experimental/plugin-automation/dist/lib/node/chunk-CUCUWUAF.cjs","kind":"import-statement"},{"path":"packages/plugins/experimental/plugin-automation/dist/lib/node/chunk-DTJ7XVO2.cjs","kind":"import-statement"},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/plugin-client","kind":"import-statement","external":true},{"path":"@dxos/plugin-graph","kind":"import-statement","external":true},{"path":"@dxos/plugin-space","kind":"import-statement","external":true},{"path":"@dxos/react-client/echo","kind":"import-statement","external":true},{"path":"@dxos/react-ui-form","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"packages/plugins/experimental/plugin-automation/dist/lib/node/AssistantPanel-RIA4TI3B.cjs","kind":"dynamic-import"},{"path":"packages/plugins/experimental/plugin-automation/dist/lib/node/AutomationPanel-HZS5WKI5.cjs","kind":"dynamic-import"},{"path":"@dxos/live-object","kind":"import-statement","external":true}],"exports":["AssistantPanel","AutomationAction","AutomationPanel","AutomationPlugin","ChainInputSchema","ChainInputType","ChainPromptType","ChainType","chainPresets","default","str"],"entryPoint":"packages/plugins/experimental/plugin-automation/src/index.ts","inputs":{"packages/plugins/experimental/plugin-automation/src/AutomationPlugin.tsx":{"bytesInOutput":8000},"packages/plugins/experimental/plugin-automation/src/components/index.ts":{"bytesInOutput":180},"packages/plugins/experimental/plugin-automation/src/translations.ts":{"bytesInOutput":1277},"packages/plugins/experimental/plugin-automation/src/index.ts":{"bytesInOutput":36},"packages/plugins/experimental/plugin-automation/src/presets.ts":{"bytesInOutput":5489}},"bytes":15863},"packages/plugins/experimental/plugin-automation/dist/lib/node/meta.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"packages/plugins/experimental/plugin-automation/dist/lib/node/meta.cjs":{"imports":[{"path":"packages/plugins/experimental/plugin-automation/dist/lib/node/chunk-DTJ7XVO2.cjs","kind":"import-statement"}],"exports":["AUTOMATION_PLUGIN","default"],"entryPoint":"packages/plugins/experimental/plugin-automation/src/meta.ts","inputs":{},"bytes":169},"packages/plugins/experimental/plugin-automation/dist/lib/node/types/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"packages/plugins/experimental/plugin-automation/dist/lib/node/types/index.cjs":{"imports":[{"path":"packages/plugins/experimental/plugin-automation/dist/lib/node/chunk-CUCUWUAF.cjs","kind":"import-statement"}],"exports":["AutomationAction","ChainInputSchema","ChainInputType","ChainPromptType","ChainType"],"entryPoint":"packages/plugins/experimental/plugin-automation/src/types/index.ts","inputs":{},"bytes":266},"packages/plugins/experimental/plugin-automation/dist/lib/node/chunk-CUCUWUAF.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":2879},"packages/plugins/experimental/plugin-automation/dist/lib/node/chunk-CUCUWUAF.cjs":{"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"exports":["AutomationAction","ChainInputSchema","ChainInputType","ChainPromptType","ChainType"],"inputs":{"packages/plugins/experimental/plugin-automation/src/types/schema.ts":{"bytesInOutput":1247},"packages/plugins/experimental/plugin-automation/src/types/index.ts":{"bytesInOutput":0},"packages/plugins/experimental/plugin-automation/src/types/types.ts":{"bytesInOutput":118}},"bytes":1653},"packages/plugins/experimental/plugin-automation/dist/lib/node/AssistantPanel-RIA4TI3B.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":22431},"packages/plugins/experimental/plugin-automation/dist/lib/node/AssistantPanel-RIA4TI3B.cjs":{"imports":[{"path":"packages/plugins/experimental/plugin-automation/dist/lib/node/chunk-DTJ7XVO2.cjs","kind":"import-statement"},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/assistant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/react-client","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-syntax-highlighter","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/react-client/echo","kind":"import-statement","external":true}],"exports":["default"],"entryPoint":"packages/plugins/experimental/plugin-automation/src/components/AssistantPanel/index.ts","inputs":{"packages/plugins/experimental/plugin-automation/src/components/AssistantPanel/AssistantPanel.tsx":{"bytesInOutput":7270},"packages/plugins/experimental/plugin-automation/src/components/AssistantPanel/system-instructions.ts":{"bytesInOutput":4067},"packages/plugins/experimental/plugin-automation/src/components/AssistantPanel/index.ts":{"bytesInOutput":45}},"bytes":11941},"packages/plugins/experimental/plugin-automation/dist/lib/node/AutomationPanel-HZS5WKI5.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":13313},"packages/plugins/experimental/plugin-automation/dist/lib/node/AutomationPanel-HZS5WKI5.cjs":{"imports":[{"path":"packages/plugins/experimental/plugin-automation/dist/lib/node/chunk-DTJ7XVO2.cjs","kind":"import-statement"},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/plugin-script","kind":"import-statement","external":true},{"path":"@dxos/react-client","kind":"import-statement","external":true},{"path":"@dxos/react-client/echo","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-list","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/plugin-script/types","kind":"import-statement","external":true},{"path":"@dxos/react-client/echo","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-form","kind":"import-statement","external":true}],"exports":["default"],"entryPoint":"packages/plugins/experimental/plugin-automation/src/components/AutomationPanel/index.ts","inputs":{"packages/plugins/experimental/plugin-automation/src/components/AutomationPanel/AutomationPanel.tsx":{"bytesInOutput":4190},"packages/plugins/experimental/plugin-automation/src/components/TriggerEditor/TriggerEditor.tsx":{"bytesInOutput":1492},"packages/plugins/experimental/plugin-automation/src/components/TriggerEditor/index.ts":{"bytesInOutput":0},"packages/plugins/experimental/plugin-automation/src/components/AutomationPanel/index.ts":{"bytesInOutput":47}},"bytes":6289},"packages/plugins/experimental/plugin-automation/dist/lib/node/chunk-DTJ7XVO2.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":763},"packages/plugins/experimental/plugin-automation/dist/lib/node/chunk-DTJ7XVO2.cjs":{"imports":[],"exports":["AUTOMATION_PLUGIN","meta_default"],"inputs":{"packages/plugins/experimental/plugin-automation/src/meta.ts":{"bytesInOutput":333}},"bytes":489}}}
1
+ {"inputs":{"packages/plugins/experimental/plugin-automation/src/components/AssistantPanel/system-instructions.ts":{"bytes":16049,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/react-client/echo","kind":"import-statement","external":true}],"format":"esm"},"packages/plugins/experimental/plugin-automation/src/meta.ts":{"bytes":1626,"imports":[],"format":"esm"},"packages/plugins/experimental/plugin-automation/src/components/AssistantPanel/AssistantPanel.tsx":{"bytes":28000,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/assistant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/react-client","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-syntax-highlighter","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"packages/plugins/experimental/plugin-automation/src/components/AssistantPanel/system-instructions.ts","kind":"import-statement","original":"./system-instructions"},{"path":"packages/plugins/experimental/plugin-automation/src/meta.ts","kind":"import-statement","original":"../../meta"}],"format":"esm"},"packages/plugins/experimental/plugin-automation/src/components/AssistantPanel/index.ts":{"bytes":739,"imports":[{"path":"packages/plugins/experimental/plugin-automation/src/components/AssistantPanel/AssistantPanel.tsx","kind":"import-statement","original":"./AssistantPanel"}],"format":"esm"},"packages/plugins/experimental/plugin-automation/src/components/TriggerEditor/TriggerEditor.tsx":{"bytes":7128,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/react-client/echo","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-form","kind":"import-statement","external":true},{"path":"packages/plugins/experimental/plugin-automation/src/meta.ts","kind":"import-statement","original":"../../meta"}],"format":"esm"},"packages/plugins/experimental/plugin-automation/src/components/TriggerEditor/index.ts":{"bytes":557,"imports":[{"path":"packages/plugins/experimental/plugin-automation/src/components/TriggerEditor/TriggerEditor.tsx","kind":"import-statement","original":"./TriggerEditor"}],"format":"esm"},"packages/plugins/experimental/plugin-automation/src/components/AutomationPanel/AutomationPanel.tsx":{"bytes":19714,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/react-client","kind":"import-statement","external":true},{"path":"@dxos/react-client/echo","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-list","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"packages/plugins/experimental/plugin-automation/src/meta.ts","kind":"import-statement","original":"../../meta"},{"path":"packages/plugins/experimental/plugin-automation/src/components/TriggerEditor/index.ts","kind":"import-statement","original":"../TriggerEditor"}],"format":"esm"},"packages/plugins/experimental/plugin-automation/src/components/AutomationPanel/index.ts":{"bytes":751,"imports":[{"path":"packages/plugins/experimental/plugin-automation/src/components/AutomationPanel/AutomationPanel.tsx","kind":"import-statement","original":"./AutomationPanel"}],"format":"esm"},"packages/plugins/experimental/plugin-automation/src/components/index.ts":{"bytes":1078,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"packages/plugins/experimental/plugin-automation/src/components/AssistantPanel/index.ts","kind":"dynamic-import","original":"./AssistantPanel"},{"path":"packages/plugins/experimental/plugin-automation/src/components/AutomationPanel/index.ts","kind":"dynamic-import","original":"./AutomationPanel"}],"format":"esm"},"packages/plugins/experimental/plugin-automation/src/translations.ts":{"bytes":4582,"imports":[{"path":"packages/plugins/experimental/plugin-automation/src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"},"packages/plugins/experimental/plugin-automation/src/types/schema.ts":{"bytes":4248,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"format":"esm"},"packages/plugins/experimental/plugin-automation/src/types/types.ts":{"bytes":1464,"imports":[],"format":"esm"},"packages/plugins/experimental/plugin-automation/src/types/index.ts":{"bytes":604,"imports":[{"path":"packages/plugins/experimental/plugin-automation/src/types/schema.ts","kind":"import-statement","original":"./schema"},{"path":"packages/plugins/experimental/plugin-automation/src/types/types.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"packages/plugins/experimental/plugin-automation/src/AutomationPlugin.tsx":{"bytes":29041,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/plugin-client/types","kind":"import-statement","external":true},{"path":"@dxos/plugin-graph","kind":"import-statement","external":true},{"path":"@dxos/plugin-space","kind":"import-statement","external":true},{"path":"@dxos/react-client/echo","kind":"import-statement","external":true},{"path":"@dxos/react-ui-form","kind":"import-statement","external":true},{"path":"packages/plugins/experimental/plugin-automation/src/components/index.ts","kind":"import-statement","original":"./components"},{"path":"packages/plugins/experimental/plugin-automation/src/meta.ts","kind":"import-statement","original":"./meta"},{"path":"packages/plugins/experimental/plugin-automation/src/translations.ts","kind":"import-statement","original":"./translations"},{"path":"packages/plugins/experimental/plugin-automation/src/types/index.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"packages/plugins/experimental/plugin-automation/src/presets.ts":{"bytes":19268,"imports":[{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"packages/plugins/experimental/plugin-automation/src/types/index.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"packages/plugins/experimental/plugin-automation/src/index.ts":{"bytes":1109,"imports":[{"path":"packages/plugins/experimental/plugin-automation/src/AutomationPlugin.tsx","kind":"import-statement","original":"./AutomationPlugin"},{"path":"packages/plugins/experimental/plugin-automation/src/AutomationPlugin.tsx","kind":"import-statement","original":"./AutomationPlugin"},{"path":"packages/plugins/experimental/plugin-automation/src/components/index.ts","kind":"import-statement","original":"./components"},{"path":"packages/plugins/experimental/plugin-automation/src/presets.ts","kind":"import-statement","original":"./presets"},{"path":"packages/plugins/experimental/plugin-automation/src/types/index.ts","kind":"import-statement","original":"./types"}],"format":"esm"}},"outputs":{"packages/plugins/experimental/plugin-automation/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":24044},"packages/plugins/experimental/plugin-automation/dist/lib/node/index.cjs":{"imports":[{"path":"packages/plugins/experimental/plugin-automation/dist/lib/node/chunk-NIL4TP6U.cjs","kind":"import-statement"},{"path":"packages/plugins/experimental/plugin-automation/dist/lib/node/chunk-DTJ7XVO2.cjs","kind":"import-statement"},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/plugin-client/types","kind":"import-statement","external":true},{"path":"@dxos/plugin-graph","kind":"import-statement","external":true},{"path":"@dxos/plugin-space","kind":"import-statement","external":true},{"path":"@dxos/react-client/echo","kind":"import-statement","external":true},{"path":"@dxos/react-ui-form","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"packages/plugins/experimental/plugin-automation/dist/lib/node/AssistantPanel-XANI7YNV.cjs","kind":"dynamic-import"},{"path":"packages/plugins/experimental/plugin-automation/dist/lib/node/AutomationPanel-2UGSAIXU.cjs","kind":"dynamic-import"},{"path":"@dxos/live-object","kind":"import-statement","external":true}],"exports":["AssistantPanel","AutomationAction","AutomationPanel","AutomationPlugin","ChainInputSchema","ChainInputType","ChainPromptType","ChainType","chainPresets","default","str"],"entryPoint":"packages/plugins/experimental/plugin-automation/src/index.ts","inputs":{"packages/plugins/experimental/plugin-automation/src/AutomationPlugin.tsx":{"bytesInOutput":7755},"packages/plugins/experimental/plugin-automation/src/components/index.ts":{"bytesInOutput":180},"packages/plugins/experimental/plugin-automation/src/translations.ts":{"bytesInOutput":1316},"packages/plugins/experimental/plugin-automation/src/index.ts":{"bytesInOutput":36},"packages/plugins/experimental/plugin-automation/src/presets.ts":{"bytesInOutput":5489}},"bytes":15657},"packages/plugins/experimental/plugin-automation/dist/lib/node/meta.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"packages/plugins/experimental/plugin-automation/dist/lib/node/meta.cjs":{"imports":[{"path":"packages/plugins/experimental/plugin-automation/dist/lib/node/chunk-DTJ7XVO2.cjs","kind":"import-statement"}],"exports":["AUTOMATION_PLUGIN","default"],"entryPoint":"packages/plugins/experimental/plugin-automation/src/meta.ts","inputs":{},"bytes":169},"packages/plugins/experimental/plugin-automation/dist/lib/node/types/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"packages/plugins/experimental/plugin-automation/dist/lib/node/types/index.cjs":{"imports":[{"path":"packages/plugins/experimental/plugin-automation/dist/lib/node/chunk-NIL4TP6U.cjs","kind":"import-statement"}],"exports":["AutomationAction","ChainInputSchema","ChainInputType","ChainPromptType","ChainType"],"entryPoint":"packages/plugins/experimental/plugin-automation/src/types/index.ts","inputs":{},"bytes":266},"packages/plugins/experimental/plugin-automation/dist/lib/node/chunk-NIL4TP6U.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":2879},"packages/plugins/experimental/plugin-automation/dist/lib/node/chunk-NIL4TP6U.cjs":{"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"exports":["AutomationAction","ChainInputSchema","ChainInputType","ChainPromptType","ChainType"],"inputs":{"packages/plugins/experimental/plugin-automation/src/types/schema.ts":{"bytesInOutput":1247},"packages/plugins/experimental/plugin-automation/src/types/index.ts":{"bytesInOutput":0},"packages/plugins/experimental/plugin-automation/src/types/types.ts":{"bytesInOutput":118}},"bytes":1653},"packages/plugins/experimental/plugin-automation/dist/lib/node/AssistantPanel-XANI7YNV.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":22398},"packages/plugins/experimental/plugin-automation/dist/lib/node/AssistantPanel-XANI7YNV.cjs":{"imports":[{"path":"packages/plugins/experimental/plugin-automation/dist/lib/node/chunk-DTJ7XVO2.cjs","kind":"import-statement"},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/assistant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/react-client","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-syntax-highlighter","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/react-client/echo","kind":"import-statement","external":true}],"exports":["default"],"entryPoint":"packages/plugins/experimental/plugin-automation/src/components/AssistantPanel/index.ts","inputs":{"packages/plugins/experimental/plugin-automation/src/components/AssistantPanel/AssistantPanel.tsx":{"bytesInOutput":7244},"packages/plugins/experimental/plugin-automation/src/components/AssistantPanel/system-instructions.ts":{"bytesInOutput":4067},"packages/plugins/experimental/plugin-automation/src/components/AssistantPanel/index.ts":{"bytesInOutput":45}},"bytes":11915},"packages/plugins/experimental/plugin-automation/dist/lib/node/AutomationPanel-2UGSAIXU.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":14860},"packages/plugins/experimental/plugin-automation/dist/lib/node/AutomationPanel-2UGSAIXU.cjs":{"imports":[{"path":"packages/plugins/experimental/plugin-automation/dist/lib/node/chunk-DTJ7XVO2.cjs","kind":"import-statement"},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/react-client","kind":"import-statement","external":true},{"path":"@dxos/react-client/echo","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-list","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/react-client/echo","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-form","kind":"import-statement","external":true}],"exports":["default"],"entryPoint":"packages/plugins/experimental/plugin-automation/src/components/AutomationPanel/index.ts","inputs":{"packages/plugins/experimental/plugin-automation/src/components/AutomationPanel/AutomationPanel.tsx":{"bytesInOutput":4896},"packages/plugins/experimental/plugin-automation/src/components/TriggerEditor/TriggerEditor.tsx":{"bytesInOutput":1456},"packages/plugins/experimental/plugin-automation/src/components/TriggerEditor/index.ts":{"bytesInOutput":0},"packages/plugins/experimental/plugin-automation/src/components/AutomationPanel/index.ts":{"bytesInOutput":47}},"bytes":6959},"packages/plugins/experimental/plugin-automation/dist/lib/node/chunk-DTJ7XVO2.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":763},"packages/plugins/experimental/plugin-automation/dist/lib/node/chunk-DTJ7XVO2.cjs":{"imports":[],"exports":["AUTOMATION_PLUGIN","meta_default"],"inputs":{"packages/plugins/experimental/plugin-automation/src/meta.ts":{"bytesInOutput":333}},"bytes":489}}}
@@ -18,14 +18,14 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var types_exports = {};
20
20
  __export(types_exports, {
21
- AutomationAction: () => import_chunk_CUCUWUAF.AutomationAction,
22
- ChainInputSchema: () => import_chunk_CUCUWUAF.ChainInputSchema,
23
- ChainInputType: () => import_chunk_CUCUWUAF.ChainInputType,
24
- ChainPromptType: () => import_chunk_CUCUWUAF.ChainPromptType,
25
- ChainType: () => import_chunk_CUCUWUAF.ChainType
21
+ AutomationAction: () => import_chunk_NIL4TP6U.AutomationAction,
22
+ ChainInputSchema: () => import_chunk_NIL4TP6U.ChainInputSchema,
23
+ ChainInputType: () => import_chunk_NIL4TP6U.ChainInputType,
24
+ ChainPromptType: () => import_chunk_NIL4TP6U.ChainPromptType,
25
+ ChainType: () => import_chunk_NIL4TP6U.ChainType
26
26
  });
27
27
  module.exports = __toCommonJS(types_exports);
28
- var import_chunk_CUCUWUAF = require("../chunk-CUCUWUAF.cjs");
28
+ var import_chunk_NIL4TP6U = require("../chunk-NIL4TP6U.cjs");
29
29
  // Annotate the CommonJS export names for ESM import in node:
30
30
  0 && (module.exports = {
31
31
  AutomationAction,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["index.cjs"],
4
- "sourcesContent": ["import {\n AutomationAction,\n ChainInputSchema,\n ChainInputType,\n ChainPromptType,\n ChainType\n} from \"../chunk-CUCUWUAF.cjs\";\nexport {\n AutomationAction,\n ChainInputSchema,\n ChainInputType,\n ChainPromptType,\n ChainType\n};\n//# sourceMappingURL=index.cjs.map\n"],
4
+ "sourcesContent": ["import {\n AutomationAction,\n ChainInputSchema,\n ChainInputType,\n ChainPromptType,\n ChainType\n} from \"../chunk-NIL4TP6U.cjs\";\nexport {\n AutomationAction,\n ChainInputSchema,\n ChainInputType,\n ChainPromptType,\n ChainType\n};\n//# sourceMappingURL=index.cjs.map\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAMO;",
6
6
  "names": []
7
7
  }
@@ -274,9 +274,7 @@ var AssistantPanel = ({ subject, classNames }) => {
274
274
  }, /* @__PURE__ */ React.createElement(Icon, {
275
275
  icon: "ph--play--regular",
276
276
  size: 4
277
- }))), /* @__PURE__ */ React.createElement(ContextMenu.Portal, null, /* @__PURE__ */ React.createElement(ContextMenu.Content, {
278
- classNames: "z-[31]"
279
- }, /* @__PURE__ */ React.createElement(ContextMenu.Viewport, null, /* @__PURE__ */ React.createElement(ContextMenu.Item, {
277
+ }))), /* @__PURE__ */ React.createElement(ContextMenu.Portal, null, /* @__PURE__ */ React.createElement(ContextMenu.Content, null, /* @__PURE__ */ React.createElement(ContextMenu.Viewport, null, /* @__PURE__ */ React.createElement(ContextMenu.Item, {
280
278
  onClick: clearThread
281
279
  }, "Clear thread"), /* @__PURE__ */ React.createElement(ContextMenu.Item, {
282
280
  onClick: async () => console.log(await getSystemPrompt())
@@ -339,4 +337,4 @@ var AssistantPanel_default = AssistantPanel;
339
337
  export {
340
338
  AssistantPanel_default as default
341
339
  };
342
- //# sourceMappingURL=AssistantPanel-72YH43CH.mjs.map
340
+ //# sourceMappingURL=AssistantPanel-5M6O6JV7.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/AssistantPanel/AssistantPanel.tsx", "../../../src/components/AssistantPanel/system-instructions.ts", "../../../src/components/AssistantPanel/index.ts"],
4
- "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\n/* eslint-disable no-console */\n\nimport React, { useEffect, useRef, useState } from 'react';\n\nimport { type AIServiceClient, AIServiceClientImpl, ObjectId, type Message } from '@dxos/assistant';\nimport type { ReactiveEchoObject } from '@dxos/echo-db';\nimport { SpaceId } from '@dxos/keys';\nimport { useClient, useConfig } from '@dxos/react-client';\nimport { ContextMenu, type ThemedClassName } from '@dxos/react-ui';\nimport { Icon, Input, Toolbar, useTranslation } from '@dxos/react-ui';\nimport { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { createSystemInstructions } from './system-instructions';\nimport { AUTOMATION_PLUGIN } from '../../meta';\n\nconst PROPERTIES_ASSISTANT_KEY = 'dxos.assistant.beta.properties';\n\nexport type AssistantPanelProps = ThemedClassName<{\n subject?: ReactiveEchoObject<any>;\n}>;\n\nexport const AssistantPanel = ({ subject, classNames }: AssistantPanelProps) => {\n const { t } = useTranslation(AUTOMATION_PLUGIN);\n const config = useConfig();\n const client = useClient();\n const aiClient = useRef<AIServiceClient>();\n const [contextSpaceId, setContextSpaceId] = useState<SpaceId | undefined>();\n const [threadId, setThreadId] = useState<ObjectId | undefined>();\n const [history, setHistory] = useState<Message[]>([]);\n const [input, setInput] = useState('');\n\n useEffect(() => {\n if (!aiClient.current) {\n const endpoint = config.values.runtime?.services?.ai?.server;\n if (!endpoint) {\n throw new Error('AI service endpoint is not configured');\n }\n aiClient.current = new AIServiceClientImpl({\n endpoint,\n });\n }\n\n queueMicrotask(async () => {\n const properties = client.spaces.default.properties;\n\n properties[PROPERTIES_ASSISTANT_KEY] ??= {};\n properties[PROPERTIES_ASSISTANT_KEY].contextSpaceId ??= SpaceId.random();\n properties[PROPERTIES_ASSISTANT_KEY].threadId ??= ObjectId.random();\n\n const contextSpaceId = properties[PROPERTIES_ASSISTANT_KEY].contextSpaceId;\n const threadId = properties[PROPERTIES_ASSISTANT_KEY].threadId;\n\n setContextSpaceId(contextSpaceId);\n setThreadId(threadId);\n\n const messages = await aiClient.current!.getMessagesInThread(contextSpaceId, threadId);\n setHistory(messages);\n });\n }, []);\n\n const handleRequest = async (input: string) => {\n if (input === '') {\n return;\n }\n\n setInput('');\n\n // TODO(dmaretskyi): Can we call `create(Message, { ... })` here?\n const userMessage: Message = {\n id: ObjectId.random(),\n spaceId: contextSpaceId!,\n threadId: threadId!,\n role: 'user',\n content: [{ type: 'text', text: input }],\n };\n await aiClient.current!.insertMessages([userMessage]);\n setHistory([...history, userMessage]);\n\n const generationStream = await aiClient.current!.generate({\n model: '@anthropic/claude-3-5-sonnet-20241022',\n spaceId: contextSpaceId!,\n threadId: threadId!,\n tools: [],\n systemPrompt: await getSystemPrompt(),\n });\n\n const historyBefore = [...history, userMessage];\n for await (const _event of generationStream) {\n setHistory([...historyBefore, ...generationStream.accumulatedMessages]);\n }\n\n await aiClient.current!.insertMessages(await generationStream.complete());\n };\n\n const getSystemPrompt = async () => {\n return createSystemInstructions({ subject });\n };\n\n const clearThread = async () => {\n const properties = client.spaces.default.properties;\n\n properties[PROPERTIES_ASSISTANT_KEY] ??= {};\n // properties[PROPERTIES_ASSISTANT_KEY].contextSpaceId ??= SpaceId.random();\n properties[PROPERTIES_ASSISTANT_KEY].threadId = ObjectId.random();\n\n // const contextSpaceId = properties[PROPERTIES_ASSISTANT_KEY].contextSpaceId;\n const threadId = properties[PROPERTIES_ASSISTANT_KEY].threadId;\n\n // setContextSpaceId(contextSpaceId);\n setThreadId(threadId);\n\n const messages = await aiClient.current!.getMessagesInThread(contextSpaceId!, threadId);\n setHistory(messages);\n };\n\n // TODO(burdon): Factor out with script plugin.\n return (\n <div className={mx('flex flex-col h-full overflow-hidden', classNames)}>\n {history.length > 0 && (\n <div className='flex flex-col gap-6 h-full p-2 overflow-x-hidden overflow-y-auto'>\n {history.map((message) => (\n <MessageItem key={message.id} message={message} />\n ))}\n </div>\n )}\n\n <Toolbar.Root classNames='p-1'>\n <Input.Root>\n <Input.TextInput\n autoFocus\n placeholder={t('ask me anything')}\n value={input}\n onChange={(ev) => setInput(ev.target.value)}\n onKeyDown={(ev) => ev.key === 'Enter' && handleRequest(input)}\n />\n </Input.Root>\n <ContextMenu.Root>\n <ContextMenu.Trigger asChild>\n <Toolbar.Button onClick={() => handleRequest(input)}>\n <Icon icon='ph--play--regular' size={4} />\n </Toolbar.Button>\n </ContextMenu.Trigger>\n <ContextMenu.Portal>\n <ContextMenu.Content classNames='z-[31]'>\n <ContextMenu.Viewport>\n <ContextMenu.Item onClick={clearThread}>Clear thread</ContextMenu.Item>\n <ContextMenu.Item onClick={async () => console.log(await getSystemPrompt())}>\n Print instructions to console\n </ContextMenu.Item>\n </ContextMenu.Viewport>\n </ContextMenu.Content>\n </ContextMenu.Portal>\n </ContextMenu.Root>\n\n {/* <Toolbar.Button onClick={() => (state ? handleStop() : handleClear())}>\n <Icon icon={state ? 'ph--stop--regular' : 'ph--trash--regular'} size={4} />\n </Toolbar.Button> */}\n </Toolbar.Root>\n </div>\n );\n};\n\nconst MessageItem = ({ classNames, message }: ThemedClassName<{ message: Message }>) => {\n const { id: _, role, content } = message;\n const styleContainer = 'flex flex-col overflow-x-hidden overflow-y-auto rounded-md gap-2 divide-y divide-separator';\n\n return (\n <div className={mx('flex', role === 'user' ? 'ml-[1rem] justify-end' : 'mr-[1rem]', classNames)}>\n {content.map((content, i) => {\n switch (content.type) {\n case 'text': {\n const { cot, message } = parseMessage(content.text);\n return (\n <div\n key={i}\n role='none'\n className={mx(\n styleContainer,\n role === 'user' ? 'bg-primary-400 dark:bg-primary-600' : 'bg-hoverSurface',\n )}\n >\n {cot && <div className='p-2 whitespace-pre-wrap text-xs text-subdued'>{cot}</div>}\n <div className='p-2 whitespace-pre-wrap'>{message}</div>\n </div>\n );\n }\n\n case 'tool_use': {\n return (\n <div key={i} className={mx(styleContainer, 'text-xs')}>\n <div>\n <span className='p-2 text-primary'>Tool use</span>: {content.name} {content.id}\n </div>\n <SyntaxHighlighter language='json'>{content.inputJson}</SyntaxHighlighter>\n </div>\n );\n }\n\n case 'tool_result': {\n return (\n <div key={i} className={mx(styleContainer, 'text-xs', content.isError && 'text-error')}>\n <div>\n <span className='p-2 text-primary'>Tool result</span>: {content.toolUseId}\n </div>\n <SyntaxHighlighter language='json'>{content.content}</SyntaxHighlighter>\n </div>\n );\n }\n }\n\n return null;\n })}\n </div>\n );\n};\n\n// TODO(burdon): Move to server-side parsing.\nconst parseMessage = (text: string): { cot?: string; message: string } => {\n const regex = /<cot>([\\s\\S]*?)<\\/cot>\\s*([\\s\\S]*)/;\n const match = text.match(regex);\n return {\n cot: match?.[1].trim(),\n message: match?.[2] ?? text ?? '\\u00D8',\n };\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { asyncTimeout } from '@dxos/async';\nimport type { ReactiveEchoObject } from '@dxos/echo-db';\nimport { getTypename } from '@dxos/echo-schema';\nimport { log } from '@dxos/log';\nimport { Filter, getSpace, ResultFormat } from '@dxos/react-client/echo';\n\n// TODO(burdon): Move into assistant-protocol.\nexport type ThreadContext = {\n subject?: ReactiveEchoObject<any>;\n};\n\nexport const createSystemInstructions = async (context: ThreadContext): Promise<string> => {\n let instructions = `\n <instructions>\n Before replying always think step-by-step on how to proceed.\n Print your thoughts inside <cot> tags.\n\n <example>\n <cot>To answer the question I need to ...</cot>\n </example>\n </instructions>\n\n <current_time>${new Date().toLocaleString()}</current_time>\n `;\n\n if (context.subject) {\n instructions += `\n <user_attention>\n The user is currently interacting with an object in Composer application:\n\n ${await formatContextObject(context.subject)}\n </user_attention>\n `;\n }\n\n return looseFormatXml(instructions);\n};\n\nconst formatContextObject = async (object: ReactiveEchoObject<any>): Promise<string> => {\n let data;\n try {\n data = await asyncTimeout(preprocessContextObject(object), CONTEXT_OBJECT_QUERY_TIMEOUT);\n } catch (err: any) {\n log.error('Failed to preprocess context object:', { err });\n data = object;\n }\n\n if (typeof data === 'string') {\n return data;\n } else {\n return `\n <object>\n <type>${getTypename(object)}</type>\n <id>${object.id}</id>\n ${formatObjectAsXMLTags(data)}\n </object>\n `;\n }\n};\n\nconst preprocessContextObject = async (object: ReactiveEchoObject<any>): Promise<Record<string, any> | string> => {\n const space = getSpace(object);\n if (!space) {\n return { ...object };\n }\n\n // TODO(dmaretskyi): Serialize based on schema annotations.\n switch (getTypename(object)) {\n // TODO(dmaretskyi): Reference types somehow without plugin-automation depending on other plugins.\n case 'dxos.org/type/Document': {\n const data = space.db\n .query({ id: object.id }, { format: ResultFormat.Plain, include: { content: true } })\n .first() ?? { content: { content: '' } };\n\n return {\n ...data,\n threads: undefined,\n };\n }\n\n case 'dxos.org/type/Table': {\n // TODO(dmaretskyi): Load references.\n const schema = object.view ? space?.db.schemaRegistry.getSchema(object.view.query.type) : undefined;\n const { objects: rows } =\n (schema &&\n (await space.db\n .query(Filter.schema(schema), { format: ResultFormat.Plain, limit: TABLE_ROWS_LIMIT })\n .run())) ??\n {};\n\n // TODO(dmaretskyi): Format table schema.\n return `\n <object>\n <id>${object.id}</id>\n <type>${getTypename(object)}</type>\n ${formatObjectAsXMLTags(object)}\n\n <rows>\n <!-- Limited to first ${TABLE_ROWS_LIMIT} rows. -->\n ${rows\n ?.map(\n (row: any) => `<row>\n ${formatObjectAsXMLTags(row)}\n </row>`,\n )\n .join('\\n')}\n </rows>\n\n `;\n }\n\n default:\n return { ...object };\n }\n};\n\nconst formatObjectAsXMLTags = (object: any, depth = 1): string => {\n return Object.entries(object)\n .filter(([key, value]) => ['string', 'number', 'boolean', 'object'].includes(typeof value))\n .map(([key, value]) => {\n if (typeof value === 'object' && value !== null) {\n if (depth === 0) {\n return '';\n } else {\n return `<${key}>\n ${formatObjectAsXMLTags(value, depth - 1)}\n </${key}>`;\n }\n }\n\n return `<${key}>${value}</${key}>`;\n })\n .join('\\n');\n};\n\nconst CONTEXT_OBJECT_QUERY_TIMEOUT = 5_000;\n\nconst TABLE_ROWS_LIMIT = 10;\n\n/**\n * Formats XML indentation for instructions so they are easier to read during debugging.\n */\nconst looseFormatXml = (xml: string): string => {\n let currentIndent = 0;\n\n return xml\n .split('\\n')\n .map((line) => {\n if (line.match(RE_CLOSE_TAG_LINE)) {\n currentIndent--;\n }\n const indent = currentIndent;\n if (line.match(RE_OPEN_TAG_LINE)) {\n currentIndent++;\n }\n return ' '.repeat(indent * 2) + line.trimStart();\n })\n .join('\\n');\n};\n\nconst RE_OPEN_TAG_LINE = /^[ ]*<[a-zA-Z0-9\\-_]+>[ ]*$/;\nconst RE_CLOSE_TAG_LINE = /^[ ]*<\\/[a-zA-Z0-9\\-_]+>[ ]*$/;\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { AssistantPanel } from './AssistantPanel';\n\nexport default AssistantPanel;\n"],
5
- "mappings": ";;;;;;AAMA,OAAOA,SAASC,WAAWC,QAAQC,gBAAgB;AAEnD,SAA+BC,qBAAqBC,gBAA8B;AAElF,SAASC,eAAe;AACxB,SAASC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GN;AAGA,IAAMqD,eAAe,CAACnD,SAAAA;AACpB,QAAM2D,QAAQ;AACd,QAAMC,QAAQ5D,KAAK4D,MAAMD,KAAAA;AACzB,SAAO;IACLT,KAAKU,QAAQ,CAAA,EAAGC,KAAAA;IAChB1C,SAASyC,QAAQ,CAAA,KAAM5D,QAAQ;EACjC;AACF;;;AE/NA,IAAA,yBAAe8D;",
4
+ "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\n/* eslint-disable no-console */\n\nimport React, { useEffect, useRef, useState } from 'react';\n\nimport { type AIServiceClient, AIServiceClientImpl, ObjectId, type Message } from '@dxos/assistant';\nimport type { ReactiveEchoObject } from '@dxos/echo-db';\nimport { SpaceId } from '@dxos/keys';\nimport { useClient, useConfig } from '@dxos/react-client';\nimport { ContextMenu, type ThemedClassName } from '@dxos/react-ui';\nimport { Icon, Input, Toolbar, useTranslation } from '@dxos/react-ui';\nimport { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { createSystemInstructions } from './system-instructions';\nimport { AUTOMATION_PLUGIN } from '../../meta';\n\nconst PROPERTIES_ASSISTANT_KEY = 'dxos.assistant.beta.properties';\n\nexport type AssistantPanelProps = ThemedClassName<{\n subject?: ReactiveEchoObject<any>;\n}>;\n\nexport const AssistantPanel = ({ subject, classNames }: AssistantPanelProps) => {\n const { t } = useTranslation(AUTOMATION_PLUGIN);\n const config = useConfig();\n const client = useClient();\n const aiClient = useRef<AIServiceClient>();\n const [contextSpaceId, setContextSpaceId] = useState<SpaceId | undefined>();\n const [threadId, setThreadId] = useState<ObjectId | undefined>();\n const [history, setHistory] = useState<Message[]>([]);\n const [input, setInput] = useState('');\n\n useEffect(() => {\n if (!aiClient.current) {\n const endpoint = config.values.runtime?.services?.ai?.server;\n if (!endpoint) {\n throw new Error('AI service endpoint is not configured');\n }\n aiClient.current = new AIServiceClientImpl({\n endpoint,\n });\n }\n\n queueMicrotask(async () => {\n const properties = client.spaces.default.properties;\n\n properties[PROPERTIES_ASSISTANT_KEY] ??= {};\n properties[PROPERTIES_ASSISTANT_KEY].contextSpaceId ??= SpaceId.random();\n properties[PROPERTIES_ASSISTANT_KEY].threadId ??= ObjectId.random();\n\n const contextSpaceId = properties[PROPERTIES_ASSISTANT_KEY].contextSpaceId;\n const threadId = properties[PROPERTIES_ASSISTANT_KEY].threadId;\n\n setContextSpaceId(contextSpaceId);\n setThreadId(threadId);\n\n const messages = await aiClient.current!.getMessagesInThread(contextSpaceId, threadId);\n setHistory(messages);\n });\n }, []);\n\n const handleRequest = async (input: string) => {\n if (input === '') {\n return;\n }\n\n setInput('');\n\n // TODO(dmaretskyi): Can we call `create(Message, { ... })` here?\n const userMessage: Message = {\n id: ObjectId.random(),\n spaceId: contextSpaceId!,\n threadId: threadId!,\n role: 'user',\n content: [{ type: 'text', text: input }],\n };\n await aiClient.current!.insertMessages([userMessage]);\n setHistory([...history, userMessage]);\n\n const generationStream = await aiClient.current!.generate({\n model: '@anthropic/claude-3-5-sonnet-20241022',\n spaceId: contextSpaceId!,\n threadId: threadId!,\n tools: [],\n systemPrompt: await getSystemPrompt(),\n });\n\n const historyBefore = [...history, userMessage];\n for await (const _event of generationStream) {\n setHistory([...historyBefore, ...generationStream.accumulatedMessages]);\n }\n\n await aiClient.current!.insertMessages(await generationStream.complete());\n };\n\n const getSystemPrompt = async () => {\n return createSystemInstructions({ subject });\n };\n\n const clearThread = async () => {\n const properties = client.spaces.default.properties;\n\n properties[PROPERTIES_ASSISTANT_KEY] ??= {};\n // properties[PROPERTIES_ASSISTANT_KEY].contextSpaceId ??= SpaceId.random();\n properties[PROPERTIES_ASSISTANT_KEY].threadId = ObjectId.random();\n\n // const contextSpaceId = properties[PROPERTIES_ASSISTANT_KEY].contextSpaceId;\n const threadId = properties[PROPERTIES_ASSISTANT_KEY].threadId;\n\n // setContextSpaceId(contextSpaceId);\n setThreadId(threadId);\n\n const messages = await aiClient.current!.getMessagesInThread(contextSpaceId!, threadId);\n setHistory(messages);\n };\n\n // TODO(burdon): Factor out with script plugin.\n return (\n <div className={mx('flex flex-col h-full overflow-hidden', classNames)}>\n {history.length > 0 && (\n <div className='flex flex-col gap-6 h-full p-2 overflow-x-hidden overflow-y-auto'>\n {history.map((message) => (\n <MessageItem key={message.id} message={message} />\n ))}\n </div>\n )}\n\n <Toolbar.Root classNames='p-1'>\n <Input.Root>\n <Input.TextInput\n autoFocus\n placeholder={t('ask me anything')}\n value={input}\n onChange={(ev) => setInput(ev.target.value)}\n onKeyDown={(ev) => ev.key === 'Enter' && handleRequest(input)}\n />\n </Input.Root>\n <ContextMenu.Root>\n <ContextMenu.Trigger asChild>\n <Toolbar.Button onClick={() => handleRequest(input)}>\n <Icon icon='ph--play--regular' size={4} />\n </Toolbar.Button>\n </ContextMenu.Trigger>\n <ContextMenu.Portal>\n <ContextMenu.Content>\n <ContextMenu.Viewport>\n <ContextMenu.Item onClick={clearThread}>Clear thread</ContextMenu.Item>\n <ContextMenu.Item onClick={async () => console.log(await getSystemPrompt())}>\n Print instructions to console\n </ContextMenu.Item>\n </ContextMenu.Viewport>\n </ContextMenu.Content>\n </ContextMenu.Portal>\n </ContextMenu.Root>\n\n {/* <Toolbar.Button onClick={() => (state ? handleStop() : handleClear())}>\n <Icon icon={state ? 'ph--stop--regular' : 'ph--trash--regular'} size={4} />\n </Toolbar.Button> */}\n </Toolbar.Root>\n </div>\n );\n};\n\nconst MessageItem = ({ classNames, message }: ThemedClassName<{ message: Message }>) => {\n const { id: _, role, content } = message;\n const styleContainer = 'flex flex-col overflow-x-hidden overflow-y-auto rounded-md gap-2 divide-y divide-separator';\n\n return (\n <div className={mx('flex', role === 'user' ? 'ml-[1rem] justify-end' : 'mr-[1rem]', classNames)}>\n {content.map((content, i) => {\n switch (content.type) {\n case 'text': {\n const { cot, message } = parseMessage(content.text);\n return (\n <div\n key={i}\n role='none'\n className={mx(\n styleContainer,\n role === 'user' ? 'bg-primary-400 dark:bg-primary-600' : 'bg-hoverSurface',\n )}\n >\n {cot && <div className='p-2 whitespace-pre-wrap text-xs text-subdued'>{cot}</div>}\n <div className='p-2 whitespace-pre-wrap'>{message}</div>\n </div>\n );\n }\n\n case 'tool_use': {\n return (\n <div key={i} className={mx(styleContainer, 'text-xs')}>\n <div>\n <span className='p-2 text-primary'>Tool use</span>: {content.name} {content.id}\n </div>\n <SyntaxHighlighter language='json'>{content.inputJson}</SyntaxHighlighter>\n </div>\n );\n }\n\n case 'tool_result': {\n return (\n <div key={i} className={mx(styleContainer, 'text-xs', content.isError && 'text-error')}>\n <div>\n <span className='p-2 text-primary'>Tool result</span>: {content.toolUseId}\n </div>\n <SyntaxHighlighter language='json'>{content.content}</SyntaxHighlighter>\n </div>\n );\n }\n }\n\n return null;\n })}\n </div>\n );\n};\n\n// TODO(burdon): Move to server-side parsing.\nconst parseMessage = (text: string): { cot?: string; message: string } => {\n const regex = /<cot>([\\s\\S]*?)<\\/cot>\\s*([\\s\\S]*)/;\n const match = text.match(regex);\n return {\n cot: match?.[1].trim(),\n message: match?.[2] ?? text ?? '\\u00D8',\n };\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { asyncTimeout } from '@dxos/async';\nimport type { ReactiveEchoObject } from '@dxos/echo-db';\nimport { getTypename } from '@dxos/echo-schema';\nimport { log } from '@dxos/log';\nimport { Filter, getSpace, ResultFormat } from '@dxos/react-client/echo';\n\n// TODO(burdon): Move into assistant-protocol.\nexport type ThreadContext = {\n subject?: ReactiveEchoObject<any>;\n};\n\nexport const createSystemInstructions = async (context: ThreadContext): Promise<string> => {\n let instructions = `\n <instructions>\n Before replying always think step-by-step on how to proceed.\n Print your thoughts inside <cot> tags.\n\n <example>\n <cot>To answer the question I need to ...</cot>\n </example>\n </instructions>\n\n <current_time>${new Date().toLocaleString()}</current_time>\n `;\n\n if (context.subject) {\n instructions += `\n <user_attention>\n The user is currently interacting with an object in Composer application:\n\n ${await formatContextObject(context.subject)}\n </user_attention>\n `;\n }\n\n return looseFormatXml(instructions);\n};\n\nconst formatContextObject = async (object: ReactiveEchoObject<any>): Promise<string> => {\n let data;\n try {\n data = await asyncTimeout(preprocessContextObject(object), CONTEXT_OBJECT_QUERY_TIMEOUT);\n } catch (err: any) {\n log.error('Failed to preprocess context object:', { err });\n data = object;\n }\n\n if (typeof data === 'string') {\n return data;\n } else {\n return `\n <object>\n <type>${getTypename(object)}</type>\n <id>${object.id}</id>\n ${formatObjectAsXMLTags(data)}\n </object>\n `;\n }\n};\n\nconst preprocessContextObject = async (object: ReactiveEchoObject<any>): Promise<Record<string, any> | string> => {\n const space = getSpace(object);\n if (!space) {\n return { ...object };\n }\n\n // TODO(dmaretskyi): Serialize based on schema annotations.\n switch (getTypename(object)) {\n // TODO(dmaretskyi): Reference types somehow without plugin-automation depending on other plugins.\n case 'dxos.org/type/Document': {\n const data = space.db\n .query({ id: object.id }, { format: ResultFormat.Plain, include: { content: true } })\n .first() ?? { content: { content: '' } };\n\n return {\n ...data,\n threads: undefined,\n };\n }\n\n case 'dxos.org/type/Table': {\n // TODO(dmaretskyi): Load references.\n const schema = object.view ? space?.db.schemaRegistry.getSchema(object.view.query.type) : undefined;\n const { objects: rows } =\n (schema &&\n (await space.db\n .query(Filter.schema(schema), { format: ResultFormat.Plain, limit: TABLE_ROWS_LIMIT })\n .run())) ??\n {};\n\n // TODO(dmaretskyi): Format table schema.\n return `\n <object>\n <id>${object.id}</id>\n <type>${getTypename(object)}</type>\n ${formatObjectAsXMLTags(object)}\n\n <rows>\n <!-- Limited to first ${TABLE_ROWS_LIMIT} rows. -->\n ${rows\n ?.map(\n (row: any) => `<row>\n ${formatObjectAsXMLTags(row)}\n </row>`,\n )\n .join('\\n')}\n </rows>\n\n `;\n }\n\n default:\n return { ...object };\n }\n};\n\nconst formatObjectAsXMLTags = (object: any, depth = 1): string => {\n return Object.entries(object)\n .filter(([key, value]) => ['string', 'number', 'boolean', 'object'].includes(typeof value))\n .map(([key, value]) => {\n if (typeof value === 'object' && value !== null) {\n if (depth === 0) {\n return '';\n } else {\n return `<${key}>\n ${formatObjectAsXMLTags(value, depth - 1)}\n </${key}>`;\n }\n }\n\n return `<${key}>${value}</${key}>`;\n })\n .join('\\n');\n};\n\nconst CONTEXT_OBJECT_QUERY_TIMEOUT = 5_000;\n\nconst TABLE_ROWS_LIMIT = 10;\n\n/**\n * Formats XML indentation for instructions so they are easier to read during debugging.\n */\nconst looseFormatXml = (xml: string): string => {\n let currentIndent = 0;\n\n return xml\n .split('\\n')\n .map((line) => {\n if (line.match(RE_CLOSE_TAG_LINE)) {\n currentIndent--;\n }\n const indent = currentIndent;\n if (line.match(RE_OPEN_TAG_LINE)) {\n currentIndent++;\n }\n return ' '.repeat(indent * 2) + line.trimStart();\n })\n .join('\\n');\n};\n\nconst RE_OPEN_TAG_LINE = /^[ ]*<[a-zA-Z0-9\\-_]+>[ ]*$/;\nconst RE_CLOSE_TAG_LINE = /^[ ]*<\\/[a-zA-Z0-9\\-_]+>[ ]*$/;\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { AssistantPanel } from './AssistantPanel';\n\nexport default AssistantPanel;\n"],
5
+ "mappings": ";;;;;;AAMA,OAAOA,SAASC,WAAWC,QAAQC,gBAAgB;AAEnD,SAA+BC,qBAAqBC,gBAA8B;AAElF,SAASC,eAAe;AACxB,SAASC,WAAWC,iBAAiB;AACrC,SAASC,mBAAyC;AAClD,SAASC,MAAMC,OAAOC,SAASC,sBAAsB;AACrD,SAASC,yBAAyB;AAClC,SAASC,UAAU;;;ACXnB,SAASC,oBAAoB;AAE7B,SAASC,mBAAmB;AAC5B,SAASC,WAAW;AACpB,SAASC,QAAQC,UAAUC,oBAAoB;;AAOxC,IAAMC,2BAA2B,OAAOC,YAAAA;AAC7C,MAAIC,eAAe;;;;;;;;;;qBAUD,oBAAIC,KAAAA,GAAOC,eAAc,CAAA;;AAG3C,MAAIH,QAAQI,SAAS;AACnBH,oBAAgB;;;;UAIV,MAAMI,oBAAoBL,QAAQI,OAAO,CAAA;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AA,cAACpC,OAAAA;UAAIC,WAAU;WAAgDmC,GAAAA,GACvE,sBAAA,cAACpC,OAAAA;UAAIC,WAAU;WAA2BI,QAAAA,CAAAA;MAGhD;MAEA,KAAK,YAAY;AACf,eACE,sBAAA,cAACL,OAAAA;UAAIO,KAAK4B;UAAGlC,WAAWC,GAAGgC,gBAAgB,SAAA;WACzC,sBAAA,cAAClC,OAAAA,MACC,sBAAA,cAACsC,QAAAA;UAAKrC,WAAU;WAAmB,UAAA,GAAe,MAAGjB,SAAQuD,MAAK,KAAEvD,SAAQH,EAAE,GAEhF,sBAAA,cAAC2D,mBAAAA;UAAkBC,UAAS;WAAQzD,SAAQ0D,SAAS,CAAA;MAG3D;MAEA,KAAK,eAAe;AAClB,eACE,sBAAA,cAAC1C,OAAAA;UAAIO,KAAK4B;UAAGlC,WAAWC,GAAGgC,gBAAgB,WAAWlD,SAAQ2D,WAAW,YAAA;WACvE,sBAAA,cAAC3C,OAAAA,MACC,sBAAA,cAACsC,QAAAA;UAAKrC,WAAU;WAAmB,aAAA,GAAkB,MAAGjB,SAAQ4D,SAAS,GAE3E,sBAAA,cAACJ,mBAAAA;UAAkBC,UAAS;WAAQzD,SAAQA,OAAO,CAAA;MAGzD;IACF;AAEA,WAAO;EACT,CAAA,CAAA;AAGN;AAGA,IAAMqD,eAAe,CAACnD,SAAAA;AACpB,QAAM2D,QAAQ;AACd,QAAMC,QAAQ5D,KAAK4D,MAAMD,KAAAA;AACzB,SAAO;IACLT,KAAKU,QAAQ,CAAA,EAAGC,KAAAA;IAChB1C,SAASyC,QAAQ,CAAA,KAAM5D,QAAQ;EACjC;AACF;;;AE/NA,IAAA,yBAAe8D;",
6
6
  "names": ["React", "useEffect", "useRef", "useState", "AIServiceClientImpl", "ObjectId", "SpaceId", "useClient", "useConfig", "ContextMenu", "Icon", "Input", "Toolbar", "useTranslation", "SyntaxHighlighter", "mx", "asyncTimeout", "getTypename", "log", "Filter", "getSpace", "ResultFormat", "createSystemInstructions", "context", "instructions", "Date", "toLocaleString", "subject", "formatContextObject", "looseFormatXml", "object", "data", "preprocessContextObject", "CONTEXT_OBJECT_QUERY_TIMEOUT", "err", "error", "id", "formatObjectAsXMLTags", "space", "db", "query", "format", "Plain", "include", "content", "first", "threads", "undefined", "schema", "view", "schemaRegistry", "getSchema", "type", "objects", "rows", "limit", "TABLE_ROWS_LIMIT", "run", "map", "row", "join", "depth", "Object", "entries", "filter", "key", "value", "includes", "xml", "currentIndent", "split", "line", "match", "RE_CLOSE_TAG_LINE", "indent", "RE_OPEN_TAG_LINE", "repeat", "trimStart", "PROPERTIES_ASSISTANT_KEY", "AssistantPanel", "subject", "classNames", "t", "useTranslation", "AUTOMATION_PLUGIN", "config", "useConfig", "client", "useClient", "aiClient", "useRef", "contextSpaceId", "setContextSpaceId", "useState", "threadId", "setThreadId", "history", "setHistory", "input", "setInput", "useEffect", "current", "endpoint", "values", "runtime", "services", "ai", "server", "Error", "AIServiceClientImpl", "queueMicrotask", "properties", "spaces", "default", "SpaceId", "random", "ObjectId", "messages", "getMessagesInThread", "handleRequest", "userMessage", "id", "spaceId", "role", "content", "type", "text", "insertMessages", "generationStream", "generate", "model", "tools", "systemPrompt", "getSystemPrompt", "historyBefore", "_event", "accumulatedMessages", "complete", "createSystemInstructions", "clearThread", "div", "className", "mx", "length", "map", "message", "MessageItem", "key", "Toolbar", "Root", "Input", "TextInput", "autoFocus", "placeholder", "value", "onChange", "ev", "target", "onKeyDown", "ContextMenu", "Trigger", "asChild", "Button", "onClick", "Icon", "icon", "size", "Portal", "Content", "Viewport", "Item", "console", "log", "_", "styleContainer", "i", "cot", "parseMessage", "span", "name", "SyntaxHighlighter", "language", "inputJson", "isError", "toolUseId", "regex", "match", "trim", "AssistantPanel"]
7
7
  }
@@ -6,8 +6,7 @@ import {
6
6
  // packages/plugins/experimental/plugin-automation/src/components/AutomationPanel/AutomationPanel.tsx
7
7
  import React2, { useState } from "react";
8
8
  import { S } from "@dxos/echo-schema";
9
- import { FunctionTriggerSchema as FunctionTriggerSchema2, FunctionTrigger } from "@dxos/functions";
10
- import { FunctionType as FunctionType2, ScriptType as ScriptType2 } from "@dxos/plugin-script";
9
+ import { FunctionType as FunctionType2, FunctionTrigger, FunctionTriggerSchema as FunctionTriggerSchema2, TriggerKind as TriggerKind2, ScriptType as ScriptType2 } from "@dxos/functions";
11
10
  import { useClient } from "@dxos/react-client";
12
11
  import { create, Filter as Filter2, useQuery as useQuery2, getSpace } from "@dxos/react-client/echo";
13
12
  import { IconButton, Input, useTranslation as useTranslation2, Button } from "@dxos/react-ui";
@@ -16,8 +15,7 @@ import { ghostHover, mx } from "@dxos/react-ui-theme";
16
15
 
17
16
  // packages/plugins/experimental/plugin-automation/src/components/TriggerEditor/TriggerEditor.tsx
18
17
  import React from "react";
19
- import { FunctionTriggerSchema, TriggerKind } from "@dxos/functions";
20
- import { FunctionType, ScriptType } from "@dxos/plugin-script/types";
18
+ import { FunctionType, FunctionTriggerSchema, ScriptType, TriggerKind } from "@dxos/functions";
21
19
  import { Filter, useQuery } from "@dxos/react-client/echo";
22
20
  import { useTranslation } from "@dxos/react-ui";
23
21
  import { Form, SelectInput } from "@dxos/react-ui-form";
@@ -53,12 +51,12 @@ var TriggerEditor = ({ space, trigger, onSave, onCancel, storedTrigger }) => {
53
51
  });
54
52
  };
55
53
  var getFunctionName = (scripts, fn) => {
56
- return scripts.find((s) => fn.source?.id === s.id)?.name ?? fn.name;
54
+ return scripts.find((s) => fn.source?.target?.id === s.id)?.name ?? fn.name;
57
55
  };
58
56
 
59
57
  // packages/plugins/experimental/plugin-automation/src/components/AutomationPanel/AutomationPanel.tsx
60
58
  var grid = "grid grid-cols-[40px_1fr_32px] min-bs-[2.5rem]";
61
- var AutomationPanel = ({ space }) => {
59
+ var AutomationPanel = ({ space, object }) => {
62
60
  const { t } = useTranslation2(AUTOMATION_PLUGIN);
63
61
  const client = useClient();
64
62
  const triggers = useQuery2(space, Filter2.schema(FunctionTrigger));
@@ -84,7 +82,14 @@ var AutomationPanel = ({ space }) => {
84
82
  if (selected) {
85
83
  Object.assign(selected, trigger2);
86
84
  } else {
87
- space.db.add(create(FunctionTrigger, trigger2));
85
+ const automationTargetId = object?.id;
86
+ space.db.add(create(FunctionTrigger, automationTargetId ? {
87
+ ...trigger2,
88
+ meta: {
89
+ ...trigger2.meta,
90
+ automationTargetId
91
+ }
92
+ } : trigger2));
88
93
  }
89
94
  setTrigger(void 0);
90
95
  setSelected(void 0);
@@ -101,23 +106,26 @@ var AutomationPanel = ({ space }) => {
101
106
  }, ({ items: triggers2 }) => /* @__PURE__ */ React2.createElement("div", {
102
107
  role: "list",
103
108
  className: "flex flex-col w-full"
104
- }, triggers2?.map((trigger2) => /* @__PURE__ */ React2.createElement(List.Item, {
105
- key: trigger2.id,
106
- item: trigger2,
107
- classNames: mx(grid, ghostHover, "items-center")
108
- }, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.Switch, {
109
- checked: trigger2.enabled,
110
- onCheckedChange: (checked) => trigger2.enabled = checked
111
- })), /* @__PURE__ */ React2.createElement("div", {
112
- className: "flex"
113
- }, /* @__PURE__ */ React2.createElement(List.ItemTitle, {
114
- classNames: "px-2 cursor-pointer w-0 shrink",
115
- onClick: () => handleSelect(trigger2)
116
- }, getFunctionName2(scripts, functions, trigger2)), /* @__PURE__ */ React2.createElement(Button, {
117
- onClick: () => navigator.clipboard.writeText(getWebhookUrl(client, trigger2))
118
- }, "Copy URL")), /* @__PURE__ */ React2.createElement(List.ItemDeleteButton, {
119
- onClick: () => handleDelete(trigger2)
120
- }))))), trigger && /* @__PURE__ */ React2.createElement(TriggerEditor, {
109
+ }, triggers2?.map((trigger2) => {
110
+ const copyAction = getCopyAction(client, trigger2);
111
+ return /* @__PURE__ */ React2.createElement(List.Item, {
112
+ key: trigger2.id,
113
+ item: trigger2,
114
+ classNames: mx(grid, ghostHover, "items-center")
115
+ }, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.Switch, {
116
+ checked: trigger2.enabled,
117
+ onCheckedChange: (checked) => trigger2.enabled = checked
118
+ })), /* @__PURE__ */ React2.createElement("div", {
119
+ className: "flex"
120
+ }, /* @__PURE__ */ React2.createElement(List.ItemTitle, {
121
+ classNames: "px-2 cursor-pointer w-0 shrink",
122
+ onClick: () => handleSelect(trigger2)
123
+ }, getFunctionName2(scripts, functions, trigger2)), copyAction && /* @__PURE__ */ React2.createElement(Button, {
124
+ onClick: () => navigator.clipboard.writeText(copyAction.contentProvider())
125
+ }, copyAction.text)), /* @__PURE__ */ React2.createElement(List.ItemDeleteButton, {
126
+ onClick: () => handleDelete(trigger2)
127
+ }));
128
+ }))), trigger && /* @__PURE__ */ React2.createElement(TriggerEditor, {
121
129
  space,
122
130
  storedTrigger: selected,
123
131
  trigger,
@@ -131,6 +139,21 @@ var AutomationPanel = ({ space }) => {
131
139
  onClick: handleAdd
132
140
  })));
133
141
  };
142
+ var getCopyAction = (client, trigger) => {
143
+ if (trigger?.spec?.type === TriggerKind2.Email) {
144
+ return {
145
+ text: "Copy Email",
146
+ contentProvider: () => `${getSpace(trigger).id}@dxos.network`
147
+ };
148
+ }
149
+ if (trigger?.spec?.type === TriggerKind2.Webhook) {
150
+ return {
151
+ text: "Copy URL",
152
+ contentProvider: () => getWebhookUrl(client, trigger)
153
+ };
154
+ }
155
+ return void 0;
156
+ };
134
157
  var getWebhookUrl = (client, trigger) => {
135
158
  const spaceId = getSpace(trigger).id;
136
159
  const edgeUrl = new URL(client.config.values.runtime.services.edge.url);
@@ -143,7 +166,7 @@ var getFunctionName2 = (scripts, functions, trigger) => {
143
166
  if (!functionObject) {
144
167
  return trigger.function;
145
168
  }
146
- return scripts.find((s) => functionObject.source?.id === s.id)?.name ?? functionObject.name;
169
+ return scripts.find((s) => functionObject.source?.target?.id === s.id)?.name ?? functionObject.name;
147
170
  };
148
171
 
149
172
  // packages/plugins/experimental/plugin-automation/src/components/AutomationPanel/index.ts
@@ -151,4 +174,4 @@ var AutomationPanel_default = AutomationPanel;
151
174
  export {
152
175
  AutomationPanel_default as default
153
176
  };
154
- //# sourceMappingURL=AutomationPanel-JUHOWQWW.mjs.map
177
+ //# sourceMappingURL=AutomationPanel-72C2JRLV.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/AutomationPanel/AutomationPanel.tsx", "../../../src/components/TriggerEditor/TriggerEditor.tsx", "../../../src/components/AutomationPanel/index.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useState } from 'react';\n\nimport { S } from '@dxos/echo-schema';\nimport {\n FunctionType,\n FunctionTrigger,\n FunctionTriggerSchema,\n TriggerKind,\n type FunctionTriggerType,\n ScriptType,\n} from '@dxos/functions';\nimport { type Client, useClient } from '@dxos/react-client';\nimport { create, Filter, useQuery, type Space, type ReactiveObject, getSpace } from '@dxos/react-client/echo';\nimport { IconButton, Input, useTranslation, Button } from '@dxos/react-ui';\nimport { List } from '@dxos/react-ui-list';\nimport { ghostHover, mx } from '@dxos/react-ui-theme';\n\nimport { AUTOMATION_PLUGIN } from '../../meta';\nimport { TriggerEditor, type TriggerEditorProps } from '../TriggerEditor';\n\nconst grid = 'grid grid-cols-[40px_1fr_32px] min-bs-[2.5rem]';\n\nexport type AutomationPanelProps = {\n space: Space;\n object?: ReactiveObject<any>;\n};\n\n// TODO(burdon): Factor out common layout with ViewEditor.\nexport const AutomationPanel = ({ space, object }: AutomationPanelProps) => {\n const { t } = useTranslation(AUTOMATION_PLUGIN);\n const client = useClient();\n const triggers = useQuery(space, Filter.schema(FunctionTrigger));\n const functions = useQuery(space, Filter.schema(FunctionType));\n const scripts = useQuery(space, Filter.schema(ScriptType));\n\n const [trigger, setTrigger] = useState<FunctionTriggerType>();\n const [selected, setSelected] = useState<FunctionTrigger>();\n\n const handleSelect = (trigger: FunctionTrigger) => {\n const { id: _, ...values } = trigger;\n setTrigger(values);\n setSelected(trigger);\n };\n\n const handleAdd = () => {\n setTrigger(create(FunctionTriggerSchema, {}));\n setSelected(undefined);\n };\n\n const handleDelete = (trigger: FunctionTrigger) => {\n space.db.remove(trigger);\n setTrigger(undefined);\n setSelected(undefined);\n };\n\n const handleSave: TriggerEditorProps['onSave'] = (trigger) => {\n if (selected) {\n Object.assign(selected, trigger);\n } else {\n const automationTargetId = object?.id;\n space.db.add(\n create(\n FunctionTrigger,\n automationTargetId ? { ...trigger, meta: { ...trigger.meta, automationTargetId } } : trigger,\n ),\n );\n }\n\n setTrigger(undefined);\n setSelected(undefined);\n };\n\n const handleCancel: TriggerEditorProps['onCancel'] = () => {\n setTrigger(undefined);\n };\n\n return (\n <div className='flex flex-col w-full divide-y divide-separator overflow-y-auto'>\n <List.Root<FunctionTrigger> items={triggers} isItem={S.is(FunctionTrigger)} getId={(field) => field.id}>\n {({ items: triggers }) => (\n <div role='list' className='flex flex-col w-full'>\n {triggers?.map((trigger) => {\n const copyAction = getCopyAction(client, trigger);\n return (\n <List.Item<FunctionTrigger>\n key={trigger.id}\n item={trigger}\n classNames={mx(grid, ghostHover, 'items-center')}\n >\n <Input.Root>\n <Input.Switch\n checked={trigger.enabled}\n onCheckedChange={(checked) => (trigger.enabled = checked)}\n />\n </Input.Root>\n\n <div className={'flex'}>\n <List.ItemTitle classNames='px-2 cursor-pointer w-0 shrink' onClick={() => handleSelect(trigger)}>\n {getFunctionName(scripts, functions, trigger)}\n </List.ItemTitle>\n\n {/* TODO: a better way to expose URL copy action */}\n {copyAction && (\n <Button onClick={() => navigator.clipboard.writeText(copyAction.contentProvider())}>\n {copyAction.text}\n </Button>\n )}\n </div>\n\n <List.ItemDeleteButton onClick={() => handleDelete(trigger)} />\n </List.Item>\n );\n })}\n </div>\n )}\n </List.Root>\n\n {trigger && (\n <TriggerEditor\n space={space}\n storedTrigger={selected}\n trigger={trigger}\n onSave={handleSave}\n onCancel={handleCancel}\n />\n )}\n\n {!trigger && (\n <div className='flex p-2 justify-center'>\n <IconButton icon='ph--plus--regular' label={t('new trigger')} onClick={handleAdd} />\n </div>\n )}\n </div>\n );\n};\n\nconst getCopyAction = (client: Client, trigger: FunctionTrigger | undefined) => {\n if (trigger?.spec?.type === TriggerKind.Email) {\n return { text: 'Copy Email', contentProvider: () => `${getSpace(trigger)!.id}@dxos.network` };\n }\n\n if (trigger?.spec?.type === TriggerKind.Webhook) {\n return { text: 'Copy URL', contentProvider: () => getWebhookUrl(client, trigger) };\n }\n\n return undefined;\n};\n\nconst getWebhookUrl = (client: Client, trigger: FunctionTrigger) => {\n const spaceId = getSpace(trigger)!.id;\n const edgeUrl = new URL(client.config.values.runtime!.services!.edge!.url!);\n const isSecure = edgeUrl.protocol.startsWith('https') || edgeUrl.protocol.startsWith('wss');\n edgeUrl.protocol = isSecure ? 'https' : 'http';\n return new URL(`/webhook/${spaceId}:${trigger.id}`, edgeUrl).toString();\n};\n\nconst getFunctionName = (scripts: ScriptType[], functions: FunctionType[], trigger: FunctionTriggerType) => {\n const functionObject = functions.find((fn) => fn.name === trigger.function);\n if (!functionObject) {\n return trigger.function;\n }\n return scripts.find((s) => functionObject.source?.target?.id === s.id)?.name ?? functionObject.name;\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport {\n FunctionType,\n FunctionTriggerSchema,\n type FunctionTriggerType,\n type FunctionTrigger,\n ScriptType,\n TriggerKind,\n} from '@dxos/functions';\nimport { Filter, useQuery, type Space } from '@dxos/react-client/echo';\nimport { useTranslation } from '@dxos/react-ui';\nimport { Form, SelectInput } from '@dxos/react-ui-form';\n\nimport { AUTOMATION_PLUGIN } from '../../meta';\n\nexport type TriggerEditorProps = {\n space: Space;\n trigger: FunctionTriggerType;\n storedTrigger?: FunctionTrigger;\n onSave?: (trigger: Omit<FunctionTrigger, 'id'>) => void;\n onCancel?: () => void;\n};\n\nexport const TriggerEditor = ({ space, trigger, onSave, onCancel, storedTrigger }: TriggerEditorProps) => {\n const { t } = useTranslation(AUTOMATION_PLUGIN);\n const functions = useQuery(space, Filter.schema(FunctionType));\n const scripts = useQuery(space, Filter.schema(ScriptType));\n\n const handleSave = (values: FunctionTriggerType) => {\n onSave?.(values);\n };\n\n return (\n <Form<FunctionTriggerType>\n schema={FunctionTriggerSchema}\n values={trigger}\n filter={(props) => props.filter((p) => p.name !== 'meta')}\n onSave={handleSave}\n onCancel={onCancel}\n Custom={{\n ['function' satisfies keyof FunctionTriggerType]: (props) => (\n <SelectInput<FunctionTriggerType>\n {...props}\n options={functions.map((fn) => ({\n value: fn.name,\n label: getFunctionName(scripts, fn),\n }))}\n />\n ),\n ['spec.type' as const]: (props) => (\n <SelectInput<FunctionTriggerType>\n {...props}\n options={Object.values(TriggerKind).map((kind) => ({\n value: kind,\n label: t(`trigger type ${kind}`),\n }))}\n />\n ),\n }}\n />\n );\n};\n\nconst getFunctionName = (scripts: ScriptType[], fn: FunctionType) => {\n return scripts.find((s) => fn.source?.target?.id === s.id)?.name ?? fn.name;\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { AutomationPanel } from './AutomationPanel';\n\nexport default AutomationPanel;\n"],
5
+ "mappings": ";;;;;;AAIA,OAAOA,UAASC,gBAAgB;AAEhC,SAASC,SAAS;AAClB,SACEC,gBAAAA,eACAC,iBACAC,yBAAAA,wBACAC,eAAAA,cAEAC,cAAAA,mBACK;AACP,SAAsBC,iBAAiB;AACvC,SAASC,QAAQC,UAAAA,SAAQC,YAAAA,WAA2CC,gBAAgB;AACpF,SAASC,YAAYC,OAAOC,kBAAAA,iBAAgBC,cAAc;AAC1D,SAASC,YAAY;AACrB,SAASC,YAAYC,UAAU;;;ACf/B,OAAOC,WAAW;AAElB,SACEC,cACAC,uBAGAC,YACAC,mBACK;AACP,SAASC,QAAQC,gBAA4B;AAC7C,SAASC,sBAAsB;AAC/B,SAASC,MAAMC,mBAAmB;AAY3B,IAAMC,gBAAgB,CAAC,EAAEC,OAAOC,SAASC,QAAQC,UAAUC,cAAa,MAAsB;AACnG,QAAM,EAAE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AASC,aAAYG,SAAS;AAC/C,WAAO;MAAEd,MAAM;MAAYD,iBAAiB,MAAMgB,cAAcnF,QAAQW,OAAAA;IAAS;EACnF;AAEA,SAAOY;AACT;AAEA,IAAM4D,gBAAgB,CAACnF,QAAgBW,YAAAA;AACrC,QAAMyE,UAAUH,SAAStE,OAAAA,EAAUM;AACnC,QAAMoE,UAAU,IAAIC,IAAItF,OAAOuF,OAAOpE,OAAOqE,QAASC,SAAUC,KAAMC,GAAG;AACzE,QAAMC,WAAWP,QAAQQ,SAASC,WAAW,OAAA,KAAYT,QAAQQ,SAASC,WAAW,KAAA;AACrFT,UAAQQ,WAAWD,WAAW,UAAU;AACxC,SAAO,IAAIN,IAAI,YAAYF,OAAAA,IAAWzE,QAAQM,EAAE,IAAIoE,OAAAA,EAASU,SAAQ;AACvE;AAEA,IAAMjC,mBAAkB,CAACrD,SAAuBF,WAA2BI,YAAAA;AACzE,QAAMqF,iBAAiBzF,UAAU0F,KAAK,CAACC,OAAOA,GAAGC,SAASxF,QAAQyF,QAAQ;AAC1E,MAAI,CAACJ,gBAAgB;AACnB,WAAOrF,QAAQyF;EACjB;AACA,SAAO3F,QAAQwF,KAAK,CAACI,MAAML,eAAeM,QAAQC,QAAQtF,OAAOoF,EAAEpF,EAAE,GAAGkF,QAAQH,eAAeG;AACjG;;;AEhKA,IAAA,0BAAeK;",
6
+ "names": ["React", "useState", "S", "FunctionType", "FunctionTrigger", "FunctionTriggerSchema", "TriggerKind", "ScriptType", "useClient", "create", "Filter", "useQuery", "getSpace", "IconButton", "Input", "useTranslation", "Button", "List", "ghostHover", "mx", "React", "FunctionType", "FunctionTriggerSchema", "ScriptType", "TriggerKind", "Filter", "useQuery", "useTranslation", "Form", "SelectInput", "TriggerEditor", "space", "trigger", "onSave", "onCancel", "storedTrigger", "t", "useTranslation", "AUTOMATION_PLUGIN", "functions", "useQuery", "Filter", "schema", "FunctionType", "scripts", "ScriptType", "handleSave", "values", "Form", "FunctionTriggerSchema", "filter", "props", "p", "name", "Custom", "SelectInput", "options", "map", "fn", "value", "label", "getFunctionName", "Object", "TriggerKind", "kind", "find", "s", "source", "target", "id", "grid", "AutomationPanel", "space", "object", "t", "useTranslation", "AUTOMATION_PLUGIN", "client", "useClient", "triggers", "useQuery", "Filter", "schema", "FunctionTrigger", "functions", "FunctionType", "scripts", "ScriptType", "trigger", "setTrigger", "useState", "selected", "setSelected", "handleSelect", "id", "_", "values", "handleAdd", "create", "FunctionTriggerSchema", "undefined", "handleDelete", "db", "remove", "handleSave", "Object", "assign", "automationTargetId", "add", "meta", "handleCancel", "React", "div", "className", "List", "Root", "items", "isItem", "S", "is", "getId", "field", "role", "map", "copyAction", "getCopyAction", "Item", "key", "item", "classNames", "mx", "ghostHover", "Input", "Switch", "checked", "enabled", "onCheckedChange", "ItemTitle", "onClick", "getFunctionName", "Button", "navigator", "clipboard", "writeText", "contentProvider", "text", "ItemDeleteButton", "TriggerEditor", "storedTrigger", "onSave", "onCancel", "IconButton", "icon", "label", "spec", "type", "TriggerKind", "Email", "getSpace", "Webhook", "getWebhookUrl", "spaceId", "edgeUrl", "URL", "config", "runtime", "services", "edge", "url", "isSecure", "protocol", "startsWith", "toString", "functionObject", "find", "fn", "name", "function", "s", "source", "target", "AutomationPanel"]
7
+ }
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
 
3
3
  // packages/plugins/experimental/plugin-automation/src/types/schema.ts
4
- import { ref, S, TypedObject } from "@dxos/echo-schema";
4
+ import { Ref, S, TypedObject } from "@dxos/echo-schema";
5
5
  var ChainInputType;
6
6
  (function(ChainInputType2) {
7
7
  ChainInputType2[ChainInputType2["VALUE"] = 0] = "VALUE";
@@ -32,7 +32,7 @@ var ChainType = class extends TypedObject({
32
32
  version: "0.1.0"
33
33
  })({
34
34
  name: S.optional(S.String),
35
- prompts: S.optional(S.mutable(S.Array(ref(ChainPromptType))))
35
+ prompts: S.optional(S.mutable(S.Array(Ref(ChainPromptType))))
36
36
  }) {
37
37
  };
38
38
 
@@ -48,4 +48,4 @@ export {
48
48
  ChainType,
49
49
  AutomationAction
50
50
  };
51
- //# sourceMappingURL=chunk-23LY7DYS.mjs.map
51
+ //# sourceMappingURL=chunk-GCHXTXVT.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/types/schema.ts", "../../../src/types/types.ts"],
4
- "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { ref, S, TypedObject } from '@dxos/echo-schema';\n\n// TODO(burdon): Change to S.Literal (and discriminated union).\nexport enum ChainInputType {\n VALUE = 0,\n PASS_THROUGH = 1,\n RETRIEVER = 2,\n FUNCTION = 3,\n QUERY = 4,\n RESOLVER = 5,\n CONTEXT = 6,\n SCHEMA = 7,\n}\n\nexport const ChainInputSchema = S.mutable(\n S.Struct({\n name: S.String,\n type: S.optional(S.Enums(ChainInputType)),\n value: S.optional(S.String),\n }),\n);\n\nexport type ChainInput = S.Schema.Type<typeof ChainInputSchema>;\n\nexport class ChainPromptType extends TypedObject({ typename: 'dxos.org/type/ChainPrompt', version: '0.1.0' })({\n command: S.optional(S.String),\n template: S.String,\n inputs: S.optional(S.mutable(S.Array(ChainInputSchema))),\n}) {}\n\nexport class ChainType extends TypedObject({ typename: 'dxos.org/type/Chain', version: '0.1.0' })({\n name: S.optional(S.String),\n prompts: S.optional(S.mutable(S.Array(ref(ChainPromptType)))),\n}) {}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport type {\n GraphBuilderProvides,\n IntentResolverProvides,\n MetadataRecordsProvides,\n SurfaceProvides,\n TranslationsProvides,\n} from '@dxos/app-framework';\nimport { type PanelProvides } from '@dxos/plugin-deck/types';\nimport { type SchemaProvides } from '@dxos/plugin-space';\n\n// import { AUTOMATION_PLUGIN } from '../meta';\n\n// const AUTOMATION_ACTION = `${AUTOMATION_PLUGIN}/action`;\n\nexport enum AutomationAction {}\n\nexport type AutomationPluginProvides = SurfaceProvides &\n IntentResolverProvides &\n MetadataRecordsProvides &\n TranslationsProvides &\n GraphBuilderProvides &\n SchemaProvides &\n PanelProvides;\n"],
4
+ "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { Ref, S, TypedObject } from '@dxos/echo-schema';\n\n// TODO(burdon): Change to S.Literal (and discriminated union).\nexport enum ChainInputType {\n VALUE = 0,\n PASS_THROUGH = 1,\n RETRIEVER = 2,\n FUNCTION = 3,\n QUERY = 4,\n RESOLVER = 5,\n CONTEXT = 6,\n SCHEMA = 7,\n}\n\nexport const ChainInputSchema = S.mutable(\n S.Struct({\n name: S.String,\n type: S.optional(S.Enums(ChainInputType)),\n value: S.optional(S.String),\n }),\n);\n\nexport type ChainInput = S.Schema.Type<typeof ChainInputSchema>;\n\nexport class ChainPromptType extends TypedObject({ typename: 'dxos.org/type/ChainPrompt', version: '0.1.0' })({\n command: S.optional(S.String),\n template: S.String,\n inputs: S.optional(S.mutable(S.Array(ChainInputSchema))),\n}) {}\n\nexport class ChainType extends TypedObject({ typename: 'dxos.org/type/Chain', version: '0.1.0' })({\n name: S.optional(S.String),\n prompts: S.optional(S.mutable(S.Array(Ref(ChainPromptType)))),\n}) {}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport type {\n GraphBuilderProvides,\n IntentResolverProvides,\n MetadataRecordsProvides,\n SurfaceProvides,\n TranslationsProvides,\n} from '@dxos/app-framework';\nimport { type PanelProvides } from '@dxos/plugin-deck/types';\nimport { type SchemaProvides } from '@dxos/plugin-space';\n\n// import { AUTOMATION_PLUGIN } from '../meta';\n\n// const AUTOMATION_ACTION = `${AUTOMATION_PLUGIN}/action`;\n\nexport enum AutomationAction {}\n\nexport type AutomationPluginProvides = SurfaceProvides &\n IntentResolverProvides &\n MetadataRecordsProvides &\n TranslationsProvides &\n GraphBuilderProvides &\n SchemaProvides &\n PanelProvides;\n"],
5
5
  "mappings": ";;;AAIA,SAASA,KAAKC,GAAGC,mBAAmB;;UAGxBC,iBAAAA;;;;;;;;;GAAAA,mBAAAA,iBAAAA,CAAAA,EAAAA;AAWL,IAAMC,mBAAmBC,EAAEC,QAChCD,EAAEE,OAAO;EACPC,MAAMH,EAAEI;EACRC,MAAML,EAAEM,SAASN,EAAEO,MAAMT,cAAAA,CAAAA;EACzBU,OAAOR,EAAEM,SAASN,EAAEI,MAAM;AAC5B,CAAA,CAAA;AAKK,IAAMK,kBAAN,cAA8BC,YAAY;EAAEC,UAAU;EAA6BC,SAAS;AAAQ,CAAA,EAAG;EAC5GC,SAASb,EAAEM,SAASN,EAAEI,MAAM;EAC5BU,UAAUd,EAAEI;EACZW,QAAQf,EAAEM,SAASN,EAAEC,QAAQD,EAAEgB,MAAMjB,gBAAAA,CAAAA,CAAAA;AACvC,CAAA,EAAA;AAAI;AAEG,IAAMkB,YAAN,cAAwBP,YAAY;EAAEC,UAAU;EAAuBC,SAAS;AAAQ,CAAA,EAAG;EAChGT,MAAMH,EAAEM,SAASN,EAAEI,MAAM;EACzBc,SAASlB,EAAEM,SAASN,EAAEC,QAAQD,EAAEgB,MAAMG,IAAIV,eAAAA,CAAAA,CAAAA,CAAAA;AAC5C,CAAA,EAAA;AAAI;;;;0BCnBQW,mBAAAA;AAAAA,GAAAA,qBAAAA,mBAAAA,CAAAA,EAAAA;",
6
- "names": ["ref", "S", "TypedObject", "ChainInputType", "ChainInputSchema", "S", "mutable", "Struct", "name", "String", "type", "optional", "Enums", "value", "ChainPromptType", "TypedObject", "typename", "version", "command", "template", "inputs", "Array", "ChainType", "prompts", "ref", "AutomationAction"]
6
+ "names": ["Ref", "S", "TypedObject", "ChainInputType", "ChainInputSchema", "S", "mutable", "Struct", "name", "String", "type", "optional", "Enums", "value", "ChainPromptType", "TypedObject", "typename", "version", "command", "template", "inputs", "Array", "ChainType", "prompts", "Ref", "AutomationAction"]
7
7
  }