@vionwilliams/agent-os 1.0.0-alpha.22 → 1.0.0-alpha.25
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 +1065 -743
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -8463,49 +8463,57 @@ function getFsImplementation() {
|
|
|
8463
8463
|
return activeFs;
|
|
8464
8464
|
}
|
|
8465
8465
|
async function readFileRange(path2, offset, maxBytes) {
|
|
8466
|
-
|
|
8467
|
-
|
|
8468
|
-
|
|
8469
|
-
|
|
8470
|
-
|
|
8471
|
-
|
|
8472
|
-
|
|
8473
|
-
|
|
8474
|
-
|
|
8475
|
-
|
|
8476
|
-
|
|
8477
|
-
|
|
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;
|
|
8478
8481
|
}
|
|
8479
|
-
|
|
8482
|
+
return {
|
|
8483
|
+
content: buffer.toString("utf8", 0, totalRead),
|
|
8484
|
+
bytesRead: totalRead,
|
|
8485
|
+
bytesTotal: size
|
|
8486
|
+
};
|
|
8487
|
+
} finally {
|
|
8488
|
+
await fh.close();
|
|
8480
8489
|
}
|
|
8481
|
-
return {
|
|
8482
|
-
content: buffer.toString("utf8", 0, totalRead),
|
|
8483
|
-
bytesRead: totalRead,
|
|
8484
|
-
bytesTotal: size
|
|
8485
|
-
};
|
|
8486
8490
|
}
|
|
8487
8491
|
async function tailFile(path2, maxBytes) {
|
|
8488
|
-
|
|
8489
|
-
|
|
8490
|
-
|
|
8491
|
-
|
|
8492
|
-
|
|
8493
|
-
|
|
8494
|
-
|
|
8495
|
-
|
|
8496
|
-
|
|
8497
|
-
|
|
8498
|
-
|
|
8499
|
-
|
|
8500
|
-
|
|
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;
|
|
8501
8508
|
}
|
|
8502
|
-
|
|
8509
|
+
return {
|
|
8510
|
+
content: buffer.toString("utf8", 0, totalRead),
|
|
8511
|
+
bytesRead: totalRead,
|
|
8512
|
+
bytesTotal: size
|
|
8513
|
+
};
|
|
8514
|
+
} finally {
|
|
8515
|
+
await fh.close();
|
|
8503
8516
|
}
|
|
8504
|
-
return {
|
|
8505
|
-
content: buffer.toString("utf8", 0, totalRead),
|
|
8506
|
-
bytesRead: totalRead,
|
|
8507
|
-
bytesTotal: size
|
|
8508
|
-
};
|
|
8509
8517
|
}
|
|
8510
8518
|
async function* readLinesReverse(path2) {
|
|
8511
8519
|
const CHUNK_SIZE = 1024 * 4;
|
|
@@ -35288,21 +35296,25 @@ async function readJSONLFile(filePath) {
|
|
|
35288
35296
|
if (size <= MAX_JSONL_READ_BYTES) {
|
|
35289
35297
|
return parseJSONL(await readFile6(filePath));
|
|
35290
35298
|
}
|
|
35291
|
-
|
|
35292
|
-
|
|
35293
|
-
|
|
35294
|
-
|
|
35295
|
-
|
|
35296
|
-
|
|
35297
|
-
|
|
35298
|
-
|
|
35299
|
-
|
|
35300
|
-
|
|
35301
|
-
|
|
35302
|
-
|
|
35303
|
-
|
|
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();
|
|
35304
35317
|
}
|
|
35305
|
-
return parseJSONL(buf.subarray(0, totalRead));
|
|
35306
35318
|
}
|
|
35307
35319
|
function addItemToJSONCArray(content, newItem) {
|
|
35308
35320
|
try {
|
|
@@ -93302,7 +93314,7 @@ var init_system = __esm(() => {
|
|
|
93302
93314
|
AGENT_SDK_CLAUDE_CODE_PRESET_PREFIX,
|
|
93303
93315
|
AGENT_SDK_PREFIX
|
|
93304
93316
|
];
|
|
93305
|
-
AGENT_OS_VERSION = typeof MACRO !== "undefined" ? "1.0.0-alpha.
|
|
93317
|
+
AGENT_OS_VERSION = typeof MACRO !== "undefined" ? "1.0.0-alpha.25" : "dev";
|
|
93306
93318
|
CLI_SYSPROMPT_PREFIXES = new Set(CLI_SYSPROMPT_PREFIX_VALUES);
|
|
93307
93319
|
});
|
|
93308
93320
|
|
|
@@ -93746,7 +93758,7 @@ function getClaudeCodeUserAgent() {
|
|
|
93746
93758
|
}
|
|
93747
93759
|
var AGENT_OS_VERSION2;
|
|
93748
93760
|
var init_userAgent = __esm(() => {
|
|
93749
|
-
AGENT_OS_VERSION2 = typeof MACRO !== "undefined" ? "1.0.0-alpha.
|
|
93761
|
+
AGENT_OS_VERSION2 = typeof MACRO !== "undefined" ? "1.0.0-alpha.25" : "dev";
|
|
93750
93762
|
});
|
|
93751
93763
|
|
|
93752
93764
|
// src/utils/http.ts
|
|
@@ -93827,7 +93839,7 @@ var init_http2 = __esm(() => {
|
|
|
93827
93839
|
init_auth();
|
|
93828
93840
|
init_userAgent();
|
|
93829
93841
|
init_workloadContext();
|
|
93830
|
-
AGENT_OS_VERSION3 = typeof MACRO !== "undefined" ? "1.0.0-alpha.
|
|
93842
|
+
AGENT_OS_VERSION3 = typeof MACRO !== "undefined" ? "1.0.0-alpha.25" : "dev";
|
|
93831
93843
|
});
|
|
93832
93844
|
|
|
93833
93845
|
// src/services/api/router/userProviders.ts
|
|
@@ -108392,11 +108404,13 @@ var WEB_FETCH_TOOL_NAME = "WebFetch", DESCRIPTION2 = `
|
|
|
108392
108404
|
|
|
108393
108405
|
Usage notes:
|
|
108394
108406
|
- IMPORTANT: If an MCP-provided web fetch tool is available, prefer using that tool instead of this one, as it may have fewer restrictions.
|
|
108407
|
+
- For market research or other current-public-data tasks, use WebSearch first to find current accessible URLs, then use WebFetch only on URLs that look valid.
|
|
108395
108408
|
- The URL must be a fully-formed valid URL
|
|
108396
108409
|
- HTTP URLs will be automatically upgraded to HTTPS
|
|
108397
108410
|
- The prompt should describe what information you want to extract from the page
|
|
108398
108411
|
- This tool is read-only and does not modify any files
|
|
108399
108412
|
- Results may be summarized if the content is very large
|
|
108413
|
+
- Public web pages can expire, redirect, block automation, or time out. When WebFetch returns ok:false, treat that source as unavailable, use the recoveryHint, and continue with other sources instead of stopping the task.
|
|
108400
108414
|
- Includes a self-cleaning 15-minute cache for faster responses when repeatedly accessing the same URL
|
|
108401
108415
|
- When a URL redirects to a different host, the tool will inform you and provide the redirect URL in a special format. You should then make a new WebFetch request with the redirect URL to fetch the content.
|
|
108402
108416
|
- For GitHub URLs, prefer using the gh CLI via Bash instead (e.g., gh pr view, gh issue view, gh api).
|
|
@@ -207163,7 +207177,7 @@ var init_sessionStorage = __esm(() => {
|
|
|
207163
207177
|
init_settings2();
|
|
207164
207178
|
init_slowOperations();
|
|
207165
207179
|
init_uuid();
|
|
207166
|
-
VERSION4 = typeof MACRO !== "undefined" ? "1.0.0-alpha.
|
|
207180
|
+
VERSION4 = typeof MACRO !== "undefined" ? "1.0.0-alpha.25" : "unknown";
|
|
207167
207181
|
MAX_TOMBSTONE_REWRITE_BYTES = 50 * 1024 * 1024;
|
|
207168
207182
|
SKIP_FIRST_PROMPT_PATTERN = /^(?:\s*<[a-z][\w-]*[\s>]|\[Request interrupted by user[^\]]*\])/;
|
|
207169
207183
|
EPHEMERAL_PROGRESS_TYPES = new Set([
|
|
@@ -207293,7 +207307,7 @@ function Feedback({
|
|
|
207293
207307
|
platform: env3.platform,
|
|
207294
207308
|
gitRepo: envInfo.isGit,
|
|
207295
207309
|
terminal: env3.terminal,
|
|
207296
|
-
version: "1.0.0-alpha.
|
|
207310
|
+
version: "1.0.0-alpha.25",
|
|
207297
207311
|
transcript: normalizeMessagesForAPI(messages),
|
|
207298
207312
|
errors: sanitizedErrors,
|
|
207299
207313
|
lastApiRequest: getLastAPIRequest(),
|
|
@@ -207477,7 +207491,7 @@ function Feedback({
|
|
|
207477
207491
|
", ",
|
|
207478
207492
|
env3.terminal,
|
|
207479
207493
|
", v",
|
|
207480
|
-
"1.0.0-alpha.
|
|
207494
|
+
"1.0.0-alpha.25"
|
|
207481
207495
|
]
|
|
207482
207496
|
})
|
|
207483
207497
|
]
|
|
@@ -207583,7 +207597,7 @@ ${sanitizedDescription}
|
|
|
207583
207597
|
` + `**Environment Info**
|
|
207584
207598
|
` + `- Platform: ${env3.platform}
|
|
207585
207599
|
` + `- Terminal: ${env3.terminal}
|
|
207586
|
-
` + `- Version: ${"1.0.0-alpha.
|
|
207600
|
+
` + `- Version: ${"1.0.0-alpha.25"}
|
|
207587
207601
|
` + `- Feedback ID: ${feedbackId}
|
|
207588
207602
|
` + `
|
|
207589
207603
|
**Errors**
|
|
@@ -259968,8 +259982,8 @@ var init_toolAnalytics = __esm(() => {
|
|
|
259968
259982
|
init_agentContext();
|
|
259969
259983
|
init_slowOperations();
|
|
259970
259984
|
init_teammate();
|
|
259971
|
-
AGENT_OS_VERSION4 = typeof MACRO !== "undefined" ? "1.0.0-alpha.
|
|
259972
|
-
AGENT_OS_BUILD_TIME = typeof MACRO !== "undefined" ? "2026-05-
|
|
259985
|
+
AGENT_OS_VERSION4 = typeof MACRO !== "undefined" ? "1.0.0-alpha.25" : "dev";
|
|
259986
|
+
AGENT_OS_BUILD_TIME = typeof MACRO !== "undefined" ? "2026-05-21T15:45:55Z" : undefined;
|
|
259973
259987
|
BUILTIN_MCP_SERVER_NAMES = new Set([]);
|
|
259974
259988
|
TOOL_INPUT_MAX_JSON_CHARS = 4 * 1024;
|
|
259975
259989
|
FILE_COMMANDS = new Set([
|
|
@@ -262581,7 +262595,8 @@ function formatInputValidationSummary(error41) {
|
|
|
262581
262595
|
`).map((line) => line.trim()).filter(Boolean);
|
|
262582
262596
|
const firstLine = lines2[0] ?? "";
|
|
262583
262597
|
const toolMatch = firstLine.match(/^InputValidationError:\s+(.+?)\s+failed\b/);
|
|
262584
|
-
const
|
|
262598
|
+
const toolName = toolMatch?.[1];
|
|
262599
|
+
const prefix = toolName && /^Task(Create|Update)$/.test(toolName) ? `${toolName} parameters do not match the task schema. Agent-OS tried safe normalization; retry with the fields below.` : toolName ? `${toolName} parameters do not match the current schema. Retry with the fields below.` : "Tool parameters do not match the current schema. Retry with the fields below.";
|
|
262585
262600
|
const details = lines2.filter((line) => line.startsWith("The required parameter") || line.startsWith("An unexpected parameter")).slice(0, 4);
|
|
262586
262601
|
return [prefix, ...details].join(`
|
|
262587
262602
|
`);
|
|
@@ -274615,7 +274630,7 @@ function getInstallationEnv() {
|
|
|
274615
274630
|
return;
|
|
274616
274631
|
}
|
|
274617
274632
|
function getClaudeCodeVersion() {
|
|
274618
|
-
return "1.0.0-alpha.
|
|
274633
|
+
return "1.0.0-alpha.25";
|
|
274619
274634
|
}
|
|
274620
274635
|
async function getInstalledVSCodeExtensionVersion(command) {
|
|
274621
274636
|
const { stdout } = await execFileNoThrow(command, ["--list-extensions", "--show-versions"], {
|
|
@@ -297333,7 +297348,7 @@ async function setupSdkMcpClients(sdkMcpConfigs, sendMcpMessage) {
|
|
|
297333
297348
|
const client = new Client({
|
|
297334
297349
|
name: "claude-code",
|
|
297335
297350
|
title: "Agent-OS",
|
|
297336
|
-
version: "1.0.0-alpha.
|
|
297351
|
+
version: "1.0.0-alpha.25",
|
|
297337
297352
|
description: "Anthropic's agentic coding tool",
|
|
297338
297353
|
websiteUrl: PRODUCT_URL
|
|
297339
297354
|
}, {
|
|
@@ -297686,7 +297701,7 @@ var init_client4 = __esm(() => {
|
|
|
297686
297701
|
const client = new Client({
|
|
297687
297702
|
name: "claude-code",
|
|
297688
297703
|
title: "Agent-OS",
|
|
297689
|
-
version: "1.0.0-alpha.
|
|
297704
|
+
version: "1.0.0-alpha.25",
|
|
297690
297705
|
description: "Anthropic's agentic coding tool",
|
|
297691
297706
|
websiteUrl: PRODUCT_URL
|
|
297692
297707
|
}, {
|
|
@@ -344496,8 +344511,10 @@ __export(exports_utils2, {
|
|
|
344496
344511
|
getURLMarkdownContent: () => getURLMarkdownContent,
|
|
344497
344512
|
formatWebFetchHttpError: () => formatWebFetchHttpError,
|
|
344498
344513
|
clearWebFetchCache: () => clearWebFetchCache,
|
|
344514
|
+
classifyRecoverableWebFetchError: () => classifyRecoverableWebFetchError,
|
|
344499
344515
|
checkDomainBlocklist: () => checkDomainBlocklist,
|
|
344500
344516
|
applyPromptToMarkdown: () => applyPromptToMarkdown,
|
|
344517
|
+
WebFetchHttpError: () => WebFetchHttpError,
|
|
344501
344518
|
MAX_MARKDOWN_LENGTH: () => MAX_MARKDOWN_LENGTH
|
|
344502
344519
|
});
|
|
344503
344520
|
function clearWebFetchCache() {
|
|
@@ -344599,6 +344616,76 @@ function formatWebFetchHttpError(params) {
|
|
|
344599
344616
|
}
|
|
344600
344617
|
return message;
|
|
344601
344618
|
}
|
|
344619
|
+
function recoverableMessage(url3, reason) {
|
|
344620
|
+
return {
|
|
344621
|
+
result: `WebFetch could not retrieve ${url3}: ${reason}`,
|
|
344622
|
+
recoveryHint: "Use WebSearch to find a current accessible source, try the redirected/current URL, or skip this source and continue with other evidence."
|
|
344623
|
+
};
|
|
344624
|
+
}
|
|
344625
|
+
function classifyRecoverableWebFetchError(error41, url3) {
|
|
344626
|
+
if (error41 instanceof DomainBlockedError)
|
|
344627
|
+
return null;
|
|
344628
|
+
if (error41 instanceof DomainCheckFailedError)
|
|
344629
|
+
return null;
|
|
344630
|
+
const message = error41 instanceof Error ? error41.message : String(error41);
|
|
344631
|
+
const name = error41 instanceof Error ? error41.name : "";
|
|
344632
|
+
const codeValue = error41?.code;
|
|
344633
|
+
const code = typeof codeValue === "string" ? codeValue : "";
|
|
344634
|
+
if (name === "AbortError" || name === "CanceledError" || code === "ERR_CANCELED") {
|
|
344635
|
+
return null;
|
|
344636
|
+
}
|
|
344637
|
+
if (error41 instanceof WebFetchHttpError && [404, 410].includes(error41.status)) {
|
|
344638
|
+
const { result, recoveryHint } = recoverableMessage(url3, `HTTP ${error41.status} ${error41.statusText}`);
|
|
344639
|
+
return {
|
|
344640
|
+
errorKind: "not_found",
|
|
344641
|
+
code: error41.status,
|
|
344642
|
+
codeText: error41.statusText,
|
|
344643
|
+
result,
|
|
344644
|
+
recoveryHint
|
|
344645
|
+
};
|
|
344646
|
+
}
|
|
344647
|
+
if (/too many redirects/i.test(message)) {
|
|
344648
|
+
const { result, recoveryHint } = recoverableMessage(url3, "the page redirects too many times");
|
|
344649
|
+
return {
|
|
344650
|
+
errorKind: "redirect_loop",
|
|
344651
|
+
code: 0,
|
|
344652
|
+
codeText: "Too Many Redirects",
|
|
344653
|
+
result,
|
|
344654
|
+
recoveryHint
|
|
344655
|
+
};
|
|
344656
|
+
}
|
|
344657
|
+
if (code === "ERR_TLS_CERT_ALTNAME_INVALID" || /ERR_TLS_CERT_ALTNAME_INVALID|certificate|cert altname/i.test(message)) {
|
|
344658
|
+
const { result, recoveryHint } = recoverableMessage(url3, "the site TLS certificate does not match the requested host");
|
|
344659
|
+
return {
|
|
344660
|
+
errorKind: "tls_error",
|
|
344661
|
+
code: 0,
|
|
344662
|
+
codeText: "TLS Certificate Error",
|
|
344663
|
+
result,
|
|
344664
|
+
recoveryHint
|
|
344665
|
+
};
|
|
344666
|
+
}
|
|
344667
|
+
if (code === "ETIMEDOUT" || code === "ECONNABORTED" || /timeout of \d+ms exceeded|timed out|timeout/i.test(message)) {
|
|
344668
|
+
const { result, recoveryHint } = recoverableMessage(url3, "the request timed out");
|
|
344669
|
+
return {
|
|
344670
|
+
errorKind: "timeout",
|
|
344671
|
+
code: 0,
|
|
344672
|
+
codeText: "Timeout",
|
|
344673
|
+
result,
|
|
344674
|
+
recoveryHint
|
|
344675
|
+
};
|
|
344676
|
+
}
|
|
344677
|
+
if (error41 instanceof EgressBlockedError || ["ENOTFOUND", "EAI_AGAIN", "ECONNRESET", "ECONNREFUSED", "EPIPE"].includes(code) || /network|egress|unreachable|getaddrinfo|socket hang up/i.test(message)) {
|
|
344678
|
+
const { result, recoveryHint } = recoverableMessage(url3, "the host is blocked or unreachable from this network");
|
|
344679
|
+
return {
|
|
344680
|
+
errorKind: "network_error",
|
|
344681
|
+
code: 0,
|
|
344682
|
+
codeText: "Network Error",
|
|
344683
|
+
result,
|
|
344684
|
+
recoveryHint
|
|
344685
|
+
};
|
|
344686
|
+
}
|
|
344687
|
+
return null;
|
|
344688
|
+
}
|
|
344602
344689
|
async function getWithPermittedRedirects(url3, signal, redirectChecker, depth = 0) {
|
|
344603
344690
|
if (depth > MAX_REDIRECTS) {
|
|
344604
344691
|
throw new Error(`Too many redirects (exceeded ${MAX_REDIRECTS})`);
|
|
@@ -344638,12 +344725,12 @@ async function getWithPermittedRedirects(url3, signal, redirectChecker, depth =
|
|
|
344638
344725
|
throw new EgressBlockedError(hostname2);
|
|
344639
344726
|
}
|
|
344640
344727
|
if (axios_default.isAxiosError(error41) && error41.response) {
|
|
344641
|
-
throw new
|
|
344728
|
+
throw new WebFetchHttpError({
|
|
344642
344729
|
url: url3,
|
|
344643
344730
|
status: error41.response.status,
|
|
344644
344731
|
statusText: error41.response.statusText,
|
|
344645
344732
|
body: error41.response.data
|
|
344646
|
-
})
|
|
344733
|
+
});
|
|
344647
344734
|
}
|
|
344648
344735
|
throw error41;
|
|
344649
344736
|
}
|
|
@@ -344764,7 +344851,7 @@ async function applyPromptToMarkdown(prompt, markdownContent, signal, isNonInter
|
|
|
344764
344851
|
}
|
|
344765
344852
|
return "No response from model";
|
|
344766
344853
|
}
|
|
344767
|
-
var DomainBlockedError, DomainCheckFailedError, EgressBlockedError, CACHE_TTL_MS, MAX_CACHE_SIZE_BYTES, URL_CACHE, DOMAIN_CHECK_CACHE, turndownServicePromise, MAX_URL_LENGTH = 2000, MAX_HTTP_CONTENT_LENGTH = 10485760, FETCH_TIMEOUT_MS2 = 60000, DOMAIN_CHECK_TIMEOUT_MS = 1e4, MAX_REDIRECTS = 10, MAX_MARKDOWN_LENGTH = 1e5;
|
|
344854
|
+
var DomainBlockedError, DomainCheckFailedError, EgressBlockedError, WebFetchHttpError, CACHE_TTL_MS, MAX_CACHE_SIZE_BYTES, URL_CACHE, DOMAIN_CHECK_CACHE, turndownServicePromise, MAX_URL_LENGTH = 2000, MAX_HTTP_CONTENT_LENGTH = 10485760, FETCH_TIMEOUT_MS2 = 60000, DOMAIN_CHECK_TIMEOUT_MS = 1e4, MAX_REDIRECTS = 10, MAX_MARKDOWN_LENGTH = 1e5;
|
|
344768
344855
|
var init_utils9 = __esm(() => {
|
|
344769
344856
|
init_axios2();
|
|
344770
344857
|
init_index_min();
|
|
@@ -344800,6 +344887,18 @@ var init_utils9 = __esm(() => {
|
|
|
344800
344887
|
this.name = "EgressBlockedError";
|
|
344801
344888
|
}
|
|
344802
344889
|
};
|
|
344890
|
+
WebFetchHttpError = class WebFetchHttpError extends Error {
|
|
344891
|
+
url;
|
|
344892
|
+
status;
|
|
344893
|
+
statusText;
|
|
344894
|
+
constructor(params) {
|
|
344895
|
+
super(formatWebFetchHttpError(params));
|
|
344896
|
+
this.name = "WebFetchHttpError";
|
|
344897
|
+
this.url = params.url;
|
|
344898
|
+
this.status = params.status;
|
|
344899
|
+
this.statusText = params.statusText?.trim() || "HTTP Error";
|
|
344900
|
+
}
|
|
344901
|
+
};
|
|
344803
344902
|
CACHE_TTL_MS = 15 * 60 * 1000;
|
|
344804
344903
|
MAX_CACHE_SIZE_BYTES = 50 * 1024 * 1024;
|
|
344805
344904
|
URL_CACHE = new L({
|
|
@@ -344850,6 +344949,9 @@ var init_WebFetchTool = __esm(() => {
|
|
|
344850
344949
|
prompt: exports_external.string().describe("The prompt to run on the fetched content")
|
|
344851
344950
|
}));
|
|
344852
344951
|
outputSchema15 = lazySchema(() => exports_external.object({
|
|
344952
|
+
ok: exports_external.boolean().optional().describe("Whether the URL was fetched successfully"),
|
|
344953
|
+
errorKind: exports_external.enum(["not_found", "redirect_loop", "tls_error", "timeout", "network_error"]).optional().describe("Recoverable fetch failure category"),
|
|
344954
|
+
recoveryHint: exports_external.string().optional().describe("Suggested next step when ok is false"),
|
|
344853
344955
|
bytes: exports_external.number().describe("Size of the fetched content in bytes"),
|
|
344854
344956
|
code: exports_external.number().describe("HTTP response code"),
|
|
344855
344957
|
codeText: exports_external.string().describe("HTTP response code text"),
|
|
@@ -344972,7 +345074,30 @@ ${DESCRIPTION2}`;
|
|
|
344972
345074
|
renderToolResultMessage: renderToolResultMessage14,
|
|
344973
345075
|
async call({ url: url3, prompt }, { abortController, options: { isNonInteractiveSession } }) {
|
|
344974
345076
|
const start = Date.now();
|
|
344975
|
-
|
|
345077
|
+
let response;
|
|
345078
|
+
try {
|
|
345079
|
+
response = await getURLMarkdownContent(url3, abortController);
|
|
345080
|
+
} catch (error41) {
|
|
345081
|
+
const failure = classifyRecoverableWebFetchError(error41, url3);
|
|
345082
|
+
if (!failure) {
|
|
345083
|
+
throw error41;
|
|
345084
|
+
}
|
|
345085
|
+
return {
|
|
345086
|
+
data: {
|
|
345087
|
+
ok: false,
|
|
345088
|
+
bytes: 0,
|
|
345089
|
+
code: failure.code,
|
|
345090
|
+
codeText: failure.codeText,
|
|
345091
|
+
result: `${failure.result}
|
|
345092
|
+
|
|
345093
|
+
${failure.recoveryHint}`,
|
|
345094
|
+
durationMs: Date.now() - start,
|
|
345095
|
+
url: url3,
|
|
345096
|
+
errorKind: failure.errorKind,
|
|
345097
|
+
recoveryHint: failure.recoveryHint
|
|
345098
|
+
}
|
|
345099
|
+
};
|
|
345100
|
+
}
|
|
344976
345101
|
if ("type" in response && response.type === "redirect") {
|
|
344977
345102
|
const statusText = response.statusCode === 301 ? "Moved Permanently" : response.statusCode === 308 ? "Permanent Redirect" : response.statusCode === 307 ? "Temporary Redirect" : "Found";
|
|
344978
345103
|
const message = `REDIRECT DETECTED: The URL redirects to a different host.
|
|
@@ -344985,6 +345110,7 @@ To complete your request, I need to fetch content from the redirected URL. Pleas
|
|
|
344985
345110
|
- url: "${response.redirectUrl}"
|
|
344986
345111
|
- prompt: "${prompt}"`;
|
|
344987
345112
|
const output2 = {
|
|
345113
|
+
ok: true,
|
|
344988
345114
|
bytes: Buffer.byteLength(message),
|
|
344989
345115
|
code: response.statusCode,
|
|
344990
345116
|
codeText: statusText,
|
|
@@ -345018,6 +345144,7 @@ To complete your request, I need to fetch content from the redirected URL. Pleas
|
|
|
345018
345144
|
[Binary content (${contentType}, ${formatFileSize(persistedSize ?? bytes)}) also saved to ${persistedPath}]`;
|
|
345019
345145
|
}
|
|
345020
345146
|
const output = {
|
|
345147
|
+
ok: true,
|
|
345021
345148
|
bytes,
|
|
345022
345149
|
code,
|
|
345023
345150
|
codeText,
|
|
@@ -406241,11 +406368,29 @@ Skip using this tool when:
|
|
|
406241
406368
|
|
|
406242
406369
|
NOTE that you should not use this tool if there is only one trivial task to do. In this case you are better off just doing the task directly.
|
|
406243
406370
|
|
|
406371
|
+
## Accepted Input Shapes
|
|
406372
|
+
|
|
406373
|
+
Create one task:
|
|
406374
|
+
\`\`\`json
|
|
406375
|
+
{"subject": "Fix login redirect", "description": "Reproduce and patch the redirect loop after OAuth login"}
|
|
406376
|
+
\`\`\`
|
|
406377
|
+
|
|
406378
|
+
Create multiple tasks atomically:
|
|
406379
|
+
\`\`\`json
|
|
406380
|
+
{"tasks": [
|
|
406381
|
+
{"subject": "Collect market sources", "description": "Find current ecommerce market reports"},
|
|
406382
|
+
{"subject": "Draft HTML report", "description": "Compile the findings into a local HTML report"}
|
|
406383
|
+
]}
|
|
406384
|
+
\`\`\`
|
|
406385
|
+
|
|
406386
|
+
Do not pass a top-level \`tasks\` array unless you are creating multiple tasks. Completion notes belong in TaskUpdate \`metadata.completionNote\`, not in TaskCreate.
|
|
406387
|
+
|
|
406244
406388
|
## Task Fields
|
|
406245
406389
|
|
|
406246
406390
|
- **subject**: A brief, actionable title in imperative form (e.g., "Fix authentication bug in login flow")
|
|
406247
406391
|
- **description**: What needs to be done
|
|
406248
406392
|
- **activeForm** (optional): Present continuous form shown in the spinner when the task is in_progress (e.g., "Fixing authentication bug"). If omitted, the spinner shows the subject instead.
|
|
406393
|
+
- **metadata** (optional): Extra structured context that should stay attached to the task
|
|
406249
406394
|
|
|
406250
406395
|
All tasks are created with status \`pending\`.
|
|
406251
406396
|
|
|
@@ -406262,7 +406407,32 @@ var init_prompt23 = __esm(() => {
|
|
|
406262
406407
|
});
|
|
406263
406408
|
|
|
406264
406409
|
// src/tools/TaskCreateTool/TaskCreateTool.ts
|
|
406265
|
-
|
|
406410
|
+
async function createOneTask(taskListId, task, context) {
|
|
406411
|
+
const taskId = await createTask(taskListId, {
|
|
406412
|
+
subject: task.subject,
|
|
406413
|
+
description: task.description,
|
|
406414
|
+
activeForm: task.activeForm,
|
|
406415
|
+
status: "pending",
|
|
406416
|
+
owner: undefined,
|
|
406417
|
+
blocks: [],
|
|
406418
|
+
blockedBy: [],
|
|
406419
|
+
metadata: task.metadata
|
|
406420
|
+
});
|
|
406421
|
+
const blockingErrors = [];
|
|
406422
|
+
const generator = executeTaskCreatedHooks(taskId, task.subject, task.description, getAgentName(), getTeamName(), undefined, context?.abortController?.signal, undefined, context);
|
|
406423
|
+
for await (const result of generator) {
|
|
406424
|
+
if (result.blockingError) {
|
|
406425
|
+
blockingErrors.push(getTaskCreatedHookMessage(result.blockingError));
|
|
406426
|
+
}
|
|
406427
|
+
}
|
|
406428
|
+
if (blockingErrors.length > 0) {
|
|
406429
|
+
await deleteTask(taskListId, taskId);
|
|
406430
|
+
throw new Error(blockingErrors.join(`
|
|
406431
|
+
`));
|
|
406432
|
+
}
|
|
406433
|
+
return { id: taskId, subject: task.subject };
|
|
406434
|
+
}
|
|
406435
|
+
var taskInputSchema, inputSchema32, createdTaskSchema, outputSchema27, TaskCreateTool;
|
|
406266
406436
|
var init_TaskCreateTool = __esm(() => {
|
|
406267
406437
|
init_v4();
|
|
406268
406438
|
init_Tool();
|
|
@@ -406270,17 +406440,43 @@ var init_TaskCreateTool = __esm(() => {
|
|
|
406270
406440
|
init_tasks();
|
|
406271
406441
|
init_teammate();
|
|
406272
406442
|
init_prompt23();
|
|
406273
|
-
|
|
406443
|
+
taskInputSchema = exports_external.strictObject({
|
|
406274
406444
|
subject: exports_external.string().describe("A brief title for the task"),
|
|
406275
406445
|
description: exports_external.string().describe("What needs to be done"),
|
|
406276
406446
|
activeForm: exports_external.string().optional().describe('Present continuous form shown in spinner when in_progress (e.g., "Running tests")'),
|
|
406277
406447
|
metadata: exports_external.record(exports_external.string(), exports_external.unknown()).optional().describe("Arbitrary metadata to attach to the task")
|
|
406448
|
+
});
|
|
406449
|
+
inputSchema32 = lazySchema(() => exports_external.strictObject({
|
|
406450
|
+
subject: exports_external.string().optional().describe("A brief title for the task"),
|
|
406451
|
+
description: exports_external.string().optional().describe("What needs to be done"),
|
|
406452
|
+
activeForm: exports_external.string().optional().describe('Present continuous form shown in spinner when in_progress (e.g., "Running tests")'),
|
|
406453
|
+
metadata: exports_external.record(exports_external.string(), exports_external.unknown()).optional().describe("Arbitrary metadata to attach to the task"),
|
|
406454
|
+
tasks: exports_external.array(taskInputSchema).min(1).optional().describe("Optional batch of tasks to create atomically")
|
|
406455
|
+
}).superRefine((input2, ctx) => {
|
|
406456
|
+
if (input2.tasks && input2.tasks.length > 0)
|
|
406457
|
+
return;
|
|
406458
|
+
if (!input2.subject) {
|
|
406459
|
+
ctx.addIssue({
|
|
406460
|
+
code: "custom",
|
|
406461
|
+
path: ["subject"],
|
|
406462
|
+
message: "TaskCreate requires subject when tasks is not provided"
|
|
406463
|
+
});
|
|
406464
|
+
}
|
|
406465
|
+
if (!input2.description) {
|
|
406466
|
+
ctx.addIssue({
|
|
406467
|
+
code: "custom",
|
|
406468
|
+
path: ["description"],
|
|
406469
|
+
message: "TaskCreate requires description when tasks is not provided"
|
|
406470
|
+
});
|
|
406471
|
+
}
|
|
406278
406472
|
}));
|
|
406473
|
+
createdTaskSchema = exports_external.object({
|
|
406474
|
+
id: exports_external.string(),
|
|
406475
|
+
subject: exports_external.string()
|
|
406476
|
+
});
|
|
406279
406477
|
outputSchema27 = lazySchema(() => exports_external.object({
|
|
406280
|
-
task:
|
|
406281
|
-
|
|
406282
|
-
subject: exports_external.string()
|
|
406283
|
-
})
|
|
406478
|
+
task: createdTaskSchema,
|
|
406479
|
+
tasks: exports_external.array(createdTaskSchema).optional()
|
|
406284
406480
|
}));
|
|
406285
406481
|
TaskCreateTool = buildTool({
|
|
406286
406482
|
name: TASK_CREATE_TOOL_NAME,
|
|
@@ -406309,33 +406505,34 @@ var init_TaskCreateTool = __esm(() => {
|
|
|
406309
406505
|
return true;
|
|
406310
406506
|
},
|
|
406311
406507
|
toAutoClassifierInput(input2) {
|
|
406312
|
-
|
|
406508
|
+
if (Array.isArray(input2.tasks)) {
|
|
406509
|
+
return input2.tasks.map((task) => task.subject).join(" ");
|
|
406510
|
+
}
|
|
406511
|
+
return input2.subject ?? "";
|
|
406313
406512
|
},
|
|
406314
406513
|
renderToolUseMessage() {
|
|
406315
406514
|
return null;
|
|
406316
406515
|
},
|
|
406317
|
-
async call(
|
|
406318
|
-
const
|
|
406319
|
-
|
|
406320
|
-
|
|
406321
|
-
|
|
406322
|
-
|
|
406323
|
-
|
|
406324
|
-
|
|
406325
|
-
blockedBy: [],
|
|
406326
|
-
metadata
|
|
406327
|
-
});
|
|
406328
|
-
const blockingErrors = [];
|
|
406329
|
-
const generator = executeTaskCreatedHooks(taskId, subject, description, getAgentName(), getTeamName(), undefined, context?.abortController?.signal, undefined, context);
|
|
406330
|
-
for await (const result of generator) {
|
|
406331
|
-
if (result.blockingError) {
|
|
406332
|
-
blockingErrors.push(getTaskCreatedHookMessage(result.blockingError));
|
|
406516
|
+
async call(input2, context) {
|
|
406517
|
+
const taskListId = getTaskListId();
|
|
406518
|
+
const tasks = input2.tasks?.length ? input2.tasks : [
|
|
406519
|
+
{
|
|
406520
|
+
subject: input2.subject,
|
|
406521
|
+
description: input2.description,
|
|
406522
|
+
activeForm: input2.activeForm,
|
|
406523
|
+
metadata: input2.metadata
|
|
406333
406524
|
}
|
|
406334
|
-
|
|
406335
|
-
|
|
406336
|
-
|
|
406337
|
-
|
|
406338
|
-
|
|
406525
|
+
];
|
|
406526
|
+
const createdTasks = [];
|
|
406527
|
+
try {
|
|
406528
|
+
for (const task of tasks) {
|
|
406529
|
+
createdTasks.push(await createOneTask(taskListId, task, context));
|
|
406530
|
+
}
|
|
406531
|
+
} catch (error41) {
|
|
406532
|
+
for (const task of createdTasks) {
|
|
406533
|
+
await deleteTask(taskListId, task.id);
|
|
406534
|
+
}
|
|
406535
|
+
throw error41;
|
|
406339
406536
|
}
|
|
406340
406537
|
context.setAppState((prev) => {
|
|
406341
406538
|
if (prev.expandedView === "tasks")
|
|
@@ -406344,19 +406541,18 @@ var init_TaskCreateTool = __esm(() => {
|
|
|
406344
406541
|
});
|
|
406345
406542
|
return {
|
|
406346
406543
|
data: {
|
|
406347
|
-
task:
|
|
406348
|
-
|
|
406349
|
-
subject
|
|
406350
|
-
}
|
|
406544
|
+
task: createdTasks[0],
|
|
406545
|
+
tasks: createdTasks
|
|
406351
406546
|
}
|
|
406352
406547
|
};
|
|
406353
406548
|
},
|
|
406354
406549
|
mapToolResultToToolResultBlockParam(content, toolUseID) {
|
|
406355
|
-
const { task } = content;
|
|
406550
|
+
const { task, tasks } = content;
|
|
406551
|
+
const createdTasks = tasks?.length ? tasks : [task];
|
|
406356
406552
|
return {
|
|
406357
406553
|
tool_use_id: toolUseID,
|
|
406358
406554
|
type: "tool_result",
|
|
406359
|
-
content: `Task #${task.id} created successfully: ${task.subject}`
|
|
406555
|
+
content: createdTasks.length === 1 ? `Task #${task.id} created successfully: ${task.subject}` : `Created ${createdTasks.length} tasks successfully: ${createdTasks.map((item) => `#${item.id} ${item.subject}`).join(", ")}`
|
|
406360
406556
|
};
|
|
406361
406557
|
}
|
|
406362
406558
|
});
|
|
@@ -406532,6 +406728,13 @@ var DESCRIPTION17 = "Update a task in the task list", PROMPT7 = `Use this tool t
|
|
|
406532
406728
|
- **addBlocks**: Mark tasks that cannot start until this one completes
|
|
406533
406729
|
- **addBlockedBy**: Mark tasks that must complete before this one can start
|
|
406534
406730
|
|
|
406731
|
+
Completion notes must be stored as metadata:
|
|
406732
|
+
\`\`\`json
|
|
406733
|
+
{"taskId": "1", "status": "completed", "metadata": {"completionNote": "Verified with bun test"}}
|
|
406734
|
+
\`\`\`
|
|
406735
|
+
|
|
406736
|
+
If a provider emits \`completionNote\`, \`note\`, \`result\`, or \`summary\`, Agent-OS will normalize it into \`metadata.completionNote\`.
|
|
406737
|
+
|
|
406535
406738
|
## Status Workflow
|
|
406536
406739
|
|
|
406537
406740
|
Status progresses: \`pending\` \u2192 \`in_progress\` \u2192 \`completed\`
|
|
@@ -406554,6 +406757,11 @@ Mark task as completed after finishing work:
|
|
|
406554
406757
|
{"taskId": "1", "status": "completed"}
|
|
406555
406758
|
\`\`\`
|
|
406556
406759
|
|
|
406760
|
+
Mark task as completed with a note:
|
|
406761
|
+
\`\`\`json
|
|
406762
|
+
{"taskId": "1", "status": "completed", "metadata": {"completionNote": "Generated the final report and checked the output file"}}
|
|
406763
|
+
\`\`\`
|
|
406764
|
+
|
|
406557
406765
|
Delete a task:
|
|
406558
406766
|
\`\`\`json
|
|
406559
406767
|
{"taskId": "1", "status": "deleted"}
|
|
@@ -416331,7 +416539,7 @@ function getInvokedBinary() {
|
|
|
416331
416539
|
async function getDoctorDiagnostic() {
|
|
416332
416540
|
return {
|
|
416333
416541
|
installationType: "package-manager",
|
|
416334
|
-
version: "1.0.0-alpha.
|
|
416542
|
+
version: "1.0.0-alpha.25",
|
|
416335
416543
|
installationPath: process.argv[1] ?? "",
|
|
416336
416544
|
invokedBinary: getInvokedBinary(),
|
|
416337
416545
|
configInstallMethod: "not set",
|
|
@@ -416736,7 +416944,7 @@ function buildPrimarySection() {
|
|
|
416736
416944
|
});
|
|
416737
416945
|
return [{
|
|
416738
416946
|
label: "Version",
|
|
416739
|
-
value: "1.0.0-alpha.
|
|
416947
|
+
value: "1.0.0-alpha.25"
|
|
416740
416948
|
}, {
|
|
416741
416949
|
label: "Session name",
|
|
416742
416950
|
value: nameValue
|
|
@@ -420379,7 +420587,7 @@ function Config({
|
|
|
420379
420587
|
}
|
|
420380
420588
|
})
|
|
420381
420589
|
}) : showSubmenu === "ChannelDowngrade" ? /* @__PURE__ */ jsx_runtime169.jsx(ChannelDowngradeDialog, {
|
|
420382
|
-
currentVersion: "1.0.0-alpha.
|
|
420590
|
+
currentVersion: "1.0.0-alpha.25",
|
|
420383
420591
|
onChoice: (choice) => {
|
|
420384
420592
|
setShowSubmenu(null);
|
|
420385
420593
|
setTabsHidden(false);
|
|
@@ -420391,7 +420599,7 @@ function Config({
|
|
|
420391
420599
|
autoUpdatesChannel: "stable"
|
|
420392
420600
|
};
|
|
420393
420601
|
if (choice === "stay") {
|
|
420394
|
-
newSettings.minimumVersion = "1.0.0-alpha.
|
|
420602
|
+
newSettings.minimumVersion = "1.0.0-alpha.25";
|
|
420395
420603
|
}
|
|
420396
420604
|
updateSettingsForSource("userSettings", newSettings);
|
|
420397
420605
|
setSettingsData((prev_27) => ({
|
|
@@ -428382,7 +428590,7 @@ function HelpV2(t0) {
|
|
|
428382
428590
|
let t6;
|
|
428383
428591
|
if ($3[31] !== tabs) {
|
|
428384
428592
|
t6 = /* @__PURE__ */ jsx_runtime195.jsx(Tabs, {
|
|
428385
|
-
title: `Agent-OS v${"1.0.0-alpha.
|
|
428593
|
+
title: `Agent-OS v${"1.0.0-alpha.25"}`,
|
|
428386
428594
|
color: "professionalBlue",
|
|
428387
428595
|
defaultTab: "general",
|
|
428388
428596
|
children: tabs
|
|
@@ -431510,7 +431718,7 @@ var init_user = __esm(() => {
|
|
|
431510
431718
|
deviceId,
|
|
431511
431719
|
sessionId: getSessionId(),
|
|
431512
431720
|
email: getEmail(),
|
|
431513
|
-
appVersion: "1.0.0-alpha.
|
|
431721
|
+
appVersion: "1.0.0-alpha.25",
|
|
431514
431722
|
platform: getHostPlatformForAnalytics(),
|
|
431515
431723
|
organizationUuid,
|
|
431516
431724
|
accountUuid,
|
|
@@ -451761,7 +451969,7 @@ function getAllReleaseNotes(changelogContent = getStoredChangelogFromMemory()) {
|
|
|
451761
451969
|
return [];
|
|
451762
451970
|
}
|
|
451763
451971
|
}
|
|
451764
|
-
async function checkForReleaseNotes(lastSeenVersion, currentVersion = "1.0.0-alpha.
|
|
451972
|
+
async function checkForReleaseNotes(lastSeenVersion, currentVersion = "1.0.0-alpha.25") {
|
|
451765
451973
|
if (process.env.USER_TYPE === "ant") {
|
|
451766
451974
|
const changelog = "";
|
|
451767
451975
|
if (changelog) {
|
|
@@ -451788,7 +451996,7 @@ async function checkForReleaseNotes(lastSeenVersion, currentVersion = "1.0.0-alp
|
|
|
451788
451996
|
releaseNotes
|
|
451789
451997
|
};
|
|
451790
451998
|
}
|
|
451791
|
-
function checkForReleaseNotesSync(lastSeenVersion, currentVersion = "1.0.0-alpha.
|
|
451999
|
+
function checkForReleaseNotesSync(lastSeenVersion, currentVersion = "1.0.0-alpha.25") {
|
|
451792
452000
|
if (process.env.USER_TYPE === "ant") {
|
|
451793
452001
|
const changelog = "";
|
|
451794
452002
|
if (changelog) {
|
|
@@ -452915,7 +453123,7 @@ function getRecentActivitySync() {
|
|
|
452915
453123
|
return cachedActivity;
|
|
452916
453124
|
}
|
|
452917
453125
|
function getLogoDisplayData() {
|
|
452918
|
-
const version2 = process.env.DEMO_VERSION ?? "1.0.0-alpha.
|
|
453126
|
+
const version2 = process.env.DEMO_VERSION ?? "1.0.0-alpha.25";
|
|
452919
453127
|
const serverUrl = getDirectConnectServerUrl();
|
|
452920
453128
|
const displayPath = process.env.DEMO_VERSION ? "/code/claude" : getDisplayPath(getCwd());
|
|
452921
453129
|
const cwd2 = serverUrl ? `${displayPath} in ${serverUrl.replace(/^https?:\/\//, "")}` : displayPath;
|
|
@@ -454130,7 +454338,7 @@ function LogoV2() {
|
|
|
454130
454338
|
if ($3[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
454131
454339
|
t2 = () => {
|
|
454132
454340
|
const currentConfig = getGlobalConfig();
|
|
454133
|
-
if (currentConfig.lastReleaseNotesSeen === "1.0.0-alpha.
|
|
454341
|
+
if (currentConfig.lastReleaseNotesSeen === "1.0.0-alpha.25") {
|
|
454134
454342
|
return;
|
|
454135
454343
|
}
|
|
454136
454344
|
saveGlobalConfig(_temp328);
|
|
@@ -454796,12 +455004,12 @@ function AgentOsPoster() {
|
|
|
454796
455004
|
});
|
|
454797
455005
|
}
|
|
454798
455006
|
function _temp328(current) {
|
|
454799
|
-
if (current.lastReleaseNotesSeen === "1.0.0-alpha.
|
|
455007
|
+
if (current.lastReleaseNotesSeen === "1.0.0-alpha.25") {
|
|
454800
455008
|
return current;
|
|
454801
455009
|
}
|
|
454802
455010
|
return {
|
|
454803
455011
|
...current,
|
|
454804
|
-
lastReleaseNotesSeen: "1.0.0-alpha.
|
|
455012
|
+
lastReleaseNotesSeen: "1.0.0-alpha.25"
|
|
454805
455013
|
};
|
|
454806
455014
|
}
|
|
454807
455015
|
function _temp245(s_0) {
|
|
@@ -481378,7 +481586,7 @@ async function captureMemoryDiagnostics(trigger, dumpNumber = 0) {
|
|
|
481378
481586
|
smapsRollup,
|
|
481379
481587
|
platform: process.platform,
|
|
481380
481588
|
nodeVersion: process.version,
|
|
481381
|
-
ccVersion: "1.0.0-alpha.
|
|
481589
|
+
ccVersion: "1.0.0-alpha.25"
|
|
481382
481590
|
};
|
|
481383
481591
|
}
|
|
481384
481592
|
async function performHeapDump(trigger = "manual", dumpNumber = 0) {
|
|
@@ -481951,7 +482159,7 @@ var init_bridge_kick = __esm(() => {
|
|
|
481951
482159
|
var call58 = async () => {
|
|
481952
482160
|
return {
|
|
481953
482161
|
type: "text",
|
|
481954
|
-
value: `${"1.0.0-alpha.
|
|
482162
|
+
value: `${"1.0.0-alpha.25"} (built ${"2026-05-21T15:45:55Z"})`
|
|
481955
482163
|
};
|
|
481956
482164
|
}, version2, version_default;
|
|
481957
482165
|
var init_version = __esm(() => {
|
|
@@ -491443,7 +491651,7 @@ function generateHtmlReport(data, insights) {
|
|
|
491443
491651
|
</html>`;
|
|
491444
491652
|
}
|
|
491445
491653
|
function buildExportData(data, insights, facets, remoteStats) {
|
|
491446
|
-
const version3 = typeof MACRO !== "undefined" ? "1.0.0-alpha.
|
|
491654
|
+
const version3 = typeof MACRO !== "undefined" ? "1.0.0-alpha.25" : "unknown";
|
|
491447
491655
|
const remote_hosts_collected = remoteStats?.hosts.filter((h3) => h3.sessionCount > 0).map((h3) => h3.name);
|
|
491448
491656
|
const facets_summary = {
|
|
491449
491657
|
total: facets.size,
|
|
@@ -495308,9 +495516,81 @@ function moveToMetadata(input2, keys2) {
|
|
|
495308
495516
|
input2.metadata = metadata;
|
|
495309
495517
|
}
|
|
495310
495518
|
}
|
|
495519
|
+
function moveFirstValueToMetadataKey(input2, keys2, metadataKey) {
|
|
495520
|
+
const metadata = isRecord4(input2.metadata) ? { ...input2.metadata } : {};
|
|
495521
|
+
let moved = false;
|
|
495522
|
+
for (const key2 of keys2) {
|
|
495523
|
+
const value = input2[key2];
|
|
495524
|
+
if (value !== undefined) {
|
|
495525
|
+
if (!moved) {
|
|
495526
|
+
metadata[metadataKey] = value;
|
|
495527
|
+
moved = true;
|
|
495528
|
+
}
|
|
495529
|
+
delete input2[key2];
|
|
495530
|
+
}
|
|
495531
|
+
}
|
|
495532
|
+
if (moved) {
|
|
495533
|
+
input2.metadata = metadata;
|
|
495534
|
+
}
|
|
495535
|
+
}
|
|
495311
495536
|
function firstMeaningfulLine(value) {
|
|
495312
495537
|
return value.split(/\r?\n/).map((line) => line.trim()).find(Boolean) ?? value.trim();
|
|
495313
495538
|
}
|
|
495539
|
+
function normalizeTaskStatus2(value) {
|
|
495540
|
+
if (typeof value !== "string")
|
|
495541
|
+
return value;
|
|
495542
|
+
const normalized = value.trim().toLowerCase();
|
|
495543
|
+
if (["done", "resolved", "complete", "completed"].includes(normalized)) {
|
|
495544
|
+
return "completed";
|
|
495545
|
+
}
|
|
495546
|
+
if (["doing", "running", "started", "active", "in-progress"].includes(normalized)) {
|
|
495547
|
+
return "in_progress";
|
|
495548
|
+
}
|
|
495549
|
+
if (["todo", "open", "new"].includes(normalized)) {
|
|
495550
|
+
return "pending";
|
|
495551
|
+
}
|
|
495552
|
+
return value;
|
|
495553
|
+
}
|
|
495554
|
+
function normalizeTaskCreateEntry(entry, commonMetadata) {
|
|
495555
|
+
const normalized = typeof entry === "string" ? { subject: firstMeaningfulLine(entry).slice(0, 120), description: entry } : isRecord4(entry) ? { ...entry } : entry;
|
|
495556
|
+
if (!isRecord4(normalized))
|
|
495557
|
+
return normalized;
|
|
495558
|
+
normalized.subject ??= takeString(normalized, ["title", "task", "name"]);
|
|
495559
|
+
normalized.description ??= takeString(normalized, [
|
|
495560
|
+
"description",
|
|
495561
|
+
"details",
|
|
495562
|
+
"content",
|
|
495563
|
+
"prompt"
|
|
495564
|
+
]);
|
|
495565
|
+
if (!normalized.subject && typeof normalized.description === "string") {
|
|
495566
|
+
normalized.subject = firstMeaningfulLine(normalized.description).slice(0, 120);
|
|
495567
|
+
}
|
|
495568
|
+
if (!normalized.description && typeof normalized.subject === "string") {
|
|
495569
|
+
normalized.description = normalized.subject;
|
|
495570
|
+
}
|
|
495571
|
+
if (commonMetadata && Object.keys(commonMetadata).length > 0) {
|
|
495572
|
+
normalized.metadata = {
|
|
495573
|
+
...commonMetadata,
|
|
495574
|
+
...isRecord4(normalized.metadata) ? normalized.metadata : {}
|
|
495575
|
+
};
|
|
495576
|
+
}
|
|
495577
|
+
moveToMetadata(normalized, [
|
|
495578
|
+
"parentTaskId",
|
|
495579
|
+
"state",
|
|
495580
|
+
"status",
|
|
495581
|
+
"subagent_type",
|
|
495582
|
+
"subtasks"
|
|
495583
|
+
]);
|
|
495584
|
+
removeKeys(normalized, [
|
|
495585
|
+
"title",
|
|
495586
|
+
"task",
|
|
495587
|
+
"name",
|
|
495588
|
+
"details",
|
|
495589
|
+
"content",
|
|
495590
|
+
"prompt"
|
|
495591
|
+
]);
|
|
495592
|
+
return normalized;
|
|
495593
|
+
}
|
|
495314
495594
|
function normalizeProviderToolInput(toolName, input2) {
|
|
495315
495595
|
if (!isRecord4(input2))
|
|
495316
495596
|
return input2;
|
|
@@ -495405,40 +495685,51 @@ function normalizeProviderToolInput(toolName, input2) {
|
|
|
495405
495685
|
}
|
|
495406
495686
|
removeKeys(normalized, ["toolName", "tool", "name", "raw"]);
|
|
495407
495687
|
} else if (toolName === TASK_CREATE_TOOL_NAME) {
|
|
495408
|
-
|
|
495409
|
-
normalized.description ??= takeString(normalized, [
|
|
495410
|
-
"description",
|
|
495411
|
-
"details",
|
|
495412
|
-
"content",
|
|
495413
|
-
"prompt"
|
|
495414
|
-
]);
|
|
495415
|
-
if (!normalized.subject && typeof normalized.description === "string") {
|
|
495416
|
-
normalized.subject = firstMeaningfulLine(normalized.description).slice(0, 120);
|
|
495417
|
-
}
|
|
495418
|
-
if (!normalized.description && typeof normalized.subject === "string") {
|
|
495419
|
-
normalized.description = normalized.subject;
|
|
495420
|
-
}
|
|
495421
|
-
moveToMetadata(normalized, [
|
|
495688
|
+
const taskContextKeys = [
|
|
495422
495689
|
"parentTaskId",
|
|
495423
495690
|
"state",
|
|
495424
495691
|
"status",
|
|
495425
495692
|
"subagent_type",
|
|
495426
495693
|
"subtasks"
|
|
495427
|
-
]
|
|
495428
|
-
|
|
495429
|
-
|
|
495430
|
-
|
|
495431
|
-
|
|
495432
|
-
|
|
495433
|
-
|
|
495434
|
-
|
|
495435
|
-
|
|
495694
|
+
];
|
|
495695
|
+
if (Array.isArray(normalized.tasks)) {
|
|
495696
|
+
const commonMetadata = {};
|
|
495697
|
+
for (const key2 of taskContextKeys) {
|
|
495698
|
+
if (normalized[key2] !== undefined) {
|
|
495699
|
+
commonMetadata[key2] = normalized[key2];
|
|
495700
|
+
}
|
|
495701
|
+
}
|
|
495702
|
+
normalized.tasks = normalized.tasks.map((task) => normalizeTaskCreateEntry(task, commonMetadata));
|
|
495703
|
+
removeKeys(normalized, [
|
|
495704
|
+
"subject",
|
|
495705
|
+
"description",
|
|
495706
|
+
"activeForm",
|
|
495707
|
+
"metadata",
|
|
495708
|
+
"title",
|
|
495709
|
+
"task",
|
|
495710
|
+
"name",
|
|
495711
|
+
"details",
|
|
495712
|
+
"content",
|
|
495713
|
+
"prompt",
|
|
495714
|
+
...taskContextKeys
|
|
495715
|
+
]);
|
|
495716
|
+
} else {
|
|
495717
|
+
const singleTask = normalizeTaskCreateEntry(normalized);
|
|
495718
|
+
if (isRecord4(singleTask)) {
|
|
495719
|
+
for (const key2 of Object.keys(normalized)) {
|
|
495720
|
+
delete normalized[key2];
|
|
495721
|
+
}
|
|
495722
|
+
Object.assign(normalized, singleTask);
|
|
495723
|
+
}
|
|
495724
|
+
}
|
|
495436
495725
|
} else if (toolName === TASK_UPDATE_TOOL_NAME) {
|
|
495437
495726
|
normalized.taskId ??= takeString(normalized, ["id", "task_id", "task"]);
|
|
495438
495727
|
normalized.status ??= takeString(normalized, ["state"]);
|
|
495728
|
+
normalized.status = normalizeTaskStatus2(normalized.status);
|
|
495439
495729
|
normalized.subject ??= takeString(normalized, ["title"]);
|
|
495440
495730
|
normalized.description ??= takeString(normalized, ["details", "content"]);
|
|
495441
495731
|
moveToMetadata(normalized, ["parentTaskId"]);
|
|
495732
|
+
moveFirstValueToMetadataKey(normalized, ["completionNote", "note", "result", "summary"], "completionNote");
|
|
495442
495733
|
removeKeys(normalized, [
|
|
495443
495734
|
"id",
|
|
495444
495735
|
"task_id",
|
|
@@ -495446,7 +495737,11 @@ function normalizeProviderToolInput(toolName, input2) {
|
|
|
495446
495737
|
"state",
|
|
495447
495738
|
"title",
|
|
495448
495739
|
"details",
|
|
495449
|
-
"content"
|
|
495740
|
+
"content",
|
|
495741
|
+
"completionNote",
|
|
495742
|
+
"note",
|
|
495743
|
+
"result",
|
|
495744
|
+
"summary"
|
|
495450
495745
|
]);
|
|
495451
495746
|
} else if (toolName === WEB_FETCH_TOOL_NAME) {
|
|
495452
495747
|
normalized.url ??= takeString(normalized, ["href", "link", "website"]);
|
|
@@ -497812,653 +498107,657 @@ async function* queryLoop(params, consumedCommandUuids) {
|
|
|
497812
498107
|
const budgetTracker = null;
|
|
497813
498108
|
let taskBudgetRemaining = undefined;
|
|
497814
498109
|
const config4 = buildQueryConfig();
|
|
497815
|
-
|
|
497816
|
-
|
|
497817
|
-
|
|
497818
|
-
|
|
497819
|
-
messages,
|
|
497820
|
-
autoCompactTracking,
|
|
497821
|
-
maxOutputTokensRecoveryCount,
|
|
497822
|
-
hasAttemptedReactiveCompact,
|
|
497823
|
-
maxOutputTokensOverride,
|
|
497824
|
-
pendingToolUseSummary,
|
|
497825
|
-
stopHookActive,
|
|
497826
|
-
turnCount
|
|
497827
|
-
} = state;
|
|
497828
|
-
const pendingSkillPrefetch = skillPrefetch?.startSkillDiscoveryPrefetch(null, messages, toolUseContext);
|
|
497829
|
-
yield { type: "stream_request_start" };
|
|
497830
|
-
queryCheckpoint("query_fn_entry");
|
|
497831
|
-
if (!toolUseContext.agentId) {
|
|
497832
|
-
headlessProfilerCheckpoint("query_started");
|
|
497833
|
-
}
|
|
497834
|
-
const queryTracking = toolUseContext.queryTracking ? {
|
|
497835
|
-
chainId: toolUseContext.queryTracking.chainId,
|
|
497836
|
-
depth: toolUseContext.queryTracking.depth + 1
|
|
497837
|
-
} : {
|
|
497838
|
-
chainId: deps.uuid(),
|
|
497839
|
-
depth: 0
|
|
497840
|
-
};
|
|
497841
|
-
const queryChainIdForAnalytics = queryTracking.chainId;
|
|
497842
|
-
toolUseContext = {
|
|
497843
|
-
...toolUseContext,
|
|
497844
|
-
queryTracking
|
|
497845
|
-
};
|
|
497846
|
-
let messagesForQuery = [...getMessagesAfterCompactBoundary(messages)];
|
|
497847
|
-
let tracking = autoCompactTracking;
|
|
497848
|
-
const persistReplacements = querySource.startsWith("agent:") || querySource.startsWith("repl_main_thread");
|
|
497849
|
-
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)));
|
|
497850
|
-
let snipTokensFreed = 0;
|
|
497851
|
-
if (false) {}
|
|
497852
|
-
queryCheckpoint("query_microcompact_start");
|
|
497853
|
-
const microcompactResult = await deps.microcompact(messagesForQuery, toolUseContext, querySource);
|
|
497854
|
-
messagesForQuery = microcompactResult.messages;
|
|
497855
|
-
const pendingCacheEdits2 = undefined;
|
|
497856
|
-
queryCheckpoint("query_microcompact_end");
|
|
497857
|
-
if (false) {}
|
|
497858
|
-
const fullSystemPrompt = asSystemPrompt(appendSystemContext(systemPrompt, systemContext));
|
|
497859
|
-
queryCheckpoint("query_autocompact_start");
|
|
497860
|
-
const { compactionResult, consecutiveFailures } = await deps.autocompact(messagesForQuery, toolUseContext, {
|
|
497861
|
-
systemPrompt,
|
|
497862
|
-
userContext,
|
|
497863
|
-
systemContext,
|
|
497864
|
-
toolUseContext,
|
|
497865
|
-
forkContextMessages: messagesForQuery
|
|
497866
|
-
}, querySource, tracking, snipTokensFreed);
|
|
497867
|
-
queryCheckpoint("query_autocompact_end");
|
|
497868
|
-
if (compactionResult) {
|
|
498110
|
+
const pendingMemoryPrefetch = startRelevantMemoryPrefetch(state.messages, state.toolUseContext);
|
|
498111
|
+
try {
|
|
498112
|
+
while (true) {
|
|
498113
|
+
let { toolUseContext } = state;
|
|
497869
498114
|
const {
|
|
497870
|
-
|
|
497871
|
-
|
|
497872
|
-
|
|
497873
|
-
|
|
497874
|
-
|
|
497875
|
-
|
|
497876
|
-
|
|
497877
|
-
|
|
497878
|
-
}
|
|
497879
|
-
|
|
497880
|
-
|
|
497881
|
-
|
|
497882
|
-
|
|
497883
|
-
|
|
497884
|
-
}
|
|
497885
|
-
const
|
|
497886
|
-
|
|
497887
|
-
|
|
497888
|
-
}
|
|
497889
|
-
|
|
497890
|
-
|
|
497891
|
-
tracking = {
|
|
497892
|
-
...tracking ?? { compacted: false, turnId: "", turnCounter: 0 },
|
|
497893
|
-
consecutiveFailures
|
|
498115
|
+
messages,
|
|
498116
|
+
autoCompactTracking,
|
|
498117
|
+
maxOutputTokensRecoveryCount,
|
|
498118
|
+
hasAttemptedReactiveCompact,
|
|
498119
|
+
maxOutputTokensOverride,
|
|
498120
|
+
pendingToolUseSummary,
|
|
498121
|
+
stopHookActive,
|
|
498122
|
+
turnCount
|
|
498123
|
+
} = state;
|
|
498124
|
+
const pendingSkillPrefetch = skillPrefetch?.startSkillDiscoveryPrefetch(null, messages, toolUseContext);
|
|
498125
|
+
yield { type: "stream_request_start" };
|
|
498126
|
+
queryCheckpoint("query_fn_entry");
|
|
498127
|
+
if (!toolUseContext.agentId) {
|
|
498128
|
+
headlessProfilerCheckpoint("query_started");
|
|
498129
|
+
}
|
|
498130
|
+
const queryTracking = toolUseContext.queryTracking ? {
|
|
498131
|
+
chainId: toolUseContext.queryTracking.chainId,
|
|
498132
|
+
depth: toolUseContext.queryTracking.depth + 1
|
|
498133
|
+
} : {
|
|
498134
|
+
chainId: deps.uuid(),
|
|
498135
|
+
depth: 0
|
|
497894
498136
|
};
|
|
497895
|
-
|
|
497896
|
-
|
|
497897
|
-
|
|
497898
|
-
|
|
497899
|
-
|
|
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
|
-
|
|
498137
|
+
const queryChainIdForAnalytics = queryTracking.chainId;
|
|
498138
|
+
toolUseContext = {
|
|
498139
|
+
...toolUseContext,
|
|
498140
|
+
queryTracking
|
|
498141
|
+
};
|
|
498142
|
+
let messagesForQuery = [...getMessagesAfterCompactBoundary(messages)];
|
|
498143
|
+
let tracking = autoCompactTracking;
|
|
498144
|
+
const persistReplacements = querySource.startsWith("agent:") || querySource.startsWith("repl_main_thread");
|
|
498145
|
+
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)));
|
|
498146
|
+
let snipTokensFreed = 0;
|
|
498147
|
+
if (false) {}
|
|
498148
|
+
queryCheckpoint("query_microcompact_start");
|
|
498149
|
+
const microcompactResult = await deps.microcompact(messagesForQuery, toolUseContext, querySource);
|
|
498150
|
+
messagesForQuery = microcompactResult.messages;
|
|
498151
|
+
const pendingCacheEdits2 = undefined;
|
|
498152
|
+
queryCheckpoint("query_microcompact_end");
|
|
498153
|
+
if (false) {}
|
|
498154
|
+
const fullSystemPrompt = asSystemPrompt(appendSystemContext(systemPrompt, systemContext));
|
|
498155
|
+
queryCheckpoint("query_autocompact_start");
|
|
498156
|
+
const { compactionResult, consecutiveFailures } = await deps.autocompact(messagesForQuery, toolUseContext, {
|
|
498157
|
+
systemPrompt,
|
|
498158
|
+
userContext,
|
|
498159
|
+
systemContext,
|
|
498160
|
+
toolUseContext,
|
|
498161
|
+
forkContextMessages: messagesForQuery
|
|
498162
|
+
}, querySource, tracking, snipTokensFreed);
|
|
498163
|
+
queryCheckpoint("query_autocompact_end");
|
|
498164
|
+
if (compactionResult) {
|
|
498165
|
+
const {
|
|
498166
|
+
preCompactTokenCount,
|
|
498167
|
+
postCompactTokenCount,
|
|
498168
|
+
truePostCompactTokenCount,
|
|
498169
|
+
compactionUsage
|
|
498170
|
+
} = compactionResult;
|
|
498171
|
+
if (params.taskBudget) {
|
|
498172
|
+
const preCompactContext = finalContextTokensFromLastResponse(messagesForQuery);
|
|
498173
|
+
taskBudgetRemaining = Math.max(0, (taskBudgetRemaining ?? params.taskBudget.total) - preCompactContext);
|
|
498174
|
+
}
|
|
498175
|
+
tracking = {
|
|
498176
|
+
compacted: true,
|
|
498177
|
+
turnId: deps.uuid(),
|
|
498178
|
+
turnCounter: 0,
|
|
498179
|
+
consecutiveFailures: 0
|
|
498180
|
+
};
|
|
498181
|
+
const postCompactMessages = buildPostCompactMessages(compactionResult);
|
|
498182
|
+
for (const message of postCompactMessages) {
|
|
498183
|
+
yield message;
|
|
498184
|
+
}
|
|
498185
|
+
messagesForQuery = postCompactMessages;
|
|
498186
|
+
} else if (consecutiveFailures !== undefined) {
|
|
498187
|
+
tracking = {
|
|
498188
|
+
...tracking ?? { compacted: false, turnId: "", turnCounter: 0 },
|
|
498189
|
+
consecutiveFailures
|
|
498190
|
+
};
|
|
497927
498191
|
}
|
|
497928
|
-
|
|
497929
|
-
|
|
497930
|
-
|
|
497931
|
-
|
|
497932
|
-
|
|
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
|
-
|
|
498192
|
+
toolUseContext = {
|
|
498193
|
+
...toolUseContext,
|
|
498194
|
+
messages: messagesForQuery
|
|
498195
|
+
};
|
|
498196
|
+
const assistantMessages = [];
|
|
498197
|
+
const toolResults = [];
|
|
498198
|
+
const toolUseBlocks = [];
|
|
498199
|
+
let needsFollowUp = false;
|
|
498200
|
+
queryCheckpoint("query_setup_start");
|
|
498201
|
+
const useStreamingToolExecution = config4.gates.streamingToolExecution;
|
|
498202
|
+
let streamingToolExecutor = useStreamingToolExecution ? new StreamingToolExecutor(toolUseContext.options.tools, canUseTool, toolUseContext) : null;
|
|
498203
|
+
const appState = toolUseContext.getAppState();
|
|
498204
|
+
const permissionMode = appState.toolPermissionContext.mode;
|
|
498205
|
+
let currentModel = getRuntimeMainLoopModel({
|
|
498206
|
+
permissionMode,
|
|
498207
|
+
mainLoopModel: toolUseContext.options.mainLoopModel,
|
|
498208
|
+
exceeds200kTokens: permissionMode === "plan" && doesMostRecentAssistantMessageExceed200k(messagesForQuery)
|
|
498209
|
+
});
|
|
498210
|
+
queryCheckpoint("query_setup_end");
|
|
498211
|
+
const dumpPromptsFetch = config4.gates.isAnt ? createDumpPromptsFetch(toolUseContext.agentId ?? config4.sessionId) : undefined;
|
|
498212
|
+
let collapseOwnsIt = false;
|
|
498213
|
+
if (false) {}
|
|
498214
|
+
const mediaRecoveryEnabled = reactiveCompact2?.isReactiveCompactEnabled() ?? false;
|
|
498215
|
+
if (!compactionResult && querySource !== "compact" && querySource !== "session_memory" && !(reactiveCompact2?.isReactiveCompactEnabled() && isAutoCompactEnabled()) && !collapseOwnsIt) {
|
|
498216
|
+
const { isAtBlockingLimit } = calculateTokenWarningState(tokenCountWithEstimation(messagesForQuery) - snipTokensFreed, toolUseContext.options.mainLoopModel);
|
|
498217
|
+
if (isAtBlockingLimit) {
|
|
498218
|
+
yield createAssistantAPIErrorMessage({
|
|
498219
|
+
content: PROMPT_TOO_LONG_ERROR_MESSAGE,
|
|
498220
|
+
error: "invalid_request"
|
|
498221
|
+
});
|
|
498222
|
+
return { reason: "blocking_limit" };
|
|
498223
|
+
}
|
|
498224
|
+
}
|
|
498225
|
+
let attemptWithFallback = true;
|
|
498226
|
+
queryCheckpoint("query_api_loop_start");
|
|
498227
|
+
try {
|
|
498228
|
+
while (attemptWithFallback) {
|
|
498229
|
+
attemptWithFallback = false;
|
|
498230
|
+
try {
|
|
498231
|
+
let streamingFallbackOccured = false;
|
|
498232
|
+
queryCheckpoint("query_api_streaming_start");
|
|
498233
|
+
for await (const message of deps.callModel({
|
|
498234
|
+
messages: prependUserContext(messagesForQuery, userContext),
|
|
498235
|
+
systemPrompt: fullSystemPrompt,
|
|
498236
|
+
thinkingConfig: toolUseContext.options.thinkingConfig,
|
|
498237
|
+
tools: toolUseContext.options.tools,
|
|
498238
|
+
signal: toolUseContext.abortController.signal,
|
|
498239
|
+
options: {
|
|
498240
|
+
async getToolPermissionContext() {
|
|
498241
|
+
const appState2 = toolUseContext.getAppState();
|
|
498242
|
+
return appState2.toolPermissionContext;
|
|
498243
|
+
},
|
|
498244
|
+
model: currentModel,
|
|
498245
|
+
...config4.gates.fastModeEnabled && {
|
|
498246
|
+
fastMode: appState.fastMode
|
|
498247
|
+
},
|
|
498248
|
+
toolChoice: undefined,
|
|
498249
|
+
isNonInteractiveSession: toolUseContext.options.isNonInteractiveSession,
|
|
498250
|
+
fallbackModel,
|
|
498251
|
+
onStreamingFallback: () => {
|
|
498252
|
+
streamingFallbackOccured = true;
|
|
498253
|
+
},
|
|
498254
|
+
querySource,
|
|
498255
|
+
agents: toolUseContext.options.agentDefinitions.activeAgents,
|
|
498256
|
+
allowedAgentTypes: toolUseContext.options.agentDefinitions.allowedAgentTypes,
|
|
498257
|
+
hasAppendSystemPrompt: !!toolUseContext.options.appendSystemPrompt,
|
|
498258
|
+
maxOutputTokensOverride,
|
|
498259
|
+
fetchOverride: dumpPromptsFetch,
|
|
498260
|
+
mcpTools: appState.mcp.tools,
|
|
498261
|
+
hasPendingMcpServers: appState.mcp.clients.some((c5) => c5.type === "pending"),
|
|
498262
|
+
queryTracking,
|
|
498263
|
+
effortValue: appState.effortValue,
|
|
498264
|
+
advisorModel: appState.advisorModel,
|
|
498265
|
+
skipCacheWrite,
|
|
498266
|
+
agentId: toolUseContext.agentId,
|
|
498267
|
+
addNotification: toolUseContext.addNotification,
|
|
498268
|
+
routeContext: buildRouteContext(turnCount, querySource, messagesForQuery, toolUseContext.options.maxBudgetUsd),
|
|
498269
|
+
...params.taskBudget && {
|
|
498270
|
+
taskBudget: {
|
|
498271
|
+
total: params.taskBudget.total,
|
|
498272
|
+
...taskBudgetRemaining !== undefined && {
|
|
498273
|
+
remaining: taskBudgetRemaining
|
|
498274
|
+
}
|
|
497978
498275
|
}
|
|
497979
498276
|
}
|
|
497980
498277
|
}
|
|
497981
|
-
}
|
|
497982
|
-
|
|
497983
|
-
|
|
497984
|
-
|
|
497985
|
-
|
|
497986
|
-
|
|
497987
|
-
|
|
497988
|
-
|
|
497989
|
-
|
|
497990
|
-
|
|
497991
|
-
|
|
497992
|
-
|
|
497993
|
-
|
|
498278
|
+
})) {
|
|
498279
|
+
if (streamingFallbackOccured) {
|
|
498280
|
+
for (const msg of assistantMessages) {
|
|
498281
|
+
yield { type: "tombstone", message: msg };
|
|
498282
|
+
}
|
|
498283
|
+
assistantMessages.length = 0;
|
|
498284
|
+
toolResults.length = 0;
|
|
498285
|
+
toolUseBlocks.length = 0;
|
|
498286
|
+
needsFollowUp = false;
|
|
498287
|
+
if (streamingToolExecutor) {
|
|
498288
|
+
streamingToolExecutor.discard();
|
|
498289
|
+
streamingToolExecutor = new StreamingToolExecutor(toolUseContext.options.tools, canUseTool, toolUseContext);
|
|
498290
|
+
}
|
|
497994
498291
|
}
|
|
497995
|
-
|
|
497996
|
-
|
|
497997
|
-
|
|
497998
|
-
|
|
497999
|
-
|
|
498000
|
-
|
|
498001
|
-
|
|
498002
|
-
|
|
498003
|
-
|
|
498004
|
-
|
|
498005
|
-
|
|
498006
|
-
|
|
498007
|
-
|
|
498008
|
-
|
|
498009
|
-
|
|
498010
|
-
|
|
498292
|
+
let yieldMessage = message;
|
|
498293
|
+
if (message.type === "assistant") {
|
|
498294
|
+
let clonedContent;
|
|
498295
|
+
for (let i4 = 0;i4 < message.message.content.length; i4++) {
|
|
498296
|
+
const block2 = message.message.content[i4];
|
|
498297
|
+
if (block2.type === "tool_use" && typeof block2.input === "object" && block2.input !== null) {
|
|
498298
|
+
const tool = findToolByName(toolUseContext.options.tools, block2.name);
|
|
498299
|
+
if (tool?.backfillObservableInput) {
|
|
498300
|
+
const originalInput = block2.input;
|
|
498301
|
+
const inputCopy = { ...originalInput };
|
|
498302
|
+
tool.backfillObservableInput(inputCopy);
|
|
498303
|
+
const addedFields = Object.keys(inputCopy).some((k2) => !(k2 in originalInput));
|
|
498304
|
+
if (addedFields) {
|
|
498305
|
+
clonedContent ??= [...message.message.content];
|
|
498306
|
+
clonedContent[i4] = { ...block2, input: inputCopy };
|
|
498307
|
+
}
|
|
498011
498308
|
}
|
|
498012
498309
|
}
|
|
498013
498310
|
}
|
|
498311
|
+
if (clonedContent) {
|
|
498312
|
+
yieldMessage = {
|
|
498313
|
+
...message,
|
|
498314
|
+
message: { ...message.message, content: clonedContent }
|
|
498315
|
+
};
|
|
498316
|
+
}
|
|
498014
498317
|
}
|
|
498015
|
-
|
|
498016
|
-
|
|
498017
|
-
|
|
498018
|
-
|
|
498019
|
-
};
|
|
498318
|
+
let withheld = false;
|
|
498319
|
+
if (false) {}
|
|
498320
|
+
if (reactiveCompact2?.isWithheldPromptTooLong(message)) {
|
|
498321
|
+
withheld = true;
|
|
498020
498322
|
}
|
|
498021
|
-
|
|
498022
|
-
|
|
498023
|
-
if (false) {}
|
|
498024
|
-
if (reactiveCompact2?.isWithheldPromptTooLong(message)) {
|
|
498025
|
-
withheld = true;
|
|
498026
|
-
}
|
|
498027
|
-
if (mediaRecoveryEnabled && reactiveCompact2?.isWithheldMediaSizeError(message)) {
|
|
498028
|
-
withheld = true;
|
|
498029
|
-
}
|
|
498030
|
-
if (isWithheldMaxOutputTokens(message)) {
|
|
498031
|
-
withheld = true;
|
|
498032
|
-
}
|
|
498033
|
-
if (!withheld) {
|
|
498034
|
-
yield yieldMessage;
|
|
498035
|
-
}
|
|
498036
|
-
if (message.type === "assistant") {
|
|
498037
|
-
assistantMessages.push(message);
|
|
498038
|
-
const msgToolUseBlocks = message.message.content.filter((content) => content.type === "tool_use");
|
|
498039
|
-
if (msgToolUseBlocks.length > 0) {
|
|
498040
|
-
toolUseBlocks.push(...msgToolUseBlocks);
|
|
498041
|
-
needsFollowUp = true;
|
|
498323
|
+
if (mediaRecoveryEnabled && reactiveCompact2?.isWithheldMediaSizeError(message)) {
|
|
498324
|
+
withheld = true;
|
|
498042
498325
|
}
|
|
498043
|
-
if (
|
|
498044
|
-
|
|
498045
|
-
|
|
498326
|
+
if (isWithheldMaxOutputTokens(message)) {
|
|
498327
|
+
withheld = true;
|
|
498328
|
+
}
|
|
498329
|
+
if (!withheld) {
|
|
498330
|
+
yield yieldMessage;
|
|
498331
|
+
}
|
|
498332
|
+
if (message.type === "assistant") {
|
|
498333
|
+
assistantMessages.push(message);
|
|
498334
|
+
const msgToolUseBlocks = message.message.content.filter((content) => content.type === "tool_use");
|
|
498335
|
+
if (msgToolUseBlocks.length > 0) {
|
|
498336
|
+
toolUseBlocks.push(...msgToolUseBlocks);
|
|
498337
|
+
needsFollowUp = true;
|
|
498338
|
+
}
|
|
498339
|
+
if (streamingToolExecutor && !toolUseContext.abortController.signal.aborted) {
|
|
498340
|
+
for (const toolBlock of msgToolUseBlocks) {
|
|
498341
|
+
streamingToolExecutor.addTool(toolBlock, message);
|
|
498342
|
+
}
|
|
498046
498343
|
}
|
|
498047
498344
|
}
|
|
498048
|
-
|
|
498049
|
-
|
|
498050
|
-
|
|
498051
|
-
|
|
498052
|
-
|
|
498053
|
-
|
|
498345
|
+
if (streamingToolExecutor && !toolUseContext.abortController.signal.aborted) {
|
|
498346
|
+
for (const result of streamingToolExecutor.getCompletedResults()) {
|
|
498347
|
+
if (result.message) {
|
|
498348
|
+
yield result.message;
|
|
498349
|
+
toolResults.push(...normalizeMessagesForAPI([result.message], toolUseContext.options.tools).filter((_) => _.type === "user"));
|
|
498350
|
+
}
|
|
498054
498351
|
}
|
|
498055
498352
|
}
|
|
498056
498353
|
}
|
|
498057
|
-
|
|
498058
|
-
|
|
498059
|
-
|
|
498060
|
-
|
|
498061
|
-
|
|
498062
|
-
|
|
498063
|
-
|
|
498064
|
-
|
|
498065
|
-
|
|
498066
|
-
|
|
498067
|
-
|
|
498068
|
-
|
|
498069
|
-
|
|
498070
|
-
|
|
498071
|
-
|
|
498072
|
-
|
|
498073
|
-
|
|
498074
|
-
|
|
498075
|
-
|
|
498354
|
+
queryCheckpoint("query_api_streaming_end");
|
|
498355
|
+
if (false) {}
|
|
498356
|
+
} catch (innerError) {
|
|
498357
|
+
if (innerError instanceof FallbackTriggeredError && fallbackModel) {
|
|
498358
|
+
currentModel = fallbackModel;
|
|
498359
|
+
attemptWithFallback = true;
|
|
498360
|
+
yield* yieldMissingToolResultBlocks(assistantMessages, "Model fallback triggered");
|
|
498361
|
+
assistantMessages.length = 0;
|
|
498362
|
+
toolResults.length = 0;
|
|
498363
|
+
toolUseBlocks.length = 0;
|
|
498364
|
+
needsFollowUp = false;
|
|
498365
|
+
if (streamingToolExecutor) {
|
|
498366
|
+
streamingToolExecutor.discard();
|
|
498367
|
+
streamingToolExecutor = new StreamingToolExecutor(toolUseContext.options.tools, canUseTool, toolUseContext);
|
|
498368
|
+
}
|
|
498369
|
+
toolUseContext.options.mainLoopModel = fallbackModel;
|
|
498370
|
+
if (process.env.USER_TYPE === "ant") {
|
|
498371
|
+
messagesForQuery = stripSignatureBlocks(messagesForQuery);
|
|
498372
|
+
}
|
|
498373
|
+
yield createSystemMessage(`Switched to ${renderModelName(innerError.fallbackModel)} due to high demand for ${renderModelName(innerError.originalModel)}`, "warning");
|
|
498374
|
+
continue;
|
|
498076
498375
|
}
|
|
498077
|
-
|
|
498078
|
-
continue;
|
|
498376
|
+
throw innerError;
|
|
498079
498377
|
}
|
|
498080
|
-
throw innerError;
|
|
498081
498378
|
}
|
|
498082
|
-
}
|
|
498083
|
-
|
|
498084
|
-
|
|
498085
|
-
|
|
498086
|
-
|
|
498379
|
+
} catch (error41) {
|
|
498380
|
+
logError2(error41);
|
|
498381
|
+
const errorMessage2 = error41 instanceof Error ? error41.message : String(error41);
|
|
498382
|
+
if (error41 instanceof ImageSizeError || error41 instanceof ImageResizeError) {
|
|
498383
|
+
yield createAssistantAPIErrorMessage({
|
|
498384
|
+
content: error41.message
|
|
498385
|
+
});
|
|
498386
|
+
return { reason: "image_error" };
|
|
498387
|
+
}
|
|
498388
|
+
yield* yieldMissingToolResultBlocks(assistantMessages, errorMessage2);
|
|
498087
498389
|
yield createAssistantAPIErrorMessage({
|
|
498088
|
-
content:
|
|
498390
|
+
content: errorMessage2
|
|
498089
498391
|
});
|
|
498090
|
-
|
|
498392
|
+
logAntError("Query error", error41);
|
|
498393
|
+
return { reason: "model_error", error: error41 };
|
|
498091
498394
|
}
|
|
498092
|
-
|
|
498093
|
-
|
|
498094
|
-
|
|
498095
|
-
|
|
498096
|
-
|
|
498097
|
-
|
|
498098
|
-
|
|
498099
|
-
|
|
498100
|
-
|
|
498101
|
-
}
|
|
498102
|
-
if (toolUseContext.abortController.signal.aborted) {
|
|
498103
|
-
if (streamingToolExecutor) {
|
|
498104
|
-
for await (const update of streamingToolExecutor.getRemainingResults()) {
|
|
498105
|
-
if (update.message) {
|
|
498106
|
-
yield update.message;
|
|
498395
|
+
if (assistantMessages.length > 0) {
|
|
498396
|
+
executePostSamplingHooks([...messagesForQuery, ...assistantMessages], systemPrompt, userContext, systemContext, toolUseContext, querySource);
|
|
498397
|
+
}
|
|
498398
|
+
if (toolUseContext.abortController.signal.aborted) {
|
|
498399
|
+
if (streamingToolExecutor) {
|
|
498400
|
+
for await (const update of streamingToolExecutor.getRemainingResults()) {
|
|
498401
|
+
if (update.message) {
|
|
498402
|
+
yield update.message;
|
|
498403
|
+
}
|
|
498107
498404
|
}
|
|
498405
|
+
} else {
|
|
498406
|
+
yield* yieldMissingToolResultBlocks(assistantMessages, "Interrupted by user");
|
|
498108
498407
|
}
|
|
498109
|
-
} else {
|
|
498110
|
-
yield* yieldMissingToolResultBlocks(assistantMessages, "Interrupted by user");
|
|
498111
|
-
}
|
|
498112
|
-
if (false) {}
|
|
498113
|
-
if (toolUseContext.abortController.signal.reason !== "interrupt") {
|
|
498114
|
-
yield createUserInterruptionMessage({
|
|
498115
|
-
toolUse: false
|
|
498116
|
-
});
|
|
498117
|
-
}
|
|
498118
|
-
return { reason: "aborted_streaming" };
|
|
498119
|
-
}
|
|
498120
|
-
if (pendingToolUseSummary) {
|
|
498121
|
-
const summary = await pendingToolUseSummary;
|
|
498122
|
-
if (summary) {
|
|
498123
|
-
yield summary;
|
|
498124
|
-
}
|
|
498125
|
-
}
|
|
498126
|
-
if (!needsFollowUp) {
|
|
498127
|
-
const lastMessage = assistantMessages.at(-1);
|
|
498128
|
-
const isWithheld413 = lastMessage?.type === "assistant" && lastMessage.isApiErrorMessage && isPromptTooLongMessage(lastMessage);
|
|
498129
|
-
const isWithheldMedia = mediaRecoveryEnabled && reactiveCompact2?.isWithheldMediaSizeError(lastMessage);
|
|
498130
|
-
if (isWithheld413) {
|
|
498131
498408
|
if (false) {}
|
|
498409
|
+
if (toolUseContext.abortController.signal.reason !== "interrupt") {
|
|
498410
|
+
yield createUserInterruptionMessage({
|
|
498411
|
+
toolUse: false
|
|
498412
|
+
});
|
|
498413
|
+
}
|
|
498414
|
+
return { reason: "aborted_streaming" };
|
|
498132
498415
|
}
|
|
498133
|
-
if (
|
|
498134
|
-
const
|
|
498135
|
-
|
|
498136
|
-
|
|
498137
|
-
|
|
498138
|
-
|
|
498139
|
-
|
|
498140
|
-
|
|
498141
|
-
|
|
498142
|
-
|
|
498143
|
-
|
|
498144
|
-
|
|
498416
|
+
if (pendingToolUseSummary) {
|
|
498417
|
+
const summary = await pendingToolUseSummary;
|
|
498418
|
+
if (summary) {
|
|
498419
|
+
yield summary;
|
|
498420
|
+
}
|
|
498421
|
+
}
|
|
498422
|
+
if (!needsFollowUp) {
|
|
498423
|
+
const lastMessage = assistantMessages.at(-1);
|
|
498424
|
+
const isWithheld413 = lastMessage?.type === "assistant" && lastMessage.isApiErrorMessage && isPromptTooLongMessage(lastMessage);
|
|
498425
|
+
const isWithheldMedia = mediaRecoveryEnabled && reactiveCompact2?.isWithheldMediaSizeError(lastMessage);
|
|
498426
|
+
if (isWithheld413) {
|
|
498427
|
+
if (false) {}
|
|
498428
|
+
}
|
|
498429
|
+
if ((isWithheld413 || isWithheldMedia) && reactiveCompact2) {
|
|
498430
|
+
const compacted = await reactiveCompact2.tryReactiveCompact({
|
|
498431
|
+
hasAttempted: hasAttemptedReactiveCompact,
|
|
498432
|
+
querySource,
|
|
498433
|
+
aborted: toolUseContext.abortController.signal.aborted,
|
|
498434
|
+
messages: messagesForQuery,
|
|
498435
|
+
cacheSafeParams: {
|
|
498436
|
+
systemPrompt,
|
|
498437
|
+
userContext,
|
|
498438
|
+
systemContext,
|
|
498439
|
+
toolUseContext,
|
|
498440
|
+
forkContextMessages: messagesForQuery
|
|
498441
|
+
}
|
|
498442
|
+
});
|
|
498443
|
+
if (compacted) {
|
|
498444
|
+
if (params.taskBudget) {
|
|
498445
|
+
const preCompactContext = finalContextTokensFromLastResponse(messagesForQuery);
|
|
498446
|
+
taskBudgetRemaining = Math.max(0, (taskBudgetRemaining ?? params.taskBudget.total) - preCompactContext);
|
|
498447
|
+
}
|
|
498448
|
+
const postCompactMessages = buildPostCompactMessages(compacted);
|
|
498449
|
+
for (const msg of postCompactMessages) {
|
|
498450
|
+
yield msg;
|
|
498451
|
+
}
|
|
498452
|
+
const next3 = {
|
|
498453
|
+
messages: postCompactMessages,
|
|
498454
|
+
toolUseContext,
|
|
498455
|
+
autoCompactTracking: undefined,
|
|
498456
|
+
maxOutputTokensRecoveryCount,
|
|
498457
|
+
hasAttemptedReactiveCompact: true,
|
|
498458
|
+
maxOutputTokensOverride: undefined,
|
|
498459
|
+
pendingToolUseSummary: undefined,
|
|
498460
|
+
stopHookActive: undefined,
|
|
498461
|
+
turnCount,
|
|
498462
|
+
transition: { reason: "reactive_compact_retry" }
|
|
498463
|
+
};
|
|
498464
|
+
state = next3;
|
|
498465
|
+
continue;
|
|
498145
498466
|
}
|
|
498146
|
-
|
|
498147
|
-
|
|
498148
|
-
|
|
498149
|
-
|
|
498150
|
-
|
|
498467
|
+
yield lastMessage;
|
|
498468
|
+
executeStopFailureHooks(lastMessage, toolUseContext);
|
|
498469
|
+
return { reason: isWithheldMedia ? "image_error" : "prompt_too_long" };
|
|
498470
|
+
} else if (isWithheld413) {
|
|
498471
|
+
try {
|
|
498472
|
+
const forcedCompactionResult = await compactConversation(messagesForQuery, toolUseContext, {
|
|
498473
|
+
systemPrompt,
|
|
498474
|
+
userContext,
|
|
498475
|
+
systemContext,
|
|
498476
|
+
toolUseContext,
|
|
498477
|
+
forkContextMessages: messagesForQuery
|
|
498478
|
+
}, true, undefined, true, {
|
|
498479
|
+
isRecompactionInChain: tracking?.compacted === true,
|
|
498480
|
+
turnsSincePreviousCompact: tracking?.turnCounter ?? -1,
|
|
498481
|
+
previousCompactTurnId: tracking?.turnId,
|
|
498482
|
+
autoCompactThreshold: getAutoCompactThreshold(currentModel),
|
|
498483
|
+
querySource
|
|
498484
|
+
});
|
|
498485
|
+
if (params.taskBudget) {
|
|
498486
|
+
const preCompactContext = finalContextTokensFromLastResponse(messagesForQuery);
|
|
498487
|
+
taskBudgetRemaining = Math.max(0, (taskBudgetRemaining ?? params.taskBudget.total) - preCompactContext);
|
|
498488
|
+
}
|
|
498489
|
+
const postCompactMessages = buildPostCompactMessages(forcedCompactionResult);
|
|
498490
|
+
for (const msg of postCompactMessages) {
|
|
498491
|
+
yield msg;
|
|
498492
|
+
}
|
|
498493
|
+
tracking = {
|
|
498494
|
+
compacted: true,
|
|
498495
|
+
turnId: deps.uuid(),
|
|
498496
|
+
turnCounter: 0,
|
|
498497
|
+
consecutiveFailures: 0
|
|
498498
|
+
};
|
|
498499
|
+
const next3 = {
|
|
498500
|
+
messages: postCompactMessages,
|
|
498501
|
+
toolUseContext,
|
|
498502
|
+
autoCompactTracking: tracking,
|
|
498503
|
+
maxOutputTokensRecoveryCount,
|
|
498504
|
+
hasAttemptedReactiveCompact: true,
|
|
498505
|
+
maxOutputTokensOverride: undefined,
|
|
498506
|
+
pendingToolUseSummary: undefined,
|
|
498507
|
+
stopHookActive: undefined,
|
|
498508
|
+
turnCount,
|
|
498509
|
+
transition: { reason: "forced_prompt_too_long_compact_retry" }
|
|
498510
|
+
};
|
|
498511
|
+
state = next3;
|
|
498512
|
+
continue;
|
|
498513
|
+
} catch {
|
|
498514
|
+
yield lastMessage;
|
|
498515
|
+
executeStopFailureHooks(lastMessage, toolUseContext);
|
|
498516
|
+
return { reason: "prompt_too_long" };
|
|
498151
498517
|
}
|
|
498152
|
-
|
|
498153
|
-
|
|
498154
|
-
|
|
498518
|
+
} else if (false) {}
|
|
498519
|
+
if (isWithheldMaxOutputTokens(lastMessage)) {
|
|
498520
|
+
const capEnabled = false;
|
|
498521
|
+
if (capEnabled && maxOutputTokensOverride === undefined && !process.env.CLAUDE_CODE_MAX_OUTPUT_TOKENS) {
|
|
498522
|
+
const next3 = {
|
|
498523
|
+
messages: messagesForQuery,
|
|
498524
|
+
toolUseContext,
|
|
498525
|
+
autoCompactTracking: tracking,
|
|
498526
|
+
maxOutputTokensRecoveryCount,
|
|
498527
|
+
hasAttemptedReactiveCompact,
|
|
498528
|
+
maxOutputTokensOverride: ESCALATED_MAX_TOKENS,
|
|
498529
|
+
pendingToolUseSummary: undefined,
|
|
498530
|
+
stopHookActive: undefined,
|
|
498531
|
+
turnCount,
|
|
498532
|
+
transition: { reason: "max_output_tokens_escalate" }
|
|
498533
|
+
};
|
|
498534
|
+
state = next3;
|
|
498535
|
+
continue;
|
|
498536
|
+
}
|
|
498537
|
+
if (maxOutputTokensRecoveryCount < MAX_OUTPUT_TOKENS_RECOVERY_LIMIT) {
|
|
498538
|
+
const recoveryMessage = createUserMessage({
|
|
498539
|
+
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.`,
|
|
498540
|
+
isMeta: true
|
|
498541
|
+
});
|
|
498542
|
+
const next3 = {
|
|
498543
|
+
messages: [
|
|
498544
|
+
...messagesForQuery,
|
|
498545
|
+
...assistantMessages,
|
|
498546
|
+
recoveryMessage
|
|
498547
|
+
],
|
|
498548
|
+
toolUseContext,
|
|
498549
|
+
autoCompactTracking: tracking,
|
|
498550
|
+
maxOutputTokensRecoveryCount: maxOutputTokensRecoveryCount + 1,
|
|
498551
|
+
hasAttemptedReactiveCompact,
|
|
498552
|
+
maxOutputTokensOverride: undefined,
|
|
498553
|
+
pendingToolUseSummary: undefined,
|
|
498554
|
+
stopHookActive: undefined,
|
|
498555
|
+
turnCount,
|
|
498556
|
+
transition: {
|
|
498557
|
+
reason: "max_output_tokens_recovery",
|
|
498558
|
+
attempt: maxOutputTokensRecoveryCount + 1
|
|
498559
|
+
}
|
|
498560
|
+
};
|
|
498561
|
+
state = next3;
|
|
498562
|
+
continue;
|
|
498155
498563
|
}
|
|
498156
|
-
const next3 = {
|
|
498157
|
-
messages: postCompactMessages,
|
|
498158
|
-
toolUseContext,
|
|
498159
|
-
autoCompactTracking: undefined,
|
|
498160
|
-
maxOutputTokensRecoveryCount,
|
|
498161
|
-
hasAttemptedReactiveCompact: true,
|
|
498162
|
-
maxOutputTokensOverride: undefined,
|
|
498163
|
-
pendingToolUseSummary: undefined,
|
|
498164
|
-
stopHookActive: undefined,
|
|
498165
|
-
turnCount,
|
|
498166
|
-
transition: { reason: "reactive_compact_retry" }
|
|
498167
|
-
};
|
|
498168
|
-
state = next3;
|
|
498169
|
-
continue;
|
|
498170
|
-
}
|
|
498171
|
-
yield lastMessage;
|
|
498172
|
-
executeStopFailureHooks(lastMessage, toolUseContext);
|
|
498173
|
-
return { reason: isWithheldMedia ? "image_error" : "prompt_too_long" };
|
|
498174
|
-
} else if (isWithheld413) {
|
|
498175
|
-
try {
|
|
498176
|
-
const forcedCompactionResult = await compactConversation(messagesForQuery, toolUseContext, {
|
|
498177
|
-
systemPrompt,
|
|
498178
|
-
userContext,
|
|
498179
|
-
systemContext,
|
|
498180
|
-
toolUseContext,
|
|
498181
|
-
forkContextMessages: messagesForQuery
|
|
498182
|
-
}, true, undefined, true, {
|
|
498183
|
-
isRecompactionInChain: tracking?.compacted === true,
|
|
498184
|
-
turnsSincePreviousCompact: tracking?.turnCounter ?? -1,
|
|
498185
|
-
previousCompactTurnId: tracking?.turnId,
|
|
498186
|
-
autoCompactThreshold: getAutoCompactThreshold(currentModel),
|
|
498187
|
-
querySource
|
|
498188
|
-
});
|
|
498189
|
-
if (params.taskBudget) {
|
|
498190
|
-
const preCompactContext = finalContextTokensFromLastResponse(messagesForQuery);
|
|
498191
|
-
taskBudgetRemaining = Math.max(0, (taskBudgetRemaining ?? params.taskBudget.total) - preCompactContext);
|
|
498192
|
-
}
|
|
498193
|
-
const postCompactMessages = buildPostCompactMessages(forcedCompactionResult);
|
|
498194
|
-
for (const msg of postCompactMessages) {
|
|
498195
|
-
yield msg;
|
|
498196
|
-
}
|
|
498197
|
-
tracking = {
|
|
498198
|
-
compacted: true,
|
|
498199
|
-
turnId: deps.uuid(),
|
|
498200
|
-
turnCounter: 0,
|
|
498201
|
-
consecutiveFailures: 0
|
|
498202
|
-
};
|
|
498203
|
-
const next3 = {
|
|
498204
|
-
messages: postCompactMessages,
|
|
498205
|
-
toolUseContext,
|
|
498206
|
-
autoCompactTracking: tracking,
|
|
498207
|
-
maxOutputTokensRecoveryCount,
|
|
498208
|
-
hasAttemptedReactiveCompact: true,
|
|
498209
|
-
maxOutputTokensOverride: undefined,
|
|
498210
|
-
pendingToolUseSummary: undefined,
|
|
498211
|
-
stopHookActive: undefined,
|
|
498212
|
-
turnCount,
|
|
498213
|
-
transition: { reason: "forced_prompt_too_long_compact_retry" }
|
|
498214
|
-
};
|
|
498215
|
-
state = next3;
|
|
498216
|
-
continue;
|
|
498217
|
-
} catch {
|
|
498218
498564
|
yield lastMessage;
|
|
498565
|
+
}
|
|
498566
|
+
if (lastMessage?.isApiErrorMessage) {
|
|
498219
498567
|
executeStopFailureHooks(lastMessage, toolUseContext);
|
|
498220
|
-
return { reason: "
|
|
498568
|
+
return { reason: "completed" };
|
|
498221
498569
|
}
|
|
498222
|
-
|
|
498223
|
-
|
|
498224
|
-
|
|
498225
|
-
if (capEnabled && maxOutputTokensOverride === undefined && !process.env.CLAUDE_CODE_MAX_OUTPUT_TOKENS) {
|
|
498226
|
-
const next3 = {
|
|
498227
|
-
messages: messagesForQuery,
|
|
498228
|
-
toolUseContext,
|
|
498229
|
-
autoCompactTracking: tracking,
|
|
498230
|
-
maxOutputTokensRecoveryCount,
|
|
498231
|
-
hasAttemptedReactiveCompact,
|
|
498232
|
-
maxOutputTokensOverride: ESCALATED_MAX_TOKENS,
|
|
498233
|
-
pendingToolUseSummary: undefined,
|
|
498234
|
-
stopHookActive: undefined,
|
|
498235
|
-
turnCount,
|
|
498236
|
-
transition: { reason: "max_output_tokens_escalate" }
|
|
498237
|
-
};
|
|
498238
|
-
state = next3;
|
|
498239
|
-
continue;
|
|
498570
|
+
const stopHookResult = yield* handleStopHooks(messagesForQuery, assistantMessages, systemPrompt, userContext, systemContext, toolUseContext, querySource, stopHookActive);
|
|
498571
|
+
if (stopHookResult.preventContinuation) {
|
|
498572
|
+
return { reason: "stop_hook_prevented" };
|
|
498240
498573
|
}
|
|
498241
|
-
if (
|
|
498242
|
-
const recoveryMessage = createUserMessage({
|
|
498243
|
-
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.`,
|
|
498244
|
-
isMeta: true
|
|
498245
|
-
});
|
|
498574
|
+
if (stopHookResult.blockingErrors.length > 0) {
|
|
498246
498575
|
const next3 = {
|
|
498247
498576
|
messages: [
|
|
498248
498577
|
...messagesForQuery,
|
|
498249
498578
|
...assistantMessages,
|
|
498250
|
-
|
|
498579
|
+
...stopHookResult.blockingErrors
|
|
498251
498580
|
],
|
|
498252
498581
|
toolUseContext,
|
|
498253
498582
|
autoCompactTracking: tracking,
|
|
498254
|
-
maxOutputTokensRecoveryCount:
|
|
498583
|
+
maxOutputTokensRecoveryCount: 0,
|
|
498255
498584
|
hasAttemptedReactiveCompact,
|
|
498256
498585
|
maxOutputTokensOverride: undefined,
|
|
498257
498586
|
pendingToolUseSummary: undefined,
|
|
498258
|
-
stopHookActive:
|
|
498587
|
+
stopHookActive: true,
|
|
498259
498588
|
turnCount,
|
|
498260
|
-
transition: {
|
|
498261
|
-
reason: "max_output_tokens_recovery",
|
|
498262
|
-
attempt: maxOutputTokensRecoveryCount + 1
|
|
498263
|
-
}
|
|
498589
|
+
transition: { reason: "stop_hook_blocking" }
|
|
498264
498590
|
};
|
|
498265
498591
|
state = next3;
|
|
498266
498592
|
continue;
|
|
498267
498593
|
}
|
|
498268
|
-
|
|
498269
|
-
}
|
|
498270
|
-
if (lastMessage?.isApiErrorMessage) {
|
|
498271
|
-
executeStopFailureHooks(lastMessage, toolUseContext);
|
|
498594
|
+
if (false) {}
|
|
498272
498595
|
return { reason: "completed" };
|
|
498273
498596
|
}
|
|
498274
|
-
|
|
498275
|
-
|
|
498276
|
-
|
|
498277
|
-
}
|
|
498278
|
-
|
|
498279
|
-
|
|
498280
|
-
|
|
498281
|
-
|
|
498282
|
-
|
|
498283
|
-
|
|
498284
|
-
],
|
|
498285
|
-
toolUseContext,
|
|
498286
|
-
autoCompactTracking: tracking,
|
|
498287
|
-
maxOutputTokensRecoveryCount: 0,
|
|
498288
|
-
hasAttemptedReactiveCompact,
|
|
498289
|
-
maxOutputTokensOverride: undefined,
|
|
498290
|
-
pendingToolUseSummary: undefined,
|
|
498291
|
-
stopHookActive: true,
|
|
498292
|
-
turnCount,
|
|
498293
|
-
transition: { reason: "stop_hook_blocking" }
|
|
498294
|
-
};
|
|
498295
|
-
state = next3;
|
|
498296
|
-
continue;
|
|
498297
|
-
}
|
|
498298
|
-
if (false) {}
|
|
498299
|
-
return { reason: "completed" };
|
|
498300
|
-
}
|
|
498301
|
-
let shouldPreventContinuation = false;
|
|
498302
|
-
let updatedToolUseContext = toolUseContext;
|
|
498303
|
-
queryCheckpoint("query_tool_execution_start");
|
|
498304
|
-
if (streamingToolExecutor) {}
|
|
498305
|
-
const toolUpdates = streamingToolExecutor ? streamingToolExecutor.getRemainingResults() : runTools(toolUseBlocks, assistantMessages, canUseTool, toolUseContext);
|
|
498306
|
-
for await (const update of toolUpdates) {
|
|
498307
|
-
if (update.message) {
|
|
498308
|
-
yield update.message;
|
|
498309
|
-
if (update.message.type === "attachment" && update.message.attachment.type === "hook_stopped_continuation") {
|
|
498310
|
-
shouldPreventContinuation = true;
|
|
498311
|
-
}
|
|
498312
|
-
toolResults.push(...normalizeMessagesForAPI([update.message], toolUseContext.options.tools).filter((_) => _.type === "user"));
|
|
498313
|
-
}
|
|
498314
|
-
if (update.newContext) {
|
|
498315
|
-
updatedToolUseContext = {
|
|
498316
|
-
...update.newContext,
|
|
498317
|
-
queryTracking
|
|
498318
|
-
};
|
|
498319
|
-
}
|
|
498320
|
-
}
|
|
498321
|
-
queryCheckpoint("query_tool_execution_end");
|
|
498322
|
-
let nextPendingToolUseSummary;
|
|
498323
|
-
if (config4.gates.emitToolUseSummaries && toolUseBlocks.length > 0 && !toolUseContext.abortController.signal.aborted && !toolUseContext.agentId) {
|
|
498324
|
-
const lastAssistantMessage = assistantMessages.at(-1);
|
|
498325
|
-
let lastAssistantText;
|
|
498326
|
-
if (lastAssistantMessage) {
|
|
498327
|
-
const textBlocks = lastAssistantMessage.message.content.filter((block2) => block2.type === "text");
|
|
498328
|
-
if (textBlocks.length > 0) {
|
|
498329
|
-
const lastTextBlock = textBlocks.at(-1);
|
|
498330
|
-
if (lastTextBlock && "text" in lastTextBlock) {
|
|
498331
|
-
lastAssistantText = lastTextBlock.text;
|
|
498597
|
+
let shouldPreventContinuation = false;
|
|
498598
|
+
let updatedToolUseContext = toolUseContext;
|
|
498599
|
+
queryCheckpoint("query_tool_execution_start");
|
|
498600
|
+
if (streamingToolExecutor) {}
|
|
498601
|
+
const toolUpdates = streamingToolExecutor ? streamingToolExecutor.getRemainingResults() : runTools(toolUseBlocks, assistantMessages, canUseTool, toolUseContext);
|
|
498602
|
+
for await (const update of toolUpdates) {
|
|
498603
|
+
if (update.message) {
|
|
498604
|
+
yield update.message;
|
|
498605
|
+
if (update.message.type === "attachment" && update.message.attachment.type === "hook_stopped_continuation") {
|
|
498606
|
+
shouldPreventContinuation = true;
|
|
498332
498607
|
}
|
|
498608
|
+
toolResults.push(...normalizeMessagesForAPI([update.message], toolUseContext.options.tools).filter((_) => _.type === "user"));
|
|
498609
|
+
}
|
|
498610
|
+
if (update.newContext) {
|
|
498611
|
+
updatedToolUseContext = {
|
|
498612
|
+
...update.newContext,
|
|
498613
|
+
queryTracking
|
|
498614
|
+
};
|
|
498333
498615
|
}
|
|
498334
498616
|
}
|
|
498335
|
-
|
|
498336
|
-
|
|
498337
|
-
|
|
498338
|
-
const
|
|
498339
|
-
|
|
498340
|
-
|
|
498341
|
-
|
|
498342
|
-
|
|
498343
|
-
|
|
498344
|
-
|
|
498345
|
-
|
|
498346
|
-
|
|
498347
|
-
|
|
498348
|
-
isNonInteractiveSession: toolUseContext.options.isNonInteractiveSession,
|
|
498349
|
-
lastAssistantText
|
|
498350
|
-
}).then((summary) => {
|
|
498351
|
-
if (summary) {
|
|
498352
|
-
return createToolUseSummaryMessage(summary, toolUseIds);
|
|
498617
|
+
queryCheckpoint("query_tool_execution_end");
|
|
498618
|
+
let nextPendingToolUseSummary;
|
|
498619
|
+
if (config4.gates.emitToolUseSummaries && toolUseBlocks.length > 0 && !toolUseContext.abortController.signal.aborted && !toolUseContext.agentId) {
|
|
498620
|
+
const lastAssistantMessage = assistantMessages.at(-1);
|
|
498621
|
+
let lastAssistantText;
|
|
498622
|
+
if (lastAssistantMessage) {
|
|
498623
|
+
const textBlocks = lastAssistantMessage.message.content.filter((block2) => block2.type === "text");
|
|
498624
|
+
if (textBlocks.length > 0) {
|
|
498625
|
+
const lastTextBlock = textBlocks.at(-1);
|
|
498626
|
+
if (lastTextBlock && "text" in lastTextBlock) {
|
|
498627
|
+
lastAssistantText = lastTextBlock.text;
|
|
498628
|
+
}
|
|
498629
|
+
}
|
|
498353
498630
|
}
|
|
498354
|
-
|
|
498355
|
-
|
|
498356
|
-
|
|
498357
|
-
|
|
498358
|
-
|
|
498359
|
-
|
|
498360
|
-
|
|
498361
|
-
|
|
498631
|
+
const toolUseIds = toolUseBlocks.map((block2) => block2.id);
|
|
498632
|
+
const toolInfoForSummary = toolUseBlocks.map((block2) => {
|
|
498633
|
+
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));
|
|
498634
|
+
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;
|
|
498635
|
+
return {
|
|
498636
|
+
name: block2.name,
|
|
498637
|
+
input: block2.input,
|
|
498638
|
+
output: resultContent && "content" in resultContent ? resultContent.content : null
|
|
498639
|
+
};
|
|
498362
498640
|
});
|
|
498641
|
+
nextPendingToolUseSummary = generateToolUseSummary({
|
|
498642
|
+
tools: toolInfoForSummary,
|
|
498643
|
+
signal: toolUseContext.abortController.signal,
|
|
498644
|
+
isNonInteractiveSession: toolUseContext.options.isNonInteractiveSession,
|
|
498645
|
+
lastAssistantText
|
|
498646
|
+
}).then((summary) => {
|
|
498647
|
+
if (summary) {
|
|
498648
|
+
return createToolUseSummaryMessage(summary, toolUseIds);
|
|
498649
|
+
}
|
|
498650
|
+
return null;
|
|
498651
|
+
}).catch(() => null);
|
|
498363
498652
|
}
|
|
498364
|
-
|
|
498365
|
-
|
|
498653
|
+
if (toolUseContext.abortController.signal.aborted) {
|
|
498654
|
+
if (false) {}
|
|
498655
|
+
if (toolUseContext.abortController.signal.reason !== "interrupt") {
|
|
498656
|
+
yield createUserInterruptionMessage({
|
|
498657
|
+
toolUse: true
|
|
498658
|
+
});
|
|
498659
|
+
}
|
|
498660
|
+
const nextTurnCountOnAbort = turnCount + 1;
|
|
498661
|
+
if (maxTurns && nextTurnCountOnAbort > maxTurns) {
|
|
498662
|
+
yield createAttachmentMessage({
|
|
498663
|
+
type: "max_turns_reached",
|
|
498664
|
+
maxTurns,
|
|
498665
|
+
turnCount: nextTurnCountOnAbort
|
|
498666
|
+
});
|
|
498667
|
+
}
|
|
498668
|
+
return { reason: "aborted_tools" };
|
|
498669
|
+
}
|
|
498670
|
+
if (shouldPreventContinuation) {
|
|
498671
|
+
return { reason: "hook_stopped" };
|
|
498672
|
+
}
|
|
498673
|
+
if (tracking?.compacted) {
|
|
498674
|
+
tracking.turnCounter++;
|
|
498675
|
+
}
|
|
498676
|
+
const sleepRan = toolUseBlocks.some((b3) => b3.name === SLEEP_TOOL_NAME);
|
|
498677
|
+
const isMainThread = querySource.startsWith("repl_main_thread") || querySource === "sdk";
|
|
498678
|
+
const currentAgentId = toolUseContext.agentId;
|
|
498679
|
+
const queuedCommandsSnapshot = getCommandsByMaxPriority(sleepRan ? "later" : "next").filter((cmd) => {
|
|
498680
|
+
if (isSlashCommand(cmd))
|
|
498681
|
+
return false;
|
|
498682
|
+
if (isMainThread)
|
|
498683
|
+
return cmd.agentId === undefined;
|
|
498684
|
+
return cmd.mode === "task-notification" && cmd.agentId === currentAgentId;
|
|
498685
|
+
});
|
|
498686
|
+
for await (const attachment of getAttachmentMessages(null, updatedToolUseContext, null, queuedCommandsSnapshot, [...messagesForQuery, ...assistantMessages, ...toolResults], querySource)) {
|
|
498687
|
+
yield attachment;
|
|
498688
|
+
toolResults.push(attachment);
|
|
498689
|
+
}
|
|
498690
|
+
if (pendingMemoryPrefetch && pendingMemoryPrefetch.settledAt !== null && pendingMemoryPrefetch.consumedOnIteration === -1) {
|
|
498691
|
+
const memoryAttachments = filterDuplicateMemoryAttachments(await pendingMemoryPrefetch.promise, toolUseContext.readFileState);
|
|
498692
|
+
for (const memAttachment of memoryAttachments) {
|
|
498693
|
+
const msg = createAttachmentMessage(memAttachment);
|
|
498694
|
+
yield msg;
|
|
498695
|
+
toolResults.push(msg);
|
|
498696
|
+
}
|
|
498697
|
+
pendingMemoryPrefetch.consumedOnIteration = turnCount - 1;
|
|
498698
|
+
}
|
|
498699
|
+
if (skillPrefetch && pendingSkillPrefetch) {
|
|
498700
|
+
const skillAttachments = await skillPrefetch.collectSkillDiscoveryPrefetch(pendingSkillPrefetch);
|
|
498701
|
+
for (const att of skillAttachments) {
|
|
498702
|
+
const msg = createAttachmentMessage(att);
|
|
498703
|
+
yield msg;
|
|
498704
|
+
toolResults.push(msg);
|
|
498705
|
+
}
|
|
498706
|
+
}
|
|
498707
|
+
const consumedCommands = queuedCommandsSnapshot.filter((cmd) => cmd.mode === "prompt" || cmd.mode === "task-notification");
|
|
498708
|
+
if (consumedCommands.length > 0) {
|
|
498709
|
+
for (const cmd of consumedCommands) {
|
|
498710
|
+
if (cmd.uuid) {
|
|
498711
|
+
consumedCommandUuids.push(cmd.uuid);
|
|
498712
|
+
notifyCommandLifecycle(cmd.uuid, "started");
|
|
498713
|
+
}
|
|
498714
|
+
}
|
|
498715
|
+
remove(consumedCommands);
|
|
498716
|
+
}
|
|
498717
|
+
const fileChangeAttachmentCount = count2(toolResults, (tr) => tr.type === "attachment" && tr.attachment.type === "edited_text_file");
|
|
498718
|
+
if (updatedToolUseContext.options.refreshTools) {
|
|
498719
|
+
const refreshedTools = updatedToolUseContext.options.refreshTools();
|
|
498720
|
+
if (refreshedTools !== updatedToolUseContext.options.tools) {
|
|
498721
|
+
updatedToolUseContext = {
|
|
498722
|
+
...updatedToolUseContext,
|
|
498723
|
+
options: {
|
|
498724
|
+
...updatedToolUseContext.options,
|
|
498725
|
+
tools: refreshedTools
|
|
498726
|
+
}
|
|
498727
|
+
};
|
|
498728
|
+
}
|
|
498729
|
+
}
|
|
498730
|
+
const toolUseContextWithQueryTracking = {
|
|
498731
|
+
...updatedToolUseContext,
|
|
498732
|
+
queryTracking
|
|
498733
|
+
};
|
|
498734
|
+
const nextTurnCount = turnCount + 1;
|
|
498735
|
+
if (false) {}
|
|
498736
|
+
if (maxTurns && nextTurnCount > maxTurns) {
|
|
498366
498737
|
yield createAttachmentMessage({
|
|
498367
498738
|
type: "max_turns_reached",
|
|
498368
498739
|
maxTurns,
|
|
498369
|
-
turnCount:
|
|
498740
|
+
turnCount: nextTurnCount
|
|
498370
498741
|
});
|
|
498742
|
+
return { reason: "max_turns", turnCount: nextTurnCount };
|
|
498371
498743
|
}
|
|
498372
|
-
|
|
498373
|
-
|
|
498374
|
-
|
|
498375
|
-
|
|
498376
|
-
|
|
498377
|
-
|
|
498378
|
-
|
|
498379
|
-
|
|
498380
|
-
|
|
498381
|
-
|
|
498382
|
-
|
|
498383
|
-
|
|
498384
|
-
|
|
498385
|
-
|
|
498386
|
-
if (isMainThread)
|
|
498387
|
-
return cmd.agentId === undefined;
|
|
498388
|
-
return cmd.mode === "task-notification" && cmd.agentId === currentAgentId;
|
|
498389
|
-
});
|
|
498390
|
-
for await (const attachment of getAttachmentMessages(null, updatedToolUseContext, null, queuedCommandsSnapshot, [...messagesForQuery, ...assistantMessages, ...toolResults], querySource)) {
|
|
498391
|
-
yield attachment;
|
|
498392
|
-
toolResults.push(attachment);
|
|
498393
|
-
}
|
|
498394
|
-
if (pendingMemoryPrefetch && pendingMemoryPrefetch.settledAt !== null && pendingMemoryPrefetch.consumedOnIteration === -1) {
|
|
498395
|
-
const memoryAttachments = filterDuplicateMemoryAttachments(await pendingMemoryPrefetch.promise, toolUseContext.readFileState);
|
|
498396
|
-
for (const memAttachment of memoryAttachments) {
|
|
498397
|
-
const msg = createAttachmentMessage(memAttachment);
|
|
498398
|
-
yield msg;
|
|
498399
|
-
toolResults.push(msg);
|
|
498400
|
-
}
|
|
498401
|
-
pendingMemoryPrefetch.consumedOnIteration = turnCount - 1;
|
|
498402
|
-
}
|
|
498403
|
-
if (skillPrefetch && pendingSkillPrefetch) {
|
|
498404
|
-
const skillAttachments = await skillPrefetch.collectSkillDiscoveryPrefetch(pendingSkillPrefetch);
|
|
498405
|
-
for (const att of skillAttachments) {
|
|
498406
|
-
const msg = createAttachmentMessage(att);
|
|
498407
|
-
yield msg;
|
|
498408
|
-
toolResults.push(msg);
|
|
498409
|
-
}
|
|
498410
|
-
}
|
|
498411
|
-
const consumedCommands = queuedCommandsSnapshot.filter((cmd) => cmd.mode === "prompt" || cmd.mode === "task-notification");
|
|
498412
|
-
if (consumedCommands.length > 0) {
|
|
498413
|
-
for (const cmd of consumedCommands) {
|
|
498414
|
-
if (cmd.uuid) {
|
|
498415
|
-
consumedCommandUuids.push(cmd.uuid);
|
|
498416
|
-
notifyCommandLifecycle(cmd.uuid, "started");
|
|
498417
|
-
}
|
|
498418
|
-
}
|
|
498419
|
-
remove(consumedCommands);
|
|
498420
|
-
}
|
|
498421
|
-
const fileChangeAttachmentCount = count2(toolResults, (tr) => tr.type === "attachment" && tr.attachment.type === "edited_text_file");
|
|
498422
|
-
if (updatedToolUseContext.options.refreshTools) {
|
|
498423
|
-
const refreshedTools = updatedToolUseContext.options.refreshTools();
|
|
498424
|
-
if (refreshedTools !== updatedToolUseContext.options.tools) {
|
|
498425
|
-
updatedToolUseContext = {
|
|
498426
|
-
...updatedToolUseContext,
|
|
498427
|
-
options: {
|
|
498428
|
-
...updatedToolUseContext.options,
|
|
498429
|
-
tools: refreshedTools
|
|
498430
|
-
}
|
|
498431
|
-
};
|
|
498432
|
-
}
|
|
498744
|
+
queryCheckpoint("query_recursive_call");
|
|
498745
|
+
const next2 = {
|
|
498746
|
+
messages: [...messagesForQuery, ...assistantMessages, ...toolResults],
|
|
498747
|
+
toolUseContext: toolUseContextWithQueryTracking,
|
|
498748
|
+
autoCompactTracking: tracking,
|
|
498749
|
+
turnCount: nextTurnCount,
|
|
498750
|
+
maxOutputTokensRecoveryCount: 0,
|
|
498751
|
+
hasAttemptedReactiveCompact: false,
|
|
498752
|
+
pendingToolUseSummary: nextPendingToolUseSummary,
|
|
498753
|
+
maxOutputTokensOverride: undefined,
|
|
498754
|
+
stopHookActive,
|
|
498755
|
+
transition: { reason: "next_turn" }
|
|
498756
|
+
};
|
|
498757
|
+
state = next2;
|
|
498433
498758
|
}
|
|
498434
|
-
|
|
498435
|
-
|
|
498436
|
-
queryTracking
|
|
498437
|
-
};
|
|
498438
|
-
const nextTurnCount = turnCount + 1;
|
|
498439
|
-
if (false) {}
|
|
498440
|
-
if (maxTurns && nextTurnCount > maxTurns) {
|
|
498441
|
-
yield createAttachmentMessage({
|
|
498442
|
-
type: "max_turns_reached",
|
|
498443
|
-
maxTurns,
|
|
498444
|
-
turnCount: nextTurnCount
|
|
498445
|
-
});
|
|
498446
|
-
return { reason: "max_turns", turnCount: nextTurnCount };
|
|
498447
|
-
}
|
|
498448
|
-
queryCheckpoint("query_recursive_call");
|
|
498449
|
-
const next2 = {
|
|
498450
|
-
messages: [...messagesForQuery, ...assistantMessages, ...toolResults],
|
|
498451
|
-
toolUseContext: toolUseContextWithQueryTracking,
|
|
498452
|
-
autoCompactTracking: tracking,
|
|
498453
|
-
turnCount: nextTurnCount,
|
|
498454
|
-
maxOutputTokensRecoveryCount: 0,
|
|
498455
|
-
hasAttemptedReactiveCompact: false,
|
|
498456
|
-
pendingToolUseSummary: nextPendingToolUseSummary,
|
|
498457
|
-
maxOutputTokensOverride: undefined,
|
|
498458
|
-
stopHookActive,
|
|
498459
|
-
transition: { reason: "next_turn" }
|
|
498460
|
-
};
|
|
498461
|
-
state = next2;
|
|
498759
|
+
} finally {
|
|
498760
|
+
pendingMemoryPrefetch?.[Symbol.dispose]();
|
|
498462
498761
|
}
|
|
498463
498762
|
}
|
|
498464
498763
|
function buildRouteContext(turnCount, querySource, messages, maxBudgetUsd) {
|
|
@@ -505249,6 +505548,7 @@ function getSimplePrompt() {
|
|
|
505249
505548
|
`Read files: Use ${FILE_READ_TOOL_NAME} (NOT cat/head/tail)`,
|
|
505250
505549
|
`Edit files: Use ${FILE_EDIT_TOOL_NAME} (NOT sed/awk)`,
|
|
505251
505550
|
`Write files: Use ${FILE_WRITE_TOOL_NAME} (NOT echo >/cat <<EOF)`,
|
|
505551
|
+
`Create reports/HTML/JSON/Markdown files: Use ${FILE_WRITE_TOOL_NAME} for the full content (NOT eval, node -e, python -c, echo, or printf with large inline strings)`,
|
|
505252
505552
|
"Communication: Output text directly (NOT echo/printf)"
|
|
505253
505553
|
];
|
|
505254
505554
|
const avoidCommands = embedded ? "`cat`, `head`, `tail`, `sed`, `awk`, or `echo`" : "`find`, `grep`, `cat`, `head`, `tail`, `sed`, `awk`, or `echo`";
|
|
@@ -505281,6 +505581,7 @@ function getSimplePrompt() {
|
|
|
505281
505581
|
"Try to maintain your current working directory throughout the session by using absolute paths and avoiding usage of `cd`. You may use `cd` if the User explicitly requests it.",
|
|
505282
505582
|
`You may specify an optional timeout in milliseconds (up to ${getMaxTimeoutMs2()}ms / ${getMaxTimeoutMs2() / 60000} minutes). By default, your command will timeout after ${getDefaultTimeoutMs2()}ms (${getDefaultTimeoutMs2() / 60000} minutes).`,
|
|
505283
505583
|
...backgroundNote !== null ? [backgroundNote] : [],
|
|
505584
|
+
"Do not compose large HTML, Markdown, or JSON artifacts through shell inline strings. If the content spans multiple lines or contains document markup like <!DOCTYPE html>, use the Write tool to create the file, then use Bash only to inspect or validate it.",
|
|
505284
505585
|
"When issuing multiple commands:",
|
|
505285
505586
|
multipleCommandsSubitems,
|
|
505286
505587
|
"For git commands:",
|
|
@@ -505440,6 +505741,18 @@ function isSilentBashCommand(command8) {
|
|
|
505440
505741
|
}
|
|
505441
505742
|
return hasNonFallbackCommand;
|
|
505442
505743
|
}
|
|
505744
|
+
function getInlineArtifactCommandBlockReason(command8) {
|
|
505745
|
+
const lower = command8.toLowerCase();
|
|
505746
|
+
const usesInlineExecution = /\beval\b/.test(lower) || /\b(?:node|bun|python3?|perl|ruby)\s+(?:-[a-z]*e|--eval|--print)\b/.test(lower) || /^\s*(?:echo|printf)\b/.test(lower);
|
|
505747
|
+
if (!usesInlineExecution)
|
|
505748
|
+
return null;
|
|
505749
|
+
const hasArtifactMarker = /<!doctype\s+html|<html[\s>]|<\/html>|<body[\s>]|<script[\s>]|<style[\s>]|```/i.test(command8);
|
|
505750
|
+
const quoteCount = (command8.match(/["']/g) ?? []).length;
|
|
505751
|
+
const looksLikeLargeInlineArtifact = command8.length > 1200 && quoteCount > 20;
|
|
505752
|
+
if (!hasArtifactMarker && !looksLikeLargeInlineArtifact)
|
|
505753
|
+
return null;
|
|
505754
|
+
return `Blocked: large HTML, Markdown, or JSON artifacts should be written with ${FILE_WRITE_TOOL_NAME}, not composed through Bash/eval/inline code. Use ${FILE_WRITE_TOOL_NAME} for the file content, then use Bash only for validation commands.`;
|
|
505755
|
+
}
|
|
505443
505756
|
function isAutobackgroundingAllowed2(command8) {
|
|
505444
505757
|
const parts = splitCommand_DEPRECATED(command8);
|
|
505445
505758
|
if (parts.length === 0)
|
|
@@ -505742,6 +506055,7 @@ var init_BashTool = __esm(() => {
|
|
|
505742
506055
|
init_readOnlyValidation2();
|
|
505743
506056
|
init_sedEditParser();
|
|
505744
506057
|
init_shouldUseSandbox();
|
|
506058
|
+
init_prompt4();
|
|
505745
506059
|
init_UI3();
|
|
505746
506060
|
init_utils5();
|
|
505747
506061
|
jsx_runtime336 = __toESM(require_jsx_runtime(), 1);
|
|
@@ -505913,6 +506227,14 @@ For commands that are harder to parse at a glance (piped commands, obscure flags
|
|
|
505913
506227
|
return `Running ${desc}`;
|
|
505914
506228
|
},
|
|
505915
506229
|
async validateInput(input2) {
|
|
506230
|
+
const inlineArtifactBlockReason = getInlineArtifactCommandBlockReason(input2.command);
|
|
506231
|
+
if (inlineArtifactBlockReason !== null) {
|
|
506232
|
+
return {
|
|
506233
|
+
result: false,
|
|
506234
|
+
message: inlineArtifactBlockReason,
|
|
506235
|
+
errorCode: 12
|
|
506236
|
+
};
|
|
506237
|
+
}
|
|
505916
506238
|
if (false) {}
|
|
505917
506239
|
return {
|
|
505918
506240
|
result: true
|
|
@@ -515661,7 +515983,7 @@ var init_filesystem = __esm(() => {
|
|
|
515661
515983
|
});
|
|
515662
515984
|
getBundledSkillsRoot = memoize_default(function getBundledSkillsRoot2() {
|
|
515663
515985
|
const nonce = randomBytes18(16).toString("hex");
|
|
515664
|
-
return join146(getClaudeTempDir(), "bundled-skills", "1.0.0-alpha.
|
|
515986
|
+
return join146(getClaudeTempDir(), "bundled-skills", "1.0.0-alpha.25", nonce);
|
|
515665
515987
|
});
|
|
515666
515988
|
getResolvedWorkingDirPaths = memoize_default(getPathsForPermissionCheck);
|
|
515667
515989
|
});
|
|
@@ -521591,7 +521913,7 @@ function computeFingerprintFromMessages(messages) {
|
|
|
521591
521913
|
}
|
|
521592
521914
|
var AGENT_OS_VERSION5, FINGERPRINT_SALT = "59cf53e54c78";
|
|
521593
521915
|
var init_fingerprint = __esm(() => {
|
|
521594
|
-
AGENT_OS_VERSION5 = typeof MACRO !== "undefined" ? "1.0.0-alpha.
|
|
521916
|
+
AGENT_OS_VERSION5 = typeof MACRO !== "undefined" ? "1.0.0-alpha.25" : "dev";
|
|
521595
521917
|
});
|
|
521596
521918
|
|
|
521597
521919
|
// src/services/compact/apiMicrocompact.ts
|
|
@@ -523345,7 +523667,7 @@ async function sideQuery(opts) {
|
|
|
523345
523667
|
betas.push(STRUCTURED_OUTPUTS_BETA_HEADER);
|
|
523346
523668
|
}
|
|
523347
523669
|
const messageText = extractFirstUserMessageText(messages);
|
|
523348
|
-
const fingerprint = computeFingerprint(messageText, "1.0.0-alpha.
|
|
523670
|
+
const fingerprint = computeFingerprint(messageText, "1.0.0-alpha.25");
|
|
523349
523671
|
const attributionHeader = getAttributionHeader(fingerprint);
|
|
523350
523672
|
const systemBlocks = [
|
|
523351
523673
|
attributionHeader ? { type: "text", text: attributionHeader } : null,
|
|
@@ -525264,7 +525586,7 @@ function appendToLog(path24, message) {
|
|
|
525264
525586
|
cwd: getFsImplementation().cwd(),
|
|
525265
525587
|
userType: process.env.USER_TYPE,
|
|
525266
525588
|
sessionId: getSessionId(),
|
|
525267
|
-
version: "1.0.0-alpha.
|
|
525589
|
+
version: "1.0.0-alpha.25"
|
|
525268
525590
|
};
|
|
525269
525591
|
getLogWriter(path24).write(messageWithTimestamp);
|
|
525270
525592
|
}
|
|
@@ -528242,7 +528564,7 @@ function getTelemetryAttributes() {
|
|
|
528242
528564
|
attributes["session.id"] = sessionId;
|
|
528243
528565
|
}
|
|
528244
528566
|
if (shouldIncludeAttribute("OTEL_METRICS_INCLUDE_VERSION")) {
|
|
528245
|
-
attributes["app.version"] = "1.0.0-alpha.
|
|
528567
|
+
attributes["app.version"] = "1.0.0-alpha.25";
|
|
528246
528568
|
}
|
|
528247
528569
|
if (envDynamic.terminal) {
|
|
528248
528570
|
attributes["terminal.type"] = envDynamic.terminal;
|
|
@@ -538386,7 +538708,7 @@ function buildSystemInitMessage(inputs) {
|
|
|
538386
538708
|
slash_commands: inputs.commands.filter((c5) => c5.userInvocable !== false).map((c5) => c5.name),
|
|
538387
538709
|
apiKeySource: getAnthropicApiKeyWithSource().source,
|
|
538388
538710
|
betas: getSdkBetas(),
|
|
538389
|
-
claude_code_version: "1.0.0-alpha.
|
|
538711
|
+
claude_code_version: "1.0.0-alpha.25",
|
|
538390
538712
|
output_style: outputStyle2,
|
|
538391
538713
|
agents: inputs.agents.map((agent) => agent.agentType),
|
|
538392
538714
|
skills: inputs.skills.filter((s2) => s2.userInvocable !== false).map((skill) => skill.name),
|
|
@@ -560855,7 +561177,7 @@ function buildStatusLineCommandInput(permissionMode, exceeds200kTokens, settings
|
|
|
560855
561177
|
project_dir: getOriginalCwd(),
|
|
560856
561178
|
added_dirs: addedDirs
|
|
560857
561179
|
},
|
|
560858
|
-
version: "1.0.0-alpha.
|
|
561180
|
+
version: "1.0.0-alpha.25",
|
|
560859
561181
|
output_style: {
|
|
560860
561182
|
name: outputStyleName
|
|
560861
561183
|
},
|
|
@@ -584211,7 +584533,7 @@ function WelcomeV2() {
|
|
|
584211
584533
|
dimColor: true,
|
|
584212
584534
|
children: [
|
|
584213
584535
|
"v",
|
|
584214
|
-
"1.0.0-alpha.
|
|
584536
|
+
"1.0.0-alpha.25",
|
|
584215
584537
|
" "
|
|
584216
584538
|
]
|
|
584217
584539
|
})
|
|
@@ -584411,7 +584733,7 @@ function WelcomeV2() {
|
|
|
584411
584733
|
dimColor: true,
|
|
584412
584734
|
children: [
|
|
584413
584735
|
"v",
|
|
584414
|
-
"1.0.0-alpha.
|
|
584736
|
+
"1.0.0-alpha.25",
|
|
584415
584737
|
" "
|
|
584416
584738
|
]
|
|
584417
584739
|
})
|
|
@@ -584637,7 +584959,7 @@ function AppleTerminalWelcomeV2(t0) {
|
|
|
584637
584959
|
dimColor: true,
|
|
584638
584960
|
children: [
|
|
584639
584961
|
"v",
|
|
584640
|
-
"1.0.0-alpha.
|
|
584962
|
+
"1.0.0-alpha.25",
|
|
584641
584963
|
" "
|
|
584642
584964
|
]
|
|
584643
584965
|
});
|
|
@@ -584891,7 +585213,7 @@ function AppleTerminalWelcomeV2(t0) {
|
|
|
584891
585213
|
dimColor: true,
|
|
584892
585214
|
children: [
|
|
584893
585215
|
"v",
|
|
584894
|
-
"1.0.0-alpha.
|
|
585216
|
+
"1.0.0-alpha.25",
|
|
584895
585217
|
" "
|
|
584896
585218
|
]
|
|
584897
585219
|
});
|
|
@@ -586357,7 +586679,7 @@ function completeOnboarding() {
|
|
|
586357
586679
|
saveGlobalConfig((current) => ({
|
|
586358
586680
|
...current,
|
|
586359
586681
|
hasCompletedOnboarding: true,
|
|
586360
|
-
lastOnboardingVersion: "1.0.0-alpha.
|
|
586682
|
+
lastOnboardingVersion: "1.0.0-alpha.25"
|
|
586361
586683
|
}));
|
|
586362
586684
|
}
|
|
586363
586685
|
function showDialog(root3, renderer) {
|
|
@@ -594820,8 +595142,8 @@ async function getEnvLessBridgeConfig() {
|
|
|
594820
595142
|
}
|
|
594821
595143
|
async function checkEnvLessBridgeMinVersion() {
|
|
594822
595144
|
const cfg = await getEnvLessBridgeConfig();
|
|
594823
|
-
if (cfg.min_version && lt("1.0.0-alpha.
|
|
594824
|
-
return `Your version of Agent-OS (${"1.0.0-alpha.
|
|
595145
|
+
if (cfg.min_version && lt("1.0.0-alpha.25", cfg.min_version)) {
|
|
595146
|
+
return `Your version of Agent-OS (${"1.0.0-alpha.25"}) is too old for Remote Control.
|
|
594825
595147
|
Version ${cfg.min_version} or higher is required. Run \`agent-os update\` to update.`;
|
|
594826
595148
|
}
|
|
594827
595149
|
return null;
|
|
@@ -595294,7 +595616,7 @@ async function initBridgeCore(params) {
|
|
|
595294
595616
|
const rawApi = createBridgeApiClient({
|
|
595295
595617
|
baseUrl,
|
|
595296
595618
|
getAccessToken,
|
|
595297
|
-
runnerVersion: "1.0.0-alpha.
|
|
595619
|
+
runnerVersion: "1.0.0-alpha.25",
|
|
595298
595620
|
onDebug: logForDebugging,
|
|
595299
595621
|
onAuth401,
|
|
595300
595622
|
getTrustedDeviceToken
|
|
@@ -600973,7 +601295,7 @@ async function startMCPServer(cwd3, debug2, verbose) {
|
|
|
600973
601295
|
setCwd(cwd3);
|
|
600974
601296
|
const server = new Server({
|
|
600975
601297
|
name: "claude/tengu",
|
|
600976
|
-
version: "1.0.0-alpha.
|
|
601298
|
+
version: "1.0.0-alpha.25"
|
|
600977
601299
|
}, {
|
|
600978
601300
|
capabilities: {
|
|
600979
601301
|
tools: {}
|
|
@@ -606484,7 +606806,7 @@ ${customInstructions}` : customInstructions;
|
|
|
606484
606806
|
}
|
|
606485
606807
|
}
|
|
606486
606808
|
logForDiagnosticsNoPII("info", "started", {
|
|
606487
|
-
version: "1.0.0-alpha.
|
|
606809
|
+
version: "1.0.0-alpha.25",
|
|
606488
606810
|
is_native_binary: isInBundledMode()
|
|
606489
606811
|
});
|
|
606490
606812
|
registerCleanup(async () => {
|
|
@@ -607276,7 +607598,7 @@ Usage: agent-os --remote "your task description"`, () => gracefulShutdown(1));
|
|
|
607276
607598
|
pendingHookMessages
|
|
607277
607599
|
}, renderAndRun);
|
|
607278
607600
|
}
|
|
607279
|
-
}).version("1.0.0-alpha.
|
|
607601
|
+
}).version("1.0.0-alpha.25 (Agent-OS)", "-v, --version", "Output the version number");
|
|
607280
607602
|
program2.option("-w, --worktree [name]", "Create a new git worktree for this session (optionally specify a name)");
|
|
607281
607603
|
program2.option("--tmux", "Create a tmux session for the worktree (requires --worktree). Uses iTerm2 native panes when available; use --tmux=classic for traditional tmux.");
|
|
607282
607604
|
if (canUserConfigureAdvisor()) {
|
|
@@ -609114,7 +609436,7 @@ if (false) {}
|
|
|
609114
609436
|
async function main2() {
|
|
609115
609437
|
const args = process.argv.slice(2);
|
|
609116
609438
|
if (args.length === 1 && (args[0] === "--version" || args[0] === "-v" || args[0] === "-V")) {
|
|
609117
|
-
console.log(`${"1.0.0-alpha.
|
|
609439
|
+
console.log(`${"1.0.0-alpha.25"} (Agent-OS)`);
|
|
609118
609440
|
return;
|
|
609119
609441
|
}
|
|
609120
609442
|
const {
|