@cnwenf/occ 2.1.337 → 2.1.339
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 +438 -117
- 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.274` — 2.1.270 fully aligned; 2.1.271–2.1.274 partial: the latest OCC-127 round landed the 2.1.274 MCP auth-stub description secret-leak fix — the byte-verified display-sanitizer family (NFKC + invisible-character stripping, quote/angle-bracket neutralization, bearer/token-family redaction, code-point-safe truncation) with the origin-only unexpanded endpoint — and confirmed NO-OP with behavioral tests for the 2.1.274 bash special-variable assignment/loop and worktree nested-expansion hardening (OCC's existing guards already ask/refuse every risky vector, byte-verified parity with the official); prior rounds 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 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/2.1.274 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.274` (2.1.270 fully aligned; 2.1.271–2.1.274 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.274 (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.274`** (2.1.270 fully aligned; 2.1.271–2.1.274 partial — the latest OCC-127 round landed the 2.1.274 MCP auth-stub description secret-leak fix (byte-verified display-sanitizer family port) and verified the 2.1.274 bash special-variable and worktree nested-expansion hardening as NO-OP with behavioral tests; prior rounds landed the 2.1.273 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/2.1.274 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.339","BINARY_NAME":"occ","BUILD_TIME":"2026-09-17T03:37:58.902Z","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 {
|
|
@@ -628227,17 +628459,78 @@ var init_auth11 = __esm(() => {
|
|
|
628227
628459
|
};
|
|
628228
628460
|
});
|
|
628229
628461
|
|
|
628462
|
+
// src/services/mcp/displaySanitize.ts
|
|
628463
|
+
function stripInvisibleForDisplay(input2) {
|
|
628464
|
+
if (typeof input2 !== "string")
|
|
628465
|
+
return "";
|
|
628466
|
+
return (input2.length > 4096 ? input2.slice(0, 4096) : input2).replace(SURROGATE_PATTERN, (match) => match.length === 2 ? match : " ").replace(INVISIBLE_PATTERN, " ");
|
|
628467
|
+
}
|
|
628468
|
+
function sanitizeLoneSurrogatesFallback(value) {
|
|
628469
|
+
const chunks = [];
|
|
628470
|
+
for (let i6 = 0;i6 < value.length; i6 += 8192) {
|
|
628471
|
+
const end = Math.min(i6 + 8192, value.length);
|
|
628472
|
+
const codes = new Uint16Array(end - i6);
|
|
628473
|
+
for (let a6 = i6;a6 < end; a6++)
|
|
628474
|
+
codes[a6 - i6] = value.charCodeAt(a6);
|
|
628475
|
+
chunks.push(String.fromCharCode(...codes));
|
|
628476
|
+
}
|
|
628477
|
+
return chunks.join("");
|
|
628478
|
+
}
|
|
628479
|
+
function sanitizeLoneSurrogates(value) {
|
|
628480
|
+
if (typeof Buffer < "u")
|
|
628481
|
+
return Buffer.from(value, "utf16le").toString("utf16le");
|
|
628482
|
+
return sanitizeLoneSurrogatesFallback(value);
|
|
628483
|
+
}
|
|
628484
|
+
function truncateToDisplayLength(value, max2) {
|
|
628485
|
+
if (max2 <= 0)
|
|
628486
|
+
return "";
|
|
628487
|
+
if (value.length <= max2)
|
|
628488
|
+
return value;
|
|
628489
|
+
const head = value.slice(0, max2);
|
|
628490
|
+
const lastUnit = head.charCodeAt(max2 - 1);
|
|
628491
|
+
return sanitizeLoneSurrogates(lastUnit >= 55296 && lastUnit <= 56319 ? head.slice(0, -1) : head);
|
|
628492
|
+
}
|
|
628493
|
+
function redactSecretsForDisplay(value, mode = "all") {
|
|
628494
|
+
function replacer(match, label, secret) {
|
|
628495
|
+
return /[0-9._~+/=%-]/.test(secret) ? `${label} [redacted]` : match;
|
|
628496
|
+
}
|
|
628497
|
+
if (mode === "none")
|
|
628498
|
+
return value;
|
|
628499
|
+
return value.replace(/(?:\b|(?<=\\[A-Za-z"']))(bearer|basic)[\s:=\uFF1A\uFF1D]+(?:(?:\\*["']|\\+)\s*)?([A-Za-z0-9._~+/=%-]{8,})/gi, replacer).replace(/(?:\b|(?<=\\[A-Za-z"']))((?:access[-_ ]?|refresh[-_ ]?|id[-_ ]?|client[-_ ]?|api[-_ ]?|x[-_]api[-_ ]?|session[-_ ]?|auth[-_ ]?)?(?:token|key|secret|password|authorization|credential)s?)(?:\\*["']|\\+)?\s*[:=\uFF1A\uFF1D]\s*(?:\\*["']|\\+)?\s*([A-Za-z0-9._~+/=%-]{8,})/gi, replacer);
|
|
628500
|
+
}
|
|
628501
|
+
function sanitizeForDisplay(input2, max2 = DEFAULT_DISPLAY_MAX, redact = "all") {
|
|
628502
|
+
if (typeof input2 !== "string")
|
|
628503
|
+
return "";
|
|
628504
|
+
const cleaned = stripInvisibleForDisplay(input2.normalize("NFKC")).replaceAll(/[<>";\u2018\u2019\u201A\u201C\u201D\u201E\u00AB\u20BB\u2039\u203A\u2329\u232A\u27E8\u27E9\u27EA\u27EB\u3008\u3009\u300A\u300B]/g, " ").replaceAll(/\s+/g, " ").trim();
|
|
628505
|
+
const scanMax = Math.max(REDACT_SCAN_MAX, max2 + REDACT_SCAN_SLACK);
|
|
628506
|
+
const overflow = cleaned.length > scanMax;
|
|
628507
|
+
const redacted = redactSecretsForDisplay(overflow ? truncateToDisplayLength(cleaned, scanMax) : cleaned, redact);
|
|
628508
|
+
return overflow || redacted.length > max2 ? `${truncateToDisplayLength(redacted, max2)}\u2026` : redacted;
|
|
628509
|
+
}
|
|
628510
|
+
function sanitizeDisplayUrl(url3, max2 = 1024) {
|
|
628511
|
+
return sanitizeForDisplay(url3, max2);
|
|
628512
|
+
}
|
|
628513
|
+
function sanitizeServerNameForDisplay(name3, max2 = 64) {
|
|
628514
|
+
if (typeof name3 !== "string")
|
|
628515
|
+
return "";
|
|
628516
|
+
return sanitizeForDisplay(name3.normalize("NFKC").replace(/['`]/g, " "), max2, "none");
|
|
628517
|
+
}
|
|
628518
|
+
var SURROGATE_PATTERN, INVISIBLE_PATTERN, DEFAULT_DISPLAY_MAX = 200, REDACT_SCAN_MAX = 2000, REDACT_SCAN_SLACK = 512;
|
|
628519
|
+
var init_displaySanitize = __esm(() => {
|
|
628520
|
+
SURROGATE_PATTERN = /[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF]|[\uDC00-\uDFFF]/g;
|
|
628521
|
+
INVISIBLE_PATTERN = /[\p{Cc}\p{Cf}\p{Zl}\p{Zp}\p{Default_Ignorable_Code_Point}\u2800]|(?!\u0020)\p{Zs}/gu;
|
|
628522
|
+
});
|
|
628523
|
+
|
|
628230
628524
|
// src/tools/McpAuthTool/McpAuthTool.ts
|
|
628231
|
-
function
|
|
628232
|
-
|
|
628233
|
-
|
|
628234
|
-
|
|
628525
|
+
function buildMcpAuthToolDescription(serverName, config7, resolveUnexpanded = resolveUnexpandedMcpServers) {
|
|
628526
|
+
const transport = config7.type ?? "stdio";
|
|
628527
|
+
const displayOrigin = getMcpErrorEndpoint(serverName, config7, { detail: "origin" }, resolveUnexpanded);
|
|
628528
|
+
const location = displayOrigin && displayOrigin !== transport ? `${transport} at ${sanitizeDisplayUrl(displayOrigin, 256)}` : transport;
|
|
628529
|
+
return `The "${sanitizeServerNameForDisplay(serverName)}" MCP server (${location}) is installed but requires authentication. ` + `Call this tool to start the OAuth flow \u2014 you'll receive an authorization URL to share with the user. ` + `Once the user completes authorization in their browser, the server's real tools will become available automatically.`;
|
|
628235
628530
|
}
|
|
628236
|
-
function createMcpAuthTool(serverName, config7) {
|
|
628237
|
-
const url3 = getConfigUrl(config7);
|
|
628531
|
+
function createMcpAuthTool(serverName, config7, resolveUnexpanded = resolveUnexpandedMcpServers) {
|
|
628238
628532
|
const transport = config7.type ?? "stdio";
|
|
628239
|
-
const
|
|
628240
|
-
const description = `The \`${serverName}\` MCP server (${location}) is installed but requires authentication. ` + `Call this tool to start the OAuth flow \u2014 you'll receive an authorization URL to share with the user. ` + `Once the user completes authorization in their browser, the server's real tools will become available automatically.`;
|
|
628533
|
+
const description = buildMcpAuthToolDescription(serverName, config7, resolveUnexpanded);
|
|
628241
628534
|
return {
|
|
628242
628535
|
name: buildMcpToolName(serverName, "authenticate"),
|
|
628243
628536
|
isMcp: true,
|
|
@@ -628358,7 +628651,10 @@ var init_McpAuthTool = __esm(() => {
|
|
|
628358
628651
|
init_v4();
|
|
628359
628652
|
init_auth11();
|
|
628360
628653
|
init_client12();
|
|
628654
|
+
init_displaySanitize();
|
|
628361
628655
|
init_mcpStringUtils();
|
|
628656
|
+
init_redaction();
|
|
628657
|
+
init_utils9();
|
|
628362
628658
|
init_errors();
|
|
628363
628659
|
init_log3();
|
|
628364
628660
|
inputSchema45 = lazySchema(() => exports_external.object({}));
|
|
@@ -633883,7 +634179,7 @@ function getCacheControl({
|
|
|
633883
634179
|
function querySourceMatchesPatterns(querySource, patterns) {
|
|
633884
634180
|
return querySource !== undefined && patterns.some((pattern) => pattern.endsWith("*") ? querySource.startsWith(pattern.slice(0, -1)) : querySource === pattern);
|
|
633885
634181
|
}
|
|
633886
|
-
function
|
|
634182
|
+
function isMainThreadQuerySource2(querySource) {
|
|
633887
634183
|
return querySourceMatchesPatterns(querySource, MAIN_THREAD_QUERY_SOURCES);
|
|
633888
634184
|
}
|
|
633889
634185
|
function parsePromptCacheTtlEnv(value) {
|
|
@@ -633893,7 +634189,7 @@ function resolvePromptCacheTtlOverride(querySource, agentCacheTtlOverride, isUsi
|
|
|
633893
634189
|
if (isEnvTruthy(process.env.FORCE_PROMPT_CACHING_5M)) {
|
|
633894
634190
|
return { ttl: "5m", reason: "force_5m_env" };
|
|
633895
634191
|
}
|
|
633896
|
-
const isMainThread =
|
|
634192
|
+
const isMainThread = isMainThreadQuerySource2(querySource);
|
|
633897
634193
|
const envTtl = parsePromptCacheTtlEnv(isMainThread ? process.env.CLAUDE_CODE_PROMPT_CACHE_TTL : process.env.CLAUDE_CODE_SUBAGENT_PROMPT_CACHE_TTL);
|
|
633898
634194
|
if (envTtl !== undefined)
|
|
633899
634195
|
return { ttl: envTtl, reason: "env" };
|
|
@@ -634150,7 +634446,7 @@ function getApiForceIdleTimeout() {
|
|
|
634150
634446
|
const ms = parseInt(raw, 10);
|
|
634151
634447
|
return Number.isFinite(ms) && ms > 0 ? ms : undefined;
|
|
634152
634448
|
}
|
|
634153
|
-
async function* executeNonStreamingRequest(clientOptions, retryOptions, paramsFromContext, onAttempt, captureRequest, originatingRequestId) {
|
|
634449
|
+
async function* executeNonStreamingRequest(clientOptions, retryOptions, paramsFromContext, onAttempt, captureRequest, originatingRequestId, gatewayHintWireValues) {
|
|
634154
634450
|
const fallbackTimeoutMs = getNonstreamingFallbackTimeoutMs();
|
|
634155
634451
|
const generator = withRetry(() => getAnthropicClient({
|
|
634156
634452
|
maxRetries: 0,
|
|
@@ -634164,12 +634460,16 @@ async function* executeNonStreamingRequest(clientOptions, retryOptions, paramsFr
|
|
|
634164
634460
|
onAttempt(attempt, start, retryParams.max_tokens);
|
|
634165
634461
|
const adjustedParams = adjustParamsForNonStreaming(retryParams, MAX_NON_STREAMING_TOKENS);
|
|
634166
634462
|
try {
|
|
634463
|
+
const hintHeaders = {};
|
|
634464
|
+
applyContextCompactedHeaders(hintHeaders, gatewayHintWireValues?.contextCompactedKindForWire, gatewayHintWireValues?.compactionRequestKindForWire);
|
|
634465
|
+
applyPrevToolDurationsHeader(hintHeaders, gatewayHintWireValues?.prevToolDurationsForWire);
|
|
634167
634466
|
return await anthropic.beta.messages.create({
|
|
634168
634467
|
...adjustedParams,
|
|
634169
634468
|
model: normalizeModelStringForAPI(adjustedParams.model)
|
|
634170
634469
|
}, {
|
|
634171
634470
|
signal: retryOptions.signal,
|
|
634172
|
-
timeout: fallbackTimeoutMs
|
|
634471
|
+
timeout: fallbackTimeoutMs,
|
|
634472
|
+
...Object.keys(hintHeaders).length > 0 ? { headers: hintHeaders } : {}
|
|
634173
634473
|
});
|
|
634174
634474
|
} catch (err2) {
|
|
634175
634475
|
if (err2 instanceof APIUserAbortError)
|
|
@@ -634672,6 +634972,9 @@ ${deferredToolList}
|
|
|
634672
634972
|
let research;
|
|
634673
634973
|
let isFastModeRequest = isFastMode;
|
|
634674
634974
|
let isAdvisorInProgress = false;
|
|
634975
|
+
const contextCompactedKindForWire = classifyQuerySource(options.querySource) === "main" && options.agentId === undefined ? consumePendingContextCompacted() : undefined;
|
|
634976
|
+
const compactionRequestKindForWire = options.compactionRequestKind;
|
|
634977
|
+
const prevToolDurationsForWire = options.prevToolDurations !== undefined ? buildPrevToolDurationsHeader(options.prevToolDurations) : undefined;
|
|
634675
634978
|
try {
|
|
634676
634979
|
let clearStreamIdleTimers = function() {
|
|
634677
634980
|
if (streamIdleWarningTimer !== null) {
|
|
@@ -634728,20 +635031,23 @@ ${deferredToolList}
|
|
|
634728
635031
|
}
|
|
634729
635032
|
clientRequestId = getAPIProvider() === "firstParty" && isFirstPartyAnthropicBaseUrl() ? randomUUID33() : undefined;
|
|
634730
635033
|
const incomingTrace = shouldPropagateTraceparent() ? getIncomingTraceContext() : undefined;
|
|
635034
|
+
const attemptHeaders = {
|
|
635035
|
+
...clientRequestId && {
|
|
635036
|
+
[CLIENT_REQUEST_ID_HEADER]: clientRequestId
|
|
635037
|
+
},
|
|
635038
|
+
...incomingTrace?.traceparent && {
|
|
635039
|
+
traceparent: incomingTrace.traceparent
|
|
635040
|
+
},
|
|
635041
|
+
...incomingTrace?.tracestate && {
|
|
635042
|
+
tracestate: incomingTrace.tracestate
|
|
635043
|
+
}
|
|
635044
|
+
};
|
|
635045
|
+
applyContextCompactedHeaders(attemptHeaders, contextCompactedKindForWire, compactionRequestKindForWire);
|
|
635046
|
+
applyPrevToolDurationsHeader(attemptHeaders, prevToolDurationsForWire);
|
|
634731
635047
|
const result = await anthropic.beta.messages.create({ ...params, stream: true }, {
|
|
634732
635048
|
signal,
|
|
634733
635049
|
...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
|
-
}
|
|
635050
|
+
headers: attemptHeaders
|
|
634745
635051
|
}).withResponse();
|
|
634746
635052
|
queryCheckpoint("query_response_headers_received");
|
|
634747
635053
|
streamRequestId = result.request_id;
|
|
@@ -635195,7 +635501,11 @@ ${deferredToolList}
|
|
|
635195
635501
|
}, paramsFromContext, (attempt, _startTime, tokens) => {
|
|
635196
635502
|
attemptNumber = attempt;
|
|
635197
635503
|
maxOutputTokens = tokens;
|
|
635198
|
-
}, (params) => captureAPIRequest(params, options.querySource), streamRequestId
|
|
635504
|
+
}, (params) => captureAPIRequest(params, options.querySource), streamRequestId, {
|
|
635505
|
+
contextCompactedKindForWire,
|
|
635506
|
+
compactionRequestKindForWire,
|
|
635507
|
+
prevToolDurationsForWire
|
|
635508
|
+
});
|
|
635199
635509
|
const m5 = {
|
|
635200
635510
|
message: {
|
|
635201
635511
|
...result,
|
|
@@ -635252,7 +635562,11 @@ ${deferredToolList}
|
|
|
635252
635562
|
}, paramsFromContext, (attempt, _startTime, tokens) => {
|
|
635253
635563
|
attemptNumber = attempt;
|
|
635254
635564
|
maxOutputTokens = tokens;
|
|
635255
|
-
}, (params) => captureAPIRequest(params, options.querySource), failedRequestId
|
|
635565
|
+
}, (params) => captureAPIRequest(params, options.querySource), failedRequestId, {
|
|
635566
|
+
contextCompactedKindForWire,
|
|
635567
|
+
compactionRequestKindForWire,
|
|
635568
|
+
prevToolDurationsForWire
|
|
635569
|
+
});
|
|
635256
635570
|
const m5 = {
|
|
635257
635571
|
message: {
|
|
635258
635572
|
...result,
|
|
@@ -635743,6 +636057,7 @@ var init_claude = __esm(() => {
|
|
|
635743
636057
|
init_utils9();
|
|
635744
636058
|
init_vcr();
|
|
635745
636059
|
init_client9();
|
|
636060
|
+
init_gatewayHints();
|
|
635746
636061
|
init_errors10();
|
|
635747
636062
|
init_logging2();
|
|
635748
636063
|
init_rawApiBodies();
|
|
@@ -638988,6 +639303,9 @@ function getValueFromInput(input2) {
|
|
|
638988
639303
|
function isInputModeCharacter(input2) {
|
|
638989
639304
|
return input2 === "!";
|
|
638990
639305
|
}
|
|
639306
|
+
function shouldTriggerModeSwitch(keystroke, isAtStart, currentMode) {
|
|
639307
|
+
return currentMode !== undefined && isAtStart && isInputModeCharacter(keystroke) && currentMode !== getModeFromInput(keystroke);
|
|
639308
|
+
}
|
|
638991
639309
|
|
|
638992
639310
|
// src/projectOnboardingState.ts
|
|
638993
639311
|
import { join as join128 } from "path";
|
|
@@ -641172,7 +641490,8 @@ function useTextInput({
|
|
|
641172
641490
|
onOffsetChange,
|
|
641173
641491
|
inputFilter,
|
|
641174
641492
|
inlineGhostText,
|
|
641175
|
-
dim: dim2
|
|
641493
|
+
dim: dim2,
|
|
641494
|
+
getInputMode
|
|
641176
641495
|
}) {
|
|
641177
641496
|
if (env4.terminal === "Apple_Terminal") {
|
|
641178
641497
|
prewarmModifiers();
|
|
@@ -641432,7 +641751,7 @@ function useTextInput({
|
|
|
641432
641751
|
if (echo !== null)
|
|
641433
641752
|
pushScreenReaderAnnouncement(echo);
|
|
641434
641753
|
}
|
|
641435
|
-
if (cursor.isAtStart()
|
|
641754
|
+
if (shouldTriggerModeSwitch(input2, cursor.isAtStart(), getInputMode?.())) {
|
|
641436
641755
|
return cursor.insert(text2).left();
|
|
641437
641756
|
}
|
|
641438
641757
|
return cursor.insert(text2);
|
|
@@ -642199,6 +642518,7 @@ function TextInput(props) {
|
|
|
642199
642518
|
onOffsetChange: props.onChangeCursorOffset,
|
|
642200
642519
|
inputFilter: props.inputFilter,
|
|
642201
642520
|
inlineGhostText: props.inlineGhostText,
|
|
642521
|
+
getInputMode: props.getInputMode,
|
|
642202
642522
|
dim: source_default.dim
|
|
642203
642523
|
});
|
|
642204
642524
|
return /* @__PURE__ */ jsx_runtime167.jsx(ThemedBox_default, {
|
|
@@ -730614,7 +730934,7 @@ function urlMatchesPattern2(url3, pattern) {
|
|
|
730614
730934
|
const regexStr = escaped.replace(/\*/g, ".*");
|
|
730615
730935
|
return new RegExp(`^${regexStr}$`).test(url3);
|
|
730616
730936
|
}
|
|
730617
|
-
function
|
|
730937
|
+
function sanitizeHeaderValue2(value) {
|
|
730618
730938
|
return value.replace(/[\r\n\x00]/g, "");
|
|
730619
730939
|
}
|
|
730620
730940
|
function interpolateEnvVars(value, allowedEnvVars) {
|
|
@@ -730626,7 +730946,7 @@ function interpolateEnvVars(value, allowedEnvVars) {
|
|
|
730626
730946
|
}
|
|
730627
730947
|
return process.env[varName] ?? "";
|
|
730628
730948
|
});
|
|
730629
|
-
return
|
|
730949
|
+
return sanitizeHeaderValue2(interpolated);
|
|
730630
730950
|
}
|
|
730631
730951
|
async function execHttpHook(hook, _hookEvent, jsonInput, signal) {
|
|
730632
730952
|
const policy = getHttpHookPolicy();
|
|
@@ -777010,7 +777330,7 @@ var init_PromptInputStashNotice = __esm(() => {
|
|
|
777010
777330
|
function stripLoneSurrogates2(text2) {
|
|
777011
777331
|
if (isWellFormed && isWellFormed(text2))
|
|
777012
777332
|
return text2;
|
|
777013
|
-
return text2.replace(
|
|
777333
|
+
return text2.replace(LONE_SURROGATE_RE2, "");
|
|
777014
777334
|
}
|
|
777015
777335
|
function stripAnsiSequences(text2) {
|
|
777016
777336
|
let result = text2;
|
|
@@ -777034,11 +777354,11 @@ function clampBannerTextWidth(maxWidth) {
|
|
|
777034
777354
|
function sanitizeAndClampBannerText(text2, maxWidth) {
|
|
777035
777355
|
return truncateToWidth(sanitizeBannerText(text2), clampBannerTextWidth(maxWidth));
|
|
777036
777356
|
}
|
|
777037
|
-
var BANNER_TEXT_MAX_WIDTH = 24, ANSI_STRIP_PASSES = 4, ANSI_SEQUENCE_RE,
|
|
777357
|
+
var BANNER_TEXT_MAX_WIDTH = 24, ANSI_STRIP_PASSES = 4, ANSI_SEQUENCE_RE, LONE_SURROGATE_RE2, CONTROL_FORMAT_RE, isWellFormed;
|
|
777038
777358
|
var init_sanitizeBannerText = __esm(() => {
|
|
777039
777359
|
init_truncate();
|
|
777040
777360
|
ANSI_SEQUENCE_RE = /\x1b\[[\x30-\x3f]*[\x20-\x2f]*[\x40-\x7e]|\x1b[\]PX^_][^\x1b\x07]*(?:\x07|\x1b\\)/g;
|
|
777041
|
-
|
|
777361
|
+
LONE_SURROGATE_RE2 = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g;
|
|
777042
777362
|
CONTROL_FORMAT_RE = /[\p{Cc}\p{Cf}\u2028\u2029]+/gu;
|
|
777043
777363
|
isWellFormed = typeof String.prototype.isWellFormed === "function" ? Function.prototype.call.bind(String.prototype.isWellFormed) : undefined;
|
|
777044
777364
|
});
|
|
@@ -778004,14 +778324,14 @@ function PromptInput({
|
|
|
778004
778324
|
abortSpeculation(setAppState);
|
|
778005
778325
|
const isSingleCharInsertion = value.length === input2.length + 1;
|
|
778006
778326
|
const insertedAtStart = cursorOffset === 0;
|
|
778007
|
-
const
|
|
778008
|
-
if (insertedAtStart &&
|
|
778327
|
+
const detectedMode = getModeFromInput(value);
|
|
778328
|
+
if (insertedAtStart && detectedMode !== "prompt" && detectedMode !== mode) {
|
|
778009
778329
|
if (isSingleCharInsertion) {
|
|
778010
|
-
onModeChange(
|
|
778330
|
+
onModeChange(detectedMode);
|
|
778011
778331
|
return;
|
|
778012
778332
|
}
|
|
778013
778333
|
if (input2.length === 0) {
|
|
778014
|
-
onModeChange(
|
|
778334
|
+
onModeChange(detectedMode);
|
|
778015
778335
|
const valueWithoutMode = getValueFromInput(value).replaceAll("\t", " ");
|
|
778016
778336
|
pushToBuffer(input2, cursorOffset, pastedContents);
|
|
778017
778337
|
trackAndSetInput(valueWithoutMode);
|
|
@@ -778028,7 +778348,7 @@ function PromptInput({
|
|
|
778028
778348
|
footerSelection: null
|
|
778029
778349
|
});
|
|
778030
778350
|
trackAndSetInput(processedValue);
|
|
778031
|
-
}, [trackAndSetInput, onModeChange, input2, cursorOffset, pushToBuffer, pastedContents, dismissStashHint, setAppState]);
|
|
778351
|
+
}, [trackAndSetInput, onModeChange, input2, cursorOffset, mode, pushToBuffer, pastedContents, dismissStashHint, setAppState]);
|
|
778032
778352
|
const {
|
|
778033
778353
|
resetHistory,
|
|
778034
778354
|
onHistoryUp,
|
|
@@ -779126,7 +779446,8 @@ function PromptInput({
|
|
|
779126
779446
|
} : undefined,
|
|
779127
779447
|
highlights: combinedHighlights,
|
|
779128
779448
|
inlineGhostText,
|
|
779129
|
-
inputFilter: lazySpaceInputFilter
|
|
779449
|
+
inputFilter: lazySpaceInputFilter,
|
|
779450
|
+
getInputMode: () => mode
|
|
779130
779451
|
};
|
|
779131
779452
|
const getBorderColor = () => {
|
|
779132
779453
|
const modeColors = {
|
|
@@ -831613,7 +831934,7 @@ var _FEATURE_ALLOWLIST = new Set([
|
|
|
831613
831934
|
var feature2 = (name3) => _FEATURE_ALLOWLIST.has(name3);
|
|
831614
831935
|
if (typeof globalThis.MACRO === "undefined") {
|
|
831615
831936
|
globalThis.MACRO = {
|
|
831616
|
-
VERSION: "2.1.
|
|
831937
|
+
VERSION: "2.1.274",
|
|
831617
831938
|
BINARY_NAME: "occ",
|
|
831618
831939
|
BUILD_TIME: new Date().toISOString(),
|
|
831619
831940
|
FEEDBACK_CHANNEL: "",
|