@wrongstack/core 0.77.0 → 0.84.1
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/{agent-bridge-EWdqs8v6.d.ts → agent-bridge-C9P_HPez.d.ts} +2 -2
- package/dist/{agent-subagent-runner-D8qW8OSC.d.ts → agent-subagent-runner-2Aq0jOSj.d.ts} +107 -102
- package/dist/{compactor-D_ExJajC.d.ts → compactor-CJq7LQev.d.ts} +3 -3
- package/dist/{config-Dy0CK_o6.d.ts → config-_DZ7dN-T.d.ts} +77 -75
- package/dist/{context-y87Jc5ei.d.ts → context-ToHAp4-U.d.ts} +119 -90
- package/dist/coordination/index.d.ts +16 -16
- package/dist/coordination/index.js +318 -37
- package/dist/coordination/index.js.map +1 -1
- package/dist/defaults/index.d.ts +32 -32
- package/dist/defaults/index.js +433 -81
- package/dist/defaults/index.js.map +1 -1
- package/dist/{director-state-BmYi3DGA.d.ts → director-state-CgIc30qi.d.ts} +19 -19
- package/dist/{events-CYaoLN5_.d.ts → events-DnRqXaZ3.d.ts} +43 -42
- package/dist/execution/index.d.ts +53 -53
- package/dist/execution/index.js +72 -29
- package/dist/execution/index.js.map +1 -1
- package/dist/extension/index.d.ts +9 -9
- package/dist/extension/index.js +8 -1
- package/dist/extension/index.js.map +1 -1
- package/dist/{goal-store-C7jcumEh.d.ts → goal-store-DvWLNu52.d.ts} +4 -4
- package/dist/{index-DIxjTOga.d.ts → index-BNOLadHw.d.ts} +28 -28
- package/dist/{index-Dsda0uCn.d.ts → index-N0_c4bHQ.d.ts} +45 -45
- package/dist/index.d.ts +167 -167
- package/dist/index.js +617 -155
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/index.d.ts +9 -9
- package/dist/infrastructure/index.js +13 -5
- package/dist/infrastructure/index.js.map +1 -1
- package/dist/kernel/index.d.ts +14 -14
- package/dist/kernel/index.js +7 -0
- package/dist/kernel/index.js.map +1 -1
- package/dist/logger-B72yyPc6.d.ts +12 -0
- package/dist/{logger-BppKxDqZ.d.ts → logger-C_27pj9i.d.ts} +6 -7
- package/dist/{mcp-servers-T0O6UN_w.d.ts → mcp-servers-Dck3T85_.d.ts} +20 -20
- package/dist/{mode-BO4SEUIv.d.ts → mode-CHo2XtHs.d.ts} +4 -4
- package/dist/models/index.d.ts +10 -10
- package/dist/models/index.js +8 -2
- package/dist/models/index.js.map +1 -1
- package/dist/{models-registry-BcYJDKLm.d.ts → models-registry-Be3osGt5.d.ts} +28 -28
- package/dist/{models-registry-Cuq1C8V9.d.ts → models-registry-Boz639EI.d.ts} +12 -12
- package/dist/{multi-agent-coordinator-DpbG3wiy.d.ts → multi-agent-coordinator-DllpCVkF.d.ts} +12 -12
- package/dist/{null-fleet-bus-u5ys3lW_.d.ts → null-fleet-bus-BY0AN-sr.d.ts} +121 -121
- package/dist/observability/index.d.ts +41 -41
- package/dist/observability/index.js.map +1 -1
- package/dist/{observability-BhnVLBLS.d.ts → observability-CoSNZdhX.d.ts} +4 -4
- package/dist/{parallel-eternal-engine-Dn0P8Pbj.d.ts → parallel-eternal-engine-D402RASp.d.ts} +49 -49
- package/dist/{path-resolver-B32v2JIq.d.ts → path-resolver-UPFTsDyD.d.ts} +6 -6
- package/dist/{permission-V5BLOrY6.d.ts → permission-14CChMmO.d.ts} +10 -8
- package/dist/{permission-policy-CBVx-d-8.d.ts → permission-policy-gW5htOo1.d.ts} +7 -7
- package/dist/{plan-templates-BcUwLlMQ.d.ts → plan-templates-DRvPgkfZ.d.ts} +65 -32
- package/dist/{provider-runner-CSi_7l0h.d.ts → provider-runner-COAJM8tC.d.ts} +6 -6
- package/dist/{retry-policy-CG3qvH_e.d.ts → retry-policy-DSu6O6rD.d.ts} +4 -4
- package/dist/sdd/index.d.ts +47 -47
- package/dist/sdd/index.js +47 -22
- package/dist/sdd/index.js.map +1 -1
- package/dist/{secret-scrubber-7rSC_emZ.d.ts → secret-scrubber-yGBFQYju.d.ts} +10 -2
- package/dist/security/index.d.ts +7 -7
- package/dist/security/index.js +15 -8
- package/dist/security/index.js.map +1 -1
- package/dist/{selector-RvBR_YRW.d.ts → selector-11-fm95U.d.ts} +2 -2
- package/dist/{session-event-bridge-CDHxcmQU.d.ts → session-event-bridge-D0u-x576.d.ts} +7 -7
- package/dist/{session-reader-BIpwM60D.d.ts → session-reader-BQU-toaN.d.ts} +23 -23
- package/dist/{skill-CxuWrsKK.d.ts → skill-BJeF2DwY.d.ts} +1 -1
- package/dist/skills/index.d.ts +9 -9
- package/dist/skills/index.js +15 -3
- package/dist/skills/index.js.map +1 -1
- package/dist/storage/index.d.ts +15 -15
- package/dist/storage/index.js +378 -76
- package/dist/storage/index.js.map +1 -1
- package/dist/{system-prompt-CA11g6Jo.d.ts → system-prompt-C0rLCeyn.d.ts} +16 -11
- package/dist/{task-graph-D1YQbpxF.d.ts → task-graph-CikNdRTG.d.ts} +22 -22
- package/dist/types/index.d.ts +26 -26
- package/dist/types/index.js +53 -17
- package/dist/types/index.js.map +1 -1
- package/dist/utils/index.d.ts +57 -45
- package/dist/utils/index.js +66 -12
- package/dist/utils/index.js.map +1 -1
- package/dist/{wstack-paths-D7evAFWM.d.ts → wstack-paths-BQMvEllz.d.ts} +2 -2
- package/package.json +1 -1
- package/dist/logger-DDd5C--Z.d.ts +0 -12
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { N as TodoItem, M as Message, J as JSONSchema } from '../context-
|
|
2
|
-
export { W as WstackPathOptions, a as WstackPaths, p as projectHash, b as projectSlug, r as resolveWstackPaths } from '../wstack-paths-
|
|
3
|
-
import { M as ModelsDevPayload } from '../models-registry-
|
|
4
|
-
import { k as CustomModelDefinition } from '../config-
|
|
1
|
+
import { N as TodoItem, M as Message, J as JSONSchema } from '../context-ToHAp4-U.js';
|
|
2
|
+
export { W as WstackPathOptions, a as WstackPaths, p as projectHash, b as projectSlug, r as resolveWstackPaths } from '../wstack-paths-BQMvEllz.js';
|
|
3
|
+
import { M as ModelsDevPayload } from '../models-registry-Be3osGt5.js';
|
|
4
|
+
import { k as CustomModelDefinition } from '../config-_DZ7dN-T.js';
|
|
5
5
|
|
|
6
6
|
interface AtomicWriteOptions {
|
|
7
|
-
mode?: number;
|
|
8
|
-
encoding?: BufferEncoding;
|
|
7
|
+
mode?: number | undefined;
|
|
8
|
+
encoding?: BufferEncoding | undefined;
|
|
9
9
|
}
|
|
10
10
|
declare function atomicWrite(targetPath: string, content: string | Uint8Array, opts?: AtomicWriteOptions): Promise<void>;
|
|
11
11
|
declare function ensureDir(dir: string): Promise<void>;
|
|
12
12
|
|
|
13
13
|
interface SafeParseResult<T> {
|
|
14
14
|
ok: boolean;
|
|
15
|
-
value?: T;
|
|
16
|
-
error?: string;
|
|
15
|
+
value?: T | undefined;
|
|
16
|
+
error?: string | undefined;
|
|
17
17
|
}
|
|
18
18
|
declare function safeParse<T = unknown>(input: string, maxBytes?: number): SafeParseResult<T>;
|
|
19
19
|
declare function safeStringify(value: unknown, pretty?: boolean): string;
|
|
@@ -116,6 +116,33 @@ declare function onResize(cb: (size: {
|
|
|
116
116
|
* `if (input.isTTY) input.setRawMode(...)` ceremony at every call site.
|
|
117
117
|
*/
|
|
118
118
|
declare function setRawMode(input: NodeJS.ReadStream, mode: boolean): boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Bracket installed by the interactive input reader while a `readline`
|
|
121
|
+
* prompt is on screen. Out-of-band terminal writes — logger WARN/INFO
|
|
122
|
+
* lines, async activity from the Telegram bridge, etc. — go to the same
|
|
123
|
+
* physical terminal as the half-typed prompt but readline has no idea they
|
|
124
|
+
* happened, so it never repaints. The result is the classic corruption the
|
|
125
|
+
* user sees: every async line strands the in-progress draft as a fresh
|
|
126
|
+
* scrollback row (sometimes with its cursor underline).
|
|
127
|
+
*
|
|
128
|
+
* The guard closes that gap. `suspend()` wipes the draft row so the message
|
|
129
|
+
* prints clean; `resume()` repaints the prompt + draft (cursor preserved).
|
|
130
|
+
* When no prompt is active the guard is `null` and writes pass straight
|
|
131
|
+
* through — so agent-turn output (spinner, renderer) is untouched.
|
|
132
|
+
*/
|
|
133
|
+
interface OutputLineGuard {
|
|
134
|
+
/** Clear the current input row right before an out-of-band write. */
|
|
135
|
+
suspend(): void;
|
|
136
|
+
/** Repaint the prompt + in-progress draft right after the write. */
|
|
137
|
+
resume(): void;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Register (or clear, with `null`) the guard that brackets out-of-band
|
|
141
|
+
* writes. Installed by {@link writeOut}/{@link writeErr} consumers — in
|
|
142
|
+
* practice the CLI's readline input reader — only while a prompt is live.
|
|
143
|
+
* Idempotent; the most recent caller wins.
|
|
144
|
+
*/
|
|
145
|
+
declare function setOutputLineGuard(guard: OutputLineGuard | null): void;
|
|
119
146
|
/**
|
|
120
147
|
* Write `s` to `stream` (defaults to `process.stdout`). Returns `false`
|
|
121
148
|
* when the stream is missing or doesn't expose `write` so callers can
|
|
@@ -175,13 +202,6 @@ declare function writeErr(s: string, stream?: NodeJS.WriteStream): boolean;
|
|
|
175
202
|
*/
|
|
176
203
|
declare function formatTodosList(todos: TodoItem[]): string;
|
|
177
204
|
|
|
178
|
-
/**
|
|
179
|
-
* Minimal glob matcher for trust patterns.
|
|
180
|
-
* Supports: *, **, ?, character classes [abc], [a-z], negation [!...] or [^...].
|
|
181
|
-
*
|
|
182
|
-
* Compiled regexes are cached so repeated calls with the same pattern
|
|
183
|
-
* avoid recompilation overhead.
|
|
184
|
-
*/
|
|
185
205
|
declare function compileGlob(pattern: string): RegExp;
|
|
186
206
|
declare function matchGlob(pattern: string, input: string): boolean;
|
|
187
207
|
declare function matchAny(patterns: string[], input: string): boolean;
|
|
@@ -191,9 +211,9 @@ declare function matchAny(patterns: string[], input: string): boolean;
|
|
|
191
211
|
* Operates on arrays of lines (newline-terminated or stripped).
|
|
192
212
|
*/
|
|
193
213
|
interface UnifiedDiffOptions {
|
|
194
|
-
context?: number;
|
|
195
|
-
fromFile?: string;
|
|
196
|
-
toFile?: string;
|
|
214
|
+
context?: number | undefined;
|
|
215
|
+
fromFile?: string | undefined;
|
|
216
|
+
toFile?: string | undefined;
|
|
197
217
|
}
|
|
198
218
|
declare function unifiedDiff(oldText: string, newText: string, opts?: UnifiedDiffOptions): string;
|
|
199
219
|
|
|
@@ -218,9 +238,9 @@ declare function unifiedDiff(oldText: string, newText: string, opts?: UnifiedDif
|
|
|
218
238
|
*/
|
|
219
239
|
interface BuildChildEnvOptions {
|
|
220
240
|
/** Session ID to inject as WRONGSTACK_SESSION_ID. */
|
|
221
|
-
sessionId?: string;
|
|
241
|
+
sessionId?: string | undefined;
|
|
222
242
|
/** Additional env vars to merge (takes priority over filtered parent env). */
|
|
223
|
-
extra?: NodeJS.ProcessEnv;
|
|
243
|
+
extra?: NodeJS.ProcessEnv | undefined;
|
|
224
244
|
}
|
|
225
245
|
/**
|
|
226
246
|
* Build a filtered child-process environment suitable for bash, exec, and
|
|
@@ -229,13 +249,24 @@ interface BuildChildEnvOptions {
|
|
|
229
249
|
*/
|
|
230
250
|
declare function buildChildEnv(optsOrSessionId?: BuildChildEnvOptions | string): NodeJS.ProcessEnv;
|
|
231
251
|
|
|
252
|
+
/** Resolve a promise after `ms` milliseconds. Prefer this over raw
|
|
253
|
+
* `setTimeout` wrappers so all delay sites use a single implementation
|
|
254
|
+
* and an abortable variant can be introduced without a codebase-wide hunt. */
|
|
255
|
+
declare function sleep(ms: number): Promise<void>;
|
|
256
|
+
|
|
257
|
+
/** Assert a value is neither null nor undefined. Throws if it is.
|
|
258
|
+
* Useful after optional chaining and indexed access when the
|
|
259
|
+
* control flow guarantees the value exists but TypeScript can't
|
|
260
|
+
* prove it (e.g. after a check on a related field). */
|
|
261
|
+
declare function expectDefined<T>(value: T | null | undefined): T;
|
|
262
|
+
|
|
232
263
|
/**
|
|
233
264
|
* Tool output serialization utilities.
|
|
234
265
|
* Extracted from Agent.executeTools to allow reuse and consistent output handling.
|
|
235
266
|
*/
|
|
236
267
|
interface ToolOutputSerializerOptions {
|
|
237
|
-
perIterationOutputCapBytes?: number;
|
|
238
|
-
estimator?: (text: string) => number;
|
|
268
|
+
perIterationOutputCapBytes?: number | undefined;
|
|
269
|
+
estimator?: ((text: string) => number) | undefined;
|
|
239
270
|
}
|
|
240
271
|
declare function createToolOutputSerializer(opts?: ToolOutputSerializerOptions): {
|
|
241
272
|
serialize: (value: unknown) => string;
|
|
@@ -246,25 +277,6 @@ declare function createToolOutputSerializer(opts?: ToolOutputSerializerOptions):
|
|
|
246
277
|
capBytes: number;
|
|
247
278
|
};
|
|
248
279
|
|
|
249
|
-
/**
|
|
250
|
-
* Shared token estimation with JSON.stringify caching.
|
|
251
|
-
* Avoids repeated stringification of tool input objects.
|
|
252
|
-
*
|
|
253
|
-
* ## Calibration
|
|
254
|
-
*
|
|
255
|
-
* `estimateRequestTokens` uses a fixed 3.5 chars/token heuristic — a
|
|
256
|
-
* conservative overestimate that prevents underestimation but reduces
|
|
257
|
-
* accuracy. After each API call, call `recordActualUsage()` with the
|
|
258
|
-
* real `usage.input` from the provider response. The module maintains a
|
|
259
|
-
* rolling average of `actual / estimated` ratio (EWM, α=0.3) and
|
|
260
|
-
* applies it to subsequent calls via `estimateRequestTokensCalibrated`.
|
|
261
|
-
*
|
|
262
|
-
* Calibration is per-module (shared across all callers), which is
|
|
263
|
-
* sufficient: the chars/token ratio is a property of the tokenizer,
|
|
264
|
-
* not the model. Uncalibrated calls (before any samples, or when
|
|
265
|
-
* `recordActualUsage` is not called) fall back to the uncalibrated
|
|
266
|
-
* estimate so nothing breaks.
|
|
267
|
-
*/
|
|
268
280
|
/**
|
|
269
281
|
* Estimate tokens for a tool_use block input.
|
|
270
282
|
* Caches the stringified result keyed by the stable string representation
|
|
@@ -286,7 +298,7 @@ declare function estimateTextTokens(text: string): number;
|
|
|
286
298
|
*/
|
|
287
299
|
declare function estimateToolDefTokens(tool: {
|
|
288
300
|
name: string;
|
|
289
|
-
description?: string;
|
|
301
|
+
description?: string | undefined;
|
|
290
302
|
inputSchema: unknown;
|
|
291
303
|
}): number;
|
|
292
304
|
/**
|
|
@@ -309,7 +321,7 @@ interface RequestTokenBreakdown {
|
|
|
309
321
|
}
|
|
310
322
|
declare function estimateRequestTokens(messages: unknown, systemPrompt: unknown, tools: {
|
|
311
323
|
name: string;
|
|
312
|
-
description?: string;
|
|
324
|
+
description?: string | undefined;
|
|
313
325
|
inputSchema: unknown;
|
|
314
326
|
}[]): RequestTokenBreakdown;
|
|
315
327
|
/**
|
|
@@ -345,7 +357,7 @@ declare function getCalibrationState(): {
|
|
|
345
357
|
*/
|
|
346
358
|
declare function estimateRequestTokensCalibrated(messages: unknown, systemPrompt: unknown, tools: {
|
|
347
359
|
name: string;
|
|
348
|
-
description?: string;
|
|
360
|
+
description?: string | undefined;
|
|
349
361
|
inputSchema: unknown;
|
|
350
362
|
}[]): RequestTokenBreakdown;
|
|
351
363
|
/**
|
|
@@ -489,4 +501,4 @@ declare function mergeModelsPayload(base: ModelsDevPayload, overlay: ModelsDevPa
|
|
|
489
501
|
*/
|
|
490
502
|
declare function mergeCustomModelDefs(providerCustomModels: Record<string, CustomModelDefinition> | undefined, configModels: Record<string, CustomModelDefinition> | undefined): Record<string, CustomModelDefinition> | undefined;
|
|
491
503
|
|
|
492
|
-
export { type AtomicWriteOptions, type BuildChildEnvOptions, type CompileFail, type CompileResult, type MessageRepairReport, type MessageRepairResult, type NewlineStyle, type RequestTokenBreakdown, type SafeParseResult, type ToolOutputSerializerOptions, type UnifiedDiffOptions, type ValidationError, type ValidationResult, atomicWrite, buildChildEnv, color, compileGlob, compileUserRegex, completePartialObject, createToolOutputSerializer, detectNewlineStyle, ensureDir, estimateRequestTokens, estimateRequestTokensCalibrated, estimateTextTokens, estimateToolDefTokens, estimateToolInputTokens, estimateToolResultTokens, expandGlob, formatTodosList, getCalibrationState, getTermSize, isInteractive, isStdinTTY, isStdoutTTY, matchAny, matchGlob, mergeCustomModelDefs, mergeModelsPayload, normalizeToLf, onResize, recordActualUsage, repairToolUseAdjacency, resetCalibration, safeParse, safeStringify, sanitizeJsonString, setRawMode, stripAnsi, toStyle, unifiedDiff, validateAgainstSchema, writeErr, writeOut };
|
|
504
|
+
export { type AtomicWriteOptions, type BuildChildEnvOptions, type CompileFail, type CompileResult, type MessageRepairReport, type MessageRepairResult, type NewlineStyle, type OutputLineGuard, type RequestTokenBreakdown, type SafeParseResult, type ToolOutputSerializerOptions, type UnifiedDiffOptions, type ValidationError, type ValidationResult, atomicWrite, buildChildEnv, color, compileGlob, compileUserRegex, completePartialObject, createToolOutputSerializer, detectNewlineStyle, ensureDir, estimateRequestTokens, estimateRequestTokensCalibrated, estimateTextTokens, estimateToolDefTokens, estimateToolInputTokens, estimateToolResultTokens, expandGlob, expectDefined, formatTodosList, getCalibrationState, getTermSize, isInteractive, isStdinTTY, isStdoutTTY, matchAny, matchGlob, mergeCustomModelDefs, mergeModelsPayload, normalizeToLf, onResize, recordActualUsage, repairToolUseAdjacency, resetCalibration, safeParse, safeStringify, sanitizeJsonString, setOutputLineGuard, setRawMode, sleep, stripAnsi, toStyle, unifiedDiff, validateAgainstSchema, writeErr, writeOut };
|
package/dist/utils/index.js
CHANGED
|
@@ -121,7 +121,7 @@ function escapeControlCharsInStrings(s) {
|
|
|
121
121
|
let inString = false;
|
|
122
122
|
let out = "";
|
|
123
123
|
for (let i = 0; i < s.length; i++) {
|
|
124
|
-
const c = s
|
|
124
|
+
const c = s.charAt(i);
|
|
125
125
|
if (c === '"' && (i === 0 || s[i - 1] !== "\\")) {
|
|
126
126
|
inString = !inString;
|
|
127
127
|
out += c;
|
|
@@ -159,12 +159,12 @@ function stripSingleLineComments(s) {
|
|
|
159
159
|
const chars = [];
|
|
160
160
|
let i = 0;
|
|
161
161
|
while (i < s.length) {
|
|
162
|
-
const c = s
|
|
163
|
-
if (c === '"' && (i === 0 || s
|
|
162
|
+
const c = s.charAt(i);
|
|
163
|
+
if (c === '"' && (i === 0 || s.charAt(i - 1) !== "\\")) {
|
|
164
164
|
inString = !inString;
|
|
165
165
|
chars.push(c);
|
|
166
|
-
} else if (c === "/" && s
|
|
167
|
-
while (i < s.length && s
|
|
166
|
+
} else if (c === "/" && s.charAt(i + 1) === "/" && !inString) {
|
|
167
|
+
while (i < s.length && s.charAt(i) !== "\n") i++;
|
|
168
168
|
} else {
|
|
169
169
|
chars.push(c);
|
|
170
170
|
}
|
|
@@ -244,9 +244,20 @@ function setRawMode(input, mode) {
|
|
|
244
244
|
input.setRawMode(mode);
|
|
245
245
|
return true;
|
|
246
246
|
}
|
|
247
|
+
var activeOutputGuard = null;
|
|
248
|
+
function setOutputLineGuard(guard) {
|
|
249
|
+
activeOutputGuard = guard;
|
|
250
|
+
}
|
|
247
251
|
function writeTo(s, stream) {
|
|
248
252
|
if (!stream || typeof stream.write !== "function") return false;
|
|
253
|
+
const guard = activeOutputGuard;
|
|
254
|
+
if (!guard) {
|
|
255
|
+
stream.write(s);
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
258
|
+
guard.suspend();
|
|
249
259
|
stream.write(s);
|
|
260
|
+
guard.resume();
|
|
250
261
|
return true;
|
|
251
262
|
}
|
|
252
263
|
function writeOut(s, stream = process.stdout) {
|
|
@@ -306,6 +317,12 @@ function formatTodosList(todos) {
|
|
|
306
317
|
}
|
|
307
318
|
|
|
308
319
|
// src/utils/glob-match.ts
|
|
320
|
+
function expectDefined(value) {
|
|
321
|
+
if (value === null || value === void 0) {
|
|
322
|
+
throw new Error("Expected value to be defined");
|
|
323
|
+
}
|
|
324
|
+
return value;
|
|
325
|
+
}
|
|
309
326
|
function escapeRegex(s) {
|
|
310
327
|
return s.replace(/[.+^${}()|\\]/g, "\\$&");
|
|
311
328
|
}
|
|
@@ -317,7 +334,7 @@ function getCachedGlob(pattern) {
|
|
|
317
334
|
if (COMPILED_GLOB_CACHE.size >= CACHE_MAX_SIZE) {
|
|
318
335
|
const keys = [...COMPILED_GLOB_CACHE.keys()];
|
|
319
336
|
for (let i = 0; i < Math.floor(CACHE_MAX_SIZE / 4); i++) {
|
|
320
|
-
COMPILED_GLOB_CACHE.delete(keys[i]);
|
|
337
|
+
COMPILED_GLOB_CACHE.delete(expectDefined(keys[i]));
|
|
321
338
|
}
|
|
322
339
|
}
|
|
323
340
|
const re = compileGlob(pattern);
|
|
@@ -673,6 +690,19 @@ function buildChildEnv(optsOrSessionId) {
|
|
|
673
690
|
return out;
|
|
674
691
|
}
|
|
675
692
|
|
|
693
|
+
// src/utils/sleep.ts
|
|
694
|
+
function sleep(ms) {
|
|
695
|
+
return new Promise((resolve3) => setTimeout(resolve3, ms));
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
// src/utils/expect-defined.ts
|
|
699
|
+
function expectDefined2(value) {
|
|
700
|
+
if (value === null || value === void 0) {
|
|
701
|
+
throw new Error("Expected value to be defined");
|
|
702
|
+
}
|
|
703
|
+
return value;
|
|
704
|
+
}
|
|
705
|
+
|
|
676
706
|
// src/utils/tool-output-serializer.ts
|
|
677
707
|
function createToolOutputSerializer(opts = {}) {
|
|
678
708
|
const capBytes = opts.perIterationOutputCapBytes ?? 1e5;
|
|
@@ -718,6 +748,12 @@ function createToolOutputSerializer(opts = {}) {
|
|
|
718
748
|
}
|
|
719
749
|
|
|
720
750
|
// src/utils/token-estimate.ts
|
|
751
|
+
function expectDefined3(value) {
|
|
752
|
+
if (value === null || value === void 0) {
|
|
753
|
+
throw new Error("Expected value to be defined");
|
|
754
|
+
}
|
|
755
|
+
return value;
|
|
756
|
+
}
|
|
721
757
|
var RoughTokenEstimate = (text, charsPerToken = 3.5) => Math.max(1, Math.ceil(text.length / charsPerToken));
|
|
722
758
|
var _cal = {
|
|
723
759
|
ratio: 1,
|
|
@@ -738,7 +774,7 @@ function getCachedEstimate(key, compute) {
|
|
|
738
774
|
if (ESTIMATE_CACHE.size >= ESTIMATE_CACHE_MAX_SIZE) {
|
|
739
775
|
const keys = [...ESTIMATE_CACHE.keys()];
|
|
740
776
|
for (let i = 0; i < Math.floor(ESTIMATE_CACHE_MAX_SIZE / 4); i++) {
|
|
741
|
-
ESTIMATE_CACHE.delete(keys[i]);
|
|
777
|
+
ESTIMATE_CACHE.delete(expectDefined3(keys[i]));
|
|
742
778
|
}
|
|
743
779
|
}
|
|
744
780
|
const estimate = compute();
|
|
@@ -851,6 +887,12 @@ function resetCalibration() {
|
|
|
851
887
|
}
|
|
852
888
|
|
|
853
889
|
// src/utils/message-invariants.ts
|
|
890
|
+
function expectDefined4(value) {
|
|
891
|
+
if (value === null || value === void 0) {
|
|
892
|
+
throw new Error("Expected value to be defined");
|
|
893
|
+
}
|
|
894
|
+
return value;
|
|
895
|
+
}
|
|
854
896
|
function repairToolUseAdjacency(messages) {
|
|
855
897
|
const removedToolUses = [];
|
|
856
898
|
const removedToolResults = [];
|
|
@@ -858,7 +900,7 @@ function repairToolUseAdjacency(messages) {
|
|
|
858
900
|
let changed = false;
|
|
859
901
|
const out = [];
|
|
860
902
|
for (let i = 0; i < messages.length; i++) {
|
|
861
|
-
const original = messages[i];
|
|
903
|
+
const original = expectDefined4(messages[i]);
|
|
862
904
|
let msg = original;
|
|
863
905
|
if (hasToolUse(msg)) {
|
|
864
906
|
const nextIds = toolResultIds(messages[i + 1]);
|
|
@@ -1071,6 +1113,12 @@ function compileUserRegex(pattern, flags) {
|
|
|
1071
1113
|
};
|
|
1072
1114
|
}
|
|
1073
1115
|
}
|
|
1116
|
+
function expectDefined5(value) {
|
|
1117
|
+
if (value === null || value === void 0) {
|
|
1118
|
+
throw new Error("Expected value to be defined");
|
|
1119
|
+
}
|
|
1120
|
+
return value;
|
|
1121
|
+
}
|
|
1074
1122
|
var GLOB_CHARS = /* @__PURE__ */ new Set(["*", "?", "["]);
|
|
1075
1123
|
var IS_WINDOWS = process.platform === "win32";
|
|
1076
1124
|
var SEP = IS_WINDOWS ? "\\" : "/";
|
|
@@ -1084,7 +1132,7 @@ function globToRegex(pat) {
|
|
|
1084
1132
|
let i = 0;
|
|
1085
1133
|
let re = "^";
|
|
1086
1134
|
while (i < pat.length) {
|
|
1087
|
-
const c = pat[i];
|
|
1135
|
+
const c = expectDefined5(pat[i]);
|
|
1088
1136
|
if (c === "*") {
|
|
1089
1137
|
if (pat[i + 1] === "*") {
|
|
1090
1138
|
re += ".*";
|
|
@@ -1123,7 +1171,7 @@ function globToRegex(pat) {
|
|
|
1123
1171
|
}
|
|
1124
1172
|
function baseDir(pat) {
|
|
1125
1173
|
let i = pat.length - 1;
|
|
1126
|
-
while (i >= 0 && !GLOB_CHARS.has(pat[i]) && pat[i] !== SEP && pat[i] !== "/") i--;
|
|
1174
|
+
while (i >= 0 && !GLOB_CHARS.has(expectDefined5(pat[i])) && pat[i] !== SEP && pat[i] !== "/") i--;
|
|
1127
1175
|
const cut = i >= 0 ? pat.lastIndexOf(SEP, i) : pat.lastIndexOf("/", i);
|
|
1128
1176
|
return cut < 0 ? "." : pat.slice(0, cut);
|
|
1129
1177
|
}
|
|
@@ -1188,6 +1236,12 @@ async function expandGlob(pattern) {
|
|
|
1188
1236
|
}
|
|
1189
1237
|
|
|
1190
1238
|
// src/utils/json-repair.ts
|
|
1239
|
+
function expectDefined6(value) {
|
|
1240
|
+
if (value === null || value === void 0) {
|
|
1241
|
+
throw new Error("Expected value to be defined");
|
|
1242
|
+
}
|
|
1243
|
+
return value;
|
|
1244
|
+
}
|
|
1191
1245
|
function completePartialObject(s) {
|
|
1192
1246
|
if (!s.trim().startsWith("{")) return s;
|
|
1193
1247
|
if (tryParse(s).ok) return s;
|
|
@@ -1199,7 +1253,7 @@ function completePartialObject(s) {
|
|
|
1199
1253
|
let contentEnd = 0;
|
|
1200
1254
|
let stringBraceDepth = 0;
|
|
1201
1255
|
for (let i = 0; i < s.length; i++) {
|
|
1202
|
-
const ch = s[i];
|
|
1256
|
+
const ch = expectDefined6(s[i]);
|
|
1203
1257
|
if (inString) {
|
|
1204
1258
|
contentEnd = i + 1;
|
|
1205
1259
|
if (escaped) {
|
|
@@ -1356,6 +1410,6 @@ function mergeCustomModelDefs(providerCustomModels, configModels) {
|
|
|
1356
1410
|
return out;
|
|
1357
1411
|
}
|
|
1358
1412
|
|
|
1359
|
-
export { atomicWrite, buildChildEnv, color, compileGlob, compileUserRegex, completePartialObject, createToolOutputSerializer, detectNewlineStyle, ensureDir, estimateRequestTokens, estimateRequestTokensCalibrated, estimateTextTokens, estimateToolDefTokens, estimateToolInputTokens, estimateToolResultTokens, expandGlob, formatTodosList, getCalibrationState, getTermSize, isInteractive, isStdinTTY, isStdoutTTY, matchAny, matchGlob, mergeCustomModelDefs, mergeModelsPayload, normalizeToLf, onResize, projectHash, projectSlug, recordActualUsage, repairToolUseAdjacency, resetCalibration, resolveWstackPaths, safeParse, safeStringify, sanitizeJsonString, setRawMode, stripAnsi, toStyle, unifiedDiff, validateAgainstSchema, writeErr, writeOut };
|
|
1413
|
+
export { atomicWrite, buildChildEnv, color, compileGlob, compileUserRegex, completePartialObject, createToolOutputSerializer, detectNewlineStyle, ensureDir, estimateRequestTokens, estimateRequestTokensCalibrated, estimateTextTokens, estimateToolDefTokens, estimateToolInputTokens, estimateToolResultTokens, expandGlob, expectDefined2 as expectDefined, formatTodosList, getCalibrationState, getTermSize, isInteractive, isStdinTTY, isStdoutTTY, matchAny, matchGlob, mergeCustomModelDefs, mergeModelsPayload, normalizeToLf, onResize, projectHash, projectSlug, recordActualUsage, repairToolUseAdjacency, resetCalibration, resolveWstackPaths, safeParse, safeStringify, sanitizeJsonString, setOutputLineGuard, setRawMode, sleep, stripAnsi, toStyle, unifiedDiff, validateAgainstSchema, writeErr, writeOut };
|
|
1360
1414
|
//# sourceMappingURL=index.js.map
|
|
1361
1415
|
//# sourceMappingURL=index.js.map
|