@proofoftech/flowsafe 0.4.0 → 0.7.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 +327 -0
- package/README.md +295 -251
- package/dist/agent-runner/approval-shapes.d.ts +36 -0
- package/dist/agent-runner/approval-shapes.d.ts.map +1 -0
- package/dist/agent-runner/approval-shapes.js +101 -0
- package/dist/agent-runner/approval-shapes.js.map +1 -0
- package/dist/agent-runner/durable-agent-runner.d.ts +158 -0
- package/dist/agent-runner/durable-agent-runner.d.ts.map +1 -0
- package/dist/agent-runner/durable-agent-runner.js +295 -0
- package/dist/agent-runner/durable-agent-runner.js.map +1 -0
- package/dist/agent-runner/index.d.ts +3 -0
- package/dist/agent-runner/index.d.ts.map +1 -0
- package/dist/agent-runner/index.js +10 -0
- package/dist/agent-runner/index.js.map +1 -0
- package/dist/approval-api/contract.d.ts +2 -2
- package/dist/approval-api/d1-store.d.ts.map +1 -1
- package/dist/approval-api/d1-store.js +87 -19
- package/dist/approval-api/d1-store.js.map +1 -1
- package/dist/approval-api/grants.d.ts +1 -1
- package/dist/approval-api/grants.js +1 -1
- package/dist/approval-api/index.d.ts +1 -1
- package/dist/approval-api/index.d.ts.map +1 -1
- package/dist/approval-api/index.js.map +1 -1
- package/dist/approval-api/router.d.ts +2 -2
- package/dist/approval-api/router.d.ts.map +1 -1
- package/dist/approval-api/router.js +1 -0
- package/dist/approval-api/router.js.map +1 -1
- package/dist/approval-api/service.d.ts +10 -11
- package/dist/approval-api/service.d.ts.map +1 -1
- package/dist/approval-api/service.js +22 -9
- package/dist/approval-api/service.js.map +1 -1
- package/dist/approval-api/store.d.ts +27 -22
- package/dist/approval-api/store.d.ts.map +1 -1
- package/dist/approval-api/store.js +25 -9
- package/dist/approval-api/store.js.map +1 -1
- package/dist/approval-api/tenant-context.d.ts +6 -6
- package/dist/approval-api/tenant-context.d.ts.map +1 -1
- package/dist/approval-api/tenant-context.js +15 -0
- package/dist/approval-api/tenant-context.js.map +1 -1
- package/dist/approval-api/tenant-store.d.ts +1 -1
- package/dist/approval-api/tenant-store.d.ts.map +1 -1
- package/dist/approval-api/types.d.ts +13 -4
- package/dist/approval-api/types.d.ts.map +1 -1
- package/dist/approval-api/types.js +2 -1
- package/dist/approval-api/types.js.map +1 -1
- package/dist/approval-ui/App.d.ts +2 -2
- package/dist/approval-ui/FilterBar.d.ts +3 -3
- package/dist/approval-ui/FilterBar.js +3 -3
- package/dist/approval-ui/client.d.ts +1 -1
- package/dist/approval-ui/components.d.ts +1 -1
- package/dist/approval-ui/stream.d.ts +3 -3
- package/dist/approval-ui/stream.js +2 -2
- package/dist/approval-ui/use-approval-dashboard.d.ts +9 -12
- package/dist/approval-ui/use-approval-dashboard.d.ts.map +1 -1
- package/dist/approval-ui/use-approval-dashboard.js +6 -9
- package/dist/approval-ui/use-approval-dashboard.js.map +1 -1
- package/dist/approval-ui/use-web-socket-transport.d.ts +1 -1
- package/dist/approval-ui/use-web-socket-transport.js +1 -1
- package/dist/background-tasks/d1-storage.d.ts +66 -0
- package/dist/background-tasks/d1-storage.d.ts.map +1 -0
- package/dist/background-tasks/d1-storage.js +196 -0
- package/dist/background-tasks/d1-storage.js.map +1 -0
- package/dist/background-tasks/host.d.ts +82 -0
- package/dist/background-tasks/host.d.ts.map +1 -0
- package/dist/background-tasks/host.js +275 -0
- package/dist/background-tasks/host.js.map +1 -0
- package/dist/background-tasks/index.d.ts +7 -0
- package/dist/background-tasks/index.d.ts.map +1 -0
- package/dist/background-tasks/index.js +10 -0
- package/dist/background-tasks/index.js.map +1 -0
- package/dist/background-tasks/routes.d.ts +15 -0
- package/dist/background-tasks/routes.d.ts.map +1 -0
- package/dist/background-tasks/routes.js +144 -0
- package/dist/background-tasks/routes.js.map +1 -0
- package/dist/do-runner/breakwater-keys.d.ts +1 -1
- package/dist/do-runner/breakwater-keys.js +1 -1
- package/dist/do-runner/cf-types.d.ts +1 -1
- package/dist/do-runner/d1-storage.d.ts +347 -5
- package/dist/do-runner/d1-storage.d.ts.map +1 -1
- package/dist/do-runner/d1-storage.js +571 -17
- package/dist/do-runner/d1-storage.js.map +1 -1
- package/dist/do-runner/do-error-response.d.ts +29 -0
- package/dist/do-runner/do-error-response.d.ts.map +1 -0
- package/dist/do-runner/do-error-response.js +73 -0
- package/dist/do-runner/do-error-response.js.map +1 -0
- package/dist/do-runner/durable-object.d.ts +3 -3
- package/dist/do-runner/durable-object.d.ts.map +1 -1
- package/dist/do-runner/durable-object.js +7 -21
- package/dist/do-runner/durable-object.js.map +1 -1
- package/dist/do-runner/hub-do.d.ts +2 -2
- package/dist/do-runner/index.d.ts +9 -3
- package/dist/do-runner/index.d.ts.map +1 -1
- package/dist/do-runner/index.js +8 -2
- package/dist/do-runner/index.js.map +1 -1
- package/dist/do-runner/init.d.ts +20 -0
- package/dist/do-runner/init.d.ts.map +1 -1
- package/dist/do-runner/init.js +12 -1
- package/dist/do-runner/init.js.map +1 -1
- package/dist/do-runner/memory-id.d.ts +3 -3
- package/dist/do-runner/memory-id.js +3 -3
- package/dist/do-runner/path-safe-id.d.ts +6 -6
- package/dist/do-runner/path-safe-id.js +6 -6
- package/dist/do-runner/pubsub.d.ts +18 -0
- package/dist/do-runner/pubsub.d.ts.map +1 -0
- package/dist/do-runner/pubsub.js +42 -0
- package/dist/do-runner/pubsub.js.map +1 -0
- package/dist/do-runner/runtime.d.ts +24 -1
- package/dist/do-runner/runtime.d.ts.map +1 -1
- package/dist/do-runner/runtime.js +28 -2
- package/dist/do-runner/runtime.js.map +1 -1
- package/dist/do-runner/thread-do.d.ts +74 -0
- package/dist/do-runner/thread-do.d.ts.map +1 -0
- package/dist/do-runner/thread-do.js +156 -0
- package/dist/do-runner/thread-do.js.map +1 -0
- package/dist/do-runner/thread-header.d.ts +16 -0
- package/dist/do-runner/thread-header.d.ts.map +1 -0
- package/dist/do-runner/thread-header.js +24 -0
- package/dist/do-runner/thread-header.js.map +1 -0
- package/dist/goals/index.d.ts +2 -0
- package/dist/goals/index.d.ts.map +1 -0
- package/dist/goals/index.js +7 -0
- package/dist/goals/index.js.map +1 -0
- package/dist/goals/objective-routes.d.ts +87 -0
- package/dist/goals/objective-routes.d.ts.map +1 -0
- package/dist/goals/objective-routes.js +375 -0
- package/dist/goals/objective-routes.js.map +1 -0
- package/dist/host-kit/approval-bridge.d.ts +28 -8
- package/dist/host-kit/approval-bridge.d.ts.map +1 -1
- package/dist/host-kit/approval-bridge.js +37 -15
- package/dist/host-kit/approval-bridge.js.map +1 -1
- package/dist/host-kit/bearer-auth.d.ts +1 -1
- package/dist/host-kit/bearer-auth.js +1 -1
- package/dist/host-kit/env-vars.d.ts +20 -0
- package/dist/host-kit/env-vars.d.ts.map +1 -1
- package/dist/host-kit/env-vars.js +30 -0
- package/dist/host-kit/env-vars.js.map +1 -1
- package/dist/host-kit/flowsafe-worker.d.ts +113 -6
- package/dist/host-kit/flowsafe-worker.d.ts.map +1 -1
- package/dist/host-kit/flowsafe-worker.js +253 -63
- package/dist/host-kit/flowsafe-worker.js.map +1 -1
- package/dist/host-kit/host-approval-service.d.ts +13 -13
- package/dist/host-kit/host-approval-service.js +10 -10
- package/dist/host-kit/index.d.ts +3 -1
- package/dist/host-kit/index.d.ts.map +1 -1
- package/dist/host-kit/index.js +7 -0
- package/dist/host-kit/index.js.map +1 -1
- package/dist/host-kit/memory-boundary.d.ts +64 -0
- package/dist/host-kit/memory-boundary.d.ts.map +1 -0
- package/dist/host-kit/memory-boundary.js +109 -0
- package/dist/host-kit/memory-boundary.js.map +1 -0
- package/dist/host-kit/route-path.d.ts +17 -0
- package/dist/host-kit/route-path.d.ts.map +1 -0
- package/dist/host-kit/route-path.js +35 -0
- package/dist/host-kit/route-path.js.map +1 -0
- package/dist/host-kit/run-router.d.ts +10 -11
- package/dist/host-kit/run-router.d.ts.map +1 -1
- package/dist/host-kit/run-router.js.map +1 -1
- package/dist/host-kit/stream-router.d.ts +1 -1
- package/dist/host-kit/stream-router.d.ts.map +1 -1
- package/dist/host-kit/stream-ticket.d.ts +3 -3
- package/dist/host-kit/stream-ticket.d.ts.map +1 -1
- package/dist/host-kit/stream-ticket.js +1 -1
- package/dist/host-kit/tenant-registry.d.ts +1 -1
- package/dist/host-kit/tenant-registry.js +1 -1
- package/dist/host-kit/thread-topology.d.ts +44 -0
- package/dist/host-kit/thread-topology.d.ts.map +1 -0
- package/dist/host-kit/thread-topology.js +76 -0
- package/dist/host-kit/thread-topology.js.map +1 -0
- package/dist/host-kit/verifier.d.ts +1 -1
- package/dist/host-kit/verifier.js +1 -1
- package/dist/index.d.ts +4 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/internal-error-response.d.ts +3 -0
- package/dist/internal-error-response.d.ts.map +1 -0
- package/dist/internal-error-response.js +20 -0
- package/dist/internal-error-response.js.map +1 -0
- package/dist/numeric-config.d.ts +4 -0
- package/dist/numeric-config.d.ts.map +1 -0
- package/dist/numeric-config.js +23 -0
- package/dist/numeric-config.js.map +1 -0
- package/dist/schedules/index.d.ts +5 -0
- package/dist/schedules/index.d.ts.map +1 -0
- package/dist/schedules/index.js +13 -0
- package/dist/schedules/index.js.map +1 -0
- package/dist/schedules/router.d.ts +66 -0
- package/dist/schedules/router.d.ts.map +1 -0
- package/dist/schedules/router.js +827 -0
- package/dist/schedules/router.js.map +1 -0
- package/dist/schedules/schedules-d1.d.ts +30 -0
- package/dist/schedules/schedules-d1.d.ts.map +1 -0
- package/dist/schedules/schedules-d1.js +374 -0
- package/dist/schedules/schedules-d1.js.map +1 -0
- package/dist/schedules/storage.d.ts +11 -0
- package/dist/schedules/storage.d.ts.map +1 -0
- package/dist/schedules/storage.js +34 -0
- package/dist/schedules/storage.js.map +1 -0
- package/dist/schedules/tick.d.ts +132 -0
- package/dist/schedules/tick.d.ts.map +1 -0
- package/dist/schedules/tick.js +598 -0
- package/dist/schedules/tick.js.map +1 -0
- package/dist/signal-providers/delivery.d.ts +24 -0
- package/dist/signal-providers/delivery.d.ts.map +1 -0
- package/dist/signal-providers/delivery.js +62 -0
- package/dist/signal-providers/delivery.js.map +1 -0
- package/dist/signal-providers/github-provider.d.ts +33 -0
- package/dist/signal-providers/github-provider.d.ts.map +1 -0
- package/dist/signal-providers/github-provider.js +116 -0
- package/dist/signal-providers/github-provider.js.map +1 -0
- package/dist/signal-providers/host-do.d.ts +81 -0
- package/dist/signal-providers/host-do.d.ts.map +1 -0
- package/dist/signal-providers/host-do.js +229 -0
- package/dist/signal-providers/host-do.js.map +1 -0
- package/dist/signal-providers/host-topology.d.ts +27 -0
- package/dist/signal-providers/host-topology.d.ts.map +1 -0
- package/dist/signal-providers/host-topology.js +36 -0
- package/dist/signal-providers/host-topology.js.map +1 -0
- package/dist/signal-providers/index.d.ts +8 -0
- package/dist/signal-providers/index.d.ts.map +1 -0
- package/dist/signal-providers/index.js +21 -0
- package/dist/signal-providers/index.js.map +1 -0
- package/dist/signal-providers/provider.d.ts +93 -0
- package/dist/signal-providers/provider.d.ts.map +1 -0
- package/dist/signal-providers/provider.js +89 -0
- package/dist/signal-providers/provider.js.map +1 -0
- package/dist/signal-providers/subscription-d1.d.ts +88 -0
- package/dist/signal-providers/subscription-d1.d.ts.map +1 -0
- package/dist/signal-providers/subscription-d1.js +259 -0
- package/dist/signal-providers/subscription-d1.js.map +1 -0
- package/dist/signal-providers/webhook-route.d.ts +96 -0
- package/dist/signal-providers/webhook-route.d.ts.map +1 -0
- package/dist/signal-providers/webhook-route.js +444 -0
- package/dist/signal-providers/webhook-route.js.map +1 -0
- package/dist/signals/client.d.ts +72 -0
- package/dist/signals/client.d.ts.map +1 -0
- package/dist/signals/client.js +87 -0
- package/dist/signals/client.js.map +1 -0
- package/dist/signals/d1-shared.d.ts +43 -0
- package/dist/signals/d1-shared.d.ts.map +1 -0
- package/dist/signals/d1-shared.js +46 -0
- package/dist/signals/d1-shared.js.map +1 -0
- package/dist/signals/index.d.ts +9 -0
- package/dist/signals/index.d.ts.map +1 -0
- package/dist/signals/index.js +15 -0
- package/dist/signals/index.js.map +1 -0
- package/dist/signals/notification-dispatch.d.ts +52 -0
- package/dist/signals/notification-dispatch.d.ts.map +1 -0
- package/dist/signals/notification-dispatch.js +198 -0
- package/dist/signals/notification-dispatch.js.map +1 -0
- package/dist/signals/notifications-d1.d.ts +27 -0
- package/dist/signals/notifications-d1.d.ts.map +1 -0
- package/dist/signals/notifications-d1.js +703 -0
- package/dist/signals/notifications-d1.js.map +1 -0
- package/dist/signals/router.d.ts +73 -0
- package/dist/signals/router.d.ts.map +1 -0
- package/dist/signals/router.js +240 -0
- package/dist/signals/router.js.map +1 -0
- package/dist/signals/storage.d.ts +11 -0
- package/dist/signals/storage.d.ts.map +1 -0
- package/dist/signals/storage.js +27 -0
- package/dist/signals/storage.js.map +1 -0
- package/dist/signals/thread-do-routes.d.ts +82 -0
- package/dist/signals/thread-do-routes.d.ts.map +1 -0
- package/dist/signals/thread-do-routes.js +660 -0
- package/dist/signals/thread-do-routes.js.map +1 -0
- package/dist/signals/thread-state-d1.d.ts +22 -0
- package/dist/signals/thread-state-d1.d.ts.map +1 -0
- package/dist/signals/thread-state-d1.js +83 -0
- package/dist/signals/thread-state-d1.js.map +1 -0
- package/package.json +11 -2
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
// imports @cloudflare/workers-types.
|
|
15
15
|
import { APPROVAL_ROLES, createApprovalRouter, createTenantResolver, } from '../approval-api/index.js';
|
|
16
16
|
import { createAuditQueueHandler } from '../audit-export/index.js';
|
|
17
|
-
import { purgeExpiredWorkflowRuns } from '../do-runner/index.js';
|
|
17
|
+
import { purgeExpiredBackgroundTasks, purgeExpiredNotifications, purgeExpiredScheduleTriggers, purgeExpiredThreadState, purgeExpiredThreads, purgeExpiredWorkflowRuns, } from '../do-runner/index.js';
|
|
18
18
|
import { bearerActorAuthenticator } from './bearer-auth.js';
|
|
19
19
|
import { createDoRunTopology, } from './do-run-topology.js';
|
|
20
|
-
import { numberVar, selfDecisionPolicyVar } from './env-vars.js';
|
|
20
|
+
import { numberVar, optionalNumberVar, selfDecisionPolicyVar, } from './env-vars.js';
|
|
21
21
|
import { approvalStoreFactoryFor, buildHostApprovalService, maintenanceActor, reconcileApprovalsOnStatusDetached, runApprovalRetentionPurge, runSlaSweepMaintenance, } from './host-approval-service.js';
|
|
22
22
|
import { createHubTopology } from './hub-topology.js';
|
|
23
23
|
import { createRunRouter } from './run-router.js';
|
|
@@ -113,6 +113,113 @@ export function createFlowsafeWorker(config) {
|
|
|
113
113
|
retentionDays: env.APPROVAL_RETENTION_DAYS,
|
|
114
114
|
cron,
|
|
115
115
|
});
|
|
116
|
+
// Agent-memory thread TTL, opt-in (docs/agent-memory-tenancy.md item 7).
|
|
117
|
+
// Its OWN try/catch, like every sibling duty above and below: isolating one
|
|
118
|
+
// loop while a sibling shares its failure is a defect this codebase has
|
|
119
|
+
// already shipped once — a wedged thread purge must cost the run-snapshot
|
|
120
|
+
// purge, the approval purge, and the extra duties nothing.
|
|
121
|
+
let threadsPurged;
|
|
122
|
+
let threadMessagesPurged;
|
|
123
|
+
// optionalNumberVar, not numberVar: this var GATES the duty rather than
|
|
124
|
+
// tuning it, so unset/empty/garbage must all mean "do not delete" — never a
|
|
125
|
+
// silent fallback threshold (see its contract in env-vars.ts).
|
|
126
|
+
// allowZero: THREAD_RETENTION_DAYS=0 means "expire idle threads now", the
|
|
127
|
+
// same operator intent RUN_RETENTION_DAYS=0 states.
|
|
128
|
+
const threadRetentionDays = optionalNumberVar(env.THREAD_RETENTION_DAYS, 'THREAD_RETENTION_DAYS', { allowZero: true });
|
|
129
|
+
if (threadRetentionDays !== undefined) {
|
|
130
|
+
try {
|
|
131
|
+
const purgedThreads = await purgeExpiredThreads(env.DB, {
|
|
132
|
+
ttlMs: threadRetentionDays * 24 * 60 * 60 * 1000,
|
|
133
|
+
});
|
|
134
|
+
threadsPurged = purgedThreads.threads;
|
|
135
|
+
threadMessagesPurged = purgedThreads.messages;
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
console.error(JSON.stringify({
|
|
139
|
+
type: 'maintenance-error',
|
|
140
|
+
surface: 'thread-retention-purge',
|
|
141
|
+
cron,
|
|
142
|
+
error: String(error),
|
|
143
|
+
}));
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
// Background-task TTL cleanup (Track B, opt-in). Its OWN try/catch, like
|
|
147
|
+
// every sibling duty: a wedged background-task purge must cost the
|
|
148
|
+
// run-snapshot, approval, and thread purges nothing.
|
|
149
|
+
let backgroundTasksPurged;
|
|
150
|
+
if (config.backgroundTasks) {
|
|
151
|
+
try {
|
|
152
|
+
backgroundTasksPurged = await purgeExpiredBackgroundTasks(env.DB, {
|
|
153
|
+
completedTtlMs: config.backgroundTasks.completedTtlMs,
|
|
154
|
+
failedTtlMs: config.backgroundTasks.failedTtlMs,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
console.error(JSON.stringify({
|
|
159
|
+
type: 'maintenance-error',
|
|
160
|
+
surface: 'background-task-purge',
|
|
161
|
+
cron,
|
|
162
|
+
error: String(error),
|
|
163
|
+
}));
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
// Track C notification TTL (opt-in). Its OWN try/catch, like every sibling
|
|
167
|
+
// duty. optionalNumberVar (GATES the duty; unset/garbage => do not delete).
|
|
168
|
+
let notificationsPurged;
|
|
169
|
+
const notificationRetentionDays = optionalNumberVar(env.NOTIFICATION_RETENTION_DAYS, 'NOTIFICATION_RETENTION_DAYS', { allowZero: true });
|
|
170
|
+
if (notificationRetentionDays !== undefined) {
|
|
171
|
+
try {
|
|
172
|
+
notificationsPurged = await purgeExpiredNotifications(env.DB, {
|
|
173
|
+
ttlMs: notificationRetentionDays * 24 * 60 * 60 * 1000,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
console.error(JSON.stringify({
|
|
178
|
+
type: 'maintenance-error',
|
|
179
|
+
surface: 'notification-purge',
|
|
180
|
+
cron,
|
|
181
|
+
error: String(error),
|
|
182
|
+
}));
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
// Track C thread-state TTL (opt-in). Same isolation + opt-in posture.
|
|
186
|
+
let threadStatePurged;
|
|
187
|
+
const threadStateRetentionDays = optionalNumberVar(env.THREAD_STATE_RETENTION_DAYS, 'THREAD_STATE_RETENTION_DAYS', { allowZero: true });
|
|
188
|
+
if (threadStateRetentionDays !== undefined) {
|
|
189
|
+
try {
|
|
190
|
+
threadStatePurged = await purgeExpiredThreadState(env.DB, {
|
|
191
|
+
ttlMs: threadStateRetentionDays * 24 * 60 * 60 * 1000,
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
catch (error) {
|
|
195
|
+
console.error(JSON.stringify({
|
|
196
|
+
type: 'maintenance-error',
|
|
197
|
+
surface: 'thread-state-purge',
|
|
198
|
+
cron,
|
|
199
|
+
error: String(error),
|
|
200
|
+
}));
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
// Track D schedule-trigger history TTL (opt-in). Same isolation + opt-in
|
|
204
|
+
// posture. Only the fire HISTORY expires; schedule config rows are reaped
|
|
205
|
+
// only at offboarding (purgeTenant).
|
|
206
|
+
let scheduleTriggersPurged;
|
|
207
|
+
const scheduleTriggerRetentionDays = optionalNumberVar(env.SCHEDULE_TRIGGER_RETENTION_DAYS, 'SCHEDULE_TRIGGER_RETENTION_DAYS', { allowZero: true });
|
|
208
|
+
if (scheduleTriggerRetentionDays !== undefined) {
|
|
209
|
+
try {
|
|
210
|
+
scheduleTriggersPurged = await purgeExpiredScheduleTriggers(env.DB, {
|
|
211
|
+
ttlMs: scheduleTriggerRetentionDays * 24 * 60 * 60 * 1000,
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
catch (error) {
|
|
215
|
+
console.error(JSON.stringify({
|
|
216
|
+
type: 'maintenance-error',
|
|
217
|
+
surface: 'schedule-trigger-purge',
|
|
218
|
+
cron,
|
|
219
|
+
error: String(error),
|
|
220
|
+
}));
|
|
221
|
+
}
|
|
222
|
+
}
|
|
116
223
|
let extra = {};
|
|
117
224
|
if (config.extraPurgeDuties) {
|
|
118
225
|
try {
|
|
@@ -132,75 +239,152 @@ export function createFlowsafeWorker(config) {
|
|
|
132
239
|
cron,
|
|
133
240
|
purged,
|
|
134
241
|
approvalsPurged,
|
|
242
|
+
threadsPurged,
|
|
243
|
+
threadMessagesPurged,
|
|
244
|
+
backgroundTasksCompletedPurged: backgroundTasksPurged?.completed,
|
|
245
|
+
backgroundTasksFailedPurged: backgroundTasksPurged?.failed,
|
|
246
|
+
notificationsPurged,
|
|
247
|
+
threadStatePurged,
|
|
248
|
+
scheduleTriggersPurged,
|
|
135
249
|
...extra,
|
|
136
250
|
}));
|
|
137
251
|
}
|
|
252
|
+
// Track D schedule tick — its OWN failure-isolated duty (own try/catch, own log
|
|
253
|
+
// line), run on the `crons.tick` invocation. A wedged fire pass must cost the
|
|
254
|
+
// sweep + purge nothing, and vice versa (the two-cron isolation rationale).
|
|
255
|
+
async function runScheduleTickDuty(env, cron) {
|
|
256
|
+
const tick = config.scheduleTick?.(env);
|
|
257
|
+
if (!tick) {
|
|
258
|
+
// The tick cron fired but no scheduleTick builder is wired — a misconfig.
|
|
259
|
+
// Do NOT fall through to sweep/purge (this invocation is the tick's).
|
|
260
|
+
console.error(JSON.stringify({
|
|
261
|
+
type: 'config-error',
|
|
262
|
+
var: 'crons.tick',
|
|
263
|
+
cron,
|
|
264
|
+
reason: 'tick cron fired but no scheduleTick builder is configured',
|
|
265
|
+
}));
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
try {
|
|
269
|
+
const result = await tick();
|
|
270
|
+
console.log(JSON.stringify({ type: 'schedule-tick', cron, result }));
|
|
271
|
+
}
|
|
272
|
+
catch (error) {
|
|
273
|
+
console.error(JSON.stringify({
|
|
274
|
+
type: 'schedule-tick-error',
|
|
275
|
+
cron,
|
|
276
|
+
error: String(error),
|
|
277
|
+
}));
|
|
278
|
+
}
|
|
279
|
+
}
|
|
138
280
|
return {
|
|
139
281
|
async fetch(request, env, ctx) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
282
|
+
try {
|
|
283
|
+
const url = new URL(request.url);
|
|
284
|
+
if (request.method === 'GET' && url.pathname === '/healthz') {
|
|
285
|
+
return json({ ok: true });
|
|
286
|
+
}
|
|
287
|
+
const waitUntil = (promise) => ctx.waitUntil(promise);
|
|
288
|
+
const topology = createDoRunTopology(env.RUNNER);
|
|
289
|
+
const notify = config.notify?.(env);
|
|
290
|
+
const selfDecision = parseSelfDecision(env);
|
|
291
|
+
// Fetch-scope live fan-out sink: present iff a hub is bound (streaming is
|
|
292
|
+
// opt-in, DL-019). Each publish rides ctx.waitUntil (DL-020) and is
|
|
293
|
+
// contained — a failed fan-out logs and never fails the mutation.
|
|
294
|
+
const hub = env.HUB;
|
|
295
|
+
let streamSink;
|
|
296
|
+
if (hub) {
|
|
297
|
+
const hubTopology = createHubTopology(hub);
|
|
298
|
+
streamSink = (event) => waitUntil(hubTopology.publish(event).catch((error) => console.error(JSON.stringify({
|
|
299
|
+
type: 'stream-publish-error',
|
|
300
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
301
|
+
}))));
|
|
302
|
+
}
|
|
303
|
+
const resolve = buildResolve(env, topology, waitUntil, notify, selfDecision, streamSink);
|
|
304
|
+
if (config.preRoutes) {
|
|
305
|
+
const preResponse = await config.preRoutes(request, env, ctx, {
|
|
306
|
+
resolve,
|
|
307
|
+
topology,
|
|
308
|
+
});
|
|
309
|
+
if (preResponse)
|
|
310
|
+
return preResponse;
|
|
311
|
+
}
|
|
312
|
+
// Optional stream stage (DL-015/DL-019): mounted only when BOTH the hub
|
|
313
|
+
// binding and the ticket secret are present. Every route is under
|
|
314
|
+
// /api/stream/, so it composes ahead of the approval router without
|
|
315
|
+
// touching the /api/* run_worker_first entry.
|
|
316
|
+
if (env.HUB && env.STREAM_TICKET_SECRET) {
|
|
317
|
+
const streamResponse = await createStreamRouter({
|
|
318
|
+
resolve,
|
|
319
|
+
ticketSecret: env.STREAM_TICKET_SECRET,
|
|
320
|
+
hub: env.HUB,
|
|
321
|
+
runner: env.RUNNER,
|
|
322
|
+
})(request);
|
|
323
|
+
if (streamResponse)
|
|
324
|
+
return streamResponse;
|
|
325
|
+
}
|
|
326
|
+
// Optional Track C signal stage (P6): the host-built createSignalRouter,
|
|
327
|
+
// closed over THIS request's resolver. `/api/threads/*` — composes ahead
|
|
328
|
+
// of approvals/runs without overlap. Absent seam => unmounted.
|
|
329
|
+
const signalRouter = config.buildSignalRouter?.(resolve, env);
|
|
330
|
+
if (signalRouter) {
|
|
331
|
+
const signalResponse = await signalRouter(request);
|
|
332
|
+
if (signalResponse)
|
|
333
|
+
return signalResponse;
|
|
334
|
+
}
|
|
335
|
+
// Optional Track F goal stage (P6-lite, DL-018): the host-built
|
|
336
|
+
// createObjectiveRouter, closed over THIS request's resolver.
|
|
337
|
+
// `/api/threads/:threadId/goal` — composes after signals (non-overlapping)
|
|
338
|
+
// and ahead of approvals/runs. Absent seam ⇒ unmounted, byte-identical.
|
|
339
|
+
const objectiveRouter = config.buildObjectiveRouter?.(resolve, env);
|
|
340
|
+
if (objectiveRouter) {
|
|
341
|
+
const objectiveResponse = await objectiveRouter(request);
|
|
342
|
+
if (objectiveResponse)
|
|
343
|
+
return objectiveResponse;
|
|
344
|
+
}
|
|
345
|
+
// Optional Track D schedule CRUD stage (DL-013): the host-built
|
|
346
|
+
// createScheduleRouter, closed over THIS request's resolver. `/api/schedules/*`
|
|
347
|
+
// — composes after goals (non-overlapping), ahead of approvals/runs. Absent
|
|
348
|
+
// seam ⇒ unmounted, byte-identical.
|
|
349
|
+
const scheduleRouter = config.buildScheduleRouter?.(resolve, env);
|
|
350
|
+
if (scheduleRouter) {
|
|
351
|
+
const scheduleResponse = await scheduleRouter(request);
|
|
352
|
+
if (scheduleResponse)
|
|
353
|
+
return scheduleResponse;
|
|
354
|
+
}
|
|
355
|
+
const approvalResponse = await createApprovalRouter({ resolve })(request);
|
|
356
|
+
if (approvalResponse)
|
|
357
|
+
return approvalResponse;
|
|
358
|
+
const runResponse = await createRunRouter({
|
|
359
|
+
workflows: config.workflows,
|
|
175
360
|
resolve,
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
361
|
+
systemActorId: config.systemActorId,
|
|
362
|
+
start: config.wrapStart
|
|
363
|
+
? config.wrapStart(topology.start, env)
|
|
364
|
+
: topology.start,
|
|
365
|
+
status: topology.status,
|
|
366
|
+
resume: config.wrapResume
|
|
367
|
+
? config.wrapResume(topology.resume, env)
|
|
368
|
+
: topology.resume,
|
|
369
|
+
// D4 self-healing, waitUntil-detached — the shared wrapper owns the
|
|
370
|
+
// detach + reconcile-error logging.
|
|
371
|
+
reconcileApprovals: reconcileApprovalsOnStatusDetached(config.systemActorId, waitUntil),
|
|
179
372
|
})(request);
|
|
180
|
-
if (
|
|
181
|
-
return
|
|
373
|
+
if (runResponse)
|
|
374
|
+
return runResponse;
|
|
375
|
+
return json({ error: 'not found' }, 404);
|
|
376
|
+
}
|
|
377
|
+
catch (error) {
|
|
378
|
+
// Backstop: a mounted router (or any handler fault) that THROWS before
|
|
379
|
+
// returning a Response — e.g. a future unguarded path decode — is
|
|
380
|
+
// contained as a generic 500 here rather than rejecting out of fetch()
|
|
381
|
+
// as an unhandled promise. Never surface error.message to the client.
|
|
382
|
+
console.error(JSON.stringify({
|
|
383
|
+
type: 'worker-fetch-error',
|
|
384
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
385
|
+
}));
|
|
386
|
+
return json({ error: 'internal error' }, 500);
|
|
182
387
|
}
|
|
183
|
-
const approvalResponse = await createApprovalRouter({ resolve })(request);
|
|
184
|
-
if (approvalResponse)
|
|
185
|
-
return approvalResponse;
|
|
186
|
-
const runResponse = await createRunRouter({
|
|
187
|
-
workflows: config.workflows,
|
|
188
|
-
resolve,
|
|
189
|
-
systemActorId: config.systemActorId,
|
|
190
|
-
start: config.wrapStart
|
|
191
|
-
? config.wrapStart(topology.start, env)
|
|
192
|
-
: topology.start,
|
|
193
|
-
status: topology.status,
|
|
194
|
-
resume: config.wrapResume
|
|
195
|
-
? config.wrapResume(topology.resume, env)
|
|
196
|
-
: topology.resume,
|
|
197
|
-
// D4 self-healing, waitUntil-detached — the shared wrapper owns the
|
|
198
|
-
// detach + reconcile-error logging.
|
|
199
|
-
reconcileApprovals: reconcileApprovalsOnStatusDetached(config.systemActorId, waitUntil),
|
|
200
|
-
})(request);
|
|
201
|
-
if (runResponse)
|
|
202
|
-
return runResponse;
|
|
203
|
-
return json({ error: 'not found' }, 404);
|
|
204
388
|
},
|
|
205
389
|
async scheduled(controller, env, ctx) {
|
|
206
390
|
// Dispatch on WHICH cron fired; an unrecognized expression (ops edited
|
|
@@ -229,6 +413,12 @@ export function createFlowsafeWorker(config) {
|
|
|
229
413
|
else if (controller.cron === config.crons.purge) {
|
|
230
414
|
ctx.waitUntil(runPurgeMaintenance(env, controller.cron));
|
|
231
415
|
}
|
|
416
|
+
else if (config.crons.tick !== undefined &&
|
|
417
|
+
controller.cron === config.crons.tick) {
|
|
418
|
+
// Track D: the schedule tick's OWN invocation (opt-in; unset ⇒ this
|
|
419
|
+
// branch is unreachable, byte-identical).
|
|
420
|
+
ctx.waitUntil(runScheduleTickDuty(env, controller.cron));
|
|
421
|
+
}
|
|
232
422
|
else {
|
|
233
423
|
console.error(JSON.stringify({
|
|
234
424
|
type: 'config-error',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowsafe-worker.js","sourceRoot":"","sources":["../../src/host-kit/flowsafe-worker.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,yEAAyE;AACzE,4EAA4E;AAC5E,4EAA4E;AAC5E,0EAA0E;AAC1E,6EAA6E;AAC7E,yEAAyE;AACzE,6EAA6E;AAC7E,sEAAsE;AACtE,wEAAwE;AACxE,4EAA4E;AAC5E,sEAAsE;AACtE,qCAAqC;AAUrC,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAKnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EACL,mBAAmB,GAGpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,gBAAgB,EAChB,kCAAkC,EAClC,yBAAyB,EACzB,sBAAsB,GACvB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAyB,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AA6IxD,SAAS,IAAI,CAAC,OAAgB,EAAE,MAAM,GAAG,GAAG;IAC1C,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE;QAC3C,MAAM;QACN,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE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C3D,CAAC;iBAAM,IACL,MAAM,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS;gBAC/B,UAAU,CAAC,IAAI,KAAK,MAAM,CAAC,KAAK,CAAC,IAAI,EACrC,CAAC;gBACD,oEAAoE;gBACpE,0CAA0C;gBAC1C,GAAG,CAAC,SAAS,CAAC,mBAAmB,CAAC,GAAG,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;YAC3D,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,KAAK,CACX,IAAI,CAAC,SAAS,CAAC;oBACb,IAAI,EAAE,cAAc;oBACpB,GAAG,EAAE,gBAAgB;oBACrB,GAAG,EAAE,UAAU,CAAC,IAAI;oBACpB,MAAM,EACJ,4DAA4D;iBAC/D,CAAC,CACH,CAAC;gBACF,GAAG,CAAC,SAAS,CACX,KAAK,EAAE;oBACL,8DAA8D;oBAC9D,iEAAiE;oBACjE,yDAAyD;qBACxD,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC;qBACf,IAAI,CAAC,GAAG,EAAE,CAAC,mBAAmB,CAAC,GAAG,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC,CACzD,CAAC;YACJ,CAAC;QACH,CAAC;QAED,mEAAmE;QACnE,mEAAmE;QACnE,sDAAsD;QACtD,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG;YACpB,MAAM,uBAAuB,CAAC;gBAC5B,QAAQ,EAAE,GAAG,CAAC,aAAa;gBAC3B,UAAU,EAAE,GAAG,CAAC,gBAAgB;aACjC,CAAC,CAAC,KAAK,CAAC,CAAC;QACZ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -65,8 +65,8 @@ export interface HostApprovalServiceOptions {
|
|
|
65
65
|
* Live-stream fan-out sink (ApprovalServiceOptions.stream) — fired once per
|
|
66
66
|
* successful approval mutation for the tenant's hub Durable Object. The host
|
|
67
67
|
* supplies a sink that forwards each event to env.HUB.idFromName(record.tenantId)
|
|
68
|
-
* (createHubTopology), wrapping the transport keepalive in ctx.waitUntil
|
|
69
|
-
*
|
|
68
|
+
* (`createHubTopology`), wrapping the transport keepalive in `ctx.waitUntil`
|
|
69
|
+
* at fetch scope. Undefined means no live fan-out (a poll-only host).
|
|
70
70
|
*/
|
|
71
71
|
stream?: ApprovalStreamSink;
|
|
72
72
|
}
|
|
@@ -77,9 +77,9 @@ export interface HostApprovalServiceOptions {
|
|
|
77
77
|
* suspends again at a later gate, the next approval is queued right here, so
|
|
78
78
|
* multi-gate workflows keep flowing through the queue.
|
|
79
79
|
*
|
|
80
|
-
* One audit sink instance backs both the service's own trail
|
|
81
|
-
* bridge's re-queue-failure signal
|
|
82
|
-
*
|
|
80
|
+
* One audit sink instance backs both the service's own trail and the
|
|
81
|
+
* bridge's re-queue-failure signal: a re-queue that fails after a durable
|
|
82
|
+
* resume is reported through it rather than silently absorbed.
|
|
83
83
|
*/
|
|
84
84
|
export declare function buildHostApprovalService(store: TenantBoundApprovalStore, options: HostApprovalServiceOptions): ApprovalService;
|
|
85
85
|
export interface SlaSweepMaintenanceOptions {
|
|
@@ -105,7 +105,7 @@ export interface SlaSweepMaintenanceOptions {
|
|
|
105
105
|
* COLLECTS each publish promise into its pendingSends and awaits it via the
|
|
106
106
|
* terminal Promise.all — never fire-and-forget (which would be cancelled when
|
|
107
107
|
* ctx.waitUntil(sweep()) settles) and never a nested waitUntil (which would
|
|
108
|
-
* throw cross-request I/O).
|
|
108
|
+
* throw cross-request I/O). Undefined means no live escalation fan-out.
|
|
109
109
|
*/
|
|
110
110
|
stream?: ApprovalStreamSink;
|
|
111
111
|
}
|
|
@@ -123,13 +123,13 @@ export interface SlaSweepMaintenanceOptions {
|
|
|
123
123
|
export declare function runSlaSweepMaintenance(options: SlaSweepMaintenanceOptions): Promise<void>;
|
|
124
124
|
/**
|
|
125
125
|
* waitUntil-detached wrapper over reconcileApprovalsOnStatus for
|
|
126
|
-
* ExecutionContext-capable hosts
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
126
|
+
* ExecutionContext-capable hosts. The heal only matters to a later poll,
|
|
127
|
+
* never the response being built, so its D1 reads and writes (the supersede
|
|
128
|
+
* CAS plus the fresh create) leave the status-response path. A rejection is
|
|
129
|
+
* logged as `reconcile-error`, never left unhandled inside waitUntil. Hosts
|
|
130
|
+
* without an ExecutionContext keep passing reconcileApprovalsOnStatus(...)
|
|
131
|
+
* directly (awaited in-path), as documented by the host-agnostic
|
|
132
|
+
* createRunRouter default.
|
|
133
133
|
*/
|
|
134
134
|
export declare function reconcileApprovalsOnStatusDetached(systemActorId: string, waitUntil: (promise: Promise<unknown>) => void): ReturnType<typeof reconcileApprovalsOnStatus>;
|
|
135
135
|
/** Options for the cron-owned approval-retention purge. */
|
|
@@ -60,9 +60,9 @@ export function hostAuditSink(options = {}) {
|
|
|
60
60
|
* suspends again at a later gate, the next approval is queued right here, so
|
|
61
61
|
* multi-gate workflows keep flowing through the queue.
|
|
62
62
|
*
|
|
63
|
-
* One audit sink instance backs both the service's own trail
|
|
64
|
-
* bridge's re-queue-failure signal
|
|
65
|
-
*
|
|
63
|
+
* One audit sink instance backs both the service's own trail and the
|
|
64
|
+
* bridge's re-queue-failure signal: a re-queue that fails after a durable
|
|
65
|
+
* resume is reported through it rather than silently absorbed.
|
|
66
66
|
*/
|
|
67
67
|
export function buildHostApprovalService(store, options) {
|
|
68
68
|
const systemActor = {
|
|
@@ -144,13 +144,13 @@ export async function runSlaSweepMaintenance(options) {
|
|
|
144
144
|
}
|
|
145
145
|
/**
|
|
146
146
|
* waitUntil-detached wrapper over reconcileApprovalsOnStatus for
|
|
147
|
-
* ExecutionContext-capable hosts
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
147
|
+
* ExecutionContext-capable hosts. The heal only matters to a later poll,
|
|
148
|
+
* never the response being built, so its D1 reads and writes (the supersede
|
|
149
|
+
* CAS plus the fresh create) leave the status-response path. A rejection is
|
|
150
|
+
* logged as `reconcile-error`, never left unhandled inside waitUntil. Hosts
|
|
151
|
+
* without an ExecutionContext keep passing reconcileApprovalsOnStatus(...)
|
|
152
|
+
* directly (awaited in-path), as documented by the host-agnostic
|
|
153
|
+
* createRunRouter default.
|
|
154
154
|
*/
|
|
155
155
|
export function reconcileApprovalsOnStatusDetached(systemActorId, waitUntil) {
|
|
156
156
|
const reconcile = reconcileApprovalsOnStatus(systemActorId);
|
package/dist/host-kit/index.d.ts
CHANGED
|
@@ -3,10 +3,11 @@ export { bearerActorAuthenticator, parseActorTokens } from './bearer-auth.js';
|
|
|
3
3
|
export { type DoResponseLike, doSummary } from './do-response.js';
|
|
4
4
|
export { createDoRunTopology, type DoRunTopology, type RunnerNamespaceLike, type RunnerStubLike, } from './do-run-topology.js';
|
|
5
5
|
export { boolVar, type NumberVarOptions, numberVar } from './env-vars.js';
|
|
6
|
-
export type { FlowsafeWorker, FlowsafeWorkerConfig, FlowsafeWorkerContext, FlowsafeWorkerEnv, } from './flowsafe-worker.js';
|
|
6
|
+
export type { BackgroundTasksCleanupConfig, FlowsafeWorker, FlowsafeWorkerConfig, FlowsafeWorkerContext, FlowsafeWorkerEnv, } from './flowsafe-worker.js';
|
|
7
7
|
export { createFlowsafeWorker } from './flowsafe-worker.js';
|
|
8
8
|
export { type ApprovalRetentionPurgeOptions, approvalStoreFactoryFor, buildHostApprovalService, type HostApprovalServiceOptions, maintenanceActor, reconcileApprovalsOnStatusDetached, runApprovalRetentionPurge, runSlaSweepMaintenance, type SlaSweepMaintenanceOptions, } from './host-approval-service.js';
|
|
9
9
|
export { createHubTopology, type HubNamespaceLike, type HubStubLike, type HubTopology, } from './hub-topology.js';
|
|
10
|
+
export { assertNoClientMemoryIds, requireOwnedMemoryId, TCB_ONLY_MEMORY_FIELDS, type TcbOnlyMemoryField, } from './memory-boundary.js';
|
|
10
11
|
export type { WorkflowIdSource } from './registration.js';
|
|
11
12
|
export { assertWorkflowsRegistered } from './registration.js';
|
|
12
13
|
export { RunRouteError } from './run-route-error.js';
|
|
@@ -20,6 +21,7 @@ export type { SubdomainCrossCheckOptions } from './subdomain-check.js';
|
|
|
20
21
|
export { withSubdomainCrossCheck } from './subdomain-check.js';
|
|
21
22
|
export type { ProvisionTenantOptions, TenantRegistryDatabase, TenantRegistryStatement, } from './tenant-registry.js';
|
|
22
23
|
export { provisionTenant, RESERVED_FOR_ALLOCATION, RESERVED_TENANT_IDS, TenantCollisionError, } from './tenant-registry.js';
|
|
24
|
+
export { createThreadTopology, type ThreadNamespaceLike, type ThreadRequestInit, type ThreadStubLike, type ThreadTopology, } from './thread-topology.js';
|
|
23
25
|
export type { HmacVerifierOptions, MintHmacTokenOptions, TokenVerifier, } from './verifier.js';
|
|
24
26
|
export { base64UrlEncode, hmacSign, hmacVerifier, mintHmacToken, staticTokenVerifier, toApprovalActor, } from './verifier.js';
|
|
25
27
|
export type { WorkflowMeta } from './workflow-meta.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/host-kit/index.ts"],"names":[],"mappings":"AAgBA,OAAO,EACL,0BAA0B,EAC1B,KAAK,WAAW,EAChB,4BAA4B,EAC5B,0BAA0B,EAC1B,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAE,KAAK,cAAc,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EACL,mBAAmB,EACnB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,cAAc,GACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,KAAK,gBAAgB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1E,YAAY,EACV,cAAc,EACd,oBAAoB,EACpB,qBAAqB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V,mBAAmB,EACnB,oBAAoB,EACpB,aAAa,GACd,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,eAAe,EACf,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,eAAe,GAChB,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/host-kit/index.js
CHANGED
|
@@ -25,6 +25,9 @@ export { createFlowsafeWorker } from './flowsafe-worker.js';
|
|
|
25
25
|
// directly.
|
|
26
26
|
export { approvalStoreFactoryFor, buildHostApprovalService, maintenanceActor, reconcileApprovalsOnStatusDetached, runApprovalRetentionPurge, runSlaSweepMaintenance, } from './host-approval-service.js';
|
|
27
27
|
export { createHubTopology, } from './hub-topology.js';
|
|
28
|
+
// The agent-memory host boundary every memory-touching route calls
|
|
29
|
+
// (docs/agent-memory-tenancy.md item 5).
|
|
30
|
+
export { assertNoClientMemoryIds, requireOwnedMemoryId, TCB_ONLY_MEMORY_FIELDS, } from './memory-boundary.js';
|
|
28
31
|
export { assertWorkflowsRegistered } from './registration.js';
|
|
29
32
|
export { RunRouteError } from './run-route-error.js';
|
|
30
33
|
export { createRunRouter } from './run-router.js';
|
|
@@ -35,5 +38,9 @@ export { mintStreamTicket, verifyStreamTicket } from './stream-ticket.js';
|
|
|
35
38
|
// withSubdomainCrossCheck, and no host consumes them directly.
|
|
36
39
|
export { withSubdomainCrossCheck } from './subdomain-check.js';
|
|
37
40
|
export { provisionTenant, RESERVED_FOR_ALLOCATION, RESERVED_TENANT_IDS, TenantCollisionError, } from './tenant-registry.js';
|
|
41
|
+
// The sanctioned way to reach a thread DO: it MINTS the tenant header
|
|
42
|
+
// ThreadDurableObject verifies, so a route never forwards a client's own
|
|
43
|
+
// (see thread-topology.ts — mint and verify ship together).
|
|
44
|
+
export { createThreadTopology, } from './thread-topology.js';
|
|
38
45
|
export { base64UrlEncode, hmacSign, hmacVerifier, mintHmacToken, staticTokenVerifier, toApprovalActor, } from './verifier.js';
|
|
39
46
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/host-kit/index.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,4EAA4E;AAC5E,4EAA4E;AAC5E,gFAAgF;AAChF,6EAA6E;AAC7E,+EAA+E;AAC/E,gFAAgF;AAChF,0CAA0C;AAC1C,EAAE;AACF,mFAAmF;AACnF,0EAA0E;AAC1E,iFAAiF;AACjF,wEAAwE;AACxE,4EAA4E;AAC5E,+EAA+E;AAE/E,OAAO,EACL,0BAA0B,EAE1B,4BAA4B,EAC5B,0BAA0B,EAC1B,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAuB,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EACL,mBAAmB,GAIpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAyB,SAAS,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/host-kit/index.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,4EAA4E;AAC5E,4EAA4E;AAC5E,gFAAgF;AAChF,6EAA6E;AAC7E,+EAA+E;AAC/E,gFAAgF;AAChF,0CAA0C;AAC1C,EAAE;AACF,mFAAmF;AACnF,0EAA0E;AAC1E,iFAAiF;AACjF,wEAAwE;AACxE,4EAA4E;AAC5E,+EAA+E;AAE/E,OAAO,EACL,0BAA0B,EAE1B,4BAA4B,EAC5B,0BAA0B,EAC1B,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAuB,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,E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enantContext } from '../approval-api/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* The memory-id fields no client body may name — the TCB_ONLY_CREATE_FIELDS
|
|
4
|
+
* doctrine applied to memory: a client that picks its own threadId/resourceId
|
|
5
|
+
* picks whose memory it reads, so these are minted server-side or not at all.
|
|
6
|
+
*/
|
|
7
|
+
export declare const TCB_ONLY_MEMORY_FIELDS: readonly ["threadId", "resourceId"];
|
|
8
|
+
export type TcbOnlyMemoryField = (typeof TCB_ONLY_MEMORY_FIELDS)[number];
|
|
9
|
+
/**
|
|
10
|
+
* Refuse a request body that names a memory id ANYWHERE in it. 400 rather than
|
|
11
|
+
* a silent override, for the same reason the run router 400s a client runId: a
|
|
12
|
+
* caller pinning ids must find out, not watch its value get quietly replaced and
|
|
13
|
+
* conclude the field works.
|
|
14
|
+
*
|
|
15
|
+
* NESTED, not just top-level, because the shape the first real consumer sends is
|
|
16
|
+
* nested: an agent run starts through `POST /runs` as
|
|
17
|
+
* `{workflowId, inputData: {...}}`, so the natural body for a threaded run is
|
|
18
|
+
* `{inputData: {threadId, prompt}}` — a top-level-only check would pass exactly
|
|
19
|
+
* the request this guard exists to refuse. A legitimate payload never carries a
|
|
20
|
+
* memory id (that is the whole doctrine: they are minted server-side and travel
|
|
21
|
+
* through requestContext, never a body), so refusing the name at any depth costs
|
|
22
|
+
* nothing real and closes the shape the leak actually arrives in.
|
|
23
|
+
*
|
|
24
|
+
* `undefined` is refused along with a value — a body carrying the KEY is a
|
|
25
|
+
* caller that believes it may choose, and the day someone writes
|
|
26
|
+
* `threadId: maybeUndefined` the tolerant reading is a leak waiting on one
|
|
27
|
+
* truthiness bug. Non-object bodies name no field and pass; body SHAPE is each
|
|
28
|
+
* route's own schema business.
|
|
29
|
+
*
|
|
30
|
+
* The walk is ITERATIVE and UNBOUNDED in depth. A depth cap would be a bypass
|
|
31
|
+
* with a number on it — nest one level past it and the id sails through the
|
|
32
|
+
* check — and depth is the attacker's choice, not the route's. Recursion is what
|
|
33
|
+
* a hostile 10k-deep body would actually break (the stack), so the fix is to not
|
|
34
|
+
* recurse: an explicit worklist costs heap proportional to a body JSON.parse has
|
|
35
|
+
* already materialized. A `seen` set keeps a cyclic in-process object (never a
|
|
36
|
+
* parsed body, which cannot cycle) from looping forever.
|
|
37
|
+
*
|
|
38
|
+
* Covers what a JSON body can express. A `Map`'s entries and a non-enumerable
|
|
39
|
+
* property are invisible to it — neither survives JSON.parse, so no HTTP caller
|
|
40
|
+
* can reach them; a route handing this a hand-built in-process object is outside
|
|
41
|
+
* the contract.
|
|
42
|
+
*/
|
|
43
|
+
export declare function assertNoClientMemoryIds(body: unknown): void;
|
|
44
|
+
/**
|
|
45
|
+
* Assert the authenticated tenant owns a memory id, returning it for use.
|
|
46
|
+
* 404 — never 403 — on a foreign id: the run router's rule, for the same
|
|
47
|
+
* reason. A 403 would confirm that another tenant's threadId EXISTS, turning
|
|
48
|
+
* every read path into an existence oracle over ids a caller can guess (a
|
|
49
|
+
* resourceId is business identity — an email, a user id — so guessing is the
|
|
50
|
+
* expected case, not a stretch).
|
|
51
|
+
*
|
|
52
|
+
* This is the ONLY thing between a foreign threadId and its history — nothing
|
|
53
|
+
* downstream re-checks. Mastra's recall filters by `resourceId` only when the
|
|
54
|
+
* caller passes one (`if (resourceId) query += ' AND resourceId = ?'`), and core
|
|
55
|
+
* ships recall sites that pass a threadId alone, so a foreign thread recalls in
|
|
56
|
+
* FULL past this point (pinned in do-runner/memory-recall-tenancy.test.ts). Call
|
|
57
|
+
* it on EVERY memory read path; there is no second line.
|
|
58
|
+
*
|
|
59
|
+
* `tenant.ownsMemoryId` is exact because the tenant-ID pattern
|
|
60
|
+
* excludes '_' from tenant ids, so 'acme' can never own 'acmecorp_...'
|
|
61
|
+
* (do-runner/path-safe-id.ts).
|
|
62
|
+
*/
|
|
63
|
+
export declare function requireOwnedMemoryId(tenant: TenantContext, id: string, label?: TcbOnlyMemoryField): string;
|
|
64
|
+
//# sourceMappingURL=memory-boundary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-boundary.d.ts","sourceRoot":"","sources":["../../src/host-kit/memory-boundary.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAG9D;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,qCAAsC,CAAC;AAE1E,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAsB3D;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,MAAM,EACV,KAAK,GAAE,kBAA+B,GACrC,MAAM,CAKR"}
|