@proofoftech/flowsafe 0.20.0 → 0.22.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 +101 -0
- package/README.md +55 -10
- package/deployment-identity-protocol.d.mts +28 -3
- package/deployment-identity-protocol.mjs +275 -21
- package/dist/agent-host/router.d.ts.map +1 -1
- package/dist/agent-host/router.js +11 -2
- package/dist/agent-host/router.js.map +1 -1
- package/dist/agent-host/thread-host.d.ts +3 -1
- package/dist/agent-host/thread-host.d.ts.map +1 -1
- package/dist/agent-host/thread-host.js +858 -351
- package/dist/agent-host/thread-host.js.map +1 -1
- package/dist/agent-host/thread-topology.d.ts +8 -0
- package/dist/agent-host/thread-topology.d.ts.map +1 -1
- package/dist/agent-host/thread-topology.js +243 -64
- package/dist/agent-host/thread-topology.js.map +1 -1
- package/dist/agent-runner/durable-agent-runner.d.ts +89 -14
- package/dist/agent-runner/durable-agent-runner.d.ts.map +1 -1
- package/dist/agent-runner/durable-agent-runner.js +369 -44
- package/dist/agent-runner/durable-agent-runner.js.map +1 -1
- package/dist/agent-runner/index.d.ts +1 -1
- package/dist/agent-runner/index.d.ts.map +1 -1
- package/dist/agent-runner/index.js.map +1 -1
- package/dist/approval-api/actor-context.d.ts +4 -0
- package/dist/approval-api/actor-context.d.ts.map +1 -1
- package/dist/approval-api/actor-context.js +53 -5
- package/dist/approval-api/actor-context.js.map +1 -1
- package/dist/approval-api/principal.d.ts +1 -1
- package/dist/approval-api/principal.js +1 -1
- package/dist/approval-api/retention.d.ts +1 -2
- package/dist/approval-api/retention.d.ts.map +1 -1
- package/dist/approval-api/retention.js.map +1 -1
- package/dist/approval-api/service.d.ts +13 -20
- package/dist/approval-api/service.d.ts.map +1 -1
- package/dist/approval-api/service.js +52 -28
- package/dist/approval-api/service.js.map +1 -1
- package/dist/audit-export/index.d.ts +2 -2
- package/dist/audit-export/index.js +2 -2
- package/dist/background-tasks/d1-storage.d.ts +4 -3
- package/dist/background-tasks/d1-storage.d.ts.map +1 -1
- package/dist/background-tasks/d1-storage.js +8 -14
- package/dist/background-tasks/d1-storage.js.map +1 -1
- package/dist/background-tasks/host.d.ts.map +1 -1
- package/dist/background-tasks/host.js +3 -2
- package/dist/background-tasks/host.js.map +1 -1
- package/dist/do-runner/constants.d.ts +3 -0
- package/dist/do-runner/constants.d.ts.map +1 -0
- package/dist/do-runner/constants.js +3 -0
- package/dist/do-runner/constants.js.map +1 -0
- package/dist/do-runner/d1-storage.d.ts +34 -158
- package/dist/do-runner/d1-storage.d.ts.map +1 -1
- package/dist/do-runner/d1-storage.js +935 -402
- package/dist/do-runner/d1-storage.js.map +1 -1
- package/dist/do-runner/durable-object.d.ts.map +1 -1
- package/dist/do-runner/durable-object.js +472 -185
- package/dist/do-runner/durable-object.js.map +1 -1
- package/dist/do-runner/execution-admission.d.ts +114 -0
- package/dist/do-runner/execution-admission.d.ts.map +1 -0
- package/dist/do-runner/execution-admission.js +206 -0
- package/dist/do-runner/execution-admission.js.map +1 -0
- package/dist/do-runner/execution-context.d.ts +5 -1
- package/dist/do-runner/execution-context.d.ts.map +1 -1
- package/dist/do-runner/execution-context.js +6 -1
- package/dist/do-runner/execution-context.js.map +1 -1
- package/dist/do-runner/execution-fence.d.ts +74 -30
- package/dist/do-runner/execution-fence.d.ts.map +1 -1
- package/dist/do-runner/execution-fence.js +684 -120
- package/dist/do-runner/execution-fence.js.map +1 -1
- package/dist/do-runner/fenced-workflow-capability.d.ts +64 -0
- package/dist/do-runner/fenced-workflow-capability.d.ts.map +1 -0
- package/dist/do-runner/fenced-workflow-capability.js +3 -0
- package/dist/do-runner/fenced-workflow-capability.js.map +1 -0
- package/dist/do-runner/fenced-workflows-d1.d.ts +15 -0
- package/dist/do-runner/fenced-workflows-d1.d.ts.map +1 -0
- package/dist/do-runner/fenced-workflows-d1.js +894 -0
- package/dist/do-runner/fenced-workflows-d1.js.map +1 -0
- package/dist/do-runner/index.d.ts +13 -8
- package/dist/do-runner/index.d.ts.map +1 -1
- package/dist/do-runner/index.js +6 -2
- package/dist/do-runner/index.js.map +1 -1
- package/dist/do-runner/initial-admission-refusal.d.ts +7 -0
- package/dist/do-runner/initial-admission-refusal.d.ts.map +1 -0
- package/dist/do-runner/initial-admission-refusal.js +41 -0
- package/dist/do-runner/initial-admission-refusal.js.map +1 -0
- package/dist/do-runner/inventory.d.ts +2 -1
- package/dist/do-runner/inventory.d.ts.map +1 -1
- package/dist/do-runner/inventory.js +28 -39
- package/dist/do-runner/inventory.js.map +1 -1
- package/dist/do-runner/notification-predicate.d.ts +7 -7
- package/dist/do-runner/notification-predicate.d.ts.map +1 -1
- package/dist/do-runner/notification-predicate.js +134 -7
- package/dist/do-runner/notification-predicate.js.map +1 -1
- package/dist/do-runner/run-lifecycle.d.ts +20 -1
- package/dist/do-runner/run-lifecycle.d.ts.map +1 -1
- package/dist/do-runner/run-lifecycle.js +69 -15
- package/dist/do-runner/run-lifecycle.js.map +1 -1
- package/dist/do-runner/run-provenance.d.ts +38 -0
- package/dist/do-runner/run-provenance.d.ts.map +1 -0
- package/dist/do-runner/run-provenance.js +152 -0
- package/dist/do-runner/run-provenance.js.map +1 -0
- package/dist/do-runner/run-storage-tables.d.ts +2 -0
- package/dist/do-runner/run-storage-tables.d.ts.map +1 -0
- package/dist/do-runner/run-storage-tables.js +4 -0
- package/dist/do-runner/run-storage-tables.js.map +1 -0
- package/dist/do-runner/run-terminal-state.d.ts +29 -0
- package/dist/do-runner/run-terminal-state.d.ts.map +1 -0
- package/dist/do-runner/run-terminal-state.js +105 -0
- package/dist/do-runner/run-terminal-state.js.map +1 -0
- package/dist/do-runner/runtime.d.ts +108 -46
- package/dist/do-runner/runtime.d.ts.map +1 -1
- package/dist/do-runner/runtime.js +927 -438
- package/dist/do-runner/runtime.js.map +1 -1
- package/dist/do-runner/start-idempotency.d.ts +35 -258
- package/dist/do-runner/start-idempotency.d.ts.map +1 -1
- package/dist/do-runner/start-idempotency.js +606 -498
- package/dist/do-runner/start-idempotency.js.map +1 -1
- package/dist/do-runner/start-reservation-contract.d.ts +103 -0
- package/dist/do-runner/start-reservation-contract.d.ts.map +1 -0
- package/dist/do-runner/start-reservation-contract.js +338 -0
- package/dist/do-runner/start-reservation-contract.js.map +1 -0
- package/dist/do-runner/suspension-deadline.d.ts +4 -11
- package/dist/do-runner/suspension-deadline.d.ts.map +1 -1
- package/dist/do-runner/suspension-deadline.js +8 -12
- package/dist/do-runner/suspension-deadline.js.map +1 -1
- package/dist/do-runner/table-prefix.d.ts.map +1 -1
- package/dist/do-runner/table-prefix.js +2 -1
- package/dist/do-runner/table-prefix.js.map +1 -1
- package/dist/do-runner/testing.d.ts +3 -0
- package/dist/do-runner/testing.d.ts.map +1 -0
- package/dist/do-runner/testing.js +3 -0
- package/dist/do-runner/testing.js.map +1 -0
- package/dist/do-runner/thread-do.d.ts +2 -1
- package/dist/do-runner/thread-do.d.ts.map +1 -1
- package/dist/do-runner/thread-do.js +14 -10
- package/dist/do-runner/thread-do.js.map +1 -1
- package/dist/do-runner/workflow-snapshot-row.d.ts +49 -0
- package/dist/do-runner/workflow-snapshot-row.d.ts.map +1 -0
- package/dist/do-runner/workflow-snapshot-row.js +97 -0
- package/dist/do-runner/workflow-snapshot-row.js.map +1 -0
- package/dist/goals/objective-routes.d.ts +1 -5
- package/dist/goals/objective-routes.d.ts.map +1 -1
- package/dist/goals/objective-routes.js +32 -53
- package/dist/goals/objective-routes.js.map +1 -1
- package/dist/host-kit/approval-bridge.d.ts +8 -8
- package/dist/host-kit/approval-bridge.d.ts.map +1 -1
- package/dist/host-kit/approval-bridge.js +18 -15
- package/dist/host-kit/approval-bridge.js.map +1 -1
- package/dist/host-kit/do-response.d.ts +16 -0
- package/dist/host-kit/do-response.d.ts.map +1 -1
- package/dist/host-kit/do-response.js +181 -0
- package/dist/host-kit/do-response.js.map +1 -1
- package/dist/host-kit/do-run-topology.d.ts +2 -14
- package/dist/host-kit/do-run-topology.d.ts.map +1 -1
- package/dist/host-kit/do-run-topology.js +31 -24
- package/dist/host-kit/do-run-topology.js.map +1 -1
- package/dist/host-kit/env-vars.d.ts.map +1 -1
- package/dist/host-kit/env-vars.js +5 -6
- package/dist/host-kit/env-vars.js.map +1 -1
- package/dist/host-kit/flowsafe-worker.d.ts +38 -6
- package/dist/host-kit/flowsafe-worker.d.ts.map +1 -1
- package/dist/host-kit/flowsafe-worker.js +115 -93
- package/dist/host-kit/flowsafe-worker.js.map +1 -1
- package/dist/host-kit/host-approval-service.d.ts +4 -14
- package/dist/host-kit/host-approval-service.d.ts.map +1 -1
- package/dist/host-kit/host-approval-service.js +23 -40
- package/dist/host-kit/host-approval-service.js.map +1 -1
- package/dist/host-kit/index.d.ts +7 -1
- package/dist/host-kit/index.d.ts.map +1 -1
- package/dist/host-kit/index.js +4 -0
- package/dist/host-kit/index.js.map +1 -1
- package/dist/host-kit/run-route-error.d.ts +3 -17
- package/dist/host-kit/run-route-error.d.ts.map +1 -1
- package/dist/host-kit/run-route-error.js +4 -24
- package/dist/host-kit/run-route-error.js.map +1 -1
- package/dist/host-kit/run-router.d.ts +6 -2
- package/dist/host-kit/run-router.d.ts.map +1 -1
- package/dist/host-kit/run-router.js +93 -80
- package/dist/host-kit/run-router.js.map +1 -1
- package/dist/host-kit/thread-topology.d.ts +1 -1
- package/dist/host-kit/thread-topology.d.ts.map +1 -1
- package/dist/host-kit/thread-topology.js +7 -3
- package/dist/host-kit/thread-topology.js.map +1 -1
- package/dist/internal-error-response.d.ts.map +1 -1
- package/dist/internal-error-response.js +16 -6
- package/dist/internal-error-response.js.map +1 -1
- package/dist/schedules/index.d.ts +1 -0
- package/dist/schedules/index.d.ts.map +1 -1
- package/dist/schedules/index.js +1 -7
- package/dist/schedules/index.js.map +1 -1
- package/dist/schedules/mutation-contract.d.ts +38 -0
- package/dist/schedules/mutation-contract.d.ts.map +1 -0
- package/dist/schedules/mutation-contract.js +21 -0
- package/dist/schedules/mutation-contract.js.map +1 -0
- package/dist/schedules/router.d.ts +11 -19
- package/dist/schedules/router.d.ts.map +1 -1
- package/dist/schedules/router.js +130 -49
- package/dist/schedules/router.js.map +1 -1
- package/dist/schedules/schedules-d1.d.ts +11 -5
- package/dist/schedules/schedules-d1.d.ts.map +1 -1
- package/dist/schedules/schedules-d1.js +571 -144
- package/dist/schedules/schedules-d1.js.map +1 -1
- package/dist/schedules/storage.d.ts +0 -7
- package/dist/schedules/storage.d.ts.map +1 -1
- package/dist/schedules/storage.js +0 -27
- package/dist/schedules/storage.js.map +1 -1
- package/dist/schedules/tick.d.ts +1 -8
- package/dist/schedules/tick.d.ts.map +1 -1
- package/dist/schedules/tick.js +15 -20
- package/dist/schedules/tick.js.map +1 -1
- package/dist/signal-providers/webhook-route.d.ts +1 -1
- package/dist/signal-providers/webhook-route.d.ts.map +1 -1
- package/dist/signal-providers/webhook-route.js +99 -109
- package/dist/signal-providers/webhook-route.js.map +1 -1
- package/dist/signals/d1-shared.d.ts +11 -8
- package/dist/signals/d1-shared.d.ts.map +1 -1
- package/dist/signals/d1-shared.js +2 -7
- package/dist/signals/d1-shared.js.map +1 -1
- package/dist/signals/index.d.ts +1 -1
- package/dist/signals/index.d.ts.map +1 -1
- package/dist/signals/index.js +1 -1
- package/dist/signals/index.js.map +1 -1
- package/dist/signals/notification-dispatch.d.ts +84 -4
- package/dist/signals/notification-dispatch.d.ts.map +1 -1
- package/dist/signals/notification-dispatch.js +365 -53
- package/dist/signals/notification-dispatch.js.map +1 -1
- package/dist/signals/notifications-d1.d.ts +6 -1
- package/dist/signals/notifications-d1.d.ts.map +1 -1
- package/dist/signals/notifications-d1.js +215 -10
- package/dist/signals/notifications-d1.js.map +1 -1
- package/dist/signals/router.d.ts +6 -4
- package/dist/signals/router.d.ts.map +1 -1
- package/dist/signals/router.js +49 -84
- package/dist/signals/router.js.map +1 -1
- package/dist/signals/thread-do-routes.d.ts +2 -0
- package/dist/signals/thread-do-routes.d.ts.map +1 -1
- package/dist/signals/thread-do-routes.js +250 -81
- package/dist/signals/thread-do-routes.js.map +1 -1
- package/package.json +9 -7
- package/scripts/seed-deployment-identity.mjs +27 -6
|
@@ -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":"AAmRA,OAAO,EACL,KAAK,KAAK,EACV,KAAK,qBAAqB,EAI1B,KAAK,UAAU,EAChB,MAAM,oBAAoB,CAAC;AAC5B,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,EACL,KAAK,sBAAsB,EAG5B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,KAAK,sBAAsB,EAG3B,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EACnB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAGL,uBAAuB,EACxB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EACV,uBAAuB,EACvB,cAAc,EACd,aAAa,EACb,UAAU,EACV,eAAe,EAChB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,4CAA4C,CAAC;AAEpD,iFAAiF;AACjF,MAAM,MAAM,4BAA4B,GAAG,uBAAuB,GAAG;IACnE,QAAQ,CAAC,SAAS,EAAE,sBAAsB,CAAC;IAC3C,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,2EAA2E;AAC3E,MAAM,MAAM,mBAAmB,GAAG,cAAc,GAAG;IACjD,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B,CAAC;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2I/C,sFAAsF;IAChF,iBAAiB,CACrB,eAAe,EAAE,aAAa,EAC9B,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC;IAe9C;;;;;;;;OAQG;cACsB,eAAe,CACtC,KAAK,EAAE,MAAM,EACb,aAAa,EAAE,2BAA2B,GACzC,OAAO,CAAC,IAAI,CAAC;CA6FjB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;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,CAYjD"}
|
|
@@ -195,16 +195,62 @@
|
|
|
195
195
|
// caveat as getWorkflow() returning a startable object, and reaching it takes a
|
|
196
196
|
// deliberate private cast, which is a first-party act.
|
|
197
197
|
//
|
|
198
|
-
// Corroboration: breakwater's guarded handle reaches the same verdict on
|
|
199
|
-
//
|
|
200
|
-
//
|
|
201
|
-
//
|
|
202
|
-
//
|
|
203
|
-
//
|
|
204
|
-
//
|
|
205
|
-
//
|
|
206
|
-
//
|
|
207
|
-
//
|
|
198
|
+
// Corroboration: breakwater's guarded handle reaches the same verdict on the
|
|
199
|
+
// network four (network, resumeNetwork, approveNetworkToolCall,
|
|
200
|
+
// declineNetworkToolCall), the legacy pair (generateLegacy, streamLegacy) and
|
|
201
|
+
// sendToolApproval, which it files `intentionallyUnavailable`
|
|
202
|
+
// (packages/breakwater/src/agent/agent.test.ts). It diverges on
|
|
203
|
+
// listSuspendedRuns, which it files under `explicitlyNonExecution` — the same
|
|
204
|
+
// divergence as listActiveRuns, and for the same reason: a narrowed HANDLE can
|
|
205
|
+
// only omit, so a data-returning member is harmless there, while an INSTANCE
|
|
206
|
+
// Mastra calls in-process must throw. The two members blocked below diverge the
|
|
207
|
+
// same way; each entry records it.
|
|
208
|
+
//
|
|
209
|
+
// Two more Agent-level members are blocked. Read from the @mastra/core 1.67.0
|
|
210
|
+
// dist, the declared peer; offsets here are 1.67.0-vintage, in
|
|
211
|
+
// agent-Dk0N0Nlg.js unless another file is named, and the 1.53.0 offsets above
|
|
212
|
+
// are left as the provenance of that read. The peer carries both members, so
|
|
213
|
+
// each refusal shadows a real implementation.
|
|
214
|
+
//
|
|
215
|
+
// - listActiveThreadRuns() (:38214) is the discovery ground one scope wider
|
|
216
|
+
// than listActiveRuns. It takes no arguments and returns `{ runId,
|
|
217
|
+
// resourceId, threadId }` for every thread on the pubsub instance with a run
|
|
218
|
+
// in flight (storage-MbGlKLkB.js:1011-1023), and that state is keyed by
|
|
219
|
+
// pubsub instance rather than by agent (`#statesByPubSub`, :150, read through
|
|
220
|
+
// #getState :294), so it narrows by neither principal nor agent where the two
|
|
221
|
+
// listings above at least narrow by agentId. The in-process sibling
|
|
222
|
+
// getActiveThreadRunId() stays non-execution because it makes the caller name
|
|
223
|
+
// the (resourceId, threadId) pair: it confirms where this enumerates.
|
|
224
|
+
// Breakwater files it `explicitlyNonExecution` (agent.test.ts) for the reason
|
|
225
|
+
// it files listActiveRuns there: a narrowed HANDLE can only omit, so a
|
|
226
|
+
// data-returning member is harmless there, while an INSTANCE Mastra calls
|
|
227
|
+
// in-process must throw. Cost, stated rather than left to be rediscovered:
|
|
228
|
+
// core's AgentController aggregates this member across its backing agents
|
|
229
|
+
// (agent-controller-CKgKFyMR.js:5722-5725), so that aggregation now throws.
|
|
230
|
+
// It is already unusable over this class — the same controller calls the
|
|
231
|
+
// blocked sendToolApproval() at :4089 and :4118.
|
|
232
|
+
// - __setThreadRuntimeAgent() (:33609) installs another agent as the target
|
|
233
|
+
// the thread-runtime paths resolve through #getThreadRuntimeAgent()
|
|
234
|
+
// (:33612, `this.#threadRuntimeAgent ?? this`); the refusal in
|
|
235
|
+
// BLOCKED_RUN_ENTRIES names those paths, for the core it is written
|
|
236
|
+
// against. That is the fourth ground by installation rather than by call:
|
|
237
|
+
// the containment those inherited members rely on IS virtual dispatch on
|
|
238
|
+
// `this`, so one call moves every run those paths start onto an agent
|
|
239
|
+
// carrying none of these overrides — no caller-minted runId assertion, no
|
|
240
|
+
// executeWorkflow, no #startRequesters backstop. subscribeToThread drives no
|
|
241
|
+
// run of its own; the field moves its replay target all the same. It is
|
|
242
|
+
// public in the type surface (agent.d.ts:229 declares it with no modifier),
|
|
243
|
+
// so unlike getLegacyHandler it takes no private cast.
|
|
244
|
+
// Breakwater files it `explicitlyNonExecution` (agent.test.ts) for the
|
|
245
|
+
// reason it files the listings there: a narrowed HANDLE can only omit, so
|
|
246
|
+
// a setter is harmless there, while an INSTANCE Mastra calls in-process
|
|
247
|
+
// must throw.
|
|
248
|
+
//
|
|
249
|
+
// Both carry the `override` keyword, like every other refusal in this class:
|
|
250
|
+
// the declared peer declares both members, so the keyword holds each refusal to
|
|
251
|
+
// a base that exists and fails the typecheck if a future core drops one. Each
|
|
252
|
+
// signature satisfies the base it shadows on that base's own terms; the caveat
|
|
253
|
+
// on each member says how.
|
|
208
254
|
//
|
|
209
255
|
// Blocking them keeps the single-resume and no-capability guarantees true by
|
|
210
256
|
// construction: resumeViaRuntime() is the ONLY way a run resumes.
|
|
@@ -215,7 +261,7 @@
|
|
|
215
261
|
// generic resumer; grants are derived on the (suspendedAt, resumeCount)
|
|
216
262
|
// fingerprint there. Blocking does not un-brand the agent — DurableAgentLike
|
|
217
263
|
// duck-types on `recover`/`recoverActiveRuns` merely BEING functions
|
|
218
|
-
// (
|
|
264
|
+
// (agent-Dk0N0Nlg.js:272), which the overrides still are. The surface tripwire in
|
|
219
265
|
// durable-agent-surface.test.ts requires every DurableAgent prototype member to
|
|
220
266
|
// stay classified, so a future peer bump surfaces whatever it adds.
|
|
221
267
|
//
|
|
@@ -229,7 +275,17 @@
|
|
|
229
275
|
import { isMastraSignalMessage, MessageList, mastraDBMessageToSignal, } from '@mastra/core/agent';
|
|
230
276
|
import { DurableAgent, globalRunRegistry, prepareForDurableExecution, } from '@mastra/core/agent/durable';
|
|
231
277
|
import { isExecutionPrincipalId, isExecutionPrincipalKind, } from '../approval-api/principal.js';
|
|
232
|
-
import {
|
|
278
|
+
import { normalizeMutationEpoch, normalizeStartIdentity, } from '../do-runner/execution-admission.js';
|
|
279
|
+
import { InvalidRunRequestError, isPathSafeId, RunStateUnreadableError, } from '../do-runner/index.js';
|
|
280
|
+
import { resourceIdFromKey } from '../do-runner/memory-id.js';
|
|
281
|
+
import { captureReservation, } from '../do-runner/start-reservation-contract.js';
|
|
282
|
+
/** @internal A coherent snapshot belongs to another agent or thread. */
|
|
283
|
+
export class AgentRunSelectorMismatchError extends RunStateUnreadableError {
|
|
284
|
+
constructor(workflowId, runId) {
|
|
285
|
+
super(workflowId, runId);
|
|
286
|
+
this.name = 'AgentRunSelectorMismatchError';
|
|
287
|
+
}
|
|
288
|
+
}
|
|
233
289
|
/**
|
|
234
290
|
* The shared workflow id every durable-agent loop compiles to (core's
|
|
235
291
|
* DurableAgentDefaults.AGENTIC_LOOP). Exposed so hosts and tests can reference
|
|
@@ -245,6 +301,77 @@ const UNREGISTERED_RUN_REFUSAL_PREFIX = 'Flowsafe durable-agent runner refused u
|
|
|
245
301
|
*/
|
|
246
302
|
export const FLOWSAFE_PERSISTENCE_FORBIDDEN = 'flowsafe.persistence-forbidden';
|
|
247
303
|
const BREAKWATER_GUARDED_AGENT_HOST_PROTOCOL = Symbol.for('@proofoftech/breakwater/guarded-agent-host/v1');
|
|
304
|
+
function captureAgentStartAuthority(source, requestedBy, requestedByKind) {
|
|
305
|
+
if (source === null || typeof source !== 'object' || Array.isArray(source)) {
|
|
306
|
+
throw new InvalidRunRequestError('agent start authority is required');
|
|
307
|
+
}
|
|
308
|
+
const { mutationEpoch: rawEpoch, startIdentity: rawIdentity, agentStart: rawAgentStart, onPreparedStartIdentity, runOwnerGuard: rawGuard, startReservation: rawReservation, } = source;
|
|
309
|
+
if (rawIdentity === undefined ||
|
|
310
|
+
rawAgentStart === undefined ||
|
|
311
|
+
!Object.hasOwn(source, 'onPreparedStartIdentity')) {
|
|
312
|
+
throw new InvalidRunRequestError('agent start authority is incomplete');
|
|
313
|
+
}
|
|
314
|
+
const startReservation = rawReservation === undefined
|
|
315
|
+
? undefined
|
|
316
|
+
: captureReservation(rawReservation, 'started');
|
|
317
|
+
const mutationEpoch = normalizeMutationEpoch(rawEpoch);
|
|
318
|
+
const identity = normalizeStartIdentity(rawIdentity);
|
|
319
|
+
if (identity.target.kind !== 'agent') {
|
|
320
|
+
throw new InvalidRunRequestError('agent start authority requires an agent target');
|
|
321
|
+
}
|
|
322
|
+
if (identity.owner.id !== requestedBy ||
|
|
323
|
+
identity.owner.kind !== requestedByKind) {
|
|
324
|
+
throw new InvalidRunRequestError('startIdentity owner does not match requester');
|
|
325
|
+
}
|
|
326
|
+
if (rawAgentStart === null ||
|
|
327
|
+
typeof rawAgentStart !== 'object' ||
|
|
328
|
+
Array.isArray(rawAgentStart)) {
|
|
329
|
+
throw new InvalidRunRequestError('agentStart is malformed');
|
|
330
|
+
}
|
|
331
|
+
const { threaded } = rawAgentStart;
|
|
332
|
+
if (typeof threaded !== 'boolean') {
|
|
333
|
+
throw new InvalidRunRequestError('agentStart is malformed');
|
|
334
|
+
}
|
|
335
|
+
if (onPreparedStartIdentity !== undefined &&
|
|
336
|
+
typeof onPreparedStartIdentity !== 'function') {
|
|
337
|
+
throw new InvalidRunRequestError('onPreparedStartIdentity is malformed');
|
|
338
|
+
}
|
|
339
|
+
let runOwnerGuard;
|
|
340
|
+
if (rawGuard !== undefined) {
|
|
341
|
+
if (rawGuard === null ||
|
|
342
|
+
typeof rawGuard !== 'object' ||
|
|
343
|
+
Array.isArray(rawGuard)) {
|
|
344
|
+
throw new InvalidRunRequestError('runOwnerGuard is malformed');
|
|
345
|
+
}
|
|
346
|
+
const { owner: rawOwner, reservationToken } = rawGuard;
|
|
347
|
+
if (rawOwner === null ||
|
|
348
|
+
typeof rawOwner !== 'object' ||
|
|
349
|
+
Array.isArray(rawOwner)) {
|
|
350
|
+
throw new InvalidRunRequestError('runOwnerGuard is malformed');
|
|
351
|
+
}
|
|
352
|
+
const { kind, id } = rawOwner;
|
|
353
|
+
if (!isExecutionPrincipalKind(kind) ||
|
|
354
|
+
!isExecutionPrincipalId(id) ||
|
|
355
|
+
!isPathSafeId(reservationToken)) {
|
|
356
|
+
throw new InvalidRunRequestError('runOwnerGuard is malformed');
|
|
357
|
+
}
|
|
358
|
+
runOwnerGuard = Object.freeze({
|
|
359
|
+
owner: Object.freeze({ kind, id }),
|
|
360
|
+
reservationToken,
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
return Object.freeze({
|
|
364
|
+
mutationEpoch,
|
|
365
|
+
startIdentity: Object.freeze({
|
|
366
|
+
owner: identity.owner,
|
|
367
|
+
target: identity.target,
|
|
368
|
+
}),
|
|
369
|
+
agentStart: Object.freeze({ threaded }),
|
|
370
|
+
onPreparedStartIdentity,
|
|
371
|
+
runOwnerGuard,
|
|
372
|
+
startReservation,
|
|
373
|
+
});
|
|
374
|
+
}
|
|
248
375
|
function snapshotDurableCallOptions(options) {
|
|
249
376
|
if (options === undefined)
|
|
250
377
|
return undefined;
|
|
@@ -332,8 +459,9 @@ const THREAD_TOOL_APPROVAL_REASON = 'the messages-plus-approved branch does not
|
|
|
332
459
|
* 3. snapshot deletion owned by deployment-scoped retention;
|
|
333
460
|
* 4. a SECOND execution surface that runs the agent outside RunnerRuntime
|
|
334
461
|
* entirely, or that mints a run id below the caller — the network loop's
|
|
335
|
-
* own workflow, the legacy handler,
|
|
336
|
-
* continuation
|
|
462
|
+
* own workflow, the legacy handler, the thread runtime's tool-approval
|
|
463
|
+
* continuation, and the setter that installs a different agent as the
|
|
464
|
+
* thread runtime's execution target.
|
|
337
465
|
*
|
|
338
466
|
* Deliberately NOT re-exported from `./index.js` (a named-exports-only barrel),
|
|
339
467
|
* so this stays off the public `@proofoftech/flowsafe/agent-runner` subpath.
|
|
@@ -350,6 +478,7 @@ export const BLOCKED_RUN_ENTRIES = {
|
|
|
350
478
|
declineToolCallGenerate: RESUME_FAMILY_REASON,
|
|
351
479
|
listActiveRuns: "core scopes the running-run listing by agentId plus the caller's own optional thread and resource ids, never by per-principal ownership, so it bypasses the host topology's run-ownership checks and returns run, thread and resource ids the caller does not own",
|
|
352
480
|
listSuspendedRuns: "core scopes the suspended-run listing by agentId plus the caller's own optional thread and resource ids, never by per-principal ownership, so it bypasses the host topology's run-ownership checks and returns run, thread and resource ids the caller does not own",
|
|
481
|
+
listActiveThreadRuns: 'core scopes the active thread-run listing by nothing at all: it takes no arguments and returns the run, thread and resource ids of every thread on the pubsub instance with a run in flight, which core keys by pubsub instance rather than by agent, so it enumerates ids across every principal AND every agent that shares the instance',
|
|
353
482
|
deleteRunSnapshots: 'durable-agent snapshot rows are retained until deployment-scoped retention purge removes them',
|
|
354
483
|
network: `${NETWORK_FAMILY_REASON}, and it mints an unowned run id when the caller omits one`,
|
|
355
484
|
resumeNetwork: NETWORK_FAMILY_REASON,
|
|
@@ -358,6 +487,7 @@ export const BLOCKED_RUN_ENTRIES = {
|
|
|
358
487
|
generateLegacy: LEGACY_FAMILY_REASON,
|
|
359
488
|
streamLegacy: LEGACY_FAMILY_REASON,
|
|
360
489
|
sendToolApproval: THREAD_TOOL_APPROVAL_REASON,
|
|
490
|
+
__setThreadRuntimeAgent: "it installs the agent the thread-runtime paths resolve their target through — on @mastra/core 1.67.0 these are subscribeToThread, claimThreadOwnership, sendMessage, queueMessage, sendStateSignal, sendNotificationSignal and sendSignal, which read the field it writes — so one call moves every run those paths start, and subscribeToThread's replay target with them, onto an agent that carries none of this class's overrides: no caller-minted run id, no executeWorkflow, and no terminal refusal for a run the host start seam never registered",
|
|
361
491
|
};
|
|
362
492
|
/**
|
|
363
493
|
* The refusal every blocked run entry point throws. A plain `Error`, not
|
|
@@ -444,6 +574,7 @@ export class FlowsafeDurableAgent extends DurableAgent {
|
|
|
444
574
|
* `finally`, so nothing outlives the start it belongs to.
|
|
445
575
|
*/
|
|
446
576
|
#startIdempotencyKeys = new Map();
|
|
577
|
+
#startAuthorities = new Map();
|
|
447
578
|
#startScheduleDispatches = new Map();
|
|
448
579
|
// The host's exact options object receives one private, single-use re-entry ticket.
|
|
449
580
|
#hostStreamTickets = new WeakSet();
|
|
@@ -472,12 +603,12 @@ export class FlowsafeDurableAgent extends DurableAgent {
|
|
|
472
603
|
* Host-owned run-ID enforcement at the public boundary. The durable-agent entry points (stream /
|
|
473
604
|
* generate / prepare) take an OPTIONAL runId, and when it is omitted core's
|
|
474
605
|
* `prepareForDurableExecution` mints `crypto.randomUUID()`
|
|
475
|
-
* (agent
|
|
476
|
-
*
|
|
477
|
-
*
|
|
478
|
-
*
|
|
479
|
-
*
|
|
480
|
-
*
|
|
606
|
+
* (create-durable-agent-DFHwqN2K.js:1211) — the exact unowned fallback this
|
|
607
|
+
* wrapper forbids — and hands it to `executeWorkflow` BELOW this class's own
|
|
608
|
+
* guard, where a bare UUID is already indistinguishable from a legitimately
|
|
609
|
+
* caller-minted one. So the guard must ALSO fire HERE, before
|
|
610
|
+
* `super.stream()/generate()/prepare()`, while "absent" is still visible. Same
|
|
611
|
+
* posture as `RunnerRuntime.start`
|
|
481
612
|
* (typeof + PATH_SAFE_ID_PATTERN, NO generation fallback); the `typeof` check
|
|
482
613
|
* is load-bearing because `RegExp.test` coerces its argument to a string, so a
|
|
483
614
|
* numeric runId would pass the pattern yet key a run by the number. Homed once
|
|
@@ -501,13 +632,17 @@ export class FlowsafeDurableAgent extends DurableAgent {
|
|
|
501
632
|
* consumption make that exemption unavailable to callers.
|
|
502
633
|
*/
|
|
503
634
|
#assertRunIdNotLive(runId) {
|
|
504
|
-
if (this
|
|
505
|
-
this.#persistenceWaiters.has(runId) ||
|
|
506
|
-
globalRunRegistry.has(runId) ||
|
|
507
|
-
this.runRegistryInternal.has(runId)) {
|
|
635
|
+
if (this.isRunLive(runId)) {
|
|
508
636
|
throw new InvalidRunRequestError('run id is live in the run registry — a registered run cannot be re-entered');
|
|
509
637
|
}
|
|
510
638
|
}
|
|
639
|
+
/** @internal */
|
|
640
|
+
isRunLive(runId) {
|
|
641
|
+
return (this.#startRequesters.has(runId) ||
|
|
642
|
+
this.#persistenceWaiters.has(runId) ||
|
|
643
|
+
globalRunRegistry.has(runId) ||
|
|
644
|
+
this.runRegistryInternal.has(runId));
|
|
645
|
+
}
|
|
511
646
|
#assertGuardedStructuredOutput(options) {
|
|
512
647
|
if (this.#isBreakwaterGuardedAgent &&
|
|
513
648
|
options !== null &&
|
|
@@ -567,7 +702,7 @@ export class FlowsafeDurableAgent extends DurableAgent {
|
|
|
567
702
|
* core, because core owns the call between `stream()` and
|
|
568
703
|
* `executeWorkflow()` and carries no field this could ride in.
|
|
569
704
|
*/
|
|
570
|
-
idempotencyKey) {
|
|
705
|
+
idempotencyKey, authority) {
|
|
571
706
|
const callOptions = snapshotDurableCallOptions(options);
|
|
572
707
|
this.#assertCallerRunId(callOptions?.runId);
|
|
573
708
|
this.#assertGuardedStructuredOutput(callOptions);
|
|
@@ -580,6 +715,20 @@ export class FlowsafeDurableAgent extends DurableAgent {
|
|
|
580
715
|
if (!isExecutionPrincipalKind(requestedByKind)) {
|
|
581
716
|
throw new InvalidRunRequestError('requestedByKind is malformed');
|
|
582
717
|
}
|
|
718
|
+
const capturedAuthority = captureAgentStartAuthority(authority, requestedBy, requestedByKind);
|
|
719
|
+
let capturedScheduleDispatch;
|
|
720
|
+
if (scheduleDispatch !== undefined) {
|
|
721
|
+
if (scheduleDispatch === null ||
|
|
722
|
+
typeof scheduleDispatch !== 'object' ||
|
|
723
|
+
Array.isArray(scheduleDispatch)) {
|
|
724
|
+
throw new Error('stored run lifecycle is malformed');
|
|
725
|
+
}
|
|
726
|
+
const { scheduleId, dispatchId } = scheduleDispatch;
|
|
727
|
+
if (!isPathSafeId(scheduleId) || !isPathSafeId(dispatchId)) {
|
|
728
|
+
throw new Error('stored run lifecycle is malformed');
|
|
729
|
+
}
|
|
730
|
+
capturedScheduleDispatch = Object.freeze({ scheduleId, dispatchId });
|
|
731
|
+
}
|
|
583
732
|
const runId = callOptions.runId;
|
|
584
733
|
this.#assertRunIdNotLive(runId);
|
|
585
734
|
let resolve;
|
|
@@ -593,8 +742,9 @@ export class FlowsafeDurableAgent extends DurableAgent {
|
|
|
593
742
|
this.#startRequesters.set(runId, requestedBy);
|
|
594
743
|
this.#startRequesterKinds.set(runId, requestedByKind);
|
|
595
744
|
this.#startAttemptTokens.set(runId, attemptToken);
|
|
596
|
-
|
|
597
|
-
|
|
745
|
+
this.#startAuthorities.set(runId, capturedAuthority);
|
|
746
|
+
if (capturedScheduleDispatch) {
|
|
747
|
+
this.#startScheduleDispatches.set(runId, capturedScheduleDispatch);
|
|
598
748
|
}
|
|
599
749
|
if (idempotencyKey !== undefined) {
|
|
600
750
|
this.#startIdempotencyKeys.set(runId, idempotencyKey);
|
|
@@ -622,6 +772,7 @@ export class FlowsafeDurableAgent extends DurableAgent {
|
|
|
622
772
|
this.#startAttemptTokens.delete(runId);
|
|
623
773
|
this.#startScheduleDispatches.delete(runId);
|
|
624
774
|
this.#startIdempotencyKeys.delete(runId);
|
|
775
|
+
this.#startAuthorities.delete(runId);
|
|
625
776
|
}
|
|
626
777
|
}
|
|
627
778
|
/**
|
|
@@ -656,11 +807,10 @@ export class FlowsafeDurableAgent extends DurableAgent {
|
|
|
656
807
|
* The same host-owned run-ID guard as {@link FlowsafeDurableAgent.stream}.
|
|
657
808
|
* `prepare()`
|
|
658
809
|
* is the third inherited minting entry point: it forwards `options?.runId` into
|
|
659
|
-
* core's `prepareForDurableExecution` (agent
|
|
660
|
-
* an unowned `crypto.randomUUID()` when it is absent
|
|
661
|
-
* (agent
|
|
662
|
-
* (agent
|
|
663
|
-
* that file is a re-export shim from 1.53.0) — so a later
|
|
810
|
+
* core's `prepareForDurableExecution` (create-durable-agent-DFHwqN2K.js:7882),
|
|
811
|
+
* which mints an unowned `crypto.randomUUID()` when it is absent
|
|
812
|
+
* (create-durable-agent-DFHwqN2K.js:1211) AND REGISTERS a run under that id
|
|
813
|
+
* (create-durable-agent-DFHwqN2K.js:7890) — so a later
|
|
664
814
|
* `resume(runId)`/`executeWorkflow` sees a bare UUID `PATH_SAFE_ID_PATTERN`
|
|
665
815
|
* already accepts, past every downstream guard. Enforce the caller-minted ID
|
|
666
816
|
* here, while "absent" is still visible. A prepared id remains live until core
|
|
@@ -727,6 +877,24 @@ export class FlowsafeDurableAgent extends DurableAgent {
|
|
|
727
877
|
async listSuspendedRuns(_options) {
|
|
728
878
|
throw unavailableRunEntry('listSuspendedRuns', BLOCKED_RUN_ENTRIES.listSuspendedRuns);
|
|
729
879
|
}
|
|
880
|
+
/**
|
|
881
|
+
* Refuse the thread-level run enumerator.
|
|
882
|
+
* `listActiveThreadRuns()` takes no arguments and returns a runId plus the
|
|
883
|
+
* resourceId and threadId parsed out of the key for every thread on the pubsub
|
|
884
|
+
* instance with a run in flight, and core keys that state by pubsub instance
|
|
885
|
+
* rather than by agent — so it is the same discovery ground as
|
|
886
|
+
* {@link FlowsafeDurableAgent.listActiveRuns} with the last scoping gone.
|
|
887
|
+
* The in-process sibling `getActiveThreadRunId()` stays inherited because it
|
|
888
|
+
* makes the caller name the (resourceId, threadId) pair it confirms.
|
|
889
|
+
*
|
|
890
|
+
* Signature caveat, and the reason this one is not `async`: the base declares
|
|
891
|
+
* it SYNCHRONOUS (`listActiveThreadRuns(): ActiveThreadRun[]`), so the
|
|
892
|
+
* `async … Promise<never>` shape every other refusal here carries would not
|
|
893
|
+
* be assignable to it. A re-check for a peer bump.
|
|
894
|
+
*/
|
|
895
|
+
listActiveThreadRuns() {
|
|
896
|
+
throw unavailableRunEntry('listActiveThreadRuns', BLOCKED_RUN_ENTRIES.listActiveThreadRuns);
|
|
897
|
+
}
|
|
730
898
|
/**
|
|
731
899
|
* Refuse the multi-agent network start. `network()` does not touch the
|
|
732
900
|
* durable-agentic-loop at all: it compiles a SEPARATE workflow and drives it
|
|
@@ -800,12 +968,28 @@ export class FlowsafeDurableAgent extends DurableAgent {
|
|
|
800
968
|
* Signature caveat: the base method is generic in OUTPUT, which
|
|
801
969
|
* `Parameters<>` instantiates to its `undefined` default and so types too
|
|
802
970
|
* narrowly to satisfy the base. The options parameter is widened to
|
|
803
|
-
* `unknown`
|
|
804
|
-
* every peer bump.
|
|
971
|
+
* `unknown` so it fits each instantiation. Re-check on a peer bump.
|
|
805
972
|
*/
|
|
806
973
|
async sendToolApproval(_options) {
|
|
807
974
|
throw unavailableRunEntry('sendToolApproval', BLOCKED_RUN_ENTRIES.sendToolApproval);
|
|
808
975
|
}
|
|
976
|
+
/**
|
|
977
|
+
* Refuse the thread-runtime target swap. It sets one private field that the
|
|
978
|
+
* thread-runtime paths resolve their target through, falling back to `this`;
|
|
979
|
+
* the refusal in `BLOCKED_RUN_ENTRIES` names those paths, for the core it is
|
|
980
|
+
* written against. So the containment those inherited members rely on is
|
|
981
|
+
* virtual dispatch on `this`, and one call to this setter moves every run they
|
|
982
|
+
* start, and their replay targets with them, onto an agent with none of these
|
|
983
|
+
* overrides in the chain. That is the fourth ground reached by installing a
|
|
984
|
+
* second execution surface rather than by calling one.
|
|
985
|
+
*
|
|
986
|
+
* Signature caveat: the parameter is `unknown` rather than core's
|
|
987
|
+
* `Agent<any, any, any, any>`. `unknown` satisfies that base without
|
|
988
|
+
* depending on method bivariance.
|
|
989
|
+
*/
|
|
990
|
+
__setThreadRuntimeAgent(_agent) {
|
|
991
|
+
throw unavailableRunEntry('__setThreadRuntimeAgent', BLOCKED_RUN_ENTRIES.__setThreadRuntimeAgent);
|
|
992
|
+
}
|
|
809
993
|
/**
|
|
810
994
|
* Refuse core's terminal snapshot cleanup. Its only call sites are the base
|
|
811
995
|
* `executeWorkflow` (overridden here), the blocked `resume()` and the blocked
|
|
@@ -817,7 +1001,7 @@ export class FlowsafeDurableAgent extends DurableAgent {
|
|
|
817
1001
|
* inventory in durable-agent-surface.test.ts sees a NEW member, never a new
|
|
818
1002
|
* core call site on an EXISTING one. So the override is the standing guard —
|
|
819
1003
|
* it converts core's best-effort cleanup into a throw the moment a future
|
|
820
|
-
* release calls it on a path FlowSafe drives. None does at 1.
|
|
1004
|
+
* release calls it on a path FlowSafe drives. None does at 1.67.0.
|
|
821
1005
|
*/
|
|
822
1006
|
async deleteRunSnapshots(_runId) {
|
|
823
1007
|
throw unavailableRunEntry('deleteRunSnapshots', BLOCKED_RUN_ENTRIES.deleteRunSnapshots);
|
|
@@ -1079,6 +1263,133 @@ export class FlowsafeDurableAgent extends DurableAgent {
|
|
|
1079
1263
|
clearTimeout(timeout);
|
|
1080
1264
|
}
|
|
1081
1265
|
}
|
|
1266
|
+
async authoritativeAgentStartState(expectedRuntime, threadId, runId, options) {
|
|
1267
|
+
const includeLegacy = options?.includeLegacy === true;
|
|
1268
|
+
const runtime = this.#runtime;
|
|
1269
|
+
const workflowId = this.getWorkflow().id;
|
|
1270
|
+
const agentId = this.#wrappedAgent.id;
|
|
1271
|
+
try {
|
|
1272
|
+
if (expectedRuntime !== runtime ||
|
|
1273
|
+
!isPathSafeId(threadId) ||
|
|
1274
|
+
!isPathSafeId(runId))
|
|
1275
|
+
throw new Error('agent observation selector is invalid');
|
|
1276
|
+
const state = includeLegacy
|
|
1277
|
+
? await runtime.authoritativeStartState(workflowId, runId, {
|
|
1278
|
+
includeLegacy: true,
|
|
1279
|
+
})
|
|
1280
|
+
: await runtime.authoritativeStartState(workflowId, runId);
|
|
1281
|
+
if (state === null)
|
|
1282
|
+
return null;
|
|
1283
|
+
if (state.kind === 'legacy') {
|
|
1284
|
+
if (!includeLegacy)
|
|
1285
|
+
throw new Error('legacy agent observation requires explicit opt-in');
|
|
1286
|
+
const context = state.snapshot.requestContext;
|
|
1287
|
+
const input = state.snapshot.context?.input;
|
|
1288
|
+
const correlation = context?.['breakwater.auditContext'];
|
|
1289
|
+
const memory = input?.messageListState?.memoryInfo;
|
|
1290
|
+
const observedAgentId = input?.agentId;
|
|
1291
|
+
const observedThreadId = context?.threadId;
|
|
1292
|
+
if (!isPathSafeId(observedAgentId) || !isPathSafeId(observedThreadId))
|
|
1293
|
+
throw new Error('legacy agent observation identity is malformed');
|
|
1294
|
+
const observedResourceId = resourceIdFromKey(observedThreadId);
|
|
1295
|
+
if (state.address.workflowId !== workflowId ||
|
|
1296
|
+
state.address.runId !== runId ||
|
|
1297
|
+
(input?.runId !== undefined && input.runId !== runId) ||
|
|
1298
|
+
context?.runId !== runId ||
|
|
1299
|
+
context.resourceId !== observedResourceId ||
|
|
1300
|
+
correlation?.agentId !== observedAgentId ||
|
|
1301
|
+
correlation.threadId !== observedThreadId ||
|
|
1302
|
+
correlation.resourceId !== observedResourceId ||
|
|
1303
|
+
(memory !== null &&
|
|
1304
|
+
(memory?.threadId !== observedThreadId ||
|
|
1305
|
+
memory.resourceId !== observedResourceId)))
|
|
1306
|
+
throw new Error('legacy agent observation context contradicts identity');
|
|
1307
|
+
if (observedAgentId !== agentId || observedThreadId !== threadId)
|
|
1308
|
+
throw new AgentRunSelectorMismatchError(workflowId, runId);
|
|
1309
|
+
return { ...state, threaded: memory !== null };
|
|
1310
|
+
}
|
|
1311
|
+
const identity = state.provenance.startIdentity;
|
|
1312
|
+
const threaded = state.provenance.agentStart?.threaded;
|
|
1313
|
+
if (identity?.target.kind !== 'agent' ||
|
|
1314
|
+
typeof threaded !== 'boolean' ||
|
|
1315
|
+
state.execution.workflowId !== workflowId ||
|
|
1316
|
+
state.execution.runId !== runId)
|
|
1317
|
+
throw new Error('agent observation identity is malformed');
|
|
1318
|
+
const observedAgentId = identity.target.id;
|
|
1319
|
+
const observedThreadId = identity.target.threadId;
|
|
1320
|
+
const observedResourceId = resourceIdFromKey(observedThreadId);
|
|
1321
|
+
const context = state.snapshot.requestContext;
|
|
1322
|
+
const record = (value) => {
|
|
1323
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value))
|
|
1324
|
+
throw new Error('agent observation context is malformed');
|
|
1325
|
+
return value;
|
|
1326
|
+
};
|
|
1327
|
+
const check = (value, selectors) => {
|
|
1328
|
+
if (value === undefined)
|
|
1329
|
+
return;
|
|
1330
|
+
const values = record(value);
|
|
1331
|
+
for (const [key, expected] of Object.entries(selectors))
|
|
1332
|
+
if (Object.hasOwn(values, key) && values[key] !== expected)
|
|
1333
|
+
throw new Error('agent observation context contradicts identity');
|
|
1334
|
+
};
|
|
1335
|
+
check(context, {
|
|
1336
|
+
runId,
|
|
1337
|
+
threadId: observedThreadId,
|
|
1338
|
+
resourceId: observedResourceId,
|
|
1339
|
+
});
|
|
1340
|
+
check(context?.['breakwater.auditContext'], {
|
|
1341
|
+
agentId: observedAgentId,
|
|
1342
|
+
threadId: observedThreadId,
|
|
1343
|
+
resourceId: observedResourceId,
|
|
1344
|
+
});
|
|
1345
|
+
const input = state.snapshot.context?.input;
|
|
1346
|
+
if (input !== undefined) {
|
|
1347
|
+
check(input, { agentId: observedAgentId, runId });
|
|
1348
|
+
const messageList = record(input).messageListState;
|
|
1349
|
+
if (messageList !== undefined) {
|
|
1350
|
+
const values = record(messageList);
|
|
1351
|
+
if (Object.hasOwn(values, 'memoryInfo')) {
|
|
1352
|
+
const memory = values.memoryInfo;
|
|
1353
|
+
if (memory === null) {
|
|
1354
|
+
if (threaded)
|
|
1355
|
+
throw new Error('agent mode contradicts memory');
|
|
1356
|
+
}
|
|
1357
|
+
else {
|
|
1358
|
+
const selected = record(memory);
|
|
1359
|
+
if (!threaded ||
|
|
1360
|
+
selected.threadId !== observedThreadId ||
|
|
1361
|
+
selected.resourceId !== observedResourceId)
|
|
1362
|
+
throw new Error('agent mode contradicts memory');
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
if (observedAgentId !== agentId || observedThreadId !== threadId)
|
|
1368
|
+
throw new AgentRunSelectorMismatchError(workflowId, runId);
|
|
1369
|
+
return {
|
|
1370
|
+
...state,
|
|
1371
|
+
execution: { ...state.execution, ...identity },
|
|
1372
|
+
threaded,
|
|
1373
|
+
};
|
|
1374
|
+
}
|
|
1375
|
+
catch (cause) {
|
|
1376
|
+
if (cause instanceof RunStateUnreadableError)
|
|
1377
|
+
throw cause;
|
|
1378
|
+
throw new RunStateUnreadableError(workflowId, runId, { cause });
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
/** @internal Initial identity can correlate proof without granting replay success. */
|
|
1382
|
+
async proofExecutionFor(expectedRuntime, threadId, runId) {
|
|
1383
|
+
const state = await this.authoritativeAgentStartState(expectedRuntime, threadId, runId);
|
|
1384
|
+
if (state?.storage !== 'd1')
|
|
1385
|
+
return undefined;
|
|
1386
|
+
return {
|
|
1387
|
+
tablePrefix: state.execution.tablePrefix,
|
|
1388
|
+
workflowId: state.execution.workflowId,
|
|
1389
|
+
runId: state.execution.runId,
|
|
1390
|
+
startToken: state.execution.startToken,
|
|
1391
|
+
};
|
|
1392
|
+
}
|
|
1082
1393
|
/**
|
|
1083
1394
|
* Drive the durable-agentic-loop through RunnerRuntime instead of the base
|
|
1084
1395
|
* `createRun + run.start`. stream()/generate() have already parked the
|
|
@@ -1101,13 +1412,7 @@ export class FlowsafeDurableAgent extends DurableAgent {
|
|
|
1101
1412
|
const attemptToken = this.#startAttemptTokens.get(runId);
|
|
1102
1413
|
const scheduleDispatch = this.#startScheduleDispatches.get(runId);
|
|
1103
1414
|
const idempotencyKey = this.#startIdempotencyKeys.get(runId);
|
|
1104
|
-
const
|
|
1105
|
-
runId,
|
|
1106
|
-
inputData: workflowInput,
|
|
1107
|
-
...(attemptToken === undefined ? {} : { attemptToken }),
|
|
1108
|
-
...(scheduleDispatch === undefined ? {} : { scheduleDispatch }),
|
|
1109
|
-
...(idempotencyKey === undefined ? {} : { idempotencyKey }),
|
|
1110
|
-
};
|
|
1415
|
+
const authority = this.#startAuthorities.get(runId);
|
|
1111
1416
|
if (requestedBy === undefined || requestedByKind === undefined) {
|
|
1112
1417
|
if (requestedBy !== undefined || requestedByKind !== undefined) {
|
|
1113
1418
|
throw new InvalidRunRequestError('requestedBy and requestedByKind must be provided together');
|
|
@@ -1133,10 +1438,30 @@ export class FlowsafeDurableAgent extends DurableAgent {
|
|
|
1133
1438
|
throw refusal;
|
|
1134
1439
|
return;
|
|
1135
1440
|
}
|
|
1136
|
-
|
|
1137
|
-
|
|
1441
|
+
const { runId: coreRunId, agentId: coreAgentId, ...payload } = workflowInput;
|
|
1442
|
+
if (!authority) {
|
|
1443
|
+
throw new InvalidRunRequestError('registered run is missing agent start authority');
|
|
1444
|
+
}
|
|
1445
|
+
if (coreRunId !== runId ||
|
|
1446
|
+
authority.startIdentity.target.id !== this.#wrappedAgent.id ||
|
|
1447
|
+
coreAgentId !== authority.startIdentity.target.id) {
|
|
1448
|
+
throw new InvalidRunRequestError('Core input does not match agent start authority');
|
|
1449
|
+
}
|
|
1450
|
+
const workflow = this.getWorkflow();
|
|
1451
|
+
summary = await this.#runtime.start(workflow.id, {
|
|
1452
|
+
runId,
|
|
1453
|
+
inputData: { ...payload, runId: coreRunId, agentId: coreAgentId },
|
|
1454
|
+
...(attemptToken === undefined ? {} : { attemptToken }),
|
|
1455
|
+
...(scheduleDispatch === undefined ? {} : { scheduleDispatch }),
|
|
1456
|
+
...(idempotencyKey === undefined ? {} : { idempotencyKey }),
|
|
1138
1457
|
requestedBy,
|
|
1139
1458
|
requestedByKind,
|
|
1459
|
+
mutationEpoch: authority.mutationEpoch,
|
|
1460
|
+
startIdentity: authority.startIdentity,
|
|
1461
|
+
agentStart: authority.agentStart,
|
|
1462
|
+
onPreparedStartIdentity: authority.onPreparedStartIdentity,
|
|
1463
|
+
runOwnerGuard: authority.runOwnerGuard,
|
|
1464
|
+
startReservation: authority.startReservation,
|
|
1140
1465
|
});
|
|
1141
1466
|
waiter?.resolve();
|
|
1142
1467
|
}
|