@wrongstack/core 0.5.3 → 0.5.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-EiUFe3if.d.ts → agent-bridge-B07AYFBk.d.ts} +1 -1
- package/dist/{compactor-BP4xhKVi.d.ts → compactor-BWhJXxsW.d.ts} +1 -1
- package/dist/{config-BOD_HQBw.d.ts → config-BgM0BIpz.d.ts} +1 -1
- package/dist/{context-PH4DvBZV.d.ts → context-CLZXPPYk.d.ts} +18 -1
- package/dist/coordination/index.d.ts +10 -9
- package/dist/coordination/index.js +269 -15
- package/dist/coordination/index.js.map +1 -1
- package/dist/defaults/index.d.ts +20 -19
- package/dist/defaults/index.js +459 -17
- package/dist/defaults/index.js.map +1 -1
- package/dist/director-state-BmYi3DGA.d.ts +108 -0
- package/dist/{events-oxn-Wkub.d.ts → events-qnDZbrtb.d.ts} +67 -2
- package/dist/execution/index.d.ts +12 -12
- package/dist/extension/index.d.ts +6 -6
- package/dist/{index-CcbWbcpy.d.ts → index-BDnUCRvL.d.ts} +113 -6
- package/dist/{index-a12jc7-r.d.ts → index-DPLJw_ZI.d.ts} +5 -5
- package/dist/index.d.ts +329 -27
- package/dist/index.js +2405 -27
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/index.d.ts +6 -6
- package/dist/kernel/index.d.ts +9 -9
- package/dist/kernel/index.js +98 -1
- package/dist/kernel/index.js.map +1 -1
- package/dist/{mcp-servers-uPmBxZ1B.d.ts → mcp-servers-CSMfaBuL.d.ts} +3 -3
- package/dist/models/index.d.ts +2 -2
- package/dist/{multi-agent-D6S4Z7H8.d.ts → multi-agent-Cv8wk47i.d.ts} +2 -2
- package/dist/observability/index.d.ts +2 -2
- package/dist/{path-resolver-CprD5DhS.d.ts → path-resolver-DiCUvEg6.d.ts} +2 -2
- package/dist/{director-state-CVzkjKRZ.d.ts → plan-templates-DaxTCPfk.d.ts} +38 -77
- package/dist/{provider-runner-DGisz_lG.d.ts → provider-runner-3SHqk9zB.d.ts} +3 -3
- package/dist/{retry-policy-DUJ8-Qc_.d.ts → retry-policy-LLUxJmYY.d.ts} +1 -1
- package/dist/sdd/index.d.ts +3 -3
- package/dist/{secret-scrubber-CB11A2P7.d.ts → secret-scrubber-BhJTNr9v.d.ts} +4 -2
- package/dist/{secret-scrubber-EqFa0SyI.d.ts → secret-scrubber-Z_VXuXQT.d.ts} +1 -1
- package/dist/security/index.d.ts +13 -3
- package/dist/security/index.js +34 -1
- package/dist/security/index.js.map +1 -1
- package/dist/{selector-yqyxt-Ii.d.ts → selector-DB2-byKH.d.ts} +1 -1
- package/dist/{session-reader-1tOyoY1s.d.ts → session-reader-4jxsYLZ8.d.ts} +1 -1
- package/dist/storage/index.d.ts +7 -6
- package/dist/storage/index.js +222 -3
- package/dist/storage/index.js.map +1 -1
- package/dist/{system-prompt-BJlzKGO6.d.ts → system-prompt-DI4Dtc1I.d.ts} +1 -1
- package/dist/{tool-executor-B6kRcWeF.d.ts → tool-executor-DSvmOBe6.d.ts} +4 -4
- package/dist/types/index.d.ts +15 -15
- package/dist/types/index.js +9 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utils/index.d.ts +2 -2
- package/dist/{wstack-paths-BGu2INTm.d.ts → wstack-paths-86YPFktR.d.ts} +1 -1
- package/package.json +1 -1
package/dist/storage/index.js
CHANGED
|
@@ -3,7 +3,12 @@ import * as fsp from 'fs/promises';
|
|
|
3
3
|
import * as path2 from 'path';
|
|
4
4
|
import * as os from 'os';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
7
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
8
|
+
}) : x)(function(x) {
|
|
9
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
10
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
11
|
+
});
|
|
7
12
|
async function atomicWrite(targetPath, content, opts = {}) {
|
|
8
13
|
const dir = path2.dirname(targetPath);
|
|
9
14
|
await fsp.mkdir(dir, { recursive: true });
|
|
@@ -929,6 +934,16 @@ function labelOf(scope) {
|
|
|
929
934
|
}
|
|
930
935
|
|
|
931
936
|
// src/storage/config-store.ts
|
|
937
|
+
function stripEphemeralFields(cfg) {
|
|
938
|
+
const env = cfg._envSource;
|
|
939
|
+
if (!env?.size) return cfg;
|
|
940
|
+
const out = { ...cfg };
|
|
941
|
+
for (const field of env) {
|
|
942
|
+
delete out[field];
|
|
943
|
+
}
|
|
944
|
+
delete out._envSource;
|
|
945
|
+
return out;
|
|
946
|
+
}
|
|
932
947
|
var DefaultConfigStore = class {
|
|
933
948
|
current;
|
|
934
949
|
watchers = /* @__PURE__ */ new Set();
|
|
@@ -946,7 +961,8 @@ var DefaultConfigStore = class {
|
|
|
946
961
|
return ext ? ext : FROZEN_EMPTY;
|
|
947
962
|
}
|
|
948
963
|
update(partial) {
|
|
949
|
-
const
|
|
964
|
+
const scrubbed = stripEphemeralFields(partial);
|
|
965
|
+
const next = deepFreeze(structuredClone({ ...this.current, ...scrubbed }));
|
|
950
966
|
if (next.version !== 1) {
|
|
951
967
|
throw new Error(`ConfigStore.update: version must remain 1, got ${String(next.version)}`);
|
|
952
968
|
}
|
|
@@ -1117,15 +1133,19 @@ var BEHAVIOR_DEFAULTS = {
|
|
|
1117
1133
|
var ENV_MAP = {
|
|
1118
1134
|
WRONGSTACK_PROVIDER: (c, v) => {
|
|
1119
1135
|
c.provider = v;
|
|
1136
|
+
(c._envSource ??= /* @__PURE__ */ new Set()).add("provider");
|
|
1120
1137
|
},
|
|
1121
1138
|
WRONGSTACK_MODEL: (c, v) => {
|
|
1122
1139
|
c.model = v;
|
|
1140
|
+
(c._envSource ??= /* @__PURE__ */ new Set()).add("model");
|
|
1123
1141
|
},
|
|
1124
1142
|
WRONGSTACK_API_KEY: (c, v) => {
|
|
1125
1143
|
c.apiKey = v;
|
|
1144
|
+
(c._envSource ??= /* @__PURE__ */ new Set()).add("apiKey");
|
|
1126
1145
|
},
|
|
1127
1146
|
WRONGSTACK_BASE_URL: (c, v) => {
|
|
1128
1147
|
c.baseUrl = v;
|
|
1148
|
+
(c._envSource ??= /* @__PURE__ */ new Set()).add("baseUrl");
|
|
1129
1149
|
},
|
|
1130
1150
|
WRONGSTACK_LOG_LEVEL: (c, v) => {
|
|
1131
1151
|
if (!c.log) c.log = { level: "info" };
|
|
@@ -2167,9 +2187,149 @@ function matchIndex(plan, idOrIndex) {
|
|
|
2167
2187
|
const lower = idOrIndex.toLowerCase();
|
|
2168
2188
|
return plan.items.findIndex((it) => it.title.toLowerCase().includes(lower));
|
|
2169
2189
|
}
|
|
2190
|
+
function deriveTodosFromPlanItem(plan, idOrIndex, subtasks) {
|
|
2191
|
+
const idx = matchIndex(plan, idOrIndex);
|
|
2192
|
+
if (idx === -1) return null;
|
|
2193
|
+
const item = plan.items[idx];
|
|
2194
|
+
if (!item) return null;
|
|
2195
|
+
let updatedPlan = plan;
|
|
2196
|
+
if (item.status !== "done") {
|
|
2197
|
+
updatedPlan = setPlanItemStatus(plan, idOrIndex, "in_progress");
|
|
2198
|
+
}
|
|
2199
|
+
const todos = [];
|
|
2200
|
+
todos.push({
|
|
2201
|
+
id: `todo_${Date.now()}_plan`,
|
|
2202
|
+
content: item.title,
|
|
2203
|
+
status: "in_progress",
|
|
2204
|
+
activeForm: item.title
|
|
2205
|
+
});
|
|
2206
|
+
if (subtasks && subtasks.length > 0) {
|
|
2207
|
+
for (const st of subtasks) {
|
|
2208
|
+
todos.push({
|
|
2209
|
+
id: `todo_${Date.now()}_${randomUUID().slice(0, 6)}`,
|
|
2210
|
+
content: st,
|
|
2211
|
+
status: "pending"
|
|
2212
|
+
});
|
|
2213
|
+
}
|
|
2214
|
+
}
|
|
2215
|
+
return { plan: updatedPlan, todos };
|
|
2216
|
+
}
|
|
2170
2217
|
function attachPlanCheckpoint(_state, _filePath, _sessionId) {
|
|
2171
2218
|
return () => void 0;
|
|
2172
2219
|
}
|
|
2220
|
+
|
|
2221
|
+
// src/storage/plan-templates.ts
|
|
2222
|
+
var templates = {
|
|
2223
|
+
"new-feature": {
|
|
2224
|
+
name: "new-feature",
|
|
2225
|
+
description: "Standard workflow for adding a new feature",
|
|
2226
|
+
category: "development",
|
|
2227
|
+
items: [
|
|
2228
|
+
{ title: "Write specification / design doc", details: "Define scope, acceptance criteria, edge cases" },
|
|
2229
|
+
{ title: "Set up feature branch", details: "git checkout -b feature/..." },
|
|
2230
|
+
{ title: "Implement core logic", details: "TDD preferred \u2014 write tests first" },
|
|
2231
|
+
{ title: "Add unit tests", details: ">= 80% coverage for new code" },
|
|
2232
|
+
{ title: "Add integration tests", details: "End-to-end happy path + error paths" },
|
|
2233
|
+
{ title: "Update documentation", details: "README, API docs, changelog" },
|
|
2234
|
+
{ title: "Code review", details: "Self-review before requesting review" },
|
|
2235
|
+
{ title: "Merge and deploy", details: "CI green, tag release" }
|
|
2236
|
+
]
|
|
2237
|
+
},
|
|
2238
|
+
"bug-fix": {
|
|
2239
|
+
name: "bug-fix",
|
|
2240
|
+
description: "Systematic approach to fixing bugs",
|
|
2241
|
+
category: "maintenance",
|
|
2242
|
+
items: [
|
|
2243
|
+
{ title: "Reproduce the bug", details: "Minimal reproduction case" },
|
|
2244
|
+
{ title: "Root cause analysis", details: "Trace through logs, debugger" },
|
|
2245
|
+
{ title: "Write failing test", details: "Test must fail before fix" },
|
|
2246
|
+
{ title: "Implement fix", details: "Smallest possible change" },
|
|
2247
|
+
{ title: "Verify fix", details: "Test passes, reproduction no longer fails" },
|
|
2248
|
+
{ title: "Regression test", details: "Ensure no related tests broken" },
|
|
2249
|
+
{ title: "Document in changelog", details: "Brief description + issue link" }
|
|
2250
|
+
]
|
|
2251
|
+
},
|
|
2252
|
+
"refactor": {
|
|
2253
|
+
name: "refactor",
|
|
2254
|
+
description: "Safe refactoring workflow",
|
|
2255
|
+
category: "maintenance",
|
|
2256
|
+
items: [
|
|
2257
|
+
{ title: "Identify refactoring target", details: "Code smell, performance bottleneck, or tech debt" },
|
|
2258
|
+
{ title: "Ensure test coverage", details: "Existing tests must pass before and after" },
|
|
2259
|
+
{ title: "Write characterization tests", details: "Capture current behavior if tests weak" },
|
|
2260
|
+
{ title: "Apply refactoring", details: "Small steps, frequent commits" },
|
|
2261
|
+
{ title: "Run full test suite", details: "All tests must pass" },
|
|
2262
|
+
{ title: "Performance check", details: "Ensure no regression" },
|
|
2263
|
+
{ title: "Code review", details: "Explain the why, not just the what" }
|
|
2264
|
+
]
|
|
2265
|
+
},
|
|
2266
|
+
"release": {
|
|
2267
|
+
name: "release",
|
|
2268
|
+
description: "Preparing a new release",
|
|
2269
|
+
category: "release",
|
|
2270
|
+
items: [
|
|
2271
|
+
{ title: "Version bump", details: "package.json, lockfiles, tags" },
|
|
2272
|
+
{ title: "Update changelog", details: "All changes since last release" },
|
|
2273
|
+
{ title: "Run full test suite", details: "Unit + integration + e2e" },
|
|
2274
|
+
{ title: "Build artifacts", details: "Docker images, bundles, binaries" },
|
|
2275
|
+
{ title: "Staging smoke tests", details: "Deploy to staging, verify" },
|
|
2276
|
+
{ title: "Production deploy", details: "Blue-green or canary" },
|
|
2277
|
+
{ title: "Post-deploy verification", details: "Health checks, error rates" },
|
|
2278
|
+
{ title: "Announce release", details: "Slack, email, GitHub release notes" }
|
|
2279
|
+
]
|
|
2280
|
+
},
|
|
2281
|
+
"security-audit": {
|
|
2282
|
+
name: "security-audit",
|
|
2283
|
+
description: "Security review and hardening",
|
|
2284
|
+
category: "infrastructure",
|
|
2285
|
+
items: [
|
|
2286
|
+
{ title: "Dependency audit", details: "npm audit, Snyk, Dependabot alerts" },
|
|
2287
|
+
{ title: "Secret scan", details: "git-secrets, truffleHog, manual review" },
|
|
2288
|
+
{ title: "Access control review", details: "IAM, roles, least privilege" },
|
|
2289
|
+
{ title: "Input validation audit", details: "SQL injection, XSS, path traversal" },
|
|
2290
|
+
{ title: "Authentication review", details: "Session management, MFA, password policy" },
|
|
2291
|
+
{ title: "Logging and monitoring", details: "PII in logs, audit trails" },
|
|
2292
|
+
{ title: "Incident response plan", details: "Runbooks, contacts, escalation" }
|
|
2293
|
+
]
|
|
2294
|
+
},
|
|
2295
|
+
"onboarding": {
|
|
2296
|
+
name: "onboarding",
|
|
2297
|
+
description: "New developer onboarding checklist",
|
|
2298
|
+
category: "infrastructure",
|
|
2299
|
+
items: [
|
|
2300
|
+
{ title: "Repository access", details: "GitHub/GitLab permissions" },
|
|
2301
|
+
{ title: "Local environment setup", details: "Docker, dependencies, env files" },
|
|
2302
|
+
{ title: "Run tests locally", details: "Verify green suite" },
|
|
2303
|
+
{ title: "Read architecture docs", details: "ADR, README, onboarding guide" },
|
|
2304
|
+
{ title: "First commit", details: "Docs fix or small improvement" },
|
|
2305
|
+
{ title: "Pair programming session", details: "Walk through codebase with buddy" },
|
|
2306
|
+
{ title: "Deploy to staging", details: "Verify CI/CD access" }
|
|
2307
|
+
]
|
|
2308
|
+
}
|
|
2309
|
+
};
|
|
2310
|
+
function listPlanTemplates() {
|
|
2311
|
+
return Object.values(templates);
|
|
2312
|
+
}
|
|
2313
|
+
function getPlanTemplate(name) {
|
|
2314
|
+
return templates[name];
|
|
2315
|
+
}
|
|
2316
|
+
function formatPlanTemplates() {
|
|
2317
|
+
const cats = /* @__PURE__ */ new Map();
|
|
2318
|
+
for (const t of Object.values(templates)) {
|
|
2319
|
+
const arr = cats.get(t.category) ?? [];
|
|
2320
|
+
arr.push(t);
|
|
2321
|
+
cats.set(t.category, arr);
|
|
2322
|
+
}
|
|
2323
|
+
const lines = ["Available plan templates:"];
|
|
2324
|
+
for (const [cat, items] of cats) {
|
|
2325
|
+
lines.push(`
|
|
2326
|
+
${cat}:`);
|
|
2327
|
+
for (const t of items) {
|
|
2328
|
+
lines.push(` ${t.name.padEnd(18)} \u2014 ${t.description}`);
|
|
2329
|
+
}
|
|
2330
|
+
}
|
|
2331
|
+
return lines.join("\n");
|
|
2332
|
+
}
|
|
2173
2333
|
async function loadDirectorState(filePath) {
|
|
2174
2334
|
let raw;
|
|
2175
2335
|
try {
|
|
@@ -2185,15 +2345,48 @@ async function loadDirectorState(filePath) {
|
|
|
2185
2345
|
return null;
|
|
2186
2346
|
}
|
|
2187
2347
|
}
|
|
2348
|
+
async function acquireDirectorStateLock(lockPath, processId = process.pid) {
|
|
2349
|
+
let existing;
|
|
2350
|
+
try {
|
|
2351
|
+
existing = await fsp.readFile(lockPath, "utf8");
|
|
2352
|
+
} catch {
|
|
2353
|
+
}
|
|
2354
|
+
if (existing) {
|
|
2355
|
+
try {
|
|
2356
|
+
const lock2 = JSON.parse(existing);
|
|
2357
|
+
try {
|
|
2358
|
+
process.kill(lock2.pid, 0);
|
|
2359
|
+
return false;
|
|
2360
|
+
} catch {
|
|
2361
|
+
}
|
|
2362
|
+
} catch {
|
|
2363
|
+
}
|
|
2364
|
+
}
|
|
2365
|
+
const lock = {
|
|
2366
|
+
pid: processId,
|
|
2367
|
+
hostname: __require("os").hostname(),
|
|
2368
|
+
startedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
2369
|
+
};
|
|
2370
|
+
await atomicWrite(lockPath, JSON.stringify(lock), { mode: 384 });
|
|
2371
|
+
return true;
|
|
2372
|
+
}
|
|
2373
|
+
async function releaseDirectorStateLock(lockPath) {
|
|
2374
|
+
try {
|
|
2375
|
+
await fsp.unlink(lockPath);
|
|
2376
|
+
} catch {
|
|
2377
|
+
}
|
|
2378
|
+
}
|
|
2188
2379
|
var DirectorStateCheckpoint = class {
|
|
2189
2380
|
snapshot;
|
|
2190
2381
|
filePath;
|
|
2382
|
+
lockPath;
|
|
2191
2383
|
timer = null;
|
|
2192
2384
|
debounceMs;
|
|
2193
2385
|
writing = false;
|
|
2194
2386
|
rewriteRequested = false;
|
|
2195
2387
|
constructor(filePath, init, debounceMs = 250) {
|
|
2196
2388
|
this.filePath = filePath;
|
|
2389
|
+
this.lockPath = `${filePath}.lock`;
|
|
2197
2390
|
this.debounceMs = debounceMs;
|
|
2198
2391
|
this.snapshot = {
|
|
2199
2392
|
version: 1,
|
|
@@ -2203,10 +2396,36 @@ var DirectorStateCheckpoint = class {
|
|
|
2203
2396
|
maxSpawns: init.maxSpawns,
|
|
2204
2397
|
spawnDepth: init.spawnDepth,
|
|
2205
2398
|
maxSpawnDepth: init.maxSpawnDepth,
|
|
2399
|
+
directorBudget: init.directorBudget,
|
|
2206
2400
|
subagents: [],
|
|
2207
2401
|
tasks: []
|
|
2208
2402
|
};
|
|
2209
2403
|
}
|
|
2404
|
+
/**
|
|
2405
|
+
* Attempt to acquire the lock for this checkpoint. Call this before
|
|
2406
|
+
* resuming a crashed director run. If it returns false, another
|
|
2407
|
+
* director process is still running this fleet — do not resume.
|
|
2408
|
+
*/
|
|
2409
|
+
async acquireLock() {
|
|
2410
|
+
return acquireDirectorStateLock(this.lockPath);
|
|
2411
|
+
}
|
|
2412
|
+
/**
|
|
2413
|
+
* Release the lock on graceful shutdown. Call `flush()` first to ensure
|
|
2414
|
+
* the final checkpoint state is on disk before removing the lock.
|
|
2415
|
+
* Without this, the next resume will see a stale-lock and refuse.
|
|
2416
|
+
*/
|
|
2417
|
+
async releaseLock() {
|
|
2418
|
+
return releaseDirectorStateLock(this.lockPath);
|
|
2419
|
+
}
|
|
2420
|
+
/**
|
|
2421
|
+
* Resume from a snapshot previously loaded via `loadDirectorState()`.
|
|
2422
|
+
* Use this when `--resume <runId>` is triggered — the snapshot has
|
|
2423
|
+
* the full fleet state (subagents, tasks) from before the crash; the
|
|
2424
|
+
* checkpoint continues from there.
|
|
2425
|
+
*/
|
|
2426
|
+
resume(snapshot) {
|
|
2427
|
+
this.snapshot = snapshot;
|
|
2428
|
+
}
|
|
2210
2429
|
current() {
|
|
2211
2430
|
return this.snapshot;
|
|
2212
2431
|
}
|
|
@@ -2290,6 +2509,6 @@ var DirectorStateCheckpoint = class {
|
|
|
2290
2509
|
}
|
|
2291
2510
|
};
|
|
2292
2511
|
|
|
2293
|
-
export { ConfigMigrationError, DEFAULT_CONFIG_MIGRATIONS, DefaultAttachmentStore, DefaultConfigLoader, DefaultConfigStore, DefaultMemoryStore, DefaultSessionReader, DefaultSessionRewinder, DefaultSessionStore, DirectorStateCheckpoint, QueueStore, RecoveryLock, SessionAnalyzer, addPlanItem, attachPlanCheckpoint, attachTodosCheckpoint, clearPlan, emptyPlan, formatPlan, loadDirectorState, loadPlan, loadTodosCheckpoint, removePlanItem, runConfigMigrations, savePlan, saveTodosCheckpoint, setPlanItemStatus };
|
|
2512
|
+
export { ConfigMigrationError, DEFAULT_CONFIG_MIGRATIONS, DefaultAttachmentStore, DefaultConfigLoader, DefaultConfigStore, DefaultMemoryStore, DefaultSessionReader, DefaultSessionRewinder, DefaultSessionStore, DirectorStateCheckpoint, QueueStore, RecoveryLock, SessionAnalyzer, addPlanItem, attachPlanCheckpoint, attachTodosCheckpoint, clearPlan, deriveTodosFromPlanItem, emptyPlan, formatPlan, formatPlanTemplates, getPlanTemplate, listPlanTemplates, loadDirectorState, loadPlan, loadTodosCheckpoint, removePlanItem, runConfigMigrations, savePlan, saveTodosCheckpoint, setPlanItemStatus };
|
|
2294
2513
|
//# sourceMappingURL=index.js.map
|
|
2295
2514
|
//# sourceMappingURL=index.js.map
|