@dxos/plugin-assistant 0.8.4-main.5acf9ea → 0.8.4-main.66e292d
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/browser/BlueprintArticle-BWSLH6LG.mjs +36 -0
- package/dist/lib/browser/BlueprintArticle-BWSLH6LG.mjs.map +7 -0
- package/dist/lib/browser/ChatCompanion-OSZZZSWV.mjs +158 -0
- package/dist/lib/browser/ChatCompanion-OSZZZSWV.mjs.map +7 -0
- package/dist/lib/browser/ChatContainer-2W6FNSJD.mjs +77 -0
- package/dist/lib/browser/ChatContainer-2W6FNSJD.mjs.map +7 -0
- package/dist/lib/browser/{ChatDialog-ZVLXFHEY.mjs → ChatDialog-XQ3KDYWE.mjs} +30 -12
- package/dist/lib/browser/ChatDialog-XQ3KDYWE.mjs.map +7 -0
- package/dist/lib/browser/PromptArticle-Q7JYGFQV.mjs +59 -0
- package/dist/lib/browser/PromptArticle-Q7JYGFQV.mjs.map +7 -0
- package/dist/lib/browser/ai-service-ERTZBTP3.mjs +19 -0
- package/dist/lib/browser/ai-service-ERTZBTP3.mjs.map +7 -0
- package/dist/lib/browser/app-graph-builder-LM6GVHQO.mjs +199 -0
- package/dist/lib/browser/app-graph-builder-LM6GVHQO.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-VBEOXNBS.mjs +12 -0
- package/dist/lib/browser/blueprint-definition-VBEOXNBS.mjs.map +7 -0
- package/dist/lib/browser/chunk-2BOE3OTW.mjs +262 -0
- package/dist/lib/browser/chunk-2BOE3OTW.mjs.map +7 -0
- package/dist/lib/browser/chunk-5JZRYQZL.mjs +229 -0
- package/dist/lib/browser/chunk-5JZRYQZL.mjs.map +7 -0
- package/dist/lib/browser/chunk-7ZJIXQ2Y.mjs +335 -0
- package/dist/lib/browser/chunk-7ZJIXQ2Y.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/browser/chunk-LRE4VEZV.mjs +16 -0
- package/dist/lib/browser/chunk-LRE4VEZV.mjs.map +7 -0
- package/dist/lib/browser/chunk-NC2QNMBF.mjs +176 -0
- package/dist/lib/browser/chunk-NC2QNMBF.mjs.map +7 -0
- package/dist/lib/browser/chunk-PWSTPQUY.mjs +1929 -0
- package/dist/lib/browser/chunk-PWSTPQUY.mjs.map +7 -0
- package/dist/lib/browser/chunk-WBG5PTSX.mjs +23 -0
- package/dist/lib/browser/chunk-WBG5PTSX.mjs.map +7 -0
- package/dist/lib/browser/edge-model-resolver-O6OFYIO2.mjs +18 -0
- package/dist/lib/browser/edge-model-resolver-O6OFYIO2.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +221 -107
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-resolver-EEYS2GJF.mjs +143 -0
- package/dist/lib/browser/intent-resolver-EEYS2GJF.mjs.map +7 -0
- package/dist/lib/browser/local-model-resolver-34MVHRKD.mjs +17 -0
- package/dist/lib/browser/local-model-resolver-34MVHRKD.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-ECKZNDSU.mjs +98 -0
- package/dist/lib/browser/react-surface-ECKZNDSU.mjs.map +7 -0
- package/dist/lib/browser/repair-3MZXLUHO.mjs +44 -0
- package/dist/lib/browser/repair-3MZXLUHO.mjs.map +7 -0
- package/dist/lib/browser/{settings-5GTTCVGD.mjs → settings-HD5WA24I.mjs} +8 -7
- package/dist/lib/{node-esm/settings-J2EXEM5H.mjs.map → browser/settings-HD5WA24I.mjs.map} +1 -1
- package/dist/lib/browser/state-GG7Z3NB7.mjs +25 -0
- package/dist/lib/browser/state-GG7Z3NB7.mjs.map +7 -0
- package/dist/lib/browser/toolkit-VYDAWNE4.mjs +17 -0
- package/dist/lib/browser/toolkit-VYDAWNE4.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +7 -4
- package/dist/lib/node-esm/BlueprintArticle-R2XYBRCK.mjs +37 -0
- package/dist/lib/node-esm/BlueprintArticle-R2XYBRCK.mjs.map +7 -0
- package/dist/lib/node-esm/ChatCompanion-IUMU7WRQ.mjs +159 -0
- package/dist/lib/node-esm/ChatCompanion-IUMU7WRQ.mjs.map +7 -0
- package/dist/lib/node-esm/{ChatContainer-W3W6FWV3.mjs → ChatContainer-CTUNUEU3.mjs} +38 -15
- package/dist/lib/node-esm/ChatContainer-CTUNUEU3.mjs.map +7 -0
- package/dist/lib/node-esm/{ChatDialog-QW4JRKVO.mjs → ChatDialog-X42ASXQD.mjs} +30 -12
- package/dist/lib/node-esm/ChatDialog-X42ASXQD.mjs.map +7 -0
- package/dist/lib/node-esm/PromptArticle-IV7O5UZ3.mjs +60 -0
- package/dist/lib/node-esm/PromptArticle-IV7O5UZ3.mjs.map +7 -0
- package/dist/lib/node-esm/ai-service-MUYLV3NT.mjs +20 -0
- package/dist/lib/node-esm/ai-service-MUYLV3NT.mjs.map +7 -0
- package/dist/lib/node-esm/app-graph-builder-6XUAGTRS.mjs +200 -0
- package/dist/lib/node-esm/app-graph-builder-6XUAGTRS.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-RDCLLIQH.mjs +13 -0
- package/dist/lib/node-esm/blueprint-definition-RDCLLIQH.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-25GMMNY5.mjs +178 -0
- package/dist/lib/node-esm/chunk-25GMMNY5.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-3Q22TTXW.mjs +264 -0
- package/dist/lib/node-esm/chunk-3Q22TTXW.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-CKW4IYLY.mjs +336 -0
- package/dist/lib/node-esm/chunk-CKW4IYLY.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-E4JSYCWZ.mjs +230 -0
- package/dist/lib/node-esm/chunk-E4JSYCWZ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-WE6KTH72.mjs +25 -0
- package/dist/lib/node-esm/chunk-WE6KTH72.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-YWFWT57N.mjs +17 -0
- package/dist/lib/node-esm/chunk-YWFWT57N.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-Z37USO4K.mjs +1930 -0
- package/dist/lib/node-esm/chunk-Z37USO4K.mjs.map +7 -0
- package/dist/lib/node-esm/edge-model-resolver-2ARXDOYS.mjs +19 -0
- package/dist/lib/node-esm/edge-model-resolver-2ARXDOYS.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +221 -107
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/intent-resolver-4SRYLDK5.mjs +144 -0
- package/dist/lib/node-esm/intent-resolver-4SRYLDK5.mjs.map +7 -0
- package/dist/lib/node-esm/local-model-resolver-TP2NTSAX.mjs +18 -0
- package/dist/lib/node-esm/local-model-resolver-TP2NTSAX.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-surface-NLIG5VAI.mjs +99 -0
- package/dist/lib/node-esm/react-surface-NLIG5VAI.mjs.map +7 -0
- package/dist/lib/node-esm/repair-RER5H7Y6.mjs +45 -0
- package/dist/lib/node-esm/repair-RER5H7Y6.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-J2EXEM5H.mjs → settings-YJQVKHH5.mjs} +8 -7
- package/dist/lib/{browser/settings-5GTTCVGD.mjs.map → node-esm/settings-YJQVKHH5.mjs.map} +1 -1
- package/dist/lib/node-esm/state-FSUHFMDM.mjs +26 -0
- package/dist/lib/node-esm/state-FSUHFMDM.mjs.map +7 -0
- package/dist/lib/node-esm/toolkit-HFJZLVIR.mjs +18 -0
- package/dist/lib/node-esm/toolkit-HFJZLVIR.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +7 -4
- package/dist/types/src/AssistantPlugin.d.ts +1 -1
- package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/ai-service.d.ts +4 -0
- package/dist/types/src/capabilities/ai-service.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +7 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/capabilities.d.ts +10 -0
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
- package/dist/types/src/capabilities/edge-model-resolver.d.ts +4 -0
- package/dist/types/src/capabilities/edge-model-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +12 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/local-model-resolver.d.ts +10 -0
- package/dist/types/src/capabilities/local-model-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/repair.d.ts +4 -0
- package/dist/types/src/capabilities/repair.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings.d.ts +1 -1
- package/dist/types/src/capabilities/state.d.ts +4 -0
- package/dist/types/src/capabilities/state.d.ts.map +1 -0
- package/dist/types/src/capabilities/toolkit.d.ts +4 -0
- package/dist/types/src/capabilities/toolkit.d.ts.map +1 -0
- package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +1 -1
- package/dist/types/src/components/BlueprintArticle.d.ts +7 -0
- package/dist/types/src/components/BlueprintArticle.d.ts.map +1 -0
- package/dist/types/src/components/Chat/Chat.d.ts +35 -21
- package/dist/types/src/components/Chat/Chat.d.ts.map +1 -1
- package/dist/types/src/components/Chat/events.d.ts +9 -0
- package/dist/types/src/components/Chat/events.d.ts.map +1 -1
- package/dist/types/src/components/ChatCompanion.d.ts +13 -0
- package/dist/types/src/components/ChatCompanion.d.ts.map +1 -0
- package/dist/types/src/components/ChatContainer.d.ts +9 -6
- package/dist/types/src/components/ChatContainer.d.ts.map +1 -1
- package/dist/types/src/components/ChatDialog.d.ts.map +1 -1
- package/dist/types/src/components/ChatProgress/ChatProgress.d.ts +7 -0
- package/dist/types/src/components/ChatProgress/ChatProgress.d.ts.map +1 -0
- package/dist/types/src/components/ChatProgress/index.d.ts +2 -0
- package/dist/types/src/components/ChatProgress/index.d.ts.map +1 -0
- package/dist/types/src/components/ChatPrompt/ChatActions.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts +20 -0
- package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts.map +1 -0
- package/dist/types/src/components/ChatPrompt/ChatPresets.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts +4 -5
- package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts +6 -4
- package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/index.d.ts +1 -1
- package/dist/types/src/components/ChatPrompt/index.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.d.ts +12 -10
- package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +196 -55
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/Link.d.ts +9 -0
- package/dist/types/src/components/ChatThread/Link.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/reducers.d.ts +40 -0
- package/dist/types/src/components/ChatThread/reducers.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/registry.d.ts +11 -0
- package/dist/types/src/components/ChatThread/registry.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/sync.d.ts +42 -0
- package/dist/types/src/components/ChatThread/sync.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/sync.test.d.ts +2 -0
- package/dist/types/src/components/ChatThread/sync.test.d.ts.map +1 -0
- package/dist/types/src/components/PromptArticle.d.ts +7 -0
- package/dist/types/src/components/PromptArticle.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +2 -6
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +317 -7
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +314 -2
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/extensions/handlebars-extension.d.ts +12 -0
- package/dist/types/src/components/TemplateEditor/extensions/handlebars-extension.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/extensions/index.d.ts +3 -0
- package/dist/types/src/components/TemplateEditor/extensions/index.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/extensions/xml-extension.d.ts +8 -0
- package/dist/types/src/components/TemplateEditor/extensions/xml-extension.d.ts.map +1 -0
- package/dist/types/src/components/ToolBlock/ToolBlock.d.ts +21 -0
- package/dist/types/src/components/ToolBlock/ToolBlock.d.ts.map +1 -0
- package/dist/types/src/components/ToolBlock/ToolBlockWidget.d.ts +2 -0
- package/dist/types/src/components/ToolBlock/ToolBlockWidget.d.ts.map +1 -0
- package/dist/types/src/components/ToolBlock/index.d.ts +3 -0
- package/dist/types/src/components/ToolBlock/index.d.ts.map +1 -0
- package/dist/types/src/components/Toolbox/Toolbox.d.ts +6 -11
- package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +318 -5
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +4 -6
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/events.d.ts +1 -1
- package/dist/types/src/events.d.ts.map +1 -1
- package/dist/types/src/functions/analysis.d.ts +5 -0
- package/dist/types/src/functions/analysis.d.ts.map +1 -0
- package/dist/types/src/functions/index.d.ts +4 -0
- package/dist/types/src/functions/index.d.ts.map +1 -0
- package/dist/types/src/functions/object-list.d.ts +10 -0
- package/dist/types/src/functions/object-list.d.ts.map +1 -0
- package/dist/types/src/functions/object-load.d.ts +8 -0
- package/dist/types/src/functions/object-load.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +8 -3
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useBlueprintRegistry.d.ts +25 -0
- package/dist/types/src/hooks/useBlueprintRegistry.d.ts.map +1 -0
- package/dist/types/src/hooks/useChatProcessor.d.ts +8 -19
- package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatServices.d.ts +5 -6
- package/dist/types/src/hooks/useChatServices.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatToolbarActions.d.ts +8 -0
- package/dist/types/src/hooks/useChatToolbarActions.d.ts.map +1 -0
- package/dist/types/src/hooks/useContextBinder.d.ts +4 -0
- package/dist/types/src/hooks/useContextBinder.d.ts.map +1 -0
- package/dist/types/src/hooks/useContextObjects.d.ts +15 -0
- package/dist/types/src/hooks/useContextObjects.d.ts.map +1 -0
- package/dist/types/src/hooks/useFilteredTypes.d.ts +4 -0
- package/dist/types/src/hooks/useFilteredTypes.d.ts.map +1 -0
- package/dist/types/src/hooks/useFlush.d.ts +6 -0
- package/dist/types/src/hooks/useFlush.d.ts.map +1 -0
- package/dist/types/src/hooks/useOnline.d.ts +3 -0
- package/dist/types/src/hooks/useOnline.d.ts.map +1 -0
- package/dist/types/src/hooks/usePresets.d.ts +7 -0
- package/dist/types/src/hooks/usePresets.d.ts.map +1 -0
- package/dist/types/src/hooks/useReferencesProvider.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +1 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/processor/index.d.ts +4 -0
- package/dist/types/src/processor/index.d.ts.map +1 -0
- package/dist/types/src/{hooks → processor}/presets.d.ts +3 -3
- package/dist/types/src/processor/presets.d.ts.map +1 -0
- package/dist/types/src/processor/processor.d.ts +74 -0
- package/dist/types/src/processor/processor.d.ts.map +1 -0
- package/dist/types/src/processor/processor.test.d.ts +2 -0
- package/dist/types/src/processor/processor.test.d.ts.map +1 -0
- package/dist/types/src/processor/update-name.d.ts +10 -0
- package/dist/types/src/processor/update-name.d.ts.map +1 -0
- package/dist/types/src/queue-logger.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +1 -1
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-generator.d.ts +7 -0
- package/dist/types/src/testing/test-generator.d.ts.map +1 -0
- package/dist/types/src/testing/test-sequence.d.ts +0 -4
- package/dist/types/src/testing/test-sequence.d.ts.map +1 -1
- package/dist/types/src/testing/test-services.d.ts +2 -2
- package/dist/types/src/testing/test-services.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +262 -28
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Assistant.d.ts +45 -0
- package/dist/types/src/types/Assistant.d.ts.map +1 -0
- package/dist/types/src/types/AssistantAction.d.ts +129 -0
- package/dist/types/src/types/AssistantAction.d.ts.map +1 -0
- package/dist/types/src/types/defs.d.ts +2 -0
- package/dist/types/src/types/defs.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +3 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/service.d.ts +135 -85
- package/dist/types/src/types/service.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +100 -97
- package/src/AssistantPlugin.tsx +151 -111
- package/src/capabilities/ai-service.ts +27 -0
- package/src/capabilities/app-graph-builder.ts +101 -60
- package/src/capabilities/blueprint-definition.ts +66 -0
- package/src/capabilities/capabilities.ts +17 -0
- package/src/capabilities/edge-model-resolver.ts +25 -0
- package/src/capabilities/index.ts +10 -0
- package/src/capabilities/intent-resolver.ts +89 -26
- package/src/capabilities/local-model-resolver.ts +30 -0
- package/src/capabilities/react-surface.tsx +24 -75
- package/src/capabilities/repair.ts +49 -0
- package/src/capabilities/state.ts +22 -0
- package/src/capabilities/toolkit.ts +17 -0
- package/src/components/AssistantSettings/AssistantSettings.tsx +83 -76
- package/src/components/BlueprintArticle.tsx +29 -0
- package/src/components/Chat/Chat.tsx +260 -217
- package/src/components/Chat/events.ts +13 -0
- package/src/components/ChatCompanion.tsx +155 -0
- package/src/components/ChatContainer.tsx +36 -20
- package/src/components/ChatDialog.tsx +25 -14
- package/src/components/ChatProgress/ChatProgress.tsx +67 -0
- package/src/components/{SequenceEditor → ChatProgress}/index.ts +1 -1
- package/src/components/ChatPrompt/ChatActions.tsx +10 -26
- package/src/components/ChatPrompt/ChatOptions.tsx +234 -0
- package/src/components/ChatPrompt/ChatPresets.tsx +1 -0
- package/src/components/ChatPrompt/ChatReferences.tsx +31 -36
- package/src/components/ChatPrompt/ChatStatusIndicator.tsx +25 -22
- package/src/components/ChatPrompt/index.ts +1 -1
- package/src/components/ChatThread/ChatThread.stories.tsx +120 -115
- package/src/components/ChatThread/ChatThread.tsx +65 -35
- package/src/components/ChatThread/Link.tsx +26 -0
- package/src/components/ChatThread/reducers.ts +151 -0
- package/src/components/ChatThread/registry.tsx +174 -0
- package/src/components/ChatThread/sync.test.ts +89 -0
- package/src/components/ChatThread/sync.ts +148 -0
- package/src/components/ChatThread/testing/thread.md +37 -0
- package/src/components/PromptArticle.tsx +51 -0
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +38 -17
- package/src/components/TemplateEditor/TemplateEditor.tsx +30 -54
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +16 -11
- package/src/components/TemplateEditor/TemplateForm.tsx +5 -3
- package/src/components/TemplateEditor/extensions/handlebars-extension.ts +269 -0
- package/src/components/TemplateEditor/extensions/index.ts +6 -0
- package/src/components/TemplateEditor/extensions/xml-extension.ts +64 -0
- package/src/components/ToolBlock/ToolBlock.tsx +143 -0
- package/src/components/ToolBlock/ToolBlockWidget.tsx +5 -0
- package/src/components/ToolBlock/index.ts +6 -0
- package/src/components/Toolbox/Toolbox.stories.tsx +14 -23
- package/src/components/Toolbox/Toolbox.tsx +25 -55
- package/src/components/index.ts +3 -7
- package/src/events.ts +2 -2
- package/src/functions/analysis.ts +22 -0
- package/src/functions/index.ts +7 -0
- package/src/functions/object-list.ts +48 -0
- package/src/functions/object-load.ts +45 -0
- package/src/hooks/index.ts +8 -4
- package/src/hooks/useBlueprintRegistry.ts +95 -0
- package/src/hooks/useChatProcessor.ts +35 -104
- package/src/hooks/useChatServices.ts +33 -49
- package/src/hooks/useChatToolbarActions.ts +122 -0
- package/src/hooks/useContextBinder.ts +30 -0
- package/src/hooks/useContextObjects.ts +58 -0
- package/src/hooks/useFilteredTypes.ts +38 -0
- package/src/hooks/useFlush.ts +35 -0
- package/src/hooks/useOnline.ts +10 -0
- package/src/hooks/usePresets.ts +44 -0
- package/src/hooks/useReferencesProvider.ts +13 -10
- package/src/index.ts +2 -0
- package/src/meta.ts +9 -6
- package/src/processor/index.ts +7 -0
- package/src/{hooks → processor}/presets.ts +16 -8
- package/src/processor/processor.test.ts +71 -0
- package/src/processor/processor.ts +277 -0
- package/src/processor/update-name.ts +56 -0
- package/src/queue-logger.ts +13 -17
- package/src/testing/index.ts +1 -1
- package/src/testing/test-generator.ts +261 -0
- package/src/testing/test-sequence.ts +2 -27
- package/src/testing/test-services.ts +2 -8
- package/src/translations.ts +49 -18
- package/src/types/Assistant.ts +63 -0
- package/src/types/AssistantAction.ts +79 -0
- package/src/types/defs.ts +5 -0
- package/src/types/index.ts +4 -1
- package/src/types/service.ts +17 -9
- package/src/vite-env.d.ts +30 -0
- package/dist/lib/browser/BlueprintContainer-IZ4AK5EO.mjs +0 -28
- package/dist/lib/browser/BlueprintContainer-IZ4AK5EO.mjs.map +0 -7
- package/dist/lib/browser/ChatContainer-RP3QEXYX.mjs +0 -54
- package/dist/lib/browser/ChatContainer-RP3QEXYX.mjs.map +0 -7
- package/dist/lib/browser/ChatDialog-ZVLXFHEY.mjs.map +0 -7
- package/dist/lib/browser/SequenceContainer-3UDVKWPA.mjs +0 -162
- package/dist/lib/browser/SequenceContainer-3UDVKWPA.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-XSEOKJLG.mjs +0 -164
- package/dist/lib/browser/app-graph-builder-XSEOKJLG.mjs.map +0 -7
- package/dist/lib/browser/chunk-63GG6U6D.mjs +0 -2226
- package/dist/lib/browser/chunk-63GG6U6D.mjs.map +0 -7
- package/dist/lib/browser/chunk-7W7LHTRH.mjs +0 -171
- package/dist/lib/browser/chunk-7W7LHTRH.mjs.map +0 -7
- package/dist/lib/browser/chunk-FDCJSQYF.mjs +0 -40
- package/dist/lib/browser/chunk-FDCJSQYF.mjs.map +0 -7
- package/dist/lib/browser/chunk-KFXSBNZR.mjs +0 -89
- package/dist/lib/browser/chunk-KFXSBNZR.mjs.map +0 -7
- package/dist/lib/browser/chunk-LERGF5YG.mjs +0 -108
- package/dist/lib/browser/chunk-LERGF5YG.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-MV3VSZLS.mjs +0 -75
- package/dist/lib/browser/intent-resolver-MV3VSZLS.mjs.map +0 -7
- package/dist/lib/browser/react-surface-3GYEHQRP.mjs +0 -150
- package/dist/lib/browser/react-surface-3GYEHQRP.mjs.map +0 -7
- package/dist/lib/node-esm/BlueprintContainer-RGTMNLNX.mjs +0 -29
- package/dist/lib/node-esm/BlueprintContainer-RGTMNLNX.mjs.map +0 -7
- package/dist/lib/node-esm/ChatContainer-W3W6FWV3.mjs.map +0 -7
- package/dist/lib/node-esm/ChatDialog-QW4JRKVO.mjs.map +0 -7
- package/dist/lib/node-esm/SequenceContainer-RQQH5XOC.mjs +0 -163
- package/dist/lib/node-esm/SequenceContainer-RQQH5XOC.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-PANCJUHV.mjs +0 -165
- package/dist/lib/node-esm/app-graph-builder-PANCJUHV.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BFO3KHYL.mjs +0 -2227
- package/dist/lib/node-esm/chunk-BFO3KHYL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MS3PJARN.mjs +0 -109
- package/dist/lib/node-esm/chunk-MS3PJARN.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-QN2H2EHV.mjs +0 -41
- package/dist/lib/node-esm/chunk-QN2H2EHV.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VIIMA3XQ.mjs +0 -90
- package/dist/lib/node-esm/chunk-VIIMA3XQ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-Z7PUODRT.mjs +0 -172
- package/dist/lib/node-esm/chunk-Z7PUODRT.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-3FMC3GHC.mjs +0 -76
- package/dist/lib/node-esm/intent-resolver-3FMC3GHC.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-QDQWJ7FZ.mjs +0 -151
- package/dist/lib/node-esm/react-surface-QDQWJ7FZ.mjs.map +0 -7
- package/dist/types/src/capability-definitions.d.ts +0 -7
- package/dist/types/src/capability-definitions.d.ts.map +0 -1
- package/dist/types/src/components/BlueprintContainer.d.ts +0 -8
- package/dist/types/src/components/BlueprintContainer.d.ts.map +0 -1
- package/dist/types/src/components/ChatPrompt/ChatOptionsMenu.d.ts +0 -9
- package/dist/types/src/components/ChatPrompt/ChatOptionsMenu.d.ts.map +0 -1
- package/dist/types/src/components/ChatThread/ChatMessage.d.ts +0 -17
- package/dist/types/src/components/ChatThread/ChatMessage.d.ts.map +0 -1
- package/dist/types/src/components/ChatThread/ToolBlock.d.ts +0 -19
- package/dist/types/src/components/ChatThread/ToolBlock.d.ts.map +0 -1
- package/dist/types/src/components/ChatThread/reducer.d.ts +0 -12
- package/dist/types/src/components/ChatThread/reducer.d.ts.map +0 -1
- package/dist/types/src/components/PromptSettings.d.ts +0 -6
- package/dist/types/src/components/PromptSettings.d.ts.map +0 -1
- package/dist/types/src/components/SequenceContainer.d.ts +0 -8
- package/dist/types/src/components/SequenceContainer.d.ts.map +0 -1
- package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts +0 -13
- package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts.map +0 -1
- package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts +0 -8
- package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts.map +0 -1
- package/dist/types/src/components/SequenceEditor/index.d.ts +0 -2
- package/dist/types/src/components/SequenceEditor/index.d.ts.map +0 -1
- package/dist/types/src/hooks/chat-processor.d.ts +0 -86
- package/dist/types/src/hooks/chat-processor.d.ts.map +0 -1
- package/dist/types/src/hooks/chat-processor.test.d.ts +0 -2
- package/dist/types/src/hooks/chat-processor.test.d.ts.map +0 -1
- package/dist/types/src/hooks/presets.d.ts.map +0 -1
- package/dist/types/src/hooks/useBlueprints.d.ts +0 -9
- package/dist/types/src/hooks/useBlueprints.d.ts.map +0 -1
- package/dist/types/src/parser/filter-generator.d.ts +0 -4
- package/dist/types/src/parser/filter-generator.d.ts.map +0 -1
- package/dist/types/src/parser/filter-generator.test.d.ts +0 -2
- package/dist/types/src/parser/filter-generator.test.d.ts.map +0 -1
- package/dist/types/src/parser/index.d.ts +0 -4
- package/dist/types/src/parser/index.d.ts.map +0 -1
- package/dist/types/src/parser/query-parser.d.ts +0 -15
- package/dist/types/src/parser/query-parser.d.ts.map +0 -1
- package/dist/types/src/parser/query-parser.test.d.ts +0 -2
- package/dist/types/src/parser/query-parser.test.d.ts.map +0 -1
- package/dist/types/src/parser/types.d.ts +0 -24
- package/dist/types/src/parser/types.d.ts.map +0 -1
- package/dist/types/src/stories/Chat.stories.d.ts +0 -207
- package/dist/types/src/stories/Chat.stories.d.ts.map +0 -1
- package/dist/types/src/testing/test-functions.d.ts +0 -3
- package/dist/types/src/testing/test-functions.d.ts.map +0 -1
- package/dist/types/src/tools/function.d.ts +0 -5
- package/dist/types/src/tools/function.d.ts.map +0 -1
- package/dist/types/src/tools/index.d.ts +0 -3
- package/dist/types/src/tools/index.d.ts.map +0 -1
- package/dist/types/src/tools/openapi.d.ts +0 -10
- package/dist/types/src/tools/openapi.d.ts.map +0 -1
- package/dist/types/src/tools/openapi.test.d.ts +0 -2
- package/dist/types/src/tools/openapi.test.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -120
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/src/capability-definitions.ts +0 -15
- package/src/components/BlueprintContainer.tsx +0 -24
- package/src/components/ChatPrompt/ChatOptionsMenu.tsx +0 -52
- package/src/components/ChatThread/ChatMessage.tsx +0 -268
- package/src/components/ChatThread/ToolBlock.tsx +0 -121
- package/src/components/ChatThread/reducer.ts +0 -52
- package/src/components/PromptSettings.tsx +0 -89
- package/src/components/SequenceContainer.tsx +0 -132
- package/src/components/SequenceEditor/SequenceEditor.stories.tsx +0 -32
- package/src/components/SequenceEditor/SequenceEditor.tsx +0 -50
- package/src/hooks/chat-processor.test.ts +0 -16
- package/src/hooks/chat-processor.ts +0 -314
- package/src/hooks/useBlueprints.ts +0 -57
- package/src/parser/filter-generator.test.ts +0 -32
- package/src/parser/filter-generator.ts +0 -81
- package/src/parser/index.ts +0 -7
- package/src/parser/query-parser.test.ts +0 -139
- package/src/parser/query-parser.ts +0 -199
- package/src/parser/types.ts +0 -34
- package/src/shims.d.ts +0 -8
- package/src/stories/Chat.stories.tsx +0 -371
- package/src/testing/test-functions.ts +0 -11
- package/src/tools/function.ts +0 -46
- package/src/tools/index.ts +0 -6
- package/src/tools/openapi.test.ts +0 -217
- package/src/tools/openapi.ts +0 -338
- package/src/types/schema.ts +0 -108
- package/src/typings.d.ts +0 -9
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { describe, test } from 'vitest';
|
|
6
|
-
|
|
7
|
-
import { Filter } from '@dxos/echo';
|
|
8
|
-
|
|
9
|
-
import { createFilter } from './filter-generator';
|
|
10
|
-
import { QueryParser } from './query-parser';
|
|
11
|
-
|
|
12
|
-
describe('FilterGenerator', () => {
|
|
13
|
-
test('simple queries', ({ expect }) => {
|
|
14
|
-
const parser = new QueryParser('type:example.com/type/Person');
|
|
15
|
-
const ast = parser.parse();
|
|
16
|
-
expect(ast).toEqual({
|
|
17
|
-
type: 'binary',
|
|
18
|
-
operator: 'EQ',
|
|
19
|
-
left: {
|
|
20
|
-
type: 'identifier',
|
|
21
|
-
name: 'type',
|
|
22
|
-
},
|
|
23
|
-
right: {
|
|
24
|
-
type: 'literal',
|
|
25
|
-
value: 'example.com/type/Person',
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const filter = createFilter(ast);
|
|
30
|
-
expect(filter).toEqual(Filter.typename('example.com/type/Person'));
|
|
31
|
-
});
|
|
32
|
-
});
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { Filter } from '@dxos/echo';
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
type BinaryExpression,
|
|
9
|
-
type Expression,
|
|
10
|
-
type Identifier,
|
|
11
|
-
type Literal,
|
|
12
|
-
type RelationalOperator,
|
|
13
|
-
type UnaryExpression,
|
|
14
|
-
} from './types';
|
|
15
|
-
|
|
16
|
-
const relationalOperators: Record<RelationalOperator, (value: any) => Filter<any>> = {
|
|
17
|
-
EQ: Filter.eq,
|
|
18
|
-
LT: Filter.lt,
|
|
19
|
-
GT: Filter.gt,
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const specialPredicates: Record<string, (value: string) => Filter<any>> = {
|
|
23
|
-
['type' as const]: Filter.typename,
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export const createFilter = (ast: Expression): Filter<any> => {
|
|
27
|
-
switch (ast.type) {
|
|
28
|
-
case 'binary': {
|
|
29
|
-
const { operator, left, right } = ast as BinaryExpression;
|
|
30
|
-
|
|
31
|
-
// Handle logical operators.
|
|
32
|
-
if (operator === 'AND') {
|
|
33
|
-
return Filter.and(createFilter(left), createFilter(right));
|
|
34
|
-
}
|
|
35
|
-
if (operator === 'OR') {
|
|
36
|
-
return Filter.or(createFilter(left), createFilter(right));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Handle special predicates (e.g., "type:Person")
|
|
40
|
-
const predicateName = (left as Identifier).name;
|
|
41
|
-
const specialFilter = specialPredicates[predicateName];
|
|
42
|
-
if (specialFilter) {
|
|
43
|
-
return specialFilter((right as Literal).value);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Handle relational operators
|
|
47
|
-
const filterFn = relationalOperators[operator as RelationalOperator];
|
|
48
|
-
if (filterFn) {
|
|
49
|
-
return filterFn((right as Literal).value);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
throw new Error(`Unsupported operator: ${operator}`);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
case 'unary': {
|
|
56
|
-
const { operator, argument } = ast as UnaryExpression;
|
|
57
|
-
if (operator === 'NOT') {
|
|
58
|
-
return Filter.not(createFilter(argument));
|
|
59
|
-
}
|
|
60
|
-
throw new Error(`Unsupported unary operator: ${operator}`);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
case 'identifier': {
|
|
64
|
-
const { name } = ast as Identifier;
|
|
65
|
-
return Filter._props({ [name]: true });
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
case 'literal': {
|
|
69
|
-
const { value } = ast as Literal;
|
|
70
|
-
// Handle special '*' value for empty input.
|
|
71
|
-
if (value === '*') {
|
|
72
|
-
return Filter.everything();
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return Filter.eq(value);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
default:
|
|
79
|
-
throw new Error(`Unsupported expression type: ${(ast as any).type}`);
|
|
80
|
-
}
|
|
81
|
-
};
|
package/src/parser/index.ts
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { describe, test } from 'vitest';
|
|
6
|
-
|
|
7
|
-
import { QueryParser } from './query-parser';
|
|
8
|
-
|
|
9
|
-
describe('QueryParser', () => {
|
|
10
|
-
test('empty', ({ expect }) => {
|
|
11
|
-
const parser = new QueryParser('');
|
|
12
|
-
expect(parser.parse()).toEqual({
|
|
13
|
-
type: 'literal',
|
|
14
|
-
value: '*',
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
test('invalid queries', ({ expect }) => {
|
|
19
|
-
const cases = [
|
|
20
|
-
//
|
|
21
|
-
'!',
|
|
22
|
-
'X:',
|
|
23
|
-
':Y',
|
|
24
|
-
'X;Y',
|
|
25
|
-
'x==100',
|
|
26
|
-
];
|
|
27
|
-
|
|
28
|
-
for (const query of cases) {
|
|
29
|
-
const parser = new QueryParser(query);
|
|
30
|
-
expect(() => parser.parse()).toThrow();
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
test('valid queries', ({ expect }) => {
|
|
35
|
-
const cases = [
|
|
36
|
-
//
|
|
37
|
-
'',
|
|
38
|
-
'type:Person',
|
|
39
|
-
'$title = "foo"',
|
|
40
|
-
'(type:Person OR type:Organization) AND $title = "DXOS" AND $ts < TODAY',
|
|
41
|
-
];
|
|
42
|
-
|
|
43
|
-
for (const query of cases) {
|
|
44
|
-
const parser = new QueryParser(query);
|
|
45
|
-
expect(parser.parse()).to.exist;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
test('simple queries', ({ expect }) => {
|
|
50
|
-
const cases = [
|
|
51
|
-
{
|
|
52
|
-
query: 'type:Person',
|
|
53
|
-
ast: {
|
|
54
|
-
type: 'binary',
|
|
55
|
-
operator: 'EQ',
|
|
56
|
-
left: { type: 'identifier', name: 'type' },
|
|
57
|
-
right: { type: 'literal', value: 'Person' },
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
query: '$title = "DXOS"',
|
|
62
|
-
ast: {
|
|
63
|
-
type: 'binary',
|
|
64
|
-
operator: 'EQ',
|
|
65
|
-
left: { type: 'identifier', name: '$title' },
|
|
66
|
-
right: { type: 'literal', value: 'DXOS' },
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
query: '(type:Person OR type:Organization) AND $title = "DXOS" AND $ts < TODAY',
|
|
71
|
-
ast: {
|
|
72
|
-
left: {
|
|
73
|
-
left: {
|
|
74
|
-
left: {
|
|
75
|
-
left: {
|
|
76
|
-
name: 'type',
|
|
77
|
-
type: 'identifier',
|
|
78
|
-
},
|
|
79
|
-
operator: 'EQ',
|
|
80
|
-
right: {
|
|
81
|
-
type: 'literal',
|
|
82
|
-
value: 'Person',
|
|
83
|
-
},
|
|
84
|
-
type: 'binary',
|
|
85
|
-
},
|
|
86
|
-
operator: 'OR',
|
|
87
|
-
right: {
|
|
88
|
-
left: {
|
|
89
|
-
name: 'type',
|
|
90
|
-
type: 'identifier',
|
|
91
|
-
},
|
|
92
|
-
operator: 'EQ',
|
|
93
|
-
right: {
|
|
94
|
-
type: 'literal',
|
|
95
|
-
value: 'Organization',
|
|
96
|
-
},
|
|
97
|
-
type: 'binary',
|
|
98
|
-
},
|
|
99
|
-
type: 'binary',
|
|
100
|
-
},
|
|
101
|
-
operator: 'AND',
|
|
102
|
-
right: {
|
|
103
|
-
left: {
|
|
104
|
-
name: '$title',
|
|
105
|
-
type: 'identifier',
|
|
106
|
-
},
|
|
107
|
-
operator: 'EQ',
|
|
108
|
-
right: {
|
|
109
|
-
type: 'literal',
|
|
110
|
-
value: 'DXOS',
|
|
111
|
-
},
|
|
112
|
-
type: 'binary',
|
|
113
|
-
},
|
|
114
|
-
type: 'binary',
|
|
115
|
-
},
|
|
116
|
-
operator: 'AND',
|
|
117
|
-
right: {
|
|
118
|
-
left: {
|
|
119
|
-
name: '$ts',
|
|
120
|
-
type: 'identifier',
|
|
121
|
-
},
|
|
122
|
-
operator: 'LT',
|
|
123
|
-
right: {
|
|
124
|
-
type: 'literal',
|
|
125
|
-
value: 'TODAY',
|
|
126
|
-
},
|
|
127
|
-
type: 'binary',
|
|
128
|
-
},
|
|
129
|
-
type: 'binary',
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
|
-
];
|
|
133
|
-
|
|
134
|
-
for (const { query, ast } of cases) {
|
|
135
|
-
const parser = new QueryParser(query);
|
|
136
|
-
expect(parser.parse()).toEqual(ast);
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
});
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { invariant } from '@dxos/invariant';
|
|
6
|
-
|
|
7
|
-
import { type Expression, type BinaryOperator, type RelationalOperator } from './types';
|
|
8
|
-
|
|
9
|
-
// TODO(burdon): Move to echo-schema?
|
|
10
|
-
|
|
11
|
-
type RelationalSymbol = '=' | '<' | '>';
|
|
12
|
-
|
|
13
|
-
const operators: Record<RelationalSymbol, RelationalOperator> = {
|
|
14
|
-
'=': 'EQ',
|
|
15
|
-
'<': 'LT',
|
|
16
|
-
'>': 'GT',
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export class QueryParser {
|
|
20
|
-
private tokens: string[] = [];
|
|
21
|
-
private current = 0;
|
|
22
|
-
|
|
23
|
-
constructor(input: string) {
|
|
24
|
-
// Tokenize the input string.
|
|
25
|
-
this.tokens = this.tokenize(input);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
private tokenize(input: string): string[] {
|
|
29
|
-
// Handle empty input.
|
|
30
|
-
if (!input.trim()) {
|
|
31
|
-
return [];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Split on spaces but preserve quoted strings.
|
|
35
|
-
const tokens: string[] = [];
|
|
36
|
-
let current = '';
|
|
37
|
-
let inQuotes = false;
|
|
38
|
-
|
|
39
|
-
for (let i = 0; i < input.length; i++) {
|
|
40
|
-
const char = input[i];
|
|
41
|
-
|
|
42
|
-
if (char === '"') {
|
|
43
|
-
// Handle quoted strings.
|
|
44
|
-
inQuotes = !inQuotes;
|
|
45
|
-
current += char;
|
|
46
|
-
} else if (char === '(' || char === ')') {
|
|
47
|
-
// If we have accumulated tokens, add them first.
|
|
48
|
-
if (current) {
|
|
49
|
-
tokens.push(current);
|
|
50
|
-
current = '';
|
|
51
|
-
}
|
|
52
|
-
// Add the parenthesis as a separate token.
|
|
53
|
-
tokens.push(char);
|
|
54
|
-
} else if (operators[char as RelationalSymbol]) {
|
|
55
|
-
// If we have accumulated tokens, add them first.
|
|
56
|
-
if (current) {
|
|
57
|
-
tokens.push(current);
|
|
58
|
-
current = '';
|
|
59
|
-
}
|
|
60
|
-
// Add the operator as a separate token.
|
|
61
|
-
tokens.push(operators[char as RelationalSymbol]);
|
|
62
|
-
} else if (char === ' ' && !inQuotes) {
|
|
63
|
-
if (current) {
|
|
64
|
-
tokens.push(current);
|
|
65
|
-
current = '';
|
|
66
|
-
}
|
|
67
|
-
} else {
|
|
68
|
-
current += char;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (current) {
|
|
73
|
-
tokens.push(current);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return tokens;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
private peek(): string {
|
|
80
|
-
return this.tokens[this.current];
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
private advance(): string {
|
|
84
|
-
return this.tokens[this.current++];
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
private match(type: string): boolean {
|
|
88
|
-
if (this.peek() === type) {
|
|
89
|
-
this.advance();
|
|
90
|
-
return true;
|
|
91
|
-
}
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
private isAtEnd(): boolean {
|
|
96
|
-
return this.current >= this.tokens.length;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
private parseExpression(): Expression {
|
|
100
|
-
let expr = this.parseTerm();
|
|
101
|
-
|
|
102
|
-
while (!this.isAtEnd()) {
|
|
103
|
-
const operator = this.peek();
|
|
104
|
-
if (operator === 'AND' || operator === 'OR') {
|
|
105
|
-
this.advance();
|
|
106
|
-
const right = this.parseTerm();
|
|
107
|
-
expr = {
|
|
108
|
-
type: 'binary',
|
|
109
|
-
operator: operator as BinaryOperator,
|
|
110
|
-
left: expr,
|
|
111
|
-
right,
|
|
112
|
-
};
|
|
113
|
-
} else {
|
|
114
|
-
break;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return expr;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
private parseTerm(): Expression {
|
|
122
|
-
// Handle NOT operator
|
|
123
|
-
if (this.peek() === 'NOT') {
|
|
124
|
-
this.advance();
|
|
125
|
-
const argument = this.parseTerm();
|
|
126
|
-
return {
|
|
127
|
-
type: 'unary',
|
|
128
|
-
operator: 'NOT',
|
|
129
|
-
argument,
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// Handle parentheses.
|
|
134
|
-
if (this.match('(')) {
|
|
135
|
-
const expr = this.parseExpression();
|
|
136
|
-
if (!this.match(')')) {
|
|
137
|
-
throw new Error('Expected closing parenthesis');
|
|
138
|
-
}
|
|
139
|
-
return expr;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const token = this.peek();
|
|
143
|
-
|
|
144
|
-
// Handle type:Person style expressions.
|
|
145
|
-
if (token.includes(':')) {
|
|
146
|
-
const [field, value] = token.split(':');
|
|
147
|
-
this.advance();
|
|
148
|
-
if (!field || !value) {
|
|
149
|
-
throw new Error(`Invalid type expression: ${token}`);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
return {
|
|
153
|
-
type: 'binary',
|
|
154
|
-
operator: 'EQ',
|
|
155
|
-
left: { type: 'identifier', name: field },
|
|
156
|
-
right: { type: 'literal', value },
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
// Handle $field expressions with operators.
|
|
161
|
-
if (token.startsWith('$')) {
|
|
162
|
-
const field = token;
|
|
163
|
-
this.advance();
|
|
164
|
-
|
|
165
|
-
// Get the operator.
|
|
166
|
-
const operator = this.peek();
|
|
167
|
-
if (operator !== 'EQ' && operator !== 'LT' && operator !== 'GT') {
|
|
168
|
-
throw new Error(`Expected operator after field ${field}, got ${operator}`);
|
|
169
|
-
}
|
|
170
|
-
this.advance();
|
|
171
|
-
|
|
172
|
-
// Get the value
|
|
173
|
-
const value = this.peek();
|
|
174
|
-
this.advance();
|
|
175
|
-
invariant(value);
|
|
176
|
-
|
|
177
|
-
return {
|
|
178
|
-
type: 'binary',
|
|
179
|
-
operator: operator as BinaryOperator,
|
|
180
|
-
left: { type: 'identifier', name: field },
|
|
181
|
-
right: { type: 'literal', value: value.replace(/^"|"$/g, '') },
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
throw new Error(`Unexpected token: ${token}`);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
public parse(): Expression {
|
|
189
|
-
// Return a special expression for empty input.
|
|
190
|
-
if (this.tokens.length === 0) {
|
|
191
|
-
return {
|
|
192
|
-
type: 'literal',
|
|
193
|
-
value: '*',
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
return this.parseExpression();
|
|
198
|
-
}
|
|
199
|
-
}
|
package/src/parser/types.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
export type UnaryOperator = 'NOT';
|
|
6
|
-
|
|
7
|
-
export type RelationalOperator = 'EQ' | 'LT' | 'GT';
|
|
8
|
-
|
|
9
|
-
export type BinaryOperator = RelationalOperator | 'AND' | 'OR';
|
|
10
|
-
|
|
11
|
-
export type Expression = BinaryExpression | UnaryExpression | Identifier | Literal;
|
|
12
|
-
|
|
13
|
-
export interface BinaryExpression {
|
|
14
|
-
type: 'binary';
|
|
15
|
-
operator: BinaryOperator;
|
|
16
|
-
left: Expression;
|
|
17
|
-
right: Expression;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface UnaryExpression {
|
|
21
|
-
type: 'unary';
|
|
22
|
-
operator: UnaryOperator;
|
|
23
|
-
argument: Expression;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface Identifier {
|
|
27
|
-
type: 'identifier';
|
|
28
|
-
name: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface Literal {
|
|
32
|
-
type: 'literal';
|
|
33
|
-
value: string;
|
|
34
|
-
}
|