@vionwilliams/agent-os 1.0.0-alpha.21 → 1.0.0-alpha.23
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 +2 -2
- package/dist/cli.js +804 -793
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -8275,37 +8275,44 @@ import {
|
|
|
8275
8275
|
function slowLoggingExternal() {
|
|
8276
8276
|
return NOOP_LOGGER;
|
|
8277
8277
|
}
|
|
8278
|
+
function withSlowOperationLogging(logger, operation) {
|
|
8279
|
+
try {
|
|
8280
|
+
return operation();
|
|
8281
|
+
} finally {
|
|
8282
|
+
logger[Symbol.dispose]();
|
|
8283
|
+
}
|
|
8284
|
+
}
|
|
8278
8285
|
function jsonStringify(value, replacer, space) {
|
|
8279
|
-
|
|
8280
|
-
return JSON.stringify(value, replacer, space);
|
|
8286
|
+
return withSlowOperationLogging(slowLogging`JSON.stringify(${value})`, () => JSON.stringify(value, replacer, space));
|
|
8281
8287
|
}
|
|
8282
8288
|
function clone(value, options) {
|
|
8283
|
-
|
|
8284
|
-
return structuredClone(value, options);
|
|
8289
|
+
return withSlowOperationLogging(slowLogging`structuredClone(${value})`, () => structuredClone(value, options));
|
|
8285
8290
|
}
|
|
8286
8291
|
function writeFileSync_DEPRECATED(filePath, data, options) {
|
|
8287
|
-
|
|
8288
|
-
|
|
8289
|
-
|
|
8290
|
-
|
|
8291
|
-
|
|
8292
|
-
|
|
8293
|
-
|
|
8294
|
-
|
|
8295
|
-
|
|
8296
|
-
|
|
8297
|
-
|
|
8298
|
-
|
|
8299
|
-
|
|
8292
|
+
return withSlowOperationLogging(slowLogging`fs.writeFileSync(${filePath}, ${data})`, () => {
|
|
8293
|
+
const needsFlush = options !== null && typeof options === "object" && "flush" in options && options.flush === true;
|
|
8294
|
+
if (needsFlush) {
|
|
8295
|
+
const encoding = typeof options === "object" && "encoding" in options ? options.encoding : undefined;
|
|
8296
|
+
const mode = typeof options === "object" && "mode" in options ? options.mode : undefined;
|
|
8297
|
+
let fd;
|
|
8298
|
+
try {
|
|
8299
|
+
fd = openSync(filePath, "w", mode);
|
|
8300
|
+
fsWriteFileSync(fd, data, { encoding: encoding ?? undefined });
|
|
8301
|
+
fsyncSync(fd);
|
|
8302
|
+
} finally {
|
|
8303
|
+
if (fd !== undefined) {
|
|
8304
|
+
closeSync(fd);
|
|
8305
|
+
}
|
|
8300
8306
|
}
|
|
8307
|
+
} else {
|
|
8308
|
+
fsWriteFileSync(filePath, data, options);
|
|
8301
8309
|
}
|
|
8302
|
-
}
|
|
8303
|
-
fsWriteFileSync(filePath, data, options);
|
|
8304
|
-
}
|
|
8310
|
+
});
|
|
8305
8311
|
}
|
|
8306
8312
|
var SLOW_OPERATION_THRESHOLD_MS, NOOP_LOGGER, slowLogging, jsonParse = (text, reviver) => {
|
|
8307
|
-
|
|
8308
|
-
|
|
8313
|
+
return withSlowOperationLogging(slowLogging`JSON.parse(${text})`, () => {
|
|
8314
|
+
return typeof reviver === "undefined" ? JSON.parse(text) : JSON.parse(text, reviver);
|
|
8315
|
+
});
|
|
8309
8316
|
};
|
|
8310
8317
|
var init_slowOperations = __esm(() => {
|
|
8311
8318
|
init_state();
|
|
@@ -8456,49 +8463,57 @@ function getFsImplementation() {
|
|
|
8456
8463
|
return activeFs;
|
|
8457
8464
|
}
|
|
8458
8465
|
async function readFileRange(path2, offset, maxBytes) {
|
|
8459
|
-
|
|
8460
|
-
|
|
8461
|
-
|
|
8462
|
-
|
|
8463
|
-
|
|
8464
|
-
|
|
8465
|
-
|
|
8466
|
-
|
|
8467
|
-
|
|
8468
|
-
|
|
8469
|
-
|
|
8470
|
-
|
|
8466
|
+
const fh = await open(path2, "r");
|
|
8467
|
+
try {
|
|
8468
|
+
const size = (await fh.stat()).size;
|
|
8469
|
+
if (size <= offset) {
|
|
8470
|
+
return null;
|
|
8471
|
+
}
|
|
8472
|
+
const bytesToRead = Math.min(size - offset, maxBytes);
|
|
8473
|
+
const buffer = Buffer.allocUnsafe(bytesToRead);
|
|
8474
|
+
let totalRead = 0;
|
|
8475
|
+
while (totalRead < bytesToRead) {
|
|
8476
|
+
const { bytesRead } = await fh.read(buffer, totalRead, bytesToRead - totalRead, offset + totalRead);
|
|
8477
|
+
if (bytesRead === 0) {
|
|
8478
|
+
break;
|
|
8479
|
+
}
|
|
8480
|
+
totalRead += bytesRead;
|
|
8471
8481
|
}
|
|
8472
|
-
|
|
8482
|
+
return {
|
|
8483
|
+
content: buffer.toString("utf8", 0, totalRead),
|
|
8484
|
+
bytesRead: totalRead,
|
|
8485
|
+
bytesTotal: size
|
|
8486
|
+
};
|
|
8487
|
+
} finally {
|
|
8488
|
+
await fh.close();
|
|
8473
8489
|
}
|
|
8474
|
-
return {
|
|
8475
|
-
content: buffer.toString("utf8", 0, totalRead),
|
|
8476
|
-
bytesRead: totalRead,
|
|
8477
|
-
bytesTotal: size
|
|
8478
|
-
};
|
|
8479
8490
|
}
|
|
8480
8491
|
async function tailFile(path2, maxBytes) {
|
|
8481
|
-
|
|
8482
|
-
|
|
8483
|
-
|
|
8484
|
-
|
|
8485
|
-
|
|
8486
|
-
|
|
8487
|
-
|
|
8488
|
-
|
|
8489
|
-
|
|
8490
|
-
|
|
8491
|
-
|
|
8492
|
-
|
|
8493
|
-
|
|
8492
|
+
const fh = await open(path2, "r");
|
|
8493
|
+
try {
|
|
8494
|
+
const size = (await fh.stat()).size;
|
|
8495
|
+
if (size === 0) {
|
|
8496
|
+
return { content: "", bytesRead: 0, bytesTotal: 0 };
|
|
8497
|
+
}
|
|
8498
|
+
const offset = Math.max(0, size - maxBytes);
|
|
8499
|
+
const bytesToRead = size - offset;
|
|
8500
|
+
const buffer = Buffer.allocUnsafe(bytesToRead);
|
|
8501
|
+
let totalRead = 0;
|
|
8502
|
+
while (totalRead < bytesToRead) {
|
|
8503
|
+
const { bytesRead } = await fh.read(buffer, totalRead, bytesToRead - totalRead, offset + totalRead);
|
|
8504
|
+
if (bytesRead === 0) {
|
|
8505
|
+
break;
|
|
8506
|
+
}
|
|
8507
|
+
totalRead += bytesRead;
|
|
8494
8508
|
}
|
|
8495
|
-
|
|
8509
|
+
return {
|
|
8510
|
+
content: buffer.toString("utf8", 0, totalRead),
|
|
8511
|
+
bytesRead: totalRead,
|
|
8512
|
+
bytesTotal: size
|
|
8513
|
+
};
|
|
8514
|
+
} finally {
|
|
8515
|
+
await fh.close();
|
|
8496
8516
|
}
|
|
8497
|
-
return {
|
|
8498
|
-
content: buffer.toString("utf8", 0, totalRead),
|
|
8499
|
-
bytesRead: totalRead,
|
|
8500
|
-
bytesTotal: size
|
|
8501
|
-
};
|
|
8502
8517
|
}
|
|
8503
8518
|
async function* readLinesReverse(path2) {
|
|
8504
8519
|
const CHUNK_SIZE = 1024 * 4;
|
|
@@ -8547,8 +8562,7 @@ var init_fsOperations = __esm(() => {
|
|
|
8547
8562
|
return process.cwd();
|
|
8548
8563
|
},
|
|
8549
8564
|
existsSync(fsPath) {
|
|
8550
|
-
|
|
8551
|
-
return fs.existsSync(fsPath);
|
|
8565
|
+
return withSlowOperationLogging(slowLogging`fs.existsSync(${fsPath})`, () => fs.existsSync(fsPath));
|
|
8552
8566
|
},
|
|
8553
8567
|
async stat(fsPath) {
|
|
8554
8568
|
return statPromise(fsPath);
|
|
@@ -8580,115 +8594,104 @@ var init_fsOperations = __esm(() => {
|
|
|
8580
8594
|
return renamePromise(oldPath, newPath);
|
|
8581
8595
|
},
|
|
8582
8596
|
statSync(fsPath) {
|
|
8583
|
-
|
|
8584
|
-
return fs.statSync(fsPath);
|
|
8597
|
+
return withSlowOperationLogging(slowLogging`fs.statSync(${fsPath})`, () => fs.statSync(fsPath));
|
|
8585
8598
|
},
|
|
8586
8599
|
lstatSync(fsPath) {
|
|
8587
|
-
|
|
8588
|
-
return fs.lstatSync(fsPath);
|
|
8600
|
+
return withSlowOperationLogging(slowLogging`fs.lstatSync(${fsPath})`, () => fs.lstatSync(fsPath));
|
|
8589
8601
|
},
|
|
8590
8602
|
readFileSync(fsPath, options) {
|
|
8591
|
-
|
|
8592
|
-
return fs.readFileSync(fsPath, { encoding: options.encoding });
|
|
8603
|
+
return withSlowOperationLogging(slowLogging`fs.readFileSync(${fsPath})`, () => fs.readFileSync(fsPath, { encoding: options.encoding }));
|
|
8593
8604
|
},
|
|
8594
8605
|
readFileBytesSync(fsPath) {
|
|
8595
|
-
|
|
8596
|
-
return fs.readFileSync(fsPath);
|
|
8606
|
+
return withSlowOperationLogging(slowLogging`fs.readFileBytesSync(${fsPath})`, () => fs.readFileSync(fsPath));
|
|
8597
8607
|
},
|
|
8598
8608
|
readSync(fsPath, options) {
|
|
8599
|
-
|
|
8600
|
-
|
|
8601
|
-
|
|
8602
|
-
|
|
8603
|
-
|
|
8604
|
-
|
|
8605
|
-
|
|
8606
|
-
|
|
8607
|
-
|
|
8608
|
-
|
|
8609
|
-
|
|
8609
|
+
return withSlowOperationLogging(slowLogging`fs.readSync(${fsPath}, ${options.length} bytes)`, () => {
|
|
8610
|
+
let fd = undefined;
|
|
8611
|
+
try {
|
|
8612
|
+
fd = fs.openSync(fsPath, "r");
|
|
8613
|
+
const buffer = Buffer.alloc(options.length);
|
|
8614
|
+
const bytesRead = fs.readSync(fd, buffer, 0, options.length, 0);
|
|
8615
|
+
return { buffer, bytesRead };
|
|
8616
|
+
} finally {
|
|
8617
|
+
if (fd)
|
|
8618
|
+
fs.closeSync(fd);
|
|
8619
|
+
}
|
|
8620
|
+
});
|
|
8610
8621
|
},
|
|
8611
8622
|
appendFileSync(path2, data, options) {
|
|
8612
|
-
|
|
8613
|
-
|
|
8614
|
-
try {
|
|
8615
|
-
const fd = fs.openSync(path2, "ax", options.mode);
|
|
8623
|
+
return withSlowOperationLogging(slowLogging`fs.appendFileSync(${path2}, ${data.length} chars)`, () => {
|
|
8624
|
+
if (options?.mode !== undefined) {
|
|
8616
8625
|
try {
|
|
8617
|
-
fs.
|
|
8618
|
-
|
|
8619
|
-
|
|
8626
|
+
const fd = fs.openSync(path2, "ax", options.mode);
|
|
8627
|
+
try {
|
|
8628
|
+
fs.appendFileSync(fd, data);
|
|
8629
|
+
} finally {
|
|
8630
|
+
fs.closeSync(fd);
|
|
8631
|
+
}
|
|
8632
|
+
return;
|
|
8633
|
+
} catch (e) {
|
|
8634
|
+
if (getErrnoCode(e) !== "EEXIST")
|
|
8635
|
+
throw e;
|
|
8620
8636
|
}
|
|
8621
|
-
return;
|
|
8622
|
-
} catch (e) {
|
|
8623
|
-
if (getErrnoCode(e) !== "EEXIST")
|
|
8624
|
-
throw e;
|
|
8625
8637
|
}
|
|
8626
|
-
|
|
8627
|
-
|
|
8638
|
+
fs.appendFileSync(path2, data);
|
|
8639
|
+
});
|
|
8628
8640
|
},
|
|
8629
8641
|
copyFileSync(src, dest) {
|
|
8630
|
-
|
|
8631
|
-
fs.copyFileSync(src, dest);
|
|
8642
|
+
return withSlowOperationLogging(slowLogging`fs.copyFileSync(${src} \u2192 ${dest})`, () => fs.copyFileSync(src, dest));
|
|
8632
8643
|
},
|
|
8633
8644
|
unlinkSync(path2) {
|
|
8634
|
-
|
|
8635
|
-
fs.unlinkSync(path2);
|
|
8645
|
+
return withSlowOperationLogging(slowLogging`fs.unlinkSync(${path2})`, () => fs.unlinkSync(path2));
|
|
8636
8646
|
},
|
|
8637
8647
|
renameSync(oldPath, newPath) {
|
|
8638
|
-
|
|
8639
|
-
fs.renameSync(oldPath, newPath);
|
|
8648
|
+
return withSlowOperationLogging(slowLogging`fs.renameSync(${oldPath} \u2192 ${newPath})`, () => fs.renameSync(oldPath, newPath));
|
|
8640
8649
|
},
|
|
8641
8650
|
linkSync(target, path2) {
|
|
8642
|
-
|
|
8643
|
-
fs.linkSync(target, path2);
|
|
8651
|
+
return withSlowOperationLogging(slowLogging`fs.linkSync(${target} \u2192 ${path2})`, () => fs.linkSync(target, path2));
|
|
8644
8652
|
},
|
|
8645
8653
|
symlinkSync(target, path2, type) {
|
|
8646
|
-
|
|
8647
|
-
fs.symlinkSync(target, path2, type);
|
|
8654
|
+
return withSlowOperationLogging(slowLogging`fs.symlinkSync(${target} \u2192 ${path2})`, () => fs.symlinkSync(target, path2, type));
|
|
8648
8655
|
},
|
|
8649
8656
|
readlinkSync(path2) {
|
|
8650
|
-
|
|
8651
|
-
return fs.readlinkSync(path2);
|
|
8657
|
+
return withSlowOperationLogging(slowLogging`fs.readlinkSync(${path2})`, () => fs.readlinkSync(path2));
|
|
8652
8658
|
},
|
|
8653
8659
|
realpathSync(path2) {
|
|
8654
|
-
|
|
8655
|
-
return fs.realpathSync(path2).normalize("NFC");
|
|
8660
|
+
return withSlowOperationLogging(slowLogging`fs.realpathSync(${path2})`, () => fs.realpathSync(path2).normalize("NFC"));
|
|
8656
8661
|
},
|
|
8657
8662
|
mkdirSync(dirPath, options) {
|
|
8658
|
-
|
|
8659
|
-
|
|
8660
|
-
|
|
8661
|
-
|
|
8662
|
-
|
|
8663
|
-
|
|
8664
|
-
|
|
8665
|
-
|
|
8666
|
-
|
|
8667
|
-
|
|
8668
|
-
|
|
8669
|
-
|
|
8670
|
-
|
|
8663
|
+
return withSlowOperationLogging(slowLogging`fs.mkdirSync(${dirPath})`, () => {
|
|
8664
|
+
const mkdirOptions = {
|
|
8665
|
+
recursive: true
|
|
8666
|
+
};
|
|
8667
|
+
if (options?.mode !== undefined) {
|
|
8668
|
+
mkdirOptions.mode = options.mode;
|
|
8669
|
+
}
|
|
8670
|
+
try {
|
|
8671
|
+
fs.mkdirSync(dirPath, mkdirOptions);
|
|
8672
|
+
} catch (e) {
|
|
8673
|
+
if (getErrnoCode(e) !== "EEXIST")
|
|
8674
|
+
throw e;
|
|
8675
|
+
}
|
|
8676
|
+
});
|
|
8671
8677
|
},
|
|
8672
8678
|
readdirSync(dirPath) {
|
|
8673
|
-
|
|
8674
|
-
return fs.readdirSync(dirPath, { withFileTypes: true });
|
|
8679
|
+
return withSlowOperationLogging(slowLogging`fs.readdirSync(${dirPath})`, () => fs.readdirSync(dirPath, { withFileTypes: true }));
|
|
8675
8680
|
},
|
|
8676
8681
|
readdirStringSync(dirPath) {
|
|
8677
|
-
|
|
8678
|
-
return fs.readdirSync(dirPath);
|
|
8682
|
+
return withSlowOperationLogging(slowLogging`fs.readdirStringSync(${dirPath})`, () => fs.readdirSync(dirPath));
|
|
8679
8683
|
},
|
|
8680
8684
|
isDirEmptySync(dirPath) {
|
|
8681
|
-
|
|
8682
|
-
|
|
8683
|
-
|
|
8685
|
+
return withSlowOperationLogging(slowLogging`fs.isDirEmptySync(${dirPath})`, () => {
|
|
8686
|
+
const files = this.readdirSync(dirPath);
|
|
8687
|
+
return files.length === 0;
|
|
8688
|
+
});
|
|
8684
8689
|
},
|
|
8685
8690
|
rmdirSync(dirPath) {
|
|
8686
|
-
|
|
8687
|
-
fs.rmdirSync(dirPath);
|
|
8691
|
+
return withSlowOperationLogging(slowLogging`fs.rmdirSync(${dirPath})`, () => fs.rmdirSync(dirPath));
|
|
8688
8692
|
},
|
|
8689
8693
|
rmSync(path2, options) {
|
|
8690
|
-
|
|
8691
|
-
fs.rmSync(path2, options);
|
|
8694
|
+
return withSlowOperationLogging(slowLogging`fs.rmSync(${path2})`, () => fs.rmSync(path2, options));
|
|
8692
8695
|
},
|
|
8693
8696
|
createWriteStream(path2) {
|
|
8694
8697
|
return fs.createWriteStream(path2);
|
|
@@ -30703,8 +30706,7 @@ import {
|
|
|
30703
30706
|
execSync as nodeExecSync
|
|
30704
30707
|
} from "child_process";
|
|
30705
30708
|
function execSync_DEPRECATED(command, options) {
|
|
30706
|
-
|
|
30707
|
-
return nodeExecSync(command, options);
|
|
30709
|
+
return withSlowOperationLogging(slowLogging`execSync: ${command.slice(0, 100)}`, () => nodeExecSync(command, options));
|
|
30708
30710
|
}
|
|
30709
30711
|
var init_execSyncWrapper = __esm(() => {
|
|
30710
30712
|
init_slowOperations();
|
|
@@ -32282,25 +32284,26 @@ function execSyncWithDefaults_DEPRECATED(command, optionsOrAbortSignal, timeout
|
|
|
32282
32284
|
stdio = ["ignore", "pipe", "pipe"]
|
|
32283
32285
|
} = options;
|
|
32284
32286
|
abortSignal?.throwIfAborted();
|
|
32285
|
-
|
|
32286
|
-
|
|
32287
|
-
|
|
32288
|
-
|
|
32289
|
-
|
|
32290
|
-
|
|
32291
|
-
|
|
32292
|
-
|
|
32293
|
-
|
|
32294
|
-
|
|
32295
|
-
|
|
32296
|
-
|
|
32297
|
-
|
|
32287
|
+
return withSlowOperationLogging(slowLogging`exec: ${command.slice(0, 200)}`, () => {
|
|
32288
|
+
try {
|
|
32289
|
+
const result = execaSync(command, {
|
|
32290
|
+
env: process.env,
|
|
32291
|
+
maxBuffer: 1e6,
|
|
32292
|
+
timeout: finalTimeout,
|
|
32293
|
+
cwd: getCwd(),
|
|
32294
|
+
stdio,
|
|
32295
|
+
shell: true,
|
|
32296
|
+
reject: false,
|
|
32297
|
+
input
|
|
32298
|
+
});
|
|
32299
|
+
if (!result.stdout) {
|
|
32300
|
+
return null;
|
|
32301
|
+
}
|
|
32302
|
+
return result.stdout.trim() || null;
|
|
32303
|
+
} catch {
|
|
32298
32304
|
return null;
|
|
32299
32305
|
}
|
|
32300
|
-
|
|
32301
|
-
} catch {
|
|
32302
|
-
return null;
|
|
32303
|
-
}
|
|
32306
|
+
});
|
|
32304
32307
|
}
|
|
32305
32308
|
var MS_IN_SECOND = 1000, SECONDS_IN_MINUTE = 60;
|
|
32306
32309
|
var init_execFileNoThrowPortable = __esm(() => {
|
|
@@ -35293,21 +35296,25 @@ async function readJSONLFile(filePath) {
|
|
|
35293
35296
|
if (size <= MAX_JSONL_READ_BYTES) {
|
|
35294
35297
|
return parseJSONL(await readFile6(filePath));
|
|
35295
35298
|
}
|
|
35296
|
-
|
|
35297
|
-
|
|
35298
|
-
|
|
35299
|
-
|
|
35300
|
-
|
|
35301
|
-
|
|
35302
|
-
|
|
35303
|
-
|
|
35304
|
-
|
|
35305
|
-
|
|
35306
|
-
|
|
35307
|
-
|
|
35308
|
-
|
|
35299
|
+
const fd = await open3(filePath, "r");
|
|
35300
|
+
try {
|
|
35301
|
+
const buf = Buffer.allocUnsafe(MAX_JSONL_READ_BYTES);
|
|
35302
|
+
let totalRead = 0;
|
|
35303
|
+
const fileOffset = size - MAX_JSONL_READ_BYTES;
|
|
35304
|
+
while (totalRead < MAX_JSONL_READ_BYTES) {
|
|
35305
|
+
const { bytesRead } = await fd.read(buf, totalRead, MAX_JSONL_READ_BYTES - totalRead, fileOffset + totalRead);
|
|
35306
|
+
if (bytesRead === 0)
|
|
35307
|
+
break;
|
|
35308
|
+
totalRead += bytesRead;
|
|
35309
|
+
}
|
|
35310
|
+
const newlineIndex = buf.indexOf(10);
|
|
35311
|
+
if (newlineIndex !== -1 && newlineIndex < totalRead - 1) {
|
|
35312
|
+
return parseJSONL(buf.subarray(newlineIndex + 1, totalRead));
|
|
35313
|
+
}
|
|
35314
|
+
return parseJSONL(buf.subarray(0, totalRead));
|
|
35315
|
+
} finally {
|
|
35316
|
+
await fd.close();
|
|
35309
35317
|
}
|
|
35310
|
-
return parseJSONL(buf.subarray(0, totalRead));
|
|
35311
35318
|
}
|
|
35312
35319
|
function addItemToJSONCArray(content, newItem) {
|
|
35313
35320
|
try {
|
|
@@ -93307,7 +93314,7 @@ var init_system = __esm(() => {
|
|
|
93307
93314
|
AGENT_SDK_CLAUDE_CODE_PRESET_PREFIX,
|
|
93308
93315
|
AGENT_SDK_PREFIX
|
|
93309
93316
|
];
|
|
93310
|
-
AGENT_OS_VERSION = typeof MACRO !== "undefined" ? "1.0.0-alpha.
|
|
93317
|
+
AGENT_OS_VERSION = typeof MACRO !== "undefined" ? "1.0.0-alpha.23" : "dev";
|
|
93311
93318
|
CLI_SYSPROMPT_PREFIXES = new Set(CLI_SYSPROMPT_PREFIX_VALUES);
|
|
93312
93319
|
});
|
|
93313
93320
|
|
|
@@ -93751,7 +93758,7 @@ function getClaudeCodeUserAgent() {
|
|
|
93751
93758
|
}
|
|
93752
93759
|
var AGENT_OS_VERSION2;
|
|
93753
93760
|
var init_userAgent = __esm(() => {
|
|
93754
|
-
AGENT_OS_VERSION2 = typeof MACRO !== "undefined" ? "1.0.0-alpha.
|
|
93761
|
+
AGENT_OS_VERSION2 = typeof MACRO !== "undefined" ? "1.0.0-alpha.23" : "dev";
|
|
93755
93762
|
});
|
|
93756
93763
|
|
|
93757
93764
|
// src/utils/http.ts
|
|
@@ -93832,7 +93839,7 @@ var init_http2 = __esm(() => {
|
|
|
93832
93839
|
init_auth();
|
|
93833
93840
|
init_userAgent();
|
|
93834
93841
|
init_workloadContext();
|
|
93835
|
-
AGENT_OS_VERSION3 = typeof MACRO !== "undefined" ? "1.0.0-alpha.
|
|
93842
|
+
AGENT_OS_VERSION3 = typeof MACRO !== "undefined" ? "1.0.0-alpha.23" : "dev";
|
|
93836
93843
|
});
|
|
93837
93844
|
|
|
93838
93845
|
// src/services/api/router/userProviders.ts
|
|
@@ -207168,7 +207175,7 @@ var init_sessionStorage = __esm(() => {
|
|
|
207168
207175
|
init_settings2();
|
|
207169
207176
|
init_slowOperations();
|
|
207170
207177
|
init_uuid();
|
|
207171
|
-
VERSION4 = typeof MACRO !== "undefined" ? "1.0.0-alpha.
|
|
207178
|
+
VERSION4 = typeof MACRO !== "undefined" ? "1.0.0-alpha.23" : "unknown";
|
|
207172
207179
|
MAX_TOMBSTONE_REWRITE_BYTES = 50 * 1024 * 1024;
|
|
207173
207180
|
SKIP_FIRST_PROMPT_PATTERN = /^(?:\s*<[a-z][\w-]*[\s>]|\[Request interrupted by user[^\]]*\])/;
|
|
207174
207181
|
EPHEMERAL_PROGRESS_TYPES = new Set([
|
|
@@ -207298,7 +207305,7 @@ function Feedback({
|
|
|
207298
207305
|
platform: env3.platform,
|
|
207299
207306
|
gitRepo: envInfo.isGit,
|
|
207300
207307
|
terminal: env3.terminal,
|
|
207301
|
-
version: "1.0.0-alpha.
|
|
207308
|
+
version: "1.0.0-alpha.23",
|
|
207302
207309
|
transcript: normalizeMessagesForAPI(messages),
|
|
207303
207310
|
errors: sanitizedErrors,
|
|
207304
207311
|
lastApiRequest: getLastAPIRequest(),
|
|
@@ -207482,7 +207489,7 @@ function Feedback({
|
|
|
207482
207489
|
", ",
|
|
207483
207490
|
env3.terminal,
|
|
207484
207491
|
", v",
|
|
207485
|
-
"1.0.0-alpha.
|
|
207492
|
+
"1.0.0-alpha.23"
|
|
207486
207493
|
]
|
|
207487
207494
|
})
|
|
207488
207495
|
]
|
|
@@ -207588,7 +207595,7 @@ ${sanitizedDescription}
|
|
|
207588
207595
|
` + `**Environment Info**
|
|
207589
207596
|
` + `- Platform: ${env3.platform}
|
|
207590
207597
|
` + `- Terminal: ${env3.terminal}
|
|
207591
|
-
` + `- Version: ${"1.0.0-alpha.
|
|
207598
|
+
` + `- Version: ${"1.0.0-alpha.23"}
|
|
207592
207599
|
` + `- Feedback ID: ${feedbackId}
|
|
207593
207600
|
` + `
|
|
207594
207601
|
**Errors**
|
|
@@ -259973,8 +259980,8 @@ var init_toolAnalytics = __esm(() => {
|
|
|
259973
259980
|
init_agentContext();
|
|
259974
259981
|
init_slowOperations();
|
|
259975
259982
|
init_teammate();
|
|
259976
|
-
AGENT_OS_VERSION4 = typeof MACRO !== "undefined" ? "1.0.0-alpha.
|
|
259977
|
-
AGENT_OS_BUILD_TIME = typeof MACRO !== "undefined" ? "2026-05-
|
|
259983
|
+
AGENT_OS_VERSION4 = typeof MACRO !== "undefined" ? "1.0.0-alpha.23" : "dev";
|
|
259984
|
+
AGENT_OS_BUILD_TIME = typeof MACRO !== "undefined" ? "2026-05-21T08:38:17Z" : undefined;
|
|
259978
259985
|
BUILTIN_MCP_SERVER_NAMES = new Set([]);
|
|
259979
259986
|
TOOL_INPUT_MAX_JSON_CHARS = 4 * 1024;
|
|
259980
259987
|
FILE_COMMANDS = new Set([
|
|
@@ -274620,7 +274627,7 @@ function getInstallationEnv() {
|
|
|
274620
274627
|
return;
|
|
274621
274628
|
}
|
|
274622
274629
|
function getClaudeCodeVersion() {
|
|
274623
|
-
return "1.0.0-alpha.
|
|
274630
|
+
return "1.0.0-alpha.23";
|
|
274624
274631
|
}
|
|
274625
274632
|
async function getInstalledVSCodeExtensionVersion(command) {
|
|
274626
274633
|
const { stdout } = await execFileNoThrow(command, ["--list-extensions", "--show-versions"], {
|
|
@@ -297338,7 +297345,7 @@ async function setupSdkMcpClients(sdkMcpConfigs, sendMcpMessage) {
|
|
|
297338
297345
|
const client = new Client({
|
|
297339
297346
|
name: "claude-code",
|
|
297340
297347
|
title: "Agent-OS",
|
|
297341
|
-
version: "1.0.0-alpha.
|
|
297348
|
+
version: "1.0.0-alpha.23",
|
|
297342
297349
|
description: "Anthropic's agentic coding tool",
|
|
297343
297350
|
websiteUrl: PRODUCT_URL
|
|
297344
297351
|
}, {
|
|
@@ -297691,7 +297698,7 @@ var init_client4 = __esm(() => {
|
|
|
297691
297698
|
const client = new Client({
|
|
297692
297699
|
name: "claude-code",
|
|
297693
297700
|
title: "Agent-OS",
|
|
297694
|
-
version: "1.0.0-alpha.
|
|
297701
|
+
version: "1.0.0-alpha.23",
|
|
297695
297702
|
description: "Anthropic's agentic coding tool",
|
|
297696
297703
|
websiteUrl: PRODUCT_URL
|
|
297697
297704
|
}, {
|
|
@@ -416336,7 +416343,7 @@ function getInvokedBinary() {
|
|
|
416336
416343
|
async function getDoctorDiagnostic() {
|
|
416337
416344
|
return {
|
|
416338
416345
|
installationType: "package-manager",
|
|
416339
|
-
version: "1.0.0-alpha.
|
|
416346
|
+
version: "1.0.0-alpha.23",
|
|
416340
416347
|
installationPath: process.argv[1] ?? "",
|
|
416341
416348
|
invokedBinary: getInvokedBinary(),
|
|
416342
416349
|
configInstallMethod: "not set",
|
|
@@ -416741,7 +416748,7 @@ function buildPrimarySection() {
|
|
|
416741
416748
|
});
|
|
416742
416749
|
return [{
|
|
416743
416750
|
label: "Version",
|
|
416744
|
-
value: "1.0.0-alpha.
|
|
416751
|
+
value: "1.0.0-alpha.23"
|
|
416745
416752
|
}, {
|
|
416746
416753
|
label: "Session name",
|
|
416747
416754
|
value: nameValue
|
|
@@ -420384,7 +420391,7 @@ function Config({
|
|
|
420384
420391
|
}
|
|
420385
420392
|
})
|
|
420386
420393
|
}) : showSubmenu === "ChannelDowngrade" ? /* @__PURE__ */ jsx_runtime169.jsx(ChannelDowngradeDialog, {
|
|
420387
|
-
currentVersion: "1.0.0-alpha.
|
|
420394
|
+
currentVersion: "1.0.0-alpha.23",
|
|
420388
420395
|
onChoice: (choice) => {
|
|
420389
420396
|
setShowSubmenu(null);
|
|
420390
420397
|
setTabsHidden(false);
|
|
@@ -420396,7 +420403,7 @@ function Config({
|
|
|
420396
420403
|
autoUpdatesChannel: "stable"
|
|
420397
420404
|
};
|
|
420398
420405
|
if (choice === "stay") {
|
|
420399
|
-
newSettings.minimumVersion = "1.0.0-alpha.
|
|
420406
|
+
newSettings.minimumVersion = "1.0.0-alpha.23";
|
|
420400
420407
|
}
|
|
420401
420408
|
updateSettingsForSource("userSettings", newSettings);
|
|
420402
420409
|
setSettingsData((prev_27) => ({
|
|
@@ -428387,7 +428394,7 @@ function HelpV2(t0) {
|
|
|
428387
428394
|
let t6;
|
|
428388
428395
|
if ($3[31] !== tabs) {
|
|
428389
428396
|
t6 = /* @__PURE__ */ jsx_runtime195.jsx(Tabs, {
|
|
428390
|
-
title: `Agent-OS v${"1.0.0-alpha.
|
|
428397
|
+
title: `Agent-OS v${"1.0.0-alpha.23"}`,
|
|
428391
428398
|
color: "professionalBlue",
|
|
428392
428399
|
defaultTab: "general",
|
|
428393
428400
|
children: tabs
|
|
@@ -431515,7 +431522,7 @@ var init_user = __esm(() => {
|
|
|
431515
431522
|
deviceId,
|
|
431516
431523
|
sessionId: getSessionId(),
|
|
431517
431524
|
email: getEmail(),
|
|
431518
|
-
appVersion: "1.0.0-alpha.
|
|
431525
|
+
appVersion: "1.0.0-alpha.23",
|
|
431519
431526
|
platform: getHostPlatformForAnalytics(),
|
|
431520
431527
|
organizationUuid,
|
|
431521
431528
|
accountUuid,
|
|
@@ -451766,7 +451773,7 @@ function getAllReleaseNotes(changelogContent = getStoredChangelogFromMemory()) {
|
|
|
451766
451773
|
return [];
|
|
451767
451774
|
}
|
|
451768
451775
|
}
|
|
451769
|
-
async function checkForReleaseNotes(lastSeenVersion, currentVersion = "1.0.0-alpha.
|
|
451776
|
+
async function checkForReleaseNotes(lastSeenVersion, currentVersion = "1.0.0-alpha.23") {
|
|
451770
451777
|
if (process.env.USER_TYPE === "ant") {
|
|
451771
451778
|
const changelog = "";
|
|
451772
451779
|
if (changelog) {
|
|
@@ -451793,7 +451800,7 @@ async function checkForReleaseNotes(lastSeenVersion, currentVersion = "1.0.0-alp
|
|
|
451793
451800
|
releaseNotes
|
|
451794
451801
|
};
|
|
451795
451802
|
}
|
|
451796
|
-
function checkForReleaseNotesSync(lastSeenVersion, currentVersion = "1.0.0-alpha.
|
|
451803
|
+
function checkForReleaseNotesSync(lastSeenVersion, currentVersion = "1.0.0-alpha.23") {
|
|
451797
451804
|
if (process.env.USER_TYPE === "ant") {
|
|
451798
451805
|
const changelog = "";
|
|
451799
451806
|
if (changelog) {
|
|
@@ -452920,7 +452927,7 @@ function getRecentActivitySync() {
|
|
|
452920
452927
|
return cachedActivity;
|
|
452921
452928
|
}
|
|
452922
452929
|
function getLogoDisplayData() {
|
|
452923
|
-
const version2 = process.env.DEMO_VERSION ?? "1.0.0-alpha.
|
|
452930
|
+
const version2 = process.env.DEMO_VERSION ?? "1.0.0-alpha.23";
|
|
452924
452931
|
const serverUrl = getDirectConnectServerUrl();
|
|
452925
452932
|
const displayPath = process.env.DEMO_VERSION ? "/code/claude" : getDisplayPath(getCwd());
|
|
452926
452933
|
const cwd2 = serverUrl ? `${displayPath} in ${serverUrl.replace(/^https?:\/\//, "")}` : displayPath;
|
|
@@ -454135,7 +454142,7 @@ function LogoV2() {
|
|
|
454135
454142
|
if ($3[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
454136
454143
|
t2 = () => {
|
|
454137
454144
|
const currentConfig = getGlobalConfig();
|
|
454138
|
-
if (currentConfig.lastReleaseNotesSeen === "1.0.0-alpha.
|
|
454145
|
+
if (currentConfig.lastReleaseNotesSeen === "1.0.0-alpha.23") {
|
|
454139
454146
|
return;
|
|
454140
454147
|
}
|
|
454141
454148
|
saveGlobalConfig(_temp328);
|
|
@@ -454801,12 +454808,12 @@ function AgentOsPoster() {
|
|
|
454801
454808
|
});
|
|
454802
454809
|
}
|
|
454803
454810
|
function _temp328(current) {
|
|
454804
|
-
if (current.lastReleaseNotesSeen === "1.0.0-alpha.
|
|
454811
|
+
if (current.lastReleaseNotesSeen === "1.0.0-alpha.23") {
|
|
454805
454812
|
return current;
|
|
454806
454813
|
}
|
|
454807
454814
|
return {
|
|
454808
454815
|
...current,
|
|
454809
|
-
lastReleaseNotesSeen: "1.0.0-alpha.
|
|
454816
|
+
lastReleaseNotesSeen: "1.0.0-alpha.23"
|
|
454810
454817
|
};
|
|
454811
454818
|
}
|
|
454812
454819
|
function _temp245(s_0) {
|
|
@@ -481383,7 +481390,7 @@ async function captureMemoryDiagnostics(trigger, dumpNumber = 0) {
|
|
|
481383
481390
|
smapsRollup,
|
|
481384
481391
|
platform: process.platform,
|
|
481385
481392
|
nodeVersion: process.version,
|
|
481386
|
-
ccVersion: "1.0.0-alpha.
|
|
481393
|
+
ccVersion: "1.0.0-alpha.23"
|
|
481387
481394
|
};
|
|
481388
481395
|
}
|
|
481389
481396
|
async function performHeapDump(trigger = "manual", dumpNumber = 0) {
|
|
@@ -481956,7 +481963,7 @@ var init_bridge_kick = __esm(() => {
|
|
|
481956
481963
|
var call58 = async () => {
|
|
481957
481964
|
return {
|
|
481958
481965
|
type: "text",
|
|
481959
|
-
value: `${"1.0.0-alpha.
|
|
481966
|
+
value: `${"1.0.0-alpha.23"} (built ${"2026-05-21T08:38:17Z"})`
|
|
481960
481967
|
};
|
|
481961
481968
|
}, version2, version_default;
|
|
481962
481969
|
var init_version = __esm(() => {
|
|
@@ -491448,7 +491455,7 @@ function generateHtmlReport(data, insights) {
|
|
|
491448
491455
|
</html>`;
|
|
491449
491456
|
}
|
|
491450
491457
|
function buildExportData(data, insights, facets, remoteStats) {
|
|
491451
|
-
const version3 = typeof MACRO !== "undefined" ? "1.0.0-alpha.
|
|
491458
|
+
const version3 = typeof MACRO !== "undefined" ? "1.0.0-alpha.23" : "unknown";
|
|
491452
491459
|
const remote_hosts_collected = remoteStats?.hosts.filter((h3) => h3.sessionCount > 0).map((h3) => h3.name);
|
|
491453
491460
|
const facets_summary = {
|
|
491454
491461
|
total: facets.size,
|
|
@@ -497817,653 +497824,657 @@ async function* queryLoop(params, consumedCommandUuids) {
|
|
|
497817
497824
|
const budgetTracker = null;
|
|
497818
497825
|
let taskBudgetRemaining = undefined;
|
|
497819
497826
|
const config4 = buildQueryConfig();
|
|
497820
|
-
|
|
497821
|
-
|
|
497822
|
-
|
|
497823
|
-
|
|
497824
|
-
messages,
|
|
497825
|
-
autoCompactTracking,
|
|
497826
|
-
maxOutputTokensRecoveryCount,
|
|
497827
|
-
hasAttemptedReactiveCompact,
|
|
497828
|
-
maxOutputTokensOverride,
|
|
497829
|
-
pendingToolUseSummary,
|
|
497830
|
-
stopHookActive,
|
|
497831
|
-
turnCount
|
|
497832
|
-
} = state;
|
|
497833
|
-
const pendingSkillPrefetch = skillPrefetch?.startSkillDiscoveryPrefetch(null, messages, toolUseContext);
|
|
497834
|
-
yield { type: "stream_request_start" };
|
|
497835
|
-
queryCheckpoint("query_fn_entry");
|
|
497836
|
-
if (!toolUseContext.agentId) {
|
|
497837
|
-
headlessProfilerCheckpoint("query_started");
|
|
497838
|
-
}
|
|
497839
|
-
const queryTracking = toolUseContext.queryTracking ? {
|
|
497840
|
-
chainId: toolUseContext.queryTracking.chainId,
|
|
497841
|
-
depth: toolUseContext.queryTracking.depth + 1
|
|
497842
|
-
} : {
|
|
497843
|
-
chainId: deps.uuid(),
|
|
497844
|
-
depth: 0
|
|
497845
|
-
};
|
|
497846
|
-
const queryChainIdForAnalytics = queryTracking.chainId;
|
|
497847
|
-
toolUseContext = {
|
|
497848
|
-
...toolUseContext,
|
|
497849
|
-
queryTracking
|
|
497850
|
-
};
|
|
497851
|
-
let messagesForQuery = [...getMessagesAfterCompactBoundary(messages)];
|
|
497852
|
-
let tracking = autoCompactTracking;
|
|
497853
|
-
const persistReplacements = querySource.startsWith("agent:") || querySource.startsWith("repl_main_thread");
|
|
497854
|
-
messagesForQuery = await applyToolResultBudget(messagesForQuery, toolUseContext.contentReplacementState, persistReplacements ? (records) => void recordContentReplacement(records, toolUseContext.agentId).catch(logError2) : undefined, new Set(toolUseContext.options.tools.filter((t2) => !Number.isFinite(t2.maxResultSizeChars)).map((t2) => t2.name)));
|
|
497855
|
-
let snipTokensFreed = 0;
|
|
497856
|
-
if (false) {}
|
|
497857
|
-
queryCheckpoint("query_microcompact_start");
|
|
497858
|
-
const microcompactResult = await deps.microcompact(messagesForQuery, toolUseContext, querySource);
|
|
497859
|
-
messagesForQuery = microcompactResult.messages;
|
|
497860
|
-
const pendingCacheEdits2 = undefined;
|
|
497861
|
-
queryCheckpoint("query_microcompact_end");
|
|
497862
|
-
if (false) {}
|
|
497863
|
-
const fullSystemPrompt = asSystemPrompt(appendSystemContext(systemPrompt, systemContext));
|
|
497864
|
-
queryCheckpoint("query_autocompact_start");
|
|
497865
|
-
const { compactionResult, consecutiveFailures } = await deps.autocompact(messagesForQuery, toolUseContext, {
|
|
497866
|
-
systemPrompt,
|
|
497867
|
-
userContext,
|
|
497868
|
-
systemContext,
|
|
497869
|
-
toolUseContext,
|
|
497870
|
-
forkContextMessages: messagesForQuery
|
|
497871
|
-
}, querySource, tracking, snipTokensFreed);
|
|
497872
|
-
queryCheckpoint("query_autocompact_end");
|
|
497873
|
-
if (compactionResult) {
|
|
497827
|
+
const pendingMemoryPrefetch = startRelevantMemoryPrefetch(state.messages, state.toolUseContext);
|
|
497828
|
+
try {
|
|
497829
|
+
while (true) {
|
|
497830
|
+
let { toolUseContext } = state;
|
|
497874
497831
|
const {
|
|
497875
|
-
|
|
497876
|
-
|
|
497877
|
-
|
|
497878
|
-
|
|
497879
|
-
|
|
497880
|
-
|
|
497881
|
-
|
|
497882
|
-
|
|
497883
|
-
}
|
|
497884
|
-
|
|
497885
|
-
|
|
497886
|
-
|
|
497887
|
-
|
|
497888
|
-
|
|
497889
|
-
}
|
|
497890
|
-
const
|
|
497891
|
-
|
|
497892
|
-
|
|
497893
|
-
}
|
|
497894
|
-
|
|
497895
|
-
|
|
497896
|
-
tracking = {
|
|
497897
|
-
...tracking ?? { compacted: false, turnId: "", turnCounter: 0 },
|
|
497898
|
-
consecutiveFailures
|
|
497832
|
+
messages,
|
|
497833
|
+
autoCompactTracking,
|
|
497834
|
+
maxOutputTokensRecoveryCount,
|
|
497835
|
+
hasAttemptedReactiveCompact,
|
|
497836
|
+
maxOutputTokensOverride,
|
|
497837
|
+
pendingToolUseSummary,
|
|
497838
|
+
stopHookActive,
|
|
497839
|
+
turnCount
|
|
497840
|
+
} = state;
|
|
497841
|
+
const pendingSkillPrefetch = skillPrefetch?.startSkillDiscoveryPrefetch(null, messages, toolUseContext);
|
|
497842
|
+
yield { type: "stream_request_start" };
|
|
497843
|
+
queryCheckpoint("query_fn_entry");
|
|
497844
|
+
if (!toolUseContext.agentId) {
|
|
497845
|
+
headlessProfilerCheckpoint("query_started");
|
|
497846
|
+
}
|
|
497847
|
+
const queryTracking = toolUseContext.queryTracking ? {
|
|
497848
|
+
chainId: toolUseContext.queryTracking.chainId,
|
|
497849
|
+
depth: toolUseContext.queryTracking.depth + 1
|
|
497850
|
+
} : {
|
|
497851
|
+
chainId: deps.uuid(),
|
|
497852
|
+
depth: 0
|
|
497899
497853
|
};
|
|
497900
|
-
|
|
497901
|
-
|
|
497902
|
-
|
|
497903
|
-
|
|
497904
|
-
|
|
497905
|
-
|
|
497906
|
-
|
|
497907
|
-
|
|
497908
|
-
|
|
497909
|
-
|
|
497910
|
-
|
|
497911
|
-
|
|
497912
|
-
|
|
497913
|
-
|
|
497914
|
-
|
|
497915
|
-
|
|
497916
|
-
|
|
497917
|
-
|
|
497918
|
-
|
|
497919
|
-
|
|
497920
|
-
|
|
497921
|
-
|
|
497922
|
-
|
|
497923
|
-
|
|
497924
|
-
|
|
497925
|
-
|
|
497926
|
-
|
|
497927
|
-
|
|
497928
|
-
|
|
497929
|
-
|
|
497930
|
-
|
|
497931
|
-
|
|
497854
|
+
const queryChainIdForAnalytics = queryTracking.chainId;
|
|
497855
|
+
toolUseContext = {
|
|
497856
|
+
...toolUseContext,
|
|
497857
|
+
queryTracking
|
|
497858
|
+
};
|
|
497859
|
+
let messagesForQuery = [...getMessagesAfterCompactBoundary(messages)];
|
|
497860
|
+
let tracking = autoCompactTracking;
|
|
497861
|
+
const persistReplacements = querySource.startsWith("agent:") || querySource.startsWith("repl_main_thread");
|
|
497862
|
+
messagesForQuery = await applyToolResultBudget(messagesForQuery, toolUseContext.contentReplacementState, persistReplacements ? (records) => void recordContentReplacement(records, toolUseContext.agentId).catch(logError2) : undefined, new Set(toolUseContext.options.tools.filter((t2) => !Number.isFinite(t2.maxResultSizeChars)).map((t2) => t2.name)));
|
|
497863
|
+
let snipTokensFreed = 0;
|
|
497864
|
+
if (false) {}
|
|
497865
|
+
queryCheckpoint("query_microcompact_start");
|
|
497866
|
+
const microcompactResult = await deps.microcompact(messagesForQuery, toolUseContext, querySource);
|
|
497867
|
+
messagesForQuery = microcompactResult.messages;
|
|
497868
|
+
const pendingCacheEdits2 = undefined;
|
|
497869
|
+
queryCheckpoint("query_microcompact_end");
|
|
497870
|
+
if (false) {}
|
|
497871
|
+
const fullSystemPrompt = asSystemPrompt(appendSystemContext(systemPrompt, systemContext));
|
|
497872
|
+
queryCheckpoint("query_autocompact_start");
|
|
497873
|
+
const { compactionResult, consecutiveFailures } = await deps.autocompact(messagesForQuery, toolUseContext, {
|
|
497874
|
+
systemPrompt,
|
|
497875
|
+
userContext,
|
|
497876
|
+
systemContext,
|
|
497877
|
+
toolUseContext,
|
|
497878
|
+
forkContextMessages: messagesForQuery
|
|
497879
|
+
}, querySource, tracking, snipTokensFreed);
|
|
497880
|
+
queryCheckpoint("query_autocompact_end");
|
|
497881
|
+
if (compactionResult) {
|
|
497882
|
+
const {
|
|
497883
|
+
preCompactTokenCount,
|
|
497884
|
+
postCompactTokenCount,
|
|
497885
|
+
truePostCompactTokenCount,
|
|
497886
|
+
compactionUsage
|
|
497887
|
+
} = compactionResult;
|
|
497888
|
+
if (params.taskBudget) {
|
|
497889
|
+
const preCompactContext = finalContextTokensFromLastResponse(messagesForQuery);
|
|
497890
|
+
taskBudgetRemaining = Math.max(0, (taskBudgetRemaining ?? params.taskBudget.total) - preCompactContext);
|
|
497891
|
+
}
|
|
497892
|
+
tracking = {
|
|
497893
|
+
compacted: true,
|
|
497894
|
+
turnId: deps.uuid(),
|
|
497895
|
+
turnCounter: 0,
|
|
497896
|
+
consecutiveFailures: 0
|
|
497897
|
+
};
|
|
497898
|
+
const postCompactMessages = buildPostCompactMessages(compactionResult);
|
|
497899
|
+
for (const message of postCompactMessages) {
|
|
497900
|
+
yield message;
|
|
497901
|
+
}
|
|
497902
|
+
messagesForQuery = postCompactMessages;
|
|
497903
|
+
} else if (consecutiveFailures !== undefined) {
|
|
497904
|
+
tracking = {
|
|
497905
|
+
...tracking ?? { compacted: false, turnId: "", turnCounter: 0 },
|
|
497906
|
+
consecutiveFailures
|
|
497907
|
+
};
|
|
497932
497908
|
}
|
|
497933
|
-
|
|
497934
|
-
|
|
497935
|
-
|
|
497936
|
-
|
|
497937
|
-
|
|
497938
|
-
|
|
497939
|
-
|
|
497940
|
-
|
|
497941
|
-
|
|
497942
|
-
|
|
497943
|
-
|
|
497944
|
-
|
|
497945
|
-
|
|
497946
|
-
|
|
497947
|
-
|
|
497948
|
-
|
|
497949
|
-
|
|
497950
|
-
|
|
497951
|
-
|
|
497952
|
-
|
|
497953
|
-
|
|
497954
|
-
|
|
497955
|
-
|
|
497956
|
-
|
|
497957
|
-
|
|
497958
|
-
|
|
497959
|
-
|
|
497960
|
-
|
|
497961
|
-
|
|
497962
|
-
|
|
497963
|
-
|
|
497964
|
-
|
|
497965
|
-
|
|
497966
|
-
|
|
497967
|
-
|
|
497968
|
-
|
|
497969
|
-
|
|
497970
|
-
|
|
497971
|
-
|
|
497972
|
-
|
|
497973
|
-
|
|
497974
|
-
|
|
497975
|
-
|
|
497976
|
-
|
|
497977
|
-
|
|
497978
|
-
|
|
497979
|
-
|
|
497980
|
-
|
|
497981
|
-
|
|
497982
|
-
|
|
497909
|
+
toolUseContext = {
|
|
497910
|
+
...toolUseContext,
|
|
497911
|
+
messages: messagesForQuery
|
|
497912
|
+
};
|
|
497913
|
+
const assistantMessages = [];
|
|
497914
|
+
const toolResults = [];
|
|
497915
|
+
const toolUseBlocks = [];
|
|
497916
|
+
let needsFollowUp = false;
|
|
497917
|
+
queryCheckpoint("query_setup_start");
|
|
497918
|
+
const useStreamingToolExecution = config4.gates.streamingToolExecution;
|
|
497919
|
+
let streamingToolExecutor = useStreamingToolExecution ? new StreamingToolExecutor(toolUseContext.options.tools, canUseTool, toolUseContext) : null;
|
|
497920
|
+
const appState = toolUseContext.getAppState();
|
|
497921
|
+
const permissionMode = appState.toolPermissionContext.mode;
|
|
497922
|
+
let currentModel = getRuntimeMainLoopModel({
|
|
497923
|
+
permissionMode,
|
|
497924
|
+
mainLoopModel: toolUseContext.options.mainLoopModel,
|
|
497925
|
+
exceeds200kTokens: permissionMode === "plan" && doesMostRecentAssistantMessageExceed200k(messagesForQuery)
|
|
497926
|
+
});
|
|
497927
|
+
queryCheckpoint("query_setup_end");
|
|
497928
|
+
const dumpPromptsFetch = config4.gates.isAnt ? createDumpPromptsFetch(toolUseContext.agentId ?? config4.sessionId) : undefined;
|
|
497929
|
+
let collapseOwnsIt = false;
|
|
497930
|
+
if (false) {}
|
|
497931
|
+
const mediaRecoveryEnabled = reactiveCompact2?.isReactiveCompactEnabled() ?? false;
|
|
497932
|
+
if (!compactionResult && querySource !== "compact" && querySource !== "session_memory" && !(reactiveCompact2?.isReactiveCompactEnabled() && isAutoCompactEnabled()) && !collapseOwnsIt) {
|
|
497933
|
+
const { isAtBlockingLimit } = calculateTokenWarningState(tokenCountWithEstimation(messagesForQuery) - snipTokensFreed, toolUseContext.options.mainLoopModel);
|
|
497934
|
+
if (isAtBlockingLimit) {
|
|
497935
|
+
yield createAssistantAPIErrorMessage({
|
|
497936
|
+
content: PROMPT_TOO_LONG_ERROR_MESSAGE,
|
|
497937
|
+
error: "invalid_request"
|
|
497938
|
+
});
|
|
497939
|
+
return { reason: "blocking_limit" };
|
|
497940
|
+
}
|
|
497941
|
+
}
|
|
497942
|
+
let attemptWithFallback = true;
|
|
497943
|
+
queryCheckpoint("query_api_loop_start");
|
|
497944
|
+
try {
|
|
497945
|
+
while (attemptWithFallback) {
|
|
497946
|
+
attemptWithFallback = false;
|
|
497947
|
+
try {
|
|
497948
|
+
let streamingFallbackOccured = false;
|
|
497949
|
+
queryCheckpoint("query_api_streaming_start");
|
|
497950
|
+
for await (const message of deps.callModel({
|
|
497951
|
+
messages: prependUserContext(messagesForQuery, userContext),
|
|
497952
|
+
systemPrompt: fullSystemPrompt,
|
|
497953
|
+
thinkingConfig: toolUseContext.options.thinkingConfig,
|
|
497954
|
+
tools: toolUseContext.options.tools,
|
|
497955
|
+
signal: toolUseContext.abortController.signal,
|
|
497956
|
+
options: {
|
|
497957
|
+
async getToolPermissionContext() {
|
|
497958
|
+
const appState2 = toolUseContext.getAppState();
|
|
497959
|
+
return appState2.toolPermissionContext;
|
|
497960
|
+
},
|
|
497961
|
+
model: currentModel,
|
|
497962
|
+
...config4.gates.fastModeEnabled && {
|
|
497963
|
+
fastMode: appState.fastMode
|
|
497964
|
+
},
|
|
497965
|
+
toolChoice: undefined,
|
|
497966
|
+
isNonInteractiveSession: toolUseContext.options.isNonInteractiveSession,
|
|
497967
|
+
fallbackModel,
|
|
497968
|
+
onStreamingFallback: () => {
|
|
497969
|
+
streamingFallbackOccured = true;
|
|
497970
|
+
},
|
|
497971
|
+
querySource,
|
|
497972
|
+
agents: toolUseContext.options.agentDefinitions.activeAgents,
|
|
497973
|
+
allowedAgentTypes: toolUseContext.options.agentDefinitions.allowedAgentTypes,
|
|
497974
|
+
hasAppendSystemPrompt: !!toolUseContext.options.appendSystemPrompt,
|
|
497975
|
+
maxOutputTokensOverride,
|
|
497976
|
+
fetchOverride: dumpPromptsFetch,
|
|
497977
|
+
mcpTools: appState.mcp.tools,
|
|
497978
|
+
hasPendingMcpServers: appState.mcp.clients.some((c5) => c5.type === "pending"),
|
|
497979
|
+
queryTracking,
|
|
497980
|
+
effortValue: appState.effortValue,
|
|
497981
|
+
advisorModel: appState.advisorModel,
|
|
497982
|
+
skipCacheWrite,
|
|
497983
|
+
agentId: toolUseContext.agentId,
|
|
497984
|
+
addNotification: toolUseContext.addNotification,
|
|
497985
|
+
routeContext: buildRouteContext(turnCount, querySource, messagesForQuery, toolUseContext.options.maxBudgetUsd),
|
|
497986
|
+
...params.taskBudget && {
|
|
497987
|
+
taskBudget: {
|
|
497988
|
+
total: params.taskBudget.total,
|
|
497989
|
+
...taskBudgetRemaining !== undefined && {
|
|
497990
|
+
remaining: taskBudgetRemaining
|
|
497991
|
+
}
|
|
497983
497992
|
}
|
|
497984
497993
|
}
|
|
497985
497994
|
}
|
|
497986
|
-
}
|
|
497987
|
-
|
|
497988
|
-
|
|
497989
|
-
|
|
497990
|
-
|
|
497991
|
-
|
|
497992
|
-
|
|
497993
|
-
|
|
497994
|
-
|
|
497995
|
-
|
|
497996
|
-
|
|
497997
|
-
|
|
497998
|
-
|
|
497995
|
+
})) {
|
|
497996
|
+
if (streamingFallbackOccured) {
|
|
497997
|
+
for (const msg of assistantMessages) {
|
|
497998
|
+
yield { type: "tombstone", message: msg };
|
|
497999
|
+
}
|
|
498000
|
+
assistantMessages.length = 0;
|
|
498001
|
+
toolResults.length = 0;
|
|
498002
|
+
toolUseBlocks.length = 0;
|
|
498003
|
+
needsFollowUp = false;
|
|
498004
|
+
if (streamingToolExecutor) {
|
|
498005
|
+
streamingToolExecutor.discard();
|
|
498006
|
+
streamingToolExecutor = new StreamingToolExecutor(toolUseContext.options.tools, canUseTool, toolUseContext);
|
|
498007
|
+
}
|
|
497999
498008
|
}
|
|
498000
|
-
|
|
498001
|
-
|
|
498002
|
-
|
|
498003
|
-
|
|
498004
|
-
|
|
498005
|
-
|
|
498006
|
-
|
|
498007
|
-
|
|
498008
|
-
|
|
498009
|
-
|
|
498010
|
-
|
|
498011
|
-
|
|
498012
|
-
|
|
498013
|
-
|
|
498014
|
-
|
|
498015
|
-
|
|
498009
|
+
let yieldMessage = message;
|
|
498010
|
+
if (message.type === "assistant") {
|
|
498011
|
+
let clonedContent;
|
|
498012
|
+
for (let i4 = 0;i4 < message.message.content.length; i4++) {
|
|
498013
|
+
const block2 = message.message.content[i4];
|
|
498014
|
+
if (block2.type === "tool_use" && typeof block2.input === "object" && block2.input !== null) {
|
|
498015
|
+
const tool = findToolByName(toolUseContext.options.tools, block2.name);
|
|
498016
|
+
if (tool?.backfillObservableInput) {
|
|
498017
|
+
const originalInput = block2.input;
|
|
498018
|
+
const inputCopy = { ...originalInput };
|
|
498019
|
+
tool.backfillObservableInput(inputCopy);
|
|
498020
|
+
const addedFields = Object.keys(inputCopy).some((k2) => !(k2 in originalInput));
|
|
498021
|
+
if (addedFields) {
|
|
498022
|
+
clonedContent ??= [...message.message.content];
|
|
498023
|
+
clonedContent[i4] = { ...block2, input: inputCopy };
|
|
498024
|
+
}
|
|
498016
498025
|
}
|
|
498017
498026
|
}
|
|
498018
498027
|
}
|
|
498028
|
+
if (clonedContent) {
|
|
498029
|
+
yieldMessage = {
|
|
498030
|
+
...message,
|
|
498031
|
+
message: { ...message.message, content: clonedContent }
|
|
498032
|
+
};
|
|
498033
|
+
}
|
|
498019
498034
|
}
|
|
498020
|
-
|
|
498021
|
-
|
|
498022
|
-
|
|
498023
|
-
|
|
498024
|
-
};
|
|
498035
|
+
let withheld = false;
|
|
498036
|
+
if (false) {}
|
|
498037
|
+
if (reactiveCompact2?.isWithheldPromptTooLong(message)) {
|
|
498038
|
+
withheld = true;
|
|
498025
498039
|
}
|
|
498026
|
-
|
|
498027
|
-
|
|
498028
|
-
if (false) {}
|
|
498029
|
-
if (reactiveCompact2?.isWithheldPromptTooLong(message)) {
|
|
498030
|
-
withheld = true;
|
|
498031
|
-
}
|
|
498032
|
-
if (mediaRecoveryEnabled && reactiveCompact2?.isWithheldMediaSizeError(message)) {
|
|
498033
|
-
withheld = true;
|
|
498034
|
-
}
|
|
498035
|
-
if (isWithheldMaxOutputTokens(message)) {
|
|
498036
|
-
withheld = true;
|
|
498037
|
-
}
|
|
498038
|
-
if (!withheld) {
|
|
498039
|
-
yield yieldMessage;
|
|
498040
|
-
}
|
|
498041
|
-
if (message.type === "assistant") {
|
|
498042
|
-
assistantMessages.push(message);
|
|
498043
|
-
const msgToolUseBlocks = message.message.content.filter((content) => content.type === "tool_use");
|
|
498044
|
-
if (msgToolUseBlocks.length > 0) {
|
|
498045
|
-
toolUseBlocks.push(...msgToolUseBlocks);
|
|
498046
|
-
needsFollowUp = true;
|
|
498040
|
+
if (mediaRecoveryEnabled && reactiveCompact2?.isWithheldMediaSizeError(message)) {
|
|
498041
|
+
withheld = true;
|
|
498047
498042
|
}
|
|
498048
|
-
if (
|
|
498049
|
-
|
|
498050
|
-
|
|
498043
|
+
if (isWithheldMaxOutputTokens(message)) {
|
|
498044
|
+
withheld = true;
|
|
498045
|
+
}
|
|
498046
|
+
if (!withheld) {
|
|
498047
|
+
yield yieldMessage;
|
|
498048
|
+
}
|
|
498049
|
+
if (message.type === "assistant") {
|
|
498050
|
+
assistantMessages.push(message);
|
|
498051
|
+
const msgToolUseBlocks = message.message.content.filter((content) => content.type === "tool_use");
|
|
498052
|
+
if (msgToolUseBlocks.length > 0) {
|
|
498053
|
+
toolUseBlocks.push(...msgToolUseBlocks);
|
|
498054
|
+
needsFollowUp = true;
|
|
498055
|
+
}
|
|
498056
|
+
if (streamingToolExecutor && !toolUseContext.abortController.signal.aborted) {
|
|
498057
|
+
for (const toolBlock of msgToolUseBlocks) {
|
|
498058
|
+
streamingToolExecutor.addTool(toolBlock, message);
|
|
498059
|
+
}
|
|
498051
498060
|
}
|
|
498052
498061
|
}
|
|
498053
|
-
|
|
498054
|
-
|
|
498055
|
-
|
|
498056
|
-
|
|
498057
|
-
|
|
498058
|
-
|
|
498062
|
+
if (streamingToolExecutor && !toolUseContext.abortController.signal.aborted) {
|
|
498063
|
+
for (const result of streamingToolExecutor.getCompletedResults()) {
|
|
498064
|
+
if (result.message) {
|
|
498065
|
+
yield result.message;
|
|
498066
|
+
toolResults.push(...normalizeMessagesForAPI([result.message], toolUseContext.options.tools).filter((_) => _.type === "user"));
|
|
498067
|
+
}
|
|
498059
498068
|
}
|
|
498060
498069
|
}
|
|
498061
498070
|
}
|
|
498062
|
-
|
|
498063
|
-
|
|
498064
|
-
|
|
498065
|
-
|
|
498066
|
-
|
|
498067
|
-
|
|
498068
|
-
|
|
498069
|
-
|
|
498070
|
-
|
|
498071
|
-
|
|
498072
|
-
|
|
498073
|
-
|
|
498074
|
-
|
|
498075
|
-
|
|
498076
|
-
|
|
498077
|
-
|
|
498078
|
-
|
|
498079
|
-
|
|
498080
|
-
|
|
498071
|
+
queryCheckpoint("query_api_streaming_end");
|
|
498072
|
+
if (false) {}
|
|
498073
|
+
} catch (innerError) {
|
|
498074
|
+
if (innerError instanceof FallbackTriggeredError && fallbackModel) {
|
|
498075
|
+
currentModel = fallbackModel;
|
|
498076
|
+
attemptWithFallback = true;
|
|
498077
|
+
yield* yieldMissingToolResultBlocks(assistantMessages, "Model fallback triggered");
|
|
498078
|
+
assistantMessages.length = 0;
|
|
498079
|
+
toolResults.length = 0;
|
|
498080
|
+
toolUseBlocks.length = 0;
|
|
498081
|
+
needsFollowUp = false;
|
|
498082
|
+
if (streamingToolExecutor) {
|
|
498083
|
+
streamingToolExecutor.discard();
|
|
498084
|
+
streamingToolExecutor = new StreamingToolExecutor(toolUseContext.options.tools, canUseTool, toolUseContext);
|
|
498085
|
+
}
|
|
498086
|
+
toolUseContext.options.mainLoopModel = fallbackModel;
|
|
498087
|
+
if (process.env.USER_TYPE === "ant") {
|
|
498088
|
+
messagesForQuery = stripSignatureBlocks(messagesForQuery);
|
|
498089
|
+
}
|
|
498090
|
+
yield createSystemMessage(`Switched to ${renderModelName(innerError.fallbackModel)} due to high demand for ${renderModelName(innerError.originalModel)}`, "warning");
|
|
498091
|
+
continue;
|
|
498081
498092
|
}
|
|
498082
|
-
|
|
498083
|
-
continue;
|
|
498093
|
+
throw innerError;
|
|
498084
498094
|
}
|
|
498085
|
-
throw innerError;
|
|
498086
498095
|
}
|
|
498087
|
-
}
|
|
498088
|
-
|
|
498089
|
-
|
|
498090
|
-
|
|
498091
|
-
|
|
498096
|
+
} catch (error41) {
|
|
498097
|
+
logError2(error41);
|
|
498098
|
+
const errorMessage2 = error41 instanceof Error ? error41.message : String(error41);
|
|
498099
|
+
if (error41 instanceof ImageSizeError || error41 instanceof ImageResizeError) {
|
|
498100
|
+
yield createAssistantAPIErrorMessage({
|
|
498101
|
+
content: error41.message
|
|
498102
|
+
});
|
|
498103
|
+
return { reason: "image_error" };
|
|
498104
|
+
}
|
|
498105
|
+
yield* yieldMissingToolResultBlocks(assistantMessages, errorMessage2);
|
|
498092
498106
|
yield createAssistantAPIErrorMessage({
|
|
498093
|
-
content:
|
|
498107
|
+
content: errorMessage2
|
|
498094
498108
|
});
|
|
498095
|
-
|
|
498109
|
+
logAntError("Query error", error41);
|
|
498110
|
+
return { reason: "model_error", error: error41 };
|
|
498096
498111
|
}
|
|
498097
|
-
|
|
498098
|
-
|
|
498099
|
-
|
|
498100
|
-
|
|
498101
|
-
|
|
498102
|
-
|
|
498103
|
-
|
|
498104
|
-
|
|
498105
|
-
|
|
498106
|
-
}
|
|
498107
|
-
if (toolUseContext.abortController.signal.aborted) {
|
|
498108
|
-
if (streamingToolExecutor) {
|
|
498109
|
-
for await (const update of streamingToolExecutor.getRemainingResults()) {
|
|
498110
|
-
if (update.message) {
|
|
498111
|
-
yield update.message;
|
|
498112
|
+
if (assistantMessages.length > 0) {
|
|
498113
|
+
executePostSamplingHooks([...messagesForQuery, ...assistantMessages], systemPrompt, userContext, systemContext, toolUseContext, querySource);
|
|
498114
|
+
}
|
|
498115
|
+
if (toolUseContext.abortController.signal.aborted) {
|
|
498116
|
+
if (streamingToolExecutor) {
|
|
498117
|
+
for await (const update of streamingToolExecutor.getRemainingResults()) {
|
|
498118
|
+
if (update.message) {
|
|
498119
|
+
yield update.message;
|
|
498120
|
+
}
|
|
498112
498121
|
}
|
|
498122
|
+
} else {
|
|
498123
|
+
yield* yieldMissingToolResultBlocks(assistantMessages, "Interrupted by user");
|
|
498113
498124
|
}
|
|
498114
|
-
} else {
|
|
498115
|
-
yield* yieldMissingToolResultBlocks(assistantMessages, "Interrupted by user");
|
|
498116
|
-
}
|
|
498117
|
-
if (false) {}
|
|
498118
|
-
if (toolUseContext.abortController.signal.reason !== "interrupt") {
|
|
498119
|
-
yield createUserInterruptionMessage({
|
|
498120
|
-
toolUse: false
|
|
498121
|
-
});
|
|
498122
|
-
}
|
|
498123
|
-
return { reason: "aborted_streaming" };
|
|
498124
|
-
}
|
|
498125
|
-
if (pendingToolUseSummary) {
|
|
498126
|
-
const summary = await pendingToolUseSummary;
|
|
498127
|
-
if (summary) {
|
|
498128
|
-
yield summary;
|
|
498129
|
-
}
|
|
498130
|
-
}
|
|
498131
|
-
if (!needsFollowUp) {
|
|
498132
|
-
const lastMessage = assistantMessages.at(-1);
|
|
498133
|
-
const isWithheld413 = lastMessage?.type === "assistant" && lastMessage.isApiErrorMessage && isPromptTooLongMessage(lastMessage);
|
|
498134
|
-
const isWithheldMedia = mediaRecoveryEnabled && reactiveCompact2?.isWithheldMediaSizeError(lastMessage);
|
|
498135
|
-
if (isWithheld413) {
|
|
498136
498125
|
if (false) {}
|
|
498126
|
+
if (toolUseContext.abortController.signal.reason !== "interrupt") {
|
|
498127
|
+
yield createUserInterruptionMessage({
|
|
498128
|
+
toolUse: false
|
|
498129
|
+
});
|
|
498130
|
+
}
|
|
498131
|
+
return { reason: "aborted_streaming" };
|
|
498137
498132
|
}
|
|
498138
|
-
if (
|
|
498139
|
-
const
|
|
498140
|
-
|
|
498141
|
-
|
|
498142
|
-
|
|
498143
|
-
|
|
498144
|
-
|
|
498145
|
-
|
|
498146
|
-
|
|
498147
|
-
|
|
498148
|
-
|
|
498149
|
-
|
|
498133
|
+
if (pendingToolUseSummary) {
|
|
498134
|
+
const summary = await pendingToolUseSummary;
|
|
498135
|
+
if (summary) {
|
|
498136
|
+
yield summary;
|
|
498137
|
+
}
|
|
498138
|
+
}
|
|
498139
|
+
if (!needsFollowUp) {
|
|
498140
|
+
const lastMessage = assistantMessages.at(-1);
|
|
498141
|
+
const isWithheld413 = lastMessage?.type === "assistant" && lastMessage.isApiErrorMessage && isPromptTooLongMessage(lastMessage);
|
|
498142
|
+
const isWithheldMedia = mediaRecoveryEnabled && reactiveCompact2?.isWithheldMediaSizeError(lastMessage);
|
|
498143
|
+
if (isWithheld413) {
|
|
498144
|
+
if (false) {}
|
|
498145
|
+
}
|
|
498146
|
+
if ((isWithheld413 || isWithheldMedia) && reactiveCompact2) {
|
|
498147
|
+
const compacted = await reactiveCompact2.tryReactiveCompact({
|
|
498148
|
+
hasAttempted: hasAttemptedReactiveCompact,
|
|
498149
|
+
querySource,
|
|
498150
|
+
aborted: toolUseContext.abortController.signal.aborted,
|
|
498151
|
+
messages: messagesForQuery,
|
|
498152
|
+
cacheSafeParams: {
|
|
498153
|
+
systemPrompt,
|
|
498154
|
+
userContext,
|
|
498155
|
+
systemContext,
|
|
498156
|
+
toolUseContext,
|
|
498157
|
+
forkContextMessages: messagesForQuery
|
|
498158
|
+
}
|
|
498159
|
+
});
|
|
498160
|
+
if (compacted) {
|
|
498161
|
+
if (params.taskBudget) {
|
|
498162
|
+
const preCompactContext = finalContextTokensFromLastResponse(messagesForQuery);
|
|
498163
|
+
taskBudgetRemaining = Math.max(0, (taskBudgetRemaining ?? params.taskBudget.total) - preCompactContext);
|
|
498164
|
+
}
|
|
498165
|
+
const postCompactMessages = buildPostCompactMessages(compacted);
|
|
498166
|
+
for (const msg of postCompactMessages) {
|
|
498167
|
+
yield msg;
|
|
498168
|
+
}
|
|
498169
|
+
const next3 = {
|
|
498170
|
+
messages: postCompactMessages,
|
|
498171
|
+
toolUseContext,
|
|
498172
|
+
autoCompactTracking: undefined,
|
|
498173
|
+
maxOutputTokensRecoveryCount,
|
|
498174
|
+
hasAttemptedReactiveCompact: true,
|
|
498175
|
+
maxOutputTokensOverride: undefined,
|
|
498176
|
+
pendingToolUseSummary: undefined,
|
|
498177
|
+
stopHookActive: undefined,
|
|
498178
|
+
turnCount,
|
|
498179
|
+
transition: { reason: "reactive_compact_retry" }
|
|
498180
|
+
};
|
|
498181
|
+
state = next3;
|
|
498182
|
+
continue;
|
|
498150
498183
|
}
|
|
498151
|
-
|
|
498152
|
-
|
|
498153
|
-
|
|
498154
|
-
|
|
498155
|
-
|
|
498184
|
+
yield lastMessage;
|
|
498185
|
+
executeStopFailureHooks(lastMessage, toolUseContext);
|
|
498186
|
+
return { reason: isWithheldMedia ? "image_error" : "prompt_too_long" };
|
|
498187
|
+
} else if (isWithheld413) {
|
|
498188
|
+
try {
|
|
498189
|
+
const forcedCompactionResult = await compactConversation(messagesForQuery, toolUseContext, {
|
|
498190
|
+
systemPrompt,
|
|
498191
|
+
userContext,
|
|
498192
|
+
systemContext,
|
|
498193
|
+
toolUseContext,
|
|
498194
|
+
forkContextMessages: messagesForQuery
|
|
498195
|
+
}, true, undefined, true, {
|
|
498196
|
+
isRecompactionInChain: tracking?.compacted === true,
|
|
498197
|
+
turnsSincePreviousCompact: tracking?.turnCounter ?? -1,
|
|
498198
|
+
previousCompactTurnId: tracking?.turnId,
|
|
498199
|
+
autoCompactThreshold: getAutoCompactThreshold(currentModel),
|
|
498200
|
+
querySource
|
|
498201
|
+
});
|
|
498202
|
+
if (params.taskBudget) {
|
|
498203
|
+
const preCompactContext = finalContextTokensFromLastResponse(messagesForQuery);
|
|
498204
|
+
taskBudgetRemaining = Math.max(0, (taskBudgetRemaining ?? params.taskBudget.total) - preCompactContext);
|
|
498205
|
+
}
|
|
498206
|
+
const postCompactMessages = buildPostCompactMessages(forcedCompactionResult);
|
|
498207
|
+
for (const msg of postCompactMessages) {
|
|
498208
|
+
yield msg;
|
|
498209
|
+
}
|
|
498210
|
+
tracking = {
|
|
498211
|
+
compacted: true,
|
|
498212
|
+
turnId: deps.uuid(),
|
|
498213
|
+
turnCounter: 0,
|
|
498214
|
+
consecutiveFailures: 0
|
|
498215
|
+
};
|
|
498216
|
+
const next3 = {
|
|
498217
|
+
messages: postCompactMessages,
|
|
498218
|
+
toolUseContext,
|
|
498219
|
+
autoCompactTracking: tracking,
|
|
498220
|
+
maxOutputTokensRecoveryCount,
|
|
498221
|
+
hasAttemptedReactiveCompact: true,
|
|
498222
|
+
maxOutputTokensOverride: undefined,
|
|
498223
|
+
pendingToolUseSummary: undefined,
|
|
498224
|
+
stopHookActive: undefined,
|
|
498225
|
+
turnCount,
|
|
498226
|
+
transition: { reason: "forced_prompt_too_long_compact_retry" }
|
|
498227
|
+
};
|
|
498228
|
+
state = next3;
|
|
498229
|
+
continue;
|
|
498230
|
+
} catch {
|
|
498231
|
+
yield lastMessage;
|
|
498232
|
+
executeStopFailureHooks(lastMessage, toolUseContext);
|
|
498233
|
+
return { reason: "prompt_too_long" };
|
|
498156
498234
|
}
|
|
498157
|
-
|
|
498158
|
-
|
|
498159
|
-
|
|
498235
|
+
} else if (false) {}
|
|
498236
|
+
if (isWithheldMaxOutputTokens(lastMessage)) {
|
|
498237
|
+
const capEnabled = false;
|
|
498238
|
+
if (capEnabled && maxOutputTokensOverride === undefined && !process.env.CLAUDE_CODE_MAX_OUTPUT_TOKENS) {
|
|
498239
|
+
const next3 = {
|
|
498240
|
+
messages: messagesForQuery,
|
|
498241
|
+
toolUseContext,
|
|
498242
|
+
autoCompactTracking: tracking,
|
|
498243
|
+
maxOutputTokensRecoveryCount,
|
|
498244
|
+
hasAttemptedReactiveCompact,
|
|
498245
|
+
maxOutputTokensOverride: ESCALATED_MAX_TOKENS,
|
|
498246
|
+
pendingToolUseSummary: undefined,
|
|
498247
|
+
stopHookActive: undefined,
|
|
498248
|
+
turnCount,
|
|
498249
|
+
transition: { reason: "max_output_tokens_escalate" }
|
|
498250
|
+
};
|
|
498251
|
+
state = next3;
|
|
498252
|
+
continue;
|
|
498253
|
+
}
|
|
498254
|
+
if (maxOutputTokensRecoveryCount < MAX_OUTPUT_TOKENS_RECOVERY_LIMIT) {
|
|
498255
|
+
const recoveryMessage = createUserMessage({
|
|
498256
|
+
content: `Output token limit hit. Resume directly \u2014 no apology, no recap of what you were doing. ` + `Pick up mid-thought if that is where the cut happened. Break remaining work into smaller pieces.`,
|
|
498257
|
+
isMeta: true
|
|
498258
|
+
});
|
|
498259
|
+
const next3 = {
|
|
498260
|
+
messages: [
|
|
498261
|
+
...messagesForQuery,
|
|
498262
|
+
...assistantMessages,
|
|
498263
|
+
recoveryMessage
|
|
498264
|
+
],
|
|
498265
|
+
toolUseContext,
|
|
498266
|
+
autoCompactTracking: tracking,
|
|
498267
|
+
maxOutputTokensRecoveryCount: maxOutputTokensRecoveryCount + 1,
|
|
498268
|
+
hasAttemptedReactiveCompact,
|
|
498269
|
+
maxOutputTokensOverride: undefined,
|
|
498270
|
+
pendingToolUseSummary: undefined,
|
|
498271
|
+
stopHookActive: undefined,
|
|
498272
|
+
turnCount,
|
|
498273
|
+
transition: {
|
|
498274
|
+
reason: "max_output_tokens_recovery",
|
|
498275
|
+
attempt: maxOutputTokensRecoveryCount + 1
|
|
498276
|
+
}
|
|
498277
|
+
};
|
|
498278
|
+
state = next3;
|
|
498279
|
+
continue;
|
|
498160
498280
|
}
|
|
498161
|
-
const next3 = {
|
|
498162
|
-
messages: postCompactMessages,
|
|
498163
|
-
toolUseContext,
|
|
498164
|
-
autoCompactTracking: undefined,
|
|
498165
|
-
maxOutputTokensRecoveryCount,
|
|
498166
|
-
hasAttemptedReactiveCompact: true,
|
|
498167
|
-
maxOutputTokensOverride: undefined,
|
|
498168
|
-
pendingToolUseSummary: undefined,
|
|
498169
|
-
stopHookActive: undefined,
|
|
498170
|
-
turnCount,
|
|
498171
|
-
transition: { reason: "reactive_compact_retry" }
|
|
498172
|
-
};
|
|
498173
|
-
state = next3;
|
|
498174
|
-
continue;
|
|
498175
|
-
}
|
|
498176
|
-
yield lastMessage;
|
|
498177
|
-
executeStopFailureHooks(lastMessage, toolUseContext);
|
|
498178
|
-
return { reason: isWithheldMedia ? "image_error" : "prompt_too_long" };
|
|
498179
|
-
} else if (isWithheld413) {
|
|
498180
|
-
try {
|
|
498181
|
-
const forcedCompactionResult = await compactConversation(messagesForQuery, toolUseContext, {
|
|
498182
|
-
systemPrompt,
|
|
498183
|
-
userContext,
|
|
498184
|
-
systemContext,
|
|
498185
|
-
toolUseContext,
|
|
498186
|
-
forkContextMessages: messagesForQuery
|
|
498187
|
-
}, true, undefined, true, {
|
|
498188
|
-
isRecompactionInChain: tracking?.compacted === true,
|
|
498189
|
-
turnsSincePreviousCompact: tracking?.turnCounter ?? -1,
|
|
498190
|
-
previousCompactTurnId: tracking?.turnId,
|
|
498191
|
-
autoCompactThreshold: getAutoCompactThreshold(currentModel),
|
|
498192
|
-
querySource
|
|
498193
|
-
});
|
|
498194
|
-
if (params.taskBudget) {
|
|
498195
|
-
const preCompactContext = finalContextTokensFromLastResponse(messagesForQuery);
|
|
498196
|
-
taskBudgetRemaining = Math.max(0, (taskBudgetRemaining ?? params.taskBudget.total) - preCompactContext);
|
|
498197
|
-
}
|
|
498198
|
-
const postCompactMessages = buildPostCompactMessages(forcedCompactionResult);
|
|
498199
|
-
for (const msg of postCompactMessages) {
|
|
498200
|
-
yield msg;
|
|
498201
|
-
}
|
|
498202
|
-
tracking = {
|
|
498203
|
-
compacted: true,
|
|
498204
|
-
turnId: deps.uuid(),
|
|
498205
|
-
turnCounter: 0,
|
|
498206
|
-
consecutiveFailures: 0
|
|
498207
|
-
};
|
|
498208
|
-
const next3 = {
|
|
498209
|
-
messages: postCompactMessages,
|
|
498210
|
-
toolUseContext,
|
|
498211
|
-
autoCompactTracking: tracking,
|
|
498212
|
-
maxOutputTokensRecoveryCount,
|
|
498213
|
-
hasAttemptedReactiveCompact: true,
|
|
498214
|
-
maxOutputTokensOverride: undefined,
|
|
498215
|
-
pendingToolUseSummary: undefined,
|
|
498216
|
-
stopHookActive: undefined,
|
|
498217
|
-
turnCount,
|
|
498218
|
-
transition: { reason: "forced_prompt_too_long_compact_retry" }
|
|
498219
|
-
};
|
|
498220
|
-
state = next3;
|
|
498221
|
-
continue;
|
|
498222
|
-
} catch {
|
|
498223
498281
|
yield lastMessage;
|
|
498282
|
+
}
|
|
498283
|
+
if (lastMessage?.isApiErrorMessage) {
|
|
498224
498284
|
executeStopFailureHooks(lastMessage, toolUseContext);
|
|
498225
|
-
return { reason: "
|
|
498285
|
+
return { reason: "completed" };
|
|
498226
498286
|
}
|
|
498227
|
-
|
|
498228
|
-
|
|
498229
|
-
|
|
498230
|
-
if (capEnabled && maxOutputTokensOverride === undefined && !process.env.CLAUDE_CODE_MAX_OUTPUT_TOKENS) {
|
|
498231
|
-
const next3 = {
|
|
498232
|
-
messages: messagesForQuery,
|
|
498233
|
-
toolUseContext,
|
|
498234
|
-
autoCompactTracking: tracking,
|
|
498235
|
-
maxOutputTokensRecoveryCount,
|
|
498236
|
-
hasAttemptedReactiveCompact,
|
|
498237
|
-
maxOutputTokensOverride: ESCALATED_MAX_TOKENS,
|
|
498238
|
-
pendingToolUseSummary: undefined,
|
|
498239
|
-
stopHookActive: undefined,
|
|
498240
|
-
turnCount,
|
|
498241
|
-
transition: { reason: "max_output_tokens_escalate" }
|
|
498242
|
-
};
|
|
498243
|
-
state = next3;
|
|
498244
|
-
continue;
|
|
498287
|
+
const stopHookResult = yield* handleStopHooks(messagesForQuery, assistantMessages, systemPrompt, userContext, systemContext, toolUseContext, querySource, stopHookActive);
|
|
498288
|
+
if (stopHookResult.preventContinuation) {
|
|
498289
|
+
return { reason: "stop_hook_prevented" };
|
|
498245
498290
|
}
|
|
498246
|
-
if (
|
|
498247
|
-
const recoveryMessage = createUserMessage({
|
|
498248
|
-
content: `Output token limit hit. Resume directly \u2014 no apology, no recap of what you were doing. ` + `Pick up mid-thought if that is where the cut happened. Break remaining work into smaller pieces.`,
|
|
498249
|
-
isMeta: true
|
|
498250
|
-
});
|
|
498291
|
+
if (stopHookResult.blockingErrors.length > 0) {
|
|
498251
498292
|
const next3 = {
|
|
498252
498293
|
messages: [
|
|
498253
498294
|
...messagesForQuery,
|
|
498254
498295
|
...assistantMessages,
|
|
498255
|
-
|
|
498296
|
+
...stopHookResult.blockingErrors
|
|
498256
498297
|
],
|
|
498257
498298
|
toolUseContext,
|
|
498258
498299
|
autoCompactTracking: tracking,
|
|
498259
|
-
maxOutputTokensRecoveryCount:
|
|
498300
|
+
maxOutputTokensRecoveryCount: 0,
|
|
498260
498301
|
hasAttemptedReactiveCompact,
|
|
498261
498302
|
maxOutputTokensOverride: undefined,
|
|
498262
498303
|
pendingToolUseSummary: undefined,
|
|
498263
|
-
stopHookActive:
|
|
498304
|
+
stopHookActive: true,
|
|
498264
498305
|
turnCount,
|
|
498265
|
-
transition: {
|
|
498266
|
-
reason: "max_output_tokens_recovery",
|
|
498267
|
-
attempt: maxOutputTokensRecoveryCount + 1
|
|
498268
|
-
}
|
|
498306
|
+
transition: { reason: "stop_hook_blocking" }
|
|
498269
498307
|
};
|
|
498270
498308
|
state = next3;
|
|
498271
498309
|
continue;
|
|
498272
498310
|
}
|
|
498273
|
-
|
|
498274
|
-
}
|
|
498275
|
-
if (lastMessage?.isApiErrorMessage) {
|
|
498276
|
-
executeStopFailureHooks(lastMessage, toolUseContext);
|
|
498311
|
+
if (false) {}
|
|
498277
498312
|
return { reason: "completed" };
|
|
498278
498313
|
}
|
|
498279
|
-
|
|
498280
|
-
|
|
498281
|
-
|
|
498282
|
-
}
|
|
498283
|
-
|
|
498284
|
-
|
|
498285
|
-
|
|
498286
|
-
|
|
498287
|
-
|
|
498288
|
-
|
|
498289
|
-
],
|
|
498290
|
-
toolUseContext,
|
|
498291
|
-
autoCompactTracking: tracking,
|
|
498292
|
-
maxOutputTokensRecoveryCount: 0,
|
|
498293
|
-
hasAttemptedReactiveCompact,
|
|
498294
|
-
maxOutputTokensOverride: undefined,
|
|
498295
|
-
pendingToolUseSummary: undefined,
|
|
498296
|
-
stopHookActive: true,
|
|
498297
|
-
turnCount,
|
|
498298
|
-
transition: { reason: "stop_hook_blocking" }
|
|
498299
|
-
};
|
|
498300
|
-
state = next3;
|
|
498301
|
-
continue;
|
|
498302
|
-
}
|
|
498303
|
-
if (false) {}
|
|
498304
|
-
return { reason: "completed" };
|
|
498305
|
-
}
|
|
498306
|
-
let shouldPreventContinuation = false;
|
|
498307
|
-
let updatedToolUseContext = toolUseContext;
|
|
498308
|
-
queryCheckpoint("query_tool_execution_start");
|
|
498309
|
-
if (streamingToolExecutor) {}
|
|
498310
|
-
const toolUpdates = streamingToolExecutor ? streamingToolExecutor.getRemainingResults() : runTools(toolUseBlocks, assistantMessages, canUseTool, toolUseContext);
|
|
498311
|
-
for await (const update of toolUpdates) {
|
|
498312
|
-
if (update.message) {
|
|
498313
|
-
yield update.message;
|
|
498314
|
-
if (update.message.type === "attachment" && update.message.attachment.type === "hook_stopped_continuation") {
|
|
498315
|
-
shouldPreventContinuation = true;
|
|
498316
|
-
}
|
|
498317
|
-
toolResults.push(...normalizeMessagesForAPI([update.message], toolUseContext.options.tools).filter((_) => _.type === "user"));
|
|
498318
|
-
}
|
|
498319
|
-
if (update.newContext) {
|
|
498320
|
-
updatedToolUseContext = {
|
|
498321
|
-
...update.newContext,
|
|
498322
|
-
queryTracking
|
|
498323
|
-
};
|
|
498324
|
-
}
|
|
498325
|
-
}
|
|
498326
|
-
queryCheckpoint("query_tool_execution_end");
|
|
498327
|
-
let nextPendingToolUseSummary;
|
|
498328
|
-
if (config4.gates.emitToolUseSummaries && toolUseBlocks.length > 0 && !toolUseContext.abortController.signal.aborted && !toolUseContext.agentId) {
|
|
498329
|
-
const lastAssistantMessage = assistantMessages.at(-1);
|
|
498330
|
-
let lastAssistantText;
|
|
498331
|
-
if (lastAssistantMessage) {
|
|
498332
|
-
const textBlocks = lastAssistantMessage.message.content.filter((block2) => block2.type === "text");
|
|
498333
|
-
if (textBlocks.length > 0) {
|
|
498334
|
-
const lastTextBlock = textBlocks.at(-1);
|
|
498335
|
-
if (lastTextBlock && "text" in lastTextBlock) {
|
|
498336
|
-
lastAssistantText = lastTextBlock.text;
|
|
498314
|
+
let shouldPreventContinuation = false;
|
|
498315
|
+
let updatedToolUseContext = toolUseContext;
|
|
498316
|
+
queryCheckpoint("query_tool_execution_start");
|
|
498317
|
+
if (streamingToolExecutor) {}
|
|
498318
|
+
const toolUpdates = streamingToolExecutor ? streamingToolExecutor.getRemainingResults() : runTools(toolUseBlocks, assistantMessages, canUseTool, toolUseContext);
|
|
498319
|
+
for await (const update of toolUpdates) {
|
|
498320
|
+
if (update.message) {
|
|
498321
|
+
yield update.message;
|
|
498322
|
+
if (update.message.type === "attachment" && update.message.attachment.type === "hook_stopped_continuation") {
|
|
498323
|
+
shouldPreventContinuation = true;
|
|
498337
498324
|
}
|
|
498325
|
+
toolResults.push(...normalizeMessagesForAPI([update.message], toolUseContext.options.tools).filter((_) => _.type === "user"));
|
|
498326
|
+
}
|
|
498327
|
+
if (update.newContext) {
|
|
498328
|
+
updatedToolUseContext = {
|
|
498329
|
+
...update.newContext,
|
|
498330
|
+
queryTracking
|
|
498331
|
+
};
|
|
498338
498332
|
}
|
|
498339
498333
|
}
|
|
498340
|
-
|
|
498341
|
-
|
|
498342
|
-
|
|
498343
|
-
const
|
|
498344
|
-
|
|
498345
|
-
|
|
498346
|
-
|
|
498347
|
-
|
|
498348
|
-
|
|
498349
|
-
|
|
498350
|
-
|
|
498351
|
-
|
|
498352
|
-
|
|
498353
|
-
isNonInteractiveSession: toolUseContext.options.isNonInteractiveSession,
|
|
498354
|
-
lastAssistantText
|
|
498355
|
-
}).then((summary) => {
|
|
498356
|
-
if (summary) {
|
|
498357
|
-
return createToolUseSummaryMessage(summary, toolUseIds);
|
|
498334
|
+
queryCheckpoint("query_tool_execution_end");
|
|
498335
|
+
let nextPendingToolUseSummary;
|
|
498336
|
+
if (config4.gates.emitToolUseSummaries && toolUseBlocks.length > 0 && !toolUseContext.abortController.signal.aborted && !toolUseContext.agentId) {
|
|
498337
|
+
const lastAssistantMessage = assistantMessages.at(-1);
|
|
498338
|
+
let lastAssistantText;
|
|
498339
|
+
if (lastAssistantMessage) {
|
|
498340
|
+
const textBlocks = lastAssistantMessage.message.content.filter((block2) => block2.type === "text");
|
|
498341
|
+
if (textBlocks.length > 0) {
|
|
498342
|
+
const lastTextBlock = textBlocks.at(-1);
|
|
498343
|
+
if (lastTextBlock && "text" in lastTextBlock) {
|
|
498344
|
+
lastAssistantText = lastTextBlock.text;
|
|
498345
|
+
}
|
|
498346
|
+
}
|
|
498358
498347
|
}
|
|
498359
|
-
|
|
498360
|
-
|
|
498361
|
-
|
|
498362
|
-
|
|
498363
|
-
|
|
498364
|
-
|
|
498365
|
-
|
|
498366
|
-
|
|
498348
|
+
const toolUseIds = toolUseBlocks.map((block2) => block2.id);
|
|
498349
|
+
const toolInfoForSummary = toolUseBlocks.map((block2) => {
|
|
498350
|
+
const toolResult = toolResults.find((result) => result.type === "user" && Array.isArray(result.message.content) && result.message.content.some((content) => content.type === "tool_result" && content.tool_use_id === block2.id));
|
|
498351
|
+
const resultContent = toolResult?.type === "user" && Array.isArray(toolResult.message.content) ? toolResult.message.content.find((c5) => c5.type === "tool_result" && c5.tool_use_id === block2.id) : undefined;
|
|
498352
|
+
return {
|
|
498353
|
+
name: block2.name,
|
|
498354
|
+
input: block2.input,
|
|
498355
|
+
output: resultContent && "content" in resultContent ? resultContent.content : null
|
|
498356
|
+
};
|
|
498367
498357
|
});
|
|
498358
|
+
nextPendingToolUseSummary = generateToolUseSummary({
|
|
498359
|
+
tools: toolInfoForSummary,
|
|
498360
|
+
signal: toolUseContext.abortController.signal,
|
|
498361
|
+
isNonInteractiveSession: toolUseContext.options.isNonInteractiveSession,
|
|
498362
|
+
lastAssistantText
|
|
498363
|
+
}).then((summary) => {
|
|
498364
|
+
if (summary) {
|
|
498365
|
+
return createToolUseSummaryMessage(summary, toolUseIds);
|
|
498366
|
+
}
|
|
498367
|
+
return null;
|
|
498368
|
+
}).catch(() => null);
|
|
498368
498369
|
}
|
|
498369
|
-
|
|
498370
|
-
|
|
498370
|
+
if (toolUseContext.abortController.signal.aborted) {
|
|
498371
|
+
if (false) {}
|
|
498372
|
+
if (toolUseContext.abortController.signal.reason !== "interrupt") {
|
|
498373
|
+
yield createUserInterruptionMessage({
|
|
498374
|
+
toolUse: true
|
|
498375
|
+
});
|
|
498376
|
+
}
|
|
498377
|
+
const nextTurnCountOnAbort = turnCount + 1;
|
|
498378
|
+
if (maxTurns && nextTurnCountOnAbort > maxTurns) {
|
|
498379
|
+
yield createAttachmentMessage({
|
|
498380
|
+
type: "max_turns_reached",
|
|
498381
|
+
maxTurns,
|
|
498382
|
+
turnCount: nextTurnCountOnAbort
|
|
498383
|
+
});
|
|
498384
|
+
}
|
|
498385
|
+
return { reason: "aborted_tools" };
|
|
498386
|
+
}
|
|
498387
|
+
if (shouldPreventContinuation) {
|
|
498388
|
+
return { reason: "hook_stopped" };
|
|
498389
|
+
}
|
|
498390
|
+
if (tracking?.compacted) {
|
|
498391
|
+
tracking.turnCounter++;
|
|
498392
|
+
}
|
|
498393
|
+
const sleepRan = toolUseBlocks.some((b3) => b3.name === SLEEP_TOOL_NAME);
|
|
498394
|
+
const isMainThread = querySource.startsWith("repl_main_thread") || querySource === "sdk";
|
|
498395
|
+
const currentAgentId = toolUseContext.agentId;
|
|
498396
|
+
const queuedCommandsSnapshot = getCommandsByMaxPriority(sleepRan ? "later" : "next").filter((cmd) => {
|
|
498397
|
+
if (isSlashCommand(cmd))
|
|
498398
|
+
return false;
|
|
498399
|
+
if (isMainThread)
|
|
498400
|
+
return cmd.agentId === undefined;
|
|
498401
|
+
return cmd.mode === "task-notification" && cmd.agentId === currentAgentId;
|
|
498402
|
+
});
|
|
498403
|
+
for await (const attachment of getAttachmentMessages(null, updatedToolUseContext, null, queuedCommandsSnapshot, [...messagesForQuery, ...assistantMessages, ...toolResults], querySource)) {
|
|
498404
|
+
yield attachment;
|
|
498405
|
+
toolResults.push(attachment);
|
|
498406
|
+
}
|
|
498407
|
+
if (pendingMemoryPrefetch && pendingMemoryPrefetch.settledAt !== null && pendingMemoryPrefetch.consumedOnIteration === -1) {
|
|
498408
|
+
const memoryAttachments = filterDuplicateMemoryAttachments(await pendingMemoryPrefetch.promise, toolUseContext.readFileState);
|
|
498409
|
+
for (const memAttachment of memoryAttachments) {
|
|
498410
|
+
const msg = createAttachmentMessage(memAttachment);
|
|
498411
|
+
yield msg;
|
|
498412
|
+
toolResults.push(msg);
|
|
498413
|
+
}
|
|
498414
|
+
pendingMemoryPrefetch.consumedOnIteration = turnCount - 1;
|
|
498415
|
+
}
|
|
498416
|
+
if (skillPrefetch && pendingSkillPrefetch) {
|
|
498417
|
+
const skillAttachments = await skillPrefetch.collectSkillDiscoveryPrefetch(pendingSkillPrefetch);
|
|
498418
|
+
for (const att of skillAttachments) {
|
|
498419
|
+
const msg = createAttachmentMessage(att);
|
|
498420
|
+
yield msg;
|
|
498421
|
+
toolResults.push(msg);
|
|
498422
|
+
}
|
|
498423
|
+
}
|
|
498424
|
+
const consumedCommands = queuedCommandsSnapshot.filter((cmd) => cmd.mode === "prompt" || cmd.mode === "task-notification");
|
|
498425
|
+
if (consumedCommands.length > 0) {
|
|
498426
|
+
for (const cmd of consumedCommands) {
|
|
498427
|
+
if (cmd.uuid) {
|
|
498428
|
+
consumedCommandUuids.push(cmd.uuid);
|
|
498429
|
+
notifyCommandLifecycle(cmd.uuid, "started");
|
|
498430
|
+
}
|
|
498431
|
+
}
|
|
498432
|
+
remove(consumedCommands);
|
|
498433
|
+
}
|
|
498434
|
+
const fileChangeAttachmentCount = count2(toolResults, (tr) => tr.type === "attachment" && tr.attachment.type === "edited_text_file");
|
|
498435
|
+
if (updatedToolUseContext.options.refreshTools) {
|
|
498436
|
+
const refreshedTools = updatedToolUseContext.options.refreshTools();
|
|
498437
|
+
if (refreshedTools !== updatedToolUseContext.options.tools) {
|
|
498438
|
+
updatedToolUseContext = {
|
|
498439
|
+
...updatedToolUseContext,
|
|
498440
|
+
options: {
|
|
498441
|
+
...updatedToolUseContext.options,
|
|
498442
|
+
tools: refreshedTools
|
|
498443
|
+
}
|
|
498444
|
+
};
|
|
498445
|
+
}
|
|
498446
|
+
}
|
|
498447
|
+
const toolUseContextWithQueryTracking = {
|
|
498448
|
+
...updatedToolUseContext,
|
|
498449
|
+
queryTracking
|
|
498450
|
+
};
|
|
498451
|
+
const nextTurnCount = turnCount + 1;
|
|
498452
|
+
if (false) {}
|
|
498453
|
+
if (maxTurns && nextTurnCount > maxTurns) {
|
|
498371
498454
|
yield createAttachmentMessage({
|
|
498372
498455
|
type: "max_turns_reached",
|
|
498373
498456
|
maxTurns,
|
|
498374
|
-
turnCount:
|
|
498457
|
+
turnCount: nextTurnCount
|
|
498375
498458
|
});
|
|
498459
|
+
return { reason: "max_turns", turnCount: nextTurnCount };
|
|
498376
498460
|
}
|
|
498377
|
-
|
|
498378
|
-
|
|
498379
|
-
|
|
498380
|
-
|
|
498381
|
-
|
|
498382
|
-
|
|
498383
|
-
|
|
498384
|
-
|
|
498385
|
-
|
|
498386
|
-
|
|
498387
|
-
|
|
498388
|
-
|
|
498389
|
-
|
|
498390
|
-
|
|
498391
|
-
if (isMainThread)
|
|
498392
|
-
return cmd.agentId === undefined;
|
|
498393
|
-
return cmd.mode === "task-notification" && cmd.agentId === currentAgentId;
|
|
498394
|
-
});
|
|
498395
|
-
for await (const attachment of getAttachmentMessages(null, updatedToolUseContext, null, queuedCommandsSnapshot, [...messagesForQuery, ...assistantMessages, ...toolResults], querySource)) {
|
|
498396
|
-
yield attachment;
|
|
498397
|
-
toolResults.push(attachment);
|
|
498398
|
-
}
|
|
498399
|
-
if (pendingMemoryPrefetch && pendingMemoryPrefetch.settledAt !== null && pendingMemoryPrefetch.consumedOnIteration === -1) {
|
|
498400
|
-
const memoryAttachments = filterDuplicateMemoryAttachments(await pendingMemoryPrefetch.promise, toolUseContext.readFileState);
|
|
498401
|
-
for (const memAttachment of memoryAttachments) {
|
|
498402
|
-
const msg = createAttachmentMessage(memAttachment);
|
|
498403
|
-
yield msg;
|
|
498404
|
-
toolResults.push(msg);
|
|
498405
|
-
}
|
|
498406
|
-
pendingMemoryPrefetch.consumedOnIteration = turnCount - 1;
|
|
498407
|
-
}
|
|
498408
|
-
if (skillPrefetch && pendingSkillPrefetch) {
|
|
498409
|
-
const skillAttachments = await skillPrefetch.collectSkillDiscoveryPrefetch(pendingSkillPrefetch);
|
|
498410
|
-
for (const att of skillAttachments) {
|
|
498411
|
-
const msg = createAttachmentMessage(att);
|
|
498412
|
-
yield msg;
|
|
498413
|
-
toolResults.push(msg);
|
|
498414
|
-
}
|
|
498415
|
-
}
|
|
498416
|
-
const consumedCommands = queuedCommandsSnapshot.filter((cmd) => cmd.mode === "prompt" || cmd.mode === "task-notification");
|
|
498417
|
-
if (consumedCommands.length > 0) {
|
|
498418
|
-
for (const cmd of consumedCommands) {
|
|
498419
|
-
if (cmd.uuid) {
|
|
498420
|
-
consumedCommandUuids.push(cmd.uuid);
|
|
498421
|
-
notifyCommandLifecycle(cmd.uuid, "started");
|
|
498422
|
-
}
|
|
498423
|
-
}
|
|
498424
|
-
remove(consumedCommands);
|
|
498425
|
-
}
|
|
498426
|
-
const fileChangeAttachmentCount = count2(toolResults, (tr) => tr.type === "attachment" && tr.attachment.type === "edited_text_file");
|
|
498427
|
-
if (updatedToolUseContext.options.refreshTools) {
|
|
498428
|
-
const refreshedTools = updatedToolUseContext.options.refreshTools();
|
|
498429
|
-
if (refreshedTools !== updatedToolUseContext.options.tools) {
|
|
498430
|
-
updatedToolUseContext = {
|
|
498431
|
-
...updatedToolUseContext,
|
|
498432
|
-
options: {
|
|
498433
|
-
...updatedToolUseContext.options,
|
|
498434
|
-
tools: refreshedTools
|
|
498435
|
-
}
|
|
498436
|
-
};
|
|
498437
|
-
}
|
|
498461
|
+
queryCheckpoint("query_recursive_call");
|
|
498462
|
+
const next2 = {
|
|
498463
|
+
messages: [...messagesForQuery, ...assistantMessages, ...toolResults],
|
|
498464
|
+
toolUseContext: toolUseContextWithQueryTracking,
|
|
498465
|
+
autoCompactTracking: tracking,
|
|
498466
|
+
turnCount: nextTurnCount,
|
|
498467
|
+
maxOutputTokensRecoveryCount: 0,
|
|
498468
|
+
hasAttemptedReactiveCompact: false,
|
|
498469
|
+
pendingToolUseSummary: nextPendingToolUseSummary,
|
|
498470
|
+
maxOutputTokensOverride: undefined,
|
|
498471
|
+
stopHookActive,
|
|
498472
|
+
transition: { reason: "next_turn" }
|
|
498473
|
+
};
|
|
498474
|
+
state = next2;
|
|
498438
498475
|
}
|
|
498439
|
-
|
|
498440
|
-
|
|
498441
|
-
queryTracking
|
|
498442
|
-
};
|
|
498443
|
-
const nextTurnCount = turnCount + 1;
|
|
498444
|
-
if (false) {}
|
|
498445
|
-
if (maxTurns && nextTurnCount > maxTurns) {
|
|
498446
|
-
yield createAttachmentMessage({
|
|
498447
|
-
type: "max_turns_reached",
|
|
498448
|
-
maxTurns,
|
|
498449
|
-
turnCount: nextTurnCount
|
|
498450
|
-
});
|
|
498451
|
-
return { reason: "max_turns", turnCount: nextTurnCount };
|
|
498452
|
-
}
|
|
498453
|
-
queryCheckpoint("query_recursive_call");
|
|
498454
|
-
const next2 = {
|
|
498455
|
-
messages: [...messagesForQuery, ...assistantMessages, ...toolResults],
|
|
498456
|
-
toolUseContext: toolUseContextWithQueryTracking,
|
|
498457
|
-
autoCompactTracking: tracking,
|
|
498458
|
-
turnCount: nextTurnCount,
|
|
498459
|
-
maxOutputTokensRecoveryCount: 0,
|
|
498460
|
-
hasAttemptedReactiveCompact: false,
|
|
498461
|
-
pendingToolUseSummary: nextPendingToolUseSummary,
|
|
498462
|
-
maxOutputTokensOverride: undefined,
|
|
498463
|
-
stopHookActive,
|
|
498464
|
-
transition: { reason: "next_turn" }
|
|
498465
|
-
};
|
|
498466
|
-
state = next2;
|
|
498476
|
+
} finally {
|
|
498477
|
+
pendingMemoryPrefetch?.[Symbol.dispose]();
|
|
498467
498478
|
}
|
|
498468
498479
|
}
|
|
498469
498480
|
function buildRouteContext(turnCount, querySource, messages, maxBudgetUsd) {
|
|
@@ -515666,7 +515677,7 @@ var init_filesystem = __esm(() => {
|
|
|
515666
515677
|
});
|
|
515667
515678
|
getBundledSkillsRoot = memoize_default(function getBundledSkillsRoot2() {
|
|
515668
515679
|
const nonce = randomBytes18(16).toString("hex");
|
|
515669
|
-
return join146(getClaudeTempDir(), "bundled-skills", "1.0.0-alpha.
|
|
515680
|
+
return join146(getClaudeTempDir(), "bundled-skills", "1.0.0-alpha.23", nonce);
|
|
515670
515681
|
});
|
|
515671
515682
|
getResolvedWorkingDirPaths = memoize_default(getPathsForPermissionCheck);
|
|
515672
515683
|
});
|
|
@@ -521596,7 +521607,7 @@ function computeFingerprintFromMessages(messages) {
|
|
|
521596
521607
|
}
|
|
521597
521608
|
var AGENT_OS_VERSION5, FINGERPRINT_SALT = "59cf53e54c78";
|
|
521598
521609
|
var init_fingerprint = __esm(() => {
|
|
521599
|
-
AGENT_OS_VERSION5 = typeof MACRO !== "undefined" ? "1.0.0-alpha.
|
|
521610
|
+
AGENT_OS_VERSION5 = typeof MACRO !== "undefined" ? "1.0.0-alpha.23" : "dev";
|
|
521600
521611
|
});
|
|
521601
521612
|
|
|
521602
521613
|
// src/services/compact/apiMicrocompact.ts
|
|
@@ -523350,7 +523361,7 @@ async function sideQuery(opts) {
|
|
|
523350
523361
|
betas.push(STRUCTURED_OUTPUTS_BETA_HEADER);
|
|
523351
523362
|
}
|
|
523352
523363
|
const messageText = extractFirstUserMessageText(messages);
|
|
523353
|
-
const fingerprint = computeFingerprint(messageText, "1.0.0-alpha.
|
|
523364
|
+
const fingerprint = computeFingerprint(messageText, "1.0.0-alpha.23");
|
|
523354
523365
|
const attributionHeader = getAttributionHeader(fingerprint);
|
|
523355
523366
|
const systemBlocks = [
|
|
523356
523367
|
attributionHeader ? { type: "text", text: attributionHeader } : null,
|
|
@@ -525269,7 +525280,7 @@ function appendToLog(path24, message) {
|
|
|
525269
525280
|
cwd: getFsImplementation().cwd(),
|
|
525270
525281
|
userType: process.env.USER_TYPE,
|
|
525271
525282
|
sessionId: getSessionId(),
|
|
525272
|
-
version: "1.0.0-alpha.
|
|
525283
|
+
version: "1.0.0-alpha.23"
|
|
525273
525284
|
};
|
|
525274
525285
|
getLogWriter(path24).write(messageWithTimestamp);
|
|
525275
525286
|
}
|
|
@@ -528247,7 +528258,7 @@ function getTelemetryAttributes() {
|
|
|
528247
528258
|
attributes["session.id"] = sessionId;
|
|
528248
528259
|
}
|
|
528249
528260
|
if (shouldIncludeAttribute("OTEL_METRICS_INCLUDE_VERSION")) {
|
|
528250
|
-
attributes["app.version"] = "1.0.0-alpha.
|
|
528261
|
+
attributes["app.version"] = "1.0.0-alpha.23";
|
|
528251
528262
|
}
|
|
528252
528263
|
if (envDynamic.terminal) {
|
|
528253
528264
|
attributes["terminal.type"] = envDynamic.terminal;
|
|
@@ -538391,7 +538402,7 @@ function buildSystemInitMessage(inputs) {
|
|
|
538391
538402
|
slash_commands: inputs.commands.filter((c5) => c5.userInvocable !== false).map((c5) => c5.name),
|
|
538392
538403
|
apiKeySource: getAnthropicApiKeyWithSource().source,
|
|
538393
538404
|
betas: getSdkBetas(),
|
|
538394
|
-
claude_code_version: "1.0.0-alpha.
|
|
538405
|
+
claude_code_version: "1.0.0-alpha.23",
|
|
538395
538406
|
output_style: outputStyle2,
|
|
538396
538407
|
agents: inputs.agents.map((agent) => agent.agentType),
|
|
538397
538408
|
skills: inputs.skills.filter((s2) => s2.userInvocable !== false).map((skill) => skill.name),
|
|
@@ -560860,7 +560871,7 @@ function buildStatusLineCommandInput(permissionMode, exceeds200kTokens, settings
|
|
|
560860
560871
|
project_dir: getOriginalCwd(),
|
|
560861
560872
|
added_dirs: addedDirs
|
|
560862
560873
|
},
|
|
560863
|
-
version: "1.0.0-alpha.
|
|
560874
|
+
version: "1.0.0-alpha.23",
|
|
560864
560875
|
output_style: {
|
|
560865
560876
|
name: outputStyleName
|
|
560866
560877
|
},
|
|
@@ -584216,7 +584227,7 @@ function WelcomeV2() {
|
|
|
584216
584227
|
dimColor: true,
|
|
584217
584228
|
children: [
|
|
584218
584229
|
"v",
|
|
584219
|
-
"1.0.0-alpha.
|
|
584230
|
+
"1.0.0-alpha.23",
|
|
584220
584231
|
" "
|
|
584221
584232
|
]
|
|
584222
584233
|
})
|
|
@@ -584416,7 +584427,7 @@ function WelcomeV2() {
|
|
|
584416
584427
|
dimColor: true,
|
|
584417
584428
|
children: [
|
|
584418
584429
|
"v",
|
|
584419
|
-
"1.0.0-alpha.
|
|
584430
|
+
"1.0.0-alpha.23",
|
|
584420
584431
|
" "
|
|
584421
584432
|
]
|
|
584422
584433
|
})
|
|
@@ -584642,7 +584653,7 @@ function AppleTerminalWelcomeV2(t0) {
|
|
|
584642
584653
|
dimColor: true,
|
|
584643
584654
|
children: [
|
|
584644
584655
|
"v",
|
|
584645
|
-
"1.0.0-alpha.
|
|
584656
|
+
"1.0.0-alpha.23",
|
|
584646
584657
|
" "
|
|
584647
584658
|
]
|
|
584648
584659
|
});
|
|
@@ -584896,7 +584907,7 @@ function AppleTerminalWelcomeV2(t0) {
|
|
|
584896
584907
|
dimColor: true,
|
|
584897
584908
|
children: [
|
|
584898
584909
|
"v",
|
|
584899
|
-
"1.0.0-alpha.
|
|
584910
|
+
"1.0.0-alpha.23",
|
|
584900
584911
|
" "
|
|
584901
584912
|
]
|
|
584902
584913
|
});
|
|
@@ -586362,7 +586373,7 @@ function completeOnboarding() {
|
|
|
586362
586373
|
saveGlobalConfig((current) => ({
|
|
586363
586374
|
...current,
|
|
586364
586375
|
hasCompletedOnboarding: true,
|
|
586365
|
-
lastOnboardingVersion: "1.0.0-alpha.
|
|
586376
|
+
lastOnboardingVersion: "1.0.0-alpha.23"
|
|
586366
586377
|
}));
|
|
586367
586378
|
}
|
|
586368
586379
|
function showDialog(root3, renderer) {
|
|
@@ -594825,8 +594836,8 @@ async function getEnvLessBridgeConfig() {
|
|
|
594825
594836
|
}
|
|
594826
594837
|
async function checkEnvLessBridgeMinVersion() {
|
|
594827
594838
|
const cfg = await getEnvLessBridgeConfig();
|
|
594828
|
-
if (cfg.min_version && lt("1.0.0-alpha.
|
|
594829
|
-
return `Your version of Agent-OS (${"1.0.0-alpha.
|
|
594839
|
+
if (cfg.min_version && lt("1.0.0-alpha.23", cfg.min_version)) {
|
|
594840
|
+
return `Your version of Agent-OS (${"1.0.0-alpha.23"}) is too old for Remote Control.
|
|
594830
594841
|
Version ${cfg.min_version} or higher is required. Run \`agent-os update\` to update.`;
|
|
594831
594842
|
}
|
|
594832
594843
|
return null;
|
|
@@ -595299,7 +595310,7 @@ async function initBridgeCore(params) {
|
|
|
595299
595310
|
const rawApi = createBridgeApiClient({
|
|
595300
595311
|
baseUrl,
|
|
595301
595312
|
getAccessToken,
|
|
595302
|
-
runnerVersion: "1.0.0-alpha.
|
|
595313
|
+
runnerVersion: "1.0.0-alpha.23",
|
|
595303
595314
|
onDebug: logForDebugging,
|
|
595304
595315
|
onAuth401,
|
|
595305
595316
|
getTrustedDeviceToken
|
|
@@ -600978,7 +600989,7 @@ async function startMCPServer(cwd3, debug2, verbose) {
|
|
|
600978
600989
|
setCwd(cwd3);
|
|
600979
600990
|
const server = new Server({
|
|
600980
600991
|
name: "claude/tengu",
|
|
600981
|
-
version: "1.0.0-alpha.
|
|
600992
|
+
version: "1.0.0-alpha.23"
|
|
600982
600993
|
}, {
|
|
600983
600994
|
capabilities: {
|
|
600984
600995
|
tools: {}
|
|
@@ -606489,7 +606500,7 @@ ${customInstructions}` : customInstructions;
|
|
|
606489
606500
|
}
|
|
606490
606501
|
}
|
|
606491
606502
|
logForDiagnosticsNoPII("info", "started", {
|
|
606492
|
-
version: "1.0.0-alpha.
|
|
606503
|
+
version: "1.0.0-alpha.23",
|
|
606493
606504
|
is_native_binary: isInBundledMode()
|
|
606494
606505
|
});
|
|
606495
606506
|
registerCleanup(async () => {
|
|
@@ -607281,7 +607292,7 @@ Usage: agent-os --remote "your task description"`, () => gracefulShutdown(1));
|
|
|
607281
607292
|
pendingHookMessages
|
|
607282
607293
|
}, renderAndRun);
|
|
607283
607294
|
}
|
|
607284
|
-
}).version("1.0.0-alpha.
|
|
607295
|
+
}).version("1.0.0-alpha.23 (Agent-OS)", "-v, --version", "Output the version number");
|
|
607285
607296
|
program2.option("-w, --worktree [name]", "Create a new git worktree for this session (optionally specify a name)");
|
|
607286
607297
|
program2.option("--tmux", "Create a tmux session for the worktree (requires --worktree). Uses iTerm2 native panes when available; use --tmux=classic for traditional tmux.");
|
|
607287
607298
|
if (canUserConfigureAdvisor()) {
|
|
@@ -609119,7 +609130,7 @@ if (false) {}
|
|
|
609119
609130
|
async function main2() {
|
|
609120
609131
|
const args = process.argv.slice(2);
|
|
609121
609132
|
if (args.length === 1 && (args[0] === "--version" || args[0] === "-v" || args[0] === "-V")) {
|
|
609122
|
-
console.log(`${"1.0.0-alpha.
|
|
609133
|
+
console.log(`${"1.0.0-alpha.23"} (Agent-OS)`);
|
|
609123
609134
|
return;
|
|
609124
609135
|
}
|
|
609125
609136
|
const {
|