@tangle-network/agent-app 0.43.40 → 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.
- package/dist/assistant/index.d.ts +3 -2
- package/dist/assistant/index.js +4 -3
- package/dist/assistant/index.js.map +1 -1
- package/dist/chat-routes/index.d.ts +19 -5
- package/dist/chat-routes/index.js +100 -7
- package/dist/chat-routes/index.js.map +1 -1
- package/dist/chat-store/index.d.ts +4 -3
- package/dist/chat-store/index.js +5 -1
- package/dist/chat-store/index.js.map +1 -1
- package/dist/chunk-2EO7CPL3.js +191 -0
- package/dist/chunk-2EO7CPL3.js.map +1 -0
- package/dist/{chunk-Y4QHNQ75.js → chunk-6KVH5SP5.js} +110 -6
- package/dist/chunk-6KVH5SP5.js.map +1 -0
- package/dist/{chunk-XYWCGFII.js → chunk-B5JD3DXD.js} +48 -2
- package/dist/chunk-B5JD3DXD.js.map +1 -0
- package/dist/{chunk-I2R2XT4M.js → chunk-I2ATYB7R.js} +18 -2
- package/dist/chunk-I2ATYB7R.js.map +1 -0
- package/dist/chunk-SIXYZ2FB.js +101 -0
- package/dist/chunk-SIXYZ2FB.js.map +1 -0
- package/dist/{chunk-4TXDD6P2.js → chunk-XAWFPMAR.js} +38 -3
- package/dist/chunk-XAWFPMAR.js.map +1 -0
- package/dist/{chunk-D4HB72W2.js → chunk-ZLHK25C3.js} +1890 -1213
- package/dist/chunk-ZLHK25C3.js.map +1 -0
- package/dist/chunk-ZU5GNSOJ.js +920 -0
- package/dist/chunk-ZU5GNSOJ.js.map +1 -0
- package/dist/{contract-DYbTzEDf.d.ts → contract-KfqJh_au.d.ts} +23 -2
- package/dist/design-canvas-react/index.js +4 -4
- package/dist/durable-chat/index.d.ts +419 -0
- package/dist/durable-chat/index.js +59 -0
- package/dist/durable-chat/index.js.map +1 -0
- package/dist/file-index-Bw_IQE_G.d.ts +194 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +123 -45
- package/dist/interactions/index.d.ts +58 -3
- package/dist/interactions/index.js +7 -3
- package/dist/{parts-BcbitSNp.d.ts → parts-DjX0RRTS.d.ts} +9 -3
- package/dist/plans/index.d.ts +69 -0
- package/dist/plans/index.js +21 -0
- package/dist/plans/index.js.map +1 -0
- package/dist/stream/index.js +3 -1
- package/dist/teams/index.js +9 -9
- package/dist/teams/invitations-api.js +3 -3
- package/dist/web-react/index.d.ts +345 -94
- package/dist/web-react/index.js +50 -5
- package/package.json +11 -1
- package/dist/chunk-4TXDD6P2.js.map +0 -1
- package/dist/chunk-5SV5PSU7.js +0 -80
- package/dist/chunk-5SV5PSU7.js.map +0 -1
- package/dist/chunk-D4HB72W2.js.map +0 -1
- package/dist/chunk-I2R2XT4M.js.map +0 -1
- package/dist/chunk-XYWCGFII.js.map +0 -1
- package/dist/chunk-Y4QHNQ75.js.map +0 -1
- package/dist/wire-BaUF66AS.d.ts +0 -61
|
@@ -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":[]}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire contract between the chat client (composer + `streamChatTurn`) and the
|
|
3
|
+
* assembled server vertical (`createChatTurnRoutes`). Import-free on purpose:
|
|
4
|
+
* `/web-react` re-exports these types into browser bundles, so nothing here may
|
|
5
|
+
* reach a Node builtin or an engine package.
|
|
6
|
+
*
|
|
7
|
+
* The part shape mirrors the sandbox SDK's `PromptInputPart` structurally
|
|
8
|
+
* (text | image | file with filename/mediaType/url/path/content) — derived
|
|
9
|
+
* here, not imported, so the client bundle never touches the SDK.
|
|
10
|
+
*/
|
|
11
|
+
interface ChatTurnTextPartInput {
|
|
12
|
+
type: 'text';
|
|
13
|
+
text: string;
|
|
14
|
+
}
|
|
15
|
+
/** A non-text prompt part the upload route hands back and the client echoes
|
|
16
|
+
* on send. `url` carries an inline `data:` URI for small files; `path` is a
|
|
17
|
+
* sandbox workspace reference for large ones (the >1 MiB gateway body cap
|
|
18
|
+
* makes the two-step upload mandatory). */
|
|
19
|
+
interface ChatTurnFilePartInput {
|
|
20
|
+
type: 'image' | 'file';
|
|
21
|
+
filename?: string;
|
|
22
|
+
mediaType?: string;
|
|
23
|
+
url?: string;
|
|
24
|
+
path?: string;
|
|
25
|
+
content?: string;
|
|
26
|
+
}
|
|
27
|
+
type ChatTurnPartInput = ChatTurnTextPartInput | ChatTurnFilePartInput;
|
|
28
|
+
/** POST body for the turn route. `content` may be empty when `parts` carry the
|
|
29
|
+
* message (an image-only send). Product routing fields (workspaceId etc.) ride
|
|
30
|
+
* alongside and are read by the product's `authorize` seam. */
|
|
31
|
+
interface ChatTurnRequestPayload {
|
|
32
|
+
threadId: string;
|
|
33
|
+
content?: string;
|
|
34
|
+
/** Non-text parts from the upload route, echoed back verbatim. */
|
|
35
|
+
parts?: ChatTurnFilePartInput[];
|
|
36
|
+
model?: string;
|
|
37
|
+
effort?: 'auto' | 'low' | 'medium' | 'high';
|
|
38
|
+
harness?: string;
|
|
39
|
+
/** Client-generated idempotency key for the logical turn (retry-safe). */
|
|
40
|
+
turnId?: string;
|
|
41
|
+
[key: string]: unknown;
|
|
42
|
+
}
|
|
43
|
+
/** `fetch` init for the turn route — the one place the client wire shape is
|
|
44
|
+
* serialized, so composer glue and products never drift from the server's
|
|
45
|
+
* parser. */
|
|
46
|
+
declare function chatTurnRequestInit(payload: ChatTurnRequestPayload): RequestInit;
|
|
47
|
+
declare const INLINE_PARTS_MAX_BYTES = 950000;
|
|
48
|
+
declare class ChatTurnInputError extends Error {
|
|
49
|
+
readonly status: number;
|
|
50
|
+
readonly code: string;
|
|
51
|
+
constructor(message: string, status?: number, code?: string);
|
|
52
|
+
}
|
|
53
|
+
declare function promptPartsByteSize(parts: ChatTurnPartInput[]): number;
|
|
54
|
+
/** Throws `ChatTurnInputError` (413) when the parts' inline payload would blow
|
|
55
|
+
* the gateway cap. Path-ref parts are tiny by construction and always pass. */
|
|
56
|
+
declare function assertPromptPartsWithinCap(parts: ChatTurnPartInput[], maxBytes?: number): void;
|
|
57
|
+
/** A file mention resolved from the composer's `@`-picker: the
|
|
58
|
+
* workspace-relative path plus enough metadata to build a prompt part and
|
|
59
|
+
* pointer text. `path` is the canonical identity — the mention pill's
|
|
60
|
+
* `MentionItem.id` for the file kind (`/web-react`'s `useFileMentions`). */
|
|
61
|
+
interface FileMention {
|
|
62
|
+
path: string;
|
|
63
|
+
name: string;
|
|
64
|
+
size?: number;
|
|
65
|
+
}
|
|
66
|
+
/** The `image/*` mime for a mention path by extension, or `undefined` for
|
|
67
|
+
* anything not in the known image set (dispatched as `type: 'file'`). */
|
|
68
|
+
declare function mediaTypeForMentionPath(path: string): string | undefined;
|
|
69
|
+
interface FileMentionsToPartsOptions {
|
|
70
|
+
/** Resolve a mention's workspace-relative path to the absolute path the
|
|
71
|
+
* dispatched part should carry (e.g. a host prefixing the in-box vault
|
|
72
|
+
* root). Default: identity — the path travels unchanged. */
|
|
73
|
+
resolvePath?: (path: string) => string;
|
|
74
|
+
}
|
|
75
|
+
/** Maps resolved file mentions to path-only `ChatTurnFilePartInput`s —
|
|
76
|
+
* `image` vs `file` by extension, and always a `path`, never a `url` (the
|
|
77
|
+
* url/path XOR invariant: a mention is a sandbox path reference, never
|
|
78
|
+
* inline bytes). */
|
|
79
|
+
declare function fileMentionsToParts(mentions: readonly FileMention[], opts?: FileMentionsToPartsOptions): ChatTurnFilePartInput[];
|
|
80
|
+
/** The agent-facing pointer block appended to the dispatched prompt — never
|
|
81
|
+
* persisted in message `content`. Empty array → `''` so callers can append
|
|
82
|
+
* unconditionally. This is the sole producer of that text: the current
|
|
83
|
+
* turn's dispatch and any history projection built from the same mention
|
|
84
|
+
* list both route through here, so the two can't drift apart. */
|
|
85
|
+
declare function buildMentionPromptBlock(mentions: readonly Pick<FileMention, 'name' | 'path'>[]): string;
|
|
86
|
+
/** Validates the untyped `parts` array off the wire. Returns the typed parts
|
|
87
|
+
* or throws `ChatTurnInputError` (400) naming the offending entry. */
|
|
88
|
+
declare function parseChatTurnParts(raw: unknown): ChatTurnFilePartInput[];
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* `createSandboxFileIndexRoute` — server side of `@`-file-mentions
|
|
92
|
+
* (companion to sandbox-ui#184's composer mention primitive). Serves a flat,
|
|
93
|
+
* ignore-filtered listing of the workspace sandbox so `useFileMentions`
|
|
94
|
+
* (`/web-react`) can filter it client-side without a round trip per
|
|
95
|
+
* keystroke.
|
|
96
|
+
*
|
|
97
|
+
* Same seam style as `createUploadRoute`: `authorize({ request })` resolves a
|
|
98
|
+
* structural `{ tree(path, opts) }` handle (the shape of the sandbox SDK's
|
|
99
|
+
* `box.fs.tree`) — no SDK import here. `authorize` also carries the
|
|
100
|
+
* cold-box signal: a sandbox that isn't running yet answers `{ status:
|
|
101
|
+
* 'warming' }` directly, never provisions-and-waits inside this route.
|
|
102
|
+
*/
|
|
103
|
+
|
|
104
|
+
/** One entry from a structural `tree()` scan. Mirrors the sandbox SDK's
|
|
105
|
+
* `FileTreeFile` (`path`, `size`, `mtime`) — `mtime` is unused here so it's
|
|
106
|
+
* omitted from the structural match. */
|
|
107
|
+
interface SandboxTreeFile {
|
|
108
|
+
path: string;
|
|
109
|
+
size: number;
|
|
110
|
+
}
|
|
111
|
+
/** Structural match of the sandbox SDK's `box.fs.tree` result shape
|
|
112
|
+
* (`FileTreeResult`). `stats.truncated` is the only stat this route reads;
|
|
113
|
+
* the rest ride through unread on the real SDK type. */
|
|
114
|
+
interface SandboxTreeResult {
|
|
115
|
+
root: string;
|
|
116
|
+
files: SandboxTreeFile[];
|
|
117
|
+
stats: {
|
|
118
|
+
truncated: boolean;
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/** Structural match of the sandbox SDK's `box.fs` tree surface. */
|
|
122
|
+
interface SandboxFileTreeSource {
|
|
123
|
+
tree(path: string, options?: {
|
|
124
|
+
maxDepth?: number;
|
|
125
|
+
}): Promise<SandboxTreeResult>;
|
|
126
|
+
}
|
|
127
|
+
interface FileIndexReadyResponse {
|
|
128
|
+
status: 'ready';
|
|
129
|
+
/** Workspace-relative entries. Same shape as `FileMention` (`./wire`) so a
|
|
130
|
+
* client can hand a response entry straight to `fileMentionsToParts` /
|
|
131
|
+
* `buildMentionPromptBlock` without remapping. */
|
|
132
|
+
files: FileMention[];
|
|
133
|
+
/** True when either the underlying scan truncated (SDK-side cap) or this
|
|
134
|
+
* route's own `maxEntries` cap trimmed the filtered list. The client
|
|
135
|
+
* should show "showing first N files" rather than imply completeness. */
|
|
136
|
+
truncated: boolean;
|
|
137
|
+
generatedAt: string;
|
|
138
|
+
}
|
|
139
|
+
/** Cold-box answer: no provisioning happened, no files were scanned. The
|
|
140
|
+
* client shows a warming state and retries — this route never blocks on a
|
|
141
|
+
* box coming up. */
|
|
142
|
+
interface FileIndexWarmingResponse {
|
|
143
|
+
status: 'warming';
|
|
144
|
+
}
|
|
145
|
+
type FileIndexResponse = FileIndexReadyResponse | FileIndexWarmingResponse;
|
|
146
|
+
/** Short-TTL cache seam so repeat popover opens in the same session don't
|
|
147
|
+
* re-scan the workspace. Host-provided (e.g. a KV binding); `key` is
|
|
148
|
+
* whatever `authorize` returns as `cacheKey` — this route treats it opaquely. */
|
|
149
|
+
interface FileIndexCache {
|
|
150
|
+
get(key: string): Promise<FileIndexReadyResponse | null> | FileIndexReadyResponse | null;
|
|
151
|
+
put(key: string, value: FileIndexReadyResponse, options?: {
|
|
152
|
+
ttlSeconds?: number;
|
|
153
|
+
}): Promise<void> | void;
|
|
154
|
+
}
|
|
155
|
+
type FileIndexAuthorization = {
|
|
156
|
+
status: 'ready';
|
|
157
|
+
/** Structural sandbox `fs` handle, usually `ensureWorkspaceSandbox(...)` → `box.fs`. */
|
|
158
|
+
fs: SandboxFileTreeSource;
|
|
159
|
+
/** Workspace root to index (e.g. `/home/agent`). */
|
|
160
|
+
root: string;
|
|
161
|
+
/** Extra ignore segments for this request, merged with the route's
|
|
162
|
+
* defaults + `CreateSandboxFileIndexRouteOptions.ignore`. */
|
|
163
|
+
ignore?: string[];
|
|
164
|
+
/** Opaque cache key for the optional cache seam. Omit to skip caching
|
|
165
|
+
* for this request (e.g. a workspace the host chooses not to cache). */
|
|
166
|
+
cacheKey?: string;
|
|
167
|
+
} | {
|
|
168
|
+
status: 'warming';
|
|
169
|
+
} | {
|
|
170
|
+
status: 'denied';
|
|
171
|
+
response: Response;
|
|
172
|
+
};
|
|
173
|
+
interface CreateSandboxFileIndexRouteOptions {
|
|
174
|
+
/** Authenticate the caller, resolve the sandbox `fs` handle, and signal a
|
|
175
|
+
* cold box — never provisions or waits. */
|
|
176
|
+
authorize(args: {
|
|
177
|
+
request: Request;
|
|
178
|
+
}): Promise<FileIndexAuthorization>;
|
|
179
|
+
/** Extra ignore segments beyond the route's defaults (node_modules, .git,
|
|
180
|
+
* dotfiles/dot-dirs, common build dirs). Matched as exact path-segment
|
|
181
|
+
* names, same rule as the defaults. */
|
|
182
|
+
ignore?: string[];
|
|
183
|
+
/** Passed to `fs.tree` as `options.maxDepth`. Default 12. */
|
|
184
|
+
maxDepth?: number;
|
|
185
|
+
/** Hard cap on entries returned after filtering. Default 5000. */
|
|
186
|
+
maxEntries?: number;
|
|
187
|
+
/** Optional host-provided cache seam. */
|
|
188
|
+
cache?: FileIndexCache;
|
|
189
|
+
/** Cache TTL in seconds when `cache` is set. Default 20. */
|
|
190
|
+
cacheTtlSeconds?: number;
|
|
191
|
+
}
|
|
192
|
+
declare function createSandboxFileIndexRoute(options: CreateSandboxFileIndexRouteOptions): (request: Request) => Promise<Response>;
|
|
193
|
+
|
|
194
|
+
export { type ChatTurnRequestPayload as C, type FileIndexAuthorization as F, INLINE_PARTS_MAX_BYTES as I, type SandboxFileTreeSource as S, type ChatTurnPartInput as a, type ChatTurnFilePartInput as b, ChatTurnInputError as c, type ChatTurnTextPartInput as d, type CreateSandboxFileIndexRouteOptions as e, type FileIndexCache as f, type FileIndexReadyResponse as g, type FileIndexResponse as h, type FileIndexWarmingResponse as i, type FileMention as j, type FileMentionsToPartsOptions as k, type SandboxTreeFile as l, type SandboxTreeResult as m, assertPromptPartsWithinCap as n, buildMentionPromptBlock as o, chatTurnRequestInit as p, createSandboxFileIndexRoute as q, fileMentionsToParts as r, mediaTypeForMentionPath as s, parseChatTurnParts as t, promptPartsByteSize as u };
|