@costrict/csc 4.2.8-beta1 → 4.2.8-beta2
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/cli.js +963 -573
- package/dist/services/rawDump/batchWorker.js +4 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -63721,8 +63721,8 @@ var init_credentials = __esm(() => {
|
|
|
63721
63721
|
import { createRequire } from "module";
|
|
63722
63722
|
function getVersion() {
|
|
63723
63723
|
try {
|
|
63724
|
-
if (typeof MACRO !== "undefined" && "4.2.8-
|
|
63725
|
-
return "4.2.8-
|
|
63724
|
+
if (typeof MACRO !== "undefined" && "4.2.8-beta2")
|
|
63725
|
+
return "4.2.8-beta2";
|
|
63726
63726
|
} catch {}
|
|
63727
63727
|
try {
|
|
63728
63728
|
const require2 = createRequire(import.meta.url);
|
|
@@ -184019,7 +184019,7 @@ async function fetchCoStrictModels(baseUrl, accessToken) {
|
|
|
184019
184019
|
headers: {
|
|
184020
184020
|
Authorization: `Bearer ${accessToken}`,
|
|
184021
184021
|
Accept: "application/json",
|
|
184022
|
-
"User-Agent": `csc/${"4.2.8-
|
|
184022
|
+
"User-Agent": `csc/${"4.2.8-beta2"}`
|
|
184023
184023
|
},
|
|
184024
184024
|
signal: controller.signal
|
|
184025
184025
|
});
|
|
@@ -187605,7 +187605,7 @@ var init_auth7 = __esm(() => {
|
|
|
187605
187605
|
|
|
187606
187606
|
// src/utils/userAgent.ts
|
|
187607
187607
|
function getClaudeCodeUserAgent() {
|
|
187608
|
-
return `costrict/${"4.2.8-
|
|
187608
|
+
return `costrict/${"4.2.8-beta2"}`;
|
|
187609
187609
|
}
|
|
187610
187610
|
|
|
187611
187611
|
// src/utils/workloadContext.ts
|
|
@@ -187627,7 +187627,7 @@ function getUserAgent() {
|
|
|
187627
187627
|
const clientApp = process.env.CLAUDE_AGENT_SDK_CLIENT_APP ? `, client-app/${process.env.CLAUDE_AGENT_SDK_CLIENT_APP}` : "";
|
|
187628
187628
|
const workload = getWorkload();
|
|
187629
187629
|
const workloadSuffix = workload ? `, workload/${workload}` : "";
|
|
187630
|
-
return `csc/${"4.2.8-
|
|
187630
|
+
return `csc/${"4.2.8-beta2"}`;
|
|
187631
187631
|
}
|
|
187632
187632
|
function getMCPUserAgent() {
|
|
187633
187633
|
const parts = [];
|
|
@@ -187641,7 +187641,7 @@ function getMCPUserAgent() {
|
|
|
187641
187641
|
parts.push(`client-app/${process.env.CLAUDE_AGENT_SDK_CLIENT_APP}`);
|
|
187642
187642
|
}
|
|
187643
187643
|
const suffix = parts.length > 0 ? ` (${parts.join(", ")})` : "";
|
|
187644
|
-
return `csc/${"4.2.8-
|
|
187644
|
+
return `csc/${"4.2.8-beta2"}${suffix}`;
|
|
187645
187645
|
}
|
|
187646
187646
|
function getWebFetchUserAgent() {
|
|
187647
187647
|
return `Claude-User (${getClaudeCodeUserAgent()}; +https://support.anthropic.com/)`;
|
|
@@ -187761,7 +187761,7 @@ var init_user = __esm(() => {
|
|
|
187761
187761
|
deviceId,
|
|
187762
187762
|
sessionId: getSessionId(),
|
|
187763
187763
|
email: getEmail(),
|
|
187764
|
-
appVersion: "4.2.8-
|
|
187764
|
+
appVersion: "4.2.8-beta2",
|
|
187765
187765
|
platform: getHostPlatformForAnalytics(),
|
|
187766
187766
|
organizationUuid,
|
|
187767
187767
|
accountUuid,
|
|
@@ -198842,7 +198842,7 @@ var init_metadata = __esm(() => {
|
|
|
198842
198842
|
COMPOUND_OPERATOR_REGEX = /\s*(?:&&|\|\||[;|])\s*/;
|
|
198843
198843
|
WHITESPACE_REGEX = /\s+/;
|
|
198844
198844
|
getVersionBase = memoize_default(() => {
|
|
198845
|
-
const match = "4.2.8-
|
|
198845
|
+
const match = "4.2.8-beta2".match(/^\d+\.\d+\.\d+(?:-[a-z]+)?/);
|
|
198846
198846
|
return match ? match[0] : undefined;
|
|
198847
198847
|
});
|
|
198848
198848
|
buildEnvContext = memoize_default(async () => {
|
|
@@ -198882,9 +198882,9 @@ var init_metadata = __esm(() => {
|
|
|
198882
198882
|
isGithubAction: isEnvTruthy(process.env.GITHUB_ACTIONS),
|
|
198883
198883
|
isClaudeCodeAction: isEnvTruthy(process.env.CLAUDE_CODE_ACTION),
|
|
198884
198884
|
isClaudeAiAuth: isClaudeAISubscriber(),
|
|
198885
|
-
version: "4.2.8-
|
|
198885
|
+
version: "4.2.8-beta2",
|
|
198886
198886
|
versionBase: getVersionBase(),
|
|
198887
|
-
buildTime: "2026-
|
|
198887
|
+
buildTime: "2026-07-01T02:28:03.350Z",
|
|
198888
198888
|
deploymentEnvironment: env4.detectDeploymentEnvironment(),
|
|
198889
198889
|
...isEnvTruthy(process.env.GITHUB_ACTIONS) && {
|
|
198890
198890
|
githubEventName: process.env.GITHUB_EVENT_NAME,
|
|
@@ -199555,7 +199555,7 @@ function initialize1PEventLogging() {
|
|
|
199555
199555
|
const platform3 = getPlatform();
|
|
199556
199556
|
const attributes = {
|
|
199557
199557
|
[import_semantic_conventions2.ATTR_SERVICE_NAME]: "claude-code",
|
|
199558
|
-
[import_semantic_conventions2.ATTR_SERVICE_VERSION]: "4.2.8-
|
|
199558
|
+
[import_semantic_conventions2.ATTR_SERVICE_VERSION]: "4.2.8-beta2"
|
|
199559
199559
|
};
|
|
199560
199560
|
if (platform3 === "wsl") {
|
|
199561
199561
|
const wslVersion = getWslVersion();
|
|
@@ -199582,7 +199582,7 @@ function initialize1PEventLogging() {
|
|
|
199582
199582
|
})
|
|
199583
199583
|
]
|
|
199584
199584
|
});
|
|
199585
|
-
firstPartyEventLogger = firstPartyEventLoggerProvider.getLogger("com.anthropic.claude_code.events", "4.2.8-
|
|
199585
|
+
firstPartyEventLogger = firstPartyEventLoggerProvider.getLogger("com.anthropic.claude_code.events", "4.2.8-beta2");
|
|
199586
199586
|
}
|
|
199587
199587
|
async function reinitialize1PEventLoggingIfConfigChanged() {
|
|
199588
199588
|
if (!is1PEventLoggingEnabled() || !firstPartyEventLoggerProvider) {
|
|
@@ -296619,8 +296619,60 @@ function wrapOpenAIErrorForRetry(error58) {
|
|
|
296619
296619
|
}
|
|
296620
296620
|
return new APIError(error58.status ?? 0, error58.error, error58.message, headers);
|
|
296621
296621
|
}
|
|
296622
|
+
if (error58 instanceof Error) {
|
|
296623
|
+
const chatRagCode = inferChatRagCodeFromApiError(error58.message);
|
|
296624
|
+
if (chatRagCode) {
|
|
296625
|
+
const nonRetryableCodes = [
|
|
296626
|
+
CHAT_RAG_ERR_CODES.ContextExceeded,
|
|
296627
|
+
CHAT_RAG_ERR_CODES.Unauthorized,
|
|
296628
|
+
CHAT_RAG_ERR_CODES.EmptyMessageContent
|
|
296629
|
+
];
|
|
296630
|
+
if (!nonRetryableCodes.includes(chatRagCode)) {
|
|
296631
|
+
const headers = new Headers;
|
|
296632
|
+
headers.set("x-chat-rag-code", chatRagCode);
|
|
296633
|
+
return new APIError(503, {}, error58.message, headers);
|
|
296634
|
+
}
|
|
296635
|
+
}
|
|
296636
|
+
if (isStreamNetworkError(error58.message)) {
|
|
296637
|
+
return new APIConnectionError({ cause: error58 });
|
|
296638
|
+
}
|
|
296639
|
+
}
|
|
296622
296640
|
return error58;
|
|
296623
296641
|
}
|
|
296642
|
+
function isStreamNetworkError(message2) {
|
|
296643
|
+
const lower = message2.toLowerCase();
|
|
296644
|
+
return lower.includes("connection reset") || lower.includes("connection error") || lower.includes("network error") || lower.includes("network connection") || lower.includes("network interrupt") || lower.includes("econnreset") || lower.includes("epipe") || lower.includes("etimedout") || lower.includes("fetch failed") || lower.includes("aborted") || lower.includes("broken pipe") || lower.includes("reset by peer") || lower.includes("unexpected end") || lower.includes("stream closed");
|
|
296645
|
+
}
|
|
296646
|
+
function isRetryableStreamError(error58) {
|
|
296647
|
+
if (error58 instanceof APIConnectionError) {
|
|
296648
|
+
return true;
|
|
296649
|
+
}
|
|
296650
|
+
if (error58 instanceof APIError) {
|
|
296651
|
+
const chatRagCode = getChatRagCode(error58);
|
|
296652
|
+
if (chatRagCode && isChatRagErrorCode(chatRagCode)) {
|
|
296653
|
+
const nonRetryableCodes = [
|
|
296654
|
+
CHAT_RAG_ERR_CODES.ContextExceeded,
|
|
296655
|
+
CHAT_RAG_ERR_CODES.Unauthorized,
|
|
296656
|
+
CHAT_RAG_ERR_CODES.EmptyMessageContent
|
|
296657
|
+
];
|
|
296658
|
+
return !nonRetryableCodes.includes(chatRagCode);
|
|
296659
|
+
}
|
|
296660
|
+
return error58.status === 429 || error58.status === 529 || (error58.status ?? 0) >= 500;
|
|
296661
|
+
}
|
|
296662
|
+
if (error58 instanceof Error) {
|
|
296663
|
+
const chatRagCode = inferChatRagCodeFromApiError(error58.message);
|
|
296664
|
+
if (chatRagCode) {
|
|
296665
|
+
const nonRetryableCodes = [
|
|
296666
|
+
CHAT_RAG_ERR_CODES.ContextExceeded,
|
|
296667
|
+
CHAT_RAG_ERR_CODES.Unauthorized,
|
|
296668
|
+
CHAT_RAG_ERR_CODES.EmptyMessageContent
|
|
296669
|
+
];
|
|
296670
|
+
return !nonRetryableCodes.includes(chatRagCode);
|
|
296671
|
+
}
|
|
296672
|
+
return isStreamNetworkError(error58.message);
|
|
296673
|
+
}
|
|
296674
|
+
return false;
|
|
296675
|
+
}
|
|
296624
296676
|
var CHAT_RAG_ERR_CODES;
|
|
296625
296677
|
var init_retry3 = __esm(() => {
|
|
296626
296678
|
init_sdk();
|
|
@@ -397124,7 +397176,7 @@ function getTelemetryAttributes() {
|
|
|
397124
397176
|
attributes["session.id"] = sessionId;
|
|
397125
397177
|
}
|
|
397126
397178
|
if (shouldIncludeAttribute("OTEL_METRICS_INCLUDE_VERSION")) {
|
|
397127
|
-
attributes["app.version"] = "4.2.8-
|
|
397179
|
+
attributes["app.version"] = "4.2.8-beta2";
|
|
397128
397180
|
}
|
|
397129
397181
|
const oauthAccount = getOauthAccountInfo();
|
|
397130
397182
|
if (oauthAccount) {
|
|
@@ -429579,7 +429631,7 @@ function initLangfuse() {
|
|
|
429579
429631
|
flushInterval: parseInt(process.env.LANGFUSE_FLUSH_INTERVAL ?? "10", 10),
|
|
429580
429632
|
mask: maskFn,
|
|
429581
429633
|
environment: process.env.LANGFUSE_TRACING_ENVIRONMENT ?? "development",
|
|
429582
|
-
release: "4.2.8-
|
|
429634
|
+
release: "4.2.8-beta2",
|
|
429583
429635
|
exportMode: process.env.LANGFUSE_EXPORT_MODE ?? "batched",
|
|
429584
429636
|
timeout: parseInt(process.env.LANGFUSE_TIMEOUT ?? "5", 10)
|
|
429585
429637
|
});
|
|
@@ -467815,7 +467867,7 @@ function initSentry() {
|
|
|
467815
467867
|
}
|
|
467816
467868
|
init3({
|
|
467817
467869
|
dsn,
|
|
467818
|
-
release: typeof MACRO !== "undefined" ? "4.2.8-
|
|
467870
|
+
release: typeof MACRO !== "undefined" ? "4.2.8-beta2" : undefined,
|
|
467819
467871
|
environment: typeof BUILD_ENV !== "undefined" ? BUILD_ENV : "production",
|
|
467820
467872
|
maxBreadcrumbs: 20,
|
|
467821
467873
|
sampleRate: 1,
|
|
@@ -495706,7 +495758,7 @@ async function initializeBetaTracing(resource) {
|
|
|
495706
495758
|
});
|
|
495707
495759
|
import_api_logs5.logs.setGlobalLoggerProvider(loggerProvider);
|
|
495708
495760
|
setLoggerProvider(loggerProvider);
|
|
495709
|
-
const eventLogger = import_api_logs5.logs.getLogger("com.anthropic.claude_code.events", "4.2.8-
|
|
495761
|
+
const eventLogger = import_api_logs5.logs.getLogger("com.anthropic.claude_code.events", "4.2.8-beta2");
|
|
495710
495762
|
setEventLogger(eventLogger);
|
|
495711
495763
|
process.on("beforeExit", async () => {
|
|
495712
495764
|
await loggerProvider?.forceFlush();
|
|
@@ -495746,7 +495798,7 @@ async function initializeTelemetry() {
|
|
|
495746
495798
|
const platform5 = getPlatform();
|
|
495747
495799
|
const baseAttributes = {
|
|
495748
495800
|
[import_semantic_conventions14.ATTR_SERVICE_NAME]: "claude-code",
|
|
495749
|
-
[import_semantic_conventions14.ATTR_SERVICE_VERSION]: "4.2.8-
|
|
495801
|
+
[import_semantic_conventions14.ATTR_SERVICE_VERSION]: "4.2.8-beta2"
|
|
495750
495802
|
};
|
|
495751
495803
|
if (platform5 === "wsl") {
|
|
495752
495804
|
const wslVersion = getWslVersion();
|
|
@@ -495791,7 +495843,7 @@ async function initializeTelemetry() {
|
|
|
495791
495843
|
} catch {}
|
|
495792
495844
|
};
|
|
495793
495845
|
registerCleanup(shutdownTelemetry2);
|
|
495794
|
-
return meterProvider2.getMeter("com.anthropic.claude_code", "4.2.8-
|
|
495846
|
+
return meterProvider2.getMeter("com.anthropic.claude_code", "4.2.8-beta2");
|
|
495795
495847
|
}
|
|
495796
495848
|
const meterProvider = new import_sdk_metrics2.MeterProvider({
|
|
495797
495849
|
resource,
|
|
@@ -495811,7 +495863,7 @@ async function initializeTelemetry() {
|
|
|
495811
495863
|
});
|
|
495812
495864
|
import_api_logs5.logs.setGlobalLoggerProvider(loggerProvider);
|
|
495813
495865
|
setLoggerProvider(loggerProvider);
|
|
495814
|
-
const eventLogger = import_api_logs5.logs.getLogger("com.anthropic.claude_code.events", "4.2.8-
|
|
495866
|
+
const eventLogger = import_api_logs5.logs.getLogger("com.anthropic.claude_code.events", "4.2.8-beta2");
|
|
495815
495867
|
setEventLogger(eventLogger);
|
|
495816
495868
|
logForDebugging("[3P telemetry] Event logger set successfully");
|
|
495817
495869
|
process.on("beforeExit", async () => {
|
|
@@ -495873,7 +495925,7 @@ Current timeout: ${timeoutMs}ms
|
|
|
495873
495925
|
}
|
|
495874
495926
|
};
|
|
495875
495927
|
registerCleanup(shutdownTelemetry);
|
|
495876
|
-
return meterProvider.getMeter("com.anthropic.claude_code", "4.2.8-
|
|
495928
|
+
return meterProvider.getMeter("com.anthropic.claude_code", "4.2.8-beta2");
|
|
495877
495929
|
}
|
|
495878
495930
|
async function flushTelemetry() {
|
|
495879
495931
|
const meterProvider = getMeterProvider();
|
|
@@ -496932,7 +496984,7 @@ async function installGlobalPackage(specificVersion) {
|
|
|
496932
496984
|
logError3(new AutoUpdaterError("Another process is currently installing an update"));
|
|
496933
496985
|
logEvent("tengu_auto_updater_lock_contention", {
|
|
496934
496986
|
pid: process.pid,
|
|
496935
|
-
currentVersion: "4.2.8-
|
|
496987
|
+
currentVersion: "4.2.8-beta2"
|
|
496936
496988
|
});
|
|
496937
496989
|
return { status: "in_progress" };
|
|
496938
496990
|
}
|
|
@@ -496941,7 +496993,7 @@ async function installGlobalPackage(specificVersion) {
|
|
|
496941
496993
|
if (!env4.isRunningWithBun() && env4.isNpmFromWindowsPath()) {
|
|
496942
496994
|
logError3(new Error("Windows NPM detected in WSL environment"));
|
|
496943
496995
|
logEvent("tengu_auto_updater_windows_npm_in_wsl", {
|
|
496944
|
-
currentVersion: "4.2.8-
|
|
496996
|
+
currentVersion: "4.2.8-beta2"
|
|
496945
496997
|
});
|
|
496946
496998
|
return {
|
|
496947
496999
|
status: "install_failed",
|
|
@@ -497487,7 +497539,7 @@ function detectLinuxGlobPatternWarnings() {
|
|
|
497487
497539
|
}
|
|
497488
497540
|
async function getDoctorDiagnostic() {
|
|
497489
497541
|
const installationType = await getCurrentInstallationType();
|
|
497490
|
-
const version7 = typeof MACRO !== "undefined" ? "4.2.8-
|
|
497542
|
+
const version7 = typeof MACRO !== "undefined" ? "4.2.8-beta2" : "unknown";
|
|
497491
497543
|
const installationPath = await getInstallationPath();
|
|
497492
497544
|
const invokedBinary = getInvokedBinary();
|
|
497493
497545
|
const multipleInstallations = await detectMultipleInstallations();
|
|
@@ -535643,7 +535695,7 @@ async function setupSdkMcpClients(sdkMcpConfigs, sendMcpMessage) {
|
|
|
535643
535695
|
const client8 = new Client3({
|
|
535644
535696
|
name: "claude-code",
|
|
535645
535697
|
title: "CoStrict",
|
|
535646
|
-
version: "4.2.8-
|
|
535698
|
+
version: "4.2.8-beta2",
|
|
535647
535699
|
description: "CoStrict agentic coding tool",
|
|
535648
535700
|
websiteUrl: PRODUCT_URL
|
|
535649
535701
|
}, {
|
|
@@ -536014,7 +536066,7 @@ var init_client17 = __esm(() => {
|
|
|
536014
536066
|
const client8 = new Client3({
|
|
536015
536067
|
name: "claude-code",
|
|
536016
536068
|
title: "CoStrict",
|
|
536017
|
-
version: "4.2.8-
|
|
536069
|
+
version: "4.2.8-beta2",
|
|
536018
536070
|
description: "CoStrict agentic coding tool",
|
|
536019
536071
|
websiteUrl: PRODUCT_URL
|
|
536020
536072
|
}, {
|
|
@@ -537392,7 +537444,7 @@ function getInstallationEnv() {
|
|
|
537392
537444
|
return;
|
|
537393
537445
|
}
|
|
537394
537446
|
function getClaudeCodeVersion() {
|
|
537395
|
-
return "4.2.8-
|
|
537447
|
+
return "4.2.8-beta2";
|
|
537396
537448
|
}
|
|
537397
537449
|
async function getInstalledVSCodeExtensionVersion(command4) {
|
|
537398
537450
|
const { stdout } = await execFileNoThrow2(command4, ["--list-extensions", "--show-versions"], {
|
|
@@ -538756,8 +538808,8 @@ async function updateLatest(channelOrVersion, forceReinstall = false) {
|
|
|
538756
538808
|
const maxVersion = await getMaxVersion();
|
|
538757
538809
|
if (maxVersion && gt(version8, maxVersion)) {
|
|
538758
538810
|
logForDebugging(`Native installer: maxVersion ${maxVersion} is set, capping update from ${version8} to ${maxVersion}`);
|
|
538759
|
-
if (gte2("4.2.8-
|
|
538760
|
-
logForDebugging(`Native installer: current version ${"4.2.8-
|
|
538811
|
+
if (gte2("4.2.8-beta2", maxVersion)) {
|
|
538812
|
+
logForDebugging(`Native installer: current version ${"4.2.8-beta2"} is already at or above maxVersion ${maxVersion}, skipping update`);
|
|
538761
538813
|
logEvent("tengu_native_update_skipped_max_version", {
|
|
538762
538814
|
latency_ms: Date.now() - startTime2,
|
|
538763
538815
|
max_version: maxVersion,
|
|
@@ -538768,7 +538820,7 @@ async function updateLatest(channelOrVersion, forceReinstall = false) {
|
|
|
538768
538820
|
version8 = maxVersion;
|
|
538769
538821
|
}
|
|
538770
538822
|
}
|
|
538771
|
-
if (!forceReinstall && version8 === "4.2.8-
|
|
538823
|
+
if (!forceReinstall && version8 === "4.2.8-beta2" && await versionIsAvailable(version8) && await isPossibleClaudeBinary(executablePath)) {
|
|
538772
538824
|
logForDebugging(`Found ${version8} at ${executablePath}, skipping install`);
|
|
538773
538825
|
logEvent("tengu_native_update_complete", {
|
|
538774
538826
|
latency_ms: Date.now() - startTime2,
|
|
@@ -645682,6 +645734,7 @@ async function isParentAlive() {
|
|
|
645682
645734
|
return true;
|
|
645683
645735
|
}
|
|
645684
645736
|
function startBatchWorker() {
|
|
645737
|
+
process.title = "csc_batch_worker";
|
|
645685
645738
|
log12.info("batch worker started");
|
|
645686
645739
|
loadAllState().then(() => {
|
|
645687
645740
|
stateLoaded = true;
|
|
@@ -673038,7 +673091,7 @@ function Feedback({
|
|
|
673038
673091
|
platform: env4.platform,
|
|
673039
673092
|
gitRepo: envInfo.isGit,
|
|
673040
673093
|
terminal: env4.terminal,
|
|
673041
|
-
version: "4.2.8-
|
|
673094
|
+
version: "4.2.8-beta2",
|
|
673042
673095
|
transcript: normalizeMessagesForAPI(messages),
|
|
673043
673096
|
errors: sanitizedErrors,
|
|
673044
673097
|
lastApiRequest: getLastAPIRequest(),
|
|
@@ -673221,7 +673274,7 @@ function Feedback({
|
|
|
673221
673274
|
", ",
|
|
673222
673275
|
env4.terminal,
|
|
673223
673276
|
", v",
|
|
673224
|
-
"4.2.8-
|
|
673277
|
+
"4.2.8-beta2"
|
|
673225
673278
|
]
|
|
673226
673279
|
})
|
|
673227
673280
|
]
|
|
@@ -673318,7 +673371,7 @@ ${sanitizedDescription}
|
|
|
673318
673371
|
` + `**Environment Info**
|
|
673319
673372
|
` + `- Platform: ${env4.platform}
|
|
673320
673373
|
` + `- Terminal: ${env4.terminal}
|
|
673321
|
-
` + `- Version: ${"4.2.8-
|
|
673374
|
+
` + `- Version: ${"4.2.8-beta2"}
|
|
673322
673375
|
` + `- Feedback ID: ${feedbackId}
|
|
673323
673376
|
` + `
|
|
673324
673377
|
**Errors**
|
|
@@ -675554,7 +675607,7 @@ function buildPrimarySection() {
|
|
|
675554
675607
|
children: t("settings.status.renameHint")
|
|
675555
675608
|
});
|
|
675556
675609
|
return [
|
|
675557
|
-
{ label: t("settings.status.version"), value: "4.2.8-
|
|
675610
|
+
{ label: t("settings.status.version"), value: "4.2.8-beta2" },
|
|
675558
675611
|
{ label: t("settings.status.sessionName"), value: nameValue },
|
|
675559
675612
|
{ label: t("settings.status.sessionId"), value: sessionId },
|
|
675560
675613
|
{ label: t("settings.status.cwd"), value: getCwd() },
|
|
@@ -678376,7 +678429,7 @@ function Config({
|
|
|
678376
678429
|
}
|
|
678377
678430
|
})
|
|
678378
678431
|
}) : showSubmenu === "ChannelDowngrade" ? /* @__PURE__ */ jsx_runtime190.jsx(ChannelDowngradeDialog, {
|
|
678379
|
-
currentVersion: "4.2.8-
|
|
678432
|
+
currentVersion: "4.2.8-beta2",
|
|
678380
678433
|
onChoice: (choice) => {
|
|
678381
678434
|
setShowSubmenu(null);
|
|
678382
678435
|
setTabsHidden(false);
|
|
@@ -678388,7 +678441,7 @@ function Config({
|
|
|
678388
678441
|
autoUpdatesChannel: "stable"
|
|
678389
678442
|
};
|
|
678390
678443
|
if (choice === "stay") {
|
|
678391
|
-
newSettings.minimumVersion = "4.2.8-
|
|
678444
|
+
newSettings.minimumVersion = "4.2.8-beta2";
|
|
678392
678445
|
}
|
|
678393
678446
|
updateSettingsForSource("userSettings", newSettings);
|
|
678394
678447
|
setSettingsData((prev) => ({
|
|
@@ -683857,7 +683910,7 @@ function HelpV2({ onClose, commands: commands7 }) {
|
|
|
683857
683910
|
color: "professionalBlue",
|
|
683858
683911
|
children: [
|
|
683859
683912
|
/* @__PURE__ */ jsx_runtime217.jsx(Tabs, {
|
|
683860
|
-
title: process.env.USER_TYPE === "sf" ? "/help" : `CoStrict v${"4.2.8-
|
|
683913
|
+
title: process.env.USER_TYPE === "sf" ? "/help" : `CoStrict v${"4.2.8-beta2"}`,
|
|
683861
683914
|
color: "professionalBlue",
|
|
683862
683915
|
defaultTab: "general",
|
|
683863
683916
|
children: tabs
|
|
@@ -774455,7 +774508,7 @@ function getAllReleaseNotes(changelogContent = getStoredChangelogFromMemory()) {
|
|
|
774455
774508
|
return [];
|
|
774456
774509
|
}
|
|
774457
774510
|
}
|
|
774458
|
-
async function checkForReleaseNotes(lastSeenVersion, currentVersion = "4.2.8-
|
|
774511
|
+
async function checkForReleaseNotes(lastSeenVersion, currentVersion = "4.2.8-beta2") {
|
|
774459
774512
|
if (process.env.USER_TYPE === "sf") {
|
|
774460
774513
|
const changelog = "";
|
|
774461
774514
|
if (changelog) {
|
|
@@ -774482,7 +774535,7 @@ async function checkForReleaseNotes(lastSeenVersion, currentVersion = "4.2.8-bet
|
|
|
774482
774535
|
releaseNotes
|
|
774483
774536
|
};
|
|
774484
774537
|
}
|
|
774485
|
-
function checkForReleaseNotesSync(lastSeenVersion, currentVersion = "4.2.8-
|
|
774538
|
+
function checkForReleaseNotesSync(lastSeenVersion, currentVersion = "4.2.8-beta2") {
|
|
774486
774539
|
if (process.env.USER_TYPE === "sf") {
|
|
774487
774540
|
const changelog = "";
|
|
774488
774541
|
if (changelog) {
|
|
@@ -777243,7 +777296,7 @@ function isNotLoggedIn() {
|
|
|
777243
777296
|
return true;
|
|
777244
777297
|
}
|
|
777245
777298
|
function getLogoDisplayData() {
|
|
777246
|
-
const version8 = process.env.DEMO_VERSION ?? "4.2.8-
|
|
777299
|
+
const version8 = process.env.DEMO_VERSION ?? "4.2.8-beta2";
|
|
777247
777300
|
const serverUrl = getDirectConnectServerUrl();
|
|
777248
777301
|
const displayPath = process.env.DEMO_VERSION ? "/code/claude" : getDisplayPath(getCwd());
|
|
777249
777302
|
const cwd2 = serverUrl ? `${displayPath} in ${serverUrl.replace(/^https?:\/\//, "")}` : displayPath;
|
|
@@ -777821,7 +777874,7 @@ var init_MatrixMessageLine = __esm(() => {
|
|
|
777821
777874
|
// src/components/matrix-tactical/MatrixWelcome.tsx
|
|
777822
777875
|
import { basename as basename47 } from "path";
|
|
777823
777876
|
function MatrixWelcome({
|
|
777824
|
-
version: version8 = "4.2.8-
|
|
777877
|
+
version: version8 = "4.2.8-beta2",
|
|
777825
777878
|
projectName,
|
|
777826
777879
|
cwd: cwd2,
|
|
777827
777880
|
modelDisplayName,
|
|
@@ -778456,13 +778509,13 @@ function LogoV2() {
|
|
|
778456
778509
|
const { hasReleaseNotes } = checkForReleaseNotesSync(config11.lastReleaseNotesSeen);
|
|
778457
778510
|
import_react167.useEffect(() => {
|
|
778458
778511
|
const currentConfig = getGlobalConfig();
|
|
778459
|
-
if (currentConfig.lastReleaseNotesSeen === "4.2.8-
|
|
778512
|
+
if (currentConfig.lastReleaseNotesSeen === "4.2.8-beta2") {
|
|
778460
778513
|
return;
|
|
778461
778514
|
}
|
|
778462
778515
|
saveGlobalConfig((current2) => {
|
|
778463
|
-
if (current2.lastReleaseNotesSeen === "4.2.8-
|
|
778516
|
+
if (current2.lastReleaseNotesSeen === "4.2.8-beta2")
|
|
778464
778517
|
return current2;
|
|
778465
|
-
return { ...current2, lastReleaseNotesSeen: "4.2.8-
|
|
778518
|
+
return { ...current2, lastReleaseNotesSeen: "4.2.8-beta2" };
|
|
778466
778519
|
});
|
|
778467
778520
|
if (showOnboarding) {
|
|
778468
778521
|
incrementProjectOnboardingSeenCount();
|
|
@@ -800400,7 +800453,7 @@ async function captureMemoryDiagnostics(trigger, dumpNumber = 0) {
|
|
|
800400
800453
|
smapsRollup,
|
|
800401
800454
|
platform: process.platform,
|
|
800402
800455
|
nodeVersion: process.version,
|
|
800403
|
-
ccVersion: "4.2.8-
|
|
800456
|
+
ccVersion: "4.2.8-beta2"
|
|
800404
800457
|
};
|
|
800405
800458
|
}
|
|
800406
800459
|
async function performHeapDump(trigger = "manual", dumpNumber = 0) {
|
|
@@ -800516,7 +800569,7 @@ var init_mock_limits = __esm(() => {
|
|
|
800516
800569
|
var call54 = async () => {
|
|
800517
800570
|
return {
|
|
800518
800571
|
type: "text",
|
|
800519
|
-
value: `${"4.2.8-
|
|
800572
|
+
value: `${"4.2.8-beta2"} (built ${"2026-07-01T02:28:03.350Z"})`
|
|
800520
800573
|
};
|
|
800521
800574
|
}, version8, version_default;
|
|
800522
800575
|
var init_version2 = __esm(() => {
|
|
@@ -806934,8 +806987,8 @@ var init_tag2 = __esm(() => {
|
|
|
806934
806987
|
import { createRequire as createRequire4 } from "module";
|
|
806935
806988
|
function getVersion2() {
|
|
806936
806989
|
try {
|
|
806937
|
-
if (typeof MACRO !== "undefined" && "4.2.8-
|
|
806938
|
-
return "4.2.8-
|
|
806990
|
+
if (typeof MACRO !== "undefined" && "4.2.8-beta2")
|
|
806991
|
+
return "4.2.8-beta2";
|
|
806939
806992
|
} catch {}
|
|
806940
806993
|
try {
|
|
806941
806994
|
const require3 = createRequire4(import.meta.url);
|
|
@@ -806945,6 +806998,32 @@ function getVersion2() {
|
|
|
806945
806998
|
return "1.0.0";
|
|
806946
806999
|
}
|
|
806947
807000
|
}
|
|
807001
|
+
function isRecord5(value) {
|
|
807002
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
807003
|
+
}
|
|
807004
|
+
async function normalizeGatewayErrorResponse(response3) {
|
|
807005
|
+
if (response3.status >= 400) {
|
|
807006
|
+
return response3;
|
|
807007
|
+
}
|
|
807008
|
+
const contentType = response3.headers.get("content-type") ?? "";
|
|
807009
|
+
if (contentType.includes("text/event-stream")) {
|
|
807010
|
+
return response3;
|
|
807011
|
+
}
|
|
807012
|
+
let body;
|
|
807013
|
+
try {
|
|
807014
|
+
body = await response3.clone().json();
|
|
807015
|
+
} catch {
|
|
807016
|
+
return response3;
|
|
807017
|
+
}
|
|
807018
|
+
if (isRecord5(body) && Array.isArray(body.error) && body.error.length > 0 && isRecord5(body.error[0]) && typeof body.error[0].ApiError === "string") {
|
|
807019
|
+
return new Response(response3.body, {
|
|
807020
|
+
status: 503,
|
|
807021
|
+
statusText: "CoStrict Gateway Error",
|
|
807022
|
+
headers: response3.headers
|
|
807023
|
+
});
|
|
807024
|
+
}
|
|
807025
|
+
return response3;
|
|
807026
|
+
}
|
|
806948
807027
|
function toKebabCase(s) {
|
|
806949
807028
|
if (!s)
|
|
806950
807029
|
return;
|
|
@@ -806986,7 +807065,8 @@ function createCoStrictFetch(options) {
|
|
|
806986
807065
|
headers.set("agent-type", agentType);
|
|
806987
807066
|
headers.set("zgsm-client-id", creds.machine_id);
|
|
806988
807067
|
headers.set("zgsm-client-ide", "cli");
|
|
806989
|
-
const
|
|
807068
|
+
const rawResponse = await fetch(input4, { ...init4, headers });
|
|
807069
|
+
const response3 = await normalizeGatewayErrorResponse(rawResponse);
|
|
806990
807070
|
if (response3.status === 401 && creds.refresh_token) {
|
|
806991
807071
|
try {
|
|
806992
807072
|
const refreshed2 = await refreshCoStrictToken({
|
|
@@ -817245,7 +817325,7 @@ function generateHtmlReport(data, insights) {
|
|
|
817245
817325
|
</html>`;
|
|
817246
817326
|
}
|
|
817247
817327
|
function buildExportData(data, insights, facets, remoteStats) {
|
|
817248
|
-
const version9 = typeof MACRO !== "undefined" ? "4.2.8-
|
|
817328
|
+
const version9 = typeof MACRO !== "undefined" ? "4.2.8-beta2" : "unknown";
|
|
817249
817329
|
const remote_hosts_collected = remoteStats?.hosts.filter((h5) => h5.sessionCount > 0).map((h5) => h5.name);
|
|
817250
817330
|
const facets_summary = {
|
|
817251
817331
|
total: facets.size,
|
|
@@ -821559,7 +821639,7 @@ var init_sessionStorage = __esm(() => {
|
|
|
821559
821639
|
init_settings2();
|
|
821560
821640
|
init_slowOperations();
|
|
821561
821641
|
init_uuid();
|
|
821562
|
-
VERSION10 = typeof MACRO !== "undefined" ? "4.2.8-
|
|
821642
|
+
VERSION10 = typeof MACRO !== "undefined" ? "4.2.8-beta2" : "unknown";
|
|
821563
821643
|
MAX_TOMBSTONE_REWRITE_BYTES = 50 * 1024 * 1024;
|
|
821564
821644
|
SKIP_FIRST_PROMPT_PATTERN2 = /^(?:\s*<[a-z][\w-]*[\s>]|\[Request interrupted by user[^\]]*\])/;
|
|
821565
821645
|
EPHEMERAL_PROGRESS_TYPES = new Set([
|
|
@@ -822900,7 +822980,7 @@ var init_filesystem = __esm(() => {
|
|
|
822900
822980
|
});
|
|
822901
822981
|
getBundledSkillsRoot = memoize_default(function getBundledSkillsRoot2() {
|
|
822902
822982
|
const nonce = randomBytes24(16).toString("hex");
|
|
822903
|
-
return join195(getCostrictTempDir(), "bundled-skills", "4.2.8-
|
|
822983
|
+
return join195(getCostrictTempDir(), "bundled-skills", "4.2.8-beta2", nonce);
|
|
822904
822984
|
});
|
|
822905
822985
|
getResolvedWorkingDirPaths = memoize_default(getPathsForPermissionCheck);
|
|
822906
822986
|
});
|
|
@@ -829098,7 +829178,7 @@ function computeFingerprint(messageText, version9) {
|
|
|
829098
829178
|
}
|
|
829099
829179
|
function computeFingerprintFromMessages(messages) {
|
|
829100
829180
|
const firstMessageText = extractFirstMessageText(messages);
|
|
829101
|
-
return computeFingerprint(firstMessageText, "4.2.8-
|
|
829181
|
+
return computeFingerprint(firstMessageText, "4.2.8-beta2");
|
|
829102
829182
|
}
|
|
829103
829183
|
var FINGERPRINT_SALT = "59cf53e54c78";
|
|
829104
829184
|
var init_fingerprint = () => {};
|
|
@@ -829240,20 +829320,20 @@ function isLangfuseRole(value) {
|
|
|
829240
829320
|
return false;
|
|
829241
829321
|
}
|
|
829242
829322
|
}
|
|
829243
|
-
function
|
|
829323
|
+
function isRecord6(value) {
|
|
829244
829324
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
829245
829325
|
}
|
|
829246
829326
|
function isLangfuseToolCall(value) {
|
|
829247
|
-
if (!
|
|
829327
|
+
if (!isRecord6(value))
|
|
829248
829328
|
return false;
|
|
829249
829329
|
const fn = value.function;
|
|
829250
|
-
return typeof value.id === "string" && value.type === "function" &&
|
|
829330
|
+
return typeof value.id === "string" && value.type === "function" && isRecord6(fn) && typeof fn.name === "string" && typeof fn.arguments === "string";
|
|
829251
829331
|
}
|
|
829252
829332
|
function getToolCalls(value) {
|
|
829253
829333
|
return Array.isArray(value) ? value.filter(isLangfuseToolCall) : [];
|
|
829254
829334
|
}
|
|
829255
829335
|
function getContentToolCalls(content) {
|
|
829256
|
-
return content.flatMap((block) =>
|
|
829336
|
+
return content.flatMap((block) => isRecord6(block) ? getToolCalls(block.tool_calls) : []);
|
|
829257
829337
|
}
|
|
829258
829338
|
function mergeToolCalls(...groups) {
|
|
829259
829339
|
const merged = new Map;
|
|
@@ -829376,10 +829456,10 @@ function convertMessagesToLangfuse(messages, systemPrompt2) {
|
|
|
829376
829456
|
}
|
|
829377
829457
|
}
|
|
829378
829458
|
for (const msg of messages) {
|
|
829379
|
-
if (!
|
|
829459
|
+
if (!isRecord6(msg))
|
|
829380
829460
|
continue;
|
|
829381
829461
|
const wrappedMessage = msg.message;
|
|
829382
|
-
const isWrappedMessage =
|
|
829462
|
+
const isWrappedMessage = isRecord6(wrappedMessage);
|
|
829383
829463
|
const inner = isWrappedMessage ? wrappedMessage : msg;
|
|
829384
829464
|
const role = isLangfuseRole(inner.role) ? inner.role : isWrappedMessage ? toRoleFromWrappedMessage(msg) : "user";
|
|
829385
829465
|
const rawContent2 = inner.content;
|
|
@@ -829508,7 +829588,7 @@ function getAnthropicEnvMetadata() {
|
|
|
829508
829588
|
function getBuildAgeMinutes() {
|
|
829509
829589
|
if (false)
|
|
829510
829590
|
;
|
|
829511
|
-
const buildTime = new Date("2026-
|
|
829591
|
+
const buildTime = new Date("2026-07-01T02:28:03.350Z").getTime();
|
|
829512
829592
|
if (isNaN(buildTime))
|
|
829513
829593
|
return;
|
|
829514
829594
|
return Math.floor((Date.now() - buildTime) / 60000);
|
|
@@ -830065,6 +830145,168 @@ var init_client18 = __esm(() => {
|
|
|
830065
830145
|
init_state();
|
|
830066
830146
|
});
|
|
830067
830147
|
|
|
830148
|
+
// src/services/api/openai/nonStreamingFallback.ts
|
|
830149
|
+
import { randomUUID as randomUUID50 } from "crypto";
|
|
830150
|
+
function mapFinishReason2(reason) {
|
|
830151
|
+
switch (reason) {
|
|
830152
|
+
case "stop":
|
|
830153
|
+
return "end_turn";
|
|
830154
|
+
case "tool_calls":
|
|
830155
|
+
return "tool_use";
|
|
830156
|
+
case "length":
|
|
830157
|
+
return "max_tokens";
|
|
830158
|
+
case "content_filter":
|
|
830159
|
+
return "end_turn";
|
|
830160
|
+
default:
|
|
830161
|
+
return "end_turn";
|
|
830162
|
+
}
|
|
830163
|
+
}
|
|
830164
|
+
function extractReasoning2(message2) {
|
|
830165
|
+
const anyMessage = message2;
|
|
830166
|
+
if (typeof anyMessage.reasoning_content === "string") {
|
|
830167
|
+
return anyMessage.reasoning_content;
|
|
830168
|
+
}
|
|
830169
|
+
if (typeof anyMessage.reasoning === "string") {
|
|
830170
|
+
return anyMessage.reasoning;
|
|
830171
|
+
}
|
|
830172
|
+
if (Array.isArray(anyMessage.reasoning_details) && anyMessage.reasoning_details.length > 0) {
|
|
830173
|
+
return anyMessage.reasoning_details.filter((d4) => d4 != null && typeof d4.text === "string").map((d4) => d4.text).join("");
|
|
830174
|
+
}
|
|
830175
|
+
return;
|
|
830176
|
+
}
|
|
830177
|
+
async function* adaptOpenAICompletionToAnthropicStream(completion) {
|
|
830178
|
+
const choice = completion.choices?.[0];
|
|
830179
|
+
if (!choice)
|
|
830180
|
+
return;
|
|
830181
|
+
const message2 = choice.message;
|
|
830182
|
+
const messageId = completion.id || `msg_${randomUUID50().replace(/-/g, "").slice(0, 24)}`;
|
|
830183
|
+
const usage2 = completion.usage;
|
|
830184
|
+
yield {
|
|
830185
|
+
type: "message_start",
|
|
830186
|
+
message: {
|
|
830187
|
+
id: messageId,
|
|
830188
|
+
type: "message",
|
|
830189
|
+
role: "assistant",
|
|
830190
|
+
content: [],
|
|
830191
|
+
model: completion.model,
|
|
830192
|
+
stop_reason: null,
|
|
830193
|
+
stop_sequence: null,
|
|
830194
|
+
usage: {
|
|
830195
|
+
input_tokens: usage2?.prompt_tokens ?? 0,
|
|
830196
|
+
output_tokens: 0,
|
|
830197
|
+
cache_creation_input_tokens: 0,
|
|
830198
|
+
cache_read_input_tokens: usage2?.prompt_tokens_details?.cached_tokens ?? 0
|
|
830199
|
+
}
|
|
830200
|
+
}
|
|
830201
|
+
};
|
|
830202
|
+
let currentIndex = -1;
|
|
830203
|
+
const reasoning = extractReasoning2(message2);
|
|
830204
|
+
if (reasoning != null && reasoning !== "") {
|
|
830205
|
+
currentIndex++;
|
|
830206
|
+
yield {
|
|
830207
|
+
type: "content_block_start",
|
|
830208
|
+
index: currentIndex,
|
|
830209
|
+
content_block: {
|
|
830210
|
+
type: "thinking",
|
|
830211
|
+
thinking: "",
|
|
830212
|
+
signature: ""
|
|
830213
|
+
}
|
|
830214
|
+
};
|
|
830215
|
+
yield {
|
|
830216
|
+
type: "content_block_delta",
|
|
830217
|
+
index: currentIndex,
|
|
830218
|
+
delta: {
|
|
830219
|
+
type: "thinking_delta",
|
|
830220
|
+
thinking: reasoning
|
|
830221
|
+
}
|
|
830222
|
+
};
|
|
830223
|
+
yield {
|
|
830224
|
+
type: "content_block_stop",
|
|
830225
|
+
index: currentIndex
|
|
830226
|
+
};
|
|
830227
|
+
}
|
|
830228
|
+
if (typeof message2.content === "string" && message2.content) {
|
|
830229
|
+
currentIndex++;
|
|
830230
|
+
yield {
|
|
830231
|
+
type: "content_block_start",
|
|
830232
|
+
index: currentIndex,
|
|
830233
|
+
content_block: {
|
|
830234
|
+
type: "text",
|
|
830235
|
+
text: ""
|
|
830236
|
+
}
|
|
830237
|
+
};
|
|
830238
|
+
yield {
|
|
830239
|
+
type: "content_block_delta",
|
|
830240
|
+
index: currentIndex,
|
|
830241
|
+
delta: {
|
|
830242
|
+
type: "text_delta",
|
|
830243
|
+
text: message2.content
|
|
830244
|
+
}
|
|
830245
|
+
};
|
|
830246
|
+
yield {
|
|
830247
|
+
type: "content_block_stop",
|
|
830248
|
+
index: currentIndex
|
|
830249
|
+
};
|
|
830250
|
+
}
|
|
830251
|
+
if (message2.tool_calls) {
|
|
830252
|
+
for (const toolCall of message2.tool_calls) {
|
|
830253
|
+
const toolCallFn = toolCall;
|
|
830254
|
+
currentIndex++;
|
|
830255
|
+
yield {
|
|
830256
|
+
type: "content_block_start",
|
|
830257
|
+
index: currentIndex,
|
|
830258
|
+
content_block: {
|
|
830259
|
+
type: "tool_use",
|
|
830260
|
+
id: toolCallFn.id || `toolu_${randomUUID50().replace(/-/g, "").slice(0, 24)}`,
|
|
830261
|
+
name: toolCallFn.function?.name || "",
|
|
830262
|
+
input: {}
|
|
830263
|
+
}
|
|
830264
|
+
};
|
|
830265
|
+
const args = toolCallFn.function?.arguments;
|
|
830266
|
+
if (args) {
|
|
830267
|
+
yield {
|
|
830268
|
+
type: "content_block_delta",
|
|
830269
|
+
index: currentIndex,
|
|
830270
|
+
delta: {
|
|
830271
|
+
type: "input_json_delta",
|
|
830272
|
+
partial_json: args
|
|
830273
|
+
}
|
|
830274
|
+
};
|
|
830275
|
+
}
|
|
830276
|
+
yield {
|
|
830277
|
+
type: "content_block_stop",
|
|
830278
|
+
index: currentIndex
|
|
830279
|
+
};
|
|
830280
|
+
}
|
|
830281
|
+
}
|
|
830282
|
+
const stopReason = mapFinishReason2(choice.finish_reason);
|
|
830283
|
+
yield {
|
|
830284
|
+
type: "message_delta",
|
|
830285
|
+
delta: {
|
|
830286
|
+
stop_reason: stopReason,
|
|
830287
|
+
stop_sequence: null
|
|
830288
|
+
},
|
|
830289
|
+
usage: {
|
|
830290
|
+
input_tokens: usage2?.prompt_tokens ?? 0,
|
|
830291
|
+
output_tokens: usage2?.completion_tokens ?? 0,
|
|
830292
|
+
cache_read_input_tokens: usage2?.prompt_tokens_details?.cached_tokens ?? 0,
|
|
830293
|
+
cache_creation_input_tokens: 0
|
|
830294
|
+
}
|
|
830295
|
+
};
|
|
830296
|
+
yield {
|
|
830297
|
+
type: "message_stop"
|
|
830298
|
+
};
|
|
830299
|
+
}
|
|
830300
|
+
function toNonStreamingOpenAIRequestBody(requestBody) {
|
|
830301
|
+
const {
|
|
830302
|
+
stream: _stream,
|
|
830303
|
+
stream_options: _streamOptions,
|
|
830304
|
+
...rest
|
|
830305
|
+
} = requestBody;
|
|
830306
|
+
return rest;
|
|
830307
|
+
}
|
|
830308
|
+
var init_nonStreamingFallback = () => {};
|
|
830309
|
+
|
|
830068
830310
|
// src/services/api/openai/chatgptAuth.ts
|
|
830069
830311
|
import { chmod as chmod12, mkdir as mkdir63, readFile as readFile74, unlink as unlink30, writeFile as writeFile68 } from "fs/promises";
|
|
830070
830312
|
import { homedir as homedir47 } from "os";
|
|
@@ -830237,7 +830479,7 @@ var init_chatgptAuth = __esm(() => {
|
|
|
830237
830479
|
});
|
|
830238
830480
|
|
|
830239
830481
|
// src/services/api/openai/responsesAdapter.ts
|
|
830240
|
-
import { randomUUID as
|
|
830482
|
+
import { randomUUID as randomUUID51 } from "crypto";
|
|
830241
830483
|
function textFromContent2(content) {
|
|
830242
830484
|
if (typeof content === "string")
|
|
830243
830485
|
return content;
|
|
@@ -830435,7 +830677,7 @@ function mapStopReason(response3) {
|
|
|
830435
830677
|
return "end_turn";
|
|
830436
830678
|
}
|
|
830437
830679
|
async function* adaptResponsesStreamToAnthropic(stream6, model) {
|
|
830438
|
-
const messageId = `msg_${
|
|
830680
|
+
const messageId = `msg_${randomUUID51().replace(/-/gu, "").slice(0, 24)}`;
|
|
830439
830681
|
const toolBlocks = new Map;
|
|
830440
830682
|
let started = false;
|
|
830441
830683
|
let currentContentIndex = -1;
|
|
@@ -830708,7 +830950,7 @@ __export(exports_openai, {
|
|
|
830708
830950
|
isOpenAIThinkingEnabled: () => isOpenAIThinkingEnabled,
|
|
830709
830951
|
buildOpenAIRequestBody: () => buildOpenAIRequestBody
|
|
830710
830952
|
});
|
|
830711
|
-
import { randomUUID as
|
|
830953
|
+
import { randomUUID as randomUUID52 } from "crypto";
|
|
830712
830954
|
function convertToResponsesReasoningEffort(effortValue) {
|
|
830713
830955
|
if (effortValue === "low")
|
|
830714
830956
|
return "low";
|
|
@@ -830772,7 +831014,7 @@ function assembleFinalAssistantOutputs(params) {
|
|
|
830772
831014
|
},
|
|
830773
831015
|
requestId: undefined,
|
|
830774
831016
|
type: "assistant",
|
|
830775
|
-
uuid:
|
|
831017
|
+
uuid: randomUUID52(),
|
|
830776
831018
|
timestamp: new Date().toISOString()
|
|
830777
831019
|
});
|
|
830778
831020
|
} catch (error99) {
|
|
@@ -830792,6 +831034,198 @@ function assembleFinalAssistantOutputs(params) {
|
|
|
830792
831034
|
}
|
|
830793
831035
|
return outputs2;
|
|
830794
831036
|
}
|
|
831037
|
+
async function* getOpenAIStream(requestBody, options, signal) {
|
|
831038
|
+
const retryGenerator = withRetry(() => Promise.resolve(getOpenAIClient({
|
|
831039
|
+
maxRetries: 0,
|
|
831040
|
+
fetchOverride: options.fetchOverride,
|
|
831041
|
+
source: options.querySource,
|
|
831042
|
+
agentId: options.agentId,
|
|
831043
|
+
parentAgentId: options.parentAgentId
|
|
831044
|
+
})), async (client8, _attempt, _context2) => {
|
|
831045
|
+
try {
|
|
831046
|
+
return await client8.chat.completions.create(requestBody, { signal });
|
|
831047
|
+
} catch (err2) {
|
|
831048
|
+
throw wrapOpenAIErrorForRetry(err2);
|
|
831049
|
+
}
|
|
831050
|
+
}, {
|
|
831051
|
+
model: options.model,
|
|
831052
|
+
thinkingConfig: { type: "disabled" },
|
|
831053
|
+
signal,
|
|
831054
|
+
querySource: options.querySource
|
|
831055
|
+
});
|
|
831056
|
+
let e4 = await retryGenerator.next();
|
|
831057
|
+
while (!e4.done) {
|
|
831058
|
+
yield e4.value;
|
|
831059
|
+
e4 = await retryGenerator.next();
|
|
831060
|
+
}
|
|
831061
|
+
return e4.value;
|
|
831062
|
+
}
|
|
831063
|
+
async function* executeOpenAINonStreamingRequest(requestBody, options, signal) {
|
|
831064
|
+
const retryGenerator = withRetry(() => Promise.resolve(getOpenAIClient({
|
|
831065
|
+
maxRetries: 0,
|
|
831066
|
+
fetchOverride: options.fetchOverride,
|
|
831067
|
+
source: options.querySource,
|
|
831068
|
+
agentId: options.agentId,
|
|
831069
|
+
parentAgentId: options.parentAgentId
|
|
831070
|
+
})), async (client8, _attempt, _context2) => {
|
|
831071
|
+
try {
|
|
831072
|
+
return await client8.chat.completions.create(requestBody, { signal });
|
|
831073
|
+
} catch (err2) {
|
|
831074
|
+
throw wrapOpenAIErrorForRetry(err2);
|
|
831075
|
+
}
|
|
831076
|
+
}, {
|
|
831077
|
+
model: options.model,
|
|
831078
|
+
thinkingConfig: { type: "disabled" },
|
|
831079
|
+
signal,
|
|
831080
|
+
querySource: options.querySource
|
|
831081
|
+
});
|
|
831082
|
+
let e4 = await retryGenerator.next();
|
|
831083
|
+
while (!e4.done) {
|
|
831084
|
+
yield e4.value;
|
|
831085
|
+
e4 = await retryGenerator.next();
|
|
831086
|
+
}
|
|
831087
|
+
return e4.value;
|
|
831088
|
+
}
|
|
831089
|
+
async function* consumeOpenAIStream(adaptedStream, openaiModel, tools, options, maxTokens, openaiMessages, toolSchemas, enableThinking) {
|
|
831090
|
+
const contentBlocks = {};
|
|
831091
|
+
const collectedMessages = [];
|
|
831092
|
+
let partialMessage;
|
|
831093
|
+
let stopReason = null;
|
|
831094
|
+
let usage2 = {
|
|
831095
|
+
input_tokens: 0,
|
|
831096
|
+
output_tokens: 0,
|
|
831097
|
+
cache_creation_input_tokens: 0,
|
|
831098
|
+
cache_read_input_tokens: 0
|
|
831099
|
+
};
|
|
831100
|
+
let ttftMs = 0;
|
|
831101
|
+
const start = Date.now();
|
|
831102
|
+
try {
|
|
831103
|
+
for await (const event of adaptedStream) {
|
|
831104
|
+
switch (event.type) {
|
|
831105
|
+
case "message_start": {
|
|
831106
|
+
partialMessage = event.message;
|
|
831107
|
+
ttftMs = Date.now() - start;
|
|
831108
|
+
if (event.message?.usage) {
|
|
831109
|
+
usage2 = {
|
|
831110
|
+
...usage2,
|
|
831111
|
+
...event.message.usage
|
|
831112
|
+
};
|
|
831113
|
+
}
|
|
831114
|
+
break;
|
|
831115
|
+
}
|
|
831116
|
+
case "content_block_start": {
|
|
831117
|
+
const idx = event.index;
|
|
831118
|
+
const cb = event.content_block;
|
|
831119
|
+
if (cb.type === "tool_use") {
|
|
831120
|
+
contentBlocks[idx] = { ...cb, input: "" };
|
|
831121
|
+
} else if (cb.type === "text") {
|
|
831122
|
+
contentBlocks[idx] = { ...cb, text: "" };
|
|
831123
|
+
} else if (cb.type === "thinking") {
|
|
831124
|
+
contentBlocks[idx] = { ...cb, thinking: "", signature: "" };
|
|
831125
|
+
} else {
|
|
831126
|
+
contentBlocks[idx] = { ...cb };
|
|
831127
|
+
}
|
|
831128
|
+
break;
|
|
831129
|
+
}
|
|
831130
|
+
case "content_block_delta": {
|
|
831131
|
+
const idx = event.index;
|
|
831132
|
+
const delta = event.delta;
|
|
831133
|
+
const block = contentBlocks[idx];
|
|
831134
|
+
if (!block)
|
|
831135
|
+
break;
|
|
831136
|
+
if (delta.type === "text_delta") {
|
|
831137
|
+
block.text = (block.text || "") + delta.text;
|
|
831138
|
+
} else if (delta.type === "input_json_delta") {
|
|
831139
|
+
block.input = (block.input || "") + delta.partial_json;
|
|
831140
|
+
} else if (delta.type === "thinking_delta") {
|
|
831141
|
+
block.thinking = (block.thinking || "") + delta.thinking;
|
|
831142
|
+
} else if (delta.type === "signature_delta") {
|
|
831143
|
+
block.signature = delta.signature;
|
|
831144
|
+
}
|
|
831145
|
+
break;
|
|
831146
|
+
}
|
|
831147
|
+
case "content_block_stop": {
|
|
831148
|
+
break;
|
|
831149
|
+
}
|
|
831150
|
+
case "message_delta": {
|
|
831151
|
+
const deltaUsage = event.usage;
|
|
831152
|
+
if (deltaUsage) {
|
|
831153
|
+
usage2 = { ...usage2, ...deltaUsage };
|
|
831154
|
+
}
|
|
831155
|
+
if (event.delta?.stop_reason != null) {
|
|
831156
|
+
stopReason = event.delta.stop_reason;
|
|
831157
|
+
}
|
|
831158
|
+
break;
|
|
831159
|
+
}
|
|
831160
|
+
case "message_stop": {
|
|
831161
|
+
if (partialMessage) {
|
|
831162
|
+
for (const output of assembleFinalAssistantOutputs({
|
|
831163
|
+
partialMessage,
|
|
831164
|
+
contentBlocks,
|
|
831165
|
+
tools,
|
|
831166
|
+
agentId: options.agentId,
|
|
831167
|
+
usage: usage2,
|
|
831168
|
+
stopReason,
|
|
831169
|
+
maxTokens
|
|
831170
|
+
})) {
|
|
831171
|
+
if (output.type === "assistant") {
|
|
831172
|
+
collectedMessages.push(output);
|
|
831173
|
+
}
|
|
831174
|
+
yield output;
|
|
831175
|
+
}
|
|
831176
|
+
partialMessage = null;
|
|
831177
|
+
}
|
|
831178
|
+
if (usage2.input_tokens + usage2.output_tokens > 0) {
|
|
831179
|
+
const costUSD = calculateUSDCost(openaiModel, usage2);
|
|
831180
|
+
addToTotalSessionCost(costUSD, usage2, options.model);
|
|
831181
|
+
}
|
|
831182
|
+
break;
|
|
831183
|
+
}
|
|
831184
|
+
}
|
|
831185
|
+
yield {
|
|
831186
|
+
type: "stream_event",
|
|
831187
|
+
event,
|
|
831188
|
+
...event.type === "message_start" ? { ttftMs } : undefined
|
|
831189
|
+
};
|
|
831190
|
+
}
|
|
831191
|
+
recordLLMObservation(options.langfuseTrace ?? null, {
|
|
831192
|
+
model: openaiModel,
|
|
831193
|
+
provider: "openai",
|
|
831194
|
+
input: convertMessagesToLangfuse(openaiMessages),
|
|
831195
|
+
output: convertOutputToLangfuse(collectedMessages),
|
|
831196
|
+
usage: {
|
|
831197
|
+
input_tokens: usage2.input_tokens,
|
|
831198
|
+
output_tokens: usage2.output_tokens,
|
|
831199
|
+
cache_creation_input_tokens: usage2.cache_creation_input_tokens,
|
|
831200
|
+
cache_read_input_tokens: usage2.cache_read_input_tokens
|
|
831201
|
+
},
|
|
831202
|
+
startTime: new Date(start),
|
|
831203
|
+
endTime: new Date,
|
|
831204
|
+
completionStartTime: ttftMs > 0 ? new Date(start + ttftMs) : undefined,
|
|
831205
|
+
tools: convertToolsToLangfuse(toolSchemas),
|
|
831206
|
+
...enableThinking && { thinking: { type: "enabled" } }
|
|
831207
|
+
});
|
|
831208
|
+
if (partialMessage) {
|
|
831209
|
+
for (const output of assembleFinalAssistantOutputs({
|
|
831210
|
+
partialMessage,
|
|
831211
|
+
contentBlocks,
|
|
831212
|
+
tools,
|
|
831213
|
+
agentId: options.agentId,
|
|
831214
|
+
usage: usage2,
|
|
831215
|
+
stopReason,
|
|
831216
|
+
maxTokens
|
|
831217
|
+
})) {
|
|
831218
|
+
yield output;
|
|
831219
|
+
}
|
|
831220
|
+
}
|
|
831221
|
+
return !!partialMessage;
|
|
831222
|
+
} catch (error99) {
|
|
831223
|
+
if (error99 instanceof Error) {
|
|
831224
|
+
error99.__streamProducedOutput = !!partialMessage;
|
|
831225
|
+
}
|
|
831226
|
+
throw error99;
|
|
831227
|
+
}
|
|
831228
|
+
}
|
|
830795
831229
|
async function* queryModelOpenAI(messages, systemPrompt2, tools, signal, options) {
|
|
830796
831230
|
try {
|
|
830797
831231
|
const openaiModel = resolveOpenAIModel(options.model);
|
|
@@ -830842,188 +831276,69 @@ async function* queryModelOpenAI(messages, systemPrompt2, tools, signal, options
|
|
|
830842
831276
|
const { upperLimit } = getModelMaxOutputTokens(openaiModel);
|
|
830843
831277
|
const maxTokens = resolveOpenAIMaxTokens(upperLimit, options.maxOutputTokensOverride);
|
|
830844
831278
|
logForDebugging(`[OpenAI] Calling model=${openaiModel}, messages=${openaiMessages.length}, tools=${openaiTools.length}, thinking=${enableThinking}`);
|
|
830845
|
-
|
|
830846
|
-
|
|
830847
|
-
|
|
830848
|
-
|
|
830849
|
-
|
|
830850
|
-
|
|
830851
|
-
|
|
830852
|
-
|
|
830853
|
-
|
|
830854
|
-
|
|
830855
|
-
|
|
830856
|
-
|
|
830857
|
-
|
|
830858
|
-
|
|
830859
|
-
|
|
830860
|
-
|
|
830861
|
-
|
|
830862
|
-
|
|
830863
|
-
|
|
830864
|
-
|
|
830865
|
-
|
|
830866
|
-
|
|
830867
|
-
|
|
830868
|
-
|
|
830869
|
-
|
|
830870
|
-
|
|
830871
|
-
|
|
830872
|
-
|
|
830873
|
-
|
|
830874
|
-
|
|
830875
|
-
})), async (client8, _attempt, _context2) => {
|
|
830876
|
-
try {
|
|
830877
|
-
return await client8.chat.completions.create(requestBody, { signal });
|
|
830878
|
-
} catch (err2) {
|
|
830879
|
-
throw wrapOpenAIErrorForRetry(err2);
|
|
830880
|
-
}
|
|
830881
|
-
}, {
|
|
830882
|
-
model: options.model,
|
|
830883
|
-
thinkingConfig: { type: "disabled" },
|
|
830884
|
-
signal,
|
|
830885
|
-
querySource: options.querySource
|
|
830886
|
-
});
|
|
830887
|
-
let stream6;
|
|
830888
|
-
let e4 = await retryGenerator.next();
|
|
830889
|
-
while (!e4.done) {
|
|
830890
|
-
if (e4.value.type === "system") {
|
|
830891
|
-
yield e4.value;
|
|
830892
|
-
}
|
|
830893
|
-
e4 = await retryGenerator.next();
|
|
831279
|
+
const requestBody = isChatGPTAuthEnabled() ? undefined : buildOpenAIRequestBody({
|
|
831280
|
+
model: openaiModel,
|
|
831281
|
+
messages: openaiMessages,
|
|
831282
|
+
tools: openaiTools,
|
|
831283
|
+
toolChoice: openaiToolChoice,
|
|
831284
|
+
enableThinking,
|
|
831285
|
+
maxTokens,
|
|
831286
|
+
temperatureOverride: options.temperatureOverride,
|
|
831287
|
+
outputFormat: options.outputFormat
|
|
831288
|
+
});
|
|
831289
|
+
let streamAttempts = 0;
|
|
831290
|
+
let lastStreamError;
|
|
831291
|
+
while (streamAttempts < MAX_STREAM_RECONNECT_ATTEMPTS) {
|
|
831292
|
+
streamAttempts++;
|
|
831293
|
+
let adaptedStream;
|
|
831294
|
+
if (isChatGPTAuthEnabled()) {
|
|
831295
|
+
adaptedStream = adaptResponsesStreamToAnthropic(await createChatGPTResponsesStream({
|
|
831296
|
+
request: buildResponsesRequest({
|
|
831297
|
+
model: openaiModel,
|
|
831298
|
+
messages: openaiMessages,
|
|
831299
|
+
tools: openaiTools,
|
|
831300
|
+
toolChoice: openaiToolChoice,
|
|
831301
|
+
reasoningEffort
|
|
831302
|
+
}),
|
|
831303
|
+
signal,
|
|
831304
|
+
fetchOverride: options.fetchOverride
|
|
831305
|
+
}), openaiModel);
|
|
831306
|
+
} else {
|
|
831307
|
+
const stream6 = yield* getOpenAIStream(requestBody, options, signal);
|
|
831308
|
+
adaptedStream = adaptOpenAIStreamToAnthropic(stream6, openaiModel);
|
|
830894
831309
|
}
|
|
830895
|
-
|
|
830896
|
-
|
|
830897
|
-
|
|
830898
|
-
|
|
830899
|
-
|
|
830900
|
-
let partialMessage;
|
|
830901
|
-
let stopReason = null;
|
|
830902
|
-
let usage2 = {
|
|
830903
|
-
input_tokens: 0,
|
|
830904
|
-
output_tokens: 0,
|
|
830905
|
-
cache_creation_input_tokens: 0,
|
|
830906
|
-
cache_read_input_tokens: 0
|
|
830907
|
-
};
|
|
830908
|
-
let ttftMs = 0;
|
|
830909
|
-
const start = Date.now();
|
|
830910
|
-
for await (const event of adaptedStream) {
|
|
830911
|
-
switch (event.type) {
|
|
830912
|
-
case "message_start": {
|
|
830913
|
-
partialMessage = event.message;
|
|
830914
|
-
ttftMs = Date.now() - start;
|
|
830915
|
-
if (event.message?.usage) {
|
|
830916
|
-
usage2 = {
|
|
830917
|
-
...usage2,
|
|
830918
|
-
...event.message.usage
|
|
830919
|
-
};
|
|
830920
|
-
}
|
|
830921
|
-
break;
|
|
830922
|
-
}
|
|
830923
|
-
case "content_block_start": {
|
|
830924
|
-
const idx = event.index;
|
|
830925
|
-
const cb = event.content_block;
|
|
830926
|
-
if (cb.type === "tool_use") {
|
|
830927
|
-
contentBlocks[idx] = { ...cb, input: "" };
|
|
830928
|
-
} else if (cb.type === "text") {
|
|
830929
|
-
contentBlocks[idx] = { ...cb, text: "" };
|
|
830930
|
-
} else if (cb.type === "thinking") {
|
|
830931
|
-
contentBlocks[idx] = { ...cb, thinking: "", signature: "" };
|
|
830932
|
-
} else {
|
|
830933
|
-
contentBlocks[idx] = { ...cb };
|
|
830934
|
-
}
|
|
830935
|
-
break;
|
|
830936
|
-
}
|
|
830937
|
-
case "content_block_delta": {
|
|
830938
|
-
const idx = event.index;
|
|
830939
|
-
const delta = event.delta;
|
|
830940
|
-
const block = contentBlocks[idx];
|
|
830941
|
-
if (!block)
|
|
830942
|
-
break;
|
|
830943
|
-
if (delta.type === "text_delta") {
|
|
830944
|
-
block.text = (block.text || "") + delta.text;
|
|
830945
|
-
} else if (delta.type === "input_json_delta") {
|
|
830946
|
-
block.input = (block.input || "") + delta.partial_json;
|
|
830947
|
-
} else if (delta.type === "thinking_delta") {
|
|
830948
|
-
block.thinking = (block.thinking || "") + delta.thinking;
|
|
830949
|
-
} else if (delta.type === "signature_delta") {
|
|
830950
|
-
block.signature = delta.signature;
|
|
830951
|
-
}
|
|
830952
|
-
break;
|
|
830953
|
-
}
|
|
830954
|
-
case "content_block_stop": {
|
|
830955
|
-
break;
|
|
831310
|
+
try {
|
|
831311
|
+
const producedOutput = yield* consumeOpenAIStream(adaptedStream, openaiModel, tools, options, maxTokens, openaiMessages, toolSchemas, enableThinking);
|
|
831312
|
+
if (!producedOutput && streamAttempts < MAX_STREAM_RECONNECT_ATTEMPTS) {
|
|
831313
|
+
logForDebugging(`[OpenAI] Stream completed without producing output (attempt ${streamAttempts}/${MAX_STREAM_RECONNECT_ATTEMPTS}), reconnecting`, { level: "warn" });
|
|
831314
|
+
continue;
|
|
830956
831315
|
}
|
|
830957
|
-
|
|
830958
|
-
|
|
830959
|
-
|
|
830960
|
-
|
|
830961
|
-
|
|
830962
|
-
|
|
830963
|
-
|
|
830964
|
-
}
|
|
830965
|
-
break;
|
|
831316
|
+
return;
|
|
831317
|
+
} catch (error99) {
|
|
831318
|
+
lastStreamError = error99;
|
|
831319
|
+
const producedOutput = error99 instanceof Error && error99.__streamProducedOutput === true;
|
|
831320
|
+
if (!producedOutput && streamAttempts < MAX_STREAM_RECONNECT_ATTEMPTS && isRetryableStreamError(error99)) {
|
|
831321
|
+
logForDebugging(`[OpenAI] Stream failed before producing output (attempt ${streamAttempts}/${MAX_STREAM_RECONNECT_ATTEMPTS}), reconnecting: ${error99 instanceof Error ? error99.message : String(error99)}`, { level: "warn" });
|
|
831322
|
+
continue;
|
|
830966
831323
|
}
|
|
830967
|
-
|
|
830968
|
-
|
|
830969
|
-
|
|
830970
|
-
|
|
830971
|
-
|
|
830972
|
-
|
|
830973
|
-
|
|
830974
|
-
|
|
830975
|
-
|
|
830976
|
-
|
|
830977
|
-
|
|
830978
|
-
if (output.type === "assistant") {
|
|
830979
|
-
collectedMessages.push(output);
|
|
830980
|
-
}
|
|
830981
|
-
yield output;
|
|
830982
|
-
}
|
|
830983
|
-
partialMessage = null;
|
|
830984
|
-
}
|
|
830985
|
-
if (usage2.input_tokens + usage2.output_tokens > 0) {
|
|
830986
|
-
const costUSD = calculateUSDCost(openaiModel, usage2);
|
|
830987
|
-
addToTotalSessionCost(costUSD, usage2, options.model);
|
|
831324
|
+
if (producedOutput && requestBody && !(error99 instanceof APIUserAbortError)) {
|
|
831325
|
+
logForDebugging(`[OpenAI] Streaming failed after producing output, falling back to non-streaming: ${error99 instanceof Error ? error99.message : String(error99)}`, { level: "warn" });
|
|
831326
|
+
try {
|
|
831327
|
+
const nonStreamingBody = toNonStreamingOpenAIRequestBody(requestBody);
|
|
831328
|
+
const completion = yield* executeOpenAINonStreamingRequest(nonStreamingBody, options, signal);
|
|
831329
|
+
const fallbackStream = adaptOpenAICompletionToAnthropicStream(completion);
|
|
831330
|
+
yield* consumeOpenAIStream(fallbackStream, openaiModel, tools, options, maxTokens, openaiMessages, toolSchemas, enableThinking);
|
|
831331
|
+
return;
|
|
831332
|
+
} catch (fallbackError) {
|
|
831333
|
+
logForDebugging(`[OpenAI] Non-streaming fallback also failed: ${fallbackError instanceof Error ? fallbackError.message : String(fallbackError)}`, { level: "error" });
|
|
831334
|
+
throw fallbackError;
|
|
830988
831335
|
}
|
|
830989
|
-
break;
|
|
830990
831336
|
}
|
|
831337
|
+
throw error99;
|
|
830991
831338
|
}
|
|
830992
|
-
yield {
|
|
830993
|
-
type: "stream_event",
|
|
830994
|
-
event,
|
|
830995
|
-
...event.type === "message_start" ? { ttftMs } : undefined
|
|
830996
|
-
};
|
|
830997
831339
|
}
|
|
830998
|
-
|
|
830999
|
-
|
|
831000
|
-
provider: "openai",
|
|
831001
|
-
input: convertMessagesToLangfuse(openaiMessages),
|
|
831002
|
-
output: convertOutputToLangfuse(collectedMessages),
|
|
831003
|
-
usage: {
|
|
831004
|
-
input_tokens: usage2.input_tokens,
|
|
831005
|
-
output_tokens: usage2.output_tokens,
|
|
831006
|
-
cache_creation_input_tokens: usage2.cache_creation_input_tokens,
|
|
831007
|
-
cache_read_input_tokens: usage2.cache_read_input_tokens
|
|
831008
|
-
},
|
|
831009
|
-
startTime: new Date(start),
|
|
831010
|
-
endTime: new Date,
|
|
831011
|
-
completionStartTime: ttftMs > 0 ? new Date(start + ttftMs) : undefined,
|
|
831012
|
-
tools: convertToolsToLangfuse(toolSchemas),
|
|
831013
|
-
...enableThinking && { thinking: { type: "enabled" } }
|
|
831014
|
-
});
|
|
831015
|
-
if (partialMessage) {
|
|
831016
|
-
for (const output of assembleFinalAssistantOutputs({
|
|
831017
|
-
partialMessage,
|
|
831018
|
-
contentBlocks,
|
|
831019
|
-
tools,
|
|
831020
|
-
agentId: options.agentId,
|
|
831021
|
-
usage: usage2,
|
|
831022
|
-
stopReason,
|
|
831023
|
-
maxTokens
|
|
831024
|
-
})) {
|
|
831025
|
-
yield output;
|
|
831026
|
-
}
|
|
831340
|
+
if (lastStreamError) {
|
|
831341
|
+
throw lastStreamError;
|
|
831027
831342
|
}
|
|
831028
831343
|
} catch (error99) {
|
|
831029
831344
|
const errorMessage2 = error99 instanceof Error ? error99.message : String(error99);
|
|
@@ -831035,11 +831350,14 @@ async function* queryModelOpenAI(messages, systemPrompt2, tools, signal, options
|
|
|
831035
831350
|
});
|
|
831036
831351
|
}
|
|
831037
831352
|
}
|
|
831353
|
+
var MAX_STREAM_RECONNECT_ATTEMPTS = 3;
|
|
831038
831354
|
var init_openai5 = __esm(() => {
|
|
831355
|
+
init_sdk();
|
|
831039
831356
|
init_client18();
|
|
831040
831357
|
init_src3();
|
|
831041
831358
|
init_withRetry();
|
|
831042
831359
|
init_retry3();
|
|
831360
|
+
init_nonStreamingFallback();
|
|
831043
831361
|
init_chatgptAuth();
|
|
831044
831362
|
init_responsesAdapter();
|
|
831045
831363
|
init_messages7();
|
|
@@ -831546,7 +831864,7 @@ var exports_gemini = {};
|
|
|
831546
831864
|
__export(exports_gemini, {
|
|
831547
831865
|
queryModelGemini: () => queryModelGemini
|
|
831548
831866
|
});
|
|
831549
|
-
import { randomUUID as
|
|
831867
|
+
import { randomUUID as randomUUID53 } from "crypto";
|
|
831550
831868
|
async function* queryModelGemini(messages, systemPrompt2, tools, signal, options, thinkingConfig) {
|
|
831551
831869
|
try {
|
|
831552
831870
|
const geminiModel = resolveGeminiModel(options.model);
|
|
@@ -831655,7 +831973,7 @@ async function* queryModelGemini(messages, systemPrompt2, tools, signal, options
|
|
|
831655
831973
|
},
|
|
831656
831974
|
requestId: undefined,
|
|
831657
831975
|
type: "assistant",
|
|
831658
|
-
uuid:
|
|
831976
|
+
uuid: randomUUID53(),
|
|
831659
831977
|
timestamp: new Date().toISOString()
|
|
831660
831978
|
};
|
|
831661
831979
|
collectedMessages.push(message2);
|
|
@@ -831740,7 +832058,7 @@ var exports_grok = {};
|
|
|
831740
832058
|
__export(exports_grok, {
|
|
831741
832059
|
queryModelGrok: () => queryModelGrok
|
|
831742
832060
|
});
|
|
831743
|
-
import { randomUUID as
|
|
832061
|
+
import { randomUUID as randomUUID54 } from "crypto";
|
|
831744
832062
|
async function* queryModelGrok(messages, systemPrompt2, tools, signal, options) {
|
|
831745
832063
|
try {
|
|
831746
832064
|
const grokModel = resolveGrokModel(options.model);
|
|
@@ -831847,7 +832165,7 @@ async function* queryModelGrok(messages, systemPrompt2, tools, signal, options)
|
|
|
831847
832165
|
},
|
|
831848
832166
|
requestId: undefined,
|
|
831849
832167
|
type: "assistant",
|
|
831850
|
-
uuid:
|
|
832168
|
+
uuid: randomUUID54(),
|
|
831851
832169
|
timestamp: new Date().toISOString()
|
|
831852
832170
|
};
|
|
831853
832171
|
collectedMessages.push(m3);
|
|
@@ -832153,8 +832471,8 @@ var exports_provider = {};
|
|
|
832153
832471
|
__export(exports_provider, {
|
|
832154
832472
|
queryModelCoStrict: () => queryModelCoStrict
|
|
832155
832473
|
});
|
|
832156
|
-
import { randomUUID as
|
|
832157
|
-
function
|
|
832474
|
+
import { randomUUID as randomUUID55 } from "crypto";
|
|
832475
|
+
function isRecord7(value) {
|
|
832158
832476
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
832159
832477
|
}
|
|
832160
832478
|
function mapErrorToSDKError(error99) {
|
|
@@ -832175,7 +832493,7 @@ function mapErrorToSDKError(error99) {
|
|
|
832175
832493
|
return "unknown";
|
|
832176
832494
|
}
|
|
832177
832495
|
function isPlainRecord(value) {
|
|
832178
|
-
return
|
|
832496
|
+
return isRecord7(value);
|
|
832179
832497
|
}
|
|
832180
832498
|
function tryParsePartialToolInput(rawInput) {
|
|
832181
832499
|
try {
|
|
@@ -832192,7 +832510,7 @@ function contentContainsImage(content) {
|
|
|
832192
832510
|
if (!Array.isArray(content))
|
|
832193
832511
|
return false;
|
|
832194
832512
|
return content.some((block) => {
|
|
832195
|
-
if (!
|
|
832513
|
+
if (!isRecord7(block))
|
|
832196
832514
|
return false;
|
|
832197
832515
|
if (block.type === "image")
|
|
832198
832516
|
return true;
|
|
@@ -832252,178 +832570,96 @@ function isNonMultimodalModelError(message2) {
|
|
|
832252
832570
|
const normalized = message2.toLowerCase();
|
|
832253
832571
|
return normalized.includes("not a multimodal model") || normalized.includes("does not support image") || normalized.includes("does not support images");
|
|
832254
832572
|
}
|
|
832255
|
-
async function*
|
|
832256
|
-
|
|
832257
|
-
|
|
832258
|
-
|
|
832259
|
-
|
|
832260
|
-
|
|
832261
|
-
setCachedIntranetBaseUrl(creds?.base_url ?? null);
|
|
832262
|
-
let defaultMaxTokens = getModelMaxOutputTokens(costrictModel).upperLimit;
|
|
832263
|
-
let maxTokensParamKey = "max_tokens";
|
|
832264
|
-
let modelInfo;
|
|
832265
|
-
if (creds?.access_token) {
|
|
832266
|
-
try {
|
|
832267
|
-
const modelList = await fetchCoStrictModels(baseUrl, creds.access_token);
|
|
832268
|
-
modelInfo = modelList.find((m3) => m3.id === costrictModel);
|
|
832269
|
-
if (modelInfo) {
|
|
832270
|
-
maxTokensParamKey = modelInfo.maxTokensKey || "max_tokens";
|
|
832271
|
-
if (modelInfo.maxTokens != null) {
|
|
832272
|
-
defaultMaxTokens = modelInfo.maxTokens;
|
|
832273
|
-
}
|
|
832274
|
-
}
|
|
832275
|
-
} catch {}
|
|
832276
|
-
}
|
|
832277
|
-
const maxTokensValue = resolveOpenAIMaxTokens(defaultMaxTokens, options.maxOutputTokensOverride);
|
|
832278
|
-
let messagesForAPI = ensureToolResultPairing(normalizeMessagesForAPI(messages, tools));
|
|
832279
|
-
if (modelInfo?.supportsImages === false && messagesContainImages(messagesForAPI)) {
|
|
832280
|
-
messagesForAPI = stripImagesFromMessages2(messagesForAPI, costrictModel);
|
|
832573
|
+
async function* executeCoStrictNonStreamingRequest(client8, requestBody, options, signal) {
|
|
832574
|
+
const retryGenerator = withRetry(() => Promise.resolve(client8), async (c7, _attempt, _context2) => {
|
|
832575
|
+
try {
|
|
832576
|
+
return await c7.chat.completions.create(requestBody, { signal });
|
|
832577
|
+
} catch (err2) {
|
|
832578
|
+
throw wrapOpenAIErrorForRetry(err2);
|
|
832281
832579
|
}
|
|
832282
|
-
|
|
832283
|
-
|
|
832284
|
-
|
|
832285
|
-
|
|
832286
|
-
|
|
832287
|
-
|
|
832288
|
-
|
|
832289
|
-
|
|
832290
|
-
|
|
832291
|
-
|
|
832292
|
-
|
|
832293
|
-
|
|
832294
|
-
|
|
832295
|
-
|
|
832296
|
-
|
|
832297
|
-
|
|
832298
|
-
|
|
832299
|
-
|
|
832300
|
-
|
|
832301
|
-
|
|
832302
|
-
|
|
832303
|
-
|
|
832304
|
-
|
|
832305
|
-
|
|
832306
|
-
|
|
832307
|
-
|
|
832308
|
-
|
|
832309
|
-
|
|
832310
|
-
|
|
832311
|
-
"User-Agent": getUserAgent(),
|
|
832312
|
-
"X-Session-Id": getSessionId(),
|
|
832313
|
-
...options.agentId ? { "X-Agent-Id": options.agentId } : {},
|
|
832314
|
-
...options.parentAgentId ? { "X-Parent-Agent-Id": options.parentAgentId } : {}
|
|
832315
|
-
}
|
|
832316
|
-
});
|
|
832317
|
-
logForDebugging(`[CoStrict] model=${costrictModel}, baseURL=${chatBaseURL}, messages=${openaiMessages.length}, tools=${openaiTools.length}`);
|
|
832318
|
-
const requestBody = {
|
|
832319
|
-
model: costrictModel,
|
|
832320
|
-
messages: openaiMessages,
|
|
832321
|
-
...openaiTools.length > 0 && {
|
|
832322
|
-
tools: openaiTools,
|
|
832323
|
-
...openaiToolChoice && {
|
|
832324
|
-
tool_choice: openaiToolChoice
|
|
832325
|
-
}
|
|
832326
|
-
},
|
|
832327
|
-
stream: true,
|
|
832328
|
-
stream_options: { include_usage: true },
|
|
832329
|
-
[maxTokensParamKey]: maxTokensValue,
|
|
832330
|
-
...enableThinking && {
|
|
832331
|
-
thinking: { type: "enabled" },
|
|
832332
|
-
enable_thinking: true,
|
|
832333
|
-
chat_template_kwargs: { thinking: true }
|
|
832334
|
-
},
|
|
832335
|
-
...!enableThinking && options.temperatureOverride !== undefined && {
|
|
832336
|
-
temperature: options.temperatureOverride
|
|
832337
|
-
}
|
|
832338
|
-
};
|
|
832339
|
-
const retryGenerator = withRetry(() => Promise.resolve(client8), async (c7, _attempt, _context2) => {
|
|
832580
|
+
}, {
|
|
832581
|
+
model: options.model,
|
|
832582
|
+
fallbackModel: options.fallbackModel,
|
|
832583
|
+
thinkingConfig: { type: "disabled" },
|
|
832584
|
+
signal,
|
|
832585
|
+
querySource: options.querySource
|
|
832586
|
+
});
|
|
832587
|
+
let e4 = await retryGenerator.next();
|
|
832588
|
+
while (!e4.done) {
|
|
832589
|
+
yield e4.value;
|
|
832590
|
+
e4 = await retryGenerator.next();
|
|
832591
|
+
}
|
|
832592
|
+
return e4.value;
|
|
832593
|
+
}
|
|
832594
|
+
async function* consumeCoStrictStream(adaptedStream, costrictModel, tools, options, maxTokensValue) {
|
|
832595
|
+
const contentBlocks = {};
|
|
832596
|
+
const toolCallStates = new Map;
|
|
832597
|
+
let partialMessage;
|
|
832598
|
+
let stopReason = null;
|
|
832599
|
+
let usage2 = {
|
|
832600
|
+
input_tokens: 0,
|
|
832601
|
+
output_tokens: 0,
|
|
832602
|
+
cache_creation_input_tokens: 0,
|
|
832603
|
+
cache_read_input_tokens: 0
|
|
832604
|
+
};
|
|
832605
|
+
let ttftMs = 0;
|
|
832606
|
+
const start = Date.now();
|
|
832607
|
+
const finalizeToolCallStates = () => {
|
|
832608
|
+
for (const state3 of toolCallStates.values()) {
|
|
832340
832609
|
try {
|
|
832341
|
-
|
|
832342
|
-
|
|
832343
|
-
throw wrapOpenAIErrorForRetry(err2);
|
|
832344
|
-
}
|
|
832345
|
-
}, {
|
|
832346
|
-
model: options.model,
|
|
832347
|
-
fallbackModel: options.fallbackModel,
|
|
832348
|
-
thinkingConfig: { type: "disabled" },
|
|
832349
|
-
signal,
|
|
832350
|
-
querySource: options.querySource
|
|
832351
|
-
});
|
|
832352
|
-
let stream6;
|
|
832353
|
-
let e4 = await retryGenerator.next();
|
|
832354
|
-
while (!e4.done) {
|
|
832355
|
-
if (e4.value.type === "system") {
|
|
832356
|
-
yield e4.value;
|
|
832357
|
-
}
|
|
832358
|
-
e4 = await retryGenerator.next();
|
|
832359
|
-
}
|
|
832360
|
-
stream6 = e4.value;
|
|
832361
|
-
const adaptedStream = adaptOpenAIStreamToAnthropic(stream6, costrictModel);
|
|
832362
|
-
const contentBlocks = {};
|
|
832363
|
-
const toolCallStates = new Map;
|
|
832364
|
-
let partialMessage;
|
|
832365
|
-
let stopReason = null;
|
|
832366
|
-
let usage2 = {
|
|
832367
|
-
input_tokens: 0,
|
|
832368
|
-
output_tokens: 0,
|
|
832369
|
-
cache_creation_input_tokens: 0,
|
|
832370
|
-
cache_read_input_tokens: 0
|
|
832371
|
-
};
|
|
832372
|
-
let ttftMs = 0;
|
|
832373
|
-
const start = Date.now();
|
|
832374
|
-
const finalizeToolCallStates = () => {
|
|
832375
|
-
for (const state3 of toolCallStates.values()) {
|
|
832376
|
-
try {
|
|
832377
|
-
const parsed = JSON.parse(state3.rawInput);
|
|
832378
|
-
if (!isPlainRecord(parsed)) {
|
|
832379
|
-
state3.finalParseError = getInvalidToolInputMessage(state3.name);
|
|
832380
|
-
}
|
|
832381
|
-
} catch {
|
|
832610
|
+
const parsed = JSON.parse(state3.rawInput);
|
|
832611
|
+
if (!isPlainRecord(parsed)) {
|
|
832382
832612
|
state3.finalParseError = getInvalidToolInputMessage(state3.name);
|
|
832383
832613
|
}
|
|
832614
|
+
} catch {
|
|
832615
|
+
state3.finalParseError = getInvalidToolInputMessage(state3.name);
|
|
832384
832616
|
}
|
|
832385
|
-
}
|
|
832386
|
-
|
|
832387
|
-
|
|
832388
|
-
|
|
832389
|
-
|
|
832390
|
-
|
|
832391
|
-
|
|
832392
|
-
|
|
832393
|
-
|
|
832394
|
-
|
|
832395
|
-
|
|
832396
|
-
|
|
832397
|
-
|
|
832398
|
-
|
|
832399
|
-
|
|
832400
|
-
|
|
832401
|
-
|
|
832402
|
-
|
|
832617
|
+
}
|
|
832618
|
+
};
|
|
832619
|
+
const assembleFinalAssistantOutputs2 = () => {
|
|
832620
|
+
const outputs2 = [];
|
|
832621
|
+
if (!partialMessage)
|
|
832622
|
+
return outputs2;
|
|
832623
|
+
const allBlocksWithIndices = Object.keys(contentBlocks).sort((a5, b6) => Number(a5) - Number(b6)).map((k5) => ({ index: Number(k5), block: contentBlocks[Number(k5)] })).filter((entry) => Boolean(entry.block));
|
|
832624
|
+
const allBlocks = allBlocksWithIndices.map((entry) => entry.block);
|
|
832625
|
+
if (allBlocks.length > 0) {
|
|
832626
|
+
for (const { index: index2, block } of allBlocksWithIndices) {
|
|
832627
|
+
if (block?.type !== "tool_use")
|
|
832628
|
+
continue;
|
|
832629
|
+
const state3 = toolCallStates.get(index2);
|
|
832630
|
+
if (!state3)
|
|
832631
|
+
continue;
|
|
832632
|
+
block.input = state3.rawInput;
|
|
832633
|
+
if (state3.finalParseError) {
|
|
832634
|
+
block.invalidToolCallError = state3.finalParseError;
|
|
832403
832635
|
}
|
|
832404
|
-
outputs2.push({
|
|
832405
|
-
message: {
|
|
832406
|
-
...partialMessage,
|
|
832407
|
-
content: normalizeContentFromAPI(allBlocks, tools, options.agentId, { preserveInvalidToolCall: true }),
|
|
832408
|
-
usage: usage2,
|
|
832409
|
-
stop_reason: stopReason,
|
|
832410
|
-
stop_sequence: null
|
|
832411
|
-
},
|
|
832412
|
-
requestId: undefined,
|
|
832413
|
-
type: "assistant",
|
|
832414
|
-
uuid: randomUUID54(),
|
|
832415
|
-
timestamp: new Date().toISOString()
|
|
832416
|
-
});
|
|
832417
|
-
}
|
|
832418
|
-
if (stopReason === "max_tokens") {
|
|
832419
|
-
outputs2.push(createAssistantAPIErrorMessage({
|
|
832420
|
-
content: `Output truncated: response exceeded the ${maxTokensValue} token limit. ` + `Set OPENAI_MAX_TOKENS or COSTRICT_MAX_OUTPUT_TOKENS to override.`,
|
|
832421
|
-
apiError: "max_output_tokens",
|
|
832422
|
-
error: "max_output_tokens"
|
|
832423
|
-
}));
|
|
832424
832636
|
}
|
|
832425
|
-
|
|
832426
|
-
|
|
832637
|
+
outputs2.push({
|
|
832638
|
+
message: {
|
|
832639
|
+
...partialMessage,
|
|
832640
|
+
content: normalizeContentFromAPI(allBlocks, tools, options.agentId, {
|
|
832641
|
+
preserveInvalidToolCall: true
|
|
832642
|
+
}),
|
|
832643
|
+
usage: usage2,
|
|
832644
|
+
stop_reason: stopReason,
|
|
832645
|
+
stop_sequence: null
|
|
832646
|
+
},
|
|
832647
|
+
requestId: undefined,
|
|
832648
|
+
type: "assistant",
|
|
832649
|
+
uuid: randomUUID55(),
|
|
832650
|
+
timestamp: new Date().toISOString()
|
|
832651
|
+
});
|
|
832652
|
+
}
|
|
832653
|
+
if (stopReason === "max_tokens") {
|
|
832654
|
+
outputs2.push(createAssistantAPIErrorMessage({
|
|
832655
|
+
content: `Output truncated: response exceeded the ${maxTokensValue} token limit. ` + `Set OPENAI_MAX_TOKENS or COSTRICT_MAX_OUTPUT_TOKENS to override.`,
|
|
832656
|
+
apiError: "max_output_tokens",
|
|
832657
|
+
error: "max_output_tokens"
|
|
832658
|
+
}));
|
|
832659
|
+
}
|
|
832660
|
+
return outputs2;
|
|
832661
|
+
};
|
|
832662
|
+
try {
|
|
832427
832663
|
for await (const event of adaptedStream) {
|
|
832428
832664
|
switch (event.type) {
|
|
832429
832665
|
case "message_start": {
|
|
@@ -832521,6 +832757,158 @@ async function* queryModelCoStrict(messages, systemPrompt2, tools, signal, optio
|
|
|
832521
832757
|
yield output;
|
|
832522
832758
|
}
|
|
832523
832759
|
}
|
|
832760
|
+
return !!partialMessage;
|
|
832761
|
+
} catch (error99) {
|
|
832762
|
+
if (error99 instanceof Error) {
|
|
832763
|
+
error99.__streamProducedOutput = !!partialMessage;
|
|
832764
|
+
}
|
|
832765
|
+
throw error99;
|
|
832766
|
+
}
|
|
832767
|
+
}
|
|
832768
|
+
async function* queryModelCoStrict(messages, systemPrompt2, tools, signal, options) {
|
|
832769
|
+
try {
|
|
832770
|
+
const costrictModel = resolveCoStrictModel(options.model);
|
|
832771
|
+
const creds = await loadCoStrictCredentials();
|
|
832772
|
+
const baseUrl = getCoStrictBaseURL(creds?.base_url);
|
|
832773
|
+
const chatBaseURL = `${baseUrl}/chat-rag/api/v1`;
|
|
832774
|
+
setCachedIntranetBaseUrl(creds?.base_url ?? null);
|
|
832775
|
+
let defaultMaxTokens = getModelMaxOutputTokens(costrictModel).upperLimit;
|
|
832776
|
+
let maxTokensParamKey = "max_tokens";
|
|
832777
|
+
let modelInfo;
|
|
832778
|
+
if (creds?.access_token) {
|
|
832779
|
+
try {
|
|
832780
|
+
const modelList = await fetchCoStrictModels(baseUrl, creds.access_token);
|
|
832781
|
+
modelInfo = modelList.find((m3) => m3.id === costrictModel);
|
|
832782
|
+
if (modelInfo) {
|
|
832783
|
+
maxTokensParamKey = modelInfo.maxTokensKey || "max_tokens";
|
|
832784
|
+
if (modelInfo.maxTokens != null) {
|
|
832785
|
+
defaultMaxTokens = modelInfo.maxTokens;
|
|
832786
|
+
}
|
|
832787
|
+
}
|
|
832788
|
+
} catch {}
|
|
832789
|
+
}
|
|
832790
|
+
const maxTokensValue = resolveOpenAIMaxTokens(defaultMaxTokens, options.maxOutputTokensOverride);
|
|
832791
|
+
let messagesForAPI = ensureToolResultPairing(normalizeMessagesForAPI(messages, tools));
|
|
832792
|
+
if (modelInfo?.supportsImages === false && messagesContainImages(messagesForAPI)) {
|
|
832793
|
+
messagesForAPI = stripImagesFromMessages2(messagesForAPI, costrictModel);
|
|
832794
|
+
}
|
|
832795
|
+
const toolSchemas = await Promise.all(tools.map((tool) => toolToAPISchema(tool, {
|
|
832796
|
+
getToolPermissionContext: options.getToolPermissionContext,
|
|
832797
|
+
tools,
|
|
832798
|
+
agents: options.agents,
|
|
832799
|
+
allowedAgentTypes: options.allowedAgentTypes,
|
|
832800
|
+
model: options.model
|
|
832801
|
+
})));
|
|
832802
|
+
const standardTools = toolSchemas.filter((t2) => {
|
|
832803
|
+
const anyT = t2;
|
|
832804
|
+
return anyT.type !== "advisor_20260301" && anyT.type !== "computer_20250124";
|
|
832805
|
+
});
|
|
832806
|
+
const enableThinking = isOpenAIThinkingEnabled(costrictModel);
|
|
832807
|
+
const openaiMessages = anthropicMessagesToOpenAI(messagesForAPI, systemPrompt2, { enableThinking });
|
|
832808
|
+
const openaiTools = anthropicToolsToOpenAI(standardTools);
|
|
832809
|
+
const openaiToolChoice = anthropicToolChoiceToOpenAI(options.toolChoice);
|
|
832810
|
+
const costrictFetch = createCoStrictFetch({
|
|
832811
|
+
agentType: getMainThreadAgentType() ?? getActiveSkillName()
|
|
832812
|
+
});
|
|
832813
|
+
const client8 = new OpenAI({
|
|
832814
|
+
apiKey: "costrict-managed",
|
|
832815
|
+
baseURL: chatBaseURL,
|
|
832816
|
+
maxRetries: 0,
|
|
832817
|
+
timeout: parseInt(process.env.API_TIMEOUT_MS || String(600 * 1000), 10),
|
|
832818
|
+
dangerouslyAllowBrowser: true,
|
|
832819
|
+
fetchOptions: getProxyFetchOptions({
|
|
832820
|
+
forAnthropicAPI: false
|
|
832821
|
+
}),
|
|
832822
|
+
fetch: costrictFetch,
|
|
832823
|
+
defaultHeaders: {
|
|
832824
|
+
"User-Agent": getUserAgent(),
|
|
832825
|
+
"X-Session-Id": getSessionId(),
|
|
832826
|
+
...options.agentId ? { "X-Agent-Id": options.agentId } : {},
|
|
832827
|
+
...options.parentAgentId ? { "X-Parent-Agent-Id": options.parentAgentId } : {}
|
|
832828
|
+
}
|
|
832829
|
+
});
|
|
832830
|
+
logForDebugging(`[CoStrict] model=${costrictModel}, baseURL=${chatBaseURL}, messages=${openaiMessages.length}, tools=${openaiTools.length}`);
|
|
832831
|
+
const requestBody = {
|
|
832832
|
+
model: costrictModel,
|
|
832833
|
+
messages: openaiMessages,
|
|
832834
|
+
...openaiTools.length > 0 && {
|
|
832835
|
+
tools: openaiTools,
|
|
832836
|
+
...openaiToolChoice && {
|
|
832837
|
+
tool_choice: openaiToolChoice
|
|
832838
|
+
}
|
|
832839
|
+
},
|
|
832840
|
+
stream: true,
|
|
832841
|
+
stream_options: { include_usage: true },
|
|
832842
|
+
[maxTokensParamKey]: maxTokensValue,
|
|
832843
|
+
...enableThinking && {
|
|
832844
|
+
thinking: { type: "enabled" },
|
|
832845
|
+
enable_thinking: true,
|
|
832846
|
+
chat_template_kwargs: { thinking: true }
|
|
832847
|
+
},
|
|
832848
|
+
...!enableThinking && options.temperatureOverride !== undefined && {
|
|
832849
|
+
temperature: options.temperatureOverride
|
|
832850
|
+
}
|
|
832851
|
+
};
|
|
832852
|
+
let streamAttempts = 0;
|
|
832853
|
+
let lastStreamError;
|
|
832854
|
+
while (streamAttempts < MAX_STREAM_RECONNECT_ATTEMPTS2) {
|
|
832855
|
+
streamAttempts++;
|
|
832856
|
+
const retryGenerator = withRetry(() => Promise.resolve(client8), async (c7, _attempt, _context2) => {
|
|
832857
|
+
try {
|
|
832858
|
+
return await c7.chat.completions.create(requestBody, { signal });
|
|
832859
|
+
} catch (err2) {
|
|
832860
|
+
throw wrapOpenAIErrorForRetry(err2);
|
|
832861
|
+
}
|
|
832862
|
+
}, {
|
|
832863
|
+
model: options.model,
|
|
832864
|
+
fallbackModel: options.fallbackModel,
|
|
832865
|
+
thinkingConfig: { type: "disabled" },
|
|
832866
|
+
signal,
|
|
832867
|
+
querySource: options.querySource
|
|
832868
|
+
});
|
|
832869
|
+
let stream6;
|
|
832870
|
+
let e4 = await retryGenerator.next();
|
|
832871
|
+
while (!e4.done) {
|
|
832872
|
+
if (e4.value.type === "system") {
|
|
832873
|
+
yield e4.value;
|
|
832874
|
+
}
|
|
832875
|
+
e4 = await retryGenerator.next();
|
|
832876
|
+
}
|
|
832877
|
+
stream6 = e4.value;
|
|
832878
|
+
const adaptedStream = adaptOpenAIStreamToAnthropic(stream6, costrictModel);
|
|
832879
|
+
try {
|
|
832880
|
+
const producedOutput = yield* consumeCoStrictStream(adaptedStream, costrictModel, tools, options, maxTokensValue);
|
|
832881
|
+
if (!producedOutput && streamAttempts < MAX_STREAM_RECONNECT_ATTEMPTS2) {
|
|
832882
|
+
logForDebugging(`[CoStrict] Stream completed without producing output (attempt ${streamAttempts}/${MAX_STREAM_RECONNECT_ATTEMPTS2}), reconnecting`, { level: "warn" });
|
|
832883
|
+
continue;
|
|
832884
|
+
}
|
|
832885
|
+
return;
|
|
832886
|
+
} catch (error99) {
|
|
832887
|
+
lastStreamError = error99;
|
|
832888
|
+
const producedOutput = error99 instanceof Error && error99.__streamProducedOutput === true;
|
|
832889
|
+
if (!producedOutput && streamAttempts < MAX_STREAM_RECONNECT_ATTEMPTS2 && isRetryableStreamError(error99)) {
|
|
832890
|
+
logForDebugging(`[CoStrict] Stream failed before producing output (attempt ${streamAttempts}/${MAX_STREAM_RECONNECT_ATTEMPTS2}), reconnecting: ${error99 instanceof Error ? error99.message : String(error99)}`, { level: "warn" });
|
|
832891
|
+
continue;
|
|
832892
|
+
}
|
|
832893
|
+
if (producedOutput && !(error99 instanceof APIUserAbortError)) {
|
|
832894
|
+
logForDebugging(`[CoStrict] Streaming failed after producing output, falling back to non-streaming: ${error99 instanceof Error ? error99.message : String(error99)}`, { level: "warn" });
|
|
832895
|
+
try {
|
|
832896
|
+
const nonStreamingBody = toNonStreamingOpenAIRequestBody(requestBody);
|
|
832897
|
+
const completion = yield* executeCoStrictNonStreamingRequest(client8, nonStreamingBody, options, signal);
|
|
832898
|
+
const fallbackStream = adaptOpenAICompletionToAnthropicStream(completion);
|
|
832899
|
+
yield* consumeCoStrictStream(fallbackStream, costrictModel, tools, options, maxTokensValue);
|
|
832900
|
+
return;
|
|
832901
|
+
} catch (fallbackError) {
|
|
832902
|
+
logForDebugging(`[CoStrict] Non-streaming fallback also failed: ${fallbackError instanceof Error ? fallbackError.message : String(fallbackError)}`, { level: "error" });
|
|
832903
|
+
throw fallbackError;
|
|
832904
|
+
}
|
|
832905
|
+
}
|
|
832906
|
+
throw error99;
|
|
832907
|
+
}
|
|
832908
|
+
}
|
|
832909
|
+
if (lastStreamError) {
|
|
832910
|
+
throw lastStreamError;
|
|
832911
|
+
}
|
|
832524
832912
|
} catch (error99) {
|
|
832525
832913
|
const errorMsg = error99 instanceof Error ? error99.message : String(error99);
|
|
832526
832914
|
logForDebugging(`[CoStrict] Error: ${errorMsg}`, { level: "error" });
|
|
@@ -832531,11 +832919,13 @@ async function* queryModelCoStrict(messages, systemPrompt2, tools, signal, optio
|
|
|
832531
832919
|
});
|
|
832532
832920
|
}
|
|
832533
832921
|
}
|
|
832534
|
-
var import_partial_json;
|
|
832922
|
+
var import_partial_json, MAX_STREAM_RECONNECT_ATTEMPTS2 = 3;
|
|
832535
832923
|
var init_provider4 = __esm(() => {
|
|
832536
832924
|
init_openai();
|
|
832925
|
+
init_sdk();
|
|
832537
832926
|
init_withRetry();
|
|
832538
832927
|
init_retry3();
|
|
832928
|
+
init_nonStreamingFallback();
|
|
832539
832929
|
init_proxy();
|
|
832540
832930
|
init_http4();
|
|
832541
832931
|
init_state();
|
|
@@ -832558,7 +832948,7 @@ var init_provider4 = __esm(() => {
|
|
|
832558
832948
|
});
|
|
832559
832949
|
|
|
832560
832950
|
// src/services/api/claude.ts
|
|
832561
|
-
import { randomUUID as
|
|
832951
|
+
import { randomUUID as randomUUID56 } from "crypto";
|
|
832562
832952
|
import { existsSync as existsSync32, unlinkSync as unlinkSync10 } from "fs";
|
|
832563
832953
|
function getExtraBodyParams(betaHeaders) {
|
|
832564
832954
|
const extraBodyStr = process.env.CLAUDE_CODE_EXTRA_BODY;
|
|
@@ -833117,7 +833507,7 @@ To invoke any tool listed above, use ExecuteExtraTool with {"tool_name": "<name>
|
|
|
833117
833507
|
const alwaysFlag = getBreakCacheAlwaysPath();
|
|
833118
833508
|
const shouldBreak = existsSync32(onceMarker) || existsSync32(alwaysFlag);
|
|
833119
833509
|
if (shouldBreak) {
|
|
833120
|
-
const nonce =
|
|
833510
|
+
const nonce = randomUUID56();
|
|
833121
833511
|
systemPrompt2 = asSystemPrompt([
|
|
833122
833512
|
...systemPrompt2,
|
|
833123
833513
|
`<!-- cache-break nonce: ${nonce} -->`
|
|
@@ -833388,7 +833778,7 @@ To invoke any tool listed above, use ExecuteExtraTool with {"tool_name": "<name>
|
|
|
833388
833778
|
if (!options.agentId) {
|
|
833389
833779
|
headlessProfilerCheckpoint("api_request_sent");
|
|
833390
833780
|
}
|
|
833391
|
-
clientRequestId = getAPIProvider() === "firstParty" && isFirstPartyAnthropicBaseUrl() ?
|
|
833781
|
+
clientRequestId = getAPIProvider() === "firstParty" && isFirstPartyAnthropicBaseUrl() ? randomUUID56() : undefined;
|
|
833392
833782
|
const result = await anthropic.beta.messages.create({ ...params, stream: true }, {
|
|
833393
833783
|
signal,
|
|
833394
833784
|
...clientRequestId && {
|
|
@@ -833471,7 +833861,7 @@ To invoke any tool listed above, use ExecuteExtraTool with {"tool_name": "<name>
|
|
|
833471
833861
|
switch (part.type) {
|
|
833472
833862
|
case "message_start": {
|
|
833473
833863
|
partialMessage = part.message;
|
|
833474
|
-
messageUUID =
|
|
833864
|
+
messageUUID = randomUUID56();
|
|
833475
833865
|
ttftMs = Date.now() - start;
|
|
833476
833866
|
usage2 = updateUsage(usage2, part.message?.usage);
|
|
833477
833867
|
if (process.env.USER_TYPE === "sf" && "research" in part.message) {
|
|
@@ -833642,7 +834032,7 @@ To invoke any tool listed above, use ExecuteExtraTool with {"tool_name": "<name>
|
|
|
833642
834032
|
},
|
|
833643
834033
|
requestId: streamRequestId ?? undefined,
|
|
833644
834034
|
type: "assistant",
|
|
833645
|
-
uuid: messageUUID ||
|
|
834035
|
+
uuid: messageUUID || randomUUID56(),
|
|
833646
834036
|
timestamp: new Date().toISOString(),
|
|
833647
834037
|
...process.env.USER_TYPE === "sf" && research !== undefined && { research },
|
|
833648
834038
|
...advisorModel && { advisorModel }
|
|
@@ -833833,7 +834223,7 @@ To invoke any tool listed above, use ExecuteExtraTool with {"tool_name": "<name>
|
|
|
833833
834223
|
},
|
|
833834
834224
|
requestId: streamRequestId ?? undefined,
|
|
833835
834225
|
type: "assistant",
|
|
833836
|
-
uuid:
|
|
834226
|
+
uuid: randomUUID56(),
|
|
833837
834227
|
timestamp: new Date().toISOString(),
|
|
833838
834228
|
...process.env.USER_TYPE === "sf" && research !== undefined && {
|
|
833839
834229
|
research
|
|
@@ -833890,7 +834280,7 @@ To invoke any tool listed above, use ExecuteExtraTool with {"tool_name": "<name>
|
|
|
833890
834280
|
},
|
|
833891
834281
|
requestId: streamRequestId ?? undefined,
|
|
833892
834282
|
type: "assistant",
|
|
833893
|
-
uuid:
|
|
834283
|
+
uuid: randomUUID56(),
|
|
833894
834284
|
timestamp: new Date().toISOString(),
|
|
833895
834285
|
...process.env.USER_TYPE === "sf" && research !== undefined && { research },
|
|
833896
834286
|
...advisorModel && { advisorModel }
|
|
@@ -834545,7 +834935,7 @@ async function sideQuery(opts) {
|
|
|
834545
834935
|
betas.push(STRUCTURED_OUTPUTS_BETA_HEADER);
|
|
834546
834936
|
}
|
|
834547
834937
|
const messageText = extractFirstUserMessageText(messages);
|
|
834548
|
-
const fingerprint = computeFingerprint(messageText, "4.2.8-
|
|
834938
|
+
const fingerprint = computeFingerprint(messageText, "4.2.8-beta2");
|
|
834549
834939
|
const attributionHeader = getAttributionHeader(fingerprint);
|
|
834550
834940
|
const systemBlocks = [
|
|
834551
834941
|
attributionHeader ? { type: "text", text: attributionHeader } : null,
|
|
@@ -837333,9 +837723,9 @@ function matchesKeepGoingKeyword(input4) {
|
|
|
837333
837723
|
}
|
|
837334
837724
|
|
|
837335
837725
|
// src/utils/processUserInput/processTextPrompt.ts
|
|
837336
|
-
import { randomUUID as
|
|
837726
|
+
import { randomUUID as randomUUID57 } from "crypto";
|
|
837337
837727
|
function processTextPrompt(input4, imageContentBlocks, imagePasteIds, attachmentMessages, uuid9, permissionMode, isMeta) {
|
|
837338
|
-
const promptId =
|
|
837728
|
+
const promptId = randomUUID57();
|
|
837339
837729
|
setPromptId(promptId);
|
|
837340
837730
|
const userPromptText = typeof input4 === "string" ? input4 : input4.find((block) => block.type === "text")?.text || "";
|
|
837341
837731
|
startInteractionSpan(userPromptText);
|
|
@@ -837432,7 +837822,7 @@ var exports_processBashCommand = {};
|
|
|
837432
837822
|
__export(exports_processBashCommand, {
|
|
837433
837823
|
processBashCommand: () => processBashCommand
|
|
837434
837824
|
});
|
|
837435
|
-
import { randomUUID as
|
|
837825
|
+
import { randomUUID as randomUUID58 } from "crypto";
|
|
837436
837826
|
async function processBashCommand(inputString, precedingInputBlocks, attachmentMessages, context26, setToolJSX) {
|
|
837437
837827
|
const command11 = getValueFromInput(inputString);
|
|
837438
837828
|
const usePowerShell = isPowerShellToolEnabled() && resolveDefaultShell() === "powershell";
|
|
@@ -837485,7 +837875,7 @@ async function processBashCommand(inputString, precedingInputBlocks, attachmentM
|
|
|
837485
837875
|
throw new Error("No result received from shell command");
|
|
837486
837876
|
}
|
|
837487
837877
|
const stderr = data.stderr;
|
|
837488
|
-
const mapped = await processToolResultBlock(shellTool, { ...data, stderr: "" },
|
|
837878
|
+
const mapped = await processToolResultBlock(shellTool, { ...data, stderr: "" }, randomUUID58());
|
|
837489
837879
|
const stdout = typeof mapped.content === "string" ? mapped.content : escapeXml(data.stdout);
|
|
837490
837880
|
return {
|
|
837491
837881
|
messages: [
|
|
@@ -837553,7 +837943,7 @@ var init_processBashCommand = __esm(() => {
|
|
|
837553
837943
|
});
|
|
837554
837944
|
|
|
837555
837945
|
// src/utils/processUserInput/processUserInput.ts
|
|
837556
|
-
import { randomUUID as
|
|
837946
|
+
import { randomUUID as randomUUID59 } from "crypto";
|
|
837557
837947
|
async function processUserInput({
|
|
837558
837948
|
input: input4,
|
|
837559
837949
|
preExpansionInput,
|
|
@@ -837616,7 +838006,7 @@ Original prompt: ${input4}`, "warning")
|
|
|
837616
838006
|
type: "hook_additional_context",
|
|
837617
838007
|
content: hookResult.additionalContexts.map(applyTruncation),
|
|
837618
838008
|
hookName: "UserPromptSubmit",
|
|
837619
|
-
toolUseID: `hook-${
|
|
838009
|
+
toolUseID: `hook-${randomUUID59()}`,
|
|
837620
838010
|
hookEvent: "UserPromptSubmit"
|
|
837621
838011
|
}));
|
|
837622
838012
|
}
|
|
@@ -837898,7 +838288,7 @@ var init_queryContext = __esm(() => {
|
|
|
837898
838288
|
});
|
|
837899
838289
|
|
|
837900
838290
|
// src/utils/messages/systemInit.ts
|
|
837901
|
-
import { randomUUID as
|
|
838291
|
+
import { randomUUID as randomUUID60 } from "crypto";
|
|
837902
838292
|
function sdkCompatToolName(name3) {
|
|
837903
838293
|
return name3 === AGENT_TOOL_NAME ? LEGACY_AGENT_TOOL_NAME : name3;
|
|
837904
838294
|
}
|
|
@@ -837920,7 +838310,7 @@ function buildSystemInitMessage(inputs) {
|
|
|
837920
838310
|
slash_commands: inputs.commands.filter((c7) => c7.userInvocable !== false).map((c7) => c7.name),
|
|
837921
838311
|
apiKeySource: getAnthropicApiKeyWithSource().source,
|
|
837922
838312
|
betas: getSdkBetas(),
|
|
837923
|
-
claude_code_version: "4.2.8-
|
|
838313
|
+
claude_code_version: "4.2.8-beta2",
|
|
837924
838314
|
output_style: outputStyle2,
|
|
837925
838315
|
agents: inputs.agents.map((agent) => agent.agentType),
|
|
837926
838316
|
skills: inputs.skills.filter((s) => s.userInvocable !== false).map((skill) => skill.name),
|
|
@@ -837929,7 +838319,7 @@ function buildSystemInitMessage(inputs) {
|
|
|
837929
838319
|
path: plugin2.path,
|
|
837930
838320
|
source: plugin2.source
|
|
837931
838321
|
})),
|
|
837932
|
-
uuid:
|
|
838322
|
+
uuid: randomUUID60()
|
|
837933
838323
|
};
|
|
837934
838324
|
if (false) {}
|
|
837935
838325
|
initMessage.fast_mode_state = getFastModeState(inputs.model, inputs.fastMode);
|
|
@@ -837952,7 +838342,7 @@ __export(exports_MessageSelector, {
|
|
|
837952
838342
|
messagesAfterAreOnlySynthetic: () => messagesAfterAreOnlySynthetic,
|
|
837953
838343
|
MessageSelector: () => MessageSelector
|
|
837954
838344
|
});
|
|
837955
|
-
import { randomUUID as
|
|
838345
|
+
import { randomUUID as randomUUID61 } from "crypto";
|
|
837956
838346
|
import * as path48 from "path";
|
|
837957
838347
|
function isTextBlock2(block) {
|
|
837958
838348
|
return block.type === "text";
|
|
@@ -837972,7 +838362,7 @@ function MessageSelector({
|
|
|
837972
838362
|
const fileHistory = useAppState((s) => s.fileHistory);
|
|
837973
838363
|
const [error99, setError] = import_react225.useState(undefined);
|
|
837974
838364
|
const isFileHistoryEnabled = fileHistoryEnabled();
|
|
837975
|
-
const currentUUID = import_react225.useMemo(
|
|
838365
|
+
const currentUUID = import_react225.useMemo(randomUUID61, []);
|
|
837976
838366
|
const messageOptions = import_react225.useMemo(() => [
|
|
837977
838367
|
...messages.filter(selectableUserMessagesFilter),
|
|
837978
838368
|
{
|
|
@@ -838734,7 +839124,7 @@ var init_MessageSelector = __esm(() => {
|
|
|
838734
839124
|
});
|
|
838735
839125
|
|
|
838736
839126
|
// src/QueryEngine.ts
|
|
838737
|
-
import { randomUUID as
|
|
839127
|
+
import { randomUUID as randomUUID62 } from "crypto";
|
|
838738
839128
|
|
|
838739
839129
|
class QueryEngine {
|
|
838740
839130
|
config;
|
|
@@ -839045,7 +839435,7 @@ class QueryEngine {
|
|
|
839045
839435
|
modelUsage: getModelUsage(),
|
|
839046
839436
|
permission_denials: this.permissionDenials,
|
|
839047
839437
|
fast_mode_state: getFastModeState(mainLoopModel, initialAppState.fastMode),
|
|
839048
|
-
uuid:
|
|
839438
|
+
uuid: randomUUID62()
|
|
839049
839439
|
};
|
|
839050
839440
|
return;
|
|
839051
839441
|
}
|
|
@@ -839172,7 +839562,7 @@ class QueryEngine {
|
|
|
839172
839562
|
event,
|
|
839173
839563
|
session_id: getSessionId(),
|
|
839174
839564
|
parent_tool_use_id: null,
|
|
839175
|
-
uuid:
|
|
839565
|
+
uuid: randomUUID62()
|
|
839176
839566
|
};
|
|
839177
839567
|
break;
|
|
839178
839568
|
}
|
|
@@ -839206,7 +839596,7 @@ class QueryEngine {
|
|
|
839206
839596
|
modelUsage: getModelUsage(),
|
|
839207
839597
|
permission_denials: this.permissionDenials,
|
|
839208
839598
|
fast_mode_state: getFastModeState(mainLoopModel, initialAppState.fastMode),
|
|
839209
|
-
uuid:
|
|
839599
|
+
uuid: randomUUID62(),
|
|
839210
839600
|
errors: [
|
|
839211
839601
|
`Reached maximum number of turns (${attachment.maxTurns})`
|
|
839212
839602
|
]
|
|
@@ -839307,7 +839697,7 @@ class QueryEngine {
|
|
|
839307
839697
|
modelUsage: getModelUsage(),
|
|
839308
839698
|
permission_denials: this.permissionDenials,
|
|
839309
839699
|
fast_mode_state: getFastModeState(mainLoopModel, initialAppState.fastMode),
|
|
839310
|
-
uuid:
|
|
839700
|
+
uuid: randomUUID62(),
|
|
839311
839701
|
errors: [
|
|
839312
839702
|
`Reached maximum budget ($${maxBudgetUsd}). Increase the limit with --max-budget-usd or start a new session.`
|
|
839313
839703
|
]
|
|
@@ -839338,7 +839728,7 @@ class QueryEngine {
|
|
|
839338
839728
|
modelUsage: getModelUsage(),
|
|
839339
839729
|
permission_denials: this.permissionDenials,
|
|
839340
839730
|
fast_mode_state: getFastModeState(mainLoopModel, initialAppState.fastMode),
|
|
839341
|
-
uuid:
|
|
839731
|
+
uuid: randomUUID62(),
|
|
839342
839732
|
errors: [
|
|
839343
839733
|
`Failed to provide valid structured output after ${maxRetries} attempts`
|
|
839344
839734
|
]
|
|
@@ -839371,7 +839761,7 @@ class QueryEngine {
|
|
|
839371
839761
|
modelUsage: getModelUsage(),
|
|
839372
839762
|
permission_denials: this.permissionDenials,
|
|
839373
839763
|
fast_mode_state: getFastModeState(mainLoopModel, initialAppState.fastMode),
|
|
839374
|
-
uuid:
|
|
839764
|
+
uuid: randomUUID62(),
|
|
839375
839765
|
errors: (() => {
|
|
839376
839766
|
const all4 = getInMemoryErrors();
|
|
839377
839767
|
const start = errorLogWatermark ? all4.lastIndexOf(errorLogWatermark) + 1 : 0;
|
|
@@ -839408,7 +839798,7 @@ class QueryEngine {
|
|
|
839408
839798
|
permission_denials: this.permissionDenials,
|
|
839409
839799
|
structured_output: structuredOutputFromTool,
|
|
839410
839800
|
fast_mode_state: getFastModeState(mainLoopModel, initialAppState.fastMode),
|
|
839411
|
-
uuid:
|
|
839801
|
+
uuid: randomUUID62()
|
|
839412
839802
|
};
|
|
839413
839803
|
}
|
|
839414
839804
|
interrupt() {
|
|
@@ -840698,7 +841088,7 @@ function formatResourceLink(name3, uri3) {
|
|
|
840698
841088
|
}
|
|
840699
841089
|
|
|
840700
841090
|
// src/services/acp/agent.ts
|
|
840701
|
-
import { randomUUID as
|
|
841091
|
+
import { randomUUID as randomUUID63 } from "crypto";
|
|
840702
841092
|
|
|
840703
841093
|
class AcpAgent {
|
|
840704
841094
|
conn;
|
|
@@ -840804,7 +841194,7 @@ class AcpAgent {
|
|
|
840804
841194
|
}
|
|
840805
841195
|
const promptCancelGeneration = session2.cancelGeneration;
|
|
840806
841196
|
if (session2.promptRunning) {
|
|
840807
|
-
const promptUuid =
|
|
841197
|
+
const promptUuid = randomUUID63();
|
|
840808
841198
|
const cancelled = await new Promise((resolve55) => {
|
|
840809
841199
|
session2.pendingQueue.push(promptUuid);
|
|
840810
841200
|
session2.pendingMessages.set(promptUuid, { resolve: resolve55 });
|
|
@@ -840917,7 +841307,7 @@ class AcpAgent {
|
|
|
840917
841307
|
}
|
|
840918
841308
|
async createSession(params, opts = {}) {
|
|
840919
841309
|
enableConfigs();
|
|
840920
|
-
const sessionId = opts.sessionId ??
|
|
841310
|
+
const sessionId = opts.sessionId ?? randomUUID63();
|
|
840921
841311
|
const cwd2 = params.cwd;
|
|
840922
841312
|
setOriginalCwd(cwd2);
|
|
840923
841313
|
const previousProcessCwd = process.cwd();
|
|
@@ -841814,7 +842204,7 @@ var init_media = __esm(() => {
|
|
|
841814
842204
|
});
|
|
841815
842205
|
|
|
841816
842206
|
// packages/weixin/src/send.ts
|
|
841817
|
-
import { randomUUID as
|
|
842207
|
+
import { randomUUID as randomUUID64 } from "crypto";
|
|
841818
842208
|
function stripCodeBlocks(text2) {
|
|
841819
842209
|
let result = "";
|
|
841820
842210
|
let i6 = 0;
|
|
@@ -841857,7 +842247,7 @@ function markdownToPlainText(text2) {
|
|
|
841857
842247
|
`).trim();
|
|
841858
842248
|
}
|
|
841859
842249
|
async function sendText2(params) {
|
|
841860
|
-
const clientId =
|
|
842250
|
+
const clientId = randomUUID64();
|
|
841861
842251
|
await sendMessage3(params.baseUrl, params.token, {
|
|
841862
842252
|
to_user_id: params.to,
|
|
841863
842253
|
from_user_id: "",
|
|
@@ -841877,7 +842267,7 @@ async function sendText2(params) {
|
|
|
841877
842267
|
async function sendItems(params) {
|
|
841878
842268
|
let lastClientId = "";
|
|
841879
842269
|
for (const item of params.items) {
|
|
841880
|
-
lastClientId =
|
|
842270
|
+
lastClientId = randomUUID64();
|
|
841881
842271
|
await sendMessage3(params.baseUrl, params.token, {
|
|
841882
842272
|
to_user_id: params.to,
|
|
841883
842273
|
from_user_id: "",
|
|
@@ -842769,7 +843159,7 @@ function appendToLog(path50, message2) {
|
|
|
842769
843159
|
cwd: getFsImplementation().cwd(),
|
|
842770
843160
|
userType: process.env.USER_TYPE,
|
|
842771
843161
|
sessionId: getSessionId(),
|
|
842772
|
-
version: "4.2.8-
|
|
843162
|
+
version: "4.2.8-beta2"
|
|
842773
843163
|
};
|
|
842774
843164
|
getLogWriter(path50).write(messageWithTimestamp);
|
|
842775
843165
|
}
|
|
@@ -850864,7 +851254,7 @@ var init_FileEditToolDiff = __esm(() => {
|
|
|
850864
851254
|
});
|
|
850865
851255
|
|
|
850866
851256
|
// src/hooks/useDiffInIDE.ts
|
|
850867
|
-
import { randomUUID as
|
|
851257
|
+
import { randomUUID as randomUUID65 } from "crypto";
|
|
850868
851258
|
import { basename as basename57 } from "path";
|
|
850869
851259
|
function useDiffInIDE({
|
|
850870
851260
|
onChange,
|
|
@@ -850875,7 +851265,7 @@ function useDiffInIDE({
|
|
|
850875
851265
|
}) {
|
|
850876
851266
|
const isUnmounted = import_react241.useRef(false);
|
|
850877
851267
|
const [hasError, setHasError] = import_react241.useState(false);
|
|
850878
|
-
const sha = import_react241.useMemo(() =>
|
|
851268
|
+
const sha = import_react241.useMemo(() => randomUUID65().slice(0, 6), []);
|
|
850879
851269
|
const tabName = import_react241.useMemo(() => `\u273B [CoStrict] ${basename57(filePath)} (${sha}) \u29C9`, [filePath, sha]);
|
|
850880
851270
|
const shouldShowDiffInIDE = hasAccessToIDEExtensionDiffFeature(toolUseContext.options.mcpClients) && getGlobalConfig().diffTool === "auto" && !filePath.endsWith(".ipynb");
|
|
850881
851271
|
const ideName = getConnectedIdeName(toolUseContext.options.mcpClients) ?? "IDE";
|
|
@@ -861070,7 +861460,7 @@ var init_ThinkingToggle = __esm(() => {
|
|
|
861070
861460
|
});
|
|
861071
861461
|
|
|
861072
861462
|
// src/components/teams/TeamsDialog.tsx
|
|
861073
|
-
import { randomUUID as
|
|
861463
|
+
import { randomUUID as randomUUID66 } from "crypto";
|
|
861074
861464
|
function TeamsDialog({ initialTeams, onDone }) {
|
|
861075
861465
|
useRegisterOverlay("teams-dialog");
|
|
861076
861466
|
const setAppState = useSetAppState();
|
|
@@ -861464,7 +861854,7 @@ async function killTeammate(paneId, backendType, teamName, teammateId, teammateN
|
|
|
861464
861854
|
messages: [
|
|
861465
861855
|
...prev.inbox.messages,
|
|
861466
861856
|
{
|
|
861467
|
-
id:
|
|
861857
|
+
id: randomUUID66(),
|
|
861468
861858
|
from: "system",
|
|
861469
861859
|
text: jsonStringify({
|
|
861470
861860
|
type: "teammate_terminated",
|
|
@@ -863571,7 +863961,7 @@ function buildStatusLineCommandInput(permissionMode, exceeds200kTokens, settings
|
|
|
863571
863961
|
project_dir: getOriginalCwd(),
|
|
863572
863962
|
added_dirs: addedDirs
|
|
863573
863963
|
},
|
|
863574
|
-
version: "4.2.8-
|
|
863964
|
+
version: "4.2.8-beta2",
|
|
863575
863965
|
output_style: {
|
|
863576
863966
|
name: outputStyleName
|
|
863577
863967
|
},
|
|
@@ -867661,11 +868051,11 @@ var init_PromptInput = __esm(() => {
|
|
|
867661
868051
|
});
|
|
867662
868052
|
|
|
867663
868053
|
// src/remote/remotePermissionBridge.ts
|
|
867664
|
-
import { randomUUID as
|
|
868054
|
+
import { randomUUID as randomUUID67 } from "crypto";
|
|
867665
868055
|
function createSyntheticAssistantMessage(request3, requestId2) {
|
|
867666
868056
|
return {
|
|
867667
868057
|
type: "assistant",
|
|
867668
|
-
uuid:
|
|
868058
|
+
uuid: randomUUID67(),
|
|
867669
868059
|
message: {
|
|
867670
868060
|
id: `remote-${requestId2}`,
|
|
867671
868061
|
type: "message",
|
|
@@ -868182,7 +868572,7 @@ var init_useDirectConnect = __esm(() => {
|
|
|
868182
868572
|
});
|
|
868183
868573
|
|
|
868184
868574
|
// src/hooks/useSSHSession.ts
|
|
868185
|
-
import { randomUUID as
|
|
868575
|
+
import { randomUUID as randomUUID68 } from "crypto";
|
|
868186
868576
|
function useSSHSession({
|
|
868187
868577
|
session: session2,
|
|
868188
868578
|
setMessages,
|
|
@@ -868280,7 +868670,7 @@ function useSSHSession({
|
|
|
868280
868670
|
subtype: "informational",
|
|
868281
868671
|
content: `SSH connection dropped \u2014 reconnecting (attempt ${attempt}/${max2})...`,
|
|
868282
868672
|
timestamp: new Date().toISOString(),
|
|
868283
|
-
uuid:
|
|
868673
|
+
uuid: randomUUID68(),
|
|
868284
868674
|
level: "warning"
|
|
868285
868675
|
};
|
|
868286
868676
|
setMessages((prev) => [...prev, msg]);
|
|
@@ -868385,7 +868775,7 @@ var init_sessionHistory = __esm(() => {
|
|
|
868385
868775
|
});
|
|
868386
868776
|
|
|
868387
868777
|
// src/hooks/useAssistantHistory.ts
|
|
868388
|
-
import { randomUUID as
|
|
868778
|
+
import { randomUUID as randomUUID69 } from "crypto";
|
|
868389
868779
|
function pageToMessages(page) {
|
|
868390
868780
|
const out = [];
|
|
868391
868781
|
for (const ev of page.events) {
|
|
@@ -868410,7 +868800,7 @@ function useAssistantHistory({
|
|
|
868410
868800
|
const inflightRef = import_react295.useRef(false);
|
|
868411
868801
|
const anchorRef = import_react295.useRef(null);
|
|
868412
868802
|
const fillBudgetRef = import_react295.useRef(0);
|
|
868413
|
-
const sentinelUuidRef = import_react295.useRef(
|
|
868803
|
+
const sentinelUuidRef = import_react295.useRef(randomUUID69());
|
|
868414
868804
|
function mkSentinel(text2) {
|
|
868415
868805
|
return {
|
|
868416
868806
|
type: "system",
|
|
@@ -878657,7 +879047,7 @@ var init_coordinatorHandler = __esm(() => {
|
|
|
878657
879047
|
});
|
|
878658
879048
|
|
|
878659
879049
|
// src/utils/pipePermissionRelay.ts
|
|
878660
|
-
import { randomUUID as
|
|
879050
|
+
import { randomUUID as randomUUID70 } from "crypto";
|
|
878661
879051
|
function getPipeSender() {
|
|
878662
879052
|
return _pipeRelay ?? null;
|
|
878663
879053
|
}
|
|
@@ -878667,7 +879057,7 @@ function tryRelayPipePermissionRequest(toolUseConfirm, onResponse2) {
|
|
|
878667
879057
|
const send = getPipeSender();
|
|
878668
879058
|
if (!send)
|
|
878669
879059
|
return null;
|
|
878670
|
-
const requestId2 =
|
|
879060
|
+
const requestId2 = randomUUID70();
|
|
878671
879061
|
const payload = {
|
|
878672
879062
|
requestId: requestId2,
|
|
878673
879063
|
toolName: toolUseConfirm.tool.name,
|
|
@@ -881031,7 +881421,7 @@ var init_inboxPollerIdentity = __esm(() => {
|
|
|
881031
881421
|
});
|
|
881032
881422
|
|
|
881033
881423
|
// src/hooks/useInboxPoller.ts
|
|
881034
|
-
import { randomUUID as
|
|
881424
|
+
import { randomUUID as randomUUID71 } from "crypto";
|
|
881035
881425
|
function useInboxPoller({
|
|
881036
881426
|
enabled: enabled2,
|
|
881037
881427
|
isLoading,
|
|
@@ -881435,7 +881825,7 @@ function useInboxPoller({
|
|
|
881435
881825
|
messages: [
|
|
881436
881826
|
...prev.inbox.messages,
|
|
881437
881827
|
{
|
|
881438
|
-
id:
|
|
881828
|
+
id: randomUUID71(),
|
|
881439
881829
|
from: "system",
|
|
881440
881830
|
text: jsonStringify({
|
|
881441
881831
|
type: "teammate_terminated",
|
|
@@ -881475,7 +881865,7 @@ ${messageContent}
|
|
|
881475
881865
|
messages: [
|
|
881476
881866
|
...prev.inbox.messages,
|
|
881477
881867
|
...regularMessages.map((m3) => ({
|
|
881478
|
-
id:
|
|
881868
|
+
id: randomUUID71(),
|
|
881479
881869
|
from: m3.from,
|
|
881480
881870
|
text: m3.text,
|
|
881481
881871
|
timestamp: m3.timestamp,
|
|
@@ -882150,7 +882540,7 @@ async function submitTranscriptShare(messages, trigger, appearanceId) {
|
|
|
882150
882540
|
} catch {}
|
|
882151
882541
|
const data = {
|
|
882152
882542
|
trigger,
|
|
882153
|
-
version: "4.2.8-
|
|
882543
|
+
version: "4.2.8-beta2",
|
|
882154
882544
|
platform: process.platform,
|
|
882155
882545
|
transcript,
|
|
882156
882546
|
subagentTranscripts: Object.keys(subagentTranscripts).length > 0 ? subagentTranscripts : undefined,
|
|
@@ -882201,7 +882591,7 @@ var init_submitTranscriptShare = __esm(() => {
|
|
|
882201
882591
|
});
|
|
882202
882592
|
|
|
882203
882593
|
// src/components/FeedbackSurvey/useSurveyState.tsx
|
|
882204
|
-
import { randomUUID as
|
|
882594
|
+
import { randomUUID as randomUUID72 } from "crypto";
|
|
882205
882595
|
function useSurveyState({
|
|
882206
882596
|
hideThanksAfterMs,
|
|
882207
882597
|
onOpen,
|
|
@@ -882212,7 +882602,7 @@ function useSurveyState({
|
|
|
882212
882602
|
}) {
|
|
882213
882603
|
const [state4, setState] = import_react324.useState("closed");
|
|
882214
882604
|
const [lastResponse, setLastResponse] = import_react324.useState(null);
|
|
882215
|
-
const appearanceId = import_react324.useRef(
|
|
882605
|
+
const appearanceId = import_react324.useRef(randomUUID72());
|
|
882216
882606
|
const lastResponseRef = import_react324.useRef(null);
|
|
882217
882607
|
const showThanksThenClose = import_react324.useCallback(() => {
|
|
882218
882608
|
setState("thanks");
|
|
@@ -882230,7 +882620,7 @@ function useSurveyState({
|
|
|
882230
882620
|
return;
|
|
882231
882621
|
}
|
|
882232
882622
|
setState("open");
|
|
882233
|
-
appearanceId.current =
|
|
882623
|
+
appearanceId.current = randomUUID72();
|
|
882234
882624
|
onOpen(appearanceId.current);
|
|
882235
882625
|
}, [state4, onOpen]);
|
|
882236
882626
|
const handleSelect = import_react324.useCallback((selected) => {
|
|
@@ -883405,7 +883795,7 @@ function getReleaseType(current2, latest) {
|
|
|
883405
883795
|
return "patch";
|
|
883406
883796
|
}
|
|
883407
883797
|
async function checkNewAutoUpdate(callbacks) {
|
|
883408
|
-
const currentVersion = "4.2.8-
|
|
883798
|
+
const currentVersion = "4.2.8-beta2";
|
|
883409
883799
|
logForDebugging(`[newAutoUpdater] checking, current: ${currentVersion}`);
|
|
883410
883800
|
if (isNewAutoUpdaterDisabled()) {
|
|
883411
883801
|
return { action: "skip", currentVersion, latestVersion: null };
|
|
@@ -884975,21 +885365,21 @@ function extractLspInfoFromManifest(lspServers) {
|
|
|
884975
885365
|
}
|
|
884976
885366
|
return extractFromServerConfigRecord(lspServers);
|
|
884977
885367
|
}
|
|
884978
|
-
function
|
|
885368
|
+
function isRecord8(value) {
|
|
884979
885369
|
return typeof value === "object" && value !== null;
|
|
884980
885370
|
}
|
|
884981
885371
|
function extractFromServerConfigRecord(serverConfigs) {
|
|
884982
885372
|
const extensions5 = new Set;
|
|
884983
885373
|
let command11 = null;
|
|
884984
885374
|
for (const [_serverName, config11] of Object.entries(serverConfigs)) {
|
|
884985
|
-
if (!
|
|
885375
|
+
if (!isRecord8(config11)) {
|
|
884986
885376
|
continue;
|
|
884987
885377
|
}
|
|
884988
885378
|
if (!command11 && typeof config11.command === "string") {
|
|
884989
885379
|
command11 = config11.command;
|
|
884990
885380
|
}
|
|
884991
885381
|
const extMapping = config11.extensionToLanguage;
|
|
884992
|
-
if (
|
|
885382
|
+
if (isRecord8(extMapping)) {
|
|
884993
885383
|
for (const ext of Object.keys(extMapping)) {
|
|
884994
885384
|
extensions5.add(ext.toLowerCase());
|
|
884995
885385
|
}
|
|
@@ -889797,7 +890187,7 @@ import { spawnSync as spawnSync9 } from "child_process";
|
|
|
889797
890187
|
import { dirname as dirname84, join as join216 } from "path";
|
|
889798
890188
|
import { tmpdir as tmpdir21 } from "os";
|
|
889799
890189
|
import { writeFile as writeFile75 } from "fs/promises";
|
|
889800
|
-
import { randomUUID as
|
|
890190
|
+
import { randomUUID as randomUUID73 } from "crypto";
|
|
889801
890191
|
function median(values4) {
|
|
889802
890192
|
const sorted = [...values4].sort((a5, b6) => a5 - b6);
|
|
889803
890193
|
const mid = Math.floor(sorted.length / 2);
|
|
@@ -890487,7 +890877,7 @@ function REPL({
|
|
|
890487
890877
|
const [isMessageSelectorVisible, setIsMessageSelectorVisible] = import_react356.useState(false);
|
|
890488
890878
|
const [messageSelectorPreselect, setMessageSelectorPreselect] = import_react356.useState(undefined);
|
|
890489
890879
|
const [showCostDialog, setShowCostDialog] = import_react356.useState(false);
|
|
890490
|
-
const [conversationId, setConversationId2] = import_react356.useState(
|
|
890880
|
+
const [conversationId, setConversationId2] = import_react356.useState(randomUUID73());
|
|
890491
890881
|
const [idleReturnPending, setIdleReturnPending] = import_react356.useState(null);
|
|
890492
890882
|
const skipIdleCheckRef = import_react356.useRef(false);
|
|
890493
890883
|
const lastQueryCompletionTimeRef = import_react356.useRef(lastQueryCompletionTime);
|
|
@@ -891243,7 +891633,7 @@ ${t("repl.sandboxRequired", { reason })}
|
|
|
891243
891633
|
} else {
|
|
891244
891634
|
setMessages(() => [newMessage]);
|
|
891245
891635
|
}
|
|
891246
|
-
setConversationId2(
|
|
891636
|
+
setConversationId2(randomUUID73());
|
|
891247
891637
|
if (true) {
|
|
891248
891638
|
proactiveModule8?.setContextBlocked(false);
|
|
891249
891639
|
}
|
|
@@ -891334,7 +891724,7 @@ ${t("repl.sandboxRequired", { reason })}
|
|
|
891334
891724
|
});
|
|
891335
891725
|
if (!shouldQuery) {
|
|
891336
891726
|
if (newMessages.some(isCompactBoundaryMessage)) {
|
|
891337
|
-
setConversationId2(
|
|
891727
|
+
setConversationId2(randomUUID73());
|
|
891338
891728
|
if (true) {
|
|
891339
891729
|
proactiveModule8?.setContextBlocked(false);
|
|
891340
891730
|
}
|
|
@@ -892017,7 +892407,7 @@ ${t("repl.sandboxRequired", { reason })}
|
|
|
892017
892407
|
rewindToMessageIndex: messageIndex
|
|
892018
892408
|
});
|
|
892019
892409
|
setMessages(prev.slice(0, messageIndex));
|
|
892020
|
-
setConversationId2(
|
|
892410
|
+
setConversationId2(randomUUID73());
|
|
892021
892411
|
resetMicrocompactState();
|
|
892022
892412
|
if (false) {}
|
|
892023
892413
|
const permMode = message2.permissionMode;
|
|
@@ -893403,7 +893793,7 @@ ${t("repl.suspended")}
|
|
|
893403
893793
|
if (true) {
|
|
893404
893794
|
proactiveModule8?.setContextBlocked(false);
|
|
893405
893795
|
}
|
|
893406
|
-
setConversationId2(
|
|
893796
|
+
setConversationId2(randomUUID73());
|
|
893407
893797
|
runPostCompactCleanup(context26.options.querySource);
|
|
893408
893798
|
if (direction === "from") {
|
|
893409
893799
|
const r4 = textForResubmit(message2);
|
|
@@ -894281,7 +894671,7 @@ function WelcomeV2() {
|
|
|
894281
894671
|
dimColor: true,
|
|
894282
894672
|
children: [
|
|
894283
894673
|
"v",
|
|
894284
|
-
"4.2.8-
|
|
894674
|
+
"4.2.8-beta2",
|
|
894285
894675
|
" "
|
|
894286
894676
|
]
|
|
894287
894677
|
})
|
|
@@ -894347,7 +894737,7 @@ function WelcomeV2() {
|
|
|
894347
894737
|
dimColor: true,
|
|
894348
894738
|
children: [
|
|
894349
894739
|
"v",
|
|
894350
|
-
"4.2.8-
|
|
894740
|
+
"4.2.8-beta2",
|
|
894351
894741
|
" "
|
|
894352
894742
|
]
|
|
894353
894743
|
})
|
|
@@ -894449,7 +894839,7 @@ function AppleTerminalWelcomeV2({ theme: theme2, welcomeMessage }) {
|
|
|
894449
894839
|
dimColor: true,
|
|
894450
894840
|
children: [
|
|
894451
894841
|
"v",
|
|
894452
|
-
"4.2.8-
|
|
894842
|
+
"4.2.8-beta2",
|
|
894453
894843
|
" "
|
|
894454
894844
|
]
|
|
894455
894845
|
})
|
|
@@ -894515,7 +894905,7 @@ function AppleTerminalWelcomeV2({ theme: theme2, welcomeMessage }) {
|
|
|
894515
894905
|
dimColor: true,
|
|
894516
894906
|
children: [
|
|
894517
894907
|
"v",
|
|
894518
|
-
"4.2.8-
|
|
894908
|
+
"4.2.8-beta2",
|
|
894519
894909
|
" "
|
|
894520
894910
|
]
|
|
894521
894911
|
})
|
|
@@ -895455,7 +895845,7 @@ function completeOnboarding() {
|
|
|
895455
895845
|
saveGlobalConfig((current2) => ({
|
|
895456
895846
|
...current2,
|
|
895457
895847
|
hasCompletedOnboarding: true,
|
|
895458
|
-
lastOnboardingVersion: "4.2.8-
|
|
895848
|
+
lastOnboardingVersion: "4.2.8-beta2"
|
|
895459
895849
|
}));
|
|
895460
895850
|
}
|
|
895461
895851
|
function showDialog(root6, renderer) {
|
|
@@ -896834,7 +897224,7 @@ function registerWeixinBuiltinPlugin() {
|
|
|
896834
897224
|
registerBuiltinPlugin({
|
|
896835
897225
|
name: "weixin",
|
|
896836
897226
|
description: "WeChat channel integration. Enables inbound WeChat messages via channels and provides reply/send_typing MCP tools. Configure with `ccb weixin login` and enable for a session with `--channels plugin:weixin@builtin`.",
|
|
896837
|
-
version: "4.2.8-
|
|
897227
|
+
version: "4.2.8-beta2",
|
|
896838
897228
|
defaultEnabled: true,
|
|
896839
897229
|
mcpServers: {
|
|
896840
897230
|
weixin: {
|
|
@@ -900435,7 +900825,7 @@ var init_resetProToOpusDefault = __esm(() => {
|
|
|
900435
900825
|
});
|
|
900436
900826
|
|
|
900437
900827
|
// src/remote/SessionsWebSocket.ts
|
|
900438
|
-
import { randomUUID as
|
|
900828
|
+
import { randomUUID as randomUUID74 } from "crypto";
|
|
900439
900829
|
function isSessionsMessage(value) {
|
|
900440
900830
|
if (typeof value !== "object" || value === null || !("type" in value)) {
|
|
900441
900831
|
return false;
|
|
@@ -900619,7 +901009,7 @@ class SessionsWebSocket {
|
|
|
900619
901009
|
}
|
|
900620
901010
|
const controlRequest = {
|
|
900621
901011
|
type: "control_request",
|
|
900622
|
-
request_id:
|
|
901012
|
+
request_id: randomUUID74(),
|
|
900623
901013
|
request: request3
|
|
900624
901014
|
};
|
|
900625
901015
|
logForDebugging(`[SessionsWebSocket] Sending control request: ${request3.subtype}`);
|
|
@@ -902755,7 +903145,7 @@ var init_ndjsonSafeStringify = __esm(() => {
|
|
|
902755
903145
|
});
|
|
902756
903146
|
|
|
902757
903147
|
// src/cli/structuredIO.ts
|
|
902758
|
-
import { randomUUID as
|
|
903148
|
+
import { randomUUID as randomUUID75 } from "crypto";
|
|
902759
903149
|
function serializeDecisionReason(reason) {
|
|
902760
903150
|
if (!reason) {
|
|
902761
903151
|
return;
|
|
@@ -903011,7 +903401,7 @@ class StructuredIO {
|
|
|
903011
903401
|
writeToStdout(ndjsonSafeStringify(message2) + `
|
|
903012
903402
|
`);
|
|
903013
903403
|
}
|
|
903014
|
-
async sendRequest(request3, schema2, signal, requestId2 =
|
|
903404
|
+
async sendRequest(request3, schema2, signal, requestId2 = randomUUID75()) {
|
|
903015
903405
|
const message2 = {
|
|
903016
903406
|
type: "control_request",
|
|
903017
903407
|
request_id: requestId2,
|
|
@@ -903077,7 +903467,7 @@ class StructuredIO {
|
|
|
903077
903467
|
parentSignal.addEventListener("abort", onParentAbort, { once: true });
|
|
903078
903468
|
try {
|
|
903079
903469
|
const hookPromise = executePermissionRequestHooksForSDK(tool.name, toolUseID, input4, toolUseContext, mainPermissionResult.suggestions).then((decision) => ({ source: "hook", decision }));
|
|
903080
|
-
const requestId2 =
|
|
903470
|
+
const requestId2 = randomUUID75();
|
|
903081
903471
|
onPermissionPrompt?.(buildRequiresActionDetails(tool, input4, toolUseID, requestId2));
|
|
903082
903472
|
const sdkPromise = this.sendRequest({
|
|
903083
903473
|
subtype: "can_use_tool",
|
|
@@ -903157,7 +903547,7 @@ class StructuredIO {
|
|
|
903157
903547
|
subtype: "can_use_tool",
|
|
903158
903548
|
tool_name: SANDBOX_NETWORK_ACCESS_TOOL_NAME,
|
|
903159
903549
|
input: { host: hostPattern.host },
|
|
903160
|
-
tool_use_id:
|
|
903550
|
+
tool_use_id: randomUUID75(),
|
|
903161
903551
|
description: `Allow network connection to ${hostPattern.host}?`
|
|
903162
903552
|
}, outputSchema41());
|
|
903163
903553
|
return result.behavior === "allow";
|
|
@@ -903471,7 +903861,7 @@ function coalescePatches(base2, overlay) {
|
|
|
903471
903861
|
var init_WorkerStateUploader = () => {};
|
|
903472
903862
|
|
|
903473
903863
|
// src/cli/transports/ccrClient.ts
|
|
903474
|
-
import { randomUUID as
|
|
903864
|
+
import { randomUUID as randomUUID76 } from "crypto";
|
|
903475
903865
|
function alwaysValidStatus2() {
|
|
903476
903866
|
return true;
|
|
903477
903867
|
}
|
|
@@ -903843,7 +904233,7 @@ class CCRClient {
|
|
|
903843
904233
|
return {
|
|
903844
904234
|
payload: {
|
|
903845
904235
|
...msg,
|
|
903846
|
-
uuid: typeof msg.uuid === "string" ? msg.uuid :
|
|
904236
|
+
uuid: typeof msg.uuid === "string" ? msg.uuid : randomUUID76()
|
|
903847
904237
|
}
|
|
903848
904238
|
};
|
|
903849
904239
|
}
|
|
@@ -903867,7 +904257,7 @@ class CCRClient {
|
|
|
903867
904257
|
payload: {
|
|
903868
904258
|
type: eventType,
|
|
903869
904259
|
...payload,
|
|
903870
|
-
uuid: typeof payload.uuid === "string" ? payload.uuid :
|
|
904260
|
+
uuid: typeof payload.uuid === "string" ? payload.uuid : randomUUID76()
|
|
903871
904261
|
},
|
|
903872
904262
|
...isCompaction && { is_compaction: true },
|
|
903873
904263
|
...agentId && { agent_id: agentId }
|
|
@@ -904927,11 +905317,11 @@ var init_idleTimeout = __esm(() => {
|
|
|
904927
905317
|
});
|
|
904928
905318
|
|
|
904929
905319
|
// src/utils/sessionUrl.ts
|
|
904930
|
-
import { randomUUID as
|
|
905320
|
+
import { randomUUID as randomUUID77 } from "crypto";
|
|
904931
905321
|
function parseSessionIdentifier(resumeIdentifier) {
|
|
904932
905322
|
if (resumeIdentifier.toLowerCase().endsWith(".jsonl")) {
|
|
904933
905323
|
return {
|
|
904934
|
-
sessionId:
|
|
905324
|
+
sessionId: randomUUID77(),
|
|
904935
905325
|
ingressUrl: null,
|
|
904936
905326
|
isUrl: false,
|
|
904937
905327
|
jsonlFile: resumeIdentifier,
|
|
@@ -904950,7 +905340,7 @@ function parseSessionIdentifier(resumeIdentifier) {
|
|
|
904950
905340
|
try {
|
|
904951
905341
|
const url5 = new URL(resumeIdentifier);
|
|
904952
905342
|
return {
|
|
904953
|
-
sessionId:
|
|
905343
|
+
sessionId: randomUUID77(),
|
|
904954
905344
|
ingressUrl: url5.href,
|
|
904955
905345
|
isUrl: true,
|
|
904956
905346
|
jsonlFile: null,
|
|
@@ -905134,7 +905524,7 @@ __export(exports_print, {
|
|
|
905134
905524
|
import { readFile as readFile83, stat as stat55 } from "fs/promises";
|
|
905135
905525
|
import { dirname as dirname86 } from "path";
|
|
905136
905526
|
import { cwd as cwd2 } from "process";
|
|
905137
|
-
import { randomUUID as
|
|
905527
|
+
import { randomUUID as randomUUID78 } from "crypto";
|
|
905138
905528
|
function trackReceivedMessageUuid(uuid9) {
|
|
905139
905529
|
if (receivedMessageUuids.has(uuid9)) {
|
|
905140
905530
|
return false;
|
|
@@ -905259,7 +905649,7 @@ Error: sandbox required but unavailable: ${sandboxUnavailableReason}
|
|
|
905259
905649
|
hook_id: event.hookId,
|
|
905260
905650
|
hook_name: event.hookName,
|
|
905261
905651
|
hook_event: event.hookEvent,
|
|
905262
|
-
uuid:
|
|
905652
|
+
uuid: randomUUID78(),
|
|
905263
905653
|
session_id: getSessionId()
|
|
905264
905654
|
};
|
|
905265
905655
|
case "progress":
|
|
@@ -905272,7 +905662,7 @@ Error: sandbox required but unavailable: ${sandboxUnavailableReason}
|
|
|
905272
905662
|
stdout: event.stdout,
|
|
905273
905663
|
stderr: event.stderr,
|
|
905274
905664
|
output: event.output,
|
|
905275
|
-
uuid:
|
|
905665
|
+
uuid: randomUUID78(),
|
|
905276
905666
|
session_id: getSessionId()
|
|
905277
905667
|
};
|
|
905278
905668
|
case "response":
|
|
@@ -905287,7 +905677,7 @@ Error: sandbox required but unavailable: ${sandboxUnavailableReason}
|
|
|
905287
905677
|
stderr: event.stderr,
|
|
905288
905678
|
exit_code: event.exitCode,
|
|
905289
905679
|
outcome: event.outcome,
|
|
905290
|
-
uuid:
|
|
905680
|
+
uuid: randomUUID78(),
|
|
905291
905681
|
session_id: getSessionId()
|
|
905292
905682
|
};
|
|
905293
905683
|
}
|
|
@@ -905504,7 +905894,7 @@ function runHeadlessStreaming(structuredIO, mcpClients, commands7, tools, initia
|
|
|
905504
905894
|
subtype: "status",
|
|
905505
905895
|
status: null,
|
|
905506
905896
|
permissionMode: newMode,
|
|
905507
|
-
uuid:
|
|
905897
|
+
uuid: randomUUID78(),
|
|
905508
905898
|
session_id: getSessionId()
|
|
905509
905899
|
});
|
|
905510
905900
|
}
|
|
@@ -905525,7 +905915,7 @@ function runHeadlessStreaming(structuredIO, mcpClients, commands7, tools, initia
|
|
|
905525
905915
|
isAuthenticating: status2.isAuthenticating,
|
|
905526
905916
|
output: status2.output,
|
|
905527
905917
|
error: status2.error,
|
|
905528
|
-
uuid:
|
|
905918
|
+
uuid: randomUUID78(),
|
|
905529
905919
|
session_id: getSessionId()
|
|
905530
905920
|
});
|
|
905531
905921
|
});
|
|
@@ -905536,7 +905926,7 @@ function runHeadlessStreaming(structuredIO, mcpClients, commands7, tools, initia
|
|
|
905536
905926
|
output.enqueue({
|
|
905537
905927
|
type: "rate_limit_event",
|
|
905538
905928
|
rate_limit_info: rateLimitInfo,
|
|
905539
|
-
uuid:
|
|
905929
|
+
uuid: randomUUID78(),
|
|
905540
905930
|
session_id: getSessionId()
|
|
905541
905931
|
});
|
|
905542
905932
|
}
|
|
@@ -905552,7 +905942,7 @@ function runHeadlessStreaming(structuredIO, mcpClients, commands7, tools, initia
|
|
|
905552
905942
|
enqueue({
|
|
905553
905943
|
mode: "prompt",
|
|
905554
905944
|
value: turnInterruptionState.message.message.content,
|
|
905555
|
-
uuid:
|
|
905945
|
+
uuid: randomUUID78()
|
|
905556
905946
|
});
|
|
905557
905947
|
}
|
|
905558
905948
|
const modelOptions = getModelOptions();
|
|
@@ -905656,7 +906046,7 @@ function runHeadlessStreaming(structuredIO, mcpClients, commands7, tools, initia
|
|
|
905656
906046
|
subtype: "elicitation_complete",
|
|
905657
906047
|
mcp_server_name: serverName,
|
|
905658
906048
|
elicitation_id: elicitationId,
|
|
905659
|
-
uuid:
|
|
906049
|
+
uuid: randomUUID78(),
|
|
905660
906050
|
session_id: getSessionId()
|
|
905661
906051
|
});
|
|
905662
906052
|
});
|
|
@@ -905899,7 +906289,7 @@ function runHeadlessStreaming(structuredIO, mcpClients, commands7, tools, initia
|
|
|
905899
906289
|
for (const command11 of commands8) {
|
|
905900
906290
|
enqueue({
|
|
905901
906291
|
...command11,
|
|
905902
|
-
uuid:
|
|
906292
|
+
uuid: randomUUID78()
|
|
905903
906293
|
});
|
|
905904
906294
|
}
|
|
905905
906295
|
run4();
|
|
@@ -906038,7 +906428,7 @@ function runHeadlessStreaming(structuredIO, mcpClients, commands7, tools, initia
|
|
|
906038
906428
|
duration_ms: durationMsMatch ? parseInt(durationMsMatch[1], 10) : 0
|
|
906039
906429
|
} : undefined,
|
|
906040
906430
|
session_id: getSessionId(),
|
|
906041
|
-
uuid:
|
|
906431
|
+
uuid: randomUUID78()
|
|
906042
906432
|
});
|
|
906043
906433
|
}
|
|
906044
906434
|
}
|
|
@@ -906112,7 +906502,7 @@ function runHeadlessStreaming(structuredIO, mcpClients, commands7, tools, initia
|
|
|
906112
906502
|
subtype: "status",
|
|
906113
906503
|
status: status2,
|
|
906114
906504
|
session_id: getSessionId(),
|
|
906115
|
-
uuid:
|
|
906505
|
+
uuid: randomUUID78()
|
|
906116
906506
|
});
|
|
906117
906507
|
}
|
|
906118
906508
|
})) {
|
|
@@ -906158,7 +906548,7 @@ function runHeadlessStreaming(structuredIO, mcpClients, commands7, tools, initia
|
|
|
906158
906548
|
for (const nextCommand of nextCommands) {
|
|
906159
906549
|
enqueue({
|
|
906160
906550
|
...nextCommand,
|
|
906161
|
-
uuid:
|
|
906551
|
+
uuid: randomUUID78()
|
|
906162
906552
|
});
|
|
906163
906553
|
}
|
|
906164
906554
|
}
|
|
@@ -906194,7 +906584,7 @@ function runHeadlessStreaming(structuredIO, mcpClients, commands7, tools, initia
|
|
|
906194
906584
|
const suggestionMsg = {
|
|
906195
906585
|
type: "prompt_suggestion",
|
|
906196
906586
|
suggestion: result.suggestion,
|
|
906197
|
-
uuid:
|
|
906587
|
+
uuid: randomUUID78(),
|
|
906198
906588
|
session_id: getSessionId()
|
|
906199
906589
|
};
|
|
906200
906590
|
const lastEmittedEntry = {
|
|
@@ -906284,7 +906674,7 @@ function runHeadlessStreaming(structuredIO, mcpClients, commands7, tools, initia
|
|
|
906284
906674
|
usage: EMPTY_USAGE,
|
|
906285
906675
|
modelUsage: {},
|
|
906286
906676
|
permission_denials: [],
|
|
906287
|
-
uuid:
|
|
906677
|
+
uuid: randomUUID78(),
|
|
906288
906678
|
errors: [
|
|
906289
906679
|
errorMessage(error99),
|
|
906290
906680
|
...getInMemoryErrors().map((_2) => _2.error)
|
|
@@ -906373,7 +906763,7 @@ ${m3.text}
|
|
|
906373
906763
|
enqueue({
|
|
906374
906764
|
mode: "prompt",
|
|
906375
906765
|
value: formatted,
|
|
906376
|
-
uuid:
|
|
906766
|
+
uuid: randomUUID78()
|
|
906377
906767
|
});
|
|
906378
906768
|
run4();
|
|
906379
906769
|
return;
|
|
@@ -906384,7 +906774,7 @@ ${m3.text}
|
|
|
906384
906774
|
enqueue({
|
|
906385
906775
|
mode: "prompt",
|
|
906386
906776
|
value: SHUTDOWN_TEAM_PROMPT,
|
|
906387
|
-
uuid:
|
|
906777
|
+
uuid: randomUUID78()
|
|
906388
906778
|
});
|
|
906389
906779
|
run4();
|
|
906390
906780
|
return;
|
|
@@ -906408,7 +906798,7 @@ ${m3.text}
|
|
|
906408
906798
|
enqueue({
|
|
906409
906799
|
mode: "prompt",
|
|
906410
906800
|
value: SHUTDOWN_TEAM_PROMPT,
|
|
906411
|
-
uuid:
|
|
906801
|
+
uuid: randomUUID78()
|
|
906412
906802
|
});
|
|
906413
906803
|
run4();
|
|
906414
906804
|
} else if (!process.env.CSC_SERVE_MODE) {
|
|
@@ -906456,7 +906846,7 @@ ${m3.text}
|
|
|
906456
906846
|
const enqueueAndRun = (command11) => {
|
|
906457
906847
|
enqueue({
|
|
906458
906848
|
...command11,
|
|
906459
|
-
uuid:
|
|
906849
|
+
uuid: randomUUID78()
|
|
906460
906850
|
});
|
|
906461
906851
|
run4();
|
|
906462
906852
|
};
|
|
@@ -907501,7 +907891,7 @@ async function handleInitializeRequest(request3, requestId2, initialized7, outpu
|
|
|
907501
907891
|
isAuthenticating: status2.isAuthenticating,
|
|
907502
907892
|
output: status2.output,
|
|
907503
907893
|
error: status2.error,
|
|
907504
|
-
uuid:
|
|
907894
|
+
uuid: randomUUID78(),
|
|
907505
907895
|
session_id: getSessionId()
|
|
907506
907896
|
});
|
|
907507
907897
|
}
|
|
@@ -907705,7 +908095,7 @@ function emitLoadError(message2, outputFormat) {
|
|
|
907705
908095
|
usage: EMPTY_USAGE,
|
|
907706
908096
|
modelUsage: {},
|
|
907707
908097
|
permission_denials: [],
|
|
907708
|
-
uuid:
|
|
908098
|
+
uuid: randomUUID78(),
|
|
907709
908099
|
errors: [message2]
|
|
907710
908100
|
};
|
|
907711
908101
|
process.stdout.write(jsonStringify(errorResult2) + `
|
|
@@ -908473,7 +908863,7 @@ var init_SSHSessionManager = __esm(() => {
|
|
|
908473
908863
|
});
|
|
908474
908864
|
|
|
908475
908865
|
// src/ssh/SSHAuthProxy.ts
|
|
908476
|
-
import { randomUUID as
|
|
908866
|
+
import { randomUUID as randomUUID79 } from "crypto";
|
|
908477
908867
|
import { unlinkSync as unlinkSync12 } from "fs";
|
|
908478
908868
|
function resolveAuthHeaders() {
|
|
908479
908869
|
const apiKey = process.env.ANTHROPIC_API_KEY;
|
|
@@ -908531,7 +908921,7 @@ async function proxyFetch(req, nonce) {
|
|
|
908531
908921
|
}
|
|
908532
908922
|
}
|
|
908533
908923
|
async function createAuthProxy() {
|
|
908534
|
-
const id =
|
|
908924
|
+
const id = randomUUID79();
|
|
908535
908925
|
if (isWindows3) {
|
|
908536
908926
|
return createTcpAuthProxy(id);
|
|
908537
908927
|
}
|
|
@@ -908559,7 +908949,7 @@ async function createUnixSocketAuthProxy(id) {
|
|
|
908559
908949
|
};
|
|
908560
908950
|
}
|
|
908561
908951
|
async function createTcpAuthProxy(id) {
|
|
908562
|
-
const nonce =
|
|
908952
|
+
const nonce = randomUUID79();
|
|
908563
908953
|
const server2 = Bun.serve({
|
|
908564
908954
|
port: 0,
|
|
908565
908955
|
hostname: "127.0.0.1",
|
|
@@ -908734,7 +909124,7 @@ __export(exports_createSSHSession, {
|
|
|
908734
909124
|
createLocalSSHSession: () => createLocalSSHSession,
|
|
908735
909125
|
SSHSessionError: () => SSHSessionError
|
|
908736
909126
|
});
|
|
908737
|
-
import { randomUUID as
|
|
909127
|
+
import { randomUUID as randomUUID80 } from "crypto";
|
|
908738
909128
|
async function createSSHSession(config11, callbacks) {
|
|
908739
909129
|
const { host, localVersion, extraCliArgs, remoteBin } = config11;
|
|
908740
909130
|
const onProgress = callbacks?.onProgress;
|
|
@@ -908773,7 +909163,7 @@ async function createSSHSession(config11, callbacks) {
|
|
|
908773
909163
|
}
|
|
908774
909164
|
const { proxy, localAddress, authEnv } = await createAuthProxy();
|
|
908775
909165
|
logForDebugging(`[SSH] auth proxy listening on ${localAddress}`);
|
|
908776
|
-
const remoteSocketId =
|
|
909166
|
+
const remoteSocketId = randomUUID80().slice(0, 8);
|
|
908777
909167
|
const isWindows4 = process.platform === "win32";
|
|
908778
909168
|
const remoteCli = [];
|
|
908779
909169
|
for (const [k5, v2] of Object.entries(authEnv)) {
|
|
@@ -909318,7 +909708,7 @@ async function startMCPServer(cwd3, debug5, verbose) {
|
|
|
909318
909708
|
setCwd(cwd3);
|
|
909319
909709
|
const server2 = new Server({
|
|
909320
909710
|
name: "claude/tengu",
|
|
909321
|
-
version: "4.2.8-
|
|
909711
|
+
version: "4.2.8-beta2"
|
|
909322
909712
|
}, {
|
|
909323
909713
|
capabilities: {
|
|
909324
909714
|
tools: {}
|
|
@@ -911597,7 +911987,7 @@ function createHealthRoutes(sessionManager) {
|
|
|
911597
911987
|
const uptime2 = process.uptime() * 1000;
|
|
911598
911988
|
return c7.json({
|
|
911599
911989
|
status: "ok",
|
|
911600
|
-
version: "4.2.8-
|
|
911990
|
+
version: "4.2.8-beta2",
|
|
911601
911991
|
uptime_ms: Math.round(uptime2),
|
|
911602
911992
|
active_sessions: sessionManager.getActiveCount()
|
|
911603
911993
|
});
|
|
@@ -911867,7 +912257,7 @@ function getMacroDefines() {
|
|
|
911867
912257
|
commit = execSync3("git rev-parse --short HEAD", { encoding: "utf-8", cwd: __dirname }).trim();
|
|
911868
912258
|
} catch {}
|
|
911869
912259
|
return {
|
|
911870
|
-
"MACRO.VERSION": JSON.stringify("4.2.8-
|
|
912260
|
+
"MACRO.VERSION": JSON.stringify("4.2.8-beta2"),
|
|
911871
912261
|
"MACRO.BUILD_TIME": JSON.stringify(new Date().toISOString()),
|
|
911872
912262
|
"MACRO.COMMIT": JSON.stringify(commit),
|
|
911873
912263
|
"MACRO.FEEDBACK_CHANNEL": JSON.stringify(""),
|
|
@@ -913565,7 +913955,7 @@ var init_transcriptReader = __esm(() => {
|
|
|
913565
913955
|
});
|
|
913566
913956
|
|
|
913567
913957
|
// src/server/streamStateTracker.ts
|
|
913568
|
-
import { randomUUID as
|
|
913958
|
+
import { randomUUID as randomUUID81 } from "crypto";
|
|
913569
913959
|
function updateStreamUsage(state4, usage2) {
|
|
913570
913960
|
if (!usage2)
|
|
913571
913961
|
return;
|
|
@@ -913578,12 +913968,12 @@ function getOrCreate(sessionID) {
|
|
|
913578
913968
|
let state4 = states.get(sessionID);
|
|
913579
913969
|
if (!state4) {
|
|
913580
913970
|
state4 = {
|
|
913581
|
-
messageID:
|
|
913971
|
+
messageID: randomUUID81(),
|
|
913582
913972
|
parentID: "",
|
|
913583
913973
|
modelID: "",
|
|
913584
913974
|
timeCreated: Date.now(),
|
|
913585
913975
|
activeBlocks: new Map,
|
|
913586
|
-
stepStartPartID:
|
|
913976
|
+
stepStartPartID: randomUUID81(),
|
|
913587
913977
|
assistantPartEmitted: false,
|
|
913588
913978
|
usage: { inputTokens: 0, outputTokens: 0, cacheReadTokens: 0, cacheWriteTokens: 0 },
|
|
913589
913979
|
stopReason: ""
|
|
@@ -913630,7 +914020,7 @@ function processStreamEvent(sessionID, event) {
|
|
|
913630
914020
|
switch (eventType) {
|
|
913631
914021
|
case "message_start": {
|
|
913632
914022
|
const msg = event.message;
|
|
913633
|
-
state4.messageID = event._message_uuid ||
|
|
914023
|
+
state4.messageID = event._message_uuid || randomUUID81();
|
|
913634
914024
|
state4.modelID = msg?.model ?? "";
|
|
913635
914025
|
state4.usage = {
|
|
913636
914026
|
inputTokens: 0,
|
|
@@ -913655,7 +914045,7 @@ function processStreamEvent(sessionID, event) {
|
|
|
913655
914045
|
});
|
|
913656
914046
|
state4.assistantPartEmitted = true;
|
|
913657
914047
|
}
|
|
913658
|
-
state4.stepStartPartID =
|
|
914048
|
+
state4.stepStartPartID = randomUUID81();
|
|
913659
914049
|
results.push({
|
|
913660
914050
|
type: "message.part.updated",
|
|
913661
914051
|
properties: {
|
|
@@ -913671,7 +914061,7 @@ function processStreamEvent(sessionID, event) {
|
|
|
913671
914061
|
const index2 = evt.index;
|
|
913672
914062
|
if (!block)
|
|
913673
914063
|
break;
|
|
913674
|
-
const partID =
|
|
914064
|
+
const partID = randomUUID81();
|
|
913675
914065
|
const blockState = {
|
|
913676
914066
|
type: block.type,
|
|
913677
914067
|
partID,
|
|
@@ -913869,7 +914259,7 @@ function processStreamEvent(sessionID, event) {
|
|
|
913869
914259
|
sessionID,
|
|
913870
914260
|
part: {
|
|
913871
914261
|
type: "step-finish",
|
|
913872
|
-
id:
|
|
914262
|
+
id: randomUUID81(),
|
|
913873
914263
|
reason: state4.stopReason || "stop",
|
|
913874
914264
|
cost: 0,
|
|
913875
914265
|
tokens: {
|
|
@@ -914021,7 +914411,7 @@ var init_streamStateTracker = __esm(() => {
|
|
|
914021
914411
|
});
|
|
914022
914412
|
|
|
914023
914413
|
// src/server/sessionMessageRouter.ts
|
|
914024
|
-
import { randomUUID as
|
|
914414
|
+
import { randomUUID as randomUUID82 } from "crypto";
|
|
914025
914415
|
function isApiErrorContent(content) {
|
|
914026
914416
|
if (typeof content === "string") {
|
|
914027
914417
|
return API_ERROR_PREFIX_RE.test(content) || COSTRICT_API_ERROR_PREFIX_RE.test(content);
|
|
@@ -914222,7 +914612,7 @@ function handleAssistantMessage(msg, ctx) {
|
|
|
914222
914612
|
ctx.emitOpencodeEvent("message.updated", {
|
|
914223
914613
|
sessionID: emitSessionID,
|
|
914224
914614
|
info: {
|
|
914225
|
-
id: streamInfo?.messageID ?? msg.uuid ??
|
|
914615
|
+
id: streamInfo?.messageID ?? msg.uuid ?? randomUUID82(),
|
|
914226
914616
|
role: "assistant",
|
|
914227
914617
|
modelID: streamInfo?.modelID ?? msg.model ?? ctx.getModel() ?? "",
|
|
914228
914618
|
providerID: msg.provider_id ?? ctx.getProviderId(),
|
|
@@ -914259,7 +914649,7 @@ function handleAssistantMessage(msg, ctx) {
|
|
|
914259
914649
|
sessionID: emitSessionID,
|
|
914260
914650
|
part: {
|
|
914261
914651
|
type: "tool",
|
|
914262
|
-
id: toolInfo?.partID ??
|
|
914652
|
+
id: toolInfo?.partID ?? randomUUID82(),
|
|
914263
914653
|
callID: toolUseID,
|
|
914264
914654
|
tool: toolInfo?.toolName ? normalizeToolName3(toolInfo.toolName) : "",
|
|
914265
914655
|
messageID: toolInfo?.messageID ?? ctx.getLastMessageUuid() ?? "",
|
|
@@ -914279,7 +914669,7 @@ function handleAssistantMessage(msg, ctx) {
|
|
|
914279
914669
|
ctx.emitOpencodeEvent("message.updated", {
|
|
914280
914670
|
sessionID: emitSessionID,
|
|
914281
914671
|
info: {
|
|
914282
|
-
id: streamInfo?.messageID ?? msg.uuid ??
|
|
914672
|
+
id: streamInfo?.messageID ?? msg.uuid ?? randomUUID82(),
|
|
914283
914673
|
role: "assistant",
|
|
914284
914674
|
modelID: streamInfo?.modelID ?? msg.model ?? ctx.getModel() ?? "",
|
|
914285
914675
|
providerID: msg.provider_id ?? ctx.getProviderId(),
|
|
@@ -914300,7 +914690,7 @@ function handleAssistantMessage(msg, ctx) {
|
|
|
914300
914690
|
if (!msg.provider_id && ctx.getProviderId()) {
|
|
914301
914691
|
enriched = { ...enriched, provider_id: ctx.getProviderId() };
|
|
914302
914692
|
}
|
|
914303
|
-
const assistantMsgID = msg.uuid ??
|
|
914693
|
+
const assistantMsgID = msg.uuid ?? randomUUID82();
|
|
914304
914694
|
ctx.emitOpencodeEvent("message.updated", {
|
|
914305
914695
|
sessionID: emitSessionID,
|
|
914306
914696
|
info: {
|
|
@@ -914367,10 +914757,10 @@ function emitCompactSummaryMessage(msg, ctx) {
|
|
|
914367
914757
|
const compactState = ctx.getCompactState();
|
|
914368
914758
|
if (!compactState)
|
|
914369
914759
|
return;
|
|
914370
|
-
const assistantMsgID = msg.uuid ??
|
|
914760
|
+
const assistantMsgID = msg.uuid ?? randomUUID82();
|
|
914371
914761
|
const now3 = Date.now();
|
|
914372
|
-
const stepSeq =
|
|
914373
|
-
const partSeq =
|
|
914762
|
+
const stepSeq = randomUUID82();
|
|
914763
|
+
const partSeq = randomUUID82();
|
|
914374
914764
|
let rawContent2 = msg.message ?? msg.content;
|
|
914375
914765
|
if (rawContent2 && typeof rawContent2 === "object" && !Array.isArray(rawContent2) && "content" in rawContent2) {
|
|
914376
914766
|
rawContent2 = rawContent2.content;
|
|
@@ -914467,7 +914857,7 @@ function handleUserMessage(msg, ctx) {
|
|
|
914467
914857
|
sessionID: emitSessionID,
|
|
914468
914858
|
part: {
|
|
914469
914859
|
type: "tool",
|
|
914470
|
-
id: toolInfo?.partID ??
|
|
914860
|
+
id: toolInfo?.partID ?? randomUUID82(),
|
|
914471
914861
|
callID: toolUseID,
|
|
914472
914862
|
tool: toolInfo?.toolName ? normalizeToolName3(toolInfo.toolName) : "",
|
|
914473
914863
|
messageID: toolInfo?.messageID,
|
|
@@ -914493,7 +914883,7 @@ function handleUserMessage(msg, ctx) {
|
|
|
914493
914883
|
ctx.emitOpencodeEvent("message.updated", {
|
|
914494
914884
|
sessionID: emitSessionID,
|
|
914495
914885
|
info: {
|
|
914496
|
-
id: msgUuid ??
|
|
914886
|
+
id: msgUuid ?? randomUUID82(),
|
|
914497
914887
|
role: "user",
|
|
914498
914888
|
time: { created: Date.now() },
|
|
914499
914889
|
parentID: null
|
|
@@ -914504,7 +914894,7 @@ function emitCompactContinueMessage(ctx) {
|
|
|
914504
914894
|
const compactState = ctx.getCompactState();
|
|
914505
914895
|
if (!compactState)
|
|
914506
914896
|
return;
|
|
914507
|
-
const continueMsgID =
|
|
914897
|
+
const continueMsgID = randomUUID82();
|
|
914508
914898
|
const now3 = Date.now();
|
|
914509
914899
|
ctx.emitOpencodeEvent("message.updated", {
|
|
914510
914900
|
sessionID: ctx.sessionId,
|
|
@@ -914519,7 +914909,7 @@ function emitCompactContinueMessage(ctx) {
|
|
|
914519
914909
|
ctx.emitOpencodeEvent("message.part.updated", {
|
|
914520
914910
|
sessionID: ctx.sessionId,
|
|
914521
914911
|
part: {
|
|
914522
|
-
id:
|
|
914912
|
+
id: randomUUID82(),
|
|
914523
914913
|
sessionID: ctx.sessionId,
|
|
914524
914914
|
messageID: continueMsgID,
|
|
914525
914915
|
type: "text",
|
|
@@ -914784,16 +915174,16 @@ function handleCancelRequest(msg, ctx) {
|
|
|
914784
915174
|
function buildPartFromContentBlock(block, messageID, sessionID) {
|
|
914785
915175
|
switch (block.type) {
|
|
914786
915176
|
case "text":
|
|
914787
|
-
return { type: "text", id:
|
|
915177
|
+
return { type: "text", id: randomUUID82(), text: block.text, messageID, sessionID };
|
|
914788
915178
|
case "thinking":
|
|
914789
|
-
return { type: "reasoning", id:
|
|
915179
|
+
return { type: "reasoning", id: randomUUID82(), text: block.thinking, messageID, sessionID };
|
|
914790
915180
|
case "redacted_thinking":
|
|
914791
|
-
return { type: "reasoning", id:
|
|
915181
|
+
return { type: "reasoning", id: randomUUID82(), text: "", redacted: true, messageID, sessionID };
|
|
914792
915182
|
case "tool_use": {
|
|
914793
915183
|
const toolInput = normalizeToolInput4(block.input);
|
|
914794
915184
|
return {
|
|
914795
915185
|
type: "tool",
|
|
914796
|
-
id:
|
|
915186
|
+
id: randomUUID82(),
|
|
914797
915187
|
callID: block.id,
|
|
914798
915188
|
tool: normalizeToolName3(block.name),
|
|
914799
915189
|
state: {
|
|
@@ -914819,7 +915209,7 @@ function emitTaskStarted(msg, ctx) {
|
|
|
914819
915209
|
const description = msg.description;
|
|
914820
915210
|
const prompt = msg.prompt;
|
|
914821
915211
|
const toolUseId = msg.tool_use_id;
|
|
914822
|
-
const assistantMessageID =
|
|
915212
|
+
const assistantMessageID = randomUUID82();
|
|
914823
915213
|
ctx.registerSubagent({
|
|
914824
915214
|
agentId,
|
|
914825
915215
|
agentType: taskType,
|
|
@@ -914903,7 +915293,7 @@ function emitTaskProgress3(msg, ctx) {
|
|
|
914903
915293
|
sessionID: ctx.sessionId,
|
|
914904
915294
|
part: {
|
|
914905
915295
|
type: "tool",
|
|
914906
|
-
id:
|
|
915296
|
+
id: randomUUID82(),
|
|
914907
915297
|
callID: toolState.mainToolUseID,
|
|
914908
915298
|
tool: mainToolInfo?.toolName ? normalizeToolName3(mainToolInfo.toolName) : "task",
|
|
914909
915299
|
state: {
|
|
@@ -914926,7 +915316,7 @@ function emitTaskProgress3(msg, ctx) {
|
|
|
914926
915316
|
const toolName = toolIndex === toolUses ? lastToolName : "Tool";
|
|
914927
915317
|
let partID = toolState.toolPartIDs.get(toolIndex);
|
|
914928
915318
|
if (!partID) {
|
|
914929
|
-
partID =
|
|
915319
|
+
partID = randomUUID82();
|
|
914930
915320
|
toolState.toolPartIDs.set(toolIndex, partID);
|
|
914931
915321
|
}
|
|
914932
915322
|
ctx.emitOpencodeEvent("message.part.updated", {
|
|
@@ -914969,7 +915359,7 @@ function emitTaskCompleted(msg, ctx) {
|
|
|
914969
915359
|
sessionID: ctx.sessionId,
|
|
914970
915360
|
part: {
|
|
914971
915361
|
type: "tool",
|
|
914972
|
-
id: agentToolInfo?.partID ??
|
|
915362
|
+
id: agentToolInfo?.partID ?? randomUUID82(),
|
|
914973
915363
|
callID: toolUseId,
|
|
914974
915364
|
tool: agentToolInfo?.toolName ? normalizeToolName3(agentToolInfo.toolName) : undefined,
|
|
914975
915365
|
messageID: agentToolInfo?.messageID,
|
|
@@ -915037,8 +915427,8 @@ function emitCompactionEvent(msg, ctx) {
|
|
|
915037
915427
|
const compactMetadata = msg.compact_metadata;
|
|
915038
915428
|
const isAuto = msg.subtype === "microcompact_boundary" || compactMetadata?.trigger === "auto";
|
|
915039
915429
|
const postCompactTokens = typeof compactMetadata?.post_compact_tokens === "number" ? compactMetadata.post_compact_tokens : typeof compactMetadata?.postCompactTokens === "number" ? compactMetadata.postCompactTokens : undefined;
|
|
915040
|
-
const userMessageID =
|
|
915041
|
-
const compactionPartID = msg.uuid ??
|
|
915430
|
+
const userMessageID = randomUUID82();
|
|
915431
|
+
const compactionPartID = msg.uuid ?? randomUUID82();
|
|
915042
915432
|
ctx.emitOpencodeEvent("message.updated", {
|
|
915043
915433
|
sessionID: ctx.sessionId,
|
|
915044
915434
|
info: {
|
|
@@ -917782,7 +918172,7 @@ __export(exports_update, {
|
|
|
917782
918172
|
});
|
|
917783
918173
|
async function update() {
|
|
917784
918174
|
logEvent("tengu_update_check", {});
|
|
917785
|
-
writeToStdout(`${t("cli.update.currentVersion", "Current version")}: ${"4.2.8-
|
|
918175
|
+
writeToStdout(`${t("cli.update.currentVersion", "Current version")}: ${"4.2.8-beta2"}
|
|
917786
918176
|
`);
|
|
917787
918177
|
const channel5 = getInitialSettings()?.autoUpdatesChannel ?? "latest";
|
|
917788
918178
|
writeToStdout(`${t("cli.update.checkingUpdates", { channel: channel5 }, "Checking for updates to {channel} version...")}
|
|
@@ -917857,8 +918247,8 @@ async function update() {
|
|
|
917857
918247
|
writeToStdout(`${t("cli.update.managedByHomebrew", "CoStrict is managed by Homebrew.")}
|
|
917858
918248
|
`);
|
|
917859
918249
|
const latest = await getLatestVersion(channel5);
|
|
917860
|
-
if (latest && !gte2("4.2.8-
|
|
917861
|
-
writeToStdout(`${t("cli.update.updateAvailable", { current: "4.2.8-
|
|
918250
|
+
if (latest && !gte2("4.2.8-beta2", latest)) {
|
|
918251
|
+
writeToStdout(`${t("cli.update.updateAvailable", { current: "4.2.8-beta2", latest }, "Update available: {current} \u2192 {latest}")}
|
|
917862
918252
|
`);
|
|
917863
918253
|
writeToStdout(`
|
|
917864
918254
|
`);
|
|
@@ -917874,8 +918264,8 @@ async function update() {
|
|
|
917874
918264
|
writeToStdout(`${t("cli.update.managedByWinget", "CoStrict is managed by winget.")}
|
|
917875
918265
|
`);
|
|
917876
918266
|
const latest = await getLatestVersion(channel5);
|
|
917877
|
-
if (latest && !gte2("4.2.8-
|
|
917878
|
-
writeToStdout(`${t("cli.update.updateAvailable", { current: "4.2.8-
|
|
918267
|
+
if (latest && !gte2("4.2.8-beta2", latest)) {
|
|
918268
|
+
writeToStdout(`${t("cli.update.updateAvailable", { current: "4.2.8-beta2", latest }, "Update available: {current} \u2192 {latest}")}
|
|
917879
918269
|
`);
|
|
917880
918270
|
writeToStdout(`
|
|
917881
918271
|
`);
|
|
@@ -917891,8 +918281,8 @@ async function update() {
|
|
|
917891
918281
|
writeToStdout(`${t("cli.update.managedByApk", "CoStrict is managed by apk.")}
|
|
917892
918282
|
`);
|
|
917893
918283
|
const latest = await getLatestVersion(channel5);
|
|
917894
|
-
if (latest && !gte2("4.2.8-
|
|
917895
|
-
writeToStdout(`${t("cli.update.updateAvailable", { current: "4.2.8-
|
|
918284
|
+
if (latest && !gte2("4.2.8-beta2", latest)) {
|
|
918285
|
+
writeToStdout(`${t("cli.update.updateAvailable", { current: "4.2.8-beta2", latest }, "Update available: {current} \u2192 {latest}")}
|
|
917896
918286
|
`);
|
|
917897
918287
|
writeToStdout(`
|
|
917898
918288
|
`);
|
|
@@ -917957,11 +918347,11 @@ async function update() {
|
|
|
917957
918347
|
`);
|
|
917958
918348
|
await gracefulShutdown(1);
|
|
917959
918349
|
}
|
|
917960
|
-
if (result2.latestVersion === "4.2.8-
|
|
917961
|
-
writeToStdout(source_default.green(t("cli.update.upToDateVersion", { version: "4.2.8-
|
|
918350
|
+
if (result2.latestVersion === "4.2.8-beta2") {
|
|
918351
|
+
writeToStdout(source_default.green(t("cli.update.upToDateVersion", { version: "4.2.8-beta2" }, "CoStrict is up to date ({version})")) + `
|
|
917962
918352
|
`);
|
|
917963
918353
|
} else {
|
|
917964
|
-
writeToStdout(source_default.green(t("cli.update.successfullyUpdated", { from: "4.2.8-
|
|
918354
|
+
writeToStdout(source_default.green(t("cli.update.successfullyUpdated", { from: "4.2.8-beta2", to: String(result2.latestVersion) }, "Successfully updated from {from} to version {to}")) + `
|
|
917965
918355
|
`);
|
|
917966
918356
|
regenerateCompletionCache();
|
|
917967
918357
|
}
|
|
@@ -918021,12 +918411,12 @@ async function update() {
|
|
|
918021
918411
|
`);
|
|
918022
918412
|
await gracefulShutdown(1);
|
|
918023
918413
|
}
|
|
918024
|
-
if (latestVersion === "4.2.8-
|
|
918025
|
-
writeToStdout(source_default.green(t("cli.update.upToDateVersion", { version: "4.2.8-
|
|
918414
|
+
if (latestVersion === "4.2.8-beta2") {
|
|
918415
|
+
writeToStdout(source_default.green(t("cli.update.upToDateVersion", { version: "4.2.8-beta2" }, "CoStrict is up to date ({version})")) + `
|
|
918026
918416
|
`);
|
|
918027
918417
|
await gracefulShutdown(0);
|
|
918028
918418
|
}
|
|
918029
|
-
writeToStdout(`${t("cli.update.newVersionAvailable", { latest: String(latestVersion), current: "4.2.8-
|
|
918419
|
+
writeToStdout(`${t("cli.update.newVersionAvailable", { latest: String(latestVersion), current: "4.2.8-beta2" }, "New version available: {latest} (current: {current})")}
|
|
918030
918420
|
`);
|
|
918031
918421
|
writeToStdout(`${t("cli.update.installing", "Installing update...")}
|
|
918032
918422
|
`);
|
|
@@ -918071,7 +918461,7 @@ async function update() {
|
|
|
918071
918461
|
logForDebugging(`update: Installation status: ${result.status}`);
|
|
918072
918462
|
switch (result.status) {
|
|
918073
918463
|
case "success":
|
|
918074
|
-
writeToStdout(source_default.green(t("cli.update.successfullyUpdated", { from: "4.2.8-
|
|
918464
|
+
writeToStdout(source_default.green(t("cli.update.successfullyUpdated", { from: "4.2.8-beta2", to: String(latestVersion) }, "Successfully updated from {from} to version {to}")) + `
|
|
918075
918465
|
`);
|
|
918076
918466
|
regenerateCompletionCache();
|
|
918077
918467
|
break;
|
|
@@ -920291,7 +920681,7 @@ ${assistantAddendum}` : assistantAddendum;
|
|
|
920291
920681
|
}
|
|
920292
920682
|
}
|
|
920293
920683
|
logForDiagnosticsNoPII("info", "started", {
|
|
920294
|
-
version: "4.2.8-
|
|
920684
|
+
version: "4.2.8-beta2",
|
|
920295
920685
|
is_native_binary: isInBundledMode()
|
|
920296
920686
|
});
|
|
920297
920687
|
registerCleanup(async () => {
|
|
@@ -920772,7 +921162,7 @@ Session: ${directConnectConfig.sessionId}`, "info");
|
|
|
920772
921162
|
sshSession = await createSSHSession2({
|
|
920773
921163
|
host: _pendingSSH.host,
|
|
920774
921164
|
cwd: _pendingSSH.cwd,
|
|
920775
|
-
localVersion: "4.2.8-
|
|
921165
|
+
localVersion: "4.2.8-beta2",
|
|
920776
921166
|
permissionMode: _pendingSSH.permissionMode,
|
|
920777
921167
|
dangerouslySkipPermissions: _pendingSSH.dangerouslySkipPermissions,
|
|
920778
921168
|
extraCliArgs: _pendingSSH.extraCliArgs,
|
|
@@ -921244,7 +921634,7 @@ Usage: csc --remote "your task description"`, () => gracefulShutdown(1));
|
|
|
921244
921634
|
pendingHookMessages
|
|
921245
921635
|
}, renderAndRun);
|
|
921246
921636
|
}
|
|
921247
|
-
}).version("4.2.8-
|
|
921637
|
+
}).version("4.2.8-beta2 (CoStrict)", "-v, --version", cliDesc("cli.option.version", "Output the version number"));
|
|
921248
921638
|
program2.addOption(new Option("-w, --worktree [name]", cliDesc("cli.option.worktree", "Create a new git worktree for this session (optionally specify a name)")).hideHelp());
|
|
921249
921639
|
program2.addOption(new Option("--tmux", cliDesc("cli.option.tmux", "Create a tmux session for the worktree (requires --worktree). Uses iTerm2 native panes when available; use --tmux=classic for traditional tmux.")).hideHelp());
|
|
921250
921640
|
if (canUserConfigureAdvisor()) {
|
|
@@ -921960,10 +922350,10 @@ if (process.env.CLAUDE_CODE_REMOTE === "true") {
|
|
|
921960
922350
|
async function main2() {
|
|
921961
922351
|
const args = process.argv.slice(2);
|
|
921962
922352
|
if (args.length === 1 && (args[0] === "--version" || args[0] === "-v" || args[0] === "-V")) {
|
|
921963
|
-
const d4 = new Date("2026-
|
|
922353
|
+
const d4 = new Date("2026-07-01T02:28:03.350Z");
|
|
921964
922354
|
const p2 = (n3) => String(n3).padStart(2, "0");
|
|
921965
922355
|
const buildTime = `${d4.getFullYear()}/${p2(d4.getMonth() + 1)}/${p2(d4.getDate())} ${p2(d4.getHours())}:${p2(d4.getMinutes())}:${p2(d4.getSeconds())}`;
|
|
921966
|
-
console.log(`${"4.2.8-
|
|
922356
|
+
console.log(`${"4.2.8-beta2"} (commit: ${"0d7f05777"}, built: ${buildTime})`);
|
|
921967
922357
|
return;
|
|
921968
922358
|
}
|
|
921969
922359
|
const { terminateBatchWorker: terminateBatchWorker2 } = await Promise.resolve().then(() => (init_spawn(), exports_spawn));
|
|
@@ -922033,7 +922423,7 @@ async function main2() {
|
|
|
922033
922423
|
registerPermissionHandler(server2, handler) {
|
|
922034
922424
|
server2.setNotificationHandler(ChannelPermissionRequestNotificationSchema2(), async (notification) => handler(notification.params));
|
|
922035
922425
|
}
|
|
922036
|
-
}, "4.2.8-
|
|
922426
|
+
}, "4.2.8-beta2");
|
|
922037
922427
|
return;
|
|
922038
922428
|
}
|
|
922039
922429
|
if (args[0] === "--daemon-worker" || args[0]?.startsWith("--daemon-worker=")) {
|
|
@@ -922131,5 +922521,5 @@ async function main2() {
|
|
|
922131
922521
|
}
|
|
922132
922522
|
main2();
|
|
922133
922523
|
|
|
922134
|
-
//# debugId=
|
|
922524
|
+
//# debugId=6E4236F81BDDD39164756E2164756E21
|
|
922135
922525
|
//# sourceMappingURL=cli.js.map
|