@dxos/plugin-automation 0.7.5-labs.e27f9b9 → 0.7.5-labs.f400bbc
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/AutomationPanel-ITYXSN5Z.mjs +132 -0
- package/dist/lib/browser/AutomationPanel-ITYXSN5Z.mjs.map +7 -0
- package/dist/lib/browser/{chunk-HKX3D3ZP.mjs → chunk-OFDNNRLE.mjs} +4 -7
- package/dist/lib/browser/{chunk-HKX3D3ZP.mjs.map → chunk-OFDNNRLE.mjs.map} +3 -3
- package/dist/lib/browser/chunk-U7QLNY2S.mjs +8 -0
- package/dist/lib/browser/chunk-U7QLNY2S.mjs.map +7 -0
- package/dist/lib/browser/chunk-WY2C7JY4.mjs +119 -0
- package/dist/lib/browser/chunk-WY2C7JY4.mjs.map +7 -0
- package/dist/lib/browser/complementary-panel-4CPOJL4Y.mjs +56 -0
- package/dist/lib/browser/complementary-panel-4CPOJL4Y.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +22 -372
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-SAPMN4PF.mjs +27 -0
- package/dist/lib/browser/react-surface-SAPMN4PF.mjs.map +7 -0
- package/dist/lib/node/{chunk-WWU5FVAO.cjs → AutomationPanel-X33HHDMQ.cjs} +19 -131
- package/dist/lib/node/AutomationPanel-X33HHDMQ.cjs.map +7 -0
- package/dist/lib/node/chunk-7Q5SNGCL.cjs +148 -0
- package/dist/lib/node/chunk-7Q5SNGCL.cjs.map +7 -0
- package/dist/lib/node/chunk-CB5OB6JH.cjs +40 -0
- package/dist/lib/node/chunk-CB5OB6JH.cjs.map +7 -0
- package/dist/lib/node/{chunk-5VF5JKUN.cjs → chunk-ORMEYEBE.cjs} +7 -10
- package/dist/lib/node/{chunk-5VF5JKUN.cjs.map → chunk-ORMEYEBE.cjs.map} +3 -3
- package/dist/lib/node/complementary-panel-ZYJJ42ZU.cjs +72 -0
- package/dist/lib/node/complementary-panel-ZYJJ42ZU.cjs.map +7 -0
- package/dist/lib/node/index.cjs +37 -373
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{react-surface-5HYLBDC3.cjs → react-surface-2WRVAPGR.cjs} +9 -28
- package/dist/lib/node/react-surface-2WRVAPGR.cjs.map +7 -0
- package/dist/lib/node-esm/AutomationPanel-HY3GB4BT.mjs +133 -0
- package/dist/lib/node-esm/AutomationPanel-HY3GB4BT.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-X3LPRWIL.mjs → chunk-6MUUH67V.mjs} +4 -7
- package/dist/lib/node-esm/{chunk-X3LPRWIL.mjs.map → chunk-6MUUH67V.mjs.map} +3 -3
- package/dist/lib/node-esm/chunk-R3P2WPBQ.mjs +10 -0
- package/dist/lib/node-esm/chunk-R3P2WPBQ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-UDD2VA6G.mjs +120 -0
- package/dist/lib/node-esm/chunk-UDD2VA6G.mjs.map +7 -0
- package/dist/lib/node-esm/complementary-panel-S42RIIAY.mjs +57 -0
- package/dist/lib/node-esm/complementary-panel-S42RIIAY.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +22 -372
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-SS5WCRJ2.mjs → react-surface-QWLPOYXO.mjs} +5 -28
- package/dist/lib/node-esm/react-surface-QWLPOYXO.mjs.map +7 -0
- package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/{ai-client.d.ts → complementary-panel.d.ts} +2 -3
- package/dist/types/src/capabilities/complementary-panel.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +1 -180
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +1 -2
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts +1 -2
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -11
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +0 -1
- package/dist/types/src/meta.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/{testing.d.ts → test-functions.d.ts} +1 -3
- package/dist/types/src/testing/test-functions.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +2 -92
- package/dist/types/src/translations.d.ts.map +1 -1
- package/package.json +23 -71
- package/src/AutomationPlugin.tsx +9 -64
- package/src/capabilities/complementary-panel.ts +56 -0
- package/src/capabilities/index.ts +1 -5
- package/src/capabilities/react-surface.tsx +1 -13
- package/src/components/AutomationPanel/AutomationPanel.stories.tsx +1 -2
- package/src/components/AutomationPanel/AutomationPanel.tsx +56 -49
- package/src/components/TriggerEditor/TriggerEditor.stories.tsx +1 -2
- package/src/components/TriggerEditor/TriggerEditor.tsx +8 -5
- package/src/components/index.ts +0 -7
- package/src/index.ts +2 -3
- package/src/meta.ts +3 -3
- package/src/testing/index.ts +1 -1
- package/src/testing/{testing.ts → test-functions.ts} +0 -7
- package/src/translations.ts +2 -29
- package/dist/lib/browser/AutomationPanel-WFJZAW4F.mjs +0 -8
- package/dist/lib/browser/AutomationPanel-WFJZAW4F.mjs.map +0 -7
- package/dist/lib/browser/ChatContainer-OFCOZ5T2.mjs +0 -12
- package/dist/lib/browser/ChatContainer-OFCOZ5T2.mjs.map +0 -7
- package/dist/lib/browser/ai-client-AARXEMMJ.mjs +0 -22
- package/dist/lib/browser/ai-client-AARXEMMJ.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-B4U34VSR.mjs +0 -162
- package/dist/lib/browser/app-graph-builder-B4U34VSR.mjs.map +0 -7
- package/dist/lib/browser/chunk-5SLV6AUA.mjs +0 -1367
- package/dist/lib/browser/chunk-5SLV6AUA.mjs.map +0 -7
- package/dist/lib/browser/chunk-7XADMUOW.mjs +0 -205
- package/dist/lib/browser/chunk-7XADMUOW.mjs.map +0 -7
- package/dist/lib/browser/chunk-HZ4TA7HY.mjs +0 -15
- package/dist/lib/browser/chunk-HZ4TA7HY.mjs.map +0 -7
- package/dist/lib/browser/chunk-IYSMXX6Q.mjs +0 -283
- package/dist/lib/browser/chunk-IYSMXX6Q.mjs.map +0 -7
- package/dist/lib/browser/chunk-RAVNWHNE.mjs +0 -242
- package/dist/lib/browser/chunk-RAVNWHNE.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-754MPV7H.mjs +0 -29
- package/dist/lib/browser/intent-resolver-754MPV7H.mjs.map +0 -7
- package/dist/lib/browser/react-surface-4QZ6AKBF.mjs +0 -50
- package/dist/lib/browser/react-surface-4QZ6AKBF.mjs.map +0 -7
- package/dist/lib/browser/types/index.mjs +0 -24
- package/dist/lib/browser/types/index.mjs.map +0 -7
- package/dist/lib/node/AutomationPanel-LRDEDGXI.cjs +0 -26
- package/dist/lib/node/AutomationPanel-LRDEDGXI.cjs.map +0 -7
- package/dist/lib/node/ChatContainer-6LZX4K2Z.cjs +0 -33
- package/dist/lib/node/ChatContainer-6LZX4K2Z.cjs.map +0 -7
- package/dist/lib/node/ai-client-SA35GN5Q.cjs +0 -38
- package/dist/lib/node/ai-client-SA35GN5Q.cjs.map +0 -7
- package/dist/lib/node/app-graph-builder-ENVDOPS4.cjs +0 -178
- package/dist/lib/node/app-graph-builder-ENVDOPS4.cjs.map +0 -7
- package/dist/lib/node/chunk-6VMSH4P6.cjs +0 -1364
- package/dist/lib/node/chunk-6VMSH4P6.cjs.map +0 -7
- package/dist/lib/node/chunk-HEYQONXC.cjs +0 -302
- package/dist/lib/node/chunk-HEYQONXC.cjs.map +0 -7
- package/dist/lib/node/chunk-LU4HQWJD.cjs +0 -226
- package/dist/lib/node/chunk-LU4HQWJD.cjs.map +0 -7
- package/dist/lib/node/chunk-WWU5FVAO.cjs.map +0 -7
- package/dist/lib/node/chunk-ZS5RZ7RM.cjs +0 -34
- package/dist/lib/node/chunk-ZS5RZ7RM.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-CNVBSG4E.cjs +0 -44
- package/dist/lib/node/intent-resolver-CNVBSG4E.cjs.map +0 -7
- package/dist/lib/node/react-surface-5HYLBDC3.cjs.map +0 -7
- package/dist/lib/node/types/index.cjs +0 -46
- package/dist/lib/node/types/index.cjs.map +0 -7
- package/dist/lib/node-esm/AutomationPanel-ZV7VEEPP.mjs +0 -9
- package/dist/lib/node-esm/AutomationPanel-ZV7VEEPP.mjs.map +0 -7
- package/dist/lib/node-esm/ChatContainer-PPVMC2FC.mjs +0 -13
- package/dist/lib/node-esm/ChatContainer-PPVMC2FC.mjs.map +0 -7
- package/dist/lib/node-esm/ai-client-2ZA4TYFZ.mjs +0 -23
- package/dist/lib/node-esm/ai-client-2ZA4TYFZ.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-IYOUCQZT.mjs +0 -163
- package/dist/lib/node-esm/app-graph-builder-IYOUCQZT.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-3KB5HRXA.mjs +0 -284
- package/dist/lib/node-esm/chunk-3KB5HRXA.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-EVTLHDM2.mjs +0 -206
- package/dist/lib/node-esm/chunk-EVTLHDM2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ISYLEDVU.mjs +0 -16
- package/dist/lib/node-esm/chunk-ISYLEDVU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MS7OIGVR.mjs +0 -243
- package/dist/lib/node-esm/chunk-MS7OIGVR.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-WISKXX7U.mjs +0 -1368
- package/dist/lib/node-esm/chunk-WISKXX7U.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-RQBXW442.mjs +0 -30
- package/dist/lib/node-esm/intent-resolver-RQBXW442.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-SS5WCRJ2.mjs.map +0 -7
- package/dist/lib/node-esm/types/index.mjs +0 -25
- package/dist/lib/node-esm/types/index.mjs.map +0 -7
- package/dist/types/src/artifacts.stories.d.ts +0 -16
- package/dist/types/src/artifacts.stories.d.ts.map +0 -1
- package/dist/types/src/capabilities/ai-client.d.ts.map +0 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -180
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/capabilities/capabilities.d.ts +0 -5
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/components/ChatContainer/ChatContainer.d.ts +0 -8
- package/dist/types/src/components/ChatContainer/ChatContainer.d.ts.map +0 -1
- package/dist/types/src/components/ChatContainer/index.d.ts +0 -4
- package/dist/types/src/components/ChatContainer/index.d.ts.map +0 -1
- package/dist/types/src/components/MarkdownViewer/MarkdownViewer.d.ts +0 -14
- package/dist/types/src/components/MarkdownViewer/MarkdownViewer.d.ts.map +0 -1
- package/dist/types/src/components/MarkdownViewer/MarkdownViewer.stories.d.ts +0 -8
- package/dist/types/src/components/MarkdownViewer/MarkdownViewer.stories.d.ts.map +0 -1
- package/dist/types/src/components/MarkdownViewer/index.d.ts +0 -2
- package/dist/types/src/components/MarkdownViewer/index.d.ts.map +0 -1
- package/dist/types/src/components/PromptEditor/PromptEditor.d.ts +0 -10
- package/dist/types/src/components/PromptEditor/PromptEditor.d.ts.map +0 -1
- package/dist/types/src/components/PromptEditor/PromptEditor.stories.d.ts +0 -6
- package/dist/types/src/components/PromptEditor/PromptEditor.stories.d.ts.map +0 -1
- package/dist/types/src/components/PromptEditor/index.d.ts +0 -2
- package/dist/types/src/components/PromptEditor/index.d.ts.map +0 -1
- package/dist/types/src/components/PromptEditor/prompt-extension.d.ts +0 -4
- package/dist/types/src/components/PromptEditor/prompt-extension.d.ts.map +0 -1
- package/dist/types/src/components/PromptEditor/types.d.ts +0 -18
- package/dist/types/src/components/PromptEditor/types.d.ts.map +0 -1
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.d.ts +0 -6
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.d.ts.map +0 -1
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.stories.d.ts +0 -8
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.stories.d.ts.map +0 -1
- package/dist/types/src/components/ServiceRegistry/index.d.ts +0 -2
- package/dist/types/src/components/ServiceRegistry/index.d.ts.map +0 -1
- package/dist/types/src/components/Thread/ScrollContainer.d.ts +0 -15
- package/dist/types/src/components/Thread/ScrollContainer.d.ts.map +0 -1
- package/dist/types/src/components/Thread/StatusLine.d.ts +0 -11
- package/dist/types/src/components/Thread/StatusLine.d.ts.map +0 -1
- package/dist/types/src/components/Thread/StatusLine.stories.d.ts +0 -9
- package/dist/types/src/components/Thread/StatusLine.stories.d.ts.map +0 -1
- package/dist/types/src/components/Thread/Tabbed.d.ts +0 -9
- package/dist/types/src/components/Thread/Tabbed.d.ts.map +0 -1
- package/dist/types/src/components/Thread/Tabbed.stories.d.ts +0 -8
- package/dist/types/src/components/Thread/Tabbed.stories.d.ts.map +0 -1
- package/dist/types/src/components/Thread/Thread.d.ts +0 -11
- package/dist/types/src/components/Thread/Thread.d.ts.map +0 -1
- package/dist/types/src/components/Thread/Thread.stories.d.ts +0 -10
- package/dist/types/src/components/Thread/Thread.stories.d.ts.map +0 -1
- package/dist/types/src/components/Thread/ThreadMessage.d.ts +0 -12
- package/dist/types/src/components/Thread/ThreadMessage.d.ts.map +0 -1
- package/dist/types/src/components/Thread/ToggleContainer.d.ts +0 -13
- package/dist/types/src/components/Thread/ToggleContainer.d.ts.map +0 -1
- package/dist/types/src/components/Thread/ToggleContainer.stories.d.ts +0 -9
- package/dist/types/src/components/Thread/ToggleContainer.stories.d.ts.map +0 -1
- package/dist/types/src/components/Thread/index.d.ts +0 -2
- package/dist/types/src/components/Thread/index.d.ts.map +0 -1
- package/dist/types/src/hooks/email.d.ts +0 -4
- package/dist/types/src/hooks/email.d.ts.map +0 -1
- package/dist/types/src/hooks/index.d.ts +0 -4
- package/dist/types/src/hooks/index.d.ts.map +0 -1
- package/dist/types/src/hooks/invocation-handler.d.ts +0 -5
- package/dist/types/src/hooks/invocation-handler.d.ts.map +0 -1
- package/dist/types/src/hooks/processor.d.ts +0 -65
- package/dist/types/src/hooks/processor.d.ts.map +0 -1
- package/dist/types/src/hooks/processor.test.d.ts +0 -2
- package/dist/types/src/hooks/processor.test.d.ts.map +0 -1
- package/dist/types/src/hooks/useLocalTriggerManager.d.ts +0 -3
- package/dist/types/src/hooks/useLocalTriggerManager.d.ts.map +0 -1
- package/dist/types/src/hooks/useServiceRegistry.d.ts +0 -3
- package/dist/types/src/hooks/useServiceRegistry.d.ts.map +0 -1
- package/dist/types/src/presets.d.ts +0 -9
- package/dist/types/src/presets.d.ts.map +0 -1
- package/dist/types/src/testing/testing.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/index.d.ts +0 -4
- package/dist/types/src/types/index.d.ts.map +0 -1
- package/dist/types/src/types/registry.d.ts +0 -9
- package/dist/types/src/types/registry.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -196
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/dist/types/src/types/types.d.ts +0 -18
- package/dist/types/src/types/types.d.ts.map +0 -1
- package/src/artifacts.stories.tsx +0 -241
- package/src/capabilities/ai-client.ts +0 -19
- package/src/capabilities/app-graph-builder.ts +0 -156
- package/src/capabilities/capabilities.ts +0 -12
- package/src/capabilities/intent-resolver.ts +0 -27
- package/src/components/ChatContainer/ChatContainer.tsx +0 -117
- package/src/components/ChatContainer/index.ts +0 -8
- package/src/components/MarkdownViewer/MarkdownViewer.stories.tsx +0 -56
- package/src/components/MarkdownViewer/MarkdownViewer.tsx +0 -79
- package/src/components/MarkdownViewer/index.ts +0 -5
- package/src/components/PromptEditor/PromptEditor.stories.tsx +0 -64
- package/src/components/PromptEditor/PromptEditor.tsx +0 -222
- package/src/components/PromptEditor/index.ts +0 -5
- package/src/components/PromptEditor/prompt-extension.ts +0 -43
- package/src/components/PromptEditor/types.tsx +0 -28
- package/src/components/ServiceRegistry/ServiceRegistry.stories.tsx +0 -48
- package/src/components/ServiceRegistry/ServiceRegistry.tsx +0 -75
- package/src/components/ServiceRegistry/index.ts +0 -5
- package/src/components/Thread/ScrollContainer.tsx +0 -92
- package/src/components/Thread/StatusLine.stories.tsx +0 -52
- package/src/components/Thread/StatusLine.tsx +0 -76
- package/src/components/Thread/Tabbed.stories.tsx +0 -52
- package/src/components/Thread/Tabbed.tsx +0 -72
- package/src/components/Thread/Thread.stories.tsx +0 -190
- package/src/components/Thread/Thread.tsx +0 -156
- package/src/components/Thread/ThreadMessage.tsx +0 -195
- package/src/components/Thread/ToggleContainer.stories.tsx +0 -111
- package/src/components/Thread/ToggleContainer.tsx +0 -103
- package/src/components/Thread/index.ts +0 -5
- package/src/hooks/email.ts +0 -49
- package/src/hooks/index.ts +0 -8
- package/src/hooks/invocation-handler.ts +0 -109
- package/src/hooks/processor.test.ts +0 -15
- package/src/hooks/processor.ts +0 -201
- package/src/hooks/useLocalTriggerManager.ts +0 -82
- package/src/hooks/useServiceRegistry.ts +0 -22
- package/src/presets.ts +0 -248
- package/src/tools/function.ts +0 -47
- package/src/tools/index.ts +0 -6
- package/src/tools/openapi.test.ts +0 -227
- package/src/tools/openapi.ts +0 -331
- package/src/types/index.ts +0 -7
- package/src/types/registry.ts +0 -89
- package/src/types/schema.ts +0 -120
- package/src/types/types.ts +0 -21
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { sleep } from '@dxos/async';
|
|
6
|
-
import { getObjectCore, ResultFormat } from '@dxos/echo-db';
|
|
7
|
-
import { type AnyObjectData } from '@dxos/echo-schema';
|
|
8
|
-
import { FunctionType } from '@dxos/functions';
|
|
9
|
-
import { type FunctionTrigger } from '@dxos/functions';
|
|
10
|
-
import { invariant } from '@dxos/invariant';
|
|
11
|
-
import { DXN, LOCAL_SPACE_TAG } from '@dxos/keys';
|
|
12
|
-
import { log } from '@dxos/log';
|
|
13
|
-
import { type Client, type Config } from '@dxos/react-client';
|
|
14
|
-
import { type Space } from '@dxos/react-client/echo';
|
|
15
|
-
|
|
16
|
-
const MAX_RETRIES = 3;
|
|
17
|
-
const RETRY_DELAY = 1_000;
|
|
18
|
-
|
|
19
|
-
const callFunction = async (funcUrl: string, trigger: any, data: any) => {
|
|
20
|
-
const body = { event: 'trigger', trigger, data };
|
|
21
|
-
|
|
22
|
-
let retryCount = 0;
|
|
23
|
-
while (retryCount < MAX_RETRIES) {
|
|
24
|
-
log.info('exec', { funcUrl, body, retryCount });
|
|
25
|
-
const response = await fetch(funcUrl, {
|
|
26
|
-
method: 'POST',
|
|
27
|
-
headers: {
|
|
28
|
-
'Content-Type': 'application/json',
|
|
29
|
-
},
|
|
30
|
-
body: JSON.stringify(body),
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const data = await response.text();
|
|
34
|
-
log.info('response', { status: response.status, body: data });
|
|
35
|
-
if (response.status === 409) {
|
|
36
|
-
retryCount++;
|
|
37
|
-
await sleep(RETRY_DELAY * Math.min(retryCount, 2));
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return { status: response.status, data };
|
|
42
|
-
}
|
|
43
|
-
return { status: 500 };
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export const invokeFunction = async (client: Client, space: Space, trigger: FunctionTrigger, data: any) => {
|
|
47
|
-
try {
|
|
48
|
-
invariant(trigger.spec);
|
|
49
|
-
invariant(trigger.function);
|
|
50
|
-
|
|
51
|
-
const script = await space.db.query({ id: trigger.function }, { format: ResultFormat.Plain }).first();
|
|
52
|
-
const { objects: functions } = await space.db
|
|
53
|
-
.query({ __typename: FunctionType.typename }, { format: ResultFormat.Plain })
|
|
54
|
-
.run();
|
|
55
|
-
const func = functions.find((fn) => referenceEquals(fn.source, trigger.function!)) as AnyObjectData | undefined;
|
|
56
|
-
const funcSlug = func?.__meta.keys.find((key) => key.source === USERFUNCTIONS_META_KEY)?.id;
|
|
57
|
-
if (!funcSlug) {
|
|
58
|
-
log.warn('function not deployed', { scriptId: script.id, name: script.name });
|
|
59
|
-
return 404;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const funcUrl = getFunctionUrl(client.config, funcSlug, space.id);
|
|
63
|
-
const triggerData: AnyObjectData = {
|
|
64
|
-
...getObjectCore(trigger).toPlainObject(),
|
|
65
|
-
// TODO: Remove when functions can query by DXN.
|
|
66
|
-
promptId: trigger.meta?.prompt?.id,
|
|
67
|
-
};
|
|
68
|
-
// TODO: Remove when functions can add objects and easily modify collections (push, splice).
|
|
69
|
-
return (await callFunction(funcUrl, triggerData, data)).status;
|
|
70
|
-
} catch (err) {
|
|
71
|
-
return 400;
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const USERFUNCTIONS_META_KEY = 'dxos.org/service/function';
|
|
76
|
-
|
|
77
|
-
const getFunctionUrl = (config: Config, slug: string, spaceId?: string) => {
|
|
78
|
-
const baseUrl = new URL('functions/', config.values.runtime?.services?.edge?.url);
|
|
79
|
-
|
|
80
|
-
// Leading slashes cause the URL to be treated as an absolute path.
|
|
81
|
-
const relativeUrl = slug.replace(/^\//, '');
|
|
82
|
-
const url = new URL(`./${relativeUrl}`, baseUrl.toString());
|
|
83
|
-
spaceId && url.searchParams.set('spaceId', spaceId);
|
|
84
|
-
url.protocol = 'https';
|
|
85
|
-
return url.toString();
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
// TODO(dmaretskyi): Factor out.
|
|
89
|
-
|
|
90
|
-
type ReferenceLike = { '/': string } | string;
|
|
91
|
-
|
|
92
|
-
const referenceEquals = (a: ReferenceLike, b: ReferenceLike): boolean => {
|
|
93
|
-
const aDXN = toDXN(a);
|
|
94
|
-
const bDXN = toDXN(b);
|
|
95
|
-
return aDXN.toString() === bDXN.toString();
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const toDXN = (ref: ReferenceLike): DXN => {
|
|
99
|
-
if (typeof ref === 'string') {
|
|
100
|
-
if (ref.startsWith('dxn:')) {
|
|
101
|
-
return DXN.parse(ref);
|
|
102
|
-
} else {
|
|
103
|
-
return new DXN(DXN.kind.ECHO, [LOCAL_SPACE_TAG, ref]);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
invariant(typeof ref['/'] === 'string');
|
|
108
|
-
return DXN.parse(ref['/']);
|
|
109
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { describe, it } from 'vitest';
|
|
6
|
-
|
|
7
|
-
import { ChatProcessor } from './processor';
|
|
8
|
-
|
|
9
|
-
describe('ChatProcessor', () => {
|
|
10
|
-
it('should be instantiable', ({ expect }) => {
|
|
11
|
-
const client = {} as any; // TODO(burdon): Create mock.
|
|
12
|
-
const processor = new ChatProcessor(client);
|
|
13
|
-
expect(processor).toBeDefined();
|
|
14
|
-
});
|
|
15
|
-
});
|
package/src/hooks/processor.ts
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type Signal, batch, computed, signal } from '@preact/signals-core';
|
|
6
|
-
|
|
7
|
-
import { type PromiseIntentDispatcher } from '@dxos/app-framework';
|
|
8
|
-
import { type Tool, Message, type MessageContentBlock } from '@dxos/artifact';
|
|
9
|
-
import {
|
|
10
|
-
isToolUse,
|
|
11
|
-
runTools,
|
|
12
|
-
type AIServiceClientImpl,
|
|
13
|
-
type GenerateRequest,
|
|
14
|
-
type GenerationStream,
|
|
15
|
-
MixedStreamParser,
|
|
16
|
-
} from '@dxos/assistant';
|
|
17
|
-
import { createStatic } from '@dxos/echo-schema';
|
|
18
|
-
import { invariant } from '@dxos/invariant';
|
|
19
|
-
import { log } from '@dxos/log';
|
|
20
|
-
import { type Space } from '@dxos/react-client/echo';
|
|
21
|
-
|
|
22
|
-
const defaultOptions: Pick<GenerateRequest, 'model' | 'systemPrompt'> = {
|
|
23
|
-
model: '@anthropic/claude-3-5-sonnet-20241022',
|
|
24
|
-
systemPrompt: '',
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
// TODO(burdon): Factor out.
|
|
28
|
-
declare global {
|
|
29
|
-
interface ToolContextExtensions {
|
|
30
|
-
space?: Space;
|
|
31
|
-
dispatch?: PromiseIntentDispatcher;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
type RequestOptions = {
|
|
36
|
-
history?: Message[];
|
|
37
|
-
onComplete?: (messages: Message[]) => void;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Handles interactions with the AI service.
|
|
42
|
-
* Maintains a queue of messages and handles streaming responses from the AI service.
|
|
43
|
-
* Executes tools based on AI responses.
|
|
44
|
-
* Supports cancellation of in-progress requests.
|
|
45
|
-
*/
|
|
46
|
-
export class ChatProcessor {
|
|
47
|
-
/** SSE stream parser. */
|
|
48
|
-
private readonly _parser = new MixedStreamParser();
|
|
49
|
-
|
|
50
|
-
/** Current streaming response (iterator). */
|
|
51
|
-
private _stream: GenerationStream | undefined;
|
|
52
|
-
|
|
53
|
-
/** Pending messages (incl. the user request). */
|
|
54
|
-
private readonly _pending: Signal<Message[]> = signal([]);
|
|
55
|
-
|
|
56
|
-
/** Current streaming block (from the AI service). */
|
|
57
|
-
private readonly _block: Signal<MessageContentBlock | undefined> = signal(undefined);
|
|
58
|
-
|
|
59
|
-
/** Prior history from queue. */
|
|
60
|
-
private _history: Message[] = [];
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Streaming state.
|
|
64
|
-
* @reactive
|
|
65
|
-
*/
|
|
66
|
-
public readonly streaming: Signal<boolean> = computed(() => this._block.value !== undefined);
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Array of Messages (incl. the current message being streamed).
|
|
70
|
-
* @reactive
|
|
71
|
-
*/
|
|
72
|
-
public readonly messages: Signal<Message[]> = computed(() => {
|
|
73
|
-
const messages = [...this._pending.value];
|
|
74
|
-
if (this._block.value) {
|
|
75
|
-
const current = messages.pop();
|
|
76
|
-
invariant(current);
|
|
77
|
-
const { content, ...rest } = current;
|
|
78
|
-
const message = { ...rest, content: [...content, this._block.value] };
|
|
79
|
-
messages.push(message);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return messages;
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
constructor(
|
|
86
|
-
private readonly _client: AIServiceClientImpl,
|
|
87
|
-
private readonly _tools?: Tool[],
|
|
88
|
-
private readonly _extensions?: ToolContextExtensions,
|
|
89
|
-
private readonly _options: Pick<GenerateRequest, 'model' | 'systemPrompt'> = defaultOptions,
|
|
90
|
-
) {
|
|
91
|
-
// Message complete.
|
|
92
|
-
this._parser.message.on((message) => {
|
|
93
|
-
batch(() => {
|
|
94
|
-
this._pending.value = [...this._pending.value, message];
|
|
95
|
-
this._block.value = undefined;
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
// Streaming update (happens before message complete).
|
|
100
|
-
this._parser.update.on((block) => {
|
|
101
|
-
batch(() => {
|
|
102
|
-
this._block.value = block;
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Make GPT request.
|
|
109
|
-
*/
|
|
110
|
-
async request(message: string, options: RequestOptions = {}): Promise<Message[]> {
|
|
111
|
-
batch(() => {
|
|
112
|
-
this._history = options.history ?? [];
|
|
113
|
-
this._pending.value = [
|
|
114
|
-
createStatic(Message, {
|
|
115
|
-
role: 'user',
|
|
116
|
-
content: [{ type: 'text', text: message }],
|
|
117
|
-
}),
|
|
118
|
-
];
|
|
119
|
-
this._block.value = undefined;
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
await this._generate();
|
|
123
|
-
options.onComplete?.(this._pending.value);
|
|
124
|
-
return this._reset();
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Cancel pending requests.
|
|
129
|
-
* @returns Pending requests (incl. the request message).
|
|
130
|
-
*/
|
|
131
|
-
async cancel(): Promise<Message[]> {
|
|
132
|
-
log.info('cancelling...');
|
|
133
|
-
this._stream?.abort();
|
|
134
|
-
return this._reset();
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
private async _reset(): Promise<Message[]> {
|
|
138
|
-
const messages = this._pending.value;
|
|
139
|
-
batch(() => {
|
|
140
|
-
this._history = [];
|
|
141
|
-
this._pending.value = [];
|
|
142
|
-
this._block.value = undefined;
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
return messages;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Generate a response from the AI service.
|
|
150
|
-
* Iterates over tool requests.
|
|
151
|
-
*/
|
|
152
|
-
private async _generate() {
|
|
153
|
-
try {
|
|
154
|
-
let more = false;
|
|
155
|
-
do {
|
|
156
|
-
log.info('requesting...', { history: this._history.length, messages: this._pending.value.length });
|
|
157
|
-
this._stream = await this._client.generate({
|
|
158
|
-
...this._options,
|
|
159
|
-
// TODO(burdon): Rename messages or separate history/message.
|
|
160
|
-
history: [...this._history, ...this._pending.value],
|
|
161
|
-
tools: this._tools,
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
// Wait until complete.
|
|
165
|
-
await this._parser.parse(this._stream);
|
|
166
|
-
await this._stream.complete();
|
|
167
|
-
|
|
168
|
-
// Add messages.
|
|
169
|
-
log.info('response', { messages: this._pending.value });
|
|
170
|
-
|
|
171
|
-
// Resolve tool use locally.
|
|
172
|
-
more = false;
|
|
173
|
-
const message = this._pending.value.at(-1);
|
|
174
|
-
invariant(message);
|
|
175
|
-
if (isToolUse(message)) {
|
|
176
|
-
log.info('tool request...');
|
|
177
|
-
const response = await runTools({
|
|
178
|
-
message: this._pending.value.at(-1)!,
|
|
179
|
-
tools: this._tools ?? [],
|
|
180
|
-
extensions: this._extensions,
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
log.info('tool response', { response });
|
|
184
|
-
switch (response.type) {
|
|
185
|
-
case 'continue': {
|
|
186
|
-
this._pending.value = [...this._pending.value, response.message];
|
|
187
|
-
more = true;
|
|
188
|
-
break;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
} while (more);
|
|
193
|
-
} catch (err) {
|
|
194
|
-
// TODO(burdon): Handle error.
|
|
195
|
-
log.catch('request failed', { err });
|
|
196
|
-
} finally {
|
|
197
|
-
log.info('done');
|
|
198
|
-
this._stream = undefined;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { useEffect, useState } from 'react';
|
|
6
|
-
|
|
7
|
-
import { Mutex } from '@dxos/async';
|
|
8
|
-
import { Context } from '@dxos/context';
|
|
9
|
-
import { createSubscriptionTrigger, type TriggerFactory } from '@dxos/functions';
|
|
10
|
-
import { FunctionTrigger } from '@dxos/functions';
|
|
11
|
-
import { invariant } from '@dxos/invariant';
|
|
12
|
-
import { log } from '@dxos/log';
|
|
13
|
-
import { useClient } from '@dxos/react-client';
|
|
14
|
-
import { Filter, type Space, useQuery } from '@dxos/react-client/echo';
|
|
15
|
-
|
|
16
|
-
import { invokeFunction } from './invocation-handler';
|
|
17
|
-
|
|
18
|
-
const registerTriggersMutex = new Mutex();
|
|
19
|
-
|
|
20
|
-
export const useLocalTriggerManager = (space: Space) => {
|
|
21
|
-
const client = useClient();
|
|
22
|
-
|
|
23
|
-
// TODO(burdon): Factor out, creating context for plugin (runs outside of component).
|
|
24
|
-
const [registry] = useState(new Map<string, Context>());
|
|
25
|
-
const triggers = useQuery(space, Filter.schema(FunctionTrigger));
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
setTimeout(async () => {
|
|
28
|
-
// Mark-and-sweep removing disabled triggers.
|
|
29
|
-
await registerTriggersMutex.executeSynchronized(async () => {
|
|
30
|
-
const deprecated = new Set(Array.from(registry.keys()));
|
|
31
|
-
log('triggers', {
|
|
32
|
-
deprecated,
|
|
33
|
-
all: triggers.map((t) => t.id),
|
|
34
|
-
enabled: triggers.filter((t) => t.enabled).map((t) => t.id),
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
for (const trigger of triggers) {
|
|
38
|
-
if (trigger.enabled) {
|
|
39
|
-
if (registry.has(trigger.id)) {
|
|
40
|
-
deprecated.delete(trigger.id);
|
|
41
|
-
continue;
|
|
42
|
-
}
|
|
43
|
-
log.info('activating trigger', trigger.id);
|
|
44
|
-
|
|
45
|
-
const ctx = new Context();
|
|
46
|
-
registry.set(trigger.id, ctx);
|
|
47
|
-
const triggerSpec = trigger.spec;
|
|
48
|
-
invariant(triggerSpec);
|
|
49
|
-
|
|
50
|
-
let triggerFactory: TriggerFactory<any>;
|
|
51
|
-
if (triggerSpec.type === 'subscription') {
|
|
52
|
-
triggerFactory = createSubscriptionTrigger;
|
|
53
|
-
} else {
|
|
54
|
-
log.info('unsupported trigger', { type: triggerSpec.type });
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
await triggerFactory(ctx, space, trigger.spec, (data: any) => {
|
|
59
|
-
return invokeFunction(client, space, trigger, data);
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
for (const id of deprecated) {
|
|
65
|
-
const ctx = registry.get(id);
|
|
66
|
-
if (ctx) {
|
|
67
|
-
await ctx.dispose();
|
|
68
|
-
registry.delete(id);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
}, [JSON.stringify(triggers)]);
|
|
74
|
-
|
|
75
|
-
useEffect(() => {
|
|
76
|
-
return () => {
|
|
77
|
-
for (const ctx of registry.values()) {
|
|
78
|
-
void ctx.dispose();
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
}, []);
|
|
82
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { useEffect, useMemo, useState } from 'react';
|
|
6
|
-
|
|
7
|
-
import { type ServiceType, MockServiceRegistry, type ServiceQuery } from '../types';
|
|
8
|
-
|
|
9
|
-
export const useServiceRegistry = (query: ServiceQuery): ServiceType[] => {
|
|
10
|
-
const registry = useMemo(() => new MockServiceRegistry(), []);
|
|
11
|
-
const [services, setServices] = useState<ServiceType[]>([]);
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
const t = setTimeout(async () => {
|
|
14
|
-
const services = await registry.queryServices(query);
|
|
15
|
-
setServices(services);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
return () => clearTimeout(t);
|
|
19
|
-
}, [query, registry]);
|
|
20
|
-
|
|
21
|
-
return services;
|
|
22
|
-
};
|
package/src/presets.ts
DELETED
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { create } from '@dxos/live-object';
|
|
6
|
-
|
|
7
|
-
import { ChainInputType, ChainPromptType } from './types';
|
|
8
|
-
|
|
9
|
-
export const str = (...text: (string | undefined | boolean)[]): string =>
|
|
10
|
-
text
|
|
11
|
-
.filter((value) => value !== undefined && value !== false)
|
|
12
|
-
.flat()
|
|
13
|
-
.join('\n');
|
|
14
|
-
|
|
15
|
-
export type Preset = {
|
|
16
|
-
id: string;
|
|
17
|
-
title: string;
|
|
18
|
-
createPrompt: () => ChainPromptType;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const chainPresets: Preset[] = [
|
|
22
|
-
{
|
|
23
|
-
id: 'dxos.org/prompt/translate',
|
|
24
|
-
title: 'Translate',
|
|
25
|
-
createPrompt: () =>
|
|
26
|
-
create(ChainPromptType, {
|
|
27
|
-
command: 'say',
|
|
28
|
-
template: str(
|
|
29
|
-
// prettier-ignore
|
|
30
|
-
'Translate the following into {language}:',
|
|
31
|
-
'',
|
|
32
|
-
'---',
|
|
33
|
-
'',
|
|
34
|
-
'{input}',
|
|
35
|
-
),
|
|
36
|
-
inputs: [
|
|
37
|
-
{
|
|
38
|
-
type: ChainInputType.VALUE,
|
|
39
|
-
name: 'language',
|
|
40
|
-
value: 'japanese',
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
type: ChainInputType.PASS_THROUGH,
|
|
44
|
-
name: 'input',
|
|
45
|
-
},
|
|
46
|
-
// TODO(burdon): Message.
|
|
47
|
-
// {
|
|
48
|
-
// type: ChainInputType.CONTEXT,
|
|
49
|
-
// name: 'input',
|
|
50
|
-
// value: 'object.text',
|
|
51
|
-
// },
|
|
52
|
-
],
|
|
53
|
-
}),
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
id: 'dxos.org/prompt/chess',
|
|
57
|
-
title: 'Chess',
|
|
58
|
-
createPrompt: () =>
|
|
59
|
-
create(ChainPromptType, {
|
|
60
|
-
command: 'hint',
|
|
61
|
-
template: str(
|
|
62
|
-
// prettier-ignore
|
|
63
|
-
'You are a machine that is an expert chess player.',
|
|
64
|
-
'',
|
|
65
|
-
'The move history of the current game is: {history}',
|
|
66
|
-
'',
|
|
67
|
-
'Suggest the next move and very briefly explain your strategy in a couple of sentences.',
|
|
68
|
-
),
|
|
69
|
-
inputs: [
|
|
70
|
-
{
|
|
71
|
-
type: ChainInputType.CONTEXT,
|
|
72
|
-
name: 'history',
|
|
73
|
-
value: 'object.pgn',
|
|
74
|
-
},
|
|
75
|
-
],
|
|
76
|
-
}),
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
id: 'dxos.org/prompt/mermaid',
|
|
80
|
-
title: 'Mermaid',
|
|
81
|
-
createPrompt: () =>
|
|
82
|
-
create(ChainPromptType, {
|
|
83
|
-
command: 'draw',
|
|
84
|
-
template: str(
|
|
85
|
-
// prettier-ignore
|
|
86
|
-
'Create a simplified mermaid graph representing the text below.',
|
|
87
|
-
'Do not explain anything.',
|
|
88
|
-
'',
|
|
89
|
-
'---',
|
|
90
|
-
'',
|
|
91
|
-
'{input}',
|
|
92
|
-
),
|
|
93
|
-
inputs: [
|
|
94
|
-
{
|
|
95
|
-
type: ChainInputType.PASS_THROUGH,
|
|
96
|
-
name: 'input',
|
|
97
|
-
},
|
|
98
|
-
],
|
|
99
|
-
}),
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
id: 'dxos.org/prompt/list',
|
|
103
|
-
title: 'List',
|
|
104
|
-
createPrompt: () =>
|
|
105
|
-
create(ChainPromptType, {
|
|
106
|
-
command: 'list',
|
|
107
|
-
template: str(
|
|
108
|
-
// prettier-ignore
|
|
109
|
-
'You are a machine that only replies with valid, iterable RFC8259 compliant JSON in your responses.',
|
|
110
|
-
'Your entire response should be a single array of JSON objects.',
|
|
111
|
-
'',
|
|
112
|
-
'Your entire response should be a map where the key is the type and the value is a single array of JSON objects conforming to the following types:',
|
|
113
|
-
'',
|
|
114
|
-
'{schema}',
|
|
115
|
-
'',
|
|
116
|
-
'---',
|
|
117
|
-
'',
|
|
118
|
-
'{question}',
|
|
119
|
-
),
|
|
120
|
-
inputs: [
|
|
121
|
-
{
|
|
122
|
-
type: ChainInputType.SCHEMA,
|
|
123
|
-
name: 'schema',
|
|
124
|
-
value: 'example.com/type/project',
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
type: ChainInputType.PASS_THROUGH,
|
|
128
|
-
name: 'question',
|
|
129
|
-
},
|
|
130
|
-
],
|
|
131
|
-
}),
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
id: 'dxos.org/prompt/base',
|
|
135
|
-
title: 'RAG',
|
|
136
|
-
createPrompt: () =>
|
|
137
|
-
create(ChainPromptType, {
|
|
138
|
-
command: 'rag',
|
|
139
|
-
template: str(
|
|
140
|
-
// prettier-ignore
|
|
141
|
-
"Very briefly answer the question based only on the following context and say if you don't know the answer.",
|
|
142
|
-
// 'answer the question using the following context as well as your training data:',
|
|
143
|
-
'',
|
|
144
|
-
'{context}',
|
|
145
|
-
'',
|
|
146
|
-
'---',
|
|
147
|
-
'',
|
|
148
|
-
'question: {question}',
|
|
149
|
-
),
|
|
150
|
-
inputs: [
|
|
151
|
-
{
|
|
152
|
-
type: ChainInputType.RETRIEVER,
|
|
153
|
-
name: 'context',
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
type: ChainInputType.CONTEXT,
|
|
157
|
-
name: 'question',
|
|
158
|
-
value: 'object.text',
|
|
159
|
-
},
|
|
160
|
-
],
|
|
161
|
-
}),
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
id: 'dxos.org/prompt/lookup',
|
|
165
|
-
title: 'Lookup',
|
|
166
|
-
createPrompt: () =>
|
|
167
|
-
create(ChainPromptType, {
|
|
168
|
-
command: 'lookup',
|
|
169
|
-
template: str(
|
|
170
|
-
// prettier-ignore
|
|
171
|
-
'Lookup and very briefly summarize the following topic in one or two sentences:',
|
|
172
|
-
'',
|
|
173
|
-
'---',
|
|
174
|
-
'',
|
|
175
|
-
'{input}',
|
|
176
|
-
),
|
|
177
|
-
inputs: [
|
|
178
|
-
{
|
|
179
|
-
type: ChainInputType.CONTEXT,
|
|
180
|
-
name: 'input',
|
|
181
|
-
value: 'text',
|
|
182
|
-
},
|
|
183
|
-
],
|
|
184
|
-
}),
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
id: 'dxos.org/prompt/extract',
|
|
188
|
-
title: 'Extract',
|
|
189
|
-
createPrompt: () =>
|
|
190
|
-
create(ChainPromptType, {
|
|
191
|
-
command: 'extract',
|
|
192
|
-
template: str(
|
|
193
|
-
// prettier-ignore
|
|
194
|
-
'List all people and companies mentioned in the text below.',
|
|
195
|
-
'',
|
|
196
|
-
'You are a machine that only replies with valid, iterable RFC8259 compliant JSON in your responses.',
|
|
197
|
-
'Your entire response should be a map where the key is the type and the value is a single array of JSON objects conforming to the following types:',
|
|
198
|
-
'',
|
|
199
|
-
'{contact}',
|
|
200
|
-
'{company}',
|
|
201
|
-
'',
|
|
202
|
-
'---',
|
|
203
|
-
'',
|
|
204
|
-
'{input}',
|
|
205
|
-
),
|
|
206
|
-
inputs: [
|
|
207
|
-
{
|
|
208
|
-
type: ChainInputType.SCHEMA,
|
|
209
|
-
name: 'contact',
|
|
210
|
-
value: 'example.com/type/contact',
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
type: ChainInputType.SCHEMA,
|
|
214
|
-
name: 'company',
|
|
215
|
-
value: 'example.com/type/organization',
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
type: ChainInputType.CONTEXT,
|
|
219
|
-
name: 'input',
|
|
220
|
-
value: 'text',
|
|
221
|
-
},
|
|
222
|
-
],
|
|
223
|
-
}),
|
|
224
|
-
},
|
|
225
|
-
{
|
|
226
|
-
id: 'dxos.org/prompt/discord',
|
|
227
|
-
title: 'Summarize',
|
|
228
|
-
createPrompt: () =>
|
|
229
|
-
create(ChainPromptType, {
|
|
230
|
-
command: 'summarize',
|
|
231
|
-
template: str(
|
|
232
|
-
// prettier-ignore
|
|
233
|
-
'Summarize what the team is working on and format it as a markdown table without any explanation.',
|
|
234
|
-
'',
|
|
235
|
-
'---',
|
|
236
|
-
'',
|
|
237
|
-
'{context}',
|
|
238
|
-
),
|
|
239
|
-
inputs: [
|
|
240
|
-
{
|
|
241
|
-
type: ChainInputType.RESOLVER,
|
|
242
|
-
name: 'context',
|
|
243
|
-
value: 'discord.messages.recent',
|
|
244
|
-
},
|
|
245
|
-
],
|
|
246
|
-
}),
|
|
247
|
-
},
|
|
248
|
-
];
|