@dxos/plugin-script 0.8.4-main.406dc2a → 0.8.4-main.548089c
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/DeploymentDialog-MZX4T77L.mjs +14 -0
- package/dist/lib/browser/{NotebookContainer-LVGRPFY3.mjs → NotebookContainer-S6GUYCUE.mjs} +216 -82
- package/dist/lib/browser/NotebookContainer-S6GUYCUE.mjs.map +7 -0
- package/dist/lib/browser/{ScriptContainer-LRTRN7JW.mjs → ScriptContainer-3JQSTDFZ.mjs} +16 -18
- package/dist/lib/browser/ScriptContainer-3JQSTDFZ.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-DPYULSME.mjs → app-graph-builder-2WR2ATTJ.mjs} +7 -6
- package/dist/lib/browser/app-graph-builder-2WR2ATTJ.mjs.map +7 -0
- package/dist/lib/browser/{blueprint-definition-ET5KZ46I.mjs → blueprint-definition-6PZWZM2Y.mjs} +3 -1
- package/dist/lib/browser/{chunk-ST3ACVUC.mjs → chunk-2G2NA6DQ.mjs} +2 -2
- package/dist/lib/browser/{chunk-ST3ACVUC.mjs.map → chunk-2G2NA6DQ.mjs.map} +1 -1
- package/dist/lib/browser/{chunk-NM4WQS4F.mjs → chunk-3IJASGG5.mjs} +12 -10
- package/dist/lib/browser/chunk-3IJASGG5.mjs.map +7 -0
- package/dist/lib/browser/chunk-5JSNQYZZ.mjs +517 -0
- package/dist/lib/browser/chunk-5JSNQYZZ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-EZVXV6DA.mjs → chunk-EB6AXFXO.mjs} +7 -2
- package/dist/lib/browser/chunk-EB6AXFXO.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/{chunk-I3QSGUFJ.mjs → chunk-JRF6FHYQ.mjs} +33 -33
- package/dist/lib/browser/chunk-JRF6FHYQ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-5CYLWXRH.mjs → chunk-LNNCD2H4.mjs} +51 -38
- package/dist/lib/browser/chunk-LNNCD2H4.mjs.map +7 -0
- package/dist/lib/browser/{chunk-N6M34EUC.mjs → chunk-M6KJPUJK.mjs} +3 -4
- package/dist/lib/browser/chunk-M6KJPUJK.mjs.map +7 -0
- package/dist/lib/browser/{chunk-75LH4EUR.mjs → chunk-RXLF2X2R.mjs} +58 -80
- package/dist/lib/browser/chunk-RXLF2X2R.mjs.map +7 -0
- package/dist/lib/browser/{chunk-OKXN2N7M.mjs → chunk-UOQ6NCH3.mjs} +2 -2
- package/dist/lib/browser/{compiler-G2N2CG63.mjs → compiler-4KHRSX7J.mjs} +11 -23
- package/dist/lib/browser/compiler-4KHRSX7J.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +27 -33
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-JLU7DVLQ.mjs → intent-resolver-PUMSYKVB.mjs} +19 -20
- package/dist/lib/browser/intent-resolver-PUMSYKVB.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-76SDTUYG.mjs → react-surface-DLRMWFTN.mjs} +22 -21
- package/dist/lib/browser/react-surface-DLRMWFTN.mjs.map +7 -0
- package/dist/lib/browser/{settings-ERFKVNUK.mjs → settings-LNLSTZM4.mjs} +5 -4
- package/dist/lib/browser/templates/index.mjs +2 -1
- package/dist/lib/browser/types/index.mjs +6 -5
- package/dist/lib/node-esm/DeploymentDialog-GL5AUWMR.mjs +15 -0
- package/dist/lib/node-esm/DeploymentDialog-GL5AUWMR.mjs.map +7 -0
- package/dist/lib/node-esm/{NotebookContainer-QY5NJGJI.mjs → NotebookContainer-RTUHQN25.mjs} +216 -82
- package/dist/lib/node-esm/NotebookContainer-RTUHQN25.mjs.map +7 -0
- package/dist/lib/node-esm/{ScriptContainer-SVXCSLNH.mjs → ScriptContainer-SSLISMLS.mjs} +16 -18
- package/dist/lib/node-esm/ScriptContainer-SSLISMLS.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-UXJGHXSL.mjs → app-graph-builder-NCVLUL5R.mjs} +7 -6
- package/dist/lib/node-esm/app-graph-builder-NCVLUL5R.mjs.map +7 -0
- package/dist/lib/node-esm/{blueprint-definition-AIYFOT7Q.mjs → blueprint-definition-5R6YCSZZ.mjs} +2 -1
- package/dist/lib/{browser/blueprint-definition-ET5KZ46I.mjs.map → node-esm/blueprint-definition-5R6YCSZZ.mjs.map} +1 -1
- package/dist/lib/node-esm/{chunk-NUXZQQ6P.mjs → chunk-55JZVM6K.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-2GVTWESW.mjs → chunk-57JA6XL5.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-2GVTWESW.mjs.map → chunk-57JA6XL5.mjs.map} +1 -1
- package/dist/lib/node-esm/{chunk-SMFPSKQT.mjs → chunk-ASPYIAYG.mjs} +33 -33
- package/dist/lib/node-esm/chunk-ASPYIAYG.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-VRSDE4CI.mjs → chunk-HDKR5WCD.mjs} +3 -4
- package/dist/lib/node-esm/chunk-HDKR5WCD.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-OG2SIKHE.mjs → chunk-IBV2DR36.mjs} +7 -2
- package/dist/lib/node-esm/chunk-IBV2DR36.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-IQTBVH4L.mjs +518 -0
- package/dist/lib/node-esm/chunk-IQTBVH4L.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-4X375PGY.mjs → chunk-NNHWLRHT.mjs} +51 -38
- package/dist/lib/node-esm/chunk-NNHWLRHT.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-67OVZHI3.mjs → chunk-Q5XB7DD4.mjs} +58 -80
- package/dist/lib/node-esm/chunk-Q5XB7DD4.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-C2ORIPKH.mjs → chunk-RIE676OW.mjs} +12 -10
- package/dist/lib/node-esm/chunk-RIE676OW.mjs.map +7 -0
- package/dist/lib/node-esm/{compiler-PLDAZ5GJ.mjs → compiler-DU5NQISX.mjs} +11 -23
- package/dist/lib/node-esm/compiler-DU5NQISX.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +27 -33
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-SFGTIFOG.mjs → intent-resolver-JK7J6JQB.mjs} +19 -20
- package/dist/lib/node-esm/intent-resolver-JK7J6JQB.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-SHEBNW4R.mjs → react-surface-BPQLLTT4.mjs} +22 -21
- package/dist/lib/node-esm/react-surface-BPQLLTT4.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-5TYXQ42N.mjs → settings-IUFMOCXY.mjs} +5 -4
- package/dist/lib/{browser/settings-ERFKVNUK.mjs.map → node-esm/settings-IUFMOCXY.mjs.map} +1 -1
- package/dist/lib/node-esm/templates/index.mjs +2 -1
- package/dist/lib/node-esm/types/index.mjs +6 -5
- package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts +2 -2
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts.map +1 -1
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts +0 -3
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/FrameContainer/FrameContainer.d.ts +1 -1
- package/dist/types/src/components/FrameContainer/FrameContainer.d.ts.map +1 -1
- package/dist/types/src/components/NotebookContainer.d.ts.map +1 -1
- package/dist/types/src/components/NotebookContainer.stories.d.ts +7 -4
- package/dist/types/src/components/NotebookContainer.stories.d.ts.map +1 -1
- package/dist/types/src/components/NotebookStack/NotebookCell.d.ts +2 -1
- package/dist/types/src/components/NotebookStack/NotebookCell.d.ts.map +1 -1
- package/dist/types/src/components/NotebookStack/NotebookStack.d.ts +1 -1
- package/dist/types/src/components/NotebookStack/NotebookStack.d.ts.map +1 -1
- package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts +0 -3
- package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts.map +1 -1
- package/dist/types/src/components/ScriptContainer.d.ts +2 -2
- package/dist/types/src/components/ScriptContainer.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts +5 -6
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts +1 -4
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts +2 -2
- package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts.map +1 -1
- package/dist/types/src/components/TestPanel/TestContainer.d.ts +2 -2
- package/dist/types/src/components/TestPanel/TestContainer.d.ts.map +1 -1
- package/dist/types/src/components/TestPanel/TestPanel.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts +1 -1
- package/dist/types/src/hooks/deploy.d.ts +8 -7
- package/dist/types/src/hooks/deploy.d.ts.map +1 -1
- package/dist/types/src/hooks/format.d.ts +2 -2
- package/dist/types/src/hooks/format.d.ts.map +1 -1
- package/dist/types/src/hooks/template.d.ts +4 -14
- package/dist/types/src/hooks/template.d.ts.map +1 -1
- package/dist/types/src/hooks/useCreateAndDeployScriptTemplates.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/notebook/{notebook.d.ts → compute-graph.d.ts} +13 -3
- package/dist/types/src/notebook/compute-graph.d.ts.map +1 -0
- package/dist/types/src/notebook/compute-graph.test.d.ts +2 -0
- package/dist/types/src/notebook/compute-graph.test.d.ts.map +1 -0
- package/dist/types/src/notebook/eval.d.ts +1 -1
- package/dist/types/src/notebook/eval.d.ts.map +1 -1
- package/dist/types/src/notebook/index.d.ts +1 -1
- package/dist/types/src/notebook/index.d.ts.map +1 -1
- package/dist/types/src/testing/data.d.ts +2 -18
- package/dist/types/src/testing/data.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +2 -3
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Notebook.d.ts +31 -0
- package/dist/types/src/types/Notebook.d.ts.map +1 -0
- package/dist/types/src/types/actions.d.ts +5 -17
- package/dist/types/src/types/actions.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +2 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +6 -0
- package/dist/types/src/types/types.d.ts.map +1 -0
- package/dist/types/src/util/deploy.d.ts +4 -4
- package/dist/types/src/util/deploy.d.ts.map +1 -1
- package/dist/types/src/util/functions.d.ts +3 -3
- package/dist/types/src/util/functions.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +61 -56
- package/src/ScriptPlugin.tsx +6 -10
- package/src/capabilities/app-graph-builder.ts +6 -6
- package/src/capabilities/artifact-definition.ts +1 -2
- package/src/capabilities/compiler.ts +1 -1
- package/src/capabilities/intent-resolver.ts +6 -7
- package/src/capabilities/react-surface.tsx +13 -12
- package/src/components/DeploymentDialog/DeploymentDialog.stories.tsx +8 -3
- package/src/components/DeploymentDialog/DeploymentDialog.tsx +30 -13
- package/src/components/FrameContainer/FrameContainer.tsx +1 -1
- package/src/components/NotebookContainer.stories.tsx +58 -7
- package/src/components/NotebookContainer.tsx +150 -11
- package/src/components/NotebookStack/NotebookCell.tsx +63 -66
- package/src/components/NotebookStack/NotebookStack.stories.tsx +24 -2
- package/src/components/NotebookStack/NotebookStack.tsx +12 -5
- package/src/components/ScriptContainer.tsx +3 -3
- package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +6 -6
- package/src/components/ScriptToolbar/ScriptToolbar.tsx +12 -12
- package/src/components/Settings/ScriptObjectSettings.tsx +21 -10
- package/src/components/TestPanel/TestContainer.tsx +2 -2
- package/src/components/TestPanel/TestPanel.tsx +36 -13
- package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +1 -1
- package/src/components/TypescriptEditor/TypescriptEditor.tsx +6 -11
- package/src/hooks/deploy.ts +6 -6
- package/src/hooks/format.ts +2 -2
- package/src/hooks/template.ts +5 -15
- package/src/hooks/useCreateAndDeployScriptTemplates.ts +8 -4
- package/src/meta.ts +6 -2
- package/src/notebook/{notebook.test.ts → compute-graph.test.ts} +19 -19
- package/src/notebook/{notebook.ts → compute-graph.ts} +32 -9
- package/src/notebook/eval.ts +1 -1
- package/src/notebook/index.ts +1 -1
- package/src/templates/gmail.ts +1 -2
- package/src/testing/data.ts +34 -9
- package/src/translations.ts +2 -3
- package/src/types/Notebook.ts +41 -0
- package/src/types/actions.ts +3 -3
- package/src/types/index.ts +2 -1
- package/src/types/types.ts +15 -0
- package/src/util/deploy.ts +13 -17
- package/src/util/functions.ts +5 -4
- package/dist/lib/browser/DeploymentDialog-65TWT6S5.mjs +0 -13
- package/dist/lib/browser/NotebookContainer-LVGRPFY3.mjs.map +0 -7
- package/dist/lib/browser/ScriptContainer-LRTRN7JW.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-DPYULSME.mjs.map +0 -7
- package/dist/lib/browser/chunk-5CYLWXRH.mjs.map +0 -7
- package/dist/lib/browser/chunk-75LH4EUR.mjs.map +0 -7
- package/dist/lib/browser/chunk-E7DXDICD.mjs +0 -282
- package/dist/lib/browser/chunk-E7DXDICD.mjs.map +0 -7
- package/dist/lib/browser/chunk-EZVXV6DA.mjs.map +0 -7
- package/dist/lib/browser/chunk-I3QSGUFJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-JO2O7W6J.mjs +0 -254
- package/dist/lib/browser/chunk-JO2O7W6J.mjs.map +0 -7
- package/dist/lib/browser/chunk-N6M34EUC.mjs.map +0 -7
- package/dist/lib/browser/chunk-NM4WQS4F.mjs.map +0 -7
- package/dist/lib/browser/compiler-G2N2CG63.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-JLU7DVLQ.mjs.map +0 -7
- package/dist/lib/browser/react-surface-76SDTUYG.mjs.map +0 -7
- package/dist/lib/node-esm/DeploymentDialog-I63ZC2HH.mjs +0 -14
- package/dist/lib/node-esm/NotebookContainer-QY5NJGJI.mjs.map +0 -7
- package/dist/lib/node-esm/ScriptContainer-SVXCSLNH.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-UXJGHXSL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-4X375PGY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-67OVZHI3.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-C2ORIPKH.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-OG2SIKHE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SMFPSKQT.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VRSDE4CI.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VZAFGLD7.mjs +0 -283
- package/dist/lib/node-esm/chunk-VZAFGLD7.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YW36TZ7K.mjs +0 -255
- package/dist/lib/node-esm/chunk-YW36TZ7K.mjs.map +0 -7
- package/dist/lib/node-esm/compiler-PLDAZ5GJ.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-SFGTIFOG.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-SHEBNW4R.mjs.map +0 -7
- package/dist/types/src/notebook/notebook.d.ts.map +0 -1
- package/dist/types/src/notebook/notebook.test.d.ts +0 -2
- package/dist/types/src/notebook/notebook.test.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -61
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/src/types/schema.ts +0 -48
- /package/dist/lib/browser/{DeploymentDialog-65TWT6S5.mjs.map → DeploymentDialog-MZX4T77L.mjs.map} +0 -0
- /package/dist/lib/{node-esm/blueprint-definition-AIYFOT7Q.mjs.map → browser/blueprint-definition-6PZWZM2Y.mjs.map} +0 -0
- /package/dist/lib/{node-esm/DeploymentDialog-I63ZC2HH.mjs.map → browser/chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-OKXN2N7M.mjs.map → chunk-UOQ6NCH3.mjs.map} +0 -0
- /package/dist/lib/{node-esm/settings-5TYXQ42N.mjs.map → browser/settings-LNLSTZM4.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-NUXZQQ6P.mjs.map → chunk-55JZVM6K.mjs.map} +0 -0
|
@@ -2,15 +2,28 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Cause from 'effect/Cause';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
import * as Exit from 'effect/Exit';
|
|
8
|
+
import React, { useCallback, useMemo, useState } from 'react';
|
|
6
9
|
|
|
7
|
-
import {
|
|
10
|
+
import { Agent } from '@dxos/assistant-toolkit';
|
|
11
|
+
import { Blueprint, Prompt } from '@dxos/blueprints';
|
|
12
|
+
import { Filter, Obj, Query, Ref } from '@dxos/echo';
|
|
13
|
+
import { QueryBuilder } from '@dxos/echo-query';
|
|
14
|
+
import { type FunctionDefinition, FunctionInvocationService } from '@dxos/functions';
|
|
15
|
+
import { InvocationTracer } from '@dxos/functions-runtime';
|
|
16
|
+
import { TracingServiceExt } from '@dxos/functions-runtime';
|
|
8
17
|
import { invariant } from '@dxos/invariant';
|
|
9
|
-
import {
|
|
18
|
+
import { log } from '@dxos/log';
|
|
19
|
+
import { useComputeRuntimeCallback } from '@dxos/plugin-automation';
|
|
20
|
+
import { Graph } from '@dxos/plugin-explorer/types';
|
|
10
21
|
import { getSpace } from '@dxos/react-client/echo';
|
|
11
22
|
import { DropdownMenu, IconButton, Toolbar, useTranslation } from '@dxos/react-ui';
|
|
23
|
+
import { useAttention } from '@dxos/react-ui-attention';
|
|
12
24
|
import { StackItem } from '@dxos/react-ui-stack';
|
|
13
|
-
import {
|
|
25
|
+
import { Text } from '@dxos/schema';
|
|
26
|
+
import { isNonNullable } from '@dxos/util';
|
|
14
27
|
|
|
15
28
|
import { meta } from '../meta';
|
|
16
29
|
import { ComputeGraph } from '../notebook';
|
|
@@ -19,6 +32,8 @@ import { type Notebook } from '../types';
|
|
|
19
32
|
import { NotebookMenu, NotebookStack, type NotebookStackProps } from './NotebookStack';
|
|
20
33
|
import { type TypescriptEditorProps } from './TypescriptEditor';
|
|
21
34
|
|
|
35
|
+
const INCLUDE_BLUEPRINTS = ['dxos.org/blueprint/assistant', 'dxos.org/blueprint/markdown'];
|
|
36
|
+
|
|
22
37
|
// TODO(burdon): Support calling named deployed functions (as with sheet).
|
|
23
38
|
|
|
24
39
|
export type NotebookContainerProps = {
|
|
@@ -29,12 +44,85 @@ export type NotebookContainerProps = {
|
|
|
29
44
|
export const NotebookContainer = ({ notebook, env }: NotebookContainerProps) => {
|
|
30
45
|
const { t } = useTranslation(meta.id);
|
|
31
46
|
const space = getSpace(notebook);
|
|
47
|
+
const attendableId = notebook ? Obj.getDXN(notebook).toString() : '';
|
|
48
|
+
const { hasAttention } = useAttention(attendableId);
|
|
49
|
+
|
|
50
|
+
// TODO(burdon): Consolidate execution and state (with graph).
|
|
51
|
+
// Generalize ComputeGraph evaluation function (using effects).
|
|
32
52
|
const graph = useMemo(() => notebook && new ComputeGraph(notebook), [notebook]);
|
|
33
53
|
|
|
54
|
+
const [queryValues, setQueryValues] = useState<Record<string, any>>({});
|
|
55
|
+
const handleExecQueries = useCallback(async () => {
|
|
56
|
+
invariant(space);
|
|
57
|
+
|
|
58
|
+
const builder = new QueryBuilder();
|
|
59
|
+
for (const cell of notebook?.cells ?? []) {
|
|
60
|
+
if (cell.type === 'query') {
|
|
61
|
+
if (cell.source?.target) {
|
|
62
|
+
const source = cell.source.target.content;
|
|
63
|
+
const { name, filter } = builder.build(source);
|
|
64
|
+
if (filter) {
|
|
65
|
+
const ast = Query.select(filter).ast;
|
|
66
|
+
const view = cell.view?.target;
|
|
67
|
+
if (!view) {
|
|
68
|
+
const graph = Graph.make({ query: { ast } });
|
|
69
|
+
const { view } = await Graph.makeView({
|
|
70
|
+
space,
|
|
71
|
+
presentation: graph,
|
|
72
|
+
});
|
|
73
|
+
cell.view = Ref.make(view);
|
|
74
|
+
cell.name = name;
|
|
75
|
+
} else {
|
|
76
|
+
view.query.ast = ast;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (cell.name && cell.view?.target) {
|
|
82
|
+
const view = Obj.getSnapshot(cell.view?.target);
|
|
83
|
+
const query = Query.fromAst(view.query.ast);
|
|
84
|
+
const result = await space?.db.query(query).run();
|
|
85
|
+
const objectIds = result?.objects?.map((obj) => obj.id);
|
|
86
|
+
setQueryValues((prev) => ({ ...prev, [cell.name!]: objectIds }));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}, [space, notebook, graph]);
|
|
91
|
+
|
|
92
|
+
const [promptResults, setPromptResults] = useState<Record<string, string>>({});
|
|
93
|
+
const handleExecPrompts = useComputeRuntimeCallback(
|
|
94
|
+
space,
|
|
95
|
+
Effect.fnUntraced(function* () {
|
|
96
|
+
invariant(graph);
|
|
97
|
+
|
|
98
|
+
const prompts =
|
|
99
|
+
notebook?.cells
|
|
100
|
+
.filter((cell) => cell.type === 'prompt')
|
|
101
|
+
.map((cell) => cell.prompt)
|
|
102
|
+
.filter(isNonNullable) ?? [];
|
|
103
|
+
|
|
104
|
+
for (const prompt of prompts) {
|
|
105
|
+
yield* runPrompt({
|
|
106
|
+
prompt,
|
|
107
|
+
input: { ...queryValues, ...graph.valuesByName.value },
|
|
108
|
+
onResult: (result) =>
|
|
109
|
+
setPromptResults((prev) => ({
|
|
110
|
+
...prev,
|
|
111
|
+
[prompt.dxn.toString()]: result,
|
|
112
|
+
})),
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}),
|
|
116
|
+
[notebook, graph, queryValues],
|
|
117
|
+
);
|
|
118
|
+
|
|
34
119
|
// TODO(burdon): Cache values in context (preserve when switched).
|
|
35
|
-
const handleCompute = useCallback(() => {
|
|
36
|
-
|
|
37
|
-
|
|
120
|
+
const handleCompute = useCallback(async () => {
|
|
121
|
+
// TODO(burdon): Generalize executors (dependencies).
|
|
122
|
+
await graph?.evaluate();
|
|
123
|
+
await handleExecQueries();
|
|
124
|
+
await handleExecPrompts();
|
|
125
|
+
}, [graph, handleExecQueries, handleExecPrompts]);
|
|
38
126
|
|
|
39
127
|
const handleRearrange = useCallback<NonNullable<NotebookStackProps['onRearrange']>>(
|
|
40
128
|
(source, target) => {
|
|
@@ -52,20 +140,24 @@ export const NotebookContainer = ({ notebook, env }: NotebookContainerProps) =>
|
|
|
52
140
|
);
|
|
53
141
|
|
|
54
142
|
const handleCellInsert = useCallback<NonNullable<NotebookStackProps['onCellInsert']>>(
|
|
55
|
-
(type, after) => {
|
|
143
|
+
async (type, after) => {
|
|
56
144
|
invariant(notebook);
|
|
57
145
|
const cell: Notebook.Cell = { id: crypto.randomUUID(), type };
|
|
58
146
|
switch (type) {
|
|
59
147
|
case 'markdown':
|
|
60
148
|
case 'script':
|
|
61
149
|
case 'query': {
|
|
62
|
-
cell.
|
|
150
|
+
cell.source = Ref.make(Text.make());
|
|
63
151
|
break;
|
|
64
152
|
}
|
|
65
153
|
|
|
66
154
|
case 'prompt': {
|
|
67
155
|
if (space) {
|
|
68
|
-
|
|
156
|
+
const result = await space.db.query(Query.select(Filter.type(Blueprint.Blueprint))).run();
|
|
157
|
+
const blueprints = result.objects
|
|
158
|
+
.filter((blueprint) => INCLUDE_BLUEPRINTS.includes(blueprint.key))
|
|
159
|
+
.map((blueprint) => Ref.make(blueprint));
|
|
160
|
+
cell.prompt = Ref.make(Prompt.make({ instructions: '', blueprints }));
|
|
69
161
|
}
|
|
70
162
|
break;
|
|
71
163
|
}
|
|
@@ -90,7 +182,7 @@ export const NotebookContainer = ({ notebook, env }: NotebookContainerProps) =>
|
|
|
90
182
|
|
|
91
183
|
return (
|
|
92
184
|
<StackItem.Content toolbar>
|
|
93
|
-
<Toolbar.Root textBlockWidth>
|
|
185
|
+
<Toolbar.Root disabled={!hasAttention} textBlockWidth>
|
|
94
186
|
<DropdownMenu.Root>
|
|
95
187
|
<DropdownMenu.Trigger asChild>
|
|
96
188
|
<IconButton icon='ph--plus--regular' iconOnly label={t('notebook cell insert label')} />
|
|
@@ -112,6 +204,7 @@ export const NotebookContainer = ({ notebook, env }: NotebookContainerProps) =>
|
|
|
112
204
|
notebook={notebook}
|
|
113
205
|
graph={graph}
|
|
114
206
|
env={env}
|
|
207
|
+
promptResults={promptResults}
|
|
115
208
|
onRearrange={handleRearrange}
|
|
116
209
|
onCellInsert={handleCellInsert}
|
|
117
210
|
onCellDelete={handleCellDelete}
|
|
@@ -122,3 +215,49 @@ export const NotebookContainer = ({ notebook, env }: NotebookContainerProps) =>
|
|
|
122
215
|
};
|
|
123
216
|
|
|
124
217
|
export default NotebookContainer;
|
|
218
|
+
|
|
219
|
+
// TODO(wittjosiah): Factor out. Copied from PromptArticle in plugin-assistant.
|
|
220
|
+
const runPrompt = Effect.fn(function* ({
|
|
221
|
+
prompt,
|
|
222
|
+
input,
|
|
223
|
+
onResult,
|
|
224
|
+
}: {
|
|
225
|
+
prompt: Ref.Ref<Prompt.Prompt>;
|
|
226
|
+
input: Record<string, any>;
|
|
227
|
+
onResult: (result: string) => void;
|
|
228
|
+
}) {
|
|
229
|
+
const inputData: FunctionDefinition.Input<typeof Agent.prompt> = {
|
|
230
|
+
prompt,
|
|
231
|
+
input,
|
|
232
|
+
};
|
|
233
|
+
const tracer = yield* InvocationTracer;
|
|
234
|
+
const trace = yield* tracer.traceInvocationStart({
|
|
235
|
+
target: undefined,
|
|
236
|
+
payload: {
|
|
237
|
+
data: {},
|
|
238
|
+
},
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
// Invoke the function.
|
|
242
|
+
const result = yield* FunctionInvocationService.invokeFunction(Agent.prompt, inputData).pipe(
|
|
243
|
+
Effect.provide(TracingServiceExt.layerQueue(trace.invocationTraceQueue)),
|
|
244
|
+
Effect.exit,
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
Exit.match(result, {
|
|
248
|
+
onFailure: (cause) => {
|
|
249
|
+
const error = Cause.prettyErrors(cause)[0];
|
|
250
|
+
log.error(error.message, error.cause ?? error.stack);
|
|
251
|
+
onResult(error.message);
|
|
252
|
+
},
|
|
253
|
+
onSuccess: (result: any) => {
|
|
254
|
+
onResult(result.note);
|
|
255
|
+
},
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
yield* tracer.traceInvocationEnd({
|
|
259
|
+
trace,
|
|
260
|
+
// TODO(dmaretskyi): Might miss errors.
|
|
261
|
+
exception: Exit.isFailure(result) ? Cause.prettyErrors(result.cause)[0] : undefined,
|
|
262
|
+
});
|
|
263
|
+
});
|
|
@@ -4,18 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useCallback, useMemo } from 'react';
|
|
6
6
|
|
|
7
|
-
import { Surface } from '@dxos/app-framework';
|
|
8
|
-
import { Query, Ref } from '@dxos/echo';
|
|
9
|
-
import { QueryBuilder } from '@dxos/echo-query';
|
|
7
|
+
import { Surface } from '@dxos/app-framework/react';
|
|
10
8
|
import { invariant } from '@dxos/invariant';
|
|
11
|
-
import {
|
|
12
|
-
import { Chat } from '@dxos/plugin-assistant';
|
|
13
|
-
import { Graph } from '@dxos/plugin-explorer/types';
|
|
9
|
+
import { TemplateEditor } from '@dxos/plugin-assistant';
|
|
14
10
|
import { createDocAccessor } from '@dxos/react-client/echo';
|
|
15
11
|
import { type Space } from '@dxos/react-client/echo';
|
|
16
|
-
import {
|
|
12
|
+
import { useThemeContext, useTranslation } from '@dxos/react-ui';
|
|
17
13
|
import { QueryEditor, type QueryEditorProps } from '@dxos/react-ui-components';
|
|
18
14
|
import {
|
|
15
|
+
type BasicExtensionsOptions,
|
|
19
16
|
Editor,
|
|
20
17
|
type EditorProps,
|
|
21
18
|
createBasicExtensions,
|
|
@@ -42,82 +39,51 @@ export type NotebookCellProps = {
|
|
|
42
39
|
graph?: ComputeGraph;
|
|
43
40
|
dragging?: boolean;
|
|
44
41
|
cell: Notebook.Cell;
|
|
42
|
+
promptResults?: Record<string, string>;
|
|
45
43
|
} & (Pick<NotebookMenuProps, 'onCellInsert' | 'onCellDelete'> & Pick<TypescriptEditorProps, 'env'>);
|
|
46
44
|
|
|
47
|
-
// TODO(burdon):
|
|
48
|
-
export const NotebookCell = ({ space, graph, dragging, cell, env }: NotebookCellProps) => {
|
|
45
|
+
// TODO(burdon): Show evaluation errors.
|
|
46
|
+
export const NotebookCell = ({ space, graph, dragging, cell, promptResults, env }: NotebookCellProps) => {
|
|
49
47
|
const { t } = useTranslation(meta.id);
|
|
50
48
|
|
|
51
|
-
//
|
|
52
|
-
// Common.
|
|
53
|
-
//
|
|
54
49
|
const extensions = useMemo(() => {
|
|
55
|
-
return cell.
|
|
56
|
-
? [
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
return cell.source?.target
|
|
51
|
+
? [
|
|
52
|
+
createDataExtensions({
|
|
53
|
+
id: cell.id,
|
|
54
|
+
text: createDocAccessor(cell.source.target, ['content']),
|
|
55
|
+
}),
|
|
56
|
+
].filter(isNonNullable)
|
|
59
57
|
: [];
|
|
60
|
-
}, [cell.
|
|
58
|
+
}, [cell.source?.target]);
|
|
61
59
|
|
|
62
|
-
//
|
|
63
|
-
// Query.
|
|
64
|
-
//
|
|
65
60
|
const view = cell.view?.target;
|
|
66
|
-
const builder = useMemo(() => new QueryBuilder(), []);
|
|
67
|
-
useAsyncEffect(async () => {
|
|
68
|
-
if (!space || !cell.script?.target) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (cell.type === 'query') {
|
|
73
|
-
const query = cell.script.target.content;
|
|
74
|
-
const filter = builder.build(query);
|
|
75
|
-
if (filter) {
|
|
76
|
-
const ast = Query.select(filter).ast;
|
|
77
|
-
const view = cell.view?.target;
|
|
78
|
-
if (!view) {
|
|
79
|
-
const graph = Graph.make({ query: { ast } });
|
|
80
|
-
const { view } = await Graph.makeView({ space, presentation: graph });
|
|
81
|
-
cell.view = Ref.make(view);
|
|
82
|
-
} else {
|
|
83
|
-
view.query.ast = ast;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}, [space, builder, cell, cell.script?.target?.content]);
|
|
88
61
|
|
|
89
62
|
const handleQueryChange = useCallback<NonNullable<QueryEditorProps['onChange']>>(
|
|
90
63
|
(value: string) => {
|
|
91
|
-
invariant(cell.
|
|
92
|
-
cell.
|
|
64
|
+
invariant(cell.source?.target);
|
|
65
|
+
cell.source.target.content = value;
|
|
93
66
|
},
|
|
94
67
|
[cell],
|
|
95
68
|
);
|
|
96
69
|
|
|
97
|
-
//
|
|
98
|
-
// Prompt.
|
|
99
|
-
// TODO(burdon): Add values to context or system message (via blueprint?).
|
|
100
|
-
//
|
|
101
|
-
const services = useChatServices({ space, chat: cell.chat?.target });
|
|
102
|
-
const processor = useChatProcessor({ chat: cell.chat?.target, services });
|
|
103
|
-
|
|
104
70
|
switch (cell.type) {
|
|
105
71
|
case 'markdown':
|
|
106
|
-
if (!cell.
|
|
72
|
+
if (!cell.source?.target) {
|
|
107
73
|
return null;
|
|
108
74
|
}
|
|
109
75
|
|
|
110
76
|
return (
|
|
111
|
-
<
|
|
77
|
+
<NotebookTextEditor
|
|
112
78
|
id={cell.id}
|
|
113
79
|
classNames={editorStyles}
|
|
114
|
-
initialValue={cell.
|
|
80
|
+
initialValue={cell.source.target.content}
|
|
115
81
|
extensions={extensions}
|
|
116
82
|
/>
|
|
117
83
|
);
|
|
118
84
|
|
|
119
85
|
case 'script':
|
|
120
|
-
if (!cell.
|
|
86
|
+
if (!cell.source?.target) {
|
|
121
87
|
return null;
|
|
122
88
|
}
|
|
123
89
|
|
|
@@ -127,7 +93,7 @@ export const NotebookCell = ({ space, graph, dragging, cell, env }: NotebookCell
|
|
|
127
93
|
id={cell.id}
|
|
128
94
|
role='section'
|
|
129
95
|
classNames={editorStyles}
|
|
130
|
-
initialValue={cell.
|
|
96
|
+
initialValue={cell.source.target.content}
|
|
131
97
|
extensions={extensions}
|
|
132
98
|
env={env}
|
|
133
99
|
options={{
|
|
@@ -141,33 +107,40 @@ export const NotebookCell = ({ space, graph, dragging, cell, env }: NotebookCell
|
|
|
141
107
|
);
|
|
142
108
|
|
|
143
109
|
case 'query':
|
|
144
|
-
if (!cell.
|
|
110
|
+
if (!cell.source?.target) {
|
|
145
111
|
return null;
|
|
146
112
|
}
|
|
147
113
|
|
|
114
|
+
// TODO(burdon): Remove app-framework deps (via render prop).
|
|
148
115
|
return (
|
|
149
116
|
<div className={mx('bs-full overflow-hidden grid', view && !dragging && 'grid-rows-[min-content_1fr]')}>
|
|
150
117
|
<QueryEditor
|
|
151
118
|
id={cell.id}
|
|
152
119
|
classNames={[editorStyles, 'border-b border-subduedSeparator']}
|
|
153
120
|
db={space?.db}
|
|
154
|
-
value={cell.
|
|
121
|
+
value={cell.source.target.content}
|
|
155
122
|
onChange={handleQueryChange}
|
|
156
123
|
/>
|
|
157
124
|
{view && !dragging && <Surface role='section' limit={1} data={{ subject: view }} />}
|
|
158
125
|
</div>
|
|
159
126
|
);
|
|
160
127
|
|
|
128
|
+
// TODO(burdon): Use streaming response from Chat.
|
|
161
129
|
case 'prompt':
|
|
162
|
-
if (!cell.
|
|
130
|
+
if (!cell.prompt?.target) {
|
|
163
131
|
return null;
|
|
164
132
|
}
|
|
165
133
|
|
|
166
134
|
return (
|
|
167
|
-
|
|
168
|
-
<
|
|
169
|
-
|
|
170
|
-
|
|
135
|
+
<>
|
|
136
|
+
<TemplateEditor
|
|
137
|
+
id={cell.id}
|
|
138
|
+
template={cell.prompt.target.instructions}
|
|
139
|
+
lineNumbers={false}
|
|
140
|
+
classNames={editorStyles}
|
|
141
|
+
/>
|
|
142
|
+
<NotebookPromptResult cell={cell} promptResults={promptResults} />
|
|
143
|
+
</>
|
|
171
144
|
);
|
|
172
145
|
|
|
173
146
|
default:
|
|
@@ -177,7 +150,7 @@ export const NotebookCell = ({ space, graph, dragging, cell, env }: NotebookCell
|
|
|
177
150
|
|
|
178
151
|
const NotebookCellValue = ({ cell, graph }: NotebookCellProps) => {
|
|
179
152
|
const name = graph?.expressions.value[cell.id]?.name;
|
|
180
|
-
const value = graph?.
|
|
153
|
+
const value = graph?.getValue(cell.id);
|
|
181
154
|
if (value == null) {
|
|
182
155
|
return null;
|
|
183
156
|
}
|
|
@@ -200,12 +173,36 @@ const NotebookCellValue = ({ cell, graph }: NotebookCellProps) => {
|
|
|
200
173
|
);
|
|
201
174
|
};
|
|
202
175
|
|
|
203
|
-
const
|
|
176
|
+
const NotebookPromptResult = ({ cell, promptResults }: NotebookCellProps) => {
|
|
177
|
+
if (!cell.prompt) {
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const value = promptResults?.[cell.prompt.dxn.toString()];
|
|
182
|
+
if (value == null) {
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return (
|
|
187
|
+
<div className={mx('flex is-full bg-groupSurface text-description border-t border-subduedSeparator', valueStyles)}>
|
|
188
|
+
<NotebookTextEditor readOnly value={value} />
|
|
189
|
+
</div>
|
|
190
|
+
);
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
const NotebookTextEditor = ({
|
|
194
|
+
extensions: extensionsParam,
|
|
195
|
+
readOnly,
|
|
196
|
+
...props
|
|
197
|
+
}: EditorProps & Pick<BasicExtensionsOptions, 'readOnly'>) => {
|
|
204
198
|
const { t } = useTranslation(meta.id);
|
|
205
199
|
const { themeMode } = useThemeContext();
|
|
206
200
|
const extensions = useMemo(() => {
|
|
207
201
|
return [
|
|
208
|
-
createBasicExtensions({
|
|
202
|
+
createBasicExtensions({
|
|
203
|
+
placeholder: t('notebook markdown placeholder'),
|
|
204
|
+
readOnly,
|
|
205
|
+
}),
|
|
209
206
|
createThemeExtensions({ themeMode, syntaxHighlighting: true }),
|
|
210
207
|
createMarkdownExtensions(),
|
|
211
208
|
decorateMarkdown(),
|
|
@@ -4,7 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { IntentPlugin, SettingsPlugin } from '@dxos/app-framework';
|
|
8
|
+
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
9
|
+
import { AutomationPlugin } from '@dxos/plugin-automation';
|
|
10
|
+
import { ClientPlugin } from '@dxos/plugin-client';
|
|
11
|
+
import { SpacePlugin } from '@dxos/plugin-space';
|
|
8
12
|
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
9
13
|
|
|
10
14
|
import { createNotebook } from '../../testing';
|
|
@@ -15,7 +19,25 @@ import { NotebookStack } from './NotebookStack';
|
|
|
15
19
|
const meta = {
|
|
16
20
|
title: 'plugins/plugin-script/NotebookStack',
|
|
17
21
|
component: NotebookStack,
|
|
18
|
-
decorators: [
|
|
22
|
+
decorators: [
|
|
23
|
+
withTheme,
|
|
24
|
+
withLayout({ container: 'column', classNames: 'is-prose' }),
|
|
25
|
+
// TODO(burdon): Factor out Surface to avoid dependency on app-framework.
|
|
26
|
+
withPluginManager({
|
|
27
|
+
plugins: [
|
|
28
|
+
ClientPlugin({
|
|
29
|
+
onClientInitialized: async ({ client }) => {
|
|
30
|
+
await client.halo.createIdentity();
|
|
31
|
+
await client.spaces.waitUntilReady();
|
|
32
|
+
},
|
|
33
|
+
}),
|
|
34
|
+
SpacePlugin({}),
|
|
35
|
+
SettingsPlugin(),
|
|
36
|
+
IntentPlugin(),
|
|
37
|
+
AutomationPlugin(),
|
|
38
|
+
],
|
|
39
|
+
}),
|
|
40
|
+
],
|
|
19
41
|
parameters: {
|
|
20
42
|
translations,
|
|
21
43
|
},
|
|
@@ -20,7 +20,7 @@ export type NotebookStackProps = ThemedClassName<
|
|
|
20
20
|
{
|
|
21
21
|
notebook?: Notebook.Notebook;
|
|
22
22
|
onRearrange?: StackProps['onRearrange'];
|
|
23
|
-
} & (Pick<NotebookSectionProps, 'space' | 'graph' | 'onCellInsert' | 'onCellDelete'> &
|
|
23
|
+
} & (Pick<NotebookSectionProps, 'space' | 'graph' | 'promptResults' | 'onCellInsert' | 'onCellDelete'> &
|
|
24
24
|
Pick<TypescriptEditorProps, 'env'>)
|
|
25
25
|
>;
|
|
26
26
|
|
|
@@ -37,11 +37,18 @@ export const NotebookStack = ({ classNames, notebook, onRearrange, ...props }: N
|
|
|
37
37
|
|
|
38
38
|
type NotebookSectionProps = NotebookCellProps;
|
|
39
39
|
|
|
40
|
-
const NotebookSection = ({
|
|
40
|
+
const NotebookSection = ({
|
|
41
|
+
cell,
|
|
42
|
+
space,
|
|
43
|
+
env,
|
|
44
|
+
promptResults,
|
|
45
|
+
onCellInsert,
|
|
46
|
+
onCellDelete,
|
|
47
|
+
...props
|
|
48
|
+
}: NotebookSectionProps) => {
|
|
41
49
|
const { t } = useTranslation(meta.id);
|
|
42
|
-
const resizable = cell.type === 'query'
|
|
50
|
+
const resizable = cell.type === 'query';
|
|
43
51
|
|
|
44
|
-
// TOOD(burdon): Set size if no extrinsic size (provider).
|
|
45
52
|
return (
|
|
46
53
|
<StackItem.Root role='section' item={cell} draggable classNames={resizable && minSectionHeight}>
|
|
47
54
|
<StackItem.Heading classNames='bs-full p-1 justify-between attention-surface'>
|
|
@@ -72,7 +79,7 @@ const NotebookSection = ({ cell, space, env, onCellInsert, onCellDelete, ...prop
|
|
|
72
79
|
</StackItem.DragPreview>
|
|
73
80
|
|
|
74
81
|
<StackItem.Content classNames='overflow-visible'>
|
|
75
|
-
<NotebookCell space={space} cell={cell} env={env} {...props} />
|
|
82
|
+
<NotebookCell space={space} cell={cell} env={env} promptResults={promptResults} {...props} />
|
|
76
83
|
</StackItem.Content>
|
|
77
84
|
</StackItem.Root>
|
|
78
85
|
);
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useMemo } from 'react';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
7
|
+
import { type Script } from '@dxos/functions';
|
|
8
8
|
import { createDocAccessor, getSpace } from '@dxos/react-client/echo';
|
|
9
9
|
import { useIdentity } from '@dxos/react-client/halo';
|
|
10
10
|
import { createDataExtensions, listener, stackItemContentEditorClassNames } from '@dxos/react-ui-editor';
|
|
@@ -18,7 +18,7 @@ import { TypescriptEditor, type TypescriptEditorProps } from './TypescriptEditor
|
|
|
18
18
|
|
|
19
19
|
export type ScriptEditorProps = {
|
|
20
20
|
role: string;
|
|
21
|
-
script:
|
|
21
|
+
script: Script.Script;
|
|
22
22
|
settings?: ScriptSettings;
|
|
23
23
|
} & Pick<TypescriptEditorProps, 'env'>;
|
|
24
24
|
|
|
@@ -33,7 +33,7 @@ export const ScriptContainer = ({ role, script, settings = { editorInputMode: 'v
|
|
|
33
33
|
script.source.target
|
|
34
34
|
? [
|
|
35
35
|
listener({
|
|
36
|
-
onChange: (text) => {
|
|
36
|
+
onChange: ({ text }) => {
|
|
37
37
|
if (script.source.target?.content !== text) {
|
|
38
38
|
script.changed = true;
|
|
39
39
|
}
|
|
@@ -6,11 +6,9 @@ import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
|
6
6
|
|
|
7
7
|
import { IntentPlugin } from '@dxos/app-framework';
|
|
8
8
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
9
|
-
import {
|
|
10
|
-
import { ScriptType } from '@dxos/functions';
|
|
9
|
+
import { Script } from '@dxos/functions';
|
|
11
10
|
import { ClientPlugin } from '@dxos/plugin-client';
|
|
12
11
|
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
13
|
-
import { DataType } from '@dxos/schema';
|
|
14
12
|
|
|
15
13
|
import { translations } from '../../translations';
|
|
16
14
|
|
|
@@ -23,7 +21,9 @@ const meta = {
|
|
|
23
21
|
decorators: [
|
|
24
22
|
withTheme,
|
|
25
23
|
withLayout({ classNames: 'is-prose' }),
|
|
26
|
-
withPluginManager({
|
|
24
|
+
withPluginManager({
|
|
25
|
+
plugins: [IntentPlugin(), ClientPlugin({})],
|
|
26
|
+
}),
|
|
27
27
|
],
|
|
28
28
|
parameters: {
|
|
29
29
|
layout: 'centered',
|
|
@@ -38,10 +38,10 @@ type Story = StoryObj<typeof meta>;
|
|
|
38
38
|
export const Default: Story = {
|
|
39
39
|
args: {
|
|
40
40
|
state: {},
|
|
41
|
-
script:
|
|
41
|
+
script: Script.make({
|
|
42
42
|
name: 'test',
|
|
43
43
|
description: 'test',
|
|
44
|
-
source:
|
|
44
|
+
source: 'test',
|
|
45
45
|
}),
|
|
46
46
|
},
|
|
47
47
|
};
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Atom } from '@effect-atom/atom-react';
|
|
6
6
|
import React, { useMemo } from 'react';
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { ElevationProvider,
|
|
8
|
+
import { Obj } from '@dxos/echo';
|
|
9
|
+
import { type Script } from '@dxos/functions';
|
|
10
|
+
import { ElevationProvider, useTranslation } from '@dxos/react-ui';
|
|
11
11
|
import {
|
|
12
12
|
type ActionGraphProps,
|
|
13
13
|
MenuProvider,
|
|
@@ -27,13 +27,13 @@ import {
|
|
|
27
27
|
} from '../../hooks';
|
|
28
28
|
import { meta } from '../../meta';
|
|
29
29
|
|
|
30
|
-
export type ScriptToolbarProps =
|
|
30
|
+
export type ScriptToolbarProps = {
|
|
31
31
|
role?: string;
|
|
32
|
-
script:
|
|
32
|
+
script: Script.Script;
|
|
33
33
|
state: ScriptToolbarState;
|
|
34
|
-
}
|
|
34
|
+
};
|
|
35
35
|
|
|
36
|
-
export const ScriptToolbar = ({ script, role, state
|
|
36
|
+
export const ScriptToolbar = ({ script, role, state }: ScriptToolbarProps) => {
|
|
37
37
|
const { t } = useTranslation(meta.id);
|
|
38
38
|
const options = useDeployDeps({ script });
|
|
39
39
|
const menu = useMemo(() => createToolbarActions({ state, script, t, ...options }), [state, script, options, t]);
|
|
@@ -41,15 +41,15 @@ export const ScriptToolbar = ({ script, role, state, classNames }: ScriptToolbar
|
|
|
41
41
|
|
|
42
42
|
return (
|
|
43
43
|
<ElevationProvider elevation={role === 'section' ? 'positioned' : 'base'}>
|
|
44
|
-
<MenuProvider {...actions} attendableId={
|
|
45
|
-
<ToolbarMenu
|
|
44
|
+
<MenuProvider {...actions} attendableId={Obj.getDXN(script).toString()}>
|
|
45
|
+
<ToolbarMenu />
|
|
46
46
|
</MenuProvider>
|
|
47
47
|
</ElevationProvider>
|
|
48
48
|
);
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
const createToolbarActions = ({ state, script, ...options }: CreateDeployOptions):
|
|
52
|
-
|
|
51
|
+
const createToolbarActions = ({ state, script, ...options }: CreateDeployOptions): Atom.Atom<ActionGraphProps> =>
|
|
52
|
+
Atom.make((get) =>
|
|
53
53
|
get(
|
|
54
54
|
rxFromSignal(() => {
|
|
55
55
|
const templateSelect = createTemplateSelect(script);
|