@rayss-dev/openclaude 0.33.3-by-rayss → 0.34.0
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/dist/acp.mjs +705 -433
- package/dist/cli.mjs +52 -51
- package/dist/sdk.mjs +681 -387
- package/docs/settings-reference.md +150 -162
- package/docs/windows-aliases-and-launchers.md +162 -162
- package/package.json +2 -1
package/dist/sdk.mjs
CHANGED
|
@@ -3724,12 +3724,145 @@ function getTeamsDir() {
|
|
|
3724
3724
|
function getProjectsDir() {
|
|
3725
3725
|
return join(getClaudeConfigHomeDir(), "projects");
|
|
3726
3726
|
}
|
|
3727
|
+
function tokenizeNodeOptions(nodeOptions) {
|
|
3728
|
+
const tokens = [];
|
|
3729
|
+
let isInString = false;
|
|
3730
|
+
let willStartNewArg = true;
|
|
3731
|
+
for (let i = 0;i < nodeOptions.length; i++) {
|
|
3732
|
+
let c = nodeOptions[i];
|
|
3733
|
+
if (c === "\\" && isInString) {
|
|
3734
|
+
if (i + 1 >= nodeOptions.length) {
|
|
3735
|
+
return null;
|
|
3736
|
+
}
|
|
3737
|
+
c = nodeOptions[++i];
|
|
3738
|
+
} else if (c === " " && !isInString) {
|
|
3739
|
+
willStartNewArg = true;
|
|
3740
|
+
continue;
|
|
3741
|
+
} else if (c === '"') {
|
|
3742
|
+
isInString = !isInString;
|
|
3743
|
+
continue;
|
|
3744
|
+
}
|
|
3745
|
+
if (willStartNewArg) {
|
|
3746
|
+
tokens.push(c);
|
|
3747
|
+
willStartNewArg = false;
|
|
3748
|
+
} else {
|
|
3749
|
+
tokens[tokens.length - 1] += c;
|
|
3750
|
+
}
|
|
3751
|
+
}
|
|
3752
|
+
if (isInString) {
|
|
3753
|
+
return null;
|
|
3754
|
+
}
|
|
3755
|
+
return tokens;
|
|
3756
|
+
}
|
|
3757
|
+
function resolveNodeOption(name, hasInlineValue) {
|
|
3758
|
+
if (hasInlineValue) {
|
|
3759
|
+
const inlineAlias = NODE_INLINE_OPTION_ALIASES.get(`${name}=`);
|
|
3760
|
+
if (inlineAlias) {
|
|
3761
|
+
return {
|
|
3762
|
+
role: NODE_OPTION_ROLES.get(inlineAlias[0]) ?? "boolean",
|
|
3763
|
+
names: [name, ...inlineAlias]
|
|
3764
|
+
};
|
|
3765
|
+
}
|
|
3766
|
+
}
|
|
3767
|
+
const alias = NODE_OPTION_ALIASES.get(name);
|
|
3768
|
+
if (alias) {
|
|
3769
|
+
return {
|
|
3770
|
+
role: NODE_OPTION_ROLES.get(alias[0]) ?? "boolean",
|
|
3771
|
+
names: [name, ...alias]
|
|
3772
|
+
};
|
|
3773
|
+
}
|
|
3774
|
+
return { role: NODE_OPTION_ROLES.get(name) ?? "boolean", names: [name] };
|
|
3775
|
+
}
|
|
3776
|
+
function parseNodeOptions(nodeOptions) {
|
|
3777
|
+
const tokens = tokenizeNodeOptions(nodeOptions);
|
|
3778
|
+
if (!tokens) {
|
|
3779
|
+
return { valid: false, options: [] };
|
|
3780
|
+
}
|
|
3781
|
+
const options = [];
|
|
3782
|
+
let index = 0;
|
|
3783
|
+
while (index < tokens.length) {
|
|
3784
|
+
const token = tokens[index];
|
|
3785
|
+
index += 1;
|
|
3786
|
+
if (token.length <= 1 || token[0] !== "-") {
|
|
3787
|
+
break;
|
|
3788
|
+
}
|
|
3789
|
+
if (token === "--") {
|
|
3790
|
+
return { valid: false, options: [] };
|
|
3791
|
+
}
|
|
3792
|
+
const equalsIndex = token.startsWith("--") ? token.indexOf("=") : -1;
|
|
3793
|
+
const name = equalsIndex === -1 ? token : token.slice(0, equalsIndex);
|
|
3794
|
+
const inlineValue = equalsIndex === -1 ? undefined : token.slice(equalsIndex + 1);
|
|
3795
|
+
let optionName = name;
|
|
3796
|
+
let negated = false;
|
|
3797
|
+
if (optionName.startsWith("--no-")) {
|
|
3798
|
+
optionName = `--${optionName.slice("--no-".length)}`;
|
|
3799
|
+
negated = true;
|
|
3800
|
+
}
|
|
3801
|
+
const { role, names } = resolveNodeOption(optionName, equalsIndex !== -1);
|
|
3802
|
+
if (negated && role !== "boolean") {
|
|
3803
|
+
return { valid: false, options: [] };
|
|
3804
|
+
}
|
|
3805
|
+
switch (role) {
|
|
3806
|
+
case "boolean":
|
|
3807
|
+
break;
|
|
3808
|
+
case "value": {
|
|
3809
|
+
if (inlineValue !== undefined) {
|
|
3810
|
+
if (inlineValue === "") {
|
|
3811
|
+
return { valid: false, options: [] };
|
|
3812
|
+
}
|
|
3813
|
+
break;
|
|
3814
|
+
}
|
|
3815
|
+
const next = tokens[index];
|
|
3816
|
+
if (next === undefined || next.startsWith("-")) {
|
|
3817
|
+
return { valid: false, options: [] };
|
|
3818
|
+
}
|
|
3819
|
+
index += 1;
|
|
3820
|
+
break;
|
|
3821
|
+
}
|
|
3822
|
+
case "inline-value": {
|
|
3823
|
+
if (inlineValue === undefined) {
|
|
3824
|
+
return { valid: false, options: [] };
|
|
3825
|
+
}
|
|
3826
|
+
break;
|
|
3827
|
+
}
|
|
3828
|
+
case "inline-required": {
|
|
3829
|
+
if (inlineValue === undefined || inlineValue === "") {
|
|
3830
|
+
return { valid: false, options: [] };
|
|
3831
|
+
}
|
|
3832
|
+
break;
|
|
3833
|
+
}
|
|
3834
|
+
}
|
|
3835
|
+
const recorded = new Set;
|
|
3836
|
+
for (const occurrenceName of names) {
|
|
3837
|
+
if (recorded.has(occurrenceName)) {
|
|
3838
|
+
continue;
|
|
3839
|
+
}
|
|
3840
|
+
recorded.add(occurrenceName);
|
|
3841
|
+
options.push({ name: occurrenceName, negated });
|
|
3842
|
+
}
|
|
3843
|
+
}
|
|
3844
|
+
return { valid: true, options };
|
|
3845
|
+
}
|
|
3727
3846
|
function hasNodeOption(flag) {
|
|
3728
3847
|
const nodeOptions = process.env.NODE_OPTIONS;
|
|
3729
3848
|
if (!nodeOptions) {
|
|
3730
3849
|
return false;
|
|
3731
3850
|
}
|
|
3732
|
-
|
|
3851
|
+
const parsed = parseNodeOptions(nodeOptions);
|
|
3852
|
+
if (!parsed.valid) {
|
|
3853
|
+
return false;
|
|
3854
|
+
}
|
|
3855
|
+
const negatedQuery = flag.startsWith("--no-");
|
|
3856
|
+
const optionName = negatedQuery ? `--${flag.slice("--no-".length)}` : flag;
|
|
3857
|
+
let enabled = false;
|
|
3858
|
+
let seen = false;
|
|
3859
|
+
for (const option of parsed.options) {
|
|
3860
|
+
if (option.name === optionName) {
|
|
3861
|
+
enabled = !option.negated;
|
|
3862
|
+
seen = true;
|
|
3863
|
+
}
|
|
3864
|
+
}
|
|
3865
|
+
return negatedQuery ? seen && !enabled : enabled;
|
|
3733
3866
|
}
|
|
3734
3867
|
function isEnvTruthy(envVar) {
|
|
3735
3868
|
if (!envVar)
|
|
@@ -3764,6 +3897,21 @@ function shouldMaintainProjectWorkingDir() {
|
|
|
3764
3897
|
function isRunningOnHomespace() {
|
|
3765
3898
|
return process.env.USER_TYPE === "ant" && isEnvTruthy(process.env.COO_RUNNING_ON_HOMESPACE);
|
|
3766
3899
|
}
|
|
3900
|
+
function getEnvNumber(key, defaultValue) {
|
|
3901
|
+
const value = process.env[key];
|
|
3902
|
+
if (value === undefined) {
|
|
3903
|
+
return defaultValue;
|
|
3904
|
+
}
|
|
3905
|
+
const trimmed = value.trim();
|
|
3906
|
+
if (!/^(0|[1-9]\d*)$/.test(trimmed)) {
|
|
3907
|
+
return defaultValue;
|
|
3908
|
+
}
|
|
3909
|
+
const parsed = Number.parseInt(trimmed, 10);
|
|
3910
|
+
if (!Number.isSafeInteger(parsed) || parsed <= 0) {
|
|
3911
|
+
return defaultValue;
|
|
3912
|
+
}
|
|
3913
|
+
return parsed;
|
|
3914
|
+
}
|
|
3767
3915
|
function isInProtectedNamespace() {
|
|
3768
3916
|
if (process.env.USER_TYPE === "ant") {
|
|
3769
3917
|
return (init_protectedNamespace(), __toCommonJS(exports_protectedNamespace)).checkProtectedNamespace();
|
|
@@ -3779,7 +3927,7 @@ function getVertexRegionForModel(model) {
|
|
|
3779
3927
|
}
|
|
3780
3928
|
return getDefaultVertexRegion();
|
|
3781
3929
|
}
|
|
3782
|
-
var claudeConfigHomeDirOverride, getDefaultClaudeConfigHomeDir, getClaudeConfigHomeDir, VERTEX_REGION_OVERRIDES;
|
|
3930
|
+
var claudeConfigHomeDirOverride, getDefaultClaudeConfigHomeDir, getClaudeConfigHomeDir, NODE_OPTION_ROLES, NODE_OPTION_ALIASES, NODE_INLINE_OPTION_ALIASES, VERTEX_REGION_OVERRIDES;
|
|
3783
3931
|
var init_envUtils = __esm(() => {
|
|
3784
3932
|
init_memoize();
|
|
3785
3933
|
getDefaultClaudeConfigHomeDir = memoize_default(() => {
|
|
@@ -3800,6 +3948,89 @@ var init_envUtils = __esm(() => {
|
|
|
3800
3948
|
}
|
|
3801
3949
|
return getDefaultClaudeConfigHomeDir();
|
|
3802
3950
|
}, { cache: getDefaultClaudeConfigHomeDir.cache });
|
|
3951
|
+
NODE_OPTION_ROLES = new Map([
|
|
3952
|
+
["--max-old-space-size", "inline-value"],
|
|
3953
|
+
["--max-semi-space-size", "inline-value"],
|
|
3954
|
+
["--stack-trace-limit", "inline-required"],
|
|
3955
|
+
["--allow-fs-read", "value"],
|
|
3956
|
+
["--allow-fs-write", "value"],
|
|
3957
|
+
["--conditions", "value"],
|
|
3958
|
+
["-C", "value"],
|
|
3959
|
+
["--cpu-prof-dir", "value"],
|
|
3960
|
+
["--cpu-prof-interval", "value"],
|
|
3961
|
+
["--cpu-prof-name", "value"],
|
|
3962
|
+
["--debug-port", "value"],
|
|
3963
|
+
["--diagnostic-dir", "value"],
|
|
3964
|
+
["--disable-proto", "value"],
|
|
3965
|
+
["--disable-warning", "value"],
|
|
3966
|
+
["--dns-result-order", "value"],
|
|
3967
|
+
["--experimental-default-type", "value"],
|
|
3968
|
+
["--experimental-loader", "value"],
|
|
3969
|
+
["--heap-prof-dir", "value"],
|
|
3970
|
+
["--heap-prof-interval", "value"],
|
|
3971
|
+
["--heap-prof-name", "value"],
|
|
3972
|
+
["--heapsnapshot-near-heap-limit", "value"],
|
|
3973
|
+
["--heapsnapshot-signal", "value"],
|
|
3974
|
+
["--icu-data-dir", "value"],
|
|
3975
|
+
["--import", "value"],
|
|
3976
|
+
["--input-type", "value"],
|
|
3977
|
+
["--inspect-port", "value"],
|
|
3978
|
+
["--inspect-publish-uid", "value"],
|
|
3979
|
+
["--loader", "value"],
|
|
3980
|
+
["--localstorage-file", "value"],
|
|
3981
|
+
["--max-http-header-size", "value"],
|
|
3982
|
+
["--max-old-space-size-percentage", "value"],
|
|
3983
|
+
["--network-family-autoselection-attempt-timeout", "value"],
|
|
3984
|
+
["--openssl-config", "value"],
|
|
3985
|
+
["--redirect-warnings", "value"],
|
|
3986
|
+
["--report-dir", "value"],
|
|
3987
|
+
["--report-directory", "value"],
|
|
3988
|
+
["--report-filename", "value"],
|
|
3989
|
+
["--report-signal", "value"],
|
|
3990
|
+
["--require", "value"],
|
|
3991
|
+
["-r", "value"],
|
|
3992
|
+
["--secure-heap", "value"],
|
|
3993
|
+
["--secure-heap-min", "value"],
|
|
3994
|
+
["--snapshot-blob", "value"],
|
|
3995
|
+
["--test-coverage-branches", "value"],
|
|
3996
|
+
["--test-coverage-exclude", "value"],
|
|
3997
|
+
["--test-coverage-functions", "value"],
|
|
3998
|
+
["--test-coverage-include", "value"],
|
|
3999
|
+
["--test-coverage-lines", "value"],
|
|
4000
|
+
["--test-global-setup", "value"],
|
|
4001
|
+
["--test-isolation", "value"],
|
|
4002
|
+
["--test-name-pattern", "value"],
|
|
4003
|
+
["--test-reporter", "value"],
|
|
4004
|
+
["--test-reporter-destination", "value"],
|
|
4005
|
+
["--test-rerun-failures", "value"],
|
|
4006
|
+
["--test-shard", "value"],
|
|
4007
|
+
["--test-skip-pattern", "value"],
|
|
4008
|
+
["--title", "value"],
|
|
4009
|
+
["--tls-cipher-list", "value"],
|
|
4010
|
+
["--tls-keylog", "value"],
|
|
4011
|
+
["--trace-event-categories", "value"],
|
|
4012
|
+
["--trace-event-file-pattern", "value"],
|
|
4013
|
+
["--trace-require-module", "value"],
|
|
4014
|
+
["--unhandled-rejections", "value"],
|
|
4015
|
+
["--use-largepages", "value"],
|
|
4016
|
+
["--v8-pool-size", "value"],
|
|
4017
|
+
["--watch-kill-signal", "value"],
|
|
4018
|
+
["--watch-path", "value"]
|
|
4019
|
+
]);
|
|
4020
|
+
NODE_OPTION_ALIASES = new Map([
|
|
4021
|
+
["-C", ["--conditions"]],
|
|
4022
|
+
["-r", ["--require"]],
|
|
4023
|
+
["--debug-port", ["--inspect-port"]],
|
|
4024
|
+
["--loader", ["--experimental-loader"]],
|
|
4025
|
+
["--report-directory", ["--report-dir"]],
|
|
4026
|
+
["--experimental-test-isolation", ["--test-isolation"]]
|
|
4027
|
+
]);
|
|
4028
|
+
NODE_INLINE_OPTION_ALIASES = new Map([
|
|
4029
|
+
["--inspect=", ["--inspect-port", "--inspect"]],
|
|
4030
|
+
["--inspect-brk=", ["--inspect-port", "--inspect-brk"]],
|
|
4031
|
+
["--inspect-brk-node=", ["--inspect-port", "--inspect-brk-node"]],
|
|
4032
|
+
["--inspect-wait=", ["--inspect-port", "--inspect-wait"]]
|
|
4033
|
+
]);
|
|
3803
4034
|
VERTEX_REGION_OVERRIDES = [
|
|
3804
4035
|
["claude-haiku-4-5", "VERTEX_REGION_CLAUDE_HAIKU_4_5"],
|
|
3805
4036
|
["claude-3-5-haiku", "VERTEX_REGION_CLAUDE_3_5_HAIKU"],
|
|
@@ -10131,7 +10362,7 @@ var init_version = __esm(() => {
|
|
|
10131
10362
|
import_semver = __toESM(require_semver2(), 1);
|
|
10132
10363
|
fallbackBuildVersion = (() => {
|
|
10133
10364
|
try {
|
|
10134
|
-
return "0.
|
|
10365
|
+
return "0.34.0";
|
|
10135
10366
|
} catch {
|
|
10136
10367
|
return "0.0.0";
|
|
10137
10368
|
}
|
|
@@ -66751,6 +66982,10 @@ var init_types2 = __esm(() => {
|
|
|
66751
66982
|
deniedMcpServers: exports_external.array(DeniedMcpServerEntrySchema()).optional().describe("Enterprise denylist of MCP servers that are explicitly blocked. " + "If a server is on the denylist, it will be blocked across all scopes including enterprise. " + "Denylist takes precedence over allowlist - if a server is on both lists, it is denied."),
|
|
66752
66983
|
hooks: HooksSchema().optional().describe("Custom commands to run before/after tool executions"),
|
|
66753
66984
|
autoFix: AutoFixConfigSchema.optional().describe("Auto-fix configuration: automatically run lint/test after AI file edits " + "and feed errors back for self-repair."),
|
|
66985
|
+
todoReminder: exports_external.object({
|
|
66986
|
+
turnsSinceWrite: exports_external.number().int().positive().optional().catch(undefined).describe("Assistant turns since last TodoWrite/TaskUpdate before showing reminder (default: 10)"),
|
|
66987
|
+
turnsBetweenReminders: exports_external.number().int().positive().optional().catch(undefined).describe("Assistant turns between reminders (default: 10)")
|
|
66988
|
+
}).optional().catch(undefined).describe("Configuration for todo/task tool usage reminders"),
|
|
66754
66989
|
worktree: exports_external.preprocess((val) => {
|
|
66755
66990
|
if (val && typeof val === "object") {
|
|
66756
66991
|
const copy = { ...val };
|
|
@@ -66838,7 +67073,6 @@ var init_types2 = __esm(() => {
|
|
|
66838
67073
|
maxOutputTokens: exports_external.number().int().positive().optional().describe("Maximum output tokens per response.")
|
|
66839
67074
|
})).optional().describe("Per-model overrides for context window and max output tokens. " + "Used for OpenAI-compatible models whose limits are not in the built-in catalog. " + "Keys are matched against the model name (exact match preferred, then prefix). " + "CLAUDE_CODE_OPENAI_CONTEXT_WINDOWS / CLAUDE_CODE_OPENAI_MAX_OUTPUT_TOKENS env vars take precedence. " + 'Example: { "qwen3.6-plus": { "contextWindow": 1048576, "maxOutputTokens": 32768 } }'),
|
|
66840
67075
|
modelPricing: ModelPricingSchema.optional().catch(undefined).describe("Exact-model pricing overrides. Token fields are USD per 1,000,000 tokens; " + "webSearchRequests is USD per request and defaults to $0.01 when omitted. " + "All four token fields are required. Keys are exact, case-sensitive resolved model ids. " + "Shared project settings are ignored for personal USD accounting."),
|
|
66841
|
-
toolUseSummariesEnabled: exports_external.boolean().optional().describe("When true, generate a short summary after completed tool batches. Defaults to false."),
|
|
66842
67076
|
apiRetry: exports_external.object({
|
|
66843
67077
|
maxRetries: exports_external.union([exports_external.number().int().nonnegative(), exports_external.literal("unlimited")]).optional().describe("How many times a retryable request is retried (rate limits like 429, " + "capacity 529, 5xx, transient network errors). Set 0 to never retry, " + 'any positive integer, or "unlimited" to keep retrying (with the fixed ' + "delayMs below) until the request succeeds or you cancel. " + "When unset, the OPENCLAUDE_MAX_RETRIES env var is used (default 10)."),
|
|
66844
67078
|
delayMs: exports_external.number().int().nonnegative().optional().describe("Fixed delay in milliseconds between retry attempts when this is set. " + "Set 5000 for 5 seconds, or 0 to retry immediately. A server-provided " + "Retry-After that is even longer is still honored. When unset, the " + "default exponential backoff (and OPENCLAUDE_RETRY_DELAY_MS env var) apply.")
|
|
@@ -67495,9 +67729,9 @@ function readLinuxProcessStartId(pid) {
|
|
|
67495
67729
|
return null;
|
|
67496
67730
|
}
|
|
67497
67731
|
}
|
|
67498
|
-
function readCommandProcessStartId(command, args, prefix) {
|
|
67732
|
+
function readCommandProcessStartId(command, args, prefix, timeoutMs) {
|
|
67499
67733
|
try {
|
|
67500
|
-
const result =
|
|
67734
|
+
const result = identityLookupSync(command, args, {
|
|
67501
67735
|
encoding: "utf8",
|
|
67502
67736
|
env: {
|
|
67503
67737
|
...process.env,
|
|
@@ -67505,7 +67739,7 @@ function readCommandProcessStartId(command, args, prefix) {
|
|
|
67505
67739
|
LC_ALL: "C",
|
|
67506
67740
|
TZ: "UTC"
|
|
67507
67741
|
},
|
|
67508
|
-
timeout:
|
|
67742
|
+
timeout: timeoutMs,
|
|
67509
67743
|
windowsHide: true
|
|
67510
67744
|
});
|
|
67511
67745
|
if (result.error || result.status !== 0)
|
|
@@ -67516,7 +67750,7 @@ function readCommandProcessStartId(command, args, prefix) {
|
|
|
67516
67750
|
return null;
|
|
67517
67751
|
}
|
|
67518
67752
|
}
|
|
67519
|
-
function readProcessStartId(pid) {
|
|
67753
|
+
function readProcessStartId(pid, windowsTimeoutMs = WINDOWS_SETTINGS_LOCK_IDENTITY_LOOKUP_TIMEOUT_MS) {
|
|
67520
67754
|
if (process.platform === "linux")
|
|
67521
67755
|
return readLinuxProcessStartId(pid);
|
|
67522
67756
|
if (process.platform === "win32") {
|
|
@@ -67525,9 +67759,9 @@ function readProcessStartId(pid) {
|
|
|
67525
67759
|
"-NonInteractive",
|
|
67526
67760
|
"-Command",
|
|
67527
67761
|
`(Get-Process -Id ${pid} -ErrorAction Stop).StartTime.ToUniversalTime().Ticks`
|
|
67528
|
-
], "windows");
|
|
67762
|
+
], "windows", windowsTimeoutMs);
|
|
67529
67763
|
}
|
|
67530
|
-
return readCommandProcessStartId("ps", ["-p", String(pid), "-o", "lstart="], "posix");
|
|
67764
|
+
return readCommandProcessStartId("ps", ["-p", String(pid), "-o", "lstart="], "posix", SETTINGS_LOCK_IDENTITY_LOOKUP_TIMEOUT_MS);
|
|
67531
67765
|
}
|
|
67532
67766
|
function currentProcessStartId() {
|
|
67533
67767
|
if (settingsLockProcessStartId !== undefined) {
|
|
@@ -67566,7 +67800,7 @@ function isIdentityOwnerAlive(identity4, processStartIds) {
|
|
|
67566
67800
|
if (processStartIds.has(cacheKey)) {
|
|
67567
67801
|
currentProcessStartId2 = processStartIds.get(cacheKey) ?? null;
|
|
67568
67802
|
} else {
|
|
67569
|
-
currentProcessStartId2 = readProcessStartId(identity4.pid);
|
|
67803
|
+
currentProcessStartId2 = readProcessStartId(identity4.pid, SETTINGS_LOCK_IDENTITY_LOOKUP_TIMEOUT_MS);
|
|
67570
67804
|
processStartIds.set(cacheKey, currentProcessStartId2);
|
|
67571
67805
|
}
|
|
67572
67806
|
return currentProcessStartId2 === null || currentProcessStartId2 === identity4.processStartId;
|
|
@@ -67702,6 +67936,10 @@ function acquireSettingsLock(targetPath) {
|
|
|
67702
67936
|
}
|
|
67703
67937
|
const remaining = deadline - now;
|
|
67704
67938
|
if (remaining <= 0) {
|
|
67939
|
+
if (tryPublishPendingLock(pendingPath, lockPath)) {
|
|
67940
|
+
acquired = true;
|
|
67941
|
+
return () => releaseOwnedLock(lockPath, owner);
|
|
67942
|
+
}
|
|
67705
67943
|
throw Object.assign(new Error(`Timed out after ${SETTINGS_LOCK_WAIT_MS}ms waiting for settings lock ${lockPath}, held by ${describeCurrentOwner(lockPath)}. If that process is known to have exited, remove the lock directory before retrying.`), { code: "ELOCKED" });
|
|
67706
67944
|
}
|
|
67707
67945
|
Atomics.wait(waitBuffer, 0, 0, Math.min(SETTINGS_LOCK_RETRY_MS, remaining));
|
|
@@ -67731,7 +67969,7 @@ function withSettingsFileTransactionSync(requestedPath, operation) {
|
|
|
67731
67969
|
release();
|
|
67732
67970
|
return result;
|
|
67733
67971
|
}
|
|
67734
|
-
var SETTINGS_LOCK_RETRY_MS = 25, SETTINGS_LOCK_CONTENTION_LOG_MS = 100, SETTINGS_LOCK_WAIT_MS = 2000, SETTINGS_LOCK_HOST, SETTINGS_LOCK_OWNER_FILE = "owner.json", waitBuffer, settingsLockProcessStartId;
|
|
67972
|
+
var identityLookupSync, SETTINGS_LOCK_RETRY_MS = 25, SETTINGS_LOCK_CONTENTION_LOG_MS = 100, SETTINGS_LOCK_WAIT_MS = 2000, SETTINGS_LOCK_IDENTITY_LOOKUP_TIMEOUT_MS = 1000, WINDOWS_SETTINGS_LOCK_IDENTITY_LOOKUP_TIMEOUT_MS = 1e4, SETTINGS_LOCK_HOST, SETTINGS_LOCK_OWNER_FILE = "owner.json", waitBuffer, settingsLockProcessStartId;
|
|
67735
67973
|
var init_settingsFileTransaction = __esm(() => {
|
|
67736
67974
|
init_debug();
|
|
67737
67975
|
init_errors();
|
|
@@ -67739,6 +67977,7 @@ var init_settingsFileTransaction = __esm(() => {
|
|
|
67739
67977
|
init_fsOperations();
|
|
67740
67978
|
init_internalWrites();
|
|
67741
67979
|
init_settingsCache();
|
|
67980
|
+
identityLookupSync = spawnSync2;
|
|
67742
67981
|
SETTINGS_LOCK_HOST = hostname2();
|
|
67743
67982
|
waitBuffer = new Int32Array(new SharedArrayBuffer(4));
|
|
67744
67983
|
});
|
|
@@ -70366,7 +70605,7 @@ function getAttributionHeader(fingerprint, policy) {
|
|
|
70366
70605
|
if (!policy.generate) {
|
|
70367
70606
|
return "";
|
|
70368
70607
|
}
|
|
70369
|
-
const version2 = `${"0.
|
|
70608
|
+
const version2 = `${"0.34.0"}.${fingerprint}`;
|
|
70370
70609
|
const entrypoint = process.env.CLAUDE_CODE_ENTRYPOINT ?? "unknown";
|
|
70371
70610
|
const cch = "";
|
|
70372
70611
|
const workload = getWorkload();
|
|
@@ -97866,7 +98105,7 @@ function createHttpsProxyAgent(proxyUrl, extra = {}) {
|
|
|
97866
98105
|
callback(null, hostname3, getAddressFamily(options));
|
|
97867
98106
|
};
|
|
97868
98107
|
}
|
|
97869
|
-
return new
|
|
98108
|
+
return new TargetTLSHttpsProxyAgent(proxyUrl, { ...agentOptions, ...extra });
|
|
97870
98109
|
}
|
|
97871
98110
|
function getWebSocketProxyAgent(url3) {
|
|
97872
98111
|
const proxyUrl = getProxyUrl();
|
|
@@ -97963,7 +98202,7 @@ async function getAWSClientProxyConfig() {
|
|
|
97963
98202
|
})
|
|
97964
98203
|
};
|
|
97965
98204
|
}
|
|
97966
|
-
var import_https_proxy_agent, keepAliveDisabled, getProxyAgent, proxyInterceptorId;
|
|
98205
|
+
var import_https_proxy_agent, keepAliveDisabled, TargetTLSHttpsProxyAgent, getProxyAgent, proxyInterceptorId;
|
|
97967
98206
|
var init_proxy = __esm(() => {
|
|
97968
98207
|
init_axios2();
|
|
97969
98208
|
init_memoize();
|
|
@@ -97974,6 +98213,17 @@ var init_proxy = __esm(() => {
|
|
|
97974
98213
|
init_optionalRuntimeModule();
|
|
97975
98214
|
import_https_proxy_agent = __toESM(require_dist2(), 1);
|
|
97976
98215
|
keepAliveDisabled = isEnvTruthy(process.env.CLAUDE_CODE_DISABLE_KEEPALIVE);
|
|
98216
|
+
TargetTLSHttpsProxyAgent = class TargetTLSHttpsProxyAgent extends import_https_proxy_agent.HttpsProxyAgent {
|
|
98217
|
+
targetTLSOptions;
|
|
98218
|
+
constructor(proxyUrl, options) {
|
|
98219
|
+
super(proxyUrl, options);
|
|
98220
|
+
const { ca, cert, key, passphrase } = options;
|
|
98221
|
+
this.targetTLSOptions = { ca, cert, key, passphrase };
|
|
98222
|
+
}
|
|
98223
|
+
connect(...[req, opts]) {
|
|
98224
|
+
return super.connect(req, { ...this.targetTLSOptions, ...opts });
|
|
98225
|
+
}
|
|
98226
|
+
};
|
|
97977
98227
|
getProxyAgent = memoize_default((uri) => {
|
|
97978
98228
|
const undiciMod = require_undici();
|
|
97979
98229
|
const mtlsConfig = getMTLSConfig();
|
|
@@ -104002,7 +104252,7 @@ var init_metadata = __esm(() => {
|
|
|
104002
104252
|
COMPOUND_OPERATOR_REGEX = /\s*(?:&&|\|\||[;|])\s*/;
|
|
104003
104253
|
WHITESPACE_REGEX = /\s+/;
|
|
104004
104254
|
getVersionBase = memoize_default(() => {
|
|
104005
|
-
const match = "0.
|
|
104255
|
+
const match = "0.34.0".match(/^\d+\.\d+\.\d+(?:-[a-z]+)?/);
|
|
104006
104256
|
return match ? match[0] : undefined;
|
|
104007
104257
|
});
|
|
104008
104258
|
buildEnvContext = memoize_default(async () => {
|
|
@@ -104042,9 +104292,9 @@ var init_metadata = __esm(() => {
|
|
|
104042
104292
|
isGithubAction: isEnvTruthy(process.env.GITHUB_ACTIONS),
|
|
104043
104293
|
isClaudeCodeAction: isEnvTruthy(process.env.CLAUDE_CODE_ACTION),
|
|
104044
104294
|
isClaudeAiAuth: isClaudeAISubscriber(),
|
|
104045
|
-
version: "0.
|
|
104295
|
+
version: "0.34.0",
|
|
104046
104296
|
versionBase: getVersionBase(),
|
|
104047
|
-
buildTime: "2026-
|
|
104297
|
+
buildTime: "2026-11-08T14:26:39.046Z",
|
|
104048
104298
|
deploymentEnvironment: env2.detectDeploymentEnvironment(),
|
|
104049
104299
|
...isEnvTruthy(process.env.GITHUB_ACTIONS) && {
|
|
104050
104300
|
githubEventName: process.env.GITHUB_EVENT_NAME,
|
|
@@ -112201,11 +112451,11 @@ var init_effort = __esm(() => {
|
|
|
112201
112451
|
|
|
112202
112452
|
// src/utils/userAgent.ts
|
|
112203
112453
|
function getClaudeCodeUserAgent() {
|
|
112204
|
-
return `claude-code/${"0.
|
|
112454
|
+
return `claude-code/${"0.34.0"}`;
|
|
112205
112455
|
}
|
|
112206
112456
|
function getOpenClaudeUserAgent() {
|
|
112207
112457
|
try {
|
|
112208
|
-
return `openclaude/${"0.
|
|
112458
|
+
return `openclaude/${"0.34.0"}`;
|
|
112209
112459
|
} catch {
|
|
112210
112460
|
return "openclaude/0.0.0";
|
|
112211
112461
|
}
|
|
@@ -112217,7 +112467,7 @@ function getUserAgent() {
|
|
|
112217
112467
|
const clientApp = process.env.CLAUDE_AGENT_SDK_CLIENT_APP ? `, client-app/${process.env.CLAUDE_AGENT_SDK_CLIENT_APP}` : "";
|
|
112218
112468
|
const workload = getWorkload();
|
|
112219
112469
|
const workloadSuffix = workload ? `, workload/${workload}` : "";
|
|
112220
|
-
return `claude-cli/${"0.
|
|
112470
|
+
return `claude-cli/${"0.34.0"} (${process.env.USER_TYPE}, ${process.env.CLAUDE_CODE_ENTRYPOINT ?? "cli"}${agentSdkVersion}${clientApp}${workloadSuffix})`;
|
|
112221
112471
|
}
|
|
112222
112472
|
function getMCPUserAgent() {
|
|
112223
112473
|
const parts = [];
|
|
@@ -112231,7 +112481,7 @@ function getMCPUserAgent() {
|
|
|
112231
112481
|
parts.push(`client-app/${process.env.CLAUDE_AGENT_SDK_CLIENT_APP}`);
|
|
112232
112482
|
}
|
|
112233
112483
|
const suffix = parts.length > 0 ? ` (${parts.join(", ")})` : "";
|
|
112234
|
-
return `claude-code/${"0.
|
|
112484
|
+
return `claude-code/${"0.34.0"}${suffix}`;
|
|
112235
112485
|
}
|
|
112236
112486
|
function getWebFetchUserAgent() {
|
|
112237
112487
|
const supportUrl = isFirstPartyAnthropicProvider() ? "https://support.anthropic.com/" : "https://github.com/rayss868/openclaude";
|
|
@@ -115727,11 +115977,13 @@ function createRequestBodyPlanner(context) {
|
|
|
115727
115977
|
options.temperature = params.temperature;
|
|
115728
115978
|
if (params.top_p !== undefined)
|
|
115729
115979
|
options.top_p = params.top_p;
|
|
115980
|
+
const think = request.reasoning?.effort ? ["xhigh", "max", "ultracode"].includes(request.reasoning.effort) ? "high" : request.reasoning.effort : false;
|
|
115730
115981
|
return {
|
|
115731
115982
|
model: request.resolvedModel,
|
|
115732
115983
|
messages: normalizeOllamaNativeMessages(body.messages),
|
|
115733
115984
|
stream: params.stream ?? false,
|
|
115734
115985
|
options,
|
|
115986
|
+
think,
|
|
115735
115987
|
...body.tools ? { tools: body.tools } : {}
|
|
115736
115988
|
};
|
|
115737
115989
|
};
|
|
@@ -152805,57 +153057,6 @@ var init_ReadMcpResourceTool = __esm(() => {
|
|
|
152805
153057
|
});
|
|
152806
153058
|
});
|
|
152807
153059
|
|
|
152808
|
-
// src/services/mcp/argCoercion.ts
|
|
152809
|
-
function coerceValue(value, schema) {
|
|
152810
|
-
if (value === null || value === undefined || !schema) {
|
|
152811
|
-
return value;
|
|
152812
|
-
}
|
|
152813
|
-
const type = schema.type;
|
|
152814
|
-
if (type === "integer" || type === "number") {
|
|
152815
|
-
if (typeof value === "string" && value.trim() !== "") {
|
|
152816
|
-
const parsed = Number(value);
|
|
152817
|
-
if (Number.isFinite(parsed)) {
|
|
152818
|
-
return parsed;
|
|
152819
|
-
}
|
|
152820
|
-
}
|
|
152821
|
-
return value;
|
|
152822
|
-
}
|
|
152823
|
-
if (type === "boolean") {
|
|
152824
|
-
if (value === "true")
|
|
152825
|
-
return true;
|
|
152826
|
-
if (value === "false")
|
|
152827
|
-
return false;
|
|
152828
|
-
return value;
|
|
152829
|
-
}
|
|
152830
|
-
if (type === "object" && typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
152831
|
-
const props = schema.properties;
|
|
152832
|
-
if (!props)
|
|
152833
|
-
return value;
|
|
152834
|
-
const out = {};
|
|
152835
|
-
for (const [key, v] of Object.entries(value)) {
|
|
152836
|
-
out[key] = coerceValue(v, props[key]);
|
|
152837
|
-
}
|
|
152838
|
-
return out;
|
|
152839
|
-
}
|
|
152840
|
-
if (type === "array" && Array.isArray(value)) {
|
|
152841
|
-
if (!schema.items)
|
|
152842
|
-
return value;
|
|
152843
|
-
return value.map((item) => coerceValue(item, schema.items));
|
|
152844
|
-
}
|
|
152845
|
-
return value;
|
|
152846
|
-
}
|
|
152847
|
-
function coerceArgsToInputSchema(args, inputSchema8) {
|
|
152848
|
-
if (!inputSchema8 || typeof inputSchema8 !== "object" || !inputSchema8.properties) {
|
|
152849
|
-
return args;
|
|
152850
|
-
}
|
|
152851
|
-
const props = inputSchema8.properties;
|
|
152852
|
-
const out = {};
|
|
152853
|
-
for (const [key, value] of Object.entries(args)) {
|
|
152854
|
-
out[key] = coerceValue(value, props[key]);
|
|
152855
|
-
}
|
|
152856
|
-
return out;
|
|
152857
|
-
}
|
|
152858
|
-
|
|
152859
153060
|
// src/utils/codeIndexing.ts
|
|
152860
153061
|
function detectCodeIndexingFromCommand(command) {
|
|
152861
153062
|
const trimmed = command.trim();
|
|
@@ -157042,7 +157243,7 @@ function computeFingerprint(messageText2, version2) {
|
|
|
157042
157243
|
}
|
|
157043
157244
|
function computeFingerprintFromMessages(messages) {
|
|
157044
157245
|
const firstMessageText = extractFirstMessageText(messages);
|
|
157045
|
-
return computeFingerprint(firstMessageText, "0.
|
|
157246
|
+
return computeFingerprint(firstMessageText, "0.34.0");
|
|
157046
157247
|
}
|
|
157047
157248
|
var FINGERPRINT_SALT = "59cf53e54c78";
|
|
157048
157249
|
var init_fingerprint = () => {};
|
|
@@ -158525,7 +158726,7 @@ var init_client2 = __esm(() => {
|
|
|
158525
158726
|
const client = new Client({
|
|
158526
158727
|
name: "claude-code",
|
|
158527
158728
|
title: "OpenClaude",
|
|
158528
|
-
version: "0.
|
|
158729
|
+
version: "0.34.0",
|
|
158529
158730
|
description: "OpenClaude — coding-agent CLI for any LLM provider",
|
|
158530
158731
|
websiteUrl: PRODUCT_URL
|
|
158531
158732
|
}, {
|
|
@@ -159023,7 +159224,6 @@ var init_client2 = __esm(() => {
|
|
|
159023
159224
|
async call(args, context2, _canUseTool, parentMessage, onProgress) {
|
|
159024
159225
|
const toolUseId = extractToolUseId(parentMessage);
|
|
159025
159226
|
const meta = toolUseId ? { "claudecode/toolUseId": toolUseId } : {};
|
|
159026
|
-
const normalizedArgs = coerceArgsToInputSchema(args, tool2.inputSchema);
|
|
159027
159227
|
if (onProgress && toolUseId) {
|
|
159028
159228
|
try {
|
|
159029
159229
|
onProgress({
|
|
@@ -159072,7 +159272,7 @@ var init_client2 = __esm(() => {
|
|
|
159072
159272
|
client: connectedClient,
|
|
159073
159273
|
clientConnection: client,
|
|
159074
159274
|
tool: tool2.name,
|
|
159075
|
-
args
|
|
159275
|
+
args,
|
|
159076
159276
|
meta,
|
|
159077
159277
|
signal: context2.abortController.signal,
|
|
159078
159278
|
setAppState: context2.setAppState,
|
|
@@ -228500,6 +228700,13 @@ var init_prefetch = __esm(() => {
|
|
|
228500
228700
|
import { readdir as readdir16, stat as stat23 } from "fs/promises";
|
|
228501
228701
|
import nodePath2, { dirname as dirname40, parse as parse10, relative as relative12, resolve as resolve28 } from "path";
|
|
228502
228702
|
import { randomUUID as randomUUID16 } from "crypto";
|
|
228703
|
+
function getTodoReminderConfig() {
|
|
228704
|
+
const config2 = getSettings_DEPRECATED()?.todoReminder;
|
|
228705
|
+
return {
|
|
228706
|
+
turnsSinceWrite: config2?.turnsSinceWrite ?? getEnvNumber("OPENCLAUDE_TODO_REMINDER_TURNS_SINCE_WRITE", 10),
|
|
228707
|
+
turnsBetweenReminders: config2?.turnsBetweenReminders ?? getEnvNumber("OPENCLAUDE_TODO_REMINDER_TURNS_BETWEEN_REMINDERS", 10)
|
|
228708
|
+
};
|
|
228709
|
+
}
|
|
228503
228710
|
function shouldIncludeSkillListingAttachment(querySource) {
|
|
228504
228711
|
return !(typeof querySource === "string" && SKILL_LISTING_SUPPRESSED_QUERY_SOURCES.has(querySource));
|
|
228505
228712
|
}
|
|
@@ -229850,7 +230057,8 @@ async function getTodoReminderAttachments(messages, toolUseContext) {
|
|
|
229850
230057
|
return [];
|
|
229851
230058
|
}
|
|
229852
230059
|
const { turnsSinceLastTodoWrite, turnsSinceLastReminder } = getTodoReminderTurnCounts(messages);
|
|
229853
|
-
|
|
230060
|
+
const reminderConfig = getTodoReminderConfig();
|
|
230061
|
+
if (turnsSinceLastTodoWrite >= reminderConfig.turnsSinceWrite && turnsSinceLastReminder >= reminderConfig.turnsBetweenReminders) {
|
|
229854
230062
|
const todoKey = toolUseContext.agentId ?? getSessionId();
|
|
229855
230063
|
const appState = toolUseContext.getAppState();
|
|
229856
230064
|
const todos = appState.todos[todoKey] ?? [];
|
|
@@ -229911,7 +230119,8 @@ async function getTaskReminderAttachments(messages, toolUseContext) {
|
|
|
229911
230119
|
return [];
|
|
229912
230120
|
}
|
|
229913
230121
|
const { turnsSinceLastTaskManagement, turnsSinceLastReminder } = getTaskReminderTurnCounts(messages);
|
|
229914
|
-
|
|
230122
|
+
const reminderConfig = getTodoReminderConfig();
|
|
230123
|
+
if (turnsSinceLastTaskManagement >= reminderConfig.turnsSinceWrite && turnsSinceLastReminder >= reminderConfig.turnsBetweenReminders) {
|
|
229915
230124
|
const tasks = await listTasks(getTaskListId());
|
|
229916
230125
|
return [
|
|
229917
230126
|
{
|
|
@@ -230233,7 +230442,7 @@ function isFileReadDenied(filePath, toolPermissionContext) {
|
|
|
230233
230442
|
const denyRule = matchingRuleForInput(filePath, toolPermissionContext, "read", "deny");
|
|
230234
230443
|
return denyRule !== null;
|
|
230235
230444
|
}
|
|
230236
|
-
var skillSearchModules, autoModeStateModule2, BRIEF_TOOL_NAME2 = null,
|
|
230445
|
+
var skillSearchModules, autoModeStateModule2, BRIEF_TOOL_NAME2 = null, PLAN_MODE_ATTACHMENT_CONFIG, AUTO_MODE_ATTACHMENT_CONFIG, SKILL_LISTING_SUPPRESSED_QUERY_SOURCES, MAX_MEMORY_LINES = 200, MAX_MEMORY_BYTES = 4096, RELEVANT_MEMORIES_CONFIG, VERIFY_PLAN_REMINDER_CONFIG, ATTACHMENT_FILE_IO_CONCURRENCY = 8, INLINE_NOTIFICATION_MODES, defaultAtMentionedFileDeps, defaultChangedFileDeps, sentSkillNames, suppressNext = false, FILTERED_LISTING_MAX = 30, LSP_DIAGNOSTIC_ATTACHMENT_MAX_WAIT_MS, MIN_SNIP_NUDGE_TOKENS = 1e4, MAX_SNIP_NUDGE_REPEAT_TOKENS = 1e5, SNIP_NUDGE_START_FRACTION = 0.6, SNIP_NUDGE_REPEAT_FRACTION = 0.1;
|
|
230237
230446
|
var init_attachments2 = __esm(() => {
|
|
230238
230447
|
init_metadata();
|
|
230239
230448
|
init_Tool();
|
|
@@ -230254,6 +230463,7 @@ var init_attachments2 = __esm(() => {
|
|
|
230254
230463
|
init_diagnosticTracking();
|
|
230255
230464
|
init_settings2();
|
|
230256
230465
|
init_providers();
|
|
230466
|
+
init_envUtils();
|
|
230257
230467
|
init_effort();
|
|
230258
230468
|
init_utils5();
|
|
230259
230469
|
init_imageResizer();
|
|
@@ -230313,10 +230523,6 @@ var init_attachments2 = __esm(() => {
|
|
|
230313
230523
|
prefetch: (init_prefetch(), __toCommonJS(exports_prefetch))
|
|
230314
230524
|
};
|
|
230315
230525
|
autoModeStateModule2 = __toCommonJS(exports_autoModeState);
|
|
230316
|
-
TODO_REMINDER_CONFIG = {
|
|
230317
|
-
TURNS_SINCE_WRITE: 10,
|
|
230318
|
-
TURNS_BETWEEN_REMINDERS: 10
|
|
230319
|
-
};
|
|
230320
230526
|
PLAN_MODE_ATTACHMENT_CONFIG = {
|
|
230321
230527
|
TURNS_BETWEEN_ATTACHMENTS: 5,
|
|
230322
230528
|
FULL_REMINDER_EVERY_N_ATTACHMENTS: 5
|
|
@@ -232283,50 +232489,6 @@ var init_doomLoop = __esm(() => {
|
|
|
232283
232489
|
stateByAgent = new Map;
|
|
232284
232490
|
});
|
|
232285
232491
|
|
|
232286
|
-
// src/utils/toolErrorRepeats.ts
|
|
232287
|
-
function getState2(agentKey) {
|
|
232288
|
-
let state2 = stateByAgent2.get(agentKey);
|
|
232289
|
-
if (!state2) {
|
|
232290
|
-
state2 = { lastTool: null, lastError: null, count: 0 };
|
|
232291
|
-
stateByAgent2.set(agentKey, state2);
|
|
232292
|
-
}
|
|
232293
|
-
return state2;
|
|
232294
|
-
}
|
|
232295
|
-
function normalizeText(text) {
|
|
232296
|
-
return text.replace(/\s+/g, " ").replace(/\d+/g, "#").trim();
|
|
232297
|
-
}
|
|
232298
|
-
function buildNudge(count4) {
|
|
232299
|
-
return `
|
|
232300
|
-
<system-reminder>This is the ${count4}th consecutive failure of this tool with the same error. Do not simply retry — pause, re-read the original request and the error above, then adjust your approach.</system-reminder>`;
|
|
232301
|
-
}
|
|
232302
|
-
function recordRepeatedToolError(agentKey, toolName, errorText) {
|
|
232303
|
-
const state2 = getState2(agentKey);
|
|
232304
|
-
const normalized = normalizeText(errorText);
|
|
232305
|
-
if (state2.lastTool === toolName && state2.lastError === normalized) {
|
|
232306
|
-
state2.count++;
|
|
232307
|
-
} else {
|
|
232308
|
-
state2.lastTool = toolName;
|
|
232309
|
-
state2.lastError = normalized;
|
|
232310
|
-
state2.count = 1;
|
|
232311
|
-
}
|
|
232312
|
-
if (state2.count >= DEFAULT_THRESHOLD2) {
|
|
232313
|
-
return { count: state2.count, nudge: buildNudge(state2.count) };
|
|
232314
|
-
}
|
|
232315
|
-
return { count: state2.count };
|
|
232316
|
-
}
|
|
232317
|
-
function resetToolErrorRepeats(agentKey, toolName) {
|
|
232318
|
-
const state2 = stateByAgent2.get(agentKey);
|
|
232319
|
-
if (state2 && state2.lastTool === toolName) {
|
|
232320
|
-
state2.lastTool = null;
|
|
232321
|
-
state2.lastError = null;
|
|
232322
|
-
state2.count = 0;
|
|
232323
|
-
}
|
|
232324
|
-
}
|
|
232325
|
-
var DEFAULT_THRESHOLD2 = 3, stateByAgent2;
|
|
232326
|
-
var init_toolErrorRepeats = __esm(() => {
|
|
232327
|
-
stateByAgent2 = new Map;
|
|
232328
|
-
});
|
|
232329
|
-
|
|
232330
232492
|
// src/utils/sessionPersistencePolicy.ts
|
|
232331
232493
|
function shouldSkipSessionPersistence() {
|
|
232332
232494
|
const allowTestPersistence = isEnvTruthy(process.env.TEST_ENABLE_SESSION_PERSISTENCE);
|
|
@@ -234160,14 +234322,13 @@ async function checkPermissionsAndCallTool(tool2, toolUseID, input, toolUseConte
|
|
|
234160
234322
|
},
|
|
234161
234323
|
...mcpToolDetailsForAnalytics(tool2.name, mcpServerType, mcpServerBaseUrl)
|
|
234162
234324
|
});
|
|
234163
|
-
const repeatedError = recordRepeatedToolError(toolUseContext.agentId ?? "main", tool2.name, errorContent);
|
|
234164
234325
|
return [
|
|
234165
234326
|
{
|
|
234166
234327
|
message: createUserMessage({
|
|
234167
234328
|
content: [
|
|
234168
234329
|
{
|
|
234169
234330
|
type: "tool_result",
|
|
234170
|
-
content: `<tool_use_error>InputValidationError: ${errorContent}</tool_use_error
|
|
234331
|
+
content: `<tool_use_error>InputValidationError: ${errorContent}</tool_use_error>`,
|
|
234171
234332
|
is_error: true,
|
|
234172
234333
|
tool_use_id: toolUseID
|
|
234173
234334
|
}
|
|
@@ -234595,7 +234756,6 @@ async function checkPermissionsAndCallTool(tool2, toolUseID, input, toolUseConte
|
|
|
234595
234756
|
const toolContextModifier = result.contextModifier;
|
|
234596
234757
|
const mcpMeta = result.mcpMeta;
|
|
234597
234758
|
async function addToolResult(toolUseResult, preMappedBlock) {
|
|
234598
|
-
resetToolErrorRepeats(toolUseContext.agentId ?? "main", tool2.name);
|
|
234599
234759
|
const toolResultBlock = preMappedBlock ? await processPreMappedToolResultBlock(preMappedBlock, tool2.name, tool2.maxResultSizeChars) : await processToolResultBlock(tool2, toolUseResult, toolUseID);
|
|
234600
234760
|
const contentBlocks = [toolResultBlock];
|
|
234601
234761
|
if ("acceptFeedback" in permissionDecision && permissionDecision.acceptFeedback) {
|
|
@@ -234781,14 +234941,13 @@ async function checkPermissionsAndCallTool(tool2, toolUseID, input, toolUseConte
|
|
|
234781
234941
|
delete hookChainsContext.hookChainsCanUseTool;
|
|
234782
234942
|
}
|
|
234783
234943
|
}
|
|
234784
|
-
const repeatedError = recordRepeatedToolError(toolUseContext.agentId ?? "main", tool2.name, content);
|
|
234785
234944
|
return [
|
|
234786
234945
|
{
|
|
234787
234946
|
message: createUserMessage({
|
|
234788
234947
|
content: [
|
|
234789
234948
|
{
|
|
234790
234949
|
type: "tool_result",
|
|
234791
|
-
content
|
|
234950
|
+
content,
|
|
234792
234951
|
is_error: true,
|
|
234793
234952
|
tool_use_id: toolUseID
|
|
234794
234953
|
}
|
|
@@ -234831,7 +234990,6 @@ var init_toolExecution = __esm(() => {
|
|
|
234831
234990
|
init_abortReasons();
|
|
234832
234991
|
init_debug();
|
|
234833
234992
|
init_doomLoop();
|
|
234834
|
-
init_toolErrorRepeats();
|
|
234835
234993
|
init_errors();
|
|
234836
234994
|
init_hooks4();
|
|
234837
234995
|
init_log();
|
|
@@ -236540,7 +236698,7 @@ function buildQueryConfig() {
|
|
|
236540
236698
|
sessionId: getSessionId(),
|
|
236541
236699
|
gates: {
|
|
236542
236700
|
streamingToolExecution: checkStatsigFeatureGate_CACHED_MAY_BE_STALE("tengu_streaming_tool_execution2"),
|
|
236543
|
-
emitToolUseSummaries:
|
|
236701
|
+
emitToolUseSummaries: isEnvTruthy(process.env.CLAUDE_CODE_EMIT_TOOL_USE_SUMMARIES),
|
|
236544
236702
|
isAnt: false,
|
|
236545
236703
|
fastModeEnabled: !isEnvTruthy(process.env.CLAUDE_CODE_DISABLE_FAST_MODE)
|
|
236546
236704
|
}
|
|
@@ -236550,7 +236708,6 @@ var init_config7 = __esm(() => {
|
|
|
236550
236708
|
init_state();
|
|
236551
236709
|
init_growthbook();
|
|
236552
236710
|
init_envUtils();
|
|
236553
|
-
init_settings2();
|
|
236554
236711
|
});
|
|
236555
236712
|
|
|
236556
236713
|
// src/query/deps.ts
|
|
@@ -238564,7 +238721,7 @@ function getAnthropicEnvMetadata() {
|
|
|
238564
238721
|
function getBuildAgeMinutes() {
|
|
238565
238722
|
if (false)
|
|
238566
238723
|
;
|
|
238567
|
-
const buildTime = new Date("2026-
|
|
238724
|
+
const buildTime = new Date("2026-11-08T14:26:39.046Z").getTime();
|
|
238568
238725
|
if (isNaN(buildTime))
|
|
238569
238726
|
return;
|
|
238570
238727
|
return Math.floor((Date.now() - buildTime) / 60000);
|
|
@@ -248641,10 +248798,8 @@ function convertOllamaStreamingResponse(response, fallbackModel, makeMessageId2
|
|
|
248641
248798
|
buffer = lines.pop() ?? "";
|
|
248642
248799
|
let emitted = false;
|
|
248643
248800
|
for (const line of lines)
|
|
248644
|
-
if (line.trim())
|
|
248645
|
-
enqueue(line.trim(), controller);
|
|
248801
|
+
if (line.trim() && enqueue(line.trim(), controller))
|
|
248646
248802
|
emitted = true;
|
|
248647
|
-
}
|
|
248648
248803
|
if (emitted)
|
|
248649
248804
|
return;
|
|
248650
248805
|
}
|
|
@@ -248658,7 +248813,7 @@ function convertOllamaStreamingResponse(response, fallbackModel, makeMessageId2
|
|
|
248658
248813
|
try {
|
|
248659
248814
|
data = JSON.parse(line);
|
|
248660
248815
|
} catch {
|
|
248661
|
-
return;
|
|
248816
|
+
return false;
|
|
248662
248817
|
}
|
|
248663
248818
|
const model = data.model ?? fallbackModel;
|
|
248664
248819
|
const chunks = [];
|
|
@@ -248684,6 +248839,7 @@ function convertOllamaStreamingResponse(response, fallbackModel, makeMessageId2
|
|
|
248684
248839
|
}
|
|
248685
248840
|
for (const chunk of chunks)
|
|
248686
248841
|
controller.enqueue(encoder.encode(chunk));
|
|
248842
|
+
return chunks.length > 0;
|
|
248687
248843
|
}
|
|
248688
248844
|
return responseWithPreservedUrl(stream4, { status: response.status, statusText: response.statusText, headers: { "content-type": "text/event-stream" } }, response.url);
|
|
248689
248845
|
}
|
|
@@ -249320,6 +249476,13 @@ function convertNonStreamingResponseToAnthropicMessage(data, model, deps) {
|
|
|
249320
249476
|
content.push({ type: "text", text: `
|
|
249321
249477
|
|
|
249322
249478
|
[Content blocked by provider safety filter]` });
|
|
249479
|
+
} else if (choice?.finish_reason === "length") {
|
|
249480
|
+
content.push({
|
|
249481
|
+
type: "text",
|
|
249482
|
+
text: `
|
|
249483
|
+
|
|
249484
|
+
[Response truncated — reached length limit or upstream stalled. Ask the model to continue.]`
|
|
249485
|
+
});
|
|
249323
249486
|
}
|
|
249324
249487
|
return {
|
|
249325
249488
|
id: data.id ?? deps.makeMessageId(),
|
|
@@ -249361,8 +249524,290 @@ function getStreamStats(state2) {
|
|
|
249361
249524
|
};
|
|
249362
249525
|
}
|
|
249363
249526
|
|
|
249527
|
+
// src/services/api/openaiShim/xmlToolCallParsing.ts
|
|
249528
|
+
function coerceXmlToolValue(raw) {
|
|
249529
|
+
const trimmed = raw.trim();
|
|
249530
|
+
if (trimmed === "")
|
|
249531
|
+
return "";
|
|
249532
|
+
try {
|
|
249533
|
+
return JSON.parse(trimmed);
|
|
249534
|
+
} catch {
|
|
249535
|
+
return raw;
|
|
249536
|
+
}
|
|
249537
|
+
}
|
|
249538
|
+
function parseHy3ToolCallInner(inner) {
|
|
249539
|
+
const args = {};
|
|
249540
|
+
const trimmed = inner.trim();
|
|
249541
|
+
const name = trimmed.split(/[\n<]/, 1)[0]?.trim().replace(/[\s`*_]+$/, "");
|
|
249542
|
+
let hasStructuredArguments = false;
|
|
249543
|
+
for (const parameter of inner.matchAll(HY3_PARAMETER_RE)) {
|
|
249544
|
+
const key = parameter[1];
|
|
249545
|
+
if (key) {
|
|
249546
|
+
hasStructuredArguments = true;
|
|
249547
|
+
args[key] = coerceXmlToolValue(parameter[2] ?? "");
|
|
249548
|
+
}
|
|
249549
|
+
}
|
|
249550
|
+
for (const line of inner.matchAll(HY3_NAMED_ARGUMENT_LINE_RE)) {
|
|
249551
|
+
const key = line[1];
|
|
249552
|
+
if (key) {
|
|
249553
|
+
hasStructuredArguments = true;
|
|
249554
|
+
args[key] = coerceXmlToolValue(line[2] ?? "");
|
|
249555
|
+
}
|
|
249556
|
+
}
|
|
249557
|
+
for (const pair of inner.matchAll(HY3_ARG_PAIR_RE)) {
|
|
249558
|
+
const key = pair[1]?.trim();
|
|
249559
|
+
if (key) {
|
|
249560
|
+
hasStructuredArguments = true;
|
|
249561
|
+
args[key] = coerceXmlToolValue(pair[2] ?? "");
|
|
249562
|
+
}
|
|
249563
|
+
}
|
|
249564
|
+
return {
|
|
249565
|
+
name: name && /^[A-Za-z_][\w.-]*$/.test(name) && (hasStructuredArguments || trimmed === name) ? name : undefined,
|
|
249566
|
+
args
|
|
249567
|
+
};
|
|
249568
|
+
}
|
|
249569
|
+
function isHy3Model(model) {
|
|
249570
|
+
return model.split("?", 1)[0]?.toLowerCase() === "tencent/hy3";
|
|
249571
|
+
}
|
|
249572
|
+
function trailingXmlOpenerPrefixLen(s, allowHy3) {
|
|
249573
|
+
let longest = 0;
|
|
249574
|
+
const openers = allowHy3 ? XML_TOOL_CALL_OPENERS : [XML_TOOL_CALL_OPEN];
|
|
249575
|
+
for (const opener2 of openers) {
|
|
249576
|
+
const max2 = Math.min(s.length, opener2.length - 1);
|
|
249577
|
+
for (let len = max2;len > 0; len--) {
|
|
249578
|
+
if (opener2.startsWith(s.slice(s.length - len))) {
|
|
249579
|
+
longest = Math.max(longest, len);
|
|
249580
|
+
break;
|
|
249581
|
+
}
|
|
249582
|
+
}
|
|
249583
|
+
}
|
|
249584
|
+
return longest;
|
|
249585
|
+
}
|
|
249586
|
+
function findXmlToolCallOpener(text, allowHy3) {
|
|
249587
|
+
const openers = allowHy3 ? XML_TOOL_CALL_OPENERS : [XML_TOOL_CALL_OPEN];
|
|
249588
|
+
return openers.reduce((first, opener2) => {
|
|
249589
|
+
const index = text.indexOf(opener2);
|
|
249590
|
+
return index === -1 ? first : first === -1 ? index : Math.min(first, index);
|
|
249591
|
+
}, -1);
|
|
249592
|
+
}
|
|
249593
|
+
function isJsonText(raw) {
|
|
249594
|
+
try {
|
|
249595
|
+
JSON.parse(raw);
|
|
249596
|
+
return true;
|
|
249597
|
+
} catch {
|
|
249598
|
+
return false;
|
|
249599
|
+
}
|
|
249600
|
+
}
|
|
249601
|
+
function findJsonEnvelopeBody(text, bodyStart) {
|
|
249602
|
+
const firstClose = text.indexOf(XML_TOOL_CALL_CLOSE, bodyStart);
|
|
249603
|
+
const jsonStart = text.indexOf("{", bodyStart);
|
|
249604
|
+
if (jsonStart === -1 || firstClose !== -1 && jsonStart > firstClose)
|
|
249605
|
+
return null;
|
|
249606
|
+
const lead = text.slice(bodyStart, jsonStart);
|
|
249607
|
+
if (XML_FUNCTION_NAME_RE.test(lead) || lead.includes(XML_ARG_KEY_OPEN))
|
|
249608
|
+
return null;
|
|
249609
|
+
const json2 = extractBalancedJson(text, jsonStart);
|
|
249610
|
+
if (!json2 || !isJsonText(json2))
|
|
249611
|
+
return null;
|
|
249612
|
+
const jsonEnd = jsonStart + json2.length;
|
|
249613
|
+
const closeIndex = text.indexOf(XML_TOOL_CALL_CLOSE, jsonEnd);
|
|
249614
|
+
return closeIndex === -1 ? { json: [jsonStart, jsonEnd], bodyEnd: text.length, end: text.length } : { json: [jsonStart, jsonEnd], bodyEnd: closeIndex, end: closeIndex + XML_TOOL_CALL_CLOSE.length };
|
|
249615
|
+
}
|
|
249616
|
+
function xmlToolCallBlockMarkup(block2) {
|
|
249617
|
+
if (!block2.startsWith(XML_TOOL_CALL_OPEN))
|
|
249618
|
+
return block2;
|
|
249619
|
+
const envelope = findJsonEnvelopeBody(block2, XML_TOOL_CALL_OPEN.length);
|
|
249620
|
+
if (envelope?.end !== block2.length)
|
|
249621
|
+
return block2;
|
|
249622
|
+
return block2.slice(0, envelope.json[0]) + block2.slice(envelope.json[1]);
|
|
249623
|
+
}
|
|
249624
|
+
function findStandardXmlToolCallBlocks(text) {
|
|
249625
|
+
const blocks = [];
|
|
249626
|
+
let start = text.indexOf(XML_TOOL_CALL_OPEN);
|
|
249627
|
+
while (start !== -1) {
|
|
249628
|
+
const bodyStart = start + XML_TOOL_CALL_OPEN.length;
|
|
249629
|
+
const envelope = findJsonEnvelopeBody(text, bodyStart);
|
|
249630
|
+
let end;
|
|
249631
|
+
if (envelope) {
|
|
249632
|
+
end = envelope.end;
|
|
249633
|
+
blocks.push({
|
|
249634
|
+
range: [start, end],
|
|
249635
|
+
inner: text.slice(bodyStart, envelope.bodyEnd),
|
|
249636
|
+
json: text.slice(envelope.json[0], envelope.json[1])
|
|
249637
|
+
});
|
|
249638
|
+
} else {
|
|
249639
|
+
const closeIndex = text.indexOf(XML_TOOL_CALL_CLOSE, bodyStart);
|
|
249640
|
+
const bodyEnd = closeIndex === -1 ? text.length : closeIndex;
|
|
249641
|
+
end = closeIndex === -1 ? text.length : closeIndex + XML_TOOL_CALL_CLOSE.length;
|
|
249642
|
+
blocks.push({ range: [start, end], inner: text.slice(bodyStart, bodyEnd) });
|
|
249643
|
+
}
|
|
249644
|
+
start = text.indexOf(XML_TOOL_CALL_OPEN, end);
|
|
249645
|
+
}
|
|
249646
|
+
return blocks;
|
|
249647
|
+
}
|
|
249648
|
+
function findXmlToolCallBlockRanges(text, allowHy3 = false) {
|
|
249649
|
+
const ranges = findStandardXmlToolCallBlocks(text).map((block2) => block2.range);
|
|
249650
|
+
if (allowHy3) {
|
|
249651
|
+
for (const blockRe of [HY3_TOOL_CALLS_BLOCK_RE, HY3_TOOL_CALL_BLOCK_RE]) {
|
|
249652
|
+
for (const block2 of text.matchAll(blockRe)) {
|
|
249653
|
+
ranges.push([block2.index, block2.index + block2[0].length]);
|
|
249654
|
+
}
|
|
249655
|
+
}
|
|
249656
|
+
}
|
|
249657
|
+
return ranges.sort((left, right) => left[0] - right[0] || right[1] - left[1]);
|
|
249658
|
+
}
|
|
249659
|
+
function parseStandardXmlToolCallInner(inner, envelopeJson) {
|
|
249660
|
+
let name;
|
|
249661
|
+
const args = {};
|
|
249662
|
+
const trimmedInner = inner.trim();
|
|
249663
|
+
const isJsonEnvelope = envelopeJson !== undefined;
|
|
249664
|
+
const fnMatch = isJsonEnvelope ? null : inner.match(XML_FUNCTION_NAME_RE);
|
|
249665
|
+
if (fnMatch) {
|
|
249666
|
+
name = fnMatch[1];
|
|
249667
|
+
for (const p of inner.matchAll(XML_PARAMETER_RE)) {
|
|
249668
|
+
const key = p[1];
|
|
249669
|
+
if (key)
|
|
249670
|
+
args[key] = coerceXmlToolValue(p[2] ?? "");
|
|
249671
|
+
}
|
|
249672
|
+
} else {
|
|
249673
|
+
const argPairs = [...inner.matchAll(XML_ARG_PAIR_RE)];
|
|
249674
|
+
if (argPairs.length > 0 && !isJsonEnvelope && !trimmedInner.startsWith("{")) {
|
|
249675
|
+
const nameTok = trimmedInner.split(/[\n<]/, 1)[0]?.trim();
|
|
249676
|
+
if (nameTok)
|
|
249677
|
+
name = nameTok;
|
|
249678
|
+
for (const p of argPairs) {
|
|
249679
|
+
const key = (p[1] ?? "").trim();
|
|
249680
|
+
if (key)
|
|
249681
|
+
args[key] = coerceXmlToolValue(p[2] ?? "");
|
|
249682
|
+
}
|
|
249683
|
+
} else if (isJsonEnvelope) {
|
|
249684
|
+
const obj = JSON.parse(envelopeJson);
|
|
249685
|
+
if (typeof obj["name"] === "string") {
|
|
249686
|
+
name = obj["name"];
|
|
249687
|
+
const rawArgs = obj["arguments"];
|
|
249688
|
+
if (typeof rawArgs === "string") {
|
|
249689
|
+
try {
|
|
249690
|
+
Object.assign(args, JSON.parse(rawArgs));
|
|
249691
|
+
} catch {}
|
|
249692
|
+
} else if (rawArgs && typeof rawArgs === "object") {
|
|
249693
|
+
Object.assign(args, rawArgs);
|
|
249694
|
+
}
|
|
249695
|
+
}
|
|
249696
|
+
}
|
|
249697
|
+
}
|
|
249698
|
+
return { name, args };
|
|
249699
|
+
}
|
|
249700
|
+
function parseXmlToolCalls(text, allowHy3, nextSequence) {
|
|
249701
|
+
const results = [];
|
|
249702
|
+
const seen = new Set;
|
|
249703
|
+
const ranges = [];
|
|
249704
|
+
const addCall = (name, args) => {
|
|
249705
|
+
const dedupKey = `${name}:${JSON.stringify(args)}`;
|
|
249706
|
+
if (seen.has(dedupKey))
|
|
249707
|
+
return;
|
|
249708
|
+
seen.add(dedupKey);
|
|
249709
|
+
results.push({ id: `xml_tc_${nextSequence()}`, name, arguments: args });
|
|
249710
|
+
};
|
|
249711
|
+
const hy3Blocks = allowHy3 ? [...text.matchAll(HY3_TOOL_CALL_BLOCK_RE)].map((block2) => ({
|
|
249712
|
+
range: [block2.index, block2.index + block2[0].length],
|
|
249713
|
+
parsed: parseHy3ToolCallInner(block2[1] ?? "")
|
|
249714
|
+
})) : [];
|
|
249715
|
+
const hy3WrapperRanges = allowHy3 ? [...text.matchAll(HY3_TOOL_CALLS_BLOCK_RE)].filter((wrapper) => {
|
|
249716
|
+
const range = [
|
|
249717
|
+
wrapper.index,
|
|
249718
|
+
wrapper.index + wrapper[0].length
|
|
249719
|
+
];
|
|
249720
|
+
return hy3Blocks.some((block2) => block2.parsed.name && range[0] <= block2.range[0] && block2.range[1] <= range[1]);
|
|
249721
|
+
}).map((wrapper) => [
|
|
249722
|
+
wrapper.index,
|
|
249723
|
+
wrapper.index + wrapper[0].length
|
|
249724
|
+
]) : [];
|
|
249725
|
+
const candidates = [];
|
|
249726
|
+
for (const block2 of hy3Blocks) {
|
|
249727
|
+
const { name, args } = block2.parsed;
|
|
249728
|
+
if (!name)
|
|
249729
|
+
continue;
|
|
249730
|
+
const range = block2.range;
|
|
249731
|
+
candidates.push({
|
|
249732
|
+
range,
|
|
249733
|
+
name,
|
|
249734
|
+
args,
|
|
249735
|
+
coveredByWrapper: hy3WrapperRanges.some((wrapper) => wrapper[0] <= range[0] && range[1] <= wrapper[1])
|
|
249736
|
+
});
|
|
249737
|
+
}
|
|
249738
|
+
for (const { range, inner, json: json2 } of findStandardXmlToolCallBlocks(text)) {
|
|
249739
|
+
const { name, args } = parseStandardXmlToolCallInner(inner, json2);
|
|
249740
|
+
if (!name)
|
|
249741
|
+
continue;
|
|
249742
|
+
candidates.push({
|
|
249743
|
+
range,
|
|
249744
|
+
name,
|
|
249745
|
+
args,
|
|
249746
|
+
coveredByWrapper: false
|
|
249747
|
+
});
|
|
249748
|
+
}
|
|
249749
|
+
candidates.sort((left, right) => left.range[0] - right.range[0]);
|
|
249750
|
+
for (const candidate of candidates) {
|
|
249751
|
+
addCall(candidate.name, candidate.args);
|
|
249752
|
+
if (!candidate.coveredByWrapper) {
|
|
249753
|
+
ranges.push(candidate.range);
|
|
249754
|
+
}
|
|
249755
|
+
}
|
|
249756
|
+
ranges.push(...hy3WrapperRanges);
|
|
249757
|
+
ranges.sort((left, right) => left[0] - right[0]);
|
|
249758
|
+
return { calls: results, toolCallRanges: ranges };
|
|
249759
|
+
}
|
|
249760
|
+
var HY3_PARAMETER_RE, HY3_NAMED_ARGUMENT_LINE_RE, HY3_ARG_PAIR_RE, XML_TOOL_CALL_OPEN = "<tool_call>", HY3_TOOL_CALLS_OPEN = "<tool_calls:", HY3_TOOL_CALL_OPEN = "<tool_call:", XML_TOOL_CALL_OPENERS, XML_TOOL_CALL_CLOSE = "</tool_call>", XML_ARG_KEY_OPEN = "<arg_key>", HY3_TOOL_CALLS_BLOCK_RE, HY3_TOOL_CALL_BLOCK_RE, XML_FUNCTION_NAME_RE, XML_PARAMETER_RE, XML_ARG_PAIR_RE;
|
|
249761
|
+
var init_xmlToolCallParsing = __esm(() => {
|
|
249762
|
+
init_rawToolCallParsing();
|
|
249763
|
+
HY3_PARAMETER_RE = /<parameter\s+name=["']([^"'>\s]+)["']\s*>([\s\S]*?)<\/parameter>/g;
|
|
249764
|
+
HY3_NAMED_ARGUMENT_LINE_RE = /^\s*([A-Za-z_][\w-]*)\s*:\s*(.+?)\s*$/gm;
|
|
249765
|
+
HY3_ARG_PAIR_RE = /<arg_key(?::[^>\s]+)?>([\s\S]*?)<\/arg_key(?::[^>\s]+)?>\s*<arg_value(?::[^>\s]+)?>([\s\S]*?)<\/arg_value(?::[^>\s]+)?>/g;
|
|
249766
|
+
XML_TOOL_CALL_OPENERS = [
|
|
249767
|
+
XML_TOOL_CALL_OPEN,
|
|
249768
|
+
HY3_TOOL_CALLS_OPEN,
|
|
249769
|
+
HY3_TOOL_CALL_OPEN
|
|
249770
|
+
];
|
|
249771
|
+
HY3_TOOL_CALLS_BLOCK_RE = /<tool_calls:[^>\s]+>([\s\S]*?)(?:<\/tool_calls(?::[^>\s]+)?>|$)/g;
|
|
249772
|
+
HY3_TOOL_CALL_BLOCK_RE = /<tool_call:[^>\s]+>([\s\S]*?)(?:<\/tool_call(?::[^>\s]+)?>|$)/g;
|
|
249773
|
+
XML_FUNCTION_NAME_RE = /<function=([^>\s]+)\s*>/;
|
|
249774
|
+
XML_PARAMETER_RE = /<parameter=([^>\s]+)\s*>([\s\S]*?)<\/parameter>/g;
|
|
249775
|
+
XML_ARG_PAIR_RE = /<arg_key>([\s\S]*?)<\/arg_key>\s*<arg_value>([\s\S]*?)<\/arg_value>/g;
|
|
249776
|
+
});
|
|
249777
|
+
|
|
249364
249778
|
// src/services/api/openaiShim/streamConversion.ts
|
|
249365
249779
|
import { APIError as APIError7 } from "@anthropic-ai/sdk";
|
|
249780
|
+
function reasoningMarkupTouchesBlock(text, start, block2) {
|
|
249781
|
+
const markup = xmlToolCallBlockMarkup(block2);
|
|
249782
|
+
if (stripThinkTags(markup) !== markup)
|
|
249783
|
+
return true;
|
|
249784
|
+
const lastTagEnd = start > 0 ? text.lastIndexOf(">", start - 1) : -1;
|
|
249785
|
+
const openerTail = text.slice(lastTagEnd + 1, text.indexOf(">", start) + 1);
|
|
249786
|
+
return stripThinkTags(openerTail) !== openerTail;
|
|
249787
|
+
}
|
|
249788
|
+
function visibleTextKeepingToolCallBlocks(text, blockRanges) {
|
|
249789
|
+
const filter2 = createThinkTagFilter();
|
|
249790
|
+
let visible = "";
|
|
249791
|
+
let position = 0;
|
|
249792
|
+
for (const [start, end] of blockRanges) {
|
|
249793
|
+
if (start < position) {
|
|
249794
|
+
if (end > position)
|
|
249795
|
+
return null;
|
|
249796
|
+
continue;
|
|
249797
|
+
}
|
|
249798
|
+
const block2 = text.slice(start, end);
|
|
249799
|
+
if (reasoningMarkupTouchesBlock(text, start, block2))
|
|
249800
|
+
return null;
|
|
249801
|
+
const before = filter2.feed(text.slice(position, start) + TOOL_CALL_BLOCK_BOUNDARY);
|
|
249802
|
+
if (filter2.isInsideBlock()) {
|
|
249803
|
+
visible += before;
|
|
249804
|
+
} else {
|
|
249805
|
+
visible += before.slice(0, -1) + block2;
|
|
249806
|
+
}
|
|
249807
|
+
position = end;
|
|
249808
|
+
}
|
|
249809
|
+
return visible + filter2.feed(text.slice(position));
|
|
249810
|
+
}
|
|
249366
249811
|
function convertOpenAIStreamUsage(usage) {
|
|
249367
249812
|
if (!usage)
|
|
249368
249813
|
return;
|
|
@@ -249375,24 +249820,24 @@ async function* openaiStreamToAnthropic(response, model, signal, isOllama, reque
|
|
|
249375
249820
|
createReaderCanceller: createReaderCanceller2,
|
|
249376
249821
|
createProviderStreamTrace: createProviderStreamTrace2,
|
|
249377
249822
|
createStreamAbortError: createStreamAbortError2,
|
|
249378
|
-
findXmlToolCallOpener,
|
|
249823
|
+
findXmlToolCallOpener: findXmlToolCallOpener2,
|
|
249379
249824
|
geminiThoughtSignatureFromExtraContent: geminiThoughtSignatureFromExtraContent2,
|
|
249380
249825
|
getStreamIdleTimeoutMs: getStreamIdleTimeoutMs2,
|
|
249381
249826
|
headersWithRequestUrl,
|
|
249382
|
-
isHy3Model,
|
|
249827
|
+
isHy3Model: isHy3Model2,
|
|
249383
249828
|
makeMessageId: makeMessageId2,
|
|
249384
249829
|
mergeGeminiThoughtSignature: mergeGeminiThoughtSignature2,
|
|
249385
249830
|
parseRawToolCallsRequestedText: parseRawToolCallsRequestedText2,
|
|
249386
249831
|
parseTextToolCalls: parseTextToolCalls2,
|
|
249387
|
-
parseXmlToolCalls,
|
|
249832
|
+
parseXmlToolCalls: parseXmlToolCalls2,
|
|
249388
249833
|
readWithIdleTimeout: readWithIdleTimeout2,
|
|
249389
249834
|
repairPossiblyTruncatedObjectJson: repairPossiblyTruncatedObjectJson2,
|
|
249390
249835
|
stripRanges: stripRanges2,
|
|
249391
249836
|
throwIfStreamAborted: throwIfStreamAborted2,
|
|
249392
|
-
trailingXmlOpenerPrefixLen
|
|
249837
|
+
trailingXmlOpenerPrefixLen: trailingXmlOpenerPrefixLen2
|
|
249393
249838
|
} = dependencies2;
|
|
249394
249839
|
const messageId = makeMessageId2();
|
|
249395
|
-
const allowHy3ToolCalls =
|
|
249840
|
+
const allowHy3ToolCalls = isHy3Model2(model);
|
|
249396
249841
|
let contentBlockIndex = 0;
|
|
249397
249842
|
const activeToolCalls = new Map;
|
|
249398
249843
|
let hasEmittedContentStart = false;
|
|
@@ -249765,7 +250210,7 @@ async function* openaiStreamToAnthropic(response, model, signal, isOllama, reque
|
|
|
249765
250210
|
}
|
|
249766
250211
|
} else {
|
|
249767
250212
|
const combined = xmlHoldback + delta.content;
|
|
249768
|
-
const openIdx =
|
|
250213
|
+
const openIdx = findXmlToolCallOpener2(combined, allowHy3ToolCalls);
|
|
249769
250214
|
if (openIdx !== -1) {
|
|
249770
250215
|
const before = combined.slice(0, openIdx);
|
|
249771
250216
|
if (before)
|
|
@@ -249773,7 +250218,7 @@ async function* openaiStreamToAnthropic(response, model, signal, isOllama, reque
|
|
|
249773
250218
|
xmlHoldback = "";
|
|
249774
250219
|
xmlToolCallText = combined.slice(openIdx);
|
|
249775
250220
|
} else {
|
|
249776
|
-
const keep =
|
|
250221
|
+
const keep = trailingXmlOpenerPrefixLen2(combined, allowHy3ToolCalls);
|
|
249777
250222
|
const emit2 = keep > 0 ? combined.slice(0, combined.length - keep) : combined;
|
|
249778
250223
|
xmlHoldback = keep > 0 ? combined.slice(combined.length - keep) : "";
|
|
249779
250224
|
if (emit2)
|
|
@@ -249901,10 +250346,25 @@ async function* openaiStreamToAnthropic(response, model, signal, isOllama, reque
|
|
|
249901
250346
|
const originalFinishReason = choice.finish_reason;
|
|
249902
250347
|
let ollamaClosedContentBlock = false;
|
|
249903
250348
|
if (isTerminalOllamaFinish) {
|
|
249904
|
-
|
|
250349
|
+
let toolCallSource = accumulatedText;
|
|
250350
|
+
let { calls: textToolCalls, toolCallRanges } = parseTextToolCalls2(accumulatedText);
|
|
250351
|
+
if (textToolCalls.length === 0) {
|
|
250352
|
+
({ calls: textToolCalls, toolCallRanges } = parseXmlToolCalls2(accumulatedText, allowHy3ToolCalls));
|
|
250353
|
+
const visibleSource = textToolCalls.length > 0 ? visibleTextKeepingToolCallBlocks(accumulatedText, findXmlToolCallBlockRanges(accumulatedText, allowHy3ToolCalls)) : accumulatedText;
|
|
250354
|
+
const callKey = (tc) => `${tc.name}\x00${JSON.stringify(tc.arguments)}`;
|
|
250355
|
+
const rawCallKeys = new Set(textToolCalls.map(callKey));
|
|
250356
|
+
if (visibleSource !== null && visibleSource !== accumulatedText) {
|
|
250357
|
+
toolCallSource = visibleSource;
|
|
250358
|
+
({ calls: textToolCalls, toolCallRanges } = parseXmlToolCalls2(toolCallSource, allowHy3ToolCalls));
|
|
250359
|
+
}
|
|
250360
|
+
if (visibleSource === null || textToolCalls.some((tc) => !rawCallKeys.has(callKey(tc)))) {
|
|
250361
|
+
textToolCalls = [];
|
|
250362
|
+
toolCallRanges = [];
|
|
250363
|
+
}
|
|
250364
|
+
}
|
|
249905
250365
|
if (textToolCalls.length > 0) {
|
|
249906
250366
|
ollamaClosedContentBlock = true;
|
|
249907
|
-
const stripped = stripRanges2(
|
|
250367
|
+
const stripped = stripRanges2(toolCallSource, toolCallRanges).trim();
|
|
249908
250368
|
const strippedVisible = stripThinkTags(stripped).trim();
|
|
249909
250369
|
if (hasEmittedContentStart) {
|
|
249910
250370
|
if (strippedVisible) {
|
|
@@ -249975,7 +250435,7 @@ async function* openaiStreamToAnthropic(response, model, signal, isOllama, reque
|
|
|
249975
250435
|
if (!isOllamaStream && xmlToolCallText !== null) {
|
|
249976
250436
|
const buffered = xmlToolCallText;
|
|
249977
250437
|
xmlToolCallText = null;
|
|
249978
|
-
const { calls, toolCallRanges } =
|
|
250438
|
+
const { calls, toolCallRanges } = parseXmlToolCalls2(buffered, allowHy3ToolCalls);
|
|
249979
250439
|
if (calls.length > 0) {
|
|
249980
250440
|
const stripped = stripRanges2(buffered, toolCallRanges).trim();
|
|
249981
250441
|
const strippedVisible = stripThinkTags(stripped).trim();
|
|
@@ -250173,13 +250633,14 @@ async function* openaiStreamToAnthropic(response, model, signal, isOllama, reque
|
|
|
250173
250633
|
throwIfStreamAborted2(signal);
|
|
250174
250634
|
yield { type: "message_stop" };
|
|
250175
250635
|
}
|
|
250176
|
-
var JSON_REPAIR_SUFFIXES2;
|
|
250636
|
+
var JSON_REPAIR_SUFFIXES2, TOOL_CALL_BLOCK_BOUNDARY = "\x00";
|
|
250177
250637
|
var init_streamConversion = __esm(() => {
|
|
250178
250638
|
init_cacheMetrics();
|
|
250179
250639
|
init_openaiErrorClassification();
|
|
250180
250640
|
init_thinkTagSanitizer();
|
|
250181
250641
|
init_toolArgumentNormalization();
|
|
250182
250642
|
init_debug();
|
|
250643
|
+
init_xmlToolCallParsing();
|
|
250183
250644
|
JSON_REPAIR_SUFFIXES2 = [
|
|
250184
250645
|
"}",
|
|
250185
250646
|
'"}',
|
|
@@ -250434,203 +250895,6 @@ var init_geminiStreamConversion = __esm(() => {
|
|
|
250434
250895
|
init_debug();
|
|
250435
250896
|
});
|
|
250436
250897
|
|
|
250437
|
-
// src/services/api/openaiShim/xmlToolCallParsing.ts
|
|
250438
|
-
function coerceXmlToolValue(raw) {
|
|
250439
|
-
const trimmed = raw.trim();
|
|
250440
|
-
if (trimmed === "")
|
|
250441
|
-
return "";
|
|
250442
|
-
try {
|
|
250443
|
-
return JSON.parse(trimmed);
|
|
250444
|
-
} catch {
|
|
250445
|
-
return raw;
|
|
250446
|
-
}
|
|
250447
|
-
}
|
|
250448
|
-
function parseHy3ToolCallInner(inner) {
|
|
250449
|
-
const args = {};
|
|
250450
|
-
const trimmed = inner.trim();
|
|
250451
|
-
const name = trimmed.split(/[\n<]/, 1)[0]?.trim().replace(/[\s`*_]+$/, "");
|
|
250452
|
-
let hasStructuredArguments = false;
|
|
250453
|
-
for (const parameter of inner.matchAll(HY3_PARAMETER_RE)) {
|
|
250454
|
-
const key = parameter[1];
|
|
250455
|
-
if (key) {
|
|
250456
|
-
hasStructuredArguments = true;
|
|
250457
|
-
args[key] = coerceXmlToolValue(parameter[2] ?? "");
|
|
250458
|
-
}
|
|
250459
|
-
}
|
|
250460
|
-
for (const line of inner.matchAll(HY3_NAMED_ARGUMENT_LINE_RE)) {
|
|
250461
|
-
const key = line[1];
|
|
250462
|
-
if (key) {
|
|
250463
|
-
hasStructuredArguments = true;
|
|
250464
|
-
args[key] = coerceXmlToolValue(line[2] ?? "");
|
|
250465
|
-
}
|
|
250466
|
-
}
|
|
250467
|
-
for (const pair of inner.matchAll(HY3_ARG_PAIR_RE)) {
|
|
250468
|
-
const key = pair[1]?.trim();
|
|
250469
|
-
if (key) {
|
|
250470
|
-
hasStructuredArguments = true;
|
|
250471
|
-
args[key] = coerceXmlToolValue(pair[2] ?? "");
|
|
250472
|
-
}
|
|
250473
|
-
}
|
|
250474
|
-
return {
|
|
250475
|
-
name: name && /^[A-Za-z_][\w.-]*$/.test(name) && (hasStructuredArguments || trimmed === name) ? name : undefined,
|
|
250476
|
-
args
|
|
250477
|
-
};
|
|
250478
|
-
}
|
|
250479
|
-
function isHy3Model(model) {
|
|
250480
|
-
return model.split("?", 1)[0]?.toLowerCase() === "tencent/hy3";
|
|
250481
|
-
}
|
|
250482
|
-
function trailingXmlOpenerPrefixLen(s, allowHy3) {
|
|
250483
|
-
let longest = 0;
|
|
250484
|
-
const openers = allowHy3 ? XML_TOOL_CALL_OPENERS : [XML_TOOL_CALL_OPEN];
|
|
250485
|
-
for (const opener2 of openers) {
|
|
250486
|
-
const max2 = Math.min(s.length, opener2.length - 1);
|
|
250487
|
-
for (let len = max2;len > 0; len--) {
|
|
250488
|
-
if (opener2.startsWith(s.slice(s.length - len))) {
|
|
250489
|
-
longest = Math.max(longest, len);
|
|
250490
|
-
break;
|
|
250491
|
-
}
|
|
250492
|
-
}
|
|
250493
|
-
}
|
|
250494
|
-
return longest;
|
|
250495
|
-
}
|
|
250496
|
-
function findXmlToolCallOpener(text, allowHy3) {
|
|
250497
|
-
const openers = allowHy3 ? XML_TOOL_CALL_OPENERS : [XML_TOOL_CALL_OPEN];
|
|
250498
|
-
return openers.reduce((first, opener2) => {
|
|
250499
|
-
const index = text.indexOf(opener2);
|
|
250500
|
-
return index === -1 ? first : first === -1 ? index : Math.min(first, index);
|
|
250501
|
-
}, -1);
|
|
250502
|
-
}
|
|
250503
|
-
function parseStandardXmlToolCallInner(inner) {
|
|
250504
|
-
let name;
|
|
250505
|
-
const args = {};
|
|
250506
|
-
const fnMatch = inner.match(XML_FUNCTION_NAME_RE);
|
|
250507
|
-
if (fnMatch) {
|
|
250508
|
-
name = fnMatch[1];
|
|
250509
|
-
for (const p of inner.matchAll(XML_PARAMETER_RE)) {
|
|
250510
|
-
const key = p[1];
|
|
250511
|
-
if (key)
|
|
250512
|
-
args[key] = coerceXmlToolValue(p[2] ?? "");
|
|
250513
|
-
}
|
|
250514
|
-
} else {
|
|
250515
|
-
const trimmedInner = inner.trim();
|
|
250516
|
-
const argPairs = [...inner.matchAll(XML_ARG_PAIR_RE)];
|
|
250517
|
-
if (argPairs.length > 0 && !trimmedInner.startsWith("{")) {
|
|
250518
|
-
const nameTok = trimmedInner.split(/[\n<]/, 1)[0]?.trim();
|
|
250519
|
-
if (nameTok)
|
|
250520
|
-
name = nameTok;
|
|
250521
|
-
for (const p of argPairs) {
|
|
250522
|
-
const key = (p[1] ?? "").trim();
|
|
250523
|
-
if (key)
|
|
250524
|
-
args[key] = coerceXmlToolValue(p[2] ?? "");
|
|
250525
|
-
}
|
|
250526
|
-
} else {
|
|
250527
|
-
const jsonStart = trimmedInner.indexOf("{");
|
|
250528
|
-
if (jsonStart !== -1) {
|
|
250529
|
-
const jsonRaw = extractBalancedJson(trimmedInner, jsonStart);
|
|
250530
|
-
if (jsonRaw) {
|
|
250531
|
-
try {
|
|
250532
|
-
const obj = JSON.parse(jsonRaw);
|
|
250533
|
-
if (typeof obj["name"] === "string") {
|
|
250534
|
-
name = obj["name"];
|
|
250535
|
-
const rawArgs = obj["arguments"];
|
|
250536
|
-
if (typeof rawArgs === "string") {
|
|
250537
|
-
try {
|
|
250538
|
-
Object.assign(args, JSON.parse(rawArgs));
|
|
250539
|
-
} catch {}
|
|
250540
|
-
} else if (rawArgs && typeof rawArgs === "object") {
|
|
250541
|
-
Object.assign(args, rawArgs);
|
|
250542
|
-
}
|
|
250543
|
-
}
|
|
250544
|
-
} catch {}
|
|
250545
|
-
}
|
|
250546
|
-
}
|
|
250547
|
-
}
|
|
250548
|
-
}
|
|
250549
|
-
return { name, args };
|
|
250550
|
-
}
|
|
250551
|
-
function parseXmlToolCalls(text, allowHy3, nextSequence) {
|
|
250552
|
-
const results = [];
|
|
250553
|
-
const seen = new Set;
|
|
250554
|
-
const ranges = [];
|
|
250555
|
-
const addCall = (name, args) => {
|
|
250556
|
-
const dedupKey = `${name}:${JSON.stringify(args)}`;
|
|
250557
|
-
if (seen.has(dedupKey))
|
|
250558
|
-
return;
|
|
250559
|
-
seen.add(dedupKey);
|
|
250560
|
-
results.push({ id: `xml_tc_${nextSequence()}`, name, arguments: args });
|
|
250561
|
-
};
|
|
250562
|
-
const hy3Blocks = allowHy3 ? [...text.matchAll(HY3_TOOL_CALL_BLOCK_RE)].map((block2) => ({
|
|
250563
|
-
range: [block2.index, block2.index + block2[0].length],
|
|
250564
|
-
parsed: parseHy3ToolCallInner(block2[1] ?? "")
|
|
250565
|
-
})) : [];
|
|
250566
|
-
const hy3WrapperRanges = allowHy3 ? [...text.matchAll(HY3_TOOL_CALLS_BLOCK_RE)].filter((wrapper) => {
|
|
250567
|
-
const range = [
|
|
250568
|
-
wrapper.index,
|
|
250569
|
-
wrapper.index + wrapper[0].length
|
|
250570
|
-
];
|
|
250571
|
-
return hy3Blocks.some((block2) => block2.parsed.name && range[0] <= block2.range[0] && block2.range[1] <= range[1]);
|
|
250572
|
-
}).map((wrapper) => [
|
|
250573
|
-
wrapper.index,
|
|
250574
|
-
wrapper.index + wrapper[0].length
|
|
250575
|
-
]) : [];
|
|
250576
|
-
const candidates = [];
|
|
250577
|
-
for (const block2 of hy3Blocks) {
|
|
250578
|
-
const { name, args } = block2.parsed;
|
|
250579
|
-
if (!name)
|
|
250580
|
-
continue;
|
|
250581
|
-
const range = block2.range;
|
|
250582
|
-
candidates.push({
|
|
250583
|
-
range,
|
|
250584
|
-
name,
|
|
250585
|
-
args,
|
|
250586
|
-
coveredByWrapper: hy3WrapperRanges.some((wrapper) => wrapper[0] <= range[0] && range[1] <= wrapper[1])
|
|
250587
|
-
});
|
|
250588
|
-
}
|
|
250589
|
-
for (const block2 of text.matchAll(XML_TOOL_CALL_BLOCK_RE)) {
|
|
250590
|
-
const range = [
|
|
250591
|
-
block2.index,
|
|
250592
|
-
block2.index + block2[0].length
|
|
250593
|
-
];
|
|
250594
|
-
const { name, args } = parseStandardXmlToolCallInner(block2[1] ?? "");
|
|
250595
|
-
if (!name)
|
|
250596
|
-
continue;
|
|
250597
|
-
candidates.push({
|
|
250598
|
-
range,
|
|
250599
|
-
name,
|
|
250600
|
-
args,
|
|
250601
|
-
coveredByWrapper: false
|
|
250602
|
-
});
|
|
250603
|
-
}
|
|
250604
|
-
candidates.sort((left, right) => left.range[0] - right.range[0]);
|
|
250605
|
-
for (const candidate of candidates) {
|
|
250606
|
-
addCall(candidate.name, candidate.args);
|
|
250607
|
-
if (!candidate.coveredByWrapper) {
|
|
250608
|
-
ranges.push(candidate.range);
|
|
250609
|
-
}
|
|
250610
|
-
}
|
|
250611
|
-
ranges.push(...hy3WrapperRanges);
|
|
250612
|
-
ranges.sort((left, right) => left[0] - right[0]);
|
|
250613
|
-
return { calls: results, toolCallRanges: ranges };
|
|
250614
|
-
}
|
|
250615
|
-
var HY3_PARAMETER_RE, HY3_NAMED_ARGUMENT_LINE_RE, HY3_ARG_PAIR_RE, XML_TOOL_CALL_OPEN = "<tool_call>", HY3_TOOL_CALLS_OPEN = "<tool_calls:", HY3_TOOL_CALL_OPEN = "<tool_call:", XML_TOOL_CALL_OPENERS, XML_TOOL_CALL_BLOCK_RE, HY3_TOOL_CALLS_BLOCK_RE, HY3_TOOL_CALL_BLOCK_RE, XML_FUNCTION_NAME_RE, XML_PARAMETER_RE, XML_ARG_PAIR_RE;
|
|
250616
|
-
var init_xmlToolCallParsing = __esm(() => {
|
|
250617
|
-
init_rawToolCallParsing();
|
|
250618
|
-
HY3_PARAMETER_RE = /<parameter\s+name=["']([^"'>\s]+)["']\s*>([\s\S]*?)<\/parameter>/g;
|
|
250619
|
-
HY3_NAMED_ARGUMENT_LINE_RE = /^\s*([A-Za-z_][\w-]*)\s*:\s*(.+?)\s*$/gm;
|
|
250620
|
-
HY3_ARG_PAIR_RE = /<arg_key(?::[^>\s]+)?>([\s\S]*?)<\/arg_key(?::[^>\s]+)?>\s*<arg_value(?::[^>\s]+)?>([\s\S]*?)<\/arg_value(?::[^>\s]+)?>/g;
|
|
250621
|
-
XML_TOOL_CALL_OPENERS = [
|
|
250622
|
-
XML_TOOL_CALL_OPEN,
|
|
250623
|
-
HY3_TOOL_CALLS_OPEN,
|
|
250624
|
-
HY3_TOOL_CALL_OPEN
|
|
250625
|
-
];
|
|
250626
|
-
XML_TOOL_CALL_BLOCK_RE = /<tool_call>([\s\S]*?)(?:<\/tool_call>|$)/g;
|
|
250627
|
-
HY3_TOOL_CALLS_BLOCK_RE = /<tool_calls:[^>\s]+>([\s\S]*?)(?:<\/tool_calls(?::[^>\s]+)?>|$)/g;
|
|
250628
|
-
HY3_TOOL_CALL_BLOCK_RE = /<tool_call:[^>\s]+>([\s\S]*?)(?:<\/tool_call(?::[^>\s]+)?>|$)/g;
|
|
250629
|
-
XML_FUNCTION_NAME_RE = /<function=([^>\s]+)\s*>/;
|
|
250630
|
-
XML_PARAMETER_RE = /<parameter=([^>\s]+)\s*>([\s\S]*?)<\/parameter>/g;
|
|
250631
|
-
XML_ARG_PAIR_RE = /<arg_key>([\s\S]*?)<\/arg_key>\s*<arg_value>([\s\S]*?)<\/arg_value>/g;
|
|
250632
|
-
});
|
|
250633
|
-
|
|
250634
250898
|
// src/services/api/openaiShim/responseAdapters.ts
|
|
250635
250899
|
function makeMessageId2() {
|
|
250636
250900
|
return `msg_${crypto.randomUUID().replace(/-/g, "")}`;
|
|
@@ -264112,9 +264376,24 @@ function getEntrypoint() {
|
|
|
264112
264376
|
function isCustomTitleEnabled() {
|
|
264113
264377
|
return true;
|
|
264114
264378
|
}
|
|
264379
|
+
function followSessionSwitches() {
|
|
264380
|
+
if (unsubscribeSessionSwitch)
|
|
264381
|
+
return;
|
|
264382
|
+
pointerSessionId = getSessionId();
|
|
264383
|
+
pointerProjectDir = getSessionProjectDir();
|
|
264384
|
+
unsubscribeSessionSwitch = onSessionSwitch((sessionId) => {
|
|
264385
|
+
const projectDir = getSessionProjectDir();
|
|
264386
|
+
if (sessionId === pointerSessionId && projectDir === pointerProjectDir)
|
|
264387
|
+
return;
|
|
264388
|
+
pointerSessionId = sessionId;
|
|
264389
|
+
pointerProjectDir = projectDir;
|
|
264390
|
+
project?.resetSessionFile();
|
|
264391
|
+
});
|
|
264392
|
+
}
|
|
264115
264393
|
function getProject() {
|
|
264116
264394
|
if (!project) {
|
|
264117
264395
|
project = new Project;
|
|
264396
|
+
followSessionSwitches();
|
|
264118
264397
|
if (!cleanupRegistered2) {
|
|
264119
264398
|
registerCleanup(async () => {
|
|
264120
264399
|
await project?.flush();
|
|
@@ -264144,6 +264423,10 @@ function resetProjectFlushStateForTesting() {
|
|
|
264144
264423
|
}
|
|
264145
264424
|
function resetProjectForTesting() {
|
|
264146
264425
|
project = null;
|
|
264426
|
+
unsubscribeSessionSwitch?.();
|
|
264427
|
+
unsubscribeSessionSwitch = null;
|
|
264428
|
+
pointerSessionId = null;
|
|
264429
|
+
pointerProjectDir = null;
|
|
264147
264430
|
}
|
|
264148
264431
|
function setSessionFileForTesting(path13) {
|
|
264149
264432
|
getProject().sessionFile = path13;
|
|
@@ -264174,8 +264457,8 @@ class Project {
|
|
|
264174
264457
|
currentSessionGoal;
|
|
264175
264458
|
currentSessionBranch;
|
|
264176
264459
|
sessionFile = null;
|
|
264177
|
-
|
|
264178
|
-
|
|
264460
|
+
hasStartedSession = false;
|
|
264461
|
+
pendingEntries = new Map;
|
|
264179
264462
|
remoteIngressUrl = null;
|
|
264180
264463
|
internalEventWriter = null;
|
|
264181
264464
|
internalEventReader = null;
|
|
@@ -264445,15 +264728,35 @@ class Project {
|
|
|
264445
264728
|
return this.trackWrite(() => this.enqueueRewrite(filePath, (signal) => replaceFileAtomic(filePath, data, { signal })));
|
|
264446
264729
|
}
|
|
264447
264730
|
resetSessionFile() {
|
|
264731
|
+
if (this.sessionFile !== null)
|
|
264732
|
+
this.hasStartedSession = true;
|
|
264733
|
+
const startupMetadata = !this.hasStartedSession ? {
|
|
264734
|
+
title: this.currentSessionTitle,
|
|
264735
|
+
agentSetting: this.currentSessionAgentSetting,
|
|
264736
|
+
worktree: this.currentSessionWorktree
|
|
264737
|
+
} : undefined;
|
|
264448
264738
|
this.sessionFile = null;
|
|
264449
|
-
this.
|
|
264450
|
-
|
|
264451
|
-
|
|
264452
|
-
|
|
264453
|
-
|
|
264454
|
-
|
|
264455
|
-
|
|
264456
|
-
|
|
264739
|
+
this.clearSessionMetadata();
|
|
264740
|
+
if (startupMetadata) {
|
|
264741
|
+
this.currentSessionTitle = startupMetadata.title;
|
|
264742
|
+
this.currentSessionAgentSetting = startupMetadata.agentSetting;
|
|
264743
|
+
this.currentSessionWorktree = startupMetadata.worktree;
|
|
264744
|
+
}
|
|
264745
|
+
}
|
|
264746
|
+
clearSessionMetadata() {
|
|
264747
|
+
this.currentSessionTitle = undefined;
|
|
264748
|
+
this.currentSessionTag = undefined;
|
|
264749
|
+
this.currentSessionAgentName = undefined;
|
|
264750
|
+
this.currentSessionAgentColor = undefined;
|
|
264751
|
+
this.currentSessionLastPrompt = undefined;
|
|
264752
|
+
this.currentSessionAgentSetting = undefined;
|
|
264753
|
+
this.currentSessionMode = undefined;
|
|
264754
|
+
this.currentSessionWorktree = undefined;
|
|
264755
|
+
this.currentSessionPrNumber = undefined;
|
|
264756
|
+
this.currentSessionPrUrl = undefined;
|
|
264757
|
+
this.currentSessionPrRepository = undefined;
|
|
264758
|
+
this.currentSessionGoal = undefined;
|
|
264759
|
+
this.currentSessionBranch = undefined;
|
|
264457
264760
|
}
|
|
264458
264761
|
reAppendSessionMetadata(skipTitleRefresh = false) {
|
|
264459
264762
|
if (!this.sessionFile)
|
|
@@ -264638,15 +264941,14 @@ class Project {
|
|
|
264638
264941
|
return shouldSkipSessionPersistence();
|
|
264639
264942
|
}
|
|
264640
264943
|
async materializeSessionFile() {
|
|
264944
|
+
this.hasStartedSession = true;
|
|
264641
264945
|
if (this.shouldSkipPersistence())
|
|
264642
264946
|
return;
|
|
264643
|
-
this.
|
|
264644
|
-
this.ensureCurrentSessionFile();
|
|
264947
|
+
const sessionFile = resolvePath2(this.ensureCurrentSessionFile());
|
|
264645
264948
|
this.reAppendSessionMetadata();
|
|
264646
|
-
|
|
264647
|
-
|
|
264648
|
-
this.pendingEntries
|
|
264649
|
-
this.pendingEntriesSessionId = null;
|
|
264949
|
+
const buffered = this.pendingEntries.get(sessionFile);
|
|
264950
|
+
if (buffered && buffered.length > 0) {
|
|
264951
|
+
this.pendingEntries.delete(sessionFile);
|
|
264650
264952
|
for (const entry of buffered) {
|
|
264651
264953
|
await this.appendEntry(entry);
|
|
264652
264954
|
}
|
|
@@ -264781,9 +265083,13 @@ class Project {
|
|
|
264781
265083
|
let sessionFile;
|
|
264782
265084
|
if (isCurrentSession) {
|
|
264783
265085
|
if (this.sessionFile === null) {
|
|
264784
|
-
|
|
264785
|
-
|
|
264786
|
-
|
|
265086
|
+
const pendingPath = resolvePath2(getTranscriptPath());
|
|
265087
|
+
let buffered = this.pendingEntries.get(pendingPath);
|
|
265088
|
+
if (!buffered) {
|
|
265089
|
+
buffered = [];
|
|
265090
|
+
this.pendingEntries.set(pendingPath, buffered);
|
|
265091
|
+
}
|
|
265092
|
+
buffered.push(entry);
|
|
264787
265093
|
return;
|
|
264788
265094
|
}
|
|
264789
265095
|
sessionFile = this.sessionFile;
|
|
@@ -264875,6 +265181,7 @@ class Project {
|
|
|
264875
265181
|
async forgetDeletedSession(sessionId, transcriptPath) {
|
|
264876
265182
|
this.deletedSessionFiles.add(resolvePath2(transcriptPath));
|
|
264877
265183
|
this.existingSessionFiles.delete(sessionId);
|
|
265184
|
+
this.pendingEntries.delete(resolvePath2(transcriptPath));
|
|
264878
265185
|
if (this.sessionFile && this.isDeletedSessionFile(this.sessionFile)) {
|
|
264879
265186
|
this.resetSessionFile();
|
|
264880
265187
|
}
|
|
@@ -265990,20 +266297,7 @@ function restoreSessionMetadata(meta) {
|
|
|
265990
266297
|
project2.currentSessionBranch = meta.sessionBranch ?? undefined;
|
|
265991
266298
|
}
|
|
265992
266299
|
function clearSessionMetadata() {
|
|
265993
|
-
|
|
265994
|
-
project2.currentSessionTitle = undefined;
|
|
265995
|
-
project2.currentSessionTag = undefined;
|
|
265996
|
-
project2.currentSessionAgentName = undefined;
|
|
265997
|
-
project2.currentSessionAgentColor = undefined;
|
|
265998
|
-
project2.currentSessionLastPrompt = undefined;
|
|
265999
|
-
project2.currentSessionAgentSetting = undefined;
|
|
266000
|
-
project2.currentSessionMode = undefined;
|
|
266001
|
-
project2.currentSessionWorktree = undefined;
|
|
266002
|
-
project2.currentSessionPrNumber = undefined;
|
|
266003
|
-
project2.currentSessionPrUrl = undefined;
|
|
266004
|
-
project2.currentSessionPrRepository = undefined;
|
|
266005
|
-
project2.currentSessionGoal = undefined;
|
|
266006
|
-
project2.currentSessionBranch = undefined;
|
|
266300
|
+
getProject().clearSessionMetadata();
|
|
266007
266301
|
}
|
|
266008
266302
|
function reAppendSessionMetadata() {
|
|
266009
266303
|
getProject().reAppendSessionMetadata();
|
|
@@ -267533,7 +267827,7 @@ async function enrichLogs(allLogs, startIndex, count4, options2) {
|
|
|
267533
267827
|
}
|
|
267534
267828
|
return { logs: result, nextIndex: i3 };
|
|
267535
267829
|
}
|
|
267536
|
-
var VERSION3, builtInCommandNamesCache, MAX_TOMBSTONE_REWRITE_BYTES, TRANSCRIPT_COPY_CHUNK_BYTES, transcriptRewriteHooksForTesting, SKIP_FIRST_PROMPT_PATTERN2, LOCAL_COMMAND_TAGS, EPHEMERAL_PROGRESS_TYPES, MAX_TRANSCRIPT_READ_BYTES, agentTranscriptSubdirs, getProjectDir2, project = null, cleanupRegistered2 = false, REMOTE_FLUSH_INTERVAL_MS = 10, PERSISTED_OUTPUT_TAG2, TOOL_USE_RESULT_KEY, SEARCH_HEAD_BYTES, SEARCH_TAIL_BYTES, SEARCH_MID_WINDOW_BYTES, SEARCH_MAX_MID_WINDOWS = 12, SEARCH_MAX_TOTAL_READ_BYTES, SEARCH_MAX_CHAR_COUNT = 80000, METADATA_TYPE_MARKERS, METADATA_MARKER_BUFS, METADATA_PREFIX_BOUND = 25, getSessionMessages2, INITIAL_ENRICH_COUNT = 50, SESSION_BRANCH_ENTRY_PREFIX = '{"type":"session-branch"', SESSION_BRANCH_ENTRY_PREFIX_SPACED = '{"type": "session-branch"';
|
|
267830
|
+
var VERSION3, builtInCommandNamesCache, MAX_TOMBSTONE_REWRITE_BYTES, TRANSCRIPT_COPY_CHUNK_BYTES, transcriptRewriteHooksForTesting, SKIP_FIRST_PROMPT_PATTERN2, LOCAL_COMMAND_TAGS, EPHEMERAL_PROGRESS_TYPES, MAX_TRANSCRIPT_READ_BYTES, agentTranscriptSubdirs, getProjectDir2, project = null, cleanupRegistered2 = false, unsubscribeSessionSwitch = null, pointerSessionId = null, pointerProjectDir = null, REMOTE_FLUSH_INTERVAL_MS = 10, PERSISTED_OUTPUT_TAG2, TOOL_USE_RESULT_KEY, SEARCH_HEAD_BYTES, SEARCH_TAIL_BYTES, SEARCH_MID_WINDOW_BYTES, SEARCH_MAX_MID_WINDOWS = 12, SEARCH_MAX_TOTAL_READ_BYTES, SEARCH_MAX_CHAR_COUNT = 80000, METADATA_TYPE_MARKERS, METADATA_MARKER_BUFS, METADATA_PREFIX_BOUND = 25, getSessionMessages2, INITIAL_ENRICH_COUNT = 50, SESSION_BRANCH_ENTRY_PREFIX = '{"type":"session-branch"', SESSION_BRANCH_ENTRY_PREFIX_SPACED = '{"type": "session-branch"';
|
|
267537
267831
|
var init_sessionStorage = __esm(() => {
|
|
267538
267832
|
init_memoize();
|
|
267539
267833
|
init_state();
|
|
@@ -267563,7 +267857,7 @@ var init_sessionStorage = __esm(() => {
|
|
|
267563
267857
|
init_slowOperations();
|
|
267564
267858
|
init_transcriptFileLock();
|
|
267565
267859
|
init_uuid();
|
|
267566
|
-
VERSION3 = typeof MACRO !== "undefined" ? "0.
|
|
267860
|
+
VERSION3 = typeof MACRO !== "undefined" ? "0.34.0" : "unknown";
|
|
267567
267861
|
MAX_TOMBSTONE_REWRITE_BYTES = 50 * 1024 * 1024;
|
|
267568
267862
|
TRANSCRIPT_COPY_CHUNK_BYTES = 64 * 1024;
|
|
267569
267863
|
transcriptRewriteHooksForTesting = {};
|
|
@@ -269040,7 +269334,7 @@ var init_filesystem = __esm(() => {
|
|
|
269040
269334
|
});
|
|
269041
269335
|
getBundledSkillsRoot = memoize_default(function getBundledSkillsRoot2() {
|
|
269042
269336
|
const nonce = randomBytes10(16).toString("hex");
|
|
269043
|
-
return join94(getClaudeTempDir(), "bundled-skills", "0.
|
|
269337
|
+
return join94(getClaudeTempDir(), "bundled-skills", "0.34.0", nonce);
|
|
269044
269338
|
});
|
|
269045
269339
|
getResolvedWorkingDirPaths = memoize_default(getPathsForPermissionCheck);
|
|
269046
269340
|
});
|
|
@@ -283579,7 +283873,7 @@ function buildSystemInitMessage(inputs) {
|
|
|
283579
283873
|
slash_commands: inputs.commands.filter((c7) => c7.userInvocable !== false).map((c7) => c7.name),
|
|
283580
283874
|
apiKeySource: getAnthropicApiKeyWithSource().source,
|
|
283581
283875
|
betas: getSdkBetas(),
|
|
283582
|
-
claude_code_version: "0.
|
|
283876
|
+
claude_code_version: "0.34.0",
|
|
283583
283877
|
output_style: outputStyle,
|
|
283584
283878
|
agents: inputs.agents.map((agent) => agent.agentType),
|
|
283585
283879
|
skills: inputs.skills.filter((s) => s.userInvocable !== false).map((skill) => skill.name),
|
|
@@ -288203,4 +288497,4 @@ export {
|
|
|
288203
288497
|
AbortError
|
|
288204
288498
|
};
|
|
288205
288499
|
|
|
288206
|
-
//# debugId=
|
|
288500
|
+
//# debugId=D63E3380C1B6979964756E2164756E21
|