@wrongstack/core 0.73.1 → 0.82.6
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-C0Ze7Ldm.d.ts → agent-bridge-C9P_HPez.d.ts} +2 -2
- package/dist/{agent-subagent-runner-BmITbs1Q.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 +382 -43
- package/dist/coordination/index.js.map +1 -1
- package/dist/defaults/index.d.ts +31 -31
- package/dist/defaults/index.js +524 -110
- 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-BBAlxBuw.d.ts → events-DnRqXaZ3.d.ts} +77 -39
- package/dist/execution/index.d.ts +53 -53
- package/dist/execution/index.js +67 -23
- 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-yQbZ2NQx.d.ts → index-BNOLadHw.d.ts} +28 -28
- package/dist/{index-BN6i2Nfg.d.ts → index-N0_c4bHQ.d.ts} +45 -45
- package/dist/index.d.ts +233 -160
- package/dist/index.js +825 -160
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/index.d.ts +9 -9
- package/dist/infrastructure/index.js +29 -7
- 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-bOzkF5LL.d.ts → logger-C_27pj9i.d.ts} +12 -4
- 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-BSBbZt0e.d.ts → multi-agent-coordinator-DllpCVkF.d.ts} +12 -12
- package/dist/{null-fleet-bus-BCIRT_nV.d.ts → null-fleet-bus-BY0AN-sr.d.ts} +129 -120
- 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-CjAYGaCw.d.ts → parallel-eternal-engine-D402RASp.d.ts} +49 -49
- package/dist/{path-resolver-BnqXa9Ze.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-DBgrTGPu.d.ts → plan-templates-DRvPgkfZ.d.ts} +70 -32
- package/dist/{provider-runner-n3KkHT_w.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/security/index.d.ts +6 -6
- package/dist/security/index.js +7 -1
- 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 +398 -80
- 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 +25 -25
- package/dist/types/index.js +61 -12
- package/dist/types/index.js.map +1 -1
- package/dist/utils/index.d.ts +46 -45
- package/dist/utils/index.js +64 -13
- package/dist/utils/index.js.map +1 -1
- package/dist/{wstack-paths-eMXnY1_X.d.ts → wstack-paths-BQMvEllz.d.ts} +10 -3
- 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, 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
|
|
@@ -234,8 +254,8 @@ declare function buildChildEnv(optsOrSessionId?: BuildChildEnvOptions | string):
|
|
|
234
254
|
* Extracted from Agent.executeTools to allow reuse and consistent output handling.
|
|
235
255
|
*/
|
|
236
256
|
interface ToolOutputSerializerOptions {
|
|
237
|
-
perIterationOutputCapBytes?: number;
|
|
238
|
-
estimator?: (text: string) => number;
|
|
257
|
+
perIterationOutputCapBytes?: number | undefined;
|
|
258
|
+
estimator?: ((text: string) => number) | undefined;
|
|
239
259
|
}
|
|
240
260
|
declare function createToolOutputSerializer(opts?: ToolOutputSerializerOptions): {
|
|
241
261
|
serialize: (value: unknown) => string;
|
|
@@ -246,25 +266,6 @@ declare function createToolOutputSerializer(opts?: ToolOutputSerializerOptions):
|
|
|
246
266
|
capBytes: number;
|
|
247
267
|
};
|
|
248
268
|
|
|
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
269
|
/**
|
|
269
270
|
* Estimate tokens for a tool_use block input.
|
|
270
271
|
* Caches the stringified result keyed by the stable string representation
|
|
@@ -286,7 +287,7 @@ declare function estimateTextTokens(text: string): number;
|
|
|
286
287
|
*/
|
|
287
288
|
declare function estimateToolDefTokens(tool: {
|
|
288
289
|
name: string;
|
|
289
|
-
description?: string;
|
|
290
|
+
description?: string | undefined;
|
|
290
291
|
inputSchema: unknown;
|
|
291
292
|
}): number;
|
|
292
293
|
/**
|
|
@@ -309,7 +310,7 @@ interface RequestTokenBreakdown {
|
|
|
309
310
|
}
|
|
310
311
|
declare function estimateRequestTokens(messages: unknown, systemPrompt: unknown, tools: {
|
|
311
312
|
name: string;
|
|
312
|
-
description?: string;
|
|
313
|
+
description?: string | undefined;
|
|
313
314
|
inputSchema: unknown;
|
|
314
315
|
}[]): RequestTokenBreakdown;
|
|
315
316
|
/**
|
|
@@ -345,7 +346,7 @@ declare function getCalibrationState(): {
|
|
|
345
346
|
*/
|
|
346
347
|
declare function estimateRequestTokensCalibrated(messages: unknown, systemPrompt: unknown, tools: {
|
|
347
348
|
name: string;
|
|
348
|
-
description?: string;
|
|
349
|
+
description?: string | undefined;
|
|
349
350
|
inputSchema: unknown;
|
|
350
351
|
}[]): RequestTokenBreakdown;
|
|
351
352
|
/**
|
|
@@ -489,4 +490,4 @@ declare function mergeModelsPayload(base: ModelsDevPayload, overlay: ModelsDevPa
|
|
|
489
490
|
*/
|
|
490
491
|
declare function mergeCustomModelDefs(providerCustomModels: Record<string, CustomModelDefinition> | undefined, configModels: Record<string, CustomModelDefinition> | undefined): Record<string, CustomModelDefinition> | undefined;
|
|
491
492
|
|
|
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 };
|
|
493
|
+
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, formatTodosList, getCalibrationState, getTermSize, isInteractive, isStdinTTY, isStdoutTTY, matchAny, matchGlob, mergeCustomModelDefs, mergeModelsPayload, normalizeToLf, onResize, recordActualUsage, repairToolUseAdjacency, resetCalibration, safeParse, safeStringify, sanitizeJsonString, setOutputLineGuard, setRawMode, 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);
|
|
@@ -535,11 +552,20 @@ function unifiedDiff(oldText, newText, opts = {}) {
|
|
|
535
552
|
function projectHash(absRoot) {
|
|
536
553
|
return createHash("sha256").update(path2.resolve(absRoot)).digest("hex").slice(0, 12);
|
|
537
554
|
}
|
|
555
|
+
function projectSlug(absRoot) {
|
|
556
|
+
const base = slugify(path2.basename(absRoot));
|
|
557
|
+
const hash = createHash("sha256").update(path2.resolve(absRoot)).digest("hex").slice(0, 6);
|
|
558
|
+
return `${base}-${hash}`;
|
|
559
|
+
}
|
|
560
|
+
function slugify(name) {
|
|
561
|
+
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 40) || "project";
|
|
562
|
+
}
|
|
538
563
|
function resolveWstackPaths(opts) {
|
|
539
564
|
const home = opts.userHome ?? os.homedir();
|
|
540
565
|
const globalRoot = opts.globalRoot ?? path2.join(home, ".wrongstack");
|
|
541
566
|
const hash = projectHash(opts.projectRoot);
|
|
542
|
-
const
|
|
567
|
+
const slug = projectSlug(opts.projectRoot);
|
|
568
|
+
const projectDir = path2.join(globalRoot, "projects", slug);
|
|
543
569
|
return {
|
|
544
570
|
globalRoot,
|
|
545
571
|
configDir: globalRoot,
|
|
@@ -564,6 +590,7 @@ function resolveWstackPaths(opts) {
|
|
|
564
590
|
inProjectSkills: path2.join(opts.projectRoot, ".wrongstack", "skills"),
|
|
565
591
|
inProjectWorktrees: path2.join(opts.projectRoot, ".wrongstack", "worktrees"),
|
|
566
592
|
projectHash: hash,
|
|
593
|
+
projectSlug: slug,
|
|
567
594
|
projectGoal: path2.join(projectDir, "goal.json"),
|
|
568
595
|
projectSpecs: path2.join(projectDir, "specs"),
|
|
569
596
|
projectTaskGraphs: path2.join(projectDir, "task-graphs"),
|
|
@@ -708,6 +735,12 @@ function createToolOutputSerializer(opts = {}) {
|
|
|
708
735
|
}
|
|
709
736
|
|
|
710
737
|
// src/utils/token-estimate.ts
|
|
738
|
+
function expectDefined2(value) {
|
|
739
|
+
if (value === null || value === void 0) {
|
|
740
|
+
throw new Error("Expected value to be defined");
|
|
741
|
+
}
|
|
742
|
+
return value;
|
|
743
|
+
}
|
|
711
744
|
var RoughTokenEstimate = (text, charsPerToken = 3.5) => Math.max(1, Math.ceil(text.length / charsPerToken));
|
|
712
745
|
var _cal = {
|
|
713
746
|
ratio: 1,
|
|
@@ -728,7 +761,7 @@ function getCachedEstimate(key, compute) {
|
|
|
728
761
|
if (ESTIMATE_CACHE.size >= ESTIMATE_CACHE_MAX_SIZE) {
|
|
729
762
|
const keys = [...ESTIMATE_CACHE.keys()];
|
|
730
763
|
for (let i = 0; i < Math.floor(ESTIMATE_CACHE_MAX_SIZE / 4); i++) {
|
|
731
|
-
ESTIMATE_CACHE.delete(keys[i]);
|
|
764
|
+
ESTIMATE_CACHE.delete(expectDefined2(keys[i]));
|
|
732
765
|
}
|
|
733
766
|
}
|
|
734
767
|
const estimate = compute();
|
|
@@ -841,6 +874,12 @@ function resetCalibration() {
|
|
|
841
874
|
}
|
|
842
875
|
|
|
843
876
|
// src/utils/message-invariants.ts
|
|
877
|
+
function expectDefined3(value) {
|
|
878
|
+
if (value === null || value === void 0) {
|
|
879
|
+
throw new Error("Expected value to be defined");
|
|
880
|
+
}
|
|
881
|
+
return value;
|
|
882
|
+
}
|
|
844
883
|
function repairToolUseAdjacency(messages) {
|
|
845
884
|
const removedToolUses = [];
|
|
846
885
|
const removedToolResults = [];
|
|
@@ -848,7 +887,7 @@ function repairToolUseAdjacency(messages) {
|
|
|
848
887
|
let changed = false;
|
|
849
888
|
const out = [];
|
|
850
889
|
for (let i = 0; i < messages.length; i++) {
|
|
851
|
-
const original = messages[i];
|
|
890
|
+
const original = expectDefined3(messages[i]);
|
|
852
891
|
let msg = original;
|
|
853
892
|
if (hasToolUse(msg)) {
|
|
854
893
|
const nextIds = toolResultIds(messages[i + 1]);
|
|
@@ -1061,6 +1100,12 @@ function compileUserRegex(pattern, flags) {
|
|
|
1061
1100
|
};
|
|
1062
1101
|
}
|
|
1063
1102
|
}
|
|
1103
|
+
function expectDefined4(value) {
|
|
1104
|
+
if (value === null || value === void 0) {
|
|
1105
|
+
throw new Error("Expected value to be defined");
|
|
1106
|
+
}
|
|
1107
|
+
return value;
|
|
1108
|
+
}
|
|
1064
1109
|
var GLOB_CHARS = /* @__PURE__ */ new Set(["*", "?", "["]);
|
|
1065
1110
|
var IS_WINDOWS = process.platform === "win32";
|
|
1066
1111
|
var SEP = IS_WINDOWS ? "\\" : "/";
|
|
@@ -1074,7 +1119,7 @@ function globToRegex(pat) {
|
|
|
1074
1119
|
let i = 0;
|
|
1075
1120
|
let re = "^";
|
|
1076
1121
|
while (i < pat.length) {
|
|
1077
|
-
const c = pat[i];
|
|
1122
|
+
const c = expectDefined4(pat[i]);
|
|
1078
1123
|
if (c === "*") {
|
|
1079
1124
|
if (pat[i + 1] === "*") {
|
|
1080
1125
|
re += ".*";
|
|
@@ -1113,7 +1158,7 @@ function globToRegex(pat) {
|
|
|
1113
1158
|
}
|
|
1114
1159
|
function baseDir(pat) {
|
|
1115
1160
|
let i = pat.length - 1;
|
|
1116
|
-
while (i >= 0 && !GLOB_CHARS.has(pat[i]) && pat[i] !== SEP && pat[i] !== "/") i--;
|
|
1161
|
+
while (i >= 0 && !GLOB_CHARS.has(expectDefined4(pat[i])) && pat[i] !== SEP && pat[i] !== "/") i--;
|
|
1117
1162
|
const cut = i >= 0 ? pat.lastIndexOf(SEP, i) : pat.lastIndexOf("/", i);
|
|
1118
1163
|
return cut < 0 ? "." : pat.slice(0, cut);
|
|
1119
1164
|
}
|
|
@@ -1178,6 +1223,12 @@ async function expandGlob(pattern) {
|
|
|
1178
1223
|
}
|
|
1179
1224
|
|
|
1180
1225
|
// src/utils/json-repair.ts
|
|
1226
|
+
function expectDefined5(value) {
|
|
1227
|
+
if (value === null || value === void 0) {
|
|
1228
|
+
throw new Error("Expected value to be defined");
|
|
1229
|
+
}
|
|
1230
|
+
return value;
|
|
1231
|
+
}
|
|
1181
1232
|
function completePartialObject(s) {
|
|
1182
1233
|
if (!s.trim().startsWith("{")) return s;
|
|
1183
1234
|
if (tryParse(s).ok) return s;
|
|
@@ -1189,7 +1240,7 @@ function completePartialObject(s) {
|
|
|
1189
1240
|
let contentEnd = 0;
|
|
1190
1241
|
let stringBraceDepth = 0;
|
|
1191
1242
|
for (let i = 0; i < s.length; i++) {
|
|
1192
|
-
const ch = s[i];
|
|
1243
|
+
const ch = expectDefined5(s[i]);
|
|
1193
1244
|
if (inString) {
|
|
1194
1245
|
contentEnd = i + 1;
|
|
1195
1246
|
if (escaped) {
|
|
@@ -1346,6 +1397,6 @@ function mergeCustomModelDefs(providerCustomModels, configModels) {
|
|
|
1346
1397
|
return out;
|
|
1347
1398
|
}
|
|
1348
1399
|
|
|
1349
|
-
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, recordActualUsage, repairToolUseAdjacency, resetCalibration, resolveWstackPaths, safeParse, safeStringify, sanitizeJsonString, setRawMode, stripAnsi, toStyle, unifiedDiff, validateAgainstSchema, writeErr, writeOut };
|
|
1400
|
+
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, setOutputLineGuard, setRawMode, stripAnsi, toStyle, unifiedDiff, validateAgainstSchema, writeErr, writeOut };
|
|
1350
1401
|
//# sourceMappingURL=index.js.map
|
|
1351
1402
|
//# sourceMappingURL=index.js.map
|