zidane 5.8.5 → 5.9.2
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/README.md +3 -1
- package/dist/{agent-CL4nT5Ti.d.ts → agent-CDFbxbHd.d.ts} +46 -15
- package/dist/agent-CDFbxbHd.d.ts.map +1 -0
- package/dist/chat/pure.d.ts +3 -3
- package/dist/chat.d.ts +6 -6
- package/dist/chat.js +2 -2
- package/dist/contexts/docker.d.ts +1 -1
- package/dist/contexts/docker.js +11 -0
- package/dist/contexts/docker.js.map +1 -1
- package/dist/contexts.d.ts +3 -3
- package/dist/eval.d.ts +2 -0
- package/dist/eval.js +1323 -0
- package/dist/eval.js.map +1 -0
- package/dist/{headless-c7MDO-iF.js → headless-C596K-Lk.js} +3 -3
- package/dist/{headless-c7MDO-iF.js.map → headless-C596K-Lk.js.map} +1 -1
- package/dist/headless.d.ts +1 -1
- package/dist/headless.js +1 -1
- package/dist/{index-CZOwAJIX.d.ts → index-ClYUGpmF.d.ts} +2 -2
- package/dist/{index-CZOwAJIX.d.ts.map → index-ClYUGpmF.d.ts.map} +1 -1
- package/dist/{index-DtLfTUXt.d.ts → index-DWw_PtJH.d.ts} +3 -3
- package/dist/{index-DtLfTUXt.d.ts.map → index-DWw_PtJH.d.ts.map} +1 -1
- package/dist/{index-BDMVtgHD.d.ts → index-D_i2Nhts.d.ts} +446 -4
- package/dist/index-D_i2Nhts.d.ts.map +1 -0
- package/dist/index.d.ts +6 -6
- package/dist/index.js +7 -6
- package/dist/index.js.map +1 -1
- package/dist/{login-DYQ6LgLP.js → login-Ujwd1HEb.js} +2 -2
- package/dist/{login-DYQ6LgLP.js.map → login-Ujwd1HEb.js.map} +1 -1
- package/dist/mcp.d.ts +1 -1
- package/dist/{presets-6SoIBrzL.js → presets-ga6dMRVd.js} +2 -2
- package/dist/{presets-6SoIBrzL.js.map → presets-ga6dMRVd.js.map} +1 -1
- package/dist/presets.d.ts +2 -2
- package/dist/presets.js +1 -1
- package/dist/{providers-ByITfqRA.js → providers-CezC9my7.js} +29 -3
- package/dist/providers-CezC9my7.js.map +1 -0
- package/dist/providers.d.ts +1 -1
- package/dist/providers.js +1 -1
- package/dist/restate.d.ts +67 -4
- package/dist/restate.d.ts.map +1 -1
- package/dist/restate.js +226 -25
- package/dist/restate.js.map +1 -1
- package/dist/session/sqlite.d.ts +1 -1
- package/dist/session.d.ts +1 -1
- package/dist/skills.d.ts +2 -2
- package/dist/{tool-formatters-D-aWpu2N.d.ts → tool-formatters-B3fSafpr.d.ts} +2 -2
- package/dist/{tool-formatters-D-aWpu2N.d.ts.map → tool-formatters-B3fSafpr.d.ts.map} +1 -1
- package/dist/tools/fetch-url.d.ts +1 -1
- package/dist/tools/web-search.d.ts +1 -1
- package/dist/{tools-DOUtulS5.js → tools-CAdllmWO.js} +402 -9
- package/dist/tools-CAdllmWO.js.map +1 -0
- package/dist/tools.d.ts +2 -2
- package/dist/tools.js +1 -1
- package/dist/{transcript-anchors-DYsnGyel.d.ts → transcript-anchors-BHVVVhR0.d.ts} +4 -4
- package/dist/{transcript-anchors-DYsnGyel.d.ts.map → transcript-anchors-BHVVVhR0.d.ts.map} +1 -1
- package/dist/{transcript-anchors-B2h3qt3S.js → transcript-anchors-DFknQ4ew.js} +4 -4
- package/dist/{transcript-anchors-B2h3qt3S.js.map → transcript-anchors-DFknQ4ew.js.map} +1 -1
- package/dist/tui.d.ts +3 -3
- package/dist/tui.js +3 -3
- package/dist/{turn-operations-D-fypW6K.d.ts → turn-operations-BMxugnqg.d.ts} +3 -3
- package/dist/{turn-operations-D-fypW6K.d.ts.map → turn-operations-BMxugnqg.d.ts.map} +1 -1
- package/dist/types-BPw_i5vb.js.map +1 -1
- package/dist/{types-CEAMIUXw.d.ts → types-CB1J-DQw.d.ts} +14 -2
- package/dist/types-CB1J-DQw.d.ts.map +1 -0
- package/dist/types.d.ts +4 -4
- package/docs/RESTATE.md +75 -19
- package/docs/SKILL.md +2 -2
- package/package.json +15 -3
- package/scripts/eval.ts +140 -0
- package/dist/agent-CL4nT5Ti.d.ts.map +0 -1
- package/dist/index-BDMVtgHD.d.ts.map +0 -1
- package/dist/providers-ByITfqRA.js.map +0 -1
- package/dist/tools-DOUtulS5.js.map +0 -1
- package/dist/types-CEAMIUXw.d.ts.map +0 -1
package/dist/restate.js
CHANGED
|
@@ -1,3 +1,41 @@
|
|
|
1
|
+
//#region src/restate/errors.ts
|
|
2
|
+
/**
|
|
3
|
+
* Restate control-flow errors must escape the agent loop. If they are turned
|
|
4
|
+
* into model-visible tool results, the runtime can retry/suspend incorrectly.
|
|
5
|
+
*
|
|
6
|
+
* Kept structural so `zidane/restate` does not need to import the SDK at
|
|
7
|
+
* runtime just to recognize the common error shapes.
|
|
8
|
+
*/
|
|
9
|
+
function shouldRethrowRestateControlError(error) {
|
|
10
|
+
if (!(error instanceof Error)) return false;
|
|
11
|
+
const codeValue = Reflect.get(error, "code");
|
|
12
|
+
if ((typeof codeValue === "number" ? codeValue : void 0) === 599) return true;
|
|
13
|
+
const name = error.name;
|
|
14
|
+
if (name === "TerminalError" || name === "TimeoutError" || name === "CancelledError" || name === "SuspendedError") return true;
|
|
15
|
+
const ctorName = error.constructor?.name;
|
|
16
|
+
const serializedCtorNameValue = Reflect.get(error, "constructorName");
|
|
17
|
+
const serializedCtorName = typeof serializedCtorNameValue === "string" ? serializedCtorNameValue : void 0;
|
|
18
|
+
if (ctorName === "TerminalError" || ctorName === "TimeoutError" || ctorName === "CancelledError" || ctorName === "SuspendedError" || serializedCtorName === "TerminalError" || serializedCtorName === "TimeoutError" || serializedCtorName === "CancelledError" || serializedCtorName === "SuspendedError") return true;
|
|
19
|
+
return typeof name === "string" && name.toLowerCase().includes("suspend");
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/restate/behavior.ts
|
|
23
|
+
/**
|
|
24
|
+
* Conservative behavior defaults for agents running inside Restate.
|
|
25
|
+
*
|
|
26
|
+
* The helper is opt-in and returns a plain AgentBehavior object, so callers can
|
|
27
|
+
* spread or override it without changing non-Restate harness defaults.
|
|
28
|
+
*/
|
|
29
|
+
function restateBehavior(overrides = {}) {
|
|
30
|
+
return {
|
|
31
|
+
maxConcurrentTools: 1,
|
|
32
|
+
disableBackgroundTasks: true,
|
|
33
|
+
cache: true,
|
|
34
|
+
shouldRethrowToolError: shouldRethrowRestateControlError,
|
|
35
|
+
...overrides
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
1
39
|
//#region src/restate/clock.ts
|
|
2
40
|
/**
|
|
3
41
|
* Wrap a Restate context's `date.now()` + `rand.uuidv4()` into the
|
|
@@ -14,6 +52,60 @@ function restateClock(ctx) {
|
|
|
14
52
|
};
|
|
15
53
|
}
|
|
16
54
|
//#endregion
|
|
55
|
+
//#region src/restate/parallel.ts
|
|
56
|
+
/**
|
|
57
|
+
* Tool batch scheduler for Restate-backed agents.
|
|
58
|
+
*
|
|
59
|
+
* It preserves unsafe-tool barriers and emits results in model submission
|
|
60
|
+
* order. Safe fleets are started in submission order, capped by
|
|
61
|
+
* `maxConcurrentTools`, and joined via the supplied durable `all()`.
|
|
62
|
+
*/
|
|
63
|
+
function restateToolBatchExecutor(options) {
|
|
64
|
+
return async (ctx) => {
|
|
65
|
+
const results = [];
|
|
66
|
+
const { toolCalls } = ctx;
|
|
67
|
+
const fillRemaining = (from, factory) => {
|
|
68
|
+
for (let i = from; i < toolCalls.length; i++) results[i] = factory(i);
|
|
69
|
+
return results;
|
|
70
|
+
};
|
|
71
|
+
for (let i = 0; i < toolCalls.length;) {
|
|
72
|
+
if (ctx.signal.aborted) return fillRemaining(i, ctx.interruptedResult);
|
|
73
|
+
if (ctx.steeringQueue.length > 0) return fillRemaining(i, ctx.skippedResult);
|
|
74
|
+
if (!ctx.isConcurrencySafe(i)) {
|
|
75
|
+
results[i] = await ctx.execute(i);
|
|
76
|
+
i += 1;
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const start = i;
|
|
80
|
+
const fleet = [];
|
|
81
|
+
while (i < toolCalls.length && ctx.isConcurrencySafe(i) && fleet.length < ctx.maxConcurrentTools) {
|
|
82
|
+
fleet.push(i);
|
|
83
|
+
i += 1;
|
|
84
|
+
}
|
|
85
|
+
const fleetResults = fleet.every((index) => ctx.canExecuteDurably(index)) ? await ctx.executeDurable(fleet, async (values) => {
|
|
86
|
+
return await options.promises.all(values);
|
|
87
|
+
}) : await executeSequential(ctx, fleet);
|
|
88
|
+
for (let offset = 0; offset < fleetResults.length; offset++) results[start + offset] = fleetResults[offset];
|
|
89
|
+
}
|
|
90
|
+
return results;
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
async function executeSequential(ctx, indices) {
|
|
94
|
+
const results = [];
|
|
95
|
+
for (const index of indices) {
|
|
96
|
+
if (ctx.signal.aborted) {
|
|
97
|
+
results.push(ctx.interruptedResult(index));
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (ctx.steeringQueue.length > 0) {
|
|
101
|
+
results.push(ctx.skippedResult(index));
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
results.push(await ctx.execute(index));
|
|
105
|
+
}
|
|
106
|
+
return results;
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
17
109
|
//#region src/restate/provider.ts
|
|
18
110
|
/**
|
|
19
111
|
* Wrap a Zidane `Provider` so its `stream()` method journals each turn's
|
|
@@ -29,10 +121,20 @@ function restateProvider(inner, ctx, options = {}) {
|
|
|
29
121
|
...inner,
|
|
30
122
|
stream(streamOpts, callbacks) {
|
|
31
123
|
seq += 1;
|
|
32
|
-
|
|
124
|
+
const durableCallbacks = options.streamCallbacks === "suppress" ? suppressStreamingCallbacks(callbacks) : callbacks;
|
|
125
|
+
return ctx.run(nameFor(seq, streamOpts), () => inner.stream(streamOpts, durableCallbacks), runOpts);
|
|
33
126
|
}
|
|
34
127
|
};
|
|
35
128
|
}
|
|
129
|
+
function suppressStreamingCallbacks(callbacks) {
|
|
130
|
+
return {
|
|
131
|
+
...callbacks,
|
|
132
|
+
onText: () => {},
|
|
133
|
+
onThinking: void 0,
|
|
134
|
+
onServerToolUse: void 0,
|
|
135
|
+
onServerToolResult: void 0
|
|
136
|
+
};
|
|
137
|
+
}
|
|
36
138
|
//#endregion
|
|
37
139
|
//#region src/restate/session.ts
|
|
38
140
|
const KEY_DATA = "session-data";
|
|
@@ -47,22 +149,36 @@ const KEY_RUNS = "session-runs";
|
|
|
47
149
|
* virtual-object key per session and the contract holds.
|
|
48
150
|
*/
|
|
49
151
|
function restateSessionStore(ctx) {
|
|
152
|
+
let nextTurnSeq;
|
|
153
|
+
async function generateTurnId() {
|
|
154
|
+
if (nextTurnSeq === void 0) nextTurnSeq = (await ctx.get(KEY_TURNS) ?? []).length;
|
|
155
|
+
nextTurnSeq += 1;
|
|
156
|
+
return `turn_${nextTurnSeq}`;
|
|
157
|
+
}
|
|
50
158
|
return {
|
|
51
159
|
/**
|
|
52
|
-
* Turn
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* though `AgentClock.randomUUID` is wired correctly — the loop
|
|
57
|
-
* calls `session?.generateTurnId() ?? clock.randomUUID()`, and a
|
|
58
|
-
* session that always returns a value short-circuits the fallback.
|
|
160
|
+
* Turn ids are deterministic from the persisted turn count. Random ids
|
|
161
|
+
* are replay-stable only when the whole handler replays from the same
|
|
162
|
+
* point; restarting from an arbitrary journal step can shift the RNG
|
|
163
|
+
* sequence before a state write.
|
|
59
164
|
*/
|
|
60
|
-
generateTurnId
|
|
165
|
+
generateTurnId,
|
|
61
166
|
async load(_sessionId) {
|
|
62
167
|
const header = await ctx.get(KEY_DATA);
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
|
|
168
|
+
const turns = sanitizeTurnsForState(await ctx.get(KEY_TURNS) ?? []);
|
|
169
|
+
const runs = sanitizeRunsForState(await ctx.get(KEY_RUNS) ?? []);
|
|
170
|
+
if (!header) {
|
|
171
|
+
if (turns.length === 0 && runs.length === 0) return null;
|
|
172
|
+
return {
|
|
173
|
+
id: _sessionId,
|
|
174
|
+
turns,
|
|
175
|
+
runs,
|
|
176
|
+
status: inferStatus(runs),
|
|
177
|
+
metadata: {},
|
|
178
|
+
createdAt: inferCreatedAt(turns, runs),
|
|
179
|
+
updatedAt: inferUpdatedAt(turns, runs)
|
|
180
|
+
};
|
|
181
|
+
}
|
|
66
182
|
return {
|
|
67
183
|
...header,
|
|
68
184
|
turns,
|
|
@@ -72,8 +188,8 @@ function restateSessionStore(ctx) {
|
|
|
72
188
|
async save(session) {
|
|
73
189
|
const { turns, runs, ...header } = session;
|
|
74
190
|
ctx.set(KEY_DATA, header);
|
|
75
|
-
ctx.set(KEY_TURNS, turns);
|
|
76
|
-
ctx.set(KEY_RUNS, runs);
|
|
191
|
+
ctx.set(KEY_TURNS, sanitizeTurnsForState(turns));
|
|
192
|
+
ctx.set(KEY_RUNS, sanitizeRunsForState(runs));
|
|
77
193
|
},
|
|
78
194
|
async delete(_sessionId) {
|
|
79
195
|
ctx.clear(KEY_DATA);
|
|
@@ -89,32 +205,88 @@ function restateSessionStore(ctx) {
|
|
|
89
205
|
return [];
|
|
90
206
|
},
|
|
91
207
|
async appendTurns(_sessionId, turns) {
|
|
92
|
-
const existing = await ctx.get(KEY_TURNS) ?? [];
|
|
93
|
-
ctx.set(KEY_TURNS, [...existing, ...turns]);
|
|
208
|
+
const existing = sanitizeTurnsForState(await ctx.get(KEY_TURNS) ?? []);
|
|
209
|
+
ctx.set(KEY_TURNS, [...existing, ...sanitizeTurnsForState(turns)]);
|
|
94
210
|
},
|
|
95
211
|
async getTurns(_sessionId, from = 0, limit) {
|
|
96
|
-
return (await ctx.get(KEY_TURNS) ?? []).slice(from, limit !== void 0 ? from + limit : void 0);
|
|
212
|
+
return sanitizeTurnsForState(await ctx.get(KEY_TURNS) ?? []).slice(from, limit !== void 0 ? from + limit : void 0);
|
|
97
213
|
},
|
|
98
214
|
async updateRun(_sessionId, run) {
|
|
99
|
-
const runs = await ctx.get(KEY_RUNS) ?? [];
|
|
215
|
+
const runs = sanitizeRunsForState(await ctx.get(KEY_RUNS) ?? []);
|
|
100
216
|
const idx = runs.findIndex((r) => r.id === run.id);
|
|
101
217
|
const next = [...runs];
|
|
102
|
-
if (idx >= 0) next[idx] = run;
|
|
103
|
-
else next.push(run);
|
|
218
|
+
if (idx >= 0) next[idx] = sanitizeRunForState(run);
|
|
219
|
+
else next.push(sanitizeRunForState(run));
|
|
104
220
|
ctx.set(KEY_RUNS, next);
|
|
105
221
|
},
|
|
106
222
|
async updateStatus(_sessionId, status) {
|
|
107
223
|
const header = await ctx.get(KEY_DATA);
|
|
224
|
+
const now = await ctx.date.now();
|
|
108
225
|
if (header) ctx.set(KEY_DATA, {
|
|
109
226
|
...header,
|
|
110
227
|
status,
|
|
111
|
-
updatedAt:
|
|
228
|
+
updatedAt: now
|
|
229
|
+
});
|
|
230
|
+
else ctx.set(KEY_DATA, {
|
|
231
|
+
id: _sessionId,
|
|
232
|
+
status,
|
|
233
|
+
metadata: {},
|
|
234
|
+
createdAt: now,
|
|
235
|
+
updatedAt: now
|
|
112
236
|
});
|
|
113
237
|
}
|
|
114
238
|
};
|
|
115
239
|
}
|
|
240
|
+
function sanitizeTurnsForState(turns) {
|
|
241
|
+
return turns.map(sanitizeTurnForState);
|
|
242
|
+
}
|
|
243
|
+
function sanitizeTurnForState(turn) {
|
|
244
|
+
if (!turn.usage || turn.usage.timeToFirstTokenMs === void 0) return turn;
|
|
245
|
+
const { timeToFirstTokenMs: _timeToFirstTokenMs, ...usage } = turn.usage;
|
|
246
|
+
return {
|
|
247
|
+
...turn,
|
|
248
|
+
usage
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
function sanitizeRunsForState(runs) {
|
|
252
|
+
return runs.map(sanitizeRunForState);
|
|
253
|
+
}
|
|
254
|
+
function sanitizeRunForState(run) {
|
|
255
|
+
if (!run.turnUsage?.some((usage) => usage.timeToFirstTokenMs !== void 0)) return run;
|
|
256
|
+
return {
|
|
257
|
+
...run,
|
|
258
|
+
turnUsage: run.turnUsage.map((usage) => {
|
|
259
|
+
if (usage.timeToFirstTokenMs === void 0) return usage;
|
|
260
|
+
const { timeToFirstTokenMs: _timeToFirstTokenMs, ...stableUsage } = usage;
|
|
261
|
+
return stableUsage;
|
|
262
|
+
})
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
function inferStatus(runs) {
|
|
266
|
+
if (runs.some((run) => run.status === "running")) return "running";
|
|
267
|
+
if (runs.some((run) => run.status === "error")) return "error";
|
|
268
|
+
if (runs.some((run) => run.status === "completed")) return "completed";
|
|
269
|
+
return "idle";
|
|
270
|
+
}
|
|
271
|
+
function inferCreatedAt(turns, runs) {
|
|
272
|
+
return minDefined([...turns.map((turn) => turn.createdAt), ...runs.map((run) => run.startedAt)]) ?? 0;
|
|
273
|
+
}
|
|
274
|
+
function inferUpdatedAt(turns, runs) {
|
|
275
|
+
return maxDefined([...turns.map((turn) => turn.createdAt), ...runs.map((run) => run.endedAt ?? run.startedAt)]) ?? inferCreatedAt(turns, runs);
|
|
276
|
+
}
|
|
277
|
+
function minDefined(values) {
|
|
278
|
+
let min;
|
|
279
|
+
for (const value of values) if (min === void 0 || value < min) min = value;
|
|
280
|
+
return min;
|
|
281
|
+
}
|
|
282
|
+
function maxDefined(values) {
|
|
283
|
+
let max;
|
|
284
|
+
for (const value of values) if (max === void 0 || value > max) max = value;
|
|
285
|
+
return max;
|
|
286
|
+
}
|
|
116
287
|
//#endregion
|
|
117
288
|
//#region src/restate/tool.ts
|
|
289
|
+
const SHELL_BACKGROUND_DISABLED_MESSAGE = "shell error: background mode is disabled for Restate-backed agents. Fall back to foreground (drop `run_in_background`).";
|
|
118
290
|
/**
|
|
119
291
|
* Wrap a single `ToolDef` so its `execute` runs inside `ctx.run`. The
|
|
120
292
|
* tool's `spec` and `isConcurrencySafe` pass through unchanged.
|
|
@@ -123,15 +295,44 @@ function restateTool(inner, ctx, options = {}) {
|
|
|
123
295
|
const runOpts = options.runOptions ?? { maxRetryAttempts: 1 };
|
|
124
296
|
const nameFor = options.entryName ?? ((seq, name) => `tool-${name}-${seq}`);
|
|
125
297
|
const canonicalName = inner.spec.name;
|
|
298
|
+
const shellBackgroundDisabled = (options.disableShellBackground ?? true) && canonicalName === "shell";
|
|
126
299
|
let seq = 0;
|
|
300
|
+
const executeDurably = (input, toolCtx) => {
|
|
301
|
+
seq += 1;
|
|
302
|
+
return ctx.run(nameFor(seq, canonicalName, input), () => {
|
|
303
|
+
if (shellBackgroundDisabled && input.run_in_background === true) return SHELL_BACKGROUND_DISABLED_MESSAGE;
|
|
304
|
+
return inner.execute(input, toolCtx);
|
|
305
|
+
}, runOpts);
|
|
306
|
+
};
|
|
127
307
|
return {
|
|
128
308
|
...inner,
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
309
|
+
spec: shellBackgroundDisabled ? withoutShellBackgroundInput(inner.spec) : inner.spec,
|
|
310
|
+
execute: executeDurably,
|
|
311
|
+
durableExecute: executeDurably
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
function withoutShellBackgroundInput(spec) {
|
|
315
|
+
const inputSchema = spec.inputSchema;
|
|
316
|
+
const properties = isRecord(inputSchema.properties) ? inputSchema.properties : void 0;
|
|
317
|
+
if (!properties || !Object.hasOwn(properties, "run_in_background")) return spec;
|
|
318
|
+
const { run_in_background: _runInBackground, ...nextProperties } = properties;
|
|
319
|
+
const required = Array.isArray(inputSchema.required) ? inputSchema.required.filter((name) => name !== "run_in_background") : inputSchema.required;
|
|
320
|
+
return {
|
|
321
|
+
...spec,
|
|
322
|
+
description: stripShellBackgroundDescription(spec.description),
|
|
323
|
+
inputSchema: {
|
|
324
|
+
...inputSchema,
|
|
325
|
+
properties: nextProperties,
|
|
326
|
+
...required !== inputSchema.required ? { required } : {}
|
|
132
327
|
}
|
|
133
328
|
};
|
|
134
329
|
}
|
|
330
|
+
function stripShellBackgroundDescription(description) {
|
|
331
|
+
return description.split("\n").filter((line) => !line.includes("run_in_background") && !line.includes("<task-notification>") && !line.includes("background task")).join("\n").replace(/\n{3,}/g, "\n\n").trim();
|
|
332
|
+
}
|
|
333
|
+
function isRecord(value) {
|
|
334
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
335
|
+
}
|
|
135
336
|
/**
|
|
136
337
|
* Wrap an entire tool map at once — convenience for the common case of
|
|
137
338
|
* "journal every tool the agent has". Pass-through for tools whose
|
|
@@ -147,6 +348,6 @@ function wrapAgentTools(tools, ctx, opts = {}) {
|
|
|
147
348
|
return wrapped;
|
|
148
349
|
}
|
|
149
350
|
//#endregion
|
|
150
|
-
export { restateClock, restateProvider, restateSessionStore, restateTool, wrapAgentTools };
|
|
351
|
+
export { restateBehavior, restateClock, restateProvider, restateSessionStore, restateTool, restateToolBatchExecutor, shouldRethrowRestateControlError, wrapAgentTools };
|
|
151
352
|
|
|
152
353
|
//# sourceMappingURL=restate.js.map
|
package/dist/restate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restate.js","names":[],"sources":["../src/restate/clock.ts","../src/restate/provider.ts","../src/restate/session.ts","../src/restate/tool.ts"],"sourcesContent":["/**\n * Restate-backed {@link AgentClock} — journals `now()` + `randomUUID()` so\n * every `SessionTurn.id` / `SessionTurn.createdAt` / `runId` / synthetic\n * turn id stays byte-identical across replays of the same invocation.\n *\n * Pass to `agent.run({ clock: restateClock(ctx) })` or bake it into\n * `createAgent({ clock: restateClock(ctx) })` for the duration of a\n * handler invocation. The clock holds a reference to `ctx`; do not reuse\n * a clock instance across invocations.\n */\n\nimport type { AgentClock } from '../types'\nimport type { RestateContextLike } from './types'\n\n/**\n * Wrap a Restate context's `date.now()` + `rand.uuidv4()` into the\n * {@link AgentClock} shape Zidane consumes for journaled metadata.\n *\n * The returned clock is a thin live view onto `ctx` — each call hits\n * the SDK afresh. No caching, no closure-captured values. Restate's\n * journal handles determinism on its end.\n */\nexport function restateClock(ctx: RestateContextLike): AgentClock {\n return {\n now: () => ctx.date.now(),\n randomUUID: () => ctx.rand.uuidv4(),\n }\n}\n","/**\n * Restate-backed Provider wrapper.\n *\n * Wraps `Provider.stream` so every assistant turn (the LLM call as a\n * whole) is journaled. The model is invoked once per turn — the live\n * stream still fires `onText` / `onThinking` callbacks for UX during the\n * original execution. On replay, `ctx.run` returns the journaled\n * `TurnResult` immediately and the inner provider is NEVER re-invoked →\n * no duplicate billed tokens, no duplicate stream chunks.\n *\n * Replay caveat: stream callbacks don't re-fire on replay. Consumers\n * that paint live UI from `stream:text` should reconstruct transcripts\n * from `session.turns` via `eventsFromTurns` (zidane/chat) instead of\n * relying on hook re-emission. The chat layer already does this.\n *\n * Journal-entry naming: a monotonic per-wrapper counter (`llm-call-1`,\n * `llm-call-2`, …). One wrapper instance per Restate handler invocation\n * resets the counter; Restate's journal is invocation-scoped so names\n * don't need to be globally unique. The counter ticks the same way on\n * replay because the wrapper is constructed fresh each attempt.\n */\n\nimport type { Provider, StreamCallbacks, StreamOptions, TurnResult } from '../providers'\nimport type { RestateContextLike, RestateRunOptions } from './types'\n\nexport interface RestateProviderOptions {\n /**\n * `ctx.run` options forwarded on every wrapped stream call. Defaults\n * to `{ maxRetryAttempts: 3 }` — provider transients (rate limits,\n * 5xx, connection resets) get retried inside the journal entry. Once\n * the cap is reached the failure becomes terminal and surfaces\n * through the loop's normal `AgentProviderError` path.\n */\n runOptions?: RestateRunOptions\n /**\n * Override the journal-entry name. Receives the 1-indexed sequence\n * number for this wrapper instance and the `StreamOptions` of the\n * call. Default: `llm-call-<n>`. Override to inject extra structure\n * (e.g. `${agentName}/llm-call-${n}`) when multiple agents share a\n * service.\n */\n entryName?: (seq: number, opts: StreamOptions) => string\n}\n\n/**\n * Wrap a Zidane `Provider` so its `stream()` method journals each turn's\n * response inside `ctx.run`. All other Provider methods (`formatTools`,\n * `userMessage`, `toolResultsMessage`, `classifyError`, …) pass through\n * unchanged — they're pure functions over already-deterministic inputs.\n */\nexport function restateProvider(\n inner: Provider,\n ctx: RestateContextLike,\n options: RestateProviderOptions = {},\n): Provider {\n const runOpts: RestateRunOptions = options.runOptions ?? { maxRetryAttempts: 3 }\n const nameFor = options.entryName ?? ((seq: number) => `llm-call-${seq}`)\n let seq = 0\n\n return {\n ...inner,\n stream(streamOpts: StreamOptions, callbacks: StreamCallbacks): Promise<TurnResult> {\n seq += 1\n return ctx.run<TurnResult>(\n nameFor(seq, streamOpts),\n () => inner.stream(streamOpts, callbacks),\n runOpts,\n )\n },\n }\n}\n","/**\n * Restate-backed `SessionStore` — turn / run state lives in the bound\n * virtual object's K/V state instead of SQLite / file / remote HTTP.\n *\n * Trade-offs vs. journal-only replay\n * ----------------------------------\n * If you only care about durable execution within ONE invocation,\n * skip this — the journaled `ctx.run` entries (LLM calls, tool\n * executions) are enough to replay the loop to byte-identical state\n * after a crash. The in-memory `createMemoryStore()` is the right\n * choice; turns rematerialize from the journal each replay.\n *\n * Pick this store when EXTERNAL consumers (TUI, web GUI, support\n * tooling) need to read a session's history WITHOUT re-entering the\n * agent handler. Virtual-object state is exposed via the SDK's read\n * APIs (`ctx.get` from another handler, `restate-cli`, the Restate\n * web UI) — same data, different access path. The journal is\n * invocation-local; this state is the externally-visible projection\n * of it.\n *\n * Storage layout\n * --------------\n * One virtual-object key per session, three K/V slots:\n *\n * `data` → `SessionData` minus the `turns` array (small header)\n * `turns` → `SessionTurn[]` (the conversation history)\n * `runs` → `SessionRun[]` (run lifecycle records)\n *\n * Splitting `turns` / `runs` out keeps the header light for `load()` —\n * a handler that only needs metadata doesn't pull the full history.\n *\n * Listing / discovery\n * -------------------\n * `list()` returns `[]` and `delete()` no-ops — virtual objects don't\n * expose cross-key enumeration. Use a separate index handler if you\n * need it (one virtual object per `projectRoot` that maintains an\n * indexed list of session ids; this store doesn't own that concern).\n * `generateSessionId` is omitted so the agent falls back to its\n * default UUID generator — for a session bound 1:1 to a virtual-\n * object key, pass `id: ctx.key` to `createSession()` instead and\n * skip ID generation entirely.\n */\n\nimport type { SessionData, SessionRun, SessionStore } from '../session'\nimport type { SessionTurn } from '../types'\nimport type { RestateObjectContextLike } from './types'\n\nconst KEY_DATA = 'session-data'\nconst KEY_TURNS = 'session-turns'\nconst KEY_RUNS = 'session-runs'\n\n/**\n * Construct a `SessionStore` backed by the bound virtual-object's K/V\n * state. The store is single-tenant — every method ignores the\n * `sessionId` argument because the virtual object is already keyed by\n * `ctx.key`. Calling `appendTurns('other-id', …)` writes to the\n * CURRENT object's state, not the one named in the argument. Bind one\n * virtual-object key per session and the contract holds.\n */\nexport function restateSessionStore(ctx: RestateObjectContextLike): SessionStore {\n return {\n /**\n * Turn-id mint backed by Restate's seeded RNG. Critical: without\n * this, `Session.generateTurnId` falls through to\n * `crypto.randomUUID()` (see `src/session/index.ts`), so every\n * assistant / tool-results turn id drifts across replays even\n * though `AgentClock.randomUUID` is wired correctly — the loop\n * calls `session?.generateTurnId() ?? clock.randomUUID()`, and a\n * session that always returns a value short-circuits the fallback.\n */\n generateTurnId: () => ctx.rand.uuidv4(),\n\n async load(_sessionId: string): Promise<SessionData | null> {\n const header = await ctx.get<Omit<SessionData, 'turns' | 'runs'>>(KEY_DATA)\n if (!header)\n return null\n const turns = (await ctx.get<SessionTurn[]>(KEY_TURNS)) ?? []\n const runs = (await ctx.get<SessionRun[]>(KEY_RUNS)) ?? []\n return { ...header, turns, runs }\n },\n\n async save(session: SessionData): Promise<void> {\n const { turns, runs, ...header } = session\n ctx.set(KEY_DATA, header)\n ctx.set(KEY_TURNS, turns)\n ctx.set(KEY_RUNS, runs)\n },\n\n async delete(_sessionId: string): Promise<void> {\n ctx.clear(KEY_DATA)\n ctx.clear(KEY_TURNS)\n ctx.clear(KEY_RUNS)\n },\n\n /**\n * Always empty — virtual objects don't support cross-key\n * enumeration. Maintain a separate index handler if discovery\n * matters.\n */\n async list(): Promise<string[]> {\n return []\n },\n\n async appendTurns(_sessionId: string, turns: SessionTurn[]): Promise<void> {\n const existing = (await ctx.get<SessionTurn[]>(KEY_TURNS)) ?? []\n ctx.set(KEY_TURNS, [...existing, ...turns])\n },\n\n async getTurns(_sessionId: string, from = 0, limit?: number): Promise<SessionTurn[]> {\n const turns = (await ctx.get<SessionTurn[]>(KEY_TURNS)) ?? []\n return turns.slice(from, limit !== undefined ? from + limit : undefined)\n },\n\n async updateRun(_sessionId: string, run: SessionRun): Promise<void> {\n const runs = (await ctx.get<SessionRun[]>(KEY_RUNS)) ?? []\n const idx = runs.findIndex(r => r.id === run.id)\n const next = [...runs]\n if (idx >= 0)\n next[idx] = run\n else\n next.push(run)\n ctx.set(KEY_RUNS, next)\n },\n\n async updateStatus(_sessionId: string, status: SessionData['status']): Promise<void> {\n const header = await ctx.get<Omit<SessionData, 'turns' | 'runs'>>(KEY_DATA)\n if (header) {\n ctx.set(KEY_DATA, { ...header, status, updatedAt: await ctx.date.now() })\n }\n },\n }\n}\n","/**\n * Restate-backed tool wrappers.\n *\n * Wraps `ToolDef.execute` so every tool invocation is journaled. The\n * tool body runs once on the original execution; on replay `ctx.run`\n * returns the journaled result without re-executing. Side effects\n * (`write_file` to disk, network POSTs in custom tools) happen\n * **exactly once** across crashes + retries — the entire reason for\n * pairing Zidane with Restate.\n *\n * `tool:gate`, `tool:transform`, `tool:after` hooks fire OUTSIDE the\n * journaled boundary, so they re-execute on replay. Built-in handlers\n * are deterministic given the journaled input + output (truncation,\n * image-stripping, `<edit-outcomes>` merge — all pure). Consumer hooks\n * that hit external services should themselves wrap side effects in\n * `ctx.run` so the substitution / annotation is replay-stable.\n *\n * `isConcurrencySafe` is preserved — Restate's per-key serialization\n * doesn't preclude in-handler parallelism. The loop's scheduler still\n * fans out safe tools up to `behavior.maxConcurrentTools`, each call\n * lands in its own journal entry. Order-of-journal-completion does NOT\n * affect replay correctness: Restate journals by call-site name, not\n * by completion order.\n */\n\nimport type { ToolDef } from '../tools/types'\nimport type { RestateContextLike, RestateRunOptions } from './types'\n\nexport interface RestateToolOptions {\n /**\n * `ctx.run` options forwarded on every wrapped tool call. Defaults to\n * `{ maxRetryAttempts: 1 }` — tool errors are typically deterministic\n * (validation failures, missing files) so blind retries waste budget.\n * Override per-tool for network-heavy custom tools that benefit from\n * SDK-level retries.\n */\n runOptions?: RestateRunOptions\n /**\n * Override the journal-entry name. Receives the canonical tool name\n * and the call's input. Default: `tool-<name>-<seq>` where `<seq>` is\n * a per-wrapper monotonic counter. Override to inject the model's\n * `callId` (read it off `ToolContext.callId` inside `execute` if you\n * need an LLM-visible key — but the default counter is sufficient\n * for journal correctness).\n */\n entryName?: (seq: number, name: string, input: Record<string, unknown>) => string\n}\n\n/**\n * Wrap a single `ToolDef` so its `execute` runs inside `ctx.run`. The\n * tool's `spec` and `isConcurrencySafe` pass through unchanged.\n */\nexport function restateTool(\n inner: ToolDef,\n ctx: RestateContextLike,\n options: RestateToolOptions = {},\n): ToolDef {\n const runOpts: RestateRunOptions = options.runOptions ?? { maxRetryAttempts: 1 }\n const nameFor = options.entryName ?? ((seq: number, name: string) => `tool-${name}-${seq}`)\n const canonicalName = inner.spec.name\n let seq = 0\n\n return {\n ...inner,\n execute: (input, toolCtx) => {\n seq += 1\n return ctx.run(\n nameFor(seq, canonicalName, input),\n () => inner.execute(input, toolCtx),\n runOpts,\n )\n },\n }\n}\n\n/**\n * Wrap an entire tool map at once — convenience for the common case of\n * \"journal every tool the agent has\". Pass-through for tools whose\n * names are listed in `opts.exclude` (e.g. fully-deterministic local\n * helpers where journaling is pure overhead).\n *\n * The returned map is a fresh object; the input is untouched.\n */\nexport function wrapAgentTools(\n tools: Record<string, ToolDef>,\n ctx: RestateContextLike,\n opts: RestateToolOptions & { exclude?: readonly string[] } = {},\n): Record<string, ToolDef> {\n const excludeSet = new Set(opts.exclude ?? [])\n const wrapped: Record<string, ToolDef> = {}\n for (const [name, def] of Object.entries(tools)) {\n wrapped[name] = excludeSet.has(name) ? def : restateTool(def, ctx, opts)\n }\n return wrapped\n}\n"],"mappings":";;;;;;;;;AAsBA,SAA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AAC;CAC7C,MAAM,UAAmC,CAAC;CAC1C,KAAK,MAAM,CAAC,MAAM,QAAQ,OAAO,QAAQ,KAAK,GAC5C,QAAQ,QAAQ,WAAW,IAAI,IAAI,IAAI,MAAM,YAAY,KAAK,KAAK,IAAI;CAEzE,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"restate.js","names":[],"sources":["../src/restate/errors.ts","../src/restate/behavior.ts","../src/restate/clock.ts","../src/restate/parallel.ts","../src/restate/provider.ts","../src/restate/session.ts","../src/restate/tool.ts"],"sourcesContent":["/**\n * Restate control-flow errors must escape the agent loop. If they are turned\n * into model-visible tool results, the runtime can retry/suspend incorrectly.\n *\n * Kept structural so `zidane/restate` does not need to import the SDK at\n * runtime just to recognize the common error shapes.\n */\nexport function shouldRethrowRestateControlError(error: unknown): boolean {\n if (!(error instanceof Error))\n return false\n\n const codeValue = Reflect.get(error, 'code')\n const code = typeof codeValue === 'number'\n ? codeValue\n : undefined\n if (code === 599)\n return true\n\n const name = error.name\n if (\n name === 'TerminalError'\n || name === 'TimeoutError'\n || name === 'CancelledError'\n || name === 'SuspendedError'\n ) {\n return true\n }\n\n const ctorName = error.constructor?.name\n const serializedCtorNameValue = Reflect.get(error, 'constructorName')\n const serializedCtorName = typeof serializedCtorNameValue === 'string'\n ? serializedCtorNameValue\n : undefined\n if (\n ctorName === 'TerminalError'\n || ctorName === 'TimeoutError'\n || ctorName === 'CancelledError'\n || ctorName === 'SuspendedError'\n || serializedCtorName === 'TerminalError'\n || serializedCtorName === 'TimeoutError'\n || serializedCtorName === 'CancelledError'\n || serializedCtorName === 'SuspendedError'\n ) {\n return true\n }\n\n return typeof name === 'string' && name.toLowerCase().includes('suspend')\n}\n","import type { AgentBehavior } from '../types'\nimport { shouldRethrowRestateControlError } from './errors'\n\n/**\n * Conservative behavior defaults for agents running inside Restate.\n *\n * The helper is opt-in and returns a plain AgentBehavior object, so callers can\n * spread or override it without changing non-Restate harness defaults.\n */\nexport function restateBehavior(overrides: AgentBehavior = {}): AgentBehavior {\n return {\n maxConcurrentTools: 1,\n disableBackgroundTasks: true,\n cache: true,\n shouldRethrowToolError: shouldRethrowRestateControlError,\n ...overrides,\n }\n}\n","/**\n * Restate-backed {@link AgentClock} — journals `now()` + `randomUUID()` so\n * `SessionTurn.createdAt`, `runId`, and fallback / synthetic turn ids stay\n * byte-identical across replays of the same invocation.\n *\n * Pass to `agent.run({ clock: restateClock(ctx) })` or bake it into\n * `createAgent({ clock: restateClock(ctx) })` for the duration of a\n * handler invocation. The clock holds a reference to `ctx`; do not reuse\n * a clock instance across invocations.\n */\n\nimport type { AgentClock } from '../types'\nimport type { RestateContextLike } from './types'\n\n/**\n * Wrap a Restate context's `date.now()` + `rand.uuidv4()` into the\n * {@link AgentClock} shape Zidane consumes for journaled metadata.\n *\n * The returned clock is a thin live view onto `ctx` — each call hits\n * the SDK afresh. No caching, no closure-captured values. Restate's\n * journal handles determinism on its end.\n */\nexport function restateClock(ctx: RestateContextLike): AgentClock {\n return {\n now: () => ctx.date.now(),\n randomUUID: () => ctx.rand.uuidv4(),\n }\n}\n","import type { ToolResult } from '../providers'\nimport type { ToolBatchExecutionContext, ToolBatchExecutor } from '../types'\n\nexport interface RestatePromiseAllLike<TPromise extends Promise<unknown> = RestatePromiseLike<unknown>> {\n all: (values: readonly TPromise[]) => Promise<readonly unknown[]>\n}\n\nexport type RestatePromiseLike<T> = Promise<T> & {\n map: <U>(mapper: (value?: T, failure?: unknown) => U) => Promise<U>\n}\n\nexport interface RestateToolBatchExecutorOptions<TPromise extends Promise<unknown> = RestatePromiseLike<unknown>> {\n /**\n * Wait for a safe fleet through Restate's durable combinator. Pass\n * `RestatePromise` from `@restatedev/restate-sdk` in real deployments.\n */\n promises: RestatePromiseAllLike<TPromise>\n}\n\n/**\n * Tool batch scheduler for Restate-backed agents.\n *\n * It preserves unsafe-tool barriers and emits results in model submission\n * order. Safe fleets are started in submission order, capped by\n * `maxConcurrentTools`, and joined via the supplied durable `all()`.\n */\nexport function restateToolBatchExecutor<TPromise extends Promise<unknown> = RestatePromiseLike<unknown>>(\n options: RestateToolBatchExecutorOptions<TPromise>,\n): ToolBatchExecutor {\n return async (ctx: ToolBatchExecutionContext): Promise<ToolResult[]> => {\n const results: ToolResult[] = []\n const { toolCalls } = ctx\n\n const fillRemaining = (from: number, factory: (index: number) => ToolResult): ToolResult[] => {\n for (let i = from; i < toolCalls.length; i++)\n results[i] = factory(i)\n return results\n }\n\n for (let i = 0; i < toolCalls.length;) {\n if (ctx.signal.aborted)\n return fillRemaining(i, ctx.interruptedResult)\n if (ctx.steeringQueue.length > 0)\n return fillRemaining(i, ctx.skippedResult)\n\n if (!ctx.isConcurrencySafe(i)) {\n results[i] = await ctx.execute(i)\n i += 1\n continue\n }\n\n const start = i\n const fleet: number[] = []\n while (\n i < toolCalls.length\n && ctx.isConcurrencySafe(i)\n && fleet.length < ctx.maxConcurrentTools\n ) {\n fleet.push(i)\n i += 1\n }\n\n const fleetResults = fleet.every(index => ctx.canExecuteDurably(index))\n ? await ctx.executeDurable(\n fleet,\n async <T>(values: readonly Promise<T>[]): Promise<readonly T[]> => {\n const results = await options.promises.all(values as readonly TPromise[])\n return results as readonly T[]\n },\n )\n : await executeSequential(ctx, fleet)\n for (let offset = 0; offset < fleetResults.length; offset++)\n results[start + offset] = fleetResults[offset]\n }\n\n return results\n }\n}\n\nasync function executeSequential(\n ctx: ToolBatchExecutionContext,\n indices: readonly number[],\n): Promise<ToolResult[]> {\n const results: ToolResult[] = []\n for (const index of indices) {\n if (ctx.signal.aborted) {\n results.push(ctx.interruptedResult(index))\n continue\n }\n if (ctx.steeringQueue.length > 0) {\n results.push(ctx.skippedResult(index))\n continue\n }\n results.push(await ctx.execute(index))\n }\n return results\n}\n","/**\n * Restate-backed Provider wrapper.\n *\n * Wraps `Provider.stream` so every assistant turn (the LLM call as a\n * whole) is journaled. The model is invoked once per turn — the live\n * stream still fires `onText` / `onThinking` callbacks for UX during the\n * original execution. On replay, `ctx.run` returns the journaled\n * `TurnResult` immediately and the inner provider is NEVER re-invoked →\n * no duplicate billed tokens, no duplicate stream chunks.\n *\n * Replay caveat: stream callbacks don't re-fire on replay. Consumers\n * that paint live UI from `stream:text` should reconstruct transcripts\n * from `session.turns` via `eventsFromTurns` (zidane/chat) instead of\n * relying on hook re-emission. The chat layer already does this.\n *\n * Journal-entry naming: a monotonic per-wrapper counter (`llm-call-1`,\n * `llm-call-2`, …). One wrapper instance per Restate handler invocation\n * resets the counter; Restate's journal is invocation-scoped so names\n * don't need to be globally unique. The counter ticks the same way on\n * replay because the wrapper is constructed fresh each attempt.\n */\n\nimport type { Provider, StreamCallbacks, StreamOptions, TurnResult } from '../providers'\nimport type { RestateContextLike, RestateRunOptions } from './types'\n\nexport interface RestateProviderOptions {\n /**\n * `ctx.run` options forwarded on every wrapped stream call. Defaults\n * to `{ maxRetryAttempts: 3 }` — provider transients (rate limits,\n * 5xx, connection resets) get retried inside the journal entry. Once\n * the cap is reached the failure becomes terminal and surfaces\n * through the loop's normal `AgentProviderError` path.\n */\n runOptions?: RestateRunOptions\n /**\n * Override the journal-entry name. Receives the 1-indexed sequence\n * number for this wrapper instance and the `StreamOptions` of the\n * call. Default: `llm-call-<n>`. Override to inject extra structure\n * (e.g. `${agentName}/llm-call-${n}`) when multiple agents share a\n * service.\n */\n entryName?: (seq: number, opts: StreamOptions) => string\n /**\n * Whether live stream callbacks should fire during the original execution.\n * Use `'suppress'` for strict durable mode: the model call still returns a\n * full TurnResult, and UIs reconstruct from persisted session turns.\n *\n * Default: `'live'`.\n */\n streamCallbacks?: 'live' | 'suppress'\n}\n\n/**\n * Wrap a Zidane `Provider` so its `stream()` method journals each turn's\n * response inside `ctx.run`. All other Provider methods (`formatTools`,\n * `userMessage`, `toolResultsMessage`, `classifyError`, …) pass through\n * unchanged — they're pure functions over already-deterministic inputs.\n */\nexport function restateProvider(\n inner: Provider,\n ctx: RestateContextLike,\n options: RestateProviderOptions = {},\n): Provider {\n const runOpts: RestateRunOptions = options.runOptions ?? { maxRetryAttempts: 3 }\n const nameFor = options.entryName ?? ((seq: number) => `llm-call-${seq}`)\n let seq = 0\n\n return {\n ...inner,\n stream(streamOpts: StreamOptions, callbacks: StreamCallbacks): Promise<TurnResult> {\n seq += 1\n const durableCallbacks = options.streamCallbacks === 'suppress'\n ? suppressStreamingCallbacks(callbacks)\n : callbacks\n return ctx.run<TurnResult>(\n nameFor(seq, streamOpts),\n () => inner.stream(streamOpts, durableCallbacks),\n runOpts,\n )\n },\n }\n}\n\nfunction suppressStreamingCallbacks(callbacks: StreamCallbacks): StreamCallbacks {\n return {\n ...callbacks,\n onText: () => {},\n onThinking: undefined,\n onServerToolUse: undefined,\n onServerToolResult: undefined,\n }\n}\n","/**\n * Restate-backed `SessionStore` — turn / run state lives in the bound\n * virtual object's K/V state instead of SQLite / file / remote HTTP.\n *\n * Trade-offs vs. journal-only replay\n * ----------------------------------\n * If you only care about durable execution within ONE invocation,\n * skip this — the journaled `ctx.run` entries (LLM calls, tool\n * executions) are enough to replay the loop to byte-identical state\n * after a crash. The in-memory `createMemoryStore()` is the right\n * choice; turns rematerialize from the journal each replay.\n *\n * Pick this store when EXTERNAL consumers (TUI, web GUI, support\n * tooling) need to read a session's history WITHOUT re-entering the\n * agent handler. Virtual-object state is exposed via the SDK's read\n * APIs (`ctx.get` from another handler, `restate-cli`, the Restate\n * web UI) — same data, different access path. The journal is\n * invocation-local; this state is the externally-visible projection\n * of it.\n *\n * Storage layout\n * --------------\n * One virtual-object key per session, three K/V slots:\n *\n * `session-data` → `SessionData` minus the `turns` array (small header)\n * `session-turns` → `SessionTurn[]` (the conversation history)\n * `session-runs` → `SessionRun[]` (run lifecycle records)\n *\n * Splitting `turns` / `runs` out keeps the header light for `load()` —\n * a handler that only needs metadata doesn't pull the full history.\n *\n * Listing / discovery\n * -------------------\n * `list()` returns `[]` because virtual objects don't expose cross-key\n * enumeration. `delete()` clears the current object's session keys only.\n * Use a separate index handler if you need discovery (one virtual object\n * per `projectRoot` that maintains an indexed list of session ids; this\n * store doesn't own that concern).\n * `generateSessionId` is omitted so the agent falls back to its\n * default UUID generator — for a session bound 1:1 to a virtual-\n * object key, pass `id: ctx.key` to `createSession()` instead and\n * skip ID generation entirely.\n */\n\nimport type { SessionData, SessionRun, SessionStore } from '../session'\nimport type { SessionTurn } from '../types'\nimport type { RestateObjectContextLike } from './types'\n\nconst KEY_DATA = 'session-data'\nconst KEY_TURNS = 'session-turns'\nconst KEY_RUNS = 'session-runs'\n\n/**\n * Construct a `SessionStore` backed by the bound virtual-object's K/V\n * state. The store is single-tenant — every method ignores the\n * `sessionId` argument because the virtual object is already keyed by\n * `ctx.key`. Calling `appendTurns('other-id', …)` writes to the\n * CURRENT object's state, not the one named in the argument. Bind one\n * virtual-object key per session and the contract holds.\n */\nexport function restateSessionStore(ctx: RestateObjectContextLike): SessionStore {\n let nextTurnSeq: number | undefined\n\n async function generateTurnId(): Promise<string> {\n if (nextTurnSeq === undefined) {\n const existing = (await ctx.get<SessionTurn[]>(KEY_TURNS)) ?? []\n nextTurnSeq = existing.length\n }\n nextTurnSeq += 1\n return `turn_${nextTurnSeq}`\n }\n\n return {\n /**\n * Turn ids are deterministic from the persisted turn count. Random ids\n * are replay-stable only when the whole handler replays from the same\n * point; restarting from an arbitrary journal step can shift the RNG\n * sequence before a state write.\n */\n generateTurnId,\n\n async load(_sessionId: string): Promise<SessionData | null> {\n const header = await ctx.get<Omit<SessionData, 'turns' | 'runs'>>(KEY_DATA)\n const turns = sanitizeTurnsForState((await ctx.get<SessionTurn[]>(KEY_TURNS)) ?? [])\n const runs = sanitizeRunsForState((await ctx.get<SessionRun[]>(KEY_RUNS)) ?? [])\n if (!header) {\n if (turns.length === 0 && runs.length === 0)\n return null\n return {\n id: _sessionId,\n turns,\n runs,\n status: inferStatus(runs),\n metadata: {},\n createdAt: inferCreatedAt(turns, runs),\n updatedAt: inferUpdatedAt(turns, runs),\n }\n }\n return { ...header, turns, runs }\n },\n\n async save(session: SessionData): Promise<void> {\n const { turns, runs, ...header } = session\n ctx.set(KEY_DATA, header)\n ctx.set(KEY_TURNS, sanitizeTurnsForState(turns))\n ctx.set(KEY_RUNS, sanitizeRunsForState(runs))\n },\n\n async delete(_sessionId: string): Promise<void> {\n ctx.clear(KEY_DATA)\n ctx.clear(KEY_TURNS)\n ctx.clear(KEY_RUNS)\n },\n\n /**\n * Always empty — virtual objects don't support cross-key\n * enumeration. Maintain a separate index handler if discovery\n * matters.\n */\n async list(): Promise<string[]> {\n return []\n },\n\n async appendTurns(_sessionId: string, turns: SessionTurn[]): Promise<void> {\n const existing = sanitizeTurnsForState((await ctx.get<SessionTurn[]>(KEY_TURNS)) ?? [])\n ctx.set(KEY_TURNS, [...existing, ...sanitizeTurnsForState(turns)])\n },\n\n async getTurns(_sessionId: string, from = 0, limit?: number): Promise<SessionTurn[]> {\n const turns = sanitizeTurnsForState((await ctx.get<SessionTurn[]>(KEY_TURNS)) ?? [])\n return turns.slice(from, limit !== undefined ? from + limit : undefined)\n },\n\n async updateRun(_sessionId: string, run: SessionRun): Promise<void> {\n const runs = sanitizeRunsForState((await ctx.get<SessionRun[]>(KEY_RUNS)) ?? [])\n const idx = runs.findIndex(r => r.id === run.id)\n const next = [...runs]\n if (idx >= 0)\n next[idx] = sanitizeRunForState(run)\n else\n next.push(sanitizeRunForState(run))\n ctx.set(KEY_RUNS, next)\n },\n\n async updateStatus(_sessionId: string, status: SessionData['status']): Promise<void> {\n const header = await ctx.get<Omit<SessionData, 'turns' | 'runs'>>(KEY_DATA)\n const now = await ctx.date.now()\n if (header) {\n ctx.set(KEY_DATA, { ...header, status, updatedAt: now })\n }\n else {\n ctx.set(KEY_DATA, {\n id: _sessionId,\n status,\n metadata: {},\n createdAt: now,\n updatedAt: now,\n })\n }\n },\n }\n}\n\nfunction sanitizeTurnsForState(turns: readonly SessionTurn[]): SessionTurn[] {\n return turns.map(sanitizeTurnForState)\n}\n\nfunction sanitizeTurnForState(turn: SessionTurn): SessionTurn {\n if (!turn.usage || turn.usage.timeToFirstTokenMs === undefined)\n return turn\n\n const { timeToFirstTokenMs: _timeToFirstTokenMs, ...usage } = turn.usage\n return { ...turn, usage }\n}\n\nfunction sanitizeRunsForState(runs: readonly SessionRun[]): SessionRun[] {\n return runs.map(sanitizeRunForState)\n}\n\nfunction sanitizeRunForState(run: SessionRun): SessionRun {\n if (!run.turnUsage?.some(usage => usage.timeToFirstTokenMs !== undefined))\n return run\n\n return {\n ...run,\n turnUsage: run.turnUsage.map((usage) => {\n if (usage.timeToFirstTokenMs === undefined)\n return usage\n const { timeToFirstTokenMs: _timeToFirstTokenMs, ...stableUsage } = usage\n return stableUsage\n }),\n }\n}\n\nfunction inferStatus(runs: readonly SessionRun[]): SessionData['status'] {\n if (runs.some(run => run.status === 'running'))\n return 'running'\n if (runs.some(run => run.status === 'error'))\n return 'error'\n if (runs.some(run => run.status === 'completed'))\n return 'completed'\n return 'idle'\n}\n\nfunction inferCreatedAt(turns: readonly SessionTurn[], runs: readonly SessionRun[]): number {\n return minDefined([\n ...turns.map(turn => turn.createdAt),\n ...runs.map(run => run.startedAt),\n ]) ?? 0\n}\n\nfunction inferUpdatedAt(turns: readonly SessionTurn[], runs: readonly SessionRun[]): number {\n return maxDefined([\n ...turns.map(turn => turn.createdAt),\n ...runs.map(run => run.endedAt ?? run.startedAt),\n ]) ?? inferCreatedAt(turns, runs)\n}\n\nfunction minDefined(values: readonly number[]): number | undefined {\n let min: number | undefined\n for (const value of values) {\n if (min === undefined || value < min)\n min = value\n }\n return min\n}\n\nfunction maxDefined(values: readonly number[]): number | undefined {\n let max: number | undefined\n for (const value of values) {\n if (max === undefined || value > max)\n max = value\n }\n return max\n}\n","/**\n * Restate-backed tool wrappers.\n *\n * Wraps `ToolDef.execute` so every tool invocation is journaled. The\n * tool body runs on the original execution; after Restate persists the\n * journal entry, replay returns the recorded result without re-executing.\n * If the process dies before the entry is durable, the latest in-flight\n * tool can run again, so non-idempotent tools still need idempotency keys.\n *\n * `tool:gate`, `tool:transform`, `tool:after` hooks fire OUTSIDE the\n * journaled boundary, so they re-execute on replay. Built-in handlers\n * are deterministic given the journaled input + output (truncation,\n * image-stripping, `<edit-outcomes>` merge — all pure). Consumer hooks\n * that hit external services should themselves wrap side effects in\n * `ctx.run` so the substitution / annotation is replay-stable.\n *\n * `isConcurrencySafe` is preserved — Restate's per-key serialization\n * doesn't preclude in-handler parallelism. The loop's scheduler still\n * fans out safe tools up to `behavior.maxConcurrentTools`, each call\n * lands in its own journal entry. Order-of-journal-completion does NOT\n * affect replay correctness: Restate journals by call-site name, not\n * by completion order.\n */\n\nimport type { ToolDef } from '../tools/types'\nimport type { RestateContextLike, RestateRunOptions } from './types'\n\nexport interface RestateToolOptions {\n /**\n * `ctx.run` options forwarded on every wrapped tool call. Defaults to\n * `{ maxRetryAttempts: 1 }` — tool errors are typically deterministic\n * (validation failures, missing files) so blind retries waste budget.\n * Override per-tool for network-heavy custom tools that benefit from\n * SDK-level retries.\n */\n runOptions?: RestateRunOptions\n /**\n * Override the journal-entry name. Receives the canonical tool name\n * and the call's input. Default: `tool-<name>-<seq>` where `<seq>` is\n * a per-wrapper monotonic counter. Override to inject the model's\n * `callId` (read it off `ToolContext.callId` inside `execute` if you\n * need an LLM-visible key — but the default counter is sufficient\n * for journal correctness).\n */\n entryName?: (seq: number, name: string, input: Record<string, unknown>) => string\n /**\n * Hide and reject the built-in shell tool's background mode. Defaults to\n * `true` because Restate cannot recover host-local background processes.\n */\n disableShellBackground?: boolean\n}\n\nconst SHELL_BACKGROUND_DISABLED_MESSAGE = 'shell error: background mode is disabled for Restate-backed agents. Fall back to foreground (drop `run_in_background`).'\n\n/**\n * Wrap a single `ToolDef` so its `execute` runs inside `ctx.run`. The\n * tool's `spec` and `isConcurrencySafe` pass through unchanged.\n */\nexport function restateTool(\n inner: ToolDef,\n ctx: RestateContextLike,\n options: RestateToolOptions = {},\n): ToolDef {\n const runOpts: RestateRunOptions = options.runOptions ?? { maxRetryAttempts: 1 }\n const nameFor = options.entryName ?? ((seq: number, name: string) => `tool-${name}-${seq}`)\n const canonicalName = inner.spec.name\n const disableShellBackground = options.disableShellBackground ?? true\n const shellBackgroundDisabled = disableShellBackground && canonicalName === 'shell'\n let seq = 0\n const executeDurably = (input: Record<string, unknown>, toolCtx: Parameters<ToolDef['execute']>[1]) => {\n seq += 1\n return ctx.run(\n nameFor(seq, canonicalName, input),\n () => {\n if (shellBackgroundDisabled && input.run_in_background === true)\n return SHELL_BACKGROUND_DISABLED_MESSAGE\n return inner.execute(input, toolCtx)\n },\n runOpts,\n )\n }\n\n return {\n ...inner,\n spec: shellBackgroundDisabled ? withoutShellBackgroundInput(inner.spec) : inner.spec,\n execute: executeDurably,\n durableExecute: executeDurably,\n }\n}\n\nfunction withoutShellBackgroundInput(spec: ToolDef['spec']): ToolDef['spec'] {\n const inputSchema = spec.inputSchema\n const properties = isRecord(inputSchema.properties) ? inputSchema.properties : undefined\n if (!properties || !Object.hasOwn(properties, 'run_in_background'))\n return spec\n\n const { run_in_background: _runInBackground, ...nextProperties } = properties\n const required = Array.isArray(inputSchema.required)\n ? inputSchema.required.filter(name => name !== 'run_in_background')\n : inputSchema.required\n return {\n ...spec,\n description: stripShellBackgroundDescription(spec.description),\n inputSchema: {\n ...inputSchema,\n properties: nextProperties,\n ...(required !== inputSchema.required ? { required } : {}),\n },\n }\n}\n\nfunction stripShellBackgroundDescription(description: string): string {\n return description\n .split('\\n')\n .filter(line =>\n !line.includes('run_in_background')\n && !line.includes('<task-notification>')\n && !line.includes('background task'),\n )\n .join('\\n')\n .replace(/\\n{3,}/g, '\\n\\n')\n .trim()\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\n/**\n * Wrap an entire tool map at once — convenience for the common case of\n * \"journal every tool the agent has\". Pass-through for tools whose\n * names are listed in `opts.exclude` (e.g. fully-deterministic local\n * helpers where journaling is pure overhead).\n *\n * The returned map is a fresh object; the input is untouched.\n */\nexport function wrapAgentTools(\n tools: Record<string, ToolDef>,\n ctx: RestateContextLike,\n opts: RestateToolOptions & { exclude?: readonly string[] } = {},\n): Record<string, ToolDef> {\n const excludeSet = new Set(opts.exclude ?? [])\n const wrapped: Record<string, ToolDef> = {}\n for (const [name, def] of Object.entries(tools)) {\n wrapped[name] = excludeSet.has(name) ? def : restateTool(def, ctx, opts)\n }\n return wrapped\n}\n"],"mappings":";;;;;;;;AAOA,SAAgB,iCAAiC,OAAyB;CACxE,IAAI,EAAE,iBAAiB,QACrB,OAAO;CAET,MAAM,YAAY,QAAQ,IAAI,OAAO,MAAM;CAI3C,KAHa,OAAO,cAAc,WAC9B,YACA,KAAA,OACS,KACX,OAAO;CAET,MAAM,OAAO,MAAM;CACnB,IACE,SAAS,mBACN,SAAS,kBACT,SAAS,oBACT,SAAS,kBAEZ,OAAO;CAGT,MAAM,WAAW,MAAM,aAAa;CACpC,MAAM,0BAA0B,QAAQ,IAAI,OAAO,iBAAiB;CACpE,MAAM,qBAAqB,OAAO,4BAA4B,WAC1D,0BACA,KAAA;CACJ,IACE,aAAa,mBACV,aAAa,kBACb,aAAa,oBACb,aAAa,oBACb,uBAAuB,mBACvB,uBAAuB,kBACvB,uBAAuB,oBACvB,uBAAuB,kBAE1B,OAAO;CAGT,OAAO,OAAO,SAAS,YAAY,KAAK,YAAY,EAAE,SAAS,SAAS;AAC1E;;;;;;;;;ACtCA,SAAgB,gBAAgB,YAA2B,CAAC,GAAkB;CAC5E,OAAO;EACL,oBAAoB;EACpB,wBAAwB;EACxB,OAAO;EACP,wBAAwB;EACxB,GAAG;CACL;AACF;;;;;;;;;;;ACKA,SAAgB,aAAa,KAAqC;CAChE,OAAO;EACL,WAAW,IAAI,KAAK,IAAI;EACxB,kBAAkB,IAAI,KAAK,OAAO;CACpC;AACF;;;;;;;;;;ACDA,SAAgB,yBACd,SACmB;CACnB,OAAO,OAAO,QAA0D;EACtE,MAAM,UAAwB,CAAC;EAC/B,MAAM,EAAE,cAAc;E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ACnE,MAAM,WAAW,MAAM,QAAQ,YAAY,QAAQ,IAC/C,YAAY,SAAS,QAAO,SAAQ,SAAS,mBAAmB,IAChE,YAAY;CAChB,OAAO;EACL,GAAG;EACH,aAAa,gCAAgC,KAAK,WAAW;EAC7D,aAAa;GACX,GAAG;GACH,YAAY;GACZ,GAAI,aAAa,YAAY,WAAW,EAAE,SAAS,IAAI,CAAC;EAC1D;CACF;AACF;AAEA,SAAS,gCAAgC,aAA6B;CACpE,OAAO,YACJ,MAAM,IAAI,EACV,QAAO,SACN,CAAC,KAAK,SAAS,mBAAmB,KAC/B,CAAC,KAAK,SAAS,qBAAqB,KACpC,CAAC,KAAK,SAAS,iBAAiB,CACrC,EACC,KAAK,IAAI,EACT,QAAQ,WAAW,MAAM,EACzB,KAAK;AACV;AAEA,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;;;;;;;;;AAUA,SAAgB,eACd,OACA,KACA,OAA6D,CAAC,GACrC;CACzB,MAAM,aAAa,IAAI,IAAI,KAAK,WAAW,CAAC,CAAC;CAC7C,MAAM,UAAmC,CAAC;CAC1C,KAAK,MAAM,CAAC,MAAM,QAAQ,OAAO,QAAQ,KAAK,GAC5C,QAAQ,QAAQ,WAAW,IAAI,IAAI,IAAI,MAAM,YAAY,KAAK,KAAK,IAAI;CAEzE,OAAO;AACT"}
|
package/dist/session/sqlite.d.ts
CHANGED
package/dist/session.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { B as RemoteStoreOptions, F as SessionData, G as createFileMapStore, H as createMemoryStore, I as SessionRun, L as SessionStore, N as CreateSessionOptions, P as Session, Q as ToWireMessagesOptions, R as createSession, U as FileMapAdapter, V as createRemoteStore, W as FileMapStoreOptions, at as fromAnthropic, ct as toOpenAI, et as autoDetectAndConvert, lt as toWireMessages, mn as SessionTurn, ot as fromOpenAI, pn as SessionMessage, st as toAnthropic, un as SessionContentBlock, z as loadSession } from "./agent-
|
|
1
|
+
import { B as RemoteStoreOptions, F as SessionData, G as createFileMapStore, H as createMemoryStore, I as SessionRun, L as SessionStore, N as CreateSessionOptions, P as Session, Q as ToWireMessagesOptions, R as createSession, U as FileMapAdapter, V as createRemoteStore, W as FileMapStoreOptions, at as fromAnthropic, ct as toOpenAI, et as autoDetectAndConvert, lt as toWireMessages, mn as SessionTurn, ot as fromOpenAI, pn as SessionMessage, st as toAnthropic, un as SessionContentBlock, z as loadSession } from "./agent-CDFbxbHd.js";
|
|
2
2
|
export { CreateSessionOptions, type FileMapAdapter, type FileMapStoreOptions, type RemoteStoreOptions, Session, type SessionContentBlock, SessionData, type SessionMessage, SessionRun, SessionStore, type SessionTurn, type ToWireMessagesOptions, autoDetectAndConvert, createFileMapStore, createMemoryStore, createRemoteStore, createSession, fromAnthropic, fromOpenAI, loadSession, toAnthropic, toOpenAI, toWireMessages };
|
package/dist/skills.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as SkillResource, M as SkillsConfig, O as SkillConfig, c as DeactivationReason, d as createSkillActivationState, j as SkillSource, k as SkillDiagnostic, l as SkillActivationState, o as ActivationVia, s as ActiveSkill, u as SkillActivationStateOptions } from "./agent-
|
|
2
|
-
import { S as installAllowedToolsGate, _ as inferSource, a as SkillValidationResult, b as buildCatalog, c as parseAllowedToolPattern, d as validateSkillName, f as resolveSkills, g as getDefaultScanPaths, h as discoverSkills, i as SkillValidationIssue, l as validateResourcePath, m as SourcedScanPath, n as writeSkillToDisk, o as isToolAllowedByUnion, p as interpolateShellCommands, r as writeSkillsToDisk, s as matchesAllowedTool, t as defineSkill, u as validateSkillForWrite, v as parseFrontmatter, x as IMPLICITLY_ALLOWED_SKILL_TOOLS, y as parseSkillFile } from "./index-
|
|
1
|
+
import { A as SkillResource, M as SkillsConfig, O as SkillConfig, c as DeactivationReason, d as createSkillActivationState, j as SkillSource, k as SkillDiagnostic, l as SkillActivationState, o as ActivationVia, s as ActiveSkill, u as SkillActivationStateOptions } from "./agent-CDFbxbHd.js";
|
|
2
|
+
import { S as installAllowedToolsGate, _ as inferSource, a as SkillValidationResult, b as buildCatalog, c as parseAllowedToolPattern, d as validateSkillName, f as resolveSkills, g as getDefaultScanPaths, h as discoverSkills, i as SkillValidationIssue, l as validateResourcePath, m as SourcedScanPath, n as writeSkillToDisk, o as isToolAllowedByUnion, p as interpolateShellCommands, r as writeSkillsToDisk, s as matchesAllowedTool, t as defineSkill, u as validateSkillForWrite, v as parseFrontmatter, x as IMPLICITLY_ALLOWED_SKILL_TOOLS, y as parseSkillFile } from "./index-DWw_PtJH.js";
|
|
3
3
|
export { type ActivationVia, type ActiveSkill, type DeactivationReason, IMPLICITLY_ALLOWED_SKILL_TOOLS, type SkillActivationState, type SkillActivationStateOptions, type SkillConfig, type SkillDiagnostic, type SkillResource, type SkillSource, type SkillValidationIssue, type SkillValidationResult, type SkillsConfig, type SourcedScanPath, buildCatalog, createSkillActivationState, defineSkill, discoverSkills, getDefaultScanPaths, inferSource, installAllowedToolsGate, interpolateShellCommands, isToolAllowedByUnion, matchesAllowedTool, parseAllowedToolPattern, parseFrontmatter, parseSkillFile, resolveSkills, validateResourcePath, validateSkillForWrite, validateSkillName, writeSkillToDisk, writeSkillsToDisk };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _n as ThinkingLevel, ut as Provider } from "./agent-
|
|
1
|
+
import { _n as ThinkingLevel, ut as Provider } from "./agent-CDFbxbHd.js";
|
|
2
2
|
import { OAuthProviderInterface } from "@earendil-works/pi-ai/oauth";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
|
|
@@ -1468,4 +1468,4 @@ declare function displayNameFor(name: string, input?: Record<string, unknown>):
|
|
|
1468
1468
|
declare function formatToolCall(name: string, input: Record<string, unknown>): ToolFormatLine | null;
|
|
1469
1469
|
//#endregion
|
|
1470
1470
|
export { anthropicDescriptor as $, SessionMeta as A, collectReferences as B, EditHunk as C, Owner as D, EditPayload as E, CompletionContext as F, ProviderKey as G, mergeReferences as H, CompletionItem as I, CustomField as J, detectAuth as K, CompletionProvider as L, StreamEvent as M, ToolCallDisplay as N, Picked as O, ActiveTrigger as P, ProviderDescriptor as Q, CompletionReference as R, EditDiffDisplay as S, EditOutcomeKind as T, AuthMethod as U, findActiveTrigger as V, ProviderAuth as W, ModelOption as X, ModelInfo as Y, OUTPUT_RESERVE_TOKENS as Z, isEditErrorResult as _, formatToolCall as a, getModelInfo as at, selectableTurnIds as b, splitPromptSegments as c, modelSupportsReasoning as ct, RequestApproval as d, openrouterDescriptor as dt, cerebrasDescriptor as et, SafeModeActions as f, piIdOf as ft, EDIT_TOOL_NAMES as g, useSafeModeQueue as h, displayNameFor as i, getContextWindow as it, Settings as j, Screen as k, ApprovalDecision as l, modelsForDescriptor as lt, useSafeModeActions as m, ToolDisplayMeta as n, effectiveContextWindow as nt, PromptSegment as o, localDescriptor as ot, SafeModeProvider as p, restoreModelOptions as pt, BUILTIN_PROVIDERS as q, ToolFormatLine as r, enabledModelOptions as rt, PromptSegmentRef as s, modelOptionsFor as st, TOOL_DISPLAY as t, credKeyOf as tt, ApprovalRequest as u, openaiDescriptor as ut, isTurnHighlighted as v, EditOutcome as w, turnSelectionOwnership as x, isVisible as y, applyInsert as z };
|
|
1471
|
-
//# sourceMappingURL=tool-formatters-
|
|
1471
|
+
//# sourceMappingURL=tool-formatters-B3fSafpr.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-formatters-
|
|
1
|
+
{"version":3,"file":"tool-formatters-B3fSafpr.d.ts","names":[],"sources":["../src/chat/providers.ts","../src/chat/auth.ts","../src/chat/completion-core.ts","../src/chat/types.ts","../src/chat/turn-selection.ts","../src/chat/safe-mode-context.tsx","../src/chat/prompt-segments.ts","../src/chat/tool-formatters.ts"],"mappings":";;;;;;;;;;;;;;;;;UA8CiB,SAAA;EACf,EAAA;EACA,IAAA;EACA,aAAA;EACA,SAAA;EAC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