@wrongstack/core 0.275.0 → 0.276.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/dist/{agent-bridge-D9JkPvJ0.d.ts → agent-bridge-D7A-eu3C.d.ts} +1 -1
- package/dist/{agent-subagent-runner-CArSFKFl.d.ts → agent-subagent-runner-CEuw4ATz.d.ts} +16 -10
- package/dist/{brain-DCkB5_e7.d.ts → brain-BLOyN5ZP.d.ts} +127 -1
- package/dist/{compactor-CzSvxM1g.d.ts → compactor-DcBpaJsI.d.ts} +1 -1
- package/dist/{config-BzFRKkg7.d.ts → config-Bf5mj-ad.d.ts} +20 -2
- package/dist/{context-BrLe8pJy.d.ts → context-CLnUMW5g.d.ts} +40 -2
- package/dist/coordination/index.d.ts +43 -24
- package/dist/coordination/index.js +849 -648
- package/dist/coordination/index.js.map +1 -1
- package/dist/defaults/index.d.ts +28 -28
- package/dist/defaults/index.js +1636 -845
- package/dist/defaults/index.js.map +1 -1
- package/dist/execution/index.d.ts +16 -16
- package/dist/execution/index.js +218 -49
- package/dist/execution/index.js.map +1 -1
- package/dist/execution/prompt-enhancer.d.ts +1 -1
- package/dist/extension/index.d.ts +7 -7
- package/dist/extension/index.js.map +1 -1
- package/dist/{global-mailbox-CXkugtNQ.d.ts → global-mailbox-Iqfkgmwu.d.ts} +3 -3
- package/dist/{goal-store-DUwdbdoY.d.ts → goal-store-DGb6b5Ed.d.ts} +1 -1
- package/dist/hq/index.d.ts +6 -6
- package/dist/hq/index.js +178 -75
- package/dist/hq/index.js.map +1 -1
- package/dist/{index-CtlizLTK.d.ts → index-Cn0NOshr.d.ts} +10 -5
- package/dist/{index-neOCEy6q.d.ts → index-L4RZN9jJ.d.ts} +2 -2
- package/dist/index.d.ts +56 -48
- package/dist/index.js +2789 -1546
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/index.d.ts +6 -6
- package/dist/infrastructure/index.js +26 -7
- package/dist/infrastructure/index.js.map +1 -1
- package/dist/kernel/index.d.ts +20 -12
- package/dist/kernel/index.js +55 -9
- package/dist/kernel/index.js.map +1 -1
- package/dist/{mailbox-types-_7gaY0Rl.d.ts → mailbox-types-DTl7bRH3.d.ts} +3 -1
- package/dist/{mcp-servers-MLL6bMlv.d.ts → mcp-servers-CuZGf9fI.d.ts} +4 -4
- package/dist/models/index.d.ts +5 -5
- package/dist/models/index.js +223 -139
- package/dist/models/index.js.map +1 -1
- package/dist/{models-registry-CrkcxQ-g.d.ts → models-registry-8XOdxWQu.d.ts} +16 -1
- package/dist/{multi-agent-coordinator-Dc_HuG9p.d.ts → multi-agent-coordinator-CiRtKVTk.d.ts} +8 -1
- package/dist/{null-fleet-bus-BMZwMin7.d.ts → null-fleet-bus-d9G-bVy9.d.ts} +26 -22
- package/dist/observability/index.d.ts +2 -2
- package/dist/{path-resolver-uVK4BatM.d.ts → path-resolver-BhIb6mtd.d.ts} +8 -3
- package/dist/{permission-CJR1qfOi.d.ts → permission-BCbQDR2s.d.ts} +1 -1
- package/dist/{permission-policy-DLVKKk4w.d.ts → permission-policy-C0ikndX_.d.ts} +2 -18
- package/dist/{pipeline-BYR-Vdau.d.ts → pipeline-Dl6XbfE7.d.ts} +10 -6
- package/dist/{provider-model-resolve-iREK_1lG.d.ts → provider-model-resolve-B70epO19.d.ts} +3 -3
- package/dist/{provider-runner-i7SQXZuC.d.ts → provider-runner-DZ808MSM.d.ts} +3 -3
- package/dist/{retry-policy-BmY5ooh3.d.ts → retry-policy-Dt3_z8Aj.d.ts} +1 -1
- package/dist/sdd/index.d.ts +19 -10
- package/dist/sdd/index.js +411 -240
- package/dist/sdd/index.js.map +1 -1
- package/dist/{secret-vault-C9leEMzr.d.ts → secret-vault-BUJ2d1gB.d.ts} +1 -1
- package/dist/security/index.d.ts +5 -5
- package/dist/security/index.js +30 -6
- package/dist/security/index.js.map +1 -1
- package/dist/{selector-qjpee9BF.d.ts → selector-BCkWgdwy.d.ts} +1 -1
- package/dist/{session-event-bridge-m7y--I-H.d.ts → session-event-bridge-CMvIO59_.d.ts} +1 -1
- package/dist/{session-reader-BjLH4V9n.d.ts → session-reader-C8aiChUu.d.ts} +1 -1
- package/dist/skills/index.js +1 -0
- package/dist/skills/index.js.map +1 -1
- package/dist/storage/index.d.ts +68 -30
- package/dist/storage/index.js +839 -528
- package/dist/storage/index.js.map +1 -1
- package/dist/{strategy-compactor-C2bmlWYg.d.ts → strategy-compactor-DI1OHVbB.d.ts} +10 -10
- package/dist/{todos-checkpoint-oDS9IBNS.d.ts → todos-checkpoint-Ddd2CGr0.d.ts} +56 -9
- package/dist/{tool-executor-D4YdaJ-M.d.ts → tool-executor-Bmd5Ygoo.d.ts} +45 -10
- package/dist/tools/index.d.ts +2 -2
- package/dist/tools/index.js.map +1 -1
- package/dist/types/index.d.ts +20 -20
- package/dist/types/index.js +331 -98
- package/dist/types/index.js.map +1 -1
- package/dist/utils/index.d.ts +16 -3
- package/dist/utils/index.js +159 -83
- package/dist/utils/index.js.map +1 -1
- package/dist/{worktree-manager-A1Efnvs0.d.ts → worktree-manager-DBdl_5rs.d.ts} +4 -1
- package/instructions/agents/shadow-agent.md +3 -3
- package/instructions/coordination/director-preamble.md +3 -3
- package/instructions/modes/research-web.md +4 -4
- package/package.json +1 -1
- package/skills/research-web/SKILL.md +26 -26
- package/skills/research-web/SKILL.save.md +1 -1
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { C as Context,
|
|
1
|
+
import { C as Context, D as ContextEvidenceState, n as ToolOutputMetadata, J as JSONSchema, M as Message, z as TodoItem, T as Tool } from '../context-CLnUMW5g.js';
|
|
2
2
|
export { H as HttpDispatcher, a as HttpsAgentAsDispatcher } from '../dispatcher-types.d-BBeXBQgS.js';
|
|
3
3
|
export { toErrorMessage } from './error.js';
|
|
4
4
|
export { expectDefined } from './expect-defined.js';
|
|
5
|
-
import { x as CustomModelDefinition, a as ModelsDevPayload, _ as ToolDescriptionMode, $ as ToolDescriptionModeConfig, T as ToolResultRenderMode, a0 as ToolResultRenderModeConfig } from '../config-
|
|
5
|
+
import { x as CustomModelDefinition, a as ModelsDevPayload, _ as ToolDescriptionMode, $ as ToolDescriptionModeConfig, T as ToolResultRenderMode, a0 as ToolResultRenderModeConfig } from '../config-Bf5mj-ad.js';
|
|
6
6
|
export { T as TaskItem, c as computeTaskItemProgress, f as formatTaskList, a as formatTaskProgress } from '../task-format-vGOIftmK.js';
|
|
7
7
|
export { a as WstackPathOptions, W as WstackPaths, p as projectHash, b as projectSlug, r as resolveWstackPaths, w as wstackGlobalRoot } from '../wstack-paths-_NrRovdr.js';
|
|
8
8
|
export { a as TaskPriority, b as TaskStatus, T as TaskType } from '../task-graph-u1q9Jkyk.js';
|
|
@@ -394,6 +394,19 @@ declare function safeStringify(value: unknown, pretty?: boolean): string;
|
|
|
394
394
|
*/
|
|
395
395
|
declare function sanitizeJsonString(s: string): string | null;
|
|
396
396
|
|
|
397
|
+
/**
|
|
398
|
+
* Resolve `<dir>/<sessionId><suffix>` for per-session sidecar files
|
|
399
|
+
* (annotations, audit chain, replay log, the session JSONL itself).
|
|
400
|
+
*
|
|
401
|
+
* Modern session ids are date-sharded ("2026-06-11/sess_<ULID>"),
|
|
402
|
+
* so a forward slash is a legitimate shard separator — NOT traversal.
|
|
403
|
+
* Escape attempts are blocked two ways: an explicit ban on `..` and
|
|
404
|
+
* backslashes, plus a resolved-path containment check that rejects any
|
|
405
|
+
* id whose resolved target leaves `dir`. Character bans alone are how
|
|
406
|
+
* several stores ended up throwing on every modern session id.
|
|
407
|
+
*/
|
|
408
|
+
declare function sessionScopedPath(dir: string, sessionId: string, suffix: string): string;
|
|
409
|
+
|
|
397
410
|
/**
|
|
398
411
|
* Turn an arbitrary string into a filesystem- and URL-safe lowercase slug.
|
|
399
412
|
*
|
|
@@ -831,4 +844,4 @@ interface CompactWireToolDefinition {
|
|
|
831
844
|
declare function compactToolDefinitionForWire(tool: ToolWireDefinitionLike, opts?: CompactToolDefinitionForWireOptions): CompactWireToolDefinition;
|
|
832
845
|
declare function compactSchemaDescriptions(schema: unknown, maxDescriptionChars?: number): Record<string, unknown>;
|
|
833
846
|
|
|
834
|
-
export { type AtomicWriteOptions, type BuildChildEnvOptions, type CompactToolDefinitionForWireOptions, type CompactWireToolDefinition, type CompileFail, type CompileResult, DEFAULT_TOOL_DESCRIPTION_MODE, DEFAULT_TOOL_RESULT_RENDER_MODE, type DeepMergeOptions, FORBIDDEN_PROTO_KEYS, type FileLockOptions, type JsonObject, type JsonPath, type JsonPathSegment, type MessageRepairReport, type MessageRepairResult, type NewlineStyle, type OutputLineGuard, type RecordToolOutputEvidenceInput, type RequestTokenBreakdown, type SafeParseResult, type ToolDescriptionRegistryLike, type ToolOutputSerializerOptions, type ToolResultRenderModeRegistryLike, type ToolWireDefinitionLike, type UnifiedDiffOptions, type ValidationError, type ValidationResult, applyToolDescriptionModeToTool, applyToolDescriptionModes, applyToolResultRenderModes, assertNever, assertNotPrivateHost, atomicWrite, buildChildEnv, buildContextEvidenceDigest, color, compactSchemaDescriptions, compactToolDefinitionForWire, compileGlob, compileUserRegex, completePartialObject, computeMessageTokens, createContextEvidenceState, createToolOutputSerializer, deepMerge, detectNewlineStyle, ensureDir, escapeGlobSubject, estimateMessageTokens, estimateRequestTokens, estimateRequestTokensCalibrated, estimateTextTokens, estimateToolDefTokens, estimateToolInputTokens, estimateToolResultTokens, expandGlob, expandIPv6, formatTodosList, getCalibrationState, getJsonPath, getTermSize, getToolDescriptionMode, getToolResultRenderMode, isInteractive, isJsonObject, isPathSubjectKey, isPrimitiveArray, isPrivateIPv4, isPrivateIPv6, isStdinTTY, isStdoutTTY, isUlid, jsonObjectFileExists, markAssistantReferencedEvidence, matchAny, matchGlob, mergeCustomModelDefs, mergeModelsPayload, normalizePathSubject, normalizeToLf, normalizeToolDescriptionMode, normalizeToolResultRenderMode, onResize, readJsonObjectFile, recordActualUsage, recordToolOutputEvidence, recordUserIntentEvidence, removeJsonPath, removeJsonPathInFile, repairToolUseAdjacency, repeatedReadPressure, resetCalibration, resolveToolDescriptionMode, resolveToolResultRenderMode, safeParse, safeStringify, sanitizeJsonString, sanitizeNodeOptions, setJsonPath, setJsonPathInFile, setOutputLineGuard, setRawMode, setToolDescriptionMode, setToolResultRenderMode, simplifyToolDescription, sleep, slugify, stripAnsi, subjectForToolInput, toStyle, truncate, ulid, unifiedDiff, updateJsonObjectFile, validateAgainstSchema, withFileLock, writeErr, writeJsonObjectFile, writeOut };
|
|
847
|
+
export { type AtomicWriteOptions, type BuildChildEnvOptions, type CompactToolDefinitionForWireOptions, type CompactWireToolDefinition, type CompileFail, type CompileResult, DEFAULT_TOOL_DESCRIPTION_MODE, DEFAULT_TOOL_RESULT_RENDER_MODE, type DeepMergeOptions, FORBIDDEN_PROTO_KEYS, type FileLockOptions, type JsonObject, type JsonPath, type JsonPathSegment, type MessageRepairReport, type MessageRepairResult, type NewlineStyle, type OutputLineGuard, type RecordToolOutputEvidenceInput, type RequestTokenBreakdown, type SafeParseResult, type ToolDescriptionRegistryLike, type ToolOutputSerializerOptions, type ToolResultRenderModeRegistryLike, type ToolWireDefinitionLike, type UnifiedDiffOptions, type ValidationError, type ValidationResult, applyToolDescriptionModeToTool, applyToolDescriptionModes, applyToolResultRenderModes, assertNever, assertNotPrivateHost, atomicWrite, buildChildEnv, buildContextEvidenceDigest, color, compactSchemaDescriptions, compactToolDefinitionForWire, compileGlob, compileUserRegex, completePartialObject, computeMessageTokens, createContextEvidenceState, createToolOutputSerializer, deepMerge, detectNewlineStyle, ensureDir, escapeGlobSubject, estimateMessageTokens, estimateRequestTokens, estimateRequestTokensCalibrated, estimateTextTokens, estimateToolDefTokens, estimateToolInputTokens, estimateToolResultTokens, expandGlob, expandIPv6, formatTodosList, getCalibrationState, getJsonPath, getTermSize, getToolDescriptionMode, getToolResultRenderMode, isInteractive, isJsonObject, isPathSubjectKey, isPrimitiveArray, isPrivateIPv4, isPrivateIPv6, isStdinTTY, isStdoutTTY, isUlid, jsonObjectFileExists, markAssistantReferencedEvidence, matchAny, matchGlob, mergeCustomModelDefs, mergeModelsPayload, normalizePathSubject, normalizeToLf, normalizeToolDescriptionMode, normalizeToolResultRenderMode, onResize, readJsonObjectFile, recordActualUsage, recordToolOutputEvidence, recordUserIntentEvidence, removeJsonPath, removeJsonPathInFile, repairToolUseAdjacency, repeatedReadPressure, resetCalibration, resolveToolDescriptionMode, resolveToolResultRenderMode, safeParse, safeStringify, sanitizeJsonString, sanitizeNodeOptions, sessionScopedPath, setJsonPath, setJsonPathInFile, setOutputLineGuard, setRawMode, setToolDescriptionMode, setToolResultRenderMode, simplifyToolDescription, sleep, slugify, stripAnsi, subjectForToolInput, toStyle, truncate, ulid, unifiedDiff, updateJsonObjectFile, validateAgainstSchema, withFileLock, writeErr, writeJsonObjectFile, writeOut };
|
package/dist/utils/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { randomBytes, createHash } from 'crypto';
|
|
2
2
|
import * as fs from 'fs/promises';
|
|
3
|
-
import * as
|
|
3
|
+
import * as path4 from 'path';
|
|
4
4
|
import { isAbsolute, resolve } from 'path';
|
|
5
5
|
import * as dns from 'dns/promises';
|
|
6
6
|
import * as net from 'net';
|
|
@@ -14,10 +14,62 @@ function assertNever(x, message) {
|
|
|
14
14
|
err.name = "AssertNeverError";
|
|
15
15
|
throw err;
|
|
16
16
|
}
|
|
17
|
+
|
|
18
|
+
// src/types/errors.ts
|
|
19
|
+
var ERROR_CODES = {
|
|
20
|
+
// File system
|
|
21
|
+
FS_READ_FAILED: "FS_READ_FAILED",
|
|
22
|
+
FS_DELETE_FAILED: "FS_DELETE_FAILED"};
|
|
23
|
+
var WrongStackError = class extends Error {
|
|
24
|
+
code;
|
|
25
|
+
subsystem;
|
|
26
|
+
severity;
|
|
27
|
+
recoverable;
|
|
28
|
+
context;
|
|
29
|
+
constructor(opts) {
|
|
30
|
+
super(opts.message, { cause: opts.cause });
|
|
31
|
+
this.name = "WrongStackError";
|
|
32
|
+
this.code = opts.code;
|
|
33
|
+
this.subsystem = opts.subsystem;
|
|
34
|
+
this.severity = opts.severity ?? "error";
|
|
35
|
+
this.recoverable = opts.recoverable ?? false;
|
|
36
|
+
this.context = opts.context;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Render a one-line user-facing description.
|
|
40
|
+
* Subclasses should override for domain-specific formatting.
|
|
41
|
+
*/
|
|
42
|
+
describe() {
|
|
43
|
+
const ctx = this.context ? ` ${formatContext(this.context)}` : "";
|
|
44
|
+
return `${this.code}: ${this.message}${ctx}`;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
function formatContext(ctx) {
|
|
48
|
+
const parts = Object.entries(ctx).filter(([, v]) => v !== void 0).slice(0, 3).map(([k, v]) => `${k}=${String(v)}`);
|
|
49
|
+
return parts.length > 0 ? `[${parts.join(" ")}]` : "";
|
|
50
|
+
}
|
|
51
|
+
var FsError = class extends WrongStackError {
|
|
52
|
+
path;
|
|
53
|
+
constructor(opts) {
|
|
54
|
+
super({
|
|
55
|
+
message: opts.message,
|
|
56
|
+
code: opts.code,
|
|
57
|
+
subsystem: "fs",
|
|
58
|
+
severity: "error",
|
|
59
|
+
recoverable: opts.code !== ERROR_CODES.FS_READ_FAILED,
|
|
60
|
+
context: { path: opts.path, ...opts.context },
|
|
61
|
+
cause: opts.cause
|
|
62
|
+
});
|
|
63
|
+
this.name = "FsError";
|
|
64
|
+
this.path = opts.path;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// src/utils/atomic-write.ts
|
|
17
69
|
async function atomicWrite(targetPath, content, opts = {}) {
|
|
18
|
-
const dir =
|
|
70
|
+
const dir = path4.dirname(targetPath);
|
|
19
71
|
await fs.mkdir(dir, { recursive: true });
|
|
20
|
-
const tmp =
|
|
72
|
+
const tmp = path4.join(dir, `.${path4.basename(targetPath)}.${randomBytes(6).toString("hex")}.tmp`);
|
|
21
73
|
try {
|
|
22
74
|
if (typeof content === "string") {
|
|
23
75
|
await fs.writeFile(tmp, content, { flag: "wx", encoding: opts.encoding ?? "utf8" });
|
|
@@ -62,9 +114,9 @@ async function ensureDir(dir) {
|
|
|
62
114
|
await fs.mkdir(dir, { recursive: true });
|
|
63
115
|
}
|
|
64
116
|
async function withFileLock(targetPath, fn, opts = {}) {
|
|
65
|
-
const dir =
|
|
117
|
+
const dir = path4.dirname(targetPath);
|
|
66
118
|
await fs.mkdir(dir, { recursive: true });
|
|
67
|
-
const lockPath =
|
|
119
|
+
const lockPath = path4.join(dir, `.${path4.basename(targetPath)}.lock`);
|
|
68
120
|
const timeoutMs = opts.timeoutMs ?? 5e3;
|
|
69
121
|
const staleMs = opts.staleMs ?? 3e4;
|
|
70
122
|
const started = Date.now();
|
|
@@ -91,9 +143,14 @@ async function withFileLock(targetPath, fn, opts = {}) {
|
|
|
91
143
|
continue;
|
|
92
144
|
}
|
|
93
145
|
if (Date.now() - started >= timeoutMs) {
|
|
94
|
-
throw new
|
|
146
|
+
throw new FsError({
|
|
147
|
+
message: `Timed out waiting for file lock: ${targetPath}`,
|
|
148
|
+
code: "FS_ATOMIC_WRITE_FAILED",
|
|
149
|
+
path: targetPath,
|
|
150
|
+
context: { timeoutMs }
|
|
151
|
+
});
|
|
95
152
|
}
|
|
96
|
-
await new Promise((
|
|
153
|
+
await new Promise((resolve5) => setTimeout(resolve5, 25));
|
|
97
154
|
}
|
|
98
155
|
}
|
|
99
156
|
try {
|
|
@@ -127,7 +184,7 @@ async function renameWithRetry(from, to) {
|
|
|
127
184
|
if (!code || !TRANSIENT_RENAME_CODES.has(code) || i === delays.length) {
|
|
128
185
|
throw err;
|
|
129
186
|
}
|
|
130
|
-
await new Promise((
|
|
187
|
+
await new Promise((resolve5) => setTimeout(resolve5, delays[i]));
|
|
131
188
|
}
|
|
132
189
|
}
|
|
133
190
|
throw lastErr;
|
|
@@ -375,9 +432,9 @@ async function updateJsonObjectFile(filePath, mutator) {
|
|
|
375
432
|
await writeJsonObjectFile(filePath, next);
|
|
376
433
|
return next;
|
|
377
434
|
}
|
|
378
|
-
function getJsonPath(root,
|
|
435
|
+
function getJsonPath(root, path5) {
|
|
379
436
|
let current = root;
|
|
380
|
-
for (const segment of
|
|
437
|
+
for (const segment of path5) {
|
|
381
438
|
if (typeof segment === "number") {
|
|
382
439
|
if (!Array.isArray(current)) return void 0;
|
|
383
440
|
current = current[segment];
|
|
@@ -388,13 +445,13 @@ function getJsonPath(root, path4) {
|
|
|
388
445
|
}
|
|
389
446
|
return current;
|
|
390
447
|
}
|
|
391
|
-
function setJsonPath(root,
|
|
392
|
-
if (
|
|
448
|
+
function setJsonPath(root, path5, value) {
|
|
449
|
+
if (path5.length === 0) {
|
|
393
450
|
if (!isJsonObject(value)) throw new Error("Root config value must be an object");
|
|
394
451
|
return value;
|
|
395
452
|
}
|
|
396
|
-
const parent = ensureJsonParent(root,
|
|
397
|
-
const leaf = lastPathSegment(
|
|
453
|
+
const parent = ensureJsonParent(root, path5);
|
|
454
|
+
const leaf = lastPathSegment(path5);
|
|
398
455
|
if (typeof leaf === "number") {
|
|
399
456
|
if (!Array.isArray(parent)) throw new Error(`Cannot set numeric segment ${leaf} on non-array parent`);
|
|
400
457
|
parent[leaf] = value;
|
|
@@ -404,10 +461,10 @@ function setJsonPath(root, path4, value) {
|
|
|
404
461
|
}
|
|
405
462
|
return root;
|
|
406
463
|
}
|
|
407
|
-
function removeJsonPath(root,
|
|
408
|
-
if (
|
|
409
|
-
const parent = getJsonPath(root,
|
|
410
|
-
const leaf = lastPathSegment(
|
|
464
|
+
function removeJsonPath(root, path5) {
|
|
465
|
+
if (path5.length === 0) return false;
|
|
466
|
+
const parent = getJsonPath(root, path5.slice(0, -1));
|
|
467
|
+
const leaf = lastPathSegment(path5);
|
|
411
468
|
if (typeof leaf === "number") {
|
|
412
469
|
if (!Array.isArray(parent) || leaf < 0 || leaf >= parent.length) return false;
|
|
413
470
|
parent.splice(leaf, 1);
|
|
@@ -417,27 +474,27 @@ function removeJsonPath(root, path4) {
|
|
|
417
474
|
delete parent[leaf];
|
|
418
475
|
return true;
|
|
419
476
|
}
|
|
420
|
-
async function setJsonPathInFile(filePath,
|
|
421
|
-
return updateJsonObjectFile(filePath, (config) => setJsonPath(config,
|
|
477
|
+
async function setJsonPathInFile(filePath, path5, value) {
|
|
478
|
+
return updateJsonObjectFile(filePath, (config) => setJsonPath(config, path5, value));
|
|
422
479
|
}
|
|
423
|
-
async function removeJsonPathInFile(filePath,
|
|
480
|
+
async function removeJsonPathInFile(filePath, path5) {
|
|
424
481
|
return updateJsonObjectFile(filePath, (config) => {
|
|
425
|
-
removeJsonPath(config,
|
|
482
|
+
removeJsonPath(config, path5);
|
|
426
483
|
});
|
|
427
484
|
}
|
|
428
485
|
function isJsonObject(value) {
|
|
429
486
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
430
487
|
}
|
|
431
|
-
function lastPathSegment(
|
|
432
|
-
const segment =
|
|
488
|
+
function lastPathSegment(path5) {
|
|
489
|
+
const segment = path5[path5.length - 1];
|
|
433
490
|
if (segment === void 0) throw new Error("Invalid empty JSON path");
|
|
434
491
|
return segment;
|
|
435
492
|
}
|
|
436
|
-
function ensureJsonParent(root,
|
|
493
|
+
function ensureJsonParent(root, path5) {
|
|
437
494
|
let current = root;
|
|
438
|
-
for (let i = 0; i <
|
|
439
|
-
const segment =
|
|
440
|
-
const nextSegment =
|
|
495
|
+
for (let i = 0; i < path5.length - 1; i += 1) {
|
|
496
|
+
const segment = path5[i];
|
|
497
|
+
const nextSegment = path5[i + 1];
|
|
441
498
|
if (segment === void 0) throw new Error("Invalid empty JSON path segment");
|
|
442
499
|
const nextContainer = typeof nextSegment === "number" ? [] : {};
|
|
443
500
|
if (typeof segment === "number") {
|
|
@@ -648,10 +705,10 @@ function addPath(ctx, out, raw) {
|
|
|
648
705
|
if (!clean || clean.length > 260) return;
|
|
649
706
|
let normalized = clean.replace(/\\/g, "/");
|
|
650
707
|
try {
|
|
651
|
-
const abs =
|
|
708
|
+
const abs = path4.isAbsolute(clean) ? path4.resolve(clean) : null;
|
|
652
709
|
if (abs) {
|
|
653
|
-
const rel =
|
|
654
|
-
if (!rel.startsWith("..") && !
|
|
710
|
+
const rel = path4.relative(ctx.projectRoot, abs);
|
|
711
|
+
if (!rel.startsWith("..") && !path4.isAbsolute(rel)) {
|
|
655
712
|
normalized = rel.replace(/\\/g, "/");
|
|
656
713
|
}
|
|
657
714
|
}
|
|
@@ -769,7 +826,7 @@ function implicitFactFor(metadata) {
|
|
|
769
826
|
function metadataReferencedByText(metadata, haystack) {
|
|
770
827
|
for (const file of metadata.files) {
|
|
771
828
|
const f = file.toLowerCase();
|
|
772
|
-
const base =
|
|
829
|
+
const base = path4.basename(file).toLowerCase();
|
|
773
830
|
if (f && haystack.includes(f)) return true;
|
|
774
831
|
if (base && haystack.includes(base)) return true;
|
|
775
832
|
}
|
|
@@ -1394,10 +1451,10 @@ function validateAgainstSchema(value, schema) {
|
|
|
1394
1451
|
return { ok: errors.length === 0, errors };
|
|
1395
1452
|
}
|
|
1396
1453
|
var MAX_SCHEMA_DEPTH = 64;
|
|
1397
|
-
function walk(value, schema,
|
|
1454
|
+
function walk(value, schema, path5, errors, depth) {
|
|
1398
1455
|
if (depth > MAX_SCHEMA_DEPTH) {
|
|
1399
1456
|
errors.push({
|
|
1400
|
-
path:
|
|
1457
|
+
path: path5 || "<root>",
|
|
1401
1458
|
message: `schema nesting exceeds maximum depth (${MAX_SCHEMA_DEPTH})`
|
|
1402
1459
|
});
|
|
1403
1460
|
return;
|
|
@@ -1405,7 +1462,7 @@ function walk(value, schema, path4, errors, depth) {
|
|
|
1405
1462
|
if (schema.enum !== void 0) {
|
|
1406
1463
|
if (!schema.enum.some((e) => deepEqual(e, value))) {
|
|
1407
1464
|
errors.push({
|
|
1408
|
-
path:
|
|
1465
|
+
path: path5 || "<root>",
|
|
1409
1466
|
message: `expected one of ${JSON.stringify(schema.enum)}, got ${JSON.stringify(value)}`
|
|
1410
1467
|
});
|
|
1411
1468
|
return;
|
|
@@ -1414,7 +1471,7 @@ function walk(value, schema, path4, errors, depth) {
|
|
|
1414
1471
|
if (typeof schema.type === "string") {
|
|
1415
1472
|
if (!checkType(value, schema.type)) {
|
|
1416
1473
|
errors.push({
|
|
1417
|
-
path:
|
|
1474
|
+
path: path5 || "<root>",
|
|
1418
1475
|
message: `expected ${schema.type}, got ${describeType(value)}`
|
|
1419
1476
|
});
|
|
1420
1477
|
return;
|
|
@@ -1424,20 +1481,20 @@ function walk(value, schema, path4, errors, depth) {
|
|
|
1424
1481
|
const obj = value;
|
|
1425
1482
|
for (const req of schema.required ?? []) {
|
|
1426
1483
|
if (!(req in obj)) {
|
|
1427
|
-
errors.push({ path: joinPath(
|
|
1484
|
+
errors.push({ path: joinPath(path5, req), message: "required property missing" });
|
|
1428
1485
|
}
|
|
1429
1486
|
}
|
|
1430
1487
|
if (schema.properties) {
|
|
1431
1488
|
for (const [key, subSchema] of Object.entries(schema.properties)) {
|
|
1432
1489
|
if (key in obj) {
|
|
1433
|
-
walk(obj[key], subSchema, joinPath(
|
|
1490
|
+
walk(obj[key], subSchema, joinPath(path5, key), errors, depth + 1);
|
|
1434
1491
|
}
|
|
1435
1492
|
}
|
|
1436
1493
|
}
|
|
1437
1494
|
}
|
|
1438
1495
|
if (schema.type === "array" && Array.isArray(value) && schema.items) {
|
|
1439
1496
|
for (let i = 0; i < value.length; i++) {
|
|
1440
|
-
walk(value[i], schema.items, `${
|
|
1497
|
+
walk(value[i], schema.items, `${path5}[${i}]`, errors, depth + 1);
|
|
1441
1498
|
}
|
|
1442
1499
|
}
|
|
1443
1500
|
}
|
|
@@ -1833,6 +1890,25 @@ function stripSingleLineComments(s) {
|
|
|
1833
1890
|
}
|
|
1834
1891
|
return chars.join("");
|
|
1835
1892
|
}
|
|
1893
|
+
function sessionScopedPath(dir, sessionId, suffix) {
|
|
1894
|
+
if (!sessionId || sessionId.includes("\\") || sessionId.includes("..")) {
|
|
1895
|
+
throw invalid(sessionId);
|
|
1896
|
+
}
|
|
1897
|
+
const resolved = path4.resolve(dir, `${sessionId}${suffix}`);
|
|
1898
|
+
const rel = path4.relative(path4.resolve(dir), resolved);
|
|
1899
|
+
if (rel.startsWith("..") || path4.isAbsolute(rel)) {
|
|
1900
|
+
throw invalid(sessionId);
|
|
1901
|
+
}
|
|
1902
|
+
return resolved;
|
|
1903
|
+
}
|
|
1904
|
+
function invalid(sessionId) {
|
|
1905
|
+
return new FsError({
|
|
1906
|
+
message: `Invalid sessionId: ${sessionId}`,
|
|
1907
|
+
code: ERROR_CODES.FS_DELETE_FAILED,
|
|
1908
|
+
path: sessionId,
|
|
1909
|
+
context: { reason: "path_traversal" }
|
|
1910
|
+
});
|
|
1911
|
+
}
|
|
1836
1912
|
|
|
1837
1913
|
// src/utils/slug.ts
|
|
1838
1914
|
function slugify(name, fallback = "prompt", maxLen = 64) {
|
|
@@ -1873,7 +1949,7 @@ function isUlid(value) {
|
|
|
1873
1949
|
|
|
1874
1950
|
// src/utils/sleep.ts
|
|
1875
1951
|
function sleep(ms) {
|
|
1876
|
-
return new Promise((
|
|
1952
|
+
return new Promise((resolve5) => setTimeout(resolve5, ms));
|
|
1877
1953
|
}
|
|
1878
1954
|
|
|
1879
1955
|
// src/utils/string.ts
|
|
@@ -3109,11 +3185,11 @@ function applyToolResultRenderModes(registry, modes) {
|
|
|
3109
3185
|
return { applied, missing };
|
|
3110
3186
|
}
|
|
3111
3187
|
function projectHash(absRoot) {
|
|
3112
|
-
return createHash("sha256").update(
|
|
3188
|
+
return createHash("sha256").update(path4.resolve(absRoot)).digest("hex").slice(0, 12);
|
|
3113
3189
|
}
|
|
3114
3190
|
function projectSlug(absRoot) {
|
|
3115
|
-
const base = slugify2(
|
|
3116
|
-
const hash = createHash("sha256").update(
|
|
3191
|
+
const base = slugify2(path4.basename(absRoot));
|
|
3192
|
+
const hash = createHash("sha256").update(path4.resolve(absRoot)).digest("hex").slice(0, 6);
|
|
3117
3193
|
return `${base}-${hash}`;
|
|
3118
3194
|
}
|
|
3119
3195
|
function slugify2(name) {
|
|
@@ -3121,58 +3197,58 @@ function slugify2(name) {
|
|
|
3121
3197
|
}
|
|
3122
3198
|
function wstackGlobalRoot() {
|
|
3123
3199
|
const fromEnv = process.env["WRONGSTACK_HOME"];
|
|
3124
|
-
if (fromEnv && fromEnv.trim().length > 0) return
|
|
3125
|
-
return
|
|
3200
|
+
if (fromEnv && fromEnv.trim().length > 0) return path4.resolve(fromEnv);
|
|
3201
|
+
return path4.join(os.homedir(), ".wrongstack");
|
|
3126
3202
|
}
|
|
3127
3203
|
function resolveWstackPaths(opts) {
|
|
3128
|
-
const globalRoot = opts.globalRoot ?? (opts.userHome ?
|
|
3204
|
+
const globalRoot = opts.globalRoot ?? (opts.userHome ? path4.join(opts.userHome, ".wrongstack") : wstackGlobalRoot());
|
|
3129
3205
|
const hash = projectHash(opts.projectRoot);
|
|
3130
3206
|
const slug = projectSlug(opts.projectRoot);
|
|
3131
|
-
const projectDir =
|
|
3207
|
+
const projectDir = path4.join(globalRoot, "projects", slug);
|
|
3132
3208
|
return {
|
|
3133
3209
|
globalRoot,
|
|
3134
3210
|
configDir: globalRoot,
|
|
3135
|
-
globalConfig:
|
|
3136
|
-
secretsKey:
|
|
3137
|
-
globalMemory:
|
|
3138
|
-
globalSkills:
|
|
3139
|
-
globalDesignKits:
|
|
3140
|
-
globalPrompts:
|
|
3141
|
-
globalInstructions:
|
|
3142
|
-
promptUsage:
|
|
3143
|
-
cacheDir:
|
|
3144
|
-
modelsCache:
|
|
3145
|
-
modelsOverlayCache:
|
|
3146
|
-
historyFile:
|
|
3147
|
-
logFile:
|
|
3211
|
+
globalConfig: path4.join(globalRoot, "config.json"),
|
|
3212
|
+
secretsKey: path4.join(globalRoot, ".key"),
|
|
3213
|
+
globalMemory: path4.join(globalRoot, "memory.md"),
|
|
3214
|
+
globalSkills: path4.join(globalRoot, "skills"),
|
|
3215
|
+
globalDesignKits: path4.join(globalRoot, "design-kits"),
|
|
3216
|
+
globalPrompts: path4.join(globalRoot, "prompts"),
|
|
3217
|
+
globalInstructions: path4.join(globalRoot, "instructions"),
|
|
3218
|
+
promptUsage: path4.join(globalRoot, "prompt-usage.json"),
|
|
3219
|
+
cacheDir: path4.join(globalRoot, "cache"),
|
|
3220
|
+
modelsCache: path4.join(globalRoot, "cache", "models.dev.json"),
|
|
3221
|
+
modelsOverlayCache: path4.join(globalRoot, "cache", "models-overlay.json"),
|
|
3222
|
+
historyFile: path4.join(globalRoot, "history"),
|
|
3223
|
+
logFile: path4.join(globalRoot, "logs", "wrongstack.log"),
|
|
3148
3224
|
projectDir,
|
|
3149
|
-
projectCodebaseIndex:
|
|
3150
|
-
projectMemory:
|
|
3151
|
-
projectSessions:
|
|
3152
|
-
projectTrust:
|
|
3153
|
-
projectMeta:
|
|
3154
|
-
projectLocalConfig:
|
|
3155
|
-
inProjectConfig:
|
|
3156
|
-
inProjectAgentsFile:
|
|
3157
|
-
inProjectSkills:
|
|
3158
|
-
inProjectPrompts:
|
|
3159
|
-
inProjectInstructions:
|
|
3160
|
-
inProjectDesignKits:
|
|
3161
|
-
inProjectWorktrees:
|
|
3225
|
+
projectCodebaseIndex: path4.join(projectDir, "codebase-index"),
|
|
3226
|
+
projectMemory: path4.join(projectDir, "memory.md"),
|
|
3227
|
+
projectSessions: path4.join(projectDir, "sessions"),
|
|
3228
|
+
projectTrust: path4.join(projectDir, "trust.json"),
|
|
3229
|
+
projectMeta: path4.join(projectDir, "meta.json"),
|
|
3230
|
+
projectLocalConfig: path4.join(projectDir, "config.local.json"),
|
|
3231
|
+
inProjectConfig: path4.join(opts.projectRoot, ".wrongstack", "config.json"),
|
|
3232
|
+
inProjectAgentsFile: path4.join(opts.projectRoot, ".wrongstack", "AGENTS.md"),
|
|
3233
|
+
inProjectSkills: path4.join(opts.projectRoot, ".wrongstack", "skills"),
|
|
3234
|
+
inProjectPrompts: path4.join(opts.projectRoot, ".wrongstack", "prompts"),
|
|
3235
|
+
inProjectInstructions: path4.join(opts.projectRoot, ".wrongstack", "instructions"),
|
|
3236
|
+
inProjectDesignKits: path4.join(opts.projectRoot, ".wrongstack", "design-kits"),
|
|
3237
|
+
inProjectWorktrees: path4.join(opts.projectRoot, ".wrongstack", "worktrees"),
|
|
3162
3238
|
projectHash: hash,
|
|
3163
3239
|
projectSlug: slug,
|
|
3164
|
-
projectGoal:
|
|
3165
|
-
projectSpecs:
|
|
3166
|
-
projectTaskGraphs:
|
|
3167
|
-
projectSddSession:
|
|
3168
|
-
projectPlan:
|
|
3169
|
-
projectAutophase:
|
|
3170
|
-
projectSddBoards:
|
|
3171
|
-
syncConfig:
|
|
3172
|
-
projectStatus: (projectHash2) =>
|
|
3240
|
+
projectGoal: path4.join(projectDir, "goal.json"),
|
|
3241
|
+
projectSpecs: path4.join(projectDir, "specs"),
|
|
3242
|
+
projectTaskGraphs: path4.join(projectDir, "task-graphs"),
|
|
3243
|
+
projectSddSession: path4.join(projectDir, "sdd-session.json"),
|
|
3244
|
+
projectPlan: path4.join(projectDir, "plan.json"),
|
|
3245
|
+
projectAutophase: path4.join(projectDir, "autophase"),
|
|
3246
|
+
projectSddBoards: path4.join(projectDir, "sdd-boards"),
|
|
3247
|
+
syncConfig: path4.join(globalRoot, "sync.json"),
|
|
3248
|
+
projectStatus: (projectHash2) => path4.join(globalRoot, "projects", projectHash2, "status.json")
|
|
3173
3249
|
};
|
|
3174
3250
|
}
|
|
3175
3251
|
|
|
3176
|
-
export { DEFAULT_TOOL_DESCRIPTION_MODE, DEFAULT_TOOL_RESULT_RENDER_MODE, FORBIDDEN_PROTO_KEYS, applyToolDescriptionModeToTool, applyToolDescriptionModes, applyToolResultRenderModes, assertNever, assertNotPrivateHost, atomicWrite, buildChildEnv, buildContextEvidenceDigest, color, compactSchemaDescriptions, compactToolDefinitionForWire, compileGlob, compileUserRegex, completePartialObject, computeMessageTokens, computeTaskItemProgress, createContextEvidenceState, createToolOutputSerializer, deepMerge, detectNewlineStyle, ensureDir, escapeGlobSubject, estimateMessageTokens, estimateRequestTokens, estimateRequestTokensCalibrated, estimateTextTokens, estimateToolDefTokens, estimateToolInputTokens, estimateToolResultTokens, expandGlob, expandIPv6, expectDefined, formatTaskList, formatTaskProgress, formatTodosList, getCalibrationState, getJsonPath, getTermSize, getToolDescriptionMode, getToolResultRenderMode, isInteractive, isJsonObject, isPathSubjectKey, isPrimitiveArray, isPrivateIPv4, isPrivateIPv6, isStdinTTY, isStdoutTTY, isUlid, jsonObjectFileExists, markAssistantReferencedEvidence, matchAny, matchGlob, mergeCustomModelDefs, mergeModelsPayload, normalizePathSubject, normalizeToLf, normalizeToolDescriptionMode, normalizeToolResultRenderMode, onResize, projectHash, projectSlug, readJsonObjectFile, recordActualUsage, recordToolOutputEvidence, recordUserIntentEvidence, removeJsonPath, removeJsonPathInFile, repairToolUseAdjacency, repeatedReadPressure, resetCalibration, resolveToolDescriptionMode, resolveToolResultRenderMode, resolveWstackPaths, safeParse, safeStringify, sanitizeJsonString, sanitizeNodeOptions, setJsonPath, setJsonPathInFile, setOutputLineGuard, setRawMode, setToolDescriptionMode, setToolResultRenderMode, simplifyToolDescription, sleep, slugify, stripAnsi, subjectForToolInput, toErrorMessage, toStyle, truncate, ulid, unifiedDiff, updateJsonObjectFile, validateAgainstSchema, withFileLock, writeErr, writeJsonObjectFile, writeOut, wstackGlobalRoot };
|
|
3252
|
+
export { DEFAULT_TOOL_DESCRIPTION_MODE, DEFAULT_TOOL_RESULT_RENDER_MODE, FORBIDDEN_PROTO_KEYS, applyToolDescriptionModeToTool, applyToolDescriptionModes, applyToolResultRenderModes, assertNever, assertNotPrivateHost, atomicWrite, buildChildEnv, buildContextEvidenceDigest, color, compactSchemaDescriptions, compactToolDefinitionForWire, compileGlob, compileUserRegex, completePartialObject, computeMessageTokens, computeTaskItemProgress, createContextEvidenceState, createToolOutputSerializer, deepMerge, detectNewlineStyle, ensureDir, escapeGlobSubject, estimateMessageTokens, estimateRequestTokens, estimateRequestTokensCalibrated, estimateTextTokens, estimateToolDefTokens, estimateToolInputTokens, estimateToolResultTokens, expandGlob, expandIPv6, expectDefined, formatTaskList, formatTaskProgress, formatTodosList, getCalibrationState, getJsonPath, getTermSize, getToolDescriptionMode, getToolResultRenderMode, isInteractive, isJsonObject, isPathSubjectKey, isPrimitiveArray, isPrivateIPv4, isPrivateIPv6, isStdinTTY, isStdoutTTY, isUlid, jsonObjectFileExists, markAssistantReferencedEvidence, matchAny, matchGlob, mergeCustomModelDefs, mergeModelsPayload, normalizePathSubject, normalizeToLf, normalizeToolDescriptionMode, normalizeToolResultRenderMode, onResize, projectHash, projectSlug, readJsonObjectFile, recordActualUsage, recordToolOutputEvidence, recordUserIntentEvidence, removeJsonPath, removeJsonPathInFile, repairToolUseAdjacency, repeatedReadPressure, resetCalibration, resolveToolDescriptionMode, resolveToolResultRenderMode, resolveWstackPaths, safeParse, safeStringify, sanitizeJsonString, sanitizeNodeOptions, sessionScopedPath, setJsonPath, setJsonPathInFile, setOutputLineGuard, setRawMode, setToolDescriptionMode, setToolResultRenderMode, simplifyToolDescription, sleep, slugify, stripAnsi, subjectForToolInput, toErrorMessage, toStyle, truncate, ulid, unifiedDiff, updateJsonObjectFile, validateAgainstSchema, withFileLock, writeErr, writeJsonObjectFile, writeOut, wstackGlobalRoot };
|
|
3177
3253
|
//# sourceMappingURL=index.js.map
|
|
3178
3254
|
//# sourceMappingURL=index.js.map
|