@nodetool-ai/app-runtime 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/README.md +104 -0
  2. package/dist/.nodetool-build-stamp +1 -0
  3. package/dist/actions.d.ts +85 -0
  4. package/dist/actions.d.ts.map +1 -0
  5. package/dist/actions.js +65 -0
  6. package/dist/actions.js.map +1 -0
  7. package/dist/bindings.d.ts +109 -0
  8. package/dist/bindings.d.ts.map +1 -0
  9. package/dist/bindings.js +257 -0
  10. package/dist/bindings.js.map +1 -0
  11. package/dist/bundle.d.ts +167 -0
  12. package/dist/bundle.d.ts.map +1 -0
  13. package/dist/bundle.js +289 -0
  14. package/dist/bundle.js.map +1 -0
  15. package/dist/chat.d.ts +33 -0
  16. package/dist/chat.d.ts.map +1 -0
  17. package/dist/chat.js +77 -0
  18. package/dist/chat.js.map +1 -0
  19. package/dist/conditions.d.ts +66 -0
  20. package/dist/conditions.d.ts.map +1 -0
  21. package/dist/conditions.js +221 -0
  22. package/dist/conditions.js.map +1 -0
  23. package/dist/doc-ops.d.ts +205 -0
  24. package/dist/doc-ops.d.ts.map +1 -0
  25. package/dist/doc-ops.js +304 -0
  26. package/dist/doc-ops.js.map +1 -0
  27. package/dist/document.d.ts +186 -0
  28. package/dist/document.d.ts.map +1 -0
  29. package/dist/document.js +326 -0
  30. package/dist/document.js.map +1 -0
  31. package/dist/documents.d.ts +38 -0
  32. package/dist/documents.d.ts.map +1 -0
  33. package/dist/documents.js +108 -0
  34. package/dist/documents.js.map +1 -0
  35. package/dist/fold.d.ts +50 -0
  36. package/dist/fold.d.ts.map +1 -0
  37. package/dist/fold.js +175 -0
  38. package/dist/fold.js.map +1 -0
  39. package/dist/index.d.ts +26 -0
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/index.js +26 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/input-validation.d.ts +4 -0
  44. package/dist/input-validation.d.ts.map +1 -0
  45. package/dist/input-validation.js +26 -0
  46. package/dist/input-validation.js.map +1 -0
  47. package/dist/mutable.d.ts +8 -0
  48. package/dist/mutable.d.ts.map +1 -0
  49. package/dist/mutable.js +2 -0
  50. package/dist/mutable.js.map +1 -0
  51. package/dist/operations.d.ts +51 -0
  52. package/dist/operations.d.ts.map +1 -0
  53. package/dist/operations.js +95 -0
  54. package/dist/operations.js.map +1 -0
  55. package/dist/policy.d.ts +29 -0
  56. package/dist/policy.d.ts.map +1 -0
  57. package/dist/policy.js +16 -0
  58. package/dist/policy.js.map +1 -0
  59. package/dist/predicates.d.ts +19 -0
  60. package/dist/predicates.d.ts.map +1 -0
  61. package/dist/predicates.js +19 -0
  62. package/dist/predicates.js.map +1 -0
  63. package/dist/script-run.d.ts +86 -0
  64. package/dist/script-run.d.ts.map +1 -0
  65. package/dist/script-run.js +113 -0
  66. package/dist/script-run.js.map +1 -0
  67. package/dist/state.d.ts +176 -0
  68. package/dist/state.d.ts.map +1 -0
  69. package/dist/state.js +357 -0
  70. package/dist/state.js.map +1 -0
  71. package/dist/widgets.d.ts +89 -0
  72. package/dist/widgets.d.ts.map +1 -0
  73. package/dist/widgets.js +667 -0
  74. package/dist/widgets.js.map +1 -0
  75. package/package.json +55 -0
package/README.md ADDED
@@ -0,0 +1,104 @@
1
+ # @nodetool-ai/app-runtime
2
+
3
+ The runtime core for NodeTool mini apps, with no framework and no dependencies.
4
+ A mini app is a UI document plus typed bindings to workflow operations — all
5
+ computation stays in the graph, so the only semantics this layer owns are
6
+ document parsing, binding resolution, instance state, the streaming fold, run
7
+ policy, conditions, and the widget catalog.
8
+
9
+ Four hosts run those semantics: the web runtime, the mobile app, the
10
+ `nodetool app debug` harness, and the eval suites. They share this package so
11
+ they cannot drift. `src/fold.ts` is here because three of them once folded a
12
+ run's messages their own way and disagreed about what an app was showing.
13
+
14
+ ## Modules
15
+
16
+ | Module | Owns |
17
+ | --- | --- |
18
+ | `document.ts` | The `ApplicationDocument` schema and its parser, including lifting legacy `workflow.app_doc` v1–v3 |
19
+ | `bindings.ts` | The binding token (`op:<id>/out:<nodeId>`, `var:<id>`, …), its parser, and the state key it resolves to |
20
+ | `state.ts` | `AppInstanceState`, its four value namespaces, and the pure reducer over `AppStateEvent` |
21
+ | `fold.ts` | Turning a run's `ProcessingMessage`s into state events |
22
+ | `operations.ts` | Resolving an operation binding into the name-keyed `params` a run wants |
23
+ | `policy.ts` | What to do when an operation is asked to run while already running |
24
+ | `conditions.ts` | `visibleWhen` / `disabledWhen` evaluation and `format` templates |
25
+ | `actions.ts` | The six-verb action vocabulary a widget event dispatches |
26
+ | `widgets.ts` | The widget catalog — one table behind the Puck editor config, the harness, and the `app-tools` eval |
27
+ | `doc-ops.ts` | Immutable edits to the non-UI half of a document (operations, variables, resources) |
28
+ | `bundle.ts` | The `ApplicationBundle`: an app plus the full graphs it binds, as one JSON artifact |
29
+ | `script-run.ts` | The contract for an operation that runs a JS script instead of a workflow |
30
+ | `chat.ts` | Reading a bound value as a conversation, for the thread and composer widgets |
31
+ | `documents.ts` | Unwrapping sketch and timeline refs out of a bound value |
32
+
33
+ ## Usage
34
+
35
+ Everything is a pure function, so a host drives the reducer itself. Folding a
36
+ run's messages into the state an app displays:
37
+
38
+ ```ts
39
+ import {
40
+ applyEvents,
41
+ createInstanceState,
42
+ messagesToEvents,
43
+ type InvocationState
44
+ } from "@nodetool-ai/app-runtime";
45
+
46
+ const invocation: InvocationState = {
47
+ id: "job-1",
48
+ operationId: "main",
49
+ status: "running",
50
+ startedAt: Date.now()
51
+ };
52
+
53
+ let state = applyEvents(createInstanceState(), [
54
+ { type: "runStarted", invocation, outputKeys: ["main:out"] }
55
+ ]);
56
+
57
+ state = applyEvents(
58
+ state,
59
+ messagesToEvents(
60
+ [
61
+ { type: "chunk", job_id: "job-1", node_id: "out", content: "Hello " },
62
+ { type: "chunk", job_id: "job-1", node_id: "out", content: "world", done: true },
63
+ { type: "chunk", job_id: "other-job", node_id: "out", content: "!" }
64
+ ],
65
+ {
66
+ resolveInvocation: (jobId) => state.invocations[jobId ?? ""] ?? null,
67
+ outputKey: (opId, nodeId) => `${opId}:${nodeId}`
68
+ }
69
+ )
70
+ );
71
+
72
+ state.outputs["main:out"];
73
+ // { value: "Hello world", invocationId: "job-1", status: "done", revision: 3 }
74
+ ```
75
+
76
+ Two rules that example pins. Text chunks concatenate rather than giving the
77
+ slot one value per token. And the message stamped `other-job` is dropped:
78
+ matching on `job_id` is what stops a second tab, an overlapping run, or a run
79
+ started in the graph editor from writing into this app's values.
80
+
81
+ ## No dependencies, on purpose
82
+
83
+ `dependencies` is empty and stays empty. The Puck document and the workflow
84
+ graph are typed structurally here rather than imported from `@puckeditor/core`
85
+ and `@nodetool-ai/protocol`, so the package loads in a browser bundle, in a
86
+ Node harness, and in React Native without dragging a server-side tree behind
87
+ it. Mobile compiles it from **source** — wired in `mobile/metro.config.js`,
88
+ `mobile/tsconfig.json`, and `mobile/jest.config.js`, all three of which must
89
+ agree.
90
+
91
+ ## Develop
92
+
93
+ ```bash
94
+ npm run build --workspace=packages/app-runtime
95
+ npm run test --workspace=packages/app-runtime
96
+ npm run lint --workspace=packages/app-runtime # tsc --noEmit
97
+ ```
98
+
99
+ What a mini app is: [docs/mini-apps.md](../../docs/mini-apps.md). Every widget,
100
+ binding, action, and condition in tables:
101
+ [docs/mini-apps-reference.md](../../docs/mini-apps-reference.md). Building one:
102
+ [docs/mini-apps-guide.md](../../docs/mini-apps-guide.md). The headless harness
103
+ that drives this package: `nodetool app debug`, in
104
+ [docs/cli.md](../../docs/cli.md).
@@ -0,0 +1 @@
1
+ 2026-09-28T09:19:02.538Z
@@ -0,0 +1,85 @@
1
+ /**
2
+ * The action vocabulary. Six actions, all referencing bindings by ID.
3
+ *
4
+ * Actions are what a widget event dispatches. They are data, not code — the
5
+ * runtime interprets them; there is no place for an app author to write a
6
+ * statement.
7
+ */
8
+ import type { ResourceOperation, ResourceRef } from "./document.js";
9
+ export type AppAction = {
10
+ kind: "run";
11
+ operationId: string;
12
+ from?: string;
13
+ } | {
14
+ kind: "cancel";
15
+ operationId?: string;
16
+ invocationId?: string;
17
+ } | {
18
+ kind: "setVariable";
19
+ variableId: string;
20
+ value?: unknown;
21
+ } | {
22
+ kind: "toggleVariable";
23
+ variableId: string;
24
+ } | {
25
+ kind: "resourceCommand";
26
+ resourceBindingId: string;
27
+ command: ResourceOperation | "upload";
28
+ args?: Record<string, unknown>;
29
+ } | {
30
+ kind: "openResource";
31
+ resourceBindingId: string;
32
+ ref?: ResourceRef;
33
+ };
34
+ export type ActionKind = AppAction["kind"];
35
+ export type EventTrigger = "click" | "change";
36
+ /**
37
+ * How often a change-trigger event fires while a control is being adjusted:
38
+ * "live" every change, "release" only when the control commits (slider
39
+ * release, input blur), "debounce" trailing after a quiet moment.
40
+ */
41
+ export type EventPace = "live" | "release" | "debounce";
42
+ /**
43
+ * A widget event as stored in Puck props — flat, so it maps onto a Puck
44
+ * `array` field. Converted to an {@link AppAction} at dispatch time.
45
+ *
46
+ * `kind` accepts the legacy `setState`/`toggleState` names that v1/v2
47
+ * documents wrote; they mean the same thing as `setVariable`/`toggleVariable`.
48
+ */
49
+ export interface AppEvent {
50
+ trigger: EventTrigger;
51
+ kind: string;
52
+ /** Variable binding for setVariable/toggleVariable. */
53
+ key?: string;
54
+ /** Literal value for setVariable. */
55
+ value?: string;
56
+ /** Which operation a run/cancel targets; defaults to the app's main one. */
57
+ operationId?: string;
58
+ /** Cancel one specific run rather than the operation's latest. */
59
+ invocationId?: string;
60
+ /** Resource binding id for resourceCommand/openResource. */
61
+ resourceBindingId?: string;
62
+ /** Command name for resourceCommand. */
63
+ command?: string;
64
+ pace?: EventPace;
65
+ }
66
+ export interface EventContext {
67
+ /** Operation a bare `run`/`cancel` targets. */
68
+ defaultOperationId: string;
69
+ /** Resolve an event's `key` to a variable id, or null if it has none. */
70
+ resolveVariableId: (key: string | undefined) => string | null;
71
+ /** The triggering widget's write binding, for subgraph-scoped reactive runs. */
72
+ from?: string;
73
+ }
74
+ /**
75
+ * Convert a stored widget event into an action, or null when the event is
76
+ * incomplete (an unresolvable variable, a resource command with no binding) or
77
+ * names a kind this runtime does not know. An unknown kind must not fall
78
+ * through to `run`: executing a workflow is the costly answer to give a typo.
79
+ *
80
+ * An absent or empty `kind` is the one exception — that is how a document
81
+ * written before the field existed spells "run", and how the app-debug parser
82
+ * has always read it.
83
+ */
84
+ export declare const eventToAction: (event: AppEvent, ctx: EventContext) => AppAction | null;
85
+ //# sourceMappingURL=actions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEpE,MAAM,MAAM,SAAS,GACjB;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GACnD;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,GAC/D;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAC5D;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAC9C;IACE,IAAI,EAAE,iBAAiB,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,iBAAiB,GAAG,QAAQ,CAAC;IACtC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,GACD;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,WAAW,CAAA;CAAE,CAAC;AAE3E,MAAM,MAAM,UAAU,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;AAE3C,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE9C;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,CAAC;AAExD;;;;;;GAMG;AACH,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,YAAY,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kEAAkE;IAClE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,4DAA4D;IAC5D,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,wCAAwC;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB;AAUD,MAAM,WAAW,YAAY;IAC3B,+CAA+C;IAC/C,kBAAkB,EAAE,MAAM,CAAC;IAC3B,yEAAyE;IACzE,iBAAiB,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,KAAK,MAAM,GAAG,IAAI,CAAC;IAC9D,gFAAgF;IAChF,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,UACjB,QAAQ,OACV,YAAY,KAChB,SAAS,GAAG,IA+Cd,CAAC"}
@@ -0,0 +1,65 @@
1
+ const RESOURCE_COMMANDS = new Set([
2
+ "read",
3
+ "create",
4
+ "update",
5
+ "delete",
6
+ "upload"
7
+ ]);
8
+ /**
9
+ * Convert a stored widget event into an action, or null when the event is
10
+ * incomplete (an unresolvable variable, a resource command with no binding) or
11
+ * names a kind this runtime does not know. An unknown kind must not fall
12
+ * through to `run`: executing a workflow is the costly answer to give a typo.
13
+ *
14
+ * An absent or empty `kind` is the one exception — that is how a document
15
+ * written before the field existed spells "run", and how the app-debug parser
16
+ * has always read it.
17
+ */
18
+ export const eventToAction = (event, ctx) => {
19
+ switch (event.kind || "run") {
20
+ case "setVariable":
21
+ case "setState": {
22
+ const variableId = ctx.resolveVariableId(event.key);
23
+ return variableId
24
+ ? { kind: "setVariable", variableId, value: event.value ?? "" }
25
+ : null;
26
+ }
27
+ case "toggleVariable":
28
+ case "toggleState": {
29
+ const variableId = ctx.resolveVariableId(event.key);
30
+ return variableId ? { kind: "toggleVariable", variableId } : null;
31
+ }
32
+ case "cancel":
33
+ const cancel = {
34
+ kind: "cancel",
35
+ operationId: event.operationId ?? ctx.defaultOperationId
36
+ };
37
+ if (event.invocationId) {
38
+ cancel.invocationId = event.invocationId;
39
+ }
40
+ return cancel;
41
+ case "resourceCommand": {
42
+ const command = event.command ?? "";
43
+ if (!event.resourceBindingId || !RESOURCE_COMMANDS.has(command))
44
+ return null;
45
+ return {
46
+ kind: "resourceCommand",
47
+ resourceBindingId: event.resourceBindingId,
48
+ command: command
49
+ };
50
+ }
51
+ case "openResource":
52
+ return event.resourceBindingId
53
+ ? { kind: "openResource", resourceBindingId: event.resourceBindingId }
54
+ : null;
55
+ case "run":
56
+ return {
57
+ kind: "run",
58
+ operationId: event.operationId ?? ctx.defaultOperationId,
59
+ from: ctx.from
60
+ };
61
+ default:
62
+ return null;
63
+ }
64
+ };
65
+ //# sourceMappingURL=actions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AA2DA,MAAM,iBAAiB,GAAwB,IAAI,GAAG,CAAC;IACrD,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;CACT,CAAC,CAAC;AAWH;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,KAAe,EACf,GAAiB,EACC,EAAE;IACpB,QAAQ,KAAK,CA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YACjB,OAAO,KAAK,CAAC,iBAAiB;gBAC5B,CAAC,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,iBAAiB,EAAE,KAAK,CAAC,iBAAiB,EAAE;gBACtE,CAAC,CAAC,IAAI,CAAC;QACX,KAAK,KAAK;YACR,OAAO;gBACL,IAAI,EAAE,KAAK;gBACX,WAAW,EAAE,KAAK,CAAC,WAAW,IAAI,GAAG,CAAC,kBAAkB;gBACxD,IAAI,EAAE,GAAG,CAAC,IAAI;aACf,CAAC;QACJ;YACE,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,109 @@
1
+ import type { VariableDeclaration } from "./document.js";
2
+ export type ExecutionField = "running" | "progress" | "error" | "activity";
3
+ export type BindingRef = {
4
+ kind: "input";
5
+ operationId: string;
6
+ nodeId: string;
7
+ } | {
8
+ kind: "output";
9
+ operationId: string;
10
+ nodeId: string;
11
+ } | {
12
+ kind: "nodeProperty";
13
+ operationId: string;
14
+ nodeId: string;
15
+ property: string;
16
+ } | {
17
+ kind: "execution";
18
+ operationId: string;
19
+ field: ExecutionField;
20
+ } | {
21
+ kind: "variable";
22
+ variableId: string;
23
+ } | {
24
+ kind: "view";
25
+ componentId: string;
26
+ prop: string;
27
+ };
28
+ export declare const OPERATION_PREFIX = "op:";
29
+ export declare const VARIABLE_PREFIX = "var:";
30
+ export declare const VIEW_PREFIX = "view:";
31
+ export declare const NODE_BINDING_PREFIX = "node:";
32
+ /** Which namespaced map in {@link AppInstanceState} a ref addresses. */
33
+ export type BindingNamespace = "inputs" | "outputs" | "variables" | "view" | "invocations";
34
+ export declare const namespaceOf: (ref: BindingRef) => BindingNamespace;
35
+ /**
36
+ * The key this ref occupies inside its namespace. Inputs and outputs are keyed
37
+ * `opId:nodeId`, so two operations that share a workflow never collide.
38
+ */
39
+ export declare const stateKey: (ref: BindingRef) => string;
40
+ /**
41
+ * Inverse of {@link stateKey} for the `inputs` namespace: `opId:nodeId` or
42
+ * `opId:nodeId#property`. Lets a runtime walk its input slots and rebuild the
43
+ * graph overlay a node-property binding drives.
44
+ */
45
+ export declare const parseInputStateKey: (key: string) => {
46
+ operationId: string;
47
+ nodeId: string;
48
+ property?: string;
49
+ } | null;
50
+ export declare const encodeBinding: (ref: BindingRef) => string;
51
+ /** The graph surface one operation exposes to bindings. */
52
+ export interface OperationIO {
53
+ operationId: string;
54
+ inputs: ReadonlyArray<{
55
+ nodeId: string;
56
+ name: string;
57
+ }>;
58
+ outputs: ReadonlyArray<{
59
+ nodeId: string;
60
+ name: string;
61
+ }>;
62
+ nodeIds: ReadonlyArray<string>;
63
+ /** SetVariable channel names the graph publishes (a legacy variable source). */
64
+ variableNames?: ReadonlyArray<string>;
65
+ }
66
+ export interface BindingScope {
67
+ operations: ReadonlyArray<OperationIO>;
68
+ variables: ReadonlyArray<VariableDeclaration>;
69
+ /** Operation a legacy (name-only) binding resolves against. */
70
+ defaultOperationId: string;
71
+ }
72
+ /** Parse an explicit (already ID-based) binding token. Legacy names return null. */
73
+ export declare const parseBinding: (binding?: string | null) => BindingRef | null;
74
+ /**
75
+ * How a binding is used, which decides how a bare name resolves: a write
76
+ * widget means an input node, a read widget means an output node or a
77
+ * variable, and "none" (a condition or a `format` token, which may read
78
+ * anything) tries outputs, then inputs, then variables.
79
+ */
80
+ export type BindingMode = "read" | "write" | "none";
81
+ /**
82
+ * Resolve a stored binding string to a {@link BindingRef} against the live
83
+ * graph. Explicit tokens resolve directly (their `operationId` is filled in
84
+ * from the default when the legacy `node:` form omitted it, and remapped by
85
+ * {@link onKnownOperation} when they name an operation the app does not have);
86
+ * a bare name is looked up by mode — a write widget means an input node, a read
87
+ * widget means an output node or a variable.
88
+ *
89
+ * Returns null when the binding cannot be resolved: a renamed node in a legacy
90
+ * document, a deleted variable. Callers surface that as a validation error
91
+ * rather than silently binding to nothing.
92
+ */
93
+ export declare const resolveBinding: (binding: string | null | undefined, scope: BindingScope, mode?: BindingMode, operationId?: string) => BindingRef | null;
94
+ /**
95
+ * Rewrite every name-based binding in a document's widget props to its ID
96
+ * form. Returns the unresolved bindings so the caller can report them instead
97
+ * of dropping them.
98
+ */
99
+ export interface BindingMigration {
100
+ /** binding string as stored → the ID form it should become. */
101
+ rewrites: Map<string, string>;
102
+ /** Bindings with no match in the live graph. */
103
+ unresolved: string[];
104
+ }
105
+ export declare const migrateBindings: (bindings: ReadonlyArray<{
106
+ binding: string;
107
+ mode: BindingMode;
108
+ }>, scope: BindingScope) => BindingMigration;
109
+ //# sourceMappingURL=bindings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bindings.d.ts","sourceRoot":"","sources":["../src/bindings.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEzD,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,UAAU,GAAG,OAAO,GAAG,UAAU,CAAC;AAE3E,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACtD;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACvD;IACE,IAAI,EAAE,cAAc,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB,GACD;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,cAAc,CAAA;CAAE,GACjE;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GACxC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAExD,eAAO,MAAM,gBAAgB,Q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AAG,IAAI,KAAG,UAAU,GAAG,IA8DnE,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAuBpD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,cAAc,YAChB,MAAM,GAAG,IAAI,GAAG,SAAS,SAC3B,YAAY,SACb,WAAW,gBACJ,MAAM,KAClB,UAAU,GAAG,IA4Cf,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,+DAA+D;IAC/D,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,gDAAgD;IAChD,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,eAAO,MAAM,eAAe,aAChB,aAAa,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,WAAW,CAAA;CAAE,CAAC,SACxD,YAAY,KAClB,gBAcF,CAAC"}
@@ -0,0 +1,257 @@
1
+ /**
2
+ * Bindings connect a widget to one slot of the app's state.
3
+ *
4
+ * A binding travels through the Puck document as a single string, so it is
5
+ * encoded as a URI-ish token. Every form that addresses the graph keys on node
6
+ * **IDs**: renaming an Input or Output node in the graph editor must not break
7
+ * an app. Bare names are still accepted and resolved against the live graph —
8
+ * that is the legacy `app_doc` form, and the migration path.
9
+ *
10
+ * op:<opId>/in:<nodeId> operation input
11
+ * op:<opId>/out:<nodeId> operation output
12
+ * op:<opId>/prop:<nodeId>#<prop> node property driven by a widget
13
+ * op:<opId>/exec#<field> running | progress | error | activity
14
+ * var:<variableId> declared app variable
15
+ * view:<componentId>#<prop> widget-local state, never persisted
16
+ * node:<nodeId>#<prop> legacy node property (default operation)
17
+ * <name> legacy input / output / variable name
18
+ */
19
+ import { DEFAULT_OPERATION_ID } from "./document.js";
20
+ export const OPERATION_PREFIX = "op:";
21
+ export const VARIABLE_PREFIX = "var:";
22
+ export const VIEW_PREFIX = "view:";
23
+ export const NODE_BINDING_PREFIX = "node:";
24
+ /**
25
+ * Split on the last separator, requiring a non-empty part on both sides. A
26
+ * missing separator, a leading one, or a trailing one all mean the token is
27
+ * malformed, so the caller rejects it.
28
+ */
29
+ const splitLast = (value, sep) => {
30
+ const at = value.lastIndexOf(sep);
31
+ if (at <= 0)
32
+ return null;
33
+ const tail = value.slice(at + sep.length);
34
+ if (tail.length === 0)
35
+ return null;
36
+ return [value.slice(0, at), tail];
37
+ };
38
+ export const namespaceOf = (ref) => {
39
+ switch (ref.kind) {
40
+ case "input":
41
+ case "nodeProperty":
42
+ return "inputs";
43
+ case "output":
44
+ return "outputs";
45
+ case "variable":
46
+ return "variables";
47
+ case "view":
48
+ return "view";
49
+ case "execution":
50
+ return "invocations";
51
+ }
52
+ };
53
+ /**
54
+ * The key this ref occupies inside its namespace. Inputs and outputs are keyed
55
+ * `opId:nodeId`, so two operations that share a workflow never collide.
56
+ */
57
+ export const stateKey = (ref) => {
58
+ switch (ref.kind) {
59
+ case "input":
60
+ case "output":
61
+ return `${ref.operationId}:${ref.nodeId}`;
62
+ case "nodeProperty":
63
+ return `${ref.operationId}:${ref.nodeId}#${ref.property}`;
64
+ case "variable":
65
+ return ref.variableId;
66
+ case "view":
67
+ return `${ref.componentId}:${ref.prop}`;
68
+ case "execution":
69
+ return ref.operationId;
70
+ }
71
+ };
72
+ /**
73
+ * Inverse of {@link stateKey} for the `inputs` namespace: `opId:nodeId` or
74
+ * `opId:nodeId#property`. Lets a runtime walk its input slots and rebuild the
75
+ * graph overlay a node-property binding drives.
76
+ */
77
+ export const parseInputStateKey = (key) => {
78
+ const colon = key.indexOf(":");
79
+ if (colon <= 0 || colon === key.length - 1)
80
+ return null;
81
+ const operationId = key.slice(0, colon);
82
+ const rest = key.slice(colon + 1);
83
+ const parts = splitLast(rest, "#");
84
+ return parts
85
+ ? { operationId, nodeId: parts[0], property: parts[1] }
86
+ : { operationId, nodeId: rest };
87
+ };
88
+ export const encodeBinding = (ref) => {
89
+ switch (ref.kind) {
90
+ case "input":
91
+ return `${OPERATION_PREFIX}${ref.operationId}/in:${ref.nodeId}`;
92
+ case "output":
93
+ return `${OPERATION_PREFIX}${ref.operationId}/out:${ref.nodeId}`;
94
+ case "nodeProperty":
95
+ return `${OPERATION_PREFIX}${ref.operationId}/prop:${ref.nodeId}#${ref.property}`;
96
+ case "execution":
97
+ return `${OPERATION_PREFIX}${ref.operationId}/exec#${ref.field}`;
98
+ case "variable":
99
+ return `${VARIABLE_PREFIX}${ref.variableId}`;
100
+ case "view":
101
+ return `${VIEW_PREFIX}${ref.componentId}#${ref.prop}`;
102
+ }
103
+ };
104
+ const isExecutionField = (value) => value === "running" ||
105
+ value === "progress" ||
106
+ value === "error" ||
107
+ value === "activity";
108
+ /** Parse an explicit (already ID-based) binding token. Legacy names return null. */
109
+ export const parseBinding = (binding) => {
110
+ if (binding == null || binding.length === 0)
111
+ return null;
112
+ if (binding.startsWith(VARIABLE_PREFIX)) {
113
+ const id = binding.slice(VARIABLE_PREFIX.length);
114
+ return id ? { kind: "variable", variableId: id } : null;
115
+ }
116
+ if (binding.startsWith(VIEW_PREFIX)) {
117
+ const parts = splitLast(binding.slice(VIEW_PREFIX.length), "#");
118
+ return parts
119
+ ? { kind: "view", componentId: parts[0], prop: parts[1] }
120
+ : null;
121
+ }
122
+ if (binding.startsWith(NODE_BINDING_PREFIX)) {
123
+ const parts = splitLast(binding.slice(NODE_BINDING_PREFIX.length), "#");
124
+ return parts
125
+ ? {
126
+ kind: "nodeProperty",
127
+ operationId: "",
128
+ nodeId: parts[0],
129
+ property: parts[1]
130
+ }
131
+ : null;
132
+ }
133
+ if (binding.startsWith(OPERATION_PREFIX)) {
134
+ const rest = binding.slice(OPERATION_PREFIX.length);
135
+ const slash = rest.indexOf("/");
136
+ if (slash <= 0)
137
+ return null;
138
+ const operationId = rest.slice(0, slash);
139
+ const tail = rest.slice(slash + 1);
140
+ if (tail.startsWith("in:")) {
141
+ const nodeId = tail.slice(3);
142
+ return nodeId ? { kind: "input", operationId, nodeId } : null;
143
+ }
144
+ if (tail.startsWith("out:")) {
145
+ const nodeId = tail.slice(4);
146
+ return nodeId ? { kind: "output", operationId, nodeId } : null;
147
+ }
148
+ if (tail.startsWith("prop:")) {
149
+ const parts = splitLast(tail.slice(5), "#");
150
+ return parts
151
+ ? {
152
+ kind: "nodeProperty",
153
+ operationId,
154
+ nodeId: parts[0],
155
+ property: parts[1]
156
+ }
157
+ : null;
158
+ }
159
+ if (tail.startsWith("exec#")) {
160
+ const field = tail.slice(5);
161
+ return isExecutionField(field)
162
+ ? { kind: "execution", operationId, field }
163
+ : null;
164
+ }
165
+ }
166
+ return null;
167
+ };
168
+ /**
169
+ * Documents written by an earlier builder hard-coded `main` as the operation of
170
+ * every binding, whatever the document's own operation was called. When the app
171
+ * binds exactly one operation and it is not `main`, such a token can only have
172
+ * meant that operation, so it resolves there instead of addressing a state slot
173
+ * no run ever fills. Resolution only — the stored document keeps the token it
174
+ * has until the author edits that binding.
175
+ *
176
+ * Narrow on purpose: any other operation id is left alone, so a document that
177
+ * genuinely names an operation the caller's scope has not loaded still resolves
178
+ * to what it says.
179
+ */
180
+ const onKnownOperation = (ref, scope) => {
181
+ if (!("operationId" in ref) || ref.operationId !== DEFAULT_OPERATION_ID) {
182
+ return ref;
183
+ }
184
+ const only = scope.operations.length === 1 ? scope.operations[0] : undefined;
185
+ if (!only || only.operationId === DEFAULT_OPERATION_ID)
186
+ return ref;
187
+ return { ...ref, operationId: only.operationId };
188
+ };
189
+ /**
190
+ * Resolve a stored binding string to a {@link BindingRef} against the live
191
+ * graph. Explicit tokens resolve directly (their `operationId` is filled in
192
+ * from the default when the legacy `node:` form omitted it, and remapped by
193
+ * {@link onKnownOperation} when they name an operation the app does not have);
194
+ * a bare name is looked up by mode — a write widget means an input node, a read
195
+ * widget means an output node or a variable.
196
+ *
197
+ * Returns null when the binding cannot be resolved: a renamed node in a legacy
198
+ * document, a deleted variable. Callers surface that as a validation error
199
+ * rather than silently binding to nothing.
200
+ */
201
+ export const resolveBinding = (binding, scope, mode = "none", operationId = scope.defaultOperationId) => {
202
+ const explicit = parseBinding(binding);
203
+ if (explicit) {
204
+ if (explicit.kind === "nodeProperty" && explicit.operationId === "") {
205
+ return onKnownOperation({ ...explicit, operationId }, scope);
206
+ }
207
+ return onKnownOperation(explicit, scope);
208
+ }
209
+ if (binding == null || binding.length === 0)
210
+ return null;
211
+ const op = scope.operations.find((o) => o.operationId === operationId) ??
212
+ scope.operations[0];
213
+ if (mode !== "write" && op) {
214
+ const output = op.outputs.find((o) => o.name === binding);
215
+ if (output) {
216
+ return {
217
+ kind: "output",
218
+ operationId: op.operationId,
219
+ nodeId: output.nodeId
220
+ };
221
+ }
222
+ }
223
+ if (mode !== "read" && op) {
224
+ const input = op.inputs.find((i) => i.name === binding);
225
+ if (input) {
226
+ return { kind: "input", operationId: op.operationId, nodeId: input.nodeId };
227
+ }
228
+ }
229
+ const variable = scope.variables.find((v) => v.id === binding || v.name === binding);
230
+ if (variable)
231
+ return { kind: "variable", variableId: variable.id };
232
+ // A SetVariable channel the graph publishes but the document never declared:
233
+ // treat the name as the variable id so legacy documents keep working.
234
+ if (op?.variableNames?.includes(binding)) {
235
+ return { kind: "variable", variableId: binding };
236
+ }
237
+ return null;
238
+ };
239
+ export const migrateBindings = (bindings, scope) => {
240
+ const rewrites = new Map();
241
+ const unresolved = [];
242
+ for (const { binding, mode } of bindings) {
243
+ if (!binding)
244
+ continue;
245
+ if (parseBinding(binding))
246
+ continue;
247
+ const ref = resolveBinding(binding, scope, mode);
248
+ if (ref) {
249
+ rewrites.set(binding, encodeBinding(ref));
250
+ }
251
+ else if (!unresolved.includes(binding)) {
252
+ unresolved.push(binding);
253
+ }
254
+ }
255
+ return { rewrites, unresolved };
256
+ };
257
+ //# sourceMappingURL=bindings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bindings.js","sourceRoot":"","sources":["../src/bindings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;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