create-expert 0.0.39 → 0.0.40
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/bin/cli.js +2214 -599
- package/dist/bin/cli.js.map +1 -1
- package/dist/{devtools-DaNYFZHF.js → devtools-BW4iRMC0.js} +3 -3
- package/dist/{devtools-DaNYFZHF.js.map → devtools-BW4iRMC0.js.map} +1 -1
- package/dist/{from-D01OR38y.js → from-CYPG0_GG.js} +2 -2
- package/dist/{from-D01OR38y.js.map → from-CYPG0_GG.js.map} +1 -1
- package/dist/{multipart-parser-DR1odBAg.js → multipart-parser-B4-GAe3j.js} +2 -2
- package/dist/{multipart-parser-DR1odBAg.js.map → multipart-parser-B4-GAe3j.js.map} +1 -1
- package/dist/perstack.toml +224 -116
- package/dist/{resolve-expert-CTnETi9d.js → resolve-expert-Circ5eKU.js} +249 -194
- package/dist/resolve-expert-Circ5eKU.js.map +1 -0
- package/dist/{src-C0pz_C3h.js → src-Ct-kpNVU.js} +109 -22
- package/dist/src-Ct-kpNVU.js.map +1 -0
- package/dist/{src-AFNJ8T_q.js → src-gAwrRWVD.js} +3 -3
- package/dist/{src-AFNJ8T_q.js.map → src-gAwrRWVD.js.map} +1 -1
- package/package.json +6 -6
- package/dist/resolve-expert-CTnETi9d.js.map +0 -1
- package/dist/src-C0pz_C3h.js.map +0 -1
package/dist/bin/cli.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { a as __toCommonJS, i as __require, n as __esmMin, o as __toESM, r as __exportAll, t as __commonJSMin } from "../chunk-D_gEzPfs.js";
|
|
3
|
-
import { $ as
|
|
3
|
+
import { $ as any, A as perstackConfigSchema, At as safeParseAsync$1, Bt as createId, C as startGeneration, Ct as describe$1, D as stopRunByInteractiveTool, Dt as parse$1, E as stopRunByError, Et as $ZodType, F as validateDelegation, Ft as NEVER, I as checkpointSchema, It as knownModels, J as ZodOptional$1, K as number$1, Lt as PerstackError, M as jobSchema, Mt as defineLazy, N as expertSchema, Nt as normalizeParams, O as runCommandInputSchema, Ot as parseAsync, P as isCoordinatorExpert, Pt as $constructor, Rt as defaultMaxRetries, S as skipDelegates, St as toJSONSchema, T as stopRunByDelegate, Tt as $ZodObject, X as _instanceof, Y as _enum, Z as _null, _ as resolveToolResults, _t as union, a as BASE_SKILL_PREFIX, at as lazy, b as runParamsSchema, bt as safeParseAsync$2, c as callTools, ct as never, d as createRuntimeEvent, dt as optional, et as array$1, f as createStreamingEvent, ft as preprocess, g as proceedToInteractiveTools, gt as tuple, h as parseExpertKey, ht as string, i as getFilteredEnv, it as intersection, j as lockfileSchema, jt as clone, k as startCommandInputSchema, kt as safeParse$1, l as completeRun, lt as number, m as finishToolCall, mt as strictObject, n as createFilteredEventListener, nt as custom, o as createBaseToolActivity, ot as literal, p as finishMcpTools, pt as record, q as ZodIssueCode$1, r as validateEventFilter, rt as discriminatedUnion, s as createGeneralToolActivity, st as looseObject, t as parseWithFriendlyError, tt as boolean, u as continueToNextStep, ut as object$2, v as resumeFromStop, vt as unknown, w as startRun, wt as meta$1, x as runSettingSchema, xt as datetime, y as retry, yt as url, zt as defaultTimeout } from "../src-Ct-kpNVU.js";
|
|
4
4
|
import { t as require_token_error } from "../token-error-CfavTss_.js";
|
|
5
5
|
import * as fs$2 from "node:fs";
|
|
6
|
-
import fs, { existsSync, readFileSync, readdirSync, realpathSync } from "node:fs";
|
|
6
|
+
import fs, { existsSync, readFileSync, readdirSync, realpathSync, statSync } from "node:fs";
|
|
7
7
|
import fs$1, { constants, lstat, mkdir, open, readFile, stat, writeFile } from "node:fs/promises";
|
|
8
8
|
import path, { dirname, extname } from "node:path";
|
|
9
9
|
import os from "node:os";
|
|
@@ -16,26 +16,6 @@ import { Buffer as Buffer$1 } from "node:buffer";
|
|
|
16
16
|
import tty from "node:tty";
|
|
17
17
|
import { Command } from "commander";
|
|
18
18
|
|
|
19
|
-
//#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/compat.js
|
|
20
|
-
/** @deprecated Use the raw string literal codes instead, e.g. "invalid_type". */
|
|
21
|
-
const ZodIssueCode$1 = {
|
|
22
|
-
invalid_type: "invalid_type",
|
|
23
|
-
too_big: "too_big",
|
|
24
|
-
too_small: "too_small",
|
|
25
|
-
invalid_format: "invalid_format",
|
|
26
|
-
not_multiple_of: "not_multiple_of",
|
|
27
|
-
unrecognized_keys: "unrecognized_keys",
|
|
28
|
-
invalid_union: "invalid_union",
|
|
29
|
-
invalid_key: "invalid_key",
|
|
30
|
-
invalid_element: "invalid_element",
|
|
31
|
-
invalid_value: "invalid_value",
|
|
32
|
-
custom: "custom"
|
|
33
|
-
};
|
|
34
|
-
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
|
|
35
|
-
var ZodFirstPartyTypeKind$1;
|
|
36
|
-
(function(ZodFirstPartyTypeKind) {})(ZodFirstPartyTypeKind$1 || (ZodFirstPartyTypeKind$1 = {}));
|
|
37
|
-
|
|
38
|
-
//#endregion
|
|
39
19
|
//#region ../../node_modules/.pnpm/smol-toml@1.6.0/node_modules/smol-toml/dist/error.js
|
|
40
20
|
/*!
|
|
41
21
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
@@ -1052,14 +1032,13 @@ function getAllJobs$1() {
|
|
|
1052
1032
|
}
|
|
1053
1033
|
return jobs.sort((a, b) => b.startedAt - a.startedAt);
|
|
1054
1034
|
}
|
|
1055
|
-
function createInitialJob(jobId, expertKey
|
|
1035
|
+
function createInitialJob(jobId, expertKey) {
|
|
1056
1036
|
return {
|
|
1057
1037
|
id: jobId,
|
|
1058
1038
|
status: "running",
|
|
1059
1039
|
coordinatorExpertKey: expertKey,
|
|
1060
1040
|
runtimeVersion: "v1.0",
|
|
1061
1041
|
totalSteps: 0,
|
|
1062
|
-
maxSteps,
|
|
1063
1042
|
usage: {
|
|
1064
1043
|
inputTokens: 0,
|
|
1065
1044
|
outputTokens: 0,
|
|
@@ -1099,7 +1078,15 @@ function getCheckpointsByJobId$1(jobId) {
|
|
|
1099
1078
|
const content = readFileSync(path.resolve(checkpointDir, file), "utf-8");
|
|
1100
1079
|
checkpoints.push(checkpointSchema.parse(JSON.parse(content)));
|
|
1101
1080
|
} catch {}
|
|
1102
|
-
return checkpoints.sort((a, b) =>
|
|
1081
|
+
return checkpoints.sort((a, b) => {
|
|
1082
|
+
try {
|
|
1083
|
+
const aStat = statSync(path.resolve(checkpointDir, `${a.id}.json`));
|
|
1084
|
+
const bStat = statSync(path.resolve(checkpointDir, `${b.id}.json`));
|
|
1085
|
+
return aStat.mtimeMs - bStat.mtimeMs;
|
|
1086
|
+
} catch {
|
|
1087
|
+
return 0;
|
|
1088
|
+
}
|
|
1089
|
+
});
|
|
1103
1090
|
}
|
|
1104
1091
|
|
|
1105
1092
|
//#endregion
|
|
@@ -16309,7 +16296,7 @@ const EMPTY_COMPLETION_RESULT = { completion: {
|
|
|
16309
16296
|
//#endregion
|
|
16310
16297
|
//#region ../base/package.json
|
|
16311
16298
|
var name$5 = "@perstack/base";
|
|
16312
|
-
var version$2 = "0.0.
|
|
16299
|
+
var version$2 = "0.0.64";
|
|
16313
16300
|
|
|
16314
16301
|
//#endregion
|
|
16315
16302
|
//#region ../base/src/tools/todo.ts
|
|
@@ -16387,8 +16374,8 @@ async function attemptCompletion() {
|
|
|
16387
16374
|
function registerAttemptCompletion(server) {
|
|
16388
16375
|
server.registerTool("attemptCompletion", {
|
|
16389
16376
|
title: "Attempt completion",
|
|
16390
|
-
description: "Signal task completion. Validates all todos are complete before ending.",
|
|
16391
|
-
inputSchema: {}
|
|
16377
|
+
description: "Signal task completion. Provide a result parameter with your final response text. Validates all todos are complete before ending.",
|
|
16378
|
+
inputSchema: object$2({ result: string().optional() }).strict()
|
|
16392
16379
|
}, async () => {
|
|
16393
16380
|
try {
|
|
16394
16381
|
return successToolResult(await attemptCompletion());
|
|
@@ -16757,12 +16744,30 @@ function registerCreateExpert(server, callbacks) {
|
|
|
16757
16744
|
}
|
|
16758
16745
|
});
|
|
16759
16746
|
}
|
|
16747
|
+
function registerAddDelegateFromConfig(server, callbacks) {
|
|
16748
|
+
server.registerTool("addDelegateFromConfig", {
|
|
16749
|
+
title: "Add delegate from config",
|
|
16750
|
+
description: "Load all experts from a perstack.toml config file and add the specified one as a delegate. This is a shortcut that combines reading the config, creating the expert, and adding it as a delegate in a single step.",
|
|
16751
|
+
inputSchema: {
|
|
16752
|
+
configPath: string().describe("Path to the perstack.toml config file"),
|
|
16753
|
+
delegateExpertName: string().describe("Name of the expert in the config to add as a delegate")
|
|
16754
|
+
}
|
|
16755
|
+
}, async (input) => {
|
|
16756
|
+
try {
|
|
16757
|
+
return successToolResult(await callbacks.addDelegateFromConfig(input));
|
|
16758
|
+
} catch (e) {
|
|
16759
|
+
if (e instanceof Error) return errorToolResult(e);
|
|
16760
|
+
throw e;
|
|
16761
|
+
}
|
|
16762
|
+
});
|
|
16763
|
+
}
|
|
16760
16764
|
function registerSkillManagementTools(server, callbacks) {
|
|
16761
16765
|
registerAddSkill(server, callbacks);
|
|
16762
16766
|
registerRemoveSkill(server, callbacks);
|
|
16763
16767
|
registerAddDelegate(server, callbacks);
|
|
16764
16768
|
registerRemoveDelegate(server, callbacks);
|
|
16765
16769
|
registerCreateExpert(server, callbacks);
|
|
16770
|
+
registerAddDelegateFromConfig(server, callbacks);
|
|
16766
16771
|
}
|
|
16767
16772
|
|
|
16768
16773
|
//#endregion
|
|
@@ -19207,6 +19212,9 @@ var InMemoryBaseSkillAdapter = class extends SkillAdapter {
|
|
|
19207
19212
|
},
|
|
19208
19213
|
createExpert: () => {
|
|
19209
19214
|
throw new Error("Skill management not initialized");
|
|
19215
|
+
},
|
|
19216
|
+
addDelegateFromConfig: () => {
|
|
19217
|
+
throw new Error("Skill management not initialized");
|
|
19210
19218
|
}
|
|
19211
19219
|
};
|
|
19212
19220
|
constructor(skill, onLifecycleEvent, options) {
|
|
@@ -19747,6 +19755,8 @@ var SkillManager = class SkillManager {
|
|
|
19747
19755
|
},
|
|
19748
19756
|
removeSkill: (name) => sm.removeSkill(name),
|
|
19749
19757
|
addDelegate: async (key) => {
|
|
19758
|
+
const delegationError = validateDelegation(expert.name, key);
|
|
19759
|
+
if (delegationError) throw new Error(delegationError);
|
|
19750
19760
|
const delegateExpert = experts[key];
|
|
19751
19761
|
if (!delegateExpert) throw new Error(`Expert "${key}" not found`);
|
|
19752
19762
|
await sm.addDelegate(delegateExpert);
|
|
@@ -19785,6 +19795,32 @@ var SkillManager = class SkillManager {
|
|
|
19785
19795
|
});
|
|
19786
19796
|
experts[newExpert.key] = newExpert;
|
|
19787
19797
|
return { expertKey: newExpert.key };
|
|
19798
|
+
},
|
|
19799
|
+
addDelegateFromConfig: async (input) => {
|
|
19800
|
+
const config = parsePerstackConfig(await readFile(input.configPath, "utf-8"));
|
|
19801
|
+
for (const [key, configExpert] of Object.entries(config.experts ?? {})) if (!experts[key]) experts[key] = expertSchema.parse({
|
|
19802
|
+
key,
|
|
19803
|
+
name: key,
|
|
19804
|
+
version: configExpert.version ?? "1.0.0",
|
|
19805
|
+
description: configExpert.description,
|
|
19806
|
+
instruction: configExpert.instruction,
|
|
19807
|
+
skills: configExpert.skills,
|
|
19808
|
+
delegates: configExpert.delegates,
|
|
19809
|
+
tags: configExpert.tags,
|
|
19810
|
+
providerTools: configExpert.providerTools,
|
|
19811
|
+
providerSkills: configExpert.providerSkills,
|
|
19812
|
+
providerToolOptions: configExpert.providerToolOptions
|
|
19813
|
+
});
|
|
19814
|
+
const delegateExpert = experts[input.delegateExpertName];
|
|
19815
|
+
if (!delegateExpert) {
|
|
19816
|
+
const validKeys = Object.keys(config.experts ?? {}).filter((key) => !validateDelegation(expert.name, key));
|
|
19817
|
+
throw new Error(`Expert "${input.delegateExpertName}" not found in config "${input.configPath}". Available experts that "${expert.name}" can delegate to: ${validKeys.join(", ")}`);
|
|
19818
|
+
}
|
|
19819
|
+
const delegationError = validateDelegation(expert.name, input.delegateExpertName);
|
|
19820
|
+
if (delegationError) throw new Error(delegationError);
|
|
19821
|
+
await sm.addDelegate(delegateExpert);
|
|
19822
|
+
if (!expert.delegates.includes(input.delegateExpertName)) expert.delegates.push(input.delegateExpertName);
|
|
19823
|
+
return { delegateToolName: sm.getAdapters().get(delegateExpert.name)?.getToolDefinitions()[0]?.name ?? delegateExpert.name };
|
|
19788
19824
|
}
|
|
19789
19825
|
});
|
|
19790
19826
|
break;
|
|
@@ -19939,7 +19975,7 @@ var SkillManager = class SkillManager {
|
|
|
19939
19975
|
|
|
19940
19976
|
//#endregion
|
|
19941
19977
|
//#region ../../packages/runtime/package.json
|
|
19942
|
-
var version$1 = "0.0.
|
|
19978
|
+
var version$1 = "0.0.113";
|
|
19943
19979
|
|
|
19944
19980
|
//#endregion
|
|
19945
19981
|
//#region ../../packages/runtime/src/helpers/usage.ts
|
|
@@ -19991,12 +20027,12 @@ function createInitialCheckpoint(checkpointId, params) {
|
|
|
19991
20027
|
contextWindowUsage: params.contextWindow ? 0 : void 0
|
|
19992
20028
|
};
|
|
19993
20029
|
}
|
|
19994
|
-
function
|
|
20030
|
+
function createRunStartCheckpoint(checkpointId, checkpoint, runId) {
|
|
19995
20031
|
return {
|
|
19996
20032
|
...checkpoint,
|
|
19997
20033
|
id: checkpointId,
|
|
19998
20034
|
runId,
|
|
19999
|
-
stepNumber:
|
|
20035
|
+
stepNumber: 1
|
|
20000
20036
|
};
|
|
20001
20037
|
}
|
|
20002
20038
|
function buildDelegationReturnState(currentSetting, resultCheckpoint, parentCheckpoint) {
|
|
@@ -20023,7 +20059,7 @@ function buildDelegationReturnState(currentSetting, resultCheckpoint, parentChec
|
|
|
20023
20059
|
checkpoint: {
|
|
20024
20060
|
...parentCheckpoint,
|
|
20025
20061
|
runId: newRunId,
|
|
20026
|
-
stepNumber:
|
|
20062
|
+
stepNumber: 1,
|
|
20027
20063
|
usage: resultCheckpoint.usage,
|
|
20028
20064
|
pendingToolCalls: parentCheckpoint.pendingToolCalls,
|
|
20029
20065
|
partialToolResults: parentCheckpoint.partialToolResults
|
|
@@ -22149,7 +22185,7 @@ async function* executeTool({ execute, input, options }) {
|
|
|
22149
22185
|
}
|
|
22150
22186
|
|
|
22151
22187
|
//#endregion
|
|
22152
|
-
//#region ../../node_modules/.pnpm/@ai-sdk+anthropic@3.0.
|
|
22188
|
+
//#region ../../node_modules/.pnpm/@ai-sdk+anthropic@3.0.46_zod@4.3.6/node_modules/@ai-sdk/anthropic/dist/internal/index.mjs
|
|
22153
22189
|
var anthropicFailedResponseHandler$1 = createJsonErrorResponseHandler({
|
|
22154
22190
|
errorSchema: lazySchema(() => zodSchema(object$2({
|
|
22155
22191
|
type: literal("error"),
|
|
@@ -22617,7 +22653,7 @@ var anthropicMessagesChunkSchema$1 = lazySchema(() => zodSchema(discriminatedUni
|
|
|
22617
22653
|
}),
|
|
22618
22654
|
object$2({
|
|
22619
22655
|
type: literal("compaction_delta"),
|
|
22620
|
-
content: string()
|
|
22656
|
+
content: string().nullish()
|
|
22621
22657
|
}),
|
|
22622
22658
|
object$2({
|
|
22623
22659
|
type: literal("citations_delta"),
|
|
@@ -25281,7 +25317,7 @@ function guessServiceRegion(url, headers) {
|
|
|
25281
25317
|
}
|
|
25282
25318
|
|
|
25283
25319
|
//#endregion
|
|
25284
|
-
//#region ../../node_modules/.pnpm/@ai-sdk+amazon-bedrock@4.0.
|
|
25320
|
+
//#region ../../node_modules/.pnpm/@ai-sdk+amazon-bedrock@4.0.62_zod@4.3.6/node_modules/@ai-sdk/amazon-bedrock/dist/index.mjs
|
|
25285
25321
|
var BEDROCK_STOP_REASONS = [
|
|
25286
25322
|
"stop",
|
|
25287
25323
|
"stop_sequence",
|
|
@@ -26681,7 +26717,7 @@ var bedrockImageResponseSchema = object$2({
|
|
|
26681
26717
|
details: record(string(), unknown()).optional(),
|
|
26682
26718
|
preview: unknown().optional()
|
|
26683
26719
|
});
|
|
26684
|
-
var VERSION$9 = "4.0.
|
|
26720
|
+
var VERSION$9 = "4.0.62";
|
|
26685
26721
|
function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
|
|
26686
26722
|
return async (input, init) => {
|
|
26687
26723
|
var _a, _b;
|
|
@@ -26927,8 +26963,8 @@ Original error: ${errorMessage}`);
|
|
|
26927
26963
|
var bedrock = createAmazonBedrock();
|
|
26928
26964
|
|
|
26929
26965
|
//#endregion
|
|
26930
|
-
//#region ../../node_modules/.pnpm/@ai-sdk+anthropic@3.0.
|
|
26931
|
-
var VERSION$8 = "3.0.
|
|
26966
|
+
//#region ../../node_modules/.pnpm/@ai-sdk+anthropic@3.0.46_zod@4.3.6/node_modules/@ai-sdk/anthropic/dist/index.mjs
|
|
26967
|
+
var VERSION$8 = "3.0.46";
|
|
26932
26968
|
var anthropicFailedResponseHandler = createJsonErrorResponseHandler({
|
|
26933
26969
|
errorSchema: lazySchema(() => zodSchema(object$2({
|
|
26934
26970
|
type: literal("error"),
|
|
@@ -27396,7 +27432,7 @@ var anthropicMessagesChunkSchema = lazySchema(() => zodSchema(discriminatedUnion
|
|
|
27396
27432
|
}),
|
|
27397
27433
|
object$2({
|
|
27398
27434
|
type: literal("compaction_delta"),
|
|
27399
|
-
content: string()
|
|
27435
|
+
content: string().nullish()
|
|
27400
27436
|
}),
|
|
27401
27437
|
object$2({
|
|
27402
27438
|
type: literal("citations_delta"),
|
|
@@ -29928,7 +29964,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
29928
29964
|
});
|
|
29929
29965
|
return;
|
|
29930
29966
|
case "compaction_delta":
|
|
29931
|
-
controller.enqueue({
|
|
29967
|
+
if (value.delta.content != null) controller.enqueue({
|
|
29932
29968
|
type: "text-delta",
|
|
29933
29969
|
id: String(value.index),
|
|
29934
29970
|
delta: value.delta.content
|
|
@@ -35887,8 +35923,8 @@ function createDeepSeek(options = {}) {
|
|
|
35887
35923
|
var deepseek = createDeepSeek();
|
|
35888
35924
|
|
|
35889
35925
|
//#endregion
|
|
35890
|
-
//#region ../../node_modules/.pnpm/@ai-sdk+google@3.0.
|
|
35891
|
-
var VERSION$5 = "3.0.
|
|
35926
|
+
//#region ../../node_modules/.pnpm/@ai-sdk+google@3.0.30_zod@4.3.6/node_modules/@ai-sdk/google/dist/index.mjs
|
|
35927
|
+
var VERSION$5 = "3.0.30";
|
|
35892
35928
|
var googleFailedResponseHandler$1 = createJsonErrorResponseHandler({
|
|
35893
35929
|
errorSchema: lazySchema(() => zodSchema(object$2({ error: object$2({
|
|
35894
35930
|
code: number().nullable(),
|
|
@@ -38320,7 +38356,7 @@ var require_gaxios = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
38320
38356
|
}
|
|
38321
38357
|
static async #getFetch() {
|
|
38322
38358
|
const hasWindow = typeof window !== "undefined" && !!window;
|
|
38323
|
-
this.#fetch ||= hasWindow ? window.fetch : (await import("../src-
|
|
38359
|
+
this.#fetch ||= hasWindow ? window.fetch : (await import("../src-gAwrRWVD.js")).default;
|
|
38324
38360
|
return this.#fetch;
|
|
38325
38361
|
}
|
|
38326
38362
|
/**
|
|
@@ -47468,7 +47504,7 @@ var require_src = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
47468
47504
|
}));
|
|
47469
47505
|
|
|
47470
47506
|
//#endregion
|
|
47471
|
-
//#region ../../node_modules/.pnpm/@ai-sdk+google@3.0.
|
|
47507
|
+
//#region ../../node_modules/.pnpm/@ai-sdk+google@3.0.30_zod@4.3.6/node_modules/@ai-sdk/google/dist/internal/index.mjs
|
|
47472
47508
|
var import_src = require_src();
|
|
47473
47509
|
function convertGoogleGenerativeAIUsage(usage) {
|
|
47474
47510
|
var _a, _b, _c, _d;
|
|
@@ -48572,7 +48608,7 @@ var googleTools = {
|
|
|
48572
48608
|
};
|
|
48573
48609
|
|
|
48574
48610
|
//#endregion
|
|
48575
|
-
//#region ../../node_modules/.pnpm/@ai-sdk+google-vertex@4.0.
|
|
48611
|
+
//#region ../../node_modules/.pnpm/@ai-sdk+google-vertex@4.0.61_zod@4.3.6/node_modules/@ai-sdk/google-vertex/dist/index.mjs
|
|
48576
48612
|
var authInstance = null;
|
|
48577
48613
|
var authOptions = null;
|
|
48578
48614
|
function getAuth(options) {
|
|
@@ -48589,7 +48625,7 @@ async function generateAuthToken(options) {
|
|
|
48589
48625
|
const token = await (await getAuth(options || {}).getClient()).getAccessToken();
|
|
48590
48626
|
return (token == null ? void 0 : token.token) || null;
|
|
48591
48627
|
}
|
|
48592
|
-
var VERSION$4 = "4.0.
|
|
48628
|
+
var VERSION$4 = "4.0.61";
|
|
48593
48629
|
var googleVertexFailedResponseHandler = createJsonErrorResponseHandler({
|
|
48594
48630
|
errorSchema: object$2({ error: object$2({
|
|
48595
48631
|
code: number().nullable(),
|
|
@@ -53918,7 +53954,7 @@ function createOpenAI(options = {}) {
|
|
|
53918
53954
|
var openai = createOpenAI();
|
|
53919
53955
|
|
|
53920
53956
|
//#endregion
|
|
53921
|
-
//#region ../../node_modules/.pnpm/ollama-ai-provider-v2@3.3.1_ai@6.0.
|
|
53957
|
+
//#region ../../node_modules/.pnpm/ollama-ai-provider-v2@3.3.1_ai@6.0.94_zod@4.3.6__zod@4.3.6/node_modules/ollama-ai-provider-v2/dist/index.mjs
|
|
53922
53958
|
function convertToOllamaCompletionPrompt({ prompt, user = "user", assistant = "assistant" }) {
|
|
53923
53959
|
let text = "";
|
|
53924
53960
|
if (prompt[0].role === "system") {
|
|
@@ -75899,7 +75935,7 @@ function validateRuntimeVersion(experts) {
|
|
|
75899
75935
|
//#endregion
|
|
75900
75936
|
//#region ../../packages/runtime/src/helpers/setup-experts.ts
|
|
75901
75937
|
async function setupExperts(setting, resolveExpertToRun) {
|
|
75902
|
-
const resolveFn = resolveExpertToRun ?? (await import("../resolve-expert-
|
|
75938
|
+
const resolveFn = resolveExpertToRun ?? (await import("../resolve-expert-Circ5eKU.js")).resolveExpertToRun;
|
|
75903
75939
|
const { expertKey } = setting;
|
|
75904
75940
|
const experts = { ...setting.experts };
|
|
75905
75941
|
const clientOptions = {
|
|
@@ -76202,7 +76238,7 @@ var require_dist$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
76202
76238
|
}));
|
|
76203
76239
|
|
|
76204
76240
|
//#endregion
|
|
76205
|
-
//#region ../../node_modules/.pnpm/@ai-sdk+gateway@3.0.
|
|
76241
|
+
//#region ../../node_modules/.pnpm/@ai-sdk+gateway@3.0.52_zod@4.3.6/node_modules/@ai-sdk/gateway/dist/index.mjs
|
|
76206
76242
|
var import_dist$1 = require_dist$1();
|
|
76207
76243
|
var symbol$1 = Symbol.for("vercel.ai.gateway.error");
|
|
76208
76244
|
var _a$1, _b;
|
|
@@ -77086,7 +77122,7 @@ async function getVercelRequestId() {
|
|
|
77086
77122
|
var _a9;
|
|
77087
77123
|
return (_a9 = (0, import_dist$1.getContext)().headers) == null ? void 0 : _a9["x-vercel-id"];
|
|
77088
77124
|
}
|
|
77089
|
-
var VERSION$2 = "3.0.
|
|
77125
|
+
var VERSION$2 = "3.0.52";
|
|
77090
77126
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
77091
77127
|
function createGatewayProvider(options = {}) {
|
|
77092
77128
|
var _a9, _b9;
|
|
@@ -78107,7 +78143,7 @@ var TraceAPI = function() {
|
|
|
78107
78143
|
var trace = TraceAPI.getInstance();
|
|
78108
78144
|
|
|
78109
78145
|
//#endregion
|
|
78110
|
-
//#region ../../node_modules/.pnpm/ai@6.0.
|
|
78146
|
+
//#region ../../node_modules/.pnpm/ai@6.0.94_zod@4.3.6/node_modules/ai/dist/index.mjs
|
|
78111
78147
|
var __defProp = Object.defineProperty;
|
|
78112
78148
|
var __export = (target, all) => {
|
|
78113
78149
|
for (var name21 in all) __defProp(target, name21, {
|
|
@@ -78643,7 +78679,7 @@ function detectMediaType({ data, signatures }) {
|
|
|
78643
78679
|
const bytes = typeof processedData === "string" ? convertBase64ToUint8Array(processedData.substring(0, Math.min(processedData.length, 24))) : processedData;
|
|
78644
78680
|
for (const signature of signatures) if (bytes.length >= signature.bytesPrefix.length && signature.bytesPrefix.every((byte, index) => byte === null || bytes[index] === byte)) return signature.mediaType;
|
|
78645
78681
|
}
|
|
78646
|
-
var VERSION = "6.0.
|
|
78682
|
+
var VERSION = "6.0.94";
|
|
78647
78683
|
var download = async ({ url, maxBytes, abortSignal }) => {
|
|
78648
78684
|
var _a21;
|
|
78649
78685
|
const urlText = url.toString();
|
|
@@ -79696,7 +79732,11 @@ function collectToolApprovals({ messages }) {
|
|
|
79696
79732
|
deniedToolApprovals
|
|
79697
79733
|
};
|
|
79698
79734
|
}
|
|
79699
|
-
|
|
79735
|
+
function now() {
|
|
79736
|
+
var _a21, _b;
|
|
79737
|
+
return (_b = (_a21 = globalThis == null ? void 0 : globalThis.performance) == null ? void 0 : _a21.now()) != null ? _b : Date.now();
|
|
79738
|
+
}
|
|
79739
|
+
async function executeToolCall({ toolCall, tools, tracer, telemetry, messages, abortSignal, experimental_context, stepNumber, model, onPreliminaryToolResult, onToolCallStart, onToolCallFinish }) {
|
|
79700
79740
|
const { toolName, toolCallId, input } = toolCall;
|
|
79701
79741
|
const tool2 = tools == null ? void 0 : tools[toolName];
|
|
79702
79742
|
if ((tool2 == null ? void 0 : tool2.execute) == null) return;
|
|
@@ -79717,6 +79757,19 @@ async function executeToolCall({ toolCall, tools, tracer, telemetry, messages, a
|
|
|
79717
79757
|
tracer,
|
|
79718
79758
|
fn: async (span) => {
|
|
79719
79759
|
let output;
|
|
79760
|
+
try {
|
|
79761
|
+
await (onToolCallStart == null ? void 0 : onToolCallStart({
|
|
79762
|
+
stepNumber,
|
|
79763
|
+
model,
|
|
79764
|
+
toolCall,
|
|
79765
|
+
messages,
|
|
79766
|
+
abortSignal,
|
|
79767
|
+
functionId: telemetry == null ? void 0 : telemetry.functionId,
|
|
79768
|
+
metadata: telemetry == null ? void 0 : telemetry.metadata,
|
|
79769
|
+
experimental_context
|
|
79770
|
+
}));
|
|
79771
|
+
} catch (_ignored) {}
|
|
79772
|
+
const startTime = now();
|
|
79720
79773
|
try {
|
|
79721
79774
|
const stream = executeTool({
|
|
79722
79775
|
execute: tool2.execute.bind(tool2),
|
|
@@ -79736,6 +79789,22 @@ async function executeToolCall({ toolCall, tools, tracer, telemetry, messages, a
|
|
|
79736
79789
|
});
|
|
79737
79790
|
else output = part.output;
|
|
79738
79791
|
} catch (error) {
|
|
79792
|
+
const durationMs2 = now() - startTime;
|
|
79793
|
+
try {
|
|
79794
|
+
await (onToolCallFinish == null ? void 0 : onToolCallFinish({
|
|
79795
|
+
stepNumber,
|
|
79796
|
+
model,
|
|
79797
|
+
toolCall,
|
|
79798
|
+
messages,
|
|
79799
|
+
abortSignal,
|
|
79800
|
+
success: false,
|
|
79801
|
+
error,
|
|
79802
|
+
durationMs: durationMs2,
|
|
79803
|
+
functionId: telemetry == null ? void 0 : telemetry.functionId,
|
|
79804
|
+
metadata: telemetry == null ? void 0 : telemetry.metadata,
|
|
79805
|
+
experimental_context
|
|
79806
|
+
}));
|
|
79807
|
+
} catch (_ignored) {}
|
|
79739
79808
|
recordErrorOnSpan(span, error);
|
|
79740
79809
|
return {
|
|
79741
79810
|
type: "tool-error",
|
|
@@ -79747,6 +79816,22 @@ async function executeToolCall({ toolCall, tools, tracer, telemetry, messages, a
|
|
|
79747
79816
|
...toolCall.providerMetadata != null ? { providerMetadata: toolCall.providerMetadata } : {}
|
|
79748
79817
|
};
|
|
79749
79818
|
}
|
|
79819
|
+
const durationMs = now() - startTime;
|
|
79820
|
+
try {
|
|
79821
|
+
await (onToolCallFinish == null ? void 0 : onToolCallFinish({
|
|
79822
|
+
stepNumber,
|
|
79823
|
+
model,
|
|
79824
|
+
toolCall,
|
|
79825
|
+
messages,
|
|
79826
|
+
abortSignal,
|
|
79827
|
+
success: true,
|
|
79828
|
+
output,
|
|
79829
|
+
durationMs,
|
|
79830
|
+
functionId: telemetry == null ? void 0 : telemetry.functionId,
|
|
79831
|
+
metadata: telemetry == null ? void 0 : telemetry.metadata,
|
|
79832
|
+
experimental_context
|
|
79833
|
+
}));
|
|
79834
|
+
} catch (_ignored) {}
|
|
79750
79835
|
try {
|
|
79751
79836
|
span.setAttributes(await selectTelemetryAttributes({
|
|
79752
79837
|
telemetry,
|
|
@@ -80438,7 +80523,12 @@ async function doParseToolCall({ toolCall, tools }) {
|
|
|
80438
80523
|
};
|
|
80439
80524
|
}
|
|
80440
80525
|
var DefaultStepResult = class {
|
|
80441
|
-
constructor({ content, finishReason, rawFinishReason, usage, warnings, request, response, providerMetadata }) {
|
|
80526
|
+
constructor({ stepNumber, model, functionId, metadata, experimental_context, content, finishReason, rawFinishReason, usage, warnings, request, response, providerMetadata }) {
|
|
80527
|
+
this.stepNumber = stepNumber;
|
|
80528
|
+
this.model = model;
|
|
80529
|
+
this.functionId = functionId;
|
|
80530
|
+
this.metadata = metadata;
|
|
80531
|
+
this.experimental_context = experimental_context;
|
|
80442
80532
|
this.content = content;
|
|
80443
80533
|
this.finishReason = finishReason;
|
|
80444
80534
|
this.rawFinishReason = rawFinishReason;
|
|
@@ -80619,7 +80709,7 @@ var originalGenerateId = createIdGenerator({
|
|
|
80619
80709
|
prefix: "aitxt",
|
|
80620
80710
|
size: 24
|
|
80621
80711
|
});
|
|
80622
|
-
async function generateText({ model: modelArg, tools, toolChoice, system, prompt, messages, maxRetries: maxRetriesArg, abortSignal, timeout, headers, stopWhen = stepCountIs(1), experimental_output, output = experimental_output, experimental_telemetry: telemetry, providerOptions, experimental_activeTools, activeTools = experimental_activeTools, experimental_prepareStep, prepareStep = experimental_prepareStep, experimental_repairToolCall: repairToolCall, experimental_download: download2, experimental_context, experimental_include: include, _internal: { generateId: generateId2 = originalGenerateId } = {}, onStepFinish, onFinish, ...settings }) {
|
|
80712
|
+
async function generateText({ model: modelArg, tools, toolChoice, system, prompt, messages, maxRetries: maxRetriesArg, abortSignal, timeout, headers, stopWhen = stepCountIs(1), experimental_output, output = experimental_output, experimental_telemetry: telemetry, providerOptions, experimental_activeTools, activeTools = experimental_activeTools, experimental_prepareStep, prepareStep = experimental_prepareStep, experimental_repairToolCall: repairToolCall, experimental_download: download2, experimental_context, experimental_include: include, _internal: { generateId: generateId2 = originalGenerateId } = {}, experimental_onStart: onStart, experimental_onStepStart: onStepStart, experimental_onToolCallStart: onToolCallStart, experimental_onToolCallFinish: onToolCallFinish, onStepFinish, onFinish, ...settings }) {
|
|
80623
80713
|
const model = resolveLanguageModel(modelArg);
|
|
80624
80714
|
const stopConditions = asArray(stopWhen);
|
|
80625
80715
|
const totalTimeoutMs = getTotalTimeoutMs(timeout);
|
|
@@ -80646,6 +80736,39 @@ async function generateText({ model: modelArg, tools, toolChoice, system, prompt
|
|
|
80646
80736
|
prompt,
|
|
80647
80737
|
messages
|
|
80648
80738
|
});
|
|
80739
|
+
try {
|
|
80740
|
+
await (onStart == null ? void 0 : onStart({
|
|
80741
|
+
model: {
|
|
80742
|
+
provider: model.provider,
|
|
80743
|
+
modelId: model.modelId
|
|
80744
|
+
},
|
|
80745
|
+
system,
|
|
80746
|
+
prompt,
|
|
80747
|
+
messages,
|
|
80748
|
+
tools,
|
|
80749
|
+
toolChoice,
|
|
80750
|
+
activeTools,
|
|
80751
|
+
maxOutputTokens: callSettings.maxOutputTokens,
|
|
80752
|
+
temperature: callSettings.temperature,
|
|
80753
|
+
topP: callSettings.topP,
|
|
80754
|
+
topK: callSettings.topK,
|
|
80755
|
+
presencePenalty: callSettings.presencePenalty,
|
|
80756
|
+
frequencyPenalty: callSettings.frequencyPenalty,
|
|
80757
|
+
stopSequences: callSettings.stopSequences,
|
|
80758
|
+
seed: callSettings.seed,
|
|
80759
|
+
maxRetries,
|
|
80760
|
+
timeout,
|
|
80761
|
+
headers,
|
|
80762
|
+
providerOptions,
|
|
80763
|
+
stopWhen,
|
|
80764
|
+
output,
|
|
80765
|
+
abortSignal,
|
|
80766
|
+
include,
|
|
80767
|
+
functionId: telemetry == null ? void 0 : telemetry.functionId,
|
|
80768
|
+
metadata: telemetry == null ? void 0 : telemetry.metadata,
|
|
80769
|
+
experimental_context
|
|
80770
|
+
}));
|
|
80771
|
+
} catch (_ignored) {}
|
|
80649
80772
|
const tracer = getTracer(telemetry);
|
|
80650
80773
|
try {
|
|
80651
80774
|
return await recordSpan({
|
|
@@ -80669,7 +80792,7 @@ async function generateText({ model: modelArg, tools, toolChoice, system, prompt
|
|
|
80669
80792
|
}),
|
|
80670
80793
|
tracer,
|
|
80671
80794
|
fn: async (span) => {
|
|
80672
|
-
var _a21, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
80795
|
+
var _a21, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
80673
80796
|
const initialMessages = initialPrompt.messages;
|
|
80674
80797
|
const responseMessages = [];
|
|
80675
80798
|
const { approvedToolApprovals, deniedToolApprovals } = collectToolApprovals({ messages: initialMessages });
|
|
@@ -80682,7 +80805,14 @@ async function generateText({ model: modelArg, tools, toolChoice, system, prompt
|
|
|
80682
80805
|
telemetry,
|
|
80683
80806
|
messages: initialMessages,
|
|
80684
80807
|
abortSignal: mergedAbortSignal,
|
|
80685
|
-
experimental_context
|
|
80808
|
+
experimental_context,
|
|
80809
|
+
stepNumber: 0,
|
|
80810
|
+
model: {
|
|
80811
|
+
provider: model.provider,
|
|
80812
|
+
modelId: model.modelId
|
|
80813
|
+
},
|
|
80814
|
+
onToolCallStart,
|
|
80815
|
+
onToolCallFinish
|
|
80686
80816
|
});
|
|
80687
80817
|
const toolContent = [];
|
|
80688
80818
|
for (const output2 of toolOutputs) {
|
|
@@ -80753,11 +80883,40 @@ async function generateText({ model: modelArg, tools, toolChoice, system, prompt
|
|
|
80753
80883
|
download: download2
|
|
80754
80884
|
});
|
|
80755
80885
|
experimental_context = (_d = prepareStepResult == null ? void 0 : prepareStepResult.experimental_context) != null ? _d : experimental_context;
|
|
80886
|
+
const stepActiveTools = (_e = prepareStepResult == null ? void 0 : prepareStepResult.activeTools) != null ? _e : activeTools;
|
|
80756
80887
|
const { toolChoice: stepToolChoice, tools: stepTools } = await prepareToolsAndToolChoice({
|
|
80757
80888
|
tools,
|
|
80758
|
-
toolChoice: (
|
|
80759
|
-
activeTools:
|
|
80889
|
+
toolChoice: (_f = prepareStepResult == null ? void 0 : prepareStepResult.toolChoice) != null ? _f : toolChoice,
|
|
80890
|
+
activeTools: stepActiveTools
|
|
80760
80891
|
});
|
|
80892
|
+
const stepMessages = (_g = prepareStepResult == null ? void 0 : prepareStepResult.messages) != null ? _g : stepInputMessages;
|
|
80893
|
+
const stepSystem = (_h = prepareStepResult == null ? void 0 : prepareStepResult.system) != null ? _h : initialPrompt.system;
|
|
80894
|
+
const stepProviderOptions = mergeObjects(providerOptions, prepareStepResult == null ? void 0 : prepareStepResult.providerOptions);
|
|
80895
|
+
try {
|
|
80896
|
+
await (onStepStart == null ? void 0 : onStepStart({
|
|
80897
|
+
stepNumber: steps.length,
|
|
80898
|
+
model: {
|
|
80899
|
+
provider: stepModel.provider,
|
|
80900
|
+
modelId: stepModel.modelId
|
|
80901
|
+
},
|
|
80902
|
+
system: stepSystem,
|
|
80903
|
+
messages: stepMessages,
|
|
80904
|
+
tools,
|
|
80905
|
+
toolChoice: stepToolChoice,
|
|
80906
|
+
activeTools: stepActiveTools,
|
|
80907
|
+
steps: [...steps],
|
|
80908
|
+
providerOptions: stepProviderOptions,
|
|
80909
|
+
timeout,
|
|
80910
|
+
headers,
|
|
80911
|
+
stopWhen,
|
|
80912
|
+
output,
|
|
80913
|
+
abortSignal,
|
|
80914
|
+
include,
|
|
80915
|
+
functionId: telemetry == null ? void 0 : telemetry.functionId,
|
|
80916
|
+
metadata: telemetry == null ? void 0 : telemetry.metadata,
|
|
80917
|
+
experimental_context
|
|
80918
|
+
}));
|
|
80919
|
+
} catch (_ignored) {}
|
|
80761
80920
|
currentModelResponse = await retry(() => {
|
|
80762
80921
|
var _a22;
|
|
80763
80922
|
return recordSpan({
|
|
@@ -80789,7 +80948,6 @@ async function generateText({ model: modelArg, tools, toolChoice, system, prompt
|
|
|
80789
80948
|
tracer,
|
|
80790
80949
|
fn: async (span2) => {
|
|
80791
80950
|
var _a23, _b2, _c2, _d2, _e2, _f2, _g2, _h2;
|
|
80792
|
-
const stepProviderOptions = mergeObjects(providerOptions, prepareStepResult == null ? void 0 : prepareStepResult.providerOptions);
|
|
80793
80951
|
const result = await stepModel.doGenerate({
|
|
80794
80952
|
...callSettings2,
|
|
80795
80953
|
tools: stepTools,
|
|
@@ -80885,7 +81043,14 @@ async function generateText({ model: modelArg, tools, toolChoice, system, prompt
|
|
|
80885
81043
|
telemetry,
|
|
80886
81044
|
messages: stepInputMessages,
|
|
80887
81045
|
abortSignal: mergedAbortSignal,
|
|
80888
|
-
experimental_context
|
|
81046
|
+
experimental_context,
|
|
81047
|
+
stepNumber: steps.length,
|
|
81048
|
+
model: {
|
|
81049
|
+
provider: stepModel.provider,
|
|
81050
|
+
modelId: stepModel.modelId
|
|
81051
|
+
},
|
|
81052
|
+
onToolCallStart,
|
|
81053
|
+
onToolCallFinish
|
|
80889
81054
|
}));
|
|
80890
81055
|
for (const toolCall of stepToolCalls) {
|
|
80891
81056
|
if (!toolCall.providerExecuted) continue;
|
|
@@ -80906,16 +81071,25 @@ async function generateText({ model: modelArg, tools, toolChoice, system, prompt
|
|
|
80906
81071
|
content: stepContent,
|
|
80907
81072
|
tools
|
|
80908
81073
|
}));
|
|
80909
|
-
const stepRequest = ((
|
|
81074
|
+
const stepRequest = ((_i = include == null ? void 0 : include.requestBody) != null ? _i : true) ? (_j = currentModelResponse.request) != null ? _j : {} : {
|
|
80910
81075
|
...currentModelResponse.request,
|
|
80911
81076
|
body: void 0
|
|
80912
81077
|
};
|
|
80913
81078
|
const stepResponse = {
|
|
80914
81079
|
...currentModelResponse.response,
|
|
80915
81080
|
messages: structuredClone(responseMessages),
|
|
80916
|
-
body: ((
|
|
81081
|
+
body: ((_k = include == null ? void 0 : include.responseBody) != null ? _k : true) ? (_l = currentModelResponse.response) == null ? void 0 : _l.body : void 0
|
|
80917
81082
|
};
|
|
81083
|
+
const stepNumber = steps.length;
|
|
80918
81084
|
const currentStepResult = new DefaultStepResult({
|
|
81085
|
+
stepNumber,
|
|
81086
|
+
model: {
|
|
81087
|
+
provider: stepModel.provider,
|
|
81088
|
+
modelId: stepModel.modelId
|
|
81089
|
+
},
|
|
81090
|
+
functionId: telemetry == null ? void 0 : telemetry.functionId,
|
|
81091
|
+
metadata: telemetry == null ? void 0 : telemetry.metadata,
|
|
81092
|
+
experimental_context,
|
|
80919
81093
|
content: stepContent,
|
|
80920
81094
|
finishReason: currentModelResponse.finishReason.unified,
|
|
80921
81095
|
rawFinishReason: currentModelResponse.finishReason.raw,
|
|
@@ -80926,7 +81100,7 @@ async function generateText({ model: modelArg, tools, toolChoice, system, prompt
|
|
|
80926
81100
|
response: stepResponse
|
|
80927
81101
|
});
|
|
80928
81102
|
logWarnings({
|
|
80929
|
-
warnings: (
|
|
81103
|
+
warnings: (_m = currentModelResponse.warnings) != null ? _m : [],
|
|
80930
81104
|
provider: stepModel.provider,
|
|
80931
81105
|
model: stepModel.modelId
|
|
80932
81106
|
});
|
|
@@ -80965,6 +81139,11 @@ async function generateText({ model: modelArg, tools, toolChoice, system, prompt
|
|
|
80965
81139
|
cachedInputTokens: void 0
|
|
80966
81140
|
});
|
|
80967
81141
|
await (onFinish == null ? void 0 : onFinish({
|
|
81142
|
+
stepNumber: lastStep.stepNumber,
|
|
81143
|
+
model: lastStep.model,
|
|
81144
|
+
functionId: lastStep.functionId,
|
|
81145
|
+
metadata: lastStep.metadata,
|
|
81146
|
+
experimental_context: lastStep.experimental_context,
|
|
80968
81147
|
finishReason: lastStep.finishReason,
|
|
80969
81148
|
rawFinishReason: lastStep.rawFinishReason,
|
|
80970
81149
|
usage: lastStep.usage,
|
|
@@ -80985,8 +81164,7 @@ async function generateText({ model: modelArg, tools, toolChoice, system, prompt
|
|
|
80985
81164
|
warnings: lastStep.warnings,
|
|
80986
81165
|
providerMetadata: lastStep.providerMetadata,
|
|
80987
81166
|
steps,
|
|
80988
|
-
totalUsage
|
|
80989
|
-
experimental_context
|
|
81167
|
+
totalUsage
|
|
80990
81168
|
}));
|
|
80991
81169
|
let resolvedOutput;
|
|
80992
81170
|
if (lastStep.finishReason === "stop") resolvedOutput = await (output != null ? output : text()).parseCompleteOutput({ text: lastStep.text }, {
|
|
@@ -81005,7 +81183,7 @@ async function generateText({ model: modelArg, tools, toolChoice, system, prompt
|
|
|
81005
81183
|
throw wrapGatewayError(error);
|
|
81006
81184
|
}
|
|
81007
81185
|
}
|
|
81008
|
-
async function executeTools({ toolCalls, tools, tracer, telemetry, messages, abortSignal, experimental_context }) {
|
|
81186
|
+
async function executeTools({ toolCalls, tools, tracer, telemetry, messages, abortSignal, experimental_context, stepNumber, model, onToolCallStart, onToolCallFinish }) {
|
|
81009
81187
|
return (await Promise.all(toolCalls.map(async (toolCall) => executeToolCall({
|
|
81010
81188
|
toolCall,
|
|
81011
81189
|
tools,
|
|
@@ -81013,7 +81191,11 @@ async function executeTools({ toolCalls, tools, tracer, telemetry, messages, abo
|
|
|
81013
81191
|
telemetry,
|
|
81014
81192
|
messages,
|
|
81015
81193
|
abortSignal,
|
|
81016
|
-
experimental_context
|
|
81194
|
+
experimental_context,
|
|
81195
|
+
stepNumber,
|
|
81196
|
+
model,
|
|
81197
|
+
onToolCallStart,
|
|
81198
|
+
onToolCallFinish
|
|
81017
81199
|
})))).filter((output) => output != null);
|
|
81018
81200
|
}
|
|
81019
81201
|
var DefaultGenerateTextResult = class {
|
|
@@ -82067,10 +82249,6 @@ function createStitchableStream() {
|
|
|
82067
82249
|
terminate
|
|
82068
82250
|
};
|
|
82069
82251
|
}
|
|
82070
|
-
function now() {
|
|
82071
|
-
var _a21, _b;
|
|
82072
|
-
return (_b = (_a21 = globalThis == null ? void 0 : globalThis.performance) == null ? void 0 : _a21.now()) != null ? _b : Date.now();
|
|
82073
|
-
}
|
|
82074
82252
|
function runToolsTransformation({ tools, generatorStream, tracer, telemetry, system, messages, abortSignal, repairToolCall, experimental_context, generateId: generateId2 }) {
|
|
82075
82253
|
let toolResultsStreamController = null;
|
|
82076
82254
|
const toolResultsStream = new ReadableStream({ start(controller) {
|
|
@@ -82514,6 +82692,14 @@ var DefaultStreamTextResult = class {
|
|
|
82514
82692
|
tools
|
|
82515
82693
|
});
|
|
82516
82694
|
const currentStepResult = new DefaultStepResult({
|
|
82695
|
+
stepNumber: recordedSteps.length,
|
|
82696
|
+
model: {
|
|
82697
|
+
provider: model.provider,
|
|
82698
|
+
modelId: model.modelId
|
|
82699
|
+
},
|
|
82700
|
+
functionId: telemetry == null ? void 0 : telemetry.functionId,
|
|
82701
|
+
metadata: telemetry == null ? void 0 : telemetry.metadata,
|
|
82702
|
+
experimental_context,
|
|
82517
82703
|
content: recordedContent,
|
|
82518
82704
|
finishReason: part.finishReason,
|
|
82519
82705
|
rawFinishReason: part.rawFinishReason,
|
|
@@ -82560,6 +82746,11 @@ var DefaultStreamTextResult = class {
|
|
|
82560
82746
|
self._steps.resolve(recordedSteps);
|
|
82561
82747
|
const finalStep = recordedSteps[recordedSteps.length - 1];
|
|
82562
82748
|
await (onFinish == null ? void 0 : onFinish({
|
|
82749
|
+
stepNumber: finalStep.stepNumber,
|
|
82750
|
+
model: finalStep.model,
|
|
82751
|
+
functionId: finalStep.functionId,
|
|
82752
|
+
metadata: finalStep.metadata,
|
|
82753
|
+
experimental_context: finalStep.experimental_context,
|
|
82563
82754
|
finishReason: finalStep.finishReason,
|
|
82564
82755
|
rawFinishReason: finalStep.rawFinishReason,
|
|
82565
82756
|
totalUsage,
|
|
@@ -82580,8 +82771,7 @@ var DefaultStreamTextResult = class {
|
|
|
82580
82771
|
response: finalStep.response,
|
|
82581
82772
|
warnings: finalStep.warnings,
|
|
82582
82773
|
providerMetadata: finalStep.providerMetadata,
|
|
82583
|
-
steps: recordedSteps
|
|
82584
|
-
experimental_context
|
|
82774
|
+
steps: recordedSteps
|
|
82585
82775
|
}));
|
|
82586
82776
|
rootSpan.setAttributes(await selectTelemetryAttributes({
|
|
82587
82777
|
telemetry,
|
|
@@ -88188,29 +88378,15 @@ function hasRemainingTodos(toolResult) {
|
|
|
88188
88378
|
}
|
|
88189
88379
|
}
|
|
88190
88380
|
/**
|
|
88191
|
-
* Extract textPart from the last expert message.
|
|
88192
|
-
* When LLM generates both text and attemptCompletion in one response,
|
|
88193
|
-
* we should use that text as the final result instead of re-generating.
|
|
88194
|
-
*/
|
|
88195
|
-
function extractTextFromLastMessage(checkpoint) {
|
|
88196
|
-
const lastMessage = checkpoint.messages[checkpoint.messages.length - 1];
|
|
88197
|
-
if (!lastMessage || lastMessage.type !== "expertMessage") return;
|
|
88198
|
-
const textPart = lastMessage.contents.find((c) => c.type === "textPart");
|
|
88199
|
-
if (!textPart || textPart.type !== "textPart") return;
|
|
88200
|
-
const text = textPart.text.trim();
|
|
88201
|
-
return text.length > 0 ? text : void 0;
|
|
88202
|
-
}
|
|
88203
|
-
/**
|
|
88204
88381
|
* CallingMcpTools state: Execute MCP tool calls in parallel.
|
|
88205
88382
|
*
|
|
88206
88383
|
* Responsibilities:
|
|
88207
88384
|
* - Execute MCP tools in parallel
|
|
88208
|
-
* - Handle attemptCompletion specially (→
|
|
88385
|
+
* - Handle attemptCompletion specially (→ completeRun directly)
|
|
88209
88386
|
* - Classify remaining tool calls and route to appropriate state
|
|
88210
88387
|
*
|
|
88211
88388
|
* Transitions:
|
|
88212
|
-
* -
|
|
88213
|
-
* - completeRun → Stopped (attemptCompletion with existing text)
|
|
88389
|
+
* - completeRun → Stopped (attemptCompletion with no remaining todos)
|
|
88214
88390
|
* - finishMcpTools → CallingDelegates (has delegate/interactive tools remaining)
|
|
88215
88391
|
* - resolveToolResults → ResolvingToolResult (MCP only, no other tools)
|
|
88216
88392
|
*/
|
|
@@ -88223,39 +88399,36 @@ async function callingMcpToolsLogic({ setting, checkpoint, step, skillManager })
|
|
|
88223
88399
|
if (attemptCompletionTool) {
|
|
88224
88400
|
const toolResult = await toolExecutorFactory.execute(attemptCompletionTool, "mcp", skillManager);
|
|
88225
88401
|
if (hasRemainingTodos(toolResult)) return resolveToolResults(setting, checkpoint, { toolResults: [toolResult] });
|
|
88226
|
-
const
|
|
88227
|
-
|
|
88228
|
-
|
|
88229
|
-
|
|
88230
|
-
|
|
88231
|
-
|
|
88232
|
-
|
|
88233
|
-
|
|
88234
|
-
|
|
88235
|
-
|
|
88236
|
-
|
|
88237
|
-
|
|
88238
|
-
|
|
88239
|
-
checkpoint
|
|
88240
|
-
|
|
88241
|
-
|
|
88242
|
-
|
|
88243
|
-
|
|
88244
|
-
|
|
88245
|
-
|
|
88246
|
-
|
|
88247
|
-
|
|
88248
|
-
step
|
|
88249
|
-
|
|
88250
|
-
|
|
88251
|
-
|
|
88252
|
-
|
|
88253
|
-
|
|
88254
|
-
|
|
88255
|
-
|
|
88256
|
-
});
|
|
88257
|
-
}
|
|
88258
|
-
return attemptCompletion$1(setting, checkpoint, { toolResult });
|
|
88402
|
+
const result = typeof attemptCompletionTool.args?.result === "string" ? attemptCompletionTool.args.result : "";
|
|
88403
|
+
const newMessages = [createToolMessage([{
|
|
88404
|
+
type: "toolResultPart",
|
|
88405
|
+
toolCallId: toolResult.id,
|
|
88406
|
+
toolName: attemptCompletionTool.toolName,
|
|
88407
|
+
contents: toolResult.result.filter((part) => part.type === "textPart" || part.type === "imageInlinePart" || part.type === "fileInlinePart")
|
|
88408
|
+
}]), createExpertMessage([{
|
|
88409
|
+
type: "textPart",
|
|
88410
|
+
text: result
|
|
88411
|
+
}])];
|
|
88412
|
+
const newUsage = sumUsage(checkpoint.usage, createEmptyUsage());
|
|
88413
|
+
return completeRun(setting, checkpoint, {
|
|
88414
|
+
checkpoint: {
|
|
88415
|
+
...checkpoint,
|
|
88416
|
+
messages: [...checkpoint.messages, ...newMessages],
|
|
88417
|
+
usage: newUsage,
|
|
88418
|
+
contextWindowUsage: checkpoint.contextWindow ? calculateContextWindowUsage(newUsage, checkpoint.contextWindow) : void 0,
|
|
88419
|
+
status: "completed",
|
|
88420
|
+
pendingToolCalls: void 0,
|
|
88421
|
+
partialToolResults: void 0
|
|
88422
|
+
},
|
|
88423
|
+
step: {
|
|
88424
|
+
...step,
|
|
88425
|
+
newMessages: [...step.newMessages, ...newMessages],
|
|
88426
|
+
finishedAt: Date.now(),
|
|
88427
|
+
usage: sumUsage(step.usage, createEmptyUsage())
|
|
88428
|
+
},
|
|
88429
|
+
text: result,
|
|
88430
|
+
usage: createEmptyUsage()
|
|
88431
|
+
});
|
|
88259
88432
|
}
|
|
88260
88433
|
const classified = classifyToolCalls$1(pendingToolCalls, skillManager);
|
|
88261
88434
|
if (classified.mcp.length > 0) {
|
|
@@ -88277,24 +88450,12 @@ async function callingMcpToolsLogic({ setting, checkpoint, step, skillManager })
|
|
|
88277
88450
|
* FinishingStep state: Complete current step and decide next action.
|
|
88278
88451
|
*
|
|
88279
88452
|
* Responsibilities:
|
|
88280
|
-
* - Check if max steps exceeded
|
|
88281
88453
|
* - Increment step number for next iteration
|
|
88282
88454
|
*
|
|
88283
88455
|
* Transitions:
|
|
88284
88456
|
* - continueToNextStep → PreparingForStep (continue loop)
|
|
88285
|
-
* - stopRunByExceededMaxSteps → Stopped (limit reached)
|
|
88286
88457
|
*/
|
|
88287
88458
|
async function finishingStepLogic({ setting, checkpoint, step }) {
|
|
88288
|
-
if (setting.maxSteps !== void 0 && checkpoint.stepNumber >= setting.maxSteps) return stopRunByExceededMaxSteps(setting, checkpoint, {
|
|
88289
|
-
checkpoint: {
|
|
88290
|
-
...checkpoint,
|
|
88291
|
-
status: "stoppedByExceededMaxSteps"
|
|
88292
|
-
},
|
|
88293
|
-
step: {
|
|
88294
|
-
...step,
|
|
88295
|
-
finishedAt: Date.now()
|
|
88296
|
-
}
|
|
88297
|
-
});
|
|
88298
88459
|
return continueToNextStep(setting, checkpoint, {
|
|
88299
88460
|
checkpoint: { ...checkpoint },
|
|
88300
88461
|
step: {
|
|
@@ -88311,127 +88472,6 @@ async function finishingStepLogic({ setting, checkpoint, step }) {
|
|
|
88311
88472
|
});
|
|
88312
88473
|
}
|
|
88313
88474
|
|
|
88314
|
-
//#endregion
|
|
88315
|
-
//#region ../../packages/runtime/src/state-machine/states/generating-run-result.ts
|
|
88316
|
-
/**
|
|
88317
|
-
* GeneratingRunResult state: Generate final result after attemptCompletion.
|
|
88318
|
-
*
|
|
88319
|
-
* Responsibilities:
|
|
88320
|
-
* - Call LLM to generate final text response
|
|
88321
|
-
* - Stream result with reasoning/result callbacks
|
|
88322
|
-
* - Build tool message from attemptCompletion result
|
|
88323
|
-
*
|
|
88324
|
-
* Transitions:
|
|
88325
|
-
* - completeRun → Stopped (successful completion)
|
|
88326
|
-
* - retry → FinishingStep (retryable error)
|
|
88327
|
-
* - stopRunByError → Stopped (non-retryable error)
|
|
88328
|
-
*/
|
|
88329
|
-
async function generatingRunResultLogic({ setting, checkpoint, step, eventListener, llmExecutor }) {
|
|
88330
|
-
if (!step.toolCalls || !step.toolResults || step.toolResults.length === 0) throw new Error("No tool calls or tool results found");
|
|
88331
|
-
const toolMessage = createToolMessage(step.toolResults.map((toolResult) => {
|
|
88332
|
-
const toolCall = step.toolCalls?.find((tc) => tc.id === toolResult.id);
|
|
88333
|
-
return {
|
|
88334
|
-
type: "toolResultPart",
|
|
88335
|
-
toolCallId: toolResult.id,
|
|
88336
|
-
toolName: toolCall?.toolName ?? toolResult.toolName,
|
|
88337
|
-
contents: toolResult.result.filter((part) => part.type === "textPart" || part.type === "imageInlinePart" || part.type === "fileInlinePart")
|
|
88338
|
-
};
|
|
88339
|
-
}));
|
|
88340
|
-
const { messages } = checkpoint;
|
|
88341
|
-
const coreMessages = [...messages, toolMessage].map(messageToCoreMessage);
|
|
88342
|
-
let reasoningCompletedViaCallback = false;
|
|
88343
|
-
const executionResult = await llmExecutor.streamText({
|
|
88344
|
-
messages: coreMessages,
|
|
88345
|
-
maxRetries: setting.maxRetries,
|
|
88346
|
-
tools: {},
|
|
88347
|
-
abortSignal: AbortSignal.timeout(setting.timeout),
|
|
88348
|
-
reasoningBudget: setting.reasoningBudget
|
|
88349
|
-
}, {
|
|
88350
|
-
onReasoningStart: () => {
|
|
88351
|
-
eventListener(createStreamingEvent("startStreamingReasoning", setting, checkpoint, {}));
|
|
88352
|
-
},
|
|
88353
|
-
onReasoningDelta: (delta) => {
|
|
88354
|
-
eventListener(createStreamingEvent("streamReasoning", setting, checkpoint, { delta }));
|
|
88355
|
-
},
|
|
88356
|
-
onReasoningComplete: (text) => {
|
|
88357
|
-
eventListener(createStreamingEvent("completeStreamingReasoning", setting, checkpoint, { text }));
|
|
88358
|
-
reasoningCompletedViaCallback = true;
|
|
88359
|
-
},
|
|
88360
|
-
onResultStart: () => {
|
|
88361
|
-
eventListener(createStreamingEvent("startStreamingRunResult", setting, checkpoint, {}));
|
|
88362
|
-
},
|
|
88363
|
-
onResultDelta: (delta) => {
|
|
88364
|
-
eventListener(createStreamingEvent("streamRunResult", setting, checkpoint, { delta }));
|
|
88365
|
-
},
|
|
88366
|
-
onResultComplete: (text) => {
|
|
88367
|
-
eventListener(createStreamingEvent("completeStreamingRunResult", setting, checkpoint, { text }));
|
|
88368
|
-
}
|
|
88369
|
-
});
|
|
88370
|
-
if (!executionResult.success) {
|
|
88371
|
-
const { error, isRetryable } = executionResult;
|
|
88372
|
-
const currentRetryCount = checkpoint.retryCount ?? 0;
|
|
88373
|
-
if (!isRetryable || currentRetryCount >= setting.maxRetries) return stopRunByError(setting, checkpoint, {
|
|
88374
|
-
checkpoint: {
|
|
88375
|
-
...checkpoint,
|
|
88376
|
-
status: "stoppedByError"
|
|
88377
|
-
},
|
|
88378
|
-
step: {
|
|
88379
|
-
...step,
|
|
88380
|
-
finishedAt: Date.now()
|
|
88381
|
-
},
|
|
88382
|
-
error: {
|
|
88383
|
-
name: error.name ?? "Error",
|
|
88384
|
-
message: currentRetryCount >= setting.maxRetries ? `Max retries (${setting.maxRetries}) exceeded: ${error.message}` : error.message,
|
|
88385
|
-
statusCode: error.statusCode,
|
|
88386
|
-
isRetryable: false
|
|
88387
|
-
}
|
|
88388
|
-
});
|
|
88389
|
-
const reason = JSON.stringify({
|
|
88390
|
-
error: error.name ?? "Error",
|
|
88391
|
-
message: error.message
|
|
88392
|
-
});
|
|
88393
|
-
return retry(setting, checkpoint, {
|
|
88394
|
-
reason,
|
|
88395
|
-
newMessages: [toolMessage, createUserMessage([{
|
|
88396
|
-
type: "textPart",
|
|
88397
|
-
text: reason
|
|
88398
|
-
}])],
|
|
88399
|
-
usage: createEmptyUsage()
|
|
88400
|
-
});
|
|
88401
|
-
}
|
|
88402
|
-
const generationResult = executionResult.result;
|
|
88403
|
-
const usage = usageFromGenerateTextResult(generationResult);
|
|
88404
|
-
const { text, reasoning } = generationResult;
|
|
88405
|
-
const thinkingParts = extractThinkingParts(reasoning);
|
|
88406
|
-
const thinkingText = extractThinkingText(reasoning);
|
|
88407
|
-
const resultText = text || "OK";
|
|
88408
|
-
const newMessages = [toolMessage, createExpertMessage([...thinkingParts, {
|
|
88409
|
-
type: "textPart",
|
|
88410
|
-
text: resultText
|
|
88411
|
-
}])];
|
|
88412
|
-
if (thinkingText && !reasoningCompletedViaCallback) await eventListener(createStreamingEvent("completeStreamingReasoning", setting, checkpoint, { text: thinkingText }));
|
|
88413
|
-
const newUsage = sumUsage(checkpoint.usage, usage);
|
|
88414
|
-
return completeRun(setting, checkpoint, {
|
|
88415
|
-
checkpoint: {
|
|
88416
|
-
...checkpoint,
|
|
88417
|
-
messages: [...messages, ...newMessages],
|
|
88418
|
-
usage: newUsage,
|
|
88419
|
-
contextWindowUsage: checkpoint.contextWindow ? calculateContextWindowUsage(usage, checkpoint.contextWindow) : void 0,
|
|
88420
|
-
status: "completed",
|
|
88421
|
-
pendingToolCalls: void 0,
|
|
88422
|
-
partialToolResults: void 0
|
|
88423
|
-
},
|
|
88424
|
-
step: {
|
|
88425
|
-
...step,
|
|
88426
|
-
newMessages: [...step.newMessages, ...newMessages],
|
|
88427
|
-
finishedAt: Date.now(),
|
|
88428
|
-
usage: sumUsage(step.usage, usage)
|
|
88429
|
-
},
|
|
88430
|
-
text: resultText,
|
|
88431
|
-
usage
|
|
88432
|
-
});
|
|
88433
|
-
}
|
|
88434
|
-
|
|
88435
88475
|
//#endregion
|
|
88436
88476
|
//#region ../../packages/runtime/src/helpers/tool-set.ts
|
|
88437
88477
|
function getToolSet(skillManager) {
|
|
@@ -88554,6 +88594,36 @@ async function generatingToolCallLogic({ setting, checkpoint, step, skillManager
|
|
|
88554
88594
|
const { text, toolCalls, finishReason, reasoning } = result;
|
|
88555
88595
|
const thinkingParts = extractThinkingParts(reasoning);
|
|
88556
88596
|
const thinkingText = extractThinkingText(reasoning);
|
|
88597
|
+
const invalidToolCalls = toolCalls.filter((tc) => tc.invalid === true);
|
|
88598
|
+
if (invalidToolCalls.length > 0) {
|
|
88599
|
+
if ((checkpoint.retryCount ?? 0) >= setting.maxRetries) return stopRunByError(setting, checkpoint, {
|
|
88600
|
+
checkpoint: {
|
|
88601
|
+
...checkpoint,
|
|
88602
|
+
status: "stoppedByError"
|
|
88603
|
+
},
|
|
88604
|
+
step: {
|
|
88605
|
+
...step,
|
|
88606
|
+
finishedAt: Date.now()
|
|
88607
|
+
},
|
|
88608
|
+
error: {
|
|
88609
|
+
name: "InvalidToolCallInput",
|
|
88610
|
+
message: `Max retries (${setting.maxRetries}) exceeded: Invalid tool call input for ${invalidToolCalls.map((tc) => tc.toolName).join(", ")}`,
|
|
88611
|
+
isRetryable: false
|
|
88612
|
+
}
|
|
88613
|
+
});
|
|
88614
|
+
const reason = JSON.stringify({
|
|
88615
|
+
error: "Error: Invalid tool call input",
|
|
88616
|
+
message: `The following tool call(s) had invalid input: ${invalidToolCalls.map((tc) => tc.toolName).join(", ")}. Ensure tool call arguments are valid JSON objects matching the tool schema. Try again.`
|
|
88617
|
+
});
|
|
88618
|
+
return retry(setting, checkpoint, {
|
|
88619
|
+
reason,
|
|
88620
|
+
newMessages: [createUserMessage([{
|
|
88621
|
+
type: "textPart",
|
|
88622
|
+
text: reason
|
|
88623
|
+
}])],
|
|
88624
|
+
usage
|
|
88625
|
+
});
|
|
88626
|
+
}
|
|
88557
88627
|
if (toolCalls.length === 0 && text) {
|
|
88558
88628
|
const newMessage = createExpertMessage([...thinkingParts, {
|
|
88559
88629
|
type: "textPart",
|
|
@@ -88691,11 +88761,33 @@ async function generatingToolCallLogic({ setting, checkpoint, step, skillManager
|
|
|
88691
88761
|
|
|
88692
88762
|
//#endregion
|
|
88693
88763
|
//#region ../../packages/runtime/src/messages/instruction-message.ts
|
|
88694
|
-
function
|
|
88764
|
+
function getDelegateMetaInstruction(startedAt) {
|
|
88695
88765
|
return import_dist.dedent`
|
|
88696
88766
|
Call tools iteratively to complete the user's task.
|
|
88697
|
-
|
|
88698
|
-
|
|
88767
|
+
|
|
88768
|
+
Before starting work, investigate the workspace and understand the current state. Then use the todo tool to create a plan of action. Work through the todos step by step, marking each completed as you go.
|
|
88769
|
+
|
|
88770
|
+
When the task is complete, call attemptCompletion with a result parameter containing your final response.
|
|
88771
|
+
When you cannot help, call attemptCompletion without a result.
|
|
88772
|
+
|
|
88773
|
+
Environment:
|
|
88774
|
+
- Current time: ${new Date(startedAt).toISOString()}
|
|
88775
|
+
- Working directory: ${process.cwd()}
|
|
88776
|
+
`;
|
|
88777
|
+
}
|
|
88778
|
+
function getCoordinatorMetaInstruction(startedAt) {
|
|
88779
|
+
return import_dist.dedent`
|
|
88780
|
+
You are a Coordinator. Your role is to plan, split tasks, and delegate. Never execute concrete tasks yourself.
|
|
88781
|
+
|
|
88782
|
+
Delegation best practices:
|
|
88783
|
+
- Parallelism: When there are N independent tasks, delegate them simultaneously in a single response.
|
|
88784
|
+
- Task splitting: Distribute N tasks across M Experts. Do not send all tasks to a single Expert.
|
|
88785
|
+
- Specificity: Include context, constraints, and expected output format in every delegation. No vague delegations.
|
|
88786
|
+
- Planning as delegation: If planning is needed, delegate to a planner Expert. If none exists, create one with createExpert, then addDelegate, then delegate.
|
|
88787
|
+
- Creating Experts: If no suitable delegate exists, use createExpert to create a specialized Expert, then addDelegate, then delegate to it.
|
|
88788
|
+
|
|
88789
|
+
When the task is complete, call attemptCompletion with a result parameter containing your final response.
|
|
88790
|
+
When you cannot help, call attemptCompletion without a result.
|
|
88699
88791
|
|
|
88700
88792
|
Environment:
|
|
88701
88793
|
- Current time: ${new Date(startedAt).toISOString()}
|
|
@@ -88706,7 +88798,7 @@ function createInstructionMessage(expert, startedAt) {
|
|
|
88706
88798
|
const instruction = import_dist.dedent`
|
|
88707
88799
|
You are Perstack, an AI expert that tackles tasks requested by users by utilizing all available tools.
|
|
88708
88800
|
|
|
88709
|
-
${
|
|
88801
|
+
${isCoordinatorExpert(expert.name) ? getCoordinatorMetaInstruction(startedAt) : getDelegateMetaInstruction(startedAt)}
|
|
88710
88802
|
|
|
88711
88803
|
---
|
|
88712
88804
|
|
|
@@ -89042,13 +89134,6 @@ const runtimeStateMachine = setup({ types: {
|
|
|
89042
89134
|
pendingToolCalls: void 0
|
|
89043
89135
|
}) })
|
|
89044
89136
|
},
|
|
89045
|
-
attemptCompletion: {
|
|
89046
|
-
target: "GeneratingRunResult",
|
|
89047
|
-
actions: assign({ step: ({ context, event }) => ({
|
|
89048
|
-
...context.step,
|
|
89049
|
-
toolResults: [event.toolResult]
|
|
89050
|
-
}) })
|
|
89051
|
-
},
|
|
89052
89137
|
finishMcpTools: {
|
|
89053
89138
|
target: "CallingDelegates",
|
|
89054
89139
|
actions: assign({ step: ({ context, event }) => ({
|
|
@@ -89118,75 +89203,17 @@ const runtimeStateMachine = setup({ types: {
|
|
|
89118
89203
|
})
|
|
89119
89204
|
})
|
|
89120
89205
|
} } },
|
|
89121
|
-
|
|
89122
|
-
|
|
89123
|
-
|
|
89124
|
-
|
|
89125
|
-
|
|
89126
|
-
|
|
89127
|
-
|
|
89128
|
-
usage: sumUsage(context.checkpoint.usage, event.usage),
|
|
89129
|
-
retryCount: (context.checkpoint.retryCount ?? 0) + 1
|
|
89130
|
-
}),
|
|
89131
|
-
step: ({ context, event }) => ({
|
|
89132
|
-
...context.step,
|
|
89133
|
-
newMessages: event.newMessages,
|
|
89134
|
-
toolCalls: event.toolCalls,
|
|
89135
|
-
toolResults: event.toolResults,
|
|
89136
|
-
usage: sumUsage(context.step.usage, event.usage)
|
|
89137
|
-
})
|
|
89138
|
-
})
|
|
89139
|
-
},
|
|
89140
|
-
stopRunByError: {
|
|
89141
|
-
target: "Stopped",
|
|
89142
|
-
actions: assign({
|
|
89143
|
-
checkpoint: ({ event }) => ({
|
|
89144
|
-
...event.checkpoint,
|
|
89145
|
-
error: event.error
|
|
89146
|
-
}),
|
|
89147
|
-
step: ({ event }) => ({
|
|
89148
|
-
...event.step,
|
|
89149
|
-
inputMessages: void 0
|
|
89150
|
-
})
|
|
89151
|
-
})
|
|
89152
|
-
},
|
|
89153
|
-
completeRun: {
|
|
89154
|
-
target: "Stopped",
|
|
89155
|
-
actions: assign({
|
|
89156
|
-
checkpoint: ({ event }) => ({
|
|
89157
|
-
...event.checkpoint,
|
|
89158
|
-
retryCount: 0
|
|
89159
|
-
}),
|
|
89160
|
-
step: ({ event }) => ({
|
|
89161
|
-
...event.step,
|
|
89162
|
-
inputMessages: void 0
|
|
89163
|
-
})
|
|
89164
|
-
})
|
|
89165
|
-
}
|
|
89166
|
-
} },
|
|
89167
|
-
FinishingStep: { on: {
|
|
89168
|
-
continueToNextStep: {
|
|
89169
|
-
target: "PreparingForStep",
|
|
89170
|
-
actions: assign({
|
|
89171
|
-
checkpoint: ({ event }) => event.nextCheckpoint,
|
|
89172
|
-
step: ({ event }) => ({
|
|
89173
|
-
...event.step,
|
|
89174
|
-
inputMessages: void 0
|
|
89175
|
-
})
|
|
89176
|
-
}),
|
|
89177
|
-
reenter: true
|
|
89178
|
-
},
|
|
89179
|
-
stopRunByExceededMaxSteps: {
|
|
89180
|
-
target: "Stopped",
|
|
89181
|
-
actions: assign({
|
|
89182
|
-
checkpoint: ({ event }) => event.checkpoint,
|
|
89183
|
-
step: ({ event }) => ({
|
|
89184
|
-
...event.step,
|
|
89185
|
-
inputMessages: void 0
|
|
89186
|
-
})
|
|
89206
|
+
FinishingStep: { on: { continueToNextStep: {
|
|
89207
|
+
target: "PreparingForStep",
|
|
89208
|
+
actions: assign({
|
|
89209
|
+
checkpoint: ({ event }) => event.nextCheckpoint,
|
|
89210
|
+
step: ({ event }) => ({
|
|
89211
|
+
...event.step,
|
|
89212
|
+
inputMessages: void 0
|
|
89187
89213
|
})
|
|
89188
|
-
}
|
|
89189
|
-
|
|
89214
|
+
}),
|
|
89215
|
+
reenter: true
|
|
89216
|
+
} } },
|
|
89190
89217
|
Stopped: { type: "final" }
|
|
89191
89218
|
}
|
|
89192
89219
|
});
|
|
@@ -89199,7 +89226,6 @@ const StateMachineLogics = {
|
|
|
89199
89226
|
CallingDelegates: callingDelegatesLogic,
|
|
89200
89227
|
CallingInteractiveTools: callingInteractiveToolsLogic,
|
|
89201
89228
|
ResolvingToolResult: resolvingToolResultLogic,
|
|
89202
|
-
GeneratingRunResult: generatingRunResultLogic,
|
|
89203
89229
|
FinishingStep: finishingStepLogic
|
|
89204
89230
|
};
|
|
89205
89231
|
|
|
@@ -89353,7 +89379,7 @@ var CoordinatorExecutor = class {
|
|
|
89353
89379
|
isDelegatedRun: !!checkpoint?.delegatedBy,
|
|
89354
89380
|
onLifecycleEvent
|
|
89355
89381
|
});
|
|
89356
|
-
const initialCheckpoint = checkpoint ?
|
|
89382
|
+
const initialCheckpoint = checkpoint ? createRunStartCheckpoint(createId(), checkpoint, setting.runId) : createInitialCheckpoint(createId(), {
|
|
89357
89383
|
jobId: setting.jobId,
|
|
89358
89384
|
runId: setting.runId,
|
|
89359
89385
|
expertKey: setting.expertKey,
|
|
@@ -89434,7 +89460,6 @@ var CoordinatorExecutor = class {
|
|
|
89434
89460
|
expertName: expertToRun.name,
|
|
89435
89461
|
experts: Object.keys(experts),
|
|
89436
89462
|
model: setting.model,
|
|
89437
|
-
maxSteps: setting.maxSteps,
|
|
89438
89463
|
maxRetries: setting.maxRetries,
|
|
89439
89464
|
timeout: setting.timeout,
|
|
89440
89465
|
query: setting.input.text,
|
|
@@ -89459,7 +89484,6 @@ var DelegationExecutor = class {
|
|
|
89459
89484
|
const [firstResult, ...restResults] = allResults;
|
|
89460
89485
|
if (!firstResult) throw new Error("No delegation results");
|
|
89461
89486
|
const aggregatedUsage = allResults.reduce((acc, result) => sumUsage(acc, result.deltaUsage), context.usage);
|
|
89462
|
-
const maxStepNumber = Math.max(...allResults.map((r) => r.stepNumber));
|
|
89463
89487
|
const restToolResults = restResults.map((result) => ({
|
|
89464
89488
|
id: result.toolCallId,
|
|
89465
89489
|
skillName: `delegate/${result.expertKey}`,
|
|
@@ -89490,7 +89514,7 @@ var DelegationExecutor = class {
|
|
|
89490
89514
|
jobId: setting.jobId,
|
|
89491
89515
|
runId: returnRunId,
|
|
89492
89516
|
status: "stoppedByDelegate",
|
|
89493
|
-
stepNumber:
|
|
89517
|
+
stepNumber: 1,
|
|
89494
89518
|
messages: context.messages,
|
|
89495
89519
|
expert: {
|
|
89496
89520
|
key: parentExpert.key,
|
|
@@ -89520,7 +89544,7 @@ var DelegationExecutor = class {
|
|
|
89520
89544
|
jobId: parentSetting.jobId,
|
|
89521
89545
|
runId: delegateRunId,
|
|
89522
89546
|
status: "init",
|
|
89523
|
-
stepNumber:
|
|
89547
|
+
stepNumber: 1,
|
|
89524
89548
|
messages: [],
|
|
89525
89549
|
expert: {
|
|
89526
89550
|
key: expert.key,
|
|
@@ -89609,14 +89633,13 @@ function extractDelegationContext(checkpoint) {
|
|
|
89609
89633
|
|
|
89610
89634
|
//#endregion
|
|
89611
89635
|
//#region ../../packages/runtime/src/run.ts
|
|
89612
|
-
const defaultCreateJob = (jobId, expertKey,
|
|
89636
|
+
const defaultCreateJob = (jobId, expertKey, runtimeVersion = getCurrentRuntimeVersion()) => ({
|
|
89613
89637
|
id: jobId,
|
|
89614
89638
|
coordinatorExpertKey: expertKey,
|
|
89615
89639
|
runtimeVersion,
|
|
89616
89640
|
status: "running",
|
|
89617
89641
|
totalSteps: 0,
|
|
89618
89642
|
startedAt: Date.now(),
|
|
89619
|
-
maxSteps,
|
|
89620
89643
|
usage: createEmptyUsage()
|
|
89621
89644
|
});
|
|
89622
89645
|
/**
|
|
@@ -89638,7 +89661,7 @@ async function run(runInput, options) {
|
|
|
89638
89661
|
throw new Error("retrieveCheckpoint not provided");
|
|
89639
89662
|
});
|
|
89640
89663
|
const createJob = options?.createJob ?? defaultCreateJob;
|
|
89641
|
-
let job = await retrieveJob(setting.jobId) ?? createJob(setting.jobId, setting.expertKey
|
|
89664
|
+
let job = await retrieveJob(setting.jobId) ?? createJob(setting.jobId, setting.expertKey);
|
|
89642
89665
|
if (job.status !== "running") job = {
|
|
89643
89666
|
...job,
|
|
89644
89667
|
status: "running",
|
|
@@ -89658,7 +89681,7 @@ async function run(runInput, options) {
|
|
|
89658
89681
|
const resultCheckpoint = runResult.checkpoint;
|
|
89659
89682
|
job = {
|
|
89660
89683
|
...job,
|
|
89661
|
-
totalSteps: resultCheckpoint.stepNumber,
|
|
89684
|
+
totalSteps: job.totalSteps + resultCheckpoint.stepNumber,
|
|
89662
89685
|
usage: resultCheckpoint.usage
|
|
89663
89686
|
};
|
|
89664
89687
|
switch (resultCheckpoint.status) {
|
|
@@ -89669,6 +89692,7 @@ async function run(runInput, options) {
|
|
|
89669
89692
|
}
|
|
89670
89693
|
if (resultCheckpoint.delegatedBy) {
|
|
89671
89694
|
await storeJob(job);
|
|
89695
|
+
job = await retrieveJob(setting.jobId) ?? job;
|
|
89672
89696
|
const parentCheckpoint = await retrieveCheckpoint(setting.jobId, resultCheckpoint.delegatedBy.checkpointId);
|
|
89673
89697
|
const result = buildReturnFromDelegation(setting, resultCheckpoint, parentCheckpoint);
|
|
89674
89698
|
setting = result.setting;
|
|
@@ -89698,17 +89722,11 @@ async function run(runInput, options) {
|
|
|
89698
89722
|
experts: runResult.experts
|
|
89699
89723
|
};
|
|
89700
89724
|
const delegationResult = await executor.execute(delegateTo, updatedSetting, context, runResult.expertToRun, run, options);
|
|
89725
|
+
job = await retrieveJob(setting.jobId) ?? job;
|
|
89701
89726
|
setting = delegationResult.nextSetting;
|
|
89702
89727
|
checkpoint = delegationResult.nextCheckpoint;
|
|
89703
89728
|
break;
|
|
89704
89729
|
}
|
|
89705
|
-
case "stoppedByExceededMaxSteps":
|
|
89706
|
-
await storeJob({
|
|
89707
|
-
...job,
|
|
89708
|
-
status: "stoppedByMaxSteps",
|
|
89709
|
-
finishedAt: Date.now()
|
|
89710
|
-
});
|
|
89711
|
-
return resultCheckpoint;
|
|
89712
89730
|
case "stoppedByError":
|
|
89713
89731
|
await storeJob({
|
|
89714
89732
|
...job,
|
|
@@ -90236,13 +90254,13 @@ function getCheckpointsWithDetails(jobId) {
|
|
|
90236
90254
|
runId: cp.runId,
|
|
90237
90255
|
stepNumber: cp.stepNumber,
|
|
90238
90256
|
contextWindowUsage: cp.contextWindowUsage ?? 0
|
|
90239
|
-
})).
|
|
90257
|
+
})).reverse();
|
|
90240
90258
|
}
|
|
90241
|
-
function getAllEventContentsForJob(jobId
|
|
90259
|
+
function getAllEventContentsForJob(jobId) {
|
|
90242
90260
|
const runIds = getRunIdsByJobId(jobId);
|
|
90243
90261
|
const allEvents = [];
|
|
90244
90262
|
for (const runId of runIds) {
|
|
90245
|
-
const events = getEventContents(jobId, runId
|
|
90263
|
+
const events = getEventContents(jobId, runId);
|
|
90246
90264
|
allEvents.push(...events);
|
|
90247
90265
|
}
|
|
90248
90266
|
return allEvents.sort((a, b) => a.timestamp - b.timestamp);
|
|
@@ -90349,7 +90367,6 @@ async function runHandler(expertKey, query, options, handlerOptions) {
|
|
|
90349
90367
|
model,
|
|
90350
90368
|
providerConfig,
|
|
90351
90369
|
reasoningBudget: input.options.reasoningBudget ?? perstackConfig.reasoningBudget,
|
|
90352
|
-
maxSteps: input.options.maxSteps ?? perstackConfig.maxSteps,
|
|
90353
90370
|
maxRetries: input.options.maxRetries ?? perstackConfig.maxRetries,
|
|
90354
90371
|
timeout: input.options.timeout ?? perstackConfig.timeout,
|
|
90355
90372
|
perstackApiBaseUrl: perstackConfig.perstackApiBaseUrl,
|
|
@@ -93807,15 +93824,15 @@ const ansiStyles$1 = assembleStyles$1();
|
|
|
93807
93824
|
|
|
93808
93825
|
//#endregion
|
|
93809
93826
|
//#region ../../node_modules/.pnpm/wrap-ansi@9.0.2/node_modules/wrap-ansi/index.js
|
|
93810
|
-
const ESCAPES$
|
|
93827
|
+
const ESCAPES$3 = new Set(["\x1B", ""]);
|
|
93811
93828
|
const END_CODE = 39;
|
|
93812
93829
|
const ANSI_ESCAPE_BELL = "\x07";
|
|
93813
|
-
const ANSI_CSI = "[";
|
|
93814
|
-
const ANSI_OSC = "]";
|
|
93815
|
-
const ANSI_SGR_TERMINATOR = "m";
|
|
93816
|
-
const ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
|
|
93817
|
-
const wrapAnsiCode = (code) => `${ESCAPES$
|
|
93818
|
-
const wrapAnsiHyperlink = (url) => `${ESCAPES$
|
|
93830
|
+
const ANSI_CSI$1 = "[";
|
|
93831
|
+
const ANSI_OSC$1 = "]";
|
|
93832
|
+
const ANSI_SGR_TERMINATOR$1 = "m";
|
|
93833
|
+
const ANSI_ESCAPE_LINK = `${ANSI_OSC$1}8;;`;
|
|
93834
|
+
const wrapAnsiCode = (code) => `${ESCAPES$3.values().next().value}${ANSI_CSI$1}${code}${ANSI_SGR_TERMINATOR$1}`;
|
|
93835
|
+
const wrapAnsiHyperlink = (url) => `${ESCAPES$3.values().next().value}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
|
|
93819
93836
|
const wordLengths = (string) => string.split(" ").map((character) => stringWidth$1(character));
|
|
93820
93837
|
const wrapWord = (rows, word, columns) => {
|
|
93821
93838
|
const characters = [...word];
|
|
@@ -93829,7 +93846,7 @@ const wrapWord = (rows, word, columns) => {
|
|
|
93829
93846
|
rows.push(character);
|
|
93830
93847
|
visible = 0;
|
|
93831
93848
|
}
|
|
93832
|
-
if (ESCAPES$
|
|
93849
|
+
if (ESCAPES$3.has(character)) {
|
|
93833
93850
|
isInsideEscape = true;
|
|
93834
93851
|
isInsideLinkEscape = characters.slice(index + 1, index + 1 + ANSI_ESCAPE_LINK.length).join("") === ANSI_ESCAPE_LINK;
|
|
93835
93852
|
}
|
|
@@ -93839,7 +93856,7 @@ const wrapWord = (rows, word, columns) => {
|
|
|
93839
93856
|
isInsideEscape = false;
|
|
93840
93857
|
isInsideLinkEscape = false;
|
|
93841
93858
|
}
|
|
93842
|
-
} else if (character === ANSI_SGR_TERMINATOR) isInsideEscape = false;
|
|
93859
|
+
} else if (character === ANSI_SGR_TERMINATOR$1) isInsideEscape = false;
|
|
93843
93860
|
continue;
|
|
93844
93861
|
}
|
|
93845
93862
|
visible += characterLength;
|
|
@@ -93906,8 +93923,8 @@ const exec$1 = (string, columns, options = {}) => {
|
|
|
93906
93923
|
let preStringIndex = 0;
|
|
93907
93924
|
for (const [index, character] of pre.entries()) {
|
|
93908
93925
|
returnValue += character;
|
|
93909
|
-
if (ESCAPES$
|
|
93910
|
-
const { groups } = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`).exec(preString.slice(preStringIndex)) || { groups: {} };
|
|
93926
|
+
if (ESCAPES$3.has(character)) {
|
|
93927
|
+
const { groups } = new RegExp(`(?:\\${ANSI_CSI$1}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`).exec(preString.slice(preStringIndex)) || { groups: {} };
|
|
93911
93928
|
if (groups.code !== void 0) {
|
|
93912
93929
|
const code = Number.parseFloat(groups.code);
|
|
93913
93930
|
escapeCode = code === END_CODE ? void 0 : code;
|
|
@@ -94017,6 +94034,10 @@ const resize = () => {
|
|
|
94017
94034
|
} catch {}
|
|
94018
94035
|
};
|
|
94019
94036
|
|
|
94037
|
+
//#endregion
|
|
94038
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/utils.js
|
|
94039
|
+
const isDev = () => process$1.env["DEV"] === "true";
|
|
94040
|
+
|
|
94020
94041
|
//#endregion
|
|
94021
94042
|
//#region ../../node_modules/.pnpm/scheduler@0.27.0/node_modules/scheduler/cjs/scheduler.production.js
|
|
94022
94043
|
/**
|
|
@@ -110156,7 +110177,7 @@ function widestLine(string) {
|
|
|
110156
110177
|
}
|
|
110157
110178
|
|
|
110158
110179
|
//#endregion
|
|
110159
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
110180
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/measure-text.js
|
|
110160
110181
|
const cache$1 = /* @__PURE__ */ new Map();
|
|
110161
110182
|
const measureText = (text) => {
|
|
110162
110183
|
if (text.length === 0) return {
|
|
@@ -110182,9 +110203,9 @@ function isFullwidthCodePoint(codePoint) {
|
|
|
110182
110203
|
|
|
110183
110204
|
//#endregion
|
|
110184
110205
|
//#region ../../node_modules/.pnpm/slice-ansi@7.1.2/node_modules/slice-ansi/index.js
|
|
110185
|
-
const ESCAPES$
|
|
110186
|
-
const CODE_POINT_0 = "0".codePointAt(0);
|
|
110187
|
-
const CODE_POINT_9 = "9".codePointAt(0);
|
|
110206
|
+
const ESCAPES$2 = new Set([27, 155]);
|
|
110207
|
+
const CODE_POINT_0$1 = "0".codePointAt(0);
|
|
110208
|
+
const CODE_POINT_9$1 = "9".codePointAt(0);
|
|
110188
110209
|
const MAX_ANSI_SEQUENCE_LENGTH = 19;
|
|
110189
110210
|
const endCodesSet$1 = /* @__PURE__ */ new Set();
|
|
110190
110211
|
const endCodesMap$1 = /* @__PURE__ */ new Map();
|
|
@@ -110204,11 +110225,11 @@ function getEndCode$1(code) {
|
|
|
110204
110225
|
function findNumberIndex(string) {
|
|
110205
110226
|
for (let index = 0; index < string.length; index++) {
|
|
110206
110227
|
const codePoint = string.codePointAt(index);
|
|
110207
|
-
if (codePoint >= CODE_POINT_0 && codePoint <= CODE_POINT_9) return index;
|
|
110228
|
+
if (codePoint >= CODE_POINT_0$1 && codePoint <= CODE_POINT_9$1) return index;
|
|
110208
110229
|
}
|
|
110209
110230
|
return -1;
|
|
110210
110231
|
}
|
|
110211
|
-
function parseAnsiCode(string, offset) {
|
|
110232
|
+
function parseAnsiCode$1(string, offset) {
|
|
110212
110233
|
string = string.slice(offset, offset + MAX_ANSI_SEQUENCE_LENGTH);
|
|
110213
110234
|
const startIndex = findNumberIndex(string);
|
|
110214
110235
|
if (startIndex !== -1) {
|
|
@@ -110223,8 +110244,8 @@ function tokenize$1(string, endCharacter = Number.POSITIVE_INFINITY) {
|
|
|
110223
110244
|
let visibleCount = 0;
|
|
110224
110245
|
while (index < string.length) {
|
|
110225
110246
|
const codePoint = string.codePointAt(index);
|
|
110226
|
-
if (ESCAPES$
|
|
110227
|
-
const code = parseAnsiCode(string, index);
|
|
110247
|
+
if (ESCAPES$2.has(codePoint)) {
|
|
110248
|
+
const code = parseAnsiCode$1(string, index);
|
|
110228
110249
|
if (code) {
|
|
110229
110250
|
returnValue.push({
|
|
110230
110251
|
type: "ansi",
|
|
@@ -110258,10 +110279,10 @@ function reduceAnsiCodes$1(codes) {
|
|
|
110258
110279
|
}
|
|
110259
110280
|
return returnValue;
|
|
110260
110281
|
}
|
|
110261
|
-
function undoAnsiCodes$
|
|
110282
|
+
function undoAnsiCodes$2(codes) {
|
|
110262
110283
|
return reduceAnsiCodes$1(codes).map(({ endCode }) => endCode).reverse().join("");
|
|
110263
110284
|
}
|
|
110264
|
-
function sliceAnsi(string, start, end) {
|
|
110285
|
+
function sliceAnsi$1(string, start, end) {
|
|
110265
110286
|
const tokens = tokenize$1(string, end);
|
|
110266
110287
|
let activeCodes = [];
|
|
110267
110288
|
let position = 0;
|
|
@@ -110282,7 +110303,7 @@ function sliceAnsi(string, start, end) {
|
|
|
110282
110303
|
position += token.isFullWidth ? 2 : token.value.length;
|
|
110283
110304
|
}
|
|
110284
110305
|
}
|
|
110285
|
-
returnValue += undoAnsiCodes$
|
|
110306
|
+
returnValue += undoAnsiCodes$2(activeCodes);
|
|
110286
110307
|
return returnValue;
|
|
110287
110308
|
}
|
|
110288
110309
|
|
|
@@ -110350,11 +110371,11 @@ function cliTruncate(text, columns, options = {}) {
|
|
|
110350
110371
|
}
|
|
110351
110372
|
if (position === "start") {
|
|
110352
110373
|
if (preferTruncationOnSpace) {
|
|
110353
|
-
const right = sliceAnsi(text, getIndexOfNearestSpace(text, length - columns + 1, true), length).trim();
|
|
110374
|
+
const right = sliceAnsi$1(text, getIndexOfNearestSpace(text, length - columns + 1, true), length).trim();
|
|
110354
110375
|
return prependWithInheritedStyleFromStart(truncationCharacter, right);
|
|
110355
110376
|
}
|
|
110356
110377
|
if (space) truncationCharacter += " ";
|
|
110357
|
-
const right = sliceAnsi(text, length - columns + stringWidth(truncationCharacter), length);
|
|
110378
|
+
const right = sliceAnsi$1(text, length - columns + stringWidth(truncationCharacter), length);
|
|
110358
110379
|
return prependWithInheritedStyleFromStart(truncationCharacter, right);
|
|
110359
110380
|
}
|
|
110360
110381
|
if (position === "middle") {
|
|
@@ -110363,20 +110384,20 @@ function cliTruncate(text, columns, options = {}) {
|
|
|
110363
110384
|
if (preferTruncationOnSpace) {
|
|
110364
110385
|
const spaceNearFirstBreakPoint = getIndexOfNearestSpace(text, half);
|
|
110365
110386
|
const spaceNearSecondBreakPoint = getIndexOfNearestSpace(text, length - (columns - half) + 1, true);
|
|
110366
|
-
return sliceAnsi(text, 0, spaceNearFirstBreakPoint) + truncationCharacter + sliceAnsi(text, spaceNearSecondBreakPoint, length).trim();
|
|
110387
|
+
return sliceAnsi$1(text, 0, spaceNearFirstBreakPoint) + truncationCharacter + sliceAnsi$1(text, spaceNearSecondBreakPoint, length).trim();
|
|
110367
110388
|
}
|
|
110368
|
-
return sliceAnsi(text, 0, half) + truncationCharacter + sliceAnsi(text, length - (columns - half) + stringWidth(truncationCharacter), length);
|
|
110389
|
+
return sliceAnsi$1(text, 0, half) + truncationCharacter + sliceAnsi$1(text, length - (columns - half) + stringWidth(truncationCharacter), length);
|
|
110369
110390
|
}
|
|
110370
110391
|
if (position === "end") {
|
|
110371
|
-
if (preferTruncationOnSpace) return appendWithInheritedStyleFromEnd(sliceAnsi(text, 0, getIndexOfNearestSpace(text, columns - 1)), truncationCharacter);
|
|
110392
|
+
if (preferTruncationOnSpace) return appendWithInheritedStyleFromEnd(sliceAnsi$1(text, 0, getIndexOfNearestSpace(text, columns - 1)), truncationCharacter);
|
|
110372
110393
|
if (space) truncationCharacter = ` ${truncationCharacter}`;
|
|
110373
|
-
return appendWithInheritedStyleFromEnd(sliceAnsi(text, 0, columns - stringWidth(truncationCharacter)), truncationCharacter);
|
|
110394
|
+
return appendWithInheritedStyleFromEnd(sliceAnsi$1(text, 0, columns - stringWidth(truncationCharacter)), truncationCharacter);
|
|
110374
110395
|
}
|
|
110375
110396
|
throw new Error(`Expected \`options.position\` to be either \`start\`, \`middle\` or \`end\`, got ${position}`);
|
|
110376
110397
|
}
|
|
110377
110398
|
|
|
110378
110399
|
//#endregion
|
|
110379
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
110400
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/wrap-text.js
|
|
110380
110401
|
const cache = {};
|
|
110381
110402
|
const wrapText = (text, maxWidth, wrapType) => {
|
|
110382
110403
|
const cacheKey = text + String(maxWidth) + String(wrapType);
|
|
@@ -110398,7 +110419,320 @@ const wrapText = (text, maxWidth, wrapType) => {
|
|
|
110398
110419
|
};
|
|
110399
110420
|
|
|
110400
110421
|
//#endregion
|
|
110401
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
110422
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/ansi-tokenizer.js
|
|
110423
|
+
const bellCharacter = "\x07";
|
|
110424
|
+
const escapeCharacter = "\x1B";
|
|
110425
|
+
const stringTerminatorCharacter = "";
|
|
110426
|
+
const csiCharacter = "";
|
|
110427
|
+
const oscCharacter = "";
|
|
110428
|
+
const dcsCharacter = "";
|
|
110429
|
+
const pmCharacter = "";
|
|
110430
|
+
const apcCharacter = "";
|
|
110431
|
+
const sosCharacter = "";
|
|
110432
|
+
const isCsiParameterCharacter$1 = (character) => {
|
|
110433
|
+
const codePoint = character.codePointAt(0);
|
|
110434
|
+
return codePoint !== void 0 && codePoint >= 48 && codePoint <= 63;
|
|
110435
|
+
};
|
|
110436
|
+
const isCsiIntermediateCharacter$1 = (character) => {
|
|
110437
|
+
const codePoint = character.codePointAt(0);
|
|
110438
|
+
return codePoint !== void 0 && codePoint >= 32 && codePoint <= 47;
|
|
110439
|
+
};
|
|
110440
|
+
const isCsiFinalCharacter$1 = (character) => {
|
|
110441
|
+
const codePoint = character.codePointAt(0);
|
|
110442
|
+
return codePoint !== void 0 && codePoint >= 64 && codePoint <= 126;
|
|
110443
|
+
};
|
|
110444
|
+
const isEscapeIntermediateCharacter = (character) => {
|
|
110445
|
+
const codePoint = character.codePointAt(0);
|
|
110446
|
+
return codePoint !== void 0 && codePoint >= 32 && codePoint <= 47;
|
|
110447
|
+
};
|
|
110448
|
+
const isEscapeFinalCharacter = (character) => {
|
|
110449
|
+
const codePoint = character.codePointAt(0);
|
|
110450
|
+
return codePoint !== void 0 && codePoint >= 48 && codePoint <= 126;
|
|
110451
|
+
};
|
|
110452
|
+
const isC1ControlCharacter = (character) => {
|
|
110453
|
+
const codePoint = character.codePointAt(0);
|
|
110454
|
+
return codePoint !== void 0 && codePoint >= 128 && codePoint <= 159;
|
|
110455
|
+
};
|
|
110456
|
+
const readCsiSequence = (text, fromIndex) => {
|
|
110457
|
+
let index = fromIndex;
|
|
110458
|
+
while (index < text.length) {
|
|
110459
|
+
const character = text[index];
|
|
110460
|
+
if (!isCsiParameterCharacter$1(character)) break;
|
|
110461
|
+
index++;
|
|
110462
|
+
}
|
|
110463
|
+
const parameterString = text.slice(fromIndex, index);
|
|
110464
|
+
const intermediateStartIndex = index;
|
|
110465
|
+
while (index < text.length) {
|
|
110466
|
+
const character = text[index];
|
|
110467
|
+
if (!isCsiIntermediateCharacter$1(character)) break;
|
|
110468
|
+
index++;
|
|
110469
|
+
}
|
|
110470
|
+
const intermediateString = text.slice(intermediateStartIndex, index);
|
|
110471
|
+
const finalCharacter = text[index];
|
|
110472
|
+
if (finalCharacter === void 0 || !isCsiFinalCharacter$1(finalCharacter)) return;
|
|
110473
|
+
return {
|
|
110474
|
+
endIndex: index + 1,
|
|
110475
|
+
parameterString,
|
|
110476
|
+
intermediateString,
|
|
110477
|
+
finalCharacter
|
|
110478
|
+
};
|
|
110479
|
+
};
|
|
110480
|
+
const findControlStringTerminatorIndex = (text, fromIndex, allowBellTerminator) => {
|
|
110481
|
+
for (let index = fromIndex; index < text.length; index++) {
|
|
110482
|
+
const character = text[index];
|
|
110483
|
+
if (allowBellTerminator && character === bellCharacter) return index + 1;
|
|
110484
|
+
if (character === stringTerminatorCharacter) return index + 1;
|
|
110485
|
+
if (character === escapeCharacter) {
|
|
110486
|
+
const followingCharacter = text[index + 1];
|
|
110487
|
+
if (followingCharacter === escapeCharacter) {
|
|
110488
|
+
index++;
|
|
110489
|
+
continue;
|
|
110490
|
+
}
|
|
110491
|
+
if (followingCharacter === "\\") return index + 2;
|
|
110492
|
+
}
|
|
110493
|
+
}
|
|
110494
|
+
};
|
|
110495
|
+
const readEscapeSequence = (text, fromIndex) => {
|
|
110496
|
+
let index = fromIndex;
|
|
110497
|
+
while (index < text.length) {
|
|
110498
|
+
const character = text[index];
|
|
110499
|
+
if (!isEscapeIntermediateCharacter(character)) break;
|
|
110500
|
+
index++;
|
|
110501
|
+
}
|
|
110502
|
+
const intermediateString = text.slice(fromIndex, index);
|
|
110503
|
+
const finalCharacter = text[index];
|
|
110504
|
+
if (finalCharacter === void 0 || !isEscapeFinalCharacter(finalCharacter)) return;
|
|
110505
|
+
return {
|
|
110506
|
+
endIndex: index + 1,
|
|
110507
|
+
intermediateString,
|
|
110508
|
+
finalCharacter
|
|
110509
|
+
};
|
|
110510
|
+
};
|
|
110511
|
+
const getControlStringFromEscapeIntroducer = (character) => {
|
|
110512
|
+
switch (character) {
|
|
110513
|
+
case "]": return {
|
|
110514
|
+
type: "osc",
|
|
110515
|
+
allowBellTerminator: true
|
|
110516
|
+
};
|
|
110517
|
+
case "P": return {
|
|
110518
|
+
type: "dcs",
|
|
110519
|
+
allowBellTerminator: false
|
|
110520
|
+
};
|
|
110521
|
+
case "^": return {
|
|
110522
|
+
type: "pm",
|
|
110523
|
+
allowBellTerminator: false
|
|
110524
|
+
};
|
|
110525
|
+
case "_": return {
|
|
110526
|
+
type: "apc",
|
|
110527
|
+
allowBellTerminator: false
|
|
110528
|
+
};
|
|
110529
|
+
case "X": return {
|
|
110530
|
+
type: "sos",
|
|
110531
|
+
allowBellTerminator: false
|
|
110532
|
+
};
|
|
110533
|
+
default: return;
|
|
110534
|
+
}
|
|
110535
|
+
};
|
|
110536
|
+
const getControlStringFromC1Introducer = (character) => {
|
|
110537
|
+
switch (character) {
|
|
110538
|
+
case oscCharacter: return {
|
|
110539
|
+
type: "osc",
|
|
110540
|
+
allowBellTerminator: true
|
|
110541
|
+
};
|
|
110542
|
+
case dcsCharacter: return {
|
|
110543
|
+
type: "dcs",
|
|
110544
|
+
allowBellTerminator: false
|
|
110545
|
+
};
|
|
110546
|
+
case pmCharacter: return {
|
|
110547
|
+
type: "pm",
|
|
110548
|
+
allowBellTerminator: false
|
|
110549
|
+
};
|
|
110550
|
+
case apcCharacter: return {
|
|
110551
|
+
type: "apc",
|
|
110552
|
+
allowBellTerminator: false
|
|
110553
|
+
};
|
|
110554
|
+
case sosCharacter: return {
|
|
110555
|
+
type: "sos",
|
|
110556
|
+
allowBellTerminator: false
|
|
110557
|
+
};
|
|
110558
|
+
default: return;
|
|
110559
|
+
}
|
|
110560
|
+
};
|
|
110561
|
+
const hasAnsiControlCharacters = (text) => {
|
|
110562
|
+
if (text.includes(escapeCharacter)) return true;
|
|
110563
|
+
for (const character of text) if (isC1ControlCharacter(character)) return true;
|
|
110564
|
+
return false;
|
|
110565
|
+
};
|
|
110566
|
+
const malformedFromIndex = (tokens, text, textStartIndex, fromIndex) => {
|
|
110567
|
+
if (fromIndex > textStartIndex) tokens.push({
|
|
110568
|
+
type: "text",
|
|
110569
|
+
value: text.slice(textStartIndex, fromIndex)
|
|
110570
|
+
});
|
|
110571
|
+
tokens.push({
|
|
110572
|
+
type: "invalid",
|
|
110573
|
+
value: text.slice(fromIndex)
|
|
110574
|
+
});
|
|
110575
|
+
return tokens;
|
|
110576
|
+
};
|
|
110577
|
+
const tokenizeAnsi$1 = (text) => {
|
|
110578
|
+
if (!hasAnsiControlCharacters(text)) return [{
|
|
110579
|
+
type: "text",
|
|
110580
|
+
value: text
|
|
110581
|
+
}];
|
|
110582
|
+
const tokens = [];
|
|
110583
|
+
let textStartIndex = 0;
|
|
110584
|
+
for (let index = 0; index < text.length;) {
|
|
110585
|
+
const character = text[index];
|
|
110586
|
+
if (character === void 0) break;
|
|
110587
|
+
if (character === escapeCharacter) {
|
|
110588
|
+
const followingCharacter = text[index + 1];
|
|
110589
|
+
if (followingCharacter === void 0) return malformedFromIndex(tokens, text, textStartIndex, index);
|
|
110590
|
+
if (followingCharacter === "[") {
|
|
110591
|
+
const csiSequence = readCsiSequence(text, index + 2);
|
|
110592
|
+
if (csiSequence === void 0) return malformedFromIndex(tokens, text, textStartIndex, index);
|
|
110593
|
+
if (index > textStartIndex) tokens.push({
|
|
110594
|
+
type: "text",
|
|
110595
|
+
value: text.slice(textStartIndex, index)
|
|
110596
|
+
});
|
|
110597
|
+
tokens.push({
|
|
110598
|
+
type: "csi",
|
|
110599
|
+
value: text.slice(index, csiSequence.endIndex),
|
|
110600
|
+
parameterString: csiSequence.parameterString,
|
|
110601
|
+
intermediateString: csiSequence.intermediateString,
|
|
110602
|
+
finalCharacter: csiSequence.finalCharacter
|
|
110603
|
+
});
|
|
110604
|
+
index = csiSequence.endIndex;
|
|
110605
|
+
textStartIndex = index;
|
|
110606
|
+
continue;
|
|
110607
|
+
}
|
|
110608
|
+
const escapeControlString = getControlStringFromEscapeIntroducer(followingCharacter);
|
|
110609
|
+
if (escapeControlString !== void 0) {
|
|
110610
|
+
const controlStringTerminatorIndex = findControlStringTerminatorIndex(text, index + 2, escapeControlString.allowBellTerminator);
|
|
110611
|
+
if (controlStringTerminatorIndex === void 0) return malformedFromIndex(tokens, text, textStartIndex, index);
|
|
110612
|
+
if (index > textStartIndex) tokens.push({
|
|
110613
|
+
type: "text",
|
|
110614
|
+
value: text.slice(textStartIndex, index)
|
|
110615
|
+
});
|
|
110616
|
+
tokens.push({
|
|
110617
|
+
type: escapeControlString.type,
|
|
110618
|
+
value: text.slice(index, controlStringTerminatorIndex)
|
|
110619
|
+
});
|
|
110620
|
+
index = controlStringTerminatorIndex;
|
|
110621
|
+
textStartIndex = index;
|
|
110622
|
+
continue;
|
|
110623
|
+
}
|
|
110624
|
+
const escapeSequence = readEscapeSequence(text, index + 1);
|
|
110625
|
+
if (escapeSequence === void 0) {
|
|
110626
|
+
if (isEscapeIntermediateCharacter(followingCharacter)) return malformedFromIndex(tokens, text, textStartIndex, index);
|
|
110627
|
+
if (index > textStartIndex) tokens.push({
|
|
110628
|
+
type: "text",
|
|
110629
|
+
value: text.slice(textStartIndex, index)
|
|
110630
|
+
});
|
|
110631
|
+
index++;
|
|
110632
|
+
textStartIndex = index;
|
|
110633
|
+
continue;
|
|
110634
|
+
}
|
|
110635
|
+
if (index > textStartIndex) tokens.push({
|
|
110636
|
+
type: "text",
|
|
110637
|
+
value: text.slice(textStartIndex, index)
|
|
110638
|
+
});
|
|
110639
|
+
tokens.push({
|
|
110640
|
+
type: "esc",
|
|
110641
|
+
value: text.slice(index, escapeSequence.endIndex),
|
|
110642
|
+
intermediateString: escapeSequence.intermediateString,
|
|
110643
|
+
finalCharacter: escapeSequence.finalCharacter
|
|
110644
|
+
});
|
|
110645
|
+
index = escapeSequence.endIndex;
|
|
110646
|
+
textStartIndex = index;
|
|
110647
|
+
continue;
|
|
110648
|
+
}
|
|
110649
|
+
if (character === csiCharacter) {
|
|
110650
|
+
const csiSequence = readCsiSequence(text, index + 1);
|
|
110651
|
+
if (csiSequence === void 0) return malformedFromIndex(tokens, text, textStartIndex, index);
|
|
110652
|
+
if (index > textStartIndex) tokens.push({
|
|
110653
|
+
type: "text",
|
|
110654
|
+
value: text.slice(textStartIndex, index)
|
|
110655
|
+
});
|
|
110656
|
+
tokens.push({
|
|
110657
|
+
type: "csi",
|
|
110658
|
+
value: text.slice(index, csiSequence.endIndex),
|
|
110659
|
+
parameterString: csiSequence.parameterString,
|
|
110660
|
+
intermediateString: csiSequence.intermediateString,
|
|
110661
|
+
finalCharacter: csiSequence.finalCharacter
|
|
110662
|
+
});
|
|
110663
|
+
index = csiSequence.endIndex;
|
|
110664
|
+
textStartIndex = index;
|
|
110665
|
+
continue;
|
|
110666
|
+
}
|
|
110667
|
+
const c1ControlString = getControlStringFromC1Introducer(character);
|
|
110668
|
+
if (c1ControlString !== void 0) {
|
|
110669
|
+
const controlStringTerminatorIndex = findControlStringTerminatorIndex(text, index + 1, c1ControlString.allowBellTerminator);
|
|
110670
|
+
if (controlStringTerminatorIndex === void 0) return malformedFromIndex(tokens, text, textStartIndex, index);
|
|
110671
|
+
if (index > textStartIndex) tokens.push({
|
|
110672
|
+
type: "text",
|
|
110673
|
+
value: text.slice(textStartIndex, index)
|
|
110674
|
+
});
|
|
110675
|
+
tokens.push({
|
|
110676
|
+
type: c1ControlString.type,
|
|
110677
|
+
value: text.slice(index, controlStringTerminatorIndex)
|
|
110678
|
+
});
|
|
110679
|
+
index = controlStringTerminatorIndex;
|
|
110680
|
+
textStartIndex = index;
|
|
110681
|
+
continue;
|
|
110682
|
+
}
|
|
110683
|
+
if (character === stringTerminatorCharacter) {
|
|
110684
|
+
if (index > textStartIndex) tokens.push({
|
|
110685
|
+
type: "text",
|
|
110686
|
+
value: text.slice(textStartIndex, index)
|
|
110687
|
+
});
|
|
110688
|
+
tokens.push({
|
|
110689
|
+
type: "st",
|
|
110690
|
+
value: character
|
|
110691
|
+
});
|
|
110692
|
+
index++;
|
|
110693
|
+
textStartIndex = index;
|
|
110694
|
+
continue;
|
|
110695
|
+
}
|
|
110696
|
+
if (isC1ControlCharacter(character)) {
|
|
110697
|
+
if (index > textStartIndex) tokens.push({
|
|
110698
|
+
type: "text",
|
|
110699
|
+
value: text.slice(textStartIndex, index)
|
|
110700
|
+
});
|
|
110701
|
+
tokens.push({
|
|
110702
|
+
type: "c1",
|
|
110703
|
+
value: character
|
|
110704
|
+
});
|
|
110705
|
+
index++;
|
|
110706
|
+
textStartIndex = index;
|
|
110707
|
+
continue;
|
|
110708
|
+
}
|
|
110709
|
+
index++;
|
|
110710
|
+
}
|
|
110711
|
+
if (textStartIndex < text.length) tokens.push({
|
|
110712
|
+
type: "text",
|
|
110713
|
+
value: text.slice(textStartIndex)
|
|
110714
|
+
});
|
|
110715
|
+
return tokens;
|
|
110716
|
+
};
|
|
110717
|
+
|
|
110718
|
+
//#endregion
|
|
110719
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/sanitize-ansi.js
|
|
110720
|
+
const sgrParametersRegex = /^[\d:;]*$/;
|
|
110721
|
+
const sanitizeAnsi = (text) => {
|
|
110722
|
+
if (!hasAnsiControlCharacters(text)) return text;
|
|
110723
|
+
let output = "";
|
|
110724
|
+
for (const token of tokenizeAnsi$1(text)) {
|
|
110725
|
+
if (token.type === "text" || token.type === "osc") {
|
|
110726
|
+
output += token.value;
|
|
110727
|
+
continue;
|
|
110728
|
+
}
|
|
110729
|
+
if (token.type === "csi" && token.finalCharacter === "m" && token.intermediateString === "" && sgrParametersRegex.test(token.parameterString)) output += token.value;
|
|
110730
|
+
}
|
|
110731
|
+
return output;
|
|
110732
|
+
};
|
|
110733
|
+
|
|
110734
|
+
//#endregion
|
|
110735
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/squash-text-nodes.js
|
|
110402
110736
|
const squashTextNodes = (node) => {
|
|
110403
110737
|
let text = "";
|
|
110404
110738
|
for (let index = 0; index < node.childNodes.length; index++) {
|
|
@@ -110412,11 +110746,11 @@ const squashTextNodes = (node) => {
|
|
|
110412
110746
|
}
|
|
110413
110747
|
text += nodeText;
|
|
110414
110748
|
}
|
|
110415
|
-
return text;
|
|
110749
|
+
return sanitizeAnsi(text);
|
|
110416
110750
|
};
|
|
110417
110751
|
|
|
110418
110752
|
//#endregion
|
|
110419
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
110753
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/dom.js
|
|
110420
110754
|
const createNode = (nodeName) => {
|
|
110421
110755
|
const node = {
|
|
110422
110756
|
nodeName,
|
|
@@ -110444,10 +110778,10 @@ const insertBeforeNode = (node, newChildNode, beforeChildNode) => {
|
|
|
110444
110778
|
if (index >= 0) {
|
|
110445
110779
|
node.childNodes.splice(index, 0, newChildNode);
|
|
110446
110780
|
if (newChildNode.yogaNode) node.yogaNode?.insertChild(newChildNode.yogaNode, index);
|
|
110447
|
-
|
|
110781
|
+
} else {
|
|
110782
|
+
node.childNodes.push(newChildNode);
|
|
110783
|
+
if (newChildNode.yogaNode) node.yogaNode?.insertChild(newChildNode.yogaNode, node.yogaNode.getChildCount());
|
|
110448
110784
|
}
|
|
110449
|
-
node.childNodes.push(newChildNode);
|
|
110450
|
-
if (newChildNode.yogaNode) node.yogaNode?.insertChild(newChildNode.yogaNode, node.yogaNode.getChildCount());
|
|
110451
110785
|
if (node.nodeName === "ink-text" || node.nodeName === "ink-virtual-text") markNodeAsDirty(node);
|
|
110452
110786
|
};
|
|
110453
110787
|
const removeChildNode = (node, removeNode) => {
|
|
@@ -110499,7 +110833,7 @@ const setTextNodeValue = (node, text) => {
|
|
|
110499
110833
|
};
|
|
110500
110834
|
|
|
110501
110835
|
//#endregion
|
|
110502
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
110836
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/styles.js
|
|
110503
110837
|
const applyPositionStyles = (node, style) => {
|
|
110504
110838
|
if ("position" in style) node.setPositionType(style.position === "absolute" ? Yoga.POSITION_TYPE_ABSOLUTE : Yoga.POSITION_TYPE_RELATIVE);
|
|
110505
110839
|
};
|
|
@@ -110600,9 +110934,9 @@ const styles$2 = (node, style = {}) => {
|
|
|
110600
110934
|
};
|
|
110601
110935
|
|
|
110602
110936
|
//#endregion
|
|
110603
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
110604
|
-
if (
|
|
110605
|
-
await import("../devtools-
|
|
110937
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/reconciler.js
|
|
110938
|
+
if (isDev()) try {
|
|
110939
|
+
await import("../devtools-BW4iRMC0.js");
|
|
110606
110940
|
} catch (error) {
|
|
110607
110941
|
if (error.code === "ERR_MODULE_NOT_FOUND") console.warn(`
|
|
110608
110942
|
The environment variable DEV is set to true, so Ink tried to import \`react-devtools-core\`,
|
|
@@ -110637,6 +110971,14 @@ const cleanupYogaNode = (node) => {
|
|
|
110637
110971
|
};
|
|
110638
110972
|
let currentUpdatePriority = import_constants.NoEventPriority;
|
|
110639
110973
|
let currentRootNode;
|
|
110974
|
+
async function loadPackageJson() {
|
|
110975
|
+
const content = (await import("node:fs")).readFileSync(new URL("../package.json", import.meta.url), "utf8");
|
|
110976
|
+
return JSON.parse(content);
|
|
110977
|
+
}
|
|
110978
|
+
const packageJson = isDev() ? await loadPackageJson() : {
|
|
110979
|
+
name: void 0,
|
|
110980
|
+
version: void 0
|
|
110981
|
+
};
|
|
110640
110982
|
var reconciler_default = (0, import_react_reconciler.default)({
|
|
110641
110983
|
getRootHostContext: () => ({ isInsideText: false }),
|
|
110642
110984
|
prepareForCommit: () => null,
|
|
@@ -110793,7 +111135,9 @@ var reconciler_default = (0, import_react_reconciler.default)({
|
|
|
110793
111135
|
suspendInstance() {},
|
|
110794
111136
|
waitForCommitToBeReady() {
|
|
110795
111137
|
return null;
|
|
110796
|
-
}
|
|
111138
|
+
},
|
|
111139
|
+
rendererPackageName: packageJson.name,
|
|
111140
|
+
rendererVersion: packageJson.version
|
|
110797
111141
|
});
|
|
110798
111142
|
|
|
110799
111143
|
//#endregion
|
|
@@ -110810,7 +111154,7 @@ function indentString(string, count = 1, options = {}) {
|
|
|
110810
111154
|
}
|
|
110811
111155
|
|
|
110812
111156
|
//#endregion
|
|
110813
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
111157
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/get-max-width.js
|
|
110814
111158
|
const getMaxWidth = (yogaNode) => {
|
|
110815
111159
|
return yogaNode.getComputedWidth() - yogaNode.getComputedPadding(Yoga.EDGE_LEFT) - yogaNode.getComputedPadding(Yoga.EDGE_RIGHT) - yogaNode.getComputedBorder(Yoga.EDGE_LEFT) - yogaNode.getComputedBorder(Yoga.EDGE_RIGHT);
|
|
110816
111160
|
};
|
|
@@ -111318,7 +111662,7 @@ const chalk = createChalk();
|
|
|
111318
111662
|
const chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
111319
111663
|
|
|
111320
111664
|
//#endregion
|
|
111321
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
111665
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/colorize.js
|
|
111322
111666
|
const rgbRegex = /^rgb\(\s?(\d+),\s?(\d+),\s?(\d+)\s?\)$/;
|
|
111323
111667
|
const ansiRegex = /^ansi256\(\s?(\d+)\s?\)$/;
|
|
111324
111668
|
const isNamedColor = (color) => {
|
|
@@ -111349,7 +111693,7 @@ const colorize = (str, color, type) => {
|
|
|
111349
111693
|
};
|
|
111350
111694
|
|
|
111351
111695
|
//#endregion
|
|
111352
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
111696
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/render-border.js
|
|
111353
111697
|
const renderBorder = (x, y, node, output) => {
|
|
111354
111698
|
if (node.style.borderStyle) {
|
|
111355
111699
|
const width = node.yogaNode.getComputedWidth();
|
|
@@ -111388,7 +111732,7 @@ const renderBorder = (x, y, node, output) => {
|
|
|
111388
111732
|
};
|
|
111389
111733
|
|
|
111390
111734
|
//#endregion
|
|
111391
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
111735
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/render-background.js
|
|
111392
111736
|
const renderBackground = (x, y, node, output) => {
|
|
111393
111737
|
if (!node.style.backgroundColor) return;
|
|
111394
111738
|
const width = node.yogaNode.getComputedWidth();
|
|
@@ -111405,7 +111749,7 @@ const renderBackground = (x, y, node, output) => {
|
|
|
111405
111749
|
};
|
|
111406
111750
|
|
|
111407
111751
|
//#endregion
|
|
111408
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
111752
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/render-node-to-output.js
|
|
111409
111753
|
const applyPaddingToText = (node, text) => {
|
|
111410
111754
|
const yogaNode = node.childNodes[0]?.yogaNode;
|
|
111411
111755
|
if (yogaNode) {
|
|
@@ -111495,6 +111839,675 @@ const renderNodeToOutput = (node, output, options) => {
|
|
|
111495
111839
|
}
|
|
111496
111840
|
};
|
|
111497
111841
|
|
|
111842
|
+
//#endregion
|
|
111843
|
+
//#region ../../node_modules/.pnpm/slice-ansi@8.0.0/node_modules/slice-ansi/tokenize-ansi.js
|
|
111844
|
+
const ESCAPE_CODE_POINT = 27;
|
|
111845
|
+
const C1_DCS_CODE_POINT = 144;
|
|
111846
|
+
const C1_SOS_CODE_POINT = 152;
|
|
111847
|
+
const C1_CSI_CODE_POINT = 155;
|
|
111848
|
+
const C1_ST_CODE_POINT = 156;
|
|
111849
|
+
const C1_OSC_CODE_POINT = 157;
|
|
111850
|
+
const C1_PM_CODE_POINT = 158;
|
|
111851
|
+
const C1_APC_CODE_POINT = 159;
|
|
111852
|
+
const ESCAPES$1 = new Set([
|
|
111853
|
+
ESCAPE_CODE_POINT,
|
|
111854
|
+
C1_DCS_CODE_POINT,
|
|
111855
|
+
C1_SOS_CODE_POINT,
|
|
111856
|
+
C1_CSI_CODE_POINT,
|
|
111857
|
+
C1_ST_CODE_POINT,
|
|
111858
|
+
C1_OSC_CODE_POINT,
|
|
111859
|
+
C1_PM_CODE_POINT,
|
|
111860
|
+
C1_APC_CODE_POINT
|
|
111861
|
+
]);
|
|
111862
|
+
const ESCAPE = "\x1B";
|
|
111863
|
+
const ANSI_BELL = "\x07";
|
|
111864
|
+
const ANSI_CSI = "[";
|
|
111865
|
+
const ANSI_OSC = "]";
|
|
111866
|
+
const ANSI_DCS = "P";
|
|
111867
|
+
const ANSI_SOS = "X";
|
|
111868
|
+
const ANSI_PM = "^";
|
|
111869
|
+
const ANSI_APC = "_";
|
|
111870
|
+
const ANSI_SGR_TERMINATOR = "m";
|
|
111871
|
+
const ANSI_OSC_TERMINATOR = "\\";
|
|
111872
|
+
const ANSI_STRING_TERMINATOR = `${ESCAPE}${ANSI_OSC_TERMINATOR}`;
|
|
111873
|
+
const C1_OSC = "";
|
|
111874
|
+
const C1_STRING_TERMINATOR = "";
|
|
111875
|
+
const ANSI_HYPERLINK_ESC_PREFIX = `${ESCAPE}${ANSI_OSC}8;`;
|
|
111876
|
+
const ANSI_HYPERLINK_C1_PREFIX = `${C1_OSC}8;`;
|
|
111877
|
+
const ANSI_HYPERLINK_ESC_CLOSE = `${ANSI_HYPERLINK_ESC_PREFIX};`;
|
|
111878
|
+
const ANSI_HYPERLINK_C1_CLOSE = `${ANSI_HYPERLINK_C1_PREFIX};`;
|
|
111879
|
+
const CODE_POINT_0 = "0".codePointAt(0);
|
|
111880
|
+
const CODE_POINT_9 = "9".codePointAt(0);
|
|
111881
|
+
const CODE_POINT_SEMICOLON = ";".codePointAt(0);
|
|
111882
|
+
const CODE_POINT_COLON = ":".codePointAt(0);
|
|
111883
|
+
const CODE_POINT_CSI_PARAMETER_START = "0".codePointAt(0);
|
|
111884
|
+
const CODE_POINT_CSI_PARAMETER_END = "?".codePointAt(0);
|
|
111885
|
+
const CODE_POINT_CSI_INTERMEDIATE_START = " ".codePointAt(0);
|
|
111886
|
+
const CODE_POINT_CSI_INTERMEDIATE_END = "/".codePointAt(0);
|
|
111887
|
+
const CODE_POINT_CSI_FINAL_START = "@".codePointAt(0);
|
|
111888
|
+
const CODE_POINT_CSI_FINAL_END = "~".codePointAt(0);
|
|
111889
|
+
const REGIONAL_INDICATOR_SYMBOL_LETTER_A = 127462;
|
|
111890
|
+
const REGIONAL_INDICATOR_SYMBOL_LETTER_Z = 127487;
|
|
111891
|
+
const SGR_RESET_CODE = 0;
|
|
111892
|
+
const SGR_EXTENDED_FOREGROUND_CODE = 38;
|
|
111893
|
+
const SGR_DEFAULT_FOREGROUND_CODE = 39;
|
|
111894
|
+
const SGR_EXTENDED_BACKGROUND_CODE = 48;
|
|
111895
|
+
const SGR_DEFAULT_BACKGROUND_CODE = 49;
|
|
111896
|
+
const SGR_COLOR_TYPE_ANSI_256 = 5;
|
|
111897
|
+
const SGR_COLOR_TYPE_TRUECOLOR = 2;
|
|
111898
|
+
const SGR_ANSI_256_FRAGMENT_LENGTH = 3;
|
|
111899
|
+
const SGR_TRUECOLOR_FRAGMENT_LENGTH = 5;
|
|
111900
|
+
const SGR_ANSI_256_LAST_PARAMETER_OFFSET = 2;
|
|
111901
|
+
const SGR_TRUECOLOR_LAST_PARAMETER_OFFSET = 4;
|
|
111902
|
+
const VARIATION_SELECTOR_16_CODE_POINT = 65039;
|
|
111903
|
+
const COMBINING_ENCLOSING_KEYCAP_CODE_POINT = 8419;
|
|
111904
|
+
const EMOJI_PRESENTATION_GRAPHEME_REGEX = /\p{Emoji_Presentation}/u;
|
|
111905
|
+
const GRAPHEME_SEGMENTER = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
111906
|
+
const endCodeNumbers = /* @__PURE__ */ new Set();
|
|
111907
|
+
for (const [, end] of ansiStyles$1.codes) endCodeNumbers.add(end);
|
|
111908
|
+
function isSgrParameterCharacter(codePoint) {
|
|
111909
|
+
return codePoint >= CODE_POINT_0 && codePoint <= CODE_POINT_9 || codePoint === CODE_POINT_SEMICOLON || codePoint === CODE_POINT_COLON;
|
|
111910
|
+
}
|
|
111911
|
+
function isCsiParameterCharacter(codePoint) {
|
|
111912
|
+
return codePoint >= CODE_POINT_CSI_PARAMETER_START && codePoint <= CODE_POINT_CSI_PARAMETER_END;
|
|
111913
|
+
}
|
|
111914
|
+
function isCsiIntermediateCharacter(codePoint) {
|
|
111915
|
+
return codePoint >= CODE_POINT_CSI_INTERMEDIATE_START && codePoint <= CODE_POINT_CSI_INTERMEDIATE_END;
|
|
111916
|
+
}
|
|
111917
|
+
function isCsiFinalCharacter(codePoint) {
|
|
111918
|
+
return codePoint >= CODE_POINT_CSI_FINAL_START && codePoint <= CODE_POINT_CSI_FINAL_END;
|
|
111919
|
+
}
|
|
111920
|
+
function isRegionalIndicatorCodePoint(codePoint) {
|
|
111921
|
+
return codePoint >= REGIONAL_INDICATOR_SYMBOL_LETTER_A && codePoint <= REGIONAL_INDICATOR_SYMBOL_LETTER_Z;
|
|
111922
|
+
}
|
|
111923
|
+
function createControlParseResult(code, endIndex) {
|
|
111924
|
+
return {
|
|
111925
|
+
token: {
|
|
111926
|
+
type: "control",
|
|
111927
|
+
code
|
|
111928
|
+
},
|
|
111929
|
+
endIndex
|
|
111930
|
+
};
|
|
111931
|
+
}
|
|
111932
|
+
function isEmojiStyleGrapheme(grapheme) {
|
|
111933
|
+
if (EMOJI_PRESENTATION_GRAPHEME_REGEX.test(grapheme)) return true;
|
|
111934
|
+
for (const character of grapheme) {
|
|
111935
|
+
const codePoint = character.codePointAt(0);
|
|
111936
|
+
if (codePoint === VARIATION_SELECTOR_16_CODE_POINT || codePoint === COMBINING_ENCLOSING_KEYCAP_CODE_POINT) return true;
|
|
111937
|
+
}
|
|
111938
|
+
return false;
|
|
111939
|
+
}
|
|
111940
|
+
function getGraphemeWidth(grapheme) {
|
|
111941
|
+
let regionalIndicatorCount = 0;
|
|
111942
|
+
for (const character of grapheme) {
|
|
111943
|
+
const codePoint = character.codePointAt(0);
|
|
111944
|
+
if (isFullwidthCodePoint(codePoint)) return 2;
|
|
111945
|
+
if (isRegionalIndicatorCodePoint(codePoint)) regionalIndicatorCount++;
|
|
111946
|
+
}
|
|
111947
|
+
if (regionalIndicatorCount >= 1) return 2;
|
|
111948
|
+
if (isEmojiStyleGrapheme(grapheme)) return 2;
|
|
111949
|
+
return 1;
|
|
111950
|
+
}
|
|
111951
|
+
function getSgrPrefix(code) {
|
|
111952
|
+
if (code.startsWith("")) return "";
|
|
111953
|
+
return `${ESCAPE}${ANSI_CSI}`;
|
|
111954
|
+
}
|
|
111955
|
+
function createSgrCode(prefix, values) {
|
|
111956
|
+
return `${prefix}${values.join(";")}${ANSI_SGR_TERMINATOR}`;
|
|
111957
|
+
}
|
|
111958
|
+
function getSgrFragments(code) {
|
|
111959
|
+
const fragments = [];
|
|
111960
|
+
const sgrPrefix = getSgrPrefix(code);
|
|
111961
|
+
let parameterString;
|
|
111962
|
+
if (code.startsWith(`${ESCAPE}${ANSI_CSI}`)) parameterString = code.slice(2, -1);
|
|
111963
|
+
else if (code.startsWith("")) parameterString = code.slice(1, -1);
|
|
111964
|
+
else return fragments;
|
|
111965
|
+
const rawCodes = parameterString.length === 0 ? [String(SGR_RESET_CODE)] : parameterString.split(";");
|
|
111966
|
+
let index = 0;
|
|
111967
|
+
while (index < rawCodes.length) {
|
|
111968
|
+
const codeNumber = Number.parseInt(rawCodes[index], 10);
|
|
111969
|
+
if (Number.isNaN(codeNumber)) {
|
|
111970
|
+
index++;
|
|
111971
|
+
continue;
|
|
111972
|
+
}
|
|
111973
|
+
if (codeNumber === SGR_RESET_CODE) {
|
|
111974
|
+
fragments.push({ type: "reset" });
|
|
111975
|
+
index++;
|
|
111976
|
+
continue;
|
|
111977
|
+
}
|
|
111978
|
+
if (codeNumber === SGR_EXTENDED_FOREGROUND_CODE || codeNumber === SGR_EXTENDED_BACKGROUND_CODE) {
|
|
111979
|
+
const colorType = Number.parseInt(rawCodes[index + 1], 10);
|
|
111980
|
+
if (colorType === SGR_COLOR_TYPE_ANSI_256 && index + SGR_ANSI_256_LAST_PARAMETER_OFFSET < rawCodes.length) {
|
|
111981
|
+
const openCode = createSgrCode(sgrPrefix, rawCodes.slice(index, index + SGR_ANSI_256_FRAGMENT_LENGTH));
|
|
111982
|
+
fragments.push({
|
|
111983
|
+
type: "start",
|
|
111984
|
+
code: openCode,
|
|
111985
|
+
endCode: ansiStyles$1.color.ansi(codeNumber === SGR_EXTENDED_FOREGROUND_CODE ? SGR_DEFAULT_FOREGROUND_CODE : SGR_DEFAULT_BACKGROUND_CODE)
|
|
111986
|
+
});
|
|
111987
|
+
index += SGR_ANSI_256_FRAGMENT_LENGTH;
|
|
111988
|
+
continue;
|
|
111989
|
+
}
|
|
111990
|
+
if (colorType === SGR_COLOR_TYPE_TRUECOLOR && index + SGR_TRUECOLOR_LAST_PARAMETER_OFFSET < rawCodes.length) {
|
|
111991
|
+
const openCode = createSgrCode(sgrPrefix, rawCodes.slice(index, index + SGR_TRUECOLOR_FRAGMENT_LENGTH));
|
|
111992
|
+
fragments.push({
|
|
111993
|
+
type: "start",
|
|
111994
|
+
code: openCode,
|
|
111995
|
+
endCode: ansiStyles$1.color.ansi(codeNumber === SGR_EXTENDED_FOREGROUND_CODE ? SGR_DEFAULT_FOREGROUND_CODE : SGR_DEFAULT_BACKGROUND_CODE)
|
|
111996
|
+
});
|
|
111997
|
+
index += SGR_TRUECOLOR_FRAGMENT_LENGTH;
|
|
111998
|
+
continue;
|
|
111999
|
+
}
|
|
112000
|
+
const openCode = createSgrCode(sgrPrefix, [rawCodes[index]]);
|
|
112001
|
+
fragments.push({
|
|
112002
|
+
type: "start",
|
|
112003
|
+
code: openCode,
|
|
112004
|
+
endCode: ansiStyles$1.color.ansi(codeNumber === SGR_EXTENDED_FOREGROUND_CODE ? SGR_DEFAULT_FOREGROUND_CODE : SGR_DEFAULT_BACKGROUND_CODE)
|
|
112005
|
+
});
|
|
112006
|
+
index++;
|
|
112007
|
+
continue;
|
|
112008
|
+
}
|
|
112009
|
+
if (endCodeNumbers.has(codeNumber)) {
|
|
112010
|
+
fragments.push({
|
|
112011
|
+
type: "end",
|
|
112012
|
+
endCode: ansiStyles$1.color.ansi(codeNumber)
|
|
112013
|
+
});
|
|
112014
|
+
index++;
|
|
112015
|
+
continue;
|
|
112016
|
+
}
|
|
112017
|
+
const mappedEndCode = ansiStyles$1.codes.get(codeNumber);
|
|
112018
|
+
if (mappedEndCode !== void 0) {
|
|
112019
|
+
const openCode = createSgrCode(sgrPrefix, [rawCodes[index]]);
|
|
112020
|
+
fragments.push({
|
|
112021
|
+
type: "start",
|
|
112022
|
+
code: openCode,
|
|
112023
|
+
endCode: ansiStyles$1.color.ansi(mappedEndCode)
|
|
112024
|
+
});
|
|
112025
|
+
index++;
|
|
112026
|
+
continue;
|
|
112027
|
+
}
|
|
112028
|
+
const openCode = createSgrCode(sgrPrefix, [rawCodes[index]]);
|
|
112029
|
+
fragments.push({
|
|
112030
|
+
type: "start",
|
|
112031
|
+
code: openCode,
|
|
112032
|
+
endCode: ansiStyles$1.reset.open
|
|
112033
|
+
});
|
|
112034
|
+
index++;
|
|
112035
|
+
}
|
|
112036
|
+
if (fragments.length === 0) fragments.push({ type: "reset" });
|
|
112037
|
+
return fragments;
|
|
112038
|
+
}
|
|
112039
|
+
function parseCsiCode(string, index) {
|
|
112040
|
+
const escapeCodePoint = string.codePointAt(index);
|
|
112041
|
+
let sequenceStartIndex;
|
|
112042
|
+
if (escapeCodePoint === ESCAPE_CODE_POINT) {
|
|
112043
|
+
if (string[index + 1] !== ANSI_CSI) return;
|
|
112044
|
+
sequenceStartIndex = index + 2;
|
|
112045
|
+
} else if (escapeCodePoint === C1_CSI_CODE_POINT) sequenceStartIndex = index + 1;
|
|
112046
|
+
else return;
|
|
112047
|
+
let hasCanonicalSgrParameters = true;
|
|
112048
|
+
for (let sequenceIndex = sequenceStartIndex; sequenceIndex < string.length; sequenceIndex++) {
|
|
112049
|
+
const codePoint = string.codePointAt(sequenceIndex);
|
|
112050
|
+
if (isCsiFinalCharacter(codePoint)) {
|
|
112051
|
+
const code = string.slice(index, sequenceIndex + 1);
|
|
112052
|
+
if (string[sequenceIndex] !== ANSI_SGR_TERMINATOR || !hasCanonicalSgrParameters) return createControlParseResult(code, sequenceIndex + 1);
|
|
112053
|
+
return {
|
|
112054
|
+
token: {
|
|
112055
|
+
type: "sgr",
|
|
112056
|
+
code,
|
|
112057
|
+
fragments: getSgrFragments(code)
|
|
112058
|
+
},
|
|
112059
|
+
endIndex: sequenceIndex + 1
|
|
112060
|
+
};
|
|
112061
|
+
}
|
|
112062
|
+
if (isCsiParameterCharacter(codePoint)) {
|
|
112063
|
+
if (!isSgrParameterCharacter(codePoint)) hasCanonicalSgrParameters = false;
|
|
112064
|
+
continue;
|
|
112065
|
+
}
|
|
112066
|
+
if (isCsiIntermediateCharacter(codePoint)) {
|
|
112067
|
+
hasCanonicalSgrParameters = false;
|
|
112068
|
+
continue;
|
|
112069
|
+
}
|
|
112070
|
+
const endIndex = sequenceIndex;
|
|
112071
|
+
return createControlParseResult(string.slice(index, endIndex), endIndex);
|
|
112072
|
+
}
|
|
112073
|
+
return createControlParseResult(string.slice(index), string.length);
|
|
112074
|
+
}
|
|
112075
|
+
function parseHyperlinkCode(string, index) {
|
|
112076
|
+
let hyperlinkPrefix;
|
|
112077
|
+
let hyperlinkClose;
|
|
112078
|
+
const codePoint = string.codePointAt(index);
|
|
112079
|
+
if (codePoint === ESCAPE_CODE_POINT && string.startsWith(ANSI_HYPERLINK_ESC_PREFIX, index)) {
|
|
112080
|
+
hyperlinkPrefix = ANSI_HYPERLINK_ESC_PREFIX;
|
|
112081
|
+
hyperlinkClose = ANSI_HYPERLINK_ESC_CLOSE;
|
|
112082
|
+
} else if (codePoint === C1_OSC_CODE_POINT && string.startsWith(ANSI_HYPERLINK_C1_PREFIX, index)) {
|
|
112083
|
+
hyperlinkPrefix = ANSI_HYPERLINK_C1_PREFIX;
|
|
112084
|
+
hyperlinkClose = ANSI_HYPERLINK_C1_CLOSE;
|
|
112085
|
+
} else return;
|
|
112086
|
+
const uriStart = string.indexOf(";", index + hyperlinkPrefix.length);
|
|
112087
|
+
if (uriStart === -1) return createControlParseResult(string.slice(index), string.length);
|
|
112088
|
+
for (let sequenceIndex = uriStart + 1; sequenceIndex < string.length; sequenceIndex++) {
|
|
112089
|
+
const character = string[sequenceIndex];
|
|
112090
|
+
if (character === ANSI_BELL) return {
|
|
112091
|
+
token: {
|
|
112092
|
+
type: "hyperlink",
|
|
112093
|
+
code: string.slice(index, sequenceIndex + 1),
|
|
112094
|
+
action: sequenceIndex === uriStart + 1 ? "close" : "open",
|
|
112095
|
+
closePrefix: hyperlinkClose,
|
|
112096
|
+
terminator: ANSI_BELL
|
|
112097
|
+
},
|
|
112098
|
+
endIndex: sequenceIndex + 1
|
|
112099
|
+
};
|
|
112100
|
+
if (character === ESCAPE && string[sequenceIndex + 1] === ANSI_OSC_TERMINATOR) return {
|
|
112101
|
+
token: {
|
|
112102
|
+
type: "hyperlink",
|
|
112103
|
+
code: string.slice(index, sequenceIndex + 2),
|
|
112104
|
+
action: sequenceIndex === uriStart + 1 ? "close" : "open",
|
|
112105
|
+
closePrefix: hyperlinkClose,
|
|
112106
|
+
terminator: ANSI_STRING_TERMINATOR
|
|
112107
|
+
},
|
|
112108
|
+
endIndex: sequenceIndex + 2
|
|
112109
|
+
};
|
|
112110
|
+
if (character === C1_STRING_TERMINATOR) return {
|
|
112111
|
+
token: {
|
|
112112
|
+
type: "hyperlink",
|
|
112113
|
+
code: string.slice(index, sequenceIndex + 1),
|
|
112114
|
+
action: sequenceIndex === uriStart + 1 ? "close" : "open",
|
|
112115
|
+
closePrefix: hyperlinkClose,
|
|
112116
|
+
terminator: C1_STRING_TERMINATOR
|
|
112117
|
+
},
|
|
112118
|
+
endIndex: sequenceIndex + 1
|
|
112119
|
+
};
|
|
112120
|
+
}
|
|
112121
|
+
return createControlParseResult(string.slice(index), string.length);
|
|
112122
|
+
}
|
|
112123
|
+
function parseControlStringCode(string, index) {
|
|
112124
|
+
const codePoint = string.codePointAt(index);
|
|
112125
|
+
let sequenceStartIndex;
|
|
112126
|
+
let supportsBellTerminator = false;
|
|
112127
|
+
switch (codePoint) {
|
|
112128
|
+
case ESCAPE_CODE_POINT:
|
|
112129
|
+
switch (string[index + 1]) {
|
|
112130
|
+
case ANSI_OSC:
|
|
112131
|
+
sequenceStartIndex = index + 2;
|
|
112132
|
+
supportsBellTerminator = true;
|
|
112133
|
+
break;
|
|
112134
|
+
case ANSI_DCS:
|
|
112135
|
+
case ANSI_SOS:
|
|
112136
|
+
case ANSI_PM:
|
|
112137
|
+
case ANSI_APC:
|
|
112138
|
+
sequenceStartIndex = index + 2;
|
|
112139
|
+
break;
|
|
112140
|
+
case ANSI_OSC_TERMINATOR: return createControlParseResult(ANSI_STRING_TERMINATOR, index + 2);
|
|
112141
|
+
default: return;
|
|
112142
|
+
}
|
|
112143
|
+
break;
|
|
112144
|
+
case C1_OSC_CODE_POINT:
|
|
112145
|
+
sequenceStartIndex = index + 1;
|
|
112146
|
+
supportsBellTerminator = true;
|
|
112147
|
+
break;
|
|
112148
|
+
case C1_DCS_CODE_POINT:
|
|
112149
|
+
case C1_SOS_CODE_POINT:
|
|
112150
|
+
case C1_PM_CODE_POINT:
|
|
112151
|
+
case C1_APC_CODE_POINT:
|
|
112152
|
+
sequenceStartIndex = index + 1;
|
|
112153
|
+
break;
|
|
112154
|
+
case C1_ST_CODE_POINT: return createControlParseResult(C1_STRING_TERMINATOR, index + 1);
|
|
112155
|
+
default: return;
|
|
112156
|
+
}
|
|
112157
|
+
for (let sequenceIndex = sequenceStartIndex; sequenceIndex < string.length; sequenceIndex++) {
|
|
112158
|
+
if (supportsBellTerminator && string[sequenceIndex] === ANSI_BELL) return createControlParseResult(string.slice(index, sequenceIndex + 1), sequenceIndex + 1);
|
|
112159
|
+
if (string[sequenceIndex] === ESCAPE && string[sequenceIndex + 1] === ANSI_OSC_TERMINATOR) return createControlParseResult(string.slice(index, sequenceIndex + 2), sequenceIndex + 2);
|
|
112160
|
+
if (string[sequenceIndex] === C1_STRING_TERMINATOR) return createControlParseResult(string.slice(index, sequenceIndex + 1), sequenceIndex + 1);
|
|
112161
|
+
}
|
|
112162
|
+
return createControlParseResult(string.slice(index), string.length);
|
|
112163
|
+
}
|
|
112164
|
+
function parseAnsiCode(string, index) {
|
|
112165
|
+
const codePoint = string.codePointAt(index);
|
|
112166
|
+
if (codePoint === ESCAPE_CODE_POINT || codePoint === C1_OSC_CODE_POINT) {
|
|
112167
|
+
const hyperlinkCode = parseHyperlinkCode(string, index);
|
|
112168
|
+
if (hyperlinkCode) return hyperlinkCode;
|
|
112169
|
+
}
|
|
112170
|
+
const controlStringCode = parseControlStringCode(string, index);
|
|
112171
|
+
if (controlStringCode) return controlStringCode;
|
|
112172
|
+
return parseCsiCode(string, index);
|
|
112173
|
+
}
|
|
112174
|
+
function appendTrailingAnsiTokens(string, index, tokens) {
|
|
112175
|
+
while (index < string.length) {
|
|
112176
|
+
const nextCodePoint = string.codePointAt(index);
|
|
112177
|
+
if (!ESCAPES$1.has(nextCodePoint)) break;
|
|
112178
|
+
const escapeCode = parseAnsiCode(string, index);
|
|
112179
|
+
if (!escapeCode) break;
|
|
112180
|
+
tokens.push(escapeCode.token);
|
|
112181
|
+
index = escapeCode.endIndex;
|
|
112182
|
+
}
|
|
112183
|
+
return index;
|
|
112184
|
+
}
|
|
112185
|
+
function parseCharacterTokenWithRawSegmentation(string, index, graphemeSegments) {
|
|
112186
|
+
const segment = graphemeSegments.containing(index);
|
|
112187
|
+
if (!segment || segment.index !== index) return;
|
|
112188
|
+
return {
|
|
112189
|
+
token: {
|
|
112190
|
+
type: "character",
|
|
112191
|
+
value: segment.segment,
|
|
112192
|
+
visibleWidth: getGraphemeWidth(segment.segment),
|
|
112193
|
+
isGraphemeContinuation: false
|
|
112194
|
+
},
|
|
112195
|
+
endIndex: index + segment.segment.length
|
|
112196
|
+
};
|
|
112197
|
+
}
|
|
112198
|
+
function collectVisibleCharacters(string) {
|
|
112199
|
+
const visibleCharacters = [];
|
|
112200
|
+
let index = 0;
|
|
112201
|
+
while (index < string.length) {
|
|
112202
|
+
const codePoint = string.codePointAt(index);
|
|
112203
|
+
if (ESCAPES$1.has(codePoint)) {
|
|
112204
|
+
const code = parseAnsiCode(string, index);
|
|
112205
|
+
if (code) {
|
|
112206
|
+
index = code.endIndex;
|
|
112207
|
+
continue;
|
|
112208
|
+
}
|
|
112209
|
+
}
|
|
112210
|
+
const value = String.fromCodePoint(codePoint);
|
|
112211
|
+
visibleCharacters.push({
|
|
112212
|
+
value,
|
|
112213
|
+
visibleWidth: 1,
|
|
112214
|
+
isGraphemeContinuation: false
|
|
112215
|
+
});
|
|
112216
|
+
index += value.length;
|
|
112217
|
+
}
|
|
112218
|
+
return visibleCharacters;
|
|
112219
|
+
}
|
|
112220
|
+
function applyGraphemeMetadata(visibleCharacters) {
|
|
112221
|
+
if (visibleCharacters.length === 0) return;
|
|
112222
|
+
const visibleString = visibleCharacters.map(({ value }) => value).join("");
|
|
112223
|
+
const scalarOffsets = [];
|
|
112224
|
+
let scalarOffset = 0;
|
|
112225
|
+
for (const visibleCharacter of visibleCharacters) {
|
|
112226
|
+
scalarOffsets.push(scalarOffset);
|
|
112227
|
+
scalarOffset += visibleCharacter.value.length;
|
|
112228
|
+
}
|
|
112229
|
+
let scalarIndex = 0;
|
|
112230
|
+
for (const segment of GRAPHEME_SEGMENTER.segment(visibleString)) {
|
|
112231
|
+
while (scalarIndex < visibleCharacters.length && scalarOffsets[scalarIndex] < segment.index) scalarIndex++;
|
|
112232
|
+
let graphemeIndex = scalarIndex;
|
|
112233
|
+
let isFirstInGrapheme = true;
|
|
112234
|
+
while (graphemeIndex < visibleCharacters.length && scalarOffsets[graphemeIndex] < segment.index + segment.segment.length) {
|
|
112235
|
+
visibleCharacters[graphemeIndex].visibleWidth = isFirstInGrapheme ? getGraphemeWidth(segment.segment) : 0;
|
|
112236
|
+
visibleCharacters[graphemeIndex].isGraphemeContinuation = !isFirstInGrapheme;
|
|
112237
|
+
isFirstInGrapheme = false;
|
|
112238
|
+
graphemeIndex++;
|
|
112239
|
+
}
|
|
112240
|
+
scalarIndex = graphemeIndex;
|
|
112241
|
+
}
|
|
112242
|
+
}
|
|
112243
|
+
function tokenizeAnsiWithVisibleSegmentation(string, { endCharacter = Number.POSITIVE_INFINITY } = {}) {
|
|
112244
|
+
const tokens = [];
|
|
112245
|
+
const visibleCharacters = collectVisibleCharacters(string);
|
|
112246
|
+
applyGraphemeMetadata(visibleCharacters);
|
|
112247
|
+
let index = 0;
|
|
112248
|
+
let visibleCharacterIndex = 0;
|
|
112249
|
+
let visibleCount = 0;
|
|
112250
|
+
while (index < string.length) {
|
|
112251
|
+
const codePoint = string.codePointAt(index);
|
|
112252
|
+
if (ESCAPES$1.has(codePoint)) {
|
|
112253
|
+
const code = parseAnsiCode(string, index);
|
|
112254
|
+
if (code) {
|
|
112255
|
+
tokens.push(code.token);
|
|
112256
|
+
index = code.endIndex;
|
|
112257
|
+
continue;
|
|
112258
|
+
}
|
|
112259
|
+
}
|
|
112260
|
+
const value = String.fromCodePoint(codePoint);
|
|
112261
|
+
const visibleCharacter = visibleCharacters[visibleCharacterIndex];
|
|
112262
|
+
let visibleWidth = isFullwidthCodePoint(codePoint) ? 2 : value.length;
|
|
112263
|
+
if (visibleCharacter) visibleWidth = visibleCharacter.visibleWidth;
|
|
112264
|
+
const token = {
|
|
112265
|
+
type: "character",
|
|
112266
|
+
value,
|
|
112267
|
+
visibleWidth,
|
|
112268
|
+
isGraphemeContinuation: visibleCharacter ? visibleCharacter.isGraphemeContinuation : false
|
|
112269
|
+
};
|
|
112270
|
+
tokens.push(token);
|
|
112271
|
+
index += value.length;
|
|
112272
|
+
visibleCharacterIndex++;
|
|
112273
|
+
visibleCount += token.visibleWidth;
|
|
112274
|
+
if (visibleCount >= endCharacter) {
|
|
112275
|
+
const nextVisibleCharacter = visibleCharacters[visibleCharacterIndex];
|
|
112276
|
+
if (!nextVisibleCharacter || !nextVisibleCharacter.isGraphemeContinuation) {
|
|
112277
|
+
index = appendTrailingAnsiTokens(string, index, tokens);
|
|
112278
|
+
break;
|
|
112279
|
+
}
|
|
112280
|
+
}
|
|
112281
|
+
}
|
|
112282
|
+
return tokens;
|
|
112283
|
+
}
|
|
112284
|
+
function areValuesInSameGrapheme(leftValue, rightValue) {
|
|
112285
|
+
const pair = `${leftValue}${rightValue}`;
|
|
112286
|
+
const splitIndex = leftValue.length;
|
|
112287
|
+
for (const segment of GRAPHEME_SEGMENTER.segment(pair)) {
|
|
112288
|
+
if (segment.index === splitIndex) return false;
|
|
112289
|
+
if (segment.index > splitIndex) return true;
|
|
112290
|
+
}
|
|
112291
|
+
return true;
|
|
112292
|
+
}
|
|
112293
|
+
function hasAnsiSplitContinuationAhead(string, startIndex, previousVisibleValue, graphemeSegments) {
|
|
112294
|
+
if (!previousVisibleValue) return false;
|
|
112295
|
+
let index = startIndex;
|
|
112296
|
+
let hasAnsiCode = false;
|
|
112297
|
+
while (index < string.length) {
|
|
112298
|
+
const codePoint = string.codePointAt(index);
|
|
112299
|
+
if (ESCAPES$1.has(codePoint)) {
|
|
112300
|
+
const code = parseAnsiCode(string, index);
|
|
112301
|
+
if (code) {
|
|
112302
|
+
hasAnsiCode = true;
|
|
112303
|
+
index = code.endIndex;
|
|
112304
|
+
continue;
|
|
112305
|
+
}
|
|
112306
|
+
}
|
|
112307
|
+
if (!hasAnsiCode) return false;
|
|
112308
|
+
const characterToken = parseCharacterTokenWithRawSegmentation(string, index, graphemeSegments);
|
|
112309
|
+
if (!characterToken) return true;
|
|
112310
|
+
return areValuesInSameGrapheme(previousVisibleValue, characterToken.token.value);
|
|
112311
|
+
}
|
|
112312
|
+
return false;
|
|
112313
|
+
}
|
|
112314
|
+
function tokenizeAnsi(string, { endCharacter = Number.POSITIVE_INFINITY } = {}) {
|
|
112315
|
+
const tokens = [];
|
|
112316
|
+
const graphemeSegments = GRAPHEME_SEGMENTER.segment(string);
|
|
112317
|
+
let index = 0;
|
|
112318
|
+
let visibleCount = 0;
|
|
112319
|
+
let previousVisibleValue;
|
|
112320
|
+
let hasAnsiSinceLastVisible = false;
|
|
112321
|
+
while (index < string.length) {
|
|
112322
|
+
const codePoint = string.codePointAt(index);
|
|
112323
|
+
if (ESCAPES$1.has(codePoint)) {
|
|
112324
|
+
const code = parseAnsiCode(string, index);
|
|
112325
|
+
if (code) {
|
|
112326
|
+
tokens.push(code.token);
|
|
112327
|
+
index = code.endIndex;
|
|
112328
|
+
hasAnsiSinceLastVisible = true;
|
|
112329
|
+
continue;
|
|
112330
|
+
}
|
|
112331
|
+
}
|
|
112332
|
+
const characterToken = parseCharacterTokenWithRawSegmentation(string, index, graphemeSegments);
|
|
112333
|
+
if (!characterToken) return tokenizeAnsiWithVisibleSegmentation(string, { endCharacter });
|
|
112334
|
+
if (hasAnsiSinceLastVisible && previousVisibleValue && areValuesInSameGrapheme(previousVisibleValue, characterToken.token.value)) return tokenizeAnsiWithVisibleSegmentation(string, { endCharacter });
|
|
112335
|
+
tokens.push(characterToken.token);
|
|
112336
|
+
index = characterToken.endIndex;
|
|
112337
|
+
visibleCount += characterToken.token.visibleWidth;
|
|
112338
|
+
hasAnsiSinceLastVisible = false;
|
|
112339
|
+
previousVisibleValue = characterToken.token.value;
|
|
112340
|
+
if (visibleCount >= endCharacter) {
|
|
112341
|
+
if (hasAnsiSplitContinuationAhead(string, index, previousVisibleValue, graphemeSegments)) return tokenizeAnsiWithVisibleSegmentation(string, { endCharacter });
|
|
112342
|
+
index = appendTrailingAnsiTokens(string, index, tokens);
|
|
112343
|
+
break;
|
|
112344
|
+
}
|
|
112345
|
+
}
|
|
112346
|
+
return tokens;
|
|
112347
|
+
}
|
|
112348
|
+
|
|
112349
|
+
//#endregion
|
|
112350
|
+
//#region ../../node_modules/.pnpm/slice-ansi@8.0.0/node_modules/slice-ansi/index.js
|
|
112351
|
+
function applySgrFragments(activeStyles, fragments) {
|
|
112352
|
+
for (const fragment of fragments) switch (fragment.type) {
|
|
112353
|
+
case "reset":
|
|
112354
|
+
activeStyles.clear();
|
|
112355
|
+
break;
|
|
112356
|
+
case "end":
|
|
112357
|
+
activeStyles.delete(fragment.endCode);
|
|
112358
|
+
break;
|
|
112359
|
+
case "start":
|
|
112360
|
+
activeStyles.delete(fragment.endCode);
|
|
112361
|
+
activeStyles.set(fragment.endCode, fragment.code);
|
|
112362
|
+
break;
|
|
112363
|
+
default: break;
|
|
112364
|
+
}
|
|
112365
|
+
return activeStyles;
|
|
112366
|
+
}
|
|
112367
|
+
function undoAnsiCodes$1(activeStyles) {
|
|
112368
|
+
return [...activeStyles.keys()].reverse().join("");
|
|
112369
|
+
}
|
|
112370
|
+
function closeHyperlink(hyperlinkToken) {
|
|
112371
|
+
return `${hyperlinkToken.closePrefix}${hyperlinkToken.terminator}`;
|
|
112372
|
+
}
|
|
112373
|
+
function shouldIncludeSgrAfterEnd(token, activeStyles) {
|
|
112374
|
+
let hasStartFragment = false;
|
|
112375
|
+
let hasClosingEffect = false;
|
|
112376
|
+
for (const fragment of token.fragments) {
|
|
112377
|
+
if (fragment.type === "start") {
|
|
112378
|
+
hasStartFragment = true;
|
|
112379
|
+
continue;
|
|
112380
|
+
}
|
|
112381
|
+
if (fragment.type === "reset" && activeStyles.size > 0) {
|
|
112382
|
+
hasClosingEffect = true;
|
|
112383
|
+
continue;
|
|
112384
|
+
}
|
|
112385
|
+
if (fragment.type === "end" && activeStyles.has(fragment.endCode)) hasClosingEffect = true;
|
|
112386
|
+
}
|
|
112387
|
+
return hasClosingEffect && !hasStartFragment;
|
|
112388
|
+
}
|
|
112389
|
+
function applySgrToken({ token, isPastEnd, activeStyles, returnValue, include, activeHyperlink, position }) {
|
|
112390
|
+
if (isPastEnd && !shouldIncludeSgrAfterEnd(token, activeStyles)) return {
|
|
112391
|
+
activeStyles,
|
|
112392
|
+
activeHyperlink,
|
|
112393
|
+
position,
|
|
112394
|
+
returnValue,
|
|
112395
|
+
include
|
|
112396
|
+
};
|
|
112397
|
+
activeStyles = applySgrFragments(activeStyles, token.fragments);
|
|
112398
|
+
if (include) returnValue += token.code;
|
|
112399
|
+
return {
|
|
112400
|
+
activeStyles,
|
|
112401
|
+
activeHyperlink,
|
|
112402
|
+
position,
|
|
112403
|
+
returnValue,
|
|
112404
|
+
include
|
|
112405
|
+
};
|
|
112406
|
+
}
|
|
112407
|
+
function applyHyperlinkToken({ token, isPastEnd, activeStyles, activeHyperlink, position, returnValue, include }) {
|
|
112408
|
+
if (isPastEnd && (token.action !== "close" || !activeHyperlink)) return {
|
|
112409
|
+
activeStyles,
|
|
112410
|
+
activeHyperlink,
|
|
112411
|
+
position,
|
|
112412
|
+
returnValue,
|
|
112413
|
+
include
|
|
112414
|
+
};
|
|
112415
|
+
if (token.action === "open") activeHyperlink = token;
|
|
112416
|
+
else if (token.action === "close") activeHyperlink = void 0;
|
|
112417
|
+
if (include) returnValue += token.code;
|
|
112418
|
+
return {
|
|
112419
|
+
activeStyles,
|
|
112420
|
+
activeHyperlink,
|
|
112421
|
+
position,
|
|
112422
|
+
returnValue,
|
|
112423
|
+
include
|
|
112424
|
+
};
|
|
112425
|
+
}
|
|
112426
|
+
function applyControlToken({ token, isPastEnd, activeStyles, activeHyperlink, position, returnValue, include }) {
|
|
112427
|
+
if (!isPastEnd && include) returnValue += token.code;
|
|
112428
|
+
return {
|
|
112429
|
+
activeStyles,
|
|
112430
|
+
activeHyperlink,
|
|
112431
|
+
position,
|
|
112432
|
+
returnValue,
|
|
112433
|
+
include
|
|
112434
|
+
};
|
|
112435
|
+
}
|
|
112436
|
+
function applyCharacterToken({ token, start, activeStyles, activeHyperlink, position, returnValue, include }) {
|
|
112437
|
+
if (!include && position >= start && !token.isGraphemeContinuation) {
|
|
112438
|
+
include = true;
|
|
112439
|
+
returnValue = [...activeStyles.values()].join("");
|
|
112440
|
+
if (activeHyperlink) returnValue += activeHyperlink.code;
|
|
112441
|
+
}
|
|
112442
|
+
if (include) returnValue += token.value;
|
|
112443
|
+
position += token.visibleWidth;
|
|
112444
|
+
return {
|
|
112445
|
+
activeStyles,
|
|
112446
|
+
activeHyperlink,
|
|
112447
|
+
position,
|
|
112448
|
+
returnValue,
|
|
112449
|
+
include
|
|
112450
|
+
};
|
|
112451
|
+
}
|
|
112452
|
+
const tokenHandlers = {
|
|
112453
|
+
sgr: applySgrToken,
|
|
112454
|
+
hyperlink: applyHyperlinkToken,
|
|
112455
|
+
control: applyControlToken,
|
|
112456
|
+
character: applyCharacterToken
|
|
112457
|
+
};
|
|
112458
|
+
function applyToken(parameters) {
|
|
112459
|
+
const tokenHandler = tokenHandlers[parameters.token.type];
|
|
112460
|
+
if (!tokenHandler) {
|
|
112461
|
+
const { activeStyles, activeHyperlink, position, returnValue, include } = parameters;
|
|
112462
|
+
return {
|
|
112463
|
+
activeStyles,
|
|
112464
|
+
activeHyperlink,
|
|
112465
|
+
position,
|
|
112466
|
+
returnValue,
|
|
112467
|
+
include
|
|
112468
|
+
};
|
|
112469
|
+
}
|
|
112470
|
+
return tokenHandler(parameters);
|
|
112471
|
+
}
|
|
112472
|
+
function createHasContinuationAheadMap(tokens) {
|
|
112473
|
+
const hasContinuationAhead = Array.from({ length: tokens.length }, () => false);
|
|
112474
|
+
let nextCharacterIsContinuation = false;
|
|
112475
|
+
for (let tokenIndex = tokens.length - 1; tokenIndex >= 0; tokenIndex--) {
|
|
112476
|
+
const token = tokens[tokenIndex];
|
|
112477
|
+
hasContinuationAhead[tokenIndex] = nextCharacterIsContinuation;
|
|
112478
|
+
if (token.type === "character") nextCharacterIsContinuation = Boolean(token.isGraphemeContinuation);
|
|
112479
|
+
}
|
|
112480
|
+
return hasContinuationAhead;
|
|
112481
|
+
}
|
|
112482
|
+
function sliceAnsi(string, start, end) {
|
|
112483
|
+
const tokens = tokenizeAnsi(string, { endCharacter: end });
|
|
112484
|
+
const hasContinuationAhead = createHasContinuationAheadMap(tokens);
|
|
112485
|
+
let activeStyles = /* @__PURE__ */ new Map();
|
|
112486
|
+
let activeHyperlink;
|
|
112487
|
+
let position = 0;
|
|
112488
|
+
let returnValue = "";
|
|
112489
|
+
let include = false;
|
|
112490
|
+
for (const [tokenIndex, token] of tokens.entries()) {
|
|
112491
|
+
let isPastEnd = end !== void 0 && position >= end;
|
|
112492
|
+
if (isPastEnd && token.type !== "character" && hasContinuationAhead[tokenIndex]) isPastEnd = false;
|
|
112493
|
+
if (isPastEnd && token.type === "character" && !token.isGraphemeContinuation) break;
|
|
112494
|
+
({activeStyles, activeHyperlink, position, returnValue, include} = applyToken({
|
|
112495
|
+
token,
|
|
112496
|
+
isPastEnd,
|
|
112497
|
+
start,
|
|
112498
|
+
activeStyles,
|
|
112499
|
+
activeHyperlink,
|
|
112500
|
+
position,
|
|
112501
|
+
returnValue,
|
|
112502
|
+
include
|
|
112503
|
+
}));
|
|
112504
|
+
}
|
|
112505
|
+
if (!include) return "";
|
|
112506
|
+
if (activeHyperlink) returnValue += closeHyperlink(activeHyperlink);
|
|
112507
|
+
returnValue += undoAnsiCodes$1(activeStyles);
|
|
112508
|
+
return returnValue;
|
|
112509
|
+
}
|
|
112510
|
+
|
|
111498
112511
|
//#endregion
|
|
111499
112512
|
//#region ../../node_modules/.pnpm/@alcalzone+ansi-tokenize@0.2.5/node_modules/@alcalzone/ansi-tokenize/build/ansiCodes.js
|
|
111500
112513
|
const ESCAPES = new Set([27, 155]);
|
|
@@ -111713,11 +112726,43 @@ function tokenize(str, endChar = Number.POSITIVE_INFINITY) {
|
|
|
111713
112726
|
}
|
|
111714
112727
|
|
|
111715
112728
|
//#endregion
|
|
111716
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
112729
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/output.js
|
|
112730
|
+
var OutputCaches = class {
|
|
112731
|
+
widths = /* @__PURE__ */ new Map();
|
|
112732
|
+
blockWidths = /* @__PURE__ */ new Map();
|
|
112733
|
+
styledChars = /* @__PURE__ */ new Map();
|
|
112734
|
+
getStyledChars(line) {
|
|
112735
|
+
let cached = this.styledChars.get(line);
|
|
112736
|
+
if (cached === void 0) {
|
|
112737
|
+
cached = styledCharsFromTokens(tokenize(line));
|
|
112738
|
+
this.styledChars.set(line, cached);
|
|
112739
|
+
}
|
|
112740
|
+
return cached;
|
|
112741
|
+
}
|
|
112742
|
+
getStringWidth(text) {
|
|
112743
|
+
let cached = this.widths.get(text);
|
|
112744
|
+
if (cached === void 0) {
|
|
112745
|
+
cached = stringWidth(text);
|
|
112746
|
+
this.widths.set(text, cached);
|
|
112747
|
+
}
|
|
112748
|
+
return cached;
|
|
112749
|
+
}
|
|
112750
|
+
getWidestLine(text) {
|
|
112751
|
+
let cached = this.blockWidths.get(text);
|
|
112752
|
+
if (cached === void 0) {
|
|
112753
|
+
let lineWidth = 0;
|
|
112754
|
+
for (const line of text.split("\n")) lineWidth = Math.max(lineWidth, this.getStringWidth(line));
|
|
112755
|
+
cached = lineWidth;
|
|
112756
|
+
this.blockWidths.set(text, cached);
|
|
112757
|
+
}
|
|
112758
|
+
return cached;
|
|
112759
|
+
}
|
|
112760
|
+
};
|
|
111717
112761
|
var Output = class {
|
|
111718
112762
|
width;
|
|
111719
112763
|
height;
|
|
111720
112764
|
operations = [];
|
|
112765
|
+
caches = new OutputCaches();
|
|
111721
112766
|
constructor(options) {
|
|
111722
112767
|
const { width, height } = options;
|
|
111723
112768
|
this.width = width;
|
|
@@ -111768,7 +112813,7 @@ var Output = class {
|
|
|
111768
112813
|
const clipHorizontally = typeof clip?.x1 === "number" && typeof clip?.x2 === "number";
|
|
111769
112814
|
const clipVertically = typeof clip?.y1 === "number" && typeof clip?.y2 === "number";
|
|
111770
112815
|
if (clipHorizontally) {
|
|
111771
|
-
const width =
|
|
112816
|
+
const width = this.caches.getWidestLine(text);
|
|
111772
112817
|
if (x + width < clip.x1 || x > clip.x2) continue;
|
|
111773
112818
|
}
|
|
111774
112819
|
if (clipVertically) {
|
|
@@ -111778,7 +112823,7 @@ var Output = class {
|
|
|
111778
112823
|
if (clipHorizontally) {
|
|
111779
112824
|
lines = lines.map((line) => {
|
|
111780
112825
|
const from = x < clip.x1 ? clip.x1 - x : 0;
|
|
111781
|
-
const width =
|
|
112826
|
+
const width = this.caches.getStringWidth(line);
|
|
111782
112827
|
return sliceAnsi(line, from, x + width > clip.x2 ? clip.x2 - x : width);
|
|
111783
112828
|
});
|
|
111784
112829
|
if (x < clip.x1) x = clip.x1;
|
|
@@ -111796,11 +112841,11 @@ var Output = class {
|
|
|
111796
112841
|
const currentLine = output[y + offsetY];
|
|
111797
112842
|
if (!currentLine) continue;
|
|
111798
112843
|
for (const transformer of transformers) line = transformer(line, index);
|
|
111799
|
-
const characters =
|
|
112844
|
+
const characters = this.caches.getStyledChars(line);
|
|
111800
112845
|
let offsetX = x;
|
|
111801
112846
|
for (const character of characters) {
|
|
111802
112847
|
currentLine[offsetX] = character;
|
|
111803
|
-
const characterWidth = Math.max(1,
|
|
112848
|
+
const characterWidth = Math.max(1, this.caches.getStringWidth(character.value));
|
|
111804
112849
|
if (characterWidth > 1) for (let index = 1; index < characterWidth; index++) currentLine[offsetX + index] = {
|
|
111805
112850
|
type: "char",
|
|
111806
112851
|
value: "",
|
|
@@ -111823,7 +112868,7 @@ var Output = class {
|
|
|
111823
112868
|
};
|
|
111824
112869
|
|
|
111825
112870
|
//#endregion
|
|
111826
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
112871
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/renderer.js
|
|
111827
112872
|
const renderer = (node, isScreenReaderEnabled) => {
|
|
111828
112873
|
if (node.yogaNode) {
|
|
111829
112874
|
if (isScreenReaderEnabled) {
|
|
@@ -111936,7 +112981,7 @@ cliCursor.toggle = (force, writableStream) => {
|
|
|
111936
112981
|
};
|
|
111937
112982
|
|
|
111938
112983
|
//#endregion
|
|
111939
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
112984
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/cursor-helpers.js
|
|
111940
112985
|
const showCursorEscape = "\x1B[?25h";
|
|
111941
112986
|
const hideCursorEscape = "\x1B[?25l";
|
|
111942
112987
|
/**
|
|
@@ -111981,7 +113026,7 @@ const buildReturnToBottomPrefix = (cursorWasShown, previousLineCount, previousCu
|
|
|
111981
113026
|
};
|
|
111982
113027
|
|
|
111983
113028
|
//#endregion
|
|
111984
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
113029
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/log-update.js
|
|
111985
113030
|
const visibleLineCount = (lines, str) => str.endsWith("\n") ? lines.length - 1 : lines.length;
|
|
111986
113031
|
const createStandard = (stream, { showCursor = false } = {}) => {
|
|
111987
113032
|
let previousLineCount = 0;
|
|
@@ -112177,7 +113222,7 @@ const create = (stream, { showCursor = false, incremental = false } = {}) => {
|
|
|
112177
113222
|
const logUpdate = { create };
|
|
112178
113223
|
|
|
112179
113224
|
//#endregion
|
|
112180
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
113225
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/write-synchronized.js
|
|
112181
113226
|
const bsu = "\x1B[?2026h";
|
|
112182
113227
|
const esu = "\x1B[?2026l";
|
|
112183
113228
|
function shouldSynchronize(stream) {
|
|
@@ -112185,11 +113230,134 @@ function shouldSynchronize(stream) {
|
|
|
112185
113230
|
}
|
|
112186
113231
|
|
|
112187
113232
|
//#endregion
|
|
112188
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
113233
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/instances.js
|
|
112189
113234
|
const instances = /* @__PURE__ */ new WeakMap();
|
|
112190
113235
|
|
|
112191
113236
|
//#endregion
|
|
112192
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
113237
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/input-parser.js
|
|
113238
|
+
const escape$2 = "\x1B";
|
|
113239
|
+
const isCsiParameterByte = (byte) => {
|
|
113240
|
+
return byte >= 48 && byte <= 63;
|
|
113241
|
+
};
|
|
113242
|
+
const isCsiIntermediateByte = (byte) => {
|
|
113243
|
+
return byte >= 32 && byte <= 47;
|
|
113244
|
+
};
|
|
113245
|
+
const isCsiFinalByte = (byte) => {
|
|
113246
|
+
return byte >= 64 && byte <= 126;
|
|
113247
|
+
};
|
|
113248
|
+
const parseCsiSequence = (input, startIndex, prefixLength) => {
|
|
113249
|
+
const csiPayloadStart = startIndex + prefixLength + 1;
|
|
113250
|
+
let index = csiPayloadStart;
|
|
113251
|
+
for (; index < input.length; index++) {
|
|
113252
|
+
const byte = input.codePointAt(index);
|
|
113253
|
+
if (byte === void 0) return "pending";
|
|
113254
|
+
if (isCsiParameterByte(byte) || isCsiIntermediateByte(byte)) continue;
|
|
113255
|
+
if (byte === 91 && index === csiPayloadStart) continue;
|
|
113256
|
+
if (isCsiFinalByte(byte)) return {
|
|
113257
|
+
sequence: input.slice(startIndex, index + 1),
|
|
113258
|
+
nextIndex: index + 1
|
|
113259
|
+
};
|
|
113260
|
+
return;
|
|
113261
|
+
}
|
|
113262
|
+
return "pending";
|
|
113263
|
+
};
|
|
113264
|
+
const parseSs3Sequence = (input, startIndex, prefixLength) => {
|
|
113265
|
+
const nextIndex = startIndex + prefixLength + 2;
|
|
113266
|
+
if (nextIndex > input.length) return "pending";
|
|
113267
|
+
const finalByte = input.codePointAt(nextIndex - 1);
|
|
113268
|
+
if (finalByte === void 0 || !isCsiFinalByte(finalByte)) return;
|
|
113269
|
+
return {
|
|
113270
|
+
sequence: input.slice(startIndex, nextIndex),
|
|
113271
|
+
nextIndex
|
|
113272
|
+
};
|
|
113273
|
+
};
|
|
113274
|
+
const parseControlSequence = (input, startIndex, prefixLength) => {
|
|
113275
|
+
const sequenceType = input[startIndex + prefixLength];
|
|
113276
|
+
if (sequenceType === void 0) return "pending";
|
|
113277
|
+
if (sequenceType === "[") return parseCsiSequence(input, startIndex, prefixLength);
|
|
113278
|
+
if (sequenceType === "O") return parseSs3Sequence(input, startIndex, prefixLength);
|
|
113279
|
+
};
|
|
113280
|
+
const parseEscapedCodePoint = (input, escapeIndex) => {
|
|
113281
|
+
const nextCodePoint = input.codePointAt(escapeIndex + 1);
|
|
113282
|
+
const nextCodePointLength = nextCodePoint !== void 0 && nextCodePoint > 65535 ? 2 : 1;
|
|
113283
|
+
const nextIndex = escapeIndex + 1 + nextCodePointLength;
|
|
113284
|
+
return {
|
|
113285
|
+
sequence: input.slice(escapeIndex, nextIndex),
|
|
113286
|
+
nextIndex
|
|
113287
|
+
};
|
|
113288
|
+
};
|
|
113289
|
+
const parseKeypresses = (input) => {
|
|
113290
|
+
const events = [];
|
|
113291
|
+
let index = 0;
|
|
113292
|
+
const pendingFrom = (pendingStartIndex) => ({
|
|
113293
|
+
events,
|
|
113294
|
+
pending: input.slice(pendingStartIndex)
|
|
113295
|
+
});
|
|
113296
|
+
while (index < input.length) {
|
|
113297
|
+
const escapeIndex = input.indexOf(escape$2, index);
|
|
113298
|
+
if (escapeIndex === -1) {
|
|
113299
|
+
events.push(input.slice(index));
|
|
113300
|
+
return {
|
|
113301
|
+
events,
|
|
113302
|
+
pending: ""
|
|
113303
|
+
};
|
|
113304
|
+
}
|
|
113305
|
+
if (escapeIndex > index) events.push(input.slice(index, escapeIndex));
|
|
113306
|
+
if (escapeIndex === input.length - 1) return pendingFrom(escapeIndex);
|
|
113307
|
+
const parsedSequence = parseControlSequence(input, escapeIndex, 1);
|
|
113308
|
+
if (parsedSequence === "pending") return pendingFrom(escapeIndex);
|
|
113309
|
+
if (parsedSequence) {
|
|
113310
|
+
events.push(parsedSequence.sequence);
|
|
113311
|
+
index = parsedSequence.nextIndex;
|
|
113312
|
+
continue;
|
|
113313
|
+
}
|
|
113314
|
+
if (input[escapeIndex + 1] === escape$2) {
|
|
113315
|
+
if (escapeIndex + 2 >= input.length) return pendingFrom(escapeIndex);
|
|
113316
|
+
const doubleEscapeSequence = parseControlSequence(input, escapeIndex, 2);
|
|
113317
|
+
if (doubleEscapeSequence === "pending") return pendingFrom(escapeIndex);
|
|
113318
|
+
if (doubleEscapeSequence) {
|
|
113319
|
+
events.push(doubleEscapeSequence.sequence);
|
|
113320
|
+
index = doubleEscapeSequence.nextIndex;
|
|
113321
|
+
continue;
|
|
113322
|
+
}
|
|
113323
|
+
events.push(input.slice(escapeIndex, escapeIndex + 2));
|
|
113324
|
+
index = escapeIndex + 2;
|
|
113325
|
+
continue;
|
|
113326
|
+
}
|
|
113327
|
+
const escapedCodePoint = parseEscapedCodePoint(input, escapeIndex);
|
|
113328
|
+
events.push(escapedCodePoint.sequence);
|
|
113329
|
+
index = escapedCodePoint.nextIndex;
|
|
113330
|
+
}
|
|
113331
|
+
return {
|
|
113332
|
+
events,
|
|
113333
|
+
pending: ""
|
|
113334
|
+
};
|
|
113335
|
+
};
|
|
113336
|
+
const createInputParser = () => {
|
|
113337
|
+
let pending = "";
|
|
113338
|
+
return {
|
|
113339
|
+
push(chunk) {
|
|
113340
|
+
const parsedInput = parseKeypresses(pending + chunk);
|
|
113341
|
+
pending = parsedInput.pending;
|
|
113342
|
+
return parsedInput.events;
|
|
113343
|
+
},
|
|
113344
|
+
hasPendingEscape() {
|
|
113345
|
+
return pending.startsWith(escape$2);
|
|
113346
|
+
},
|
|
113347
|
+
flushPendingEscape() {
|
|
113348
|
+
if (!pending.startsWith(escape$2)) return;
|
|
113349
|
+
const pendingEscape = pending;
|
|
113350
|
+
pending = "";
|
|
113351
|
+
return pendingEscape;
|
|
113352
|
+
},
|
|
113353
|
+
reset() {
|
|
113354
|
+
pending = "";
|
|
113355
|
+
}
|
|
113356
|
+
};
|
|
113357
|
+
};
|
|
113358
|
+
|
|
113359
|
+
//#endregion
|
|
113360
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/components/AppContext.js
|
|
112193
113361
|
/**
|
|
112194
113362
|
`AppContext` is a React context that exposes a method to manually exit the app (unmount).
|
|
112195
113363
|
*/
|
|
@@ -112197,7 +113365,7 @@ const AppContext = (0, import_react.createContext)({ exit() {} });
|
|
|
112197
113365
|
AppContext.displayName = "InternalAppContext";
|
|
112198
113366
|
|
|
112199
113367
|
//#endregion
|
|
112200
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
113368
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/components/StdinContext.js
|
|
112201
113369
|
/**
|
|
112202
113370
|
`StdinContext` is a React context that exposes the input stream.
|
|
112203
113371
|
*/
|
|
@@ -112211,7 +113379,7 @@ const StdinContext = (0, import_react.createContext)({
|
|
|
112211
113379
|
StdinContext.displayName = "InternalStdinContext";
|
|
112212
113380
|
|
|
112213
113381
|
//#endregion
|
|
112214
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
113382
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/components/StdoutContext.js
|
|
112215
113383
|
/**
|
|
112216
113384
|
`StdoutContext` is a React context that exposes the stdout stream where Ink renders your app.
|
|
112217
113385
|
*/
|
|
@@ -112222,7 +113390,7 @@ const StdoutContext = (0, import_react.createContext)({
|
|
|
112222
113390
|
StdoutContext.displayName = "InternalStdoutContext";
|
|
112223
113391
|
|
|
112224
113392
|
//#endregion
|
|
112225
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
113393
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/components/StderrContext.js
|
|
112226
113394
|
/**
|
|
112227
113395
|
`StderrContext` is a React context that exposes the stderr stream.
|
|
112228
113396
|
*/
|
|
@@ -112233,7 +113401,7 @@ const StderrContext = (0, import_react.createContext)({
|
|
|
112233
113401
|
StderrContext.displayName = "InternalStderrContext";
|
|
112234
113402
|
|
|
112235
113403
|
//#endregion
|
|
112236
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
113404
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/components/FocusContext.js
|
|
112237
113405
|
const FocusContext = (0, import_react.createContext)({
|
|
112238
113406
|
activeId: void 0,
|
|
112239
113407
|
add() {},
|
|
@@ -112249,7 +113417,7 @@ const FocusContext = (0, import_react.createContext)({
|
|
|
112249
113417
|
FocusContext.displayName = "InternalFocusContext";
|
|
112250
113418
|
|
|
112251
113419
|
//#endregion
|
|
112252
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
113420
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/components/CursorContext.js
|
|
112253
113421
|
const CursorContext = (0, import_react.createContext)({ setCursorPosition() {} });
|
|
112254
113422
|
CursorContext.displayName = "InternalCursorContext";
|
|
112255
113423
|
|
|
@@ -112475,15 +113643,15 @@ const codeExcerpt = (source, line, options = {}) => {
|
|
|
112475
113643
|
};
|
|
112476
113644
|
|
|
112477
113645
|
//#endregion
|
|
112478
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
113646
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/components/AccessibilityContext.js
|
|
112479
113647
|
const accessibilityContext = (0, import_react.createContext)({ isScreenReaderEnabled: false });
|
|
112480
113648
|
|
|
112481
113649
|
//#endregion
|
|
112482
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
113650
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/components/BackgroundContext.js
|
|
112483
113651
|
const backgroundContext = (0, import_react.createContext)(void 0);
|
|
112484
113652
|
|
|
112485
113653
|
//#endregion
|
|
112486
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
113654
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/components/Box.js
|
|
112487
113655
|
/**
|
|
112488
113656
|
`<Box>` is an essential Ink component to build your layout. It's like `<div style="display: flex">` in the browser.
|
|
112489
113657
|
*/
|
|
@@ -112514,7 +113682,7 @@ const Box = (0, import_react.forwardRef)(({ children, backgroundColor, "aria-lab
|
|
|
112514
113682
|
Box.displayName = "Box";
|
|
112515
113683
|
|
|
112516
113684
|
//#endregion
|
|
112517
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
113685
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/components/Text.js
|
|
112518
113686
|
/**
|
|
112519
113687
|
This component can display text and change its style to make it bold, underlined, italic, or strikethrough.
|
|
112520
113688
|
*/
|
|
@@ -112548,7 +113716,7 @@ function Text({ color, backgroundColor, dimColor = false, bold = false, italic =
|
|
|
112548
113716
|
}
|
|
112549
113717
|
|
|
112550
113718
|
//#endregion
|
|
112551
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
113719
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/components/ErrorOverview.js
|
|
112552
113720
|
const cleanupPath = (path) => {
|
|
112553
113721
|
return path?.replace(`file://${cwd()}/`, "");
|
|
112554
113722
|
};
|
|
@@ -112605,7 +113773,7 @@ function ErrorOverview({ error }) {
|
|
|
112605
113773
|
}
|
|
112606
113774
|
|
|
112607
113775
|
//#endregion
|
|
112608
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
113776
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/components/ErrorBoundary.js
|
|
112609
113777
|
var ErrorBoundary = class extends import_react.PureComponent {
|
|
112610
113778
|
static displayName = "InternalErrorBoundary";
|
|
112611
113779
|
static getDerivedStateFromError(error) {
|
|
@@ -112622,7 +113790,7 @@ var ErrorBoundary = class extends import_react.PureComponent {
|
|
|
112622
113790
|
};
|
|
112623
113791
|
|
|
112624
113792
|
//#endregion
|
|
112625
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
113793
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/components/App.js
|
|
112626
113794
|
const tab = " ";
|
|
112627
113795
|
const shiftTab = "\x1B[Z";
|
|
112628
113796
|
const escape$1 = "\x1B";
|
|
@@ -112635,21 +113803,37 @@ function App({ children, stdin, stdout, stderr, writeToStdout, writeToStderr, ex
|
|
|
112635
113803
|
const internal_eventEmitter = (0, import_react.useRef)(new EventEmitter());
|
|
112636
113804
|
internal_eventEmitter.current.setMaxListeners(Infinity);
|
|
112637
113805
|
const readableListenerRef = (0, import_react.useRef)(void 0);
|
|
113806
|
+
const inputParserRef = (0, import_react.useRef)(createInputParser());
|
|
113807
|
+
const pendingInputFlushRef = (0, import_react.useRef)(void 0);
|
|
113808
|
+
const clearPendingInputFlush = (0, import_react.useCallback)(() => {
|
|
113809
|
+
if (!pendingInputFlushRef.current) return;
|
|
113810
|
+
clearImmediate(pendingInputFlushRef.current);
|
|
113811
|
+
pendingInputFlushRef.current = void 0;
|
|
113812
|
+
}, []);
|
|
112638
113813
|
const isRawModeSupported = stdin.isTTY;
|
|
112639
|
-
const
|
|
112640
|
-
if (
|
|
112641
|
-
|
|
112642
|
-
|
|
112643
|
-
|
|
112644
|
-
|
|
112645
|
-
|
|
112646
|
-
|
|
112647
|
-
|
|
112648
|
-
|
|
112649
|
-
|
|
113814
|
+
const detachReadableListener = (0, import_react.useCallback)(() => {
|
|
113815
|
+
if (!readableListenerRef.current) return;
|
|
113816
|
+
stdin.removeListener("readable", readableListenerRef.current);
|
|
113817
|
+
readableListenerRef.current = void 0;
|
|
113818
|
+
}, [stdin]);
|
|
113819
|
+
const disableRawMode = (0, import_react.useCallback)(() => {
|
|
113820
|
+
stdin.setRawMode(false);
|
|
113821
|
+
detachReadableListener();
|
|
113822
|
+
stdin.unref();
|
|
113823
|
+
rawModeEnabledCount.current = 0;
|
|
113824
|
+
inputParserRef.current.reset();
|
|
113825
|
+
clearPendingInputFlush();
|
|
112650
113826
|
}, [
|
|
112651
|
-
isRawModeSupported,
|
|
112652
113827
|
stdin,
|
|
113828
|
+
detachReadableListener,
|
|
113829
|
+
clearPendingInputFlush
|
|
113830
|
+
]);
|
|
113831
|
+
const handleExit = (0, import_react.useCallback)((errorOrResult) => {
|
|
113832
|
+
if (isRawModeSupported && rawModeEnabledCount.current > 0) disableRawMode();
|
|
113833
|
+
onExit(errorOrResult);
|
|
113834
|
+
}, [
|
|
113835
|
+
isRawModeSupported,
|
|
113836
|
+
disableRawMode,
|
|
112653
113837
|
onExit
|
|
112654
113838
|
]);
|
|
112655
113839
|
const handleInput = (0, import_react.useCallback)((input) => {
|
|
@@ -112662,13 +113846,33 @@ function App({ children, stdin, stdout, stderr, writeToStdout, writeToStderr, ex
|
|
|
112662
113846
|
return currentActiveFocusId;
|
|
112663
113847
|
});
|
|
112664
113848
|
}, [exitOnCtrlC, handleExit]);
|
|
113849
|
+
const emitInput = (0, import_react.useCallback)((input) => {
|
|
113850
|
+
handleInput(input);
|
|
113851
|
+
internal_eventEmitter.current.emit("input", input);
|
|
113852
|
+
}, [handleInput]);
|
|
113853
|
+
const schedulePendingInputFlush = (0, import_react.useCallback)(() => {
|
|
113854
|
+
clearPendingInputFlush();
|
|
113855
|
+
pendingInputFlushRef.current = setImmediate(() => {
|
|
113856
|
+
pendingInputFlushRef.current = void 0;
|
|
113857
|
+
const pendingEscape = inputParserRef.current.flushPendingEscape();
|
|
113858
|
+
if (!pendingEscape) return;
|
|
113859
|
+
emitInput(pendingEscape);
|
|
113860
|
+
});
|
|
113861
|
+
}, [clearPendingInputFlush, emitInput]);
|
|
112665
113862
|
const handleReadable = (0, import_react.useCallback)(() => {
|
|
113863
|
+
clearPendingInputFlush();
|
|
112666
113864
|
let chunk;
|
|
112667
113865
|
while ((chunk = stdin.read()) !== null) {
|
|
112668
|
-
|
|
112669
|
-
|
|
113866
|
+
const inputEvents = inputParserRef.current.push(chunk);
|
|
113867
|
+
for (const input of inputEvents) emitInput(input);
|
|
112670
113868
|
}
|
|
112671
|
-
|
|
113869
|
+
if (inputParserRef.current.hasPendingEscape()) schedulePendingInputFlush();
|
|
113870
|
+
}, [
|
|
113871
|
+
stdin,
|
|
113872
|
+
emitInput,
|
|
113873
|
+
clearPendingInputFlush,
|
|
113874
|
+
schedulePendingInputFlush
|
|
113875
|
+
]);
|
|
112672
113876
|
const handleSetRawMode = (0, import_react.useCallback)((isEnabled) => {
|
|
112673
113877
|
if (!isRawModeSupported) if (stdin === process$1.stdin) throw new Error("Raw mode is not supported on the current process.stdin, which Ink uses as input stream by default.\nRead about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported");
|
|
112674
113878
|
else throw new Error("Raw mode is not supported on the stdin provided to Ink.\nRead about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported");
|
|
@@ -112683,18 +113887,13 @@ function App({ children, stdin, stdout, stderr, writeToStdout, writeToStderr, ex
|
|
|
112683
113887
|
rawModeEnabledCount.current++;
|
|
112684
113888
|
return;
|
|
112685
113889
|
}
|
|
112686
|
-
if (
|
|
112687
|
-
|
|
112688
|
-
if (readableListenerRef.current) {
|
|
112689
|
-
stdin.removeListener("readable", readableListenerRef.current);
|
|
112690
|
-
readableListenerRef.current = void 0;
|
|
112691
|
-
}
|
|
112692
|
-
stdin.unref();
|
|
112693
|
-
}
|
|
113890
|
+
if (rawModeEnabledCount.current === 0) return;
|
|
113891
|
+
if (--rawModeEnabledCount.current === 0) disableRawMode();
|
|
112694
113892
|
}, [
|
|
112695
113893
|
isRawModeSupported,
|
|
112696
113894
|
stdin,
|
|
112697
|
-
handleReadable
|
|
113895
|
+
handleReadable,
|
|
113896
|
+
disableRawMode
|
|
112698
113897
|
]);
|
|
112699
113898
|
const findNextFocusable = (0, import_react.useCallback)((currentFocusables, currentActiveFocusId) => {
|
|
112700
113899
|
const activeIndex = currentFocusables.findIndex((focusable) => {
|
|
@@ -112811,19 +114010,12 @@ function App({ children, stdin, stdout, stderr, writeToStdout, writeToStderr, ex
|
|
|
112811
114010
|
(0, import_react.useEffect)(() => {
|
|
112812
114011
|
return () => {
|
|
112813
114012
|
cliCursor.show(stdout);
|
|
112814
|
-
if (isRawModeSupported && rawModeEnabledCount.current > 0)
|
|
112815
|
-
stdin.setRawMode(false);
|
|
112816
|
-
if (readableListenerRef.current) {
|
|
112817
|
-
stdin.removeListener("readable", readableListenerRef.current);
|
|
112818
|
-
readableListenerRef.current = void 0;
|
|
112819
|
-
}
|
|
112820
|
-
stdin.unref();
|
|
112821
|
-
}
|
|
114013
|
+
if (isRawModeSupported && rawModeEnabledCount.current > 0) disableRawMode();
|
|
112822
114014
|
};
|
|
112823
114015
|
}, [
|
|
112824
114016
|
stdout,
|
|
112825
|
-
|
|
112826
|
-
|
|
114017
|
+
isRawModeSupported,
|
|
114018
|
+
disableRawMode
|
|
112827
114019
|
]);
|
|
112828
114020
|
const appContextValue = (0, import_react.useMemo)(() => ({ exit: handleExit }), [handleExit]);
|
|
112829
114021
|
const stdinContextValue = (0, import_react.useMemo)(() => ({
|
|
@@ -112875,7 +114067,7 @@ function App({ children, stdin, stdout, stderr, writeToStdout, writeToStderr, ex
|
|
|
112875
114067
|
App.displayName = "InternalApp";
|
|
112876
114068
|
|
|
112877
114069
|
//#endregion
|
|
112878
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
114070
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/kitty-keyboard.js
|
|
112879
114071
|
const kittyFlags = {
|
|
112880
114072
|
disambiguateEscapeCodes: 1,
|
|
112881
114073
|
reportEventTypes: 2,
|
|
@@ -112900,8 +114092,49 @@ const kittyModifiers = {
|
|
|
112900
114092
|
};
|
|
112901
114093
|
|
|
112902
114094
|
//#endregion
|
|
112903
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
114095
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/ink.js
|
|
112904
114096
|
const noop = () => {};
|
|
114097
|
+
const kittyQueryEscapeByte = 27;
|
|
114098
|
+
const kittyQueryOpenBracketByte = 91;
|
|
114099
|
+
const kittyQueryQuestionMarkByte = 63;
|
|
114100
|
+
const kittyQueryLetterByte = 117;
|
|
114101
|
+
const zeroByte = 48;
|
|
114102
|
+
const nineByte = 57;
|
|
114103
|
+
const isDigitByte = (byte) => byte >= zeroByte && byte <= nineByte;
|
|
114104
|
+
const matchKittyQueryResponse = (buffer, startIndex) => {
|
|
114105
|
+
if (buffer[startIndex] !== kittyQueryEscapeByte || buffer[startIndex + 1] !== kittyQueryOpenBracketByte || buffer[startIndex + 2] !== kittyQueryQuestionMarkByte) return;
|
|
114106
|
+
let index = startIndex + 3;
|
|
114107
|
+
const digitsStartIndex = index;
|
|
114108
|
+
while (index < buffer.length && isDigitByte(buffer[index])) index++;
|
|
114109
|
+
if (index === digitsStartIndex) return;
|
|
114110
|
+
if (index === buffer.length) return { state: "partial" };
|
|
114111
|
+
if (buffer[index] === kittyQueryLetterByte) return {
|
|
114112
|
+
state: "complete",
|
|
114113
|
+
endIndex: index
|
|
114114
|
+
};
|
|
114115
|
+
};
|
|
114116
|
+
const hasCompleteKittyQueryResponse = (buffer) => {
|
|
114117
|
+
for (let index = 0; index < buffer.length; index++) if (matchKittyQueryResponse(buffer, index)?.state === "complete") return true;
|
|
114118
|
+
return false;
|
|
114119
|
+
};
|
|
114120
|
+
const stripKittyQueryResponsesAndTrailingPartial = (buffer) => {
|
|
114121
|
+
const keptBytes = [];
|
|
114122
|
+
let index = 0;
|
|
114123
|
+
while (index < buffer.length) {
|
|
114124
|
+
const match = matchKittyQueryResponse(buffer, index);
|
|
114125
|
+
if (match?.state === "complete") {
|
|
114126
|
+
index = match.endIndex + 1;
|
|
114127
|
+
continue;
|
|
114128
|
+
}
|
|
114129
|
+
if (match?.state === "partial") break;
|
|
114130
|
+
keptBytes.push(buffer[index]);
|
|
114131
|
+
index++;
|
|
114132
|
+
}
|
|
114133
|
+
return keptBytes;
|
|
114134
|
+
};
|
|
114135
|
+
const isErrorInput = (value) => {
|
|
114136
|
+
return value instanceof Error || Object.prototype.toString.call(value) === "[object Error]";
|
|
114137
|
+
};
|
|
112905
114138
|
var Ink = class {
|
|
112906
114139
|
/**
|
|
112907
114140
|
Whether this instance is using concurrent rendering mode.
|
|
@@ -112913,6 +114146,7 @@ var Ink = class {
|
|
|
112913
114146
|
throttledLog;
|
|
112914
114147
|
isScreenReaderEnabled;
|
|
112915
114148
|
isUnmounted;
|
|
114149
|
+
isUnmounting;
|
|
112916
114150
|
lastOutput;
|
|
112917
114151
|
lastOutputToRender;
|
|
112918
114152
|
lastOutputHeight;
|
|
@@ -112921,10 +114155,12 @@ var Ink = class {
|
|
|
112921
114155
|
rootNode;
|
|
112922
114156
|
fullStaticOutput;
|
|
112923
114157
|
exitPromise;
|
|
114158
|
+
exitResult;
|
|
112924
114159
|
beforeExitHandler;
|
|
112925
114160
|
restoreConsole;
|
|
112926
114161
|
unsubscribeResize;
|
|
112927
114162
|
throttledOnRender;
|
|
114163
|
+
hasPendingThrottledRender = false;
|
|
112928
114164
|
kittyProtocolEnabled = false;
|
|
112929
114165
|
cancelKittyDetection;
|
|
112930
114166
|
constructor(options) {
|
|
@@ -112944,7 +114180,10 @@ var Ink = class {
|
|
|
112944
114180
|
leading: true,
|
|
112945
114181
|
trailing: true
|
|
112946
114182
|
});
|
|
112947
|
-
this.rootNode.onRender =
|
|
114183
|
+
this.rootNode.onRender = () => {
|
|
114184
|
+
this.hasPendingThrottledRender = true;
|
|
114185
|
+
throttled();
|
|
114186
|
+
};
|
|
112948
114187
|
this.throttledOnRender = throttled;
|
|
112949
114188
|
}
|
|
112950
114189
|
this.rootNode.onImmediateRender = this.onRender;
|
|
@@ -112961,6 +114200,7 @@ var Ink = class {
|
|
|
112961
114200
|
trailing: true
|
|
112962
114201
|
});
|
|
112963
114202
|
this.isUnmounted = false;
|
|
114203
|
+
this.isUnmounting = false;
|
|
112964
114204
|
this.isConcurrent = options.concurrent ?? false;
|
|
112965
114205
|
this.lastOutput = "";
|
|
112966
114206
|
this.lastOutputToRender = "";
|
|
@@ -112970,11 +114210,7 @@ var Ink = class {
|
|
|
112970
114210
|
const rootTag = options.concurrent ? import_constants.ConcurrentRoot : import_constants.LegacyRoot;
|
|
112971
114211
|
this.container = reconciler_default.createContainer(this.rootNode, rootTag, null, false, null, "id", () => {}, () => {}, () => {}, () => {});
|
|
112972
114212
|
this.unsubscribeExit = (0, import_signal_exit.default)(this.unmount, { alwaysLast: false });
|
|
112973
|
-
if (
|
|
112974
|
-
bundleType: 0,
|
|
112975
|
-
version: "16.13.1",
|
|
112976
|
-
rendererPackageName: "ink"
|
|
112977
|
-
});
|
|
114213
|
+
if (isDev()) reconciler_default.injectIntoDevTools();
|
|
112978
114214
|
if (options.patchConsole) this.patchConsole();
|
|
112979
114215
|
if (!isInCi) {
|
|
112980
114216
|
options.stdout.on("resize", this.resized);
|
|
@@ -113002,6 +114238,15 @@ var Ink = class {
|
|
|
113002
114238
|
resolveExitPromise = () => {};
|
|
113003
114239
|
rejectExitPromise = () => {};
|
|
113004
114240
|
unsubscribeExit = () => {};
|
|
114241
|
+
handleAppExit = (errorOrResult) => {
|
|
114242
|
+
if (this.isUnmounted || this.isUnmounting) return;
|
|
114243
|
+
if (isErrorInput(errorOrResult)) {
|
|
114244
|
+
this.unmount(errorOrResult);
|
|
114245
|
+
return;
|
|
114246
|
+
}
|
|
114247
|
+
this.exitResult = errorOrResult;
|
|
114248
|
+
this.unmount();
|
|
114249
|
+
};
|
|
113005
114250
|
setCursorPosition = (position) => {
|
|
113006
114251
|
this.cursorPosition = position;
|
|
113007
114252
|
this.log.setCursorPosition(position);
|
|
@@ -113016,6 +114261,7 @@ var Ink = class {
|
|
|
113016
114261
|
this.rootNode.yogaNode.calculateLayout(void 0, void 0, Yoga.DIRECTION_LTR);
|
|
113017
114262
|
};
|
|
113018
114263
|
onRender = () => {
|
|
114264
|
+
this.hasPendingThrottledRender = false;
|
|
113019
114265
|
if (this.isUnmounted) return;
|
|
113020
114266
|
const startTime = performance.now();
|
|
113021
114267
|
const { output, outputHeight, staticOutput } = renderer(this.rootNode, this.isScreenReaderEnabled);
|
|
@@ -113094,7 +114340,7 @@ var Ink = class {
|
|
|
113094
114340
|
writeToStdout: this.writeToStdout,
|
|
113095
114341
|
writeToStderr: this.writeToStderr,
|
|
113096
114342
|
setCursorPosition: this.setCursorPosition,
|
|
113097
|
-
onExit: this.
|
|
114343
|
+
onExit: this.handleAppExit
|
|
113098
114344
|
}, node));
|
|
113099
114345
|
if (this.options.concurrent) reconciler_default.updateContainer(tree, this.container, null, noop);
|
|
113100
114346
|
else {
|
|
@@ -113138,41 +114384,56 @@ var Ink = class {
|
|
|
113138
114384
|
if (sync) this.options.stdout.write(esu);
|
|
113139
114385
|
}
|
|
113140
114386
|
unmount(error) {
|
|
113141
|
-
if (this.isUnmounted) return;
|
|
114387
|
+
if (this.isUnmounted || this.isUnmounting) return;
|
|
114388
|
+
this.isUnmounting = true;
|
|
113142
114389
|
if (this.beforeExitHandler) {
|
|
113143
114390
|
process$1.off("beforeExit", this.beforeExitHandler);
|
|
113144
114391
|
this.beforeExitHandler = void 0;
|
|
113145
114392
|
}
|
|
113146
|
-
|
|
113147
|
-
|
|
113148
|
-
|
|
114393
|
+
const stdout = this.options.stdout;
|
|
114394
|
+
const canWriteToStdout = !stdout.destroyed && !stdout.writableEnded && (stdout.writable ?? true);
|
|
114395
|
+
const settleThrottle = (throttled) => {
|
|
114396
|
+
if (typeof throttled.flush !== "function") return;
|
|
114397
|
+
if (canWriteToStdout) throttled.flush();
|
|
114398
|
+
else if (typeof throttled.cancel === "function") throttled.cancel();
|
|
114399
|
+
};
|
|
114400
|
+
settleThrottle(this.throttledOnRender ?? {});
|
|
114401
|
+
if (canWriteToStdout) {
|
|
114402
|
+
if (!this.throttledOnRender || !this.hasPendingThrottledRender && this.fullStaticOutput === "") {
|
|
114403
|
+
this.calculateLayout();
|
|
114404
|
+
this.onRender();
|
|
114405
|
+
}
|
|
114406
|
+
}
|
|
114407
|
+
this.isUnmounted = true;
|
|
113149
114408
|
this.unsubscribeExit();
|
|
113150
114409
|
if (typeof this.restoreConsole === "function") this.restoreConsole();
|
|
113151
114410
|
if (typeof this.unsubscribeResize === "function") this.unsubscribeResize();
|
|
113152
|
-
const throttledLog = this.throttledLog;
|
|
113153
|
-
if (typeof throttledLog.flush === "function") throttledLog.flush();
|
|
113154
114411
|
if (this.cancelKittyDetection) this.cancelKittyDetection();
|
|
113155
|
-
|
|
113156
|
-
|
|
114412
|
+
const throttledLog = this.throttledLog;
|
|
114413
|
+
settleThrottle(throttledLog);
|
|
114414
|
+
if (canWriteToStdout) {
|
|
114415
|
+
if (this.kittyProtocolEnabled) try {
|
|
113157
114416
|
this.options.stdout.write("\x1B[<u");
|
|
113158
114417
|
} catch {}
|
|
113159
|
-
this.
|
|
114418
|
+
if (isInCi) this.options.stdout.write(this.lastOutput + "\n");
|
|
114419
|
+
else if (!this.options.debug) this.log.done();
|
|
113160
114420
|
}
|
|
113161
|
-
|
|
113162
|
-
else if (!this.options.debug) this.log.done();
|
|
113163
|
-
this.isUnmounted = true;
|
|
114421
|
+
this.kittyProtocolEnabled = false;
|
|
113164
114422
|
if (this.options.concurrent) reconciler_default.updateContainer(null, this.container, null, noop);
|
|
113165
114423
|
else {
|
|
113166
114424
|
reconciler_default.updateContainerSync(null, this.container, null, noop);
|
|
113167
114425
|
reconciler_default.flushSyncWork();
|
|
113168
114426
|
}
|
|
113169
114427
|
instances.delete(this.options.stdout);
|
|
114428
|
+
const { exitResult } = this;
|
|
113170
114429
|
const resolveOrReject = () => {
|
|
113171
|
-
if (error
|
|
113172
|
-
else this.resolveExitPromise();
|
|
114430
|
+
if (isErrorInput(error)) this.rejectExitPromise(error);
|
|
114431
|
+
else this.resolveExitPromise(exitResult);
|
|
113173
114432
|
};
|
|
113174
|
-
|
|
113175
|
-
|
|
114433
|
+
const isProcessExiting = error !== void 0 && !isErrorInput(error);
|
|
114434
|
+
const hasWritableState = stdout._writableState !== void 0 || stdout.writableLength !== void 0;
|
|
114435
|
+
if (isProcessExiting) resolveOrReject();
|
|
114436
|
+
else if (canWriteToStdout && hasWritableState) this.options.stdout.write("", resolveOrReject);
|
|
113176
114437
|
else setImmediate(resolveOrReject);
|
|
113177
114438
|
}
|
|
113178
114439
|
async waitUntilExit() {
|
|
@@ -113220,18 +114481,19 @@ var Ink = class {
|
|
|
113220
114481
|
}
|
|
113221
114482
|
confirmKittySupport(flags) {
|
|
113222
114483
|
const { stdin, stdout } = this.options;
|
|
113223
|
-
let responseBuffer =
|
|
114484
|
+
let responseBuffer = [];
|
|
113224
114485
|
const cleanup = () => {
|
|
113225
114486
|
this.cancelKittyDetection = void 0;
|
|
113226
114487
|
clearTimeout(timer);
|
|
113227
114488
|
stdin.removeListener("data", onData);
|
|
113228
|
-
const remaining = responseBuffer
|
|
113229
|
-
responseBuffer =
|
|
113230
|
-
if (remaining) stdin.unshift(Buffer.from(remaining));
|
|
114489
|
+
const remaining = stripKittyQueryResponsesAndTrailingPartial(responseBuffer);
|
|
114490
|
+
responseBuffer = [];
|
|
114491
|
+
if (remaining.length > 0) stdin.unshift(Buffer.from(remaining));
|
|
113231
114492
|
};
|
|
113232
114493
|
const onData = (data) => {
|
|
113233
|
-
|
|
113234
|
-
|
|
114494
|
+
const chunk = typeof data === "string" ? Buffer.from(data) : data;
|
|
114495
|
+
for (const byte of chunk) responseBuffer.push(byte);
|
|
114496
|
+
if (hasCompleteKittyQueryResponse(responseBuffer)) {
|
|
113235
114497
|
cleanup();
|
|
113236
114498
|
if (!this.isUnmounted) this.enableKittyProtocol(flags);
|
|
113237
114499
|
}
|
|
@@ -113248,7 +114510,7 @@ var Ink = class {
|
|
|
113248
114510
|
};
|
|
113249
114511
|
|
|
113250
114512
|
//#endregion
|
|
113251
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
114513
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/render.js
|
|
113252
114514
|
/**
|
|
113253
114515
|
Mount a component and render the output.
|
|
113254
114516
|
*/
|
|
@@ -113294,7 +114556,7 @@ const getInstance = (stdout, createInstance, concurrent) => {
|
|
|
113294
114556
|
};
|
|
113295
114557
|
|
|
113296
114558
|
//#endregion
|
|
113297
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
114559
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/components/Static.js
|
|
113298
114560
|
/**
|
|
113299
114561
|
`<Static>` component permanently renders its output above everything else. It's useful for displaying activity like completed tasks or logs—things that don't change after they're rendered (hence the name "Static").
|
|
113300
114562
|
|
|
@@ -113326,7 +114588,7 @@ function Static(props) {
|
|
|
113326
114588
|
}
|
|
113327
114589
|
|
|
113328
114590
|
//#endregion
|
|
113329
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
114591
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/parse-keypress.js
|
|
113330
114592
|
const metaKeyCodeRe = /^(?:\x1b)([a-zA-Z0-9])$/;
|
|
113331
114593
|
const fnKeyRe = /^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/;
|
|
113332
114594
|
const keyName = {
|
|
@@ -113719,14 +114981,14 @@ const parseKeypress = (s = "") => {
|
|
|
113719
114981
|
};
|
|
113720
114982
|
|
|
113721
114983
|
//#endregion
|
|
113722
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
114984
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/hooks/use-stdin.js
|
|
113723
114985
|
/**
|
|
113724
114986
|
`useStdin` is a React hook that exposes the stdin stream.
|
|
113725
114987
|
*/
|
|
113726
114988
|
const useStdin = () => (0, import_react.useContext)(StdinContext);
|
|
113727
114989
|
|
|
113728
114990
|
//#endregion
|
|
113729
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
114991
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/hooks/use-input.js
|
|
113730
114992
|
/**
|
|
113731
114993
|
This hook is used for handling user input. It's a more convenient alternative to using `StdinContext` and listening for `data` events. The callback you pass to `useInput` is called for each character when the user enters any input. However, if the user pastes text and it's more than one character, the callback will be called only once, and the whole string will be passed as `input`.
|
|
113732
114994
|
|
|
@@ -113810,7 +115072,7 @@ const useInput = (inputHandler, options = {}) => {
|
|
|
113810
115072
|
};
|
|
113811
115073
|
|
|
113812
115074
|
//#endregion
|
|
113813
|
-
//#region ../../node_modules/.pnpm/ink@6.
|
|
115075
|
+
//#region ../../node_modules/.pnpm/ink@6.8.0_@types+react@19.2.14_react@19.2.4/node_modules/ink/build/hooks/use-app.js
|
|
113814
115076
|
/**
|
|
113815
115077
|
`useApp` is a React hook that exposes a method to manually exit the app (unmount).
|
|
113816
115078
|
*/
|
|
@@ -113887,7 +115149,7 @@ const INDICATOR = {
|
|
|
113887
115149
|
BULLET: "●",
|
|
113888
115150
|
ELLIPSIS: "..."
|
|
113889
115151
|
};
|
|
113890
|
-
const STOP_EVENT_TYPES = ["stopRunByInteractiveTool"
|
|
115152
|
+
const STOP_EVENT_TYPES = ["stopRunByInteractiveTool"];
|
|
113891
115153
|
const KEY_BINDINGS = {
|
|
113892
115154
|
NAVIGATE_UP: "↑",
|
|
113893
115155
|
NAVIGATE_DOWN: "↓",
|
|
@@ -114471,7 +115733,6 @@ const BrowsingEventsInput = ({ checkpoint, events, onEventSelect, onBack }) => /
|
|
|
114471
115733
|
|
|
114472
115734
|
//#endregion
|
|
114473
115735
|
//#region ../../packages/react/src/utils/event-to-activity.ts
|
|
114474
|
-
const TOOL_RESULT_EVENT_TYPES = new Set(["resolveToolResults", "attemptCompletion"]);
|
|
114475
115736
|
/**
|
|
114476
115737
|
* Converts a tool call and result to an Activity.
|
|
114477
115738
|
* Delegates to core's createBaseToolActivity/createGeneralToolActivity to avoid duplication.
|
|
@@ -114513,7 +115774,6 @@ const isToolCallsEvent = (event) => event.type === "callTools" && "toolCalls" in
|
|
|
114513
115774
|
const isStopRunByDelegateEvent = (event) => event.type === "stopRunByDelegate" && "checkpoint" in event;
|
|
114514
115775
|
const isStopRunByInteractiveToolEvent = (event) => event.type === "stopRunByInteractiveTool" && "checkpoint" in event;
|
|
114515
115776
|
const isToolResultsEvent = (event) => event.type === "resolveToolResults" && "toolResults" in event;
|
|
114516
|
-
const isToolResultEvent = (event) => TOOL_RESULT_EVENT_TYPES.has(event.type) && "toolResult" in event;
|
|
114517
115777
|
/**
|
|
114518
115778
|
* Wraps multiple activities in a ParallelActivitiesGroup with shared reasoning.
|
|
114519
115779
|
* If only one activity, returns it directly.
|
|
@@ -114754,22 +116014,6 @@ function processRunEventToActivity(state, event, addActivity) {
|
|
|
114754
116014
|
for (const item of wrapped) addActivity(item);
|
|
114755
116015
|
runState.completedReasoning = void 0;
|
|
114756
116016
|
}
|
|
114757
|
-
} else if (isToolResultEvent(event)) {
|
|
114758
|
-
const { toolResult } = event;
|
|
114759
|
-
const tool = state.tools.get(toolResult.id);
|
|
114760
|
-
if (tool && !tool.logged) {
|
|
114761
|
-
const activityId = `action-${tool.id}`;
|
|
114762
|
-
addActivity(toolToActivity(tool.toolCall, toolResult, runState.completedReasoning, {
|
|
114763
|
-
id: activityId,
|
|
114764
|
-
expertKey: event.expertKey,
|
|
114765
|
-
runId: event.runId,
|
|
114766
|
-
previousActivityId: runState.lastActivityId,
|
|
114767
|
-
delegatedBy: runState.delegatedBy
|
|
114768
|
-
}));
|
|
114769
|
-
runState.lastActivityId = activityId;
|
|
114770
|
-
tool.logged = true;
|
|
114771
|
-
runState.completedReasoning = void 0;
|
|
114772
|
-
}
|
|
114773
116017
|
}
|
|
114774
116018
|
}
|
|
114775
116019
|
|
|
@@ -114960,7 +116204,6 @@ const useRuntimeInfo = (options) => {
|
|
|
114960
116204
|
runtimeVersion: options.initialConfig.runtimeVersion,
|
|
114961
116205
|
expertName: options.initialExpertName,
|
|
114962
116206
|
model: options.initialConfig.model,
|
|
114963
|
-
maxSteps: options.initialConfig.maxSteps,
|
|
114964
116207
|
maxRetries: options.initialConfig.maxRetries,
|
|
114965
116208
|
timeout: options.initialConfig.timeout,
|
|
114966
116209
|
activeSkills: [],
|
|
@@ -114974,7 +116217,6 @@ const useRuntimeInfo = (options) => {
|
|
|
114974
116217
|
runtimeVersion: event.runtimeVersion,
|
|
114975
116218
|
expertName: event.expertName,
|
|
114976
116219
|
model: event.model,
|
|
114977
|
-
maxSteps: event.maxSteps,
|
|
114978
116220
|
maxRetries: event.maxRetries,
|
|
114979
116221
|
timeout: event.timeout,
|
|
114980
116222
|
currentStep: 1,
|
|
@@ -115679,7 +116921,6 @@ function getActivityProps(activityOrGroup) {
|
|
|
115679
116921
|
const ActivityLogItem = ({ activity }) => {
|
|
115680
116922
|
const { delegatedBy, expertKey } = getActivityProps(activity);
|
|
115681
116923
|
if (delegatedBy) return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
|
|
115682
|
-
marginLeft: 1,
|
|
115683
116924
|
flexDirection: "column",
|
|
115684
116925
|
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
|
|
115685
116926
|
dimColor: true,
|
|
@@ -115694,6 +116935,272 @@ const ActivityLogItem = ({ activity }) => {
|
|
|
115694
116935
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CheckpointActionRow, { action: activity });
|
|
115695
116936
|
};
|
|
115696
116937
|
|
|
116938
|
+
//#endregion
|
|
116939
|
+
//#region ../../packages/tui-components/src/execution/hooks/use-delegation-tree.ts
|
|
116940
|
+
function createInitialDelegationTreeState() {
|
|
116941
|
+
return {
|
|
116942
|
+
nodes: /* @__PURE__ */ new Map(),
|
|
116943
|
+
rootRunId: void 0,
|
|
116944
|
+
jobTotalTokens: 0,
|
|
116945
|
+
jobStartedAt: void 0,
|
|
116946
|
+
runIdAliases: /* @__PURE__ */ new Map()
|
|
116947
|
+
};
|
|
116948
|
+
}
|
|
116949
|
+
function resolveRunId(state, runId) {
|
|
116950
|
+
let current = runId;
|
|
116951
|
+
const visited = /* @__PURE__ */ new Set();
|
|
116952
|
+
while (state.runIdAliases.has(current)) {
|
|
116953
|
+
if (visited.has(current)) break;
|
|
116954
|
+
visited.add(current);
|
|
116955
|
+
current = state.runIdAliases.get(current);
|
|
116956
|
+
}
|
|
116957
|
+
return current;
|
|
116958
|
+
}
|
|
116959
|
+
function formatToolName(name) {
|
|
116960
|
+
if (name.includes("_")) return name.split("_").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
|
|
116961
|
+
return name.replace(/([A-Z])/g, " $1").replace(/^./, (s) => s.toUpperCase()).trim();
|
|
116962
|
+
}
|
|
116963
|
+
const FILE_ARG_TOOLS = new Set([
|
|
116964
|
+
"readTextFile",
|
|
116965
|
+
"writeTextFile",
|
|
116966
|
+
"editTextFile",
|
|
116967
|
+
"readImageFile",
|
|
116968
|
+
"readPdfFile"
|
|
116969
|
+
]);
|
|
116970
|
+
function deriveActionLabel(toolCalls) {
|
|
116971
|
+
if (toolCalls.length === 0) return {
|
|
116972
|
+
label: "Processing",
|
|
116973
|
+
fileArg: void 0
|
|
116974
|
+
};
|
|
116975
|
+
if (toolCalls.length > 1) return {
|
|
116976
|
+
label: `${toolCalls.length} Tool Calls`,
|
|
116977
|
+
fileArg: void 0
|
|
116978
|
+
};
|
|
116979
|
+
const tc = toolCalls[0];
|
|
116980
|
+
const label = formatToolName(tc.toolName);
|
|
116981
|
+
let fileArg;
|
|
116982
|
+
if (FILE_ARG_TOOLS.has(tc.toolName) && typeof tc.args.path === "string") fileArg = shortenPath(tc.args.path);
|
|
116983
|
+
else if (tc.toolName === "exec" && typeof tc.args.command === "string") fileArg = truncateText(tc.args.command, UI_CONSTANTS.TRUNCATE_TEXT_SHORT);
|
|
116984
|
+
return {
|
|
116985
|
+
label,
|
|
116986
|
+
fileArg
|
|
116987
|
+
};
|
|
116988
|
+
}
|
|
116989
|
+
function formatTokenCount(n) {
|
|
116990
|
+
if (n >= 1e6) return `${(n / 1e6).toFixed(1)}M`;
|
|
116991
|
+
if (n >= 1e3) return `${(n / 1e3).toFixed(1)}k`;
|
|
116992
|
+
return String(n);
|
|
116993
|
+
}
|
|
116994
|
+
function getStatusCounts(state) {
|
|
116995
|
+
let running = 0;
|
|
116996
|
+
let waiting = 0;
|
|
116997
|
+
for (const node of state.nodes.values()) if (node.status === "running") running++;
|
|
116998
|
+
else if (node.status === "suspending") waiting++;
|
|
116999
|
+
return {
|
|
117000
|
+
running,
|
|
117001
|
+
waiting
|
|
117002
|
+
};
|
|
117003
|
+
}
|
|
117004
|
+
function flattenTree(state) {
|
|
117005
|
+
if (!state.rootRunId) return [];
|
|
117006
|
+
if (!state.nodes.get(state.rootRunId)) return [];
|
|
117007
|
+
const result = [];
|
|
117008
|
+
const visited = /* @__PURE__ */ new Set();
|
|
117009
|
+
function markSubtreeVisited(nodeId) {
|
|
117010
|
+
visited.add(nodeId);
|
|
117011
|
+
const node = state.nodes.get(nodeId);
|
|
117012
|
+
if (node) {
|
|
117013
|
+
for (const childId of node.childRunIds) if (!visited.has(childId)) markSubtreeVisited(childId);
|
|
117014
|
+
}
|
|
117015
|
+
}
|
|
117016
|
+
function dfs(nodeId, depth, isLast, ancestorIsLast) {
|
|
117017
|
+
const node = state.nodes.get(nodeId);
|
|
117018
|
+
if (!node) return;
|
|
117019
|
+
visited.add(nodeId);
|
|
117020
|
+
result.push({
|
|
117021
|
+
node,
|
|
117022
|
+
depth,
|
|
117023
|
+
isLast,
|
|
117024
|
+
ancestorIsLast: [...ancestorIsLast]
|
|
117025
|
+
});
|
|
117026
|
+
const children = node.childRunIds;
|
|
117027
|
+
if (node.status === "completed" || node.status === "error") {
|
|
117028
|
+
for (const childId of children) markSubtreeVisited(childId);
|
|
117029
|
+
return;
|
|
117030
|
+
}
|
|
117031
|
+
const visibleChildren = children.filter((id) => {
|
|
117032
|
+
const child = state.nodes.get(id);
|
|
117033
|
+
return child && child.status !== "completed" && child.status !== "error";
|
|
117034
|
+
});
|
|
117035
|
+
for (const childId of children) if (!visibleChildren.includes(childId)) markSubtreeVisited(childId);
|
|
117036
|
+
for (let i = 0; i < visibleChildren.length; i++) {
|
|
117037
|
+
const childIsLast = i === visibleChildren.length - 1;
|
|
117038
|
+
dfs(visibleChildren[i], depth + 1, childIsLast, [...ancestorIsLast, isLast]);
|
|
117039
|
+
}
|
|
117040
|
+
}
|
|
117041
|
+
dfs(state.rootRunId, 0, true, []);
|
|
117042
|
+
for (const [nodeId, node] of state.nodes) if (!visited.has(nodeId) && node.status !== "completed" && node.status !== "error") result.push({
|
|
117043
|
+
node,
|
|
117044
|
+
depth: 0,
|
|
117045
|
+
isLast: true,
|
|
117046
|
+
ancestorIsLast: []
|
|
117047
|
+
});
|
|
117048
|
+
return result;
|
|
117049
|
+
}
|
|
117050
|
+
function processDelegationTreeEvent(state, event) {
|
|
117051
|
+
switch (event.type) {
|
|
117052
|
+
case "initializeRuntime":
|
|
117053
|
+
if (state.jobStartedAt === void 0) state.jobStartedAt = event.timestamp;
|
|
117054
|
+
return true;
|
|
117055
|
+
case "startRun": {
|
|
117056
|
+
const initCheckpoint = event.initialCheckpoint;
|
|
117057
|
+
const parentRawRunId = initCheckpoint.delegatedBy?.runId;
|
|
117058
|
+
const parentRunId = parentRawRunId ? resolveRunId(state, parentRawRunId) : void 0;
|
|
117059
|
+
let expertName;
|
|
117060
|
+
try {
|
|
117061
|
+
expertName = parseExpertKey(event.expertKey).name;
|
|
117062
|
+
} catch {
|
|
117063
|
+
expertName = event.expertKey;
|
|
117064
|
+
}
|
|
117065
|
+
const node = {
|
|
117066
|
+
runId: event.runId,
|
|
117067
|
+
expertName,
|
|
117068
|
+
expertKey: event.expertKey,
|
|
117069
|
+
status: "running",
|
|
117070
|
+
actionLabel: "Starting...",
|
|
117071
|
+
actionFileArg: void 0,
|
|
117072
|
+
contextWindowUsage: initCheckpoint.contextWindowUsage ?? 0,
|
|
117073
|
+
parentRunId,
|
|
117074
|
+
childRunIds: [],
|
|
117075
|
+
totalTokens: 0
|
|
117076
|
+
};
|
|
117077
|
+
state.nodes.set(event.runId, node);
|
|
117078
|
+
if (parentRunId) {
|
|
117079
|
+
const parent = state.nodes.get(parentRunId);
|
|
117080
|
+
if (parent && !parent.childRunIds.includes(event.runId)) parent.childRunIds.push(event.runId);
|
|
117081
|
+
} else state.rootRunId = event.runId;
|
|
117082
|
+
return true;
|
|
117083
|
+
}
|
|
117084
|
+
case "resumeFromStop": {
|
|
117085
|
+
const checkpoint = event.checkpoint;
|
|
117086
|
+
const originalRunId = checkpoint.runId;
|
|
117087
|
+
let targetNodeId;
|
|
117088
|
+
if (originalRunId !== event.runId) targetNodeId = resolveRunId(state, originalRunId);
|
|
117089
|
+
if (!targetNodeId || !state.nodes.has(targetNodeId)) {
|
|
117090
|
+
for (const [nodeId, node] of state.nodes) if (node.expertKey === event.expertKey && node.status === "suspending") {
|
|
117091
|
+
targetNodeId = nodeId;
|
|
117092
|
+
break;
|
|
117093
|
+
}
|
|
117094
|
+
}
|
|
117095
|
+
if (targetNodeId && targetNodeId !== event.runId) state.runIdAliases.set(event.runId, targetNodeId);
|
|
117096
|
+
const nodeId = targetNodeId ?? event.runId;
|
|
117097
|
+
const node = state.nodes.get(nodeId);
|
|
117098
|
+
if (node) {
|
|
117099
|
+
node.status = "running";
|
|
117100
|
+
if (checkpoint.contextWindowUsage !== void 0) node.contextWindowUsage = checkpoint.contextWindowUsage;
|
|
117101
|
+
}
|
|
117102
|
+
return true;
|
|
117103
|
+
}
|
|
117104
|
+
case "startStreamingReasoning": {
|
|
117105
|
+
const nodeId = resolveRunId(state, event.runId);
|
|
117106
|
+
const node = state.nodes.get(nodeId);
|
|
117107
|
+
if (node) {
|
|
117108
|
+
node.actionLabel = "Streaming Reasoning...";
|
|
117109
|
+
node.actionFileArg = void 0;
|
|
117110
|
+
}
|
|
117111
|
+
return true;
|
|
117112
|
+
}
|
|
117113
|
+
case "startStreamingRunResult": {
|
|
117114
|
+
const nodeId = resolveRunId(state, event.runId);
|
|
117115
|
+
const node = state.nodes.get(nodeId);
|
|
117116
|
+
if (node) {
|
|
117117
|
+
node.actionLabel = "Streaming Generation...";
|
|
117118
|
+
node.actionFileArg = void 0;
|
|
117119
|
+
}
|
|
117120
|
+
return true;
|
|
117121
|
+
}
|
|
117122
|
+
case "callTools": {
|
|
117123
|
+
const nodeId = resolveRunId(state, event.runId);
|
|
117124
|
+
const node = state.nodes.get(nodeId);
|
|
117125
|
+
if (node) {
|
|
117126
|
+
const { label, fileArg } = deriveActionLabel(event.toolCalls);
|
|
117127
|
+
node.actionLabel = label;
|
|
117128
|
+
node.actionFileArg = fileArg;
|
|
117129
|
+
node.totalTokens += event.usage.totalTokens;
|
|
117130
|
+
state.jobTotalTokens += event.usage.totalTokens;
|
|
117131
|
+
}
|
|
117132
|
+
return true;
|
|
117133
|
+
}
|
|
117134
|
+
case "stopRunByDelegate": {
|
|
117135
|
+
const nodeId = resolveRunId(state, event.runId);
|
|
117136
|
+
const node = state.nodes.get(nodeId);
|
|
117137
|
+
if (node) {
|
|
117138
|
+
node.status = "suspending";
|
|
117139
|
+
node.actionLabel = "Waiting for delegates";
|
|
117140
|
+
node.actionFileArg = void 0;
|
|
117141
|
+
if (event.checkpoint.contextWindowUsage !== void 0) node.contextWindowUsage = event.checkpoint.contextWindowUsage;
|
|
117142
|
+
}
|
|
117143
|
+
return true;
|
|
117144
|
+
}
|
|
117145
|
+
case "completeRun": {
|
|
117146
|
+
const nodeId = resolveRunId(state, event.runId);
|
|
117147
|
+
const node = state.nodes.get(nodeId);
|
|
117148
|
+
if (node) {
|
|
117149
|
+
node.status = "completed";
|
|
117150
|
+
node.actionLabel = "Completed";
|
|
117151
|
+
node.actionFileArg = void 0;
|
|
117152
|
+
node.totalTokens += event.usage.totalTokens;
|
|
117153
|
+
state.jobTotalTokens += event.usage.totalTokens;
|
|
117154
|
+
if (event.checkpoint.contextWindowUsage !== void 0) node.contextWindowUsage = event.checkpoint.contextWindowUsage;
|
|
117155
|
+
}
|
|
117156
|
+
return true;
|
|
117157
|
+
}
|
|
117158
|
+
case "stopRunByError": {
|
|
117159
|
+
const nodeId = resolveRunId(state, event.runId);
|
|
117160
|
+
const node = state.nodes.get(nodeId);
|
|
117161
|
+
if (node) {
|
|
117162
|
+
node.status = "error";
|
|
117163
|
+
node.actionLabel = event.error.message ? truncateText(event.error.message, UI_CONSTANTS.TRUNCATE_TEXT_SHORT) : "Error";
|
|
117164
|
+
node.actionFileArg = void 0;
|
|
117165
|
+
if (event.checkpoint.contextWindowUsage !== void 0) node.contextWindowUsage = event.checkpoint.contextWindowUsage;
|
|
117166
|
+
}
|
|
117167
|
+
return true;
|
|
117168
|
+
}
|
|
117169
|
+
case "continueToNextStep": {
|
|
117170
|
+
const nodeId = resolveRunId(state, event.runId);
|
|
117171
|
+
const node = state.nodes.get(nodeId);
|
|
117172
|
+
if (node) {
|
|
117173
|
+
if (event.nextCheckpoint.contextWindowUsage !== void 0) node.contextWindowUsage = event.nextCheckpoint.contextWindowUsage;
|
|
117174
|
+
}
|
|
117175
|
+
return true;
|
|
117176
|
+
}
|
|
117177
|
+
case "retry": {
|
|
117178
|
+
const nodeId = resolveRunId(state, event.runId);
|
|
117179
|
+
const node = state.nodes.get(nodeId);
|
|
117180
|
+
if (node) {
|
|
117181
|
+
node.totalTokens += event.usage.totalTokens;
|
|
117182
|
+
state.jobTotalTokens += event.usage.totalTokens;
|
|
117183
|
+
}
|
|
117184
|
+
return true;
|
|
117185
|
+
}
|
|
117186
|
+
default: return false;
|
|
117187
|
+
}
|
|
117188
|
+
}
|
|
117189
|
+
function useDelegationTree() {
|
|
117190
|
+
const stateRef = (0, import_react.useRef)(createInitialDelegationTreeState());
|
|
117191
|
+
const [, setVersion] = (0, import_react.useState)(0);
|
|
117192
|
+
const processEvent = (0, import_react.useCallback)((event) => {
|
|
117193
|
+
if (processDelegationTreeEvent(stateRef.current, event)) setVersion((v) => v + 1);
|
|
117194
|
+
}, []);
|
|
117195
|
+
const state = stateRef.current;
|
|
117196
|
+
return {
|
|
117197
|
+
state,
|
|
117198
|
+
processEvent,
|
|
117199
|
+
statusCounts: getStatusCounts(state),
|
|
117200
|
+
formattedTotalTokens: formatTokenCount(state.jobTotalTokens)
|
|
117201
|
+
};
|
|
117202
|
+
}
|
|
117203
|
+
|
|
115697
117204
|
//#endregion
|
|
115698
117205
|
//#region ../../packages/tui-components/src/execution/hooks/use-spinner.ts
|
|
115699
117206
|
const useSpinner = ({ isActive }) => {
|
|
@@ -115722,53 +117229,103 @@ const useSpinner = ({ isActive }) => {
|
|
|
115722
117229
|
};
|
|
115723
117230
|
|
|
115724
117231
|
//#endregion
|
|
115725
|
-
//#region ../../packages/tui-components/src/execution/
|
|
115726
|
-
function deriveStreamingPhase(streaming) {
|
|
115727
|
-
for (const run of Object.values(streaming.runs)) {
|
|
115728
|
-
if (run.isReasoningActive) return "reasoning";
|
|
115729
|
-
if (run.isRunResultActive) return "generating";
|
|
115730
|
-
}
|
|
115731
|
-
return "idle";
|
|
115732
|
-
}
|
|
115733
|
-
const useStreamingPhase = (streaming) => {
|
|
115734
|
-
return (0, import_react.useMemo)(() => deriveStreamingPhase(streaming), [streaming]);
|
|
115735
|
-
};
|
|
115736
|
-
|
|
115737
|
-
//#endregion
|
|
115738
|
-
//#region ../../packages/tui-components/src/execution/components/interface-panel.tsx
|
|
117232
|
+
//#region ../../packages/tui-components/src/execution/components/delegation-tree.tsx
|
|
115739
117233
|
function getUsageIcon(percent) {
|
|
115740
117234
|
if (percent <= 25) return USAGE_INDICATORS.LOW;
|
|
115741
117235
|
if (percent <= 50) return USAGE_INDICATORS.MEDIUM;
|
|
115742
117236
|
if (percent <= 75) return USAGE_INDICATORS.HIGH;
|
|
115743
117237
|
return USAGE_INDICATORS.FULL;
|
|
115744
117238
|
}
|
|
115745
|
-
|
|
115746
|
-
|
|
115747
|
-
|
|
117239
|
+
function buildPrefix(flatNode) {
|
|
117240
|
+
if (flatNode.depth === 0) return "";
|
|
117241
|
+
let prefix = "";
|
|
117242
|
+
for (let i = 1; i < flatNode.ancestorIsLast.length; i++) prefix += flatNode.ancestorIsLast[i] ? " " : "│ ";
|
|
117243
|
+
prefix += flatNode.isLast ? "└ " : "├ ";
|
|
117244
|
+
return prefix;
|
|
117245
|
+
}
|
|
117246
|
+
function TreeNodeLine({ flatNode, spinner }) {
|
|
117247
|
+
const { node } = flatNode;
|
|
117248
|
+
const prefix = buildPrefix(flatNode);
|
|
117249
|
+
let indicator;
|
|
117250
|
+
switch (node.status) {
|
|
117251
|
+
case "running":
|
|
117252
|
+
indicator = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
117253
|
+
color: colors.accent,
|
|
117254
|
+
children: spinner
|
|
117255
|
+
});
|
|
117256
|
+
break;
|
|
117257
|
+
case "suspending":
|
|
117258
|
+
indicator = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
117259
|
+
color: colors.muted,
|
|
117260
|
+
children: "⏸"
|
|
117261
|
+
});
|
|
117262
|
+
break;
|
|
117263
|
+
case "completed":
|
|
117264
|
+
indicator = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
117265
|
+
color: colors.success,
|
|
117266
|
+
children: "✓"
|
|
117267
|
+
});
|
|
117268
|
+
break;
|
|
117269
|
+
case "error":
|
|
117270
|
+
indicator = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
117271
|
+
color: colors.destructive,
|
|
117272
|
+
children: "✗"
|
|
117273
|
+
});
|
|
117274
|
+
break;
|
|
117275
|
+
}
|
|
117276
|
+
const usagePercent = (node.contextWindowUsage * 100).toFixed(1);
|
|
117277
|
+
const usageIcon = getUsageIcon(node.contextWindowUsage * 100);
|
|
117278
|
+
const showUsage = node.status !== "completed";
|
|
117279
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: [
|
|
117280
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
117281
|
+
dimColor: true,
|
|
117282
|
+
children: prefix
|
|
117283
|
+
}),
|
|
117284
|
+
indicator,
|
|
117285
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: " " }),
|
|
117286
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
117287
|
+
bold: true,
|
|
117288
|
+
children: node.expertName
|
|
117289
|
+
}),
|
|
117290
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
117291
|
+
dimColor: true,
|
|
117292
|
+
children: ": "
|
|
117293
|
+
}),
|
|
117294
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: node.actionLabel }),
|
|
117295
|
+
node.actionFileArg ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
|
|
117296
|
+
color: colors.muted,
|
|
117297
|
+
children: [" ", node.actionFileArg]
|
|
117298
|
+
}) : null,
|
|
117299
|
+
showUsage ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
117300
|
+
dimColor: true,
|
|
117301
|
+
children: " · "
|
|
117302
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: [
|
|
117303
|
+
usageIcon,
|
|
117304
|
+
" ",
|
|
117305
|
+
usagePercent,
|
|
117306
|
+
"%"
|
|
117307
|
+
] })] }) : null
|
|
117308
|
+
] });
|
|
117309
|
+
}
|
|
117310
|
+
const DelegationTree = ({ state }) => {
|
|
117311
|
+
const flatNodes = flattenTree(state);
|
|
117312
|
+
const spinner = useSpinner({ isActive: flatNodes.some((n) => n.node.status === "running" || n.node.status === "suspending") });
|
|
117313
|
+
if (flatNodes.length === 0) return null;
|
|
117314
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: flatNodes.map((flatNode) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TreeNodeLine, {
|
|
117315
|
+
flatNode,
|
|
117316
|
+
spinner
|
|
117317
|
+
}, flatNode.node.runId)) });
|
|
117318
|
+
};
|
|
117319
|
+
|
|
117320
|
+
//#endregion
|
|
117321
|
+
//#region ../../packages/tui-components/src/execution/components/interface-panel.tsx
|
|
117322
|
+
const InterfacePanel = ({ query, runStatus, onSubmit, delegationTreeState, runningCount, waitingCount, formattedTotalTokens, elapsedTime }) => {
|
|
115748
117323
|
const { input, handleInput } = useTextInput({
|
|
115749
117324
|
onSubmit,
|
|
115750
117325
|
canSubmit: runStatus !== "running"
|
|
115751
117326
|
});
|
|
115752
117327
|
useInput(handleInput);
|
|
115753
|
-
|
|
115754
|
-
if (runStatus === "waiting") statusLabel = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
115755
|
-
color: colors.accent,
|
|
115756
|
-
children: "Waiting for query..."
|
|
115757
|
-
});
|
|
115758
|
-
else if (runStatus === "completed") statusLabel = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
115759
|
-
color: colors.success,
|
|
115760
|
-
children: "Completed"
|
|
115761
|
-
});
|
|
115762
|
-
else if (runStatus === "stopped") statusLabel = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
115763
|
-
color: colors.warn,
|
|
115764
|
-
children: "Stopped"
|
|
115765
|
-
});
|
|
115766
|
-
else if (streamingPhase === "reasoning") statusLabel = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: "Streaming Reasoning..." });
|
|
115767
|
-
else if (streamingPhase === "generating") statusLabel = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: "Streaming Generation..." });
|
|
115768
|
-
else statusLabel = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: "Running..." });
|
|
115769
|
-
const step = runtimeInfo.currentStep !== void 0 ? String(runtimeInfo.currentStep) : "–";
|
|
115770
|
-
const usagePercent = (runtimeInfo.contextWindowUsage * 100).toFixed(1);
|
|
115771
|
-
const usageIcon = getUsageIcon(runtimeInfo.contextWindowUsage * 100);
|
|
117328
|
+
const isWaiting = runStatus === "waiting";
|
|
115772
117329
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
|
|
115773
117330
|
flexDirection: "column",
|
|
115774
117331
|
borderStyle: "single",
|
|
@@ -115777,41 +117334,79 @@ const InterfacePanel = ({ runtimeInfo, runStatus, streaming, onSubmit }) => {
|
|
|
115777
117334
|
borderBottom: false,
|
|
115778
117335
|
borderLeft: false,
|
|
115779
117336
|
borderRight: false,
|
|
115780
|
-
children: [
|
|
115781
|
-
|
|
117337
|
+
children: [
|
|
117338
|
+
isWaiting ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
115782
117339
|
color: colors.accent,
|
|
115783
|
-
children:
|
|
115784
|
-
}) :
|
|
115785
|
-
|
|
115786
|
-
|
|
115787
|
-
|
|
115788
|
-
|
|
115789
|
-
|
|
115790
|
-
|
|
115791
|
-
|
|
115792
|
-
children: "↻ "
|
|
115793
|
-
}),
|
|
115794
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: step }),
|
|
115795
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
117340
|
+
children: "Waiting for query..."
|
|
117341
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
|
|
117342
|
+
color: colors.success,
|
|
117343
|
+
wrap: "truncate",
|
|
117344
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
117345
|
+
bold: true,
|
|
117346
|
+
children: "Query: "
|
|
117347
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: query || "–" })]
|
|
117348
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
|
|
115796
117349
|
dimColor: true,
|
|
115797
|
-
children:
|
|
115798
|
-
|
|
115799
|
-
|
|
115800
|
-
|
|
115801
|
-
|
|
115802
|
-
|
|
115803
|
-
|
|
115804
|
-
|
|
115805
|
-
|
|
115806
|
-
|
|
115807
|
-
|
|
115808
|
-
|
|
115809
|
-
|
|
115810
|
-
})
|
|
115811
|
-
|
|
117350
|
+
children: [
|
|
117351
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: [runningCount, " running"] }),
|
|
117352
|
+
waitingCount > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: [
|
|
117353
|
+
" · ",
|
|
117354
|
+
waitingCount,
|
|
117355
|
+
" waiting"
|
|
117356
|
+
] }) : null,
|
|
117357
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: " · " }),
|
|
117358
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: elapsedTime }),
|
|
117359
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: " · " }),
|
|
117360
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: [formattedTotalTokens, " tokens"] })
|
|
117361
|
+
]
|
|
117362
|
+
})] }),
|
|
117363
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DelegationTree, { state: delegationTreeState }),
|
|
117364
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: [
|
|
117365
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
117366
|
+
color: colors.muted,
|
|
117367
|
+
children: "> "
|
|
117368
|
+
}),
|
|
117369
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: input }),
|
|
117370
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
117371
|
+
color: colors.accent,
|
|
117372
|
+
children: "_"
|
|
117373
|
+
})
|
|
117374
|
+
] })
|
|
117375
|
+
]
|
|
115812
117376
|
});
|
|
115813
117377
|
};
|
|
115814
117378
|
|
|
117379
|
+
//#endregion
|
|
117380
|
+
//#region ../../packages/tui-components/src/execution/hooks/use-elapsed-time.ts
|
|
117381
|
+
function formatElapsedTime(ms) {
|
|
117382
|
+
const totalSeconds = Math.floor(ms / 1e3);
|
|
117383
|
+
if (totalSeconds < 60) return `${totalSeconds}s`;
|
|
117384
|
+
const minutes = Math.floor(totalSeconds / 60);
|
|
117385
|
+
const seconds = totalSeconds % 60;
|
|
117386
|
+
return `${minutes}m ${String(seconds).padStart(2, "0")}s`;
|
|
117387
|
+
}
|
|
117388
|
+
function useElapsedTime(startedAt, isRunning) {
|
|
117389
|
+
const [now, setNow] = (0, import_react.useState)(Date.now());
|
|
117390
|
+
const intervalRef = (0, import_react.useRef)(null);
|
|
117391
|
+
(0, import_react.useEffect)(() => {
|
|
117392
|
+
if (startedAt !== void 0 && isRunning) intervalRef.current = setInterval(() => {
|
|
117393
|
+
setNow(Date.now());
|
|
117394
|
+
}, 1e3);
|
|
117395
|
+
else if (intervalRef.current) {
|
|
117396
|
+
clearInterval(intervalRef.current);
|
|
117397
|
+
intervalRef.current = null;
|
|
117398
|
+
}
|
|
117399
|
+
return () => {
|
|
117400
|
+
if (intervalRef.current) {
|
|
117401
|
+
clearInterval(intervalRef.current);
|
|
117402
|
+
intervalRef.current = null;
|
|
117403
|
+
}
|
|
117404
|
+
};
|
|
117405
|
+
}, [startedAt, isRunning]);
|
|
117406
|
+
if (startedAt === void 0) return "0s";
|
|
117407
|
+
return formatElapsedTime(now - startedAt);
|
|
117408
|
+
}
|
|
117409
|
+
|
|
115815
117410
|
//#endregion
|
|
115816
117411
|
//#region ../../packages/tui-components/src/execution/hooks/use-execution-state.ts
|
|
115817
117412
|
let logEntryCounter = 0;
|
|
@@ -115839,7 +117434,10 @@ const useExecutionState = (options) => {
|
|
|
115839
117434
|
initialExpertName: expertKey,
|
|
115840
117435
|
initialConfig: config
|
|
115841
117436
|
});
|
|
117437
|
+
const delegationTree = useDelegationTree();
|
|
115842
117438
|
const [runStatus, setRunStatus] = (0, import_react.useState)(query ? "running" : "waiting");
|
|
117439
|
+
const elapsedTime = useElapsedTime(delegationTree.state.jobStartedAt, runStatus === "running");
|
|
117440
|
+
const [userQuery, setUserQuery] = (0, import_react.useState)(query);
|
|
115843
117441
|
const [staticItems, setStaticItems] = (0, import_react.useState)([]);
|
|
115844
117442
|
const lastSyncedCountRef = (0, import_react.useRef)(0);
|
|
115845
117443
|
(0, import_react.useEffect)(() => {
|
|
@@ -115849,10 +117447,17 @@ const useExecutionState = (options) => {
|
|
|
115849
117447
|
if (historicalEvents && historicalEvents.length > 0) {
|
|
115850
117448
|
runState.appendHistoricalEvents(historicalEvents);
|
|
115851
117449
|
const logEntries = [];
|
|
115852
|
-
for (const event of historicalEvents)
|
|
117450
|
+
for (const event of historicalEvents) {
|
|
117451
|
+
logEntries.push(...extractLogEntriesFromEvent(event));
|
|
117452
|
+
delegationTree.processEvent(event);
|
|
117453
|
+
}
|
|
115853
117454
|
if (logEntries.length > 0) setStaticItems((prev) => [...prev, ...logEntries]);
|
|
115854
117455
|
}
|
|
115855
|
-
}, [
|
|
117456
|
+
}, [
|
|
117457
|
+
historicalEvents,
|
|
117458
|
+
runState.appendHistoricalEvents,
|
|
117459
|
+
delegationTree.processEvent
|
|
117460
|
+
]);
|
|
115856
117461
|
(0, import_react.useEffect)(() => {
|
|
115857
117462
|
const currentActivities = runState.activities;
|
|
115858
117463
|
if (currentActivities.length > lastSyncedCountRef.current) {
|
|
@@ -115865,6 +117470,7 @@ const useExecutionState = (options) => {
|
|
|
115865
117470
|
onReady((event) => {
|
|
115866
117471
|
runState.addEvent(event);
|
|
115867
117472
|
const result = handleEvent(event);
|
|
117473
|
+
delegationTree.processEvent(event);
|
|
115868
117474
|
const logEntries = extractLogEntriesFromEvent(event);
|
|
115869
117475
|
if (logEntries.length > 0) setStaticItems((prev) => [...prev, ...logEntries]);
|
|
115870
117476
|
if (result?.stopped) setRunStatus("stopped");
|
|
@@ -115872,7 +117478,8 @@ const useExecutionState = (options) => {
|
|
|
115872
117478
|
}, [
|
|
115873
117479
|
onReady,
|
|
115874
117480
|
runState.addEvent,
|
|
115875
|
-
handleEvent
|
|
117481
|
+
handleEvent,
|
|
117482
|
+
delegationTree.processEvent
|
|
115876
117483
|
]);
|
|
115877
117484
|
(0, import_react.useEffect)(() => {
|
|
115878
117485
|
if (runState.isComplete) setRunStatus("completed");
|
|
@@ -115881,6 +117488,7 @@ const useExecutionState = (options) => {
|
|
|
115881
117488
|
if (!newQuery.trim()) return;
|
|
115882
117489
|
if (runStatus === "waiting") {
|
|
115883
117490
|
const trimmed = newQuery.trim();
|
|
117491
|
+
setUserQuery(trimmed);
|
|
115884
117492
|
setQuery(trimmed);
|
|
115885
117493
|
setRunStatus("running");
|
|
115886
117494
|
onQueryReady?.(trimmed);
|
|
@@ -115897,8 +117505,14 @@ const useExecutionState = (options) => {
|
|
|
115897
117505
|
staticItems,
|
|
115898
117506
|
streaming: runState.streaming,
|
|
115899
117507
|
runtimeInfo,
|
|
117508
|
+
query: userQuery,
|
|
115900
117509
|
runStatus,
|
|
115901
|
-
handleSubmit
|
|
117510
|
+
handleSubmit,
|
|
117511
|
+
delegationTreeState: delegationTree.state,
|
|
117512
|
+
runningCount: delegationTree.statusCounts.running,
|
|
117513
|
+
waitingCount: delegationTree.statusCounts.waiting,
|
|
117514
|
+
formattedTotalTokens: delegationTree.formattedTotalTokens,
|
|
117515
|
+
elapsedTime
|
|
115902
117516
|
};
|
|
115903
117517
|
};
|
|
115904
117518
|
|
|
@@ -115956,10 +117570,14 @@ const ExecutionApp = (props) => {
|
|
|
115956
117570
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActivityLogItem, { activity: item }, item.id || `activity-${index}`);
|
|
115957
117571
|
}
|
|
115958
117572
|
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(InterfacePanel, {
|
|
115959
|
-
|
|
117573
|
+
query: state.query,
|
|
115960
117574
|
runStatus: state.runStatus,
|
|
115961
|
-
|
|
115962
|
-
|
|
117575
|
+
onSubmit: state.handleSubmit,
|
|
117576
|
+
delegationTreeState: state.delegationTreeState,
|
|
117577
|
+
runningCount: state.runningCount,
|
|
117578
|
+
waitingCount: state.waitingCount,
|
|
117579
|
+
formattedTotalTokens: state.formattedTotalTokens,
|
|
117580
|
+
elapsedTime: state.elapsedTime
|
|
115963
117581
|
})]
|
|
115964
117582
|
});
|
|
115965
117583
|
};
|
|
@@ -116211,7 +117829,6 @@ async function startHandler(expertKey, query, options, handlerOptions) {
|
|
|
116211
117829
|
expertKey: input.expertKey
|
|
116212
117830
|
});
|
|
116213
117831
|
if (handlerOptions?.additionalEnv) Object.assign(env, handlerOptions.additionalEnv(env));
|
|
116214
|
-
const maxSteps = input.options.maxSteps ?? perstackConfig.maxSteps;
|
|
116215
117832
|
const maxRetries = input.options.maxRetries ?? perstackConfig.maxRetries ?? defaultMaxRetries;
|
|
116216
117833
|
const timeout = input.options.timeout ?? perstackConfig.timeout ?? defaultTimeout;
|
|
116217
117834
|
const configuredExperts = Object.keys(perstackConfig.experts ?? {}).map((key) => ({
|
|
@@ -116262,7 +117879,7 @@ async function startHandler(expertKey, query, options, handlerOptions) {
|
|
|
116262
117879
|
let currentJobId = currentCheckpoint?.jobId ?? input.options.jobId ?? createId();
|
|
116263
117880
|
let isNextQueryInteractiveToolResult = input.options.interactiveToolCallResult ?? false;
|
|
116264
117881
|
let isFirstIteration = true;
|
|
116265
|
-
const initialHistoricalEvents = currentCheckpoint ? getAllEventContentsForJob(currentCheckpoint.jobId
|
|
117882
|
+
const initialHistoricalEvents = currentCheckpoint ? getAllEventContentsForJob(currentCheckpoint.jobId) : void 0;
|
|
116266
117883
|
while (true) {
|
|
116267
117884
|
const historicalEvents = isFirstIteration ? initialHistoricalEvents : void 0;
|
|
116268
117885
|
const runId = createId();
|
|
@@ -116272,7 +117889,6 @@ async function startHandler(expertKey, query, options, handlerOptions) {
|
|
|
116272
117889
|
config: {
|
|
116273
117890
|
runtimeVersion,
|
|
116274
117891
|
model,
|
|
116275
|
-
maxSteps,
|
|
116276
117892
|
maxRetries,
|
|
116277
117893
|
timeout,
|
|
116278
117894
|
contextWindowUsage: currentCheckpoint?.contextWindowUsage ?? 0
|
|
@@ -116290,7 +117906,6 @@ async function startHandler(expertKey, query, options, handlerOptions) {
|
|
|
116290
117906
|
model,
|
|
116291
117907
|
providerConfig,
|
|
116292
117908
|
reasoningBudget: input.options.reasoningBudget ?? perstackConfig.reasoningBudget,
|
|
116293
|
-
maxSteps: input.options.maxSteps ?? perstackConfig.maxSteps,
|
|
116294
117909
|
maxRetries: input.options.maxRetries ?? perstackConfig.maxRetries,
|
|
116295
117910
|
timeout: input.options.timeout ?? perstackConfig.timeout,
|
|
116296
117911
|
perstackApiBaseUrl: perstackConfig.perstackApiBaseUrl,
|
|
@@ -116311,7 +117926,7 @@ async function startHandler(expertKey, query, options, handlerOptions) {
|
|
|
116311
117926
|
lockfile
|
|
116312
117927
|
});
|
|
116313
117928
|
const result = await executionResult;
|
|
116314
|
-
const canContinue = runResult.status === "completed" || runResult.status === "
|
|
117929
|
+
const canContinue = runResult.status === "completed" || runResult.status === "stoppedByError" || runResult.status === "stoppedByInteractiveTool";
|
|
116315
117930
|
if (result.nextQuery && canContinue) {
|
|
116316
117931
|
currentQuery = result.nextQuery;
|
|
116317
117932
|
currentCheckpoint = runResult;
|
|
@@ -116325,13 +117940,13 @@ async function startHandler(expertKey, query, options, handlerOptions) {
|
|
|
116325
117940
|
//#endregion
|
|
116326
117941
|
//#region package.json
|
|
116327
117942
|
var name = "create-expert";
|
|
116328
|
-
var version = "0.0.
|
|
117943
|
+
var version = "0.0.40";
|
|
116329
117944
|
var description = "Create and modify Perstack expert definitions";
|
|
116330
117945
|
|
|
116331
117946
|
//#endregion
|
|
116332
117947
|
//#region bin/cli.ts
|
|
116333
117948
|
const tomlPath = new URL("../perstack.toml", import.meta.url);
|
|
116334
|
-
new Command().name(name).description(description).version(version).argument("[query]", "Description of the expert to create or modify").option("--headless", "Run in headless mode with JSON output (no TUI)").option("--filter <types>", "Filter events by type (comma-separated, e.g., completeRun,stopRunByError)").option("--provider <provider>", "Provider to use").option("--model <model>", "Model to use").option("--reasoning-budget <budget>", "Reasoning budget for native LLM reasoning (minimal, low, medium, high, or token count)").option("--max-
|
|
117949
|
+
new Command().name(name).description(description).version(version).argument("[query]", "Description of the expert to create or modify").option("--headless", "Run in headless mode with JSON output (no TUI)").option("--filter <types>", "Filter events by type (comma-separated, e.g., completeRun,stopRunByError)").option("--provider <provider>", "Provider to use").option("--model <model>", "Model to use").option("--reasoning-budget <budget>", "Reasoning budget for native LLM reasoning (minimal, low, medium, high, or token count)").option("--max-retries <maxRetries>", "Maximum number of generation retries, default is 5").option("--timeout <timeout>", "Timeout for each generation in milliseconds, default is 300000 (5 minutes)").option("--job-id <jobId>", "Job ID for identifying the job").option("--env-path <path>", "Path to the environment file (can be specified multiple times), default is .env and .env.local", (value, previous) => previous.concat(value), []).option("--verbose", "Enable verbose logging").option("--continue", "Continue the most recent job with new query").option("--continue-job <jobId>", "Continue the specified job with new query").option("--resume-from <checkpointId>", "Resume from a specific checkpoint (requires --continue or --continue-job)").option("-i, --interactive-tool-call-result", "Query is interactive tool call result").action(async (query, options) => {
|
|
116335
117950
|
const config = parsePerstackConfig(readFileSync(tomlPath, "utf-8"));
|
|
116336
117951
|
const lockfilePath = findLockfile();
|
|
116337
117952
|
const lockfile = lockfilePath ? loadLockfile(lockfilePath) ?? void 0 : void 0;
|
|
@@ -116345,12 +117960,12 @@ new Command().name(name).description(description).version(version).argument("[qu
|
|
|
116345
117960
|
console.error("Error: query argument is required in headless mode");
|
|
116346
117961
|
process.exit(1);
|
|
116347
117962
|
}
|
|
116348
|
-
await runHandler("expert", query, options, {
|
|
117963
|
+
await runHandler("create-expert", query, options, {
|
|
116349
117964
|
perstackConfig: config,
|
|
116350
117965
|
lockfile,
|
|
116351
117966
|
additionalEnv
|
|
116352
117967
|
});
|
|
116353
|
-
} else await startHandler("expert", query, options, {
|
|
117968
|
+
} else await startHandler("create-expert", query, options, {
|
|
116354
117969
|
perstackConfig: config,
|
|
116355
117970
|
lockfile,
|
|
116356
117971
|
additionalEnv
|