@tangle-network/agent-app 0.43.41 → 0.43.42

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.
Files changed (47) hide show
  1. package/dist/assistant/index.d.ts +2 -1
  2. package/dist/assistant/index.js +3 -2
  3. package/dist/assistant/index.js.map +1 -1
  4. package/dist/chat-routes/index.d.ts +17 -3
  5. package/dist/chat-routes/index.js +91 -6
  6. package/dist/chat-routes/index.js.map +1 -1
  7. package/dist/chat-store/index.d.ts +4 -3
  8. package/dist/chat-store/index.js +5 -1
  9. package/dist/chat-store/index.js.map +1 -1
  10. package/dist/{chunk-Y4QHNQ75.js → chunk-6KVH5SP5.js} +110 -6
  11. package/dist/chunk-6KVH5SP5.js.map +1 -0
  12. package/dist/{chunk-XYWCGFII.js → chunk-B5JD3DXD.js} +48 -2
  13. package/dist/chunk-B5JD3DXD.js.map +1 -0
  14. package/dist/{chunk-I2R2XT4M.js → chunk-I2ATYB7R.js} +18 -2
  15. package/dist/chunk-I2ATYB7R.js.map +1 -0
  16. package/dist/chunk-SIXYZ2FB.js +101 -0
  17. package/dist/chunk-SIXYZ2FB.js.map +1 -0
  18. package/dist/{chunk-4TXDD6P2.js → chunk-XAWFPMAR.js} +38 -3
  19. package/dist/chunk-XAWFPMAR.js.map +1 -0
  20. package/dist/{chunk-KM766NN3.js → chunk-ZLHK25C3.js} +1766 -1223
  21. package/dist/chunk-ZLHK25C3.js.map +1 -0
  22. package/dist/chunk-ZU5GNSOJ.js +920 -0
  23. package/dist/chunk-ZU5GNSOJ.js.map +1 -0
  24. package/dist/{contract-DYbTzEDf.d.ts → contract-KfqJh_au.d.ts} +23 -2
  25. package/dist/design-canvas-react/index.js +4 -4
  26. package/dist/durable-chat/index.d.ts +419 -0
  27. package/dist/durable-chat/index.js +59 -0
  28. package/dist/durable-chat/index.js.map +1 -0
  29. package/dist/index.d.ts +5 -3
  30. package/dist/index.js +123 -45
  31. package/dist/interactions/index.d.ts +58 -3
  32. package/dist/interactions/index.js +7 -3
  33. package/dist/{parts-BcbitSNp.d.ts → parts-DjX0RRTS.d.ts} +9 -3
  34. package/dist/plans/index.d.ts +69 -0
  35. package/dist/plans/index.js +21 -0
  36. package/dist/plans/index.js.map +1 -0
  37. package/dist/stream/index.js +3 -1
  38. package/dist/teams/index.js +9 -9
  39. package/dist/teams/invitations-api.js +3 -3
  40. package/dist/web-react/index.d.ts +252 -93
  41. package/dist/web-react/index.js +32 -3
  42. package/package.json +11 -1
  43. package/dist/chunk-4TXDD6P2.js.map +0 -1
  44. package/dist/chunk-I2R2XT4M.js.map +0 -1
  45. package/dist/chunk-KM766NN3.js.map +0 -1
  46. package/dist/chunk-XYWCGFII.js.map +0 -1
  47. package/dist/chunk-Y4QHNQ75.js.map +0 -1
@@ -0,0 +1,419 @@
1
+ import { C as ChatInteraction, g as InteractionAnswerValue, k as InteractionRequestWire, i as InteractionCancelData, j as InteractionPersistedPart } from '../contract-KfqJh_au.js';
2
+ import { ChatPlan } from '../plans/index.js';
3
+ import { DurableInteractionRouteArgs, DurableInteractionRoutePersistence } from '../interactions/index.js';
4
+ import '@tangle-network/agent-interface';
5
+
6
+ type DurableChatErrorCode = 'DURABLE_CHAT_BAD_REQUEST' | 'DURABLE_CHAT_UNAUTHORIZED' | 'DURABLE_CHAT_CONFLICT' | 'DURABLE_CHAT_UNAVAILABLE' | 'DURABLE_CHAT_GONE' | 'DURABLE_CHAT_NOT_FOUND';
7
+ /** Typed, fail-loud errors for adapters and route seams. */
8
+ declare class DurableChatError extends Error {
9
+ readonly code: DurableChatErrorCode;
10
+ readonly status: number;
11
+ readonly details?: unknown;
12
+ constructor(code: DurableChatErrorCode, message: string, status: number, details?: unknown);
13
+ }
14
+ declare class DurableChatConflictError extends DurableChatError {
15
+ constructor(message?: string, details?: unknown);
16
+ }
17
+ declare class DurableChatUnavailableError extends DurableChatError {
18
+ constructor(message?: string, details?: unknown);
19
+ }
20
+ declare class DurableChatGoneError extends DurableChatError {
21
+ constructor(message?: string, details?: unknown);
22
+ }
23
+
24
+ /** An authorization-derived tenant/thread scope. Consumers should only
25
+ * create this value after authenticating the request; the route never accepts
26
+ * an identity or scope from the request body. */
27
+ type DurableChatScope = string & {
28
+ readonly __durableChatScope: unique symbol;
29
+ };
30
+ declare function createDurableChatScope(value: string): DurableChatScope;
31
+ declare function durableChatScopeKey(scope: DurableChatScope): string;
32
+ type DurablePlanDecision = 'approved' | 'rejected';
33
+ type DurablePlanAuthorityDecision = DurablePlanDecision | 'approve' | 'reject';
34
+ /** Projection retained by a durable store. It is intentionally compatible
35
+ * with the browser `/plans` projection and adds no product-specific fields. */
36
+ type DurablePlanProjection = ChatPlan & {
37
+ metadata?: Record<string, unknown>;
38
+ decidedBy?: string;
39
+ };
40
+ type DurablePlanCommandKey = string;
41
+ type DurablePlanCommandState = 'claimed' | 'authority_committed' | 'finalized' | 'conflicted';
42
+ interface DurablePlanCommandRecord {
43
+ scope: DurableChatScope;
44
+ planId: string;
45
+ revision: number;
46
+ decision: DurablePlanDecision;
47
+ commandKey: DurablePlanCommandKey;
48
+ authorityIdempotencyKey: string;
49
+ state: DurablePlanCommandState;
50
+ claimedAt: string;
51
+ authorityResult?: DurablePlanAuthorityResult;
52
+ receipt?: DurableFollowUpReceipt;
53
+ conflict?: string;
54
+ }
55
+ interface DurablePlanAuthorityCurrentResult {
56
+ /** Authoritative state. `null` means the authority has forgotten the plan. */
57
+ plan: DurablePlanProjection | null;
58
+ receipt?: DurableFollowUpReceipt;
59
+ }
60
+ interface DurableFollowUpReceipt {
61
+ /** Stable for a scope + plan + revision + decision. */
62
+ receiptId: string;
63
+ planId: string;
64
+ revision: number;
65
+ decision: DurablePlanDecision;
66
+ turnId: string;
67
+ state: string;
68
+ /** Authority's stable idempotency key, useful when reconciling. */
69
+ authorityIdempotencyKey: string;
70
+ }
71
+ interface DurablePlanAuthorityResult {
72
+ /** Authority's final plan projection. */
73
+ plan: DurablePlanProjection;
74
+ /** Sandbox-style follow-up result. */
75
+ followUp: {
76
+ turnId: string;
77
+ state: string;
78
+ };
79
+ /** True when the authority served a previously committed decision. */
80
+ idempotent?: boolean;
81
+ /** Stable authority operation id, if the provider has one. */
82
+ authorityId?: string;
83
+ receipt?: DurableFollowUpReceipt;
84
+ }
85
+ /** Structural port to Sandbox (or another durable plan authority). */
86
+ interface DurablePlanAuthority {
87
+ current(args: {
88
+ scope: DurableChatScope;
89
+ planId: string;
90
+ revision?: number;
91
+ }): Promise<DurablePlanAuthorityCurrentResult | DurablePlanProjection | null>;
92
+ decide(args: {
93
+ scope: DurableChatScope;
94
+ planId: string;
95
+ revision: number;
96
+ decision: DurablePlanDecision;
97
+ feedback?: string;
98
+ idempotencyKey: string;
99
+ }): Promise<DurablePlanAuthorityResult>;
100
+ }
101
+ interface DurablePlanEffectRecord {
102
+ effectKey: string;
103
+ scope: DurableChatScope;
104
+ planId: string;
105
+ revision: number;
106
+ decision: DurablePlanDecision;
107
+ state: 'claimed' | 'completed' | 'error';
108
+ claimedAt: string;
109
+ completedAt?: string;
110
+ error?: string;
111
+ }
112
+ interface DurablePlanStore {
113
+ getPlanProjection(scope: DurableChatScope, planId: string, revision?: number): Promise<DurablePlanProjection | null>;
114
+ putPlanProjection(scope: DurableChatScope, projection: DurablePlanProjection): Promise<void>;
115
+ listPlanProjections?(scope: DurableChatScope, planId?: string): Promise<DurablePlanProjection[]>;
116
+ getPlanCommand(scope: DurableChatScope, commandKey: DurablePlanCommandKey): Promise<DurablePlanCommandRecord | null>;
117
+ claimPlanCommand(scope: DurableChatScope, command: DurablePlanCommandRecord): Promise<{
118
+ status: 'claimed';
119
+ record: DurablePlanCommandRecord;
120
+ } | {
121
+ status: 'existing';
122
+ record: DurablePlanCommandRecord;
123
+ } | {
124
+ status: 'conflict';
125
+ record?: DurablePlanCommandRecord;
126
+ reason: string;
127
+ }>;
128
+ recordPlanAuthorityResult(scope: DurableChatScope, commandKey: DurablePlanCommandKey, result: DurablePlanAuthorityResult, receipt: DurableFollowUpReceipt): Promise<void>;
129
+ finalizePlanCommand(scope: DurableChatScope, commandKey: DurablePlanCommandKey): Promise<void>;
130
+ getPlanEffect(scope: DurableChatScope, effectKey: string): Promise<DurablePlanEffectRecord | null>;
131
+ claimPlanEffect(scope: DurableChatScope, effect: DurablePlanEffectRecord): Promise<{
132
+ status: 'claimed';
133
+ record: DurablePlanEffectRecord;
134
+ } | {
135
+ status: 'existing';
136
+ record: DurablePlanEffectRecord;
137
+ }>;
138
+ completePlanEffect(scope: DurableChatScope, effectKey: string): Promise<void>;
139
+ failPlanEffect(scope: DurableChatScope, effectKey: string, error: string): Promise<void>;
140
+ getInteractionProjection(scope: DurableChatScope, interactionId: string): Promise<DurableInteractionProjection | null>;
141
+ upsertInteractionProjection(scope: DurableChatScope, projection: DurableInteractionProjection): Promise<DurableInteractionProjection>;
142
+ listInteractionProjections?(scope: DurableChatScope): Promise<DurableInteractionProjection[]>;
143
+ getAnswerIntent(scope: DurableChatScope, intentKey: string): Promise<DurableAnswerIntentRecord | null>;
144
+ claimAnswerIntent(scope: DurableChatScope, intent: DurableAnswerIntentRecord): Promise<{
145
+ status: 'claimed';
146
+ record: DurableAnswerIntentRecord;
147
+ } | {
148
+ status: 'existing';
149
+ record: DurableAnswerIntentRecord;
150
+ } | {
151
+ status: 'conflict';
152
+ record?: DurableAnswerIntentRecord;
153
+ reason: string;
154
+ }>;
155
+ acknowledgeAnswerIntent(scope: DurableChatScope, intentKey: string, acknowledgement: DurableInteractionAcknowledgement): Promise<void>;
156
+ /** Atomically settle the interaction projection (including semantic aliases)
157
+ * from the acknowledged intent and mark the intent finalized. */
158
+ finalizeAnswerIntent(scope: DurableChatScope, intentKey: string, guarantee?: DurableInteractionGuarantee): Promise<void>;
159
+ abortAnswerIntent(scope: DurableChatScope, intentKey: string, error: string): Promise<void>;
160
+ }
161
+ /** Alias used by adapters that store all durable chat state in one port. */
162
+ type DurableChatStateStore = DurablePlanStore;
163
+ type DurablePlanStateStore = DurablePlanStore;
164
+ type DurablePlanCommandJournal = Pick<DurablePlanStore, 'getPlanCommand' | 'claimPlanCommand' | 'recordPlanAuthorityResult' | 'finalizePlanCommand'>;
165
+ type DurableAnswerIntentJournal = Pick<DurablePlanStore, 'getAnswerIntent' | 'claimAnswerIntent' | 'acknowledgeAnswerIntent' | 'finalizeAnswerIntent' | 'abortAnswerIntent'>;
166
+ interface DurableInteractionProjection extends ChatInteraction {
167
+ /** Sequence/event identity used to make ask replays idempotent. */
168
+ eventId?: string;
169
+ semanticKey?: string;
170
+ /** A cancel-before-ask row is a terminal tombstone. */
171
+ tombstone?: boolean;
172
+ updatedAt?: string;
173
+ }
174
+ type DurableAnswerIntentState = 'prepared' | 'acknowledged' | 'finalized' | 'aborted';
175
+ interface DurableAnswerIntentRecord {
176
+ scope: DurableChatScope;
177
+ interactionId: string;
178
+ attemptKey: string;
179
+ intentKey: string;
180
+ outcome: 'accepted' | 'declined';
181
+ data?: Record<string, InteractionAnswerValue>;
182
+ state: DurableAnswerIntentState;
183
+ guarantee?: DurableInteractionGuarantee;
184
+ acknowledgement?: DurableInteractionAcknowledgement;
185
+ createdAt: string;
186
+ finalizedAt?: string;
187
+ error?: string;
188
+ }
189
+ interface DurableInteractionAcknowledgement {
190
+ acknowledged: true;
191
+ authorityId?: string;
192
+ status?: string;
193
+ at?: string;
194
+ }
195
+ type DurableInteractionGuarantee = 'reconciled' | 'best-effort';
196
+ interface DurableInteractionSettlementOptions {
197
+ /** Caller-created and stable across retries/reconnects. */
198
+ attemptKey: string;
199
+ guarantee?: DurableInteractionGuarantee;
200
+ now?: () => string;
201
+ }
202
+ interface DurableInteractionSettlement {
203
+ prepare(scope: DurableChatScope, interactionId: string, outcome: 'accepted' | 'declined', data?: Record<string, InteractionAnswerValue>): Promise<DurableAnswerIntentRecord>;
204
+ acknowledge(scope: DurableChatScope, intentKey: string, acknowledgement?: Omit<DurableInteractionAcknowledgement, 'acknowledged'>): Promise<DurableAnswerIntentRecord>;
205
+ finalize(scope: DurableChatScope, intentKey: string): Promise<DurableAnswerIntentRecord>;
206
+ abort(scope: DurableChatScope, intentKey: string, error: string): Promise<DurableAnswerIntentRecord>;
207
+ reconcile(scope: DurableChatScope, intentKey: string): Promise<DurableAnswerIntentRecord | null>;
208
+ }
209
+ declare function normalizePlanDecision(value: unknown): DurablePlanDecision | null;
210
+ declare function planCommandKey(planId: string, revision: number, decision: DurablePlanDecision): string;
211
+ declare function planAuthorityIdempotencyKey(scope: DurableChatScope, planId: string, revision: number, decision: DurablePlanDecision): string;
212
+ declare function planEffectKey(scope: DurableChatScope, planId: string, revision: number, decision: DurablePlanDecision): string;
213
+ declare function stablePlanReceipt(scope: DurableChatScope, planId: string, revision: number, decision: DurablePlanDecision, result: Pick<DurablePlanAuthorityResult, 'followUp'>): DurableFollowUpReceipt;
214
+
215
+ /**
216
+ * Reference adapter for tests and local development. It is intentionally
217
+ * process-local and non-production: there is no locking across processes,
218
+ * transaction, or crash recovery. Production adapters should implement the
219
+ * same port with a database/Workflow primitive and CAS at every claim.
220
+ */
221
+ declare class InMemoryDurableChatStateStore implements DurablePlanStore {
222
+ private readonly plans;
223
+ private readonly currentPlans;
224
+ private readonly commands;
225
+ private readonly effects;
226
+ private readonly interactions;
227
+ private readonly interactionSemantic;
228
+ /** Duplicate event ids point at the canonical semantic interaction so all
229
+ * duplicate asks settle through one terminal row/attempt. */
230
+ private readonly interactionAliases;
231
+ private readonly answerIntents;
232
+ private scopePrefix;
233
+ private scopedKey;
234
+ private planKey;
235
+ private currentKey;
236
+ private commandKey;
237
+ private interactionKey;
238
+ private intentKey;
239
+ private effectKey;
240
+ getPlanProjection(scope: DurableChatScope, planId: string, revision?: number): Promise<DurablePlanProjection | null>;
241
+ listPlanProjections(scope: DurableChatScope, planId?: string): Promise<DurablePlanProjection[]>;
242
+ putPlanProjection(scope: DurableChatScope, projection: DurablePlanProjection): Promise<void>;
243
+ getPlanCommand(scope: DurableChatScope, commandKey: DurablePlanCommandKey): Promise<DurablePlanCommandRecord | null>;
244
+ claimPlanCommand(scope: DurableChatScope, command: DurablePlanCommandRecord): Promise<{
245
+ status: "conflict";
246
+ record: DurablePlanCommandRecord;
247
+ reason: string;
248
+ } | {
249
+ status: "claimed";
250
+ record: DurablePlanCommandRecord;
251
+ reason?: undefined;
252
+ } | {
253
+ status: "existing";
254
+ record: DurablePlanCommandRecord;
255
+ reason?: undefined;
256
+ }>;
257
+ recordPlanAuthorityResult(scope: DurableChatScope, commandKey: string, result: DurablePlanAuthorityResult, receipt: DurablePlanCommandRecord['receipt']): Promise<void>;
258
+ finalizePlanCommand(scope: DurableChatScope, commandKey: string): Promise<void>;
259
+ getPlanEffect(scope: DurableChatScope, effectKey: string): Promise<DurablePlanEffectRecord | null>;
260
+ claimPlanEffect(scope: DurableChatScope, effect: DurablePlanEffectRecord): Promise<{
261
+ status: "existing";
262
+ record: DurablePlanEffectRecord;
263
+ } | {
264
+ status: "claimed";
265
+ record: DurablePlanEffectRecord;
266
+ }>;
267
+ completePlanEffect(scope: DurableChatScope, effectKey: string): Promise<void>;
268
+ failPlanEffect(scope: DurableChatScope, effectKey: string, error: string): Promise<void>;
269
+ getInteractionProjection(scope: DurableChatScope, interactionId: string): Promise<DurableInteractionProjection | null>;
270
+ listInteractionProjections(scope: DurableChatScope): Promise<DurableInteractionProjection[]>;
271
+ upsertInteractionProjection(scope: DurableChatScope, projection: DurableInteractionProjection): Promise<DurableInteractionProjection>;
272
+ getAnswerIntent(scope: DurableChatScope, intentKey: string): Promise<DurableAnswerIntentRecord | null>;
273
+ claimAnswerIntent(scope: DurableChatScope, intent: DurableAnswerIntentRecord): Promise<{
274
+ status: "claimed";
275
+ record: DurableAnswerIntentRecord;
276
+ reason?: undefined;
277
+ } | {
278
+ status: "existing";
279
+ record: DurableAnswerIntentRecord;
280
+ reason?: undefined;
281
+ } | {
282
+ status: "conflict";
283
+ record: DurableAnswerIntentRecord;
284
+ reason: string;
285
+ }>;
286
+ acknowledgeAnswerIntent(scope: DurableChatScope, intentKey: string, acknowledgement: DurableAnswerIntentRecord['acknowledgement']): Promise<void>;
287
+ finalizeAnswerIntent(scope: DurableChatScope, intentKey: string, guarantee?: DurableAnswerIntentRecord['guarantee']): Promise<void>;
288
+ abortAnswerIntent(scope: DurableChatScope, intentKey: string, error: string): Promise<void>;
289
+ }
290
+ /** Short aliases retained for adapter authors who call this a durable chat
291
+ * store rather than a state store. Both names refer to the same non-production
292
+ * reference implementation. */
293
+ declare const InMemoryDurableChatStore: typeof InMemoryDurableChatStateStore;
294
+ declare function createInMemoryDurableChatStateStore(): InMemoryDurableChatStateStore;
295
+
296
+ /** Apply an ask event. Event ids and semantic signatures make replays safe;
297
+ * a prior cancel creates a tombstone and cannot be resurrected by a late ask. */
298
+ declare function upsertDurableInteractionAsk(store: DurablePlanStore, scope: DurableChatScope, request: InteractionRequestWire, options?: {
299
+ eventId?: string;
300
+ semanticKey?: string;
301
+ now?: () => string;
302
+ }): Promise<DurableInteractionProjection>;
303
+ /** Apply a cancel event. It is valid before the ask arrives and leaves a
304
+ * terminal tombstone so a delayed ask cannot re-open the card. */
305
+ declare function recordDurableInteractionCancel(store: DurablePlanStore, scope: DurableChatScope, interactionId: string, reason?: string, options?: {
306
+ eventId?: string;
307
+ now?: () => string;
308
+ }): Promise<DurableInteractionProjection>;
309
+ /** Record an accepted/declined answer in the projection. The terminal
310
+ * transition is intentionally separate from answer-intent acknowledgement so
311
+ * callers can choose reconciled or best-effort delivery. */
312
+ declare function recordDurableInteractionAnswer(store: DurablePlanStore, scope: DurableChatScope, interactionId: string, outcome: 'accepted' | 'declined', answers?: Record<string, InteractionAnswerValue>, options?: {
313
+ eventId?: string;
314
+ now?: () => string;
315
+ }): Promise<DurableInteractionProjection>;
316
+ interface DurableInteractionSettlementFactoryOptions extends DurableInteractionSettlementOptions {
317
+ store: DurablePlanStore;
318
+ /** Optional authority lookup used by `reconcile`; returning null leaves the
319
+ * intent prepared for a later durable retry. */
320
+ reconcileAuthority?: (args: {
321
+ scope: DurableChatScope;
322
+ intent: DurableAnswerIntentRecord;
323
+ }) => Promise<DurableInteractionAcknowledgement | null>;
324
+ }
325
+ /** Additive answer settlement primitive for wiring into `/interactions`.
326
+ * `attemptKey` belongs to the caller and is never generated from user data. */
327
+ declare function createDurableInteractionSettlement(options: DurableInteractionSettlementFactoryOptions): DurableInteractionSettlement;
328
+ /** Stable key helper exported for products implementing their own settlement
329
+ * loop. */
330
+ declare function durableInteractionIntentKey(scope: DurableChatScope, interactionId: string, attemptKey: string): string;
331
+ declare const applyDurableInteractionAsk: typeof upsertDurableInteractionAsk;
332
+ declare const applyDurableInteractionCancel: typeof recordDurableInteractionCancel;
333
+ declare const applyDurableInteractionAnswer: typeof recordDurableInteractionAnswer;
334
+
335
+ interface DurableInteractionProjectionAdapter {
336
+ upsertAsk(request: InteractionRequestWire): Promise<void>;
337
+ cancel(cancel: InteractionCancelData): Promise<void>;
338
+ materialize(): Promise<InteractionPersistedPart[]>;
339
+ }
340
+ /** Binds an authorized durable scope/store to interaction lifecycle events. */
341
+ declare function createDurableInteractionProjectionAdapter(options: {
342
+ store: DurablePlanStore;
343
+ scope: DurableChatScope;
344
+ now?: () => string;
345
+ }): DurableInteractionProjectionAdapter;
346
+ interface DurableChatEventProjection {
347
+ observe(event: unknown): void | Promise<void>;
348
+ materialize(): Array<Record<string, unknown>> | Promise<Array<Record<string, unknown>>>;
349
+ }
350
+ /** Event projector usable with any `ChatTurnRouteProducer` through
351
+ * `withDurableChatProjection`. It tracks this turn's identities so older
352
+ * thread state is not copied into every assistant message. */
353
+ declare function createDurableChatEventProjection(options: {
354
+ store: DurablePlanStore;
355
+ scope: DurableChatScope;
356
+ now?: () => string;
357
+ }): DurableChatEventProjection;
358
+ interface PreparedDurableInteractionAnswer {
359
+ scope: DurableChatScope;
360
+ settlement: DurableInteractionSettlement;
361
+ intent: DurableAnswerIntentRecord;
362
+ }
363
+ interface DurableInteractionRoutePersistenceBase {
364
+ store: DurablePlanStore;
365
+ scope(args: DurableInteractionRouteArgs): DurableChatScope | Promise<DurableChatScope>;
366
+ now?: () => string;
367
+ }
368
+ type CreateDurableInteractionRoutePersistenceOptions = (DurableInteractionRoutePersistenceBase & {
369
+ guarantee: 'reconciled';
370
+ reconcileAuthority(args: {
371
+ scope: DurableChatScope;
372
+ intent: DurableAnswerIntentRecord;
373
+ route: DurableInteractionRouteArgs;
374
+ }): Promise<DurableInteractionAcknowledgement | null>;
375
+ }) | (DurableInteractionRoutePersistenceBase & {
376
+ guarantee: 'best-effort';
377
+ reconcileAuthority?: (args: {
378
+ scope: DurableChatScope;
379
+ intent: DurableAnswerIntentRecord;
380
+ route: DurableInteractionRouteArgs;
381
+ }) => Promise<DurableInteractionAcknowledgement | null>;
382
+ });
383
+ /** Ready-to-use bridge from `/interactions` to the durable state port. Only
384
+ * the reconciled variant may claim crash-safe behavior; best-effort is
385
+ * explicit in both its type and persisted intent. */
386
+ declare function createDurableInteractionRoutePersistence(options: CreateDurableInteractionRoutePersistenceOptions): DurableInteractionRoutePersistence<PreparedDurableInteractionAnswer>;
387
+
388
+ type DurablePlanAuthorization = DurableChatScope | {
389
+ scope: DurableChatScope;
390
+ } | Response | null | undefined;
391
+ interface DurablePlanRouteAuthorizeArgs {
392
+ request: Request;
393
+ operation: 'current' | 'decide';
394
+ planId?: string;
395
+ }
396
+ interface DurablePlanRouteOptions {
397
+ store: DurablePlanStore;
398
+ authority: DurablePlanAuthority;
399
+ /** Authentication and resource authorization. Scope must be derived by the
400
+ * caller from trusted credentials, never from client JSON. */
401
+ authorize: (args: DurablePlanRouteAuthorizeArgs) => Promise<DurablePlanAuthorization> | DurablePlanAuthorization;
402
+ /** Required idempotent side effect seam. The route claims `effectKey` before
403
+ * calling it; a product must make the callback safe to retry by that key. */
404
+ afterDecision: (args: {
405
+ scope: DurableChatScope;
406
+ plan: DurablePlanProjection;
407
+ receipt: DurableFollowUpReceipt;
408
+ effectKey: string;
409
+ }) => Promise<void> | void;
410
+ now?: () => string;
411
+ logger?: Pick<Console, 'warn' | 'error'>;
412
+ }
413
+ interface DurablePlanRoutes {
414
+ current(request: Request): Promise<Response>;
415
+ decide(request: Request): Promise<Response>;
416
+ }
417
+ declare function createDurablePlanRoutes(options: DurablePlanRouteOptions): DurablePlanRoutes;
418
+
419
+ export { type CreateDurableInteractionRoutePersistenceOptions, type DurableAnswerIntentJournal, type DurableAnswerIntentRecord, type DurableAnswerIntentState, DurableChatConflictError, DurableChatError, type DurableChatErrorCode, type DurableChatEventProjection, DurableChatGoneError, type DurableChatScope, type DurableChatStateStore, DurableChatUnavailableError, type DurableFollowUpReceipt, type DurableInteractionAcknowledgement, type DurableInteractionGuarantee, type DurableInteractionProjection, type DurableInteractionProjectionAdapter, type DurableInteractionSettlement, type DurableInteractionSettlementFactoryOptions, type DurableInteractionSettlementOptions, type DurablePlanAuthority, type DurablePlanAuthorityCurrentResult, type DurablePlanAuthorityDecision, type DurablePlanAuthorityResult, type DurablePlanAuthorization, type DurablePlanCommandJournal, type DurablePlanCommandKey, type DurablePlanCommandRecord, type DurablePlanCommandState, type DurablePlanDecision, type DurablePlanEffectRecord, type DurablePlanProjection, type DurablePlanRouteAuthorizeArgs, type DurablePlanRouteOptions, type DurablePlanRoutes, type DurablePlanStateStore, type DurablePlanStore, InMemoryDurableChatStateStore, InMemoryDurableChatStore, type PreparedDurableInteractionAnswer, applyDurableInteractionAnswer, applyDurableInteractionAsk, applyDurableInteractionCancel, createDurableChatEventProjection, createDurableChatScope, createDurableInteractionProjectionAdapter, createDurableInteractionRoutePersistence, createDurableInteractionSettlement, createDurablePlanRoutes, createInMemoryDurableChatStateStore, durableChatScopeKey, durableInteractionIntentKey, normalizePlanDecision, planAuthorityIdempotencyKey, planCommandKey, planEffectKey, recordDurableInteractionAnswer, recordDurableInteractionCancel, stablePlanReceipt, upsertDurableInteractionAsk };
@@ -0,0 +1,59 @@
1
+ import {
2
+ DurableChatConflictError,
3
+ DurableChatError,
4
+ DurableChatGoneError,
5
+ DurableChatUnavailableError,
6
+ InMemoryDurableChatStateStore,
7
+ InMemoryDurableChatStore,
8
+ applyDurableInteractionAnswer,
9
+ applyDurableInteractionAsk,
10
+ applyDurableInteractionCancel,
11
+ createDurableChatEventProjection,
12
+ createDurableChatScope,
13
+ createDurableInteractionProjectionAdapter,
14
+ createDurableInteractionRoutePersistence,
15
+ createDurableInteractionSettlement,
16
+ createDurablePlanRoutes,
17
+ createInMemoryDurableChatStateStore,
18
+ durableChatScopeKey,
19
+ durableInteractionIntentKey,
20
+ normalizePlanDecision,
21
+ planAuthorityIdempotencyKey,
22
+ planCommandKey,
23
+ planEffectKey,
24
+ recordDurableInteractionAnswer,
25
+ recordDurableInteractionCancel,
26
+ stablePlanReceipt,
27
+ upsertDurableInteractionAsk
28
+ } from "../chunk-ZU5GNSOJ.js";
29
+ import "../chunk-XAWFPMAR.js";
30
+ import "../chunk-SIXYZ2FB.js";
31
+ export {
32
+ DurableChatConflictError,
33
+ DurableChatError,
34
+ DurableChatGoneError,
35
+ DurableChatUnavailableError,
36
+ InMemoryDurableChatStateStore,
37
+ InMemoryDurableChatStore,
38
+ applyDurableInteractionAnswer,
39
+ applyDurableInteractionAsk,
40
+ applyDurableInteractionCancel,
41
+ createDurableChatEventProjection,
42
+ createDurableChatScope,
43
+ createDurableInteractionProjectionAdapter,
44
+ createDurableInteractionRoutePersistence,
45
+ createDurableInteractionSettlement,
46
+ createDurablePlanRoutes,
47
+ createInMemoryDurableChatStateStore,
48
+ durableChatScopeKey,
49
+ durableInteractionIntentKey,
50
+ normalizePlanDecision,
51
+ planAuthorityIdempotencyKey,
52
+ planCommandKey,
53
+ planEffectKey,
54
+ recordDurableInteractionAnswer,
55
+ recordDurableInteractionCancel,
56
+ stablePlanReceipt,
57
+ upsertDurableInteractionAsk
58
+ };
59
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/dist/index.d.ts CHANGED
@@ -17,12 +17,14 @@ export { KeyCrypto, KeyProvisioner, PlanLimit, PlatformBalanceInfo, PlatformBala
17
17
  export { HttpHeadProbeConfig, PreflightProbe, PreflightProbeResult, PreflightProbeVerdict, PreflightReport, RouterChatProbeConfig, SandboxAuthProbeConfig, formatPreflightReport, httpHeadProbe, routerChatProbe, runPreflight, sandboxAuthProbe } from './preflight/index.js';
18
18
  export { ObjectBody, ObjectKeyParts, ObjectStore, PutObjectOptions, R2LikeBucket, R2LikeObjectBody, R2LikeObjectHead, SignObjectUrlArgs, VerifyObjectUrlResult, assertSafeKeySegment, createProxiedArtifactRoute, createR2ObjectStore, objectKey, signObjectUrl, verifyObjectUrl } from './object-store/index.js';
19
19
  export { B as BULK_DELETE_MAX_THREADS, C as ChatStoreInputError, t as threadTitleFromMessage } from './core-7qIM7svy.js';
20
- export { C as ChatFilePart, a as ChatImagePart, b as ChatInteractionPart, c as ChatMessagePart, d as ChatNoticePart, e as ChatPartTime, f as ChatReasoningPart, g as ChatStepFinishPart, h as ChatStepStartPart, i as ChatSubtaskPart, j as ChatTextPart, k as ChatToolPart, l as ChatToolState, m as ChatToolStatus, n as ChatUsageTokens, S as StorableHarnessPartKind, o as isChatInteractionPart, p as isChatStepFinishPart, q as isChatTextPart, r as isChatToolPart, t as toChatMessageParts } from './parts-BcbitSNp.js';
20
+ export { C as ChatFilePart, a as ChatImagePart, b as ChatInteractionPart, c as ChatMessagePart, d as ChatNoticePart, e as ChatPartTime, f as ChatPlanPart, g as ChatReasoningPart, h as ChatStepFinishPart, i as ChatStepStartPart, j as ChatSubtaskPart, k as ChatTextPart, l as ChatToolPart, m as ChatToolState, n as ChatToolStatus, o as ChatUsageTokens, S as StorableHarnessPartKind, p as isChatInteractionPart, q as isChatPlanPart, r as isChatStepFinishPart, s as isChatTextPart, t as isChatToolPart, u as toChatMessageParts } from './parts-DjX0RRTS.js';
21
21
  export { DeriveKeyOptions, createFieldCrypto, decodeHexKey, decryptAesGcm, decryptBytes, decryptWithKey, deriveKey, encryptAesGcm, encryptBytes, encryptWithKey } from './crypto/index.js';
22
22
  export { BufferedTurnEvent, BufferedTurnOptions, BufferedTurnTap, D1LikeForTurns, JsonRecord, PersistedChatMessageForTurn, PumpBufferedTurnOptions, ReplayTurnEventsOptions, ResolvedChatTurn, StreamEvent, TURN_EVENTS_MIGRATION_SQL, TURN_STATUS_SCOPE_MIGRATION_SQL, TurnEventStore, TurnStatus, asRecord, asString, buildUserTextParts, coalesceChatStreamEvents, coalesceDeltas, createBufferedTurnTap, createD1TurnEventStore, createMemoryTurnEventStore, encodeEvent, finalizeAssistantParts, getPartKey, mergePersistedPart, messageHasTurnId, normalizeClientTurnId, normalizePersistedPart, normalizeTime, normalizeToolEvent, pumpBufferedTurn, replayTurnEvents, resolveChatTurn, resolveToolId, resolveToolName } from './stream/index.js';
23
23
  export { HubExecClient, HubExecClientOptions, HubExecErrorCode, HubExecResult, HubInvokeDeps, HubInvokeInput, HubInvokeOutcome, ParsedIntegrationAction, invokeIntegrationHub, resolveIntegrationAction } from './integrations/index.js';
24
- export { C as ChatInteraction, a as ChatInteractionField, b as ChatInteractionStatus, c as ChatSelectField, d as ComposerAnswerDelivery, I as INTERACTION_CANCEL_EVENT, e as INTERACTION_EVENT, f as INTERACTION_RESOLVED_EVENT, g as InteractionCancelData, h as InteractionPersistedPart, i as InteractionRequestWire, N as NoticeKind, j as NoticePersistedPart, P as ParseInteractionResult, k as canTransitionInteractionStatus, l as cancelStatusFor, m as composerAnswerData, n as composerAnswerDeliveries, o as dedupeQuestionInteractionsByContent, p as fieldAcceptsFreeText, q as interactionFromWireRequest, r as interactionPartKey, s as interactionToPersistedPart, t as isRenderableInteractionKind, u as isSafeInteractionFieldKey, v as isTerminalInteractionStatus, w as noticePart, x as noticePartKey, y as parseInteractionCancel, z as parseInteractionRequest, A as persistedPartToInteraction, B as questionInteractionContentSignature } from './contract-DYbTzEDf.js';
25
- export { InteractionAnswerBodyValidation, InteractionAnswerRoute, InteractionAnswerRouteOptions, InteractionClientOutcome, InteractionConnectionResolution, InteractionRouteLogger, ResolveInteractionConnectionArgs, SidecarInteractionsConnection, SidecarInteractionsError, SidecarInteractionsResult, createInteractionAnswerRoute, listSessionInteractions, mapInteractionRespondFailure, respondToSessionInteraction, validateInteractionAnswerBody } from './interactions/index.js';
24
+ export { C as ChatInteraction, a as ChatInteractionField, b as ChatInteractionStatus, c as ChatSelectField, d as ComposerAnswerDelivery, I as INTERACTION_CANCEL_EVENT, e as INTERACTION_EVENT, f as INTERACTION_RESOLVED_EVENT, g as InteractionAnswerValue, h as InteractionAnswers, i as InteractionCancelData, j as InteractionPersistedPart, k as InteractionRequestWire, N as NoticeKind, l as NoticePersistedPart, P as ParseInteractionAnswersResult, m as ParseInteractionResult, n as canTransitionInteractionStatus, o as cancelStatusFor, p as composerAnswerData, q as composerAnswerDeliveries, r as dedupeQuestionInteractionsByContent, s as fieldAcceptsFreeText, t as interactionFromWireRequest, u as interactionPartKey, v as interactionToPersistedPart, w as isRenderableInteractionKind, x as isSafeInteractionFieldKey, y as isTerminalInteractionStatus, z as noticePart, A as noticePartKey, B as parseInteractionAnswers, D as parseInteractionCancel, E as parseInteractionRequest, F as persistedPartToInteraction, G as questionInteractionContentSignature, H as stampInteractionAnswers } from './contract-KfqJh_au.js';
25
+ export { BeforeInteractionAnswerArgs, DurableInteractionRouteArgs, DurableInteractionRoutePersistence, InteractionAnswerBodyValidation, InteractionAnswerRoute, InteractionAnswerRouteOptions, InteractionClientOutcome, InteractionConnectionResolution, InteractionRouteLogger, ResolveInteractionConnectionArgs, SidecarInteractionsConnection, SidecarInteractionsError, SidecarInteractionsResult, createInteractionAnswerRoute, listSessionInteractions, mapInteractionRespondFailure, respondToSessionInteraction, validateInteractionAnswerBody } from './interactions/index.js';
26
+ export { ChatPlan, ChatPlanPersistedPart, ChatPlanStatus, PLAN_SUBMITTED_EVENT, ParsePlanSubmittedResult, canTransitionPlanStatus, parsePlanSubmittedEvent, persistedPartToPlan, planFollowUpTurnId, planPartKey, planRevisionKey, planToPersistedPart } from './plans/index.js';
27
+ export { CreateDurableInteractionRoutePersistenceOptions, DurableAnswerIntentJournal, DurableAnswerIntentRecord, DurableAnswerIntentState, DurableChatConflictError, DurableChatError, DurableChatErrorCode, DurableChatEventProjection, DurableChatGoneError, DurableChatScope, DurableChatStateStore, DurableChatUnavailableError, DurableFollowUpReceipt, DurableInteractionAcknowledgement, DurableInteractionGuarantee, DurableInteractionProjection, DurableInteractionProjectionAdapter, DurableInteractionSettlement, DurableInteractionSettlementFactoryOptions, DurableInteractionSettlementOptions, DurablePlanAuthority, DurablePlanAuthorityCurrentResult, DurablePlanAuthorityDecision, DurablePlanAuthorityResult, DurablePlanAuthorization, DurablePlanCommandJournal, DurablePlanCommandKey, DurablePlanCommandRecord, DurablePlanCommandState, DurablePlanDecision, DurablePlanEffectRecord, DurablePlanProjection, DurablePlanRouteAuthorizeArgs, DurablePlanRouteOptions, DurablePlanRoutes, DurablePlanStateStore, DurablePlanStore, InMemoryDurableChatStateStore, InMemoryDurableChatStore, PreparedDurableInteractionAnswer, applyDurableInteractionAnswer, applyDurableInteractionAsk, applyDurableInteractionCancel, createDurableChatEventProjection, createDurableChatScope, createDurableInteractionProjectionAdapter, createDurableInteractionRoutePersistence, createDurableInteractionSettlement, createDurablePlanRoutes, createInMemoryDurableChatStateStore, durableChatScopeKey, durableInteractionIntentKey, normalizePlanDecision, planAuthorityIdempotencyKey, planCommandKey, planEffectKey, recordDurableInteractionAnswer, recordDurableInteractionCancel, stablePlanReceipt, upsertDurableInteractionAsk } from './durable-chat/index.js';
26
28
  export { CompleteMissionInput, CreateMissionInput, DEFAULT_MISSION_STEP_KINDS, InMemoryMissionStore, MISSION_CONTROL_CHANNEL_ID, MissionApprovalsPort, MissionAuditEvent, MissionConcurrencyError, MissionCostLedger, MissionEngine, MissionEngineOptions, MissionEventSink, MissionGateKind, MissionGateOptions, MissionGateProposal, MissionOutcome, MissionPlanRunOptions, MissionProposalResolution, MissionRecord, MissionService, MissionServiceOptions, MissionState, MissionStatus, MissionStep, MissionStepState, MissionStepStatus, MissionStorePort, MissionStreamEvent, MissionStreamStatus, MissionStreamStep, MissionStreamStepStatus, MissionUpdateGuard, MissionUpdatePatch, ParseMissionBlocksOptions, ParsedMission, ParsedMissionStep, PlanOutcome, RetryableStepError, SandboxDispatch, SandboxDispatchDoneResult, SandboxDispatchInProgressResult, SandboxDispatchInput, SandboxDispatchResult, SetStepStatusPatch, StepGateClassification, StepOutcome, applyMissionEvent, asMissionStreamEvent, budgetGateProposalId, buildAgentMissionPlan, createInMemoryMissionStore, createMissionEngine, createMissionService, isMissionStopRequested, isMissionTerminal, mergeMissionState, noopEventSink, parseMissionBlocks, parseSessionStreamEnvelope, reduceMissionEvents, stepGateProposalId, volumeGateProposalId } from './missions/index.js';
27
29
  export { S as StepAgentActivity, W as WithAgentActivity, s as stepAgentActivity } from './agent-activity-C8ZG0F0M.js';
28
30
  export { AppToolDescriptor, AuthenticatedSandboxUser, BuildAppToolMcpServersOptions, BuildSandboxToolFileMountsOptions, DEFAULT_SANDBOX_RESOURCES, DriveSandboxTurnOptions, ENV_TOTAL_MAX_BYTES, ENV_VALUE_MAX_BYTES, EnsureWorkspaceSandboxOptions, LivenessProbeConfig, MemberSyncSeam, Outcome, PROVISION_PAYLOAD_MAX_BYTES, ProfileComposeOptions, PromptInputPart, ProviderResolutionConfig, ProvisionPayloadSections, ProvisionProfileSection, ResolveSandboxClientCredentialsOptions, ResolvedModel, SandboxApiCredentials, SandboxBuildContext, SandboxClientCredentials, SandboxCredentialEnvironment, SandboxPermissionLevel, SandboxResourceConfig, SandboxRestoreSpec, SandboxRuntimeAuthRefreshError, SandboxRuntimeConfig, SandboxRuntimeConnection, SandboxScope, SandboxStepTransition, SandboxTerminalTokenOptions, SandboxTerminalTokenResult, SandboxTerminalTokenSubject, SandboxTerminalWsMatch, SandboxToolPathOptions, SandboxToolSpec, ScopedTokenResult, SecretStore, StoppedSandboxResumeFailure, StoppedSandboxResumeRecovery, StreamSandboxPromptOptions, TerminalProxyIdentity, WorkspaceSandboxConnectionArgs, WorkspaceSandboxConnectionHandlerOptions, WorkspaceSandboxEnsureContext, WorkspaceSandboxInstanceLike, WorkspaceSandboxManager, WorkspaceSandboxManagerOptions, WorkspaceSandboxRuntimeProxyArgs, WorkspaceSandboxRuntimeProxyHandlerOptions, WorkspaceSandboxTerminalUpgradeHandlerOptions, WriteProfileFilesOptions, assertEnvWithinLimits, assertProvisionPayloadWithinCap, attachReasoningEffort, bearerSubprotocolToken, bearerToken, buildAppToolMcpServers, buildSandboxRuntimeProxyHeaders, buildSandboxToolFileMounts, buildSandboxToolPathSetupScript, classifySeveredStream, createSandboxTerminalToken, createWorkspaceSandboxConnectionHandler, createWorkspaceSandboxManager, createWorkspaceSandboxRuntimeProxyHandler, createWorkspaceSandboxTerminalUpgradeHandler, deferredCorpusHash, deleteSecret, detectInteractiveQuestion, driveSandboxTurn, encodeSandboxRuntimePath, ensureWorkspaceSandbox, flattenHistory, getClient, isSandboxTerminalWsUpgrade, isTerminalPromptEvent, matchSandboxTerminalWsPath, mergeExtraMcp, mergeHistoryIntoParts, mintSandboxScopedToken, mintTerminalProxyToken, readSecret, resetClientCache, resolveModel, resolveSandboxClientCredentials, runSandboxPrompt, runSandboxToolPathSetup, sandboxToolBinDir, sandboxToolPath, sandboxToolRootDir, secretStoreFromClient, splitDeferredProfileFiles, storeSecret, streamSandboxPrompt, syncSandboxMemberAdd, syncSandboxMemberRemove, syncSandboxMemberRole, terminalTokenFromRequest, verifySandboxTerminalToken, verifyTerminalProxyToken, writeProfileFilesToBox } from './sandbox/index.js';