@adonis-agora/agent 0.65.0 → 0.66.0
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/CHANGELOG.md +51 -0
- package/dist/src/ag-ui/core/encoder.d.ts.map +1 -1
- package/dist/src/ag-ui/core/encoder.js +6 -1
- package/dist/src/ag-ui/core/encoder.js.map +1 -1
- package/dist/src/ag-ui/frames.d.ts.map +1 -1
- package/dist/src/ag-ui/frames.js +1 -0
- package/dist/src/ag-ui/frames.js.map +1 -1
- package/dist/src/agent-loop.d.ts +12 -1
- package/dist/src/agent-loop.d.ts.map +1 -1
- package/dist/src/agent-loop.js +100 -14
- package/dist/src/agent-loop.js.map +1 -1
- package/dist/src/agent-service.d.ts +12 -0
- package/dist/src/agent-service.d.ts.map +1 -1
- package/dist/src/agent-service.js +18 -4
- package/dist/src/agent-service.js.map +1 -1
- package/dist/src/ai-sdk/ai-sdk-model.js +6 -2
- package/dist/src/ai-sdk/ai-sdk-model.js.map +1 -1
- package/dist/src/authz/authz-tool-authorizer.d.ts +1 -1
- package/dist/src/authz/authz-tool-authorizer.js +1 -1
- package/dist/src/channels/handler.d.ts +1 -1
- package/dist/src/channels/handler.d.ts.map +1 -1
- package/dist/src/channels/handler.js +33 -0
- package/dist/src/channels/handler.js.map +1 -1
- package/dist/src/client/chat-client.d.ts.map +1 -1
- package/dist/src/client/chat-client.js +5 -1
- package/dist/src/client/chat-client.js.map +1 -1
- package/dist/src/client/index.d.ts +1 -1
- package/dist/src/client/index.d.ts.map +1 -1
- package/dist/src/client/index.js +1 -1
- package/dist/src/client/index.js.map +1 -1
- package/dist/src/client/sse.d.ts +12 -0
- package/dist/src/client/sse.d.ts.map +1 -1
- package/dist/src/client/sse.js +18 -0
- package/dist/src/client/sse.js.map +1 -1
- package/dist/src/define_config.d.ts +1 -1
- package/dist/src/durable/agent-run-workflow.d.ts.map +1 -1
- package/dist/src/durable/agent-run-workflow.js +1 -27
- package/dist/src/durable/agent-run-workflow.js.map +1 -1
- package/dist/src/durable/drive-pending-runs.d.ts +17 -0
- package/dist/src/durable/drive-pending-runs.d.ts.map +1 -0
- package/dist/src/durable/drive-pending-runs.js +41 -0
- package/dist/src/durable/drive-pending-runs.js.map +1 -0
- package/dist/src/durable/durable-agent-runner.d.ts +4 -0
- package/dist/src/durable/durable-agent-runner.d.ts.map +1 -1
- package/dist/src/durable/durable-agent-runner.js +7 -0
- package/dist/src/durable/durable-agent-runner.js.map +1 -1
- package/dist/src/durable/outside-workflow-ctx.d.ts +27 -0
- package/dist/src/durable/outside-workflow-ctx.d.ts.map +1 -0
- package/dist/src/durable/outside-workflow-ctx.js +29 -0
- package/dist/src/durable/outside-workflow-ctx.js.map +1 -0
- package/dist/src/genui/catalog.d.ts +13 -0
- package/dist/src/genui/catalog.d.ts.map +1 -1
- package/dist/src/genui/catalog.js +4 -0
- package/dist/src/genui/catalog.js.map +1 -1
- package/dist/src/genui/index.d.ts +3 -2
- package/dist/src/genui/index.d.ts.map +1 -1
- package/dist/src/genui/index.js +3 -2
- package/dist/src/genui/index.js.map +1 -1
- package/dist/src/genui/progressive.d.ts +44 -0
- package/dist/src/genui/progressive.d.ts.map +1 -0
- package/dist/src/genui/progressive.js +101 -0
- package/dist/src/genui/progressive.js.map +1 -0
- package/dist/src/genui/public.d.ts +3 -2
- package/dist/src/genui/public.d.ts.map +1 -1
- package/dist/src/genui/public.js +1 -0
- package/dist/src/genui/public.js.map +1 -1
- package/dist/src/genui/tools.d.ts +29 -6
- package/dist/src/genui/tools.d.ts.map +1 -1
- package/dist/src/genui/tools.js +40 -6
- package/dist/src/genui/tools.js.map +1 -1
- package/dist/src/genui/tree.d.ts +26 -5
- package/dist/src/genui/tree.d.ts.map +1 -1
- package/dist/src/genui/tree.js +81 -12
- package/dist/src/genui/tree.js.map +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/opencode/durable/runner.d.ts +4 -0
- package/dist/src/opencode/durable/runner.d.ts.map +1 -1
- package/dist/src/opencode/durable/runner.js +7 -0
- package/dist/src/opencode/durable/runner.js.map +1 -1
- package/dist/src/partial-json.d.ts +28 -0
- package/dist/src/partial-json.d.ts.map +1 -0
- package/dist/src/partial-json.js +231 -0
- package/dist/src/partial-json.js.map +1 -0
- package/dist/src/react/core/agent-chat-transport.d.ts.map +1 -1
- package/dist/src/react/core/agent-chat-transport.js +3 -0
- package/dist/src/react/core/agent-chat-transport.js.map +1 -1
- package/dist/src/react/core/genui/generative-ui.d.ts +26 -4
- package/dist/src/react/core/genui/generative-ui.d.ts.map +1 -1
- package/dist/src/react/core/genui/generative-ui.js +50 -14
- package/dist/src/react/core/genui/generative-ui.js.map +1 -1
- package/dist/src/react/core/genui/index.d.ts +2 -2
- package/dist/src/react/core/genui/index.d.ts.map +1 -1
- package/dist/src/react/core/genui/index.js +1 -1
- package/dist/src/react/core/genui/index.js.map +1 -1
- package/dist/src/react/core/genui/json-render.d.ts.map +1 -1
- package/dist/src/react/core/genui/json-render.js +3 -1
- package/dist/src/react/core/genui/json-render.js.map +1 -1
- package/dist/src/react/core/genui/types.d.ts +33 -0
- package/dist/src/react/core/genui/types.d.ts.map +1 -1
- package/dist/src/react/core/genui/use-generative-ui.d.ts.map +1 -1
- package/dist/src/react/core/genui/use-generative-ui.js +4 -0
- package/dist/src/react/core/genui/use-generative-ui.js.map +1 -1
- package/dist/src/react/core/transcript/model.d.ts +5 -0
- package/dist/src/react/core/transcript/model.d.ts.map +1 -1
- package/dist/src/react/core/transcript/model.js +17 -0
- package/dist/src/react/core/transcript/model.js.map +1 -1
- package/dist/src/runners/inline-agent-runner.d.ts +9 -0
- package/dist/src/runners/inline-agent-runner.d.ts.map +1 -1
- package/dist/src/runners/inline-agent-runner.js +28 -4
- package/dist/src/runners/inline-agent-runner.js.map +1 -1
- package/dist/src/spi/agent-runner.d.ts +8 -0
- package/dist/src/spi/agent-runner.d.ts.map +1 -1
- package/dist/src/spi/token-stream-sink.d.ts +2 -0
- package/dist/src/spi/token-stream-sink.d.ts.map +1 -1
- package/dist/src/spi/token-stream-sink.js.map +1 -1
- package/dist/src/spi/tool.d.ts +54 -2
- package/dist/src/spi/tool.d.ts.map +1 -1
- package/dist/src/sse.d.ts.map +1 -1
- package/dist/src/sse.js +1 -0
- package/dist/src/sse.js.map +1 -1
- package/dist/src/stores/factory.d.ts +2 -2
- package/dist/src/stores/factory.js +2 -2
- package/dist/src/stream-events.d.ts +7 -0
- package/dist/src/stream-events.d.ts.map +1 -1
- package/dist/src/testing/fake-model-provider.d.ts +9 -1
- package/dist/src/testing/fake-model-provider.d.ts.map +1 -1
- package/dist/src/testing/fake-model-provider.js +12 -1
- package/dist/src/testing/fake-model-provider.js.map +1 -1
- package/dist/src/tool-input-preview.d.ts +34 -0
- package/dist/src/tool-input-preview.d.ts.map +1 -0
- package/dist/src/tool-input-preview.js +137 -0
- package/dist/src/tool-input-preview.js.map +1 -0
- package/dist/src/tool-registry.d.ts +8 -2
- package/dist/src/tool-registry.d.ts.map +1 -1
- package/dist/src/tool-registry.js +34 -1
- package/dist/src/tool-registry.js.map +1 -1
- package/dist/src/turn-frames.d.ts.map +1 -1
- package/dist/src/turn-frames.js +5 -0
- package/dist/src/turn-frames.js.map +1 -1
- package/dist/stubs/config/agent.stub +10 -2
- package/package.json +1 -1
- package/skills/agent-setup/SKILL.md +10 -0
- package/skills/agent-testing/SKILL.md +3 -1
- package/skills/agent-tools/SKILL.md +14 -3
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { WorkflowEngine } from '@adonis-agora/durable';
|
|
2
|
+
/**
|
|
3
|
+
* Set going, in this process, what of `runId`'s tree waits for a worker: the run itself while it is
|
|
4
|
+
* `pending`, and — while it is suspended on a delegation — the children it waits on, the same way.
|
|
5
|
+
* Each through `engine.runOne`, which takes the run's lease first: a run another worker holds is left
|
|
6
|
+
* to it, so a run still has exactly one executor. Returns once they are set going, not once they end;
|
|
7
|
+
* an execution's failure is the run's own (`failed` on its row) and only logged here.
|
|
8
|
+
*
|
|
9
|
+
* `driving` holds the runs this process set going and has not seen end — one set per runner, so two
|
|
10
|
+
* readers of one run do not both start it.
|
|
11
|
+
*
|
|
12
|
+
* Under a dispatcher that only persists a started run (a no-op one, with `durable:work` polling), a
|
|
13
|
+
* caller that is itself a run of that worker — a channel job reading the turn it started — holds the
|
|
14
|
+
* worker's tick: the turn would wait for the next tick, which waits for the caller.
|
|
15
|
+
*/
|
|
16
|
+
export declare function drivePendingRuns(engine: WorkflowEngine, runId: string, driving: Set<string>, seen?: Set<string>): Promise<void>;
|
|
17
|
+
//# sourceMappingURL=drive-pending-runs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drive-pending-runs.d.ts","sourceRoot":"","sources":["../../../src/durable/drive-pending-runs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAG5D;;;;;;;;;;;;;GAaG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,cAAc,EACtB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,EACpB,IAAI,cAAoB,GACvB,OAAO,CAAC,IAAI,CAAC,CAsBf"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { outsideWorkflowCtx } from './outside-workflow-ctx.js';
|
|
2
|
+
/**
|
|
3
|
+
* Set going, in this process, what of `runId`'s tree waits for a worker: the run itself while it is
|
|
4
|
+
* `pending`, and — while it is suspended on a delegation — the children it waits on, the same way.
|
|
5
|
+
* Each through `engine.runOne`, which takes the run's lease first: a run another worker holds is left
|
|
6
|
+
* to it, so a run still has exactly one executor. Returns once they are set going, not once they end;
|
|
7
|
+
* an execution's failure is the run's own (`failed` on its row) and only logged here.
|
|
8
|
+
*
|
|
9
|
+
* `driving` holds the runs this process set going and has not seen end — one set per runner, so two
|
|
10
|
+
* readers of one run do not both start it.
|
|
11
|
+
*
|
|
12
|
+
* Under a dispatcher that only persists a started run (a no-op one, with `durable:work` polling), a
|
|
13
|
+
* caller that is itself a run of that worker — a channel job reading the turn it started — holds the
|
|
14
|
+
* worker's tick: the turn would wait for the next tick, which waits for the caller.
|
|
15
|
+
*/
|
|
16
|
+
export async function drivePendingRuns(engine, runId, driving, seen = new Set()) {
|
|
17
|
+
if (seen.has(runId))
|
|
18
|
+
return;
|
|
19
|
+
seen.add(runId);
|
|
20
|
+
const run = await engine.getRun(runId);
|
|
21
|
+
if (run === null)
|
|
22
|
+
return;
|
|
23
|
+
if (run.status === 'pending') {
|
|
24
|
+
if (driving.has(runId))
|
|
25
|
+
return;
|
|
26
|
+
driving.add(runId);
|
|
27
|
+
// The run executes as itself, not inside whatever run the caller is a step of.
|
|
28
|
+
void outsideWorkflowCtx(() => engine.runOne(runId))
|
|
29
|
+
.catch((error) => {
|
|
30
|
+
console.error(`[@adonis-agora/agent] could not run ${runId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
31
|
+
})
|
|
32
|
+
.finally(() => driving.delete(runId));
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
// A run waiting on a delegate: the delegate (or one of its own) may be what is waiting.
|
|
36
|
+
if (run.status !== 'suspended')
|
|
37
|
+
return;
|
|
38
|
+
for (const child of await engine.getRunChildren(runId))
|
|
39
|
+
await drivePendingRuns(engine, child, driving, seen);
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=drive-pending-runs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drive-pending-runs.js","sourceRoot":"","sources":["../../../src/durable/drive-pending-runs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAAsB,EACtB,KAAa,EACb,OAAoB,EACpB,IAAI,GAAG,IAAI,GAAG,EAAU;IAExB,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;QAAE,OAAO;IAC5B,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAChB,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvC,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO;IACzB,IAAI,GAAG,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC7B,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC;YAAE,OAAO;QAC/B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACnB,+EAA+E;QAC/E,KAAK,kBAAkB,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;aAChD,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;YACxB,OAAO,CAAC,KAAK,CACX,uCAAuC,KAAK,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAC1G,CAAC;QACJ,CAAC,CAAC;aACD,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACxC,OAAO;IACT,CAAC;IACD,wFAAwF;IACxF,IAAI,GAAG,CAAC,MAAM,KAAK,WAAW;QAAE,OAAO;IACvC,KAAK,MAAM,KAAK,IAAI,MAAM,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC;QACpD,MAAM,gBAAgB,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;AACzD,CAAC"}
|
|
@@ -31,6 +31,10 @@ export declare class DurableAgentRunner implements AgentRunner {
|
|
|
31
31
|
runId: string;
|
|
32
32
|
}>;
|
|
33
33
|
signal(runId: string, toolCallId: string, reply: HumanReply): Promise<void>;
|
|
34
|
+
/** The runs {@link drive} set going that have not ended yet. */
|
|
35
|
+
private readonly driving;
|
|
36
|
+
/** Lease and execute here what of `runId` is still pending — see {@link drivePendingRuns}. */
|
|
37
|
+
drive(runId: string): Promise<void>;
|
|
34
38
|
/**
|
|
35
39
|
* From the engine's own run row. A run it does not know yet counts as running — a queued turn is
|
|
36
40
|
* claimed before its start lands — and so does one it cannot be asked about: only a run the engine
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"durable-agent-runner.d.ts","sourceRoot":"","sources":["../../../src/durable/durable-agent-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,KAAK,gBAAgB,EAAgB,MAAM,0BAA0B,CAAC;AAE/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"durable-agent-runner.d.ts","sourceRoot":"","sources":["../../../src/durable/durable-agent-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,KAAK,gBAAgB,EAAgB,MAAM,0BAA0B,CAAC;AAE/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CA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{ releaseThreadRun } from '../spi/chat-queue.js';
|
|
5
5
|
import { AgentRunWorkflow } from './agent-run-workflow.js';
|
|
6
|
+
import { drivePendingRuns } from './drive-pending-runs.js';
|
|
6
7
|
/**
|
|
7
8
|
* A control-flow signal surfaced out of `engine.start`. With the default in-process dispatcher the
|
|
8
9
|
* body runs on a microtask AFTER `start` returns, so this never fires; but an app that configures a
|
|
@@ -64,6 +65,12 @@ export class DurableAgentRunner {
|
|
|
64
65
|
async signal(runId, toolCallId, reply) {
|
|
65
66
|
await this.engine.signal(`tool:${runId}:${toolCallId}`, reply);
|
|
66
67
|
}
|
|
68
|
+
/** The runs {@link drive} set going that have not ended yet. */
|
|
69
|
+
driving = new Set();
|
|
70
|
+
/** Lease and execute here what of `runId` is still pending — see {@link drivePendingRuns}. */
|
|
71
|
+
async drive(runId) {
|
|
72
|
+
await drivePendingRuns(this.engine, runId, this.driving);
|
|
73
|
+
}
|
|
67
74
|
/**
|
|
68
75
|
* From the engine's own run row. A run it does not know yet counts as running — a queued turn is
|
|
69
76
|
* claimed before its start lands — and so does one it cannot be asked about: only a run the engine
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"durable-agent-runner.js","sourceRoot":"","sources":["../../../src/durable/durable-agent-runner.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAyB,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAI7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAGxD,OAAO,EAAE,gBAAgB,EAA6B,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"durable-agent-runner.js","sourceRoot":"","sources":["../../../src/durable/durable-agent-runner.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAyB,YAAY,E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K,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;QAClE,MAAM,KAAK,GAAG,KAAK,EAAE,KAAkD,CAAC;QACxE,IACE,KAAK,KAAK,IAAI;YACd,KAAK,KAAK,SAAS;YACnB,KAAK,EAAE,SAAS,KAAK,SAAS;YAC9B,KAAK,CAAC,SAAS,KAAK,SAAS;YAC7B,KAAK,CAAC,MAAM,KAAK,WAAW,EAC5B,CAAC;YACD,OAAO;QACT,CAAC;QACD,MAAM,IAAI,CAAC,KAAK,EAAE,YAAY,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC/F,MAAM,IAAI,CAAC,uBAAuB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACrD,CAAC;CACF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run a checkpoint's BODY outside the ambient workflow ctx.
|
|
3
|
+
*
|
|
4
|
+
* The runtime keeps the running workflow's ctx in an `AsyncLocalStorage` for the whole turn, and a
|
|
5
|
+
* `BaseWorkflow` static reads it to route: inside a workflow, `SomeWorkflow.dispatch(...)` becomes
|
|
6
|
+
* `ctx.startChild` and `SomeWorkflow.start(...)` becomes `ctx.child` — each of which takes a
|
|
7
|
+
* POSITION in the journal. That is right in a workflow body and wrong in a step body, and a step
|
|
8
|
+
* body is where everything the application wrote runs: a tool's `execute`, a processor, a store. A
|
|
9
|
+
* tool that starts a workflow of the app's own (directly, or through a service three calls down)
|
|
10
|
+
* would record `spawn:<id>` at the position after its own `tool:<callId>`, from inside that step.
|
|
11
|
+
* The first attempt then writes `persist:toolexec:<callId>` one position further on; a replay skips
|
|
12
|
+
* the completed step's body, never asks for the spawn's position, and offers it to
|
|
13
|
+
* `persist:toolexec:<callId>` instead — which the runtime refuses as non-determinism, failing a run
|
|
14
|
+
* nothing had changed under. It only takes a resume after such a tool to get there: a second action
|
|
15
|
+
* awaiting approval in the same step, or an approval in any later one.
|
|
16
|
+
*
|
|
17
|
+
* Outside the ambient ctx those statics go to the engine, as they do from a controller: the started
|
|
18
|
+
* run is a run of its own, and the step memoizes the body's result so a replay never starts it
|
|
19
|
+
* twice. Resolved off the namespace because `workflowAls` is not exported by every
|
|
20
|
+
* `@adonis-agora/durable` this package accepts as a peer; a runtime without it has no ambient ctx
|
|
21
|
+
* to leave.
|
|
22
|
+
*/
|
|
23
|
+
export declare const ambientWorkflowCtx: {
|
|
24
|
+
exit<T>(fn: () => T): T;
|
|
25
|
+
} | undefined;
|
|
26
|
+
export declare function outsideWorkflowCtx<T>(fn: () => Promise<T>): Promise<T>;
|
|
27
|
+
//# sourceMappingURL=outside-workflow-ctx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outside-workflow-ctx.d.ts","sourceRoot":"","sources":["../../../src/durable/outside-workflow-ctx.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,kBAAkB;SAAsC,CAAC,MAAM,MAAM,CAAC,GAAG,CAAC;aACzE,CAAC;AAEf,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAEtE"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as durable from '@adonis-agora/durable';
|
|
2
|
+
/**
|
|
3
|
+
* Run a checkpoint's BODY outside the ambient workflow ctx.
|
|
4
|
+
*
|
|
5
|
+
* The runtime keeps the running workflow's ctx in an `AsyncLocalStorage` for the whole turn, and a
|
|
6
|
+
* `BaseWorkflow` static reads it to route: inside a workflow, `SomeWorkflow.dispatch(...)` becomes
|
|
7
|
+
* `ctx.startChild` and `SomeWorkflow.start(...)` becomes `ctx.child` — each of which takes a
|
|
8
|
+
* POSITION in the journal. That is right in a workflow body and wrong in a step body, and a step
|
|
9
|
+
* body is where everything the application wrote runs: a tool's `execute`, a processor, a store. A
|
|
10
|
+
* tool that starts a workflow of the app's own (directly, or through a service three calls down)
|
|
11
|
+
* would record `spawn:<id>` at the position after its own `tool:<callId>`, from inside that step.
|
|
12
|
+
* The first attempt then writes `persist:toolexec:<callId>` one position further on; a replay skips
|
|
13
|
+
* the completed step's body, never asks for the spawn's position, and offers it to
|
|
14
|
+
* `persist:toolexec:<callId>` instead — which the runtime refuses as non-determinism, failing a run
|
|
15
|
+
* nothing had changed under. It only takes a resume after such a tool to get there: a second action
|
|
16
|
+
* awaiting approval in the same step, or an approval in any later one.
|
|
17
|
+
*
|
|
18
|
+
* Outside the ambient ctx those statics go to the engine, as they do from a controller: the started
|
|
19
|
+
* run is a run of its own, and the step memoizes the body's result so a replay never starts it
|
|
20
|
+
* twice. Resolved off the namespace because `workflowAls` is not exported by every
|
|
21
|
+
* `@adonis-agora/durable` this package accepts as a peer; a runtime without it has no ambient ctx
|
|
22
|
+
* to leave.
|
|
23
|
+
*/
|
|
24
|
+
export const ambientWorkflowCtx = durable
|
|
25
|
+
.workflowAls;
|
|
26
|
+
export function outsideWorkflowCtx(fn) {
|
|
27
|
+
return ambientWorkflowCtx === undefined ? fn() : ambientWorkflowCtx.exit(fn);
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=outside-workflow-ctx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outside-workflow-ctx.js","sourceRoot":"","sources":["../../../src/durable/outside-workflow-ctx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAI,OAAyD;KACzF,WAAW,CAAC;AAEf,MAAM,UAAU,kBAAkB,CAAI,EAAoB;IACxD,OAAO,kBAAkB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC/E,CAAC"}
|
|
@@ -39,7 +39,20 @@ export interface ComponentDefinition<P = Record<string, unknown>> {
|
|
|
39
39
|
* client can keep rendering messages persisted under an older shape.
|
|
40
40
|
*/
|
|
41
41
|
version?: number;
|
|
42
|
+
/**
|
|
43
|
+
* How this component appears in a tree the model is still writing (tree mode with streaming
|
|
44
|
+
* previews — see `GenuiToolsOptions.streaming`). Absent → the tree's default.
|
|
45
|
+
*
|
|
46
|
+
* - `'partial'`: drawn as soon as its type is known, its props filling in as they arrive (the
|
|
47
|
+
* node is flagged `incomplete` until its object closes).
|
|
48
|
+
* - `'complete'`: held back until its whole subtree has arrived — the node is sent as a
|
|
49
|
+
* placeholder (`held`, no props, no children) and drawn once it closes. For a component that
|
|
50
|
+
* cannot draw half its data: a chart, a map.
|
|
51
|
+
*/
|
|
52
|
+
streaming?: GenuiStreaming;
|
|
42
53
|
}
|
|
54
|
+
/** How a tree node appears while the model writes it ({@link ComponentDefinition.streaming}). */
|
|
55
|
+
export type GenuiStreaming = 'partial' | 'complete';
|
|
43
56
|
/** Component names: an identifier a registry key, a tool name and a snake_case slug can all be derived from. */
|
|
44
57
|
export declare const COMPONENT_NAME: RegExp;
|
|
45
58
|
/** Declare a component. Validates the name and returns the definition unchanged (typed). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../../src/genui/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAIjB,MAAM,aAAa,CAAC;AAErB;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC9D,6EAA6E;IAC7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AC,OAAO,CAAC,EAAE,GAAG,OAAO,CAAC;CACtE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,UAAU,EAAE,SAAS,mBAAmB,CAAC,OAAO,CAAC,EAAE,EACnD,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAUT;AAyDD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,mBAAmB,CAAC,OAAO,CAAC,EAAE,CAErF;AAED,4DAA4D;AAC5D,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMhD;AAED,kFAAkF;AAClF,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,SAAc,GAAG,MAAM,CAE3E"}
|
|
@@ -11,6 +11,10 @@ export function defineComponent(definition) {
|
|
|
11
11
|
throw new RangeError('genui: component version must be a positive safe integer');
|
|
12
12
|
if (definition.fallbackText !== undefined && typeof definition.fallbackText !== 'function')
|
|
13
13
|
throw new TypeError('genui: fallbackText must be a function');
|
|
14
|
+
if (definition.streaming !== undefined &&
|
|
15
|
+
definition.streaming !== 'partial' &&
|
|
16
|
+
definition.streaming !== 'complete')
|
|
17
|
+
throw new TypeError("genui: streaming must be 'partial' or 'complete'");
|
|
14
18
|
return definition;
|
|
15
19
|
}
|
|
16
20
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../../src/genui/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAK1B,YAAY,EACZ,aAAa,EACb,iBAAiB,GAClB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../../src/genui/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAK1B,YAAY,EACZ,aAAa,EACb,iBAAiB,GAClB,MAAM,aAAa,CAAC;AA0DrB,gHAAgH;AAChH,MAAM,CAAC,MAAM,cAAc,GAA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,CAAC;SAC9B,WAAW,EAAE,CAAC;AACnB,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,WAAW,CAAC,SAAiB,EAAE,MAAM,GAAG,WAAW;IACjE,OAAO,GAAG,MAAM,GAAG,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC;AAC9C,CAAC"}
|
|
@@ -36,8 +36,9 @@ export interface GenuiOptions extends Omit<GenuiToolsOptions, 'resolveCatalog'>
|
|
|
36
36
|
* export default defineConfig({ model, genui: genui({ catalog }) })
|
|
37
37
|
* ```
|
|
38
38
|
*
|
|
39
|
-
* Registers
|
|
40
|
-
*
|
|
39
|
+
* Registers one `ui__render` tool taking a component tree composed from the catalog (or, with
|
|
40
|
+
* `mode: 'per-component'`, a `ui__show_<component>` tool per model-facing component; and/or the
|
|
41
|
+
* generic `ui__show` with `showTool: true`). Each call validates
|
|
41
42
|
* against the catalog and pushes through `ctx.emitUi`, so it streams as a `ui` frame and is persisted
|
|
42
43
|
* on the message. Tools without `roles` get the config's `defaultRoles`, like every other tool.
|
|
43
44
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/genui/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,YAAY,EAA4B,MAAM,cAAc,CAAC;AAC3E,OAAO,EACL,KAAK,OAAO,EAEZ,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EAEvB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,UAAU,EACV,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,UAAU,GAChB,MAAM,cAAc,CAAC;AACtB,cAAc,aAAa,CAAC;AAE5B;;;;GAIG;AACH,8BAAsB,oBAAoB;IACxC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACxE;AAED,KAAK,cAAc,GACf,oBAAoB,GACpB,C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G;IACH,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B;AAuBD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,KAAK,CAAC,OAAO,GAAE,YAAiB,GAAG,YAAY,CAe9D"}
|
package/dist/src/genui/index.js
CHANGED
|
@@ -36,8 +36,9 @@ async function resolveCatalogFn(resolver, ctx) {
|
|
|
36
36
|
* export default defineConfig({ model, genui: genui({ catalog }) })
|
|
37
37
|
* ```
|
|
38
38
|
*
|
|
39
|
-
* Registers
|
|
40
|
-
*
|
|
39
|
+
* Registers one `ui__render` tool taking a component tree composed from the catalog (or, with
|
|
40
|
+
* `mode: 'per-component'`, a `ui__show_<component>` tool per model-facing component; and/or the
|
|
41
|
+
* generic `ui__show` with `showTool: true`). Each call validates
|
|
41
42
|
* against the catalog and pushes through `ctx.emitUi`, so it streams as a `ui` frame and is persisted
|
|
42
43
|
* on the message. Tools without `roles` get the config's `defaultRoles`, like every other tool.
|
|
43
44
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/genui/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAEL,aAAa,EAGb,UAAU,GACX,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,UAAU,GAIX,MAAM,cAAc,CAAC;AACtB,cAAc,aAAa,CAAC;AAE5B;;;;GAIG;AACH,MAAM,OAAgB,oBAAoB;CAEzC;AAqBD,SAAS,eAAe,CACtB,KAAqB;IAIrB,OAAO,OAAO,KAAK,KAAK,UAAU,IAAI,KAAK,CAAC,SAAS,YAAY,oBAAoB,CAAC;AACxF,CAAC;AAED,KAAK,UAAU,gBAAgB,CAC7B,QAAoC,EACpC,GAAwB;IAExB,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC7C,IAAI,QAAQ,YAAY,oBAAoB;QAAE,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,KA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GAAiB,EAAE;IAC9C,OAAO,KAAK,EAAE,GAAG,EAAE,EAAE;QACnB,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;QACtD,MAAM,OAAO,GAAG,KAAK,IAAI,aAAa,CAAC,EAAE,CAAC,CAAC;QAC3C,MAAM,cAAc,GAAG,MAAM,gBAAgB,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QAC7D,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,EAAE;YAChC,GAAG,IAAI;YACP,GAAG,CAAC,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC5D,CAAC,CAAC;QACH,OAAO;YACL,OAAO;YACP,GAAG,CAAC,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC;YAC3D,KAAK;SACN,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { PartialToolInput } from '../spi/tool.js';
|
|
2
|
+
import type { Catalog, GenuiStreaming } from './catalog.js';
|
|
3
|
+
import type { TreeLimits } from './tree.js';
|
|
4
|
+
/**
|
|
5
|
+
* One node of a tree the model is still writing — what a partial `genui:tree` frame carries.
|
|
6
|
+
*
|
|
7
|
+
* `id` is the node's position: `root`, then `<parent id>.<index>` (`root.1.0`). It never changes as
|
|
8
|
+
* the tree grows (a model only ever appends), and the final tree's nodes are addressed by the same
|
|
9
|
+
* rule, so a renderer keyed on it keeps every node mounted from the first preview to the final frame.
|
|
10
|
+
*/
|
|
11
|
+
export interface GenuiPartialElement {
|
|
12
|
+
id: string;
|
|
13
|
+
type: string;
|
|
14
|
+
props: Record<string, unknown>;
|
|
15
|
+
children?: GenuiPartialElement[];
|
|
16
|
+
/** The model has not finished writing this node: its props (or children) may still grow. */
|
|
17
|
+
incomplete?: true;
|
|
18
|
+
/**
|
|
19
|
+
* The node's component streams `complete`: its props and children are held back until its whole
|
|
20
|
+
* subtree has arrived (`props` is `{}`). Draw a placeholder, never the component.
|
|
21
|
+
*/
|
|
22
|
+
held?: true;
|
|
23
|
+
}
|
|
24
|
+
/** The id of the child at `index` of the node `parentId` (the root is `root`). */
|
|
25
|
+
export declare function treeNodeId(parentId: string, index: number): string;
|
|
26
|
+
export interface PartialTreeOptions {
|
|
27
|
+
/** How a component without its own `streaming` appears. Default `'complete'`. */
|
|
28
|
+
streaming?: GenuiStreaming;
|
|
29
|
+
limits?: TreeLimits;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The part of a streaming `ui__render` input worth drawing: every node whose `type` has fully
|
|
33
|
+
* arrived and names a component of `catalog` (the negotiated one: what this client draws), with its
|
|
34
|
+
* props so far — unvalidated, and flagged `incomplete` while still open. A node whose component
|
|
35
|
+
* streams `complete` is a `held` placeholder until it closes.
|
|
36
|
+
*
|
|
37
|
+
* `{ root: null }` while nothing is drawable yet. `null` when the input can no longer become a tree
|
|
38
|
+
* this client draws (an unknown or undrawable component, children where none are taken, past the
|
|
39
|
+
* size limits): the preview stops there, and the final push decides what is shown.
|
|
40
|
+
*/
|
|
41
|
+
export declare function partialTree(catalog: Catalog, input: PartialToolInput, options?: PartialTreeOptions): {
|
|
42
|
+
root: GenuiPartialElement | null;
|
|
43
|
+
} | null;
|
|
44
|
+
//# sourceMappingURL=progressive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progressive.d.ts","sourceRoot":"","sources":["../../../src/genui/progressive.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,QAAQ,CAAC,EAAE,mBAAmB,EAAE,CAAC;IACjC,4FAA4F;IAC5F,UAAU,CAAC,EAAE,IAAI,CAAC;IAClB;;;OAGG;IACH,IAAI,CAAC,EAAE,IAAI,CAAC;CACb;AAED,kFAAkF;AAClF,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAElE;AAED,MAAM,WAAW,kBAAkB;IACjC,iFAAiF;IACjF,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB;AAMD;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,gBAAgB,EACvB,OAAO,GAAE,kBAAuB,GAC/B;IAAE,IAAI,EAAE,mBAAmB,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,CAqF7C"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { validatePropsSync } from './schema.js';
|
|
2
|
+
/** The id of the child at `index` of the node `parentId` (the root is `root`). */
|
|
3
|
+
export function treeNodeId(parentId, index) {
|
|
4
|
+
return `${parentId}.${index}`;
|
|
5
|
+
}
|
|
6
|
+
function isRecord(value) {
|
|
7
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The part of a streaming `ui__render` input worth drawing: every node whose `type` has fully
|
|
11
|
+
* arrived and names a component of `catalog` (the negotiated one: what this client draws), with its
|
|
12
|
+
* props so far — unvalidated, and flagged `incomplete` while still open. A node whose component
|
|
13
|
+
* streams `complete` is a `held` placeholder until it closes.
|
|
14
|
+
*
|
|
15
|
+
* `{ root: null }` while nothing is drawable yet. `null` when the input can no longer become a tree
|
|
16
|
+
* this client draws (an unknown or undrawable component, children where none are taken, past the
|
|
17
|
+
* size limits): the preview stops there, and the final push decides what is shown.
|
|
18
|
+
*/
|
|
19
|
+
export function partialTree(catalog, input, options = {}) {
|
|
20
|
+
const maxDepth = options.limits?.maxDepth ?? 12;
|
|
21
|
+
const maxNodes = options.limits?.maxNodes ?? 200;
|
|
22
|
+
const fallback = options.streaming ?? 'complete';
|
|
23
|
+
let nodes = 0;
|
|
24
|
+
let broken = false;
|
|
25
|
+
const visit = (value, id, depth) => {
|
|
26
|
+
if (broken)
|
|
27
|
+
return undefined;
|
|
28
|
+
if (!isRecord(value)) {
|
|
29
|
+
// An element that is not an object will never validate.
|
|
30
|
+
if (value !== undefined)
|
|
31
|
+
broken = true;
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
const open = input.isOpen(value);
|
|
35
|
+
const type = value.type;
|
|
36
|
+
// `"type": "Car` may yet be `"CardGrid"`: wait for the closing quote.
|
|
37
|
+
if (typeof type !== 'string' || (open && input.pendingMember(value) === 'type')) {
|
|
38
|
+
if (!open)
|
|
39
|
+
broken = true;
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
const definition = catalog.get(type);
|
|
43
|
+
nodes += 1;
|
|
44
|
+
if (definition === undefined ||
|
|
45
|
+
definition.internal === true ||
|
|
46
|
+
nodes > maxNodes ||
|
|
47
|
+
depth > maxDepth) {
|
|
48
|
+
broken = true;
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
const mode = definition.streaming ?? fallback;
|
|
52
|
+
if (mode === 'complete') {
|
|
53
|
+
// Drawn only whole — and only once its props would pass (a display gate; the final tree is
|
|
54
|
+
// validated on its own, as every tree is).
|
|
55
|
+
const checked = open
|
|
56
|
+
? undefined
|
|
57
|
+
: validatePropsSync(definition.props, value.props ?? {}, catalog.validator);
|
|
58
|
+
if (checked === undefined || !checked.ok) {
|
|
59
|
+
return { id, type, props: {}, incomplete: true, held: true };
|
|
60
|
+
}
|
|
61
|
+
const children = childrenOf(value, id, depth, definition.children === true);
|
|
62
|
+
return {
|
|
63
|
+
id,
|
|
64
|
+
type,
|
|
65
|
+
props: checked.value,
|
|
66
|
+
...(children !== undefined && children.length > 0 ? { children } : {}),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
const props = isRecord(value.props) ? value.props : {};
|
|
70
|
+
const children = childrenOf(value, id, depth, definition.children === true);
|
|
71
|
+
return {
|
|
72
|
+
id,
|
|
73
|
+
type,
|
|
74
|
+
props,
|
|
75
|
+
...(children !== undefined && children.length > 0 ? { children } : {}),
|
|
76
|
+
...(open ? { incomplete: true } : {}),
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
const childrenOf = (value, id, depth, takesChildren) => {
|
|
80
|
+
const raw = value.children;
|
|
81
|
+
// A stringified `children` (a model quirk the final validation repairs) cannot be drawn yet.
|
|
82
|
+
if (!Array.isArray(raw))
|
|
83
|
+
return undefined;
|
|
84
|
+
if (raw.length > 0 && !takesChildren) {
|
|
85
|
+
broken = true;
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
const children = [];
|
|
89
|
+
for (const [index, child] of raw.entries()) {
|
|
90
|
+
const next = visit(child, treeNodeId(id, index), depth + 1);
|
|
91
|
+
if (next !== undefined)
|
|
92
|
+
children.push(next);
|
|
93
|
+
}
|
|
94
|
+
return children;
|
|
95
|
+
};
|
|
96
|
+
const root = visit(input.value, 'root', 1);
|
|
97
|
+
if (broken)
|
|
98
|
+
return null;
|
|
99
|
+
return { root: root ?? null };
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=progressive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progressive.js","sourceRoot":"","sources":["../../../src/genui/progressive.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAwBhD,kFAAkF;AAClF,MAAM,UAA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;QAC9C,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC;IAEF,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IAC3C,IAAI,MAAM;QAAE,OAAO,IAAI,CAAC;IACxB,OAAO,EAAE,IAAI,EAAE,IAAI,IAAI,IAAI,EAAE,CAAC;AAChC,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/** Isomorphic public GenUI contracts and implementation. */
|
|
2
2
|
export { negotiateCatalog, type PreparedUiEmission, prepareUiEmission, type UiCapabilities, validateUiCapabilities, } from './capabilities.js';
|
|
3
|
-
export { type Catalog, type CatalogOptions, COMPONENT_NAME, type ComponentDefinition, defineCatalog, defineComponent, toolNameFor, toSnakeCase, } from './catalog.js';
|
|
3
|
+
export { type Catalog, type CatalogOptions, COMPONENT_NAME, type ComponentDefinition, defineCatalog, defineComponent, type GenuiStreaming, toolNameFor, toSnakeCase, } from './catalog.js';
|
|
4
|
+
export { type GenuiPartialElement, type PartialTreeOptions, partialTree, treeNodeId, } from './progressive.js';
|
|
4
5
|
export { type ChartProps, type ComponentFactory, type ComponentManifest, type ComponentPresentation, type ComponentRegistry, type ComponentRenderer, chart, createComponent, createComponentRegistry, snapshotComponentPresentation, type TableCell, type TableProps, table, validatePresentationBatch, } from './registry.js';
|
|
5
6
|
export { type AjvLike, ajvValidator, builtinJsonSchemaValidator, formatIssues, type GenuiIssue, type GenuiValidation, isStandardSchema, type JsonSchema, type JsonSchemaValidator, type PropsSchema, toJsonSchema, validateProps, validatePropsSync, } from './schema.js';
|
|
6
7
|
export { type CatalogTextOptions, catalogToModelText, componentToText, fillTemplate, getPath, summarizeSchema, treeToText, } from './text.js';
|
|
7
8
|
export { GENUI_SHOW_TOOL, type GenuiCatalogScope, type GenuiTool, type GenuiToolOutput, type GenuiToolsOptions, genuiTools, jsonStandardSchema, type ResolveGenuiCatalog, showToolJsonSchema, } from './tools.js';
|
|
8
|
-
export { type FlatSpec, GENUI_TREE_COMPONENT, type GenuiElement, type GenuiTreeProps, type TreeLimits, treeJsonSchema, treeToFlatSpec, validateTree, } from './tree.js';
|
|
9
|
+
export { type FlatSpec, GENUI_TREE_COMPONENT, type GenuiElement, type GenuiTreeProps, type TreeLimits, type TreeSchemaMode, treeJsonSchema, treeToFlatSpec, validateTree, } from './tree.js';
|
|
9
10
|
//# sourceMappingURL=public.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../../src/genui/public.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAE5D,OAAO,EACL,gBAAgB,EAChB,KAAK,kBAAkB,EACvB,iBAAiB,EACjB,KAAK,cAAc,EACnB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,cAAc,EACd,KAAK,mBAAmB,EACxB,aAAa,EACb,eAAe,EACf,WAAW,EACX,WAAW,GACZ,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,EACL,eAAe,EACf,uBAAuB,EACvB,6BAA6B,EAC7B,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,EACL,yBAAyB,GAC1B,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,KAAK,OAAO,EACZ,YAAY,EACZ,0BAA0B,EAC1B,YAAY,EACZ,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,gBAAgB,EAChB,KAAK,UAAU,EACf,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAChB,YAAY,EACZ,aAAa,EACb,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,KAAK,kBAAkB,EACvB,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,OAAO,EACP,eAAe,EACf,UAAU,GACX,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,eAAe,EACf,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,UAAU,EACV,kBAAkB,EAClB,KAAK,mBAAmB,EACxB,kBAAkB,GACnB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,KAAK,QAAQ,EACb,oBAAoB,EACpB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,cAAc,EACd,cAAc,EACd,YAAY,GACb,MAAM,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../../src/genui/public.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAE5D,OAAO,EACL,gBAAgB,EAChB,KAAK,kBAAkB,EACvB,iBAAiB,EACjB,KAAK,cAAc,EACnB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,cAAc,EACd,KAAK,mBAAmB,EACxB,aAAa,EACb,eAAe,EACf,KAAK,cAAc,EACnB,WAAW,EACX,WAAW,GACZ,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,WAAW,EACX,UAAU,GACX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,EACL,eAAe,EACf,uBAAuB,EACvB,6BAA6B,EAC7B,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,EACL,yBAAyB,GAC1B,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,KAAK,OAAO,EACZ,YAAY,EACZ,0BAA0B,EAC1B,YAAY,EACZ,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,gBAAgB,EAChB,KAAK,UAAU,EACf,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAChB,YAAY,EACZ,aAAa,EACb,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,KAAK,kBAAkB,EACvB,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,OAAO,EACP,eAAe,EACf,UAAU,GACX,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,eAAe,EACf,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,UAAU,EACV,kBAAkB,EAClB,KAAK,mBAAmB,EACxB,kBAAkB,GACnB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,KAAK,QAAQ,EACb,oBAAoB,EACpB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,cAAc,EACd,cAAc,EACd,YAAY,GACb,MAAM,WAAW,CAAC"}
|
package/dist/src/genui/public.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** Isomorphic public GenUI contracts and implementation. */
|
|
2
2
|
export { negotiateCatalog, prepareUiEmission, validateUiCapabilities, } from './capabilities.js';
|
|
3
3
|
export { COMPONENT_NAME, defineCatalog, defineComponent, toolNameFor, toSnakeCase, } from './catalog.js';
|
|
4
|
+
export { partialTree, treeNodeId, } from './progressive.js';
|
|
4
5
|
export { chart, createComponent, createComponentRegistry, snapshotComponentPresentation, table, validatePresentationBatch, } from './registry.js';
|
|
5
6
|
export { ajvValidator, builtinJsonSchemaValidator, formatIssues, isStandardSchema, toJsonSchema, validateProps, validatePropsSync, } from './schema.js';
|
|
6
7
|
export { catalogToModelText, componentToText, fillTemplate, getPath, summarizeSchema, treeToText, } from './text.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.js","sourceRoot":"","sources":["../../../src/genui/public.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAE5D,OAAO,EACL,gBAAgB,EAEhB,iBAAiB,EAEjB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAGL,cAAc,EAEd,aAAa,EACb,eAAe,
|
|
1
|
+
{"version":3,"file":"public.js","sourceRoot":"","sources":["../../../src/genui/public.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAE5D,OAAO,EACL,gBAAgB,EAEhB,iBAAiB,EAEjB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAGL,cAAc,EAEd,aAAa,EACb,eAAe,EAEf,WAAW,EACX,WAAW,GACZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAGL,WAAW,EACX,UAAU,GACX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAOL,KAAK,EACL,eAAe,EACf,uBAAuB,EACvB,6BAA6B,EAG7B,KAAK,EACL,yBAAyB,GAC1B,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,YAAY,EACZ,0BAA0B,EAC1B,YAAY,EAGZ,gBAAgB,EAIhB,YAAY,EACZ,aAAa,EACb,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAEL,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,OAAO,EACP,eAAe,EACf,UAAU,GACX,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,eAAe,EAKf,UAAU,EACV,kBAAkB,EAElB,kBAAkB,GACnB,MAAM,YAAY,CAAC;AACpB,OAAO,EAEL,oBAAoB,EAKpB,cAAc,EACd,cAAc,EACd,YAAY,GACb,MAAM,WAAW,CAAC"}
|
|
@@ -2,9 +2,9 @@ import type { StandardJSONSchemaV1, StandardSchemaV1 } from '@standard-schema/sp
|
|
|
2
2
|
import type { ToolHandler } from '../spi/tool.js';
|
|
3
3
|
import type { ToolPresentation } from '../tool-presentation.js';
|
|
4
4
|
import type { Actor, ToolSpec } from '../types.js';
|
|
5
|
-
import { type Catalog } from './catalog.js';
|
|
5
|
+
import { type Catalog, type GenuiStreaming } from './catalog.js';
|
|
6
6
|
import { type GenuiIssue, type JsonSchema } from './schema.js';
|
|
7
|
-
import { type TreeLimits } from './tree.js';
|
|
7
|
+
import { type TreeLimits, type TreeSchemaMode } from './tree.js';
|
|
8
8
|
/** A lib tool: register it with `aiTool(tool)` (AdonisJS) or `registry.register(tool.spec, tool.handler)`. */
|
|
9
9
|
export interface GenuiTool {
|
|
10
10
|
spec: ToolSpec & {
|
|
@@ -31,12 +31,20 @@ export interface GenuiCatalogScope {
|
|
|
31
31
|
export type ResolveGenuiCatalog = (scope: GenuiCatalogScope) => Catalog | Promise<Catalog>;
|
|
32
32
|
export interface GenuiToolsOptions {
|
|
33
33
|
/**
|
|
34
|
-
* `
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* `
|
|
34
|
+
* `tree` (default): a single `ui__render` tool whose input is a nested `{ type, props, children }`
|
|
35
|
+
* tree composed from the catalog (json-render's nested shape). A tree of one component with no
|
|
36
|
+
* children is pushed as that component, exactly as its `ui__show_*` tool would push it.
|
|
37
|
+
* `per-component`: one tool per model-facing component, `ui__show_<snake>`, whose input IS the
|
|
38
|
+
* component's props — for small models, or when each tool should carry its exact schema. Layouts
|
|
39
|
+
* (`children: true`) get none: they can only be composed in a tree.
|
|
38
40
|
*/
|
|
39
41
|
mode?: 'per-component' | 'tree';
|
|
42
|
+
/**
|
|
43
|
+
* How the tree tool's input schema describes the nodes (see {@link treeJsonSchema}): `'strict'`
|
|
44
|
+
* (default) — a recursive union by `type` with each component's exact props; `'loose'` — one
|
|
45
|
+
* generic node shape, for a provider that refuses `$ref` in tool parameters.
|
|
46
|
+
*/
|
|
47
|
+
treeSchema?: TreeSchemaMode;
|
|
40
48
|
/**
|
|
41
49
|
* The model's turn ends once a genui call succeeds — no further model call to narrate what the UI
|
|
42
50
|
* already shows. Stamped as `spec.terminal`.
|
|
@@ -50,6 +58,21 @@ export interface GenuiToolsOptions {
|
|
|
50
58
|
treeInstructions?: string;
|
|
51
59
|
/** Size limits for `tree`. */
|
|
52
60
|
treeLimits?: TreeLimits;
|
|
61
|
+
/**
|
|
62
|
+
* Tree mode: whether the layout is drawn WHILE the model writes it.
|
|
63
|
+
*
|
|
64
|
+
* - `'complete'` (default): nothing is drawn until the call has run; then the validated tree
|
|
65
|
+
* appears whole.
|
|
66
|
+
* - `'partial'`: the server parses the streaming `ui__render` arguments and pushes the tree so far
|
|
67
|
+
* as `partial` `ui` frames under the id the final push replaces — throttled, unvalidated, never
|
|
68
|
+
* persisted, never sent to a text channel. Nodes still being written are flagged `incomplete`; a
|
|
69
|
+
* component declared `streaming: 'complete'` is a `held` placeholder until its subtree closes.
|
|
70
|
+
*
|
|
71
|
+
* A component's own {@link ComponentDefinition.streaming} overrides this per component.
|
|
72
|
+
*/
|
|
73
|
+
streaming?: GenuiStreaming;
|
|
74
|
+
/** Least time between two partial tree frames of one call, in ms. Default 100. */
|
|
75
|
+
streamingThrottleMs?: number;
|
|
53
76
|
/**
|
|
54
77
|
* Also offer ONE generic tool taking `{ component, props }`, validated against the (resolved)
|
|
55
78
|
* catalog — how a model reaches components that only exist per request (a tenant's own), which a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/genui/tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACpF,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/genui/tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACpF,OAAO,KAAK,EAIV,WAAW,EAGZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MA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