@wrongstack/core 0.265.1 → 0.268.0
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-DrkBxszZ.d.ts → agent-bridge-UhojbpWx.d.ts} +1 -1
- package/dist/{agent-subagent-runner-DM2pP-B6.d.ts → agent-subagent-runner-Bvtf1o9K.d.ts} +25 -7
- package/dist/{brain-BXd_61kQ.d.ts → brain-69wzMKp1.d.ts} +73 -1
- package/dist/{compactor-B8pOf45Y.d.ts → compactor-CBQAJoDc.d.ts} +19 -1
- package/dist/{config-BMCj_XDs.d.ts → config-VKfOZ-6X.d.ts} +122 -3
- package/dist/{context-MRk5PhNv.d.ts → context-C0U8B9NF.d.ts} +88 -1
- package/dist/coordination/index.d.ts +57 -161
- package/dist/coordination/index.js +471 -177
- package/dist/coordination/index.js.map +1 -1
- package/dist/defaults/index.d.ts +26 -25
- package/dist/defaults/index.js +1818 -844
- package/dist/defaults/index.js.map +1 -1
- package/dist/execution/index.d.ts +72 -16
- package/dist/execution/index.js +1270 -265
- package/dist/execution/index.js.map +1 -1
- package/dist/execution/prompt-enhancer.d.ts +1 -1
- package/dist/extension/index.d.ts +7 -6
- package/dist/global-mailbox-KByEFFBa.d.ts +663 -0
- package/dist/{goal-preamble-DvHDSKSe.d.ts → goal-preamble-CrYjmdw4.d.ts} +28 -11
- package/dist/{goal-store-DtLMySNb.d.ts → goal-store-Y_zdLZ3q.d.ts} +1 -1
- package/dist/hq/index.d.ts +195 -0
- package/dist/hq/index.js +1884 -0
- package/dist/hq/index.js.map +1 -0
- package/dist/index-BfaS-f_m.d.ts +82 -0
- package/dist/{index-B-ch8K9C.d.ts → index-CtQnmkaS.d.ts} +8 -8
- package/dist/{index-CEDeNodM.d.ts → index-gCv830d7.d.ts} +5 -5
- package/dist/index.d.ts +124 -47
- package/dist/index.js +5600 -2662
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/index.d.ts +6 -6
- package/dist/infrastructure/index.js +117 -19
- package/dist/infrastructure/index.js.map +1 -1
- package/dist/kernel/index.d.ts +10 -9
- package/dist/kernel/index.js.map +1 -1
- package/dist/{pipeline-DPDxH_7m.d.ts → mailbox-types-Ct2hJq0P.d.ts} +1 -244
- package/dist/{mcp-servers-2x4w6Jn9.d.ts → mcp-servers-HT3Fi7Bl.d.ts} +10 -4
- package/dist/models/index.d.ts +5 -5
- package/dist/models/index.js +33 -3
- package/dist/models/index.js.map +1 -1
- package/dist/{models-registry-DmJlKuNp.d.ts → models-registry-Bvcl3Vaa.d.ts} +1 -1
- package/dist/{multi-agent-coordinator-DyCkCZnU.d.ts → multi-agent-coordinator-BACjsmkC.d.ts} +1 -1
- package/dist/{null-fleet-bus-CG9QY2aP.d.ts → null-fleet-bus-DA7fvhUg.d.ts} +14 -9
- package/dist/observability/index.d.ts +2 -2
- package/dist/{parallel-eternal-engine-Jw9uhEoT.d.ts → parallel-eternal-engine-Ci71gYu_.d.ts} +11 -15
- package/dist/{path-resolver-Dy2ej-gE.d.ts → path-resolver-O1IJnmKE.d.ts} +4 -3
- package/dist/{permission-B9SB45lp.d.ts → permission-Bd-57Lbl.d.ts} +1 -1
- package/dist/{permission-policy-CkjSXabK.d.ts → permission-policy-uNXC6Kge.d.ts} +2 -3
- package/dist/pipeline-BDNvENyV.d.ts +245 -0
- package/dist/{plan-templates-CzD9GnAU.d.ts → plan-templates-EMsalEtN.d.ts} +5 -5
- package/dist/{llm-selector-C0tfTCUe.d.ts → provider-model-resolve-CEb9x886.d.ts} +40 -3
- package/dist/{provider-runner-DMa70ODu.d.ts → provider-runner-DWJbpo70.d.ts} +3 -3
- package/dist/{retry-policy-CN0khdlj.d.ts → retry-policy-C3s_lvdK.d.ts} +1 -1
- package/dist/sdd/index.d.ts +9 -8
- package/dist/sdd/index.js +44 -14
- package/dist/sdd/index.js.map +1 -1
- package/dist/{secret-vault-B2yw84VT.d.ts → secret-vault-Cgduf5xL.d.ts} +2 -2
- package/dist/security/index.d.ts +5 -67
- package/dist/security/index.js +129 -99
- package/dist/security/index.js.map +1 -1
- package/dist/{selector-CzHh_igB.d.ts → selector-47LBnBVk.d.ts} +1 -1
- package/dist/{session-event-bridge-BUI6Jf-4.d.ts → session-event-bridge-Cw7oqmW2.d.ts} +1 -1
- package/dist/{session-reader-CMgdMSRP.d.ts → session-reader-DD4v2Obw.d.ts} +1 -1
- package/dist/storage/index.d.ts +14 -12
- package/dist/storage/index.js +144 -120
- package/dist/storage/index.js.map +1 -1
- package/dist/tools/index.d.ts +4 -2
- package/dist/tools/index.js +166 -31
- package/dist/tools/index.js.map +1 -1
- package/dist/types/index.d.ts +20 -19
- package/dist/types/index.js +1358 -476
- package/dist/types/index.js.map +1 -1
- package/dist/utils/index.d.ts +472 -405
- package/dist/utils/index.js +2321 -1193
- package/dist/utils/index.js.map +1 -1
- package/package.json +5 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as ContentBlock, S as SessionEvent, h as SessionMetadata, i as SessionStore } from './context-
|
|
1
|
+
import { g as ContentBlock, S as SessionEvent, h as SessionMetadata, i as SessionStore } from './context-C0U8B9NF.js';
|
|
2
2
|
|
|
3
3
|
type AttachmentKind = 'text' | 'image' | 'file';
|
|
4
4
|
interface AttachmentMeta {
|
package/dist/storage/index.d.ts
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import { M as MemoryBackend, j as FileMemoryBackendOptions } from '../plan-templates-
|
|
2
|
-
export { A as AbandonedSession, a as AttachmentStoreOptions, C as ConfigLoaderOptions, b as ConfigMigration, c as ConfigMigrationError, d as ConfigSource, D as DEFAULT_CONFIG_MIGRATIONS, e as DefaultAttachmentStore, f as DefaultConfigLoader, g as DefaultConfigStore, h as DefaultMemoryStore, i as DefaultSessionStore, F as FileMemoryBackend, k as MemoryStoreOptions, l as MigrationContext, m as MigrationResult, P as PersistedQueueItem, n as PlanFile, o as PlanItem, p as PlanTemplate, Q as QueueStore, R as RecoveryLock, q as RecoveryLockOptions, S as SessionAnalyzer, r as SessionStoreOptions, T as TodosCheckpointFile, s as addPlanItem, t as attachPlanCheckpoint, u as attachTodosCheckpoint, v as clearPlan, w as deriveTodosFromPlanItem, x as emptyPlan, y as formatPlan, z as formatPlanTemplates, B as getPlanTemplate, E as listPlanTemplates, G as loadPlan, H as loadTodosCheckpoint, I as mutatePlan, J as parseEntries, K as removePlanItem, L as runConfigMigrations, N as savePlan, O as saveTodosCheckpoint, U as setPlanItemStatus } from '../plan-templates-
|
|
3
|
-
import { M as MemoryScope, b as MemoryEntry, c as MemoryStore, E as EventBus } from '../brain-
|
|
4
|
-
import { l as AgentExtension, j as AfterRunHook } from '../index-
|
|
5
|
-
import { P as Provider, R as Request, b as Response, S as SessionEvent } from '../context-
|
|
6
|
-
export { D as DefaultSessionReader, f as DefaultSessionReaderOptions, S as SessionReader } from '../session-reader-
|
|
1
|
+
import { M as MemoryBackend, j as FileMemoryBackendOptions } from '../plan-templates-EMsalEtN.js';
|
|
2
|
+
export { A as AbandonedSession, a as AttachmentStoreOptions, C as ConfigLoaderOptions, b as ConfigMigration, c as ConfigMigrationError, d as ConfigSource, D as DEFAULT_CONFIG_MIGRATIONS, e as DefaultAttachmentStore, f as DefaultConfigLoader, g as DefaultConfigStore, h as DefaultMemoryStore, i as DefaultSessionStore, F as FileMemoryBackend, k as MemoryStoreOptions, l as MigrationContext, m as MigrationResult, P as PersistedQueueItem, n as PlanFile, o as PlanItem, p as PlanTemplate, Q as QueueStore, R as RecoveryLock, q as RecoveryLockOptions, S as SessionAnalyzer, r as SessionStoreOptions, T as TodosCheckpointFile, s as addPlanItem, t as attachPlanCheckpoint, u as attachTodosCheckpoint, v as clearPlan, w as deriveTodosFromPlanItem, x as emptyPlan, y as formatPlan, z as formatPlanTemplates, B as getPlanTemplate, E as listPlanTemplates, G as loadPlan, H as loadTodosCheckpoint, I as mutatePlan, J as parseEntries, K as removePlanItem, L as runConfigMigrations, N as savePlan, O as saveTodosCheckpoint, U as setPlanItemStatus } from '../plan-templates-EMsalEtN.js';
|
|
3
|
+
import { M as MemoryScope, b as MemoryEntry, c as MemoryStore, E as EventBus } from '../brain-69wzMKp1.js';
|
|
4
|
+
import { l as AgentExtension, j as AfterRunHook } from '../index-gCv830d7.js';
|
|
5
|
+
import { P as Provider, R as Request, b as Response, S as SessionEvent } from '../context-C0U8B9NF.js';
|
|
6
|
+
export { D as DefaultSessionReader, f as DefaultSessionReaderOptions, S as SessionReader } from '../session-reader-DD4v2Obw.js';
|
|
7
7
|
import { S as SessionRewinder, C as CheckpointInfo, a as RewindResultExtended } from '../session-rewinder-C9HnMkhP.js';
|
|
8
8
|
import { T as TaskItem } from '../task-format-vGOIftmK.js';
|
|
9
9
|
export { a as DirectorStateCheckpoint, D as DirectorStateSnapshot, b as DirectorSubagentState, c as DirectorTaskState, l as loadDirectorState } from '../director-state-BfeCUbmk.js';
|
|
10
|
-
export { G as GoalFile, J as JournalEntry, M as MAX_JOURNAL_ENTRIES, a as MAX_PROGRESS_HISTORY, P as ProgressSnapshot, b as appendJournal, e as emptyGoal, f as formatGoal, g as goalFilePath, l as loadGoal, p as parseProgressFromText, r as recordProgress, s as saveGoal, c as setProgress, d as summarizeUsage } from '../goal-store-
|
|
10
|
+
export { G as GoalFile, J as JournalEntry, M as MAX_JOURNAL_ENTRIES, a as MAX_PROGRESS_HISTORY, P as ProgressSnapshot, b as appendJournal, e as emptyGoal, f as formatGoal, g as goalFilePath, l as loadGoal, p as parseProgressFromText, r as recordProgress, s as saveGoal, c as setProgress, d as summarizeUsage } from '../goal-store-Y_zdLZ3q.js';
|
|
11
11
|
import { W as WstackPaths } from '../wstack-paths-hOpNLmvf.js';
|
|
12
|
-
import {
|
|
13
|
-
export { A as AuditLevel, C as CORE_RECONSTRUCT_EVENTS, a as STANDARD_AUDIT_EVENTS, S as SessionEventBridge, b as SessionEventBridgeOptions, c as SessionSamplingOptions, T as ToolProgressSamplingOptions, d as createSessionEventBridge, r as resolveAuditLevel, e as resolveSessionLoggingConfig } from '../session-event-bridge-
|
|
14
|
-
import '../permission-
|
|
12
|
+
import { O as SyncCategory, l as SyncConfig } from '../config-VKfOZ-6X.js';
|
|
13
|
+
export { A as AuditLevel, C as CORE_RECONSTRUCT_EVENTS, a as STANDARD_AUDIT_EVENTS, S as SessionEventBridge, b as SessionEventBridgeOptions, c as SessionSamplingOptions, T as ToolProgressSamplingOptions, d as createSessionEventBridge, r as resolveAuditLevel, e as resolveSessionLoggingConfig } from '../session-event-bridge-Cw7oqmW2.js';
|
|
14
|
+
import '../permission-Bd-57Lbl.js';
|
|
15
15
|
import '../secret-vault-BAKpgFw_.js';
|
|
16
16
|
import '../logger-B63L5bTg.js';
|
|
17
|
-
import '../pipeline-
|
|
17
|
+
import '../pipeline-BDNvENyV.js';
|
|
18
|
+
import '../mailbox-types-Ct2hJq0P.js';
|
|
18
19
|
import '../observability-D-HZN_mF.js';
|
|
19
20
|
import '../task-graph-u1q9Jkyk.js';
|
|
20
21
|
|
|
@@ -68,7 +69,7 @@ declare class GraphMemoryBackend implements MemoryBackend {
|
|
|
68
69
|
forget(scope: MemoryScope, query: string, filePath: string): Promise<number>;
|
|
69
70
|
readAll(scope: MemoryScope, filePath: string): Promise<string>;
|
|
70
71
|
list(scope: MemoryScope, filePath: string, limit?: number): Promise<MemoryEntry[]>;
|
|
71
|
-
search(scope: MemoryScope, query: string,
|
|
72
|
+
search(scope: MemoryScope, query: string, _filePath: string, limit?: number): Promise<MemoryEntry[]>;
|
|
72
73
|
clear(scope: MemoryScope, filePath: string): Promise<void>;
|
|
73
74
|
consolidate(scope: MemoryScope, filePath: string): Promise<number>;
|
|
74
75
|
/**
|
|
@@ -329,6 +330,7 @@ declare class ReplayLogStore {
|
|
|
329
330
|
path: string;
|
|
330
331
|
}>>;
|
|
331
332
|
private filePath;
|
|
333
|
+
private countEntries;
|
|
332
334
|
private readAll;
|
|
333
335
|
private writeAll;
|
|
334
336
|
private ensureCache;
|
package/dist/storage/index.js
CHANGED
|
@@ -219,26 +219,6 @@ function isEmptyMessage(msg) {
|
|
|
219
219
|
return msg.content.length === 0;
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
-
// src/utils/error.ts
|
|
223
|
-
function toErrorMessage(err) {
|
|
224
|
-
return err instanceof Error ? err.message : String(err);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
// src/utils/safe-json.ts
|
|
228
|
-
function safeParse(input, maxBytes = 5e6) {
|
|
229
|
-
if (input.length > maxBytes) {
|
|
230
|
-
return { ok: false, error: `Input exceeds limit (${maxBytes} bytes)` };
|
|
231
|
-
}
|
|
232
|
-
try {
|
|
233
|
-
return { ok: true, value: JSON.parse(input) };
|
|
234
|
-
} catch (err) {
|
|
235
|
-
return {
|
|
236
|
-
ok: false,
|
|
237
|
-
error: toErrorMessage(err)
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
222
|
// src/utils/term.ts
|
|
243
223
|
var hasStdout = () => typeof process !== "undefined" && !!process.stdout;
|
|
244
224
|
function isStdoutTTY() {
|
|
@@ -257,7 +237,7 @@ function envFlag(value) {
|
|
|
257
237
|
return !/^(0|false|no|off)$/i.test(value.trim());
|
|
258
238
|
}
|
|
259
239
|
var COLOR = isColorTty();
|
|
260
|
-
var wrap = (
|
|
240
|
+
var wrap = (open7, close) => (s) => COLOR ? `\x1B[${open7}m${s}\x1B[${close}m` : s;
|
|
261
241
|
var color = {
|
|
262
242
|
reset: wrap("0", "0"),
|
|
263
243
|
bold: wrap("1", "22"),
|
|
@@ -276,63 +256,6 @@ var color = {
|
|
|
276
256
|
bgRed: wrap("41", "49"),
|
|
277
257
|
bgGreen: wrap("42", "49")
|
|
278
258
|
};
|
|
279
|
-
function projectHash(absRoot) {
|
|
280
|
-
return createHash("sha256").update(path2.resolve(absRoot)).digest("hex").slice(0, 12);
|
|
281
|
-
}
|
|
282
|
-
function projectSlug(absRoot) {
|
|
283
|
-
const base = slugify(path2.basename(absRoot));
|
|
284
|
-
const hash = createHash("sha256").update(path2.resolve(absRoot)).digest("hex").slice(0, 6);
|
|
285
|
-
return `${base}-${hash}`;
|
|
286
|
-
}
|
|
287
|
-
function slugify(name) {
|
|
288
|
-
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 40) || "project";
|
|
289
|
-
}
|
|
290
|
-
function wstackGlobalRoot() {
|
|
291
|
-
const fromEnv = process.env["WRONGSTACK_HOME"];
|
|
292
|
-
if (fromEnv && fromEnv.trim().length > 0) return path2.resolve(fromEnv);
|
|
293
|
-
return path2.join(os.homedir(), ".wrongstack");
|
|
294
|
-
}
|
|
295
|
-
function resolveWstackPaths(opts) {
|
|
296
|
-
const globalRoot = opts.globalRoot ?? (opts.userHome ? path2.join(opts.userHome, ".wrongstack") : wstackGlobalRoot());
|
|
297
|
-
const hash = projectHash(opts.projectRoot);
|
|
298
|
-
const slug = projectSlug(opts.projectRoot);
|
|
299
|
-
const projectDir = path2.join(globalRoot, "projects", slug);
|
|
300
|
-
return {
|
|
301
|
-
globalRoot,
|
|
302
|
-
configDir: globalRoot,
|
|
303
|
-
globalConfig: path2.join(globalRoot, "config.json"),
|
|
304
|
-
secretsKey: path2.join(globalRoot, ".key"),
|
|
305
|
-
globalMemory: path2.join(globalRoot, "memory.md"),
|
|
306
|
-
globalSkills: path2.join(globalRoot, "skills"),
|
|
307
|
-
globalPrompts: path2.join(globalRoot, "prompts"),
|
|
308
|
-
cacheDir: path2.join(globalRoot, "cache"),
|
|
309
|
-
modelsCache: path2.join(globalRoot, "cache", "models.dev.json"),
|
|
310
|
-
modelsOverlayCache: path2.join(globalRoot, "cache", "models-overlay.json"),
|
|
311
|
-
historyFile: path2.join(globalRoot, "history"),
|
|
312
|
-
logFile: path2.join(globalRoot, "logs", "wrongstack.log"),
|
|
313
|
-
projectDir,
|
|
314
|
-
projectCodebaseIndex: path2.join(projectDir, "codebase-index"),
|
|
315
|
-
projectMemory: path2.join(projectDir, "memory.md"),
|
|
316
|
-
projectSessions: path2.join(projectDir, "sessions"),
|
|
317
|
-
projectTrust: path2.join(projectDir, "trust.json"),
|
|
318
|
-
projectMeta: path2.join(projectDir, "meta.json"),
|
|
319
|
-
projectLocalConfig: path2.join(projectDir, "config.local.json"),
|
|
320
|
-
inProjectConfig: path2.join(opts.projectRoot, ".wrongstack", "config.json"),
|
|
321
|
-
inProjectAgentsFile: path2.join(opts.projectRoot, ".wrongstack", "AGENTS.md"),
|
|
322
|
-
inProjectSkills: path2.join(opts.projectRoot, ".wrongstack", "skills"),
|
|
323
|
-
inProjectWorktrees: path2.join(opts.projectRoot, ".wrongstack", "worktrees"),
|
|
324
|
-
projectHash: hash,
|
|
325
|
-
projectSlug: slug,
|
|
326
|
-
projectGoal: path2.join(projectDir, "goal.json"),
|
|
327
|
-
projectSpecs: path2.join(projectDir, "specs"),
|
|
328
|
-
projectTaskGraphs: path2.join(projectDir, "task-graphs"),
|
|
329
|
-
projectSddSession: path2.join(projectDir, "sdd-session.json"),
|
|
330
|
-
projectPlan: path2.join(projectDir, "plan.json"),
|
|
331
|
-
projectAutophase: path2.join(projectDir, "autophase"),
|
|
332
|
-
syncConfig: path2.join(globalRoot, "sync.json"),
|
|
333
|
-
projectStatus: (projectHash2) => path2.join(globalRoot, "projects", projectHash2, "status.json")
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
259
|
|
|
337
260
|
// src/utils/deep-merge.ts
|
|
338
261
|
var FORBIDDEN_PROTO_KEYS = /* @__PURE__ */ new Set([
|
|
@@ -393,6 +316,11 @@ function deepMerge(base, patch, options = {}) {
|
|
|
393
316
|
return out;
|
|
394
317
|
}
|
|
395
318
|
|
|
319
|
+
// src/utils/error.ts
|
|
320
|
+
function toErrorMessage(err) {
|
|
321
|
+
return err instanceof Error ? err.message : String(err);
|
|
322
|
+
}
|
|
323
|
+
|
|
396
324
|
// src/utils/regex-guard.ts
|
|
397
325
|
var MAX_PATTERN_LEN = 512;
|
|
398
326
|
var DANGEROUS_PATTERNS = [
|
|
@@ -429,6 +357,78 @@ function compileUserRegex(pattern, flags) {
|
|
|
429
357
|
}
|
|
430
358
|
}
|
|
431
359
|
|
|
360
|
+
// src/utils/safe-json.ts
|
|
361
|
+
function safeParse(input, maxBytes = 5e6) {
|
|
362
|
+
if (input.length > maxBytes) {
|
|
363
|
+
return { ok: false, error: `Input exceeds limit (${maxBytes} bytes)` };
|
|
364
|
+
}
|
|
365
|
+
try {
|
|
366
|
+
return { ok: true, value: JSON.parse(input) };
|
|
367
|
+
} catch (err) {
|
|
368
|
+
return {
|
|
369
|
+
ok: false,
|
|
370
|
+
error: toErrorMessage(err)
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
function projectHash(absRoot) {
|
|
375
|
+
return createHash("sha256").update(path2.resolve(absRoot)).digest("hex").slice(0, 12);
|
|
376
|
+
}
|
|
377
|
+
function projectSlug(absRoot) {
|
|
378
|
+
const base = slugify(path2.basename(absRoot));
|
|
379
|
+
const hash = createHash("sha256").update(path2.resolve(absRoot)).digest("hex").slice(0, 6);
|
|
380
|
+
return `${base}-${hash}`;
|
|
381
|
+
}
|
|
382
|
+
function slugify(name) {
|
|
383
|
+
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 40) || "project";
|
|
384
|
+
}
|
|
385
|
+
function wstackGlobalRoot() {
|
|
386
|
+
const fromEnv = process.env["WRONGSTACK_HOME"];
|
|
387
|
+
if (fromEnv && fromEnv.trim().length > 0) return path2.resolve(fromEnv);
|
|
388
|
+
return path2.join(os.homedir(), ".wrongstack");
|
|
389
|
+
}
|
|
390
|
+
function resolveWstackPaths(opts) {
|
|
391
|
+
const globalRoot = opts.globalRoot ?? (opts.userHome ? path2.join(opts.userHome, ".wrongstack") : wstackGlobalRoot());
|
|
392
|
+
const hash = projectHash(opts.projectRoot);
|
|
393
|
+
const slug = projectSlug(opts.projectRoot);
|
|
394
|
+
const projectDir = path2.join(globalRoot, "projects", slug);
|
|
395
|
+
return {
|
|
396
|
+
globalRoot,
|
|
397
|
+
configDir: globalRoot,
|
|
398
|
+
globalConfig: path2.join(globalRoot, "config.json"),
|
|
399
|
+
secretsKey: path2.join(globalRoot, ".key"),
|
|
400
|
+
globalMemory: path2.join(globalRoot, "memory.md"),
|
|
401
|
+
globalSkills: path2.join(globalRoot, "skills"),
|
|
402
|
+
globalPrompts: path2.join(globalRoot, "prompts"),
|
|
403
|
+
cacheDir: path2.join(globalRoot, "cache"),
|
|
404
|
+
modelsCache: path2.join(globalRoot, "cache", "models.dev.json"),
|
|
405
|
+
modelsOverlayCache: path2.join(globalRoot, "cache", "models-overlay.json"),
|
|
406
|
+
historyFile: path2.join(globalRoot, "history"),
|
|
407
|
+
logFile: path2.join(globalRoot, "logs", "wrongstack.log"),
|
|
408
|
+
projectDir,
|
|
409
|
+
projectCodebaseIndex: path2.join(projectDir, "codebase-index"),
|
|
410
|
+
projectMemory: path2.join(projectDir, "memory.md"),
|
|
411
|
+
projectSessions: path2.join(projectDir, "sessions"),
|
|
412
|
+
projectTrust: path2.join(projectDir, "trust.json"),
|
|
413
|
+
projectMeta: path2.join(projectDir, "meta.json"),
|
|
414
|
+
projectLocalConfig: path2.join(projectDir, "config.local.json"),
|
|
415
|
+
inProjectConfig: path2.join(opts.projectRoot, ".wrongstack", "config.json"),
|
|
416
|
+
inProjectAgentsFile: path2.join(opts.projectRoot, ".wrongstack", "AGENTS.md"),
|
|
417
|
+
inProjectSkills: path2.join(opts.projectRoot, ".wrongstack", "skills"),
|
|
418
|
+
inProjectWorktrees: path2.join(opts.projectRoot, ".wrongstack", "worktrees"),
|
|
419
|
+
projectHash: hash,
|
|
420
|
+
projectSlug: slug,
|
|
421
|
+
projectGoal: path2.join(projectDir, "goal.json"),
|
|
422
|
+
projectSpecs: path2.join(projectDir, "specs"),
|
|
423
|
+
projectTaskGraphs: path2.join(projectDir, "task-graphs"),
|
|
424
|
+
projectSddSession: path2.join(projectDir, "sdd-session.json"),
|
|
425
|
+
projectPlan: path2.join(projectDir, "plan.json"),
|
|
426
|
+
projectAutophase: path2.join(projectDir, "autophase"),
|
|
427
|
+
syncConfig: path2.join(globalRoot, "sync.json"),
|
|
428
|
+
projectStatus: (projectHash2) => path2.join(globalRoot, "projects", projectHash2, "status.json")
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
|
|
432
432
|
// src/storage/session-store.ts
|
|
433
433
|
function sanitizeModel(model) {
|
|
434
434
|
return model.replace(/[^a-zA-Z0-9_-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "").slice(0, 40);
|
|
@@ -626,6 +626,8 @@ var DefaultSessionStore = class _DefaultSessionStore {
|
|
|
626
626
|
const cached = this._loadCache.get(id);
|
|
627
627
|
if (cached && cached.mtimeMs === stat7.mtimeMs && cached.size === stat7.size) {
|
|
628
628
|
cacheHit = true;
|
|
629
|
+
this._loadCache.delete(id);
|
|
630
|
+
this._loadCache.set(id, cached);
|
|
629
631
|
return cached.data;
|
|
630
632
|
}
|
|
631
633
|
const raw = await fsp.readFile(file, "utf8");
|
|
@@ -2750,27 +2752,25 @@ var GraphMemoryBackend = class {
|
|
|
2750
2752
|
enriched.sort((a, b) => b.ts.localeCompare(a.ts));
|
|
2751
2753
|
return limit ? enriched.slice(0, limit) : enriched;
|
|
2752
2754
|
}
|
|
2753
|
-
async search(scope, query,
|
|
2755
|
+
async search(scope, query, _filePath, limit) {
|
|
2754
2756
|
await this.loadGraph(scope);
|
|
2755
2757
|
const needle = query.toLowerCase().split(/\s+/);
|
|
2756
|
-
const
|
|
2757
|
-
const
|
|
2758
|
-
|
|
2758
|
+
const scored = [];
|
|
2759
|
+
for (const node of this.nodes.values()) {
|
|
2760
|
+
if (node.entry.scope !== scope) continue;
|
|
2761
|
+
const words = node.entry.text.toLowerCase().split(/\s+/);
|
|
2759
2762
|
let score = 0;
|
|
2760
2763
|
for (const n of needle) {
|
|
2761
2764
|
if (words.some((w) => w.includes(n))) score += 1;
|
|
2762
|
-
if (entry.tags?.some((t) => t.toLowerCase().includes(n))) score += 2;
|
|
2765
|
+
if (node.entry.tags?.some((t) => t.toLowerCase().includes(n))) score += 2;
|
|
2763
2766
|
}
|
|
2764
|
-
|
|
2765
|
-
if (node)
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
}
|
|
2770
|
-
return { entry, score };
|
|
2771
|
-
});
|
|
2767
|
+
if (node.priority === "critical") score += 3;
|
|
2768
|
+
else if (node.priority === "high") score += 2;
|
|
2769
|
+
score += node.count * 0.5;
|
|
2770
|
+
if (score > 0) scored.push({ entry: node.entry, score });
|
|
2771
|
+
}
|
|
2772
2772
|
scored.sort((a, b) => b.score - a.score);
|
|
2773
|
-
const matched = scored.
|
|
2773
|
+
const matched = scored.map((s) => s.entry);
|
|
2774
2774
|
return limit ? matched.slice(0, limit) : matched;
|
|
2775
2775
|
}
|
|
2776
2776
|
async clear(scope, filePath) {
|
|
@@ -3343,6 +3343,7 @@ var BEHAVIOR_DEFAULTS = {
|
|
|
3343
3343
|
modelsRegistry: true,
|
|
3344
3344
|
skills: true
|
|
3345
3345
|
},
|
|
3346
|
+
mcpServers: {},
|
|
3346
3347
|
indexing: {
|
|
3347
3348
|
onSessionStart: true,
|
|
3348
3349
|
onEdit: true,
|
|
@@ -4676,11 +4677,11 @@ var ReplayLogStore = class {
|
|
|
4676
4677
|
if (!entry.isFile() || !entry.name.endsWith(".replay.jsonl")) continue;
|
|
4677
4678
|
const base = entry.name.slice(0, -".replay.jsonl".length);
|
|
4678
4679
|
const sessionId = prefix ? `${prefix}/${base}` : base;
|
|
4679
|
-
const
|
|
4680
|
+
const fp = path2.join(dir, entry.name);
|
|
4680
4681
|
out.push({
|
|
4681
4682
|
sessionId,
|
|
4682
|
-
entryCount:
|
|
4683
|
-
path:
|
|
4683
|
+
entryCount: await this.countEntries(fp),
|
|
4684
|
+
path: fp
|
|
4684
4685
|
});
|
|
4685
4686
|
}
|
|
4686
4687
|
};
|
|
@@ -4691,6 +4692,33 @@ var ReplayLogStore = class {
|
|
|
4691
4692
|
filePath(sessionId) {
|
|
4692
4693
|
return sessionScopedPath(this.dir, sessionId, ".replay.jsonl");
|
|
4693
4694
|
}
|
|
4695
|
+
async countEntries(filePath) {
|
|
4696
|
+
const handle = await fsp.open(filePath, "r");
|
|
4697
|
+
const buffer = Buffer.allocUnsafe(64 * 1024);
|
|
4698
|
+
let count = 0;
|
|
4699
|
+
let hasNonWhitespace = false;
|
|
4700
|
+
try {
|
|
4701
|
+
while (true) {
|
|
4702
|
+
const { bytesRead } = await handle.read(buffer, 0, buffer.length, null);
|
|
4703
|
+
if (bytesRead === 0) break;
|
|
4704
|
+
for (let i = 0; i < bytesRead; i++) {
|
|
4705
|
+
const ch = buffer[i];
|
|
4706
|
+
if (ch === 10) {
|
|
4707
|
+
if (hasNonWhitespace) count++;
|
|
4708
|
+
hasNonWhitespace = false;
|
|
4709
|
+
continue;
|
|
4710
|
+
}
|
|
4711
|
+
if (ch !== 13 && ch !== 32 && ch !== 9) {
|
|
4712
|
+
hasNonWhitespace = true;
|
|
4713
|
+
}
|
|
4714
|
+
}
|
|
4715
|
+
}
|
|
4716
|
+
} finally {
|
|
4717
|
+
await handle.close();
|
|
4718
|
+
}
|
|
4719
|
+
if (hasNonWhitespace) count++;
|
|
4720
|
+
return count;
|
|
4721
|
+
}
|
|
4694
4722
|
async readAll(sessionId) {
|
|
4695
4723
|
const fp = this.filePath(sessionId);
|
|
4696
4724
|
try {
|
|
@@ -5494,25 +5522,24 @@ var SessionRegistry = class {
|
|
|
5494
5522
|
async heartbeat() {
|
|
5495
5523
|
if (!this.currentSessionId) return;
|
|
5496
5524
|
try {
|
|
5497
|
-
const
|
|
5498
|
-
const
|
|
5499
|
-
|
|
5500
|
-
|
|
5501
|
-
|
|
5502
|
-
|
|
5503
|
-
|
|
5504
|
-
|
|
5505
|
-
|
|
5506
|
-
|
|
5507
|
-
|
|
5508
|
-
await this.writeAtomic(registry);
|
|
5509
|
-
} else if (this.lastEntry) {
|
|
5510
|
-
await this.atomicUpdate((reg) => {
|
|
5511
|
-
if (!reg[this.currentSessionId] && this.lastEntry) {
|
|
5512
|
-
reg[this.currentSessionId] = { ...this.lastEntry, lastHeartbeatAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
5525
|
+
const sessionId = this.currentSessionId;
|
|
5526
|
+
const nowIso = (/* @__PURE__ */ new Date()).toISOString();
|
|
5527
|
+
await this.atomicUpdate((registry) => {
|
|
5528
|
+
const entry = registry[sessionId];
|
|
5529
|
+
if (entry) {
|
|
5530
|
+
entry.lastHeartbeatAt = nowIso;
|
|
5531
|
+
if (entry.status !== "closing") {
|
|
5532
|
+
const hasRunning = (entry.agents ?? []).some(
|
|
5533
|
+
(a) => a.status === "running" || a.status === "streaming"
|
|
5534
|
+
);
|
|
5535
|
+
entry.status = hasRunning ? "active" : "idle";
|
|
5513
5536
|
}
|
|
5514
|
-
|
|
5515
|
-
|
|
5537
|
+
return;
|
|
5538
|
+
}
|
|
5539
|
+
if (this.lastEntry) {
|
|
5540
|
+
registry[sessionId] = { ...this.lastEntry, lastHeartbeatAt: nowIso };
|
|
5541
|
+
}
|
|
5542
|
+
});
|
|
5516
5543
|
} catch {
|
|
5517
5544
|
}
|
|
5518
5545
|
}
|
|
@@ -5985,13 +6012,10 @@ var FleetNotifier = class {
|
|
|
5985
6012
|
}
|
|
5986
6013
|
};
|
|
5987
6014
|
async function defaultPost(url) {
|
|
5988
|
-
|
|
5989
|
-
|
|
5990
|
-
|
|
5991
|
-
|
|
5992
|
-
} finally {
|
|
5993
|
-
clearTimeout(t);
|
|
5994
|
-
}
|
|
6015
|
+
await fetch(url, {
|
|
6016
|
+
method: "POST",
|
|
6017
|
+
signal: AbortSignal.timeout(POST_TIMEOUT_MS)
|
|
6018
|
+
});
|
|
5995
6019
|
}
|
|
5996
6020
|
var DefaultSessionRewinder = class {
|
|
5997
6021
|
constructor(sessionsDir, projectRoot) {
|