@proofoftech/flowsafe 0.21.0 → 0.23.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 +73 -0
- package/README.md +25 -12
- package/dist/agent-host/catalog.d.ts.map +1 -1
- package/dist/agent-host/catalog.js +5 -2
- package/dist/agent-host/catalog.js.map +1 -1
- package/dist/agent-host/thread-host.d.ts +16 -0
- package/dist/agent-host/thread-host.d.ts.map +1 -1
- package/dist/agent-host/thread-host.js +108 -58
- package/dist/agent-host/thread-host.js.map +1 -1
- package/dist/agent-host/thread-topology.d.ts.map +1 -1
- package/dist/agent-host/thread-topology.js +11 -9
- package/dist/agent-host/thread-topology.js.map +1 -1
- package/dist/agent-runner/durable-agent-runner.d.ts +134 -96
- package/dist/agent-runner/durable-agent-runner.d.ts.map +1 -1
- package/dist/agent-runner/durable-agent-runner.js +424 -282
- package/dist/agent-runner/durable-agent-runner.js.map +1 -1
- package/dist/approval-api/actor-context.js +3 -3
- package/dist/approval-api/actor-context.js.map +1 -1
- package/dist/approval-api/service.d.ts +6 -9
- package/dist/approval-api/service.d.ts.map +1 -1
- package/dist/approval-api/service.js +6 -9
- package/dist/approval-api/service.js.map +1 -1
- package/dist/background-tasks/d1-storage.js +1 -1
- 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/d1-storage.d.ts +4 -2
- package/dist/do-runner/d1-storage.d.ts.map +1 -1
- package/dist/do-runner/d1-storage.js +4 -2
- 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 +22 -22
- package/dist/do-runner/durable-object.js.map +1 -1
- 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 +5 -1
- package/dist/do-runner/execution-context.js.map +1 -1
- package/dist/do-runner/execution-fence.js +2 -2
- package/dist/do-runner/execution-fence.js.map +1 -1
- package/dist/do-runner/run-lifecycle.js +6 -6
- package/dist/do-runner/run-lifecycle.js.map +1 -1
- package/dist/do-runner/runtime.d.ts +23 -47
- package/dist/do-runner/runtime.d.ts.map +1 -1
- package/dist/do-runner/runtime.js +61 -68
- package/dist/do-runner/runtime.js.map +1 -1
- package/dist/do-runner/start-idempotency.js +4 -4
- package/dist/do-runner/start-idempotency.js.map +1 -1
- package/dist/host-kit/approval-bridge.d.ts +8 -8
- package/dist/host-kit/approval-bridge.js +8 -8
- package/dist/host-kit/flowsafe-worker.d.ts.map +1 -1
- package/dist/host-kit/flowsafe-worker.js +5 -0
- package/dist/host-kit/flowsafe-worker.js.map +1 -1
- package/dist/schedules/schedules-d1.js +1 -1
- package/dist/schedules/tick.d.ts +1 -8
- package/dist/schedules/tick.d.ts.map +1 -1
- package/dist/schedules/tick.js +8 -19
- package/dist/schedules/tick.js.map +1 -1
- package/dist/signals/client.d.ts +7 -4
- package/dist/signals/client.d.ts.map +1 -1
- package/dist/signals/client.js +9 -7
- package/dist/signals/client.js.map +1 -1
- package/dist/signals/d1-shared.js +1 -1
- package/dist/signals/index.d.ts +1 -1
- package/dist/signals/index.d.ts.map +1 -1
- package/dist/signals/index.js.map +1 -1
- package/dist/signals/notification-dispatch.d.ts +1 -12
- package/dist/signals/notification-dispatch.d.ts.map +1 -1
- package/dist/signals/notification-dispatch.js +0 -53
- package/dist/signals/notification-dispatch.js.map +1 -1
- package/dist/signals/thread-do-routes.d.ts +48 -9
- package/dist/signals/thread-do-routes.d.ts.map +1 -1
- package/dist/signals/thread-do-routes.js +411 -230
- package/dist/signals/thread-do-routes.js.map +1 -1
- package/package.json +14 -9
- package/scripts/seed-deployment-identity.mjs +25 -11
- package/patches/@mastra__core@1.53.0.patch +0 -54
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,78 @@
|
|
|
1
1
|
# @proofoftech/flowsafe
|
|
2
2
|
|
|
3
|
+
## 0.23.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 23eee3f: `createFlowsafeDurableAgent()` fixes the wrapper's agent-level pub/sub at construction to `pubsub ?? runtime.pubsub`, or its own stream bus when both are absent. HTTP-started threaded runs register on the thread Durable Object's pub/sub from their first start. Co-located thread Durable Objects keep separate active-run state, signals sent into those runs are drained by them, and each run publishes one stream to the thread's pub/sub topic from its first start. A `threadRuntime` object passed to the wrapper receives `registerRun` only for runs resumed through `resumeViaRuntime()`; core registers started runs. The constructor throws a `TypeError` when the wrapped agent has a different pub/sub of its own.
|
|
8
|
+
|
|
9
|
+
`FlowsafeDurableAgent` refuses `__setMemory()`, `__setPubSub()`, `abortRunStream()`, `abortThreadStream()` and `discoverThreadPeers()`.
|
|
10
|
+
|
|
11
|
+
Security: a controller's service installation reached the wrapped agent before the Mastra refusal. Direct aborts bypassed the terminate route's ownership and disputed-settlement checks and could reach another thread's run in the isolate. Peer discovery returned every advertised thread identity on the pub/sub.
|
|
12
|
+
|
|
13
|
+
Migration: the signal routes set pub/sub only on agents that are not runtime-driven and answer `503` when a runtime-driven agent's pub/sub is missing or differs from the thread's. Construct the wrapper with the thread Durable Object's pub/sub, as the thread host does, and use a fresh wrapped agent for each thread Durable Object. Configure memory and pub/sub at construction. Cancel runs through the terminate route; the stream result's `abort()` still works.
|
|
14
|
+
|
|
15
|
+
- 850f95b: The thread host refuses durable starts containing caller system messages or call-level provider options rejected by Breakwater's `assertAcceptedCallProviderOptions()` with `400`, before authorization or any write. A threadless fire whose stored options are refused records `failed`. The optional `scheduleProviderOptionsPolicy` runs on every threaded schedule fire before signal creation; a denial settles a discard, while an error leaves the lease for a later tick. The optional Breakwater peer minimum rises to `0.16.0`, which supplies these checks.
|
|
16
|
+
|
|
17
|
+
Security: before this release, a caller `role: 'system'` message passed to the thread host's durable start, and a stored schedule's call-level provider options reached the model outside the guarded agent's input policies.
|
|
18
|
+
|
|
19
|
+
Migration: raise `@proofoftech/breakwater` to `0.16.0`. Move per-agent provider options from schedules and topology starts to the agent's model entry. Wire `scheduleProviderOptionsPolicy` with both `providerOptionsCarryContent()` and `assertAcceptedCallProviderOptions()` so threaded fires are refused when either check rejects their stored options.
|
|
20
|
+
|
|
21
|
+
- ad61e7a: `createThreadSignalRoutes()` accepts an optional `notificationDispatchAllowed` callback for non-owner notification ingestion. `ThreadAgentHost` gains a required `notificationDispatchAllowed()` member that checks the target agent's catalog declaration for `system` on `notification.dispatch`; hosts can wire it to the router callback. A refused non-owner notification receives `409` with `notification-dispatch-forbidden` before an inbox row is created. This is BREAKING for hand-built `ThreadAgentHost` implementations; hosts from `createThreadAgentHost()` get the member automatically, hence the minor bump.
|
|
22
|
+
- ccffeca: `FlowsafeDurableAgent` now refuses `setChannels()`, `__setDeclaredSchedules()`, `__setMastra()` and `__registerMastra()`, so the wrapper cannot be registered on a Mastra: `Mastra.addAgent()` and constructing a `Mastra` or an `MCPServer` with the wrapper in `agents` throw; an `AgentController` throws during service installation when configured with memory or pub/sub that the wrapped agent does not own, and otherwise throws when `init()` registers the wrapper on its Mastra through `__setMastra()`. Its constructor throws a `TypeError`, and the guarded agent catalog refuses the module, when the wrapped agent has channels configured, declares schedules, sets the `durable` option, or is already a durable agent. `RunnerRuntime` refuses a workflow object that another Mastra has registered, including one registered while a start, resume or start recovery is in progress, up to the point the runtime creates the run.
|
|
23
|
+
|
|
24
|
+
Security: channels on the wrapped agent, or bound through the wrapper, dispatched inbound messages and tool approvals to the wrapped agent outside `RunnerRuntime`, and a Mastra schedule worker fired its declared schedules the same way. A wrapped agent with the `durable` option, or a Mastra `DurableAgent` passed as the wrapped agent, was registered on the runtime's Mastra as a durable agent whose recovery and run listing the runner does not guard. Registering the wrapper on a Mastra bound every later leg to that Mastra, and once the runtime had built its own Mastra it also repointed the runtime's loop workflow to the other Mastra's storage, where `status()` read a stored run as absent. A runtime workflow added to another Mastra did the same.
|
|
25
|
+
|
|
26
|
+
Migration: pass `createFlowsafeDurableAgent()` and the agent catalog a plain `Agent` without `channels`, declared schedules or the `durable` option. Do not register the wrapper on a Mastra, pass it to an `AgentController` or an `MCPServer`, or configure it as a sub-agent: every run of a parent agent registered on a Mastra fails when the parent converts its tools. Register each workflow object on one runtime, and do not add a runtime's workflows, or the wrapper's `getWorkflow()`, to another Mastra.
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- 68c4c61: Signal routes, agent-host start and resume routes, and the runner's start route read the request body before waiting for the thread's lock, so a request whose sender disconnects while it waits is still processed.
|
|
31
|
+
- 84bb66a: An owner `/signal/notification` to a runtime-driven agent is recorded in the notifications inbox and delivered at ingestion under the owner's principal: into the owner's running run, or persisted to agent memory when the thread is idle or the owner's run is not running. It never wakes a run, and no dispatch tick selects its row. The response is `{ record, delivery }`: the settled `NotificationRecord`, and Mastra's delivery decision with the delivered `signalId`. A `FlowsafeDurableAgent` registered on no Mastra uses this route-owned delivery path because Mastra's `sendNotificationSignal()` requires a notifications store on the agent's own Mastra.
|
|
32
|
+
|
|
33
|
+
Before writing anything, the route answers `409` with a `reason` when another principal's run holds the thread (`principal-mismatch`, with `retry: true`), when the delivery would need agent memory the agent lacks (`memory-unavailable`), or when a `dedupeKey` or `coalesceKey` matches a pending row the dispatch tick will deliver (`notification-pending`). After the write, the row is discarded when Mastra reports the thread blocked (`409`, `thread-blocked`), when the content policy denies the stored row's signal (`422`) or fails (`503`), and when storage or the send fails before acceptance (`502`). A failed delivered receipt write after an accepted send is retried; if the retry fails, the route answers `502` and the row stays pending with no due time. A row whose isolate dies or whose settle write the execution fence refuses also stays pending with no due time; clear it with a direct write that sets it `discarded`, or delete it. A matching keyed non-owner notification receives `notification-pending` instead of merging into this residue.
|
|
34
|
+
|
|
35
|
+
When a host passes no `canPersist`, every principal takes this owner path, signal providers included, and a provider treats a `409` as a permanent drop.
|
|
36
|
+
|
|
37
|
+
A non-owner notification is still recorded for `createNotificationDispatchTick()`, which delivers each row individually as `system` on `notification.dispatch`; no Mastra delivery policy applies, neither the default nor a configured one. On an idle thread the tick wakes a run whose principal and approval requester is `system`: the self-approval bar does not cover the notification's author, the row stores no author, and the run's permission projection and audit are `system`'s. Idle starts are limited only by `consultRunCap` where the host wires it. The tick counts a failed attempt when the run cap refuses the wake, when another principal's run holds the thread, and when the agent does not declare `system` on `notification.dispatch` in `allowedAutomation`, and it discards the row after `maxDeliveryAttempts` failed attempts.
|
|
38
|
+
|
|
39
|
+
An agent without the runtime-driven brand keeps Mastra's delivery path for owner notifications and its `degraded: 'not-runtime-driven'` marker. When its own Mastra has no notifications store, the route answers `409` before calling Mastra's sender.
|
|
40
|
+
|
|
41
|
+
`BlockingAgentRun` and the `resolveBlockingRun` result of `createThreadSignalRoutes()` take an optional `status`, which the thread host fills from the run's stored status.
|
|
42
|
+
|
|
43
|
+
Migration: a host that accepts owner notifications for a runtime-driven agent must pass `resolveNotificationsStorage` to `createThreadSignalRoutes()`, or the route returns `409`. A host with its own `resolveBlockingRun` reports each run's `status`, so that an owner notification is not queued into a run that is not executing; a run with no status is treated as running. A caller that read an owner response's `record.record` or `record.decision` reads the settled record from `record` and the delivery from `delivery`.
|
|
44
|
+
|
|
45
|
+
- 52cc784: A run resumed through `resumeViaRuntime()`, as an approval decision resumes one, registers with Mastra's thread runtime in a form whose `status` Mastra can read. Before this release, reading it threw `Cannot read private member #status`: Mastra's completion check failed after every threaded resume and never released the finished run's registration, and on a thread host built with `cache: false`, or with a `CachingPubSub` as its pub/sub, later signals, messages and schedule fires to that thread answered `502`.
|
|
46
|
+
- cf7ad72: `/signal` answers 409 when a thread has no wired resource, matching the sibling routes. Signals and messages sent into suspended runs persist to thread memory instead of remaining in the isolate, including wakes, notification dispatch, and agent-schedule fires.
|
|
47
|
+
- 20cabc3: `FlowsafeDurableAgent` preserves the input of a run that the host start seam did not register by the guarded input chain's verdict, before it refuses the run. Such a run starts when Mastra drains a signal still queued after the run it was delivered to completes, or when a caller streams into the agent directly.
|
|
48
|
+
|
|
49
|
+
- When no input processor refused the run, its prepared input is saved.
|
|
50
|
+
- When the run's input is a created signal, the call carries neither a host ticket nor a request context, and Breakwater's RBAC gate refuses it, the signal is saved as received. That is the drain after a run resumed through `resumeViaRuntime()`, whose options carry no request context: the gate refuses it for its missing actor without reading content, and on a guarded agent before any application input processor runs. Breakwater removes a refused call's input from Mastra's prepared message list, so the signal would otherwise be lost. Host code that calls `stream()` the same way, with a created signal or an object carrying the signal brand as input, has that input saved when the gate refuses it.
|
|
51
|
+
- After any other refusal nothing is saved.
|
|
52
|
+
- A transient signal is never saved.
|
|
53
|
+
|
|
54
|
+
Security: the input of an unregistered run that an input policy or processor refused was saved to the thread, where later calls load it as history without the input policies reading it.
|
|
55
|
+
|
|
56
|
+
## 0.22.0
|
|
57
|
+
|
|
58
|
+
### Minor Changes
|
|
59
|
+
|
|
60
|
+
- 36c60c8: Require `@mastra/core` 1.67.0 exactly (previously 1.53.0). The peer is exact, so every consumer must move to 1.67.0 as well; this is breaking for consumers pinned to 1.53.0. 1.67.0 bundles for Cloudflare Workers and Vite again — mastra-ai/mastra#20638, the dynamic-import regression that held the pin at 1.53.0, closed upstream.
|
|
61
|
+
|
|
62
|
+
`@mastra/cloudflare-d1` moves from 1.1.1 to 1.3.2, whose own peer requires a core newer than 1.53.0. FlowSafe's `@proofoftech/breakwater` peer floor rises to `>=0.15.0 <1.0.0` in step, that being the first Breakwater release built against the same core.
|
|
63
|
+
|
|
64
|
+
The `@mastra/core` patch FlowSafe shipped under `patches/` is retired: 1.67.0 carries both fixes upstream (mastra-ai/mastra#23693, mastra-ai/mastra#23694). The patch file is gone from the published package, and so are the two refusals that required it — FlowSafe no longer refuses to construct a delivering notification dispatch tick, nor notification ingestion and dispatch requests, on an install whose core lacks the patch. Consequence for anyone running a core outside the declared peer without having applied the patch: a notification `source` named after an `Object.prototype` member is miscounted in the summary core renders, and its source delivery policy resolves the inherited member instead of the configured priority or default action. That configuration was unsupported before and remains so, but it now fails silently rather than loudly. Application roots that copied the patch into their own `patches/` should drop it along with the `patchedDependencies` entry or `postinstall` script that applied it.
|
|
65
|
+
|
|
66
|
+
`createD1Storage({ domains })` composes the two storage domains 1.67.0 adds, `workflowDefinitions` and `knowledge`, through the same override seam as the other domains. `@mastra/cloudflare-d1` backs neither, so each resolves `undefined` unless a host supplies one through that seam.
|
|
67
|
+
|
|
68
|
+
The workspace lockfile behind this release was resolved once with pnpm's seven-day minimum-release-age gate overridden for that resolution only. Five newly resolved versions were younger than the gate at resolution on 2026-09-19: `@mastra/core` 1.67.0 and `@mastra/schema-compat` 1.3.10 (published 2026-09-15), which the workspace's standing `@mastra/*` exclude admits with the gate on, and `posthog-node` 5.52.4 (2026-09-15), `@posthog/types` 1.412.2 (2026-09-17) and `@posthog/core` 1.55.0 (2026-09-18), which the override alone admitted. None of the five declares a lifecycle script or ships a native component; all five carry npm provenance attestations (SLSA v1, published from GitHub Actions); and `posthog-node`, with `@posthog/core` and `@posthog/types` beneath it, is a hard dependency of `@mastra/core` that ships inside a bundled Worker.
|
|
69
|
+
|
|
70
|
+
The private `showcase` and `anchorage-agent-starter` packages move to the same core.
|
|
71
|
+
|
|
72
|
+
### Patch Changes
|
|
73
|
+
|
|
74
|
+
- 36cfdc2: Keep `flowsafe-provision` inert when imported from stdin, eval or print programs, and virtual workers, even when an entry name aliases the script. Direct execution, file and directory symlinks, and file workers under eval parents continue to invoke the CLI.
|
|
75
|
+
|
|
3
76
|
## 0.21.0
|
|
4
77
|
|
|
5
78
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ Flowsafe runs Mastra workflows and agents through Cloudflare Durable Objects, st
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
npm install @mastra/core@1.
|
|
12
|
+
npm install @mastra/core@1.67.0 @proofoftech/flowsafe
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
Install `@proofoftech/breakwater` when resumed steps call approval-protected connectors:
|
|
@@ -25,9 +25,9 @@ Compatibility:
|
|
|
25
25
|
- Node.js 22.13.0 or later (engine range `>=22.13.0`)
|
|
26
26
|
- ESM only
|
|
27
27
|
- TypeScript `moduleResolution: "NodeNext"`, `"Node16"`, or `"Bundler"`
|
|
28
|
-
- `@mastra/core` `1.
|
|
28
|
+
- `@mastra/core` `1.67.0`
|
|
29
29
|
- `react` and `react-dom` `>=18 <20` (React 18 or 19) for the optional approval UI
|
|
30
|
-
- `@proofoftech/breakwater` `>=0.
|
|
30
|
+
- `@proofoftech/breakwater` `>=0.16.0 <1.0.0` when used
|
|
31
31
|
- host-provided Wrangler `>=4.118 <5` for the optional `flowsafe-provision` CLI
|
|
32
32
|
|
|
33
33
|
## Choose an export
|
|
@@ -103,7 +103,7 @@ export class AppRunner extends DurableObjectRunner<Env> {
|
|
|
103
103
|
}
|
|
104
104
|
```
|
|
105
105
|
|
|
106
|
-
`init()` creates D1-backed Mastra storage from the conventional `DB` binding unless you inject storage. Workflow definitions use the same `createWorkflow()` and `createStep()` shape as Mastra. Flowsafe pins `@mastra/cloudflare-d1` 1.
|
|
106
|
+
`init()` creates D1-backed Mastra storage from the conventional `DB` binding unless you inject storage. Workflow definitions use the same `createWorkflow()` and `createStep()` shape as Mastra. Flowsafe pins `@mastra/cloudflare-d1` 1.3.2 because the shipped D1 storage is written against that release's domain surface: it subclasses the adapter's background-tasks domain to apply the `TaskFilter.resourceId` predicate the adapter accepts but omits from its SQL builder, and hand-writes the schedules, notifications, and thread-state domains the adapter does not ship at all. `D1StorageOptions.domains` accepts host-supplied `workflowDefinitions` and `knowledge` domains, which have no D1-backed defaults. The pin also holds the adapter on its `@cloudflare/workers-types` v4 peer, which is the major Flowsafe still builds against.
|
|
107
107
|
|
|
108
108
|
If the deployment uses a table prefix, pass one shared constant to storage and host maintenance:
|
|
109
109
|
|
|
@@ -117,7 +117,7 @@ const worker = createFlowsafeWorker({
|
|
|
117
117
|
});
|
|
118
118
|
```
|
|
119
119
|
|
|
120
|
-
The prefix may be empty or must start with an ASCII letter or underscore and continue with ASCII letters, numbers, or underscores. It can contain at most 39 characters because Mastra limits final table identifiers to 63 characters and `mastra_workflow_snapshot` uses the remaining 24.
|
|
120
|
+
The prefix may be empty or must start with an ASCII letter or underscore and continue with ASCII letters, numbers, or underscores. It can contain at most 39 characters because Mastra limits final table identifiers to 63 characters and `mastra_workflow_snapshot` uses the remaining 24. The exported low-level purge functions validate the same contract before preparing D1 statements. `storageTablePrefix` is not auto-discovered and must match the `tablePrefix` used by `init()` or `createD1Storage()`.
|
|
121
121
|
|
|
122
122
|
## Approval lifecycle
|
|
123
123
|
|
|
@@ -451,9 +451,9 @@ A policy failure is opaque: direct delivery returns 503, schedule state is left
|
|
|
451
451
|
|
|
452
452
|
Configure the same positive safe-integer `maxDeliveryAttempts` on `createNotificationDispatchTick()` and `createThreadSignalRoutes()`. Both default to `DEFAULT_MAX_NOTIFICATION_DELIVERY_ATTEMPTS`. A recorded failure at the bound discards the notification with `deliveryReason: "delivery-attempts-exhausted"`, retaining its count and last error. An already-exhausted row is never sent; its discard is conditional on the observed record remaining current. Below the bound, existing retry delays apply.
|
|
453
453
|
|
|
454
|
-
Dispatch requires `NotificationDeliveryStorage`; `D1NotificationsStorage` implements it. A custom store's `updateNotificationDeliveryIfUnchanged()` must compare the captured observation and apply the failure patch atomically against its other writers. Ordinary Core storage still serves notification ingestion
|
|
454
|
+
Dispatch requires `NotificationDeliveryStorage`; `D1NotificationsStorage` implements it. A custom store's `updateNotificationDeliveryIfUnchanged()` must compare the captured observation and apply the failure patch atomically against its other writers. Ordinary Core storage still serves notification ingestion. See the [delivery and receipt guide](https://github.com/ProofOfTechOrg/anchorage/blob/main/docs/durable-agents.md#bound-notification-delivery) for custom-store migration, lost responses and receipt retention.
|
|
455
455
|
|
|
456
|
-
Summary source counts and a configured source delivery policy read own properties
|
|
456
|
+
Summary items arise only from rows written by Mastra's delivery policy, which means an unbranded agent's owner notifications. Summary source counts and a configured source delivery policy read own properties: the declared `@mastra/core` peer guards both lookups, so a source named after an `Object.prototype` member is counted under its own key and resolves the configured priority or default action. A core outside the declared peer range that predates [mastra-ai/mastra#23693](https://github.com/mastra-ai/mastra/issues/23693) and [mastra-ai/mastra#23694](https://github.com/mastra-ai/mastra/issues/23694) miscounts such a source and selects the inherited policy entry instead.
|
|
457
457
|
|
|
458
458
|
Adapt Breakwater without adding a FlowSafe runtime dependency on it:
|
|
459
459
|
|
|
@@ -462,7 +462,9 @@ import { RequestContext } from '@mastra/core/request-context';
|
|
|
462
462
|
import {
|
|
463
463
|
ACTOR_CONTEXT_KEY,
|
|
464
464
|
AGENT_AUDIT_CONTEXT_KEY,
|
|
465
|
+
assertAcceptedCallProviderOptions,
|
|
465
466
|
createContentPolicyGate,
|
|
467
|
+
providerOptionsCarryContent,
|
|
466
468
|
} from '@proofoftech/breakwater';
|
|
467
469
|
import {
|
|
468
470
|
breakwaterActorFor,
|
|
@@ -496,6 +498,19 @@ function signalPolicyContext(input: SignalContentPolicyInput): RequestContext {
|
|
|
496
498
|
|
|
497
499
|
const signalRoutes = createThreadSignalRoutes({
|
|
498
500
|
// Existing server-owned resolvers and dispatch seams.
|
|
501
|
+
notificationDispatchAllowed: (scope, agentId) =>
|
|
502
|
+
host.notificationDispatchAllowed(scope, agentId),
|
|
503
|
+
scheduleProviderOptionsPolicy: ({ providerOptions }) => {
|
|
504
|
+
try {
|
|
505
|
+
if (providerOptionsCarryContent(providerOptions)) {
|
|
506
|
+
return { allowed: false, outcome: 'denied' };
|
|
507
|
+
}
|
|
508
|
+
assertAcceptedCallProviderOptions(providerOptions);
|
|
509
|
+
return { allowed: true };
|
|
510
|
+
} catch {
|
|
511
|
+
return { allowed: false, outcome: 'denied' };
|
|
512
|
+
}
|
|
513
|
+
},
|
|
499
514
|
contentPolicy: (input) =>
|
|
500
515
|
inspectContent({
|
|
501
516
|
text: input.text,
|
|
@@ -506,7 +521,7 @@ const signalRoutes = createThreadSignalRoutes({
|
|
|
506
521
|
|
|
507
522
|
Build the request context only from the callback input. FlowSafe derives those fields from the asserted Thread Durable Object scope and server-owned metadata; never merge HTTP body context or caller-supplied identity into it.
|
|
508
523
|
|
|
509
|
-
|
|
524
|
+
A non-owner's notification, and an unbranded agent's owner notification, are checked before the inbox write, so a denied one is never recorded. Storage owns the id, the timestamps and any coalescing, so ingestion inspects a canonical prospective notification carrying every untrusted model-visible field, as the individual signal and as the single-record summary. An owner notification to a runtime-driven agent is delivered at ingestion instead: the route records it, checks the exact individual signal built from the stored row, and sends only that signal; a denial discards the row. Dispatch checks the exact persisted individual or summary signal for each record it delivers.
|
|
510
525
|
|
|
511
526
|
`D1NotificationsStorage` and `D1ThreadStateStorage` mirror Mastra's in-memory domains on D1. `SignalClient` is available from the browser-safe `signals/client` export.
|
|
512
527
|
|
|
@@ -538,7 +553,7 @@ The composed `createFlowsafeWorker()` owns the shared route and maintenance-duty
|
|
|
538
553
|
|
|
539
554
|
Configure `mutationEpoch` with a nonnegative safe integer or a synchronous environment callback. The Worker captures it before deployment verification or authentication, then forwards it through trusted contexts and protected internal headers. Start paths preserve the original actor, principal, epoch and selectors across waits, including class-backed context method receivers. Do not accept the epoch from public headers or start JSON.
|
|
540
555
|
|
|
541
|
-
The internal durable-agent host start requires an eighth `AgentStartAuthority` argument, with an explicit `onPreparedStartIdentity` property.
|
|
556
|
+
The internal durable-agent host start requires an eighth `AgentStartAuthority` argument, with an explicit `onPreparedStartIdentity` property. This transport does not activate final-write epoch checks or managed recovery; the [deployment reference](https://github.com/ProofOfTechOrg/anchorage/blob/main/docs/deployment-reference.md#configure-the-trusted-caller-epoch) and [durable-agents guide](https://github.com/ProofOfTechOrg/anchorage/blob/main/docs/durable-agents.md) describe the boundary.
|
|
542
557
|
|
|
543
558
|
Protect `GET` and `POST /admin/execution-fence` plus `GET /admin/inventory` with a distinct `MAINTENANCE_ADMIN_SECRET`. Fence transitions use CAS and return `409` with `FENCE_CAS_CONFLICT` when the expected state is stale. Fenced execution returns `503` with an `EXECUTION_FENCED` reason. The agent-host and stream routers preserve structured `503` and `409` refusals instead of collapsing them to a generic `500`.
|
|
544
559
|
|
|
@@ -574,7 +589,7 @@ Critical host obligations:
|
|
|
574
589
|
|
|
575
590
|
## Verification
|
|
576
591
|
|
|
577
|
-
The repository
|
|
592
|
+
The repository runs a deterministic workerd spike against the package. Durable Object conformance suites separately cover wrong and missing internal caller credentials.
|
|
578
593
|
|
|
579
594
|
```bash
|
|
580
595
|
pnpm --filter @proofoftech/flowsafe spike:verify
|
|
@@ -589,5 +604,3 @@ pnpm --filter @proofoftech/flowsafe spike:verify:llm
|
|
|
589
604
|
## License
|
|
590
605
|
|
|
591
606
|
Apache-2.0.
|
|
592
|
-
|
|
593
|
-
`patches/@mastra__core@1.53.0.patch` is a modification of `@mastra/core` `1.53.0`, which is licensed under Apache-2.0 and copyright its authors. It changes that package's published runtime chunks to correct the two defects reported as mastra-ai/mastra#23693 and mastra-ai/mastra#23694.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/agent-host/catalog.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/agent-host/catalog.ts"],"names":[],"mappings":"AAgBA,OAAO,EAEL,KAAK,YAAY,EAEjB,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,kBAAkB,EAIxB,MAAM,YAAY,CAAC;AAiJpB,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,SAAS,GAAG,SAAS,CAqB5D;AAED,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,SAAS,SAAS,EAAE,GAC7B,YAAY,CAwBd;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CAyDpE;AAED,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,SAAS,WAAW,EAAE,GAC9B,kBAAkB,CAoBpB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
import { isGuardedAgentHandle } from '@proofoftech/breakwater/agent';
|
|
3
|
-
import { breakwaterGuardedAgentHostProtocol } from '../agent-runner/durable-agent-runner.js';
|
|
3
|
+
import { breakwaterGuardedAgentHostProtocol, unwrappableAgentReason, } from '../agent-runner/durable-agent-runner.js';
|
|
4
4
|
import { AGENT_ENTRY_PATHS } from '../agent-runner/index.js';
|
|
5
5
|
import { AUTOMATED_PRINCIPAL_KINDS, RUN_START_ROLES, } from '../approval-api/index.js';
|
|
6
6
|
import { isPathSafeId } from '../do-runner/index.js';
|
|
@@ -171,6 +171,9 @@ export function validateAgentModule(module) {
|
|
|
171
171
|
if (breakwaterGuardedAgentHostProtocol(module.agent) === undefined) {
|
|
172
172
|
fail(`agent '${meta.id}' was built by a @proofoftech/breakwater release without the durable-host protocol (added in 0.12.0); install a release inside the declared peer range`);
|
|
173
173
|
}
|
|
174
|
+
const refusal = unwrappableAgentReason(module.agent);
|
|
175
|
+
if (refusal !== undefined)
|
|
176
|
+
fail(`agent '${meta.id}' ${refusal}`);
|
|
174
177
|
if (module.agent.id !== meta.id) {
|
|
175
178
|
fail(`metadata id '${meta.id}' does not match guarded agent id '${module.agent.id}'`);
|
|
176
179
|
}
|
|
@@ -188,7 +191,7 @@ export function validateAgentModule(module) {
|
|
|
188
191
|
// A handle from a breakwater older than the principal-kinds release has no
|
|
189
192
|
// such field. Say so, rather than throwing on `.filter` of undefined.
|
|
190
193
|
if (!Array.isArray(module.agent.allowedPrincipalKinds)) {
|
|
191
|
-
fail(`agent '${meta.id}' was built by a @proofoftech/breakwater without principal kinds
|
|
194
|
+
fail(`agent '${meta.id}' was built by a @proofoftech/breakwater without principal kinds`);
|
|
192
195
|
}
|
|
193
196
|
const metaKinds = new Set((meta.allowedAutomation ?? []).map((rule) => rule.kind));
|
|
194
197
|
const handleKinds = new Set(module.agent.allowedPrincipalKinds.filter((kind) => kind !== 'human'));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/agent-host/catalog.ts"],"names":[],"mappings":"AAAA,sCAAsC;
|
|
1
|
+
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/agent-host/catalog.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAGtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EACL,kCAAkC,EAClC,sBAAsB,GACvB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAEL,yBAAyB,EAEzB,eAAe,GAChB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAQL,sBAAsB,GAEvB,MAAM,YAAY,CAAC;AAEpB,SAAS,IAAI,CAAC,OAAe;IAC3B,MAAM,IAAI,KAAK,CAAC,kBAAkB,OAAO,EAAE,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,eAAe,CACtB,KAA0C,EAC1C,OAAe;IAEf,MAAM,SAAS,GAAG,KAAK,IAAI,eAAe,CAAC;IAC3C,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,IAAI,CAAC,UAAU,OAAO,kCAAkC,CAAC,CAAC;IAC5D,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAgB,CAAC;IACvC,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;QAC7B,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACpC,IAAI,CAAC,UAAU,OAAO,WAAW,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;QAC5E,CAAC;QACD,IAAI,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACrB,IAAI,CAAC,UAAU,OAAO,sCAAsC,IAAI,GAAG,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AAC"}
|
|
@@ -3,6 +3,7 @@ import { type AgentEntryPath, type FlowsafeDurableAgent, type FlowsafeDurableAge
|
|
|
3
3
|
import { type ApprovalAuditSink, type ApprovalService, type ExecutionPrincipal, type RecoverableResourceOwnershipStore } from '../approval-api/index.js';
|
|
4
4
|
import { type AutomatedExecutionPrincipal } from '../approval-api/principal.js';
|
|
5
5
|
import { type RequestContextProvider, type RunSummary, type ScheduleSourceStore, type ThreadScope } from '../do-runner/index.js';
|
|
6
|
+
import { type RunStatus } from '../do-runner/run-terminal-state.js';
|
|
6
7
|
import { type StartReservationReading } from '../do-runner/start-reservation-contract.js';
|
|
7
8
|
import type { AgentModule, AgentRunEnvelope, PrincipalPermissionResolver } from './types.js';
|
|
8
9
|
export interface AgentThreadStateStorage {
|
|
@@ -70,6 +71,11 @@ export interface ThreadAgentStartInput {
|
|
|
70
71
|
resourceId: string;
|
|
71
72
|
runId: string;
|
|
72
73
|
prompt?: string;
|
|
74
|
+
/**
|
|
75
|
+
* Created signals, alone or as list items, pass through unchanged. Every
|
|
76
|
+
* other input must be structured-cloneable (use string file and image URLs),
|
|
77
|
+
* or start answers 400.
|
|
78
|
+
*/
|
|
73
79
|
messages?: Parameters<FlowsafeDurableAgent['stream']>[0];
|
|
74
80
|
entryPath: AgentEntryPath;
|
|
75
81
|
threaded?: boolean;
|
|
@@ -109,11 +115,21 @@ export interface BoundThreadAgent {
|
|
|
109
115
|
export interface BlockingAgentRun {
|
|
110
116
|
runId: string;
|
|
111
117
|
principal: ExecutionPrincipal;
|
|
118
|
+
/**
|
|
119
|
+
* The run's stored status. Absent for a run with an operation executing in
|
|
120
|
+
* this isolate, and for one with no readable started state.
|
|
121
|
+
*/
|
|
122
|
+
status?: RunStatus;
|
|
112
123
|
}
|
|
113
124
|
export interface ThreadAgentHost {
|
|
114
125
|
requestContextForRun(base?: RequestContextProvider): RequestContextProvider;
|
|
115
126
|
/** Serialize one target-thread dispatch decision with public start/resume routes. */
|
|
116
127
|
serializeDispatch<T>(operation: () => Promise<T>): Promise<T>;
|
|
128
|
+
/**
|
|
129
|
+
* Check the catalog's system notification-dispatch declaration. Automated-entry
|
|
130
|
+
* authorization and required permissions still apply at dispatch.
|
|
131
|
+
*/
|
|
132
|
+
notificationDispatchAllowed(scope: ThreadScope, agentId: string): Promise<boolean>;
|
|
117
133
|
start(scope: ThreadScope, input: ThreadAgentStartInput): Promise<AgentRunEnvelope>;
|
|
118
134
|
resolveBoundAgent(scope: ThreadScope, input: {
|
|
119
135
|
agentId?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thread-host.d.ts","sourceRoot":"","sources":["../../src/agent-host/thread-host.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"thread-host.d.ts","sourceRoot":"","sources":["../../src/agent-host/thread-host.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAWjE,OAAO,EAGL,KAAK,cAAc,EAQnB,KAAK,oBAAoB,EACzB,KAAK,2BAA2B,EAIjC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,KAAK,iBAAiB,EAEtB,KAAK,eAAe,EAEpB,KAAK,kBAAkB,EAIvB,KAAK,iCAAiC,EAIvC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,KAAK,2BAA2B,EAGjC,MAAM,8BAA8B,CAAC;AAUtC,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,UAAU,EAIf,KAAK,mBAAmB,EAExB,KAAK,WAAW,EACjB,MAAM,uBAAuB,CAAC;AAO/B,OAAO,EAEL,KAAK,SAAS,EACf,MAAM,oCAAoC,CAAC;AAK5C,OAAO,EAEL,KAAK,uBAAuB,EAE7B,MAAM,4CAA4C,CAAC;AAgBpD,OAAO,KAAK,EACV,WAAW,EAEX,gBAAgB,EAEhB,2BAA2B,EAE5B,MAAM,YA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