@cnwenf/occ 2.1.337 → 2.1.338
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 +5 -5
- package/dist/cli.js +366 -109
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[](https://www.npmjs.com/package/@cnwenf/occ)
|
|
6
6
|
[](./LICENSE)
|
|
7
7
|
[](https://bun.sh/)
|
|
8
|
-
[](https://docs.anthropic.com/en/docs/claude-code)
|
|
9
9
|
|
|
10
10
|
[简体中文](./README.zh-CN.md) · **English**
|
|
11
11
|
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
## What is OCC
|
|
15
15
|
|
|
16
|
-
**Open C Code (OCC)** is an open-source coding agent. Its capabilities are aligned with [Claude Code](https://docs.anthropic.com/en/docs/claude-code) (currently tracking `2.1.
|
|
16
|
+
**Open C Code (OCC)** is an open-source coding agent. Its capabilities are aligned with [Claude Code](https://docs.anthropic.com/en/docs/claude-code) (currently tracking `2.1.273` — 2.1.270 fully aligned; 2.1.271–2.1.273 partial: the OCC-127 catch-up round landed the 2.1.273 gateway-hint request headers (default on for the first-party api.anthropic.com endpoint, off for third-party/custom endpoints; tri-bool `CLAUDE_CODE_GATEWAY_HINT_HEADERS` override), the spinner doubled-ellipsis guard, the shell-mode `!` insert fix, and — the round's security centerpiece — the subshell-hidden dangerous-`rm` bypass fix (per-segment analysis in the always-on catastrophic-rm deny guard), per `docs/upstream-version-gap-occ127.md`; remaining 2.1.273 entries are triaged there as NO-OP (surfaces OCC trims) or STAGED (per-site forensics needed); still not landed from the 2.1.270→2.1.272 delta: `/config` panel fullscreen mouse support (PORTABLE-LARGE scope) and the spinner status ladder "deep in thought"/"picking the thought back up" (STAGED), plus the pre-existing sandbox per-command `allowed_domains` gap; prior alignment through 2.1.270 landed via OCC-122/OCC-123/OCC-84/OCC-124/OCC-85/OCC-125/OCC-126). The code is fully open, auditable, backdoor-free, and your data stays under your control.
|
|
17
17
|
|
|
18
18
|
If you worry that a closed-source CLI might hide backdoors, or that your code and credentials are uploaded to unauditable services, OCC is for you: all source is open and unobfuscated, the build is reproducible from source, and API credentials are sent only to endpoints you configure.
|
|
19
19
|
|
|
@@ -62,7 +62,7 @@ Requires a valid Anthropic API Key (or AWS Bedrock / Google Vertex / Azure Found
|
|
|
62
62
|
| **Auditability** | Line-by-line reviewable | No |
|
|
63
63
|
| **Telemetry** | Minimal (analytics stubbed) | Standard |
|
|
64
64
|
| **Data sovereignty** | Credentials stay on your machine; requests only to endpoints you configure | Anthropic endpoints |
|
|
65
|
-
| **Capability parity** | Tracks CC `2.1.
|
|
65
|
+
| **Capability parity** | Tracks CC `2.1.273` (2.1.270 fully aligned; 2.1.271–2.1.273 partial) | Reference implementation |
|
|
66
66
|
| **Providers** | Anthropic Direct, Bedrock, Vertex, Azure | Anthropic, Bedrock, Vertex |
|
|
67
67
|
| **Cost** | Free & open-source (MIT) | Subscription |
|
|
68
68
|
| **Build** | Reproducible from source | N/A |
|
|
@@ -143,7 +143,7 @@ Requires [Bun](https://bun.sh/) >= 1.3.11 (use `bun upgrade` — older Bun cause
|
|
|
143
143
|
|
|
144
144
|
```bash
|
|
145
145
|
bun install
|
|
146
|
-
bun run dev # run from source; version prints 2.1.
|
|
146
|
+
bun run dev # run from source; version prints 2.1.273 (dev polyfill; build overrides with pkg.version) when working
|
|
147
147
|
bun run build # output: dist/cli.js (~26 MB, single-file bundle)
|
|
148
148
|
bun test # test suite (Bun test runner)
|
|
149
149
|
bun run lint # Biome lint (formatter disabled to avoid large diffs)
|
|
@@ -157,7 +157,7 @@ For architecture, entry/bootstrap, tool system, UI layer, and module-status deta
|
|
|
157
157
|
|
|
158
158
|
## Status
|
|
159
159
|
|
|
160
|
-
- Tracks Claude Code **`2.1.
|
|
160
|
+
- Tracks Claude Code **`2.1.273`** (2.1.270 fully aligned; 2.1.271–2.1.273 partial — the OCC-127 catch-up round landed the gateway-hint request headers, the spinner doubled-ellipsis guard, the shell-mode `!` insert fix, and the subshell-hidden dangerous-`rm` bypass fix — see `docs/upstream-version-gap-occ127.md`; remaining 2.1.273 entries are triaged there as NO-OP or STAGED; still not landed from the 2.1.270→2.1.272 delta: `/config` fullscreen mouse support (PORTABLE-LARGE) and the spinner status ladder (STAGED), plus the pre-existing sandbox per-command `allowed_domains` gap; prior alignment through 2.1.270 landed via OCC-122/OCC-123/OCC-84, OCC-124 + OCC-85, OCC-125, and OCC-126 — see `docs/upstream-version-gap-occ124.md`, `docs/upstream-version-gap-occ125.md`, and `docs/upstream-version-gap-occ126.md`).
|
|
161
161
|
- Published to npm as [`@cnwenf/occ`](https://www.npmjs.com/package/@cnwenf/occ).
|
|
162
162
|
- Many modules are intentionally stubbed or feature-flagged off — see "Disabled / stubbed" above.
|
|
163
163
|
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
globalThis.MACRO={"VERSION":"2.1.
|
|
2
|
+
globalThis.MACRO={"VERSION":"2.1.338","BINARY_NAME":"occ","BUILD_TIME":"2026-09-16T23:15:11.887Z","FEEDBACK_CHANNEL":"","ISSUES_EXPLAINER":"","NATIVE_PACKAGE_URL":"","PACKAGE_URL":"@cnwenf/occ","VERSION_CHANGELOG":""};
|
|
3
3
|
// @bun
|
|
4
4
|
var __create = Object.create;
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
@@ -101874,6 +101874,62 @@ var init_model = __esm(() => {
|
|
|
101874
101874
|
];
|
|
101875
101875
|
});
|
|
101876
101876
|
|
|
101877
|
+
// src/utils/agentSwarmsEnabled.ts
|
|
101878
|
+
function isAgentTeamsFlagSet() {
|
|
101879
|
+
return process.argv.includes("--agent-teams");
|
|
101880
|
+
}
|
|
101881
|
+
function isAgentSwarmsEnabled() {
|
|
101882
|
+
if (process.env.USER_TYPE === "ant") {
|
|
101883
|
+
return true;
|
|
101884
|
+
}
|
|
101885
|
+
if (!isEnvTruthy(process.env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS) && !isAgentTeamsFlagSet()) {
|
|
101886
|
+
return false;
|
|
101887
|
+
}
|
|
101888
|
+
if (!getFeatureValue_CACHED_MAY_BE_STALE("tengu_amber_flint", true)) {
|
|
101889
|
+
return false;
|
|
101890
|
+
}
|
|
101891
|
+
return true;
|
|
101892
|
+
}
|
|
101893
|
+
var init_agentSwarmsEnabled = __esm(() => {
|
|
101894
|
+
init_growthbook();
|
|
101895
|
+
init_envUtils();
|
|
101896
|
+
});
|
|
101897
|
+
|
|
101898
|
+
// src/utils/agentContext.ts
|
|
101899
|
+
import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
|
|
101900
|
+
function getAgentContext() {
|
|
101901
|
+
return agentContextStorage.getStore();
|
|
101902
|
+
}
|
|
101903
|
+
function runWithAgentContext(context, fn) {
|
|
101904
|
+
return agentContextStorage.run(context, fn);
|
|
101905
|
+
}
|
|
101906
|
+
function isSubagentContext(context) {
|
|
101907
|
+
return context?.agentType === "subagent";
|
|
101908
|
+
}
|
|
101909
|
+
function getSubagentLogName() {
|
|
101910
|
+
const context = getAgentContext();
|
|
101911
|
+
if (!isSubagentContext(context) || !context.subagentName) {
|
|
101912
|
+
return;
|
|
101913
|
+
}
|
|
101914
|
+
return context.isBuiltIn ? context.subagentName : "user-defined";
|
|
101915
|
+
}
|
|
101916
|
+
function consumeInvokingRequestId() {
|
|
101917
|
+
const context = getAgentContext();
|
|
101918
|
+
if (!context?.invokingRequestId || context.invocationEmitted) {
|
|
101919
|
+
return;
|
|
101920
|
+
}
|
|
101921
|
+
context.invocationEmitted = true;
|
|
101922
|
+
return {
|
|
101923
|
+
invokingRequestId: context.invokingRequestId,
|
|
101924
|
+
invocationKind: context.invocationKind
|
|
101925
|
+
};
|
|
101926
|
+
}
|
|
101927
|
+
var agentContextStorage;
|
|
101928
|
+
var init_agentContext = __esm(() => {
|
|
101929
|
+
init_agentSwarmsEnabled();
|
|
101930
|
+
agentContextStorage = new AsyncLocalStorage2;
|
|
101931
|
+
});
|
|
101932
|
+
|
|
101877
101933
|
// src/services/api/bedrockContentTypeGuard.ts
|
|
101878
101934
|
function assertBedrockStreamingContentType(response, requestUrl, provider3) {
|
|
101879
101935
|
if (provider3 !== "bedrock")
|
|
@@ -101909,6 +101965,160 @@ var init_bedrockContentTypeGuard = __esm(() => {
|
|
|
101909
101965
|
};
|
|
101910
101966
|
});
|
|
101911
101967
|
|
|
101968
|
+
// src/services/api/gatewayHints.ts
|
|
101969
|
+
function isFirstPartyAnthropicGateway() {
|
|
101970
|
+
return getAPIProvider() === "firstParty" && isFirstPartyAnthropicBaseUrl();
|
|
101971
|
+
}
|
|
101972
|
+
function isGatewayHintHeadersEnabled() {
|
|
101973
|
+
const envOverride = parseTriBool(process.env.CLAUDE_CODE_GATEWAY_HINT_HEADERS);
|
|
101974
|
+
if (envOverride !== undefined) {
|
|
101975
|
+
return envOverride;
|
|
101976
|
+
}
|
|
101977
|
+
if (isFirstPartyAnthropicGateway()) {
|
|
101978
|
+
return true;
|
|
101979
|
+
}
|
|
101980
|
+
if (getAPIProvider() !== "firstParty") {
|
|
101981
|
+
return false;
|
|
101982
|
+
}
|
|
101983
|
+
return false;
|
|
101984
|
+
}
|
|
101985
|
+
function parseTriBool(value) {
|
|
101986
|
+
if (value === undefined) {
|
|
101987
|
+
return;
|
|
101988
|
+
}
|
|
101989
|
+
if (isEnvTruthy(value)) {
|
|
101990
|
+
return true;
|
|
101991
|
+
}
|
|
101992
|
+
if (isEnvDefinedFalsy(value)) {
|
|
101993
|
+
return false;
|
|
101994
|
+
}
|
|
101995
|
+
return;
|
|
101996
|
+
}
|
|
101997
|
+
function toWellFormedString(value) {
|
|
101998
|
+
if (typeof String.prototype.toWellFormed === "function") {
|
|
101999
|
+
return value.toWellFormed();
|
|
102000
|
+
}
|
|
102001
|
+
return value.replace(LONE_SURROGATE_RE, "\uFFFD");
|
|
102002
|
+
}
|
|
102003
|
+
function sanitizeToolNameForHeader(toolName) {
|
|
102004
|
+
return toWellFormedString(toolName).replace(/%|[;=, ]|[^\x20-\x7e]/gu, encodeURIComponent);
|
|
102005
|
+
}
|
|
102006
|
+
function sanitizeHeaderValue(value) {
|
|
102007
|
+
return value.replace(/%|[^\x20-\x7e]/gu, encodeURIComponent);
|
|
102008
|
+
}
|
|
102009
|
+
function buildPrevToolDurationsHeader(entries) {
|
|
102010
|
+
const parts = [];
|
|
102011
|
+
let length = 0;
|
|
102012
|
+
for (const { toolName, durationMs } of entries) {
|
|
102013
|
+
if (parts.length >= MAX_TOOL_DURATION_ENTRIES) {
|
|
102014
|
+
break;
|
|
102015
|
+
}
|
|
102016
|
+
if (!Number.isFinite(durationMs)) {
|
|
102017
|
+
continue;
|
|
102018
|
+
}
|
|
102019
|
+
const ms = Math.max(0, Math.round(durationMs));
|
|
102020
|
+
const entry = `${sanitizeToolNameForHeader(toolName)}=${ms}`;
|
|
102021
|
+
const separatorLength = parts.length > 0 ? 1 : 0;
|
|
102022
|
+
if (length + separatorLength + entry.length > MAX_TOOL_DURATION_HEADER_BYTES) {
|
|
102023
|
+
break;
|
|
102024
|
+
}
|
|
102025
|
+
length += separatorLength + entry.length;
|
|
102026
|
+
parts.push(entry);
|
|
102027
|
+
}
|
|
102028
|
+
return parts.length > 0 ? parts.join(";") : undefined;
|
|
102029
|
+
}
|
|
102030
|
+
function classifyQuerySource(querySource) {
|
|
102031
|
+
if (querySource === undefined) {
|
|
102032
|
+
return;
|
|
102033
|
+
}
|
|
102034
|
+
if (querySource.startsWith("repl_main_thread") || querySource === "sdk") {
|
|
102035
|
+
return "main";
|
|
102036
|
+
}
|
|
102037
|
+
if (querySource.startsWith("agent:") || querySource === "hook_agent") {
|
|
102038
|
+
return "subagent";
|
|
102039
|
+
}
|
|
102040
|
+
return "auxiliary";
|
|
102041
|
+
}
|
|
102042
|
+
function isMainThreadQuerySource(querySource) {
|
|
102043
|
+
return querySource === undefined || classifyQuerySource(querySource) === "main";
|
|
102044
|
+
}
|
|
102045
|
+
function shouldSendContextCompactedHeader(querySource, agentId) {
|
|
102046
|
+
return agentId === undefined && isMainThreadQuerySource(querySource);
|
|
102047
|
+
}
|
|
102048
|
+
function getRequestClassHeader(querySource, agentContext) {
|
|
102049
|
+
if (querySource === undefined) {
|
|
102050
|
+
return;
|
|
102051
|
+
}
|
|
102052
|
+
if (querySource === "compact") {
|
|
102053
|
+
return "compaction";
|
|
102054
|
+
}
|
|
102055
|
+
const querySourceClass = classifyQuerySource(querySource);
|
|
102056
|
+
if (querySourceClass === "subagent" && agentContext?.agentType === "subagent" && agentContext.workflowRunId) {
|
|
102057
|
+
return "workflow";
|
|
102058
|
+
}
|
|
102059
|
+
return querySourceClass;
|
|
102060
|
+
}
|
|
102061
|
+
function getAgentTypeHeader(querySource, agentContext) {
|
|
102062
|
+
if (querySource === undefined || !querySource.startsWith("agent:")) {
|
|
102063
|
+
return;
|
|
102064
|
+
}
|
|
102065
|
+
if (agentContext?.agentType === "teammate") {
|
|
102066
|
+
return "teammate";
|
|
102067
|
+
}
|
|
102068
|
+
if (querySource.startsWith(BUILTIN_AGENT_QUERY_SOURCE_PREFIX)) {
|
|
102069
|
+
return querySource.slice(BUILTIN_AGENT_QUERY_SOURCE_PREFIX.length) || undefined;
|
|
102070
|
+
}
|
|
102071
|
+
if (querySource.startsWith("agent:custom")) {
|
|
102072
|
+
return "custom";
|
|
102073
|
+
}
|
|
102074
|
+
return;
|
|
102075
|
+
}
|
|
102076
|
+
function getCompactionKind(trigger, definednessProbe) {
|
|
102077
|
+
return trigger === "manual" ? "manual" : definednessProbe !== undefined ? "auto" : "reactive";
|
|
102078
|
+
}
|
|
102079
|
+
function armPendingContextCompacted(kind) {
|
|
102080
|
+
pendingContextCompacted = kind;
|
|
102081
|
+
}
|
|
102082
|
+
function consumePendingContextCompacted() {
|
|
102083
|
+
const kind = pendingContextCompacted;
|
|
102084
|
+
pendingContextCompacted = undefined;
|
|
102085
|
+
return kind;
|
|
102086
|
+
}
|
|
102087
|
+
function applyContextCompactedHeaders(headers, contextCompactedKind, compactionRequestKind) {
|
|
102088
|
+
if (contextCompactedKind === undefined && compactionRequestKind === undefined) {
|
|
102089
|
+
return;
|
|
102090
|
+
}
|
|
102091
|
+
const firstPartyGateway = isFirstPartyAnthropicGateway();
|
|
102092
|
+
const hintsEnabled = isGatewayHintHeadersEnabled();
|
|
102093
|
+
if (contextCompactedKind !== undefined) {
|
|
102094
|
+
if (firstPartyGateway) {
|
|
102095
|
+
headers[CONTEXT_COMPACTED_GATEWAY_HEADER] = contextCompactedKind;
|
|
102096
|
+
}
|
|
102097
|
+
if (hintsEnabled) {
|
|
102098
|
+
headers[CONTEXT_COMPACTED_HEADER] = contextCompactedKind;
|
|
102099
|
+
}
|
|
102100
|
+
}
|
|
102101
|
+
if (compactionRequestKind !== undefined) {
|
|
102102
|
+
if (firstPartyGateway) {
|
|
102103
|
+
headers[COMPACTION_REQUEST_GATEWAY_HEADER] = compactionRequestKind;
|
|
102104
|
+
}
|
|
102105
|
+
if (hintsEnabled) {
|
|
102106
|
+
headers[COMPACTION_HEADER] = compactionRequestKind;
|
|
102107
|
+
}
|
|
102108
|
+
}
|
|
102109
|
+
}
|
|
102110
|
+
function applyPrevToolDurationsHeader(headers, prevToolDurationsHeader) {
|
|
102111
|
+
if (prevToolDurationsHeader !== undefined && isGatewayHintHeadersEnabled()) {
|
|
102112
|
+
headers[PREV_TOOL_DURATIONS_HEADER] = prevToolDurationsHeader;
|
|
102113
|
+
}
|
|
102114
|
+
}
|
|
102115
|
+
var CONTEXT_COMPACTED_GATEWAY_HEADER = "x-cc-context-compacted", COMPACTION_REQUEST_GATEWAY_HEADER = "x-cc-compaction-request", COMPACTION_HEADER = "x-claude-code-compaction", CONTEXT_COMPACTED_HEADER = "x-claude-code-context-compacted", PREV_TOOL_DURATIONS_HEADER = "x-claude-code-prev-tool-durations", REQUEST_CLASS_HEADER = "x-claude-code-request-class", AGENT_TYPE_HEADER = "x-claude-code-agent-type", MAX_TOOL_DURATION_ENTRIES = 32, MAX_TOOL_DURATION_HEADER_BYTES = 4096, BUILTIN_AGENT_QUERY_SOURCE_PREFIX = "agent:builtin:", LONE_SURROGATE_RE, pendingContextCompacted;
|
|
102116
|
+
var init_gatewayHints = __esm(() => {
|
|
102117
|
+
init_envUtils();
|
|
102118
|
+
init_providers();
|
|
102119
|
+
LONE_SURROGATE_RE = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g;
|
|
102120
|
+
});
|
|
102121
|
+
|
|
101912
102122
|
// node_modules/.bun/tslib@1.14.1/node_modules/tslib/tslib.js
|
|
101913
102123
|
var require_tslib2 = __commonJS((exports, module) => {
|
|
101914
102124
|
/*! *****************************************************************************
|
|
@@ -139857,6 +140067,17 @@ async function getAnthropicClient({
|
|
|
139857
140067
|
...remoteSessionId ? { "x-claude-remote-session-id": remoteSessionId } : {},
|
|
139858
140068
|
...clientApp ? { "x-client-app": clientApp } : {}
|
|
139859
140069
|
};
|
|
140070
|
+
if (isGatewayHintHeadersEnabled()) {
|
|
140071
|
+
const agentContext = getAgentContext();
|
|
140072
|
+
const requestClass = getRequestClassHeader(source, agentContext);
|
|
140073
|
+
if (requestClass) {
|
|
140074
|
+
defaultHeaders[REQUEST_CLASS_HEADER] = requestClass;
|
|
140075
|
+
}
|
|
140076
|
+
const agentType = getAgentTypeHeader(source, agentContext);
|
|
140077
|
+
if (agentType) {
|
|
140078
|
+
defaultHeaders[AGENT_TYPE_HEADER] = sanitizeHeaderValue(agentType);
|
|
140079
|
+
}
|
|
140080
|
+
}
|
|
139860
140081
|
logForDebugging(`[API:request] Creating client, ANTHROPIC_CUSTOM_HEADERS present: ${!!process.env.ANTHROPIC_CUSTOM_HEADERS}, has Authorization header: ${!!customHeaders["Authorization"]}`);
|
|
139861
140082
|
const additionalProtectionEnabled = isEnvTruthy(process.env.CLAUDE_CODE_ADDITIONAL_PROTECTION);
|
|
139862
140083
|
if (additionalProtectionEnabled) {
|
|
@@ -140064,7 +140285,9 @@ var init_client9 = __esm(() => {
|
|
|
140064
140285
|
init_oauth();
|
|
140065
140286
|
init_debug();
|
|
140066
140287
|
init_envUtils();
|
|
140288
|
+
init_agentContext();
|
|
140067
140289
|
init_bedrockContentTypeGuard();
|
|
140290
|
+
init_gatewayHints();
|
|
140068
140291
|
});
|
|
140069
140292
|
|
|
140070
140293
|
// src/utils/model/modelCapabilities.ts
|
|
@@ -143744,7 +143967,7 @@ function getClaudeCodeUserAgent() {
|
|
|
143744
143967
|
}
|
|
143745
143968
|
|
|
143746
143969
|
// src/utils/workloadContext.ts
|
|
143747
|
-
import { AsyncLocalStorage as
|
|
143970
|
+
import { AsyncLocalStorage as AsyncLocalStorage3 } from "async_hooks";
|
|
143748
143971
|
function getWorkload() {
|
|
143749
143972
|
return workloadStorage.getStore()?.workload;
|
|
143750
143973
|
}
|
|
@@ -143753,7 +143976,7 @@ function runWithWorkload(workload, fn) {
|
|
|
143753
143976
|
}
|
|
143754
143977
|
var WORKLOAD_CRON = "cron", workloadStorage;
|
|
143755
143978
|
var init_workloadContext = __esm(() => {
|
|
143756
|
-
workloadStorage = new
|
|
143979
|
+
workloadStorage = new AsyncLocalStorage3;
|
|
143757
143980
|
});
|
|
143758
143981
|
|
|
143759
143982
|
// src/utils/http.ts
|
|
@@ -150712,62 +150935,6 @@ var init_officialRegistry = __esm(() => {
|
|
|
150712
150935
|
init_errors();
|
|
150713
150936
|
});
|
|
150714
150937
|
|
|
150715
|
-
// src/utils/agentSwarmsEnabled.ts
|
|
150716
|
-
function isAgentTeamsFlagSet() {
|
|
150717
|
-
return process.argv.includes("--agent-teams");
|
|
150718
|
-
}
|
|
150719
|
-
function isAgentSwarmsEnabled() {
|
|
150720
|
-
if (process.env.USER_TYPE === "ant") {
|
|
150721
|
-
return true;
|
|
150722
|
-
}
|
|
150723
|
-
if (!isEnvTruthy(process.env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS) && !isAgentTeamsFlagSet()) {
|
|
150724
|
-
return false;
|
|
150725
|
-
}
|
|
150726
|
-
if (!getFeatureValue_CACHED_MAY_BE_STALE("tengu_amber_flint", true)) {
|
|
150727
|
-
return false;
|
|
150728
|
-
}
|
|
150729
|
-
return true;
|
|
150730
|
-
}
|
|
150731
|
-
var init_agentSwarmsEnabled = __esm(() => {
|
|
150732
|
-
init_growthbook();
|
|
150733
|
-
init_envUtils();
|
|
150734
|
-
});
|
|
150735
|
-
|
|
150736
|
-
// src/utils/agentContext.ts
|
|
150737
|
-
import { AsyncLocalStorage as AsyncLocalStorage3 } from "async_hooks";
|
|
150738
|
-
function getAgentContext() {
|
|
150739
|
-
return agentContextStorage.getStore();
|
|
150740
|
-
}
|
|
150741
|
-
function runWithAgentContext(context4, fn) {
|
|
150742
|
-
return agentContextStorage.run(context4, fn);
|
|
150743
|
-
}
|
|
150744
|
-
function isSubagentContext(context4) {
|
|
150745
|
-
return context4?.agentType === "subagent";
|
|
150746
|
-
}
|
|
150747
|
-
function getSubagentLogName() {
|
|
150748
|
-
const context4 = getAgentContext();
|
|
150749
|
-
if (!isSubagentContext(context4) || !context4.subagentName) {
|
|
150750
|
-
return;
|
|
150751
|
-
}
|
|
150752
|
-
return context4.isBuiltIn ? context4.subagentName : "user-defined";
|
|
150753
|
-
}
|
|
150754
|
-
function consumeInvokingRequestId() {
|
|
150755
|
-
const context4 = getAgentContext();
|
|
150756
|
-
if (!context4?.invokingRequestId || context4.invocationEmitted) {
|
|
150757
|
-
return;
|
|
150758
|
-
}
|
|
150759
|
-
context4.invocationEmitted = true;
|
|
150760
|
-
return {
|
|
150761
|
-
invokingRequestId: context4.invokingRequestId,
|
|
150762
|
-
invocationKind: context4.invocationKind
|
|
150763
|
-
};
|
|
150764
|
-
}
|
|
150765
|
-
var agentContextStorage;
|
|
150766
|
-
var init_agentContext = __esm(() => {
|
|
150767
|
-
init_agentSwarmsEnabled();
|
|
150768
|
-
agentContextStorage = new AsyncLocalStorage3;
|
|
150769
|
-
});
|
|
150770
|
-
|
|
150771
150938
|
// src/utils/teammateContext.ts
|
|
150772
150939
|
import { AsyncLocalStorage as AsyncLocalStorage4 } from "async_hooks";
|
|
150773
150940
|
function getTeammateContext() {
|
|
@@ -385080,8 +385247,8 @@ function findCatastrophicSubstitutionBlock(command4) {
|
|
|
385080
385247
|
}
|
|
385081
385248
|
return null;
|
|
385082
385249
|
}
|
|
385083
|
-
|
|
385084
|
-
let c9 =
|
|
385250
|
+
const analyzeText = (text2) => {
|
|
385251
|
+
let c9 = text2.trim();
|
|
385085
385252
|
if (c9.startsWith("{") && /;?\s*\}$/.test(c9) || c9.startsWith("(") && c9.endsWith(")")) {
|
|
385086
385253
|
c9 = c9.slice(1).replace(/;?\s*[)}]$/, "").trim();
|
|
385087
385254
|
}
|
|
@@ -385098,6 +385265,18 @@ function findCatastrophicSubstitutionBlock(command4) {
|
|
|
385098
385265
|
reason: "rm -rf targeting the root or home directory detected inside command substitution"
|
|
385099
385266
|
};
|
|
385100
385267
|
}
|
|
385268
|
+
return null;
|
|
385269
|
+
};
|
|
385270
|
+
for (const body of [command4, ...subs]) {
|
|
385271
|
+
for (const text2 of [body, ...splitCommand_DEPRECATED(body)]) {
|
|
385272
|
+
if (text2.trim() === "") {
|
|
385273
|
+
continue;
|
|
385274
|
+
}
|
|
385275
|
+
const block = analyzeText(text2);
|
|
385276
|
+
if (block !== null) {
|
|
385277
|
+
return block;
|
|
385278
|
+
}
|
|
385279
|
+
}
|
|
385101
385280
|
}
|
|
385102
385281
|
return null;
|
|
385103
385282
|
}
|
|
@@ -453775,9 +453954,13 @@ function computeTodoLabel(todo) {
|
|
|
453775
453954
|
function computeSpinnerVerbWidth(columns) {
|
|
453776
453955
|
return Math.max(40, columns - 8);
|
|
453777
453956
|
}
|
|
453778
|
-
|
|
453957
|
+
function appendSpinnerEllipsis(verb) {
|
|
453958
|
+
return SPINNER_ELLIPSIS_RE.test(verb) ? verb : verb + "\u2026";
|
|
453959
|
+
}
|
|
453960
|
+
var THINKING_AMBER_DELAY_MS = 1e4, THINKING_AMBER_RAMP_MS = 1e4, RGB_CACHE, SPINNER_ELLIPSIS_RE;
|
|
453779
453961
|
var init_utils10 = __esm(() => {
|
|
453780
453962
|
RGB_CACHE = new Map;
|
|
453963
|
+
SPINNER_ELLIPSIS_RE = /(\u2026|\.\.\.)$/;
|
|
453781
453964
|
});
|
|
453782
453965
|
|
|
453783
453966
|
// src/components/Spinner/FlashingChar.tsx
|
|
@@ -460580,7 +460763,7 @@ function SpinnerWithVerbInner({
|
|
|
460580
460763
|
const leaderTodoLabel = currentTodo ? computeTodoLabel(currentTodo) : undefined;
|
|
460581
460764
|
const leaderVerb = overrideMessage ?? (leaderTodoLabel === undefined ? undefined : truncateToWidthNoEllipsis(leaderTodoLabel, computeSpinnerVerbWidth(columns))) ?? randomVerb;
|
|
460582
460765
|
const effectiveVerb = foregroundedTeammate && !foregroundedTeammate.isIdle ? foregroundedTeammate.spinnerVerb ?? randomVerb : leaderVerb;
|
|
460583
|
-
const message = effectiveVerb
|
|
460766
|
+
const message = appendSpinnerEllipsis(effectiveVerb);
|
|
460584
460767
|
import_react64.useEffect(() => {
|
|
460585
460768
|
const operationId = "spinner-" + mode;
|
|
460586
460769
|
activityManager.startCLIActivity(operationId);
|
|
@@ -587155,9 +587338,20 @@ You MUST call the ${SYNTHETIC_OUTPUT_TOOL_NAME} tool exactly once at the end of
|
|
|
587155
587338
|
model: agentModel,
|
|
587156
587339
|
startTime: agentStartTime
|
|
587157
587340
|
});
|
|
587341
|
+
const workflowAgentContext = {
|
|
587342
|
+
agentId,
|
|
587343
|
+
parentSessionId: getParentSessionId2(),
|
|
587344
|
+
agentType: "subagent",
|
|
587345
|
+
subagentName: agentDef.agentType,
|
|
587346
|
+
isBuiltIn: isBuiltInAgent(agentDef),
|
|
587347
|
+
workflowRunId: ctx.runId,
|
|
587348
|
+
workflowName: ctx.workflowName,
|
|
587349
|
+
invocationKind: "spawn",
|
|
587350
|
+
invocationEmitted: false
|
|
587351
|
+
};
|
|
587158
587352
|
let messages;
|
|
587159
587353
|
try {
|
|
587160
|
-
messages = await drainGenerator(gen);
|
|
587354
|
+
messages = await runWithAgentContext(workflowAgentContext, () => drainGenerator(gen));
|
|
587161
587355
|
} catch (e4) {
|
|
587162
587356
|
const msg = `Agent "${opts.label ?? prompt.slice(0, 40)}" failed: ${e4.message}`;
|
|
587163
587357
|
ctx.counters.failures.push(msg);
|
|
@@ -587443,6 +587637,9 @@ var WORKFLOW_AGENT_LIFETIME_CAP = 1000, WORKFLOW_PARALLEL_MAX_ITEMS = 4096, WORK
|
|
|
587443
587637
|
var init_primitives = __esm(() => {
|
|
587444
587638
|
init_runAgent();
|
|
587445
587639
|
init_generalPurposeAgent();
|
|
587640
|
+
init_loadAgentsDir();
|
|
587641
|
+
init_agentContext();
|
|
587642
|
+
init_teammate();
|
|
587446
587643
|
init_worktree();
|
|
587447
587644
|
init_messages3();
|
|
587448
587645
|
init_tokens();
|
|
@@ -596533,7 +596730,8 @@ async function checkPermissionsAndCallTool(tool, toolUseID, input2, toolUseConte
|
|
|
596533
596730
|
contextModifier: toolContextModifier ? {
|
|
596534
596731
|
toolUseID,
|
|
596535
596732
|
modifyContext: toolContextModifier
|
|
596536
|
-
} : undefined
|
|
596733
|
+
} : undefined,
|
|
596734
|
+
toolDuration: { toolName: tool.name, durationMs }
|
|
596537
596735
|
});
|
|
596538
596736
|
}
|
|
596539
596737
|
if (!isMcpTool(tool)) {
|
|
@@ -596700,7 +596898,8 @@ async function checkPermissionsAndCallTool(tool, toolUseID, input2, toolUseConte
|
|
|
596700
596898
|
toolUseResult: `Error: ${content}`,
|
|
596701
596899
|
mcpMeta: toolUseContext.agentId ? undefined : error52 instanceof McpToolCallError_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS ? error52.mcpMeta : undefined,
|
|
596702
596900
|
sourceToolAssistantUUID: assistantMessage.uuid
|
|
596703
|
-
})
|
|
596901
|
+
}),
|
|
596902
|
+
toolDuration: { toolName: tool.name, durationMs }
|
|
596704
596903
|
},
|
|
596705
596904
|
...hookMessages
|
|
596706
596905
|
];
|
|
@@ -596961,6 +597160,9 @@ class StreamingToolExecutor {
|
|
|
596961
597160
|
if (update.contextModifier) {
|
|
596962
597161
|
contextModifiers.push(update.contextModifier.modifyContext);
|
|
596963
597162
|
}
|
|
597163
|
+
if (update.toolDuration) {
|
|
597164
|
+
tool.toolDuration = update.toolDuration;
|
|
597165
|
+
}
|
|
596964
597166
|
}
|
|
596965
597167
|
tool.results = messages;
|
|
596966
597168
|
tool.contextModifiers = contextModifiers;
|
|
@@ -596992,8 +597194,10 @@ class StreamingToolExecutor {
|
|
|
596992
597194
|
}
|
|
596993
597195
|
if (tool.status === "completed" && tool.results) {
|
|
596994
597196
|
tool.status = "yielded";
|
|
597197
|
+
let toolDuration = tool.toolDuration;
|
|
596995
597198
|
for (const message of tool.results) {
|
|
596996
|
-
yield { message, newContext: this.toolUseContext };
|
|
597199
|
+
yield { message, newContext: this.toolUseContext, toolDuration };
|
|
597200
|
+
toolDuration = undefined;
|
|
596997
597201
|
}
|
|
596998
597202
|
markToolUseAsComplete(this.toolUseContext, tool.id);
|
|
596999
597203
|
} else if (tool.status === "executing" && !tool.isConcurrencySafe) {
|
|
@@ -597253,7 +597457,8 @@ async function* runTools(toolUseMessages, assistantMessages, canUseTool, toolUse
|
|
|
597253
597457
|
}
|
|
597254
597458
|
yield {
|
|
597255
597459
|
message: update.message,
|
|
597256
|
-
newContext: currentContext
|
|
597460
|
+
newContext: currentContext,
|
|
597461
|
+
...update.toolDuration && { toolDuration: update.toolDuration }
|
|
597257
597462
|
};
|
|
597258
597463
|
}
|
|
597259
597464
|
for (const block of blocks) {
|
|
@@ -597273,7 +597478,8 @@ async function* runTools(toolUseMessages, assistantMessages, canUseTool, toolUse
|
|
|
597273
597478
|
}
|
|
597274
597479
|
yield {
|
|
597275
597480
|
message: update.message,
|
|
597276
|
-
newContext: currentContext
|
|
597481
|
+
newContext: currentContext,
|
|
597482
|
+
...update.toolDuration && { toolDuration: update.toolDuration }
|
|
597277
597483
|
};
|
|
597278
597484
|
}
|
|
597279
597485
|
}
|
|
@@ -597308,7 +597514,8 @@ async function* runToolsSerially(toolUseMessages, assistantMessages, canUseTool,
|
|
|
597308
597514
|
}
|
|
597309
597515
|
yield {
|
|
597310
597516
|
message: update.message,
|
|
597311
|
-
newContext: currentContext
|
|
597517
|
+
newContext: currentContext,
|
|
597518
|
+
...update.toolDuration && { toolDuration: update.toolDuration }
|
|
597312
597519
|
};
|
|
597313
597520
|
}
|
|
597314
597521
|
markToolUseAsComplete2(toolUseContext, toolUse.id);
|
|
@@ -599829,7 +600036,8 @@ async function* queryLoop(params, consumedCommandUuids) {
|
|
|
599829
600036
|
querySource,
|
|
599830
600037
|
maxTurns,
|
|
599831
600038
|
skipCacheWrite,
|
|
599832
|
-
agentCacheTtlOverride
|
|
600039
|
+
agentCacheTtlOverride,
|
|
600040
|
+
compactionRequestKind
|
|
599833
600041
|
} = params;
|
|
599834
600042
|
const deps = params.deps ?? productionDeps();
|
|
599835
600043
|
let state3 = {
|
|
@@ -599847,6 +600055,7 @@ async function* queryLoop(params, consumedCommandUuids) {
|
|
|
599847
600055
|
};
|
|
599848
600056
|
const budgetTracker = feature("TOKEN_BUDGET") ? createBudgetTracker() : null;
|
|
599849
600057
|
let taskBudgetRemaining;
|
|
600058
|
+
let prevToolDurations;
|
|
599850
600059
|
const config7 = buildQueryConfig();
|
|
599851
600060
|
const pendingMemoryPrefetch = startRelevantMemoryPrefetch(state3.messages, state3.toolUseContext);
|
|
599852
600061
|
while (true) {
|
|
@@ -599963,6 +600172,7 @@ async function* queryLoop(params, consumedCommandUuids) {
|
|
|
599963
600172
|
const toolResults = [];
|
|
599964
600173
|
const toolUseBlocks = [];
|
|
599965
600174
|
let needsFollowUp = false;
|
|
600175
|
+
const toolDurations = [];
|
|
599966
600176
|
queryCheckpoint("query_setup_start");
|
|
599967
600177
|
const useStreamingToolExecution = config7.gates.streamingToolExecution;
|
|
599968
600178
|
let streamingToolExecutor = useStreamingToolExecution ? new StreamingToolExecutor(toolUseContext.options.tools, canUseTool, toolUseContext) : null;
|
|
@@ -600045,6 +600255,10 @@ async function* queryLoop(params, consumedCommandUuids) {
|
|
|
600045
600255
|
agentCacheTtlOverride,
|
|
600046
600256
|
agentId: toolUseContext.agentId,
|
|
600047
600257
|
addNotification: toolUseContext.addNotification,
|
|
600258
|
+
...prevToolDurations !== undefined && { prevToolDurations },
|
|
600259
|
+
...compactionRequestKind !== undefined && {
|
|
600260
|
+
compactionRequestKind
|
|
600261
|
+
},
|
|
600048
600262
|
...params.taskBudget && {
|
|
600049
600263
|
taskBudget: {
|
|
600050
600264
|
total: params.taskBudget.total,
|
|
@@ -600135,6 +600349,9 @@ async function* queryLoop(params, consumedCommandUuids) {
|
|
|
600135
600349
|
}
|
|
600136
600350
|
if (streamingToolExecutor && !toolUseContext.abortController.signal.aborted) {
|
|
600137
600351
|
for (const result of streamingToolExecutor.getCompletedResults()) {
|
|
600352
|
+
if (result.toolDuration) {
|
|
600353
|
+
toolDurations.push(result.toolDuration);
|
|
600354
|
+
}
|
|
600138
600355
|
if (result.message) {
|
|
600139
600356
|
yield result.message;
|
|
600140
600357
|
toolResults.push(...normalizeMessagesForAPI([result.message], toolUseContext.options.tools).filter((_4) => _4.type === "user"));
|
|
@@ -600482,6 +600699,9 @@ ${stopHookAdditionalContexts.join(`
|
|
|
600482
600699
|
}
|
|
600483
600700
|
const toolUpdates = streamingToolExecutor ? streamingToolExecutor.getRemainingResults() : runTools(toolUseBlocks, assistantMessages, canUseTool, toolUseContext);
|
|
600484
600701
|
for await (const update of toolUpdates) {
|
|
600702
|
+
if (update.toolDuration) {
|
|
600703
|
+
toolDurations.push(update.toolDuration);
|
|
600704
|
+
}
|
|
600485
600705
|
if (update.message) {
|
|
600486
600706
|
yield update.message;
|
|
600487
600707
|
if (update.message.type === "attachment" && update.message.attachment.type === "hook_stopped_continuation") {
|
|
@@ -600497,6 +600717,7 @@ ${stopHookAdditionalContexts.join(`
|
|
|
600497
600717
|
}
|
|
600498
600718
|
}
|
|
600499
600719
|
queryCheckpoint("query_tool_execution_end");
|
|
600720
|
+
prevToolDurations = toolDurations.length > 0 ? [...toolDurations] : undefined;
|
|
600500
600721
|
let nextPendingToolUseSummary;
|
|
600501
600722
|
if (config7.gates.emitToolUseSummaries && toolUseBlocks.length > 0 && !toolUseContext.abortController.signal.aborted && !toolUseContext.agentId) {
|
|
600502
600723
|
const lastAssistantMessage = assistantMessages.at(-1);
|
|
@@ -601503,7 +601724,8 @@ async function runForkedAgent({
|
|
|
601503
601724
|
maxTurns,
|
|
601504
601725
|
onMessage: onMessage2,
|
|
601505
601726
|
skipTranscript,
|
|
601506
|
-
skipCacheWrite
|
|
601727
|
+
skipCacheWrite,
|
|
601728
|
+
compactionRequestKind
|
|
601507
601729
|
}) {
|
|
601508
601730
|
const startTime2 = Date.now();
|
|
601509
601731
|
const outputMessages = [];
|
|
@@ -601536,7 +601758,8 @@ async function runForkedAgent({
|
|
|
601536
601758
|
maxOutputTokensOverride: maxOutputTokens,
|
|
601537
601759
|
maxTurns,
|
|
601538
601760
|
skipCacheWrite,
|
|
601539
|
-
agentCacheTtlOverride
|
|
601761
|
+
agentCacheTtlOverride,
|
|
601762
|
+
compactionRequestKind
|
|
601540
601763
|
})) {
|
|
601541
601764
|
if (message.type === "stream_event") {
|
|
601542
601765
|
if ("event" in message && message.event?.type === "message_delta" && message.event.usage) {
|
|
@@ -606556,7 +606779,8 @@ function mergeHookInstructions(userInstructions, hookInstructions) {
|
|
|
606556
606779
|
|
|
606557
606780
|
${hookInstructions}`;
|
|
606558
606781
|
}
|
|
606559
|
-
async function compactConversation(messages, context7, cacheSafeParams, suppressFollowUpQuestions, customInstructions, isAutoCompact = false, recompactionInfo) {
|
|
606782
|
+
async function compactConversation(messages, context7, cacheSafeParams, suppressFollowUpQuestions, customInstructions, isAutoCompact = false, recompactionInfo, thresholdSource) {
|
|
606783
|
+
const compactionRequestKind = getCompactionKind(isAutoCompact ? "auto" : "manual", thresholdSource);
|
|
606560
606784
|
try {
|
|
606561
606785
|
if (messages.length === 0) {
|
|
606562
606786
|
throw new Error(ERROR_MESSAGE_NOT_ENOUGH_MESSAGES);
|
|
@@ -606598,7 +606822,8 @@ async function compactConversation(messages, context7, cacheSafeParams, suppress
|
|
|
606598
606822
|
appState,
|
|
606599
606823
|
context: context7,
|
|
606600
606824
|
preCompactTokenCount,
|
|
606601
|
-
cacheSafeParams: retryCacheSafeParams
|
|
606825
|
+
cacheSafeParams: retryCacheSafeParams,
|
|
606826
|
+
compactionRequestKind
|
|
606602
606827
|
});
|
|
606603
606828
|
summary = getAssistantMessageText(summaryResponse);
|
|
606604
606829
|
if (!summary?.startsWith(PROMPT_TOO_LONG_ERROR_MESSAGE))
|
|
@@ -606755,6 +606980,9 @@ async function compactConversation(messages, context7, cacheSafeParams, suppress
|
|
|
606755
606980
|
postCompactHookResult.userDisplayMessage
|
|
606756
606981
|
].filter(Boolean).join(`
|
|
606757
606982
|
`);
|
|
606983
|
+
if (shouldSendContextCompactedHeader(recompactionInfo?.querySource ?? context7.options.querySource, context7.agentId)) {
|
|
606984
|
+
armPendingContextCompacted(getCompactionKind(isAutoCompact ? "auto" : "manual", getLastMainRequestId()));
|
|
606985
|
+
}
|
|
606758
606986
|
return {
|
|
606759
606987
|
boundaryMarker,
|
|
606760
606988
|
summaryMessages,
|
|
@@ -607012,7 +607240,8 @@ async function streamCompactSummary({
|
|
|
607012
607240
|
appState,
|
|
607013
607241
|
context: context7,
|
|
607014
607242
|
preCompactTokenCount,
|
|
607015
|
-
cacheSafeParams
|
|
607243
|
+
cacheSafeParams,
|
|
607244
|
+
compactionRequestKind
|
|
607016
607245
|
}) {
|
|
607017
607246
|
const promptCacheSharingEnabled = getFeatureValue_CACHED_MAY_BE_STALE("tengu_compact_cache_prefix", true);
|
|
607018
607247
|
const activityInterval = isSessionActivityTrackingActive() ? setInterval((statusSetter) => {
|
|
@@ -607030,7 +607259,8 @@ async function streamCompactSummary({
|
|
|
607030
607259
|
forkLabel: "compact",
|
|
607031
607260
|
maxTurns: 1,
|
|
607032
607261
|
skipCacheWrite: true,
|
|
607033
|
-
overrides: { abortController: context7.abortController }
|
|
607262
|
+
overrides: { abortController: context7.abortController },
|
|
607263
|
+
...compactionRequestKind !== undefined && { compactionRequestKind }
|
|
607034
607264
|
});
|
|
607035
607265
|
const assistantMsg = getLastAssistantMessage(result.messages);
|
|
607036
607266
|
const assistantText = assistantMsg ? getAssistantMessageText(assistantMsg) : null;
|
|
@@ -607093,6 +607323,7 @@ async function streamCompactSummary({
|
|
|
607093
607323
|
hasAppendSystemPrompt: !!context7.options.appendSystemPrompt,
|
|
607094
607324
|
maxOutputTokensOverride: Math.min(COMPACT_MAX_OUTPUT_TOKENS, getMaxOutputTokensForModel(context7.options.mainLoopModel)),
|
|
607095
607325
|
querySource: "compact",
|
|
607326
|
+
...compactionRequestKind !== undefined && { compactionRequestKind },
|
|
607096
607327
|
agents: context7.options.agentDefinitions.activeAgents,
|
|
607097
607328
|
mcpTools: [],
|
|
607098
607329
|
effortValue: appState.effortValue
|
|
@@ -607304,6 +607535,7 @@ var init_compact = __esm(() => {
|
|
|
607304
607535
|
init_uniqBy();
|
|
607305
607536
|
init_sdk();
|
|
607306
607537
|
init_state();
|
|
607538
|
+
init_gatewayHints();
|
|
607307
607539
|
init_state();
|
|
607308
607540
|
init_FileReadTool();
|
|
607309
607541
|
init_prompt3();
|
|
@@ -608039,7 +608271,7 @@ async function autoCompactIfNeeded(messages, toolUseContext, cacheSafeParams, qu
|
|
|
608039
608271
|
};
|
|
608040
608272
|
}
|
|
608041
608273
|
try {
|
|
608042
|
-
const compactionResult = await compactConversation(messages, toolUseContext, cacheSafeParams, true, undefined, true, recompactionInfo);
|
|
608274
|
+
const compactionResult = await compactConversation(messages, toolUseContext, cacheSafeParams, true, undefined, true, recompactionInfo, "auto-compact-threshold");
|
|
608043
608275
|
setLastSummarizedMessageId(undefined);
|
|
608044
608276
|
runPostCompactCleanup(querySource);
|
|
608045
608277
|
return {
|
|
@@ -633883,7 +634115,7 @@ function getCacheControl({
|
|
|
633883
634115
|
function querySourceMatchesPatterns(querySource, patterns) {
|
|
633884
634116
|
return querySource !== undefined && patterns.some((pattern) => pattern.endsWith("*") ? querySource.startsWith(pattern.slice(0, -1)) : querySource === pattern);
|
|
633885
634117
|
}
|
|
633886
|
-
function
|
|
634118
|
+
function isMainThreadQuerySource2(querySource) {
|
|
633887
634119
|
return querySourceMatchesPatterns(querySource, MAIN_THREAD_QUERY_SOURCES);
|
|
633888
634120
|
}
|
|
633889
634121
|
function parsePromptCacheTtlEnv(value) {
|
|
@@ -633893,7 +634125,7 @@ function resolvePromptCacheTtlOverride(querySource, agentCacheTtlOverride, isUsi
|
|
|
633893
634125
|
if (isEnvTruthy(process.env.FORCE_PROMPT_CACHING_5M)) {
|
|
633894
634126
|
return { ttl: "5m", reason: "force_5m_env" };
|
|
633895
634127
|
}
|
|
633896
|
-
const isMainThread =
|
|
634128
|
+
const isMainThread = isMainThreadQuerySource2(querySource);
|
|
633897
634129
|
const envTtl = parsePromptCacheTtlEnv(isMainThread ? process.env.CLAUDE_CODE_PROMPT_CACHE_TTL : process.env.CLAUDE_CODE_SUBAGENT_PROMPT_CACHE_TTL);
|
|
633898
634130
|
if (envTtl !== undefined)
|
|
633899
634131
|
return { ttl: envTtl, reason: "env" };
|
|
@@ -634150,7 +634382,7 @@ function getApiForceIdleTimeout() {
|
|
|
634150
634382
|
const ms = parseInt(raw, 10);
|
|
634151
634383
|
return Number.isFinite(ms) && ms > 0 ? ms : undefined;
|
|
634152
634384
|
}
|
|
634153
|
-
async function* executeNonStreamingRequest(clientOptions, retryOptions, paramsFromContext, onAttempt, captureRequest, originatingRequestId) {
|
|
634385
|
+
async function* executeNonStreamingRequest(clientOptions, retryOptions, paramsFromContext, onAttempt, captureRequest, originatingRequestId, gatewayHintWireValues) {
|
|
634154
634386
|
const fallbackTimeoutMs = getNonstreamingFallbackTimeoutMs();
|
|
634155
634387
|
const generator = withRetry(() => getAnthropicClient({
|
|
634156
634388
|
maxRetries: 0,
|
|
@@ -634164,12 +634396,16 @@ async function* executeNonStreamingRequest(clientOptions, retryOptions, paramsFr
|
|
|
634164
634396
|
onAttempt(attempt, start, retryParams.max_tokens);
|
|
634165
634397
|
const adjustedParams = adjustParamsForNonStreaming(retryParams, MAX_NON_STREAMING_TOKENS);
|
|
634166
634398
|
try {
|
|
634399
|
+
const hintHeaders = {};
|
|
634400
|
+
applyContextCompactedHeaders(hintHeaders, gatewayHintWireValues?.contextCompactedKindForWire, gatewayHintWireValues?.compactionRequestKindForWire);
|
|
634401
|
+
applyPrevToolDurationsHeader(hintHeaders, gatewayHintWireValues?.prevToolDurationsForWire);
|
|
634167
634402
|
return await anthropic.beta.messages.create({
|
|
634168
634403
|
...adjustedParams,
|
|
634169
634404
|
model: normalizeModelStringForAPI(adjustedParams.model)
|
|
634170
634405
|
}, {
|
|
634171
634406
|
signal: retryOptions.signal,
|
|
634172
|
-
timeout: fallbackTimeoutMs
|
|
634407
|
+
timeout: fallbackTimeoutMs,
|
|
634408
|
+
...Object.keys(hintHeaders).length > 0 ? { headers: hintHeaders } : {}
|
|
634173
634409
|
});
|
|
634174
634410
|
} catch (err2) {
|
|
634175
634411
|
if (err2 instanceof APIUserAbortError)
|
|
@@ -634672,6 +634908,9 @@ ${deferredToolList}
|
|
|
634672
634908
|
let research;
|
|
634673
634909
|
let isFastModeRequest = isFastMode;
|
|
634674
634910
|
let isAdvisorInProgress = false;
|
|
634911
|
+
const contextCompactedKindForWire = classifyQuerySource(options.querySource) === "main" && options.agentId === undefined ? consumePendingContextCompacted() : undefined;
|
|
634912
|
+
const compactionRequestKindForWire = options.compactionRequestKind;
|
|
634913
|
+
const prevToolDurationsForWire = options.prevToolDurations !== undefined ? buildPrevToolDurationsHeader(options.prevToolDurations) : undefined;
|
|
634675
634914
|
try {
|
|
634676
634915
|
let clearStreamIdleTimers = function() {
|
|
634677
634916
|
if (streamIdleWarningTimer !== null) {
|
|
@@ -634728,20 +634967,23 @@ ${deferredToolList}
|
|
|
634728
634967
|
}
|
|
634729
634968
|
clientRequestId = getAPIProvider() === "firstParty" && isFirstPartyAnthropicBaseUrl() ? randomUUID33() : undefined;
|
|
634730
634969
|
const incomingTrace = shouldPropagateTraceparent() ? getIncomingTraceContext() : undefined;
|
|
634970
|
+
const attemptHeaders = {
|
|
634971
|
+
...clientRequestId && {
|
|
634972
|
+
[CLIENT_REQUEST_ID_HEADER]: clientRequestId
|
|
634973
|
+
},
|
|
634974
|
+
...incomingTrace?.traceparent && {
|
|
634975
|
+
traceparent: incomingTrace.traceparent
|
|
634976
|
+
},
|
|
634977
|
+
...incomingTrace?.tracestate && {
|
|
634978
|
+
tracestate: incomingTrace.tracestate
|
|
634979
|
+
}
|
|
634980
|
+
};
|
|
634981
|
+
applyContextCompactedHeaders(attemptHeaders, contextCompactedKindForWire, compactionRequestKindForWire);
|
|
634982
|
+
applyPrevToolDurationsHeader(attemptHeaders, prevToolDurationsForWire);
|
|
634731
634983
|
const result = await anthropic.beta.messages.create({ ...params, stream: true }, {
|
|
634732
634984
|
signal,
|
|
634733
634985
|
...getApiForceIdleTimeout() !== undefined ? { timeout: false } : {},
|
|
634734
|
-
headers:
|
|
634735
|
-
...clientRequestId && {
|
|
634736
|
-
[CLIENT_REQUEST_ID_HEADER]: clientRequestId
|
|
634737
|
-
},
|
|
634738
|
-
...incomingTrace?.traceparent && {
|
|
634739
|
-
traceparent: incomingTrace.traceparent
|
|
634740
|
-
},
|
|
634741
|
-
...incomingTrace?.tracestate && {
|
|
634742
|
-
tracestate: incomingTrace.tracestate
|
|
634743
|
-
}
|
|
634744
|
-
}
|
|
634986
|
+
headers: attemptHeaders
|
|
634745
634987
|
}).withResponse();
|
|
634746
634988
|
queryCheckpoint("query_response_headers_received");
|
|
634747
634989
|
streamRequestId = result.request_id;
|
|
@@ -635195,7 +635437,11 @@ ${deferredToolList}
|
|
|
635195
635437
|
}, paramsFromContext, (attempt, _startTime, tokens) => {
|
|
635196
635438
|
attemptNumber = attempt;
|
|
635197
635439
|
maxOutputTokens = tokens;
|
|
635198
|
-
}, (params) => captureAPIRequest(params, options.querySource), streamRequestId
|
|
635440
|
+
}, (params) => captureAPIRequest(params, options.querySource), streamRequestId, {
|
|
635441
|
+
contextCompactedKindForWire,
|
|
635442
|
+
compactionRequestKindForWire,
|
|
635443
|
+
prevToolDurationsForWire
|
|
635444
|
+
});
|
|
635199
635445
|
const m5 = {
|
|
635200
635446
|
message: {
|
|
635201
635447
|
...result,
|
|
@@ -635252,7 +635498,11 @@ ${deferredToolList}
|
|
|
635252
635498
|
}, paramsFromContext, (attempt, _startTime, tokens) => {
|
|
635253
635499
|
attemptNumber = attempt;
|
|
635254
635500
|
maxOutputTokens = tokens;
|
|
635255
|
-
}, (params) => captureAPIRequest(params, options.querySource), failedRequestId
|
|
635501
|
+
}, (params) => captureAPIRequest(params, options.querySource), failedRequestId, {
|
|
635502
|
+
contextCompactedKindForWire,
|
|
635503
|
+
compactionRequestKindForWire,
|
|
635504
|
+
prevToolDurationsForWire
|
|
635505
|
+
});
|
|
635256
635506
|
const m5 = {
|
|
635257
635507
|
message: {
|
|
635258
635508
|
...result,
|
|
@@ -635743,6 +635993,7 @@ var init_claude = __esm(() => {
|
|
|
635743
635993
|
init_utils9();
|
|
635744
635994
|
init_vcr();
|
|
635745
635995
|
init_client9();
|
|
635996
|
+
init_gatewayHints();
|
|
635746
635997
|
init_errors10();
|
|
635747
635998
|
init_logging2();
|
|
635748
635999
|
init_rawApiBodies();
|
|
@@ -638988,6 +639239,9 @@ function getValueFromInput(input2) {
|
|
|
638988
639239
|
function isInputModeCharacter(input2) {
|
|
638989
639240
|
return input2 === "!";
|
|
638990
639241
|
}
|
|
639242
|
+
function shouldTriggerModeSwitch(keystroke, isAtStart, currentMode) {
|
|
639243
|
+
return currentMode !== undefined && isAtStart && isInputModeCharacter(keystroke) && currentMode !== getModeFromInput(keystroke);
|
|
639244
|
+
}
|
|
638991
639245
|
|
|
638992
639246
|
// src/projectOnboardingState.ts
|
|
638993
639247
|
import { join as join128 } from "path";
|
|
@@ -641172,7 +641426,8 @@ function useTextInput({
|
|
|
641172
641426
|
onOffsetChange,
|
|
641173
641427
|
inputFilter,
|
|
641174
641428
|
inlineGhostText,
|
|
641175
|
-
dim: dim2
|
|
641429
|
+
dim: dim2,
|
|
641430
|
+
getInputMode
|
|
641176
641431
|
}) {
|
|
641177
641432
|
if (env4.terminal === "Apple_Terminal") {
|
|
641178
641433
|
prewarmModifiers();
|
|
@@ -641432,7 +641687,7 @@ function useTextInput({
|
|
|
641432
641687
|
if (echo !== null)
|
|
641433
641688
|
pushScreenReaderAnnouncement(echo);
|
|
641434
641689
|
}
|
|
641435
|
-
if (cursor.isAtStart()
|
|
641690
|
+
if (shouldTriggerModeSwitch(input2, cursor.isAtStart(), getInputMode?.())) {
|
|
641436
641691
|
return cursor.insert(text2).left();
|
|
641437
641692
|
}
|
|
641438
641693
|
return cursor.insert(text2);
|
|
@@ -642199,6 +642454,7 @@ function TextInput(props) {
|
|
|
642199
642454
|
onOffsetChange: props.onChangeCursorOffset,
|
|
642200
642455
|
inputFilter: props.inputFilter,
|
|
642201
642456
|
inlineGhostText: props.inlineGhostText,
|
|
642457
|
+
getInputMode: props.getInputMode,
|
|
642202
642458
|
dim: source_default.dim
|
|
642203
642459
|
});
|
|
642204
642460
|
return /* @__PURE__ */ jsx_runtime167.jsx(ThemedBox_default, {
|
|
@@ -730614,7 +730870,7 @@ function urlMatchesPattern2(url3, pattern) {
|
|
|
730614
730870
|
const regexStr = escaped.replace(/\*/g, ".*");
|
|
730615
730871
|
return new RegExp(`^${regexStr}$`).test(url3);
|
|
730616
730872
|
}
|
|
730617
|
-
function
|
|
730873
|
+
function sanitizeHeaderValue2(value) {
|
|
730618
730874
|
return value.replace(/[\r\n\x00]/g, "");
|
|
730619
730875
|
}
|
|
730620
730876
|
function interpolateEnvVars(value, allowedEnvVars) {
|
|
@@ -730626,7 +730882,7 @@ function interpolateEnvVars(value, allowedEnvVars) {
|
|
|
730626
730882
|
}
|
|
730627
730883
|
return process.env[varName] ?? "";
|
|
730628
730884
|
});
|
|
730629
|
-
return
|
|
730885
|
+
return sanitizeHeaderValue2(interpolated);
|
|
730630
730886
|
}
|
|
730631
730887
|
async function execHttpHook(hook, _hookEvent, jsonInput, signal) {
|
|
730632
730888
|
const policy = getHttpHookPolicy();
|
|
@@ -777010,7 +777266,7 @@ var init_PromptInputStashNotice = __esm(() => {
|
|
|
777010
777266
|
function stripLoneSurrogates2(text2) {
|
|
777011
777267
|
if (isWellFormed && isWellFormed(text2))
|
|
777012
777268
|
return text2;
|
|
777013
|
-
return text2.replace(
|
|
777269
|
+
return text2.replace(LONE_SURROGATE_RE2, "");
|
|
777014
777270
|
}
|
|
777015
777271
|
function stripAnsiSequences(text2) {
|
|
777016
777272
|
let result = text2;
|
|
@@ -777034,11 +777290,11 @@ function clampBannerTextWidth(maxWidth) {
|
|
|
777034
777290
|
function sanitizeAndClampBannerText(text2, maxWidth) {
|
|
777035
777291
|
return truncateToWidth(sanitizeBannerText(text2), clampBannerTextWidth(maxWidth));
|
|
777036
777292
|
}
|
|
777037
|
-
var BANNER_TEXT_MAX_WIDTH = 24, ANSI_STRIP_PASSES = 4, ANSI_SEQUENCE_RE,
|
|
777293
|
+
var BANNER_TEXT_MAX_WIDTH = 24, ANSI_STRIP_PASSES = 4, ANSI_SEQUENCE_RE, LONE_SURROGATE_RE2, CONTROL_FORMAT_RE, isWellFormed;
|
|
777038
777294
|
var init_sanitizeBannerText = __esm(() => {
|
|
777039
777295
|
init_truncate();
|
|
777040
777296
|
ANSI_SEQUENCE_RE = /\x1b\[[\x30-\x3f]*[\x20-\x2f]*[\x40-\x7e]|\x1b[\]PX^_][^\x1b\x07]*(?:\x07|\x1b\\)/g;
|
|
777041
|
-
|
|
777297
|
+
LONE_SURROGATE_RE2 = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g;
|
|
777042
777298
|
CONTROL_FORMAT_RE = /[\p{Cc}\p{Cf}\u2028\u2029]+/gu;
|
|
777043
777299
|
isWellFormed = typeof String.prototype.isWellFormed === "function" ? Function.prototype.call.bind(String.prototype.isWellFormed) : undefined;
|
|
777044
777300
|
});
|
|
@@ -778004,14 +778260,14 @@ function PromptInput({
|
|
|
778004
778260
|
abortSpeculation(setAppState);
|
|
778005
778261
|
const isSingleCharInsertion = value.length === input2.length + 1;
|
|
778006
778262
|
const insertedAtStart = cursorOffset === 0;
|
|
778007
|
-
const
|
|
778008
|
-
if (insertedAtStart &&
|
|
778263
|
+
const detectedMode = getModeFromInput(value);
|
|
778264
|
+
if (insertedAtStart && detectedMode !== "prompt" && detectedMode !== mode) {
|
|
778009
778265
|
if (isSingleCharInsertion) {
|
|
778010
|
-
onModeChange(
|
|
778266
|
+
onModeChange(detectedMode);
|
|
778011
778267
|
return;
|
|
778012
778268
|
}
|
|
778013
778269
|
if (input2.length === 0) {
|
|
778014
|
-
onModeChange(
|
|
778270
|
+
onModeChange(detectedMode);
|
|
778015
778271
|
const valueWithoutMode = getValueFromInput(value).replaceAll("\t", " ");
|
|
778016
778272
|
pushToBuffer(input2, cursorOffset, pastedContents);
|
|
778017
778273
|
trackAndSetInput(valueWithoutMode);
|
|
@@ -778028,7 +778284,7 @@ function PromptInput({
|
|
|
778028
778284
|
footerSelection: null
|
|
778029
778285
|
});
|
|
778030
778286
|
trackAndSetInput(processedValue);
|
|
778031
|
-
}, [trackAndSetInput, onModeChange, input2, cursorOffset, pushToBuffer, pastedContents, dismissStashHint, setAppState]);
|
|
778287
|
+
}, [trackAndSetInput, onModeChange, input2, cursorOffset, mode, pushToBuffer, pastedContents, dismissStashHint, setAppState]);
|
|
778032
778288
|
const {
|
|
778033
778289
|
resetHistory,
|
|
778034
778290
|
onHistoryUp,
|
|
@@ -779126,7 +779382,8 @@ function PromptInput({
|
|
|
779126
779382
|
} : undefined,
|
|
779127
779383
|
highlights: combinedHighlights,
|
|
779128
779384
|
inlineGhostText,
|
|
779129
|
-
inputFilter: lazySpaceInputFilter
|
|
779385
|
+
inputFilter: lazySpaceInputFilter,
|
|
779386
|
+
getInputMode: () => mode
|
|
779130
779387
|
};
|
|
779131
779388
|
const getBorderColor = () => {
|
|
779132
779389
|
const modeColors = {
|
|
@@ -831613,7 +831870,7 @@ var _FEATURE_ALLOWLIST = new Set([
|
|
|
831613
831870
|
var feature2 = (name3) => _FEATURE_ALLOWLIST.has(name3);
|
|
831614
831871
|
if (typeof globalThis.MACRO === "undefined") {
|
|
831615
831872
|
globalThis.MACRO = {
|
|
831616
|
-
VERSION: "2.1.
|
|
831873
|
+
VERSION: "2.1.273",
|
|
831617
831874
|
BINARY_NAME: "occ",
|
|
831618
831875
|
BUILD_TIME: new Date().toISOString(),
|
|
831619
831876
|
FEEDBACK_CHANNEL: "",
|