@proofoftech/flowsafe 0.6.0 → 0.8.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 +31 -1
- package/README.md +305 -251
- package/dist/agent-host/approval-resumer.d.ts +13 -0
- package/dist/agent-host/approval-resumer.d.ts.map +1 -0
- package/dist/agent-host/approval-resumer.js +43 -0
- package/dist/agent-host/approval-resumer.js.map +1 -0
- package/dist/agent-host/catalog.d.ts +6 -0
- package/dist/agent-host/catalog.d.ts.map +1 -0
- package/dist/agent-host/catalog.js +98 -0
- package/dist/agent-host/catalog.js.map +1 -0
- package/dist/agent-host/index.d.ts +9 -0
- package/dist/agent-host/index.d.ts.map +1 -0
- package/dist/agent-host/index.js +11 -0
- package/dist/agent-host/index.js.map +1 -0
- package/dist/agent-host/router.d.ts +11 -0
- package/dist/agent-host/router.d.ts.map +1 -0
- package/dist/agent-host/router.js +240 -0
- package/dist/agent-host/router.js.map +1 -0
- package/dist/agent-host/thread-host.d.ts +55 -0
- package/dist/agent-host/thread-host.d.ts.map +1 -0
- package/dist/agent-host/thread-host.js +636 -0
- package/dist/agent-host/thread-host.js.map +1 -0
- package/dist/agent-host/thread-topology.d.ts +39 -0
- package/dist/agent-host/thread-topology.d.ts.map +1 -0
- package/dist/agent-host/thread-topology.js +127 -0
- package/dist/agent-host/thread-topology.js.map +1 -0
- package/dist/agent-host/trusted-context.d.ts +9 -0
- package/dist/agent-host/trusted-context.d.ts.map +1 -0
- package/dist/agent-host/trusted-context.js +40 -0
- package/dist/agent-host/trusted-context.js.map +1 -0
- package/dist/agent-host/types.d.ts +49 -0
- package/dist/agent-host/types.d.ts.map +1 -0
- package/dist/agent-host/types.js +3 -0
- package/dist/agent-host/types.js.map +1 -0
- package/dist/agent-runner/agent-run-state.d.ts +30 -0
- package/dist/agent-runner/agent-run-state.d.ts.map +1 -0
- package/dist/agent-runner/agent-run-state.js +128 -0
- package/dist/agent-runner/agent-run-state.js.map +1 -0
- package/dist/agent-runner/approval-shapes.d.ts +1 -1
- package/dist/agent-runner/approval-shapes.js +1 -1
- package/dist/agent-runner/durable-agent-runner.d.ts +32 -16
- package/dist/agent-runner/durable-agent-runner.d.ts.map +1 -1
- package/dist/agent-runner/durable-agent-runner.js +149 -28
- package/dist/agent-runner/durable-agent-runner.js.map +1 -1
- package/dist/agent-runner/index.d.ts +2 -0
- package/dist/agent-runner/index.d.ts.map +1 -1
- package/dist/agent-runner/index.js +1 -0
- package/dist/agent-runner/index.js.map +1 -1
- package/dist/approval-api/contract.d.ts +2 -2
- package/dist/approval-api/d1-store.d.ts.map +1 -1
- package/dist/approval-api/d1-store.js +27 -11
- package/dist/approval-api/d1-store.js.map +1 -1
- package/dist/approval-api/grants.d.ts +1 -1
- package/dist/approval-api/grants.js +1 -1
- package/dist/approval-api/router.d.ts +1 -1
- package/dist/approval-api/service.d.ts +8 -9
- package/dist/approval-api/service.d.ts.map +1 -1
- package/dist/approval-api/service.js +37 -16
- package/dist/approval-api/service.js.map +1 -1
- package/dist/approval-api/store.d.ts +17 -16
- package/dist/approval-api/store.d.ts.map +1 -1
- package/dist/approval-api/store.js +10 -9
- package/dist/approval-api/store.js.map +1 -1
- package/dist/approval-api/tenant-context.d.ts +6 -6
- package/dist/approval-api/tenant-context.d.ts.map +1 -1
- package/dist/approval-api/tenant-context.js +20 -3
- package/dist/approval-api/tenant-context.js.map +1 -1
- package/dist/approval-api/tenant-store.d.ts +1 -1
- package/dist/approval-api/tenant-store.d.ts.map +1 -1
- package/dist/approval-api/types.d.ts +14 -7
- package/dist/approval-api/types.d.ts.map +1 -1
- package/dist/approval-api/types.js +2 -1
- package/dist/approval-api/types.js.map +1 -1
- package/dist/approval-ui/App.d.ts +2 -2
- package/dist/approval-ui/FilterBar.d.ts +3 -3
- package/dist/approval-ui/FilterBar.js +3 -3
- package/dist/approval-ui/client.d.ts +1 -1
- package/dist/approval-ui/components.d.ts +1 -1
- package/dist/approval-ui/stream.d.ts +3 -3
- package/dist/approval-ui/stream.js +2 -2
- package/dist/approval-ui/use-approval-dashboard.d.ts +9 -12
- package/dist/approval-ui/use-approval-dashboard.d.ts.map +1 -1
- package/dist/approval-ui/use-approval-dashboard.js +6 -9
- package/dist/approval-ui/use-approval-dashboard.js.map +1 -1
- package/dist/approval-ui/use-web-socket-transport.d.ts +1 -1
- package/dist/approval-ui/use-web-socket-transport.js +1 -1
- package/dist/background-tasks/d1-storage.d.ts +3 -3
- package/dist/background-tasks/d1-storage.js +3 -3
- package/dist/background-tasks/host.d.ts +4 -4
- package/dist/background-tasks/host.js +2 -2
- package/dist/background-tasks/routes.js +3 -3
- package/dist/do-runner/breakwater-keys.d.ts +1 -1
- package/dist/do-runner/breakwater-keys.js +1 -1
- package/dist/do-runner/cf-types.d.ts +1 -1
- package/dist/do-runner/d1-storage.d.ts +37 -36
- package/dist/do-runner/d1-storage.d.ts.map +1 -1
- package/dist/do-runner/d1-storage.js +24 -23
- package/dist/do-runner/d1-storage.js.map +1 -1
- package/dist/do-runner/durable-object.d.ts +2 -2
- package/dist/do-runner/durable-object.d.ts.map +1 -1
- package/dist/do-runner/durable-object.js +5 -5
- package/dist/do-runner/durable-object.js.map +1 -1
- package/dist/do-runner/execution-context.d.ts +19 -0
- package/dist/do-runner/execution-context.d.ts.map +1 -0
- package/dist/do-runner/execution-context.js +70 -0
- package/dist/do-runner/execution-context.js.map +1 -0
- package/dist/do-runner/hub-do.d.ts +2 -2
- package/dist/do-runner/index.d.ts +2 -1
- package/dist/do-runner/index.d.ts.map +1 -1
- package/dist/do-runner/index.js +2 -1
- package/dist/do-runner/index.js.map +1 -1
- package/dist/do-runner/init.d.ts +1 -1
- package/dist/do-runner/memory-id.d.ts +3 -3
- package/dist/do-runner/memory-id.js +3 -3
- package/dist/do-runner/path-safe-id.d.ts +6 -6
- package/dist/do-runner/path-safe-id.js +6 -6
- package/dist/do-runner/runtime.d.ts +12 -5
- package/dist/do-runner/runtime.d.ts.map +1 -1
- package/dist/do-runner/runtime.js +158 -21
- package/dist/do-runner/runtime.js.map +1 -1
- package/dist/do-runner/thread-do.d.ts +8 -5
- package/dist/do-runner/thread-do.d.ts.map +1 -1
- package/dist/do-runner/thread-do.js +23 -6
- package/dist/do-runner/thread-do.js.map +1 -1
- package/dist/do-runner/thread-header.d.ts +2 -0
- package/dist/do-runner/thread-header.d.ts.map +1 -1
- package/dist/do-runner/thread-header.js +2 -0
- package/dist/do-runner/thread-header.js.map +1 -1
- package/dist/goals/objective-routes.d.ts +6 -6
- package/dist/goals/objective-routes.d.ts.map +1 -1
- package/dist/goals/objective-routes.js +3 -3
- package/dist/host-kit/approval-bridge.d.ts +14 -17
- package/dist/host-kit/approval-bridge.d.ts.map +1 -1
- package/dist/host-kit/approval-bridge.js +20 -20
- package/dist/host-kit/approval-bridge.js.map +1 -1
- package/dist/host-kit/bearer-auth.d.ts +1 -1
- package/dist/host-kit/bearer-auth.js +1 -1
- package/dist/host-kit/flowsafe-worker.d.ts +27 -14
- package/dist/host-kit/flowsafe-worker.d.ts.map +1 -1
- package/dist/host-kit/flowsafe-worker.js +9 -1
- package/dist/host-kit/flowsafe-worker.js.map +1 -1
- package/dist/host-kit/host-approval-service.d.ts +13 -13
- package/dist/host-kit/host-approval-service.js +10 -10
- package/dist/host-kit/index.d.ts +1 -1
- package/dist/host-kit/index.d.ts.map +1 -1
- package/dist/host-kit/index.js.map +1 -1
- package/dist/host-kit/memory-boundary.d.ts +1 -1
- package/dist/host-kit/memory-boundary.js +1 -1
- package/dist/host-kit/run-router.d.ts +10 -11
- package/dist/host-kit/run-router.d.ts.map +1 -1
- package/dist/host-kit/run-router.js.map +1 -1
- package/dist/host-kit/stream-router.d.ts +1 -1
- package/dist/host-kit/stream-router.d.ts.map +1 -1
- package/dist/host-kit/stream-ticket.d.ts +3 -3
- package/dist/host-kit/stream-ticket.d.ts.map +1 -1
- package/dist/host-kit/stream-ticket.js +1 -1
- package/dist/host-kit/tenant-registry.d.ts +1 -1
- package/dist/host-kit/tenant-registry.js +1 -1
- package/dist/host-kit/thread-topology.d.ts.map +1 -1
- package/dist/host-kit/thread-topology.js +3 -1
- package/dist/host-kit/thread-topology.js.map +1 -1
- package/dist/host-kit/verifier.d.ts +1 -1
- package/dist/host-kit/verifier.js +1 -1
- package/dist/index.d.ts +4 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -6
- package/dist/index.js.map +1 -1
- package/dist/schedules/router.d.ts +3 -3
- package/dist/schedules/router.d.ts.map +1 -1
- package/dist/schedules/router.js +2 -2
- package/dist/schedules/tick.d.ts +8 -11
- package/dist/schedules/tick.d.ts.map +1 -1
- package/dist/schedules/tick.js +11 -45
- package/dist/schedules/tick.js.map +1 -1
- package/dist/signal-providers/delivery.d.ts +1 -1
- package/dist/signal-providers/delivery.js +1 -1
- package/dist/signal-providers/host-do.d.ts +9 -7
- package/dist/signal-providers/host-do.d.ts.map +1 -1
- package/dist/signal-providers/host-do.js +28 -15
- package/dist/signal-providers/host-do.js.map +1 -1
- package/dist/signal-providers/host-topology.d.ts +27 -0
- package/dist/signal-providers/host-topology.d.ts.map +1 -0
- package/dist/signal-providers/host-topology.js +36 -0
- package/dist/signal-providers/host-topology.js.map +1 -0
- package/dist/signal-providers/index.d.ts +1 -0
- package/dist/signal-providers/index.d.ts.map +1 -1
- package/dist/signal-providers/index.js +2 -0
- package/dist/signal-providers/index.js.map +1 -1
- package/dist/signal-providers/provider.d.ts +8 -7
- package/dist/signal-providers/provider.d.ts.map +1 -1
- package/dist/signal-providers/provider.js +11 -9
- package/dist/signal-providers/provider.js.map +1 -1
- package/dist/signal-providers/subscription-d1.d.ts +3 -3
- package/dist/signal-providers/subscription-d1.d.ts.map +1 -1
- package/dist/signal-providers/subscription-d1.js +1 -1
- package/dist/signal-providers/subscription-d1.js.map +1 -1
- package/dist/signal-providers/webhook-route.d.ts +10 -2
- package/dist/signal-providers/webhook-route.d.ts.map +1 -1
- package/dist/signal-providers/webhook-route.js +55 -2
- package/dist/signal-providers/webhook-route.js.map +1 -1
- package/dist/signals/notifications-d1.d.ts +3 -4
- package/dist/signals/notifications-d1.d.ts.map +1 -1
- package/dist/signals/notifications-d1.js +3 -4
- package/dist/signals/notifications-d1.js.map +1 -1
- package/dist/signals/router.d.ts +1 -1
- package/dist/signals/router.d.ts.map +1 -1
- package/dist/signals/thread-do-routes.d.ts +10 -5
- package/dist/signals/thread-do-routes.d.ts.map +1 -1
- package/dist/signals/thread-do-routes.js +54 -18
- package/dist/signals/thread-do-routes.js.map +1 -1
- package/package.json +6 -3
|
@@ -10,19 +10,19 @@ import { type RunnerRuntime, type RunSummary } from '../do-runner/index.js';
|
|
|
10
10
|
export declare const DURABLE_AGENTIC_LOOP_WORKFLOW_ID = "durable-agentic-loop";
|
|
11
11
|
/**
|
|
12
12
|
* Brand marking an agent as RUNTIME-DRIVEN: its inherited signal wake
|
|
13
|
-
* (`agent.stream` under `ifIdle:'wake'`) re-enters the
|
|
13
|
+
* (`agent.stream` under `ifIdle:'wake'`) re-enters the tenant-run-ID-guarded
|
|
14
14
|
* {@link FlowsafeDurableAgent.executeWorkflow}, which drives
|
|
15
15
|
* `runtime.start('durable-agentic-loop', …)` rather than the base
|
|
16
|
-
* `createRun + run.start` on the
|
|
17
|
-
* routes
|
|
16
|
+
* `createRun + run.start` on the default engine. The thread-Durable-Object signal
|
|
17
|
+
* routes require this brand before honoring an idle wake, because the wake is the
|
|
18
18
|
* one signal path that starts a run: a plain core `Agent` (or a STOCK
|
|
19
19
|
* `DurableAgent`, whose `stream()` mints a tenant-less UUID and whose
|
|
20
20
|
* `executeWorkflow` runs on the default engine) would start a run OUTSIDE
|
|
21
|
-
* RunnerRuntime —
|
|
21
|
+
* RunnerRuntime — an unsafe second execution path that is tenant-unscoped and
|
|
22
22
|
* grant-underivable. Structural (a `unique symbol`-keyed truthy field) so a test
|
|
23
23
|
* double can opt in without constructing a real durable agent.
|
|
24
24
|
*
|
|
25
|
-
* The brand is paired with
|
|
25
|
+
* The brand is paired with the host-owned idle-start seam: the thread Durable Object
|
|
26
26
|
* mints the tenant-salted run id and invokes the wrapper directly, avoiding
|
|
27
27
|
* core's tenant-less idle-wake id generation.
|
|
28
28
|
*/
|
|
@@ -39,10 +39,10 @@ export interface FlowsafeDurableAgentOptions<TAgentId extends string = string, T
|
|
|
39
39
|
/** The Agent to wrap with durable, runtime-driven execution. */
|
|
40
40
|
agent: Agent<TAgentId, TTools, TOutput>;
|
|
41
41
|
/**
|
|
42
|
-
* The RunnerRuntime the loop is driven
|
|
42
|
+
* The RunnerRuntime through which the loop is driven. Required because
|
|
43
43
|
* this is the whole point of the flowsafe wrapper: executeWorkflow() calls
|
|
44
44
|
* `runtime.start('durable-agentic-loop', ...)` instead of the base
|
|
45
|
-
* `createRun + start`, so
|
|
45
|
+
* `createRun + start`, so tenant-scoped run IDs, the per-leg grant context, and the resume
|
|
46
46
|
* ledger apply to agent legs. The loop workflow is registered on this runtime
|
|
47
47
|
* by the factory (idempotently — one shared id serves every durable agent).
|
|
48
48
|
*/
|
|
@@ -55,7 +55,7 @@ export interface FlowsafeDurableAgentOptions<TAgentId extends string = string, T
|
|
|
55
55
|
cache?: DurableAgentConfig<TAgentId, TTools, TOutput>['cache'];
|
|
56
56
|
/**
|
|
57
57
|
* PubSub for the agent's own stream events (observe()/onChunk). DEFAULTS to
|
|
58
|
-
* `runtime.pubsub` (the host
|
|
58
|
+
* `runtime.pubsub` (the host Durable Object's single identity) when omitted, so the
|
|
59
59
|
* run's events and the agent's observe()/emitError feed agree without the host
|
|
60
60
|
* wiring it twice — a mismatched pubsub would leave observe() replaying an
|
|
61
61
|
* empty feed. Pass an explicit instance only to override that default.
|
|
@@ -78,33 +78,49 @@ export interface FlowsafeDurableAgentOptions<TAgentId extends string = string, T
|
|
|
78
78
|
export declare class FlowsafeDurableAgent<TAgentId extends string = string, TTools extends ToolsInput = ToolsInput, TOutput = undefined> extends DurableAgent<TAgentId, TTools, TOutput> {
|
|
79
79
|
#private;
|
|
80
80
|
/**
|
|
81
|
-
* The runtime-driven brand
|
|
81
|
+
* The runtime-driven brand the thread-Durable-Object signal wake requires (see
|
|
82
82
|
* {@link RUNTIME_DRIVEN_AGENT}). A `unique symbol` field, so it cannot collide
|
|
83
83
|
* with an inherited property and a plain `Agent` never carries it.
|
|
84
84
|
*/
|
|
85
85
|
readonly [RUNTIME_DRIVEN_AGENT] = true;
|
|
86
86
|
constructor(options: FlowsafeDurableAgentOptions<TAgentId, TTools, TOutput>);
|
|
87
87
|
/**
|
|
88
|
-
* Enforce
|
|
88
|
+
* Enforce a caller-minted tenant-scoped run ID before the inherited durable
|
|
89
|
+
* `stream()` runs: without this the
|
|
89
90
|
* optional `options.runId` would let core mint a tenant-less
|
|
90
|
-
* `crypto.randomUUID()` upstream
|
|
91
|
+
* `crypto.randomUUID()` upstream. The private run-ID guard rejects a missing or
|
|
92
|
+
* non-path-safe value before delegating to core.
|
|
91
93
|
* A host mints `${tenantId}_${uuid}` and passes it as `options.runId`.
|
|
92
94
|
*/
|
|
93
95
|
stream(messages: Parameters<DurableAgent<TAgentId, TTools, TOutput>['stream']>[0], options?: Parameters<DurableAgent<TAgentId, TTools, TOutput>['stream']>[1]): Promise<Awaited<ReturnType<DurableAgent<TAgentId, TTools, TOutput>['stream']>>>;
|
|
94
96
|
/**
|
|
95
|
-
*
|
|
97
|
+
* Start a durable stream and wait until RunnerRuntime has persisted the
|
|
98
|
+
* first suspended or terminal summary.
|
|
99
|
+
*
|
|
100
|
+
* The regular durable `stream()` returns after subscription setup while its
|
|
101
|
+
* workflow starts asynchronously. Agent hosts need an authoritative summary
|
|
102
|
+
* before answering a start request, but must keep the stream subscription
|
|
103
|
+
* and replay cache intact for later HTTP observation.
|
|
104
|
+
*
|
|
105
|
+
* @internal
|
|
106
|
+
*/
|
|
107
|
+
streamUntilPersisted(messages: Parameters<DurableAgent<TAgentId, TTools, TOutput>['stream']>[0], options: NonNullable<Parameters<DurableAgent<TAgentId, TTools, TOutput>['stream']>[1]>): Promise<Awaited<ReturnType<DurableAgent<TAgentId, TTools, TOutput>['stream']>>>;
|
|
108
|
+
/**
|
|
109
|
+
* The same tenant-scoped run-ID guard as {@link FlowsafeDurableAgent.stream} —
|
|
110
|
+
* `generate()`
|
|
96
111
|
* re-implements the durable setup and mints its own runId the same way when
|
|
97
112
|
* one is not supplied.
|
|
98
113
|
*/
|
|
99
114
|
generate(messages: Parameters<DurableAgent<TAgentId, TTools, TOutput>['generate']>[0], options?: Parameters<DurableAgent<TAgentId, TTools, TOutput>['generate']>[1]): Promise<Awaited<ReturnType<DurableAgent<TAgentId, TTools, TOutput>['generate']>>>;
|
|
100
115
|
/**
|
|
101
|
-
*
|
|
116
|
+
* The same tenant-scoped run-ID guard as {@link FlowsafeDurableAgent.stream}.
|
|
117
|
+
* `prepare()`
|
|
102
118
|
* is the third inherited minting entry point: it forwards `options?.runId` into
|
|
103
119
|
* core's `prepareForDurableExecution` (agent/durable/index.js:5980), which mints
|
|
104
120
|
* a tenant-less `crypto.randomUUID()` when it is absent (index.js:589) AND
|
|
105
121
|
* REGISTERS a run under that id (index.js:5984) — so a later
|
|
106
122
|
* `resume(runId)`/`executeWorkflow` sees a bare UUID `PATH_SAFE_ID_PATTERN`
|
|
107
|
-
* already accepts, past every downstream guard. Enforce
|
|
123
|
+
* already accepts, past every downstream guard. Enforce the caller-minted ID here, while
|
|
108
124
|
* "absent" is still visible.
|
|
109
125
|
*/
|
|
110
126
|
prepare(messages: Parameters<DurableAgent<TAgentId, TTools, TOutput>['prepare']>[0], options?: Parameters<DurableAgent<TAgentId, TTools, TOutput>['prepare']>[1]): Promise<Awaited<ReturnType<DurableAgent<TAgentId, TTools, TOutput>['prepare']>>>;
|
|
@@ -122,12 +138,12 @@ export declare class FlowsafeDurableAgent<TAgentId extends string = string, TToo
|
|
|
122
138
|
}): Promise<RunSummary>;
|
|
123
139
|
/**
|
|
124
140
|
* Drive the durable-agentic-loop through RunnerRuntime instead of the base
|
|
125
|
-
* `createRun + run.start
|
|
141
|
+
* `createRun + run.start`. stream()/generate() have already parked the
|
|
126
142
|
* non-serializables (model/tools/messageList) on the in-process run registry
|
|
127
143
|
* keyed by this runId, so the loop the runtime starts resolves them in-isolate
|
|
128
144
|
* while the runtime mints the per-leg grant context. The runId guard here is
|
|
129
145
|
* defense in depth — the public boundary (stream/generate) already enforced
|
|
130
|
-
*
|
|
146
|
+
* the tenant-scoped run-ID rule; this catches any future internal caller.
|
|
131
147
|
*/
|
|
132
148
|
protected executeWorkflow(runId: string, workflowInput: DurableAgenticWorkflowInput): Promise<void>;
|
|
133
149
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"durable-agent-runner.d.ts","sourceRoot":"","sources":["../../src/agent-runner/durable-agent-runner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"durable-agent-runner.d.ts","sourceRoot":"","sources":["../../src/agent-runner/durable-agent-runner.ts"],"names":[],"mappings":"AA0DA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EACL,YAAY,EACZ,KAAK,kBAAkB,EACvB,KAAK,2BAA2B,EAChC,KAAK,yBAAyB,EAG/B,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAIlD,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,UAAU,EAChB,MAAM,uBAAuB,CAAC;AAE/B;;;;GAIG;AACH,eAAO,MAAM,gCAAgC,yBAAyB,CAAC;AAEvE;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,oBAAoB,EAAE,OAAO,MAEzC,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAM5D;AAED,sDAAsD;AACtD,MAAM,WAAW,2BAA2B,CAC1C,QAAQ,SAAS,MAAM,GAAG,MAAM,EAChC,MAAM,SAAS,UAAU,GAAG,UAAU,EACtC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C,CAAC,CAAC,CAAC,GAC1E,OAAO,CACR,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CACxE;IAiFD;;;;;OAKG;IACG,gBAAgB,CAAC,OAAO,EAAE;QAC9B,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QACzB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,MAAM,CAAC,EAAE,yBAAyB,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC;KACvD,GAAG,OAAO,CAAC,UAAU,CAAC;IAsEvB;;;;;;;;OAQG;cACsB,eAAe,CACtC,KAAK,EAAE,MAAM,EACb,aAAa,EAAE,2BAA2B,GACzC,OAAO,CAAC,IAAI,CAAC;CA6BjB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,SAAS,MAAM,GAAG,MAAM,EAChC,MAAM,SAAS,UAAU,GAAG,UAAU,EACtC,OAAO,GAAG,SAAS,EAEnB,OAAO,EAAE,2BAA2B,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,GAC9D,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAWjD"}
|
|
@@ -51,10 +51,11 @@
|
|
|
51
51
|
// Live-isolate scope: the loop resolves the tool's execute closure from the
|
|
52
52
|
// in-process globalRunRegistry (populated by stream()). A DO holds one run in
|
|
53
53
|
// one isolate (P1), so a resume decided before eviction finds it. A resume
|
|
54
|
-
// AFTER eviction must first rehydrate that registry
|
|
55
|
-
//
|
|
56
|
-
//
|
|
57
|
-
|
|
54
|
+
// AFTER eviction must first rehydrate that registry without replaying
|
|
55
|
+
// application input processors. resumeViaRuntime() rebuilds the registry with
|
|
56
|
+
// complete runtime processor lists after invoking only reserved RBAC during
|
|
57
|
+
// empty-message preparation, then drives runtime.resume().
|
|
58
|
+
import { DurableAgent, globalRunRegistry, prepareForDurableExecution, } from '@mastra/core/agent/durable';
|
|
58
59
|
import { InvalidRunRequestError, PATH_SAFE_ID_PATTERN, } from '../do-runner/index.js';
|
|
59
60
|
/**
|
|
60
61
|
* The shared workflow id every durable-agent loop compiles to (core's
|
|
@@ -64,19 +65,19 @@ import { InvalidRunRequestError, PATH_SAFE_ID_PATTERN, } from '../do-runner/inde
|
|
|
64
65
|
export const DURABLE_AGENTIC_LOOP_WORKFLOW_ID = 'durable-agentic-loop';
|
|
65
66
|
/**
|
|
66
67
|
* Brand marking an agent as RUNTIME-DRIVEN: its inherited signal wake
|
|
67
|
-
* (`agent.stream` under `ifIdle:'wake'`) re-enters the
|
|
68
|
+
* (`agent.stream` under `ifIdle:'wake'`) re-enters the tenant-run-ID-guarded
|
|
68
69
|
* {@link FlowsafeDurableAgent.executeWorkflow}, which drives
|
|
69
70
|
* `runtime.start('durable-agentic-loop', …)` rather than the base
|
|
70
|
-
* `createRun + run.start` on the
|
|
71
|
-
* routes
|
|
71
|
+
* `createRun + run.start` on the default engine. The thread-Durable-Object signal
|
|
72
|
+
* routes require this brand before honoring an idle wake, because the wake is the
|
|
72
73
|
* one signal path that starts a run: a plain core `Agent` (or a STOCK
|
|
73
74
|
* `DurableAgent`, whose `stream()` mints a tenant-less UUID and whose
|
|
74
75
|
* `executeWorkflow` runs on the default engine) would start a run OUTSIDE
|
|
75
|
-
* RunnerRuntime —
|
|
76
|
+
* RunnerRuntime — an unsafe second execution path that is tenant-unscoped and
|
|
76
77
|
* grant-underivable. Structural (a `unique symbol`-keyed truthy field) so a test
|
|
77
78
|
* double can opt in without constructing a real durable agent.
|
|
78
79
|
*
|
|
79
|
-
* The brand is paired with
|
|
80
|
+
* The brand is paired with the host-owned idle-start seam: the thread Durable Object
|
|
80
81
|
* mints the tenant-salted run id and invokes the wrapper directly, avoiding
|
|
81
82
|
* core's tenant-less idle-wake id generation.
|
|
82
83
|
*/
|
|
@@ -99,13 +100,15 @@ export function isRuntimeDrivenAgent(agent) {
|
|
|
99
100
|
*/
|
|
100
101
|
export class FlowsafeDurableAgent extends DurableAgent {
|
|
101
102
|
/**
|
|
102
|
-
* The runtime-driven brand
|
|
103
|
+
* The runtime-driven brand the thread-Durable-Object signal wake requires (see
|
|
103
104
|
* {@link RUNTIME_DRIVEN_AGENT}). A `unique symbol` field, so it cannot collide
|
|
104
105
|
* with an inherited property and a plain `Agent` never carries it.
|
|
105
106
|
*/
|
|
106
107
|
[RUNTIME_DRIVEN_AGENT] = true;
|
|
107
108
|
#runtime;
|
|
109
|
+
#wrappedAgent;
|
|
108
110
|
#threadRuntime;
|
|
111
|
+
#persistenceWaiters = new Map();
|
|
109
112
|
constructor(options) {
|
|
110
113
|
super({
|
|
111
114
|
agent: options.agent,
|
|
@@ -122,13 +125,14 @@ export class FlowsafeDurableAgent extends DurableAgent {
|
|
|
122
125
|
maxSteps: options.maxSteps,
|
|
123
126
|
});
|
|
124
127
|
this.#runtime = options.runtime;
|
|
128
|
+
this.#wrappedAgent = options.agent;
|
|
125
129
|
this.#threadRuntime = options.threadRuntime;
|
|
126
130
|
}
|
|
127
131
|
/**
|
|
128
|
-
*
|
|
132
|
+
* Tenant-scoped run-ID enforcement at the public boundary. The durable-agent entry points (stream /
|
|
129
133
|
* generate / prepare) take an OPTIONAL runId, and when it is omitted core's
|
|
130
134
|
* `prepareForDurableExecution` mints `crypto.randomUUID()`
|
|
131
|
-
* (agent/durable/index.js:589) — the exact tenant-less fallback
|
|
135
|
+
* (agent/durable/index.js:589) — the exact tenant-less fallback this wrapper forbids —
|
|
132
136
|
* and hands it to `executeWorkflow` BELOW this class's own guard, where a bare
|
|
133
137
|
* UUID is already indistinguishable from a legitimately caller-minted one. So
|
|
134
138
|
* the guard must ALSO fire HERE, before `super.stream()/generate()/prepare()`,
|
|
@@ -145,9 +149,11 @@ export class FlowsafeDurableAgent extends DurableAgent {
|
|
|
145
149
|
}
|
|
146
150
|
}
|
|
147
151
|
/**
|
|
148
|
-
* Enforce
|
|
152
|
+
* Enforce a caller-minted tenant-scoped run ID before the inherited durable
|
|
153
|
+
* `stream()` runs: without this the
|
|
149
154
|
* optional `options.runId` would let core mint a tenant-less
|
|
150
|
-
* `crypto.randomUUID()` upstream
|
|
155
|
+
* `crypto.randomUUID()` upstream. The private run-ID guard rejects a missing or
|
|
156
|
+
* non-path-safe value before delegating to core.
|
|
151
157
|
* A host mints `${tenantId}_${uuid}` and passes it as `options.runId`.
|
|
152
158
|
*/
|
|
153
159
|
async stream(messages, options) {
|
|
@@ -159,7 +165,51 @@ export class FlowsafeDurableAgent extends DurableAgent {
|
|
|
159
165
|
return result;
|
|
160
166
|
}
|
|
161
167
|
/**
|
|
162
|
-
*
|
|
168
|
+
* Start a durable stream and wait until RunnerRuntime has persisted the
|
|
169
|
+
* first suspended or terminal summary.
|
|
170
|
+
*
|
|
171
|
+
* The regular durable `stream()` returns after subscription setup while its
|
|
172
|
+
* workflow starts asynchronously. Agent hosts need an authoritative summary
|
|
173
|
+
* before answering a start request, but must keep the stream subscription
|
|
174
|
+
* and replay cache intact for later HTTP observation.
|
|
175
|
+
*
|
|
176
|
+
* @internal
|
|
177
|
+
*/
|
|
178
|
+
async streamUntilPersisted(messages, options) {
|
|
179
|
+
this.#assertCallerRunId(options.runId);
|
|
180
|
+
const runId = options.runId;
|
|
181
|
+
if (this.#persistenceWaiters.has(runId)) {
|
|
182
|
+
throw new InvalidRunRequestError(`run '${runId}' already has a pending durable start`);
|
|
183
|
+
}
|
|
184
|
+
let resolve;
|
|
185
|
+
let reject;
|
|
186
|
+
const persisted = new Promise((resolvePromise, rejectPromise) => {
|
|
187
|
+
resolve = resolvePromise;
|
|
188
|
+
reject = rejectPromise;
|
|
189
|
+
});
|
|
190
|
+
void persisted.catch(() => undefined);
|
|
191
|
+
this.#persistenceWaiters.set(runId, { resolve, reject });
|
|
192
|
+
const onError = options.onError;
|
|
193
|
+
try {
|
|
194
|
+
const result = await this.stream(messages, {
|
|
195
|
+
...options,
|
|
196
|
+
onError: async (data) => {
|
|
197
|
+
reject(data.error instanceof Error
|
|
198
|
+
? data.error
|
|
199
|
+
: new Error(String(data.error)));
|
|
200
|
+
await onError?.(data);
|
|
201
|
+
},
|
|
202
|
+
});
|
|
203
|
+
await persisted;
|
|
204
|
+
return result;
|
|
205
|
+
}
|
|
206
|
+
finally {
|
|
207
|
+
this.#persistenceWaiters.delete(runId);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* The same tenant-scoped run-ID guard as {@link FlowsafeDurableAgent.stream} —
|
|
212
|
+
* `generate()`
|
|
163
213
|
* re-implements the durable setup and mints its own runId the same way when
|
|
164
214
|
* one is not supplied.
|
|
165
215
|
*/
|
|
@@ -168,19 +218,75 @@ export class FlowsafeDurableAgent extends DurableAgent {
|
|
|
168
218
|
return super.generate(messages, options);
|
|
169
219
|
}
|
|
170
220
|
/**
|
|
171
|
-
*
|
|
221
|
+
* The same tenant-scoped run-ID guard as {@link FlowsafeDurableAgent.stream}.
|
|
222
|
+
* `prepare()`
|
|
172
223
|
* is the third inherited minting entry point: it forwards `options?.runId` into
|
|
173
224
|
* core's `prepareForDurableExecution` (agent/durable/index.js:5980), which mints
|
|
174
225
|
* a tenant-less `crypto.randomUUID()` when it is absent (index.js:589) AND
|
|
175
226
|
* REGISTERS a run under that id (index.js:5984) — so a later
|
|
176
227
|
* `resume(runId)`/`executeWorkflow` sees a bare UUID `PATH_SAFE_ID_PATTERN`
|
|
177
|
-
* already accepts, past every downstream guard. Enforce
|
|
228
|
+
* already accepts, past every downstream guard. Enforce the caller-minted ID here, while
|
|
178
229
|
* "absent" is still visible.
|
|
179
230
|
*/
|
|
180
231
|
async prepare(messages, options) {
|
|
181
232
|
this.#assertCallerRunId(options?.runId);
|
|
182
233
|
return super.prepare(messages, options);
|
|
183
234
|
}
|
|
235
|
+
async #rehydrateRegistry(options) {
|
|
236
|
+
const wrappedAgent = this.#wrappedAgent;
|
|
237
|
+
let inputProcessors = [];
|
|
238
|
+
let llmRequestInputProcessors = [];
|
|
239
|
+
const rehydrationAgent = new Proxy(wrappedAgent, {
|
|
240
|
+
get(target, property) {
|
|
241
|
+
if (property === 'listInputProcessors') {
|
|
242
|
+
return async (requestContext) => {
|
|
243
|
+
inputProcessors = await target.listInputProcessors(requestContext);
|
|
244
|
+
return inputProcessors.filter((processor) => processor.id === 'breakwater-rbac');
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
if (property === '__listLLMRequestProcessors') {
|
|
248
|
+
return async (requestContext) => {
|
|
249
|
+
llmRequestInputProcessors =
|
|
250
|
+
await target.__listLLMRequestProcessors(requestContext);
|
|
251
|
+
return [];
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
const value = Reflect.get(target, property, target);
|
|
255
|
+
return typeof value === 'function' ? value.bind(target) : value;
|
|
256
|
+
},
|
|
257
|
+
});
|
|
258
|
+
const preparationOptions = options.memory !== undefined
|
|
259
|
+
? {
|
|
260
|
+
memory: options.memory,
|
|
261
|
+
}
|
|
262
|
+
: undefined;
|
|
263
|
+
const preparation = await prepareForDurableExecution({
|
|
264
|
+
agent: rehydrationAgent,
|
|
265
|
+
messages: [],
|
|
266
|
+
...(preparationOptions !== undefined
|
|
267
|
+
? { options: preparationOptions }
|
|
268
|
+
: {}),
|
|
269
|
+
runId: options.runId,
|
|
270
|
+
requestContext: options.requestContext,
|
|
271
|
+
mastra: this.getMastraInstance(),
|
|
272
|
+
});
|
|
273
|
+
const tripwire = preparation.registryEntry.tripwire;
|
|
274
|
+
if (tripwire) {
|
|
275
|
+
preparation.registryEntry.cleanup?.();
|
|
276
|
+
throw new Error(`Durable agent registry rehydration denied: ${tripwire.reason}`);
|
|
277
|
+
}
|
|
278
|
+
preparation.registryEntry.inputProcessors = inputProcessors;
|
|
279
|
+
preparation.registryEntry.llmRequestInputProcessors =
|
|
280
|
+
llmRequestInputProcessors;
|
|
281
|
+
this.runRegistryInternal.registerWithMessageList(options.runId, preparation.registryEntry, preparation.messageList, {
|
|
282
|
+
threadId: preparation.threadId,
|
|
283
|
+
resourceId: preparation.resourceId,
|
|
284
|
+
});
|
|
285
|
+
globalRunRegistry.set(options.runId, {
|
|
286
|
+
...preparation.registryEntry,
|
|
287
|
+
messageList: preparation.messageList,
|
|
288
|
+
});
|
|
289
|
+
}
|
|
184
290
|
/**
|
|
185
291
|
* Rehydrate a suspended durable-agent run after isolate eviction, restore its
|
|
186
292
|
* active thread registration, then resume through RunnerRuntime so approval
|
|
@@ -189,8 +295,10 @@ export class FlowsafeDurableAgent extends DurableAgent {
|
|
|
189
295
|
*/
|
|
190
296
|
async resumeViaRuntime(options) {
|
|
191
297
|
this.#assertCallerRunId(options.runId);
|
|
192
|
-
await this.
|
|
298
|
+
const requestContext = await this.#runtime.trustedRequestContextForResume(this.getWorkflow().id, options.runId, options.step !== undefined ? { step: options.step } : {});
|
|
299
|
+
await this.#rehydrateRegistry({
|
|
193
300
|
runId: options.runId,
|
|
301
|
+
requestContext,
|
|
194
302
|
...(options.memory !== undefined ? { memory: options.memory } : {}),
|
|
195
303
|
});
|
|
196
304
|
const observed = await this.observe(options.runId);
|
|
@@ -213,8 +321,12 @@ export class FlowsafeDurableAgent extends DurableAgent {
|
|
|
213
321
|
runId: options.runId,
|
|
214
322
|
...(options.memory !== undefined ? { memory: options.memory } : {}),
|
|
215
323
|
}, this.pubsub);
|
|
324
|
+
// The approval fingerprint is the parent suspension recorded above.
|
|
325
|
+
// Do not forward that collapsed parent path to Mastra: omitting `step`
|
|
326
|
+
// lets it append the nested tool-call path stored in __workflow_meta.
|
|
327
|
+
// RunnerRuntime independently resolves the same single parent step for
|
|
328
|
+
// exact-leg capability derivation before execution.
|
|
216
329
|
const summary = await this.#runtime.resume(this.getWorkflow().id, options.runId, {
|
|
217
|
-
...(options.step !== undefined ? { step: options.step } : {}),
|
|
218
330
|
...(options.resumeData !== undefined
|
|
219
331
|
? { resumeData: options.resumeData }
|
|
220
332
|
: {}),
|
|
@@ -231,22 +343,31 @@ export class FlowsafeDurableAgent extends DurableAgent {
|
|
|
231
343
|
}
|
|
232
344
|
/**
|
|
233
345
|
* Drive the durable-agentic-loop through RunnerRuntime instead of the base
|
|
234
|
-
* `createRun + run.start
|
|
346
|
+
* `createRun + run.start`. stream()/generate() have already parked the
|
|
235
347
|
* non-serializables (model/tools/messageList) on the in-process run registry
|
|
236
348
|
* keyed by this runId, so the loop the runtime starts resolves them in-isolate
|
|
237
349
|
* while the runtime mints the per-leg grant context. The runId guard here is
|
|
238
350
|
* defense in depth — the public boundary (stream/generate) already enforced
|
|
239
|
-
*
|
|
351
|
+
* the tenant-scoped run-ID rule; this catches any future internal caller.
|
|
240
352
|
*/
|
|
241
353
|
async executeWorkflow(runId, workflowInput) {
|
|
242
354
|
this.#assertCallerRunId(runId);
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
355
|
+
const waiter = this.#persistenceWaiters.get(runId);
|
|
356
|
+
let summary;
|
|
357
|
+
try {
|
|
358
|
+
// getWorkflow() is memoized and its id is the shared loop id the factory
|
|
359
|
+
// registered; driving that exact id keeps the started run and the
|
|
360
|
+
// registered workflow in lockstep.
|
|
361
|
+
summary = await this.#runtime.start(this.getWorkflow().id, {
|
|
362
|
+
runId,
|
|
363
|
+
inputData: workflowInput,
|
|
364
|
+
});
|
|
365
|
+
waiter?.resolve();
|
|
366
|
+
}
|
|
367
|
+
catch (error) {
|
|
368
|
+
waiter?.reject(error);
|
|
369
|
+
throw error;
|
|
370
|
+
}
|
|
250
371
|
// Mirror the base: a FAILED run emits an error onto the agent's stream so
|
|
251
372
|
// observe()/onError see it. A SUSPENDED run is the approval-gate path — it
|
|
252
373
|
// returns normally and the host bridges the suspension to the approval
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"durable-agent-runner.js","sourceRoot":"","sources":["../../src/agent-runner/durable-agent-runner.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,2EAA2E;AAC3E,2EAA2E;AAC3E,8DAA8D;AAC9D,4EAA4E;AAC5E,4DAA4D;AAC5D,EAAE;AACF,uEAAuE;AACvE,sEAAsE;AACtE,oEAAoE;AACpE,6EAA6E;AAC7E,8EAA8E;AAC9E,6EAA6E;AAC7E,uEAAuE;AACvE,0DAA0D;AAC1D,yEAAyE;AACzE,6EAA6E;AAC7E,8EAA8E;AAC9E,yEAAyE;AACzE,iFAAiF;AACjF,EAAE;AACF,4EAA4E;AAC5E,+EAA+E;AAC/E,+DAA+D;AAC/D,mDAAmD;AACnD,yEAAyE;AACzE,6EAA6E;AAC7E,gEAAgE;AAChE,8EAA8E;AAC9E,+EAA+E;AAC/E,+EAA+E;AAC/E,2BAA2B;AAC3B,EAAE;AACF,+EAA+E;AAC/E,8EAA8E;AAC9E,4DAA4D;AAC5D,gEAAgE;AAChE,+EAA+E;AAC/E,0EAA0E;AAC1E,gFAAgF;AAChF,4EAA4E;AAC5E,mFAAmF;AACnF,8EAA8E;AAC9E,0EAA0E;AAC1E,kEAAkE;AAClE,gFAAgF;AAChF,sEAAsE;AACtE,gFAAgF;AAChF,yDAAyD;AACzD,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,2EAA2E;AAC3E,
|
|
1
|
+
{"version":3,"file":"durable-agent-runner.js","sourceRoot":"","sources":["../../src/agent-runner/durable-agent-runner.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,2EAA2E;AAC3E,2EAA2E;AAC3E,8DAA8D;AAC9D,4EAA4E;AAC5E,4DAA4D;AAC5D,EAAE;AACF,uEAAuE;AACvE,sEAAsE;AACtE,oEAAoE;AACpE,6EAA6E;AAC7E,8EAA8E;AAC9E,6EAA6E;AAC7E,uEAAuE;AACvE,0DAA0D;AAC1D,yEAAyE;AACzE,6EAA6E;AAC7E,8EAA8E;AAC9E,yEAAyE;AACzE,iFAAiF;AACjF,EAAE;AACF,4EAA4E;AAC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YAAY,CAAC,WAAW,EAAE,CAAC;IAC5C,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;QACzD,6EAA6E;QAC7E,8EAA8E;QAC9E,4EAA4E;QAC5E,+EAA+E;QAC/E,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAkC,CAAC,CAAC;IAC/D,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export type { AgentEntryPath, AgentRunRecord, AgentThreadBinding, } from './agent-run-state.js';
|
|
2
|
+
export { AGENT_ENTRY_PATHS, AGENT_RUN_STORAGE_KEY_PREFIX, AGENT_THREAD_BINDING_STORAGE_KEY, AgentRunStateConflictError, AgentRunStateError, agentRunStorageKey, bindAgentThread, deleteAgentRunRecord, readAgentRunRecord, readAgentThreadBinding, writeAgentRunRecord, } from './agent-run-state.js';
|
|
1
3
|
export { AGENT_APPROVAL_SUSPEND_TYPE, type AgentApprovalSuspend, agentGateConnectors, parseAgentApprovalSuspend, } from './approval-shapes.js';
|
|
2
4
|
export { createFlowsafeDurableAgent, DURABLE_AGENTIC_LOOP_WORKFLOW_ID, FlowsafeDurableAgent, type FlowsafeDurableAgentOptions, isRuntimeDrivenAgent, RUNTIME_DRIVEN_AGENT, } from './durable-agent-runner.js';
|
|
3
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agent-runner/index.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,2BAA2B,EAC3B,KAAK,oBAAoB,EACzB,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,0BAA0B,EAC1B,gCAAgC,EAChC,oBAAoB,EACpB,KAAK,2BAA2B,EAChC,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,2BAA2B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agent-runner/index.ts"],"names":[],"mappings":"AAQA,YAAY,EACV,cAAc,EACd,cAAc,EACd,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,iBAAiB,EACjB,4BAA4B,EAC5B,gCAAgC,EAChC,0BAA0B,EAC1B,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,2BAA2B,EAC3B,KAAK,oBAAoB,EACzB,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,0BAA0B,EAC1B,gCAAgC,EAChC,oBAAoB,EACpB,KAAK,2BAA2B,EAChC,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,2BAA2B,CAAC"}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// Subpath-only (like host-kit): it imports the durable Agent, which drags
|
|
6
6
|
// @mastra's Node built-ins, so it stays out of the root barrel and off the
|
|
7
7
|
// browser's import graph.
|
|
8
|
+
export { AGENT_ENTRY_PATHS, AGENT_RUN_STORAGE_KEY_PREFIX, AGENT_THREAD_BINDING_STORAGE_KEY, AgentRunStateConflictError, AgentRunStateError, agentRunStorageKey, bindAgentThread, deleteAgentRunRecord, readAgentRunRecord, readAgentThreadBinding, writeAgentRunRecord, } from './agent-run-state.js';
|
|
8
9
|
export { AGENT_APPROVAL_SUSPEND_TYPE, agentGateConnectors, parseAgentApprovalSuspend, } from './approval-shapes.js';
|
|
9
10
|
export { createFlowsafeDurableAgent, DURABLE_AGENTIC_LOOP_WORKFLOW_ID, FlowsafeDurableAgent, isRuntimeDrivenAgent, RUNTIME_DRIVEN_AGENT, } from './durable-agent-runner.js';
|
|
10
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/agent-runner/index.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,+EAA+E;AAC/E,qDAAqD;AACrD,EAAE;AACF,0EAA0E;AAC1E,2EAA2E;AAC3E,0BAA0B;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/agent-runner/index.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,+EAA+E;AAC/E,qDAAqD;AACrD,EAAE;AACF,0EAA0E;AAC1E,2EAA2E;AAC3E,0BAA0B;AAO1B,OAAO,EACL,iBAAiB,EACjB,4BAA4B,EAC5B,gCAAgC,EAChC,0BAA0B,EAC1B,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,2BAA2B,EAE3B,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,0BAA0B,EAC1B,gCAAgC,EAChC,oBAAoB,EAEpB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,2BAA2B,CAAC"}
|
|
@@ -29,8 +29,8 @@ export declare const DECIDER_ROLES: readonly ApprovalRole[];
|
|
|
29
29
|
* e2e mirror tripwire pins "breakwater's Actor fields + tenantId".
|
|
30
30
|
*
|
|
31
31
|
* `tenantId` crosses an authentication boundary (bearer map or JWT claims):
|
|
32
|
-
* every verifier must validate it against TENANT_ID_PATTERN
|
|
33
|
-
* do-runner/path-safe-id.ts
|
|
32
|
+
* every verifier must validate it against TENANT_ID_PATTERN in
|
|
33
|
+
* do-runner/path-safe-id.ts before constructing an ApprovalActor — the type
|
|
34
34
|
* says `string`, but the type system has no authority over a decoded token.
|
|
35
35
|
*/
|
|
36
36
|
export interface ApprovalActor {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"d1-store.d.ts","sourceRoot":"","sources":["../../src/approval-api/d1-store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"d1-store.d.ts","sourceRoot":"","sources":["../../src/approval-api/d1-store.ts"],"names":[],"mappings":"AAuBA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,YAAY,EAElB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,KAAK,mBAAmB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,cAAc,EAEnB,KAAK,cAAc,EAQpB,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,yBAAyB,CAAC;CACnD;AAED,MAAM,WAAW,yBAAyB;IACxC,IAAI,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,yBAAyB,CAAC;IACtD,KAAK,CAAC,CAAC,GAAG,OAAO,KAAK,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IACxC,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IACxB,GAAG,CAAC,CAAC,GAAG,OAAO,KAAK,OAAO,CAAC;QAAE,OAAO,EAAE,CAAC,EAAE,CAAA;KAAE,CAAC,CAAC;CAC/C;AA6WD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7B;AAED;;;;;;;;;GASG;AACH,wBAAsB,oBAAoB,CACxC,EAAE,EAAE,gBAAgB,GACnB,OAAO,CAAC,IAAI,CAAC,CA+Cf;AAED,qBAAa,eAAgB,YAAW,aAAa;;IACnD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,CAAC,YAAY,CAAC,EAAG,IAAI,CAAU;gBAK5B,EAAE,EAAE,gBAAgB,EAAE,OAAO,EAAE,sBAAsB;IAc3D,MAAM,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;IAkGrD,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAU/C,IAAI,CAAC,MAAM,GAAE,kBAAuB,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAoBhE,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAShD,UAAU,CACd,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,SAAS,cAAc,EAAE,EAC/B,KAAK,EAAE,aAAa,GACnB,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;CA0ElC;AAMD,iFAAiF;AACjF,wBAAgB,qBAAqB,CACnC,EAAE,EAAE,gBAAgB,EACpB,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GACzB,mBAAmB,CA8DrB"}
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
// D1ApprovalStoreFactory (tenant-store.ts) — this class is not exported from
|
|
15
15
|
// the package barrel.
|
|
16
16
|
import { d1Changes } from '../do-runner/d1-storage.js';
|
|
17
|
-
import { TENANT_ID_PATTERN, tenantOwnsSaltedId, } from '../do-runner/path-safe-id.js';
|
|
17
|
+
import { PATH_SAFE_ID_PATTERN, TENANT_ID_PATTERN, tenantOwnsSaltedId, } from '../do-runner/path-safe-id.js';
|
|
18
|
+
import { APPROVAL_ROLES } from './contract.js';
|
|
18
19
|
import { stepKeyOf, } from './store.js';
|
|
19
20
|
import { TENANT_BOUND } from './tenant-brand.js';
|
|
20
21
|
import { approvalListOrder, clampApprovalLimit, MAX_APPROVAL_LIST_LIMIT, OPEN_STATUSES, parseApprovalCursor, parseApprovalTimeBound, TERMINAL_APPROVAL_STATUSES, } from './types.js';
|
|
@@ -171,8 +172,8 @@ function listOrderBy(filter) {
|
|
|
171
172
|
return 'ORDER BY created_at ASC, id ASC';
|
|
172
173
|
}
|
|
173
174
|
/**
|
|
174
|
-
* One aggregate query, computed once per call
|
|
175
|
-
*
|
|
175
|
+
* One aggregate query, computed once per call, instead of loading every
|
|
176
|
+
* record into JavaScript just to count. Must match
|
|
176
177
|
* store.ts's computeApprovalMetrics field-for-field (store.test.ts pins the
|
|
177
178
|
* cross-backend parity, including the AVG-over-julianday vs JS Date-ms/1000
|
|
178
179
|
* arithmetic landing on the same value for round-second fixtures). SUM over
|
|
@@ -261,14 +262,29 @@ function rowToRecord(row) {
|
|
|
261
262
|
catch {
|
|
262
263
|
throw new Error(`approval '${row.id}' has invalid resume_target JSON`);
|
|
263
264
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
265
|
+
const ownsPathSafeId = (value) => typeof value === 'string' &&
|
|
266
|
+
PATH_SAFE_ID_PATTERN.test(value) &&
|
|
267
|
+
tenantOwnsSaltedId(row.tenant_id, value);
|
|
268
|
+
const object = typeof target === 'object' && target !== null
|
|
269
|
+
? target
|
|
270
|
+
: undefined;
|
|
271
|
+
const validThreadTarget = object?.kind === 'thread' &&
|
|
272
|
+
ownsPathSafeId(object.threadId) &&
|
|
273
|
+
(object.resourceId === undefined || ownsPathSafeId(object.resourceId));
|
|
274
|
+
const principal = object?.principal !== null && typeof object?.principal === 'object'
|
|
275
|
+
? object.principal
|
|
276
|
+
: undefined;
|
|
277
|
+
const validAgentTarget = object?.kind === 'agent-thread' &&
|
|
278
|
+
typeof object.agentId === 'string' &&
|
|
279
|
+
PATH_SAFE_ID_PATTERN.test(object.agentId) &&
|
|
280
|
+
ownsPathSafeId(object.threadId) &&
|
|
281
|
+
ownsPathSafeId(object.resourceId) &&
|
|
282
|
+
typeof principal?.id === 'string' &&
|
|
283
|
+
principal.id.trim() !== '' &&
|
|
284
|
+
typeof principal.role === 'string' &&
|
|
285
|
+
APPROVAL_ROLES.includes(principal.role) &&
|
|
286
|
+
principal.tenantId === row.tenant_id;
|
|
287
|
+
if (!validThreadTarget && !validAgentTarget) {
|
|
272
288
|
throw new Error(`approval '${row.id}' has an invalid or foreign resume_target`);
|
|
273
289
|
}
|
|
274
290
|
record.resumeTarget = target;
|