@buildaharness/aielia 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -7
- package/dist/agent-loop.d.ts +8 -8
- package/dist/ask-clarification-service.d.ts +1 -1
- package/dist/ask-mode-flag.d.ts +1 -1
- package/dist/assistant-session.d.ts +1 -1
- package/dist/assistant-types.d.ts +3 -3
- package/dist/assistant.d.ts +12 -12
- package/dist/batch-research-fixtures.d.ts +1 -1
- package/dist/benchmark-injected-failure.d.ts +1 -1
- package/dist/bin-CqkqT6KK.js +2107 -0
- package/dist/bin-CqkqT6KK.js.map +1 -0
- package/dist/bin-sea-bootstrap.d.ts +1 -0
- package/dist/bin.d.ts +1 -0
- package/dist/claude-cli-llm-client.d.ts +2 -2
- package/dist/cli-args.d.ts +20 -0
- package/dist/cli-icons.d.ts +28 -0
- package/dist/{cli-session-D0uLdT2A.js → cli-session-BiX2DOni.js} +550 -121
- package/dist/cli-session-BiX2DOni.js.map +1 -0
- package/dist/cli.d.ts +31 -1
- package/dist/cli.js +1 -1691
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +14 -6
- package/dist/contradiction-checker.d.ts +1 -1
- package/dist/diff-format.d.ts +16 -0
- package/dist/execution-mode.d.ts +1 -1
- package/dist/fact-extraction.d.ts +4 -4
- package/dist/failure-mode-matcher.d.ts +1 -1
- package/dist/file-tools-mcp-server.mjs +2 -2
- package/dist/file-tools.d.ts +10 -2
- package/dist/harness-bridge.d.ts +4 -4
- package/dist/index.js +68 -68
- package/dist/index.js.map +1 -1
- package/dist/ink-select-prompt.d.ts +21 -0
- package/dist/markdown-line.d.ts +42 -0
- package/dist/mcp-server-asset.d.ts +24 -0
- package/dist/memory-service.d.ts +2 -2
- package/dist/network-containment.d.ts +1 -1
- package/dist/node-display-names.d.ts +1 -1
- package/dist/one-loop-flag.d.ts +1 -1
- package/dist/plan-drafting-service.d.ts +1 -1
- package/dist/plan-drafting.d.ts +4 -4
- package/dist/plan-mode-flag.d.ts +1 -1
- package/dist/plan-sketch-service.d.ts +1 -1
- package/dist/plan-sketch.d.ts +1 -1
- package/dist/plan-store.d.ts +2 -2
- package/dist/plan-templates/index.d.ts +1 -1
- package/dist/plan-verification.d.ts +1 -1
- package/dist/scripted-llm-client.d.ts +1 -1
- package/dist/sea-cache.d.ts +9 -0
- package/dist/self-update.d.ts +101 -0
- package/dist/shell-tools.d.ts +1 -1
- package/dist/spike.js.map +1 -1
- package/dist/tool-control-plane.d.ts +1 -1
- package/dist/tool-policy.d.ts +1 -1
- package/dist/tool-step.d.ts +10 -0
- package/dist/trace-events.d.ts +5 -5
- package/dist/trust-tagging.d.ts +1 -1
- package/dist/{tui-app-DxLPSGh2.js → tui-app-4_TrzESz.js} +176 -20
- package/dist/tui-app-4_TrzESz.js.map +1 -0
- package/dist/tui-app.d.ts +34 -9
- package/dist/tui-mode-flag.d.ts +1 -1
- package/dist/turn-intent-classifier.d.ts +5 -5
- package/dist/turn-policy.d.ts +1 -1
- package/dist/update-check-flag.d.ts +11 -0
- package/dist/version.d.ts +6 -0
- package/package.json +7 -3
- package/dist/cli-session-D0uLdT2A.js.map +0 -1
- package/dist/tui-app-DxLPSGh2.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { loadHarnessCheckpoint, deleteHarnessCheckpoint, ControlState, FailureDiagnostics, Diagnostics, WorldModel, EvidenceStore, gatherEvidence, applyToolReliability, updateWorldModel, normalise, DimensionType, resolveControlState, containsCJK, Budget, validateInvestigationTools, tokenize, validateAskQuestion, validateAskResponse, makeQuestionsBatch, HarnessRuntime, saveHarnessCheckpoint, supervisorEnabled, EscalationHalt, riskSummary, InMemoryExperienceStore, resolveAskMode as resolveAskMode$1 } from "@buildaharness/harness";
|
|
4
|
+
import { loadHarnessCheckpoint, deleteHarnessCheckpoint, ControlState, FailureDiagnostics, Diagnostics, WorldModel, EvidenceStore, gatherEvidence, applyToolReliability, updateWorldModel, normalise, DimensionType, resolveControlState, containsCJK, Budget, validateInvestigationTools, tokenize as tokenize$1, validateAskQuestion, validateAskResponse, makeQuestionsBatch, HarnessRuntime, saveHarnessCheckpoint, supervisorEnabled, EscalationHalt, riskSummary, InMemoryExperienceStore, resolveAskMode as resolveAskMode$1 } from "@buildaharness/harness";
|
|
5
5
|
import { ANTHROPIC_DEFAULT_MODEL, InMemoryAdapter, InMemoryReminderStore, IndexedDBAdapter, DexieExperienceStore } from "@buildaharness/runtime";
|
|
6
6
|
const en$9 = {
|
|
7
7
|
factMarkers: "\\b(my(?:\\s+\\w+(?:'s)?){0,3}\\s+name is|i(?:\\s+\\w+){0,4}\\s+live(?:\\s+\\w+){0,2}\\s+in|i(?:\\s+\\w+){0,4}\\s+work(?:\\s+\\w+){0,4}\\s+(at|as|for)|i am(?:\\s+(?!\\w*ing\\b)\\w+){0,4}\\s+an?\\b|i'm(?:\\s+(?!\\w*ing\\b)\\w+){0,4}\\s+an?\\b|i prefer|remember that|note that|for future reference|call me|i go by|i have (?:a|an|\\d+)(?:\\s+\\w+){0,4}\\s+named)\\b",
|
|
@@ -625,7 +625,7 @@ function compileRiskPatternsAcrossLanguages(data) {
|
|
|
625
625
|
mediumRiskPatterns: languages.flatMap((lang) => lang.mediumRiskPatterns.map(compileRiskPattern)),
|
|
626
626
|
// Reason text stays whichever language declared it first (today: "en") — the assistant's own
|
|
627
627
|
// output isn't translated by this change, only its ability to understand non-English input;
|
|
628
|
-
// see
|
|
628
|
+
// see the internal plan's Phase 4 for that separate,
|
|
629
629
|
// later concern.
|
|
630
630
|
reminderPattern: { pattern: new RegExp(languages.map((lang) => lang.reminderPattern.source).join("|"), "i"), reason: first.reminderPattern.reason },
|
|
631
631
|
reminderRecallQuestion: languages.map((lang) => new RegExp(lang.reminderRecallQuestion, "i")),
|
|
@@ -877,7 +877,7 @@ function migrateFact(fact) {
|
|
|
877
877
|
const TIER_RULES = {
|
|
878
878
|
episodic: { allowedSources: ["user_asserted", "model_inferred", "observed", "externally_verified"], retention: "session", contradictionChecked: false },
|
|
879
879
|
// model_inferred added to semantic/identity/preference in Phase 4 of
|
|
880
|
-
//
|
|
880
|
+
// the internal plan: tierForFact() now routes a
|
|
881
881
|
// model_inferred fact here too, but only once it's durable AND high-confidence — see that
|
|
882
882
|
// function's doc comment.
|
|
883
883
|
semantic: { allowedSources: ["user_asserted", "model_inferred", "externally_verified"], retention: "durable", contradictionChecked: true },
|
|
@@ -1570,6 +1570,11 @@ async function resolveAndVerify(ctx, requestedPath) {
|
|
|
1570
1570
|
await assertRealPathInWorkspace(ctx.backend, ctx.workspaceRoot, resolved);
|
|
1571
1571
|
return resolved;
|
|
1572
1572
|
}
|
|
1573
|
+
async function readCurrentFileContent(backend, workspaceRoot, requestedPath) {
|
|
1574
|
+
const resolved = resolveInWorkspace(workspaceRoot, requestedPath);
|
|
1575
|
+
await assertRealPathInWorkspace(backend, workspaceRoot, resolved);
|
|
1576
|
+
return backend.readTextFile(resolved);
|
|
1577
|
+
}
|
|
1573
1578
|
const READ_FILE_TOOL = {
|
|
1574
1579
|
name: "read_file",
|
|
1575
1580
|
description: "Read a text file inside the sandboxed workspace directory. `path` is relative to the workspace root (or an absolute path that is still inside it) — any path outside the workspace is rejected.",
|
|
@@ -1681,7 +1686,10 @@ async function applyPendingAction(backend, workspaceRoot, id, options = {}) {
|
|
|
1681
1686
|
await backend.writeTextFile(resolved, record.content);
|
|
1682
1687
|
await recordUndoLogEntry(backend, workspaceRoot, undoEntry2);
|
|
1683
1688
|
await backend.removeFile(pendingActionPath(workspaceRoot, id));
|
|
1684
|
-
return
|
|
1689
|
+
return {
|
|
1690
|
+
...record,
|
|
1691
|
+
previousContent: snapshot.undoable ? snapshot.previousContent ?? void 0 : void 0
|
|
1692
|
+
};
|
|
1685
1693
|
}
|
|
1686
1694
|
if (record.kind === "email") {
|
|
1687
1695
|
if (!options.sendEmail) {
|
|
@@ -2289,6 +2297,407 @@ function classifyToolYield(toolName, resultText) {
|
|
|
2289
2297
|
if (testAny(DEAD_END_MARKERS, resultText)) return "dead_end";
|
|
2290
2298
|
return "productive";
|
|
2291
2299
|
}
|
|
2300
|
+
class Diff {
|
|
2301
|
+
diff(oldStr, newStr, options = {}) {
|
|
2302
|
+
let callback;
|
|
2303
|
+
if (typeof options === "function") {
|
|
2304
|
+
callback = options;
|
|
2305
|
+
options = {};
|
|
2306
|
+
} else if ("callback" in options) {
|
|
2307
|
+
callback = options.callback;
|
|
2308
|
+
}
|
|
2309
|
+
const oldString = this.castInput(oldStr, options);
|
|
2310
|
+
const newString = this.castInput(newStr, options);
|
|
2311
|
+
const oldTokens = this.removeEmpty(this.tokenize(oldString, options));
|
|
2312
|
+
const newTokens = this.removeEmpty(this.tokenize(newString, options));
|
|
2313
|
+
return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);
|
|
2314
|
+
}
|
|
2315
|
+
diffWithOptionsObj(oldTokens, newTokens, options, callback) {
|
|
2316
|
+
var _a;
|
|
2317
|
+
const done = (value) => {
|
|
2318
|
+
value = this.postProcess(value, options);
|
|
2319
|
+
if (callback) {
|
|
2320
|
+
setTimeout(function() {
|
|
2321
|
+
callback(value);
|
|
2322
|
+
}, 0);
|
|
2323
|
+
return void 0;
|
|
2324
|
+
} else {
|
|
2325
|
+
return value;
|
|
2326
|
+
}
|
|
2327
|
+
};
|
|
2328
|
+
const newLen = newTokens.length, oldLen = oldTokens.length;
|
|
2329
|
+
let editLength = 1;
|
|
2330
|
+
let maxEditLength = newLen + oldLen;
|
|
2331
|
+
if (options.maxEditLength != null) {
|
|
2332
|
+
maxEditLength = Math.min(maxEditLength, options.maxEditLength);
|
|
2333
|
+
}
|
|
2334
|
+
const maxExecutionTime = (_a = options.timeout) !== null && _a !== void 0 ? _a : Infinity;
|
|
2335
|
+
const abortAfterTimestamp = Date.now() + maxExecutionTime;
|
|
2336
|
+
const bestPath = [{ oldPos: -1, lastComponent: void 0 }];
|
|
2337
|
+
let newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);
|
|
2338
|
+
if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
2339
|
+
return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));
|
|
2340
|
+
}
|
|
2341
|
+
let minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
|
|
2342
|
+
const execEditLength = () => {
|
|
2343
|
+
for (let diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
|
|
2344
|
+
let basePath;
|
|
2345
|
+
const removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
|
|
2346
|
+
if (removePath) {
|
|
2347
|
+
bestPath[diagonalPath - 1] = void 0;
|
|
2348
|
+
}
|
|
2349
|
+
let canAdd = false;
|
|
2350
|
+
if (addPath) {
|
|
2351
|
+
const addPathNewPos = addPath.oldPos - diagonalPath;
|
|
2352
|
+
canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
|
|
2353
|
+
}
|
|
2354
|
+
const canRemove = removePath && removePath.oldPos + 1 < oldLen;
|
|
2355
|
+
if (!canAdd && !canRemove) {
|
|
2356
|
+
bestPath[diagonalPath] = void 0;
|
|
2357
|
+
continue;
|
|
2358
|
+
}
|
|
2359
|
+
if (!canRemove || canAdd && removePath.oldPos < addPath.oldPos) {
|
|
2360
|
+
basePath = this.addToPath(addPath, true, false, 0, options);
|
|
2361
|
+
} else {
|
|
2362
|
+
basePath = this.addToPath(removePath, false, true, 1, options);
|
|
2363
|
+
}
|
|
2364
|
+
newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
|
|
2365
|
+
if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
2366
|
+
return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
|
|
2367
|
+
} else {
|
|
2368
|
+
bestPath[diagonalPath] = basePath;
|
|
2369
|
+
if (basePath.oldPos + 1 >= oldLen) {
|
|
2370
|
+
maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
|
|
2371
|
+
}
|
|
2372
|
+
if (newPos + 1 >= newLen) {
|
|
2373
|
+
minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
|
|
2374
|
+
}
|
|
2375
|
+
}
|
|
2376
|
+
}
|
|
2377
|
+
editLength++;
|
|
2378
|
+
};
|
|
2379
|
+
if (callback) {
|
|
2380
|
+
(function exec() {
|
|
2381
|
+
setTimeout(function() {
|
|
2382
|
+
if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
|
|
2383
|
+
return callback(void 0);
|
|
2384
|
+
}
|
|
2385
|
+
if (!execEditLength()) {
|
|
2386
|
+
exec();
|
|
2387
|
+
}
|
|
2388
|
+
}, 0);
|
|
2389
|
+
})();
|
|
2390
|
+
} else {
|
|
2391
|
+
while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
|
|
2392
|
+
const ret = execEditLength();
|
|
2393
|
+
if (ret) {
|
|
2394
|
+
return ret;
|
|
2395
|
+
}
|
|
2396
|
+
}
|
|
2397
|
+
}
|
|
2398
|
+
}
|
|
2399
|
+
addToPath(path, added, removed, oldPosInc, options) {
|
|
2400
|
+
const last = path.lastComponent;
|
|
2401
|
+
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
2402
|
+
return {
|
|
2403
|
+
oldPos: path.oldPos + oldPosInc,
|
|
2404
|
+
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
2405
|
+
};
|
|
2406
|
+
} else {
|
|
2407
|
+
return {
|
|
2408
|
+
oldPos: path.oldPos + oldPosInc,
|
|
2409
|
+
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
2410
|
+
};
|
|
2411
|
+
}
|
|
2412
|
+
}
|
|
2413
|
+
extractCommon(basePath, newTokens, oldTokens, diagonalPath, options) {
|
|
2414
|
+
const newLen = newTokens.length, oldLen = oldTokens.length;
|
|
2415
|
+
let oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
|
|
2416
|
+
while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) {
|
|
2417
|
+
newPos++;
|
|
2418
|
+
oldPos++;
|
|
2419
|
+
commonCount++;
|
|
2420
|
+
if (options.oneChangePerToken) {
|
|
2421
|
+
basePath.lastComponent = { count: 1, previousComponent: basePath.lastComponent, added: false, removed: false };
|
|
2422
|
+
}
|
|
2423
|
+
}
|
|
2424
|
+
if (commonCount && !options.oneChangePerToken) {
|
|
2425
|
+
basePath.lastComponent = { count: commonCount, previousComponent: basePath.lastComponent, added: false, removed: false };
|
|
2426
|
+
}
|
|
2427
|
+
basePath.oldPos = oldPos;
|
|
2428
|
+
return newPos;
|
|
2429
|
+
}
|
|
2430
|
+
equals(left, right, options) {
|
|
2431
|
+
if (options.comparator) {
|
|
2432
|
+
return options.comparator(left, right);
|
|
2433
|
+
} else {
|
|
2434
|
+
return left === right || !!options.ignoreCase && left.toLowerCase() === right.toLowerCase();
|
|
2435
|
+
}
|
|
2436
|
+
}
|
|
2437
|
+
removeEmpty(array) {
|
|
2438
|
+
const ret = [];
|
|
2439
|
+
for (let i = 0; i < array.length; i++) {
|
|
2440
|
+
if (array[i]) {
|
|
2441
|
+
ret.push(array[i]);
|
|
2442
|
+
}
|
|
2443
|
+
}
|
|
2444
|
+
return ret;
|
|
2445
|
+
}
|
|
2446
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2447
|
+
castInput(value, options) {
|
|
2448
|
+
return value;
|
|
2449
|
+
}
|
|
2450
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2451
|
+
tokenize(value, options) {
|
|
2452
|
+
return Array.from(value);
|
|
2453
|
+
}
|
|
2454
|
+
join(chars) {
|
|
2455
|
+
return chars.join("");
|
|
2456
|
+
}
|
|
2457
|
+
postProcess(changeObjects, options) {
|
|
2458
|
+
return changeObjects;
|
|
2459
|
+
}
|
|
2460
|
+
get useLongestToken() {
|
|
2461
|
+
return false;
|
|
2462
|
+
}
|
|
2463
|
+
buildValues(lastComponent, newTokens, oldTokens) {
|
|
2464
|
+
const components = [];
|
|
2465
|
+
let nextComponent;
|
|
2466
|
+
while (lastComponent) {
|
|
2467
|
+
components.push(lastComponent);
|
|
2468
|
+
nextComponent = lastComponent.previousComponent;
|
|
2469
|
+
delete lastComponent.previousComponent;
|
|
2470
|
+
lastComponent = nextComponent;
|
|
2471
|
+
}
|
|
2472
|
+
components.reverse();
|
|
2473
|
+
const componentLen = components.length;
|
|
2474
|
+
let componentPos = 0, newPos = 0, oldPos = 0;
|
|
2475
|
+
for (; componentPos < componentLen; componentPos++) {
|
|
2476
|
+
const component = components[componentPos];
|
|
2477
|
+
if (!component.removed) {
|
|
2478
|
+
if (!component.added && this.useLongestToken) {
|
|
2479
|
+
let value = newTokens.slice(newPos, newPos + component.count);
|
|
2480
|
+
value = value.map(function(value2, i) {
|
|
2481
|
+
const oldValue = oldTokens[oldPos + i];
|
|
2482
|
+
return oldValue.length > value2.length ? oldValue : value2;
|
|
2483
|
+
});
|
|
2484
|
+
component.value = this.join(value);
|
|
2485
|
+
} else {
|
|
2486
|
+
component.value = this.join(newTokens.slice(newPos, newPos + component.count));
|
|
2487
|
+
}
|
|
2488
|
+
newPos += component.count;
|
|
2489
|
+
if (!component.added) {
|
|
2490
|
+
oldPos += component.count;
|
|
2491
|
+
}
|
|
2492
|
+
} else {
|
|
2493
|
+
component.value = this.join(oldTokens.slice(oldPos, oldPos + component.count));
|
|
2494
|
+
oldPos += component.count;
|
|
2495
|
+
}
|
|
2496
|
+
}
|
|
2497
|
+
return components;
|
|
2498
|
+
}
|
|
2499
|
+
}
|
|
2500
|
+
class LineDiff extends Diff {
|
|
2501
|
+
constructor() {
|
|
2502
|
+
super(...arguments);
|
|
2503
|
+
this.tokenize = tokenize;
|
|
2504
|
+
}
|
|
2505
|
+
equals(left, right, options) {
|
|
2506
|
+
if (options.ignoreWhitespace) {
|
|
2507
|
+
if (!options.newlineIsToken || !left.includes("\n")) {
|
|
2508
|
+
left = left.trim();
|
|
2509
|
+
}
|
|
2510
|
+
if (!options.newlineIsToken || !right.includes("\n")) {
|
|
2511
|
+
right = right.trim();
|
|
2512
|
+
}
|
|
2513
|
+
} else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {
|
|
2514
|
+
if (left.endsWith("\n")) {
|
|
2515
|
+
left = left.slice(0, -1);
|
|
2516
|
+
}
|
|
2517
|
+
if (right.endsWith("\n")) {
|
|
2518
|
+
right = right.slice(0, -1);
|
|
2519
|
+
}
|
|
2520
|
+
}
|
|
2521
|
+
return super.equals(left, right, options);
|
|
2522
|
+
}
|
|
2523
|
+
}
|
|
2524
|
+
const lineDiff = new LineDiff();
|
|
2525
|
+
function diffLines(oldStr, newStr, options) {
|
|
2526
|
+
return lineDiff.diff(oldStr, newStr, options);
|
|
2527
|
+
}
|
|
2528
|
+
function tokenize(value, options) {
|
|
2529
|
+
if (options.stripTrailingCr) {
|
|
2530
|
+
value = value.replace(/\r\n/g, "\n");
|
|
2531
|
+
}
|
|
2532
|
+
const retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
|
|
2533
|
+
if (!linesAndNewlines[linesAndNewlines.length - 1]) {
|
|
2534
|
+
linesAndNewlines.pop();
|
|
2535
|
+
}
|
|
2536
|
+
for (let i = 0; i < linesAndNewlines.length; i++) {
|
|
2537
|
+
const line = linesAndNewlines[i];
|
|
2538
|
+
if (i % 2 && !options.newlineIsToken) {
|
|
2539
|
+
retLines[retLines.length - 1] += line;
|
|
2540
|
+
} else {
|
|
2541
|
+
retLines.push(line);
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2544
|
+
return retLines;
|
|
2545
|
+
}
|
|
2546
|
+
function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
|
|
2547
|
+
let optionsObj;
|
|
2548
|
+
if (!options) {
|
|
2549
|
+
optionsObj = {};
|
|
2550
|
+
} else if (typeof options === "function") {
|
|
2551
|
+
optionsObj = { callback: options };
|
|
2552
|
+
} else {
|
|
2553
|
+
optionsObj = options;
|
|
2554
|
+
}
|
|
2555
|
+
if (typeof optionsObj.context === "undefined") {
|
|
2556
|
+
optionsObj.context = 4;
|
|
2557
|
+
}
|
|
2558
|
+
const context = optionsObj.context;
|
|
2559
|
+
if (optionsObj.newlineIsToken) {
|
|
2560
|
+
throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");
|
|
2561
|
+
}
|
|
2562
|
+
if (!optionsObj.callback) {
|
|
2563
|
+
return diffLinesResultToPatch(diffLines(oldStr, newStr, optionsObj));
|
|
2564
|
+
} else {
|
|
2565
|
+
const { callback } = optionsObj;
|
|
2566
|
+
diffLines(oldStr, newStr, Object.assign(Object.assign({}, optionsObj), { callback: (diff) => {
|
|
2567
|
+
const patch = diffLinesResultToPatch(diff);
|
|
2568
|
+
callback(patch);
|
|
2569
|
+
} }));
|
|
2570
|
+
}
|
|
2571
|
+
function diffLinesResultToPatch(diff) {
|
|
2572
|
+
if (!diff) {
|
|
2573
|
+
return;
|
|
2574
|
+
}
|
|
2575
|
+
diff.push({ value: "", lines: [] });
|
|
2576
|
+
function contextLines(lines) {
|
|
2577
|
+
return lines.map(function(entry) {
|
|
2578
|
+
return " " + entry;
|
|
2579
|
+
});
|
|
2580
|
+
}
|
|
2581
|
+
const hunks = [];
|
|
2582
|
+
let oldRangeStart = 0, newRangeStart = 0, curRange = [], oldLine = 1, newLine = 1;
|
|
2583
|
+
for (let i = 0; i < diff.length; i++) {
|
|
2584
|
+
const current = diff[i], lines = current.lines || splitLines(current.value);
|
|
2585
|
+
current.lines = lines;
|
|
2586
|
+
if (current.added || current.removed) {
|
|
2587
|
+
if (!oldRangeStart) {
|
|
2588
|
+
const prev = diff[i - 1];
|
|
2589
|
+
oldRangeStart = oldLine;
|
|
2590
|
+
newRangeStart = newLine;
|
|
2591
|
+
if (prev) {
|
|
2592
|
+
curRange = context > 0 ? contextLines(prev.lines.slice(-context)) : [];
|
|
2593
|
+
oldRangeStart -= curRange.length;
|
|
2594
|
+
newRangeStart -= curRange.length;
|
|
2595
|
+
}
|
|
2596
|
+
}
|
|
2597
|
+
for (const line of lines) {
|
|
2598
|
+
curRange.push((current.added ? "+" : "-") + line);
|
|
2599
|
+
}
|
|
2600
|
+
if (current.added) {
|
|
2601
|
+
newLine += lines.length;
|
|
2602
|
+
} else {
|
|
2603
|
+
oldLine += lines.length;
|
|
2604
|
+
}
|
|
2605
|
+
} else {
|
|
2606
|
+
if (oldRangeStart) {
|
|
2607
|
+
if (lines.length <= context * 2 && i < diff.length - 2) {
|
|
2608
|
+
for (const line of contextLines(lines)) {
|
|
2609
|
+
curRange.push(line);
|
|
2610
|
+
}
|
|
2611
|
+
} else {
|
|
2612
|
+
const contextSize = Math.min(lines.length, context);
|
|
2613
|
+
for (const line of contextLines(lines.slice(0, contextSize))) {
|
|
2614
|
+
curRange.push(line);
|
|
2615
|
+
}
|
|
2616
|
+
const hunk = {
|
|
2617
|
+
oldStart: oldRangeStart,
|
|
2618
|
+
oldLines: oldLine - oldRangeStart + contextSize,
|
|
2619
|
+
newStart: newRangeStart,
|
|
2620
|
+
newLines: newLine - newRangeStart + contextSize,
|
|
2621
|
+
lines: curRange
|
|
2622
|
+
};
|
|
2623
|
+
hunks.push(hunk);
|
|
2624
|
+
oldRangeStart = 0;
|
|
2625
|
+
newRangeStart = 0;
|
|
2626
|
+
curRange = [];
|
|
2627
|
+
}
|
|
2628
|
+
}
|
|
2629
|
+
oldLine += lines.length;
|
|
2630
|
+
newLine += lines.length;
|
|
2631
|
+
}
|
|
2632
|
+
}
|
|
2633
|
+
for (const hunk of hunks) {
|
|
2634
|
+
for (let i = 0; i < hunk.lines.length; i++) {
|
|
2635
|
+
if (hunk.lines[i].endsWith("\n")) {
|
|
2636
|
+
hunk.lines[i] = hunk.lines[i].slice(0, -1);
|
|
2637
|
+
} else {
|
|
2638
|
+
hunk.lines.splice(i + 1, 0, "\");
|
|
2639
|
+
i++;
|
|
2640
|
+
}
|
|
2641
|
+
}
|
|
2642
|
+
}
|
|
2643
|
+
return {
|
|
2644
|
+
oldFileName,
|
|
2645
|
+
newFileName,
|
|
2646
|
+
oldHeader,
|
|
2647
|
+
newHeader,
|
|
2648
|
+
hunks
|
|
2649
|
+
};
|
|
2650
|
+
}
|
|
2651
|
+
}
|
|
2652
|
+
function splitLines(text) {
|
|
2653
|
+
const hasTrailingNl = text.endsWith("\n");
|
|
2654
|
+
const result = text.split("\n").map((line) => line + "\n");
|
|
2655
|
+
if (hasTrailingNl) {
|
|
2656
|
+
result.pop();
|
|
2657
|
+
} else {
|
|
2658
|
+
result.push(result.pop().slice(0, -1));
|
|
2659
|
+
}
|
|
2660
|
+
return result;
|
|
2661
|
+
}
|
|
2662
|
+
const DEFAULT_MAX_LINES = 20;
|
|
2663
|
+
const DIFF_INDENT = " ";
|
|
2664
|
+
function formatWriteDiff(oldContent, newContent, maxLines = DEFAULT_MAX_LINES) {
|
|
2665
|
+
if (oldContent === void 0) return previewContent(newContent, maxLines);
|
|
2666
|
+
const hunks = structuredPatch("before", "after", oldContent, newContent, "", "", { context: 3 }).hunks;
|
|
2667
|
+
const entries = [];
|
|
2668
|
+
for (const hunk of hunks) {
|
|
2669
|
+
let oldLine = hunk.oldStart;
|
|
2670
|
+
let newLine = hunk.newStart;
|
|
2671
|
+
for (const rawLine of hunk.lines) {
|
|
2672
|
+
if (rawLine.startsWith("\\")) continue;
|
|
2673
|
+
const sign = rawLine[0];
|
|
2674
|
+
const content = rawLine.slice(1);
|
|
2675
|
+
if (sign === "-") {
|
|
2676
|
+
entries.push({ lineNumber: oldLine, sign, content });
|
|
2677
|
+
oldLine++;
|
|
2678
|
+
} else if (sign === "+") {
|
|
2679
|
+
entries.push({ lineNumber: newLine, sign, content });
|
|
2680
|
+
newLine++;
|
|
2681
|
+
} else {
|
|
2682
|
+
entries.push({ lineNumber: newLine, sign, content });
|
|
2683
|
+
oldLine++;
|
|
2684
|
+
newLine++;
|
|
2685
|
+
}
|
|
2686
|
+
}
|
|
2687
|
+
}
|
|
2688
|
+
if (entries.length === 0) return "(no changes)";
|
|
2689
|
+
const gutterWidth = Math.max(...entries.map((e) => String(e.lineNumber).length));
|
|
2690
|
+
const diffLines2 = entries.map((e) => `${DIFF_INDENT}${String(e.lineNumber).padStart(gutterWidth, " ")} ${e.sign}${e.content}`);
|
|
2691
|
+
return previewLines(diffLines2, maxLines);
|
|
2692
|
+
}
|
|
2693
|
+
function previewContent(content, maxLines = DEFAULT_MAX_LINES) {
|
|
2694
|
+
return previewLines(content.split("\n"), maxLines);
|
|
2695
|
+
}
|
|
2696
|
+
function previewLines(lines, maxLines) {
|
|
2697
|
+
if (lines.length <= maxLines) return lines.join("\n");
|
|
2698
|
+
return `${lines.slice(0, maxLines).join("\n")}
|
|
2699
|
+
… (truncated)`;
|
|
2700
|
+
}
|
|
2292
2701
|
class PrivateNetworkTargetError extends Error {
|
|
2293
2702
|
constructor(requestedUrl, detail) {
|
|
2294
2703
|
super(`Refusing to fetch "${requestedUrl}": ${detail}`);
|
|
@@ -2863,12 +3272,6 @@ const UNPARSED_TOOL_CALL_PATTERN = /<tool_call>|<\/?|[^|<>]{1,32}|(?:tool_
|
|
|
2863
3272
|
function looksLikeUnparsedToolCall(content) {
|
|
2864
3273
|
return UNPARSED_TOOL_CALL_PATTERN.test(content);
|
|
2865
3274
|
}
|
|
2866
|
-
function previewContent$1(content, maxLines = 20) {
|
|
2867
|
-
const lines = content.split("\n");
|
|
2868
|
-
if (lines.length <= maxLines) return content;
|
|
2869
|
-
return `${lines.slice(0, maxLines).join("\n")}
|
|
2870
|
-
… (truncated)`;
|
|
2871
|
-
}
|
|
2872
3275
|
function shellApprovalReason(command, cwd) {
|
|
2873
3276
|
const base = `Proposes running: ${command}
|
|
2874
3277
|
(cwd: ${cwd})`;
|
|
@@ -2910,7 +3313,7 @@ class AgentLoop {
|
|
|
2910
3313
|
return createTurnControlPlaneState(toolNames);
|
|
2911
3314
|
}
|
|
2912
3315
|
/**
|
|
2913
|
-
* R2 of
|
|
3316
|
+
* R2 of the internal plan: builds the real toolExecutors['default']
|
|
2914
3317
|
* entry HarnessBridge.run() swaps in when the one-loop flag is enabled — a proposer that calls
|
|
2915
3318
|
* runToolIterationStep once per driveMainLoop iteration and translates its discriminated result
|
|
2916
3319
|
* into the primitives D0/D1 already built: a plain return (status 'continue', no output yet) for
|
|
@@ -2981,7 +3384,7 @@ ${freshFindings.map((o) => o.content).join("\n\n")}`
|
|
|
2981
3384
|
};
|
|
2982
3385
|
}
|
|
2983
3386
|
/**
|
|
2984
|
-
* R3 of
|
|
3387
|
+
* R3 of the internal plan: the wiring-level counterpart to
|
|
2985
3388
|
* `createHarnessProposer` above — builds the same `messages`/`tools` shape `runToolLoop` builds
|
|
2986
3389
|
* (system prompt + transcript + user message; whichever of FILE_TOOLS/WEB_TOOLS/SHELL_TOOLS/
|
|
2987
3390
|
* ACTION_TOOLS/REMINDER_TOOLS are configured) so `assistant.ts`'s `runTurn` doesn't need to
|
|
@@ -3020,7 +3423,7 @@ ${freshFindings.map((o) => o.content).join("\n\n")}`
|
|
|
3020
3423
|
return { proposer, sources };
|
|
3021
3424
|
}
|
|
3022
3425
|
/**
|
|
3023
|
-
* R4 of
|
|
3426
|
+
* R4 of the internal plan: the batch-research counterpart to
|
|
3024
3427
|
* `createOneLoopProposer` above — routes `runBatchToolLoop`'s probe → calibrate → confirm-gate
|
|
3025
3428
|
* → resolve-remaining → synthesize sequence through the same harness-driven proposer mechanism,
|
|
3026
3429
|
* instead of batch research remaining a second code path that (per R3) never reached the
|
|
@@ -3199,7 +3602,7 @@ ${freshFindings.map((o) => o.content).join("\n\n")}`
|
|
|
3199
3602
|
}
|
|
3200
3603
|
/**
|
|
3201
3604
|
* One iteration's worth of `runToolIterations`' ReAct loop, extracted (R1 of the D2
|
|
3202
|
-
* one-loop-rewire follow-up plan,
|
|
3605
|
+
* one-loop-rewire follow-up plan, the internal plan) so a
|
|
3203
3606
|
* harness-driven proposer (R2) can call this directly, once per `driveMainLoop` iteration,
|
|
3204
3607
|
* instead of only ever being driven by `runToolIterations`' own `for` loop. Preserves every
|
|
3205
3608
|
* early-return branch of the original loop body exactly — the unparsed-tool-call retry,
|
|
@@ -3217,6 +3620,9 @@ ${freshFindings.map((o) => o.content).join("\n\n")}`
|
|
|
3217
3620
|
const reportStep = (tool, input) => {
|
|
3218
3621
|
onToolStep == null ? void 0 : onToolStep({ tool, input, summary: summarizeToolStep(tool, input) });
|
|
3219
3622
|
};
|
|
3623
|
+
const reportDenied = (tool, input, reason) => {
|
|
3624
|
+
onToolStep == null ? void 0 : onToolStep({ tool, input, summary: summarizeToolStep(tool, input), deniedReason: reason });
|
|
3625
|
+
};
|
|
3220
3626
|
{
|
|
3221
3627
|
const response = await this.llmClient.callChatStructured(messages, tools, {
|
|
3222
3628
|
model: this.model(),
|
|
@@ -3229,9 +3635,10 @@ ${freshFindings.map((o) => o.content).join("\n\n")}`
|
|
|
3229
3635
|
// makes directly, now also covering the calls this backend used to resolve invisibly.
|
|
3230
3636
|
// A backend without such an internal loop (the proxy client) never calls this — its
|
|
3231
3637
|
// calls come back as response.toolCalls and are gated inline below instead.
|
|
3232
|
-
onToolProposal: async (tool) => {
|
|
3638
|
+
onToolProposal: async (tool, input) => {
|
|
3233
3639
|
const policy = this.checkToolPolicy(tool, riskHint, controlPlaneState == null ? void 0 : controlPlaneState.controlState);
|
|
3234
3640
|
if (policy.decision === "ALLOW") return { decision: "allow" };
|
|
3641
|
+
reportDenied(tool, input, policy.reason);
|
|
3235
3642
|
return { decision: "deny", reason: policy.reason };
|
|
3236
3643
|
}
|
|
3237
3644
|
});
|
|
@@ -3261,12 +3668,13 @@ ${freshFindings.map((o) => o.content).join("\n\n")}`
|
|
|
3261
3668
|
const { id, kind, ...payload } = alreadyStagedCall.input;
|
|
3262
3669
|
if (kind === "write") {
|
|
3263
3670
|
const { path, content } = payload;
|
|
3671
|
+
const previousContent = this.fileTools ? await readCurrentFileContent(this.fileTools.backend, this.fileTools.workspaceRoot, path) : void 0;
|
|
3264
3672
|
return {
|
|
3265
3673
|
done: true,
|
|
3266
3674
|
result: {
|
|
3267
3675
|
kind: "needs_approval",
|
|
3268
3676
|
reason: `Proposes writing to "${path}":
|
|
3269
|
-
${
|
|
3677
|
+
${formatWriteDiff(previousContent, content)}`,
|
|
3270
3678
|
pendingActionId: id,
|
|
3271
3679
|
pendingActionKind: "write"
|
|
3272
3680
|
}
|
|
@@ -3303,12 +3711,13 @@ ${previewContent$1(content)}`,
|
|
|
3303
3711
|
if (result.kind !== "staged_write") {
|
|
3304
3712
|
throw new Error("write_file executor returned an unexpected result kind");
|
|
3305
3713
|
}
|
|
3714
|
+
const previousContent = await readCurrentFileContent(this.fileTools.backend, this.fileTools.workspaceRoot, result.path);
|
|
3306
3715
|
return {
|
|
3307
3716
|
done: true,
|
|
3308
3717
|
result: {
|
|
3309
3718
|
kind: "needs_approval",
|
|
3310
3719
|
reason: `Proposes writing to "${result.path}":
|
|
3311
|
-
${
|
|
3720
|
+
${formatWriteDiff(previousContent, result.content)}`,
|
|
3312
3721
|
pendingActionId: result.id,
|
|
3313
3722
|
pendingActionKind: "write"
|
|
3314
3723
|
}
|
|
@@ -3350,6 +3759,7 @@ ${previewContent$1(result.content)}`,
|
|
|
3350
3759
|
const policy = this.checkToolPolicy(call.name, riskHint, controlPlaneState == null ? void 0 : controlPlaneState.controlState);
|
|
3351
3760
|
if (policy.decision === "DENY") {
|
|
3352
3761
|
const resultText2 = `Denied by tool policy: ${policy.reason}`;
|
|
3762
|
+
reportDenied(call.name, call.input, policy.reason);
|
|
3353
3763
|
messages.push({ role: "tool", content: resultText2, toolCallId: call.id });
|
|
3354
3764
|
(_a = this.onTrace) == null ? void 0 : _a.call(this, { kind: "tool_call", tool: call.name, ok: false });
|
|
3355
3765
|
continue;
|
|
@@ -3614,7 +4024,7 @@ ${text}` : text;
|
|
|
3614
4024
|
}
|
|
3615
4025
|
/**
|
|
3616
4026
|
* Trajectory Supervisor GATHER_EVIDENCE host (S5 of
|
|
3617
|
-
*
|
|
4027
|
+
* the internal plan). A bounded, strictly read-only tool
|
|
3618
4028
|
* loop the harness calls (via HarnessRunOptions.runInvestigation) when the supervisor
|
|
3619
4029
|
* decides the run is stuck for lack of a fact.
|
|
3620
4030
|
*
|
|
@@ -3692,12 +4102,6 @@ ${content}`.slice(0, 800), tool: "read_file", reliability: "MEDIUM" });
|
|
|
3692
4102
|
return findings;
|
|
3693
4103
|
}
|
|
3694
4104
|
}
|
|
3695
|
-
function previewContent(content, maxLines = 20) {
|
|
3696
|
-
const lines = content.split("\n");
|
|
3697
|
-
if (lines.length <= maxLines) return content;
|
|
3698
|
-
return `${lines.slice(0, maxLines).join("\n")}
|
|
3699
|
-
… (truncated)`;
|
|
3700
|
-
}
|
|
3701
4105
|
class ActionApprovalService {
|
|
3702
4106
|
constructor(memory, llmClient, model, fileTools, shellTools, actionTools, session, agentLoop, onTrace, onDebugLog) {
|
|
3703
4107
|
this.memory = memory;
|
|
@@ -3829,19 +4233,27 @@ ${reply.slice(0, 4e3)}${reply.length > 4e3 ? `
|
|
|
3829
4233
|
async loadChainedApproval(backend, workspaceRoot, nextPendingActionId, previousOutcome) {
|
|
3830
4234
|
const next = await loadPendingAction(backend, workspaceRoot, nextPendingActionId);
|
|
3831
4235
|
if (!next) return void 0;
|
|
3832
|
-
|
|
4236
|
+
let reason;
|
|
4237
|
+
if (next.kind === "write") {
|
|
4238
|
+
const previousContent = await readCurrentFileContent(backend, workspaceRoot, next.path);
|
|
4239
|
+
reason = `${previousOutcome}
|
|
3833
4240
|
|
|
3834
4241
|
Next, it also proposes writing to "${next.path}":
|
|
3835
|
-
${
|
|
4242
|
+
${formatWriteDiff(previousContent, next.content)}`;
|
|
4243
|
+
} else if (next.kind === "shell") {
|
|
4244
|
+
reason = `${previousOutcome}
|
|
3836
4245
|
|
|
3837
4246
|
Next, it also proposes running: ${next.command}
|
|
3838
|
-
(cwd: ${next.cwd})
|
|
4247
|
+
(cwd: ${next.cwd})`;
|
|
4248
|
+
} else if (next.kind === "email") {
|
|
4249
|
+
reason = `${previousOutcome}
|
|
3839
4250
|
|
|
3840
4251
|
Next, it also proposes sending an email:
|
|
3841
4252
|
To: ${next.to}
|
|
3842
4253
|
Subject: ${next.subject}
|
|
3843
4254
|
|
|
3844
|
-
${previewContent(next.body)}
|
|
4255
|
+
${previewContent(next.body)}`;
|
|
4256
|
+
}
|
|
3845
4257
|
if (!reason) return void 0;
|
|
3846
4258
|
return {
|
|
3847
4259
|
status: "needs_approval",
|
|
@@ -4060,7 +4472,7 @@ function matchTaskCancelAttempt(message, plan) {
|
|
|
4060
4472
|
const lower = message.toLowerCase();
|
|
4061
4473
|
for (const task of plan.tasks) {
|
|
4062
4474
|
if (task.status === "COMPLETE" || task.cancelled) continue;
|
|
4063
|
-
const words = tokenize(`${task.id} ${task.description}`.toLowerCase()).filter(
|
|
4475
|
+
const words = tokenize$1(`${task.id} ${task.description}`.toLowerCase()).filter(
|
|
4064
4476
|
(w) => !CANCEL_MATCH_STOPWORDS.has(w) && (containsCJK(w) || w.length >= 4)
|
|
4065
4477
|
);
|
|
4066
4478
|
if (words.some((w) => lower.includes(w))) {
|
|
@@ -6006,7 +6418,7 @@ class HarnessBridge {
|
|
|
6006
6418
|
// task-graph *shape* (visible in stepsUsed/nodeExecutionOrder), not the number of
|
|
6007
6419
|
// distinct replies produced.
|
|
6008
6420
|
//
|
|
6009
|
-
// R2 of
|
|
6421
|
+
// R2 of the internal plan: flag-OFF (the default) and flag-ON
|
|
6010
6422
|
// with no caller-supplied proposer are byte-identical to the line above — `() =>
|
|
6011
6423
|
// draftReply` — satisfying INV-19. Flag-ON with a real oneLoopProposer swaps it in as the
|
|
6012
6424
|
// 'default' toolExecutor instead, read once per turn right here.
|
|
@@ -6043,7 +6455,7 @@ class HarnessBridge {
|
|
|
6043
6455
|
// Trajectory Supervisor decider (S5) — the single stall-edge LLM call. Flag-gated on
|
|
6044
6456
|
// HARNESS_TRAJECTORY_SUPERVISOR (default OFF); when off, the harness never consults it
|
|
6045
6457
|
// and the whole supervisor path stays inert (INV-22). The harness itself only calls this
|
|
6046
|
-
// inside its own cannotMakeProgress() branch. Twin of
|
|
6458
|
+
// inside its own cannotMakeProgress() branch. Twin of the planner driver's _run_planner gate.
|
|
6047
6459
|
supervisorDecider: supervisorEnabled() ? (digest) => decideSupervisorDirective(digest, this.llmClient, this.model(), onUsage) : void 0,
|
|
6048
6460
|
onSupervisorDirective: (directive) => {
|
|
6049
6461
|
var _a2;
|
|
@@ -6328,7 +6740,7 @@ class AskClarificationService {
|
|
|
6328
6740
|
sessionId,
|
|
6329
6741
|
userMessage: answerText,
|
|
6330
6742
|
facts: staged.facts,
|
|
6331
|
-
// Phase 4 of
|
|
6743
|
+
// Phase 4 of the internal plan — same
|
|
6332
6744
|
// reasoning as assistant.ts's own call site: buildSuccessResult below runs recordFacts()
|
|
6333
6745
|
// with this same (sessionId, answerText, staged.classification.statesDurableFacts) triple,
|
|
6334
6746
|
// so this stays consistent with what actually gets written to the fact stores this turn.
|
|
@@ -6539,7 +6951,7 @@ class PersonalAssistant {
|
|
|
6539
6951
|
__publicField(this, "dangerouslySkipPermissions");
|
|
6540
6952
|
/** Whenever any of fileTools/webTools/shellTools is configured, `turn()` routes through AgentLoop instead of a single plain chat call — computed once here since it never changes for the lifetime of an instance. */
|
|
6541
6953
|
__publicField(this, "toolLoopWillRun");
|
|
6542
|
-
/** R3 of
|
|
6954
|
+
/** R3 of the internal plan — mirrors the same flag HarnessBridge was given at construction, kept here too so runTurn can decide whether to defer the tool loop into a harness-driven proposer instead of precomputing draftReply. See PersonalAssistantOptions.oneLoopMode's doc comment. */
|
|
6543
6955
|
__publicField(this, "oneLoopMode");
|
|
6544
6956
|
/** Q2 — global-flag tier of the ask-question mechanism's three-tier INV-29 resolution. See PersonalAssistantOptions.askMode's doc comment. */
|
|
6545
6957
|
__publicField(this, "askMode");
|
|
@@ -6550,7 +6962,7 @@ class PersonalAssistant {
|
|
|
6550
6962
|
* AssistantTurnResult.proposerKind, and emitted as a 'proposer_selected' trace event from
|
|
6551
6963
|
* runTurn itself. A single mutable field is safe because `turn()` is awaited end to end (turns
|
|
6552
6964
|
* never overlap within one instance). See AssistantTurnResult.proposerKind and
|
|
6553
|
-
*
|
|
6965
|
+
* the internal plan phase B1.
|
|
6554
6966
|
*/
|
|
6555
6967
|
__publicField(this, "lastProposerKind", "posthoc");
|
|
6556
6968
|
__publicField(this, "memoryService");
|
|
@@ -6708,7 +7120,7 @@ class PersonalAssistant {
|
|
|
6708
7120
|
return this.session.clearSession(sessionId);
|
|
6709
7121
|
}
|
|
6710
7122
|
/**
|
|
6711
|
-
* P1 of
|
|
7123
|
+
* P1 of the internal plan — explicit entry point into plan mode's
|
|
6712
7124
|
* exclusive drafting state. No production caller yet: P3 will later set this automatically from
|
|
6713
7125
|
* a judgment-based trigger ahead of TurnInterpreter's classification. Until then this is reached
|
|
6714
7126
|
* only by a caller (a future `/plan` CLI command, or a test) that wants to exercise the drafting
|
|
@@ -6720,7 +7132,7 @@ class PersonalAssistant {
|
|
|
6720
7132
|
return this.session.enterPlanMode(sessionId);
|
|
6721
7133
|
}
|
|
6722
7134
|
/**
|
|
6723
|
-
* P7 of
|
|
7135
|
+
* P7 of the internal plan — the raw current `PlanRecord` for this
|
|
6724
7136
|
* session, regardless of `mode`, so a caller (chat-ui's persistent banner, the CLI's `/plan
|
|
6725
7137
|
* show`) can display live drafting/awaiting-approval state independent of any single turn's
|
|
6726
7138
|
* own result (a `needs_plan_approval` result only carries a snapshot at the moment it's
|
|
@@ -6731,7 +7143,7 @@ class PersonalAssistant {
|
|
|
6731
7143
|
return this.planService.loadPlanRecord(sessionId);
|
|
6732
7144
|
}
|
|
6733
7145
|
/**
|
|
6734
|
-
* P9 of
|
|
7146
|
+
* P9 of the internal plan — the lightweight plan-sketch delegate: a
|
|
6735
7147
|
* cheaper "just go research and draft an approach" path than plan mode's durable task-graph
|
|
6736
7148
|
* machinery (P0-P8), explicitly invoked (a CLI `/plan sketch <request>` command, a chat-ui
|
|
6737
7149
|
* "Sketch a plan" action) rather than auto-triggered. Returns advice in the reply text — it
|
|
@@ -6785,7 +7197,7 @@ class PersonalAssistant {
|
|
|
6785
7197
|
/**
|
|
6786
7198
|
* `/memory confirm <n|category>` — `selector` is either a 1-based index into `/memory`'s
|
|
6787
7199
|
* flat, display-order "Pending confirmation" listing, or one of FactCategory's names for a
|
|
6788
|
-
* bulk confirm. Phase 3 of
|
|
7200
|
+
* bulk confirm. Phase 3 of the internal plan.
|
|
6789
7201
|
* `conflictNotices` (if any) are advisory only — every confirmed fact is promoted regardless,
|
|
6790
7202
|
* matching how every other contradiction check in this codebase never gates belief admission.
|
|
6791
7203
|
*/
|
|
@@ -7009,7 +7421,7 @@ class PersonalAssistant {
|
|
|
7009
7421
|
sessionId,
|
|
7010
7422
|
userMessage,
|
|
7011
7423
|
facts,
|
|
7012
|
-
// Phase 4 of
|
|
7424
|
+
// Phase 4 of the internal plan: the same
|
|
7013
7425
|
// merged lexical+LLM list recordFacts() (called later, in responseService's build*Result)
|
|
7014
7426
|
// derives its writes from — computed independently here (both calls are pure given the
|
|
7015
7427
|
// same sessionId/userMessage/statedFacts) so the harness's World Model sees a same-turn
|
|
@@ -7088,7 +7500,7 @@ class PersonalAssistant {
|
|
|
7088
7500
|
/**
|
|
7089
7501
|
* Shared by the flag-OFF flat/batch tool loop's own needs_approval/escalated ToolLoopResult and
|
|
7090
7502
|
* the flag-ON harness-driven proposer's equivalent OneLoopPause (R3 of
|
|
7091
|
-
*
|
|
7503
|
+
* the internal plan, see runTurn's two call sites) — "the model wants
|
|
7092
7504
|
* to write/run/send something" or "the tool loop gave up" means the same thing to the caller
|
|
7093
7505
|
* regardless of which loop discovered it.
|
|
7094
7506
|
*/
|
|
@@ -7363,6 +7775,7 @@ const CONFIG_KEYS = [
|
|
|
7363
7775
|
"askMode",
|
|
7364
7776
|
"planMode",
|
|
7365
7777
|
"tuiMode",
|
|
7778
|
+
"updateCheck",
|
|
7366
7779
|
"activeProject"
|
|
7367
7780
|
];
|
|
7368
7781
|
const DEFAULT_CONFIG = {
|
|
@@ -7430,6 +7843,16 @@ function resolveTuiMode(env) {
|
|
|
7430
7843
|
function shouldLaunchTuiApp(tuiMode, stdoutIsTty, stdinIsTty) {
|
|
7431
7844
|
return tuiMode === "enabled" && stdoutIsTty && stdinIsTty;
|
|
7432
7845
|
}
|
|
7846
|
+
const DEFAULT_UPDATE_CHECK_MODE = "enabled";
|
|
7847
|
+
function normalizeUpdateCheckMode(raw, varName = "ASSISTANT_UPDATE_CHECK") {
|
|
7848
|
+
if (raw === void 0 || raw === "") return DEFAULT_UPDATE_CHECK_MODE;
|
|
7849
|
+
if (raw === "enabled" || raw === "disabled") return raw;
|
|
7850
|
+
console.error(`[warning] ${varName}="${raw}" is not "enabled" or "disabled" — using the default (${DEFAULT_UPDATE_CHECK_MODE}).`);
|
|
7851
|
+
return DEFAULT_UPDATE_CHECK_MODE;
|
|
7852
|
+
}
|
|
7853
|
+
function resolveUpdateCheckMode(env) {
|
|
7854
|
+
return normalizeUpdateCheckMode(env.ASSISTANT_UPDATE_CHECK);
|
|
7855
|
+
}
|
|
7433
7856
|
const SECRET_CONFIG_KEYS = /* @__PURE__ */ new Set(["authToken", "apiKey", "braveApiKey"]);
|
|
7434
7857
|
const ENV_VAR_FOR_CONFIG_KEY = {
|
|
7435
7858
|
llmBackend: "ASSISTANT_LLM_BACKEND",
|
|
@@ -7458,6 +7881,7 @@ const ENV_VAR_FOR_CONFIG_KEY = {
|
|
|
7458
7881
|
askMode: "ASSISTANT_ASK_MODE",
|
|
7459
7882
|
planMode: "ASSISTANT_PLAN_MODE",
|
|
7460
7883
|
tuiMode: "ASSISTANT_TUI",
|
|
7884
|
+
updateCheck: "ASSISTANT_UPDATE_CHECK",
|
|
7461
7885
|
activeProject: "ASSISTANT_ACTIVE_PROJECT"
|
|
7462
7886
|
};
|
|
7463
7887
|
function isConfigKey(key) {
|
|
@@ -7505,6 +7929,7 @@ function envOverridesFromProcessEnv(env) {
|
|
|
7505
7929
|
if (env.ASSISTANT_ASK_MODE !== void 0) overrides.askMode = resolveAskMode(env);
|
|
7506
7930
|
if (env.ASSISTANT_PLAN_MODE !== void 0) overrides.planMode = resolvePlanMode(env);
|
|
7507
7931
|
if (env.ASSISTANT_TUI !== void 0) overrides.tuiMode = resolveTuiMode(env);
|
|
7932
|
+
if (env.ASSISTANT_UPDATE_CHECK !== void 0) overrides.updateCheck = resolveUpdateCheckMode(env);
|
|
7508
7933
|
if (env.ASSISTANT_ACTIVE_PROJECT !== void 0) overrides.activeProject = env.ASSISTANT_ACTIVE_PROJECT;
|
|
7509
7934
|
return overrides;
|
|
7510
7935
|
}
|
|
@@ -7560,6 +7985,9 @@ function parseConfigValue(key, raw) {
|
|
|
7560
7985
|
case "tuiMode":
|
|
7561
7986
|
if (raw !== "enabled" && raw !== "disabled") throw new ConfigValueParseError('tuiMode must be "enabled" or "disabled"');
|
|
7562
7987
|
return raw;
|
|
7988
|
+
case "updateCheck":
|
|
7989
|
+
if (raw !== "enabled" && raw !== "disabled") throw new ConfigValueParseError('updateCheck must be "enabled" or "disabled"');
|
|
7990
|
+
return raw;
|
|
7563
7991
|
default:
|
|
7564
7992
|
return raw;
|
|
7565
7993
|
}
|
|
@@ -7761,103 +8189,104 @@ function formatDoctorReport(checks) {
|
|
|
7761
8189
|
return checks.map((c) => ` ${c.ok ? "✓" : "✗"} ${c.label}${!c.ok && c.detail ? ` — ${c.detail}` : ""}`).join("\n");
|
|
7762
8190
|
}
|
|
7763
8191
|
export {
|
|
7764
|
-
|
|
8192
|
+
executeWebTool as $,
|
|
7765
8193
|
ACTION_TOOLS as A,
|
|
7766
|
-
|
|
8194
|
+
classifyRisk as B,
|
|
7767
8195
|
CONFIG_KEYS as C,
|
|
7768
8196
|
DEFAULT_ASK_MODE as D,
|
|
7769
8197
|
ENV_VAR_FOR_CONFIG_KEY as E,
|
|
7770
8198
|
FETCH_URL_TOOL as F,
|
|
7771
|
-
|
|
7772
|
-
|
|
8199
|
+
classifyToolYield as G,
|
|
8200
|
+
classifyTurnIntent as H,
|
|
7773
8201
|
InvalidEmailArgsError as I,
|
|
7774
|
-
|
|
7775
|
-
|
|
8202
|
+
computePlanPosition as J,
|
|
8203
|
+
createPlanRecord as K,
|
|
7776
8204
|
LAYER_DISPLAY_NAME as L,
|
|
7777
|
-
|
|
7778
|
-
|
|
7779
|
-
|
|
8205
|
+
createResendSender as M,
|
|
8206
|
+
createSmtpSender as N,
|
|
8207
|
+
defaultExportFilename as O,
|
|
7780
8208
|
PathOutsideWorkspaceError as P,
|
|
7781
|
-
|
|
8209
|
+
defaultMemoryExportFilename as Q,
|
|
7782
8210
|
READ_FILE_TOOL as R,
|
|
7783
8211
|
SEND_EMAIL_TOOL as S,
|
|
7784
|
-
|
|
7785
|
-
|
|
7786
|
-
|
|
8212
|
+
detectHomogeneousBatchList as T,
|
|
8213
|
+
discardPendingAction as U,
|
|
8214
|
+
envOverridesFromProcessEnv as V,
|
|
7787
8215
|
WEB_SEARCH_TOOL as W,
|
|
7788
|
-
|
|
7789
|
-
|
|
7790
|
-
|
|
7791
|
-
|
|
8216
|
+
estimateCostUsd as X,
|
|
8217
|
+
executeActionTool as Y,
|
|
8218
|
+
executeFileTool as Z,
|
|
8219
|
+
executeShellTool as _,
|
|
7792
8220
|
ALREADY_STAGED_ACTION_TOOL as a,
|
|
7793
|
-
|
|
7794
|
-
|
|
7795
|
-
|
|
7796
|
-
|
|
7797
|
-
|
|
7798
|
-
|
|
7799
|
-
|
|
7800
|
-
|
|
7801
|
-
|
|
7802
|
-
|
|
7803
|
-
|
|
7804
|
-
|
|
7805
|
-
|
|
7806
|
-
|
|
7807
|
-
|
|
7808
|
-
|
|
7809
|
-
|
|
7810
|
-
|
|
7811
|
-
|
|
7812
|
-
|
|
7813
|
-
|
|
7814
|
-
|
|
7815
|
-
|
|
7816
|
-
|
|
7817
|
-
|
|
7818
|
-
|
|
7819
|
-
|
|
7820
|
-
|
|
7821
|
-
|
|
7822
|
-
|
|
7823
|
-
|
|
7824
|
-
|
|
7825
|
-
|
|
7826
|
-
|
|
7827
|
-
|
|
7828
|
-
|
|
7829
|
-
|
|
7830
|
-
|
|
7831
|
-
|
|
7832
|
-
|
|
7833
|
-
|
|
7834
|
-
|
|
7835
|
-
|
|
7836
|
-
|
|
8221
|
+
formatConfigListing as a0,
|
|
8222
|
+
formatCostSummary as a1,
|
|
8223
|
+
formatDoctorReport as a2,
|
|
8224
|
+
formatEmailApprovalReason as a3,
|
|
8225
|
+
formatHelp as a4,
|
|
8226
|
+
formatMemoryExport as a5,
|
|
8227
|
+
formatMemoryPendingOutcome as a6,
|
|
8228
|
+
formatMemorySummary as a7,
|
|
8229
|
+
formatPlanProgress as a8,
|
|
8230
|
+
formatSearchResults as a9,
|
|
8231
|
+
savePlan as aA,
|
|
8232
|
+
shouldLaunchTuiApp as aB,
|
|
8233
|
+
stagePendingAction as aC,
|
|
8234
|
+
stagedActionInput as aD,
|
|
8235
|
+
stripJsonCodeFence as aE,
|
|
8236
|
+
stripMcpToolPrefix as aF,
|
|
8237
|
+
summarizeToolStep as aG,
|
|
8238
|
+
updatePlanFromRun as aH,
|
|
8239
|
+
validateConfig as aI,
|
|
8240
|
+
formatSpendCapStatus as aa,
|
|
8241
|
+
formatStatus as ab,
|
|
8242
|
+
formatTranscriptMarkdown as ac,
|
|
8243
|
+
formatUndoLogListing as ad,
|
|
8244
|
+
isConfigKey as ae,
|
|
8245
|
+
isLikelyEmailAddress as af,
|
|
8246
|
+
listTemplateNames as ag,
|
|
8247
|
+
loadActivePlan as ah,
|
|
8248
|
+
loadPendingAction as ai,
|
|
8249
|
+
loadTemplate as aj,
|
|
8250
|
+
matchTemplateIfConfident as ak,
|
|
8251
|
+
nextPendingTask as al,
|
|
8252
|
+
nodeDisplayName as am,
|
|
8253
|
+
nodeToLayer as an,
|
|
8254
|
+
normalizeAskMode as ao,
|
|
8255
|
+
normalizeOneLoopMode as ap,
|
|
8256
|
+
normalizePlanMode as aq,
|
|
8257
|
+
parseClaudeCliOutput as ar,
|
|
8258
|
+
parseConfigValue as as,
|
|
8259
|
+
pickTemplateForTask as at,
|
|
8260
|
+
planCompletionPct as au,
|
|
8261
|
+
resolveAskMode as av,
|
|
8262
|
+
resolveConfig as aw,
|
|
8263
|
+
resolveInWorkspace as ax,
|
|
8264
|
+
resolveOneLoopMode as ay,
|
|
8265
|
+
resolvePlanMode as az,
|
|
7837
8266
|
AskClarificationService as b,
|
|
7838
8267
|
ConfigValidationError as c,
|
|
7839
8268
|
ConfigValueParseError as d,
|
|
7840
8269
|
DEFAULT_CONFIG as e,
|
|
7841
8270
|
DEFAULT_ONE_LOOP_MODE as f,
|
|
7842
8271
|
DEFAULT_PLAN_MODE as g,
|
|
7843
|
-
|
|
7844
|
-
|
|
7845
|
-
|
|
7846
|
-
|
|
7847
|
-
|
|
7848
|
-
|
|
7849
|
-
|
|
7850
|
-
|
|
7851
|
-
|
|
7852
|
-
|
|
7853
|
-
|
|
7854
|
-
|
|
7855
|
-
|
|
7856
|
-
|
|
7857
|
-
|
|
7858
|
-
|
|
7859
|
-
|
|
7860
|
-
|
|
7861
|
-
|
|
8272
|
+
DIFF_INDENT as h,
|
|
8273
|
+
EmailDeliveryError as i,
|
|
8274
|
+
FILE_TOOLS as j,
|
|
8275
|
+
LAYER_ORDER as k,
|
|
8276
|
+
LAYER_SHORT_CODE as l,
|
|
8277
|
+
LIST_DIRECTORY_TOOL as m,
|
|
8278
|
+
PersonalAssistant as n,
|
|
8279
|
+
PrivateNetworkTargetError as o,
|
|
8280
|
+
RUN_SHELL_COMMAND_TOOL as p,
|
|
8281
|
+
SHELL_TOOLS as q,
|
|
8282
|
+
WEB_TOOLS as r,
|
|
8283
|
+
WRITE_FILE_TOOL as s,
|
|
8284
|
+
abandonPlan as t,
|
|
8285
|
+
applyPendingAction as u,
|
|
8286
|
+
assertPublicHttpUrl as v,
|
|
8287
|
+
braveSearch as w,
|
|
8288
|
+
buildClaudePrompt as x,
|
|
8289
|
+
buildWhyChain as y,
|
|
8290
|
+
classifyError as z
|
|
7862
8291
|
};
|
|
7863
|
-
//# sourceMappingURL=cli-session-
|
|
8292
|
+
//# sourceMappingURL=cli-session-BiX2DOni.js.map
|