@vtxmacro/cli 2026.10.33 → 2026.10.35
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/bin/vtx-mcp.js +70 -4
- package/bin/vtx-service-bootstrap.js +58 -2
- package/bin/vtx.js +460 -257
- package/package.json +2 -2
package/bin/vtx.js
CHANGED
|
@@ -113,7 +113,7 @@ var init_routing = __esm({
|
|
|
113
113
|
var agent_cli_release_default;
|
|
114
114
|
var init_agent_cli_release = __esm({
|
|
115
115
|
"agent-cli-release.json"() {
|
|
116
|
-
agent_cli_release_default = { package_name: "@vtxmacro/cli", package_version: "2026.10.
|
|
116
|
+
agent_cli_release_default = { package_name: "@vtxmacro/cli", package_version: "2026.10.35", codex_package_name: "@openai/codex", codex_version: "0.155.0", copilot_sdk_package_name: "@github/copilot-sdk", copilot_sdk_version: "1.0.0-beta.8", copilot_cli_package_name: "@github/copilot", copilot_cli_version: "1.0.80", deepseek_harness_version: "0.1.1-rc.2", deepseek_harness_packages: ["@deepseek-ai/dsh-agent", "@deepseek-ai/dsh-agent-instructions", "@deepseek-ai/dsh-agent-loop", "@deepseek-ai/dsh-agent-spine-demo", "@deepseek-ai/dsh-anonymous-user-id", "@deepseek-ai/dsh-atomic-write", "@deepseek-ai/dsh-attachment", "@deepseek-ai/dsh-brand", "@deepseek-ai/dsh-code-runtime", "@deepseek-ai/dsh-credentials", "@deepseek-ai/dsh-fs", "@deepseek-ai/dsh-goal", "@deepseek-ai/dsh-goal-round-driver", "@deepseek-ai/dsh-home-paths", "@deepseek-ai/dsh-invariants", "@deepseek-ai/dsh-jobs", "@deepseek-ai/dsh-jobs-local", "@deepseek-ai/dsh-launch-environment", "@deepseek-ai/dsh-llm", "@deepseek-ai/dsh-llm-deepseek", "@deepseek-ai/dsh-llm-retry", "@deepseek-ai/dsh-output-retention", "@deepseek-ai/dsh-sandbox", "@deepseek-ai/dsh-sandbox-policy", "@deepseek-ai/dsh-scope", "@deepseek-ai/dsh-session", "@deepseek-ai/dsh-session-checkpoint-policy", "@deepseek-ai/dsh-session-persistence", "@deepseek-ai/dsh-session-persistence-jsonl", "@deepseek-ai/dsh-session-projection", "@deepseek-ai/dsh-session-title", "@deepseek-ai/dsh-settings", "@deepseek-ai/dsh-shell", "@deepseek-ai/dsh-shell-env", "@deepseek-ai/dsh-skill", "@deepseek-ai/dsh-skill-filesystem", "@deepseek-ai/dsh-subprocess", "@deepseek-ai/dsh-system-prompt", "@deepseek-ai/dsh-timeout", "@deepseek-ai/dsh-tool-bash", "@deepseek-ai/dsh-tool-goal", "@deepseek-ai/dsh-tool-jobs", "@deepseek-ai/dsh-tool-skill", "@deepseek-ai/dsh-tools", "@deepseek-ai/dsh-typert-protocol", "@deepseek-ai/dsh-user-approval"], deepseek_cordis_package_name: "@deepseek-ai/cordis", deepseek_cordis_version: "4.0.1", deepseek_support_packages: { "@deepseek-ai/cordis-plugin-timer": "1.1.3" }, platforms: { "linux-x64": { package_name: "@openai/codex-linux-x64", target: "x86_64-unknown-linux-musl", binary_name: "codex", sha256: "660e159a49e823ac8e5986cb238f73158ce4b957d40d9292f8de90862644b501" }, "win32-x64": { package_name: "@openai/codex-win32-x64", target: "x86_64-pc-windows-msvc", binary_name: "codex.exe", sha256: "e4c11374bd9de8ad5c3b7617fd4654bb7839901edb0863f9930666863c7a021b" } }, pi_coding_agent_package_name: "@earendil-works/pi-coding-agent", pi_ai_package_name: "@earendil-works/pi-ai", pi_version: "0.85.1", pi_support_packages: ["@earendil-works/pi-agent-core", "@earendil-works/pi-telemetry", "@earendil-works/pi-tui", "@earendil-works/chord"], grok_version: "1.0.30", grok_platforms: { "linux-x64": { package_name: "@xai-official/grok-linux-x64", binary_name: "grok", sha256: "504dd6546ab991b75d36698242875ce461489cd1f8cd84285873cb55bd5c7d54" }, "win32-x64": { package_name: "@xai-official/grok-win32-x64", binary_name: "grok.exe", sha256: "48736d1a4342a801ea26d0ecde4c516b653f791399065adaa55973f83abd8867" } } };
|
|
117
117
|
}
|
|
118
118
|
});
|
|
119
119
|
|
|
@@ -3891,10 +3891,10 @@ while(($line=[Console]::In.ReadLine()) -ne $null) {
|
|
|
3891
3891
|
env: invocation.env
|
|
3892
3892
|
});
|
|
3893
3893
|
const output3 = [];
|
|
3894
|
-
let
|
|
3894
|
+
let settled2 = false;
|
|
3895
3895
|
const settle = (value) => {
|
|
3896
|
-
if (
|
|
3897
|
-
|
|
3896
|
+
if (settled2) return;
|
|
3897
|
+
settled2 = true;
|
|
3898
3898
|
clearTimeout(timer);
|
|
3899
3899
|
resolvePromise(value);
|
|
3900
3900
|
};
|
|
@@ -3921,10 +3921,10 @@ while(($line=[Console]::In.ReadLine()) -ne $null) {
|
|
|
3921
3921
|
stdio: ["ignore", "pipe", "ignore"]
|
|
3922
3922
|
});
|
|
3923
3923
|
const output3 = [];
|
|
3924
|
-
let
|
|
3924
|
+
let settled2 = false;
|
|
3925
3925
|
const settle = (value) => {
|
|
3926
|
-
if (
|
|
3927
|
-
|
|
3926
|
+
if (settled2) return;
|
|
3927
|
+
settled2 = true;
|
|
3928
3928
|
clearTimeout(timer);
|
|
3929
3929
|
resolvePromise(value);
|
|
3930
3930
|
};
|
|
@@ -3947,10 +3947,10 @@ while(($line=[Console]::In.ReadLine()) -ne $null) {
|
|
|
3947
3947
|
});
|
|
3948
3948
|
const output3 = [];
|
|
3949
3949
|
let bytes3 = 0;
|
|
3950
|
-
let
|
|
3950
|
+
let settled2 = false;
|
|
3951
3951
|
const settle = (value) => {
|
|
3952
|
-
if (
|
|
3953
|
-
|
|
3952
|
+
if (settled2) return;
|
|
3953
|
+
settled2 = true;
|
|
3954
3954
|
clearTimeout(timer);
|
|
3955
3955
|
resolvePromise(value);
|
|
3956
3956
|
};
|
|
@@ -4335,6 +4335,165 @@ while(($line=[Console]::In.ReadLine()) -ne $null) {
|
|
|
4335
4335
|
}
|
|
4336
4336
|
});
|
|
4337
4337
|
|
|
4338
|
+
// lib/runtime/abort.ts
|
|
4339
|
+
var ABORT_MESSAGE_TOKENS, readAbortLikeMessage, isAbortLikeError, toAbortError;
|
|
4340
|
+
var init_abort = __esm({
|
|
4341
|
+
"lib/runtime/abort.ts"() {
|
|
4342
|
+
"use strict";
|
|
4343
|
+
init_define_VTX_EXO_POLICY();
|
|
4344
|
+
init_define_VTX_GROK_POLICY();
|
|
4345
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
4346
|
+
ABORT_MESSAGE_TOKENS = [
|
|
4347
|
+
"the operation was aborted",
|
|
4348
|
+
"the user aborted a request",
|
|
4349
|
+
"request was aborted",
|
|
4350
|
+
"request aborted",
|
|
4351
|
+
"signal is aborted",
|
|
4352
|
+
"client runtime stop requested"
|
|
4353
|
+
];
|
|
4354
|
+
readAbortLikeMessage = (error48) => {
|
|
4355
|
+
if (error48 instanceof Error) {
|
|
4356
|
+
return error48.message;
|
|
4357
|
+
}
|
|
4358
|
+
if (typeof error48 === "string") {
|
|
4359
|
+
return error48;
|
|
4360
|
+
}
|
|
4361
|
+
if (error48 && typeof error48 === "object" && typeof error48.message === "string") {
|
|
4362
|
+
return String(error48.message);
|
|
4363
|
+
}
|
|
4364
|
+
return "";
|
|
4365
|
+
};
|
|
4366
|
+
isAbortLikeError = (error48) => {
|
|
4367
|
+
if (typeof DOMException !== "undefined" && error48 instanceof DOMException) {
|
|
4368
|
+
return error48.name === "AbortError";
|
|
4369
|
+
}
|
|
4370
|
+
if (error48 instanceof Error && error48.name === "AbortError") {
|
|
4371
|
+
return true;
|
|
4372
|
+
}
|
|
4373
|
+
if (error48 && typeof error48 === "object" && error48.name === "AbortError") {
|
|
4374
|
+
return true;
|
|
4375
|
+
}
|
|
4376
|
+
const normalized = readAbortLikeMessage(error48).trim().toLowerCase();
|
|
4377
|
+
if (!normalized) {
|
|
4378
|
+
return false;
|
|
4379
|
+
}
|
|
4380
|
+
return ABORT_MESSAGE_TOKENS.some((token) => normalized.includes(token));
|
|
4381
|
+
};
|
|
4382
|
+
toAbortError = (error48, fallbackMessage = "The operation was aborted.") => {
|
|
4383
|
+
const message = readAbortLikeMessage(error48).trim() || fallbackMessage;
|
|
4384
|
+
try {
|
|
4385
|
+
return new DOMException(message, "AbortError");
|
|
4386
|
+
} catch {
|
|
4387
|
+
const fallback = new Error(message);
|
|
4388
|
+
fallback.name = "AbortError";
|
|
4389
|
+
return fallback;
|
|
4390
|
+
}
|
|
4391
|
+
};
|
|
4392
|
+
}
|
|
4393
|
+
});
|
|
4394
|
+
|
|
4395
|
+
// lib/runtime/runtime-redaction.ts
|
|
4396
|
+
var REDACTED_VALUE, WHITESPACE_CLASS, SEPARATOR, VALUE_RUN, NAME_LETTER_VARIANTS, NAME_START, NAME_PREFIX, secretName, SECRET_NAME_WORDS, NAMED_VALUE, SECRET_QUERY_PARAM_PATTERN, BEARER_TOKEN_PATTERN, ASSIGNMENT_SEPARATOR, AUTHORIZATION_SCHEMES, assignmentPattern, SECRET_ASSIGNMENT_PATTERN, SECRET_WORD_ASSIGNMENT_PATTERN, SECRET_TOKEN_PATTERN, redactAssignedValue, isRuntimeErrorObject, sanitizeRuntimeDiagnosticValue, sanitizeRuntimeNetworkPath, getSanitizedRuntimeErrorMessage, toSanitizedRuntimeError, getSanitizedRuntimeAbortReason;
|
|
4397
|
+
var init_runtime_redaction = __esm({
|
|
4398
|
+
"lib/runtime/runtime-redaction.ts"() {
|
|
4399
|
+
"use strict";
|
|
4400
|
+
init_define_VTX_EXO_POLICY();
|
|
4401
|
+
init_define_VTX_GROK_POLICY();
|
|
4402
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
4403
|
+
init_abort();
|
|
4404
|
+
REDACTED_VALUE = "[REDACTED]";
|
|
4405
|
+
WHITESPACE_CLASS = String.raw`[\t\n\v\f\r \x1c-\x1f\x85\xa0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]`;
|
|
4406
|
+
SEPARATOR = WHITESPACE_CLASS;
|
|
4407
|
+
VALUE_RUN = String.raw`[^,\t\n\v\f\r ]+`;
|
|
4408
|
+
NAME_LETTER_VARIANTS = {
|
|
4409
|
+
s: String.raw`[s\u017f]`,
|
|
4410
|
+
k: String.raw`[k\u212a]`,
|
|
4411
|
+
i: String.raw`[i\u0131\u0130]`
|
|
4412
|
+
};
|
|
4413
|
+
NAME_START = "(?:^|[^A-Za-z0-9_.-])";
|
|
4414
|
+
NAME_PREFIX = "[A-Za-z0-9_.-]*";
|
|
4415
|
+
secretName = (word) => Array.from(word, (letter) => NAME_LETTER_VARIANTS[letter] ?? letter).join("");
|
|
4416
|
+
SECRET_NAME_WORDS = `(?:${[
|
|
4417
|
+
"key",
|
|
4418
|
+
"token",
|
|
4419
|
+
"secret",
|
|
4420
|
+
"password",
|
|
4421
|
+
"passphrase",
|
|
4422
|
+
"credentials",
|
|
4423
|
+
"credential",
|
|
4424
|
+
"authorization"
|
|
4425
|
+
].map(secretName).join("|")})`;
|
|
4426
|
+
NAMED_VALUE = String.raw`("[^"]*"|'[^']*'` + String.raw`|(?:[^,\t\n\v\f\r ]*${SECRET_NAME_WORDS}(?:[:=]${SEPARATOR}+|${SEPARATOR}+[:=]${SEPARATOR}*))*${VALUE_RUN})`;
|
|
4427
|
+
SECRET_QUERY_PARAM_PATTERN = new RegExp(
|
|
4428
|
+
`([?&](?:${NAME_PREFIX}${SECRET_NAME_WORDS}|${secretName("auth")}|${secretName("sig")}|${secretName("signature")})=)${NAMED_VALUE}`,
|
|
4429
|
+
"gi"
|
|
4430
|
+
);
|
|
4431
|
+
BEARER_TOKEN_PATTERN = new RegExp(
|
|
4432
|
+
String.raw`(\bBearer${SEPARATOR}+)(?:[^,;\t\n\v\f\r ]*${SECRET_NAME_WORDS}(?:[:=]${SEPARATOR}+|${SEPARATOR}+[:=]${SEPARATOR}*))*[^,;\t\n\v\f\r ]+`,
|
|
4433
|
+
"gi"
|
|
4434
|
+
);
|
|
4435
|
+
ASSIGNMENT_SEPARATOR = `['"]?${SEPARATOR}*[:=]${SEPARATOR}*`;
|
|
4436
|
+
AUTHORIZATION_SCHEMES = "(?:Bearer|Basic|Digest|Token|Bot|Negotiate|NTLM|ApiKey)";
|
|
4437
|
+
assignmentPattern = (nameStart) => new RegExp(
|
|
4438
|
+
`(${nameStart}(?:${secretName("authorization")}${ASSIGNMENT_SEPARATOR}['"]?${AUTHORIZATION_SCHEMES}${SEPARATOR}+|${SECRET_NAME_WORDS}${ASSIGNMENT_SEPARATOR}))${NAMED_VALUE}`,
|
|
4439
|
+
"gi"
|
|
4440
|
+
);
|
|
4441
|
+
SECRET_ASSIGNMENT_PATTERN = assignmentPattern(`${NAME_START}${NAME_PREFIX}`);
|
|
4442
|
+
SECRET_WORD_ASSIGNMENT_PATTERN = assignmentPattern(
|
|
4443
|
+
`(?:^|[^A-Za-z0-9_])(?:(?:${["api", "access", "private"].map(secretName).join("|")})[_ -]?)?`
|
|
4444
|
+
);
|
|
4445
|
+
SECRET_TOKEN_PATTERN = /\b(?:AIza[A-Za-z0-9_-]+|sk-[A-Za-z0-9._-]+|xai-[A-Za-z0-9]{20,}|gsk_[A-Za-z0-9]{20,}|AQ\.[A-Za-z0-9._-]+|0x[a-fA-F0-9]{64})\b/g;
|
|
4446
|
+
redactAssignedValue = (_match, prefix, value) => {
|
|
4447
|
+
const quote = value[0] === '"' || value[0] === "'" ? value[0] : "";
|
|
4448
|
+
const closing = quote && value.length > 1 && value[value.length - 1] === quote ? quote : "";
|
|
4449
|
+
return `${prefix}${quote}${REDACTED_VALUE}${closing}`;
|
|
4450
|
+
};
|
|
4451
|
+
isRuntimeErrorObject = (error48) => error48 instanceof Error || error48 != null && typeof error48 === "object" && Object.prototype.toString.call(error48) === "[object DOMException]" && typeof error48.message === "string" && typeof error48.name === "string";
|
|
4452
|
+
sanitizeRuntimeDiagnosticValue = (value) => {
|
|
4453
|
+
const normalized = String(value || "");
|
|
4454
|
+
if (!normalized) {
|
|
4455
|
+
return normalized;
|
|
4456
|
+
}
|
|
4457
|
+
return normalized.replace(BEARER_TOKEN_PATTERN, `$1${REDACTED_VALUE}`).replace(SECRET_WORD_ASSIGNMENT_PATTERN, redactAssignedValue).replace(SECRET_TOKEN_PATTERN, REDACTED_VALUE).replace(SECRET_QUERY_PARAM_PATTERN, redactAssignedValue).replace(SECRET_ASSIGNMENT_PATTERN, redactAssignedValue);
|
|
4458
|
+
};
|
|
4459
|
+
sanitizeRuntimeNetworkPath = (value) => {
|
|
4460
|
+
const normalized = String(value || "").trim();
|
|
4461
|
+
if (!normalized) {
|
|
4462
|
+
return "/";
|
|
4463
|
+
}
|
|
4464
|
+
const withoutFragment = normalized.split("#", 1)[0] || normalized;
|
|
4465
|
+
const withoutQuery = withoutFragment.split("?", 1)[0] || withoutFragment;
|
|
4466
|
+
const sanitized = sanitizeRuntimeDiagnosticValue(withoutQuery.trim());
|
|
4467
|
+
return sanitized || "/";
|
|
4468
|
+
};
|
|
4469
|
+
getSanitizedRuntimeErrorMessage = (error48) => {
|
|
4470
|
+
const message = isRuntimeErrorObject(error48) ? error48.message : typeof error48 === "string" ? error48 : error48 == null ? null : String(error48);
|
|
4471
|
+
if (message == null) {
|
|
4472
|
+
return null;
|
|
4473
|
+
}
|
|
4474
|
+
return sanitizeRuntimeDiagnosticValue(message);
|
|
4475
|
+
};
|
|
4476
|
+
toSanitizedRuntimeError = (error48) => {
|
|
4477
|
+
const message = getSanitizedRuntimeErrorMessage(error48) || "Unknown runtime error.";
|
|
4478
|
+
if (isRuntimeErrorObject(error48) && error48.message === message) {
|
|
4479
|
+
if (isAbortLikeError(error48) && error48.name !== "AbortError") {
|
|
4480
|
+
if (error48 instanceof Error) error48.name = "AbortError";
|
|
4481
|
+
else return Object.assign(new Error(message), { name: "AbortError" });
|
|
4482
|
+
}
|
|
4483
|
+
return error48;
|
|
4484
|
+
}
|
|
4485
|
+
const sanitized = new Error(message);
|
|
4486
|
+
if (isAbortLikeError(error48)) {
|
|
4487
|
+
sanitized.name = "AbortError";
|
|
4488
|
+
} else if (isRuntimeErrorObject(error48) && error48.name) {
|
|
4489
|
+
sanitized.name = error48.name;
|
|
4490
|
+
}
|
|
4491
|
+
return sanitized;
|
|
4492
|
+
};
|
|
4493
|
+
getSanitizedRuntimeAbortReason = (signal, fallbackMessage = "The operation was aborted.") => isRuntimeErrorObject(signal?.reason) ? toSanitizedRuntimeError(signal.reason) : new DOMException(fallbackMessage, "AbortError");
|
|
4494
|
+
}
|
|
4495
|
+
});
|
|
4496
|
+
|
|
4338
4497
|
// lib/cli-release/updater.ts
|
|
4339
4498
|
var updater_exports = {};
|
|
4340
4499
|
__export(updater_exports, {
|
|
@@ -4390,6 +4549,7 @@ var init_updater = __esm({
|
|
|
4390
4549
|
init_stop_signals();
|
|
4391
4550
|
init_config2();
|
|
4392
4551
|
init_routing();
|
|
4552
|
+
init_runtime_redaction();
|
|
4393
4553
|
CLI_PACKAGE_NAME = "@vtxmacro/cli";
|
|
4394
4554
|
OFFICIAL_NPM_REGISTRY = "https://registry.npmjs.org";
|
|
4395
4555
|
CLI_UPDATE_COMMAND = `npm install -g ${CLI_PACKAGE_NAME}@latest`;
|
|
@@ -4424,10 +4584,10 @@ var init_updater = __esm({
|
|
|
4424
4584
|
});
|
|
4425
4585
|
const stdout = [];
|
|
4426
4586
|
const stderr = [];
|
|
4427
|
-
let
|
|
4587
|
+
let settled2 = false;
|
|
4428
4588
|
const settle = (result) => {
|
|
4429
|
-
if (
|
|
4430
|
-
|
|
4589
|
+
if (settled2) return;
|
|
4590
|
+
settled2 = true;
|
|
4431
4591
|
resolvePromise(result);
|
|
4432
4592
|
};
|
|
4433
4593
|
child.stdout.on("data", (chunk) => stdout.push(Buffer.from(chunk)));
|
|
@@ -4845,7 +5005,7 @@ var init_updater = __esm({
|
|
|
4845
5005
|
try {
|
|
4846
5006
|
await ensureUpdaterPrivateDirectory(paths.root, paths.root, { platform: input.platform });
|
|
4847
5007
|
} catch (error48) {
|
|
4848
|
-
const reason = `update_directory_unsafe: ${error48 instanceof Error ? error48.message.slice(0, runtime_policy_generated_default.agent_cli.update_failure_reason_max_chars) : "unknown"}`;
|
|
5008
|
+
const reason = `update_directory_unsafe: ${error48 instanceof Error ? sanitizeRuntimeDiagnosticValue(error48.message).slice(0, runtime_policy_generated_default.agent_cli.update_failure_reason_max_chars) : "unknown"}`;
|
|
4849
5009
|
await appendCliUpdateLog(paths, "cli_update_failed", { package_version: target.version, reason });
|
|
4850
5010
|
return { kind: "failed", reason };
|
|
4851
5011
|
}
|
|
@@ -4878,7 +5038,7 @@ var init_updater = __esm({
|
|
|
4878
5038
|
await appendCliUpdateLog(paths, "cli_release_staged", { package_version: selection.package_version });
|
|
4879
5039
|
return { kind: "staged", selection };
|
|
4880
5040
|
} catch (error48) {
|
|
4881
|
-
const reason = error48 instanceof Error ? error48.message.slice(0, runtime_policy_generated_default.agent_cli.update_failure_reason_max_chars) : "unknown";
|
|
5041
|
+
const reason = error48 instanceof Error ? sanitizeRuntimeDiagnosticValue(error48.message).slice(0, runtime_policy_generated_default.agent_cli.update_failure_reason_max_chars) : "unknown";
|
|
4882
5042
|
await appendCliUpdateLog(paths, "cli_update_failed", { package_version: target.version, reason });
|
|
4883
5043
|
return { kind: "failed", reason };
|
|
4884
5044
|
} finally {
|
|
@@ -4966,7 +5126,7 @@ var init_updater = __esm({
|
|
|
4966
5126
|
return runSelected();
|
|
4967
5127
|
} catch (error48) {
|
|
4968
5128
|
await appendCliUpdateLog(paths, "cli_update_check_failed", {
|
|
4969
|
-
reason: error48 instanceof Error ? error48.message.slice(0, runtime_policy_generated_default.agent_cli.update_failure_reason_max_chars) : "unknown"
|
|
5129
|
+
reason: error48 instanceof Error ? sanitizeRuntimeDiagnosticValue(error48.message).slice(0, runtime_policy_generated_default.agent_cli.update_failure_reason_max_chars) : "unknown"
|
|
4970
5130
|
});
|
|
4971
5131
|
return { kind: "run" };
|
|
4972
5132
|
}
|
|
@@ -5394,7 +5554,7 @@ var init_updater = __esm({
|
|
|
5394
5554
|
return active && compareCliReleaseVersions(active.package_version, current) > 0 && rejection?.package_version !== active.package_version ? active : null;
|
|
5395
5555
|
} catch (error48) {
|
|
5396
5556
|
await appendCliUpdateLog(paths, "cli_runtime_release_poll_failed", {
|
|
5397
|
-
reason: error48 instanceof Error ? error48.message.slice(0, runtime_policy_generated_default.agent_cli.update_failure_reason_max_chars) : "unknown"
|
|
5557
|
+
reason: error48 instanceof Error ? sanitizeRuntimeDiagnosticValue(error48.message).slice(0, runtime_policy_generated_default.agent_cli.update_failure_reason_max_chars) : "unknown"
|
|
5398
5558
|
});
|
|
5399
5559
|
return null;
|
|
5400
5560
|
}
|
|
@@ -23618,20 +23778,20 @@ var init_credential_store = __esm({
|
|
|
23618
23778
|
stdio: ["pipe", "pipe", "pipe"],
|
|
23619
23779
|
windowsHide: true
|
|
23620
23780
|
});
|
|
23621
|
-
let
|
|
23781
|
+
let settled2 = false;
|
|
23622
23782
|
let terminating = false;
|
|
23623
23783
|
const cleanup = () => {
|
|
23624
23784
|
clearTimeout(timer);
|
|
23625
23785
|
options.signal?.removeEventListener("abort", abort);
|
|
23626
23786
|
};
|
|
23627
23787
|
const settleReject = (error48) => {
|
|
23628
|
-
if (
|
|
23629
|
-
|
|
23788
|
+
if (settled2) return;
|
|
23789
|
+
settled2 = true;
|
|
23630
23790
|
cleanup();
|
|
23631
23791
|
reject(error48);
|
|
23632
23792
|
};
|
|
23633
23793
|
const terminate = (error48) => {
|
|
23634
|
-
if (
|
|
23794
|
+
if (settled2 || terminating) return;
|
|
23635
23795
|
terminating = true;
|
|
23636
23796
|
void terminateCredentialProcessTree(child).finally(() => settleReject(error48));
|
|
23637
23797
|
};
|
|
@@ -23654,12 +23814,12 @@ var init_credential_store = __esm({
|
|
|
23654
23814
|
child.stderr.resume();
|
|
23655
23815
|
child.once("error", () => settleReject(new Error("OS credential command could not start.")));
|
|
23656
23816
|
child.once("close", (exitCode) => {
|
|
23657
|
-
if (terminating ||
|
|
23817
|
+
if (terminating || settled2) return;
|
|
23658
23818
|
try {
|
|
23659
23819
|
const normalizedExitCode = Number(exitCode ?? 1);
|
|
23660
23820
|
const stdout = Buffer.concat(stdoutChunks).toString("utf8");
|
|
23661
23821
|
const transformedStdout = normalizedExitCode === 0 ? command.transformStdout?.(stdout) ?? stdout : stdout;
|
|
23662
|
-
|
|
23822
|
+
settled2 = true;
|
|
23663
23823
|
cleanup();
|
|
23664
23824
|
resolve14({
|
|
23665
23825
|
exitCode: normalizedExitCode,
|
|
@@ -24888,16 +25048,16 @@ async function beginInferenceOAuthLogin(options) {
|
|
|
24888
25048
|
state: pkce.state,
|
|
24889
25049
|
challenge: pkce.challenge
|
|
24890
25050
|
});
|
|
24891
|
-
let
|
|
25051
|
+
let settled2 = false;
|
|
24892
25052
|
let rejectCompletion;
|
|
24893
25053
|
const completion = new Promise((resolve14, reject) => {
|
|
24894
25054
|
rejectCompletion = reject;
|
|
24895
25055
|
handler = async (requestUrl2, method, writeResponse) => {
|
|
24896
|
-
if (
|
|
25056
|
+
if (settled2) {
|
|
24897
25057
|
writeResponse(HTTP_STATUS.CONFLICT, "Authorization callback is no longer active.");
|
|
24898
25058
|
return;
|
|
24899
25059
|
}
|
|
24900
|
-
|
|
25060
|
+
settled2 = true;
|
|
24901
25061
|
try {
|
|
24902
25062
|
if (method !== "GET") throw new Error("Inference OAuth callback is invalid.");
|
|
24903
25063
|
const callbackUrl = new URL(requestUrl2, redirectUri).toString();
|
|
@@ -24982,8 +25142,8 @@ async function beginInferenceOAuthLogin(options) {
|
|
|
24982
25142
|
};
|
|
24983
25143
|
});
|
|
24984
25144
|
const abortLogin = () => {
|
|
24985
|
-
if (
|
|
24986
|
-
|
|
25145
|
+
if (settled2) return;
|
|
25146
|
+
settled2 = true;
|
|
24987
25147
|
void closeServer(server).finally(() => rejectCompletion(
|
|
24988
25148
|
new InferenceOAuthRequestError(
|
|
24989
25149
|
"request_aborted",
|
|
@@ -24994,8 +25154,8 @@ async function beginInferenceOAuthLogin(options) {
|
|
|
24994
25154
|
options.signal?.addEventListener("abort", abortLogin, { once: true });
|
|
24995
25155
|
if (options.signal?.aborted) abortLogin();
|
|
24996
25156
|
const timeout = setTimeout(() => {
|
|
24997
|
-
if (
|
|
24998
|
-
|
|
25157
|
+
if (settled2) return;
|
|
25158
|
+
settled2 = true;
|
|
24999
25159
|
void closeServer(server).finally(
|
|
25000
25160
|
() => rejectCompletion(new Error("Inference OAuth authorization timed out."))
|
|
25001
25161
|
);
|
|
@@ -25016,8 +25176,8 @@ async function beginInferenceOAuthLogin(options) {
|
|
|
25016
25176
|
redirectUri,
|
|
25017
25177
|
completion,
|
|
25018
25178
|
cancel: async () => {
|
|
25019
|
-
if (
|
|
25020
|
-
|
|
25179
|
+
if (settled2) return;
|
|
25180
|
+
settled2 = true;
|
|
25021
25181
|
await closeServer(server);
|
|
25022
25182
|
rejectCompletion(new Error("Inference OAuth authorization was cancelled."));
|
|
25023
25183
|
}
|
|
@@ -25120,6 +25280,7 @@ var init_mcp_client = __esm({
|
|
|
25120
25280
|
init_runtime_policy_generated2();
|
|
25121
25281
|
init_constants();
|
|
25122
25282
|
init_mcp_transport();
|
|
25283
|
+
init_runtime_redaction();
|
|
25123
25284
|
init_external_inference_contract();
|
|
25124
25285
|
EXTERNAL_INFERENCE_MCP_PROTOCOL_VERSION = "2026-07-28";
|
|
25125
25286
|
EXTERNAL_INFERENCE_AUTOMATED_HOST_TOOLS = [
|
|
@@ -25300,7 +25461,7 @@ var init_mcp_client = __esm({
|
|
|
25300
25461
|
publicRejectionReason = (text) => {
|
|
25301
25462
|
const marker = text.indexOf(PUBLIC_TOOL_ERROR_PREFIX);
|
|
25302
25463
|
const [firstLine = ""] = (marker < 0 ? text : text.slice(0, marker)).split("\n");
|
|
25303
|
-
const reason = firstLine.replace(CONTROL_CHARACTERS, " ").trim();
|
|
25464
|
+
const reason = sanitizeRuntimeDiagnosticValue(firstLine.replace(CONTROL_CHARACTERS, " ")).trim();
|
|
25304
25465
|
if (!reason) return null;
|
|
25305
25466
|
return reason.length > MAX_REJECTION_REASON_CHARS ? `${reason.slice(0, MAX_REJECTION_REASON_CHARS)}\u2026` : reason;
|
|
25306
25467
|
};
|
|
@@ -35854,7 +36015,7 @@ var init_runner = __esm({
|
|
|
35854
36015
|
};
|
|
35855
36016
|
settlesWithin = async (promise2, timeoutMs) => {
|
|
35856
36017
|
let timer = null;
|
|
35857
|
-
const
|
|
36018
|
+
const settled2 = await Promise.race([
|
|
35858
36019
|
promise2.then(() => true, () => true),
|
|
35859
36020
|
new Promise((resolve14) => {
|
|
35860
36021
|
timer = setTimeout(
|
|
@@ -35864,7 +36025,7 @@ var init_runner = __esm({
|
|
|
35864
36025
|
})
|
|
35865
36026
|
]);
|
|
35866
36027
|
if (timer !== null) clearTimeout(timer);
|
|
35867
|
-
return
|
|
36028
|
+
return settled2;
|
|
35868
36029
|
};
|
|
35869
36030
|
defaultRegisterSignalHandlers = (requestDrain) => {
|
|
35870
36031
|
const onSigint = () => requestDrain("sigint");
|
|
@@ -41325,10 +41486,10 @@ var init_codex_adapter = __esm({
|
|
|
41325
41486
|
}
|
|
41326
41487
|
const start = this.durableSessionStart;
|
|
41327
41488
|
return await new Promise((resolveSession, reject) => {
|
|
41328
|
-
let
|
|
41489
|
+
let settled2 = false;
|
|
41329
41490
|
const finish = (callback) => {
|
|
41330
|
-
if (
|
|
41331
|
-
|
|
41491
|
+
if (settled2) return;
|
|
41492
|
+
settled2 = true;
|
|
41332
41493
|
clearTimeout(timer);
|
|
41333
41494
|
signal?.removeEventListener("abort", onAbort);
|
|
41334
41495
|
callback();
|
|
@@ -41404,10 +41565,10 @@ var init_codex_adapter = __esm({
|
|
|
41404
41565
|
}
|
|
41405
41566
|
async waitForCapabilities(preflight, deadlineAtMs, signal) {
|
|
41406
41567
|
return await new Promise((resolve14, reject) => {
|
|
41407
|
-
let
|
|
41568
|
+
let settled2 = false;
|
|
41408
41569
|
const finish = (callback) => {
|
|
41409
|
-
if (
|
|
41410
|
-
|
|
41570
|
+
if (settled2) return;
|
|
41571
|
+
settled2 = true;
|
|
41411
41572
|
clearTimeout(timer);
|
|
41412
41573
|
signal?.removeEventListener("abort", onAbort);
|
|
41413
41574
|
callback();
|
|
@@ -47436,6 +47597,7 @@ var init_service = __esm({
|
|
|
47436
47597
|
init_define_VTX_GROK_POLICY();
|
|
47437
47598
|
init_define_VTX_PI_MODEL_POLICY();
|
|
47438
47599
|
init_service_launcher_state();
|
|
47600
|
+
init_runtime_redaction();
|
|
47439
47601
|
init_agent_cli_release();
|
|
47440
47602
|
init_runtime_policy_generated();
|
|
47441
47603
|
init_constants();
|
|
@@ -48722,7 +48884,7 @@ ${result.stderr}`)) {
|
|
|
48722
48884
|
event: "worker_output",
|
|
48723
48885
|
instance_name: worker.instance_name,
|
|
48724
48886
|
stream,
|
|
48725
|
-
message: line.slice(0, SERVICE_POLICY.worker_output_line_max_chars)
|
|
48887
|
+
message: sanitizeRuntimeDiagnosticValue(line).slice(0, SERVICE_POLICY.worker_output_line_max_chars)
|
|
48726
48888
|
})}
|
|
48727
48889
|
`);
|
|
48728
48890
|
}
|
|
@@ -49002,8 +49164,8 @@ ${result.stderr}`)) {
|
|
|
49002
49164
|
record5.controller.abort();
|
|
49003
49165
|
await updateRecord(record5, "draining");
|
|
49004
49166
|
}
|
|
49005
|
-
const
|
|
49006
|
-
const failedDrain =
|
|
49167
|
+
const settled2 = await Promise.allSettled(retiring.map((record5) => record5.promise));
|
|
49168
|
+
const failedDrain = settled2.find(
|
|
49007
49169
|
(result) => result.status === "rejected"
|
|
49008
49170
|
);
|
|
49009
49171
|
if (failedDrain) {
|
|
@@ -49037,8 +49199,8 @@ ${result.stderr}`)) {
|
|
|
49037
49199
|
record5.controller.abort();
|
|
49038
49200
|
await updateRecord(record5, "draining");
|
|
49039
49201
|
}
|
|
49040
|
-
const
|
|
49041
|
-
const failedDrain =
|
|
49202
|
+
const settled2 = await Promise.allSettled(draining.map((record5) => record5.promise));
|
|
49203
|
+
const failedDrain = settled2.find(
|
|
49042
49204
|
(result) => result.status === "rejected"
|
|
49043
49205
|
);
|
|
49044
49206
|
if (failedDrain) throw failedDrain.reason;
|
|
@@ -49081,8 +49243,8 @@ ${result.stderr}`)) {
|
|
|
49081
49243
|
await drainWorkers();
|
|
49082
49244
|
break;
|
|
49083
49245
|
}
|
|
49084
|
-
const
|
|
49085
|
-
const failure2 =
|
|
49246
|
+
const settled2 = await completion;
|
|
49247
|
+
const failure2 = settled2.find((result) => result.status === "rejected");
|
|
49086
49248
|
if (failure2) throw failure2.reason;
|
|
49087
49249
|
break;
|
|
49088
49250
|
}
|
|
@@ -55607,63 +55769,6 @@ var init_request_encoding = __esm({
|
|
|
55607
55769
|
}
|
|
55608
55770
|
});
|
|
55609
55771
|
|
|
55610
|
-
// lib/runtime/abort.ts
|
|
55611
|
-
var ABORT_MESSAGE_TOKENS, readAbortLikeMessage, isAbortLikeError, toAbortError;
|
|
55612
|
-
var init_abort = __esm({
|
|
55613
|
-
"lib/runtime/abort.ts"() {
|
|
55614
|
-
"use strict";
|
|
55615
|
-
init_define_VTX_EXO_POLICY();
|
|
55616
|
-
init_define_VTX_GROK_POLICY();
|
|
55617
|
-
init_define_VTX_PI_MODEL_POLICY();
|
|
55618
|
-
ABORT_MESSAGE_TOKENS = [
|
|
55619
|
-
"the operation was aborted",
|
|
55620
|
-
"the user aborted a request",
|
|
55621
|
-
"request was aborted",
|
|
55622
|
-
"request aborted",
|
|
55623
|
-
"signal is aborted",
|
|
55624
|
-
"client runtime stop requested"
|
|
55625
|
-
];
|
|
55626
|
-
readAbortLikeMessage = (error48) => {
|
|
55627
|
-
if (error48 instanceof Error) {
|
|
55628
|
-
return error48.message;
|
|
55629
|
-
}
|
|
55630
|
-
if (typeof error48 === "string") {
|
|
55631
|
-
return error48;
|
|
55632
|
-
}
|
|
55633
|
-
if (error48 && typeof error48 === "object" && typeof error48.message === "string") {
|
|
55634
|
-
return String(error48.message);
|
|
55635
|
-
}
|
|
55636
|
-
return "";
|
|
55637
|
-
};
|
|
55638
|
-
isAbortLikeError = (error48) => {
|
|
55639
|
-
if (typeof DOMException !== "undefined" && error48 instanceof DOMException) {
|
|
55640
|
-
return error48.name === "AbortError";
|
|
55641
|
-
}
|
|
55642
|
-
if (error48 instanceof Error && error48.name === "AbortError") {
|
|
55643
|
-
return true;
|
|
55644
|
-
}
|
|
55645
|
-
if (error48 && typeof error48 === "object" && error48.name === "AbortError") {
|
|
55646
|
-
return true;
|
|
55647
|
-
}
|
|
55648
|
-
const normalized = readAbortLikeMessage(error48).trim().toLowerCase();
|
|
55649
|
-
if (!normalized) {
|
|
55650
|
-
return false;
|
|
55651
|
-
}
|
|
55652
|
-
return ABORT_MESSAGE_TOKENS.some((token) => normalized.includes(token));
|
|
55653
|
-
};
|
|
55654
|
-
toAbortError = (error48, fallbackMessage = "The operation was aborted.") => {
|
|
55655
|
-
const message = readAbortLikeMessage(error48).trim() || fallbackMessage;
|
|
55656
|
-
try {
|
|
55657
|
-
return new DOMException(message, "AbortError");
|
|
55658
|
-
} catch {
|
|
55659
|
-
const fallback = new Error(message);
|
|
55660
|
-
fallback.name = "AbortError";
|
|
55661
|
-
return fallback;
|
|
55662
|
-
}
|
|
55663
|
-
};
|
|
55664
|
-
}
|
|
55665
|
-
});
|
|
55666
|
-
|
|
55667
55772
|
// lib/api/shared.ts
|
|
55668
55773
|
function configureApiTransport(transport) {
|
|
55669
55774
|
if (transport === null) {
|
|
@@ -55691,7 +55796,7 @@ function getProfileHeaders(baseHeaders = {}, explicitProfileId) {
|
|
|
55691
55796
|
if (profileId) headers["x-profile-id"] = profileId.toString();
|
|
55692
55797
|
return headers;
|
|
55693
55798
|
}
|
|
55694
|
-
var configuredApiTransport, getApiUrl, sendApiRequest, apiFetch, sleep, inFlightClientGetRequests, recentClientGetResponses, clientGetRequestGenerations, initializedClientGetRequestKeys, CLIENT_GET_DEDUPE_TTL_MS, CLIENT_RUNTIME_STATUSES_DEDUPE_TTL_MS, CLIENT_LLM_CONFIG_PRIME_TTL_MS, AUTH_BOOTSTRAP_GET_MAX_ATTEMPTS, AUTH_BOOTSTRAP_RETRY_JITTER_MS, canUseClientGetRequestCache, invalidateClientGetRequestCache, raceWithAbortSignal, shareClientGetRequest, clientGetRequestKey, clientPreferencesRequestKey, invalidateClientPreferencesCache, parseRetryAfterMs2, resolveAuthBootstrapRetryDelayMs, fetchAuthBootstrapGetWithRetry, annotateMarketDataRequestError, buildMarketDataFetchError, buildMarketDataNetworkError, buildMarketDataResponseBodyError, isTransientNetworkFetchError, createIdempotencyKey, getErrorMessage, getErrorPayloadOrEmpty, getErrorPayloadOrFallbackDetail, getErrorMessageFromResponse, throwUnauthorizedIfNeeded, activeProfileId, PROFILE_STORAGE_KEY;
|
|
55799
|
+
var configuredApiTransport, getApiUrl, sendApiRequest, apiFetch, sleep, DEVICE_CLOCK_HEADER, deviceClockHeader, inFlightClientGetRequests, recentClientGetResponses, clientGetRequestGenerations, initializedClientGetRequestKeys, CLIENT_GET_DEDUPE_TTL_MS, CLIENT_RUNTIME_STATUSES_DEDUPE_TTL_MS, CLIENT_LLM_CONFIG_PRIME_TTL_MS, AUTH_BOOTSTRAP_GET_MAX_ATTEMPTS, AUTH_BOOTSTRAP_RETRY_JITTER_MS, canUseClientGetRequestCache, invalidateClientGetRequestCache, raceWithAbortSignal, shareClientGetRequest, clientGetRequestKey, clientPreferencesRequestKey, invalidateClientPreferencesCache, parseRetryAfterMs2, resolveAuthBootstrapRetryDelayMs, fetchAuthBootstrapGetWithRetry, annotateMarketDataRequestError, buildMarketDataFetchError, buildMarketDataNetworkError, buildMarketDataResponseBodyError, isTransientNetworkFetchError, createIdempotencyKey, getErrorMessage, getErrorPayloadOrEmpty, getErrorPayloadOrFallbackDetail, getErrorMessageFromResponse, throwUnauthorizedIfNeeded, activeProfileId, PROFILE_STORAGE_KEY;
|
|
55695
55800
|
var init_shared = __esm({
|
|
55696
55801
|
"lib/api/shared.ts"() {
|
|
55697
55802
|
"use strict";
|
|
@@ -55704,6 +55809,7 @@ var init_shared = __esm({
|
|
|
55704
55809
|
init_runtime_policy_generated2();
|
|
55705
55810
|
init_constants();
|
|
55706
55811
|
init_abort();
|
|
55812
|
+
init_runtime_redaction();
|
|
55707
55813
|
configuredApiTransport = null;
|
|
55708
55814
|
getApiUrl = () => {
|
|
55709
55815
|
if (configuredApiTransport) return configuredApiTransport.baseUrl;
|
|
@@ -55738,6 +55844,8 @@ var init_shared = __esm({
|
|
|
55738
55844
|
return sent !== init2 && refusedUnread(response, readsGzip) ? sendApiRequest(input, init2) : response;
|
|
55739
55845
|
};
|
|
55740
55846
|
sleep = (ms) => new Promise((resolve14) => setTimeout(resolve14, ms));
|
|
55847
|
+
DEVICE_CLOCK_HEADER = "X-Device-Clock-Ms";
|
|
55848
|
+
deviceClockHeader = () => ({ [DEVICE_CLOCK_HEADER]: String(Date.now()) });
|
|
55741
55849
|
inFlightClientGetRequests = /* @__PURE__ */ new Map();
|
|
55742
55850
|
recentClientGetResponses = /* @__PURE__ */ new Map();
|
|
55743
55851
|
clientGetRequestGenerations = /* @__PURE__ */ new Map();
|
|
@@ -55852,7 +55960,7 @@ var init_shared = __esm({
|
|
|
55852
55960
|
responseText = "";
|
|
55853
55961
|
}
|
|
55854
55962
|
const statusText = response.statusText ? ` ${response.statusText}` : "";
|
|
55855
|
-
const detail = responseText ? `: ${responseText.slice(0, runtime_policy_generated_default2.ui.api_client.market_data_error_detail_chars)}` : "";
|
|
55963
|
+
const detail = responseText ? `: ${sanitizeRuntimeDiagnosticValue(responseText).slice(0, runtime_policy_generated_default2.ui.api_client.market_data_error_detail_chars)}` : "";
|
|
55856
55964
|
return annotateMarketDataRequestError(
|
|
55857
55965
|
new Error(`Market data request failed: ${label2} unavailable (HTTP ${response.status}${statusText})${detail}`),
|
|
55858
55966
|
path,
|
|
@@ -56189,6 +56297,16 @@ function normalizeClientRuntimeSecretRateLimitErrorMessage(rawMessage, options)
|
|
|
56189
56297
|
);
|
|
56190
56298
|
return projectClientRuntimeSecretRateLimit(operation, retryAfterSeconds).detail;
|
|
56191
56299
|
}
|
|
56300
|
+
function getClientRuntimeSecretRateLimitRetryAfterSeconds(rawMessage, options) {
|
|
56301
|
+
const normalized = normalizeClientRuntimeSecretRateLimitErrorMessage(rawMessage, options);
|
|
56302
|
+
if (!normalized) {
|
|
56303
|
+
return null;
|
|
56304
|
+
}
|
|
56305
|
+
const retryFromDetail = normalized.match(/try\s*again\s*in\s*([0-9]+(?:\.[0-9]+)?)\s*seconds?/i)?.[1];
|
|
56306
|
+
return normalizeClientRuntimeSecretRetryAfterSeconds(
|
|
56307
|
+
retryFromDetail ?? options?.retryAfterHeader
|
|
56308
|
+
);
|
|
56309
|
+
}
|
|
56192
56310
|
function isClientRuntimeSecretRateLimitError(error48, options) {
|
|
56193
56311
|
const message = error48 instanceof Error ? error48.message : String(error48 ?? "");
|
|
56194
56312
|
return normalizeClientRuntimeSecretRateLimitErrorMessage(message, options) !== null;
|
|
@@ -56324,68 +56442,6 @@ var init_google_auth_url = __esm({
|
|
|
56324
56442
|
}
|
|
56325
56443
|
});
|
|
56326
56444
|
|
|
56327
|
-
// lib/runtime/runtime-redaction.ts
|
|
56328
|
-
var REDACTED_VALUE, SECRET_QUERY_PARAM_PATTERN, BEARER_TOKEN_PATTERN, SECRET_ASSIGNMENT_PATTERN, SECRET_KEYWORD_VALUE_PATTERN, OPENAI_STYLE_KEY_PATTERN, VERTEX_EXPRESS_KEY_PATTERN, isRuntimeErrorObject, sanitizeRuntimeDiagnosticValue, sanitizeRuntimeNetworkPath, getSanitizedRuntimeErrorMessage, toSanitizedRuntimeError, getSanitizedRuntimeAbortReason;
|
|
56329
|
-
var init_runtime_redaction = __esm({
|
|
56330
|
-
"lib/runtime/runtime-redaction.ts"() {
|
|
56331
|
-
"use strict";
|
|
56332
|
-
init_define_VTX_EXO_POLICY();
|
|
56333
|
-
init_define_VTX_GROK_POLICY();
|
|
56334
|
-
init_define_VTX_PI_MODEL_POLICY();
|
|
56335
|
-
init_abort();
|
|
56336
|
-
REDACTED_VALUE = "[REDACTED]";
|
|
56337
|
-
SECRET_QUERY_PARAM_PATTERN = /([?&](?:access_token|api(?:_|-)?key|auth|authorization|key|private_key|secret|sig|signature|token)=)[^&#\s]*/gi;
|
|
56338
|
-
BEARER_TOKEN_PATTERN = /\b(Bearer)\s+[A-Za-z0-9._:-]+\b/gi;
|
|
56339
|
-
SECRET_ASSIGNMENT_PATTERN = /((?:authorization\s*[:=]\s*['"]?Bearer\s+|x-api-key\s*[:=]\s*['"]?|api(?:_|-)?key\s*[:=]\s*['"]?|\bkey\s*[:=]\s*['"]?|token\s*[:=]\s*['"]?|secret\s*[:=]\s*['"]?))[^'"\s,}]+/gi;
|
|
56340
|
-
SECRET_KEYWORD_VALUE_PATTERN = /((?:private(?:_|-|\s)?key|signing(?:_|-|\s)?key)\s*[:=]\s*['"]?)(0x[a-fA-F0-9]{64}|[^'"\s,}]+)/gi;
|
|
56341
|
-
OPENAI_STYLE_KEY_PATTERN = /\bsk-[A-Za-z0-9._-]+\b/g;
|
|
56342
|
-
VERTEX_EXPRESS_KEY_PATTERN = /\bAQ\.[A-Za-z0-9._-]+\b/g;
|
|
56343
|
-
isRuntimeErrorObject = (error48) => error48 instanceof Error || error48 != null && typeof error48 === "object" && Object.prototype.toString.call(error48) === "[object DOMException]" && typeof error48.message === "string" && typeof error48.name === "string";
|
|
56344
|
-
sanitizeRuntimeDiagnosticValue = (value) => {
|
|
56345
|
-
const normalized = String(value || "");
|
|
56346
|
-
if (!normalized) {
|
|
56347
|
-
return normalized;
|
|
56348
|
-
}
|
|
56349
|
-
return normalized.replace(SECRET_QUERY_PARAM_PATTERN, `$1${REDACTED_VALUE}`).replace(BEARER_TOKEN_PATTERN, `$1 ${REDACTED_VALUE}`).replace(SECRET_ASSIGNMENT_PATTERN, `$1${REDACTED_VALUE}`).replace(SECRET_KEYWORD_VALUE_PATTERN, `$1${REDACTED_VALUE}`).replace(OPENAI_STYLE_KEY_PATTERN, REDACTED_VALUE).replace(VERTEX_EXPRESS_KEY_PATTERN, REDACTED_VALUE);
|
|
56350
|
-
};
|
|
56351
|
-
sanitizeRuntimeNetworkPath = (value) => {
|
|
56352
|
-
const normalized = String(value || "").trim();
|
|
56353
|
-
if (!normalized) {
|
|
56354
|
-
return "/";
|
|
56355
|
-
}
|
|
56356
|
-
const withoutFragment = normalized.split("#", 1)[0] || normalized;
|
|
56357
|
-
const withoutQuery = withoutFragment.split("?", 1)[0] || withoutFragment;
|
|
56358
|
-
const sanitized = sanitizeRuntimeDiagnosticValue(withoutQuery.trim());
|
|
56359
|
-
return sanitized || "/";
|
|
56360
|
-
};
|
|
56361
|
-
getSanitizedRuntimeErrorMessage = (error48) => {
|
|
56362
|
-
const message = isRuntimeErrorObject(error48) ? error48.message : typeof error48 === "string" ? error48 : error48 == null ? null : String(error48);
|
|
56363
|
-
if (message == null) {
|
|
56364
|
-
return null;
|
|
56365
|
-
}
|
|
56366
|
-
return sanitizeRuntimeDiagnosticValue(message);
|
|
56367
|
-
};
|
|
56368
|
-
toSanitizedRuntimeError = (error48) => {
|
|
56369
|
-
const message = getSanitizedRuntimeErrorMessage(error48) || "Unknown runtime error.";
|
|
56370
|
-
if (isRuntimeErrorObject(error48) && error48.message === message) {
|
|
56371
|
-
if (isAbortLikeError(error48) && error48.name !== "AbortError") {
|
|
56372
|
-
if (error48 instanceof Error) error48.name = "AbortError";
|
|
56373
|
-
else return Object.assign(new Error(message), { name: "AbortError" });
|
|
56374
|
-
}
|
|
56375
|
-
return error48;
|
|
56376
|
-
}
|
|
56377
|
-
const sanitized = new Error(message);
|
|
56378
|
-
if (isAbortLikeError(error48)) {
|
|
56379
|
-
sanitized.name = "AbortError";
|
|
56380
|
-
} else if (isRuntimeErrorObject(error48) && error48.name) {
|
|
56381
|
-
sanitized.name = error48.name;
|
|
56382
|
-
}
|
|
56383
|
-
return sanitized;
|
|
56384
|
-
};
|
|
56385
|
-
getSanitizedRuntimeAbortReason = (signal, fallbackMessage = "The operation was aborted.") => isRuntimeErrorObject(signal?.reason) ? toSanitizedRuntimeError(signal.reason) : new DOMException(fallbackMessage, "AbortError");
|
|
56386
|
-
}
|
|
56387
|
-
});
|
|
56388
|
-
|
|
56389
56445
|
// lib/runtime/channel-sender.ts
|
|
56390
56446
|
var RUNTIME_TAB_ID_STORAGE_KEY, createRuntimeUuid, getOrCreateRuntimeTabSenderId;
|
|
56391
56447
|
var init_channel_sender = __esm({
|
|
@@ -57086,6 +57142,7 @@ var init_local_breadcrumbs = __esm({
|
|
|
57086
57142
|
init_define_VTX_PI_MODEL_POLICY();
|
|
57087
57143
|
init_constants();
|
|
57088
57144
|
init_runtime_policy_generated2();
|
|
57145
|
+
init_runtime_redaction();
|
|
57089
57146
|
LOCAL_RUNTIME_BREADCRUMBS_STORAGE_KEY = "vtx_client_runtime_local_breadcrumbs_v1";
|
|
57090
57147
|
DEVICE_DIAGNOSTICS2 = runtime_policy_generated_default2.trading.engine.client_runtime.device_diagnostics;
|
|
57091
57148
|
LOCAL_RUNTIME_BREADCRUMBS_MAX_ENTRIES = DEVICE_DIAGNOSTICS2.breadcrumbs_max_entries;
|
|
@@ -57098,7 +57155,7 @@ var init_local_breadcrumbs = __esm({
|
|
|
57098
57155
|
return window;
|
|
57099
57156
|
};
|
|
57100
57157
|
sanitizeText = (value, maxLength) => {
|
|
57101
|
-
const text = String(value ?? "").trim();
|
|
57158
|
+
const text = sanitizeRuntimeDiagnosticValue(String(value ?? "")).trim();
|
|
57102
57159
|
if (!text) {
|
|
57103
57160
|
return null;
|
|
57104
57161
|
}
|
|
@@ -57529,6 +57586,7 @@ var init_market_data = __esm({
|
|
|
57529
57586
|
init_define_VTX_GROK_POLICY();
|
|
57530
57587
|
init_define_VTX_PI_MODEL_POLICY();
|
|
57531
57588
|
init_abort();
|
|
57589
|
+
init_runtime_redaction();
|
|
57532
57590
|
init_network_debug();
|
|
57533
57591
|
init_shared();
|
|
57534
57592
|
init_constants();
|
|
@@ -58972,7 +59030,7 @@ var init_hyperliquid_public_read = __esm({
|
|
|
58972
59030
|
let permit = null;
|
|
58973
59031
|
const rowWeightedReservationId = !hostTransport && HYPERLIQUID_ROW_WEIGHTED_INFO_REQUESTS.includes(requestType) ? crypto.randomUUID() : void 0;
|
|
58974
59032
|
let outcome = "cancelled";
|
|
58975
|
-
let
|
|
59033
|
+
let settled2;
|
|
58976
59034
|
let acquiring = false;
|
|
58977
59035
|
let observedRateLimit;
|
|
58978
59036
|
let privateRouteUsed = false;
|
|
@@ -59016,7 +59074,7 @@ var init_hyperliquid_public_read = __esm({
|
|
|
59016
59074
|
checkAbort(signal);
|
|
59017
59075
|
}
|
|
59018
59076
|
pending2.set(key, { promise: new Promise((resolve14) => {
|
|
59019
|
-
|
|
59077
|
+
settled2 = resolve14;
|
|
59020
59078
|
}), priority });
|
|
59021
59079
|
}
|
|
59022
59080
|
if (options.reservation?.closed) throw new DOMException("Hyperliquid account read was cancelled.", "AbortError");
|
|
@@ -59129,9 +59187,9 @@ var init_hyperliquid_public_read = __esm({
|
|
|
59129
59187
|
try {
|
|
59130
59188
|
await finishHyperliquidRecoveryRequest(permit, outcome);
|
|
59131
59189
|
} finally {
|
|
59132
|
-
if (
|
|
59190
|
+
if (settled2) {
|
|
59133
59191
|
pending2.delete(key);
|
|
59134
|
-
|
|
59192
|
+
settled2();
|
|
59135
59193
|
}
|
|
59136
59194
|
}
|
|
59137
59195
|
}
|
|
@@ -92783,7 +92841,7 @@ var init_hyperliquid_client = __esm({
|
|
|
92783
92841
|
}
|
|
92784
92842
|
settlementAttempted = true;
|
|
92785
92843
|
try {
|
|
92786
|
-
const
|
|
92844
|
+
const settled2 = await settleClientRuntimeExchangeMutation(
|
|
92787
92845
|
durableMutation.profileId,
|
|
92788
92846
|
durableMutation.mutationId,
|
|
92789
92847
|
{
|
|
@@ -92798,10 +92856,10 @@ var init_hyperliquid_client = __esm({
|
|
|
92798
92856
|
...durableMutationAuthorityArgs(durableMutation)
|
|
92799
92857
|
);
|
|
92800
92858
|
try {
|
|
92801
|
-
durableMutation.onSettled?.(
|
|
92859
|
+
durableMutation.onSettled?.(settled2);
|
|
92802
92860
|
} catch {
|
|
92803
92861
|
}
|
|
92804
|
-
return
|
|
92862
|
+
return settled2;
|
|
92805
92863
|
} catch (settlementCause) {
|
|
92806
92864
|
throw Object.assign(new RuntimeExecutionError(
|
|
92807
92865
|
"Exchange submission may have completed; durable reconciliation is pending.",
|
|
@@ -92846,10 +92904,10 @@ var init_hyperliquid_client = __esm({
|
|
|
92846
92904
|
);
|
|
92847
92905
|
}
|
|
92848
92906
|
await new Promise((resolve14) => {
|
|
92849
|
-
let
|
|
92907
|
+
let settled2 = false;
|
|
92850
92908
|
const finish = () => {
|
|
92851
|
-
if (
|
|
92852
|
-
|
|
92909
|
+
if (settled2) return;
|
|
92910
|
+
settled2 = true;
|
|
92853
92911
|
globalThis.clearTimeout(timeoutId);
|
|
92854
92912
|
input.signal?.removeEventListener("abort", finish);
|
|
92855
92913
|
resolve14();
|
|
@@ -93600,7 +93658,8 @@ async function postClientRuntime(path, profileId, body, options) {
|
|
|
93600
93658
|
signal: requestSignal,
|
|
93601
93659
|
headers: {
|
|
93602
93660
|
...requestHeaders,
|
|
93603
|
-
...lastRequestId ? { "X-Request-ID": lastRequestId } : {}
|
|
93661
|
+
...lastRequestId ? { "X-Request-ID": lastRequestId } : {},
|
|
93662
|
+
...deviceClockHeader()
|
|
93604
93663
|
},
|
|
93605
93664
|
body
|
|
93606
93665
|
});
|
|
@@ -94722,6 +94781,7 @@ var init_api2 = __esm({
|
|
|
94722
94781
|
init_bot_exchanges();
|
|
94723
94782
|
init_local_breadcrumbs();
|
|
94724
94783
|
init_abort();
|
|
94784
|
+
init_runtime_redaction();
|
|
94725
94785
|
init_client_runtime_ownership_errors();
|
|
94726
94786
|
init_shared();
|
|
94727
94787
|
init_shared();
|
|
@@ -95277,7 +95337,7 @@ var init_api2 = __esm({
|
|
|
95277
95337
|
if (code !== "client_exchange_evidence_invalid") throw error48;
|
|
95278
95338
|
appendRuntimeDebugEvent({
|
|
95279
95339
|
label: "client_exchange_reconcile_evidence_rejected",
|
|
95280
|
-
note: `mutation_id=${answer.mutation_id} code=${code} detail=${String(error48.message ?? "").slice(0, runtime_policy_generated_default2.ui.api_client.exchange_evidence_rejection_detail_chars)}`,
|
|
95340
|
+
note: `mutation_id=${answer.mutation_id} code=${code} detail=${sanitizeRuntimeDiagnosticValue(String(error48.message ?? "")).slice(0, runtime_policy_generated_default2.ui.api_client.exchange_evidence_rejection_detail_chars)}`,
|
|
95281
95341
|
outcome: "error"
|
|
95282
95342
|
});
|
|
95283
95343
|
return answer;
|
|
@@ -96007,7 +96067,7 @@ function validateDeviceSecrets(value, options) {
|
|
|
96007
96067
|
missing: missing2
|
|
96008
96068
|
};
|
|
96009
96069
|
}
|
|
96010
|
-
var CLIENT_VAULT_CHANGED_EVENT, memory, runtimeSecretsInFlight, buildRuntimeSecretsRequestKey, fetchClientRuntimeSecretsSingleFlight, mapClientRuntimeSecretsToDeviceSecrets, normalizeLocalAiSecrets, normalizeOpenAiCompatibleSecrets, hasAnySecretValues, normalizeClientRuntimeSecretProvider, getResponseSecretVersion, buildHydrationState, normalizeProfileIdForApi, LEGACY_VAULT_PREFIX, LEGACY_VAULT_DB_NAME, LEGACY_VAULT_DB_VERSION, LEGACY_VAULT_KEY_STORE, safeLocalStorage, hasIndexedDb, base64ToArrayBuffer, openLegacyVaultDb, withLegacyStore, legacyRecordCache, readLegacyRecordUncached, readLegacyRecord, fillFromLegacy, legacyMigrations, ClientVault;
|
|
96070
|
+
var CLIENT_VAULT_CHANGED_EVENT, ClientRuntimeSecretRefreshPendingError, memory, runtimeSecretsInFlight, runtimeSecretsRetryAtMs, runtimeSecretsRetryKey, buildRuntimeSecretsRequestKey, fetchClientRuntimeSecretsSingleFlight, mapClientRuntimeSecretsToDeviceSecrets, normalizeLocalAiSecrets, normalizeOpenAiCompatibleSecrets, hasAnySecretValues, normalizeClientRuntimeSecretProvider, getResponseSecretVersion, buildHydrationState, normalizeProfileIdForApi, LEGACY_VAULT_PREFIX, LEGACY_VAULT_DB_NAME, LEGACY_VAULT_DB_VERSION, LEGACY_VAULT_KEY_STORE, safeLocalStorage, hasIndexedDb, base64ToArrayBuffer, openLegacyVaultDb, withLegacyStore, legacyRecordCache, readLegacyRecordUncached, readLegacyRecord, fillFromLegacy, legacyMigrations, ClientVault;
|
|
96011
96071
|
var init_vault = __esm({
|
|
96012
96072
|
"lib/runtime/vault.ts"() {
|
|
96013
96073
|
"use strict";
|
|
@@ -96015,6 +96075,7 @@ var init_vault = __esm({
|
|
|
96015
96075
|
init_define_VTX_GROK_POLICY();
|
|
96016
96076
|
init_define_VTX_PI_MODEL_POLICY();
|
|
96017
96077
|
init_host_storage();
|
|
96078
|
+
init_runtime_redaction();
|
|
96018
96079
|
init_api2();
|
|
96019
96080
|
init_client_runtime_secret_contract();
|
|
96020
96081
|
init_client_runtime_provider_contract();
|
|
@@ -96024,9 +96085,19 @@ var init_vault = __esm({
|
|
|
96024
96085
|
init_client_runtime_secret_rate_limit_contract();
|
|
96025
96086
|
init_local_ai();
|
|
96026
96087
|
init_byokProviderRegistry();
|
|
96088
|
+
init_constants();
|
|
96027
96089
|
CLIENT_VAULT_CHANGED_EVENT = "vtx-client-vault-changed";
|
|
96090
|
+
ClientRuntimeSecretRefreshPendingError = class extends Error {
|
|
96091
|
+
constructor(retryAfterSeconds) {
|
|
96092
|
+
super("Client provider credentials changed; account refresh is pending.");
|
|
96093
|
+
this.code = "client_runtime_secret_refresh_pending";
|
|
96094
|
+
this.retryAfterSeconds = retryAfterSeconds;
|
|
96095
|
+
}
|
|
96096
|
+
};
|
|
96028
96097
|
memory = /* @__PURE__ */ new Map();
|
|
96029
96098
|
runtimeSecretsInFlight = /* @__PURE__ */ new Map();
|
|
96099
|
+
runtimeSecretsRetryAtMs = /* @__PURE__ */ new Map();
|
|
96100
|
+
runtimeSecretsRetryKey = (profileId) => String(normalizeProfileIdForApi(profileId) ?? profileId);
|
|
96030
96101
|
buildRuntimeSecretsRequestKey = (profileId, activeProvider, includeAllProviderKeys) => `${normalizeProfileIdForApi(profileId)}:${activeProvider ?? "auto"}:${includeAllProviderKeys ? "all" : "active"}`;
|
|
96031
96102
|
fetchClientRuntimeSecretsSingleFlight = (profileId, activeProvider, includeAllProviderKeys) => {
|
|
96032
96103
|
const key = buildRuntimeSecretsRequestKey(profileId, activeProvider, includeAllProviderKeys);
|
|
@@ -96034,13 +96105,35 @@ var init_vault = __esm({
|
|
|
96034
96105
|
if (existing) {
|
|
96035
96106
|
return existing;
|
|
96036
96107
|
}
|
|
96108
|
+
const retryKey = runtimeSecretsRetryKey(profileId);
|
|
96109
|
+
const retryAtMs = runtimeSecretsRetryAtMs.get(retryKey);
|
|
96110
|
+
if (retryAtMs !== void 0) {
|
|
96111
|
+
const remainingMs = retryAtMs - Date.now();
|
|
96112
|
+
if (remainingMs > 0) {
|
|
96113
|
+
return Promise.reject(new Error(projectClientRuntimeSecretRateLimit(
|
|
96114
|
+
"get",
|
|
96115
|
+
Math.ceil(remainingMs / MS_PER_SECOND)
|
|
96116
|
+
).detail));
|
|
96117
|
+
}
|
|
96118
|
+
runtimeSecretsRetryAtMs.delete(retryKey);
|
|
96119
|
+
}
|
|
96037
96120
|
const request = getClientRuntimeSecrets(
|
|
96038
96121
|
normalizeProfileIdForApi(profileId),
|
|
96039
96122
|
{
|
|
96040
96123
|
activeProvider,
|
|
96041
96124
|
includeAllProviderKeys
|
|
96042
96125
|
}
|
|
96043
|
-
).
|
|
96126
|
+
).catch((error48) => {
|
|
96127
|
+
if (isClientRuntimeSecretRateLimitError(error48)) {
|
|
96128
|
+
const retryAfterSeconds = getClientRuntimeSecretRateLimitRetryAfterSeconds(
|
|
96129
|
+
error48 instanceof Error ? error48.message : String(error48)
|
|
96130
|
+
);
|
|
96131
|
+
if (retryAfterSeconds && retryAfterSeconds > 0) {
|
|
96132
|
+
runtimeSecretsRetryAtMs.set(retryKey, Date.now() + retryAfterSeconds * MS_PER_SECOND);
|
|
96133
|
+
}
|
|
96134
|
+
}
|
|
96135
|
+
throw error48;
|
|
96136
|
+
}).finally(() => {
|
|
96044
96137
|
runtimeSecretsInFlight.delete(key);
|
|
96045
96138
|
});
|
|
96046
96139
|
runtimeSecretsInFlight.set(key, request);
|
|
@@ -96297,27 +96390,8 @@ var init_vault = __esm({
|
|
|
96297
96390
|
static async refreshProviderSecretsForVersion(profileId, current, serverVersion) {
|
|
96298
96391
|
const version3 = normalizeClientRuntimeSecretVersion(serverVersion);
|
|
96299
96392
|
if (!version3) return current;
|
|
96300
|
-
let savedSecrets;
|
|
96301
96393
|
const stored = memory.get(profileId);
|
|
96302
|
-
|
|
96303
|
-
const hydrated = await _ClientVault.hydrateFromServerWithState(profileId, {
|
|
96304
|
-
includeAllProviderKeys: true,
|
|
96305
|
-
requireProviderSecret: false
|
|
96306
|
-
});
|
|
96307
|
-
if (hydrated.hydrationState.serverSecretVersion !== version3) {
|
|
96308
|
-
throw new Error("Client provider credentials changed; account refresh is pending.");
|
|
96309
|
-
}
|
|
96310
|
-
savedSecrets = hydrated.secrets;
|
|
96311
|
-
if (!memory.has(profileId)) {
|
|
96312
|
-
memory.set(profileId, {
|
|
96313
|
-
secrets: savedSecrets ?? { providerKeys: {} },
|
|
96314
|
-
serverSecretVersion: version3,
|
|
96315
|
-
allProviderKeysHydrated: true
|
|
96316
|
-
});
|
|
96317
|
-
}
|
|
96318
|
-
} else {
|
|
96319
|
-
savedSecrets = stored.secrets;
|
|
96320
|
-
}
|
|
96394
|
+
const savedSecrets = stored?.serverSecretVersion === version3 && stored.allProviderKeysHydrated ? stored.secrets : await _ClientVault.loadProviderSecretsRevision(profileId, version3);
|
|
96321
96395
|
return {
|
|
96322
96396
|
...current,
|
|
96323
96397
|
providerKeys: savedSecrets?.providerKeys ?? {},
|
|
@@ -96328,6 +96402,33 @@ var init_vault = __esm({
|
|
|
96328
96402
|
openaiCompatible: savedSecrets?.openaiCompatible
|
|
96329
96403
|
};
|
|
96330
96404
|
}
|
|
96405
|
+
/** Every provider secret of account revision `version`, read from the server when this page lacks it. */
|
|
96406
|
+
static async loadProviderSecretsRevision(profileId, version3) {
|
|
96407
|
+
let hydrated;
|
|
96408
|
+
try {
|
|
96409
|
+
hydrated = await _ClientVault.hydrateFromServerWithState(profileId, {
|
|
96410
|
+
includeAllProviderKeys: true,
|
|
96411
|
+
requireProviderSecret: false
|
|
96412
|
+
});
|
|
96413
|
+
} catch (error48) {
|
|
96414
|
+
const held = memory.get(profileId);
|
|
96415
|
+
if (isClientRuntimeSecretRateLimitError(error48) && held?.serverSecretVersion === version3) {
|
|
96416
|
+
return held.secrets;
|
|
96417
|
+
}
|
|
96418
|
+
throw error48;
|
|
96419
|
+
}
|
|
96420
|
+
if (hydrated.secretVersion !== version3) {
|
|
96421
|
+
throw new ClientRuntimeSecretRefreshPendingError(hydrated.rateLimited?.retryAfterSeconds ?? null);
|
|
96422
|
+
}
|
|
96423
|
+
if (!hydrated.rateLimited && !memory.has(profileId)) {
|
|
96424
|
+
memory.set(profileId, {
|
|
96425
|
+
secrets: hydrated.secrets ?? { providerKeys: {} },
|
|
96426
|
+
serverSecretVersion: version3,
|
|
96427
|
+
allProviderKeysHydrated: true
|
|
96428
|
+
});
|
|
96429
|
+
}
|
|
96430
|
+
return hydrated.secrets;
|
|
96431
|
+
}
|
|
96331
96432
|
static async hydrateFromServer(profileId, options) {
|
|
96332
96433
|
const result = await _ClientVault.hydrateFromServerWithState(profileId, options);
|
|
96333
96434
|
return result.secrets;
|
|
@@ -96349,17 +96450,24 @@ var init_vault = __esm({
|
|
|
96349
96450
|
includeAllProviderKeys
|
|
96350
96451
|
);
|
|
96351
96452
|
} catch (error48) {
|
|
96453
|
+
const record5 = memory.get(profileId);
|
|
96352
96454
|
const existing = await _ClientVault.getSecrets(profileId);
|
|
96353
96455
|
const localValidation = validateDeviceSecrets(existing, validationOptions);
|
|
96354
96456
|
if (isClientRuntimeSecretRateLimitError(error48) && localValidation.readyForClientRuntime && localValidation.normalized) {
|
|
96457
|
+
const message = error48 instanceof Error ? error48.message : String(error48);
|
|
96355
96458
|
return {
|
|
96356
96459
|
secrets: localValidation.normalized,
|
|
96357
|
-
hydrationState: await _ClientVault.getHydrationState(profileId, validationOptions)
|
|
96460
|
+
hydrationState: await _ClientVault.getHydrationState(profileId, validationOptions),
|
|
96461
|
+
// The revision of the copy returned (none for a legacy device copy).
|
|
96462
|
+
secretVersion: record5?.serverSecretVersion ?? null,
|
|
96463
|
+
rateLimited: { retryAfterSeconds: getClientRuntimeSecretRateLimitRetryAfterSeconds(message) ?? 0 }
|
|
96358
96464
|
};
|
|
96359
96465
|
}
|
|
96360
96466
|
throw error48;
|
|
96361
96467
|
}
|
|
96362
96468
|
const remoteSecretVersion = getResponseSecretVersion(remoteSecrets);
|
|
96469
|
+
const held = memory.get(profileId);
|
|
96470
|
+
const keepsCompleteCopy = !includeAllProviderKeys && remoteSecretVersion !== null && held?.allProviderKeysHydrated === true && held.serverSecretVersion === remoteSecretVersion;
|
|
96363
96471
|
const mapped = mapClientRuntimeSecretsToDeviceSecrets(remoteSecrets, {
|
|
96364
96472
|
activeProvider,
|
|
96365
96473
|
includeAllProviderKeys
|
|
@@ -96371,18 +96479,22 @@ var init_vault = __esm({
|
|
|
96371
96479
|
);
|
|
96372
96480
|
const validation = validateDeviceSecrets(merged, validationOptions);
|
|
96373
96481
|
if (!validation.normalized || !hasAnySecretValues(validation.normalized)) {
|
|
96374
|
-
_ClientVault.forget(profileId);
|
|
96482
|
+
if (!keepsCompleteCopy) _ClientVault.forget(profileId);
|
|
96375
96483
|
return {
|
|
96376
96484
|
secrets: validation.normalized,
|
|
96377
|
-
hydrationState: buildHydrationState(remoteSecrets, validation.normalized, "missing", null, validationOptions)
|
|
96485
|
+
hydrationState: keepsCompleteCopy ? buildHydrationState(remoteSecrets, validation.normalized, "memory", remoteSecretVersion, validationOptions) : buildHydrationState(remoteSecrets, validation.normalized, "missing", null, validationOptions),
|
|
96486
|
+
secretVersion: remoteSecretVersion,
|
|
96487
|
+
rateLimited: null
|
|
96378
96488
|
};
|
|
96379
96489
|
}
|
|
96380
|
-
|
|
96381
|
-
|
|
96382
|
-
|
|
96383
|
-
|
|
96384
|
-
|
|
96385
|
-
|
|
96490
|
+
if (!keepsCompleteCopy) {
|
|
96491
|
+
memory.set(profileId, {
|
|
96492
|
+
secrets: validation.normalized,
|
|
96493
|
+
serverSecretVersion: remoteSecretVersion,
|
|
96494
|
+
allProviderKeysHydrated: includeAllProviderKeys
|
|
96495
|
+
});
|
|
96496
|
+
notifyVaultChanged(profileId);
|
|
96497
|
+
}
|
|
96386
96498
|
return {
|
|
96387
96499
|
secrets: validation.normalized,
|
|
96388
96500
|
hydrationState: buildHydrationState(
|
|
@@ -96391,7 +96503,9 @@ var init_vault = __esm({
|
|
|
96391
96503
|
"memory",
|
|
96392
96504
|
remoteSecretVersion,
|
|
96393
96505
|
validationOptions
|
|
96394
|
-
)
|
|
96506
|
+
),
|
|
96507
|
+
secretVersion: remoteSecretVersion,
|
|
96508
|
+
rateLimited: null
|
|
96395
96509
|
};
|
|
96396
96510
|
}
|
|
96397
96511
|
/**
|
|
@@ -97804,8 +97918,8 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
97804
97918
|
return await Promise.all(reads);
|
|
97805
97919
|
} catch (error48) {
|
|
97806
97920
|
controller.abort(error48);
|
|
97807
|
-
const
|
|
97808
|
-
for (const result of
|
|
97921
|
+
const settled2 = await Promise.allSettled(reads);
|
|
97922
|
+
for (const result of settled2) {
|
|
97809
97923
|
if (result.status === "rejected" && result.reason instanceof HyperliquidPublicReadError && result.reason.code === "public_rate_limited") throw result.reason;
|
|
97810
97924
|
}
|
|
97811
97925
|
throw error48;
|
|
@@ -99042,7 +99156,7 @@ var init_protective_actions = __esm({
|
|
|
99042
99156
|
});
|
|
99043
99157
|
continue;
|
|
99044
99158
|
}
|
|
99045
|
-
let
|
|
99159
|
+
let settled2 = null;
|
|
99046
99160
|
try {
|
|
99047
99161
|
await executeClientPreparedProtectiveAction({
|
|
99048
99162
|
profileId: input.profileId,
|
|
@@ -99061,7 +99175,7 @@ var init_protective_actions = __esm({
|
|
|
99061
99175
|
clientOrderIds: action.client_order_ids,
|
|
99062
99176
|
wireAction: canonical,
|
|
99063
99177
|
onSettled: (mutation) => {
|
|
99064
|
-
|
|
99178
|
+
settled2 = mutation;
|
|
99065
99179
|
}
|
|
99066
99180
|
});
|
|
99067
99181
|
result.processed.push({ actionId: action.action_id, actionKind: action.action_kind, outcome: "sent" });
|
|
@@ -99073,7 +99187,7 @@ var init_protective_actions = __esm({
|
|
|
99073
99187
|
reason: errorCode2(error48) || (error48 instanceof RuntimeExecutionError ? error48.reasonCode : "execution_failed")
|
|
99074
99188
|
});
|
|
99075
99189
|
}
|
|
99076
|
-
const settledMutation =
|
|
99190
|
+
const settledMutation = settled2;
|
|
99077
99191
|
if (settledMutation?.protection) result.protection = settledMutation.protection;
|
|
99078
99192
|
if (settledMutation && Array.isArray(settledMutation.protective_actions)) {
|
|
99079
99193
|
actions = settledMutation.protective_actions;
|
|
@@ -99215,7 +99329,7 @@ var init_client_exchange_mutations = __esm({
|
|
|
99215
99329
|
});
|
|
99216
99330
|
|
|
99217
99331
|
// lib/runtime/execution-guard-contract.ts
|
|
99218
|
-
var unitsFromPosition, signedUnitsFromPosition, signedUnitsFromEntryPosition, classifyExecutionIntent, reductionFirstOrder, usdAmount, orderMetadataRetryReason, orderCeilingRefusal, resolveExecutionTarget, decisionOrderSizeAsset, flipExecutionLegs, executedOrderPositionEvent;
|
|
99332
|
+
var unitsFromPosition, signedUnitsFromPosition, signedUnitsFromEntryPosition, classifyExecutionIntent, reductionFirstOrder, usdAmount, orderMetadataRetryReason, orderCeilingRefusal, copyClosingSize, copyOrderClosingSize, copyOrderNotionalCap, resolveExecutionTarget, decisionOrderSizeAsset, flipExecutionLegs, executedOrderPositionEvent;
|
|
99219
99333
|
var init_execution_guard_contract = __esm({
|
|
99220
99334
|
"lib/runtime/execution-guard-contract.ts"() {
|
|
99221
99335
|
"use strict";
|
|
@@ -99426,6 +99540,10 @@ var init_execution_guard_contract = __esm({
|
|
|
99426
99540
|
return null;
|
|
99427
99541
|
};
|
|
99428
99542
|
orderCeilingRefusal = (input) => {
|
|
99543
|
+
const closingSide2 = input.side === "sell" && input.currentPositionSize > 0 || input.side === "buy" && input.currentPositionSize < 0;
|
|
99544
|
+
if (input.reduceOnly && closingSide2 && input.size <= Math.abs(input.currentPositionSize)) {
|
|
99545
|
+
return null;
|
|
99546
|
+
}
|
|
99429
99547
|
const orderNotional = input.size * input.price;
|
|
99430
99548
|
if (orderNotional > input.maxOrderNotional) {
|
|
99431
99549
|
return `Order notional ${usdAmount(orderNotional)} exceeds limit ${usdAmount(input.maxOrderNotional)}`;
|
|
@@ -99437,6 +99555,23 @@ var init_execution_guard_contract = __esm({
|
|
|
99437
99555
|
}
|
|
99438
99556
|
return null;
|
|
99439
99557
|
};
|
|
99558
|
+
copyClosingSize = (destinationPosition, destinationDelta) => destinationPosition * destinationDelta >= 0 ? 0 : Math.min(Math.abs(destinationDelta), Math.abs(destinationPosition));
|
|
99559
|
+
copyOrderClosingSize = (input) => {
|
|
99560
|
+
const size = Number.isFinite(input.size) && input.size > 0 ? input.size : 0;
|
|
99561
|
+
if (input.reduceOnly) return size;
|
|
99562
|
+
if (input.actualPosition === null || !Number.isFinite(input.actualPosition)) return 0;
|
|
99563
|
+
const signedSize = String(input.side).trim().toLowerCase() === "buy" ? size : -size;
|
|
99564
|
+
return copyClosingSize(input.actualPosition, signedSize);
|
|
99565
|
+
};
|
|
99566
|
+
copyOrderNotionalCap = (followerCap, platformCap, closingNotional) => {
|
|
99567
|
+
const platform = Number(platformCap);
|
|
99568
|
+
if (!Number.isFinite(platform) || platform <= 0) return null;
|
|
99569
|
+
const closing = Number(closingNotional);
|
|
99570
|
+
const platformBound = (Number.isFinite(closing) && closing > 0 ? closing : 0) + platform;
|
|
99571
|
+
const follower = Number(followerCap);
|
|
99572
|
+
if (!Number.isFinite(follower) || follower <= 0) return platformBound;
|
|
99573
|
+
return Math.min(follower, platformBound);
|
|
99574
|
+
};
|
|
99440
99575
|
resolveExecutionTarget = (classified, liveSignedUnits, livePositionDirection) => {
|
|
99441
99576
|
const liveUnits = Number.isFinite(liveSignedUnits) ? Math.trunc(liveSignedUnits) : 0;
|
|
99442
99577
|
const exactLiveDirection = livePositionDirection == null ? liveUnits > 0 ? 1 : liveUnits < 0 ? -1 : 0 : livePositionDirection;
|
|
@@ -105502,7 +105637,7 @@ var init_runtime_execution = __esm({
|
|
|
105502
105637
|
const io = nativeProtectionIo(request, read.record.isLong);
|
|
105503
105638
|
const standby = read.record.standby ?? [];
|
|
105504
105639
|
if (read.record.phase === "entry_pending" || standby.length > 0) {
|
|
105505
|
-
const
|
|
105640
|
+
const settled2 = await settleNativeProtectionAfterFill({
|
|
105506
105641
|
record: read.record,
|
|
105507
105642
|
settings: nativeSettingsOf(request.executionContext),
|
|
105508
105643
|
sizeDecimals: request.executionContext.sizeDecimals,
|
|
@@ -105510,8 +105645,8 @@ var init_runtime_execution = __esm({
|
|
|
105510
105645
|
entryOrderId: read.record.phase === "entry_pending" ? read.record.entryClientOrderId : standby[0].orderId ?? standby[0].clientOrderId,
|
|
105511
105646
|
io
|
|
105512
105647
|
});
|
|
105513
|
-
const reports2 = [...
|
|
105514
|
-
let record5 =
|
|
105648
|
+
const reports2 = [...settled2.reports];
|
|
105649
|
+
let record5 = settled2.record;
|
|
105515
105650
|
if (record5 != null && record5.phase !== "entry_pending" && (record5.standby ?? []).length > 0) {
|
|
105516
105651
|
const kept = await reconcileNativeProtection({
|
|
105517
105652
|
record: record5,
|
|
@@ -108773,6 +108908,7 @@ var init_runtime_execution = __esm({
|
|
|
108773
108908
|
price: executionPrice,
|
|
108774
108909
|
// A flip's close has filled by now: its new position starts from flat.
|
|
108775
108910
|
currentPositionSize: targetResolution.closeOpposingPosition ? 0 : currentPositionSize,
|
|
108911
|
+
reduceOnly: classified.reduceOnly === true,
|
|
108776
108912
|
maxOrderNotional: runtime_policy_generated_default2.trading.risk.max_order_notional,
|
|
108777
108913
|
maxPositionNotional: runtime_policy_generated_default2.trading.risk.max_position_notional
|
|
108778
108914
|
});
|
|
@@ -109244,7 +109380,7 @@ var init_runtime_execution = __esm({
|
|
|
109244
109380
|
});
|
|
109245
109381
|
} else {
|
|
109246
109382
|
try {
|
|
109247
|
-
const
|
|
109383
|
+
const settled2 = await settleNativeProtectionAfterFill({
|
|
109248
109384
|
record: record5,
|
|
109249
109385
|
settings: nativeSettingsOf(input.executionContext),
|
|
109250
109386
|
sizeDecimals: input.executionContext.sizeDecimals,
|
|
@@ -109252,8 +109388,8 @@ var init_runtime_execution = __esm({
|
|
|
109252
109388
|
entryOrderId: confirmedMarketFill.orderId,
|
|
109253
109389
|
io: nativeProtectionIo(input, record5.isLong)
|
|
109254
109390
|
});
|
|
109255
|
-
executionReports.push(...
|
|
109256
|
-
if (
|
|
109391
|
+
executionReports.push(...settled2.reports);
|
|
109392
|
+
if (settled2.record != null) record5 = settled2.record;
|
|
109257
109393
|
} catch (postEntryProtectionError) {
|
|
109258
109394
|
if (isClientRuntimeLeaseOwnershipError(postEntryProtectionError)) throw postEntryProtectionError;
|
|
109259
109395
|
if (nativePassEnded(input, postEntryProtectionError)) {
|
|
@@ -109751,7 +109887,7 @@ var init_runtime_execution = __esm({
|
|
|
109751
109887
|
let actualPosition = null;
|
|
109752
109888
|
let desiredPosition = null;
|
|
109753
109889
|
let exactFullCloseBeforeQuantization = false;
|
|
109754
|
-
let
|
|
109890
|
+
let followerOrderNotionalCap = 0;
|
|
109755
109891
|
let minOrderNotional = 0;
|
|
109756
109892
|
let executionReferencePrice = Number(intent.source_price);
|
|
109757
109893
|
let dispatchedOrder = null;
|
|
@@ -109762,13 +109898,21 @@ var init_runtime_execution = __esm({
|
|
|
109762
109898
|
desiredPosition = Number(
|
|
109763
109899
|
record5.target_space === "copied" ? copiedNowServed ? record5.copied_target_after : Number.NaN : record5.desired_destination_position_after
|
|
109764
109900
|
);
|
|
109765
|
-
|
|
109766
|
-
reconciliation.max_order_notional_usdc
|
|
109767
|
-
);
|
|
109901
|
+
followerOrderNotionalCap = reconciliation.max_order_notional_usdc;
|
|
109768
109902
|
minOrderNotional = Number(
|
|
109769
109903
|
reconciliation.min_notional_usdc
|
|
109770
109904
|
);
|
|
109771
109905
|
}
|
|
109906
|
+
const platformOrderNotionalCap = input.config?.copy_trading?.execution?.max_per_intent_order_notional_usdc;
|
|
109907
|
+
let maxOrderNotional = 0;
|
|
109908
|
+
let orderNotionalCapResolved = false;
|
|
109909
|
+
if (copyOrderNotionalCap(followerOrderNotionalCap, platformOrderNotionalCap, 0) === null) {
|
|
109910
|
+
return {
|
|
109911
|
+
status: "failed",
|
|
109912
|
+
orderId: null,
|
|
109913
|
+
message: "Copy Trading platform order notional cap is unavailable."
|
|
109914
|
+
};
|
|
109915
|
+
}
|
|
109772
109916
|
if (!destinationSide || !Number.isFinite(destinationSize) || destinationSize <= 0) {
|
|
109773
109917
|
return {
|
|
109774
109918
|
status: "skipped",
|
|
@@ -109844,6 +109988,17 @@ var init_runtime_execution = __esm({
|
|
|
109844
109988
|
destinationSize = Math.abs(liveDelta);
|
|
109845
109989
|
exactFullCloseBeforeQuantization = Math.abs(desiredPosition) <= tolerance && Math.abs(actualPosition) > tolerance;
|
|
109846
109990
|
reduceOnly = Math.abs(desiredPosition) <= tolerance || (actualPosition > 0 && liveDelta < 0 && desiredPosition >= 0 || actualPosition < 0 && liveDelta > 0 && desiredPosition <= 0);
|
|
109991
|
+
maxOrderNotional = copyOrderNotionalCap(
|
|
109992
|
+
followerOrderNotionalCap,
|
|
109993
|
+
platformOrderNotionalCap,
|
|
109994
|
+
copyOrderClosingSize({
|
|
109995
|
+
side: destinationSide,
|
|
109996
|
+
size: destinationSize,
|
|
109997
|
+
reduceOnly,
|
|
109998
|
+
actualPosition
|
|
109999
|
+
}) * executionReferencePrice
|
|
110000
|
+
) ?? 0;
|
|
110001
|
+
orderNotionalCapResolved = true;
|
|
109847
110002
|
if (Number.isFinite(maxOrderNotional) && maxOrderNotional > 0) {
|
|
109848
110003
|
destinationSize = Math.min(
|
|
109849
110004
|
destinationSize,
|
|
@@ -109863,6 +110018,18 @@ var init_runtime_execution = __esm({
|
|
|
109863
110018
|
};
|
|
109864
110019
|
}
|
|
109865
110020
|
const referencePrice = executionReferencePrice;
|
|
110021
|
+
if (!orderNotionalCapResolved) {
|
|
110022
|
+
maxOrderNotional = copyOrderNotionalCap(
|
|
110023
|
+
followerOrderNotionalCap,
|
|
110024
|
+
platformOrderNotionalCap,
|
|
110025
|
+
copyOrderClosingSize({
|
|
110026
|
+
side: destinationSide,
|
|
110027
|
+
size: destinationSize,
|
|
110028
|
+
reduceOnly,
|
|
110029
|
+
actualPosition: null
|
|
110030
|
+
}) * referencePrice
|
|
110031
|
+
) ?? 0;
|
|
110032
|
+
}
|
|
109866
110033
|
if (Number.isFinite(maxOrderNotional) && maxOrderNotional > 0 && Number.isFinite(referencePrice) && referencePrice > 0 && sizePrecision.quantizedSize * referencePrice > maxOrderNotional + COPY_TRADING_NOTIONAL_CAP_TOLERANCE_USD) {
|
|
109867
110034
|
const cappedSize = Math.min(destinationSize, maxOrderNotional / referencePrice);
|
|
109868
110035
|
sizePrecision = {
|
|
@@ -110489,7 +110656,7 @@ var init_periodic_schedule = __esm({
|
|
|
110489
110656
|
});
|
|
110490
110657
|
|
|
110491
110658
|
// lib/runtime/provider-observability.ts
|
|
110492
|
-
var MAX_DIAGNOSTIC_LIST_ITEMS, record4, ERROR_TOKEN, ERROR_DOMAIN, ERROR_INPUT,
|
|
110659
|
+
var MAX_DIAGNOSTIC_LIST_ITEMS, record4, ERROR_TOKEN, ERROR_DOMAIN, ERROR_INPUT, ERROR_ECHO_REDACTIONS, ERROR_PROSE_REDACTIONS, CONTROL_CHARACTER_RUN, WHITESPACE_RUN, collapseProse, settled, REDACTED_MARKER_START, boundedMessage, normalizeProviderError, identifier, count3, normalizeProviderDiagnostics, providerRequestId, hash4, googleCredentialDiagnostics, extractProviderDiagnostics, estimateRequestInputTokens;
|
|
110493
110660
|
var init_provider_observability = __esm({
|
|
110494
110661
|
"lib/runtime/provider-observability.ts"() {
|
|
110495
110662
|
"use strict";
|
|
@@ -110497,34 +110664,68 @@ var init_provider_observability = __esm({
|
|
|
110497
110664
|
init_define_VTX_GROK_POLICY();
|
|
110498
110665
|
init_define_VTX_PI_MODEL_POLICY();
|
|
110499
110666
|
init_constants();
|
|
110667
|
+
init_runtime_redaction();
|
|
110500
110668
|
MAX_DIAGNOSTIC_LIST_ITEMS = PROVIDER_DIAGNOSTIC_LIMITS.MAX_LIST_ITEMS;
|
|
110501
110669
|
record4 = (v) => v !== null && typeof v === "object" && !Array.isArray(v) ? v : {};
|
|
110502
110670
|
ERROR_TOKEN = /^[A-Z][A-Z0-9_]{0,63}$/;
|
|
110503
110671
|
ERROR_DOMAIN = /^[a-z0-9][a-z0-9.-]{0,127}$/;
|
|
110504
|
-
ERROR_INPUT =
|
|
110505
|
-
|
|
110506
|
-
|
|
110672
|
+
ERROR_INPUT = new RegExp(
|
|
110673
|
+
String.raw`\b(?:prompt|contents|messages|system[_ ]?instruction|tools|request${WHITESPACE_CLASS}+body|input(?:${WHITESPACE_CLASS}+text)?)${WHITESPACE_CLASS}*[:=]|[{}]|` + "```",
|
|
110674
|
+
"i"
|
|
110675
|
+
);
|
|
110676
|
+
ERROR_ECHO_REDACTIONS = [
|
|
110677
|
+
[/https?:\/\/[^<>"'\t\n\v\f\r \x1c-\x1f\x85\xa0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000]+/gi, "[REDACTED_URL]"],
|
|
110507
110678
|
[/\b[A-Za-z0-9.!#$%&'*+/=?^_`{|}~-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g, "[REDACTED_EMAIL]"],
|
|
110508
|
-
|
|
110509
|
-
|
|
110510
|
-
[/\
|
|
110679
|
+
// A URL whose scheme a key form already took ("AIzahttps://..." is read as
|
|
110680
|
+
// a key first): the rest is still an echoed URL.
|
|
110681
|
+
[/\[REDACTED\]:\/\/[^<>"'\t\n\v\f\r \x1c-\x1f\x85\xa0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000]+/g, "[REDACTED_URL]"]
|
|
110682
|
+
];
|
|
110683
|
+
ERROR_PROSE_REDACTIONS = [
|
|
110684
|
+
...ERROR_ECHO_REDACTIONS,
|
|
110511
110685
|
[/"[^"]*"|'[^'\r\n]*'/g, "[REDACTED]"]
|
|
110512
110686
|
];
|
|
110687
|
+
CONTROL_CHARACTER_RUN = /[\x00-\x1f\x7f]+/g;
|
|
110688
|
+
WHITESPACE_RUN = new RegExp(`${WHITESPACE_CLASS}+`, "g");
|
|
110689
|
+
collapseProse = (value) => value.replace(CONTROL_CHARACTER_RUN, " ").replace(WHITESPACE_RUN, " ").trim();
|
|
110690
|
+
settled = (value) => {
|
|
110691
|
+
let current = value;
|
|
110692
|
+
let previous = null;
|
|
110693
|
+
while (current !== previous) {
|
|
110694
|
+
previous = current;
|
|
110695
|
+
for (const [pattern, replacement] of ERROR_PROSE_REDACTIONS) current = current.replace(pattern, replacement);
|
|
110696
|
+
current = sanitizeRuntimeDiagnosticValue(collapseProse(current));
|
|
110697
|
+
}
|
|
110698
|
+
return current;
|
|
110699
|
+
};
|
|
110700
|
+
REDACTED_MARKER_START = "[REDACTED";
|
|
110701
|
+
boundedMessage = (value) => {
|
|
110702
|
+
const characters = Array.from(value);
|
|
110703
|
+
if (characters.length <= PROVIDER_DIAGNOSTIC_LIMITS.MAX_ERROR_MESSAGE_CHARS) return value;
|
|
110704
|
+
let cut = characters.slice(0, PROVIDER_DIAGNOSTIC_LIMITS.MAX_ERROR_MESSAGE_CHARS).join("");
|
|
110705
|
+
const marker = cut.lastIndexOf(REDACTED_MARKER_START);
|
|
110706
|
+
if (marker !== -1 && value.indexOf("]", marker) >= cut.length) cut = cut.slice(0, marker);
|
|
110707
|
+
return cut.replace(/ +$/, "");
|
|
110708
|
+
};
|
|
110513
110709
|
normalizeProviderError = (value) => {
|
|
110514
110710
|
const raw = record4(value);
|
|
110515
110711
|
const result = {};
|
|
110516
110712
|
if (typeof raw.code === "number" && Number.isInteger(raw.code) && raw.code >= HTTP_STATUS_MIN && raw.code <= HTTP_STATUS_MAX) result.code = raw.code;
|
|
110517
110713
|
if (typeof raw.status === "string" && ERROR_TOKEN.test(raw.status)) result.status = raw.status;
|
|
110518
|
-
if (typeof raw.message === "string" && raw.message
|
|
110714
|
+
if (typeof raw.message === "string" && collapseProse(raw.message)) {
|
|
110519
110715
|
let message = raw.message;
|
|
110520
|
-
if (Array.from(message).length > PROVIDER_DIAGNOSTIC_LIMITS.MAX_ERROR_INPUT_CHARS || ERROR_INPUT.test(message)) message = "[REDACTED_INPUT]";
|
|
110716
|
+
if (Array.from(message).length > PROVIDER_DIAGNOSTIC_LIMITS.MAX_ERROR_INPUT_CHARS || ERROR_INPUT.test(message) || ERROR_INPUT.test(collapseProse(message))) message = "[REDACTED_INPUT]";
|
|
110521
110717
|
else {
|
|
110522
|
-
|
|
110523
|
-
|
|
110524
|
-
|
|
110525
|
-
|
|
110526
|
-
|
|
110527
|
-
|
|
110718
|
+
message = sanitizeRuntimeDiagnosticValue(message);
|
|
110719
|
+
for (const [pattern, replacement] of ERROR_ECHO_REDACTIONS) message = message.replace(pattern, replacement);
|
|
110720
|
+
message = sanitizeRuntimeDiagnosticValue(message);
|
|
110721
|
+
for (const [pattern, replacement] of ERROR_PROSE_REDACTIONS) message = message.replace(pattern, replacement);
|
|
110722
|
+
message = settled(sanitizeRuntimeDiagnosticValue(collapseProse(sanitizeRuntimeDiagnosticValue(message))));
|
|
110723
|
+
}
|
|
110724
|
+
const fullLength = Array.from(message).length;
|
|
110725
|
+
let bounded = boundedMessage(message);
|
|
110726
|
+
while (settled(bounded) !== bounded) bounded = Array.from(bounded).slice(0, -1).join("").replace(/ +$/, "");
|
|
110727
|
+
result.message = bounded;
|
|
110728
|
+
if (fullLength > PROVIDER_DIAGNOSTIC_LIMITS.MAX_ERROR_MESSAGE_CHARS || raw.message_truncated === true) result.message_truncated = true;
|
|
110528
110729
|
}
|
|
110529
110730
|
if (Array.isArray(raw.details)) {
|
|
110530
110731
|
const details = raw.details.slice(0, PROVIDER_DIAGNOSTIC_LIMITS.MAX_ERROR_DETAILS).map((value2) => {
|
|
@@ -116739,7 +116940,7 @@ var init_provider_client = __esm({
|
|
|
116739
116940
|
return payload.message.trim();
|
|
116740
116941
|
}
|
|
116741
116942
|
if (rawText) {
|
|
116742
|
-
return rawText.replace(/\s+/g, " ").slice(0, PROVIDER_ERROR_RAW_TEXT_MAX_CHARS);
|
|
116943
|
+
return sanitizeRuntimeDiagnosticValue(rawText).replace(/\s+/g, " ").slice(0, PROVIDER_ERROR_RAW_TEXT_MAX_CHARS);
|
|
116743
116944
|
}
|
|
116744
116945
|
return "";
|
|
116745
116946
|
};
|
|
@@ -120791,7 +120992,7 @@ var init_local_analysis = __esm({
|
|
|
120791
120992
|
return numeric2;
|
|
120792
120993
|
};
|
|
120793
120994
|
compactSnippet = (value, max2 = RUNTIME_DEBUG_SNIPPET_CHARS) => {
|
|
120794
|
-
const text = String(value ?? "").replace(/\s+/g, " ").trim();
|
|
120995
|
+
const text = sanitizeRuntimeDiagnosticValue(String(value ?? "").replace(/\s+/g, " ")).trim();
|
|
120795
120996
|
if (!text) {
|
|
120796
120997
|
return "";
|
|
120797
120998
|
}
|
|
@@ -121507,7 +121708,7 @@ ${reviewOutputContract}`;
|
|
|
121507
121708
|
return REVIEW_FAILURE_SQL_STATEMENT_PATTERN.test(lowered) && REVIEW_FAILURE_SCHEMA_DISCLOSURE_TOKENS.some((token) => lowered.includes(token));
|
|
121508
121709
|
};
|
|
121509
121710
|
summarizeReviewFailureExplanation = (detail) => {
|
|
121510
|
-
const message = String(detail ?? "").trim();
|
|
121711
|
+
const message = sanitizeRuntimeDiagnosticValue(String(detail ?? "")).trim();
|
|
121511
121712
|
if (!message) {
|
|
121512
121713
|
return "The review step stopped before VTX received error details.";
|
|
121513
121714
|
}
|
|
@@ -127306,10 +127507,10 @@ var init_engine = __esm({
|
|
|
127306
127507
|
outcome: "error"
|
|
127307
127508
|
});
|
|
127308
127509
|
await new Promise((resolve14) => {
|
|
127309
|
-
let
|
|
127510
|
+
let settled2 = false;
|
|
127310
127511
|
const finish = () => {
|
|
127311
|
-
if (
|
|
127312
|
-
|
|
127512
|
+
if (settled2) return;
|
|
127513
|
+
settled2 = true;
|
|
127313
127514
|
globalThis.clearTimeout(timeoutId);
|
|
127314
127515
|
signal.removeEventListener("abort", finish);
|
|
127315
127516
|
resolve14();
|
|
@@ -128252,14 +128453,14 @@ var init_engine = __esm({
|
|
|
128252
128453
|
const loop = this._executionLoopPromise;
|
|
128253
128454
|
if (!loop) return true;
|
|
128254
128455
|
let timer;
|
|
128255
|
-
const
|
|
128456
|
+
const settled2 = await Promise.race([
|
|
128256
128457
|
loop.then(() => true, () => true),
|
|
128257
128458
|
new Promise((resolve14) => {
|
|
128258
128459
|
timer = setTimeout(() => resolve14(false), timeoutMs);
|
|
128259
128460
|
})
|
|
128260
128461
|
]);
|
|
128261
128462
|
clearTimeout(timer);
|
|
128262
|
-
return
|
|
128463
|
+
return settled2;
|
|
128263
128464
|
}
|
|
128264
128465
|
get active() {
|
|
128265
128466
|
return this._startPromise !== null || this._isStopping || this._state === "running" || this._state === "stale" || this._state === "offline";
|
|
@@ -129390,10 +129591,10 @@ var init_engine = __esm({
|
|
|
129390
129591
|
throw signal.reason ?? createStopAbortError("trade_sync_settlement_cancelled");
|
|
129391
129592
|
}
|
|
129392
129593
|
await new Promise((resolve14) => {
|
|
129393
|
-
let
|
|
129594
|
+
let settled2 = false;
|
|
129394
129595
|
const finish = () => {
|
|
129395
|
-
if (
|
|
129396
|
-
|
|
129596
|
+
if (settled2) return;
|
|
129597
|
+
settled2 = true;
|
|
129397
129598
|
globalThis.clearTimeout(timeoutId);
|
|
129398
129599
|
signal?.removeEventListener("abort", finish);
|
|
129399
129600
|
resolve14();
|
|
@@ -130014,7 +130215,9 @@ var init_engine = __esm({
|
|
|
130014
130215
|
reviewModelResponse: result.reviewModelResponse,
|
|
130015
130216
|
primaryReasoningContent: result.primaryReasoningContent,
|
|
130016
130217
|
reviewReasoningContent: result.reviewReasoningContent,
|
|
130017
|
-
|
|
130218
|
+
// Raw provider error text never leaves the device; the server
|
|
130219
|
+
// stores the reason through the same redaction contract.
|
|
130220
|
+
reviewFailureReason: result.reviewFailureReason == null ? result.reviewFailureReason : sanitizeRuntimeDiagnosticValue(result.reviewFailureReason),
|
|
130018
130221
|
systemPrompt: result.systemPrompt,
|
|
130019
130222
|
userPrompt: result.userPrompt,
|
|
130020
130223
|
reviewSystemPrompt: result.reviewSystemPrompt,
|