@proofoftech/flowsafe 0.22.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 CHANGED
@@ -1,5 +1,58 @@
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
+
3
56
  ## 0.22.0
4
57
 
5
58
  ### Minor Changes
package/README.md CHANGED
@@ -27,7 +27,7 @@ Compatibility:
27
27
  - TypeScript `moduleResolution: "NodeNext"`, `"Node16"`, or `"Bundler"`
28
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.15.0 <1.0.0` when used
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
@@ -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. All six 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()`.
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
 
@@ -453,7 +453,7 @@ Configure the same positive safe-integer `maxDeliveryAttempts` on `createNotific
453
453
 
454
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: 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.
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
- Notification ingestion is checked before persistence, and that check is authoritative rather than advisory: Mastra's default delivery decision sends an urgent notification — and an idle-thread high or medium one — straight out of `sendNotificationSignal`, so those records never reach the dispatcher. Storage owns the id, the timestamps and any coalescing, so ingestion inspects a canonical prospective notification carrying every untrusted model-visible field, in both renderings Mastra can choose between: the individual signal and the single-record summary. Dispatch then checks the exact persisted individual or summary signal for every record that was deferred or batched to the tick.
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. Built-in hosts supply `undefined` while Runtime and owner journals remain v1. 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.
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's deterministic workerd spike proves suspend, process restart, resume, forged-resume denial, repeated gates, deployment-sentinel mismatch refusal, live streaming, durable-agent recovery, signals, goals, schedules, providers, notifications, and background-task restart. Durable Object conformance suites separately cover wrong and missing internal caller credentials.
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
@@ -1 +1 @@
1
- {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/agent-host/catalog.ts"],"names":[],"mappings":"AAYA,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,CAuDpE;AAED,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,SAAS,WAAW,EAAE,GAC9B,kBAAkB,CAoBpB"}
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; >=0.7.0 is required`);
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;AAEtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,kCAAkC,EAAE,MAAM,yCAAyC,CAAC;AAC7F,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,S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,CAAC,CAAC;IACxE,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,OAAO,EAAE,MAAM;QACf,GAAG,EAAE,CAAC,OAAe,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;QAC3C,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,iBAAiB,EAAE,OAAO,CAAC,iBAAiB;KAC7C,CAAC,CAAC;AACL,CAAC"}
@@ -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;AAOjE,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;AAY/B,OAAO,EAEL,KAAK,uBAAuB,EAE7B,MAAM,4CAA4C,CAAC;AAgBpD,OAAO,KAAK,EACV,WAAW,EAEX,gBAAgB,EAEhB,2BAA2B,EAE5B,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,uBAAuB;IACtC,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IACtD,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KA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,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAAC;IACvE,uEAAuE;IACvE,sBAAsB,CACpB,KAAK,EAAE,WAAW,EAClB,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAC5D,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;IACnC,gBAAgB,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjE,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;CACvE;AA4SD,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,sBAAsB,GAC9B,eAAe,CAszEjB"}
@@ -1,6 +1,8 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
+ import { isCreatedAgentSignal } from '@mastra/core/agent';
2
3
  import { AGENT_STREAM_TOPIC, globalRunRegistry, } from '@mastra/core/agent/durable';
3
4
  import { Mastra } from '@mastra/core/mastra';
5
+ import { assertAcceptedCallProviderOptions, assertNoGuardedSystemMessages, } from '@proofoftech/breakwater/agent';
4
6
  import { isPrincipalPermissions } from '@proofoftech/breakwater/rbac';
5
7
  import { AgentRunSelectorMismatchError, } from '../agent-runner/durable-agent-runner.js';
6
8
  import { AGENT_ENTRY_PATHS, AGENT_RUN_STORAGE_KEY_PREFIX, bindAgentThread, createFlowsafeDurableAgent, deleteAgentRunRecord, deleteAgentThreadBinding, readAgentRunRecord, readAgentThreadBinding, writeAgentRunRecord, } from '../agent-runner/index.js';
@@ -11,7 +13,7 @@ import { DoStatusError, isPathSafeId, resolveScheduleStartOwner, resourceIdFromK
11
13
  import { isDefinitiveInitialAdmissionRefusal } from '../do-runner/initial-admission-refusal.js';
12
14
  import { mastraRegistryEntries } from '../do-runner/mastra-registry.js';
13
15
  import { lifecycleFromRequestContext, terminalCleanupFor, } from '../do-runner/run-lifecycle.js';
14
- import { isTerminalRunStatus } from '../do-runner/run-terminal-state.js';
16
+ import { isTerminalRunStatus, } from '../do-runner/run-terminal-state.js';
15
17
  import { captureReservation, sameReservationIdentity, } from '../do-runner/start-reservation-contract.js';
16
18
  import { persistedStartRecord } from '../host-kit/do-response.js';
17
19
  import { abandonApprovalsForRun, reconcileApprovalsForSummary, } from '../host-kit/index.js';
@@ -145,13 +147,13 @@ function requestedBy(value) {
145
147
  return value;
146
148
  }
147
149
  /**
148
- * The reserved suspension-timeout envelope is minted by a run object's alarm and
149
- * by nothing else. Agent runs never arm a suspension deadline, so a forged
150
+ * The reserved suspension-timeout envelope is minted by a run object's alarm.
151
+ * Agent runs never arm a suspension deadline, so a forged
150
152
  * envelope here could only mislead a step — but this route forwards client
151
153
  * resume data verbatim under `requestedByKind: 'human'`, and the guarantee the
152
154
  * feature sells is that no caller can present itself to a step as an expired
153
- * deadline. The KEY is refused, exactly as the workflow resume route refuses it,
154
- * so a step that reads the key directly cannot be fooled either.
155
+ * deadline. The KEY is refused, so a step that reads the key directly cannot be
156
+ * fooled either.
155
157
  */
156
158
  function resumeData(value) {
157
159
  if (value !== null &&
@@ -305,11 +307,11 @@ export function createThreadAgentHost(options) {
305
307
  return runtime;
306
308
  };
307
309
  /**
308
- * The one entry gate, split by principal kind because the two kinds are
310
+ * The entry gate, split by principal kind because the two kinds are
309
311
  * authorized by different things and must not fall through to each other.
310
312
  *
311
313
  * A human passes the route-level start roles intersected with the agent's own
312
- * allowedRoles, exactly as before. An automated principal never consults
314
+ * allowedRoles. An automated principal never consults
313
315
  * roles at all: it must be declared in the agent's `allowedAutomation` for
314
316
  * this precise entry path, AND survive the host's optional authorizer. Absent
315
317
  * declaration denies — which is why a scheduled start of an agent that has
@@ -461,14 +463,19 @@ export function createThreadAgentHost(options) {
461
463
  resourceId: resourceIdFromKey(scope.threadId),
462
464
  runId,
463
465
  }, { includeLegacy: true });
464
- if (!state ||
465
- state.kind === 'initial' ||
466
- !isTerminalRunStatus(state.summary.status) ||
467
- (state.kind === 'legacy' && !isTerminalRunStatus(state.snapshot.status)))
466
+ if (!state || state.kind === 'initial')
468
467
  return { runId, principal: runRecord.principal };
468
+ const blocking = {
469
+ runId,
470
+ principal: runRecord.principal,
471
+ status: state.summary.status,
472
+ };
473
+ if (!isTerminalRunStatus(state.summary.status) ||
474
+ (state.kind === 'legacy' && !isTerminalRunStatus(state.snapshot.status)))
475
+ return blocking;
469
476
  const recovery = await storage.get(ownerRecoveryKey(runId));
470
477
  if (recovery !== undefined)
471
- return { runId, principal: runRecord.principal };
478
+ return blocking;
472
479
  await withRecoveryLock(() => finalizeTerminalRecord(scope, runId, runRecord, state));
473
480
  }
474
481
  return undefined;
@@ -909,7 +916,7 @@ export function createThreadAgentHost(options) {
909
916
  // The bridge mints its own principal from this id, so the audit trail shows
910
917
  // an automated principal rather than a human operator.
911
918
  const systemPrincipalId = options.systemPrincipalId ?? 'flowsafe-system';
912
- // Deliberately NOT vouched. Its only consumer projects it to an ApprovalActor
919
+ // NOT vouched. Its consumer projects it to an ApprovalActor
913
920
  // for a role-gated READ, which grants nothing an automated principal does not
914
921
  // already have — so calling the trust assertion here would assert trust that
915
922
  // nothing consumes, and `trustAutomationPrincipal` has to stay greppable as
@@ -1147,6 +1154,14 @@ export function createThreadAgentHost(options) {
1147
1154
  : values;
1148
1155
  },
1149
1156
  serializeDispatch: withDispatchLock,
1157
+ notificationDispatchAllowed: async (scope, agentId) => {
1158
+ instanceScopeFor(scope);
1159
+ return (await catalogFor(scope)).automationAllowed(agentId, {
1160
+ kind: 'system',
1161
+ id: systemPrincipalId,
1162
+ purpose: 'notification-dispatch',
1163
+ }, 'notification.dispatch');
1164
+ },
1150
1165
  blockingRun: (scope) => withBindingLock(() => findBlockingRun(instanceScopeFor(scope))),
1151
1166
  scheduleDispatchStatus: async (scope, input) => {
1152
1167
  const ref = runRef(scope, {
@@ -1274,6 +1289,34 @@ export function createThreadAgentHost(options) {
1274
1289
  const resolvedProviderOptions = source.target
1275
1290
  ? source.target.providerOptions
1276
1291
  : input.providerOptions;
1292
+ // This host bypasses the guarded handle, so checks run on forwarded
1293
+ // snapshots before state writes.
1294
+ let providerOptionsSnapshot;
1295
+ let messagesSnapshot;
1296
+ try {
1297
+ providerOptionsSnapshot = providerOptions(resolvedProviderOptions);
1298
+ // Created signals carry methods that structuredClone cannot copy.
1299
+ messagesSnapshot = isCreatedAgentSignal(messages)
1300
+ ? messages
1301
+ : Array.isArray(messages)
1302
+ ? messages.map((item) => isCreatedAgentSignal(item) ? item : structuredClone(item))
1303
+ : structuredClone(messages);
1304
+ }
1305
+ catch (error) {
1306
+ if (error instanceof AgentHostRequestError)
1307
+ throw error;
1308
+ throw new AgentHostRequestError(400, 'agent input must be cloneable');
1309
+ }
1310
+ try {
1311
+ assertNoGuardedSystemMessages(messagesSnapshot);
1312
+ assertAcceptedCallProviderOptions(providerOptionsSnapshot);
1313
+ }
1314
+ catch (error) {
1315
+ if (error instanceof TypeError) {
1316
+ throw new AgentHostRequestError(400, error.message);
1317
+ }
1318
+ throw error;
1319
+ }
1277
1320
  const { current, module, principalPermissions } = await authorize(scope, ref.agentId, entry, scope.principal);
1278
1321
  if (ref.resourceId !== resourceIdFromKey(scope.threadId)) {
1279
1322
  throw new AgentHostRequestError(404, 'run not found');
@@ -1394,8 +1437,8 @@ export function createThreadAgentHost(options) {
1394
1437
  : {}),
1395
1438
  maxSteps: module.agent.maxSteps,
1396
1439
  disableBackgroundTasks: true,
1397
- ...(resolvedProviderOptions !== undefined
1398
- ? { providerOptions: providerOptions(resolvedProviderOptions) }
1440
+ ...(providerOptionsSnapshot !== undefined
1441
+ ? { providerOptions: providerOptionsSnapshot }
1399
1442
  : {}),
1400
1443
  };
1401
1444
  const scheduleDispatch = source.target &&
@@ -1405,7 +1448,7 @@ export function createThreadAgentHost(options) {
1405
1448
  ? { scheduleId: input.scheduleId, dispatchId: input.dispatchId }
1406
1449
  : undefined;
1407
1450
  try {
1408
- await durable.streamUntilPersisted(messages, streamOptions, principal.id, principal.kind, recovery.token, scheduleDispatch, idempotencyKey, {
1451
+ await durable.streamUntilPersisted(messagesSnapshot, streamOptions, principal.id, principal.kind, recovery.token, scheduleDispatch, idempotencyKey, {
1409
1452
  ...(mutationEpoch === undefined ? {} : { mutationEpoch }),
1410
1453
  startIdentity,
1411
1454
  agentStart: { threaded },
@@ -1478,9 +1521,9 @@ export function createThreadAgentHost(options) {
1478
1521
  route: async (request, scope) => {
1479
1522
  let preflightedTermination = false;
1480
1523
  const preflightUrl = new URL(request.url);
1481
- const preflightSuffix = preflightUrl.pathname.startsWith(AGENT_HOST_ROUTE_PREFIX)
1482
- ? preflightUrl.pathname.slice(AGENT_HOST_ROUTE_PREFIX.length)
1483
- : '';
1524
+ if (!preflightUrl.pathname.startsWith(AGENT_HOST_ROUTE_PREFIX))
1525
+ return null;
1526
+ const preflightSuffix = preflightUrl.pathname.slice(AGENT_HOST_ROUTE_PREFIX.length);
1484
1527
  const preflightSegments = preflightSuffix.split('/').filter(Boolean);
1485
1528
  // The start holds the dispatch lock while its liveness probe must remain responsive.
1486
1529
  if (request.method === 'GET' &&
@@ -1546,10 +1589,17 @@ export function createThreadAgentHost(options) {
1546
1589
  preflightedTermination = true;
1547
1590
  }
1548
1591
  }
1592
+ // A queued start or resume keeps its parsed body if the sender disconnects.
1593
+ const startBody = request.method === 'POST' &&
1594
+ preflightUrl.pathname === `${AGENT_HOST_ROUTE_PREFIX}/start`
1595
+ ? await objectBody(request)
1596
+ : undefined;
1597
+ const resumeBody = request.method === 'POST' &&
1598
+ preflightUrl.pathname === `${AGENT_HOST_ROUTE_PREFIX}/resume`
1599
+ ? await objectBody(request)
1600
+ : undefined;
1549
1601
  return withDispatchLock(async () => {
1550
1602
  const url = new URL(request.url);
1551
- if (!url.pathname.startsWith(AGENT_HOST_ROUTE_PREFIX))
1552
- return null;
1553
1603
  if (request.method === 'GET' &&
1554
1604
  url.pathname === `${AGENT_HOST_ROUTE_PREFIX}/binding`) {
1555
1605
  const resourceId = url.searchParams.get('resourceId');
@@ -1563,9 +1613,8 @@ export function createThreadAgentHost(options) {
1563
1613
  }
1564
1614
  return json({ bound: true });
1565
1615
  }
1566
- if (request.method === 'POST' &&
1567
- url.pathname === `${AGENT_HOST_ROUTE_PREFIX}/start`) {
1568
- const body = await objectBody(request);
1616
+ if (startBody) {
1617
+ const body = startBody;
1569
1618
  if ('resourceOwner' in body ||
1570
1619
  'requestedBy' in body ||
1571
1620
  [
@@ -1631,9 +1680,8 @@ export function createThreadAgentHost(options) {
1631
1680
  : {}),
1632
1681
  }));
1633
1682
  }
1634
- if (request.method === 'POST' &&
1635
- url.pathname === `${AGENT_HOST_ROUTE_PREFIX}/resume`) {
1636
- const body = await objectBody(request);
1683
+ if (resumeBody) {
1684
+ const body = resumeBody;
1637
1685
  const ref = runRef(scope, body);
1638
1686
  const snapshotExecution = await snapshotExecutionFor(scope, ref);
1639
1687
  await statusFor(scope, ref, snapshotExecution.state);