@lobehub/cli 0.0.95 → 0.0.96
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/acceptance-report.html +251 -251
- package/dist/index.js +416 -280
- package/man/man1/lh.1 +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import { Buffer as Buffer$1 } from "node:buffer";
|
|
|
15
15
|
import * as net$1 from "node:net";
|
|
16
16
|
import net, { BlockList, connect, createServer, isIP } from "node:net";
|
|
17
17
|
import { scheduler, setImmediate as setImmediate$1, setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
18
|
-
import
|
|
18
|
+
import process$1, { cwd, execArgv, execPath, hrtime, platform as platform$1 } from "node:process";
|
|
19
19
|
import { URL as URL$1, fileURLToPath, pathToFileURL } from "node:url";
|
|
20
20
|
import { finished, pipeline } from "node:stream/promises";
|
|
21
21
|
import { Duplex, PassThrough, Readable, Transform, Writable, getDefaultHighWaterMark, pipeline as pipeline$1 } from "node:stream";
|
|
@@ -8250,6 +8250,7 @@ var init_agentRuntime = __esmMin((() => {
|
|
|
8250
8250
|
RequestTrigger["Inbox"] = "inbox";
|
|
8251
8251
|
/** Chat input inline completion suggestions while the user is typing. */
|
|
8252
8252
|
RequestTrigger["InputCompletion"] = "input_completion";
|
|
8253
|
+
RequestTrigger["McpEvent"] = "mcp_event";
|
|
8253
8254
|
RequestTrigger["Memory"] = "memory";
|
|
8254
8255
|
RequestTrigger["MultimodalAnalysis"] = "multimodal_analysis";
|
|
8255
8256
|
/** Text-to-music generation from a music generation topic. */
|
|
@@ -11209,6 +11210,11 @@ var init_preference = __esmMin((() => {
|
|
|
11209
11210
|
uploadFileInKnowledgeBase: boolean().optional()
|
|
11210
11211
|
});
|
|
11211
11212
|
UserLabSchema = object$1({
|
|
11213
|
+
/**
|
|
11214
|
+
* one switch for the experiments that improve how agents write and work with
|
|
11215
|
+
* code; every coding-experience improvement reads this flag
|
|
11216
|
+
*/
|
|
11217
|
+
enableBetterCodingExperience: boolean().optional(),
|
|
11212
11218
|
/**
|
|
11213
11219
|
* enable agent identity: give an agent its own mail address
|
|
11214
11220
|
*/
|
|
@@ -12056,6 +12062,10 @@ var init_acceptanceReviewRound = __esmMin((() => {
|
|
|
12056
12062
|
});
|
|
12057
12063
|
}));
|
|
12058
12064
|
|
|
12065
|
+
//#endregion
|
|
12066
|
+
//#region ../../packages/types/src/artboard.ts
|
|
12067
|
+
var init_artboard = __esmMin((() => {}));
|
|
12068
|
+
|
|
12059
12069
|
//#endregion
|
|
12060
12070
|
//#region ../../packages/types/src/connector.ts
|
|
12061
12071
|
var init_connector = __esmMin((() => {}));
|
|
@@ -12067,7 +12077,8 @@ var init_inboundWebhook = __esmMin((() => {
|
|
|
12067
12077
|
init_zod$1();
|
|
12068
12078
|
McpEventsWebhookConfigSchema = object$1({
|
|
12069
12079
|
arguments: record(string(), unknown()),
|
|
12070
|
-
eventName: string().min(1)
|
|
12080
|
+
eventName: string().min(1),
|
|
12081
|
+
linkId: string().min(1).optional()
|
|
12071
12082
|
}).strict();
|
|
12072
12083
|
McpEventsWebhookStateSchema = object$1({
|
|
12073
12084
|
cursor: string().nullable().optional(),
|
|
@@ -12230,6 +12241,7 @@ var init_src$2 = __esmMin((() => {
|
|
|
12230
12241
|
init_acceptanceReview();
|
|
12231
12242
|
init_acceptanceReviewRound();
|
|
12232
12243
|
init_agentRuntime();
|
|
12244
|
+
init_artboard();
|
|
12233
12245
|
init_connector();
|
|
12234
12246
|
init_inboundWebhook();
|
|
12235
12247
|
init_oauthApp();
|
|
@@ -18101,6 +18113,7 @@ const TRPC_NAMESPACE_API_KEY_RULES = {
|
|
|
18101
18113
|
home: rw("chat:read", "chat:write"),
|
|
18102
18114
|
image: { any: "model:invoke" },
|
|
18103
18115
|
importer: "blocked",
|
|
18116
|
+
inboundWebhook: "blocked",
|
|
18104
18117
|
klavis: "blocked",
|
|
18105
18118
|
knowledge: rw("knowledge:read", "knowledge:write"),
|
|
18106
18119
|
knowledgeBase: rw("knowledge:read", "knowledge:write"),
|
|
@@ -21796,7 +21809,7 @@ var require_command = /* @__PURE__ */ __commonJSMin$2(((exports) => {
|
|
|
21796
21809
|
const childProcess$2 = __require("node:child_process");
|
|
21797
21810
|
const path$16 = __require("node:path");
|
|
21798
21811
|
const fs$17 = __require("node:fs");
|
|
21799
|
-
const process$
|
|
21812
|
+
const process$3 = __require("node:process");
|
|
21800
21813
|
const { Argument, humanReadableArgName } = require_argument();
|
|
21801
21814
|
const { CommanderError } = require_error$1();
|
|
21802
21815
|
const { Help, stripColor } = require_help();
|
|
@@ -21848,13 +21861,13 @@ var require_command = /* @__PURE__ */ __commonJSMin$2(((exports) => {
|
|
|
21848
21861
|
this._showSuggestionAfterError = true;
|
|
21849
21862
|
this._savedState = null;
|
|
21850
21863
|
this._outputConfiguration = {
|
|
21851
|
-
writeOut: (str) => process$
|
|
21852
|
-
writeErr: (str) => process$
|
|
21864
|
+
writeOut: (str) => process$3.stdout.write(str),
|
|
21865
|
+
writeErr: (str) => process$3.stderr.write(str),
|
|
21853
21866
|
outputError: (str, write) => write(str),
|
|
21854
|
-
getOutHelpWidth: () => process$
|
|
21855
|
-
getErrHelpWidth: () => process$
|
|
21856
|
-
getOutHasColors: () => useColor() ?? (process$
|
|
21857
|
-
getErrHasColors: () => useColor() ?? (process$
|
|
21867
|
+
getOutHelpWidth: () => process$3.stdout.isTTY ? process$3.stdout.columns : void 0,
|
|
21868
|
+
getErrHelpWidth: () => process$3.stderr.isTTY ? process$3.stderr.columns : void 0,
|
|
21869
|
+
getOutHasColors: () => useColor() ?? (process$3.stdout.isTTY && process$3.stdout.hasColors?.()),
|
|
21870
|
+
getErrHasColors: () => useColor() ?? (process$3.stderr.isTTY && process$3.stderr.hasColors?.()),
|
|
21858
21871
|
stripColor: (str) => stripColor(str)
|
|
21859
21872
|
};
|
|
21860
21873
|
this._hidden = false;
|
|
@@ -22212,7 +22225,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
22212
22225
|
*/
|
|
22213
22226
|
_exit(exitCode, code, message) {
|
|
22214
22227
|
if (this._exitCallback) this._exitCallback(new CommanderError(exitCode, code, message));
|
|
22215
|
-
process$
|
|
22228
|
+
process$3.exit(exitCode);
|
|
22216
22229
|
}
|
|
22217
22230
|
/**
|
|
22218
22231
|
* Register callback `fn` for the command.
|
|
@@ -22551,11 +22564,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
22551
22564
|
if (argv !== void 0 && !Array.isArray(argv)) throw new Error("first parameter to parse must be array or undefined");
|
|
22552
22565
|
parseOptions = parseOptions || {};
|
|
22553
22566
|
if (argv === void 0 && parseOptions.from === void 0) {
|
|
22554
|
-
if (process$
|
|
22555
|
-
const execArgv = process$
|
|
22567
|
+
if (process$3.versions?.electron) parseOptions.from = "electron";
|
|
22568
|
+
const execArgv = process$3.execArgv ?? [];
|
|
22556
22569
|
if (execArgv.includes("-e") || execArgv.includes("--eval") || execArgv.includes("-p") || execArgv.includes("--print")) parseOptions.from = "eval";
|
|
22557
22570
|
}
|
|
22558
|
-
if (argv === void 0) argv = process$
|
|
22571
|
+
if (argv === void 0) argv = process$3.argv;
|
|
22559
22572
|
this.rawArgs = argv.slice();
|
|
22560
22573
|
let userArgs;
|
|
22561
22574
|
switch (parseOptions.from) {
|
|
@@ -22565,7 +22578,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
22565
22578
|
userArgs = argv.slice(2);
|
|
22566
22579
|
break;
|
|
22567
22580
|
case "electron":
|
|
22568
|
-
if (process$
|
|
22581
|
+
if (process$3.defaultApp) {
|
|
22569
22582
|
this._scriptPath = argv[1];
|
|
22570
22583
|
userArgs = argv.slice(2);
|
|
22571
22584
|
} else userArgs = argv.slice(1);
|
|
@@ -22730,16 +22743,16 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
22730
22743
|
}
|
|
22731
22744
|
launchWithNode = sourceExt.includes(path$16.extname(executableFile));
|
|
22732
22745
|
let proc;
|
|
22733
|
-
if (process$
|
|
22746
|
+
if (process$3.platform !== "win32") if (launchWithNode) {
|
|
22734
22747
|
args.unshift(executableFile);
|
|
22735
|
-
args = incrementNodeInspectorPort(process$
|
|
22736
|
-
proc = childProcess$2.spawn(process$
|
|
22748
|
+
args = incrementNodeInspectorPort(process$3.execArgv).concat(args);
|
|
22749
|
+
proc = childProcess$2.spawn(process$3.argv[0], args, { stdio: "inherit" });
|
|
22737
22750
|
} else proc = childProcess$2.spawn(executableFile, args, { stdio: "inherit" });
|
|
22738
22751
|
else {
|
|
22739
22752
|
this._checkForMissingExecutable(executableFile, executableDir, subcommand._name);
|
|
22740
22753
|
args.unshift(executableFile);
|
|
22741
|
-
args = incrementNodeInspectorPort(process$
|
|
22742
|
-
proc = childProcess$2.spawn(process$
|
|
22754
|
+
args = incrementNodeInspectorPort(process$3.execArgv).concat(args);
|
|
22755
|
+
proc = childProcess$2.spawn(process$3.execPath, args, { stdio: "inherit" });
|
|
22743
22756
|
}
|
|
22744
22757
|
if (!proc.killed) [
|
|
22745
22758
|
"SIGUSR1",
|
|
@@ -22748,20 +22761,20 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
22748
22761
|
"SIGINT",
|
|
22749
22762
|
"SIGHUP"
|
|
22750
22763
|
].forEach((signal) => {
|
|
22751
|
-
process$
|
|
22764
|
+
process$3.on(signal, () => {
|
|
22752
22765
|
if (proc.killed === false && proc.exitCode === null) proc.kill(signal);
|
|
22753
22766
|
});
|
|
22754
22767
|
});
|
|
22755
22768
|
const exitCallback = this._exitCallback;
|
|
22756
22769
|
proc.on("close", (code) => {
|
|
22757
22770
|
code = code ?? 1;
|
|
22758
|
-
if (!exitCallback) process$
|
|
22771
|
+
if (!exitCallback) process$3.exit(code);
|
|
22759
22772
|
else exitCallback(new CommanderError(code, "commander.executeSubCommandAsync", "(close)"));
|
|
22760
22773
|
});
|
|
22761
22774
|
proc.on("error", (err) => {
|
|
22762
22775
|
if (err.code === "ENOENT") this._checkForMissingExecutable(executableFile, executableDir, subcommand._name);
|
|
22763
22776
|
else if (err.code === "EACCES") throw new Error(`'${executableFile}' not executable`);
|
|
22764
|
-
if (!exitCallback) process$
|
|
22777
|
+
if (!exitCallback) process$3.exit(1);
|
|
22765
22778
|
else {
|
|
22766
22779
|
const wrappedError = new CommanderError(1, "commander.executeSubCommandAsync", "(error)");
|
|
22767
22780
|
wrappedError.nestedError = err;
|
|
@@ -23170,13 +23183,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
23170
23183
|
*/
|
|
23171
23184
|
_parseOptionsEnv() {
|
|
23172
23185
|
this.options.forEach((option) => {
|
|
23173
|
-
if (option.envVar && option.envVar in process$
|
|
23186
|
+
if (option.envVar && option.envVar in process$3.env) {
|
|
23174
23187
|
const optionKey = option.attributeName();
|
|
23175
23188
|
if (this.getOptionValue(optionKey) === void 0 || [
|
|
23176
23189
|
"default",
|
|
23177
23190
|
"config",
|
|
23178
23191
|
"env"
|
|
23179
|
-
].includes(this.getOptionValueSource(optionKey))) if (option.required || option.optional) this.emit(`optionEnv:${option.name()}`, process$
|
|
23192
|
+
].includes(this.getOptionValueSource(optionKey))) if (option.required || option.optional) this.emit(`optionEnv:${option.name()}`, process$3.env[option.envVar]);
|
|
23180
23193
|
else this.emit(`optionEnv:${option.name()}`);
|
|
23181
23194
|
}
|
|
23182
23195
|
});
|
|
@@ -23593,7 +23606,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
23593
23606
|
*/
|
|
23594
23607
|
help(contextOptions) {
|
|
23595
23608
|
this.outputHelp(contextOptions);
|
|
23596
|
-
let exitCode = Number(process$
|
|
23609
|
+
let exitCode = Number(process$3.exitCode ?? 0);
|
|
23597
23610
|
if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) exitCode = 1;
|
|
23598
23611
|
this._exit(exitCode, "commander.help", "(outputHelp)");
|
|
23599
23612
|
}
|
|
@@ -23683,8 +23696,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
23683
23696
|
* @package
|
|
23684
23697
|
*/
|
|
23685
23698
|
function useColor() {
|
|
23686
|
-
if (process$
|
|
23687
|
-
if (process$
|
|
23699
|
+
if (process$3.env.NO_COLOR || process$3.env.FORCE_COLOR === "0" || process$3.env.FORCE_COLOR === "false") return false;
|
|
23700
|
+
if (process$3.env.FORCE_COLOR || process$3.env.CLICOLOR_FORCE !== void 0) return true;
|
|
23688
23701
|
}
|
|
23689
23702
|
exports.Command = Command;
|
|
23690
23703
|
exports.useColor = useColor;
|
|
@@ -24023,7 +24036,7 @@ const GOMS_KLM_TIMING_SECONDS = {
|
|
|
24023
24036
|
};
|
|
24024
24037
|
|
|
24025
24038
|
//#endregion
|
|
24026
|
-
//#region node_modules/.pnpm/@trpc+server@11.28.
|
|
24039
|
+
//#region node_modules/.pnpm/@trpc+server@11.28.3_@types+ws@8.18.2_typescript@6.0.3/node_modules/@trpc/server/dist/observable-CodTG6Sf.mjs
|
|
24027
24040
|
/**
|
|
24028
24041
|
* Creates an observable. `subscribe` runs for each subscriber, and can
|
|
24029
24042
|
* return a function that cleans up when it unsubscribes.
|
|
@@ -24249,7 +24262,7 @@ function observableToAsyncIterable(observable, signal) {
|
|
|
24249
24262
|
}
|
|
24250
24263
|
|
|
24251
24264
|
//#endregion
|
|
24252
|
-
//#region node_modules/.pnpm/@trpc+server@11.28.
|
|
24265
|
+
//#region node_modules/.pnpm/@trpc+server@11.28.3_@types+ws@8.18.2_typescript@6.0.3/node_modules/@trpc/server/dist/observable-BjUZYMQq.mjs
|
|
24253
24266
|
/**
|
|
24254
24267
|
* Shares one subscription to the source between all subscribers. It
|
|
24255
24268
|
* starts with the first subscriber and ends when the last unsubscribes.
|
|
@@ -24375,7 +24388,7 @@ function behaviorSubject(initialValue) {
|
|
|
24375
24388
|
}
|
|
24376
24389
|
|
|
24377
24390
|
//#endregion
|
|
24378
|
-
//#region node_modules/.pnpm/@trpc+client@11.28.
|
|
24391
|
+
//#region node_modules/.pnpm/@trpc+client@11.28.3_@trpc+server@11.28.3_@types+ws@8.18.2_typescript@6.0.3__typescript@6.0.3/node_modules/@trpc/client/dist/splitLink-PFsRy7Mf.mjs
|
|
24379
24392
|
/** @internal */
|
|
24380
24393
|
function createChain(opts) {
|
|
24381
24394
|
return observable$1((observer) => {
|
|
@@ -24394,7 +24407,7 @@ function createChain(opts) {
|
|
|
24394
24407
|
}
|
|
24395
24408
|
|
|
24396
24409
|
//#endregion
|
|
24397
|
-
//#region node_modules/.pnpm/@trpc+client@11.28.
|
|
24410
|
+
//#region node_modules/.pnpm/@trpc+client@11.28.3_@trpc+server@11.28.3_@types+ws@8.18.2_typescript@6.0.3__typescript@6.0.3/node_modules/@trpc/client/dist/objectSpread2-pyA4QVO4.mjs
|
|
24398
24411
|
function _typeof$1(o) {
|
|
24399
24412
|
"@babel/helpers - typeof";
|
|
24400
24413
|
return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -24448,7 +24461,7 @@ function _objectSpread2$1(e) {
|
|
|
24448
24461
|
}
|
|
24449
24462
|
|
|
24450
24463
|
//#endregion
|
|
24451
|
-
//#region node_modules/.pnpm/@trpc+server@11.28.
|
|
24464
|
+
//#region node_modules/.pnpm/@trpc+server@11.28.3_@types+ws@8.18.2_typescript@6.0.3/node_modules/@trpc/server/dist/codes-BCsCCyMj.mjs
|
|
24452
24465
|
/**
|
|
24453
24466
|
* Check that value is object
|
|
24454
24467
|
* @internal
|
|
@@ -24511,7 +24524,7 @@ const retryableRpcCodes = [
|
|
|
24511
24524
|
];
|
|
24512
24525
|
|
|
24513
24526
|
//#endregion
|
|
24514
|
-
//#region node_modules/.pnpm/@trpc+server@11.28.
|
|
24527
|
+
//#region node_modules/.pnpm/@trpc+server@11.28.3_@types+ws@8.18.2_typescript@6.0.3/node_modules/@trpc/server/dist/getErrorShape-CVrl8_-w.mjs
|
|
24515
24528
|
const noop$4 = () => {};
|
|
24516
24529
|
const freezeIfAvailable = (obj) => {
|
|
24517
24530
|
if (Object.freeze) Object.freeze(obj);
|
|
@@ -24616,7 +24629,7 @@ function _objectSpread2(e) {
|
|
|
24616
24629
|
}
|
|
24617
24630
|
|
|
24618
24631
|
//#endregion
|
|
24619
|
-
//#region node_modules/.pnpm/@trpc+server@11.28.
|
|
24632
|
+
//#region node_modules/.pnpm/@trpc+server@11.28.3_@types+ws@8.18.2_typescript@6.0.3/node_modules/@trpc/server/dist/asyncGeneratorDelegate-BRQGtkYG.mjs
|
|
24620
24633
|
/** @internal */
|
|
24621
24634
|
function transformResultInner(response, transformer) {
|
|
24622
24635
|
if ("error" in response) {
|
|
@@ -24722,7 +24735,7 @@ AsyncGenerator$1.prototype["function" == typeof Symbol && Symbol.asyncIterator |
|
|
|
24722
24735
|
};
|
|
24723
24736
|
|
|
24724
24737
|
//#endregion
|
|
24725
|
-
//#region node_modules/.pnpm/@trpc+client@11.28.
|
|
24738
|
+
//#region node_modules/.pnpm/@trpc+client@11.28.3_@trpc+server@11.28.3_@types+ws@8.18.2_typescript@6.0.3__typescript@6.0.3/node_modules/@trpc/client/dist/TRPCClientError-DE6-fd1n.mjs
|
|
24726
24739
|
/**
|
|
24727
24740
|
* Whether a value is a `TRPCClientError`, typed for a router or procedure.
|
|
24728
24741
|
* @see https://trpc.io/docs/client/vanilla/error-handling#catching-a-thrown-error
|
|
@@ -24778,7 +24791,7 @@ var TRPCClientError = class TRPCClientError extends Error {
|
|
|
24778
24791
|
};
|
|
24779
24792
|
|
|
24780
24793
|
//#endregion
|
|
24781
|
-
//#region node_modules/.pnpm/@trpc+client@11.28.
|
|
24794
|
+
//#region node_modules/.pnpm/@trpc+client@11.28.3_@trpc+server@11.28.3_@types+ws@8.18.2_typescript@6.0.3__typescript@6.0.3/node_modules/@trpc/client/dist/unstable-internals.mjs
|
|
24782
24795
|
/**
|
|
24783
24796
|
* @internal
|
|
24784
24797
|
*/
|
|
@@ -24805,7 +24818,7 @@ function getTransformer(transformer) {
|
|
|
24805
24818
|
}
|
|
24806
24819
|
|
|
24807
24820
|
//#endregion
|
|
24808
|
-
//#region node_modules/.pnpm/@trpc+client@11.28.
|
|
24821
|
+
//#region node_modules/.pnpm/@trpc+client@11.28.3_@trpc+server@11.28.3_@types+ws@8.18.2_typescript@6.0.3__typescript@6.0.3/node_modules/@trpc/client/dist/httpUtils-CtMuyl9j.mjs
|
|
24809
24822
|
const isFunction$1 = (fn) => typeof fn === "function";
|
|
24810
24823
|
/**
|
|
24811
24824
|
* The `fetch` to use: `customFetchImpl` if given, or else the global one.
|
|
@@ -24941,7 +24954,7 @@ async function httpRequest(opts) {
|
|
|
24941
24954
|
}
|
|
24942
24955
|
|
|
24943
24956
|
//#endregion
|
|
24944
|
-
//#region node_modules/.pnpm/@trpc+client@11.28.
|
|
24957
|
+
//#region node_modules/.pnpm/@trpc+client@11.28.3_@trpc+server@11.28.3_@types+ws@8.18.2_typescript@6.0.3__typescript@6.0.3/node_modules/@trpc/client/dist/httpLink-B4UwXApa.mjs
|
|
24945
24958
|
/** Whether an input is binary: a `Uint8Array`, `Blob` or `File`. */
|
|
24946
24959
|
function isOctetType(input) {
|
|
24947
24960
|
return input instanceof Uint8Array || input instanceof Blob;
|
|
@@ -25034,7 +25047,7 @@ function httpLink(opts) {
|
|
|
25034
25047
|
}
|
|
25035
25048
|
|
|
25036
25049
|
//#endregion
|
|
25037
|
-
//#region node_modules/.pnpm/@trpc+client@11.28.
|
|
25050
|
+
//#region node_modules/.pnpm/@trpc+client@11.28.3_@trpc+server@11.28.3_@types+ws@8.18.2_typescript@6.0.3__typescript@6.0.3/node_modules/@trpc/client/dist/wsLink-BiIe_j6D.mjs
|
|
25038
25051
|
/**
|
|
25039
25052
|
* Get the result of a value or function that returns a value
|
|
25040
25053
|
* It also optionally accepts typesafe arguments for the function
|
|
@@ -25224,7 +25237,7 @@ var WsConnection = class WsConnection {
|
|
|
25224
25237
|
_defineProperty$1(WsConnection, "connectCount", 0);
|
|
25225
25238
|
|
|
25226
25239
|
//#endregion
|
|
25227
|
-
//#region node_modules/.pnpm/@trpc+client@11.28.
|
|
25240
|
+
//#region node_modules/.pnpm/@trpc+client@11.28.3_@trpc+server@11.28.3_@types+ws@8.18.2_typescript@6.0.3__typescript@6.0.3/node_modules/@trpc/client/dist/index.mjs
|
|
25228
25241
|
const observerKeys = [
|
|
25229
25242
|
"onStarted",
|
|
25230
25243
|
"onData",
|
|
@@ -26369,7 +26382,7 @@ const cliVersion = pkg.version;
|
|
|
26369
26382
|
const cliNodeEngine = pkg.engines?.node;
|
|
26370
26383
|
|
|
26371
26384
|
//#endregion
|
|
26372
|
-
//#region ../../node_modules/.pnpm/@trpc+server@11.28.
|
|
26385
|
+
//#region ../../node_modules/.pnpm/@trpc+server@11.28.3_@types+aws-lambda@8.10.164_@types+express@5.0.6_@types+ws@8.18.2_n_4faacf2dd8c5d7e32e12b289867122f6/node_modules/@trpc/server/dist/observable-CodTG6Sf.mjs
|
|
26373
26386
|
/**
|
|
26374
26387
|
* Creates an observable. `subscribe` runs for each subscriber, and can
|
|
26375
26388
|
* return a function that cleans up when it unsubscribes.
|
|
@@ -72380,6 +72393,259 @@ const prepareClaudeCodeLobeHubCli = async (prompt, args = [], options = {}) => {
|
|
|
72380
72393
|
};
|
|
72381
72394
|
};
|
|
72382
72395
|
|
|
72396
|
+
//#endregion
|
|
72397
|
+
//#region ../../packages/heterogeneous-agents/src/spawn/claudeCodeLiveInput.ts
|
|
72398
|
+
/**
|
|
72399
|
+
* How long the session may sit between turns with no stdout before stdin is
|
|
72400
|
+
* closed anyway. Background tasks that stream (sub-agents) keep resetting it;
|
|
72401
|
+
* a silent one (a long background shell) would otherwise hold the process open
|
|
72402
|
+
* forever, since Claude Code's own wind-down ceiling only starts once stdin is
|
|
72403
|
+
* closed.
|
|
72404
|
+
*/
|
|
72405
|
+
const DEFAULT_IDLE_CLOSE_MS = 1800 * 1e3;
|
|
72406
|
+
/**
|
|
72407
|
+
* How long a task that ends between turns may wait for the main-agent turn its
|
|
72408
|
+
* notification wakes. Claude Code opens that turn within milliseconds; the
|
|
72409
|
+
* grace only bounds an end that wakes nothing, such as a task killed between
|
|
72410
|
+
* turns.
|
|
72411
|
+
*/
|
|
72412
|
+
const DEFAULT_WAKE_UP_GRACE_MS = 30 * 1e3;
|
|
72413
|
+
const TERMINAL_TASK_STATUSES = new Set([
|
|
72414
|
+
"completed",
|
|
72415
|
+
"failed",
|
|
72416
|
+
"killed"
|
|
72417
|
+
]);
|
|
72418
|
+
const readIdleCloseMs = () => {
|
|
72419
|
+
const value = Number(process.env.LOBE_CLAUDE_CODE_LIVE_INPUT_IDLE_MS);
|
|
72420
|
+
return Number.isFinite(value) && value > 0 ? value : DEFAULT_IDLE_CLOSE_MS;
|
|
72421
|
+
};
|
|
72422
|
+
/** Stamp a stream-json `user` line with the uuid Claude Code replays it under. */
|
|
72423
|
+
const withUserMessageUuid = (stdinLine, uuid) => `${JSON.stringify({
|
|
72424
|
+
...JSON.parse(stdinLine),
|
|
72425
|
+
uuid
|
|
72426
|
+
})}\n`;
|
|
72427
|
+
const isAbortedResult = (message) => !!message.is_error && String(message.terminal_reason ?? "").startsWith("aborted");
|
|
72428
|
+
const SESSION_ENDED = {
|
|
72429
|
+
error: "The session ended before answering",
|
|
72430
|
+
subtype: "error"
|
|
72431
|
+
};
|
|
72432
|
+
/**
|
|
72433
|
+
* Keeps a Claude Code print-mode (`-p --input-format stream-json`) stdin open
|
|
72434
|
+
* for as long as the run can still use input, so the host can deliver a user
|
|
72435
|
+
* message into the running session or interrupt only the current turn.
|
|
72436
|
+
*
|
|
72437
|
+
* Closing stdin early is not neutral: once input is closed, print mode stops
|
|
72438
|
+
* waiting for background tasks after `CLAUDE_CODE_PRINT_BG_WAIT_CEILING_MS`
|
|
72439
|
+
* (10 minutes by default) and kills them. So stdin stays open until the session
|
|
72440
|
+
* is between turns with no running task and no delivered message it has not
|
|
72441
|
+
* picked up yet.
|
|
72442
|
+
*
|
|
72443
|
+
* A task that ends between turns does not make the session idle: its
|
|
72444
|
+
* notification wakes the main agent for a turn, and that turn can start a new
|
|
72445
|
+
* task or resume a finished sub-agent with `SendMessage`. Closing at the end
|
|
72446
|
+
* would put those tasks under the ceiling, so the decision waits for the
|
|
72447
|
+
* wake-up turn's result.
|
|
72448
|
+
*
|
|
72449
|
+
* Requires `--replay-user-messages`: the replayed `uuid` is how a delivered
|
|
72450
|
+
* message is known to have been picked up.
|
|
72451
|
+
*/
|
|
72452
|
+
var ClaudeCodeLiveInput = class {
|
|
72453
|
+
activeTasks = /* @__PURE__ */ new Set();
|
|
72454
|
+
closed = false;
|
|
72455
|
+
idleTimer;
|
|
72456
|
+
idleCloseMs;
|
|
72457
|
+
lastOutcome;
|
|
72458
|
+
lineBuffer = "";
|
|
72459
|
+
pendingControl = /* @__PURE__ */ new Map();
|
|
72460
|
+
turnOpen = true;
|
|
72461
|
+
unconsumed = /* @__PURE__ */ new Set();
|
|
72462
|
+
wakeUpGraceMs;
|
|
72463
|
+
wakeUpTimer;
|
|
72464
|
+
constructor(stdin, options = {}) {
|
|
72465
|
+
this.stdin = stdin;
|
|
72466
|
+
this.idleCloseMs = options.idleCloseMs ?? readIdleCloseMs();
|
|
72467
|
+
this.wakeUpGraceMs = options.wakeUpGraceMs ?? DEFAULT_WAKE_UP_GRACE_MS;
|
|
72468
|
+
stdin.on("error", () => this.markClosed());
|
|
72469
|
+
stdin.on("close", () => this.markClosed());
|
|
72470
|
+
}
|
|
72471
|
+
get isOpen() {
|
|
72472
|
+
return !this.closed;
|
|
72473
|
+
}
|
|
72474
|
+
/** How the last turn ended; undefined while the session has not finished one. */
|
|
72475
|
+
get lastTurn() {
|
|
72476
|
+
return this.lastOutcome;
|
|
72477
|
+
}
|
|
72478
|
+
/**
|
|
72479
|
+
* Deliver a `user` line into the session; it stays pending until Claude Code
|
|
72480
|
+
* replays it. Returns false once input has closed.
|
|
72481
|
+
*/
|
|
72482
|
+
send(stdinLine, uuid = randomUUID()) {
|
|
72483
|
+
if (this.closed) return false;
|
|
72484
|
+
this.unconsumed.add(uuid);
|
|
72485
|
+
this.clearIdleTimer();
|
|
72486
|
+
this.stdin.write(withUserMessageUuid(stdinLine, uuid));
|
|
72487
|
+
return true;
|
|
72488
|
+
}
|
|
72489
|
+
/** Stop the current turn without ending the process. Returns false once input has closed. */
|
|
72490
|
+
interrupt() {
|
|
72491
|
+
return !!this.sendControlRequest({ subtype: "interrupt" });
|
|
72492
|
+
}
|
|
72493
|
+
/**
|
|
72494
|
+
* Write a stream-json `control_request` into the session — the protocol
|
|
72495
|
+
* Claude Code's SDK uses to steer a live process (interrupt, stop a task,
|
|
72496
|
+
* change the model…).
|
|
72497
|
+
*
|
|
72498
|
+
* @returns the request and its answer, or `undefined` once input has closed
|
|
72499
|
+
*/
|
|
72500
|
+
sendControlRequest(request) {
|
|
72501
|
+
if (this.closed) return;
|
|
72502
|
+
const requestId = randomUUID();
|
|
72503
|
+
const response = new Promise((resolve) => {
|
|
72504
|
+
this.pendingControl.set(requestId, resolve);
|
|
72505
|
+
});
|
|
72506
|
+
this.stdin.write(`${JSON.stringify({
|
|
72507
|
+
request,
|
|
72508
|
+
request_id: requestId,
|
|
72509
|
+
type: "control_request"
|
|
72510
|
+
})}\n`);
|
|
72511
|
+
return {
|
|
72512
|
+
requestId,
|
|
72513
|
+
response
|
|
72514
|
+
};
|
|
72515
|
+
}
|
|
72516
|
+
/** Feed raw stdout so the session state tracks what Claude Code reports. */
|
|
72517
|
+
observe(chunk) {
|
|
72518
|
+
this.lineBuffer += chunk.toString();
|
|
72519
|
+
const lines = this.lineBuffer.split("\n");
|
|
72520
|
+
this.lineBuffer = lines.pop() ?? "";
|
|
72521
|
+
for (const line of lines) {
|
|
72522
|
+
if (!line.trim()) continue;
|
|
72523
|
+
try {
|
|
72524
|
+
const message = JSON.parse(line);
|
|
72525
|
+
if (message?.type === "result") this.lastOutcome = {
|
|
72526
|
+
aborted: isAbortedResult(message),
|
|
72527
|
+
terminalReason: message.terminal_reason
|
|
72528
|
+
};
|
|
72529
|
+
this.observeMessage(message);
|
|
72530
|
+
} catch {}
|
|
72531
|
+
}
|
|
72532
|
+
if (this.closed) return;
|
|
72533
|
+
if (this.turnOpen) this.clearIdleTimer();
|
|
72534
|
+
else this.armIdleTimer();
|
|
72535
|
+
}
|
|
72536
|
+
/**
|
|
72537
|
+
* stdout ended: take a final record left without a trailing newline, then
|
|
72538
|
+
* close input, since nothing can read it any more.
|
|
72539
|
+
*/
|
|
72540
|
+
finish() {
|
|
72541
|
+
if (this.lineBuffer.trim()) this.observe("\n");
|
|
72542
|
+
this.close();
|
|
72543
|
+
for (const resolve of this.pendingControl.values()) resolve(SESSION_ENDED);
|
|
72544
|
+
this.pendingControl.clear();
|
|
72545
|
+
}
|
|
72546
|
+
close() {
|
|
72547
|
+
if (this.closed) return;
|
|
72548
|
+
this.markClosed();
|
|
72549
|
+
this.stdin.end();
|
|
72550
|
+
}
|
|
72551
|
+
observeMessage(message) {
|
|
72552
|
+
if (message?.type === "control_response") {
|
|
72553
|
+
this.observeControlResponse(message.response);
|
|
72554
|
+
return;
|
|
72555
|
+
}
|
|
72556
|
+
if (message?.parent_tool_use_id && message.type !== "system") return;
|
|
72557
|
+
switch (message?.type) {
|
|
72558
|
+
case "user":
|
|
72559
|
+
if (message.isReplay && typeof message.uuid === "string") {
|
|
72560
|
+
this.unconsumed.delete(message.uuid);
|
|
72561
|
+
this.openTurn();
|
|
72562
|
+
}
|
|
72563
|
+
return;
|
|
72564
|
+
case "assistant":
|
|
72565
|
+
case "stream_event":
|
|
72566
|
+
this.openTurn();
|
|
72567
|
+
return;
|
|
72568
|
+
case "system":
|
|
72569
|
+
this.observeSystem(message);
|
|
72570
|
+
return;
|
|
72571
|
+
case "result":
|
|
72572
|
+
this.turnOpen = false;
|
|
72573
|
+
if (message.is_error && !isAbortedResult(message)) this.close();
|
|
72574
|
+
else this.closeIfIdle();
|
|
72575
|
+
return;
|
|
72576
|
+
}
|
|
72577
|
+
}
|
|
72578
|
+
/** Answers arrive even after input closed, for requests written before. */
|
|
72579
|
+
observeControlResponse(response) {
|
|
72580
|
+
const requestId = response?.request_id;
|
|
72581
|
+
const resolve = typeof requestId === "string" && this.pendingControl.get(requestId);
|
|
72582
|
+
if (!resolve) return;
|
|
72583
|
+
this.pendingControl.delete(requestId);
|
|
72584
|
+
resolve(response.subtype === "success" ? {
|
|
72585
|
+
response: response.response ?? void 0,
|
|
72586
|
+
subtype: "success"
|
|
72587
|
+
} : {
|
|
72588
|
+
error: String(response.error ?? "Control request failed"),
|
|
72589
|
+
subtype: "error"
|
|
72590
|
+
});
|
|
72591
|
+
}
|
|
72592
|
+
observeSystem(message) {
|
|
72593
|
+
if (message.subtype === "init") {
|
|
72594
|
+
this.openTurn();
|
|
72595
|
+
return;
|
|
72596
|
+
}
|
|
72597
|
+
if (message.subtype === "task_started" && message.task_id) {
|
|
72598
|
+
this.activeTasks.add(message.task_id);
|
|
72599
|
+
return;
|
|
72600
|
+
}
|
|
72601
|
+
if ((message.subtype === "task_notification" || message.subtype === "task_updated" && TERMINAL_TASK_STATUSES.has(message.patch?.status)) && message.task_id) {
|
|
72602
|
+
this.activeTasks.delete(message.task_id);
|
|
72603
|
+
this.awaitWakeUpTurn();
|
|
72604
|
+
}
|
|
72605
|
+
}
|
|
72606
|
+
/** A newer turn supersedes how the last one ended until it reports its own. */
|
|
72607
|
+
openTurn() {
|
|
72608
|
+
this.turnOpen = true;
|
|
72609
|
+
this.lastOutcome = void 0;
|
|
72610
|
+
this.clearWakeUpTimer();
|
|
72611
|
+
}
|
|
72612
|
+
closeIfIdle() {
|
|
72613
|
+
if (this.turnOpen || this.activeTasks.size > 0 || this.unconsumed.size > 0) return;
|
|
72614
|
+
this.close();
|
|
72615
|
+
}
|
|
72616
|
+
/**
|
|
72617
|
+
* The last task ended between turns. The turn its notification wakes decides
|
|
72618
|
+
* at its result; close here only if no turn opens within the grace.
|
|
72619
|
+
*/
|
|
72620
|
+
awaitWakeUpTurn() {
|
|
72621
|
+
if (this.closed) return;
|
|
72622
|
+
if (this.turnOpen || this.activeTasks.size > 0 || this.unconsumed.size > 0) return;
|
|
72623
|
+
this.clearWakeUpTimer();
|
|
72624
|
+
this.wakeUpTimer = setTimeout(() => this.closeIfIdle(), this.wakeUpGraceMs);
|
|
72625
|
+
this.wakeUpTimer.unref?.();
|
|
72626
|
+
}
|
|
72627
|
+
clearWakeUpTimer() {
|
|
72628
|
+
if (!this.wakeUpTimer) return;
|
|
72629
|
+
clearTimeout(this.wakeUpTimer);
|
|
72630
|
+
this.wakeUpTimer = void 0;
|
|
72631
|
+
}
|
|
72632
|
+
armIdleTimer() {
|
|
72633
|
+
this.clearIdleTimer();
|
|
72634
|
+
this.idleTimer = setTimeout(() => this.close(), this.idleCloseMs);
|
|
72635
|
+
this.idleTimer.unref?.();
|
|
72636
|
+
}
|
|
72637
|
+
clearIdleTimer() {
|
|
72638
|
+
if (!this.idleTimer) return;
|
|
72639
|
+
clearTimeout(this.idleTimer);
|
|
72640
|
+
this.idleTimer = void 0;
|
|
72641
|
+
}
|
|
72642
|
+
markClosed() {
|
|
72643
|
+
this.closed = true;
|
|
72644
|
+
this.clearIdleTimer();
|
|
72645
|
+
this.clearWakeUpTimer();
|
|
72646
|
+
}
|
|
72647
|
+
};
|
|
72648
|
+
|
|
72383
72649
|
//#endregion
|
|
72384
72650
|
//#region ../../packages/heterogeneous-agents/src/spawn/presetEnv.ts
|
|
72385
72651
|
/**
|
|
@@ -72792,217 +73058,6 @@ const spawnTraeAcpAgent = async (options) => {
|
|
|
72792
73058
|
return createAcpSpawnHandle(bridge, session, () => session.nativeSessionId);
|
|
72793
73059
|
};
|
|
72794
73060
|
|
|
72795
|
-
//#endregion
|
|
72796
|
-
//#region ../../packages/heterogeneous-agents/src/spawn/claudeCodeLiveInput.ts
|
|
72797
|
-
/**
|
|
72798
|
-
* How long the session may sit between turns with no stdout before stdin is
|
|
72799
|
-
* closed anyway. Background tasks that stream (sub-agents) keep resetting it;
|
|
72800
|
-
* a silent one (a long background shell) would otherwise hold the process open
|
|
72801
|
-
* forever, since Claude Code's own wind-down ceiling only starts once stdin is
|
|
72802
|
-
* closed.
|
|
72803
|
-
*/
|
|
72804
|
-
const DEFAULT_IDLE_CLOSE_MS = 1800 * 1e3;
|
|
72805
|
-
/**
|
|
72806
|
-
* How long a task that ends between turns may wait for the main-agent turn its
|
|
72807
|
-
* notification wakes. Claude Code opens that turn within milliseconds; the
|
|
72808
|
-
* grace only bounds an end that wakes nothing, such as a task killed between
|
|
72809
|
-
* turns.
|
|
72810
|
-
*/
|
|
72811
|
-
const DEFAULT_WAKE_UP_GRACE_MS = 30 * 1e3;
|
|
72812
|
-
const TERMINAL_TASK_STATUSES = new Set([
|
|
72813
|
-
"completed",
|
|
72814
|
-
"failed",
|
|
72815
|
-
"killed"
|
|
72816
|
-
]);
|
|
72817
|
-
const readIdleCloseMs = () => {
|
|
72818
|
-
const value = Number(process.env.LOBE_CLAUDE_CODE_LIVE_INPUT_IDLE_MS);
|
|
72819
|
-
return Number.isFinite(value) && value > 0 ? value : DEFAULT_IDLE_CLOSE_MS;
|
|
72820
|
-
};
|
|
72821
|
-
/** Stamp a stream-json `user` line with the uuid Claude Code replays it under. */
|
|
72822
|
-
const withUserMessageUuid = (stdinLine, uuid) => `${JSON.stringify({
|
|
72823
|
-
...JSON.parse(stdinLine),
|
|
72824
|
-
uuid
|
|
72825
|
-
})}\n`;
|
|
72826
|
-
const isAbortedResult = (message) => !!message.is_error && String(message.terminal_reason ?? "").startsWith("aborted");
|
|
72827
|
-
/**
|
|
72828
|
-
* Keeps a Claude Code print-mode (`-p --input-format stream-json`) stdin open
|
|
72829
|
-
* for as long as the run can still use input, so the host can deliver a user
|
|
72830
|
-
* message into the running session or interrupt only the current turn.
|
|
72831
|
-
*
|
|
72832
|
-
* Closing stdin early is not neutral: once input is closed, print mode stops
|
|
72833
|
-
* waiting for background tasks after `CLAUDE_CODE_PRINT_BG_WAIT_CEILING_MS`
|
|
72834
|
-
* (10 minutes by default) and kills them. So stdin stays open until the session
|
|
72835
|
-
* is between turns with no running task and no delivered message it has not
|
|
72836
|
-
* picked up yet.
|
|
72837
|
-
*
|
|
72838
|
-
* A task that ends between turns does not make the session idle: its
|
|
72839
|
-
* notification wakes the main agent for a turn, and that turn can start a new
|
|
72840
|
-
* task or resume a finished sub-agent with `SendMessage`. Closing at the end
|
|
72841
|
-
* would put those tasks under the ceiling, so the decision waits for the
|
|
72842
|
-
* wake-up turn's result.
|
|
72843
|
-
*
|
|
72844
|
-
* Requires `--replay-user-messages`: the replayed `uuid` is how a delivered
|
|
72845
|
-
* message is known to have been picked up.
|
|
72846
|
-
*/
|
|
72847
|
-
var ClaudeCodeLiveInput = class {
|
|
72848
|
-
activeTasks = /* @__PURE__ */ new Set();
|
|
72849
|
-
closed = false;
|
|
72850
|
-
idleTimer;
|
|
72851
|
-
idleCloseMs;
|
|
72852
|
-
lastOutcome;
|
|
72853
|
-
lineBuffer = "";
|
|
72854
|
-
turnOpen = true;
|
|
72855
|
-
unconsumed = /* @__PURE__ */ new Set();
|
|
72856
|
-
wakeUpGraceMs;
|
|
72857
|
-
wakeUpTimer;
|
|
72858
|
-
constructor(stdin, options = {}) {
|
|
72859
|
-
this.stdin = stdin;
|
|
72860
|
-
this.idleCloseMs = options.idleCloseMs ?? readIdleCloseMs();
|
|
72861
|
-
this.wakeUpGraceMs = options.wakeUpGraceMs ?? DEFAULT_WAKE_UP_GRACE_MS;
|
|
72862
|
-
stdin.on("error", () => this.markClosed());
|
|
72863
|
-
stdin.on("close", () => this.markClosed());
|
|
72864
|
-
}
|
|
72865
|
-
get isOpen() {
|
|
72866
|
-
return !this.closed;
|
|
72867
|
-
}
|
|
72868
|
-
/** How the last turn ended; undefined while the session has not finished one. */
|
|
72869
|
-
get lastTurn() {
|
|
72870
|
-
return this.lastOutcome;
|
|
72871
|
-
}
|
|
72872
|
-
/**
|
|
72873
|
-
* Deliver a `user` line into the session; it stays pending until Claude Code
|
|
72874
|
-
* replays it. Returns false once input has closed.
|
|
72875
|
-
*/
|
|
72876
|
-
send(stdinLine, uuid = randomUUID()) {
|
|
72877
|
-
if (this.closed) return false;
|
|
72878
|
-
this.unconsumed.add(uuid);
|
|
72879
|
-
this.clearIdleTimer();
|
|
72880
|
-
this.stdin.write(withUserMessageUuid(stdinLine, uuid));
|
|
72881
|
-
return true;
|
|
72882
|
-
}
|
|
72883
|
-
/** Stop the current turn without ending the process. Returns false once input has closed. */
|
|
72884
|
-
interrupt() {
|
|
72885
|
-
if (this.closed) return false;
|
|
72886
|
-
this.stdin.write(`${JSON.stringify({
|
|
72887
|
-
request: { subtype: "interrupt" },
|
|
72888
|
-
request_id: randomUUID(),
|
|
72889
|
-
type: "control_request"
|
|
72890
|
-
})}\n`);
|
|
72891
|
-
return true;
|
|
72892
|
-
}
|
|
72893
|
-
/** Feed raw stdout so the session state tracks what Claude Code reports. */
|
|
72894
|
-
observe(chunk) {
|
|
72895
|
-
this.lineBuffer += chunk.toString();
|
|
72896
|
-
const lines = this.lineBuffer.split("\n");
|
|
72897
|
-
this.lineBuffer = lines.pop() ?? "";
|
|
72898
|
-
for (const line of lines) {
|
|
72899
|
-
if (!line.trim()) continue;
|
|
72900
|
-
try {
|
|
72901
|
-
const message = JSON.parse(line);
|
|
72902
|
-
if (message?.type === "result") this.lastOutcome = {
|
|
72903
|
-
aborted: isAbortedResult(message),
|
|
72904
|
-
terminalReason: message.terminal_reason
|
|
72905
|
-
};
|
|
72906
|
-
this.observeMessage(message);
|
|
72907
|
-
} catch {}
|
|
72908
|
-
}
|
|
72909
|
-
if (this.closed) return;
|
|
72910
|
-
if (this.turnOpen) this.clearIdleTimer();
|
|
72911
|
-
else this.armIdleTimer();
|
|
72912
|
-
}
|
|
72913
|
-
/**
|
|
72914
|
-
* stdout ended: take a final record left without a trailing newline, then
|
|
72915
|
-
* close input, since nothing can read it any more.
|
|
72916
|
-
*/
|
|
72917
|
-
finish() {
|
|
72918
|
-
if (this.lineBuffer.trim()) this.observe("\n");
|
|
72919
|
-
this.close();
|
|
72920
|
-
}
|
|
72921
|
-
close() {
|
|
72922
|
-
if (this.closed) return;
|
|
72923
|
-
this.markClosed();
|
|
72924
|
-
this.stdin.end();
|
|
72925
|
-
}
|
|
72926
|
-
observeMessage(message) {
|
|
72927
|
-
if (message?.parent_tool_use_id && message.type !== "system") return;
|
|
72928
|
-
switch (message?.type) {
|
|
72929
|
-
case "user":
|
|
72930
|
-
if (message.isReplay && typeof message.uuid === "string") {
|
|
72931
|
-
this.unconsumed.delete(message.uuid);
|
|
72932
|
-
this.openTurn();
|
|
72933
|
-
}
|
|
72934
|
-
return;
|
|
72935
|
-
case "assistant":
|
|
72936
|
-
case "stream_event":
|
|
72937
|
-
this.openTurn();
|
|
72938
|
-
return;
|
|
72939
|
-
case "system":
|
|
72940
|
-
this.observeSystem(message);
|
|
72941
|
-
return;
|
|
72942
|
-
case "result":
|
|
72943
|
-
this.turnOpen = false;
|
|
72944
|
-
if (message.is_error && !isAbortedResult(message)) this.close();
|
|
72945
|
-
else this.closeIfIdle();
|
|
72946
|
-
return;
|
|
72947
|
-
}
|
|
72948
|
-
}
|
|
72949
|
-
observeSystem(message) {
|
|
72950
|
-
if (message.subtype === "init") {
|
|
72951
|
-
this.openTurn();
|
|
72952
|
-
return;
|
|
72953
|
-
}
|
|
72954
|
-
if (message.subtype === "task_started" && message.task_id) {
|
|
72955
|
-
this.activeTasks.add(message.task_id);
|
|
72956
|
-
return;
|
|
72957
|
-
}
|
|
72958
|
-
if ((message.subtype === "task_notification" || message.subtype === "task_updated" && TERMINAL_TASK_STATUSES.has(message.patch?.status)) && message.task_id) {
|
|
72959
|
-
this.activeTasks.delete(message.task_id);
|
|
72960
|
-
this.awaitWakeUpTurn();
|
|
72961
|
-
}
|
|
72962
|
-
}
|
|
72963
|
-
/** A newer turn supersedes how the last one ended until it reports its own. */
|
|
72964
|
-
openTurn() {
|
|
72965
|
-
this.turnOpen = true;
|
|
72966
|
-
this.lastOutcome = void 0;
|
|
72967
|
-
this.clearWakeUpTimer();
|
|
72968
|
-
}
|
|
72969
|
-
closeIfIdle() {
|
|
72970
|
-
if (this.turnOpen || this.activeTasks.size > 0 || this.unconsumed.size > 0) return;
|
|
72971
|
-
this.close();
|
|
72972
|
-
}
|
|
72973
|
-
/**
|
|
72974
|
-
* The last task ended between turns. The turn its notification wakes decides
|
|
72975
|
-
* at its result; close here only if no turn opens within the grace.
|
|
72976
|
-
*/
|
|
72977
|
-
awaitWakeUpTurn() {
|
|
72978
|
-
if (this.closed) return;
|
|
72979
|
-
if (this.turnOpen || this.activeTasks.size > 0 || this.unconsumed.size > 0) return;
|
|
72980
|
-
this.clearWakeUpTimer();
|
|
72981
|
-
this.wakeUpTimer = setTimeout(() => this.closeIfIdle(), this.wakeUpGraceMs);
|
|
72982
|
-
this.wakeUpTimer.unref?.();
|
|
72983
|
-
}
|
|
72984
|
-
clearWakeUpTimer() {
|
|
72985
|
-
if (!this.wakeUpTimer) return;
|
|
72986
|
-
clearTimeout(this.wakeUpTimer);
|
|
72987
|
-
this.wakeUpTimer = void 0;
|
|
72988
|
-
}
|
|
72989
|
-
armIdleTimer() {
|
|
72990
|
-
this.clearIdleTimer();
|
|
72991
|
-
this.idleTimer = setTimeout(() => this.close(), this.idleCloseMs);
|
|
72992
|
-
this.idleTimer.unref?.();
|
|
72993
|
-
}
|
|
72994
|
-
clearIdleTimer() {
|
|
72995
|
-
if (!this.idleTimer) return;
|
|
72996
|
-
clearTimeout(this.idleTimer);
|
|
72997
|
-
this.idleTimer = void 0;
|
|
72998
|
-
}
|
|
72999
|
-
markClosed() {
|
|
73000
|
-
this.closed = true;
|
|
73001
|
-
this.clearIdleTimer();
|
|
73002
|
-
this.clearWakeUpTimer();
|
|
73003
|
-
}
|
|
73004
|
-
};
|
|
73005
|
-
|
|
73006
73061
|
//#endregion
|
|
73007
73062
|
//#region ../../packages/heterogeneous-agents/src/spawn/spawnAgent.ts
|
|
73008
73063
|
init_config();
|
|
@@ -73419,6 +73474,7 @@ const spawnCliAgent = async (options, command, cwd, inputPlan, childEnv, codexJw
|
|
|
73419
73474
|
exit,
|
|
73420
73475
|
...live && {
|
|
73421
73476
|
interruptTurn: () => live.interrupt(),
|
|
73477
|
+
sendControlRequest: (request) => live.sendControlRequest(request),
|
|
73422
73478
|
sendUserMessage: async (prompt, sendOptions) => {
|
|
73423
73479
|
if (!live.isOpen) return false;
|
|
73424
73480
|
const plan = await buildAgentInput("claude-code", prompt, options.inputOptions);
|
|
@@ -330850,7 +330906,7 @@ var stdio_exports = /* @__PURE__ */ __exportAll$2({
|
|
|
330850
330906
|
function getDefaultEnvironment() {
|
|
330851
330907
|
const env = {};
|
|
330852
330908
|
for (const key of DEFAULT_INHERITED_ENV_VARS) {
|
|
330853
|
-
const value =
|
|
330909
|
+
const value = process$1.env[key];
|
|
330854
330910
|
if (value === void 0) continue;
|
|
330855
330911
|
if (value.startsWith("()")) continue;
|
|
330856
330912
|
env[key] = value;
|
|
@@ -330861,7 +330917,7 @@ var import_cross_spawn$1, DEFAULT_INHERITED_ENV_VARS, StdioClientTransport;
|
|
|
330861
330917
|
var init_stdio = __esmMin((() => {
|
|
330862
330918
|
init_src_CeKsbNLO();
|
|
330863
330919
|
import_cross_spawn$1 = /* @__PURE__ */ __toESM$2(require_cross_spawn(), 1);
|
|
330864
|
-
DEFAULT_INHERITED_ENV_VARS =
|
|
330920
|
+
DEFAULT_INHERITED_ENV_VARS = process$1.platform === "win32" ? [
|
|
330865
330921
|
"APPDATA",
|
|
330866
330922
|
"COMSPEC",
|
|
330867
330923
|
"HOMEDRIVE",
|
|
@@ -330918,7 +330974,7 @@ var init_stdio = __esmMin((() => {
|
|
|
330918
330974
|
this._serverParams.stderr ?? "inherit"
|
|
330919
330975
|
],
|
|
330920
330976
|
shell: false,
|
|
330921
|
-
windowsHide:
|
|
330977
|
+
windowsHide: process$1.platform === "win32",
|
|
330922
330978
|
cwd: this._serverParams.cwd
|
|
330923
330979
|
});
|
|
330924
330980
|
this._process.on("error", (error) => {
|
|
@@ -333952,9 +334008,9 @@ const getSubprocessResult = ({ stdout }) => {
|
|
|
333952
334008
|
//#region node_modules/.pnpm/execa@9.6.1/node_modules/execa/lib/utils/standard-stream.js
|
|
333953
334009
|
const isStandardStream = (stream) => STANDARD_STREAMS.includes(stream);
|
|
333954
334010
|
const STANDARD_STREAMS = [
|
|
333955
|
-
|
|
333956
|
-
|
|
333957
|
-
|
|
334011
|
+
process$1.stdin,
|
|
334012
|
+
process$1.stdout,
|
|
334013
|
+
process$1.stderr
|
|
333958
334014
|
];
|
|
333959
334015
|
const STANDARD_STREAMS_ALIASES = [
|
|
333960
334016
|
"stdin",
|
|
@@ -334079,9 +334135,9 @@ const NO_ESCAPE_REGEXP = /^[\w./-]+$/;
|
|
|
334079
334135
|
//#endregion
|
|
334080
334136
|
//#region node_modules/.pnpm/is-unicode-supported@2.1.0/node_modules/is-unicode-supported/index.js
|
|
334081
334137
|
function isUnicodeSupported() {
|
|
334082
|
-
const { env } =
|
|
334138
|
+
const { env } = process$1;
|
|
334083
334139
|
const { TERM, TERM_PROGRAM } = env;
|
|
334084
|
-
if (
|
|
334140
|
+
if (process$1.platform !== "win32") return TERM !== "linux";
|
|
334085
334141
|
return Boolean(env.WT_SESSION) || Boolean(env.TERMINUS_SUBLIME) || env.ConEmuTask === "{cmd::Cmder}" || TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM === "xterm-256color" || TERM === "alacritty" || TERM === "rxvt-unicode" || TERM === "rxvt-unicode-256color" || env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
334086
334142
|
}
|
|
334087
334143
|
|
|
@@ -334616,7 +334672,7 @@ function traversePathUp(startPath) {
|
|
|
334616
334672
|
|
|
334617
334673
|
//#endregion
|
|
334618
334674
|
//#region node_modules/.pnpm/npm-run-path@6.0.0/node_modules/npm-run-path/index.js
|
|
334619
|
-
const npmRunPath = ({ cwd =
|
|
334675
|
+
const npmRunPath = ({ cwd = process$1.cwd(), path: pathOption = process$1.env[pathKey()], preferLocal = true, execPath = process$1.execPath, addExecPath = true } = {}) => {
|
|
334620
334676
|
const cwdPath = path.resolve(toPath(cwd));
|
|
334621
334677
|
const result = [];
|
|
334622
334678
|
const pathParts = pathOption.split(path.delimiter);
|
|
@@ -334634,7 +334690,7 @@ const applyExecPath = (result, pathParts, execPath, cwdPath) => {
|
|
|
334634
334690
|
const pathPart = path.resolve(cwdPath, toPath(execPath), "..");
|
|
334635
334691
|
if (!pathParts.includes(pathPart)) result.push(pathPart);
|
|
334636
334692
|
};
|
|
334637
|
-
const npmRunPathEnv = ({ env =
|
|
334693
|
+
const npmRunPathEnv = ({ env = process$1.env, ...options } = {}) => {
|
|
334638
334694
|
env = { ...env };
|
|
334639
334695
|
const pathName = pathKey({ env });
|
|
334640
334696
|
options.path = env[pathName];
|
|
@@ -335769,7 +335825,7 @@ const normalizeCwd = (cwd = getDefaultCwd()) => {
|
|
|
335769
335825
|
};
|
|
335770
335826
|
const getDefaultCwd = () => {
|
|
335771
335827
|
try {
|
|
335772
|
-
return
|
|
335828
|
+
return process$1.cwd();
|
|
335773
335829
|
} catch (error) {
|
|
335774
335830
|
error.message = `The current directory does not exist.\n${error.message}`;
|
|
335775
335831
|
throw error;
|
|
@@ -335805,7 +335861,7 @@ const normalizeOptions = (filePath, rawArguments, rawOptions) => {
|
|
|
335805
335861
|
options.killSignal = normalizeKillSignal(options.killSignal);
|
|
335806
335862
|
options.forceKillAfterDelay = normalizeForceKillAfterDelay(options.forceKillAfterDelay);
|
|
335807
335863
|
options.lines = options.lines.map((lines, fdNumber) => lines && !BINARY_ENCODINGS.has(options.encoding) && options.buffer[fdNumber]);
|
|
335808
|
-
if (
|
|
335864
|
+
if (process$1.platform === "win32" && path.basename(file, ".exe") === "cmd") commandArguments.unshift("/q");
|
|
335809
335865
|
return {
|
|
335810
335866
|
file,
|
|
335811
335867
|
commandArguments,
|
|
@@ -335832,7 +335888,7 @@ const addDefaultOptions = ({ extendEnv = true, preferLocal = false, cwd, localDi
|
|
|
335832
335888
|
});
|
|
335833
335889
|
const getEnv = ({ env: envOption, extendEnv, preferLocal, node, localDirectory, nodePath }) => {
|
|
335834
335890
|
const env = extendEnv ? {
|
|
335835
|
-
...
|
|
335891
|
+
...process$1.env,
|
|
335836
335892
|
...envOption
|
|
335837
335893
|
} : envOption;
|
|
335838
335894
|
if (preferLocal || node) return npmRunPathEnv({
|
|
@@ -336834,12 +336890,12 @@ const guessStreamDirection = {
|
|
|
336834
336890
|
}
|
|
336835
336891
|
};
|
|
336836
336892
|
const getStandardStreamDirection = (value) => {
|
|
336837
|
-
if ([0,
|
|
336893
|
+
if ([0, process$1.stdin].includes(value)) return "input";
|
|
336838
336894
|
if ([
|
|
336839
336895
|
1,
|
|
336840
336896
|
2,
|
|
336841
|
-
|
|
336842
|
-
|
|
336897
|
+
process$1.stdout,
|
|
336898
|
+
process$1.stderr
|
|
336843
336899
|
].includes(value)) return "output";
|
|
336844
336900
|
};
|
|
336845
336901
|
const DEFAULT_DIRECTION = "output";
|
|
@@ -337903,9 +337959,9 @@ const addIpcMethods = (subprocess, { ipc }) => {
|
|
|
337903
337959
|
Object.assign(subprocess, getIpcMethods(subprocess, false, ipc));
|
|
337904
337960
|
};
|
|
337905
337961
|
const getIpcExport = () => {
|
|
337906
|
-
const anyProcess =
|
|
337962
|
+
const anyProcess = process$1;
|
|
337907
337963
|
const isSubprocess = true;
|
|
337908
|
-
const ipc =
|
|
337964
|
+
const ipc = process$1.channel !== void 0;
|
|
337909
337965
|
return {
|
|
337910
337966
|
...getIpcMethods(anyProcess, isSubprocess, ipc),
|
|
337911
337967
|
getCancelSignal: getCancelSignal$1.bind(void 0, {
|
|
@@ -338382,7 +338438,7 @@ var SignalExitFallback = class extends SignalExitBase {
|
|
|
338382
338438
|
};
|
|
338383
338439
|
var SignalExit = class extends SignalExitBase {
|
|
338384
338440
|
/* c8 ignore start */
|
|
338385
|
-
#hupSig = process$
|
|
338441
|
+
#hupSig = process$2.platform === "win32" ? "SIGINT" : "SIGHUP";
|
|
338386
338442
|
/* c8 ignore stop */
|
|
338387
338443
|
#emitter = new Emitter();
|
|
338388
338444
|
#process;
|
|
@@ -338477,8 +338533,8 @@ var SignalExit = class extends SignalExitBase {
|
|
|
338477
338533
|
} else return og.call(this.#process, ev, ...args);
|
|
338478
338534
|
}
|
|
338479
338535
|
};
|
|
338480
|
-
const process$
|
|
338481
|
-
const { onExit, load: load$1, unload } = signalExitWrap(processOk(process$
|
|
338536
|
+
const process$2 = globalThis.process;
|
|
338537
|
+
const { onExit, load: load$1, unload } = signalExitWrap(processOk(process$2) ? new SignalExit(process$2) : new SignalExitFallback());
|
|
338482
338538
|
|
|
338483
338539
|
//#endregion
|
|
338484
338540
|
//#region node_modules/.pnpm/execa@9.6.1/node_modules/execa/lib/terminate/cleanup.js
|
|
@@ -580894,6 +580950,36 @@ var CoalescingBatchIngester = class {
|
|
|
580894
580950
|
}
|
|
580895
580951
|
};
|
|
580896
580952
|
|
|
580953
|
+
//#endregion
|
|
580954
|
+
//#region src/utils/heteroControl.ts
|
|
580955
|
+
/**
|
|
580956
|
+
* Command handlers by command name. Empty until a command ships: an unknown
|
|
580957
|
+
* command is reported `unsupported`, so the server can tell "this `lh` does
|
|
580958
|
+
* not know it" from "it failed".
|
|
580959
|
+
*/
|
|
580960
|
+
const handlers = /* @__PURE__ */ new Map();
|
|
580961
|
+
/** Run the handler for a control message and say how it went; never throws. */
|
|
580962
|
+
const dispatchHeteroControl = async (message, context) => {
|
|
580963
|
+
const handler = handlers.get(message.command);
|
|
580964
|
+
if (!handler) return { status: "unsupported" };
|
|
580965
|
+
try {
|
|
580966
|
+
const data = await handler({
|
|
580967
|
+
...context,
|
|
580968
|
+
controlId: message.id,
|
|
580969
|
+
params: message.params
|
|
580970
|
+
});
|
|
580971
|
+
return data === void 0 ? { status: "ok" } : {
|
|
580972
|
+
data,
|
|
580973
|
+
status: "ok"
|
|
580974
|
+
};
|
|
580975
|
+
} catch (error) {
|
|
580976
|
+
return {
|
|
580977
|
+
error: ((error instanceof Error ? error.message : String(error)) || "The control handler failed").slice(0, 4e3),
|
|
580978
|
+
status: "error"
|
|
580979
|
+
};
|
|
580980
|
+
}
|
|
580981
|
+
};
|
|
580982
|
+
|
|
580897
580983
|
//#endregion
|
|
580898
580984
|
//#region src/utils/heteroSteer.ts
|
|
580899
580985
|
/** The prompt a follow-up is typed in as: its text, then its images as image blocks. */
|
|
@@ -580913,6 +580999,9 @@ const buildSteerPrompt = (message) => {
|
|
|
580913
580999
|
}))];
|
|
580914
581000
|
};
|
|
580915
581001
|
const RETRY_MS = 2e3;
|
|
581002
|
+
const REPORT_ATTEMPTS = 3;
|
|
581003
|
+
/** How long the end of a run waits for control handlers still running. */
|
|
581004
|
+
const CONTROL_SETTLE_MS = 1e4;
|
|
580916
581005
|
/** The server predates steer delivery, or refuses it for this run: stop asking. */
|
|
580917
581006
|
const isPermanentRefusal = (error) => {
|
|
580918
581007
|
const code = error?.data?.code;
|
|
@@ -580933,6 +581022,12 @@ const isMainStreamStart = (event) => event.type === "stream_start" && !event.dat
|
|
|
580933
581022
|
* Once the server answered, the next main `stream_start` carries `liveSteer`
|
|
580934
581023
|
* so the client knows the run's queue no longer waits for the run to end.
|
|
580935
581024
|
*
|
|
581025
|
+
* The same poll carries the server's control messages (`acceptsControl`):
|
|
581026
|
+
* each goes to its handler in the `heteroControl` registry, which can write
|
|
581027
|
+
* control requests into the session, and its outcome goes back with
|
|
581028
|
+
* `aiAgent.reportHeteroControlResult`. A child run takes no follow-ups, but
|
|
581029
|
+
* keeps polling for control messages when the server delivers them.
|
|
581030
|
+
*
|
|
580936
581031
|
* Without a server context or a live session, events pass through unchanged.
|
|
580937
581032
|
*/
|
|
580938
581033
|
async function* withHeteroSteer(handle, context) {
|
|
@@ -580942,26 +581037,59 @@ async function* withHeteroSteer(handle, context) {
|
|
|
580942
581037
|
return;
|
|
580943
581038
|
}
|
|
580944
581039
|
const { operationId } = context;
|
|
581040
|
+
const sendControlRequest = handle.sendControlRequest;
|
|
580945
581041
|
const delivered = /* @__PURE__ */ new Set();
|
|
580946
581042
|
const abort = new AbortController();
|
|
581043
|
+
const handling = /* @__PURE__ */ new Set();
|
|
581044
|
+
let answered = false;
|
|
580947
581045
|
let supported = false;
|
|
580948
581046
|
let markedLive = false;
|
|
581047
|
+
const report = async (client, control, outcome) => {
|
|
581048
|
+
const reportResult = client.aiAgent.reportHeteroControlResult;
|
|
581049
|
+
if (!reportResult) return;
|
|
581050
|
+
for (let attempt = 1;; attempt++) try {
|
|
581051
|
+
await reportResult.mutate({
|
|
581052
|
+
controlId: control.id,
|
|
581053
|
+
operationId,
|
|
581054
|
+
...outcome
|
|
581055
|
+
});
|
|
581056
|
+
return;
|
|
581057
|
+
} catch (error) {
|
|
581058
|
+
if (isPermanentRefusal(error) || attempt >= REPORT_ATTEMPTS) {
|
|
581059
|
+
log$13.debug("Reporting control %s failed: %s", control.id, String(error));
|
|
581060
|
+
return;
|
|
581061
|
+
}
|
|
581062
|
+
await new Promise((resolve) => setTimeout(resolve, RETRY_MS));
|
|
581063
|
+
}
|
|
581064
|
+
};
|
|
581065
|
+
const handleControl = (client, control) => {
|
|
581066
|
+
const task = (async () => {
|
|
581067
|
+
log$13.debug("Control %s: %s", control.id, control.command);
|
|
581068
|
+
await report(client, control, await dispatchHeteroControl(control, {
|
|
581069
|
+
operationId,
|
|
581070
|
+
sendControlRequest,
|
|
581071
|
+
signal: abort.signal
|
|
581072
|
+
}));
|
|
581073
|
+
})().catch((error) => log$13.debug("Control %s failed: %s", control.id, String(error))).finally(() => handling.delete(task));
|
|
581074
|
+
handling.add(task);
|
|
581075
|
+
};
|
|
580949
581076
|
const poll = async () => {
|
|
580950
581077
|
const client = await context.getTrpcClient();
|
|
581078
|
+
const acceptsControl = !!sendControlRequest && !!client.aiAgent.reportHeteroControlResult;
|
|
580951
581079
|
while (!abort.signal.aborted) {
|
|
580952
581080
|
let message;
|
|
580953
581081
|
try {
|
|
580954
|
-
const res = await client.aiAgent.waitHeteroSteer.mutate(
|
|
581082
|
+
const res = await client.aiAgent.waitHeteroSteer.mutate({
|
|
581083
|
+
...acceptsControl && { acceptsControl: true },
|
|
580955
581084
|
acceptsImages: true,
|
|
580956
|
-
|
|
580957
|
-
} : {
|
|
580958
|
-
acceptsImages: true,
|
|
580959
|
-
blockMs: 1,
|
|
581085
|
+
...!answered && { blockMs: 1 },
|
|
580960
581086
|
operationId
|
|
580961
581087
|
}, { signal: abort.signal });
|
|
580962
|
-
if (res.steerable === false) return;
|
|
581088
|
+
if (res.steerable === false && !(acceptsControl && res.control !== void 0)) return;
|
|
581089
|
+
answered = true;
|
|
581090
|
+
if (res.steerable !== false) supported = true;
|
|
581091
|
+
if (res.control) handleControl(client, res.control);
|
|
580963
581092
|
message = res.message;
|
|
580964
|
-
supported = true;
|
|
580965
581093
|
} catch (error) {
|
|
580966
581094
|
if (abort.signal.aborted) return;
|
|
580967
581095
|
if (isPermanentRefusal(error)) {
|
|
@@ -581012,6 +581140,14 @@ async function* withHeteroSteer(handle, context) {
|
|
|
581012
581140
|
} finally {
|
|
581013
581141
|
abort.abort();
|
|
581014
581142
|
await polling;
|
|
581143
|
+
if (handling.size > 0) {
|
|
581144
|
+
let timer;
|
|
581145
|
+
await Promise.race([Promise.all(handling), new Promise((resolve) => {
|
|
581146
|
+
timer = setTimeout(resolve, CONTROL_SETTLE_MS);
|
|
581147
|
+
timer.unref?.();
|
|
581148
|
+
})]);
|
|
581149
|
+
clearTimeout(timer);
|
|
581150
|
+
}
|
|
581015
581151
|
}
|
|
581016
581152
|
}
|
|
581017
581153
|
|