@proofoftech/flowsafe 0.7.0 → 0.9.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 +42 -0
- package/README.md +14 -4
- package/dist/agent-host/approval-resumer.d.ts +18 -0
- package/dist/agent-host/approval-resumer.d.ts.map +1 -0
- package/dist/agent-host/approval-resumer.js +53 -0
- package/dist/agent-host/approval-resumer.js.map +1 -0
- package/dist/agent-host/catalog.d.ts +6 -0
- package/dist/agent-host/catalog.d.ts.map +1 -0
- package/dist/agent-host/catalog.js +194 -0
- package/dist/agent-host/catalog.js.map +1 -0
- package/dist/agent-host/index.d.ts +9 -0
- package/dist/agent-host/index.d.ts.map +1 -0
- package/dist/agent-host/index.js +11 -0
- package/dist/agent-host/index.js.map +1 -0
- package/dist/agent-host/router.d.ts +11 -0
- package/dist/agent-host/router.d.ts.map +1 -0
- package/dist/agent-host/router.js +240 -0
- package/dist/agent-host/router.js.map +1 -0
- package/dist/agent-host/thread-host.d.ts +74 -0
- package/dist/agent-host/thread-host.d.ts.map +1 -0
- package/dist/agent-host/thread-host.js +688 -0
- package/dist/agent-host/thread-host.js.map +1 -0
- package/dist/agent-host/thread-topology.d.ts +39 -0
- package/dist/agent-host/thread-topology.d.ts.map +1 -0
- package/dist/agent-host/thread-topology.js +127 -0
- package/dist/agent-host/thread-topology.js.map +1 -0
- package/dist/agent-host/trusted-context.d.ts +8 -0
- package/dist/agent-host/trusted-context.d.ts.map +1 -0
- package/dist/agent-host/trusted-context.js +38 -0
- package/dist/agent-host/trusted-context.js.map +1 -0
- package/dist/agent-host/types.d.ts +85 -0
- package/dist/agent-host/types.d.ts.map +1 -0
- package/dist/agent-host/types.js +3 -0
- package/dist/agent-host/types.js.map +1 -0
- package/dist/agent-runner/agent-run-state.d.ts +38 -0
- package/dist/agent-runner/agent-run-state.d.ts.map +1 -0
- package/dist/agent-runner/agent-run-state.js +118 -0
- package/dist/agent-runner/agent-run-state.js.map +1 -0
- package/dist/agent-runner/durable-agent-runner.d.ts +12 -0
- package/dist/agent-runner/durable-agent-runner.d.ts.map +1 -1
- package/dist/agent-runner/durable-agent-runner.js +130 -13
- package/dist/agent-runner/durable-agent-runner.js.map +1 -1
- package/dist/agent-runner/index.d.ts +2 -0
- package/dist/agent-runner/index.d.ts.map +1 -1
- package/dist/agent-runner/index.js +1 -0
- package/dist/agent-runner/index.js.map +1 -1
- package/dist/approval-api/contract.d.ts.map +1 -1
- package/dist/approval-api/contract.js.map +1 -1
- package/dist/approval-api/d1-store.d.ts.map +1 -1
- package/dist/approval-api/d1-store.js +24 -9
- package/dist/approval-api/d1-store.js.map +1 -1
- package/dist/approval-api/index.d.ts +2 -0
- package/dist/approval-api/index.d.ts.map +1 -1
- package/dist/approval-api/index.js +7 -0
- package/dist/approval-api/index.js.map +1 -1
- package/dist/approval-api/principal.d.ts +214 -0
- package/dist/approval-api/principal.d.ts.map +1 -0
- package/dist/approval-api/principal.js +391 -0
- package/dist/approval-api/principal.js.map +1 -0
- package/dist/approval-api/service.d.ts +42 -1
- package/dist/approval-api/service.d.ts.map +1 -1
- package/dist/approval-api/service.js +142 -13
- package/dist/approval-api/service.js.map +1 -1
- package/dist/approval-api/tenant-context.d.ts +7 -0
- package/dist/approval-api/tenant-context.d.ts.map +1 -1
- package/dist/approval-api/tenant-context.js +31 -3
- package/dist/approval-api/tenant-context.js.map +1 -1
- package/dist/approval-api/types.d.ts +19 -3
- package/dist/approval-api/types.d.ts.map +1 -1
- package/dist/approval-api/types.js.map +1 -1
- package/dist/do-runner/execution-context.d.ts +19 -0
- package/dist/do-runner/execution-context.d.ts.map +1 -0
- package/dist/do-runner/execution-context.js +70 -0
- package/dist/do-runner/execution-context.js.map +1 -0
- package/dist/do-runner/index.d.ts +2 -1
- package/dist/do-runner/index.d.ts.map +1 -1
- package/dist/do-runner/index.js +2 -1
- package/dist/do-runner/index.js.map +1 -1
- package/dist/do-runner/runtime.d.ts +8 -0
- package/dist/do-runner/runtime.d.ts.map +1 -1
- package/dist/do-runner/runtime.js +157 -19
- package/dist/do-runner/runtime.js.map +1 -1
- package/dist/do-runner/thread-do.d.ts +15 -1
- package/dist/do-runner/thread-do.d.ts.map +1 -1
- package/dist/do-runner/thread-do.js +31 -5
- package/dist/do-runner/thread-do.js.map +1 -1
- package/dist/do-runner/thread-header.d.ts +17 -2
- package/dist/do-runner/thread-header.d.ts.map +1 -1
- package/dist/do-runner/thread-header.js +17 -2
- package/dist/do-runner/thread-header.js.map +1 -1
- package/dist/host-kit/approval-bridge.d.ts +12 -13
- package/dist/host-kit/approval-bridge.d.ts.map +1 -1
- package/dist/host-kit/approval-bridge.js +63 -25
- package/dist/host-kit/approval-bridge.js.map +1 -1
- package/dist/host-kit/flowsafe-worker.d.ts +13 -0
- package/dist/host-kit/flowsafe-worker.d.ts.map +1 -1
- package/dist/host-kit/flowsafe-worker.js +11 -3
- package/dist/host-kit/flowsafe-worker.js.map +1 -1
- package/dist/host-kit/host-approval-service.d.ts +10 -5
- package/dist/host-kit/host-approval-service.d.ts.map +1 -1
- package/dist/host-kit/host-approval-service.js +10 -10
- package/dist/host-kit/host-approval-service.js.map +1 -1
- package/dist/host-kit/index.d.ts +2 -2
- package/dist/host-kit/index.d.ts.map +1 -1
- package/dist/host-kit/index.js +1 -1
- package/dist/host-kit/index.js.map +1 -1
- package/dist/host-kit/run-router.d.ts.map +1 -1
- package/dist/host-kit/run-router.js +1 -6
- 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 +29 -3
- package/dist/host-kit/thread-topology.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/schedules/tick.d.ts +3 -7
- package/dist/schedules/tick.d.ts.map +1 -1
- package/dist/schedules/tick.js +7 -41
- package/dist/schedules/tick.js.map +1 -1
- package/dist/signal-providers/delivery.d.ts +1 -1
- package/dist/signal-providers/delivery.d.ts.map +1 -1
- package/dist/signal-providers/delivery.js +9 -3
- package/dist/signal-providers/delivery.js.map +1 -1
- package/dist/signals/thread-do-routes.d.ts +12 -1
- package/dist/signals/thread-do-routes.d.ts.map +1 -1
- package/dist/signals/thread-do-routes.js +48 -12
- package/dist/signals/thread-do-routes.js.map +1 -1
- package/package.json +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
# @proofoftech/flowsafe
|
|
2
2
|
|
|
3
|
+
## 0.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 3a259b8: Add first-class execution principals so automated work stops impersonating people.
|
|
8
|
+
|
|
9
|
+
Every automated path previously fabricated a human to satisfy the one identity the platform had: the schedule tick, cron SLA maintenance, signal-provider delivery, and the suspension-reconcile bridge all minted `role: 'operator'`. That lost provenance and gave autonomous execution an operator's authority.
|
|
10
|
+
|
|
11
|
+
Breakwater's `Actor` gains an optional `kind` (`human` | `service` | `agent` | `system`, absent meaning human), and both `RBACMiddleware` and `createGuardedAgent` gain `allowedPrincipalKinds`, defaulting to `['human']`. The gate checks kind before role and does not consult the role allowlist for a non-human kind, because an automated principal carries a role only to satisfy the required field — consulting it would either admit whatever role the host projected, or force hosts to allow that role and thereby admit real humans holding it. Both the processor gate and the direct-call gate enforce it. **An existing agent therefore denies every automated principal without a config change.**
|
|
12
|
+
|
|
13
|
+
Flowsafe adds `ExecutionPrincipal`, with `purpose` required on every automated kind, and persists it in agent-run state and approval resume targets. `AgentMeta.allowedAutomation` declares which principal kinds may enter on which entry paths; absent or empty denies all automated entry, and an optional host authorizer can only narrow it further. `ApprovalActor` is unchanged and still means an authenticated human at the HTTP boundary or a reviewer deciding an approval — a human approval never transfers the decider's authority into the resumed run.
|
|
14
|
+
|
|
15
|
+
The `@proofoftech/flowsafe/agent-host` entry point exports its automation policy types, including `AgentAutomationRule`, `AutomationCheck`, `AutomatedEntryRequest`, and `AutomatedEntryAuthorizer`, so public catalog and host signatures never require deep imports.
|
|
16
|
+
|
|
17
|
+
`ApprovalService` gains `createAsPrincipal` and `supersedeStaleAsPrincipal` for trusted platform bridges. They replace the human role gate with a kind-and-tenant check rather than widening it. There is deliberately no principal-taking `decide`, `claim`, or `delegate`.
|
|
18
|
+
|
|
19
|
+
`trustAutomationPrincipal()` returns a branded, frozen canonical clone rather than the caller's own object. Validating a principal and handing the same reference back left the vouch time-of-check/time-of-use: the caller kept a mutable alias and could rewrite a vouched `system` principal into `{kind:'human', role:'admin'}` before the service read `kind`. The trusted entries now recheck the own brand, the automated shape, the kind, and that every field is a plain data property — an accessor survives `Object.freeze` and would reopen the same hole — instead of trusting a parameter type that does not exist at runtime. `ExecutionPrincipal` fields are `readonly`.
|
|
20
|
+
|
|
21
|
+
`AutomatedExecutionPrincipal` is added for duties that want provenance but derive no authority from the principal, so the trust brand is demanded only where it is read. `sweepSLA` and `SlaSweepMaintenanceOptions` take it, and `sweepSLA` refuses a human or malformed principal outright: it writes across every tenant, and a human there would stamp `principalKind: 'human'` onto cron escalations. `TRUSTED_AUTOMATION` is not on the package barrel — `trustAutomationPrincipal` is the sanctioned constructor.
|
|
22
|
+
|
|
23
|
+
Audit correlation now carries `principalKind`, `principalId`, `purpose`, and `delegatedBy` alongside the existing tenant, run, thread, and entry-path fields.
|
|
24
|
+
|
|
25
|
+
`x-flowsafe-actor` and `x-flowsafe-role` are retired from the wire. The principal is now the sole identity channel: a thread Durable Object projects `scope.actor` from it, so a host's separate `TenantContext.actor` can no longer disagree with what executes. Both header constants are removed from `@proofoftech/flowsafe/do-runner`; the topology strips the names on send and forward, and `createTenantResolver` still refuses them on inbound requests so a mixed-version client fails loudly.
|
|
26
|
+
|
|
27
|
+
`queueApprovalForSuspension`, `reconcileApprovalsForSummary`, and `resumeRunWithRequeue` take a `systemActorId` string instead of a principal, and mint their own bookkeeping identity against the service's tenant binding. Hosts no longer perform a trust assertion for the platform's own bookkeeping. `ApprovalService` exposes its `tenantId` for that.
|
|
28
|
+
|
|
29
|
+
The principal travels to a Durable Object in a trusted `x-flowsafe-principal` header that `createThreadTopology` stamps on every send and forward. A thread DO refuses a request that carries none rather than treating the caller as a human, and `createTenantResolver` refuses the header on inbound requests exactly as it does the tenant, actor, and role headers.
|
|
30
|
+
|
|
31
|
+
BREAKING for in-flight state, deliberately and without an upgrade path: `AgentRunRecord` is version 2 and `agent-thread` resume targets now store an `ExecutionPrincipal`. Records written by the previous release fail closed, so a suspended agent run started before this upgrade cannot resume. A version-1 record cannot be upgraded honestly — a `schedule.fire` run stored `role: 'operator'`, so reading it back as a human would launder exactly the authority this change removes. Flowsafe's breakwater peer floor moves to `>=0.7.0`. `rejectReservedAgentContext` is removed from `@proofoftech/flowsafe/agent-host`; it was exported but never called on any path, and every real caller uses `sanitizeStoredAgentContext`.
|
|
32
|
+
|
|
33
|
+
A thread Durable Object now requires the principal header on every request, so a deployment whose Worker and Durable Object resolve different `@proofoftech/flowsafe` versions returns 403 until both sides ship this release. Cloudflare's single-bundle model makes that skew unlikely, but there is no negotiation.
|
|
34
|
+
|
|
35
|
+
## 0.8.0
|
|
36
|
+
|
|
37
|
+
### Minor Changes
|
|
38
|
+
|
|
39
|
+
- 09a4406: Add guarded Breakwater agents and Flowsafe's authenticated, catalog-driven agent host. Agent starts now derive trusted identity and execution context, agent resumes require an approval-bound capability, and status and NDJSON observation remain tenant-bound.
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- 6670285: Prevent approval resume after isolate eviction from rerunning application input processors or input policy evaluation. Durable-agent recovery now reauthorizes the stored principal, restores both Mastra run registries with complete runtime processor chains, and fails before resumed tool execution when authorization is denied.
|
|
44
|
+
|
|
3
45
|
## 0.7.0
|
|
4
46
|
|
|
5
47
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -27,13 +27,14 @@ Compatibility:
|
|
|
27
27
|
- TypeScript `moduleResolution: "NodeNext"`, `"Node16"`, or `"Bundler"`
|
|
28
28
|
- `@mastra/core` in the declared `^1.50.0` peer range
|
|
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.7.0 <1.0.0` when used
|
|
31
31
|
|
|
32
32
|
## Choose an export
|
|
33
33
|
|
|
34
34
|
| Import | Purpose |
|
|
35
35
|
| --- | --- |
|
|
36
36
|
| `@proofoftech/flowsafe` | Compatibility barrel for approval API, runner, artifacts, and audit export |
|
|
37
|
+
| `@proofoftech/flowsafe/agent-host` | Server-only guarded-agent catalogs, authenticated run routes, thread hosting, NDJSON observation, and approval-only resume |
|
|
37
38
|
| `@proofoftech/flowsafe/approval-api` | Approval records, service, tenant-bound stores, REST router, grants, SLA, retention, notifications, and stream events |
|
|
38
39
|
| `@proofoftech/flowsafe/do-runner` | Durable Object runner, D1 storage, run summaries, identities, pub/sub, resume ledger, retention, and offboarding |
|
|
39
40
|
| `@proofoftech/flowsafe/approval-ui` | Styling-library-agnostic React dashboard, DOM-free API client, headless hook, and live transport |
|
|
@@ -49,7 +50,7 @@ Compatibility:
|
|
|
49
50
|
| `@proofoftech/flowsafe/background-tasks` | Tenant task host, D1 task domains, routes, and cleanup |
|
|
50
51
|
| `@proofoftech/flowsafe/signal-providers` | Alarm-driven provider host, topology, subscriptions, verified webhooks, and GitHub reference provider |
|
|
51
52
|
|
|
52
|
-
New host-side and React features are subpath-only. This keeps the root import free of durable-agent and UI dependency graphs.
|
|
53
|
+
New host-side and React features are subpath-only. This keeps the root import free of Breakwater, durable-agent-host, and UI dependency graphs.
|
|
53
54
|
|
|
54
55
|
## Start with the baseline Worker
|
|
55
56
|
|
|
@@ -255,7 +256,15 @@ The following surfaces are supported and opt-in: they are tested and covered by
|
|
|
255
256
|
|
|
256
257
|
### Durable agents
|
|
257
258
|
|
|
258
|
-
`
|
|
259
|
+
Use `@proofoftech/flowsafe/agent-host` for a public protected surface. `createAgentRouter()` lists server-owned metadata and exposes authenticated start, status, and newline-delimited JSON observation routes. The router mints every ID and rejects trusted context and execution overrides. Authenticated human starts must satisfy both the global start roles and the selected agent's `allowedRoles`. Automated entry uses trusted host paths instead: it never consults human roles and requires a matching principal kind and entry path in the selected agent's `allowedAutomation`.
|
|
260
|
+
|
|
261
|
+
`createThreadAgentHost()` validates Breakwater's guarded-handle brand before it registers the agent with Mastra. It persists the thread/agent binding and original run principal, so eviction recovery and approval resume cannot switch agents or actors.
|
|
262
|
+
|
|
263
|
+
Agent resume is approval-only. `createAgentApprovalResumer()` rejects legacy agent targets without the original principal, then rechecks that principal against the current catalog. A human must still satisfy the selected agent's `allowedRoles`. An automated principal's kind must still appear in `allowedAutomation`; `approval.resume` is implied for a declared kind. The resumer delegates non-agent workflow records to the existing resume function.
|
|
264
|
+
|
|
265
|
+
`createFlowsafeDurableAgent()` remains the lower-level compatibility API. It routes Mastra's durable-agent workflow through `RunnerRuntime`, but it does not guard an arbitrary raw agent. Use `agent-host` when an HTTP surface must enforce catalog and Breakwater invariants.
|
|
266
|
+
|
|
267
|
+
Agent event replay lasts only as long as the configured Mastra cache. The default in-memory cache does not survive process restart. A 409 stream response means the client must read the authoritative status route.
|
|
259
268
|
|
|
260
269
|
### Signals and notifications
|
|
261
270
|
|
|
@@ -305,7 +314,8 @@ Critical host obligations:
|
|
|
305
314
|
|
|
306
315
|
- derive tenants and actors from verified credentials;
|
|
307
316
|
- mint run, thread, resource, schedule, and subscription identities server-side;
|
|
308
|
-
- keep connector lists and resume targets server-authored;
|
|
317
|
+
- keep connector lists and agent resume targets server-authored;
|
|
318
|
+
- persist the original authorized agent requester and resume execution as that principal;
|
|
309
319
|
- expose decisions only through the approval path;
|
|
310
320
|
- configure shared stores for cross-isolate connector budgets;
|
|
311
321
|
- keep raw Durable Object namespaces behind the exported topologies;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ApprovalRecord, type ExecutionPrincipal, type TenantContext } from '../approval-api/index.js';
|
|
2
|
+
import type { ResumeRunFn } from '../host-kit/index.js';
|
|
3
|
+
import type { AgentThreadTopology } from './thread-topology.js';
|
|
4
|
+
import type { AgentMeta } from './types.js';
|
|
5
|
+
export interface AgentApprovalResumerOptions {
|
|
6
|
+
fallback: ResumeRunFn;
|
|
7
|
+
agents: readonly AgentMeta[];
|
|
8
|
+
topology: AgentThreadTopology;
|
|
9
|
+
/**
|
|
10
|
+
* Builds the tenant context the resume runs under, from the STORED principal.
|
|
11
|
+
* It must return that principal unchanged; createAgentApprovalResumer
|
|
12
|
+
* enforces that with an exact comparison after calling this.
|
|
13
|
+
*/
|
|
14
|
+
tenantForPrincipal: (principal: ExecutionPrincipal, record: ApprovalRecord) => TenantContext | Promise<TenantContext>;
|
|
15
|
+
}
|
|
16
|
+
export type AgentApprovalResumer = ResumeRunFn;
|
|
17
|
+
export declare function createAgentApprovalResumer(options: AgentApprovalResumerOptions): AgentApprovalResumer;
|
|
18
|
+
//# sourceMappingURL=approval-resumer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"approval-resumer.d.ts","sourceRoot":"","sources":["../../src/agent-host/approval-resumer.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,kBAAkB,EAEvB,KAAK,aAAa,EACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,EAAE,WAAW,CAAC;IACtB,MAAM,EAAE,SAAS,SAAS,EAAE,CAAC;IAC7B,QAAQ,EAAE,mBAAmB,CAAC;IAC9B;;;;OAIG;IACH,kBAAkB,EAAE,CAClB,SAAS,EAAE,kBAAkB,EAC7B,MAAM,EAAE,cAAc,KACnB,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CAC7C;AAED,MAAM,MAAM,oBAAoB,GAAG,WAAW,CAAC;AAE/C,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,2BAA2B,GACnC,oBAAoB,CAsEtB"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import { DURABLE_AGENTIC_LOOP_WORKFLOW_ID } from '../agent-runner/index.js';
|
|
3
|
+
import { samePrincipal, } from '../approval-api/index.js';
|
|
4
|
+
import { createAgentCatalog } from './catalog.js';
|
|
5
|
+
export function createAgentApprovalResumer(options) {
|
|
6
|
+
const catalog = createAgentCatalog(options.agents);
|
|
7
|
+
return async (record, decision) => {
|
|
8
|
+
if (record.workflowId !== DURABLE_AGENTIC_LOOP_WORKFLOW_ID) {
|
|
9
|
+
if (record.resumeTarget?.kind === 'agent-thread') {
|
|
10
|
+
throw new Error('agent-thread resume targets are valid only for durable agent runs');
|
|
11
|
+
}
|
|
12
|
+
return options.fallback(record, decision);
|
|
13
|
+
}
|
|
14
|
+
const target = record.resumeTarget;
|
|
15
|
+
if (target?.kind !== 'agent-thread') {
|
|
16
|
+
throw new Error('legacy durable-agent approvals cannot be resumed without an agent-thread target');
|
|
17
|
+
}
|
|
18
|
+
const meta = catalog.get(target.agentId);
|
|
19
|
+
const principal = target.principal;
|
|
20
|
+
// Re-authorize the STORED principal against the CURRENT catalog: a decision
|
|
21
|
+
// taken yesterday must not resume an agent whose policy has since narrowed.
|
|
22
|
+
// Split by kind for the same reason the entry gate is: a human resumes
|
|
23
|
+
// under the role rules, automation under its declared entry paths, and
|
|
24
|
+
// neither may answer for the other. Note this authorizes the principal that
|
|
25
|
+
// STARTED the run, never the reviewer who approved it — a human decision
|
|
26
|
+
// does not transfer that human's authority into the resumed leg.
|
|
27
|
+
const authorized = meta !== undefined &&
|
|
28
|
+
(principal.kind === 'human'
|
|
29
|
+
? catalog.allowedRoles(target.agentId)?.includes(principal.role) ===
|
|
30
|
+
true
|
|
31
|
+
: catalog.automationAllowed(target.agentId, principal, 'approval.resume'));
|
|
32
|
+
if (!authorized) {
|
|
33
|
+
throw new Error(`principal kind '${principal.kind}' may no longer resume agent '${target.agentId}'`);
|
|
34
|
+
}
|
|
35
|
+
if (principal.tenantId !== record.tenantId || principal.id.trim() === '') {
|
|
36
|
+
throw new Error('agent approval principal does not match the record tenant');
|
|
37
|
+
}
|
|
38
|
+
const tenant = await options.tenantForPrincipal(principal, record);
|
|
39
|
+
if (tenant.tenantId !== record.tenantId ||
|
|
40
|
+
!samePrincipal(tenant.principal, principal)) {
|
|
41
|
+
throw new Error('tenantForPrincipal must preserve the stored agent execution principal exactly');
|
|
42
|
+
}
|
|
43
|
+
const envelope = await options.topology.resume(tenant, record, decision);
|
|
44
|
+
if (envelope.agentId !== target.agentId ||
|
|
45
|
+
envelope.threadId !== target.threadId ||
|
|
46
|
+
envelope.resourceId !== target.resourceId ||
|
|
47
|
+
envelope.runId !== record.runId) {
|
|
48
|
+
throw new Error('agent resume topology returned a mismatched run envelope');
|
|
49
|
+
}
|
|
50
|
+
return envelope.summary;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=approval-resumer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"approval-resumer.js","sourceRoot":"","sources":["../../src/agent-host/approval-resumer.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC,OAAO,EAAE,gCAAgC,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAGL,aAAa,GAEd,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAqBlD,MAAM,UAAU,0BAA0B,CACxC,OAAoC;IAEpC,MAAM,OAAO,GAAG,kBAAkB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACnD,OAAO,KAAK,EA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,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACzE,MAAM,IAAI,KAAK,CACb,2DAA2D,CAC5D,CAAC;QACJ,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,kBAAkB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QACnE,IACE,MAAM,CAAC,QAAQ,KAAK,MAAM,CAAC,QAAQ;YACnC,CAAC,aAAa,CAAC,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC,EAC3C,CAAC;YACD,MAAM,IAAI,KAAK,CACb,+EAA+E,CAChF,CAAC;QACJ,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;QACzE,IACE,QAAQ,CAAC,OAAO,KAAK,MAAM,CAAC,OAAO;YACnC,QAAQ,CAAC,QAAQ,KAAK,MAAM,CAAC,QAAQ;YACrC,QAAQ,CAAC,UAAU,KAAK,MAAM,CAAC,UAAU;YACzC,QAAQ,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,EAC/B,CAAC;YACD,MAAM,IAAI,KAAK,CACb,0DAA0D,CAC3D,CAAC;QACJ,CAAC;QACD,OAAO,QAAQ,CAAC,OAAO,CAAC;IAC1B,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AgentCatalog, AgentMeta, AgentModule, AgentModuleCatalog } from './types.js';
|
|
2
|
+
export declare function validateAgentMeta(meta: AgentMeta): AgentMeta;
|
|
3
|
+
export declare function createAgentCatalog(metadata: readonly AgentMeta[]): AgentCatalog;
|
|
4
|
+
export declare function validateAgentModule(module: AgentModule): AgentModule;
|
|
5
|
+
export declare function createAgentModuleCatalog(modules: readonly AgentModule[]): AgentModuleCatalog;
|
|
6
|
+
//# sourceMappingURL=catalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/agent-host/catalog.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAEV,YAAY,EAEZ,SAAS,EACT,WAAW,EACX,kBAAkB,EAEnB,MAAM,YAAY,CAAC;AAqHpB,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,SAAS,GAAG,SAAS,CAmB5D;AAED,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,SAAS,SAAS,EAAE,GAC7B,YAAY,CAwBd;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CAkDpE;AAED,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,SAAS,WAAW,EAAE,GAC9B,kBAAkB,CAoBpB"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import { isGuardedAgentHandle } from '@proofoftech/breakwater/agent';
|
|
3
|
+
import { AGENT_ENTRY_PATHS } from '../agent-runner/index.js';
|
|
4
|
+
import { AUTOMATED_PRINCIPAL_KINDS, RUN_START_ROLES, } from '../approval-api/index.js';
|
|
5
|
+
import { PATH_SAFE_ID_PATTERN } from '../do-runner/index.js';
|
|
6
|
+
function fail(message) {
|
|
7
|
+
throw new Error(`agent catalog: ${message}`);
|
|
8
|
+
}
|
|
9
|
+
function normalizedRoles(roles, agentId) {
|
|
10
|
+
const effective = roles ?? RUN_START_ROLES;
|
|
11
|
+
if (effective.length === 0) {
|
|
12
|
+
fail(`agent '${agentId}' allowedRoles must not be empty`);
|
|
13
|
+
}
|
|
14
|
+
const unique = new Set();
|
|
15
|
+
for (const role of effective) {
|
|
16
|
+
if (!RUN_START_ROLES.includes(role)) {
|
|
17
|
+
fail(`agent '${agentId}' role '${String(role)}' is not a run-start role`);
|
|
18
|
+
}
|
|
19
|
+
if (unique.has(role)) {
|
|
20
|
+
fail(`agent '${agentId}' allowedRoles contains duplicate '${role}'`);
|
|
21
|
+
}
|
|
22
|
+
unique.add(role);
|
|
23
|
+
}
|
|
24
|
+
return Object.freeze([...effective]);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Normalize the automation declaration. An absent field stays absent rather
|
|
28
|
+
* than becoming a default set: there is no safe default for "which robots may
|
|
29
|
+
* drive this agent", and materializing one would make the deny-by-default read
|
|
30
|
+
* as an oversight instead of the contract.
|
|
31
|
+
*/
|
|
32
|
+
function normalizedAutomation(rules, agentId) {
|
|
33
|
+
if (rules === undefined)
|
|
34
|
+
return undefined;
|
|
35
|
+
if (!Array.isArray(rules)) {
|
|
36
|
+
fail(`agent '${agentId}' allowedAutomation must be an array`);
|
|
37
|
+
}
|
|
38
|
+
const seenKinds = new Set();
|
|
39
|
+
const normalized = rules.map((rule) => {
|
|
40
|
+
if (rule === null || typeof rule !== 'object') {
|
|
41
|
+
fail(`agent '${agentId}' allowedAutomation entries must be objects`);
|
|
42
|
+
}
|
|
43
|
+
if (!AUTOMATED_PRINCIPAL_KINDS.includes(rule.kind)) {
|
|
44
|
+
fail(`agent '${agentId}' allowedAutomation kind '${String(rule.kind)}' is not an automated principal kind`);
|
|
45
|
+
}
|
|
46
|
+
if (seenKinds.has(rule.kind)) {
|
|
47
|
+
fail(`agent '${agentId}' allowedAutomation repeats kind '${rule.kind}'; list its entry paths once`);
|
|
48
|
+
}
|
|
49
|
+
seenKinds.add(rule.kind);
|
|
50
|
+
if (!Array.isArray(rule.entryPaths) || rule.entryPaths.length === 0) {
|
|
51
|
+
fail(`agent '${agentId}' allowedAutomation kind '${rule.kind}' must name at least one entry path`);
|
|
52
|
+
}
|
|
53
|
+
const seenPaths = new Set();
|
|
54
|
+
for (const entryPath of rule.entryPaths) {
|
|
55
|
+
if (entryPath === 'approval.resume') {
|
|
56
|
+
fail(`agent '${agentId}' must not declare 'approval.resume'; resuming is implied by the kind that started the run`);
|
|
57
|
+
}
|
|
58
|
+
if (!AGENT_ENTRY_PATHS.includes(entryPath)) {
|
|
59
|
+
fail(`agent '${agentId}' allowedAutomation names unknown entry path '${String(entryPath)}'`);
|
|
60
|
+
}
|
|
61
|
+
if (seenPaths.has(entryPath)) {
|
|
62
|
+
fail(`agent '${agentId}' allowedAutomation repeats entry path '${entryPath}'`);
|
|
63
|
+
}
|
|
64
|
+
seenPaths.add(entryPath);
|
|
65
|
+
}
|
|
66
|
+
return Object.freeze({
|
|
67
|
+
kind: rule.kind,
|
|
68
|
+
entryPaths: Object.freeze([...rule.entryPaths]),
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
return Object.freeze(normalized);
|
|
72
|
+
}
|
|
73
|
+
function automationCheckFor(automationById, known) {
|
|
74
|
+
return (agentId, principal, entryPath) => {
|
|
75
|
+
if (!known(agentId))
|
|
76
|
+
return false;
|
|
77
|
+
// Humans are authorized by role, elsewhere. Saying "not allowed" here is
|
|
78
|
+
// the honest answer for a gate that only speaks about automation.
|
|
79
|
+
if (principal.kind === 'human')
|
|
80
|
+
return false;
|
|
81
|
+
const rules = automationById.get(agentId);
|
|
82
|
+
if (!rules)
|
|
83
|
+
return false;
|
|
84
|
+
// Resuming is CONTINUING a run this kind was already admitted to start, so
|
|
85
|
+
// it asks a different question: may this kind still drive this agent at
|
|
86
|
+
// all? Demanding that hosts also list 'approval.resume' would mean any
|
|
87
|
+
// automated agent that suspends for approval loses the run the moment a
|
|
88
|
+
// human approves it — a decided approval and a stranded run. The narrowing
|
|
89
|
+
// that matters is still enforced: a kind removed from the declaration
|
|
90
|
+
// entirely can no longer resume.
|
|
91
|
+
if (entryPath === 'approval.resume') {
|
|
92
|
+
return rules.some((rule) => rule.kind === principal.kind);
|
|
93
|
+
}
|
|
94
|
+
return rules.some((rule) => rule.kind === principal.kind && rule.entryPaths.includes(entryPath));
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
export function validateAgentMeta(meta) {
|
|
98
|
+
if (typeof meta.id !== 'string' || !PATH_SAFE_ID_PATTERN.test(meta.id)) {
|
|
99
|
+
fail('id must be URL-path-safe');
|
|
100
|
+
}
|
|
101
|
+
if (typeof meta.title !== 'string' || meta.title.trim() === '') {
|
|
102
|
+
fail(`agent '${meta.id}' title must not be empty`);
|
|
103
|
+
}
|
|
104
|
+
if (typeof meta.description !== 'string' || meta.description.trim() === '') {
|
|
105
|
+
fail(`agent '${meta.id}' description must not be empty`);
|
|
106
|
+
}
|
|
107
|
+
const roles = normalizedRoles(meta.allowedRoles, meta.id);
|
|
108
|
+
const automation = normalizedAutomation(meta.allowedAutomation, meta.id);
|
|
109
|
+
return Object.freeze({
|
|
110
|
+
id: meta.id,
|
|
111
|
+
title: meta.title,
|
|
112
|
+
description: meta.description,
|
|
113
|
+
...(meta.allowedRoles !== undefined ? { allowedRoles: roles } : {}),
|
|
114
|
+
...(automation !== undefined ? { allowedAutomation: automation } : {}),
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
export function createAgentCatalog(metadata) {
|
|
118
|
+
const agents = [];
|
|
119
|
+
const byId = new Map();
|
|
120
|
+
const rolesById = new Map();
|
|
121
|
+
const automationById = new Map();
|
|
122
|
+
for (const candidate of metadata) {
|
|
123
|
+
const meta = validateAgentMeta(candidate);
|
|
124
|
+
if (byId.has(meta.id))
|
|
125
|
+
fail(`duplicate agent id '${meta.id}'`);
|
|
126
|
+
agents.push(meta);
|
|
127
|
+
byId.set(meta.id, meta);
|
|
128
|
+
rolesById.set(meta.id, normalizedRoles(meta.allowedRoles, meta.id));
|
|
129
|
+
if (meta.allowedAutomation !== undefined) {
|
|
130
|
+
automationById.set(meta.id, meta.allowedAutomation);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const frozen = Object.freeze(agents);
|
|
134
|
+
return Object.freeze({
|
|
135
|
+
agents: frozen,
|
|
136
|
+
get: (agentId) => byId.get(agentId),
|
|
137
|
+
allowedRoles: (agentId) => rolesById.get(agentId),
|
|
138
|
+
automationAllowed: automationCheckFor(automationById, (agentId) => byId.has(agentId)),
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
export function validateAgentModule(module) {
|
|
142
|
+
const meta = validateAgentMeta(module.meta);
|
|
143
|
+
if (!isGuardedAgentHandle(module.agent)) {
|
|
144
|
+
fail(`agent '${meta.id}' must be created by createGuardedAgent`);
|
|
145
|
+
}
|
|
146
|
+
if (module.agent.id !== meta.id) {
|
|
147
|
+
fail(`metadata id '${meta.id}' does not match guarded agent id '${module.agent.id}'`);
|
|
148
|
+
}
|
|
149
|
+
const metaRoles = normalizedRoles(meta.allowedRoles, meta.id);
|
|
150
|
+
const handleRoles = normalizedRoles(module.agent.allowedRoles, meta.id);
|
|
151
|
+
if (metaRoles.length !== handleRoles.length ||
|
|
152
|
+
metaRoles.some((role) => !handleRoles.includes(role))) {
|
|
153
|
+
fail(`agent '${meta.id}' metadata roles must exactly match guarded agent roles`);
|
|
154
|
+
}
|
|
155
|
+
// Two halves of one decision: flowsafe's catalog decides WHICH automated
|
|
156
|
+
// entry paths reach the agent, breakwater's handle decides WHICH kinds may
|
|
157
|
+
// execute at all. If they disagree, the host either advertises automation
|
|
158
|
+
// breakwater will refuse, or declares an agent automation-capable that its
|
|
159
|
+
// catalog will never route to. Both are wiring bugs, so fail at construction.
|
|
160
|
+
// A handle from a breakwater older than the principal-kinds release has no
|
|
161
|
+
// such field. Say so, rather than throwing on `.filter` of undefined.
|
|
162
|
+
if (!Array.isArray(module.agent.allowedPrincipalKinds)) {
|
|
163
|
+
fail(`agent '${meta.id}' was built by a @proofoftech/breakwater without principal kinds; >=0.7.0 is required`);
|
|
164
|
+
}
|
|
165
|
+
const metaKinds = new Set((meta.allowedAutomation ?? []).map((rule) => rule.kind));
|
|
166
|
+
const handleKinds = new Set(module.agent.allowedPrincipalKinds.filter((kind) => kind !== 'human'));
|
|
167
|
+
if (metaKinds.size !== handleKinds.size ||
|
|
168
|
+
[...metaKinds].some((kind) => !handleKinds.has(kind))) {
|
|
169
|
+
fail(`agent '${meta.id}' allowedAutomation kinds [${[...metaKinds].sort().join(', ')}] must exactly match guarded agent allowedPrincipalKinds [${[...handleKinds].sort().join(', ')}]`);
|
|
170
|
+
}
|
|
171
|
+
return Object.freeze({ meta, agent: module.agent });
|
|
172
|
+
}
|
|
173
|
+
export function createAgentModuleCatalog(modules) {
|
|
174
|
+
const validated = [];
|
|
175
|
+
const byId = new Map();
|
|
176
|
+
for (const candidate of modules) {
|
|
177
|
+
const module = validateAgentModule(candidate);
|
|
178
|
+
if (byId.has(module.meta.id)) {
|
|
179
|
+
fail(`duplicate agent id '${module.meta.id}'`);
|
|
180
|
+
}
|
|
181
|
+
validated.push(module);
|
|
182
|
+
byId.set(module.meta.id, module);
|
|
183
|
+
}
|
|
184
|
+
const frozen = Object.freeze(validated);
|
|
185
|
+
const catalog = createAgentCatalog(frozen.map((module) => module.meta));
|
|
186
|
+
return Object.freeze({
|
|
187
|
+
agents: catalog.agents,
|
|
188
|
+
modules: frozen,
|
|
189
|
+
get: (agentId) => byId.get(agentId),
|
|
190
|
+
allowedRoles: catalog.allowedRoles,
|
|
191
|
+
automationAllowed: catalog.automationAllowed,
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=catalog.js.map
|
|
@@ -0,0 +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;AAErE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAEL,yBAAyB,EAEzB,eAAe,GAChB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAW7D,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,eA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AC;IACxC,MAAM,OAAO,GAAG,kBAAkB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,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"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { assertNoReservedExecutionContext, findReservedExecutionContextKey, isReservedExecutionContextKey, RESERVED_EXECUTION_CONTEXT_KEYS, ReservedExecutionContextError, stripReservedExecutionContext, } from '../do-runner/index.js';
|
|
2
|
+
export { type AgentApprovalResumer, type AgentApprovalResumerOptions, createAgentApprovalResumer, } from './approval-resumer.js';
|
|
3
|
+
export { createAgentCatalog, createAgentModuleCatalog, validateAgentMeta, validateAgentModule, } from './catalog.js';
|
|
4
|
+
export { type AgentRouter, type AgentRouterOptions, createAgentRouter, } from './router.js';
|
|
5
|
+
export { type AgentThreadInstanceScope, type AgentThreadStateStorage, type AutomatedEntryAuthorizer, type AutomatedEntryRequest, type BoundThreadAgent, createThreadAgentHost, type ThreadAgentHost, type ThreadAgentHostOptions, type ThreadAgentStartInput, } from './thread-host.js';
|
|
6
|
+
export { AGENT_HOST_ROUTE_PREFIX, type AgentThreadObserveInput, type AgentThreadRunRef, type AgentThreadStartInput, type AgentThreadTopology, createAgentThreadTopology, } from './thread-topology.js';
|
|
7
|
+
export { AGENT_AUDIT_CONTEXT_KEY, createTrustedAgentRequestContext, deriveTrustedAgentContext, sanitizeStoredAgentContext, } from './trusted-context.js';
|
|
8
|
+
export type { AgentAutomationRule, AgentCatalog, AgentEntryPath, AgentMeta, AgentModule, AgentModuleCatalog, AgentRunEnvelope, AutomationCheck, TrustedAgentExecution, } from './types.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agent-host/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,gCAAgC,EAChC,+BAA+B,EAC/B,6BAA6B,EAC7B,+BAA+B,EAC/B,6BAA6B,EAC7B,6BAA6B,GAC9B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,2BAA2B,EAChC,0BAA0B,GAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EACrB,qBAAqB,EACrB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,GAC3B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,uBAAuB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,yBAAyB,GAC1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,uBAAuB,EACvB,gCAAgC,EAChC,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,mBAAmB,EACnB,YAAY,EACZ,cAAc,EACd,SAAS,EACT,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,qBAAqB,GACtB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Server-only guarded-agent catalog and Durable Object host. This subpath
|
|
3
|
+
// intentionally stays out of the Flowsafe root and host-kit barrels.
|
|
4
|
+
export { assertNoReservedExecutionContext, findReservedExecutionContextKey, isReservedExecutionContextKey, RESERVED_EXECUTION_CONTEXT_KEYS, ReservedExecutionContextError, stripReservedExecutionContext, } from '../do-runner/index.js';
|
|
5
|
+
export { createAgentApprovalResumer, } from './approval-resumer.js';
|
|
6
|
+
export { createAgentCatalog, createAgentModuleCatalog, validateAgentMeta, validateAgentModule, } from './catalog.js';
|
|
7
|
+
export { createAgentRouter, } from './router.js';
|
|
8
|
+
export { createThreadAgentHost, } from './thread-host.js';
|
|
9
|
+
export { AGENT_HOST_ROUTE_PREFIX, createAgentThreadTopology, } from './thread-topology.js';
|
|
10
|
+
export { AGENT_AUDIT_CONTEXT_KEY, createTrustedAgentRequestContext, deriveTrustedAgentContext, sanitizeStoredAgentContext, } from './trusted-context.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/agent-host/index.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,0EAA0E;AAC1E,qEAAqE;AAErE,OAAO,EACL,gCAAgC,EAChC,+BAA+B,EAC/B,6BAA6B,EAC7B,+BAA+B,EAC/B,6BAA6B,EAC7B,6BAA6B,GAC9B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAGL,0BAA0B,GAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAGL,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAML,qBAAqB,GAItB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,uBAAuB,EAKvB,yBAAyB,GAC1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,uBAAuB,EACvB,gCAAgC,EAChC,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type TenantResolver } from '../approval-api/index.js';
|
|
2
|
+
import type { AgentThreadTopology } from './thread-topology.js';
|
|
3
|
+
import type { AgentMeta } from './types.js';
|
|
4
|
+
export interface AgentRouterOptions {
|
|
5
|
+
agents: readonly AgentMeta[];
|
|
6
|
+
resolve: TenantResolver;
|
|
7
|
+
topology: AgentThreadTopology;
|
|
8
|
+
}
|
|
9
|
+
export type AgentRouter = (request: Request) => Promise<Response | null>;
|
|
10
|
+
export declare function createAgentRouter(options: AgentRouterOptions): AgentRouter;
|
|
11
|
+
//# sourceMappingURL=router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/agent-host/router.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,0BAA0B,CAAC;AAIlC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAK5C,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,SAAS,SAAS,EAAE,CAAC;IAC7B,OAAO,EAAE,cAAc,CAAC;IACxB,QAAQ,EAAE,mBAAmB,CAAC;CAC/B;AAED,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;AA0LzE,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,WAAW,CAiF1E"}
|