happy-imou-cloud 2.0.13 → 2.0.16
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/BaseReasoningProcessor-BqMAZlIw.cjs +323 -0
- package/dist/BaseReasoningProcessor-C04_LHjN.mjs +320 -0
- package/dist/ProviderSelectionHandler-CO9NkAt6.cjs +265 -0
- package/dist/ProviderSelectionHandler-DDWyn9Lo.mjs +261 -0
- package/dist/{api-DH5-IqeM.cjs → api-Db1SQcP_.cjs} +2 -2
- package/dist/{api-D1meoL-9.mjs → api-sRF6xXi-.mjs} +2 -2
- package/dist/{command-CMvWClny.mjs → command-WcgGTRnG.mjs} +4 -3
- package/dist/{command-Ch8Dgidj.cjs → command-eRjSBm2C.cjs} +4 -3
- package/dist/{index-CryJfCh5.cjs → index-B6ID1zDR.cjs} +1106 -50
- package/dist/{index-Cxrx9m5D.mjs → index-DpWeKfvS.mjs} +1102 -50
- package/dist/index.cjs +5 -4
- package/dist/index.mjs +5 -4
- package/dist/lib.cjs +1 -1
- package/dist/lib.mjs +1 -1
- package/dist/{persistence-9Iu0wGNM.mjs → persistence-B89V4xY5.mjs} +1 -1
- package/dist/{persistence-Bl3FYvwd.cjs → persistence-Btu2VPXI.cjs} +1 -1
- package/dist/{registerKillSessionHandler-BElGmD1E.mjs → registerKillSessionHandler-CwmYlUfS.mjs} +541 -5
- package/dist/{registerKillSessionHandler-BjkY-oUn.cjs → registerKillSessionHandler-eZ2TsHqx.cjs} +549 -4
- package/dist/{runClaude-CDZxAF3l.cjs → runClaude-C9-ylbQh.cjs} +599 -747
- package/dist/{runClaude-D7dF4RDM.mjs → runClaude-kRPXCaBj.mjs} +591 -738
- package/dist/{runCodex-DnGz1XES.mjs → runCodex-B1xN0wAU.mjs} +9 -215
- package/dist/{runCodex-Cik8VzFs.cjs → runCodex-CRNBxY5f.cjs} +20 -226
- package/dist/{runGemini-BM2BQ4I7.cjs → runGemini-BZ5hqJyl.cjs} +16 -15
- package/dist/{runGemini-B8tXMHeL.mjs → runGemini-Xn2VwS88.mjs} +8 -7
- package/package.json +1 -1
- package/scripts/release-smoke.mjs +6 -5
- package/dist/ConversationHistory-V3VLmjJf.cjs +0 -868
- package/dist/ConversationHistory-_ciJNIgH.mjs +0 -856
- package/dist/createKeepAliveController-C5cQlDRr.mjs +0 -51
- package/dist/createKeepAliveController-DO8H6d5E.cjs +0 -54
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chalk = require('chalk');
|
|
4
|
-
var api = require('./api-
|
|
5
|
-
var persistence = require('./persistence-
|
|
4
|
+
var api = require('./api-Db1SQcP_.cjs');
|
|
5
|
+
var persistence = require('./persistence-Btu2VPXI.cjs');
|
|
6
6
|
var z = require('zod');
|
|
7
7
|
var fs$2 = require('fs/promises');
|
|
8
8
|
var os$1 = require('os');
|
|
@@ -33,6 +33,7 @@ var node_readline = require('node:readline');
|
|
|
33
33
|
var http = require('http');
|
|
34
34
|
var util = require('util');
|
|
35
35
|
var sdk = require('@agentclientprotocol/sdk');
|
|
36
|
+
var node_url = require('node:url');
|
|
36
37
|
require('node:events');
|
|
37
38
|
|
|
38
39
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
@@ -71,7 +72,7 @@ async function openBrowser(url) {
|
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
|
|
74
|
-
const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-
|
|
75
|
+
const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-B6ID1zDR.cjs', document.baseURI).href)));
|
|
75
76
|
const QRCode = require$1("qrcode-terminal/vendor/QRCode");
|
|
76
77
|
const QRErrorCorrectLevel = require$1("qrcode-terminal/vendor/QRCode/QRErrorCorrectLevel");
|
|
77
78
|
const pendingTempFiles = /* @__PURE__ */ new Set();
|
|
@@ -694,9 +695,9 @@ function setupCleanupHandlers() {
|
|
|
694
695
|
});
|
|
695
696
|
}
|
|
696
697
|
|
|
697
|
-
const __dirname$
|
|
698
|
+
const __dirname$2 = path$1.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-B6ID1zDR.cjs', document.baseURI).href))));
|
|
698
699
|
function projectPath() {
|
|
699
|
-
const path = path$1.resolve(__dirname$
|
|
700
|
+
const path = path$1.resolve(__dirname$2, "..");
|
|
700
701
|
return path;
|
|
701
702
|
}
|
|
702
703
|
|
|
@@ -4968,7 +4969,7 @@ class ClaudeTransport extends DefaultTransport {
|
|
|
4968
4969
|
return 600;
|
|
4969
4970
|
}
|
|
4970
4971
|
}
|
|
4971
|
-
|
|
4972
|
+
new ClaudeTransport();
|
|
4972
4973
|
|
|
4973
4974
|
class CursorTransport extends DefaultTransport {
|
|
4974
4975
|
constructor() {
|
|
@@ -5006,7 +5007,7 @@ function appendToolOutput(existing, next) {
|
|
|
5006
5007
|
}
|
|
5007
5008
|
return `${existing}${next}`;
|
|
5008
5009
|
}
|
|
5009
|
-
function isRecord(value) {
|
|
5010
|
+
function isRecord$1(value) {
|
|
5010
5011
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5011
5012
|
}
|
|
5012
5013
|
function hasMeaningfulContent(value) {
|
|
@@ -5019,7 +5020,7 @@ function hasMeaningfulContent(value) {
|
|
|
5019
5020
|
if (Array.isArray(value)) {
|
|
5020
5021
|
return value.length > 0;
|
|
5021
5022
|
}
|
|
5022
|
-
if (isRecord(value)) {
|
|
5023
|
+
if (isRecord$1(value)) {
|
|
5023
5024
|
return Object.keys(value).length > 0;
|
|
5024
5025
|
}
|
|
5025
5026
|
return true;
|
|
@@ -5042,7 +5043,7 @@ function looksLikeToolMetadata(record) {
|
|
|
5042
5043
|
const nestedKeys = ["input", "toolCall", "arguments", "content"];
|
|
5043
5044
|
for (const key of nestedKeys) {
|
|
5044
5045
|
const nested = record[key];
|
|
5045
|
-
if (isRecord(nested) && looksLikeToolMetadata(nested)) {
|
|
5046
|
+
if (isRecord$1(nested) && looksLikeToolMetadata(nested)) {
|
|
5046
5047
|
return true;
|
|
5047
5048
|
}
|
|
5048
5049
|
}
|
|
@@ -5056,7 +5057,7 @@ function extractToolOutputChunk(content) {
|
|
|
5056
5057
|
const parts = content.map((item) => extractToolOutputChunk(item)).filter((item) => Boolean(item));
|
|
5057
5058
|
return parts.length > 0 ? parts.join("") : null;
|
|
5058
5059
|
}
|
|
5059
|
-
if (!isRecord(content)) {
|
|
5060
|
+
if (!isRecord$1(content)) {
|
|
5060
5061
|
return null;
|
|
5061
5062
|
}
|
|
5062
5063
|
const outputKeys = ["stdout", "stderr", "output", "text", "message", "data", "error", "reason"];
|
|
@@ -5084,7 +5085,7 @@ function mergeStreamedOutputWithResult(content, streamedOutput) {
|
|
|
5084
5085
|
if (!hasMeaningfulContent(content)) {
|
|
5085
5086
|
return streamedOutput;
|
|
5086
5087
|
}
|
|
5087
|
-
if (isRecord(content)) {
|
|
5088
|
+
if (isRecord$1(content)) {
|
|
5088
5089
|
const hasStructuredOutput = ["stdout", "stderr", "output", "text", "message", "data"].some((key) => key in content);
|
|
5089
5090
|
if (!hasStructuredOutput) {
|
|
5090
5091
|
return {
|
|
@@ -7376,6 +7377,1051 @@ function registerCodexAgent() {
|
|
|
7376
7377
|
agentRegistry.register("codex", (opts) => createCodexBackend(opts).backend);
|
|
7377
7378
|
}
|
|
7378
7379
|
|
|
7380
|
+
class Stream {
|
|
7381
|
+
constructor(returned) {
|
|
7382
|
+
this.returned = returned;
|
|
7383
|
+
}
|
|
7384
|
+
queue = [];
|
|
7385
|
+
readResolve;
|
|
7386
|
+
readReject;
|
|
7387
|
+
isDone = false;
|
|
7388
|
+
hasError;
|
|
7389
|
+
started = false;
|
|
7390
|
+
/**
|
|
7391
|
+
* Implements async iterable protocol
|
|
7392
|
+
*/
|
|
7393
|
+
[Symbol.asyncIterator]() {
|
|
7394
|
+
if (this.started) {
|
|
7395
|
+
throw new Error("Stream can only be iterated once");
|
|
7396
|
+
}
|
|
7397
|
+
this.started = true;
|
|
7398
|
+
return this;
|
|
7399
|
+
}
|
|
7400
|
+
/**
|
|
7401
|
+
* Gets the next value from the stream
|
|
7402
|
+
*/
|
|
7403
|
+
async next() {
|
|
7404
|
+
if (this.queue.length > 0) {
|
|
7405
|
+
return Promise.resolve({
|
|
7406
|
+
done: false,
|
|
7407
|
+
value: this.queue.shift()
|
|
7408
|
+
});
|
|
7409
|
+
}
|
|
7410
|
+
if (this.isDone) {
|
|
7411
|
+
return Promise.resolve({ done: true, value: void 0 });
|
|
7412
|
+
}
|
|
7413
|
+
if (this.hasError) {
|
|
7414
|
+
return Promise.reject(this.hasError);
|
|
7415
|
+
}
|
|
7416
|
+
return new Promise((resolve, reject) => {
|
|
7417
|
+
this.readResolve = resolve;
|
|
7418
|
+
this.readReject = reject;
|
|
7419
|
+
});
|
|
7420
|
+
}
|
|
7421
|
+
/**
|
|
7422
|
+
* Adds a value to the stream
|
|
7423
|
+
*/
|
|
7424
|
+
enqueue(value) {
|
|
7425
|
+
if (this.readResolve) {
|
|
7426
|
+
const resolve = this.readResolve;
|
|
7427
|
+
this.readResolve = void 0;
|
|
7428
|
+
this.readReject = void 0;
|
|
7429
|
+
resolve({ done: false, value });
|
|
7430
|
+
} else {
|
|
7431
|
+
this.queue.push(value);
|
|
7432
|
+
}
|
|
7433
|
+
}
|
|
7434
|
+
/**
|
|
7435
|
+
* Marks the stream as complete
|
|
7436
|
+
*/
|
|
7437
|
+
done() {
|
|
7438
|
+
this.isDone = true;
|
|
7439
|
+
if (this.readResolve) {
|
|
7440
|
+
const resolve = this.readResolve;
|
|
7441
|
+
this.readResolve = void 0;
|
|
7442
|
+
this.readReject = void 0;
|
|
7443
|
+
resolve({ done: true, value: void 0 });
|
|
7444
|
+
}
|
|
7445
|
+
}
|
|
7446
|
+
/**
|
|
7447
|
+
* Propagates an error through the stream
|
|
7448
|
+
*/
|
|
7449
|
+
error(error) {
|
|
7450
|
+
this.hasError = error;
|
|
7451
|
+
if (this.readReject) {
|
|
7452
|
+
const reject = this.readReject;
|
|
7453
|
+
this.readResolve = void 0;
|
|
7454
|
+
this.readReject = void 0;
|
|
7455
|
+
reject(error);
|
|
7456
|
+
}
|
|
7457
|
+
}
|
|
7458
|
+
/**
|
|
7459
|
+
* Implements async iterator cleanup
|
|
7460
|
+
*/
|
|
7461
|
+
async return() {
|
|
7462
|
+
this.isDone = true;
|
|
7463
|
+
if (this.returned) {
|
|
7464
|
+
this.returned();
|
|
7465
|
+
}
|
|
7466
|
+
return Promise.resolve({ done: true, value: void 0 });
|
|
7467
|
+
}
|
|
7468
|
+
}
|
|
7469
|
+
|
|
7470
|
+
class AbortError extends Error {
|
|
7471
|
+
constructor(message) {
|
|
7472
|
+
super(message);
|
|
7473
|
+
this.name = "AbortError";
|
|
7474
|
+
}
|
|
7475
|
+
}
|
|
7476
|
+
|
|
7477
|
+
const __filename$1 = node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-B6ID1zDR.cjs', document.baseURI).href)));
|
|
7478
|
+
const __dirname$1 = path.join(__filename$1, "..");
|
|
7479
|
+
function getGlobalClaudeVersion() {
|
|
7480
|
+
try {
|
|
7481
|
+
const cleanEnv = getCleanEnv();
|
|
7482
|
+
const output = node_child_process.execSync("claude --version", {
|
|
7483
|
+
encoding: "utf8",
|
|
7484
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
7485
|
+
cwd: os.homedir(),
|
|
7486
|
+
env: cleanEnv
|
|
7487
|
+
}).trim();
|
|
7488
|
+
const match = output.match(/(\d+\.\d+\.\d+)/);
|
|
7489
|
+
api.logger.debug(`[Claude SDK] Global claude --version output: ${output}`);
|
|
7490
|
+
return match ? match[1] : null;
|
|
7491
|
+
} catch {
|
|
7492
|
+
return null;
|
|
7493
|
+
}
|
|
7494
|
+
}
|
|
7495
|
+
function getCleanEnv() {
|
|
7496
|
+
const env = { ...process.env };
|
|
7497
|
+
const cwd = process.cwd();
|
|
7498
|
+
const pathSep = process.platform === "win32" ? ";" : ":";
|
|
7499
|
+
const pathKey = process.platform === "win32" ? "Path" : "PATH";
|
|
7500
|
+
const actualPathKey = Object.keys(env).find((k) => k.toLowerCase() === "path") || pathKey;
|
|
7501
|
+
if (env[actualPathKey]) {
|
|
7502
|
+
const cleanPath = env[actualPathKey].split(pathSep).filter((p) => {
|
|
7503
|
+
const normalizedP = p.replace(/\\/g, "/").toLowerCase();
|
|
7504
|
+
const normalizedCwd = cwd.replace(/\\/g, "/").toLowerCase();
|
|
7505
|
+
return !normalizedP.startsWith(normalizedCwd);
|
|
7506
|
+
}).join(pathSep);
|
|
7507
|
+
env[actualPathKey] = cleanPath;
|
|
7508
|
+
api.logger.debug(`[Claude SDK] Cleaned PATH, removed local paths from: ${cwd}`);
|
|
7509
|
+
}
|
|
7510
|
+
if (isBun()) {
|
|
7511
|
+
Object.keys(env).forEach((key) => {
|
|
7512
|
+
if (key.startsWith("BUN_")) {
|
|
7513
|
+
delete env[key];
|
|
7514
|
+
}
|
|
7515
|
+
});
|
|
7516
|
+
api.logger.debug("[Claude SDK] Removed Bun-specific environment variables for Node.js compatibility");
|
|
7517
|
+
}
|
|
7518
|
+
return env;
|
|
7519
|
+
}
|
|
7520
|
+
function findGlobalClaudePath() {
|
|
7521
|
+
const homeDir = os.homedir();
|
|
7522
|
+
const cleanEnv = getCleanEnv();
|
|
7523
|
+
try {
|
|
7524
|
+
node_child_process.execSync("claude --version", {
|
|
7525
|
+
encoding: "utf8",
|
|
7526
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
7527
|
+
cwd: homeDir,
|
|
7528
|
+
env: cleanEnv
|
|
7529
|
+
});
|
|
7530
|
+
api.logger.debug("[Claude SDK] Global claude command available (checked with clean PATH)");
|
|
7531
|
+
return "claude";
|
|
7532
|
+
} catch {
|
|
7533
|
+
}
|
|
7534
|
+
if (process.platform !== "win32") {
|
|
7535
|
+
try {
|
|
7536
|
+
const result = node_child_process.execSync("which claude", {
|
|
7537
|
+
encoding: "utf8",
|
|
7538
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
7539
|
+
cwd: homeDir,
|
|
7540
|
+
env: cleanEnv
|
|
7541
|
+
}).trim();
|
|
7542
|
+
if (result && fs.existsSync(result)) {
|
|
7543
|
+
api.logger.debug(`[Claude SDK] Found global claude path via which: ${result}`);
|
|
7544
|
+
return result;
|
|
7545
|
+
}
|
|
7546
|
+
} catch {
|
|
7547
|
+
}
|
|
7548
|
+
}
|
|
7549
|
+
return null;
|
|
7550
|
+
}
|
|
7551
|
+
function getDefaultClaudeCodePath() {
|
|
7552
|
+
const nodeModulesPath = path.join(__dirname$1, "..", "..", "..", "node_modules", "@anthropic-ai", "claude-code", "cli.js");
|
|
7553
|
+
if (process.env.HAPPY_CLAUDE_PATH) {
|
|
7554
|
+
api.logger.debug(`[Claude SDK] Using HAPPY_CLAUDE_PATH: ${process.env.HAPPY_CLAUDE_PATH}`);
|
|
7555
|
+
return process.env.HAPPY_CLAUDE_PATH;
|
|
7556
|
+
}
|
|
7557
|
+
if (process.env.HAPPY_USE_BUNDLED_CLAUDE === "1") {
|
|
7558
|
+
api.logger.debug(`[Claude SDK] Forced bundled version: ${nodeModulesPath}`);
|
|
7559
|
+
return nodeModulesPath;
|
|
7560
|
+
}
|
|
7561
|
+
const globalPath = findGlobalClaudePath();
|
|
7562
|
+
if (!globalPath) {
|
|
7563
|
+
api.logger.debug(`[Claude SDK] No global claude found, using bundled: ${nodeModulesPath}`);
|
|
7564
|
+
return nodeModulesPath;
|
|
7565
|
+
}
|
|
7566
|
+
const globalVersion = getGlobalClaudeVersion();
|
|
7567
|
+
api.logger.debug(`[Claude SDK] Global version: ${globalVersion || "unknown"}`);
|
|
7568
|
+
if (!globalVersion) {
|
|
7569
|
+
api.logger.debug(`[Claude SDK] Cannot compare versions, using global: ${globalPath}`);
|
|
7570
|
+
return globalPath;
|
|
7571
|
+
}
|
|
7572
|
+
return globalPath;
|
|
7573
|
+
}
|
|
7574
|
+
function logDebug(message) {
|
|
7575
|
+
if (process.env.DEBUG) {
|
|
7576
|
+
api.logger.debug(message);
|
|
7577
|
+
console.log(message);
|
|
7578
|
+
}
|
|
7579
|
+
}
|
|
7580
|
+
async function streamToStdin(stream, stdin, abort) {
|
|
7581
|
+
for await (const message of stream) {
|
|
7582
|
+
if (abort?.aborted) break;
|
|
7583
|
+
stdin.write(JSON.stringify(message) + "\n");
|
|
7584
|
+
}
|
|
7585
|
+
stdin.end();
|
|
7586
|
+
}
|
|
7587
|
+
|
|
7588
|
+
class Query {
|
|
7589
|
+
constructor(childStdin, childStdout, processExitPromise, canCallTool) {
|
|
7590
|
+
this.childStdin = childStdin;
|
|
7591
|
+
this.childStdout = childStdout;
|
|
7592
|
+
this.processExitPromise = processExitPromise;
|
|
7593
|
+
this.canCallTool = canCallTool;
|
|
7594
|
+
this.readMessages();
|
|
7595
|
+
this.sdkMessages = this.readSdkMessages();
|
|
7596
|
+
}
|
|
7597
|
+
pendingControlResponses = /* @__PURE__ */ new Map();
|
|
7598
|
+
cancelControllers = /* @__PURE__ */ new Map();
|
|
7599
|
+
sdkMessages;
|
|
7600
|
+
inputStream = new Stream();
|
|
7601
|
+
canCallTool;
|
|
7602
|
+
/**
|
|
7603
|
+
* Set an error on the stream
|
|
7604
|
+
*/
|
|
7605
|
+
setError(error) {
|
|
7606
|
+
this.inputStream.error(error);
|
|
7607
|
+
}
|
|
7608
|
+
/**
|
|
7609
|
+
* AsyncIterableIterator implementation
|
|
7610
|
+
*/
|
|
7611
|
+
next(...args) {
|
|
7612
|
+
return this.sdkMessages.next(...args);
|
|
7613
|
+
}
|
|
7614
|
+
return(value) {
|
|
7615
|
+
if (this.sdkMessages.return) {
|
|
7616
|
+
return this.sdkMessages.return(value);
|
|
7617
|
+
}
|
|
7618
|
+
return Promise.resolve({ done: true, value: void 0 });
|
|
7619
|
+
}
|
|
7620
|
+
throw(e) {
|
|
7621
|
+
if (this.sdkMessages.throw) {
|
|
7622
|
+
return this.sdkMessages.throw(e);
|
|
7623
|
+
}
|
|
7624
|
+
return Promise.reject(e);
|
|
7625
|
+
}
|
|
7626
|
+
[Symbol.asyncIterator]() {
|
|
7627
|
+
return this.sdkMessages;
|
|
7628
|
+
}
|
|
7629
|
+
/**
|
|
7630
|
+
* Read messages from Claude process stdout
|
|
7631
|
+
*/
|
|
7632
|
+
async readMessages() {
|
|
7633
|
+
const rl = node_readline.createInterface({ input: this.childStdout });
|
|
7634
|
+
try {
|
|
7635
|
+
for await (const line of rl) {
|
|
7636
|
+
if (line.trim()) {
|
|
7637
|
+
try {
|
|
7638
|
+
const message = JSON.parse(line);
|
|
7639
|
+
if (message.type === "control_response") {
|
|
7640
|
+
const controlResponse = message;
|
|
7641
|
+
const handler = this.pendingControlResponses.get(controlResponse.response.request_id);
|
|
7642
|
+
if (handler) {
|
|
7643
|
+
handler(controlResponse.response);
|
|
7644
|
+
}
|
|
7645
|
+
continue;
|
|
7646
|
+
} else if (message.type === "control_request") {
|
|
7647
|
+
await this.handleControlRequest(message);
|
|
7648
|
+
continue;
|
|
7649
|
+
} else if (message.type === "control_cancel_request") {
|
|
7650
|
+
this.handleControlCancelRequest(message);
|
|
7651
|
+
continue;
|
|
7652
|
+
}
|
|
7653
|
+
this.inputStream.enqueue(message);
|
|
7654
|
+
} catch (e) {
|
|
7655
|
+
api.logger.debug(line);
|
|
7656
|
+
}
|
|
7657
|
+
}
|
|
7658
|
+
}
|
|
7659
|
+
await this.processExitPromise;
|
|
7660
|
+
} catch (error) {
|
|
7661
|
+
this.inputStream.error(error);
|
|
7662
|
+
} finally {
|
|
7663
|
+
this.inputStream.done();
|
|
7664
|
+
this.cleanupControllers();
|
|
7665
|
+
rl.close();
|
|
7666
|
+
}
|
|
7667
|
+
}
|
|
7668
|
+
/**
|
|
7669
|
+
* Async generator for SDK messages
|
|
7670
|
+
*/
|
|
7671
|
+
async *readSdkMessages() {
|
|
7672
|
+
for await (const message of this.inputStream) {
|
|
7673
|
+
yield message;
|
|
7674
|
+
}
|
|
7675
|
+
}
|
|
7676
|
+
/**
|
|
7677
|
+
* Send interrupt request to Claude
|
|
7678
|
+
*/
|
|
7679
|
+
async interrupt() {
|
|
7680
|
+
if (!this.childStdin) {
|
|
7681
|
+
throw new Error("Interrupt requires --input-format stream-json");
|
|
7682
|
+
}
|
|
7683
|
+
await this.request({
|
|
7684
|
+
subtype: "interrupt"
|
|
7685
|
+
}, this.childStdin);
|
|
7686
|
+
}
|
|
7687
|
+
/**
|
|
7688
|
+
* Send control request to Claude process
|
|
7689
|
+
*/
|
|
7690
|
+
request(request, childStdin) {
|
|
7691
|
+
const requestId = Math.random().toString(36).substring(2, 15);
|
|
7692
|
+
const sdkRequest = {
|
|
7693
|
+
request_id: requestId,
|
|
7694
|
+
type: "control_request",
|
|
7695
|
+
request
|
|
7696
|
+
};
|
|
7697
|
+
return new Promise((resolve, reject) => {
|
|
7698
|
+
this.pendingControlResponses.set(requestId, (response) => {
|
|
7699
|
+
if (response.subtype === "success") {
|
|
7700
|
+
resolve(response);
|
|
7701
|
+
} else {
|
|
7702
|
+
reject(new Error(response.error));
|
|
7703
|
+
}
|
|
7704
|
+
});
|
|
7705
|
+
childStdin.write(JSON.stringify(sdkRequest) + "\n");
|
|
7706
|
+
});
|
|
7707
|
+
}
|
|
7708
|
+
/**
|
|
7709
|
+
* Handle incoming control requests for tool permissions
|
|
7710
|
+
* Replicates the exact logic from the SDK's handleControlRequest method
|
|
7711
|
+
*/
|
|
7712
|
+
async handleControlRequest(request) {
|
|
7713
|
+
if (!this.childStdin) {
|
|
7714
|
+
logDebug("Cannot handle control request - no stdin available");
|
|
7715
|
+
return;
|
|
7716
|
+
}
|
|
7717
|
+
const controller = new AbortController();
|
|
7718
|
+
this.cancelControllers.set(request.request_id, controller);
|
|
7719
|
+
try {
|
|
7720
|
+
const response = await this.processControlRequest(request, controller.signal);
|
|
7721
|
+
const controlResponse = {
|
|
7722
|
+
type: "control_response",
|
|
7723
|
+
response: {
|
|
7724
|
+
subtype: "success",
|
|
7725
|
+
request_id: request.request_id,
|
|
7726
|
+
response
|
|
7727
|
+
}
|
|
7728
|
+
};
|
|
7729
|
+
this.childStdin.write(JSON.stringify(controlResponse) + "\n");
|
|
7730
|
+
} catch (error) {
|
|
7731
|
+
const controlErrorResponse = {
|
|
7732
|
+
type: "control_response",
|
|
7733
|
+
response: {
|
|
7734
|
+
subtype: "error",
|
|
7735
|
+
request_id: request.request_id,
|
|
7736
|
+
error: error instanceof Error ? error.message : String(error)
|
|
7737
|
+
}
|
|
7738
|
+
};
|
|
7739
|
+
this.childStdin.write(JSON.stringify(controlErrorResponse) + "\n");
|
|
7740
|
+
} finally {
|
|
7741
|
+
this.cancelControllers.delete(request.request_id);
|
|
7742
|
+
}
|
|
7743
|
+
}
|
|
7744
|
+
/**
|
|
7745
|
+
* Handle control cancel requests
|
|
7746
|
+
* Replicates the exact logic from the SDK's handleControlCancelRequest method
|
|
7747
|
+
*/
|
|
7748
|
+
handleControlCancelRequest(request) {
|
|
7749
|
+
const controller = this.cancelControllers.get(request.request_id);
|
|
7750
|
+
if (controller) {
|
|
7751
|
+
controller.abort();
|
|
7752
|
+
this.cancelControllers.delete(request.request_id);
|
|
7753
|
+
}
|
|
7754
|
+
}
|
|
7755
|
+
/**
|
|
7756
|
+
* Process control requests based on subtype
|
|
7757
|
+
* Replicates the exact logic from the SDK's processControlRequest method
|
|
7758
|
+
*/
|
|
7759
|
+
async processControlRequest(request, signal) {
|
|
7760
|
+
if (request.request.subtype === "can_use_tool") {
|
|
7761
|
+
if (!this.canCallTool) {
|
|
7762
|
+
throw new Error("canCallTool callback is not provided.");
|
|
7763
|
+
}
|
|
7764
|
+
return this.canCallTool(request.request.tool_name, request.request.input, {
|
|
7765
|
+
signal,
|
|
7766
|
+
requestId: request.request_id
|
|
7767
|
+
});
|
|
7768
|
+
}
|
|
7769
|
+
throw new Error("Unsupported control request subtype: " + request.request.subtype);
|
|
7770
|
+
}
|
|
7771
|
+
/**
|
|
7772
|
+
* Cleanup method to abort all pending control requests
|
|
7773
|
+
*/
|
|
7774
|
+
cleanupControllers() {
|
|
7775
|
+
for (const [requestId, controller] of this.cancelControllers.entries()) {
|
|
7776
|
+
controller.abort();
|
|
7777
|
+
this.cancelControllers.delete(requestId);
|
|
7778
|
+
}
|
|
7779
|
+
}
|
|
7780
|
+
}
|
|
7781
|
+
function query(config) {
|
|
7782
|
+
const {
|
|
7783
|
+
prompt,
|
|
7784
|
+
options: {
|
|
7785
|
+
allowedTools = [],
|
|
7786
|
+
appendSystemPrompt,
|
|
7787
|
+
customSystemPrompt,
|
|
7788
|
+
cwd,
|
|
7789
|
+
disallowedTools = [],
|
|
7790
|
+
env,
|
|
7791
|
+
executable = "node",
|
|
7792
|
+
executableArgs = [],
|
|
7793
|
+
maxTurns,
|
|
7794
|
+
mcpServers,
|
|
7795
|
+
pathToClaudeCodeExecutable = getDefaultClaudeCodePath(),
|
|
7796
|
+
permissionMode,
|
|
7797
|
+
continue: continueConversation,
|
|
7798
|
+
resume,
|
|
7799
|
+
model,
|
|
7800
|
+
fallbackModel,
|
|
7801
|
+
strictMcpConfig,
|
|
7802
|
+
canCallTool,
|
|
7803
|
+
settingsPath,
|
|
7804
|
+
extraArgs = []
|
|
7805
|
+
} = {}
|
|
7806
|
+
} = config;
|
|
7807
|
+
if (!process.env.CLAUDE_CODE_ENTRYPOINT) {
|
|
7808
|
+
process.env.CLAUDE_CODE_ENTRYPOINT = "sdk-ts";
|
|
7809
|
+
}
|
|
7810
|
+
const args = [...extraArgs, "--output-format", "stream-json", "--verbose"];
|
|
7811
|
+
if (customSystemPrompt) args.push("--system-prompt", customSystemPrompt);
|
|
7812
|
+
if (appendSystemPrompt) args.push("--append-system-prompt", appendSystemPrompt);
|
|
7813
|
+
if (maxTurns) args.push("--max-turns", maxTurns.toString());
|
|
7814
|
+
if (model) args.push("--model", model);
|
|
7815
|
+
if (canCallTool) {
|
|
7816
|
+
if (typeof prompt === "string") {
|
|
7817
|
+
throw new Error("canCallTool callback requires --input-format stream-json. Please set prompt as an AsyncIterable.");
|
|
7818
|
+
}
|
|
7819
|
+
args.push("--permission-prompt-tool", "stdio");
|
|
7820
|
+
}
|
|
7821
|
+
if (continueConversation) args.push("--continue");
|
|
7822
|
+
if (resume) args.push("--resume", resume);
|
|
7823
|
+
if (allowedTools.length > 0) args.push("--allowedTools", allowedTools.join(","));
|
|
7824
|
+
if (disallowedTools.length > 0) args.push("--disallowedTools", disallowedTools.join(","));
|
|
7825
|
+
if (mcpServers && Object.keys(mcpServers).length > 0) {
|
|
7826
|
+
args.push("--mcp-config", JSON.stringify({ mcpServers }));
|
|
7827
|
+
}
|
|
7828
|
+
if (strictMcpConfig) args.push("--strict-mcp-config");
|
|
7829
|
+
if (permissionMode) args.push("--permission-mode", permissionMode);
|
|
7830
|
+
if (settingsPath) args.push("--settings", settingsPath);
|
|
7831
|
+
if (fallbackModel) {
|
|
7832
|
+
if (model && fallbackModel === model) {
|
|
7833
|
+
throw new Error("Fallback model cannot be the same as the main model. Please specify a different model for fallbackModel option.");
|
|
7834
|
+
}
|
|
7835
|
+
args.push("--fallback-model", fallbackModel);
|
|
7836
|
+
}
|
|
7837
|
+
if (typeof prompt === "string") {
|
|
7838
|
+
args.push("--print", prompt.trim());
|
|
7839
|
+
} else {
|
|
7840
|
+
args.push("--input-format", "stream-json");
|
|
7841
|
+
}
|
|
7842
|
+
const isJsFile = pathToClaudeCodeExecutable.endsWith(".js") || pathToClaudeCodeExecutable.endsWith(".cjs");
|
|
7843
|
+
const isCommandOnly = pathToClaudeCodeExecutable === "claude";
|
|
7844
|
+
if (!isCommandOnly && !fs.existsSync(pathToClaudeCodeExecutable)) {
|
|
7845
|
+
throw new ReferenceError(`Claude Code executable not found at ${pathToClaudeCodeExecutable}. Is options.pathToClaudeCodeExecutable set?`);
|
|
7846
|
+
}
|
|
7847
|
+
const spawnCommand = isJsFile ? executable : pathToClaudeCodeExecutable;
|
|
7848
|
+
const spawnArgs = isJsFile ? [...executableArgs, pathToClaudeCodeExecutable, ...args] : args;
|
|
7849
|
+
const spawnEnv = {
|
|
7850
|
+
...isCommandOnly ? getCleanEnv() : process.env,
|
|
7851
|
+
...env
|
|
7852
|
+
};
|
|
7853
|
+
logDebug(`Spawning Claude Code process: ${spawnCommand} ${spawnArgs.join(" ")} (using ${isCommandOnly ? "clean" : "normal"} env)`);
|
|
7854
|
+
const child = node_child_process.spawn(spawnCommand, spawnArgs, {
|
|
7855
|
+
cwd,
|
|
7856
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
7857
|
+
signal: config.options?.abort,
|
|
7858
|
+
env: spawnEnv,
|
|
7859
|
+
// Use shell on Windows for global binaries and command-only mode
|
|
7860
|
+
shell: !isJsFile && process.platform === "win32"
|
|
7861
|
+
});
|
|
7862
|
+
let childStdin = null;
|
|
7863
|
+
if (typeof prompt === "string") {
|
|
7864
|
+
child.stdin.end();
|
|
7865
|
+
} else {
|
|
7866
|
+
streamToStdin(prompt, child.stdin, config.options?.abort);
|
|
7867
|
+
childStdin = child.stdin;
|
|
7868
|
+
}
|
|
7869
|
+
if (process.env.DEBUG) {
|
|
7870
|
+
child.stderr.on("data", (data) => {
|
|
7871
|
+
console.error("Claude Code stderr:", data.toString());
|
|
7872
|
+
});
|
|
7873
|
+
}
|
|
7874
|
+
const cleanup = () => {
|
|
7875
|
+
if (!child.killed) {
|
|
7876
|
+
child.kill("SIGTERM");
|
|
7877
|
+
}
|
|
7878
|
+
};
|
|
7879
|
+
config.options?.abort?.addEventListener("abort", cleanup);
|
|
7880
|
+
process.on("exit", cleanup);
|
|
7881
|
+
const processExitPromise = new Promise((resolve) => {
|
|
7882
|
+
child.on("close", (code) => {
|
|
7883
|
+
if (config.options?.abort?.aborted) {
|
|
7884
|
+
query2.setError(new AbortError("Claude Code process aborted by user"));
|
|
7885
|
+
}
|
|
7886
|
+
if (code !== 0) {
|
|
7887
|
+
query2.setError(new Error(`Claude Code process exited with code ${code}`));
|
|
7888
|
+
} else {
|
|
7889
|
+
resolve();
|
|
7890
|
+
}
|
|
7891
|
+
});
|
|
7892
|
+
});
|
|
7893
|
+
const query2 = new Query(childStdin, child.stdout, processExitPromise, canCallTool);
|
|
7894
|
+
child.on("error", (error) => {
|
|
7895
|
+
if (config.options?.abort?.aborted) {
|
|
7896
|
+
query2.setError(new AbortError("Claude Code process aborted by user"));
|
|
7897
|
+
} else {
|
|
7898
|
+
query2.setError(new Error(`Failed to spawn Claude Code process: ${error.message}`));
|
|
7899
|
+
}
|
|
7900
|
+
});
|
|
7901
|
+
processExitPromise.finally(() => {
|
|
7902
|
+
cleanup();
|
|
7903
|
+
config.options?.abort?.removeEventListener("abort", cleanup);
|
|
7904
|
+
if (process.env.CLAUDE_SDK_MCP_SERVERS) {
|
|
7905
|
+
delete process.env.CLAUDE_SDK_MCP_SERVERS;
|
|
7906
|
+
}
|
|
7907
|
+
});
|
|
7908
|
+
return query2;
|
|
7909
|
+
}
|
|
7910
|
+
|
|
7911
|
+
class Future {
|
|
7912
|
+
_resolve;
|
|
7913
|
+
_reject;
|
|
7914
|
+
_promise;
|
|
7915
|
+
constructor() {
|
|
7916
|
+
this._promise = new Promise((resolve, reject) => {
|
|
7917
|
+
this._resolve = resolve;
|
|
7918
|
+
this._reject = reject;
|
|
7919
|
+
});
|
|
7920
|
+
}
|
|
7921
|
+
resolve(value) {
|
|
7922
|
+
this._resolve(value);
|
|
7923
|
+
}
|
|
7924
|
+
reject(reason) {
|
|
7925
|
+
this._reject(reason);
|
|
7926
|
+
}
|
|
7927
|
+
get promise() {
|
|
7928
|
+
return this._promise;
|
|
7929
|
+
}
|
|
7930
|
+
}
|
|
7931
|
+
|
|
7932
|
+
class PushableAsyncIterable {
|
|
7933
|
+
queue = [];
|
|
7934
|
+
waiters = [];
|
|
7935
|
+
isDone = false;
|
|
7936
|
+
error = null;
|
|
7937
|
+
started = false;
|
|
7938
|
+
constructor() {
|
|
7939
|
+
}
|
|
7940
|
+
/**
|
|
7941
|
+
* Push a value to the iterable
|
|
7942
|
+
*/
|
|
7943
|
+
push(value) {
|
|
7944
|
+
if (this.isDone) {
|
|
7945
|
+
throw new Error("Cannot push to completed iterable");
|
|
7946
|
+
}
|
|
7947
|
+
if (this.error) {
|
|
7948
|
+
throw this.error;
|
|
7949
|
+
}
|
|
7950
|
+
const waiter = this.waiters.shift();
|
|
7951
|
+
if (waiter) {
|
|
7952
|
+
waiter.resolve({ done: false, value });
|
|
7953
|
+
} else {
|
|
7954
|
+
this.queue.push(value);
|
|
7955
|
+
}
|
|
7956
|
+
}
|
|
7957
|
+
/**
|
|
7958
|
+
* Mark the iterable as complete
|
|
7959
|
+
*/
|
|
7960
|
+
end() {
|
|
7961
|
+
if (this.isDone) {
|
|
7962
|
+
return;
|
|
7963
|
+
}
|
|
7964
|
+
this.isDone = true;
|
|
7965
|
+
this.cleanup();
|
|
7966
|
+
}
|
|
7967
|
+
/**
|
|
7968
|
+
* Set an error on the iterable
|
|
7969
|
+
*/
|
|
7970
|
+
setError(err) {
|
|
7971
|
+
if (this.isDone) {
|
|
7972
|
+
return;
|
|
7973
|
+
}
|
|
7974
|
+
this.error = err;
|
|
7975
|
+
this.isDone = true;
|
|
7976
|
+
this.cleanup();
|
|
7977
|
+
}
|
|
7978
|
+
/**
|
|
7979
|
+
* Cleanup waiting consumers
|
|
7980
|
+
*/
|
|
7981
|
+
cleanup() {
|
|
7982
|
+
while (this.waiters.length > 0) {
|
|
7983
|
+
const waiter = this.waiters.shift();
|
|
7984
|
+
if (this.error) {
|
|
7985
|
+
waiter.reject(this.error);
|
|
7986
|
+
} else {
|
|
7987
|
+
waiter.resolve({ done: true, value: void 0 });
|
|
7988
|
+
}
|
|
7989
|
+
}
|
|
7990
|
+
}
|
|
7991
|
+
/**
|
|
7992
|
+
* AsyncIterableIterator implementation
|
|
7993
|
+
*/
|
|
7994
|
+
async next() {
|
|
7995
|
+
if (this.queue.length > 0) {
|
|
7996
|
+
return { done: false, value: this.queue.shift() };
|
|
7997
|
+
}
|
|
7998
|
+
if (this.isDone) {
|
|
7999
|
+
if (this.error) {
|
|
8000
|
+
throw this.error;
|
|
8001
|
+
}
|
|
8002
|
+
return { done: true, value: void 0 };
|
|
8003
|
+
}
|
|
8004
|
+
return new Promise((resolve, reject) => {
|
|
8005
|
+
this.waiters.push({ resolve, reject });
|
|
8006
|
+
});
|
|
8007
|
+
}
|
|
8008
|
+
/**
|
|
8009
|
+
* AsyncIterableIterator return implementation
|
|
8010
|
+
*/
|
|
8011
|
+
async return(_value) {
|
|
8012
|
+
this.end();
|
|
8013
|
+
return { done: true, value: void 0 };
|
|
8014
|
+
}
|
|
8015
|
+
/**
|
|
8016
|
+
* AsyncIterableIterator throw implementation
|
|
8017
|
+
*/
|
|
8018
|
+
async throw(e) {
|
|
8019
|
+
this.setError(e instanceof Error ? e : new Error(String(e)));
|
|
8020
|
+
throw this.error;
|
|
8021
|
+
}
|
|
8022
|
+
/**
|
|
8023
|
+
* Make this iterable
|
|
8024
|
+
*/
|
|
8025
|
+
[Symbol.asyncIterator]() {
|
|
8026
|
+
if (this.started) {
|
|
8027
|
+
throw new Error("PushableAsyncIterable can only be iterated once");
|
|
8028
|
+
}
|
|
8029
|
+
this.started = true;
|
|
8030
|
+
return this;
|
|
8031
|
+
}
|
|
8032
|
+
/**
|
|
8033
|
+
* Check if the iterable is done
|
|
8034
|
+
*/
|
|
8035
|
+
get done() {
|
|
8036
|
+
return this.isDone;
|
|
8037
|
+
}
|
|
8038
|
+
/**
|
|
8039
|
+
* Check if the iterable has an error
|
|
8040
|
+
*/
|
|
8041
|
+
get hasError() {
|
|
8042
|
+
return this.error !== null;
|
|
8043
|
+
}
|
|
8044
|
+
/**
|
|
8045
|
+
* Get the current queue size
|
|
8046
|
+
*/
|
|
8047
|
+
get queueSize() {
|
|
8048
|
+
return this.queue.length;
|
|
8049
|
+
}
|
|
8050
|
+
/**
|
|
8051
|
+
* Get the number of waiting consumers
|
|
8052
|
+
*/
|
|
8053
|
+
get waiterCount() {
|
|
8054
|
+
return this.waiters.length;
|
|
8055
|
+
}
|
|
8056
|
+
}
|
|
8057
|
+
|
|
8058
|
+
function normalizeClaudeBackendError(error) {
|
|
8059
|
+
const record = typeof error === "object" && error !== null ? error : null;
|
|
8060
|
+
const text = formatDisplayMessage(error).trim();
|
|
8061
|
+
const stderrText = record ? formatDisplayMessage(record.stderr).trim() : "";
|
|
8062
|
+
const detailText = record ? formatDisplayMessage(record.detail).trim() : "";
|
|
8063
|
+
const searchable = [text, stderrText, detailText].filter(Boolean).join("\n").trim();
|
|
8064
|
+
return searchable || "Claude runtime backend exited unexpectedly";
|
|
8065
|
+
}
|
|
8066
|
+
function isRecord(value) {
|
|
8067
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8068
|
+
}
|
|
8069
|
+
function createTimeoutError(timeoutMs) {
|
|
8070
|
+
return new Error(`Claude response did not complete within ${timeoutMs}ms`);
|
|
8071
|
+
}
|
|
8072
|
+
function normalizePermissionResult(input, decision) {
|
|
8073
|
+
if (decision === "approved" || decision === "approved_for_session") {
|
|
8074
|
+
return {
|
|
8075
|
+
behavior: "allow",
|
|
8076
|
+
updatedInput: isRecord(input) ? input : {}
|
|
8077
|
+
};
|
|
8078
|
+
}
|
|
8079
|
+
return {
|
|
8080
|
+
behavior: "deny",
|
|
8081
|
+
message: decision === "denied" ? "The user denied this tool request." : "The tool request was aborted."
|
|
8082
|
+
};
|
|
8083
|
+
}
|
|
8084
|
+
function getClaudeExecutablePath(command) {
|
|
8085
|
+
if (command === "claude") {
|
|
8086
|
+
return path.resolve(path.join(projectPath(), "scripts", "claude_remote_launcher.cjs"));
|
|
8087
|
+
}
|
|
8088
|
+
return command;
|
|
8089
|
+
}
|
|
8090
|
+
class ClaudeCodeBackend {
|
|
8091
|
+
constructor(options) {
|
|
8092
|
+
this.options = options;
|
|
8093
|
+
}
|
|
8094
|
+
listeners = /* @__PURE__ */ new Set();
|
|
8095
|
+
toolNamesByCallId = /* @__PURE__ */ new Map();
|
|
8096
|
+
runtimeSessionId = node_crypto.randomUUID();
|
|
8097
|
+
messageStream = null;
|
|
8098
|
+
queryInstance = null;
|
|
8099
|
+
runtimeAbortController = null;
|
|
8100
|
+
consumeTask = null;
|
|
8101
|
+
activeResponse = null;
|
|
8102
|
+
responseCompletionOutcome = null;
|
|
8103
|
+
disposed = false;
|
|
8104
|
+
lastStatus = null;
|
|
8105
|
+
onMessage(handler) {
|
|
8106
|
+
this.listeners.add(handler);
|
|
8107
|
+
}
|
|
8108
|
+
offMessage(handler) {
|
|
8109
|
+
this.listeners.delete(handler);
|
|
8110
|
+
}
|
|
8111
|
+
async startSession(initialPrompt) {
|
|
8112
|
+
if (initialPrompt) {
|
|
8113
|
+
await this.sendPrompt(this.runtimeSessionId, initialPrompt);
|
|
8114
|
+
}
|
|
8115
|
+
return { sessionId: this.runtimeSessionId };
|
|
8116
|
+
}
|
|
8117
|
+
async sendPrompt(_sessionId, prompt) {
|
|
8118
|
+
if (this.disposed) {
|
|
8119
|
+
throw new Error("Claude runtime backend has already been disposed");
|
|
8120
|
+
}
|
|
8121
|
+
if (this.activeResponse) {
|
|
8122
|
+
throw new Error("Claude runtime backend is already processing a prompt");
|
|
8123
|
+
}
|
|
8124
|
+
await this.ensureQueryStarted();
|
|
8125
|
+
this.responseCompletionOutcome = null;
|
|
8126
|
+
this.activeResponse = new Future();
|
|
8127
|
+
void this.activeResponse.promise.catch(() => {
|
|
8128
|
+
});
|
|
8129
|
+
this.emitStatus("running");
|
|
8130
|
+
this.messageStream.push({
|
|
8131
|
+
type: "user",
|
|
8132
|
+
message: {
|
|
8133
|
+
role: "user",
|
|
8134
|
+
content: prompt
|
|
8135
|
+
}
|
|
8136
|
+
});
|
|
8137
|
+
}
|
|
8138
|
+
async cancel(_sessionId) {
|
|
8139
|
+
if (!this.queryInstance) {
|
|
8140
|
+
return;
|
|
8141
|
+
}
|
|
8142
|
+
try {
|
|
8143
|
+
await this.queryInstance.interrupt();
|
|
8144
|
+
} catch (error) {
|
|
8145
|
+
api.logger.debug("[ClaudeRuntimeBackend] Error interrupting Claude query:", error);
|
|
8146
|
+
}
|
|
8147
|
+
}
|
|
8148
|
+
async waitForResponseComplete(timeoutMs = 12e4) {
|
|
8149
|
+
if (this.responseCompletionOutcome) {
|
|
8150
|
+
const outcome = this.responseCompletionOutcome;
|
|
8151
|
+
if (outcome.kind === "rejected") {
|
|
8152
|
+
throw outcome.error;
|
|
8153
|
+
}
|
|
8154
|
+
return;
|
|
8155
|
+
}
|
|
8156
|
+
if (!this.activeResponse) {
|
|
8157
|
+
return;
|
|
8158
|
+
}
|
|
8159
|
+
let timeoutHandle;
|
|
8160
|
+
try {
|
|
8161
|
+
await Promise.race([
|
|
8162
|
+
this.activeResponse.promise,
|
|
8163
|
+
new Promise((_, reject) => {
|
|
8164
|
+
timeoutHandle = setTimeout(() => reject(createTimeoutError(timeoutMs)), timeoutMs);
|
|
8165
|
+
})
|
|
8166
|
+
]);
|
|
8167
|
+
} finally {
|
|
8168
|
+
if (timeoutHandle) {
|
|
8169
|
+
clearTimeout(timeoutHandle);
|
|
8170
|
+
}
|
|
8171
|
+
}
|
|
8172
|
+
}
|
|
8173
|
+
async dispose() {
|
|
8174
|
+
if (this.disposed) {
|
|
8175
|
+
return;
|
|
8176
|
+
}
|
|
8177
|
+
this.disposed = true;
|
|
8178
|
+
const activeQuery = this.queryInstance;
|
|
8179
|
+
this.rejectActiveResponse(new Error("Claude runtime backend disposed"));
|
|
8180
|
+
this.messageStream?.end();
|
|
8181
|
+
this.runtimeAbortController?.abort();
|
|
8182
|
+
if (activeQuery && typeof activeQuery.return === "function") {
|
|
8183
|
+
try {
|
|
8184
|
+
await activeQuery.return();
|
|
8185
|
+
} catch (error) {
|
|
8186
|
+
api.logger.debug("[ClaudeRuntimeBackend] Error closing Claude query iterator:", error);
|
|
8187
|
+
}
|
|
8188
|
+
}
|
|
8189
|
+
try {
|
|
8190
|
+
await this.consumeTask;
|
|
8191
|
+
} catch (error) {
|
|
8192
|
+
api.logger.debug("[ClaudeRuntimeBackend] Error while disposing backend:", error);
|
|
8193
|
+
} finally {
|
|
8194
|
+
this.queryInstance = null;
|
|
8195
|
+
this.messageStream = null;
|
|
8196
|
+
this.runtimeAbortController = null;
|
|
8197
|
+
this.consumeTask = null;
|
|
8198
|
+
this.toolNamesByCallId.clear();
|
|
8199
|
+
this.emitStatus("stopped");
|
|
8200
|
+
}
|
|
8201
|
+
}
|
|
8202
|
+
emit(message) {
|
|
8203
|
+
for (const listener of this.listeners) {
|
|
8204
|
+
listener(message);
|
|
8205
|
+
}
|
|
8206
|
+
}
|
|
8207
|
+
emitStatus(status, detail) {
|
|
8208
|
+
if (this.lastStatus?.status === status && this.lastStatus.detail === detail) {
|
|
8209
|
+
return;
|
|
8210
|
+
}
|
|
8211
|
+
const message = {
|
|
8212
|
+
type: "status",
|
|
8213
|
+
status,
|
|
8214
|
+
...detail ? { detail } : {}
|
|
8215
|
+
};
|
|
8216
|
+
this.lastStatus = message;
|
|
8217
|
+
this.emit(message);
|
|
8218
|
+
}
|
|
8219
|
+
async ensureQueryStarted() {
|
|
8220
|
+
if (this.queryInstance) {
|
|
8221
|
+
return;
|
|
8222
|
+
}
|
|
8223
|
+
this.emitStatus("starting");
|
|
8224
|
+
this.runtimeAbortController = new AbortController();
|
|
8225
|
+
this.messageStream = new PushableAsyncIterable();
|
|
8226
|
+
this.queryInstance = query({
|
|
8227
|
+
prompt: this.messageStream,
|
|
8228
|
+
options: {
|
|
8229
|
+
cwd: this.options.cwd,
|
|
8230
|
+
env: this.options.env,
|
|
8231
|
+
allowedTools: this.options.allowedTools,
|
|
8232
|
+
appendSystemPrompt: this.options.appendSystemPrompt,
|
|
8233
|
+
customSystemPrompt: this.options.customSystemPrompt,
|
|
8234
|
+
disallowedTools: this.options.disallowedTools,
|
|
8235
|
+
extraArgs: this.options.args,
|
|
8236
|
+
fallbackModel: this.options.fallbackModel,
|
|
8237
|
+
mcpServers: this.options.mcpServers,
|
|
8238
|
+
model: this.options.model,
|
|
8239
|
+
pathToClaudeCodeExecutable: getClaudeExecutablePath(this.options.command),
|
|
8240
|
+
permissionMode: this.options.permissionMode,
|
|
8241
|
+
settingsPath: this.options.settingsPath,
|
|
8242
|
+
canCallTool: this.options.permissionHandler ? async (toolName, input, requestOptions) => {
|
|
8243
|
+
const requestId = requestOptions.requestId ?? node_crypto.randomUUID();
|
|
8244
|
+
this.emit({
|
|
8245
|
+
type: "permission-request",
|
|
8246
|
+
id: requestId,
|
|
8247
|
+
reason: `Claude wants to use ${toolName}`,
|
|
8248
|
+
payload: {
|
|
8249
|
+
toolName,
|
|
8250
|
+
input
|
|
8251
|
+
}
|
|
8252
|
+
});
|
|
8253
|
+
const decision = await this.options.permissionHandler.handleToolCall(requestId, toolName, input);
|
|
8254
|
+
this.emit({
|
|
8255
|
+
type: "permission-response",
|
|
8256
|
+
id: requestId,
|
|
8257
|
+
approved: decision.decision === "approved" || decision.decision === "approved_for_session"
|
|
8258
|
+
});
|
|
8259
|
+
return normalizePermissionResult(input, decision.decision);
|
|
8260
|
+
} : void 0,
|
|
8261
|
+
abort: this.runtimeAbortController.signal
|
|
8262
|
+
}
|
|
8263
|
+
});
|
|
8264
|
+
this.consumeTask = this.consumeMessages(this.queryInstance);
|
|
8265
|
+
}
|
|
8266
|
+
async consumeMessages(activeQuery) {
|
|
8267
|
+
try {
|
|
8268
|
+
for await (const message of activeQuery) {
|
|
8269
|
+
this.handleMessage(message);
|
|
8270
|
+
}
|
|
8271
|
+
} catch (error) {
|
|
8272
|
+
const aborted = this.runtimeAbortController?.signal.aborted === true;
|
|
8273
|
+
if (!aborted) {
|
|
8274
|
+
const detail = normalizeClaudeBackendError(error);
|
|
8275
|
+
this.emitStatus("error", detail);
|
|
8276
|
+
this.rejectActiveResponse(new Error(detail));
|
|
8277
|
+
}
|
|
8278
|
+
} finally {
|
|
8279
|
+
if (!this.disposed && this.activeResponse) {
|
|
8280
|
+
const detail = "Claude runtime backend stopped before completing the response";
|
|
8281
|
+
this.emitStatus("error", detail);
|
|
8282
|
+
this.rejectActiveResponse(new Error(detail));
|
|
8283
|
+
}
|
|
8284
|
+
if (!this.disposed) {
|
|
8285
|
+
this.queryInstance = null;
|
|
8286
|
+
this.messageStream = null;
|
|
8287
|
+
this.runtimeAbortController = null;
|
|
8288
|
+
this.consumeTask = null;
|
|
8289
|
+
this.emitStatus("stopped");
|
|
8290
|
+
}
|
|
8291
|
+
}
|
|
8292
|
+
}
|
|
8293
|
+
handleMessage(message) {
|
|
8294
|
+
switch (message.type) {
|
|
8295
|
+
case "system":
|
|
8296
|
+
this.handleSystemMessage(message);
|
|
8297
|
+
return;
|
|
8298
|
+
case "assistant":
|
|
8299
|
+
this.handleAssistantMessage(message);
|
|
8300
|
+
return;
|
|
8301
|
+
case "user":
|
|
8302
|
+
this.handleUserMessage(message);
|
|
8303
|
+
return;
|
|
8304
|
+
case "result":
|
|
8305
|
+
this.handleResultMessage(message);
|
|
8306
|
+
return;
|
|
8307
|
+
default:
|
|
8308
|
+
return;
|
|
8309
|
+
}
|
|
8310
|
+
}
|
|
8311
|
+
handleSystemMessage(message) {
|
|
8312
|
+
if (message.subtype === "init") {
|
|
8313
|
+
this.emitStatus("running");
|
|
8314
|
+
this.emit({
|
|
8315
|
+
type: "event",
|
|
8316
|
+
name: "session-init",
|
|
8317
|
+
payload: {
|
|
8318
|
+
sessionId: message.session_id,
|
|
8319
|
+
cwd: message.cwd,
|
|
8320
|
+
model: message.model,
|
|
8321
|
+
tools: message.tools
|
|
8322
|
+
}
|
|
8323
|
+
});
|
|
8324
|
+
}
|
|
8325
|
+
}
|
|
8326
|
+
handleAssistantMessage(message) {
|
|
8327
|
+
for (const block of message.message.content ?? []) {
|
|
8328
|
+
if (block.type === "text" && typeof block.text === "string" && block.text.length > 0) {
|
|
8329
|
+
this.emit({
|
|
8330
|
+
type: "model-output",
|
|
8331
|
+
textDelta: block.text
|
|
8332
|
+
});
|
|
8333
|
+
continue;
|
|
8334
|
+
}
|
|
8335
|
+
if (block.type === "thinking") {
|
|
8336
|
+
const thinkingText = isRecord(block) && typeof block.thinking === "string" ? block.thinking : "";
|
|
8337
|
+
if (thinkingText) {
|
|
8338
|
+
this.emit({
|
|
8339
|
+
type: "event",
|
|
8340
|
+
name: "thinking",
|
|
8341
|
+
payload: { text: thinkingText }
|
|
8342
|
+
});
|
|
8343
|
+
}
|
|
8344
|
+
continue;
|
|
8345
|
+
}
|
|
8346
|
+
if (block.type === "tool_use" && block.id && block.name) {
|
|
8347
|
+
this.toolNamesByCallId.set(block.id, block.name);
|
|
8348
|
+
this.emit({
|
|
8349
|
+
type: "tool-call",
|
|
8350
|
+
toolName: block.name,
|
|
8351
|
+
args: isRecord(block.input) ? block.input : {},
|
|
8352
|
+
callId: block.id
|
|
8353
|
+
});
|
|
8354
|
+
}
|
|
8355
|
+
}
|
|
8356
|
+
}
|
|
8357
|
+
handleUserMessage(message) {
|
|
8358
|
+
const content = Array.isArray(message.message.content) ? message.message.content : [];
|
|
8359
|
+
for (const block of content) {
|
|
8360
|
+
if (block.type !== "tool_result" || !block.tool_use_id) {
|
|
8361
|
+
continue;
|
|
8362
|
+
}
|
|
8363
|
+
const toolName = this.toolNamesByCallId.get(block.tool_use_id) ?? "unknown";
|
|
8364
|
+
this.emit({
|
|
8365
|
+
type: "tool-result",
|
|
8366
|
+
toolName,
|
|
8367
|
+
result: block.content,
|
|
8368
|
+
callId: block.tool_use_id
|
|
8369
|
+
});
|
|
8370
|
+
if (toolName === "Bash" && isRecord(message.tool_use_result)) {
|
|
8371
|
+
const toolResult = message.tool_use_result;
|
|
8372
|
+
const stdout = formatDisplayMessage(toolResult.stdout).trim();
|
|
8373
|
+
const stderr = formatDisplayMessage(toolResult.stderr).trim();
|
|
8374
|
+
const combined = [stdout, stderr].filter(Boolean).join("\n");
|
|
8375
|
+
if (combined) {
|
|
8376
|
+
this.emit({
|
|
8377
|
+
type: "terminal-output",
|
|
8378
|
+
data: combined,
|
|
8379
|
+
callId: block.tool_use_id
|
|
8380
|
+
});
|
|
8381
|
+
}
|
|
8382
|
+
}
|
|
8383
|
+
}
|
|
8384
|
+
}
|
|
8385
|
+
handleResultMessage(message) {
|
|
8386
|
+
if (message.usage) {
|
|
8387
|
+
this.emit({
|
|
8388
|
+
type: "token-count",
|
|
8389
|
+
...message.usage,
|
|
8390
|
+
duration_ms: message.duration_ms,
|
|
8391
|
+
duration_api_ms: message.duration_api_ms,
|
|
8392
|
+
total_cost_usd: message.total_cost_usd,
|
|
8393
|
+
session_id: message.session_id
|
|
8394
|
+
});
|
|
8395
|
+
}
|
|
8396
|
+
if (message.is_error) {
|
|
8397
|
+
const detail = typeof message.result === "string" && message.result.trim().length > 0 ? message.result : message.subtype;
|
|
8398
|
+
this.emitStatus("error", detail);
|
|
8399
|
+
this.rejectActiveResponse(new Error(detail));
|
|
8400
|
+
return;
|
|
8401
|
+
}
|
|
8402
|
+
this.emitStatus("idle");
|
|
8403
|
+
this.resolveActiveResponse();
|
|
8404
|
+
}
|
|
8405
|
+
resolveActiveResponse() {
|
|
8406
|
+
this.responseCompletionOutcome = { kind: "resolved" };
|
|
8407
|
+
if (!this.activeResponse) {
|
|
8408
|
+
return;
|
|
8409
|
+
}
|
|
8410
|
+
const active = this.activeResponse;
|
|
8411
|
+
this.activeResponse = null;
|
|
8412
|
+
active.resolve(void 0);
|
|
8413
|
+
}
|
|
8414
|
+
rejectActiveResponse(error) {
|
|
8415
|
+
this.responseCompletionOutcome = { kind: "rejected", error };
|
|
8416
|
+
if (!this.activeResponse) {
|
|
8417
|
+
return;
|
|
8418
|
+
}
|
|
8419
|
+
const active = this.activeResponse;
|
|
8420
|
+
this.activeResponse = null;
|
|
8421
|
+
active.reject(error);
|
|
8422
|
+
}
|
|
8423
|
+
}
|
|
8424
|
+
|
|
7379
8425
|
function mapToClaudeMode(mode) {
|
|
7380
8426
|
const codexToClaudeMap = {
|
|
7381
8427
|
"yolo": "bypassPermissions",
|
|
@@ -7385,14 +8431,8 @@ function mapToClaudeMode(mode) {
|
|
|
7385
8431
|
return codexToClaudeMap[mode] ?? mode;
|
|
7386
8432
|
}
|
|
7387
8433
|
|
|
7388
|
-
function
|
|
7389
|
-
|
|
7390
|
-
return args;
|
|
7391
|
-
}
|
|
7392
|
-
return ["--experimental-acp", ...args];
|
|
7393
|
-
}
|
|
7394
|
-
function defaultClaudeArgs() {
|
|
7395
|
-
return ensureExperimentalAcp([]);
|
|
8434
|
+
function defaultClaudeCommand() {
|
|
8435
|
+
return process.env.HAPPY_CLAUDE_COMMAND ?? process.env.HAPPY_CLAUDE_ACP_COMMAND ?? "claude";
|
|
7396
8436
|
}
|
|
7397
8437
|
function appendStringFlag(args, flag, value) {
|
|
7398
8438
|
if (value && value.trim().length > 0) {
|
|
@@ -7404,11 +8444,22 @@ function appendListFlag(args, flag, values) {
|
|
|
7404
8444
|
args.push(flag, values.join(","));
|
|
7405
8445
|
}
|
|
7406
8446
|
}
|
|
7407
|
-
function
|
|
7408
|
-
|
|
7409
|
-
|
|
8447
|
+
function normalizeClaudePassthroughArgs(options) {
|
|
8448
|
+
const sourceArgs = options.args ?? options.baseArgs ?? [];
|
|
8449
|
+
return sourceArgs.filter((arg) => arg !== "--experimental-acp");
|
|
8450
|
+
}
|
|
8451
|
+
function resolveClaudeCliArgs(options) {
|
|
8452
|
+
const args = [
|
|
8453
|
+
"--output-format",
|
|
8454
|
+
"stream-json",
|
|
8455
|
+
"--verbose",
|
|
8456
|
+
"--input-format",
|
|
8457
|
+
"stream-json",
|
|
8458
|
+
...normalizeClaudePassthroughArgs(options)
|
|
8459
|
+
];
|
|
8460
|
+
if (options.permissionHandler) {
|
|
8461
|
+
args.push("--permission-prompt-tool", "stdio");
|
|
7410
8462
|
}
|
|
7411
|
-
const args = ensureExperimentalAcp([...options.baseArgs ?? []]);
|
|
7412
8463
|
appendStringFlag(args, "--system-prompt", options.customSystemPrompt);
|
|
7413
8464
|
appendStringFlag(args, "--append-system-prompt", options.appendSystemPrompt);
|
|
7414
8465
|
appendStringFlag(args, "--model", options.model);
|
|
@@ -7422,27 +8473,28 @@ function resolveClaudeAcpArgs(options) {
|
|
|
7422
8473
|
return args;
|
|
7423
8474
|
}
|
|
7424
8475
|
function createClaudeBackend(options) {
|
|
7425
|
-
const command = options.command ??
|
|
7426
|
-
const args =
|
|
7427
|
-
...options,
|
|
7428
|
-
baseArgs: options.baseArgs ?? defaultClaudeArgs()
|
|
7429
|
-
});
|
|
7430
|
-
const backendOptions = {
|
|
7431
|
-
agentName: "claude",
|
|
7432
|
-
cwd: options.cwd,
|
|
7433
|
-
command,
|
|
7434
|
-
args,
|
|
7435
|
-
env: {
|
|
7436
|
-
...options.env,
|
|
7437
|
-
NODE_ENV: "production"
|
|
7438
|
-
},
|
|
7439
|
-
mcpServers: options.mcpServers,
|
|
7440
|
-
permissionHandler: options.permissionHandler,
|
|
7441
|
-
selectionHandler: options.selectionHandler,
|
|
7442
|
-
transportHandler: claudeTransport
|
|
7443
|
-
};
|
|
8476
|
+
const command = options.command ?? defaultClaudeCommand();
|
|
8477
|
+
const args = resolveClaudeCliArgs(options);
|
|
7444
8478
|
return {
|
|
7445
|
-
backend: new
|
|
8479
|
+
backend: new ClaudeCodeBackend({
|
|
8480
|
+
cwd: options.cwd,
|
|
8481
|
+
env: {
|
|
8482
|
+
...options.env,
|
|
8483
|
+
NODE_ENV: "production"
|
|
8484
|
+
},
|
|
8485
|
+
command,
|
|
8486
|
+
args: normalizeClaudePassthroughArgs(options),
|
|
8487
|
+
model: options.model,
|
|
8488
|
+
fallbackModel: options.fallbackModel,
|
|
8489
|
+
permissionMode: options.permissionMode ? mapToClaudeMode(options.permissionMode) : void 0,
|
|
8490
|
+
customSystemPrompt: options.customSystemPrompt,
|
|
8491
|
+
appendSystemPrompt: options.appendSystemPrompt,
|
|
8492
|
+
allowedTools: options.allowedTools,
|
|
8493
|
+
disallowedTools: options.disallowedTools,
|
|
8494
|
+
settingsPath: options.settingsPath,
|
|
8495
|
+
mcpServers: options.mcpServers,
|
|
8496
|
+
permissionHandler: options.permissionHandler
|
|
8497
|
+
}),
|
|
7446
8498
|
command,
|
|
7447
8499
|
args
|
|
7448
8500
|
};
|
|
@@ -7673,11 +8725,11 @@ var launch = /*#__PURE__*/Object.freeze({
|
|
|
7673
8725
|
|
|
7674
8726
|
const unifiedProviderExecutors = {
|
|
7675
8727
|
claude: async (opts) => {
|
|
7676
|
-
const { runClaude } = await Promise.resolve().then(function () { return require('./runClaude-
|
|
8728
|
+
const { runClaude } = await Promise.resolve().then(function () { return require('./runClaude-C9-ylbQh.cjs'); });
|
|
7677
8729
|
await runClaude(opts.credentials, opts.claudeOptions ?? {});
|
|
7678
8730
|
},
|
|
7679
8731
|
codex: async (opts) => {
|
|
7680
|
-
const { runCodex } = await Promise.resolve().then(function () { return require('./runCodex-
|
|
8732
|
+
const { runCodex } = await Promise.resolve().then(function () { return require('./runCodex-CRNBxY5f.cjs'); });
|
|
7681
8733
|
await runCodex({
|
|
7682
8734
|
credentials: opts.credentials,
|
|
7683
8735
|
startedBy: opts.startedBy,
|
|
@@ -7686,7 +8738,7 @@ const unifiedProviderExecutors = {
|
|
|
7686
8738
|
});
|
|
7687
8739
|
},
|
|
7688
8740
|
gemini: async (opts) => {
|
|
7689
|
-
const { runGemini } = await Promise.resolve().then(function () { return require('./runGemini-
|
|
8741
|
+
const { runGemini } = await Promise.resolve().then(function () { return require('./runGemini-BZ5hqJyl.cjs'); });
|
|
7690
8742
|
await runGemini({
|
|
7691
8743
|
credentials: opts.credentials,
|
|
7692
8744
|
startedBy: opts.startedBy
|
|
@@ -7762,7 +8814,7 @@ function shouldRunMainClaudeFlow(opts) {
|
|
|
7762
8814
|
return;
|
|
7763
8815
|
} else if (subcommand === "runtime") {
|
|
7764
8816
|
if (args[1] === "providers") {
|
|
7765
|
-
const { renderRuntimeProviders } = await Promise.resolve().then(function () { return require('./command-
|
|
8817
|
+
const { renderRuntimeProviders } = await Promise.resolve().then(function () { return require('./command-eRjSBm2C.cjs'); });
|
|
7766
8818
|
console.log(renderRuntimeProviders());
|
|
7767
8819
|
return;
|
|
7768
8820
|
}
|
|
@@ -7940,8 +8992,8 @@ function shouldRunMainClaudeFlow(opts) {
|
|
|
7940
8992
|
const projectId = args[3];
|
|
7941
8993
|
try {
|
|
7942
8994
|
const { saveGoogleCloudProjectToConfig } = await Promise.resolve().then(function () { return config; });
|
|
7943
|
-
const { readCredentials: readCredentials2 } = await Promise.resolve().then(function () { return require('./persistence-
|
|
7944
|
-
const { ApiClient: ApiClient2 } = await Promise.resolve().then(function () { return require('./api-
|
|
8995
|
+
const { readCredentials: readCredentials2 } = await Promise.resolve().then(function () { return require('./persistence-Btu2VPXI.cjs'); });
|
|
8996
|
+
const { ApiClient: ApiClient2 } = await Promise.resolve().then(function () { return require('./api-Db1SQcP_.cjs'); }).then(function (n) { return n.api; });
|
|
7945
8997
|
let userEmail = void 0;
|
|
7946
8998
|
try {
|
|
7947
8999
|
const credentials = await readCredentials2();
|
|
@@ -8357,11 +9409,15 @@ ${chalk.bold("Examples:")}
|
|
|
8357
9409
|
}
|
|
8358
9410
|
}
|
|
8359
9411
|
|
|
9412
|
+
exports.AbortError = AbortError;
|
|
8360
9413
|
exports.ExitCodeError = ExitCodeError;
|
|
9414
|
+
exports.Future = Future;
|
|
8361
9415
|
exports.GEMINI_MODEL_ENV = GEMINI_MODEL_ENV;
|
|
9416
|
+
exports.PushableAsyncIterable = PushableAsyncIterable;
|
|
8362
9417
|
exports.RuntimeShell = RuntimeShell;
|
|
8363
9418
|
exports.claudeCheckSession = claudeCheckSession;
|
|
8364
9419
|
exports.claudeLocal = claudeLocal;
|
|
9420
|
+
exports.createClaudeBackend = createClaudeBackend;
|
|
8365
9421
|
exports.createCodexBackend = createCodexBackend;
|
|
8366
9422
|
exports.createDefaultRuntimeShell = createDefaultRuntimeShell;
|
|
8367
9423
|
exports.createGeminiBackend = createGeminiBackend;
|
|
@@ -8370,10 +9426,10 @@ exports.getEnvironmentInfo = getEnvironmentInfo;
|
|
|
8370
9426
|
exports.getInitialGeminiModel = getInitialGeminiModel;
|
|
8371
9427
|
exports.getProjectPath = getProjectPath;
|
|
8372
9428
|
exports.initialMachineMetadata = initialMachineMetadata;
|
|
8373
|
-
exports.isBun = isBun;
|
|
8374
9429
|
exports.mapToClaudeMode = mapToClaudeMode;
|
|
8375
9430
|
exports.projectPath = projectPath;
|
|
8376
9431
|
exports.publishSessionRegistration = publishSessionRegistration;
|
|
9432
|
+
exports.query = query;
|
|
8377
9433
|
exports.readGeminiLocalConfig = readGeminiLocalConfig;
|
|
8378
9434
|
exports.resolveCanonicalToolNameV2 = resolveCanonicalToolNameV2;
|
|
8379
9435
|
exports.saveGeminiModelToConfig = saveGeminiModelToConfig;
|