@wrongstack/core 0.41.0 → 0.51.3
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-D_XcS2HL.d.ts → agent-bridge-CjbD-i7-.d.ts} +1 -1
- package/dist/{agent-subagent-runner-C66vi4Gq.d.ts → agent-subagent-runner-DfvlBx5N.d.ts} +3 -3
- package/dist/coordination/index.d.ts +8 -8
- package/dist/coordination/index.js +234 -32
- package/dist/coordination/index.js.map +1 -1
- package/dist/defaults/index.d.ts +11 -11
- package/dist/defaults/index.js +151 -59
- package/dist/defaults/index.js.map +1 -1
- package/dist/{events-BrQiweXN.d.ts → events-Bt44ikPN.d.ts} +135 -1
- package/dist/execution/index.d.ts +34 -8
- package/dist/execution/index.js +61 -28
- package/dist/execution/index.js.map +1 -1
- package/dist/extension/index.d.ts +2 -2
- package/dist/{index-DkVgH3wC.d.ts → index-OzA1XjHL.d.ts} +4 -2
- package/dist/{index-6_csX32J.d.ts → index-mAWBdLyJ.d.ts} +1 -1
- package/dist/index.d.ts +96 -20
- package/dist/index.js +532 -132
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/index.d.ts +2 -2
- package/dist/kernel/index.d.ts +3 -3
- package/dist/kernel/index.js +3 -1
- package/dist/kernel/index.js.map +1 -1
- package/dist/models/index.js +5 -2
- package/dist/models/index.js.map +1 -1
- package/dist/{multi-agent-C8Z1i__e.d.ts → multi-agent-Ba9Ni2hC.d.ts} +1 -1
- package/dist/{multi-agent-coordinator-BUsjiRWl.d.ts → multi-agent-coordinator-BuKq0q89.d.ts} +2 -2
- package/dist/{null-fleet-bus-FvgHnZah.d.ts → null-fleet-bus-C0xd73YP.d.ts} +21 -9
- package/dist/observability/index.d.ts +1 -1
- package/dist/{path-resolver-DumKAi0n.d.ts → path-resolver-nkmdiFgi.d.ts} +1 -1
- package/dist/{plan-templates-DYCeRCDN.d.ts → plan-templates-BmDdJ7UL.d.ts} +1 -1
- package/dist/{provider-runner-Dlv8Fvw9.d.ts → provider-runner-BGro2qQB.d.ts} +1 -1
- package/dist/sdd/index.d.ts +4 -4
- package/dist/storage/index.d.ts +2 -2
- package/dist/{tool-executor-BpK-SWtJ.d.ts → tool-executor-p4tP9tGF.d.ts} +1 -1
- package/dist/types/index.d.ts +7 -7
- package/dist/types/index.js +5 -2
- package/dist/types/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { readFile, readdir, stat, mkdir } from 'fs/promises';
|
|
|
5
5
|
import * as path6 from 'path';
|
|
6
6
|
import { join, extname, relative, isAbsolute, resolve, sep } from 'path';
|
|
7
7
|
import * as fs2 from 'fs';
|
|
8
|
-
import * as
|
|
8
|
+
import * as os6 from 'os';
|
|
9
9
|
import { execFile, spawn } from 'child_process';
|
|
10
10
|
import { promisify } from 'util';
|
|
11
11
|
import { EventEmitter } from 'events';
|
|
@@ -93,7 +93,7 @@ async function renameWithRetry(from, to) {
|
|
|
93
93
|
if (!code || !TRANSIENT_RENAME_CODES.has(code) || i === delays.length) {
|
|
94
94
|
throw err;
|
|
95
95
|
}
|
|
96
|
-
await new Promise((
|
|
96
|
+
await new Promise((resolve11) => setTimeout(resolve11, delays[i]));
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
throw lastErr;
|
|
@@ -882,7 +882,9 @@ var TOKENS = {
|
|
|
882
882
|
/** Replaces the entire provider call layer — retry, streaming, tracing. */
|
|
883
883
|
ProviderRunner: t("ProviderRunner"),
|
|
884
884
|
/** Optional git-worktree lifecycle manager (per-phase isolation in AutoPhase). */
|
|
885
|
-
WorktreeManager: t("WorktreeManager")
|
|
885
|
+
WorktreeManager: t("WorktreeManager"),
|
|
886
|
+
/** Optional global Brain arbiter for policy/decision escalation. */
|
|
887
|
+
BrainArbiter: t("BrainArbiter")
|
|
886
888
|
};
|
|
887
889
|
|
|
888
890
|
// src/kernel/run-controller.ts
|
|
@@ -2490,12 +2492,12 @@ var DefaultModelsRegistry = class {
|
|
|
2490
2492
|
*/
|
|
2491
2493
|
async loadOverlay(opts = {}) {
|
|
2492
2494
|
if (this.overlayPayload && !opts.force) return this.overlayPayload;
|
|
2493
|
-
if (this.overlay) {
|
|
2495
|
+
if (hasEntries(this.overlay)) {
|
|
2494
2496
|
this.overlayPayload = this.overlay;
|
|
2495
2497
|
return this.overlayPayload;
|
|
2496
2498
|
}
|
|
2497
2499
|
const fetched = await this.loadOverlayFromUrl(opts);
|
|
2498
|
-
if (fetched) {
|
|
2500
|
+
if (hasEntries(fetched)) {
|
|
2499
2501
|
this.overlayPayload = fetched;
|
|
2500
2502
|
return fetched;
|
|
2501
2503
|
}
|
|
@@ -2622,6 +2624,9 @@ var DefaultModelsRegistry = class {
|
|
|
2622
2624
|
return path6.resolve(this.cacheFile);
|
|
2623
2625
|
}
|
|
2624
2626
|
};
|
|
2627
|
+
function hasEntries(payload) {
|
|
2628
|
+
return payload !== void 0 && Object.keys(payload).length > 0;
|
|
2629
|
+
}
|
|
2625
2630
|
|
|
2626
2631
|
// src/types/mode.ts
|
|
2627
2632
|
var DEFAULT_MODES = [
|
|
@@ -3029,7 +3034,7 @@ var InMemoryAgentBridge = class {
|
|
|
3029
3034
|
);
|
|
3030
3035
|
}
|
|
3031
3036
|
this.inflightGuards.add(correlationId);
|
|
3032
|
-
return new Promise((
|
|
3037
|
+
return new Promise((resolve11, reject) => {
|
|
3033
3038
|
const timer = setTimeout(() => {
|
|
3034
3039
|
this.inflightGuards.delete(correlationId);
|
|
3035
3040
|
this.pendingRequests.delete(correlationId);
|
|
@@ -3041,7 +3046,7 @@ var InMemoryAgentBridge = class {
|
|
|
3041
3046
|
return;
|
|
3042
3047
|
}
|
|
3043
3048
|
this.pendingRequests.set(correlationId, {
|
|
3044
|
-
resolve:
|
|
3049
|
+
resolve: resolve11,
|
|
3045
3050
|
reject,
|
|
3046
3051
|
timer
|
|
3047
3052
|
});
|
|
@@ -3234,11 +3239,11 @@ function validateAgainstSchema(value, schema) {
|
|
|
3234
3239
|
walk2(value, schema, "", errors);
|
|
3235
3240
|
return { ok: errors.length === 0, errors };
|
|
3236
3241
|
}
|
|
3237
|
-
function walk2(value, schema,
|
|
3242
|
+
function walk2(value, schema, path36, errors) {
|
|
3238
3243
|
if (schema.enum !== void 0) {
|
|
3239
3244
|
if (!schema.enum.some((e) => deepEqual(e, value))) {
|
|
3240
3245
|
errors.push({
|
|
3241
|
-
path:
|
|
3246
|
+
path: path36 || "<root>",
|
|
3242
3247
|
message: `expected one of ${JSON.stringify(schema.enum)}, got ${JSON.stringify(value)}`
|
|
3243
3248
|
});
|
|
3244
3249
|
return;
|
|
@@ -3247,7 +3252,7 @@ function walk2(value, schema, path35, errors) {
|
|
|
3247
3252
|
if (typeof schema.type === "string") {
|
|
3248
3253
|
if (!checkType(value, schema.type)) {
|
|
3249
3254
|
errors.push({
|
|
3250
|
-
path:
|
|
3255
|
+
path: path36 || "<root>",
|
|
3251
3256
|
message: `expected ${schema.type}, got ${describeType(value)}`
|
|
3252
3257
|
});
|
|
3253
3258
|
return;
|
|
@@ -3257,19 +3262,19 @@ function walk2(value, schema, path35, errors) {
|
|
|
3257
3262
|
const obj = value;
|
|
3258
3263
|
for (const req of schema.required ?? []) {
|
|
3259
3264
|
if (!(req in obj)) {
|
|
3260
|
-
errors.push({ path: joinPath(
|
|
3265
|
+
errors.push({ path: joinPath(path36, req), message: "required property missing" });
|
|
3261
3266
|
}
|
|
3262
3267
|
}
|
|
3263
3268
|
if (schema.properties) {
|
|
3264
3269
|
for (const [key, subSchema] of Object.entries(schema.properties)) {
|
|
3265
3270
|
if (key in obj) {
|
|
3266
|
-
walk2(obj[key], subSchema, joinPath(
|
|
3271
|
+
walk2(obj[key], subSchema, joinPath(path36, key), errors);
|
|
3267
3272
|
}
|
|
3268
3273
|
}
|
|
3269
3274
|
}
|
|
3270
3275
|
}
|
|
3271
3276
|
if (schema.type === "array" && Array.isArray(value) && schema.items) {
|
|
3272
|
-
value.forEach((item, i) => walk2(item, schema.items, `${
|
|
3277
|
+
value.forEach((item, i) => walk2(item, schema.items, `${path36}[${i}]`, errors));
|
|
3273
3278
|
}
|
|
3274
3279
|
}
|
|
3275
3280
|
function checkType(value, type) {
|
|
@@ -4417,7 +4422,7 @@ function projectHash(absRoot) {
|
|
|
4417
4422
|
return createHash("sha256").update(path6.resolve(absRoot)).digest("hex").slice(0, 12);
|
|
4418
4423
|
}
|
|
4419
4424
|
function resolveWstackPaths(opts) {
|
|
4420
|
-
const home = opts.userHome ??
|
|
4425
|
+
const home = opts.userHome ?? os6.homedir();
|
|
4421
4426
|
const globalRoot = opts.globalRoot ?? path6.join(home, ".wrongstack");
|
|
4422
4427
|
const hash = projectHash(opts.projectRoot);
|
|
4423
4428
|
const projectDir = path6.join(globalRoot, "projects", hash);
|
|
@@ -6092,7 +6097,7 @@ var RecoveryLock = class {
|
|
|
6092
6097
|
constructor(opts) {
|
|
6093
6098
|
this.file = path6.join(opts.dir, LOCK_FILE);
|
|
6094
6099
|
this.pid = opts.pid ?? process.pid;
|
|
6095
|
-
this.hostname = opts.hostname ??
|
|
6100
|
+
this.hostname = opts.hostname ?? os6.hostname();
|
|
6096
6101
|
this.maxAgeMs = opts.maxAgeMs ?? DEFAULT_MAX_AGE_MS;
|
|
6097
6102
|
this.sessionStore = opts.sessionStore;
|
|
6098
6103
|
this.probe = opts.isPidAlive ?? defaultIsPidAlive;
|
|
@@ -7529,8 +7534,8 @@ async function streamProviderToResponse(provider, req, signal, ctx, events) {
|
|
|
7529
7534
|
try {
|
|
7530
7535
|
await Promise.race([
|
|
7531
7536
|
Promise.resolve(iter.return?.()),
|
|
7532
|
-
new Promise((
|
|
7533
|
-
drainTimer = setTimeout(
|
|
7537
|
+
new Promise((resolve11) => {
|
|
7538
|
+
drainTimer = setTimeout(resolve11, 500);
|
|
7534
7539
|
})
|
|
7535
7540
|
]);
|
|
7536
7541
|
} finally {
|
|
@@ -7591,7 +7596,7 @@ async function runProviderWithRetry(opts) {
|
|
|
7591
7596
|
description
|
|
7592
7597
|
});
|
|
7593
7598
|
}
|
|
7594
|
-
await new Promise((
|
|
7599
|
+
await new Promise((resolve11, reject) => {
|
|
7595
7600
|
let settled = false;
|
|
7596
7601
|
const onAbort = () => {
|
|
7597
7602
|
if (settled) return;
|
|
@@ -7604,7 +7609,7 @@ async function runProviderWithRetry(opts) {
|
|
|
7604
7609
|
settled = true;
|
|
7605
7610
|
clearTimeout(t2);
|
|
7606
7611
|
signal.removeEventListener("abort", onAbort);
|
|
7607
|
-
|
|
7612
|
+
resolve11();
|
|
7608
7613
|
}, delay);
|
|
7609
7614
|
if (signal.aborted) {
|
|
7610
7615
|
onAbort();
|
|
@@ -8611,7 +8616,7 @@ init_atomic_write();
|
|
|
8611
8616
|
var MAX_JOURNAL_ENTRIES = 500;
|
|
8612
8617
|
function goalFilePath(projectRoot) {
|
|
8613
8618
|
const hash = createHash("sha256").update(path6.resolve(projectRoot)).digest("hex").slice(0, 12);
|
|
8614
|
-
return path6.join(
|
|
8619
|
+
return path6.join(os6.homedir(), ".wrongstack", "projects", hash, "goal.json");
|
|
8615
8620
|
}
|
|
8616
8621
|
async function loadGoal(filePath) {
|
|
8617
8622
|
let raw;
|
|
@@ -9283,7 +9288,7 @@ ${recentJournal}` : "No prior iterations.",
|
|
|
9283
9288
|
}
|
|
9284
9289
|
};
|
|
9285
9290
|
function sleep(ms) {
|
|
9286
|
-
return new Promise((
|
|
9291
|
+
return new Promise((resolve11) => setTimeout(resolve11, ms));
|
|
9287
9292
|
}
|
|
9288
9293
|
|
|
9289
9294
|
// src/coordination/subagent-budget.ts
|
|
@@ -9499,12 +9504,12 @@ var SubagentBudget = class _SubagentBudget {
|
|
|
9499
9504
|
if (!bus || !bus.hasListenerFor("budget.threshold_reached")) {
|
|
9500
9505
|
return Promise.resolve("stop");
|
|
9501
9506
|
}
|
|
9502
|
-
return new Promise((
|
|
9507
|
+
return new Promise((resolve11) => {
|
|
9503
9508
|
let resolved = false;
|
|
9504
9509
|
const respond = (d) => {
|
|
9505
9510
|
if (resolved) return;
|
|
9506
9511
|
resolved = true;
|
|
9507
|
-
|
|
9512
|
+
resolve11(d);
|
|
9508
9513
|
};
|
|
9509
9514
|
const fallback = setTimeout(
|
|
9510
9515
|
() => respond("stop"),
|
|
@@ -12731,7 +12736,7 @@ var DefaultMultiAgentCoordinator = class _DefaultMultiAgentCoordinator extends E
|
|
|
12731
12736
|
taskIds.map((id) => {
|
|
12732
12737
|
const cached = this.completedResults.find((r) => r.taskId === id);
|
|
12733
12738
|
if (cached) return cached;
|
|
12734
|
-
return new Promise((
|
|
12739
|
+
return new Promise((resolve11, reject) => {
|
|
12735
12740
|
const timeout = setTimeout(() => {
|
|
12736
12741
|
this.off("task.completed", handler);
|
|
12737
12742
|
reject(new Error(`awaitTasks timed out waiting for task "${id}"`));
|
|
@@ -12740,7 +12745,7 @@ var DefaultMultiAgentCoordinator = class _DefaultMultiAgentCoordinator extends E
|
|
|
12740
12745
|
if (result.taskId === id) {
|
|
12741
12746
|
clearTimeout(timeout);
|
|
12742
12747
|
this.off("task.completed", handler);
|
|
12743
|
-
|
|
12748
|
+
resolve11(result);
|
|
12744
12749
|
}
|
|
12745
12750
|
};
|
|
12746
12751
|
this.on("task.completed", handler);
|
|
@@ -13243,7 +13248,7 @@ function providerErrorToSubagentError(err, message, cause) {
|
|
|
13243
13248
|
|
|
13244
13249
|
// src/execution/parallel-eternal-engine.ts
|
|
13245
13250
|
function sleep2(ms) {
|
|
13246
|
-
return new Promise((
|
|
13251
|
+
return new Promise((resolve11) => setTimeout(resolve11, ms));
|
|
13247
13252
|
}
|
|
13248
13253
|
var GOAL_COMPLETE_MARKER2 = /^\s*\[goal[_\s-]?complete\]\s*$/im;
|
|
13249
13254
|
var ParallelEternalEngine = class {
|
|
@@ -13309,8 +13314,14 @@ var ParallelEternalEngine = class {
|
|
|
13309
13314
|
await this.runOneIteration();
|
|
13310
13315
|
} catch (err) {
|
|
13311
13316
|
this.consecutiveFailures++;
|
|
13312
|
-
this.opts.onError?.(
|
|
13313
|
-
|
|
13317
|
+
this.opts.onError?.(
|
|
13318
|
+
err instanceof Error ? err : new Error(String(err)),
|
|
13319
|
+
this.consecutiveFailures
|
|
13320
|
+
);
|
|
13321
|
+
await this.appendFailure(
|
|
13322
|
+
"engine error",
|
|
13323
|
+
err instanceof Error ? err.message : String(err)
|
|
13324
|
+
);
|
|
13314
13325
|
}
|
|
13315
13326
|
if (this.stopRequested) break;
|
|
13316
13327
|
await sleep2(2e3);
|
|
@@ -13326,14 +13337,19 @@ var ParallelEternalEngine = class {
|
|
|
13326
13337
|
* Called by the REPL in its main loop (REPL drives, engine is stateless per tick).
|
|
13327
13338
|
*/
|
|
13328
13339
|
async runOneIteration() {
|
|
13340
|
+
const emit = (stage) => {
|
|
13341
|
+
this.opts.onStage?.(stage);
|
|
13342
|
+
};
|
|
13329
13343
|
this.iterations++;
|
|
13330
13344
|
const goal = await loadGoal(this.goalPath);
|
|
13331
13345
|
if (!goal) {
|
|
13332
13346
|
this.stopRequested = true;
|
|
13347
|
+
emit({ phase: "stopped" });
|
|
13333
13348
|
return false;
|
|
13334
13349
|
}
|
|
13335
13350
|
if (goal.goalState !== "active") {
|
|
13336
13351
|
this.stopRequested = true;
|
|
13352
|
+
emit({ phase: "stopped" });
|
|
13337
13353
|
return false;
|
|
13338
13354
|
}
|
|
13339
13355
|
if (!this.coordinator) {
|
|
@@ -13346,10 +13362,13 @@ var ParallelEternalEngine = class {
|
|
|
13346
13362
|
const runner = makeAgentSubagentRunner({ factory: this.agentFactory });
|
|
13347
13363
|
this.coordinator.setRunner?.(runner);
|
|
13348
13364
|
}
|
|
13365
|
+
emit({ phase: "decompose" });
|
|
13349
13366
|
const tasks = await this.decomposeGoal(goal);
|
|
13350
13367
|
if (!tasks || tasks.length === 0) {
|
|
13368
|
+
emit({ phase: "sleep", ms: 2e3 });
|
|
13351
13369
|
return false;
|
|
13352
13370
|
}
|
|
13371
|
+
emit({ phase: "fanout", slots: Math.min(this.slots, tasks.length) });
|
|
13353
13372
|
const fanOut = await this.fanOut(goal, tasks);
|
|
13354
13373
|
this.iterationsSinceCompact++;
|
|
13355
13374
|
const successCount = fanOut.results.filter((r) => r.status === "success").length;
|
|
@@ -13366,12 +13385,20 @@ var ParallelEternalEngine = class {
|
|
|
13366
13385
|
status,
|
|
13367
13386
|
note
|
|
13368
13387
|
});
|
|
13388
|
+
emit({
|
|
13389
|
+
phase: "aggregate",
|
|
13390
|
+
successCount,
|
|
13391
|
+
total: fanOut.results.length,
|
|
13392
|
+
goalComplete: fanOut.goalComplete
|
|
13393
|
+
});
|
|
13369
13394
|
if (fanOut.goalComplete) {
|
|
13370
13395
|
this.stopRequested = true;
|
|
13371
13396
|
this.state = "stopped";
|
|
13397
|
+
emit({ phase: "stopped" });
|
|
13372
13398
|
return true;
|
|
13373
13399
|
}
|
|
13374
13400
|
await this.maybeCompact();
|
|
13401
|
+
emit({ phase: "sleep", ms: 2e3 });
|
|
13375
13402
|
return fanOut.allSuccessful;
|
|
13376
13403
|
}
|
|
13377
13404
|
// -------------------------------------------------------------------------
|
|
@@ -13385,7 +13412,9 @@ var ParallelEternalEngine = class {
|
|
|
13385
13412
|
(t2) => dispatchAgent(t2, { classifier: this.dispatchClassifier }).catch(() => null)
|
|
13386
13413
|
)
|
|
13387
13414
|
) : [];
|
|
13388
|
-
const recentJournal = goal.journal.slice(-5).map(
|
|
13415
|
+
const recentJournal = goal.journal.slice(-5).map(
|
|
13416
|
+
(e) => ` #${e.iteration} [${e.status}] ${e.task}${e.note ? ` \u2014 ${e.note.slice(0, 80)}` : ""}`
|
|
13417
|
+
).join("\n");
|
|
13389
13418
|
const directivePreamble = [
|
|
13390
13419
|
"\u2550\u2550\u2550 ETERNAL AUTONOMY \u2014 parallel task slot \u2550\u2550\u2550",
|
|
13391
13420
|
"",
|
|
@@ -13428,35 +13457,44 @@ ${personaLine}Task: ${task}
|
|
|
13428
13457
|
role: route?.role ?? "generic",
|
|
13429
13458
|
method: route?.method ?? "none"
|
|
13430
13459
|
});
|
|
13431
|
-
spawnPromises.push(
|
|
13432
|
-
|
|
13433
|
-
|
|
13434
|
-
|
|
13435
|
-
|
|
13436
|
-
|
|
13437
|
-
|
|
13438
|
-
|
|
13439
|
-
|
|
13440
|
-
|
|
13441
|
-
|
|
13442
|
-
|
|
13443
|
-
|
|
13444
|
-
|
|
13445
|
-
|
|
13446
|
-
|
|
13447
|
-
|
|
13448
|
-
|
|
13449
|
-
|
|
13450
|
-
|
|
13451
|
-
|
|
13452
|
-
|
|
13453
|
-
|
|
13454
|
-
|
|
13460
|
+
spawnPromises.push(
|
|
13461
|
+
(async () => {
|
|
13462
|
+
try {
|
|
13463
|
+
await coordinator.spawn(
|
|
13464
|
+
route ? {
|
|
13465
|
+
id: subagentId,
|
|
13466
|
+
name: route.definition.config.name,
|
|
13467
|
+
role: route.role,
|
|
13468
|
+
tools: route.definition.config.tools,
|
|
13469
|
+
systemPromptOverride: route.definition.config.prompt,
|
|
13470
|
+
timeoutMs: this.timeoutMs
|
|
13471
|
+
} : {
|
|
13472
|
+
id: subagentId,
|
|
13473
|
+
name: `slot-${subagentId.slice(-6)}`,
|
|
13474
|
+
// Let the coordinator apply its default budget (roster or generic).
|
|
13475
|
+
// Hardcoding low limits here defeats the x10 budget improvement.
|
|
13476
|
+
timeoutMs: this.timeoutMs
|
|
13477
|
+
}
|
|
13478
|
+
);
|
|
13479
|
+
subagentIds.push(subagentId);
|
|
13480
|
+
taskIds.push(taskId);
|
|
13481
|
+
await coordinator.assign(spec);
|
|
13482
|
+
} catch {
|
|
13483
|
+
}
|
|
13484
|
+
})()
|
|
13485
|
+
);
|
|
13455
13486
|
}
|
|
13456
13487
|
await Promise.all(spawnPromises);
|
|
13457
13488
|
if (taskIds.length === 0) {
|
|
13458
|
-
return {
|
|
13489
|
+
return {
|
|
13490
|
+
results: [],
|
|
13491
|
+
allSuccessful: false,
|
|
13492
|
+
goalComplete: false,
|
|
13493
|
+
partialOutput: "",
|
|
13494
|
+
routes: routeInfo
|
|
13495
|
+
};
|
|
13459
13496
|
}
|
|
13497
|
+
this.opts.onStage?.({ phase: "await", taskIds: [...taskIds] });
|
|
13460
13498
|
let results = [];
|
|
13461
13499
|
try {
|
|
13462
13500
|
const ctrl = new AbortController();
|
|
@@ -15158,6 +15196,12 @@ var Director = class _Director {
|
|
|
15158
15196
|
getLeaderContextPressure() {
|
|
15159
15197
|
return this.leaderContextPressure;
|
|
15160
15198
|
}
|
|
15199
|
+
resolveMaxContext() {
|
|
15200
|
+
const resolved = typeof this.maxContext === "function" ? this.maxContext() : this.maxContext;
|
|
15201
|
+
return resolved && resolved > 0 ? resolved : 128e3;
|
|
15202
|
+
}
|
|
15203
|
+
/** Optional Brain arbiter for director-level policy decisions. */
|
|
15204
|
+
brain;
|
|
15161
15205
|
/**
|
|
15162
15206
|
* Optional fleet-level policy container. When provided the Director
|
|
15163
15207
|
* delegates spawn budgeting, manifest entries, and checkpointing to it
|
|
@@ -15249,7 +15293,7 @@ var Director = class _Director {
|
|
|
15249
15293
|
leaderContextPressure = 0;
|
|
15250
15294
|
/** Maximum context load fraction before spawn is refused. */
|
|
15251
15295
|
maxLeaderContextLoad;
|
|
15252
|
-
/** Provider's max context window in tokens. */
|
|
15296
|
+
/** Provider's max context window in tokens, or a live resolver for runtime model switches. */
|
|
15253
15297
|
maxContext;
|
|
15254
15298
|
/** Per-task model matrix (static record or live getter); resolved
|
|
15255
15299
|
* per-spawn when no explicit model is set. */
|
|
@@ -15269,6 +15313,7 @@ var Director = class _Director {
|
|
|
15269
15313
|
largeAnswerStore;
|
|
15270
15314
|
constructor(opts) {
|
|
15271
15315
|
this.id = opts.config.coordinatorId || randomUUID();
|
|
15316
|
+
this.brain = opts.brain;
|
|
15272
15317
|
this.manifestPath = opts.manifestPath;
|
|
15273
15318
|
this.roster = opts.roster;
|
|
15274
15319
|
this.directorPreamble = opts.directorPreamble ?? DEFAULT_DIRECTOR_PREAMBLE;
|
|
@@ -15413,33 +15458,81 @@ var Director = class _Director {
|
|
|
15413
15458
|
return;
|
|
15414
15459
|
}
|
|
15415
15460
|
}
|
|
15416
|
-
|
|
15417
|
-
|
|
15418
|
-
|
|
15419
|
-
|
|
15420
|
-
|
|
15421
|
-
|
|
15422
|
-
|
|
15423
|
-
|
|
15424
|
-
|
|
15425
|
-
|
|
15426
|
-
|
|
15427
|
-
|
|
15428
|
-
|
|
15429
|
-
|
|
15430
|
-
|
|
15431
|
-
|
|
15432
|
-
|
|
15433
|
-
|
|
15434
|
-
|
|
15435
|
-
|
|
15436
|
-
|
|
15437
|
-
|
|
15438
|
-
|
|
15439
|
-
|
|
15440
|
-
|
|
15441
|
-
|
|
15442
|
-
|
|
15461
|
+
const grantExtension = () => {
|
|
15462
|
+
setImmediate(() => {
|
|
15463
|
+
const extra = {};
|
|
15464
|
+
const base = Math.max(payload.limit, payload.used);
|
|
15465
|
+
const grow = (ceiling) => Math.min(Math.ceil(base * 1.5), ceiling);
|
|
15466
|
+
let newLimit = base;
|
|
15467
|
+
switch (payload.kind) {
|
|
15468
|
+
case "iterations":
|
|
15469
|
+
newLimit = grow(5e4);
|
|
15470
|
+
extra.maxIterations = newLimit;
|
|
15471
|
+
break;
|
|
15472
|
+
case "tool_calls":
|
|
15473
|
+
newLimit = grow(1e5);
|
|
15474
|
+
extra.maxToolCalls = newLimit;
|
|
15475
|
+
break;
|
|
15476
|
+
case "tokens":
|
|
15477
|
+
newLimit = grow(5e6);
|
|
15478
|
+
extra.maxTokens = newLimit;
|
|
15479
|
+
break;
|
|
15480
|
+
case "cost":
|
|
15481
|
+
newLimit = Math.min(base * 1.5, 100);
|
|
15482
|
+
extra.maxCostUsd = newLimit;
|
|
15483
|
+
break;
|
|
15484
|
+
}
|
|
15485
|
+
extendCounts.set(guardKey, prior + 1);
|
|
15486
|
+
this.recordExtension(e.subagentId, e.taskId, payload.kind, newLimit);
|
|
15487
|
+
payload.extend(extra);
|
|
15488
|
+
});
|
|
15489
|
+
};
|
|
15490
|
+
if (this.brain) {
|
|
15491
|
+
void this.brain.decide({
|
|
15492
|
+
id: `director-budget-${e.subagentId}-${payload.kind}`,
|
|
15493
|
+
source: "director",
|
|
15494
|
+
question: `Should the director extend the ${payload.kind} budget for subagent ${e.subagentId}?`,
|
|
15495
|
+
context: [
|
|
15496
|
+
e.taskId ? `Task id: ${e.taskId}` : void 0,
|
|
15497
|
+
`Used: ${payload.used}`,
|
|
15498
|
+
`Limit: ${payload.limit}`,
|
|
15499
|
+
`Prior extensions for this kind: ${prior}`
|
|
15500
|
+
].filter(Boolean).join("\n"),
|
|
15501
|
+
risk: payload.kind === "cost" ? "high" : "medium",
|
|
15502
|
+
fallback: "continue",
|
|
15503
|
+
options: [
|
|
15504
|
+
{
|
|
15505
|
+
id: "extend",
|
|
15506
|
+
label: "Grant the director default budget extension",
|
|
15507
|
+
consequence: "The subagent continues with a larger per-kind budget.",
|
|
15508
|
+
risk: payload.kind === "cost" ? "high" : "medium",
|
|
15509
|
+
recommended: true
|
|
15510
|
+
},
|
|
15511
|
+
{
|
|
15512
|
+
id: "stop",
|
|
15513
|
+
label: "Stop this subagent at the current budget limit",
|
|
15514
|
+
consequence: "The current task will fail or stop due to budget pressure.",
|
|
15515
|
+
risk: "low"
|
|
15516
|
+
}
|
|
15517
|
+
]
|
|
15518
|
+
}).then((decision) => {
|
|
15519
|
+
if (decision.type === "deny") {
|
|
15520
|
+
payload.deny();
|
|
15521
|
+
return;
|
|
15522
|
+
}
|
|
15523
|
+
if (decision.type === "ask_human") {
|
|
15524
|
+
payload.deny();
|
|
15525
|
+
return;
|
|
15526
|
+
}
|
|
15527
|
+
if (decision.optionId === "stop" || /\bstop\b/i.test(decision.text)) {
|
|
15528
|
+
payload.deny();
|
|
15529
|
+
return;
|
|
15530
|
+
}
|
|
15531
|
+
grantExtension();
|
|
15532
|
+
}).catch(() => payload.deny());
|
|
15533
|
+
return;
|
|
15534
|
+
}
|
|
15535
|
+
grantExtension();
|
|
15443
15536
|
});
|
|
15444
15537
|
this.largeAnswerStore = new LargeAnswerStore(2e3);
|
|
15445
15538
|
}
|
|
@@ -15649,7 +15742,8 @@ var Director = class _Director {
|
|
|
15649
15742
|
}
|
|
15650
15743
|
}
|
|
15651
15744
|
if (this.maxLeaderContextLoad < 1) {
|
|
15652
|
-
const
|
|
15745
|
+
const maxContext = this.resolveMaxContext();
|
|
15746
|
+
const threshold = maxContext * this.maxLeaderContextLoad;
|
|
15653
15747
|
if (this.leaderContextPressure >= threshold) {
|
|
15654
15748
|
throw new FleetContextOverflowError(threshold, this.leaderContextPressure);
|
|
15655
15749
|
}
|
|
@@ -15959,11 +16053,11 @@ var Director = class _Director {
|
|
|
15959
16053
|
if (cached) return cached;
|
|
15960
16054
|
const existing = this.taskWaiters.get(id);
|
|
15961
16055
|
if (existing) return existing.promise;
|
|
15962
|
-
let
|
|
16056
|
+
let resolve11;
|
|
15963
16057
|
const promise = new Promise((res) => {
|
|
15964
|
-
|
|
16058
|
+
resolve11 = res;
|
|
15965
16059
|
});
|
|
15966
|
-
this.taskWaiters.set(id, { promise, resolve:
|
|
16060
|
+
this.taskWaiters.set(id, { promise, resolve: resolve11 });
|
|
15967
16061
|
return promise;
|
|
15968
16062
|
})
|
|
15969
16063
|
);
|
|
@@ -16348,7 +16442,7 @@ function createDelegateTool(opts) {
|
|
|
16348
16442
|
subagentId
|
|
16349
16443
|
});
|
|
16350
16444
|
const dir = director;
|
|
16351
|
-
const result = await new Promise((
|
|
16445
|
+
const result = await new Promise((resolve11) => {
|
|
16352
16446
|
let settled = false;
|
|
16353
16447
|
let timer;
|
|
16354
16448
|
const finish = (value) => {
|
|
@@ -16358,7 +16452,7 @@ function createDelegateTool(opts) {
|
|
|
16358
16452
|
offTool();
|
|
16359
16453
|
offIter();
|
|
16360
16454
|
offProgress();
|
|
16361
|
-
|
|
16455
|
+
resolve11(value);
|
|
16362
16456
|
};
|
|
16363
16457
|
const arm = () => {
|
|
16364
16458
|
if (timer) clearTimeout(timer);
|
|
@@ -17988,9 +18082,9 @@ var AISpecBuilder = class {
|
|
|
17988
18082
|
if (!this.sessionPath) return;
|
|
17989
18083
|
try {
|
|
17990
18084
|
const fsp20 = await import('fs/promises');
|
|
17991
|
-
const
|
|
18085
|
+
const path36 = await import('path');
|
|
17992
18086
|
const { atomicWrite: atomicWrite2 } = await Promise.resolve().then(() => (init_atomic_write(), atomic_write_exports));
|
|
17993
|
-
await fsp20.mkdir(
|
|
18087
|
+
await fsp20.mkdir(path36.dirname(this.sessionPath), { recursive: true });
|
|
17994
18088
|
await atomicWrite2(this.sessionPath, JSON.stringify(this.session, null, 2));
|
|
17995
18089
|
} catch {
|
|
17996
18090
|
}
|
|
@@ -18700,15 +18794,15 @@ function computeCriticalPath(graph, _topoOrder, blockedByMap) {
|
|
|
18700
18794
|
maxId = id;
|
|
18701
18795
|
}
|
|
18702
18796
|
}
|
|
18703
|
-
const
|
|
18797
|
+
const path36 = [];
|
|
18704
18798
|
let current = maxId;
|
|
18705
18799
|
const visited = /* @__PURE__ */ new Set();
|
|
18706
18800
|
while (current && !visited.has(current)) {
|
|
18707
18801
|
visited.add(current);
|
|
18708
|
-
|
|
18802
|
+
path36.unshift(current);
|
|
18709
18803
|
current = prev.get(current) ?? null;
|
|
18710
18804
|
}
|
|
18711
|
-
return
|
|
18805
|
+
return path36;
|
|
18712
18806
|
}
|
|
18713
18807
|
function computeParallelGroups(graph, blockedByMap) {
|
|
18714
18808
|
const groups = [];
|
|
@@ -19501,9 +19595,9 @@ var DefaultHealthRegistry = class {
|
|
|
19501
19595
|
}
|
|
19502
19596
|
async runOne(check) {
|
|
19503
19597
|
let timer = null;
|
|
19504
|
-
const timeout = new Promise((
|
|
19598
|
+
const timeout = new Promise((resolve11) => {
|
|
19505
19599
|
timer = setTimeout(
|
|
19506
|
-
() =>
|
|
19600
|
+
() => resolve11({ status: "unhealthy", detail: `timeout after ${this.timeoutMs}ms` }),
|
|
19507
19601
|
this.timeoutMs
|
|
19508
19602
|
);
|
|
19509
19603
|
});
|
|
@@ -19686,7 +19780,7 @@ async function startMetricsServer(opts) {
|
|
|
19686
19780
|
const tls = opts.tls;
|
|
19687
19781
|
const useHttps = !!(tls?.cert && tls?.key);
|
|
19688
19782
|
const host = opts.host ?? "127.0.0.1";
|
|
19689
|
-
const
|
|
19783
|
+
const path36 = opts.path ?? "/metrics";
|
|
19690
19784
|
const healthPath = opts.healthPath ?? "/healthz";
|
|
19691
19785
|
const healthRegistry = opts.healthRegistry;
|
|
19692
19786
|
const listener = (req, res) => {
|
|
@@ -19696,7 +19790,7 @@ async function startMetricsServer(opts) {
|
|
|
19696
19790
|
return;
|
|
19697
19791
|
}
|
|
19698
19792
|
const url = req.url.split("?")[0];
|
|
19699
|
-
if (url ===
|
|
19793
|
+
if (url === path36) {
|
|
19700
19794
|
let body;
|
|
19701
19795
|
try {
|
|
19702
19796
|
body = renderPrometheus(opts.sink.snapshot());
|
|
@@ -19742,14 +19836,14 @@ async function startMetricsServer(opts) {
|
|
|
19742
19836
|
const { createServer } = await import('http');
|
|
19743
19837
|
server = createServer(listener);
|
|
19744
19838
|
}
|
|
19745
|
-
await new Promise((
|
|
19839
|
+
await new Promise((resolve11, reject) => {
|
|
19746
19840
|
const onError = (err) => {
|
|
19747
19841
|
server.off("listening", onListening);
|
|
19748
19842
|
reject(err);
|
|
19749
19843
|
};
|
|
19750
19844
|
const onListening = () => {
|
|
19751
19845
|
server.off("error", onError);
|
|
19752
|
-
|
|
19846
|
+
resolve11();
|
|
19753
19847
|
};
|
|
19754
19848
|
server.once("error", onError);
|
|
19755
19849
|
server.once("listening", onListening);
|
|
@@ -19760,9 +19854,9 @@ async function startMetricsServer(opts) {
|
|
|
19760
19854
|
const protocol = useHttps ? "https" : "http";
|
|
19761
19855
|
return {
|
|
19762
19856
|
port: boundPort,
|
|
19763
|
-
url: `${protocol}://${host}:${boundPort}${
|
|
19764
|
-
close: () => new Promise((
|
|
19765
|
-
server.close((err) => err ? reject(err) :
|
|
19857
|
+
url: `${protocol}://${host}:${boundPort}${path36}`,
|
|
19858
|
+
close: () => new Promise((resolve11, reject) => {
|
|
19859
|
+
server.close((err) => err ? reject(err) : resolve11());
|
|
19766
19860
|
})
|
|
19767
19861
|
};
|
|
19768
19862
|
}
|
|
@@ -20462,7 +20556,7 @@ async function downloadGitHubTarball(parsed) {
|
|
|
20462
20556
|
`Tarball too large (${(Number.parseInt(contentLength, 10) / 1024 / 1024).toFixed(1)}MB). Max: ${MAX_TARBALL_SIZE / 1024 / 1024}MB`
|
|
20463
20557
|
);
|
|
20464
20558
|
}
|
|
20465
|
-
const tempDir = await fsp3.mkdtemp(path6.join(
|
|
20559
|
+
const tempDir = await fsp3.mkdtemp(path6.join(os6.tmpdir(), "wskill-"));
|
|
20466
20560
|
try {
|
|
20467
20561
|
if (!response.body) {
|
|
20468
20562
|
throw new Error("Empty response body from GitHub API");
|
|
@@ -22962,8 +23056,8 @@ var ReportGenerator = class {
|
|
|
22962
23056
|
try {
|
|
22963
23057
|
await stat(this.options.outputDir);
|
|
22964
23058
|
} catch {
|
|
22965
|
-
const { mkdir:
|
|
22966
|
-
await
|
|
23059
|
+
const { mkdir: mkdir16 } = await import('fs/promises');
|
|
23060
|
+
await mkdir16(this.options.outputDir, { recursive: true });
|
|
22967
23061
|
}
|
|
22968
23062
|
}
|
|
22969
23063
|
generateMarkdown(result) {
|
|
@@ -23243,7 +23337,7 @@ var SecurityScannerOrchestrator = class {
|
|
|
23243
23337
|
const delay = Math.round(policy.delayMs(attempt));
|
|
23244
23338
|
const status = isProviderErr ? err.status : 0;
|
|
23245
23339
|
console.warn(`[SecurityScanner] retry ${attempt + 1} after ${delay}ms (status=${status}) \u2014 ${errAsErr.message}`);
|
|
23246
|
-
await new Promise((
|
|
23340
|
+
await new Promise((resolve11) => setTimeout(resolve11, delay));
|
|
23247
23341
|
return this.completeWithRetry(provider, request, abortController, attempt + 1);
|
|
23248
23342
|
}
|
|
23249
23343
|
}
|
|
@@ -23988,7 +24082,7 @@ var FleetManager = class {
|
|
|
23988
24082
|
leaderContextPressure = 0;
|
|
23989
24083
|
/** Maximum context load fraction before spawn is refused. */
|
|
23990
24084
|
maxLeaderContextLoad;
|
|
23991
|
-
/** Provider's max context window in tokens. */
|
|
24085
|
+
/** Provider's max context window in tokens, or a live resolver for runtime model switches. */
|
|
23992
24086
|
maxContext;
|
|
23993
24087
|
constructor(opts = {}) {
|
|
23994
24088
|
this.manifestPath = opts.manifestPath;
|
|
@@ -24068,7 +24162,8 @@ var FleetManager = class {
|
|
|
24068
24162
|
}
|
|
24069
24163
|
}
|
|
24070
24164
|
if (this.maxLeaderContextLoad < 1) {
|
|
24071
|
-
const
|
|
24165
|
+
const maxContext = this.resolveMaxContext();
|
|
24166
|
+
const threshold = maxContext * this.maxLeaderContextLoad;
|
|
24072
24167
|
if (this.leaderContextPressure >= threshold) {
|
|
24073
24168
|
return {
|
|
24074
24169
|
kind: "max_context_load",
|
|
@@ -24082,6 +24177,10 @@ var FleetManager = class {
|
|
|
24082
24177
|
setLeaderContextPressure(tokens) {
|
|
24083
24178
|
this.leaderContextPressure = tokens;
|
|
24084
24179
|
}
|
|
24180
|
+
resolveMaxContext() {
|
|
24181
|
+
const resolved = typeof this.maxContext === "function" ? this.maxContext() : this.maxContext;
|
|
24182
|
+
return resolved && resolved > 0 ? resolved : 128e3;
|
|
24183
|
+
}
|
|
24085
24184
|
/**
|
|
24086
24185
|
* Assign a memorable nickname (e.g. "Einstein (Bug Hunter)") to the config,
|
|
24087
24186
|
* record it so the same name is never reused, then record the spawn.
|
|
@@ -24814,12 +24913,12 @@ function makeContinueToNextIterationTool() {
|
|
|
24814
24913
|
// src/core/iteration-limit.ts
|
|
24815
24914
|
function requestLimitExtension(opts) {
|
|
24816
24915
|
const { events, currentIterations, currentLimit, autoExtend, timeoutMs = 3e4 } = opts;
|
|
24817
|
-
return new Promise((
|
|
24916
|
+
return new Promise((resolve11) => {
|
|
24818
24917
|
let resolved = false;
|
|
24819
24918
|
const timerFired = () => {
|
|
24820
24919
|
if (!resolved) {
|
|
24821
24920
|
resolved = true;
|
|
24822
|
-
|
|
24921
|
+
resolve11(0);
|
|
24823
24922
|
}
|
|
24824
24923
|
};
|
|
24825
24924
|
const timer = setTimeout(timerFired, timeoutMs);
|
|
@@ -24828,14 +24927,14 @@ function requestLimitExtension(opts) {
|
|
|
24828
24927
|
if (!resolved) {
|
|
24829
24928
|
resolved = true;
|
|
24830
24929
|
clearTimeout(timer);
|
|
24831
|
-
|
|
24930
|
+
resolve11(0);
|
|
24832
24931
|
}
|
|
24833
24932
|
};
|
|
24834
24933
|
const grant = (extra) => {
|
|
24835
24934
|
if (!resolved) {
|
|
24836
24935
|
resolved = true;
|
|
24837
24936
|
clearTimeout(timer);
|
|
24838
|
-
|
|
24937
|
+
resolve11(Math.max(0, extra));
|
|
24839
24938
|
}
|
|
24840
24939
|
};
|
|
24841
24940
|
events.emit("iteration.limit_reached", {
|
|
@@ -24849,7 +24948,7 @@ function requestLimitExtension(opts) {
|
|
|
24849
24948
|
if (!resolved) {
|
|
24850
24949
|
resolved = true;
|
|
24851
24950
|
clearTimeout(timer);
|
|
24852
|
-
|
|
24951
|
+
resolve11(100);
|
|
24853
24952
|
}
|
|
24854
24953
|
});
|
|
24855
24954
|
}
|
|
@@ -25441,13 +25540,13 @@ var Agent = class {
|
|
|
25441
25540
|
}
|
|
25442
25541
|
}
|
|
25443
25542
|
waitForConfirm(info) {
|
|
25444
|
-
return new Promise((
|
|
25543
|
+
return new Promise((resolve11) => {
|
|
25445
25544
|
this.events.emit("tool.confirm_needed", {
|
|
25446
25545
|
tool: info.tool,
|
|
25447
25546
|
input: info.input,
|
|
25448
25547
|
toolUseId: info.toolUseId,
|
|
25449
25548
|
suggestedPattern: info.suggestedPattern,
|
|
25450
|
-
resolve:
|
|
25549
|
+
resolve: resolve11
|
|
25451
25550
|
});
|
|
25452
25551
|
});
|
|
25453
25552
|
}
|
|
@@ -25521,6 +25620,85 @@ function sizeSignals(toolName, content) {
|
|
|
25521
25620
|
}
|
|
25522
25621
|
return { outputBytes, outputTokens, outputLines };
|
|
25523
25622
|
}
|
|
25623
|
+
async function bootConfig(options = {}) {
|
|
25624
|
+
const { flags = {}, appLabel = "wstack", loadSyncConfig = true } = options;
|
|
25625
|
+
const cwd = typeof flags["cwd"] === "string" ? path6.resolve(flags["cwd"]) : process.cwd();
|
|
25626
|
+
const pathResolver = new DefaultPathResolver(cwd);
|
|
25627
|
+
const projectRoot = pathResolver.projectRoot;
|
|
25628
|
+
const userHome = os6.homedir();
|
|
25629
|
+
const wpaths = resolveWstackPaths({ projectRoot, userHome });
|
|
25630
|
+
await fsp3.mkdir(wpaths.globalRoot, { recursive: true });
|
|
25631
|
+
await fsp3.mkdir(wpaths.projectDir, { recursive: true });
|
|
25632
|
+
await fsp3.mkdir(wpaths.projectSessions, { recursive: true });
|
|
25633
|
+
await writeProjectMeta(wpaths, projectRoot);
|
|
25634
|
+
const vault = new DefaultSecretVault({ keyFile: wpaths.secretsKey });
|
|
25635
|
+
for (const file of [wpaths.globalConfig, wpaths.projectLocalConfig]) {
|
|
25636
|
+
try {
|
|
25637
|
+
const { migrated } = await migratePlaintextSecrets(file, vault);
|
|
25638
|
+
if (migrated > 0) {
|
|
25639
|
+
writeErr(`[${appLabel}] Encrypted ${migrated} plaintext secret(s) in ${file}
|
|
25640
|
+
`);
|
|
25641
|
+
}
|
|
25642
|
+
} catch {
|
|
25643
|
+
}
|
|
25644
|
+
}
|
|
25645
|
+
const configLoader = new DefaultConfigLoader({ paths: wpaths, vault });
|
|
25646
|
+
let config = await configLoader.load({ cliFlags: flagsToConfigPatch(flags) });
|
|
25647
|
+
if (loadSyncConfig) {
|
|
25648
|
+
const syncConfig = await configLoader.loadSyncConfig();
|
|
25649
|
+
if (syncConfig) {
|
|
25650
|
+
config = Object.freeze({ ...config, sync: syncConfig });
|
|
25651
|
+
}
|
|
25652
|
+
}
|
|
25653
|
+
const logger = new DefaultLogger({ level: config.log?.level ?? "info", file: wpaths.logFile });
|
|
25654
|
+
return {
|
|
25655
|
+
cwd,
|
|
25656
|
+
projectRoot,
|
|
25657
|
+
userHome,
|
|
25658
|
+
wpaths,
|
|
25659
|
+
pathResolver,
|
|
25660
|
+
config,
|
|
25661
|
+
vault,
|
|
25662
|
+
logger,
|
|
25663
|
+
globalConfigPath: wpaths.globalConfig
|
|
25664
|
+
};
|
|
25665
|
+
}
|
|
25666
|
+
function flagsToConfigPatch(flags) {
|
|
25667
|
+
const patch = {};
|
|
25668
|
+
if (typeof flags["provider"] === "string") patch.provider = flags["provider"];
|
|
25669
|
+
if (typeof flags["model"] === "string") patch.model = flags["model"];
|
|
25670
|
+
if (typeof flags["cwd"] === "string") patch.cwd = flags["cwd"];
|
|
25671
|
+
if (typeof flags["log-level"] === "string") {
|
|
25672
|
+
patch.log = { level: flags["log-level"] };
|
|
25673
|
+
} else if (flags["verbose"]) {
|
|
25674
|
+
patch.log = { level: "debug" };
|
|
25675
|
+
} else if (flags["trace"]) {
|
|
25676
|
+
patch.log = { level: "trace" };
|
|
25677
|
+
}
|
|
25678
|
+
if (flags["yolo"]) patch.yolo = true;
|
|
25679
|
+
if (flags["no-features"]) {
|
|
25680
|
+
patch.features = {
|
|
25681
|
+
mcp: false,
|
|
25682
|
+
plugins: false,
|
|
25683
|
+
memory: false,
|
|
25684
|
+
modelsRegistry: false,
|
|
25685
|
+
skills: false
|
|
25686
|
+
};
|
|
25687
|
+
}
|
|
25688
|
+
return patch;
|
|
25689
|
+
}
|
|
25690
|
+
async function writeProjectMeta(paths, projectRoot) {
|
|
25691
|
+
try {
|
|
25692
|
+
await fsp3.mkdir(paths.projectDir, { recursive: true });
|
|
25693
|
+
const meta = {
|
|
25694
|
+
hash: paths.projectHash,
|
|
25695
|
+
root: projectRoot,
|
|
25696
|
+
lastSeen: (/* @__PURE__ */ new Date()).toISOString()
|
|
25697
|
+
};
|
|
25698
|
+
await fsp3.writeFile(paths.projectMeta, JSON.stringify(meta, null, 2));
|
|
25699
|
+
} catch {
|
|
25700
|
+
}
|
|
25701
|
+
}
|
|
25524
25702
|
|
|
25525
25703
|
// src/core/conversation-state.ts
|
|
25526
25704
|
var ConversationState = class {
|
|
@@ -25820,8 +25998,8 @@ var InputBuilder = class {
|
|
|
25820
25998
|
async registerFile(input) {
|
|
25821
25999
|
const ref = await this.store.add({ ...input, kind: "file" });
|
|
25822
26000
|
this.refs.push(ref);
|
|
25823
|
-
const
|
|
25824
|
-
return `[file:${
|
|
26001
|
+
const path36 = ref.meta.filename ?? ref.meta.label ?? String(ref.seq);
|
|
26002
|
+
return `[file:${path36}]`;
|
|
25825
26003
|
}
|
|
25826
26004
|
/**
|
|
25827
26005
|
* Whether `appendPaste(text)` would collapse the text to a placeholder
|
|
@@ -26152,7 +26330,7 @@ summarize it, and let the tool result hold only the summary.`);
|
|
|
26152
26330
|
const cached = this.envCacheByRoot.get(ctx.projectRoot);
|
|
26153
26331
|
if (cached) return cached;
|
|
26154
26332
|
const today = this.opts.todayIso ?? (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
26155
|
-
const platform2 = `${
|
|
26333
|
+
const platform2 = `${os6.platform()} ${os6.release()}`;
|
|
26156
26334
|
const shell = process.env.SHELL ?? process.env.ComSpec ?? "unknown";
|
|
26157
26335
|
const node = process.version;
|
|
26158
26336
|
const isGit = await this.dirExists(path6.join(ctx.projectRoot, ".git"));
|
|
@@ -26221,12 +26399,12 @@ ${mem}`);
|
|
|
26221
26399
|
}
|
|
26222
26400
|
}
|
|
26223
26401
|
async gitStatus(root) {
|
|
26224
|
-
return new Promise((
|
|
26402
|
+
return new Promise((resolve11) => {
|
|
26225
26403
|
let settled = false;
|
|
26226
26404
|
const finish = (s) => {
|
|
26227
26405
|
if (settled) return;
|
|
26228
26406
|
settled = true;
|
|
26229
|
-
|
|
26407
|
+
resolve11(s);
|
|
26230
26408
|
};
|
|
26231
26409
|
let proc;
|
|
26232
26410
|
const timer = setTimeout(() => {
|
|
@@ -27183,11 +27361,15 @@ var PhaseOrchestrator = class {
|
|
|
27183
27361
|
this.graph.updatedAt = Date.now();
|
|
27184
27362
|
let readyPhases = this.getReadyPhases();
|
|
27185
27363
|
while (readyPhases.length > 0 && !this.stopped) {
|
|
27364
|
+
await this.waitWhilePaused();
|
|
27365
|
+
if (this.stopped) break;
|
|
27186
27366
|
const batch = readyPhases.slice(0, this.opts.maxConcurrentPhases);
|
|
27187
27367
|
await Promise.all(batch.map((p) => this.startPhase(p)));
|
|
27188
27368
|
if (this.opts.phaseDelayMs > 0) {
|
|
27189
27369
|
await this.delay(this.opts.phaseDelayMs);
|
|
27190
27370
|
}
|
|
27371
|
+
await this.waitWhilePaused();
|
|
27372
|
+
if (this.stopped) break;
|
|
27191
27373
|
readyPhases = this.getReadyPhases().filter(
|
|
27192
27374
|
(p) => !this.runningPhases.has(p.id) && p.status !== "completed" && p.status !== "failed"
|
|
27193
27375
|
);
|
|
@@ -27428,7 +27610,9 @@ var PhaseOrchestrator = class {
|
|
|
27428
27610
|
async mergeOne(phase, handle) {
|
|
27429
27611
|
if (!this.worktrees) return;
|
|
27430
27612
|
try {
|
|
27431
|
-
const
|
|
27613
|
+
const resolve11 = this.ctx.resolveConflict ? async (info) => {
|
|
27614
|
+
const shouldResolve = await this.shouldAttemptConflictResolution(phase, info);
|
|
27615
|
+
if (!shouldResolve) return false;
|
|
27432
27616
|
this.emit("phase.conflictResolving", {
|
|
27433
27617
|
phaseId: phase.id,
|
|
27434
27618
|
name: phase.name,
|
|
@@ -27436,12 +27620,22 @@ var PhaseOrchestrator = class {
|
|
|
27436
27620
|
});
|
|
27437
27621
|
return this.ctx.resolveConflict(phase, info);
|
|
27438
27622
|
} : void 0;
|
|
27439
|
-
const result = await this.worktrees.merge(handle, { squash: true, resolve:
|
|
27623
|
+
const result = await this.worktrees.merge(handle, { squash: true, resolve: resolve11 });
|
|
27440
27624
|
if (result.resolved) {
|
|
27441
27625
|
this.emit("phase.conflictResolved", { phaseId: phase.id, name: phase.name });
|
|
27442
27626
|
}
|
|
27627
|
+
this.setIntegrationMetadata(phase, result.ok ? "merged" : "needs_review", {
|
|
27628
|
+
branch: handle.branch,
|
|
27629
|
+
worktreeDir: handle.dir,
|
|
27630
|
+
conflictFiles: result.conflictFiles
|
|
27631
|
+
});
|
|
27443
27632
|
await this.worktrees.release(handle, { keep: !result.ok });
|
|
27444
27633
|
} catch (err) {
|
|
27634
|
+
this.setIntegrationMetadata(phase, "merge_failed", {
|
|
27635
|
+
branch: handle.branch,
|
|
27636
|
+
worktreeDir: handle.dir,
|
|
27637
|
+
error: err instanceof Error ? err.message : String(err)
|
|
27638
|
+
});
|
|
27445
27639
|
this.emit("phase.failed", {
|
|
27446
27640
|
phaseId: phase.id,
|
|
27447
27641
|
name: phase.name,
|
|
@@ -27449,6 +27643,56 @@ var PhaseOrchestrator = class {
|
|
|
27449
27643
|
});
|
|
27450
27644
|
}
|
|
27451
27645
|
}
|
|
27646
|
+
async shouldAttemptConflictResolution(phase, info) {
|
|
27647
|
+
if (!this.ctx.brain) return true;
|
|
27648
|
+
const decision = await this.ctx.brain.decide({
|
|
27649
|
+
id: `autophase-conflict-${phase.id}`,
|
|
27650
|
+
source: "autophase",
|
|
27651
|
+
question: `Should AutoPhase try to resolve merge conflicts for phase "${phase.name}" automatically?`,
|
|
27652
|
+
context: [
|
|
27653
|
+
`Phase id: ${phase.id}`,
|
|
27654
|
+
`Conflicted files: ${info.conflictFiles.join(", ") || "(unknown)"}`,
|
|
27655
|
+
`Base working tree: ${info.cwd}`
|
|
27656
|
+
].join("\n"),
|
|
27657
|
+
risk: "high",
|
|
27658
|
+
fallback: "ask_human",
|
|
27659
|
+
options: [
|
|
27660
|
+
{
|
|
27661
|
+
id: "resolve",
|
|
27662
|
+
label: "Try the configured conflict resolver",
|
|
27663
|
+
consequence: "A resolver agent may edit conflicted files in the base working tree.",
|
|
27664
|
+
risk: "medium"
|
|
27665
|
+
},
|
|
27666
|
+
{
|
|
27667
|
+
id: "review",
|
|
27668
|
+
label: "Keep the worktree for human review",
|
|
27669
|
+
consequence: "No automatic conflict resolution is attempted.",
|
|
27670
|
+
risk: "low",
|
|
27671
|
+
recommended: true
|
|
27672
|
+
}
|
|
27673
|
+
]
|
|
27674
|
+
});
|
|
27675
|
+
phase.metadata = {
|
|
27676
|
+
...phase.metadata,
|
|
27677
|
+
brainConflictDecision: decision.type,
|
|
27678
|
+
brainConflictDecisionAt: Date.now()
|
|
27679
|
+
};
|
|
27680
|
+
if (decision.type !== "answer") return false;
|
|
27681
|
+
return decision.optionId === "resolve" || /\bresolve\b/i.test(decision.text);
|
|
27682
|
+
}
|
|
27683
|
+
setIntegrationMetadata(phase, status, details = {}) {
|
|
27684
|
+
phase.metadata = {
|
|
27685
|
+
...phase.metadata,
|
|
27686
|
+
integrationStatus: status,
|
|
27687
|
+
integrationBranch: details.branch,
|
|
27688
|
+
integrationWorktreeDir: details.worktreeDir,
|
|
27689
|
+
integrationConflictFiles: details.conflictFiles,
|
|
27690
|
+
integrationError: details.error,
|
|
27691
|
+
integrationUpdatedAt: Date.now()
|
|
27692
|
+
};
|
|
27693
|
+
phase.updatedAt = Date.now();
|
|
27694
|
+
this.graph.updatedAt = Date.now();
|
|
27695
|
+
}
|
|
27452
27696
|
/** A failed phase keeps its worktree on disk for inspection (no merge). */
|
|
27453
27697
|
async keepWorktreeForReview(phase) {
|
|
27454
27698
|
const handle = this.phaseWorktrees.get(phase.id);
|
|
@@ -27457,6 +27701,10 @@ var PhaseOrchestrator = class {
|
|
|
27457
27701
|
await this.worktrees.commitAll(handle, `autophase(${phase.name}) [failed]: ${phase.id}`);
|
|
27458
27702
|
} catch {
|
|
27459
27703
|
}
|
|
27704
|
+
this.setIntegrationMetadata(phase, "not_merged_failed_phase", {
|
|
27705
|
+
branch: handle.branch,
|
|
27706
|
+
worktreeDir: handle.dir
|
|
27707
|
+
});
|
|
27460
27708
|
await this.worktrees.release(handle, { keep: true }).catch(() => {
|
|
27461
27709
|
});
|
|
27462
27710
|
}
|
|
@@ -27716,8 +27964,13 @@ var PhaseOrchestrator = class {
|
|
|
27716
27964
|
}
|
|
27717
27965
|
};
|
|
27718
27966
|
}
|
|
27967
|
+
async waitWhilePaused() {
|
|
27968
|
+
while (this.paused && !this.stopped) {
|
|
27969
|
+
await this.delay(100);
|
|
27970
|
+
}
|
|
27971
|
+
}
|
|
27719
27972
|
delay(ms) {
|
|
27720
|
-
return new Promise((
|
|
27973
|
+
return new Promise((resolve11) => setTimeout(resolve11, ms));
|
|
27721
27974
|
}
|
|
27722
27975
|
};
|
|
27723
27976
|
|
|
@@ -27761,6 +28014,10 @@ var AutoPhaseRunner = class {
|
|
|
27761
28014
|
this.graph = await builder.build();
|
|
27762
28015
|
const ctx = {
|
|
27763
28016
|
executeTask: this.opts.executeTask,
|
|
28017
|
+
verifyPhase: this.opts.verifyPhase,
|
|
28018
|
+
repairPhase: this.opts.repairPhase,
|
|
28019
|
+
resolveConflict: this.opts.resolveConflict,
|
|
28020
|
+
brain: this.opts.brain,
|
|
27764
28021
|
onPhaseComplete: (phase) => {
|
|
27765
28022
|
this.opts.onPhaseComplete?.(phase);
|
|
27766
28023
|
},
|
|
@@ -27777,10 +28034,12 @@ var AutoPhaseRunner = class {
|
|
|
27777
28034
|
maxConcurrentPhases: this.opts.maxConcurrentPhases,
|
|
27778
28035
|
maxConcurrentTasks: this.opts.maxConcurrentTasks,
|
|
27779
28036
|
maxRetries: this.opts.maxRetries,
|
|
28037
|
+
maxVerifyAttempts: this.opts.maxVerifyAttempts,
|
|
27780
28038
|
autonomous: this.opts.autonomous,
|
|
27781
28039
|
phaseDelayMs: this.opts.phaseDelayMs,
|
|
27782
28040
|
stopOnFailure: this.opts.stopOnFailure,
|
|
27783
|
-
events: this.opts.events
|
|
28041
|
+
events: this.opts.events,
|
|
28042
|
+
worktrees: this.opts.worktrees
|
|
27784
28043
|
});
|
|
27785
28044
|
if (this.opts.onProgress) {
|
|
27786
28045
|
this.progressInterval = setInterval(() => {
|
|
@@ -28699,6 +28958,147 @@ function assertSafePath(dir, projectRoot) {
|
|
|
28699
28958
|
}
|
|
28700
28959
|
}
|
|
28701
28960
|
|
|
28961
|
+
// src/coordination/brain.ts
|
|
28962
|
+
var ObservableBrainArbiter = class {
|
|
28963
|
+
constructor(inner, events) {
|
|
28964
|
+
this.inner = inner;
|
|
28965
|
+
this.events = events;
|
|
28966
|
+
}
|
|
28967
|
+
inner;
|
|
28968
|
+
events;
|
|
28969
|
+
async decide(request) {
|
|
28970
|
+
this.events.emit("brain.decision_requested", { request, at: Date.now() });
|
|
28971
|
+
const decision = await this.inner.decide(request);
|
|
28972
|
+
const event = decision.type === "ask_human" ? "brain.decision_ask_human" : decision.type === "deny" ? "brain.decision_denied" : "brain.decision_answered";
|
|
28973
|
+
this.events.emit(event, { request, decision, at: Date.now() });
|
|
28974
|
+
return decision;
|
|
28975
|
+
}
|
|
28976
|
+
};
|
|
28977
|
+
var BrainDecisionQueue = class {
|
|
28978
|
+
constructor(events, opts = {}) {
|
|
28979
|
+
this.events = events;
|
|
28980
|
+
this.opts = opts;
|
|
28981
|
+
this.offAnswer = this.events.on("brain.human_answered", (answer) => {
|
|
28982
|
+
const pending = this.pending.get(answer.id);
|
|
28983
|
+
if (!pending) return;
|
|
28984
|
+
this.pending.delete(answer.id);
|
|
28985
|
+
if (pending.timer) clearTimeout(pending.timer);
|
|
28986
|
+
if (answer.deny) {
|
|
28987
|
+
pending.resolve({ type: "deny", reason: answer.text ?? "Denied by human." });
|
|
28988
|
+
return;
|
|
28989
|
+
}
|
|
28990
|
+
const option = pending.request.options?.find((o) => o.id === answer.optionId);
|
|
28991
|
+
pending.resolve({
|
|
28992
|
+
type: "answer",
|
|
28993
|
+
optionId: answer.optionId,
|
|
28994
|
+
text: answer.text ?? option?.label ?? answer.optionId ?? "Human answered.",
|
|
28995
|
+
rationale: "Human answered a Brain escalation prompt."
|
|
28996
|
+
});
|
|
28997
|
+
});
|
|
28998
|
+
}
|
|
28999
|
+
events;
|
|
29000
|
+
opts;
|
|
29001
|
+
pending = /* @__PURE__ */ new Map();
|
|
29002
|
+
offAnswer;
|
|
29003
|
+
async requestHumanDecision(request) {
|
|
29004
|
+
const ask = {
|
|
29005
|
+
type: "ask_human",
|
|
29006
|
+
prompt: formatHumanPrompt(request),
|
|
29007
|
+
options: request.options,
|
|
29008
|
+
rationale: "Decision escalated to human authority."
|
|
29009
|
+
};
|
|
29010
|
+
const pending = new Promise((resolve11) => {
|
|
29011
|
+
const entry = { request, resolve: resolve11 };
|
|
29012
|
+
if (this.opts.timeoutMs && this.opts.timeoutMs > 0) {
|
|
29013
|
+
entry.timer = setTimeout(() => {
|
|
29014
|
+
this.pending.delete(request.id);
|
|
29015
|
+
resolve11({ type: "deny", reason: "Brain human decision timed out." });
|
|
29016
|
+
}, this.opts.timeoutMs);
|
|
29017
|
+
}
|
|
29018
|
+
this.pending.set(request.id, entry);
|
|
29019
|
+
});
|
|
29020
|
+
this.events.emit("brain.decision_ask_human", { request, decision: ask, at: Date.now() });
|
|
29021
|
+
return pending;
|
|
29022
|
+
}
|
|
29023
|
+
dispose() {
|
|
29024
|
+
this.offAnswer();
|
|
29025
|
+
for (const [id, pending] of this.pending) {
|
|
29026
|
+
if (pending.timer) clearTimeout(pending.timer);
|
|
29027
|
+
pending.resolve({ type: "deny", reason: "Brain decision queue disposed." });
|
|
29028
|
+
this.pending.delete(id);
|
|
29029
|
+
}
|
|
29030
|
+
}
|
|
29031
|
+
};
|
|
29032
|
+
var HumanEscalatingBrainArbiter = class {
|
|
29033
|
+
constructor(inner, queue) {
|
|
29034
|
+
this.inner = inner;
|
|
29035
|
+
this.queue = queue;
|
|
29036
|
+
}
|
|
29037
|
+
inner;
|
|
29038
|
+
queue;
|
|
29039
|
+
async decide(request) {
|
|
29040
|
+
const decision = await this.inner.decide(request);
|
|
29041
|
+
if (decision.type !== "ask_human") return decision;
|
|
29042
|
+
return this.queue.requestHumanDecision(request);
|
|
29043
|
+
}
|
|
29044
|
+
};
|
|
29045
|
+
var DefaultBrainArbiter = class {
|
|
29046
|
+
allowLowRiskAutoAnswer;
|
|
29047
|
+
constructor(opts = {}) {
|
|
29048
|
+
this.allowLowRiskAutoAnswer = opts.allowLowRiskAutoAnswer ?? true;
|
|
29049
|
+
}
|
|
29050
|
+
async decide(request) {
|
|
29051
|
+
const recommended = request.options?.find((option) => option.recommended);
|
|
29052
|
+
if (this.allowLowRiskAutoAnswer && request.risk === "low" && recommended) {
|
|
29053
|
+
return {
|
|
29054
|
+
type: "answer",
|
|
29055
|
+
optionId: recommended.id,
|
|
29056
|
+
text: recommended.label,
|
|
29057
|
+
rationale: "Low-risk request with an explicit recommended option."
|
|
29058
|
+
};
|
|
29059
|
+
}
|
|
29060
|
+
switch (request.fallback) {
|
|
29061
|
+
case "deny":
|
|
29062
|
+
return {
|
|
29063
|
+
type: "deny",
|
|
29064
|
+
reason: `Brain could not safely decide: ${request.question}`
|
|
29065
|
+
};
|
|
29066
|
+
case "continue":
|
|
29067
|
+
return {
|
|
29068
|
+
type: "answer",
|
|
29069
|
+
text: "Continue with the caller default.",
|
|
29070
|
+
rationale: "No safe Brain decision was available; request fallback is continue."
|
|
29071
|
+
};
|
|
29072
|
+
case "ask_human":
|
|
29073
|
+
return {
|
|
29074
|
+
type: "ask_human",
|
|
29075
|
+
prompt: formatHumanPrompt(request),
|
|
29076
|
+
options: request.options,
|
|
29077
|
+
rationale: "Decision requires human authority or lacks a safe automatic option."
|
|
29078
|
+
};
|
|
29079
|
+
}
|
|
29080
|
+
}
|
|
29081
|
+
};
|
|
29082
|
+
function formatHumanPrompt(request) {
|
|
29083
|
+
const lines = [
|
|
29084
|
+
`Brain requires human decision for ${request.source}:`,
|
|
29085
|
+
`Question: ${request.question}`
|
|
29086
|
+
];
|
|
29087
|
+
if (request.context?.trim()) {
|
|
29088
|
+
lines.push("", "Context:", request.context.trim());
|
|
29089
|
+
}
|
|
29090
|
+
if (request.options?.length) {
|
|
29091
|
+
lines.push("", "Options:");
|
|
29092
|
+
for (const option of request.options) {
|
|
29093
|
+
const risk = option.risk ? ` [risk: ${option.risk}]` : "";
|
|
29094
|
+
const consequence = option.consequence ? ` \u2014 ${option.consequence}` : "";
|
|
29095
|
+
lines.push(`- ${option.id}: ${option.label}${risk}${consequence}`);
|
|
29096
|
+
}
|
|
29097
|
+
}
|
|
29098
|
+
lines.push("", `Risk: ${request.risk}`);
|
|
29099
|
+
return lines.join("\n");
|
|
29100
|
+
}
|
|
29101
|
+
|
|
28702
29102
|
// src/coordination/collab-bus.ts
|
|
28703
29103
|
var CollaborationBus = class {
|
|
28704
29104
|
pausePromise = null;
|
|
@@ -28727,8 +29127,8 @@ var CollaborationBus = class {
|
|
|
28727
29127
|
if (this.isPaused()) return false;
|
|
28728
29128
|
this.pausedAtMs = Date.now();
|
|
28729
29129
|
this.pausedBy = byParticipant;
|
|
28730
|
-
this.pausePromise = new Promise((
|
|
28731
|
-
this.pauseResolve =
|
|
29130
|
+
this.pausePromise = new Promise((resolve11) => {
|
|
29131
|
+
this.pauseResolve = resolve11;
|
|
28732
29132
|
});
|
|
28733
29133
|
return true;
|
|
28734
29134
|
}
|
|
@@ -28764,8 +29164,8 @@ var CollaborationBus = class {
|
|
|
28764
29164
|
return true;
|
|
28765
29165
|
}
|
|
28766
29166
|
let timer;
|
|
28767
|
-
const timeoutPromise = new Promise((
|
|
28768
|
-
timer = setTimeout(() =>
|
|
29167
|
+
const timeoutPromise = new Promise((resolve11) => {
|
|
29168
|
+
timer = setTimeout(() => resolve11("timeout"), timeoutMs);
|
|
28769
29169
|
});
|
|
28770
29170
|
const resumedPromise = this.pausePromise.then(() => "resumed");
|
|
28771
29171
|
const winner = await Promise.race([resumedPromise, timeoutPromise]);
|
|
@@ -29256,7 +29656,7 @@ function createGitPlugin() {
|
|
|
29256
29656
|
}
|
|
29257
29657
|
async function runGit(args, cwd) {
|
|
29258
29658
|
try {
|
|
29259
|
-
return await new Promise((
|
|
29659
|
+
return await new Promise((resolve11, reject) => {
|
|
29260
29660
|
const child = spawn("git", args, { cwd, stdio: ["ignore", "pipe", "pipe"] });
|
|
29261
29661
|
let stdout = "";
|
|
29262
29662
|
let stderr = "";
|
|
@@ -29277,7 +29677,7 @@ async function runGit(args, cwd) {
|
|
|
29277
29677
|
})
|
|
29278
29678
|
);
|
|
29279
29679
|
});
|
|
29280
|
-
child.on("close", (code) =>
|
|
29680
|
+
child.on("close", (code) => resolve11({ stdout, stderr, code: code ?? 0 }));
|
|
29281
29681
|
});
|
|
29282
29682
|
} catch (err) {
|
|
29283
29683
|
if (err instanceof WrongStackError) throw err;
|
|
@@ -29602,7 +30002,7 @@ function createSkillsPlugin(opts) {
|
|
|
29602
30002
|
};
|
|
29603
30003
|
}
|
|
29604
30004
|
function makeInstaller(skillLoader, projectRoot) {
|
|
29605
|
-
const globalRoot = path6.join(
|
|
30005
|
+
const globalRoot = path6.join(os6.homedir(), ".wrongstack");
|
|
29606
30006
|
return new SkillInstaller({
|
|
29607
30007
|
manifestPath: path6.join(globalRoot, "installed-skills.json"),
|
|
29608
30008
|
projectSkillsDir: path6.join(projectRoot, ".wrongstack", "skills"),
|
|
@@ -29953,6 +30353,6 @@ ${formatPlan(updated)}`
|
|
|
29953
30353
|
};
|
|
29954
30354
|
}
|
|
29955
30355
|
|
|
29956
|
-
export { ACP_AGENTS, AGENTS_BY_PHASE, AGENT_CATALOG, AISpecBuilder, ALL_AGENT_DEFINITIONS, ALL_FLEET_AGENTS, ALL_SYNC_CATEGORIES, AUDIT_LOG_AGENT, Agent, AgentError, AnnotationsStore, AutoApprovePermissionPolicy, AutoCompactionMiddleware, AutoExecutor, AutoPhasePlanner, AutoPhaseRunner, AutonomousRunner, BUG_HUNTER_AGENT, BudgetExceededError, CONTEXT_WINDOW_MODES, CORE_RECONSTRUCT_EVENTS, CheckpointManager, CloudSync, CollaborationBus, ConfigError, ConfigMigrationError, Container, Context, ConversationState, DEFAULT_AUTONOMY_CONFIG, DEFAULT_CONFIG_MIGRATIONS, DEFAULT_CONTEXT_CONFIG, DEFAULT_CONTEXT_WINDOW_MODE_ID, DEFAULT_DIRECTOR_PREAMBLE, DEFAULT_DISPATCH_ROLE, DEFAULT_MAX_ITERATIONS, DEFAULT_MODES, DEFAULT_RECOVERY_STRATEGIES, DEFAULT_SESSION_LOGGING_CONFIG, DEFAULT_SPEC_TEMPLATE, DEFAULT_SUBAGENT_BASELINE, DEFAULT_TOOLS_CONFIG, DefaultAttachmentStore, DefaultConfigLoader, DefaultConfigStore, DefaultErrorHandler, DefaultHealthRegistry, DefaultLogger, DefaultMemoryStore, DefaultModeStore, DefaultModelsRegistry, DefaultMultiAgentCoordinator, DefaultPathResolver, DefaultPermissionPolicy, DefaultPluginAPI, DefaultPromptStore, DefaultProviderRunner, DefaultRetryPolicy, DefaultSecretScrubber, DefaultSecretVault, DefaultSessionReader, DefaultSessionRewinder, DefaultSessionStore, DefaultSkillLoader, DefaultSystemPromptBuilder, DefaultTaskStore, DefaultTokenCounter, Director, DirectorStateCheckpoint, DoneConditionChecker, ERROR_CODES, EternalAutonomyEngine, EventBus, ExtensionRegistry, FLEET_ROSTER, FLEET_ROSTER_BUDGETS, FLEET_ROSTER_WITHACP, FleetBus, FleetCostCapError, FleetManager, FleetSpawnBudgetError, FleetUsageAggregator, FsError, GitignoreUpdater, HybridCompactor, InMemoryAgentBridge, InMemoryBridgeTransport, InMemoryMetricsSink, InputBuilder, IntelligentCompactor, KERNEL_API_VERSION, LAYER_1_IDENTITY, LLMSelector, MATRIX_PHASE_KEYS, MAX_JOURNAL_ENTRIES, NULL_FLEET_BUS, NoopMetricsSink, NoopTracer, OTelTracer, PROMETHEUS_CONTENT_TYPE, ParallelEternalEngine, PhaseGraphBuilder, PhaseOrchestrator, PhaseStore, Pipeline, PluginError, ProviderError, ProviderRegistry, QueueStore, REFACTOR_PLANNER_AGENT, RecoveryLock, ReplayLogStore, ReplayProviderRunner, ReportGenerator, RunController, SECURITY_SCANNER_AGENT, SPEC_TEMPLATES, STANDARD_AUDIT_EVENTS, ScopedEventBus, SddParallelRun, SddTaskDecomposer, SecurityScanner, SecurityScannerOrchestrator, SelectiveCompactor, SessionAnalyzer, SessionError, SessionRecovery, SkillGenerator, SkillInstaller, SkillManifestStore, SlashCommandRegistry, SpecDrivenDev, SpecParser, SpecStore, SpecVersioning, SubagentBudget, TOKENS, TaskFlow, TaskGenerator, TaskGraphStore, TaskTracker, TechStackDetector, ToolAuditLog, ToolError, ToolExecutor, ToolRegistry, WorktreeManager, WrongStackError, addPlanItem, allServers, analyzeCriticalPath, appendJournal, applyRosterBudget, asBlocks, asText, assertSafePath, atomicWrite, attachAutoExtend, attachPlanCheckpoint, attachTodosCheckpoint, awsServer, blockServer, braveSearchServer, buildBtwBlock, buildChildEnv, buildGoalPreamble, buildOtlpMetricsRequest, buildOtlpTracesRequest, buildRecoveryStrategies, classifyFamily, clearPlan, collabInjectMiddleware, collabPauseMiddleware, color, compileGlob, compileUserRegex, completePartialObject, composeDirectorPrompt, composeSubagentPrompt, computeTaskProgress, consumeBtwNotes, context7Server, contextManagerTool, createAutoExecutor, createAutoPhaseFromTaskGraph, createContextManagerTool, createDefaultPipelines, createDelegateTool, createGitPlugin, createMcpControlTool, createMessage, createObservabilityPlugin, createPlanPlugin, createPromptsPlugin, createSecurityPlugin, createSecuritySlashCommand, createSessionEventBridge, createSkillsPlugin, createSyncPlugin, createToolOutputSerializer, decryptConfigSecrets, defaultGitignoreUpdater, defaultOrchestrator, defaultReportGenerator, defaultSecurityScanner, defaultSkillGenerator, defaultTechStackDetector, deriveTodosFromPlanItem, detectNewlineStyle, dispatchAgent, downloadGitHubTarball, emptyGoal, emptyPlan, encryptConfigSecrets, ensureDir, estimateRequestTokens, estimateRequestTokensCalibrated, estimateTextTokens, estimateToolDefTokens, estimateToolInputTokens, estimateToolResultTokens, everArtServer, expandGlob, extractRunEnv, filesystemServer, findCriticalPath, formatContextWindowModeList, formatGoal, formatPlan, formatPlanTemplates, formatTodosList, getAgentDefinition, getCalibrationState, getContextWindowMode, getPlanTemplate, getTemplate, getTermSize, githubServer, goalFilePath, googleMapsServer, hashRequest, isAgentError, isConfigError, isContextWindowModeId, isFsError, isImageBlock, isInteractive, isPluginError, isSessionError, isStdinTTY, isStdoutTTY, isTextBlock, isThinkingBlock, isToolError, isToolResultBlock, isToolUseBlock, isValidMatrixKey, isWrongStackError, listContextWindowModes, listPlanTemplates, listTemplates, loadDirectorState, loadGoal, loadPlan, loadPlugins, loadProjectModes, loadTodosCheckpoint, loadUserModes, makeAgentSubagentRunner, makeAskTool, makeAssignTool, makeAutonomyPromptContributor, makeAwaitTasksTool, makeCollabDebugTool, makeContinueToNextIterationTool, makeDirectorSessionFactory, makeFleetEmitTool, makeFleetHealthTool, makeFleetSessionTool, makeFleetStatusTool, makeFleetUsageTool, makeLLMClassifier, makeRollUpTool, makeSpawnTool, makeTerminateTool, matchAny, matchGlob, matrixKeyKind, mergeModelsPayload, migratePlaintextSecrets, miniMaxVisionServer, normalizeToLf, onResize, parseContinueDirective, parseSkillRef, pendingBtwCount, phaseForRole, projectHash, recordActualUsage, removePlanItem, renderProgress, renderPrometheus, renderSpecAnalysis, renderTaskGraph, renderTaskList, repairToolUseAdjacency, resetCalibration, resolveAuditLevel, resolveContextWindowPolicy, resolveModelMatrix, resolveSessionLoggingConfig, resolveWstackPaths, rewriteConfigEncrypted, rosterSummaryFromConfigs, runConfigMigrations, runProviderWithRetry, safeParse, safeStringify, sanitizeJsonString, saveGoal, savePlan, saveTodosCheckpoint, scoreAgents, securitySlashCommand, sentinelServer, setBtwNote, setPlanItemStatus, setRawMode, slackServer, stableStringify, startMetricsServer, startOtlpMetricsExporter, startOtlpTraceExporter, stripAnsi, summarizeUsage, templateToMarkdown, toStyle, toWrongStackError, topologicalSort, unifiedDiff, unloadPlugins, validateAgainstSchema, wireMetricsToEvents, wrapAsState, writeErr, writeOut, zaiVisionServer };
|
|
30356
|
+
export { ACP_AGENTS, AGENTS_BY_PHASE, AGENT_CATALOG, AISpecBuilder, ALL_AGENT_DEFINITIONS, ALL_FLEET_AGENTS, ALL_SYNC_CATEGORIES, AUDIT_LOG_AGENT, Agent, AgentError, AnnotationsStore, AutoApprovePermissionPolicy, AutoCompactionMiddleware, AutoExecutor, AutoPhasePlanner, AutoPhaseRunner, AutonomousRunner, BUG_HUNTER_AGENT, BrainDecisionQueue, BudgetExceededError, CONTEXT_WINDOW_MODES, CORE_RECONSTRUCT_EVENTS, CheckpointManager, CloudSync, CollaborationBus, ConfigError, ConfigMigrationError, Container, Context, ConversationState, DEFAULT_AUTONOMY_CONFIG, DEFAULT_CONFIG_MIGRATIONS, DEFAULT_CONTEXT_CONFIG, DEFAULT_CONTEXT_WINDOW_MODE_ID, DEFAULT_DIRECTOR_PREAMBLE, DEFAULT_DISPATCH_ROLE, DEFAULT_MAX_ITERATIONS, DEFAULT_MODES, DEFAULT_RECOVERY_STRATEGIES, DEFAULT_SESSION_LOGGING_CONFIG, DEFAULT_SPEC_TEMPLATE, DEFAULT_SUBAGENT_BASELINE, DEFAULT_TOOLS_CONFIG, DefaultAttachmentStore, DefaultBrainArbiter, DefaultConfigLoader, DefaultConfigStore, DefaultErrorHandler, DefaultHealthRegistry, DefaultLogger, DefaultMemoryStore, DefaultModeStore, DefaultModelsRegistry, DefaultMultiAgentCoordinator, DefaultPathResolver, DefaultPermissionPolicy, DefaultPluginAPI, DefaultPromptStore, DefaultProviderRunner, DefaultRetryPolicy, DefaultSecretScrubber, DefaultSecretVault, DefaultSessionReader, DefaultSessionRewinder, DefaultSessionStore, DefaultSkillLoader, DefaultSystemPromptBuilder, DefaultTaskStore, DefaultTokenCounter, Director, DirectorStateCheckpoint, DoneConditionChecker, ERROR_CODES, EternalAutonomyEngine, EventBus, ExtensionRegistry, FLEET_ROSTER, FLEET_ROSTER_BUDGETS, FLEET_ROSTER_WITHACP, FleetBus, FleetCostCapError, FleetManager, FleetSpawnBudgetError, FleetUsageAggregator, FsError, GitignoreUpdater, HumanEscalatingBrainArbiter, HybridCompactor, InMemoryAgentBridge, InMemoryBridgeTransport, InMemoryMetricsSink, InputBuilder, IntelligentCompactor, KERNEL_API_VERSION, LAYER_1_IDENTITY, LLMSelector, MATRIX_PHASE_KEYS, MAX_JOURNAL_ENTRIES, NULL_FLEET_BUS, NoopMetricsSink, NoopTracer, OTelTracer, ObservableBrainArbiter, PROMETHEUS_CONTENT_TYPE, ParallelEternalEngine, PhaseGraphBuilder, PhaseOrchestrator, PhaseStore, Pipeline, PluginError, ProviderError, ProviderRegistry, QueueStore, REFACTOR_PLANNER_AGENT, RecoveryLock, ReplayLogStore, ReplayProviderRunner, ReportGenerator, RunController, SECURITY_SCANNER_AGENT, SPEC_TEMPLATES, STANDARD_AUDIT_EVENTS, ScopedEventBus, SddParallelRun, SddTaskDecomposer, SecurityScanner, SecurityScannerOrchestrator, SelectiveCompactor, SessionAnalyzer, SessionError, SessionRecovery, SkillGenerator, SkillInstaller, SkillManifestStore, SlashCommandRegistry, SpecDrivenDev, SpecParser, SpecStore, SpecVersioning, SubagentBudget, TOKENS, TaskFlow, TaskGenerator, TaskGraphStore, TaskTracker, TechStackDetector, ToolAuditLog, ToolError, ToolExecutor, ToolRegistry, WorktreeManager, WrongStackError, addPlanItem, allServers, analyzeCriticalPath, appendJournal, applyRosterBudget, asBlocks, asText, assertSafePath, atomicWrite, attachAutoExtend, attachPlanCheckpoint, attachTodosCheckpoint, awsServer, blockServer, bootConfig, braveSearchServer, buildBtwBlock, buildChildEnv, buildGoalPreamble, buildOtlpMetricsRequest, buildOtlpTracesRequest, buildRecoveryStrategies, classifyFamily, clearPlan, collabInjectMiddleware, collabPauseMiddleware, color, compileGlob, compileUserRegex, completePartialObject, composeDirectorPrompt, composeSubagentPrompt, computeTaskProgress, consumeBtwNotes, context7Server, contextManagerTool, createAutoExecutor, createAutoPhaseFromTaskGraph, createContextManagerTool, createDefaultPipelines, createDelegateTool, createGitPlugin, createMcpControlTool, createMessage, createObservabilityPlugin, createPlanPlugin, createPromptsPlugin, createSecurityPlugin, createSecuritySlashCommand, createSessionEventBridge, createSkillsPlugin, createSyncPlugin, createToolOutputSerializer, decryptConfigSecrets, defaultGitignoreUpdater, defaultOrchestrator, defaultReportGenerator, defaultSecurityScanner, defaultSkillGenerator, defaultTechStackDetector, deriveTodosFromPlanItem, detectNewlineStyle, dispatchAgent, downloadGitHubTarball, emptyGoal, emptyPlan, encryptConfigSecrets, ensureDir, estimateRequestTokens, estimateRequestTokensCalibrated, estimateTextTokens, estimateToolDefTokens, estimateToolInputTokens, estimateToolResultTokens, everArtServer, expandGlob, extractRunEnv, filesystemServer, findCriticalPath, flagsToConfigPatch, formatContextWindowModeList, formatGoal, formatHumanPrompt, formatPlan, formatPlanTemplates, formatTodosList, getAgentDefinition, getCalibrationState, getContextWindowMode, getPlanTemplate, getTemplate, getTermSize, githubServer, goalFilePath, googleMapsServer, hashRequest, isAgentError, isConfigError, isContextWindowModeId, isFsError, isImageBlock, isInteractive, isPluginError, isSessionError, isStdinTTY, isStdoutTTY, isTextBlock, isThinkingBlock, isToolError, isToolResultBlock, isToolUseBlock, isValidMatrixKey, isWrongStackError, listContextWindowModes, listPlanTemplates, listTemplates, loadDirectorState, loadGoal, loadPlan, loadPlugins, loadProjectModes, loadTodosCheckpoint, loadUserModes, makeAgentSubagentRunner, makeAskTool, makeAssignTool, makeAutonomyPromptContributor, makeAwaitTasksTool, makeCollabDebugTool, makeContinueToNextIterationTool, makeDirectorSessionFactory, makeFleetEmitTool, makeFleetHealthTool, makeFleetSessionTool, makeFleetStatusTool, makeFleetUsageTool, makeLLMClassifier, makeRollUpTool, makeSpawnTool, makeTerminateTool, matchAny, matchGlob, matrixKeyKind, mergeModelsPayload, migratePlaintextSecrets, miniMaxVisionServer, normalizeToLf, onResize, parseContinueDirective, parseSkillRef, pendingBtwCount, phaseForRole, projectHash, recordActualUsage, removePlanItem, renderProgress, renderPrometheus, renderSpecAnalysis, renderTaskGraph, renderTaskList, repairToolUseAdjacency, resetCalibration, resolveAuditLevel, resolveContextWindowPolicy, resolveModelMatrix, resolveSessionLoggingConfig, resolveWstackPaths, rewriteConfigEncrypted, rosterSummaryFromConfigs, runConfigMigrations, runProviderWithRetry, safeParse, safeStringify, sanitizeJsonString, saveGoal, savePlan, saveTodosCheckpoint, scoreAgents, securitySlashCommand, sentinelServer, setBtwNote, setPlanItemStatus, setRawMode, slackServer, stableStringify, startMetricsServer, startOtlpMetricsExporter, startOtlpTraceExporter, stripAnsi, summarizeUsage, templateToMarkdown, toStyle, toWrongStackError, topologicalSort, unifiedDiff, unloadPlugins, validateAgainstSchema, wireMetricsToEvents, wrapAsState, writeErr, writeOut, zaiVisionServer };
|
|
29957
30357
|
//# sourceMappingURL=index.js.map
|
|
29958
30358
|
//# sourceMappingURL=index.js.map
|