create-expert 0.0.37 → 0.0.39
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 +672 -211
- package/dist/bin/cli.js.map +1 -1
- package/dist/perstack.toml +51 -11
- package/dist/{resolve-expert-DsQia0Mr.js → resolve-expert-CTnETi9d.js} +2 -2
- package/dist/{resolve-expert-DsQia0Mr.js.map → resolve-expert-CTnETi9d.js.map} +1 -1
- package/dist/{src-D-q0VJ6r.js → src-C0pz_C3h.js} +80 -2
- package/dist/{src-D-q0VJ6r.js.map → src-C0pz_C3h.js.map} +1 -1
- package/package.json +6 -6
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 boolean, A as startCommandInputSchema, At as defineLazy, C as startGeneration, Ct as $ZodObject, D as stopRunByExceededMaxSteps, Dt as safeParse$1, E as stopRunByError, Et as parseAsync, F as checkpointSchema, Ft as PerstackError, G as number$1, It as defaultMaxRetries, J as _instanceof, K as ZodOptional$1, Lt as defaultTimeout, M as lockfileSchema, Mt as $constructor, N as jobSchema, Nt as NEVER, O as stopRunByInteractiveTool, Ot as safeParseAsync$1, P as expertSchema, Pt as knownModels, Q as array$1, Rt as createId, S as skipDelegates, St as meta$1, T as stopRunByDelegate, Tt as parse$1, Y as _null, Z as any, _ as resolveToolResults, _t as url, a as BASE_SKILL_PREFIX, at as looseObject, b as runParamsSchema, bt as toJSONSchema, c as attemptCompletion$1, ct as object$2, d as continueToNextStep, dt as record, et as custom, f as createRuntimeEvent, ft as strictObject, g as proceedToInteractiveTools, gt as unknown, h as finishToolCall, ht as union, i as getFilteredEnv, it as literal, j as perstackConfigSchema, jt as normalizeParams, k as runCommandInputSchema, kt as clone, l as callTools, lt as optional, m as finishMcpTools, mt as tuple, n as createFilteredEventListener, nt as intersection, o as createBaseToolActivity, ot as never, p as createStreamingEvent, pt as string, q as _enum, r as validateEventFilter, rt as lazy, s as createGeneralToolActivity, st as number, t as parseWithFriendlyError, tt as discriminatedUnion, u as completeRun, ut as preprocess, v as resumeFromStop, vt as safeParseAsync$2, w as startRun, wt as $ZodType, x as runSettingSchema, xt as describe$1, y as retry, yt as datetime } from "../src-
|
|
3
|
+
import { $ as boolean, A as startCommandInputSchema, At as defineLazy, C as startGeneration, Ct as $ZodObject, D as stopRunByExceededMaxSteps, Dt as safeParse$1, E as stopRunByError, Et as parseAsync, F as checkpointSchema, Ft as PerstackError, G as number$1, It as defaultMaxRetries, J as _instanceof, K as ZodOptional$1, Lt as defaultTimeout, M as lockfileSchema, Mt as $constructor, N as jobSchema, Nt as NEVER, O as stopRunByInteractiveTool, Ot as safeParseAsync$1, P as expertSchema, Pt as knownModels, Q as array$1, Rt as createId, S as skipDelegates, St as meta$1, T as stopRunByDelegate, Tt as parse$1, Y as _null, Z as any, _ as resolveToolResults, _t as url, a as BASE_SKILL_PREFIX, at as looseObject, b as runParamsSchema, bt as toJSONSchema, c as attemptCompletion$1, ct as object$2, d as continueToNextStep, dt as record, et as custom, f as createRuntimeEvent, ft as strictObject, g as proceedToInteractiveTools, gt as unknown, h as finishToolCall, ht as union, i as getFilteredEnv, it as literal, j as perstackConfigSchema, jt as normalizeParams, k as runCommandInputSchema, kt as clone, l as callTools, lt as optional, m as finishMcpTools, mt as tuple, n as createFilteredEventListener, nt as intersection, o as createBaseToolActivity, ot as never, p as createStreamingEvent, pt as string, q as _enum, r as validateEventFilter, rt as lazy, s as createGeneralToolActivity, st as number, t as parseWithFriendlyError, tt as discriminatedUnion, u as completeRun, ut as preprocess, v as resumeFromStop, vt as safeParseAsync$2, w as startRun, wt as $ZodType, x as runSettingSchema, xt as describe$1, y as retry, yt as datetime } from "../src-C0pz_C3h.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,
|
|
6
|
+
import fs, { existsSync, readFileSync, readdirSync, realpathSync } 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";
|
|
@@ -1020,17 +1020,21 @@ function getJobsDir() {
|
|
|
1020
1020
|
function getJobDir(jobId) {
|
|
1021
1021
|
return `${getJobsDir()}/${jobId}`;
|
|
1022
1022
|
}
|
|
1023
|
-
function storeJob(job) {
|
|
1023
|
+
async function storeJob(job) {
|
|
1024
1024
|
const jobDir = getJobDir(job.id);
|
|
1025
|
-
|
|
1026
|
-
|
|
1025
|
+
await mkdir(jobDir, { recursive: true });
|
|
1026
|
+
await writeFile(path.resolve(jobDir, "job.json"), JSON.stringify(job, null, 2));
|
|
1027
1027
|
}
|
|
1028
|
-
function retrieveJob(jobId) {
|
|
1028
|
+
async function retrieveJob(jobId) {
|
|
1029
1029
|
const jobDir = getJobDir(jobId);
|
|
1030
1030
|
const jobPath = path.resolve(jobDir, "job.json");
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1031
|
+
try {
|
|
1032
|
+
const content = await readFile(jobPath, "utf-8");
|
|
1033
|
+
return jobSchema.parse(JSON.parse(content));
|
|
1034
|
+
} catch (error) {
|
|
1035
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") return;
|
|
1036
|
+
throw error;
|
|
1037
|
+
}
|
|
1034
1038
|
}
|
|
1035
1039
|
function getAllJobs$1() {
|
|
1036
1040
|
const jobsDir = getJobsDir();
|
|
@@ -16305,7 +16309,7 @@ const EMPTY_COMPLETION_RESULT = { completion: {
|
|
|
16305
16309
|
//#endregion
|
|
16306
16310
|
//#region ../base/package.json
|
|
16307
16311
|
var name$5 = "@perstack/base";
|
|
16308
|
-
var version$2 = "0.0.
|
|
16312
|
+
var version$2 = "0.0.61";
|
|
16309
16313
|
|
|
16310
16314
|
//#endregion
|
|
16311
16315
|
//#region ../base/src/tools/todo.ts
|
|
@@ -19746,23 +19750,41 @@ var SkillManager = class SkillManager {
|
|
|
19746
19750
|
const delegateExpert = experts[key];
|
|
19747
19751
|
if (!delegateExpert) throw new Error(`Expert "${key}" not found`);
|
|
19748
19752
|
await sm.addDelegate(delegateExpert);
|
|
19753
|
+
if (!expert.delegates.includes(key)) expert.delegates.push(key);
|
|
19749
19754
|
return { delegateToolName: sm.getAdapters().get(delegateExpert.name)?.getToolDefinitions()[0]?.name ?? delegateExpert.name };
|
|
19750
19755
|
},
|
|
19751
|
-
removeDelegate: (name) =>
|
|
19756
|
+
removeDelegate: async (name) => {
|
|
19757
|
+
await sm.removeDelegate(name);
|
|
19758
|
+
const index = expert.delegates.indexOf(name);
|
|
19759
|
+
if (index >= 0) expert.delegates.splice(index, 1);
|
|
19760
|
+
},
|
|
19752
19761
|
createExpert: async (input) => {
|
|
19753
|
-
|
|
19762
|
+
if (input.delegates) {
|
|
19763
|
+
const missing = input.delegates.filter((d) => !experts[d]);
|
|
19764
|
+
if (missing.length > 0) throw new Error(`Cannot create expert "${input.key}": delegates [${missing.join(", ")}] do not exist. Create them with createExpert first.`);
|
|
19765
|
+
}
|
|
19766
|
+
const skills = input.skills ? {
|
|
19767
|
+
"@perstack/base": input.skills["@perstack/base"] ?? {
|
|
19768
|
+
type: "mcpStdioSkill",
|
|
19769
|
+
command: "npx",
|
|
19770
|
+
packageName: "@perstack/base",
|
|
19771
|
+
pick: ["attemptCompletion"]
|
|
19772
|
+
},
|
|
19773
|
+
...input.skills
|
|
19774
|
+
} : void 0;
|
|
19775
|
+
const newExpert = expertSchema.parse({
|
|
19754
19776
|
key: input.key,
|
|
19755
19777
|
name: input.key,
|
|
19756
19778
|
version: input.version ?? "1.0.0",
|
|
19757
19779
|
description: input.description,
|
|
19758
19780
|
instruction: input.instruction,
|
|
19759
|
-
skills
|
|
19781
|
+
skills,
|
|
19760
19782
|
delegates: input.delegates,
|
|
19761
19783
|
tags: input.tags,
|
|
19762
19784
|
providerTools: input.providerTools
|
|
19763
19785
|
});
|
|
19764
|
-
experts[
|
|
19765
|
-
return { expertKey:
|
|
19786
|
+
experts[newExpert.key] = newExpert;
|
|
19787
|
+
return { expertKey: newExpert.key };
|
|
19766
19788
|
}
|
|
19767
19789
|
});
|
|
19768
19790
|
break;
|
|
@@ -19917,7 +19939,7 @@ var SkillManager = class SkillManager {
|
|
|
19917
19939
|
|
|
19918
19940
|
//#endregion
|
|
19919
19941
|
//#region ../../packages/runtime/package.json
|
|
19920
|
-
var version$1 = "0.0.
|
|
19942
|
+
var version$1 = "0.0.110";
|
|
19921
19943
|
|
|
19922
19944
|
//#endregion
|
|
19923
19945
|
//#region ../../packages/runtime/src/helpers/usage.ts
|
|
@@ -22127,7 +22149,7 @@ async function* executeTool({ execute, input, options }) {
|
|
|
22127
22149
|
}
|
|
22128
22150
|
|
|
22129
22151
|
//#endregion
|
|
22130
|
-
//#region ../../node_modules/.pnpm/@ai-sdk+anthropic@3.0.
|
|
22152
|
+
//#region ../../node_modules/.pnpm/@ai-sdk+anthropic@3.0.45_zod@4.3.6/node_modules/@ai-sdk/anthropic/dist/internal/index.mjs
|
|
22131
22153
|
var anthropicFailedResponseHandler$1 = createJsonErrorResponseHandler({
|
|
22132
22154
|
errorSchema: lazySchema(() => zodSchema(object$2({
|
|
22133
22155
|
type: literal("error"),
|
|
@@ -25259,7 +25281,7 @@ function guessServiceRegion(url, headers) {
|
|
|
25259
25281
|
}
|
|
25260
25282
|
|
|
25261
25283
|
//#endregion
|
|
25262
|
-
//#region ../../node_modules/.pnpm/@ai-sdk+amazon-bedrock@4.0.
|
|
25284
|
+
//#region ../../node_modules/.pnpm/@ai-sdk+amazon-bedrock@4.0.61_zod@4.3.6/node_modules/@ai-sdk/amazon-bedrock/dist/index.mjs
|
|
25263
25285
|
var BEDROCK_STOP_REASONS = [
|
|
25264
25286
|
"stop",
|
|
25265
25287
|
"stop_sequence",
|
|
@@ -26659,7 +26681,7 @@ var bedrockImageResponseSchema = object$2({
|
|
|
26659
26681
|
details: record(string(), unknown()).optional(),
|
|
26660
26682
|
preview: unknown().optional()
|
|
26661
26683
|
});
|
|
26662
|
-
var VERSION$9 = "4.0.
|
|
26684
|
+
var VERSION$9 = "4.0.61";
|
|
26663
26685
|
function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
|
|
26664
26686
|
return async (input, init) => {
|
|
26665
26687
|
var _a, _b;
|
|
@@ -26905,8 +26927,8 @@ Original error: ${errorMessage}`);
|
|
|
26905
26927
|
var bedrock = createAmazonBedrock();
|
|
26906
26928
|
|
|
26907
26929
|
//#endregion
|
|
26908
|
-
//#region ../../node_modules/.pnpm/@ai-sdk+anthropic@3.0.
|
|
26909
|
-
var VERSION$8 = "3.0.
|
|
26930
|
+
//#region ../../node_modules/.pnpm/@ai-sdk+anthropic@3.0.45_zod@4.3.6/node_modules/@ai-sdk/anthropic/dist/index.mjs
|
|
26931
|
+
var VERSION$8 = "3.0.45";
|
|
26910
26932
|
var anthropicFailedResponseHandler = createJsonErrorResponseHandler({
|
|
26911
26933
|
errorSchema: lazySchema(() => zodSchema(object$2({
|
|
26912
26934
|
type: literal("error"),
|
|
@@ -30104,7 +30126,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
30104
30126
|
}
|
|
30105
30127
|
};
|
|
30106
30128
|
function getModelCapabilities(modelId) {
|
|
30107
|
-
if (modelId.includes("claude-opus-4-6")) return {
|
|
30129
|
+
if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) return {
|
|
30108
30130
|
maxOutputTokens: 128e3,
|
|
30109
30131
|
supportsStructuredOutput: true,
|
|
30110
30132
|
isKnownModel: true
|
|
@@ -30460,7 +30482,7 @@ function createAnthropic(options = {}) {
|
|
|
30460
30482
|
var anthropic = createAnthropic();
|
|
30461
30483
|
|
|
30462
30484
|
//#endregion
|
|
30463
|
-
//#region ../../node_modules/.pnpm/@ai-sdk+openai@3.0.
|
|
30485
|
+
//#region ../../node_modules/.pnpm/@ai-sdk+openai@3.0.30_zod@4.3.6/node_modules/@ai-sdk/openai/dist/internal/index.mjs
|
|
30464
30486
|
var openaiErrorDataSchema$1 = object$2({ error: object$2({
|
|
30465
30487
|
message: string(),
|
|
30466
30488
|
type: string().nullish(),
|
|
@@ -32241,6 +32263,54 @@ var shellOutputSchema$1 = lazySchema(() => zodSchema(object$2({ output: array$1(
|
|
|
32241
32263
|
exitCode: number()
|
|
32242
32264
|
})])
|
|
32243
32265
|
})) })));
|
|
32266
|
+
var shellSkillsSchema$1 = array$1(discriminatedUnion("type", [object$2({
|
|
32267
|
+
type: literal("skillReference"),
|
|
32268
|
+
skillId: string(),
|
|
32269
|
+
version: string().optional()
|
|
32270
|
+
}), object$2({
|
|
32271
|
+
type: literal("inline"),
|
|
32272
|
+
name: string(),
|
|
32273
|
+
description: string(),
|
|
32274
|
+
source: object$2({
|
|
32275
|
+
type: literal("base64"),
|
|
32276
|
+
mediaType: literal("application/zip"),
|
|
32277
|
+
data: string()
|
|
32278
|
+
})
|
|
32279
|
+
})])).optional();
|
|
32280
|
+
var shellArgsSchema$1 = lazySchema(() => zodSchema(object$2({ environment: union([
|
|
32281
|
+
object$2({
|
|
32282
|
+
type: literal("containerAuto"),
|
|
32283
|
+
fileIds: array$1(string()).optional(),
|
|
32284
|
+
memoryLimit: _enum([
|
|
32285
|
+
"1g",
|
|
32286
|
+
"4g",
|
|
32287
|
+
"16g",
|
|
32288
|
+
"64g"
|
|
32289
|
+
]).optional(),
|
|
32290
|
+
networkPolicy: discriminatedUnion("type", [object$2({ type: literal("disabled") }), object$2({
|
|
32291
|
+
type: literal("allowlist"),
|
|
32292
|
+
allowedDomains: array$1(string()),
|
|
32293
|
+
domainSecrets: array$1(object$2({
|
|
32294
|
+
domain: string(),
|
|
32295
|
+
name: string(),
|
|
32296
|
+
value: string()
|
|
32297
|
+
})).optional()
|
|
32298
|
+
})]).optional(),
|
|
32299
|
+
skills: shellSkillsSchema$1
|
|
32300
|
+
}),
|
|
32301
|
+
object$2({
|
|
32302
|
+
type: literal("containerReference"),
|
|
32303
|
+
containerId: string()
|
|
32304
|
+
}),
|
|
32305
|
+
object$2({
|
|
32306
|
+
type: literal("local").optional(),
|
|
32307
|
+
skills: array$1(object$2({
|
|
32308
|
+
name: string(),
|
|
32309
|
+
description: string(),
|
|
32310
|
+
path: string()
|
|
32311
|
+
})).optional()
|
|
32312
|
+
})
|
|
32313
|
+
]).optional() })));
|
|
32244
32314
|
createProviderToolFactoryWithOutputSchema({
|
|
32245
32315
|
id: "openai.shell",
|
|
32246
32316
|
inputSchema: shellInputSchema$1,
|
|
@@ -32418,11 +32488,33 @@ async function convertToOpenAIResponsesInput$1({ prompt, toolNameMapping, system
|
|
|
32418
32488
|
});
|
|
32419
32489
|
break;
|
|
32420
32490
|
}
|
|
32421
|
-
case "tool-result":
|
|
32491
|
+
case "tool-result": {
|
|
32422
32492
|
if (part.output.type === "execution-denied" || part.output.type === "json" && typeof part.output.value === "object" && part.output.value != null && "type" in part.output.value && part.output.value.type === "execution-denied") break;
|
|
32423
32493
|
if (hasConversation) break;
|
|
32494
|
+
const resolvedResultToolName = toolNameMapping.toProviderToolName(part.toolName);
|
|
32495
|
+
if (hasShellTool && resolvedResultToolName === "shell") {
|
|
32496
|
+
if (part.output.type === "json") {
|
|
32497
|
+
const parsedOutput = await validateTypes({
|
|
32498
|
+
value: part.output.value,
|
|
32499
|
+
schema: shellOutputSchema$1
|
|
32500
|
+
});
|
|
32501
|
+
input.push({
|
|
32502
|
+
type: "shell_call_output",
|
|
32503
|
+
call_id: part.toolCallId,
|
|
32504
|
+
output: parsedOutput.output.map((item) => ({
|
|
32505
|
+
stdout: item.stdout,
|
|
32506
|
+
stderr: item.stderr,
|
|
32507
|
+
outcome: item.outcome.type === "timeout" ? { type: "timeout" } : {
|
|
32508
|
+
type: "exit",
|
|
32509
|
+
exit_code: item.outcome.exitCode
|
|
32510
|
+
}
|
|
32511
|
+
}))
|
|
32512
|
+
});
|
|
32513
|
+
}
|
|
32514
|
+
break;
|
|
32515
|
+
}
|
|
32424
32516
|
if (store) {
|
|
32425
|
-
const itemId = (_j = (_i = (_h = part.
|
|
32517
|
+
const itemId = (_j = (_i = (_h = part.providerOptions) == null ? void 0 : _h[providerOptionsName]) == null ? void 0 : _i.itemId) != null ? _j : part.toolCallId;
|
|
32426
32518
|
input.push({
|
|
32427
32519
|
type: "item_reference",
|
|
32428
32520
|
id: itemId
|
|
@@ -32432,6 +32524,7 @@ async function convertToOpenAIResponsesInput$1({ prompt, toolNameMapping, system
|
|
|
32432
32524
|
message: `Results for OpenAI tool ${part.toolName} are not sent to the API when store is false`
|
|
32433
32525
|
});
|
|
32434
32526
|
break;
|
|
32527
|
+
}
|
|
32435
32528
|
case "reasoning": {
|
|
32436
32529
|
const providerOptions = await parseProviderOptions({
|
|
32437
32530
|
provider: providerOptionsName,
|
|
@@ -32760,6 +32853,24 @@ var openaiResponsesChunkSchema$1 = lazySchema(() => zodSchema(union([
|
|
|
32760
32853
|
"incomplete"
|
|
32761
32854
|
]),
|
|
32762
32855
|
action: object$2({ commands: array$1(string()) })
|
|
32856
|
+
}),
|
|
32857
|
+
object$2({
|
|
32858
|
+
type: literal("shell_call_output"),
|
|
32859
|
+
id: string(),
|
|
32860
|
+
call_id: string(),
|
|
32861
|
+
status: _enum([
|
|
32862
|
+
"in_progress",
|
|
32863
|
+
"completed",
|
|
32864
|
+
"incomplete"
|
|
32865
|
+
]),
|
|
32866
|
+
output: array$1(object$2({
|
|
32867
|
+
stdout: string(),
|
|
32868
|
+
stderr: string(),
|
|
32869
|
+
outcome: discriminatedUnion("type", [object$2({ type: literal("timeout") }), object$2({
|
|
32870
|
+
type: literal("exit"),
|
|
32871
|
+
exit_code: number()
|
|
32872
|
+
})])
|
|
32873
|
+
}))
|
|
32763
32874
|
})
|
|
32764
32875
|
])
|
|
32765
32876
|
}),
|
|
@@ -32934,6 +33045,24 @@ var openaiResponsesChunkSchema$1 = lazySchema(() => zodSchema(union([
|
|
|
32934
33045
|
"incomplete"
|
|
32935
33046
|
]),
|
|
32936
33047
|
action: object$2({ commands: array$1(string()) })
|
|
33048
|
+
}),
|
|
33049
|
+
object$2({
|
|
33050
|
+
type: literal("shell_call_output"),
|
|
33051
|
+
id: string(),
|
|
33052
|
+
call_id: string(),
|
|
33053
|
+
status: _enum([
|
|
33054
|
+
"in_progress",
|
|
33055
|
+
"completed",
|
|
33056
|
+
"incomplete"
|
|
33057
|
+
]),
|
|
33058
|
+
output: array$1(object$2({
|
|
33059
|
+
stdout: string(),
|
|
33060
|
+
stderr: string(),
|
|
33061
|
+
outcome: discriminatedUnion("type", [object$2({ type: literal("timeout") }), object$2({
|
|
33062
|
+
type: literal("exit"),
|
|
33063
|
+
exit_code: number()
|
|
33064
|
+
})])
|
|
33065
|
+
}))
|
|
32937
33066
|
})
|
|
32938
33067
|
])
|
|
32939
33068
|
}),
|
|
@@ -33258,6 +33387,24 @@ var openaiResponsesResponseSchema$1 = lazySchema(() => zodSchema(object$2({
|
|
|
33258
33387
|
"incomplete"
|
|
33259
33388
|
]),
|
|
33260
33389
|
action: object$2({ commands: array$1(string()) })
|
|
33390
|
+
}),
|
|
33391
|
+
object$2({
|
|
33392
|
+
type: literal("shell_call_output"),
|
|
33393
|
+
id: string(),
|
|
33394
|
+
call_id: string(),
|
|
33395
|
+
status: _enum([
|
|
33396
|
+
"in_progress",
|
|
33397
|
+
"completed",
|
|
33398
|
+
"incomplete"
|
|
33399
|
+
]),
|
|
33400
|
+
output: array$1(object$2({
|
|
33401
|
+
stdout: string(),
|
|
33402
|
+
stderr: string(),
|
|
33403
|
+
outcome: discriminatedUnion("type", [object$2({ type: literal("timeout") }), object$2({
|
|
33404
|
+
type: literal("exit"),
|
|
33405
|
+
exit_code: number()
|
|
33406
|
+
})])
|
|
33407
|
+
}))
|
|
33261
33408
|
})
|
|
33262
33409
|
])).optional(),
|
|
33263
33410
|
service_tier: string().nullish(),
|
|
@@ -33572,9 +33719,17 @@ async function prepareResponsesTools$2({ tools, toolChoice }) {
|
|
|
33572
33719
|
case "openai.local_shell":
|
|
33573
33720
|
openaiTools.push({ type: "local_shell" });
|
|
33574
33721
|
break;
|
|
33575
|
-
case "openai.shell":
|
|
33576
|
-
|
|
33722
|
+
case "openai.shell": {
|
|
33723
|
+
const args = await validateTypes({
|
|
33724
|
+
value: tool.args,
|
|
33725
|
+
schema: shellArgsSchema$1
|
|
33726
|
+
});
|
|
33727
|
+
openaiTools.push({
|
|
33728
|
+
type: "shell",
|
|
33729
|
+
...args.environment && { environment: mapShellEnvironment$1(args.environment) }
|
|
33730
|
+
});
|
|
33577
33731
|
break;
|
|
33732
|
+
}
|
|
33578
33733
|
case "openai.apply_patch":
|
|
33579
33734
|
openaiTools.push({ type: "apply_patch" });
|
|
33580
33735
|
break;
|
|
@@ -33702,6 +33857,46 @@ async function prepareResponsesTools$2({ tools, toolChoice }) {
|
|
|
33702
33857
|
default: throw new UnsupportedFunctionalityError({ functionality: `tool choice type: ${type}` });
|
|
33703
33858
|
}
|
|
33704
33859
|
}
|
|
33860
|
+
function mapShellEnvironment$1(environment) {
|
|
33861
|
+
if (environment.type === "containerReference") return {
|
|
33862
|
+
type: "container_reference",
|
|
33863
|
+
container_id: environment.containerId
|
|
33864
|
+
};
|
|
33865
|
+
if (environment.type === "containerAuto") {
|
|
33866
|
+
const env2 = environment;
|
|
33867
|
+
return {
|
|
33868
|
+
type: "container_auto",
|
|
33869
|
+
file_ids: env2.fileIds,
|
|
33870
|
+
memory_limit: env2.memoryLimit,
|
|
33871
|
+
network_policy: env2.networkPolicy == null ? void 0 : env2.networkPolicy.type === "disabled" ? { type: "disabled" } : {
|
|
33872
|
+
type: "allowlist",
|
|
33873
|
+
allowed_domains: env2.networkPolicy.allowedDomains,
|
|
33874
|
+
domain_secrets: env2.networkPolicy.domainSecrets
|
|
33875
|
+
},
|
|
33876
|
+
skills: mapShellSkills$1(env2.skills)
|
|
33877
|
+
};
|
|
33878
|
+
}
|
|
33879
|
+
return {
|
|
33880
|
+
type: "local",
|
|
33881
|
+
skills: environment.skills
|
|
33882
|
+
};
|
|
33883
|
+
}
|
|
33884
|
+
function mapShellSkills$1(skills) {
|
|
33885
|
+
return skills == null ? void 0 : skills.map((skill) => skill.type === "skillReference" ? {
|
|
33886
|
+
type: "skill_reference",
|
|
33887
|
+
skill_id: skill.skillId,
|
|
33888
|
+
version: skill.version
|
|
33889
|
+
} : {
|
|
33890
|
+
type: "inline",
|
|
33891
|
+
name: skill.name,
|
|
33892
|
+
description: skill.description,
|
|
33893
|
+
source: {
|
|
33894
|
+
type: "base64",
|
|
33895
|
+
media_type: skill.source.mediaType,
|
|
33896
|
+
data: skill.source.data
|
|
33897
|
+
}
|
|
33898
|
+
});
|
|
33899
|
+
}
|
|
33705
33900
|
function extractApprovalRequestIdToToolCallIdMapping$1(prompt) {
|
|
33706
33901
|
var _a, _b;
|
|
33707
33902
|
const mapping = {};
|
|
@@ -33729,7 +33924,7 @@ var OpenAIResponsesLanguageModel$1 = class {
|
|
|
33729
33924
|
return this.config.provider;
|
|
33730
33925
|
}
|
|
33731
33926
|
async getArgs({ maxOutputTokens, temperature, stopSequences, topP, topK, presencePenalty, frequencyPenalty, seed, prompt, providerOptions, tools, toolChoice, responseFormat }) {
|
|
33732
|
-
var _a, _b, _c, _d, _e, _f;
|
|
33927
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
33733
33928
|
const warnings = [];
|
|
33734
33929
|
const modelCapabilities = getOpenAILanguageModelCapabilities$1(this.modelId);
|
|
33735
33930
|
if (topK != null) warnings.push({
|
|
@@ -33899,6 +34094,8 @@ var OpenAIResponsesLanguageModel$1 = class {
|
|
|
33899
34094
|
tools,
|
|
33900
34095
|
toolChoice
|
|
33901
34096
|
});
|
|
34097
|
+
const shellToolEnvType = (_i = (_h = (_g = tools == null ? void 0 : tools.find((tool) => tool.type === "provider" && tool.id === "openai.shell")) == null ? void 0 : _g.args) == null ? void 0 : _h.environment) == null ? void 0 : _i.type;
|
|
34098
|
+
const isShellProviderExecuted = shellToolEnvType === "containerAuto" || shellToolEnvType === "containerReference";
|
|
33902
34099
|
return {
|
|
33903
34100
|
webSearchToolName,
|
|
33904
34101
|
args: {
|
|
@@ -33909,12 +34106,13 @@ var OpenAIResponsesLanguageModel$1 = class {
|
|
|
33909
34106
|
warnings: [...warnings, ...toolWarnings],
|
|
33910
34107
|
store,
|
|
33911
34108
|
toolNameMapping,
|
|
33912
|
-
providerOptionsName
|
|
34109
|
+
providerOptionsName,
|
|
34110
|
+
isShellProviderExecuted
|
|
33913
34111
|
};
|
|
33914
34112
|
}
|
|
33915
34113
|
async doGenerate(options) {
|
|
33916
34114
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
33917
|
-
const { args: body, warnings, webSearchToolName, toolNameMapping, providerOptionsName } = await this.getArgs(options);
|
|
34115
|
+
const { args: body, warnings, webSearchToolName, toolNameMapping, providerOptionsName, isShellProviderExecuted } = await this.getArgs(options);
|
|
33918
34116
|
const url = this.config.url({
|
|
33919
34117
|
path: "/responses",
|
|
33920
34118
|
modelId: this.modelId
|
|
@@ -33986,9 +34184,25 @@ var OpenAIResponsesLanguageModel$1 = class {
|
|
|
33986
34184
|
toolCallId: part.call_id,
|
|
33987
34185
|
toolName: toolNameMapping.toCustomToolName("shell"),
|
|
33988
34186
|
input: JSON.stringify({ action: { commands: part.action.commands } }),
|
|
34187
|
+
...isShellProviderExecuted && { providerExecuted: true },
|
|
33989
34188
|
providerMetadata: { [providerOptionsName]: { itemId: part.id } }
|
|
33990
34189
|
});
|
|
33991
34190
|
break;
|
|
34191
|
+
case "shell_call_output":
|
|
34192
|
+
content.push({
|
|
34193
|
+
type: "tool-result",
|
|
34194
|
+
toolCallId: part.call_id,
|
|
34195
|
+
toolName: toolNameMapping.toCustomToolName("shell"),
|
|
34196
|
+
result: { output: part.output.map((item) => ({
|
|
34197
|
+
stdout: item.stdout,
|
|
34198
|
+
stderr: item.stderr,
|
|
34199
|
+
outcome: item.outcome.type === "exit" ? {
|
|
34200
|
+
type: "exit",
|
|
34201
|
+
exitCode: item.outcome.exit_code
|
|
34202
|
+
} : { type: "timeout" }
|
|
34203
|
+
})) }
|
|
34204
|
+
});
|
|
34205
|
+
break;
|
|
33992
34206
|
case "message":
|
|
33993
34207
|
for (const contentPart of part.content) {
|
|
33994
34208
|
if (((_c = (_b = options.providerOptions) == null ? void 0 : _b[providerOptionsName]) == null ? void 0 : _c.logprobs) && contentPart.logprobs) logprobs.push(contentPart.logprobs);
|
|
@@ -34223,7 +34437,7 @@ var OpenAIResponsesLanguageModel$1 = class {
|
|
|
34223
34437
|
};
|
|
34224
34438
|
}
|
|
34225
34439
|
async doStream(options) {
|
|
34226
|
-
const { args: body, warnings, webSearchToolName, toolNameMapping, store, providerOptionsName } = await this.getArgs(options);
|
|
34440
|
+
const { args: body, warnings, webSearchToolName, toolNameMapping, store, providerOptionsName, isShellProviderExecuted } = await this.getArgs(options);
|
|
34227
34441
|
const { responseHeaders, value: response } = await postJsonToApi({
|
|
34228
34442
|
url: this.config.url({
|
|
34229
34443
|
path: "/responses",
|
|
@@ -34393,7 +34607,7 @@ var OpenAIResponsesLanguageModel$1 = class {
|
|
|
34393
34607
|
toolName: toolNameMapping.toCustomToolName("shell"),
|
|
34394
34608
|
toolCallId: value.item.call_id
|
|
34395
34609
|
};
|
|
34396
|
-
else if (value.item.type === "message") {
|
|
34610
|
+
else if (value.item.type === "shell_call_output") {} else if (value.item.type === "message") {
|
|
34397
34611
|
ongoingAnnotations.splice(0, ongoingAnnotations.length);
|
|
34398
34612
|
controller.enqueue({
|
|
34399
34613
|
type: "text-start",
|
|
@@ -34598,9 +34812,23 @@ var OpenAIResponsesLanguageModel$1 = class {
|
|
|
34598
34812
|
toolCallId: value.item.call_id,
|
|
34599
34813
|
toolName: toolNameMapping.toCustomToolName("shell"),
|
|
34600
34814
|
input: JSON.stringify({ action: { commands: value.item.action.commands } }),
|
|
34815
|
+
...isShellProviderExecuted && { providerExecuted: true },
|
|
34601
34816
|
providerMetadata: { [providerOptionsName]: { itemId: value.item.id } }
|
|
34602
34817
|
});
|
|
34603
|
-
} else if (value.item.type === "
|
|
34818
|
+
} else if (value.item.type === "shell_call_output") controller.enqueue({
|
|
34819
|
+
type: "tool-result",
|
|
34820
|
+
toolCallId: value.item.call_id,
|
|
34821
|
+
toolName: toolNameMapping.toCustomToolName("shell"),
|
|
34822
|
+
result: { output: value.item.output.map((item) => ({
|
|
34823
|
+
stdout: item.stdout,
|
|
34824
|
+
stderr: item.stderr,
|
|
34825
|
+
outcome: item.outcome.type === "exit" ? {
|
|
34826
|
+
type: "exit",
|
|
34827
|
+
exitCode: item.outcome.exit_code
|
|
34828
|
+
} : { type: "timeout" }
|
|
34829
|
+
})) }
|
|
34830
|
+
});
|
|
34831
|
+
else if (value.item.type === "reasoning") {
|
|
34604
34832
|
const activeReasoningPart = activeReasoning[value.item.id];
|
|
34605
34833
|
const summaryPartIndices = Object.entries(activeReasoningPart.summaryParts).filter(([_, status]) => status === "active" || status === "can-conclude").map(([summaryIndex]) => summaryIndex);
|
|
34606
34834
|
for (const summaryIndex of summaryPartIndices) controller.enqueue({
|
|
@@ -34886,14 +35114,14 @@ function escapeJSONDelta$1(delta) {
|
|
|
34886
35114
|
}
|
|
34887
35115
|
|
|
34888
35116
|
//#endregion
|
|
34889
|
-
//#region ../../node_modules/.pnpm/@ai-sdk+azure@3.0.
|
|
35117
|
+
//#region ../../node_modules/.pnpm/@ai-sdk+azure@3.0.31_zod@4.3.6/node_modules/@ai-sdk/azure/dist/index.mjs
|
|
34890
35118
|
var azureOpenaiTools = {
|
|
34891
35119
|
codeInterpreter: codeInterpreter$1,
|
|
34892
35120
|
fileSearch: fileSearch$3,
|
|
34893
35121
|
imageGeneration: imageGeneration$1,
|
|
34894
35122
|
webSearchPreview: webSearchPreview$1
|
|
34895
35123
|
};
|
|
34896
|
-
var VERSION$7 = "3.0.
|
|
35124
|
+
var VERSION$7 = "3.0.31";
|
|
34897
35125
|
function createAzure(options = {}) {
|
|
34898
35126
|
var _a;
|
|
34899
35127
|
const getHeaders = () => {
|
|
@@ -48344,7 +48572,7 @@ var googleTools = {
|
|
|
48344
48572
|
};
|
|
48345
48573
|
|
|
48346
48574
|
//#endregion
|
|
48347
|
-
//#region ../../node_modules/.pnpm/@ai-sdk+google-vertex@4.0.
|
|
48575
|
+
//#region ../../node_modules/.pnpm/@ai-sdk+google-vertex@4.0.59_zod@4.3.6/node_modules/@ai-sdk/google-vertex/dist/index.mjs
|
|
48348
48576
|
var authInstance = null;
|
|
48349
48577
|
var authOptions = null;
|
|
48350
48578
|
function getAuth(options) {
|
|
@@ -48361,7 +48589,7 @@ async function generateAuthToken(options) {
|
|
|
48361
48589
|
const token = await (await getAuth(options || {}).getClient()).getAccessToken();
|
|
48362
48590
|
return (token == null ? void 0 : token.token) || null;
|
|
48363
48591
|
}
|
|
48364
|
-
var VERSION$4 = "4.0.
|
|
48592
|
+
var VERSION$4 = "4.0.59";
|
|
48365
48593
|
var googleVertexFailedResponseHandler = createJsonErrorResponseHandler({
|
|
48366
48594
|
errorSchema: object$2({ error: object$2({
|
|
48367
48595
|
code: number().nullable(),
|
|
@@ -48959,7 +49187,7 @@ function createVertex2(options = {}) {
|
|
|
48959
49187
|
var vertex = createVertex2();
|
|
48960
49188
|
|
|
48961
49189
|
//#endregion
|
|
48962
|
-
//#region ../../node_modules/.pnpm/@ai-sdk+openai@3.0.
|
|
49190
|
+
//#region ../../node_modules/.pnpm/@ai-sdk+openai@3.0.30_zod@4.3.6/node_modules/@ai-sdk/openai/dist/index.mjs
|
|
48963
49191
|
var openaiErrorDataSchema = object$2({ error: object$2({
|
|
48964
49192
|
message: string(),
|
|
48965
49193
|
type: string().nullish(),
|
|
@@ -50560,6 +50788,54 @@ var shellOutputSchema = lazySchema(() => zodSchema(object$2({ output: array$1(ob
|
|
|
50560
50788
|
exitCode: number()
|
|
50561
50789
|
})])
|
|
50562
50790
|
})) })));
|
|
50791
|
+
var shellSkillsSchema = array$1(discriminatedUnion("type", [object$2({
|
|
50792
|
+
type: literal("skillReference"),
|
|
50793
|
+
skillId: string(),
|
|
50794
|
+
version: string().optional()
|
|
50795
|
+
}), object$2({
|
|
50796
|
+
type: literal("inline"),
|
|
50797
|
+
name: string(),
|
|
50798
|
+
description: string(),
|
|
50799
|
+
source: object$2({
|
|
50800
|
+
type: literal("base64"),
|
|
50801
|
+
mediaType: literal("application/zip"),
|
|
50802
|
+
data: string()
|
|
50803
|
+
})
|
|
50804
|
+
})])).optional();
|
|
50805
|
+
var shellArgsSchema = lazySchema(() => zodSchema(object$2({ environment: union([
|
|
50806
|
+
object$2({
|
|
50807
|
+
type: literal("containerAuto"),
|
|
50808
|
+
fileIds: array$1(string()).optional(),
|
|
50809
|
+
memoryLimit: _enum([
|
|
50810
|
+
"1g",
|
|
50811
|
+
"4g",
|
|
50812
|
+
"16g",
|
|
50813
|
+
"64g"
|
|
50814
|
+
]).optional(),
|
|
50815
|
+
networkPolicy: discriminatedUnion("type", [object$2({ type: literal("disabled") }), object$2({
|
|
50816
|
+
type: literal("allowlist"),
|
|
50817
|
+
allowedDomains: array$1(string()),
|
|
50818
|
+
domainSecrets: array$1(object$2({
|
|
50819
|
+
domain: string(),
|
|
50820
|
+
name: string(),
|
|
50821
|
+
value: string()
|
|
50822
|
+
})).optional()
|
|
50823
|
+
})]).optional(),
|
|
50824
|
+
skills: shellSkillsSchema
|
|
50825
|
+
}),
|
|
50826
|
+
object$2({
|
|
50827
|
+
type: literal("containerReference"),
|
|
50828
|
+
containerId: string()
|
|
50829
|
+
}),
|
|
50830
|
+
object$2({
|
|
50831
|
+
type: literal("local").optional(),
|
|
50832
|
+
skills: array$1(object$2({
|
|
50833
|
+
name: string(),
|
|
50834
|
+
description: string(),
|
|
50835
|
+
path: string()
|
|
50836
|
+
})).optional()
|
|
50837
|
+
})
|
|
50838
|
+
]).optional() })));
|
|
50563
50839
|
var shell = createProviderToolFactoryWithOutputSchema({
|
|
50564
50840
|
id: "openai.shell",
|
|
50565
50841
|
inputSchema: shellInputSchema,
|
|
@@ -50895,11 +51171,33 @@ async function convertToOpenAIResponsesInput({ prompt, toolNameMapping, systemMe
|
|
|
50895
51171
|
});
|
|
50896
51172
|
break;
|
|
50897
51173
|
}
|
|
50898
|
-
case "tool-result":
|
|
51174
|
+
case "tool-result": {
|
|
50899
51175
|
if (part.output.type === "execution-denied" || part.output.type === "json" && typeof part.output.value === "object" && part.output.value != null && "type" in part.output.value && part.output.value.type === "execution-denied") break;
|
|
50900
51176
|
if (hasConversation) break;
|
|
51177
|
+
const resolvedResultToolName = toolNameMapping.toProviderToolName(part.toolName);
|
|
51178
|
+
if (hasShellTool && resolvedResultToolName === "shell") {
|
|
51179
|
+
if (part.output.type === "json") {
|
|
51180
|
+
const parsedOutput = await validateTypes({
|
|
51181
|
+
value: part.output.value,
|
|
51182
|
+
schema: shellOutputSchema
|
|
51183
|
+
});
|
|
51184
|
+
input.push({
|
|
51185
|
+
type: "shell_call_output",
|
|
51186
|
+
call_id: part.toolCallId,
|
|
51187
|
+
output: parsedOutput.output.map((item) => ({
|
|
51188
|
+
stdout: item.stdout,
|
|
51189
|
+
stderr: item.stderr,
|
|
51190
|
+
outcome: item.outcome.type === "timeout" ? { type: "timeout" } : {
|
|
51191
|
+
type: "exit",
|
|
51192
|
+
exit_code: item.outcome.exitCode
|
|
51193
|
+
}
|
|
51194
|
+
}))
|
|
51195
|
+
});
|
|
51196
|
+
}
|
|
51197
|
+
break;
|
|
51198
|
+
}
|
|
50901
51199
|
if (store) {
|
|
50902
|
-
const itemId = (_j = (_i = (_h = part.
|
|
51200
|
+
const itemId = (_j = (_i = (_h = part.providerOptions) == null ? void 0 : _h[providerOptionsName]) == null ? void 0 : _i.itemId) != null ? _j : part.toolCallId;
|
|
50903
51201
|
input.push({
|
|
50904
51202
|
type: "item_reference",
|
|
50905
51203
|
id: itemId
|
|
@@ -50909,6 +51207,7 @@ async function convertToOpenAIResponsesInput({ prompt, toolNameMapping, systemMe
|
|
|
50909
51207
|
message: `Results for OpenAI tool ${part.toolName} are not sent to the API when store is false`
|
|
50910
51208
|
});
|
|
50911
51209
|
break;
|
|
51210
|
+
}
|
|
50912
51211
|
case "reasoning": {
|
|
50913
51212
|
const providerOptions = await parseProviderOptions({
|
|
50914
51213
|
provider: providerOptionsName,
|
|
@@ -51237,6 +51536,24 @@ var openaiResponsesChunkSchema = lazySchema(() => zodSchema(union([
|
|
|
51237
51536
|
"incomplete"
|
|
51238
51537
|
]),
|
|
51239
51538
|
action: object$2({ commands: array$1(string()) })
|
|
51539
|
+
}),
|
|
51540
|
+
object$2({
|
|
51541
|
+
type: literal("shell_call_output"),
|
|
51542
|
+
id: string(),
|
|
51543
|
+
call_id: string(),
|
|
51544
|
+
status: _enum([
|
|
51545
|
+
"in_progress",
|
|
51546
|
+
"completed",
|
|
51547
|
+
"incomplete"
|
|
51548
|
+
]),
|
|
51549
|
+
output: array$1(object$2({
|
|
51550
|
+
stdout: string(),
|
|
51551
|
+
stderr: string(),
|
|
51552
|
+
outcome: discriminatedUnion("type", [object$2({ type: literal("timeout") }), object$2({
|
|
51553
|
+
type: literal("exit"),
|
|
51554
|
+
exit_code: number()
|
|
51555
|
+
})])
|
|
51556
|
+
}))
|
|
51240
51557
|
})
|
|
51241
51558
|
])
|
|
51242
51559
|
}),
|
|
@@ -51411,6 +51728,24 @@ var openaiResponsesChunkSchema = lazySchema(() => zodSchema(union([
|
|
|
51411
51728
|
"incomplete"
|
|
51412
51729
|
]),
|
|
51413
51730
|
action: object$2({ commands: array$1(string()) })
|
|
51731
|
+
}),
|
|
51732
|
+
object$2({
|
|
51733
|
+
type: literal("shell_call_output"),
|
|
51734
|
+
id: string(),
|
|
51735
|
+
call_id: string(),
|
|
51736
|
+
status: _enum([
|
|
51737
|
+
"in_progress",
|
|
51738
|
+
"completed",
|
|
51739
|
+
"incomplete"
|
|
51740
|
+
]),
|
|
51741
|
+
output: array$1(object$2({
|
|
51742
|
+
stdout: string(),
|
|
51743
|
+
stderr: string(),
|
|
51744
|
+
outcome: discriminatedUnion("type", [object$2({ type: literal("timeout") }), object$2({
|
|
51745
|
+
type: literal("exit"),
|
|
51746
|
+
exit_code: number()
|
|
51747
|
+
})])
|
|
51748
|
+
}))
|
|
51414
51749
|
})
|
|
51415
51750
|
])
|
|
51416
51751
|
}),
|
|
@@ -51735,6 +52070,24 @@ var openaiResponsesResponseSchema = lazySchema(() => zodSchema(object$2({
|
|
|
51735
52070
|
"incomplete"
|
|
51736
52071
|
]),
|
|
51737
52072
|
action: object$2({ commands: array$1(string()) })
|
|
52073
|
+
}),
|
|
52074
|
+
object$2({
|
|
52075
|
+
type: literal("shell_call_output"),
|
|
52076
|
+
id: string(),
|
|
52077
|
+
call_id: string(),
|
|
52078
|
+
status: _enum([
|
|
52079
|
+
"in_progress",
|
|
52080
|
+
"completed",
|
|
52081
|
+
"incomplete"
|
|
52082
|
+
]),
|
|
52083
|
+
output: array$1(object$2({
|
|
52084
|
+
stdout: string(),
|
|
52085
|
+
stderr: string(),
|
|
52086
|
+
outcome: discriminatedUnion("type", [object$2({ type: literal("timeout") }), object$2({
|
|
52087
|
+
type: literal("exit"),
|
|
52088
|
+
exit_code: number()
|
|
52089
|
+
})])
|
|
52090
|
+
}))
|
|
51738
52091
|
})
|
|
51739
52092
|
])).optional(),
|
|
51740
52093
|
service_tier: string().nullish(),
|
|
@@ -51828,9 +52181,17 @@ async function prepareResponsesTools$1({ tools, toolChoice }) {
|
|
|
51828
52181
|
case "openai.local_shell":
|
|
51829
52182
|
openaiTools2.push({ type: "local_shell" });
|
|
51830
52183
|
break;
|
|
51831
|
-
case "openai.shell":
|
|
51832
|
-
|
|
52184
|
+
case "openai.shell": {
|
|
52185
|
+
const args = await validateTypes({
|
|
52186
|
+
value: tool.args,
|
|
52187
|
+
schema: shellArgsSchema
|
|
52188
|
+
});
|
|
52189
|
+
openaiTools2.push({
|
|
52190
|
+
type: "shell",
|
|
52191
|
+
...args.environment && { environment: mapShellEnvironment(args.environment) }
|
|
52192
|
+
});
|
|
51833
52193
|
break;
|
|
52194
|
+
}
|
|
51834
52195
|
case "openai.apply_patch":
|
|
51835
52196
|
openaiTools2.push({ type: "apply_patch" });
|
|
51836
52197
|
break;
|
|
@@ -51958,6 +52319,46 @@ async function prepareResponsesTools$1({ tools, toolChoice }) {
|
|
|
51958
52319
|
default: throw new UnsupportedFunctionalityError({ functionality: `tool choice type: ${type}` });
|
|
51959
52320
|
}
|
|
51960
52321
|
}
|
|
52322
|
+
function mapShellEnvironment(environment) {
|
|
52323
|
+
if (environment.type === "containerReference") return {
|
|
52324
|
+
type: "container_reference",
|
|
52325
|
+
container_id: environment.containerId
|
|
52326
|
+
};
|
|
52327
|
+
if (environment.type === "containerAuto") {
|
|
52328
|
+
const env2 = environment;
|
|
52329
|
+
return {
|
|
52330
|
+
type: "container_auto",
|
|
52331
|
+
file_ids: env2.fileIds,
|
|
52332
|
+
memory_limit: env2.memoryLimit,
|
|
52333
|
+
network_policy: env2.networkPolicy == null ? void 0 : env2.networkPolicy.type === "disabled" ? { type: "disabled" } : {
|
|
52334
|
+
type: "allowlist",
|
|
52335
|
+
allowed_domains: env2.networkPolicy.allowedDomains,
|
|
52336
|
+
domain_secrets: env2.networkPolicy.domainSecrets
|
|
52337
|
+
},
|
|
52338
|
+
skills: mapShellSkills(env2.skills)
|
|
52339
|
+
};
|
|
52340
|
+
}
|
|
52341
|
+
return {
|
|
52342
|
+
type: "local",
|
|
52343
|
+
skills: environment.skills
|
|
52344
|
+
};
|
|
52345
|
+
}
|
|
52346
|
+
function mapShellSkills(skills) {
|
|
52347
|
+
return skills == null ? void 0 : skills.map((skill) => skill.type === "skillReference" ? {
|
|
52348
|
+
type: "skill_reference",
|
|
52349
|
+
skill_id: skill.skillId,
|
|
52350
|
+
version: skill.version
|
|
52351
|
+
} : {
|
|
52352
|
+
type: "inline",
|
|
52353
|
+
name: skill.name,
|
|
52354
|
+
description: skill.description,
|
|
52355
|
+
source: {
|
|
52356
|
+
type: "base64",
|
|
52357
|
+
media_type: skill.source.mediaType,
|
|
52358
|
+
data: skill.source.data
|
|
52359
|
+
}
|
|
52360
|
+
});
|
|
52361
|
+
}
|
|
51961
52362
|
function extractApprovalRequestIdToToolCallIdMapping(prompt) {
|
|
51962
52363
|
var _a, _b;
|
|
51963
52364
|
const mapping = {};
|
|
@@ -51985,7 +52386,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
51985
52386
|
return this.config.provider;
|
|
51986
52387
|
}
|
|
51987
52388
|
async getArgs({ maxOutputTokens, temperature, stopSequences, topP, topK, presencePenalty, frequencyPenalty, seed, prompt, providerOptions, tools, toolChoice, responseFormat }) {
|
|
51988
|
-
var _a, _b, _c, _d, _e, _f;
|
|
52389
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
51989
52390
|
const warnings = [];
|
|
51990
52391
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
51991
52392
|
if (topK != null) warnings.push({
|
|
@@ -52155,6 +52556,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
52155
52556
|
tools,
|
|
52156
52557
|
toolChoice
|
|
52157
52558
|
});
|
|
52559
|
+
const shellToolEnvType = (_i = (_h = (_g = tools == null ? void 0 : tools.find((tool) => tool.type === "provider" && tool.id === "openai.shell")) == null ? void 0 : _g.args) == null ? void 0 : _h.environment) == null ? void 0 : _i.type;
|
|
52560
|
+
const isShellProviderExecuted = shellToolEnvType === "containerAuto" || shellToolEnvType === "containerReference";
|
|
52158
52561
|
return {
|
|
52159
52562
|
webSearchToolName,
|
|
52160
52563
|
args: {
|
|
@@ -52165,12 +52568,13 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
52165
52568
|
warnings: [...warnings, ...toolWarnings],
|
|
52166
52569
|
store,
|
|
52167
52570
|
toolNameMapping,
|
|
52168
|
-
providerOptionsName
|
|
52571
|
+
providerOptionsName,
|
|
52572
|
+
isShellProviderExecuted
|
|
52169
52573
|
};
|
|
52170
52574
|
}
|
|
52171
52575
|
async doGenerate(options) {
|
|
52172
52576
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
52173
|
-
const { args: body, warnings, webSearchToolName, toolNameMapping, providerOptionsName } = await this.getArgs(options);
|
|
52577
|
+
const { args: body, warnings, webSearchToolName, toolNameMapping, providerOptionsName, isShellProviderExecuted } = await this.getArgs(options);
|
|
52174
52578
|
const url = this.config.url({
|
|
52175
52579
|
path: "/responses",
|
|
52176
52580
|
modelId: this.modelId
|
|
@@ -52242,9 +52646,25 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
52242
52646
|
toolCallId: part.call_id,
|
|
52243
52647
|
toolName: toolNameMapping.toCustomToolName("shell"),
|
|
52244
52648
|
input: JSON.stringify({ action: { commands: part.action.commands } }),
|
|
52649
|
+
...isShellProviderExecuted && { providerExecuted: true },
|
|
52245
52650
|
providerMetadata: { [providerOptionsName]: { itemId: part.id } }
|
|
52246
52651
|
});
|
|
52247
52652
|
break;
|
|
52653
|
+
case "shell_call_output":
|
|
52654
|
+
content.push({
|
|
52655
|
+
type: "tool-result",
|
|
52656
|
+
toolCallId: part.call_id,
|
|
52657
|
+
toolName: toolNameMapping.toCustomToolName("shell"),
|
|
52658
|
+
result: { output: part.output.map((item) => ({
|
|
52659
|
+
stdout: item.stdout,
|
|
52660
|
+
stderr: item.stderr,
|
|
52661
|
+
outcome: item.outcome.type === "exit" ? {
|
|
52662
|
+
type: "exit",
|
|
52663
|
+
exitCode: item.outcome.exit_code
|
|
52664
|
+
} : { type: "timeout" }
|
|
52665
|
+
})) }
|
|
52666
|
+
});
|
|
52667
|
+
break;
|
|
52248
52668
|
case "message":
|
|
52249
52669
|
for (const contentPart of part.content) {
|
|
52250
52670
|
if (((_c = (_b = options.providerOptions) == null ? void 0 : _b[providerOptionsName]) == null ? void 0 : _c.logprobs) && contentPart.logprobs) logprobs.push(contentPart.logprobs);
|
|
@@ -52479,7 +52899,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
52479
52899
|
};
|
|
52480
52900
|
}
|
|
52481
52901
|
async doStream(options) {
|
|
52482
|
-
const { args: body, warnings, webSearchToolName, toolNameMapping, store, providerOptionsName } = await this.getArgs(options);
|
|
52902
|
+
const { args: body, warnings, webSearchToolName, toolNameMapping, store, providerOptionsName, isShellProviderExecuted } = await this.getArgs(options);
|
|
52483
52903
|
const { responseHeaders, value: response } = await postJsonToApi({
|
|
52484
52904
|
url: this.config.url({
|
|
52485
52905
|
path: "/responses",
|
|
@@ -52649,7 +53069,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
52649
53069
|
toolName: toolNameMapping.toCustomToolName("shell"),
|
|
52650
53070
|
toolCallId: value.item.call_id
|
|
52651
53071
|
};
|
|
52652
|
-
else if (value.item.type === "message") {
|
|
53072
|
+
else if (value.item.type === "shell_call_output") {} else if (value.item.type === "message") {
|
|
52653
53073
|
ongoingAnnotations.splice(0, ongoingAnnotations.length);
|
|
52654
53074
|
controller.enqueue({
|
|
52655
53075
|
type: "text-start",
|
|
@@ -52854,9 +53274,23 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
52854
53274
|
toolCallId: value.item.call_id,
|
|
52855
53275
|
toolName: toolNameMapping.toCustomToolName("shell"),
|
|
52856
53276
|
input: JSON.stringify({ action: { commands: value.item.action.commands } }),
|
|
53277
|
+
...isShellProviderExecuted && { providerExecuted: true },
|
|
52857
53278
|
providerMetadata: { [providerOptionsName]: { itemId: value.item.id } }
|
|
52858
53279
|
});
|
|
52859
|
-
} else if (value.item.type === "
|
|
53280
|
+
} else if (value.item.type === "shell_call_output") controller.enqueue({
|
|
53281
|
+
type: "tool-result",
|
|
53282
|
+
toolCallId: value.item.call_id,
|
|
53283
|
+
toolName: toolNameMapping.toCustomToolName("shell"),
|
|
53284
|
+
result: { output: value.item.output.map((item) => ({
|
|
53285
|
+
stdout: item.stdout,
|
|
53286
|
+
stderr: item.stderr,
|
|
53287
|
+
outcome: item.outcome.type === "exit" ? {
|
|
53288
|
+
type: "exit",
|
|
53289
|
+
exitCode: item.outcome.exit_code
|
|
53290
|
+
} : { type: "timeout" }
|
|
53291
|
+
})) }
|
|
53292
|
+
});
|
|
53293
|
+
else if (value.item.type === "reasoning") {
|
|
52860
53294
|
const activeReasoningPart = activeReasoning[value.item.id];
|
|
52861
53295
|
const summaryPartIndices = Object.entries(activeReasoningPart.summaryParts).filter(([_, status]) => status === "active" || status === "can-conclude").map(([summaryIndex]) => summaryIndex);
|
|
52862
53296
|
for (const summaryIndex of summaryPartIndices) controller.enqueue({
|
|
@@ -53393,7 +53827,7 @@ var OpenAITranscriptionModel = class {
|
|
|
53393
53827
|
};
|
|
53394
53828
|
}
|
|
53395
53829
|
};
|
|
53396
|
-
var VERSION$3 = "3.0.
|
|
53830
|
+
var VERSION$3 = "3.0.30";
|
|
53397
53831
|
function createOpenAI(options = {}) {
|
|
53398
53832
|
var _a, _b;
|
|
53399
53833
|
const baseURL = (_a = withoutTrailingSlash(loadOptionalSetting({
|
|
@@ -53484,7 +53918,7 @@ function createOpenAI(options = {}) {
|
|
|
53484
53918
|
var openai = createOpenAI();
|
|
53485
53919
|
|
|
53486
53920
|
//#endregion
|
|
53487
|
-
//#region ../../node_modules/.pnpm/ollama-ai-provider-v2@3.3.
|
|
53921
|
+
//#region ../../node_modules/.pnpm/ollama-ai-provider-v2@3.3.1_ai@6.0.91_zod@4.3.6__zod@4.3.6/node_modules/ollama-ai-provider-v2/dist/index.mjs
|
|
53488
53922
|
function convertToOllamaCompletionPrompt({ prompt, user = "user", assistant = "assistant" }) {
|
|
53489
53923
|
let text = "";
|
|
53490
53924
|
if (prompt[0].role === "system") {
|
|
@@ -75465,7 +75899,7 @@ function validateRuntimeVersion(experts) {
|
|
|
75465
75899
|
//#endregion
|
|
75466
75900
|
//#region ../../packages/runtime/src/helpers/setup-experts.ts
|
|
75467
75901
|
async function setupExperts(setting, resolveExpertToRun) {
|
|
75468
|
-
const resolveFn = resolveExpertToRun ?? (await import("../resolve-expert-
|
|
75902
|
+
const resolveFn = resolveExpertToRun ?? (await import("../resolve-expert-CTnETi9d.js")).resolveExpertToRun;
|
|
75469
75903
|
const { expertKey } = setting;
|
|
75470
75904
|
const experts = { ...setting.experts };
|
|
75471
75905
|
const clientOptions = {
|
|
@@ -75768,7 +76202,7 @@ var require_dist$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
75768
76202
|
}));
|
|
75769
76203
|
|
|
75770
76204
|
//#endregion
|
|
75771
|
-
//#region ../../node_modules/.pnpm/@ai-sdk+gateway@3.0.
|
|
76205
|
+
//#region ../../node_modules/.pnpm/@ai-sdk+gateway@3.0.50_zod@4.3.6/node_modules/@ai-sdk/gateway/dist/index.mjs
|
|
75772
76206
|
var import_dist$1 = require_dist$1();
|
|
75773
76207
|
var symbol$1 = Symbol.for("vercel.ai.gateway.error");
|
|
75774
76208
|
var _a$1, _b;
|
|
@@ -76652,7 +77086,7 @@ async function getVercelRequestId() {
|
|
|
76652
77086
|
var _a9;
|
|
76653
77087
|
return (_a9 = (0, import_dist$1.getContext)().headers) == null ? void 0 : _a9["x-vercel-id"];
|
|
76654
77088
|
}
|
|
76655
|
-
var VERSION$2 = "3.0.
|
|
77089
|
+
var VERSION$2 = "3.0.50";
|
|
76656
77090
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
76657
77091
|
function createGatewayProvider(options = {}) {
|
|
76658
77092
|
var _a9, _b9;
|
|
@@ -77673,7 +78107,7 @@ var TraceAPI = function() {
|
|
|
77673
78107
|
var trace = TraceAPI.getInstance();
|
|
77674
78108
|
|
|
77675
78109
|
//#endregion
|
|
77676
|
-
//#region ../../node_modules/.pnpm/ai@6.0.
|
|
78110
|
+
//#region ../../node_modules/.pnpm/ai@6.0.91_zod@4.3.6/node_modules/ai/dist/index.mjs
|
|
77677
78111
|
var __defProp = Object.defineProperty;
|
|
77678
78112
|
var __export = (target, all) => {
|
|
77679
78113
|
for (var name21 in all) __defProp(target, name21, {
|
|
@@ -78209,7 +78643,7 @@ function detectMediaType({ data, signatures }) {
|
|
|
78209
78643
|
const bytes = typeof processedData === "string" ? convertBase64ToUint8Array(processedData.substring(0, Math.min(processedData.length, 24))) : processedData;
|
|
78210
78644
|
for (const signature of signatures) if (bytes.length >= signature.bytesPrefix.length && signature.bytesPrefix.every((byte, index) => byte === null || bytes[index] === byte)) return signature.mediaType;
|
|
78211
78645
|
}
|
|
78212
|
-
var VERSION = "6.0.
|
|
78646
|
+
var VERSION = "6.0.91";
|
|
78213
78647
|
var download = async ({ url, maxBytes, abortSignal }) => {
|
|
78214
78648
|
var _a21;
|
|
78215
78649
|
const urlText = url.toString();
|
|
@@ -87806,7 +88240,7 @@ async function callingMcpToolsLogic({ setting, checkpoint, step, skillManager })
|
|
|
87806
88240
|
...checkpoint,
|
|
87807
88241
|
messages: [...checkpoint.messages, ...newMessages],
|
|
87808
88242
|
usage: newUsage,
|
|
87809
|
-
contextWindowUsage: checkpoint.
|
|
88243
|
+
contextWindowUsage: checkpoint.contextWindowUsage,
|
|
87810
88244
|
status: "completed",
|
|
87811
88245
|
pendingToolCalls: void 0,
|
|
87812
88246
|
partialToolResults: void 0
|
|
@@ -87970,9 +88404,10 @@ async function generatingRunResultLogic({ setting, checkpoint, step, eventListen
|
|
|
87970
88404
|
const { text, reasoning } = generationResult;
|
|
87971
88405
|
const thinkingParts = extractThinkingParts(reasoning);
|
|
87972
88406
|
const thinkingText = extractThinkingText(reasoning);
|
|
88407
|
+
const resultText = text || "OK";
|
|
87973
88408
|
const newMessages = [toolMessage, createExpertMessage([...thinkingParts, {
|
|
87974
88409
|
type: "textPart",
|
|
87975
|
-
text:
|
|
88410
|
+
text: resultText
|
|
87976
88411
|
}])];
|
|
87977
88412
|
if (thinkingText && !reasoningCompletedViaCallback) await eventListener(createStreamingEvent("completeStreamingReasoning", setting, checkpoint, { text: thinkingText }));
|
|
87978
88413
|
const newUsage = sumUsage(checkpoint.usage, usage);
|
|
@@ -87981,7 +88416,7 @@ async function generatingRunResultLogic({ setting, checkpoint, step, eventListen
|
|
|
87981
88416
|
...checkpoint,
|
|
87982
88417
|
messages: [...messages, ...newMessages],
|
|
87983
88418
|
usage: newUsage,
|
|
87984
|
-
contextWindowUsage: checkpoint.contextWindow ? calculateContextWindowUsage(
|
|
88419
|
+
contextWindowUsage: checkpoint.contextWindow ? calculateContextWindowUsage(usage, checkpoint.contextWindow) : void 0,
|
|
87985
88420
|
status: "completed",
|
|
87986
88421
|
pendingToolCalls: void 0,
|
|
87987
88422
|
partialToolResults: void 0
|
|
@@ -87992,7 +88427,7 @@ async function generatingRunResultLogic({ setting, checkpoint, step, eventListen
|
|
|
87992
88427
|
finishedAt: Date.now(),
|
|
87993
88428
|
usage: sumUsage(step.usage, usage)
|
|
87994
88429
|
},
|
|
87995
|
-
text,
|
|
88430
|
+
text: resultText,
|
|
87996
88431
|
usage
|
|
87997
88432
|
});
|
|
87998
88433
|
}
|
|
@@ -88583,7 +89018,7 @@ const runtimeStateMachine = setup({ types: {
|
|
|
88583
89018
|
...context.checkpoint,
|
|
88584
89019
|
messages: [...context.checkpoint.messages, event.newMessage],
|
|
88585
89020
|
usage: newUsage,
|
|
88586
|
-
contextWindowUsage: context.checkpoint.contextWindow ? calculateContextWindowUsage(
|
|
89021
|
+
contextWindowUsage: context.checkpoint.contextWindow ? calculateContextWindowUsage(event.usage, context.checkpoint.contextWindow) : void 0,
|
|
88587
89022
|
retryCount: 0
|
|
88588
89023
|
};
|
|
88589
89024
|
},
|
|
@@ -89074,43 +89509,65 @@ var DelegationExecutor = class {
|
|
|
89074
89509
|
async executeSingleDelegation(delegation, parentSetting, parentContext, parentExpert, runFn, parentOptions) {
|
|
89075
89510
|
const { expert, toolCallId, toolName, query } = delegation;
|
|
89076
89511
|
const delegateRunId = createId();
|
|
89077
|
-
const
|
|
89078
|
-
|
|
89079
|
-
|
|
89080
|
-
|
|
89081
|
-
|
|
89082
|
-
|
|
89512
|
+
const delegateSetting = {
|
|
89513
|
+
...parentSetting,
|
|
89514
|
+
runId: delegateRunId,
|
|
89515
|
+
expertKey: expert.key,
|
|
89516
|
+
input: { text: query }
|
|
89517
|
+
};
|
|
89518
|
+
const delegateCheckpoint = {
|
|
89519
|
+
id: createId(),
|
|
89520
|
+
jobId: parentSetting.jobId,
|
|
89521
|
+
runId: delegateRunId,
|
|
89522
|
+
status: "init",
|
|
89523
|
+
stepNumber: parentContext.stepNumber,
|
|
89524
|
+
messages: [],
|
|
89525
|
+
expert: {
|
|
89526
|
+
key: expert.key,
|
|
89527
|
+
name: expert.name,
|
|
89528
|
+
version: expert.version
|
|
89083
89529
|
},
|
|
89084
|
-
|
|
89085
|
-
id: createId(),
|
|
89086
|
-
jobId: parentSetting.jobId,
|
|
89087
|
-
runId: delegateRunId,
|
|
89088
|
-
status: "init",
|
|
89089
|
-
stepNumber: parentContext.stepNumber,
|
|
89090
|
-
messages: [],
|
|
89530
|
+
delegatedBy: {
|
|
89091
89531
|
expert: {
|
|
89092
|
-
key:
|
|
89093
|
-
name:
|
|
89094
|
-
version:
|
|
89095
|
-
},
|
|
89096
|
-
delegatedBy: {
|
|
89097
|
-
expert: {
|
|
89098
|
-
key: parentExpert.key,
|
|
89099
|
-
name: parentExpert.name,
|
|
89100
|
-
version: parentExpert.version
|
|
89101
|
-
},
|
|
89102
|
-
toolCallId,
|
|
89103
|
-
toolName,
|
|
89104
|
-
checkpointId: parentContext.id,
|
|
89105
|
-
runId: parentSetting.runId
|
|
89532
|
+
key: parentExpert.key,
|
|
89533
|
+
name: parentExpert.name,
|
|
89534
|
+
version: parentExpert.version
|
|
89106
89535
|
},
|
|
89107
|
-
|
|
89108
|
-
|
|
89109
|
-
|
|
89110
|
-
|
|
89111
|
-
|
|
89112
|
-
|
|
89113
|
-
|
|
89536
|
+
toolCallId,
|
|
89537
|
+
toolName,
|
|
89538
|
+
checkpointId: parentContext.id,
|
|
89539
|
+
runId: parentSetting.runId
|
|
89540
|
+
},
|
|
89541
|
+
usage: createEmptyUsage(),
|
|
89542
|
+
contextWindow: parentContext.contextWindow
|
|
89543
|
+
};
|
|
89544
|
+
let resultCheckpoint;
|
|
89545
|
+
try {
|
|
89546
|
+
resultCheckpoint = await runFn({
|
|
89547
|
+
setting: delegateSetting,
|
|
89548
|
+
checkpoint: delegateCheckpoint
|
|
89549
|
+
}, {
|
|
89550
|
+
...parentOptions,
|
|
89551
|
+
returnOnDelegationComplete: true
|
|
89552
|
+
});
|
|
89553
|
+
} catch (error) {
|
|
89554
|
+
return {
|
|
89555
|
+
toolCallId,
|
|
89556
|
+
toolName,
|
|
89557
|
+
expertKey: expert.key,
|
|
89558
|
+
text: `Delegation to ${expert.key} failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
89559
|
+
stepNumber: parentContext.stepNumber,
|
|
89560
|
+
deltaUsage: createEmptyUsage()
|
|
89561
|
+
};
|
|
89562
|
+
}
|
|
89563
|
+
if (resultCheckpoint.status !== "completed") return {
|
|
89564
|
+
toolCallId,
|
|
89565
|
+
toolName,
|
|
89566
|
+
expertKey: expert.key,
|
|
89567
|
+
text: `Delegation to ${expert.key} ended with status: ${resultCheckpoint.status}`,
|
|
89568
|
+
stepNumber: resultCheckpoint.stepNumber,
|
|
89569
|
+
deltaUsage: resultCheckpoint.usage
|
|
89570
|
+
};
|
|
89114
89571
|
return this.extractDelegationResult(resultCheckpoint, toolCallId, toolName, expert.key);
|
|
89115
89572
|
}
|
|
89116
89573
|
extractDelegationResult(checkpoint, toolCallId, toolName, expertKey) {
|
|
@@ -89175,19 +89632,19 @@ const defaultCreateJob = (jobId, expertKey, maxSteps, runtimeVersion = getCurren
|
|
|
89175
89632
|
*/
|
|
89176
89633
|
async function run(runInput, options) {
|
|
89177
89634
|
let { setting, checkpoint } = runParamsSchema.parse(runInput);
|
|
89178
|
-
const storeJob = options?.storeJob ?? (() => {});
|
|
89179
|
-
const retrieveJob = options?.retrieveJob ?? (() => void 0);
|
|
89635
|
+
const storeJob = options?.storeJob ?? (async () => {});
|
|
89636
|
+
const retrieveJob = options?.retrieveJob ?? (async () => void 0);
|
|
89180
89637
|
const retrieveCheckpoint = options?.retrieveCheckpoint ?? (async () => {
|
|
89181
89638
|
throw new Error("retrieveCheckpoint not provided");
|
|
89182
89639
|
});
|
|
89183
89640
|
const createJob = options?.createJob ?? defaultCreateJob;
|
|
89184
|
-
let job = retrieveJob(setting.jobId) ?? createJob(setting.jobId, setting.expertKey, setting.maxSteps);
|
|
89641
|
+
let job = await retrieveJob(setting.jobId) ?? createJob(setting.jobId, setting.expertKey, setting.maxSteps);
|
|
89185
89642
|
if (job.status !== "running") job = {
|
|
89186
89643
|
...job,
|
|
89187
89644
|
status: "running",
|
|
89188
89645
|
finishedAt: void 0
|
|
89189
89646
|
};
|
|
89190
|
-
storeJob(job);
|
|
89647
|
+
await storeJob(job);
|
|
89191
89648
|
const runExecutor = new CoordinatorExecutor({
|
|
89192
89649
|
shouldContinueRun: options?.shouldContinueRun,
|
|
89193
89650
|
storeCheckpoint: options?.storeCheckpoint,
|
|
@@ -89207,31 +89664,31 @@ async function run(runInput, options) {
|
|
|
89207
89664
|
switch (resultCheckpoint.status) {
|
|
89208
89665
|
case "completed":
|
|
89209
89666
|
if (options?.returnOnDelegationComplete) {
|
|
89210
|
-
storeJob(job);
|
|
89667
|
+
await storeJob(job);
|
|
89211
89668
|
return resultCheckpoint;
|
|
89212
89669
|
}
|
|
89213
89670
|
if (resultCheckpoint.delegatedBy) {
|
|
89214
|
-
storeJob(job);
|
|
89671
|
+
await storeJob(job);
|
|
89215
89672
|
const parentCheckpoint = await retrieveCheckpoint(setting.jobId, resultCheckpoint.delegatedBy.checkpointId);
|
|
89216
89673
|
const result = buildReturnFromDelegation(setting, resultCheckpoint, parentCheckpoint);
|
|
89217
89674
|
setting = result.setting;
|
|
89218
89675
|
checkpoint = result.checkpoint;
|
|
89219
89676
|
break;
|
|
89220
89677
|
}
|
|
89221
|
-
storeJob({
|
|
89678
|
+
await storeJob({
|
|
89222
89679
|
...job,
|
|
89223
89680
|
status: "completed",
|
|
89224
89681
|
finishedAt: Date.now()
|
|
89225
89682
|
});
|
|
89226
89683
|
return resultCheckpoint;
|
|
89227
89684
|
case "stoppedByInteractiveTool":
|
|
89228
|
-
storeJob({
|
|
89685
|
+
await storeJob({
|
|
89229
89686
|
...job,
|
|
89230
89687
|
status: "stoppedByInteractiveTool"
|
|
89231
89688
|
});
|
|
89232
89689
|
return resultCheckpoint;
|
|
89233
89690
|
case "stoppedByDelegate": {
|
|
89234
|
-
storeJob(job);
|
|
89691
|
+
await storeJob(job);
|
|
89235
89692
|
const { delegateTo } = resultCheckpoint;
|
|
89236
89693
|
if (!delegateTo || delegateTo.length === 0) throw new Error("No delegations found in checkpoint");
|
|
89237
89694
|
const executor = new DelegationExecutor();
|
|
@@ -89246,21 +89703,21 @@ async function run(runInput, options) {
|
|
|
89246
89703
|
break;
|
|
89247
89704
|
}
|
|
89248
89705
|
case "stoppedByExceededMaxSteps":
|
|
89249
|
-
storeJob({
|
|
89706
|
+
await storeJob({
|
|
89250
89707
|
...job,
|
|
89251
89708
|
status: "stoppedByMaxSteps",
|
|
89252
89709
|
finishedAt: Date.now()
|
|
89253
89710
|
});
|
|
89254
89711
|
return resultCheckpoint;
|
|
89255
89712
|
case "stoppedByError":
|
|
89256
|
-
storeJob({
|
|
89713
|
+
await storeJob({
|
|
89257
89714
|
...job,
|
|
89258
89715
|
status: "stoppedByError",
|
|
89259
89716
|
finishedAt: Date.now()
|
|
89260
89717
|
});
|
|
89261
89718
|
return resultCheckpoint;
|
|
89262
89719
|
case "stoppedByCancellation":
|
|
89263
|
-
storeJob({
|
|
89720
|
+
await storeJob({
|
|
89264
89721
|
...job,
|
|
89265
89722
|
status: "stoppedByCancellation",
|
|
89266
89723
|
finishedAt: Date.now()
|
|
@@ -113396,6 +113853,17 @@ var EventQueue = class EventQueue {
|
|
|
113396
113853
|
}
|
|
113397
113854
|
};
|
|
113398
113855
|
|
|
113856
|
+
//#endregion
|
|
113857
|
+
//#region ../../packages/tui-components/src/colors.ts
|
|
113858
|
+
const colors = {
|
|
113859
|
+
primary: "white",
|
|
113860
|
+
muted: "gray",
|
|
113861
|
+
accent: "cyan",
|
|
113862
|
+
success: "green",
|
|
113863
|
+
warn: "yellow",
|
|
113864
|
+
destructive: "red"
|
|
113865
|
+
};
|
|
113866
|
+
|
|
113399
113867
|
//#endregion
|
|
113400
113868
|
//#region ../../packages/tui-components/src/constants.ts
|
|
113401
113869
|
const UI_CONSTANTS = {
|
|
@@ -113419,11 +113887,7 @@ const INDICATOR = {
|
|
|
113419
113887
|
BULLET: "●",
|
|
113420
113888
|
ELLIPSIS: "..."
|
|
113421
113889
|
};
|
|
113422
|
-
const STOP_EVENT_TYPES = [
|
|
113423
|
-
"stopRunByInteractiveTool",
|
|
113424
|
-
"stopRunByDelegate",
|
|
113425
|
-
"stopRunByExceededMaxSteps"
|
|
113426
|
-
];
|
|
113890
|
+
const STOP_EVENT_TYPES = ["stopRunByInteractiveTool", "stopRunByExceededMaxSteps"];
|
|
113427
113891
|
const KEY_BINDINGS = {
|
|
113428
113892
|
NAVIGATE_UP: "↑",
|
|
113429
113893
|
NAVIGATE_DOWN: "↓",
|
|
@@ -113729,7 +114193,7 @@ const ActionRowSimple = ({ indicatorColor, text, textDimColor = false }) => /* @
|
|
|
113729
114193
|
color: indicatorColor,
|
|
113730
114194
|
children: INDICATOR.BULLET
|
|
113731
114195
|
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
113732
|
-
color:
|
|
114196
|
+
color: colors.primary,
|
|
113733
114197
|
dimColor: textDimColor,
|
|
113734
114198
|
children: text
|
|
113735
114199
|
})]
|
|
@@ -113747,11 +114211,11 @@ const ActionRow = ({ indicatorColor, label, summary, children }) => /* @__PURE__
|
|
|
113747
114211
|
children: INDICATOR.BULLET
|
|
113748
114212
|
}),
|
|
113749
114213
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
113750
|
-
color:
|
|
114214
|
+
color: colors.primary,
|
|
113751
114215
|
children: label
|
|
113752
114216
|
}),
|
|
113753
114217
|
summary && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
113754
|
-
color:
|
|
114218
|
+
color: colors.primary,
|
|
113755
114219
|
dimColor: true,
|
|
113756
114220
|
children: summary
|
|
113757
114221
|
})
|
|
@@ -113863,10 +114327,10 @@ const ListBrowser = ({ title, items, renderItem, onSelect, emptyMessage = "No it
|
|
|
113863
114327
|
flexDirection: "column",
|
|
113864
114328
|
children: [
|
|
113865
114329
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
113866
|
-
color:
|
|
114330
|
+
color: colors.accent,
|
|
113867
114331
|
children: title
|
|
113868
114332
|
}), items.length > maxItems && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
|
|
113869
|
-
color:
|
|
114333
|
+
color: colors.muted,
|
|
113870
114334
|
children: [
|
|
113871
114335
|
" ",
|
|
113872
114336
|
"(",
|
|
@@ -113877,13 +114341,13 @@ const ListBrowser = ({ title, items, renderItem, onSelect, emptyMessage = "No it
|
|
|
113877
114341
|
]
|
|
113878
114342
|
})] }),
|
|
113879
114343
|
hasMoreAbove && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
113880
|
-
color:
|
|
114344
|
+
color: colors.muted,
|
|
113881
114345
|
children: INDICATOR.ELLIPSIS
|
|
113882
114346
|
}),
|
|
113883
114347
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
|
|
113884
114348
|
flexDirection: "column",
|
|
113885
114349
|
children: displayItems.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
113886
|
-
color:
|
|
114350
|
+
color: colors.muted,
|
|
113887
114351
|
children: emptyMessage
|
|
113888
114352
|
}) : displayItems.map((item, index) => {
|
|
113889
114353
|
const actualIndex = scrollOffset + index;
|
|
@@ -113891,7 +114355,7 @@ const ListBrowser = ({ title, items, renderItem, onSelect, emptyMessage = "No it
|
|
|
113891
114355
|
})
|
|
113892
114356
|
}),
|
|
113893
114357
|
hasMoreBelow && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
113894
|
-
color:
|
|
114358
|
+
color: colors.muted,
|
|
113895
114359
|
children: INDICATOR.ELLIPSIS
|
|
113896
114360
|
})
|
|
113897
114361
|
]
|
|
@@ -113914,7 +114378,7 @@ const BrowsingCheckpointsInput = ({ job, checkpoints, onCheckpointSelect, onChec
|
|
|
113914
114378
|
return false;
|
|
113915
114379
|
},
|
|
113916
114380
|
renderItem: (cp, isSelected) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
|
|
113917
|
-
color: isSelected ?
|
|
114381
|
+
color: isSelected ? colors.accent : colors.muted,
|
|
113918
114382
|
children: [
|
|
113919
114383
|
isSelected ? ">" : " ",
|
|
113920
114384
|
" Step ",
|
|
@@ -113949,29 +114413,29 @@ const BrowsingEventDetailInput = ({ event, onBack }) => {
|
|
|
113949
114413
|
marginLeft: 2,
|
|
113950
114414
|
children: [
|
|
113951
114415
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
113952
|
-
color:
|
|
114416
|
+
color: colors.muted,
|
|
113953
114417
|
children: "Type: "
|
|
113954
114418
|
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
113955
|
-
color:
|
|
114419
|
+
color: colors.accent,
|
|
113956
114420
|
children: event.type
|
|
113957
114421
|
})] }),
|
|
113958
114422
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
113959
|
-
color:
|
|
114423
|
+
color: colors.muted,
|
|
113960
114424
|
children: "Step: "
|
|
113961
114425
|
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: event.stepNumber })] }),
|
|
113962
114426
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
113963
|
-
color:
|
|
114427
|
+
color: colors.muted,
|
|
113964
114428
|
children: "Timestamp: "
|
|
113965
114429
|
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: formatTimestamp(event.timestamp) })] }),
|
|
113966
114430
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
113967
|
-
color:
|
|
114431
|
+
color: colors.muted,
|
|
113968
114432
|
children: "ID: "
|
|
113969
114433
|
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
113970
114434
|
dimColor: true,
|
|
113971
114435
|
children: event.id
|
|
113972
114436
|
})] }),
|
|
113973
114437
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
113974
|
-
color:
|
|
114438
|
+
color: colors.muted,
|
|
113975
114439
|
children: "Run ID: "
|
|
113976
114440
|
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
113977
114441
|
dimColor: true,
|
|
@@ -113991,7 +114455,7 @@ const BrowsingEventsInput = ({ checkpoint, events, onEventSelect, onBack }) => /
|
|
|
113991
114455
|
onBack,
|
|
113992
114456
|
emptyMessage: "No events found",
|
|
113993
114457
|
renderItem: (ev, isSelected) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
|
|
113994
|
-
color: isSelected ?
|
|
114458
|
+
color: isSelected ? colors.accent : colors.muted,
|
|
113995
114459
|
children: [
|
|
113996
114460
|
isSelected ? ">" : " ",
|
|
113997
114461
|
" [",
|
|
@@ -114673,17 +115137,17 @@ const useExpertSelector = (options) => {
|
|
|
114673
115137
|
const ExpertList = ({ experts, selectedIndex, showSource = false, inline = false, maxItems }) => {
|
|
114674
115138
|
const displayExperts = maxItems ? experts.slice(0, maxItems) : experts;
|
|
114675
115139
|
if (displayExperts.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
114676
|
-
color:
|
|
115140
|
+
color: colors.muted,
|
|
114677
115141
|
children: "No experts found."
|
|
114678
115142
|
});
|
|
114679
115143
|
const items = displayExperts.map((expert, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
|
|
114680
|
-
color: index === selectedIndex ?
|
|
115144
|
+
color: index === selectedIndex ? colors.accent : colors.muted,
|
|
114681
115145
|
children: [
|
|
114682
115146
|
index === selectedIndex ? ">" : " ",
|
|
114683
115147
|
" ",
|
|
114684
115148
|
showSource ? expert.key : expert.name,
|
|
114685
115149
|
showSource && expert.source && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [" ", /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
|
|
114686
|
-
color: expert.source === "configured" ?
|
|
115150
|
+
color: expert.source === "configured" ? colors.success : colors.warn,
|
|
114687
115151
|
children: [
|
|
114688
115152
|
"[",
|
|
114689
115153
|
expert.source === "configured" ? "config" : "recent",
|
|
@@ -114713,7 +115177,7 @@ const ExpertSelectorBase = ({ experts, hint, onExpertSelect, showSource = false,
|
|
|
114713
115177
|
children: [!inputMode && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
|
|
114714
115178
|
flexDirection: "column",
|
|
114715
115179
|
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
114716
|
-
color:
|
|
115180
|
+
color: colors.accent,
|
|
114717
115181
|
children: hint
|
|
114718
115182
|
}) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ExpertList, {
|
|
114719
115183
|
experts,
|
|
@@ -114724,15 +115188,15 @@ const ExpertSelectorBase = ({ experts, hint, onExpertSelect, showSource = false,
|
|
|
114724
115188
|
})]
|
|
114725
115189
|
}), inputMode && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, { children: [
|
|
114726
115190
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
114727
|
-
color:
|
|
115191
|
+
color: colors.muted,
|
|
114728
115192
|
children: "Expert: "
|
|
114729
115193
|
}),
|
|
114730
115194
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
114731
|
-
color:
|
|
115195
|
+
color: colors.primary,
|
|
114732
115196
|
children: input
|
|
114733
115197
|
}),
|
|
114734
115198
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
114735
|
-
color:
|
|
115199
|
+
color: colors.accent,
|
|
114736
115200
|
children: "_"
|
|
114737
115201
|
})
|
|
114738
115202
|
] })]
|
|
@@ -114778,7 +115242,7 @@ const BrowsingHistoryInput = ({ jobs, onJobSelect, onJobResume, onSwitchToExpert
|
|
|
114778
115242
|
return false;
|
|
114779
115243
|
},
|
|
114780
115244
|
renderItem: (job, isSelected) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
|
|
114781
|
-
color: isSelected ?
|
|
115245
|
+
color: isSelected ? colors.accent : colors.muted,
|
|
114782
115246
|
children: [
|
|
114783
115247
|
isSelected ? ">" : " ",
|
|
114784
115248
|
" ",
|
|
@@ -114860,12 +115324,13 @@ function renderParallelGroup(group) {
|
|
|
114860
115324
|
});
|
|
114861
115325
|
}
|
|
114862
115326
|
function renderReasoning(text) {
|
|
115327
|
+
const lines = text.split("\n");
|
|
114863
115328
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActionRow, {
|
|
114864
|
-
indicatorColor:
|
|
115329
|
+
indicatorColor: colors.primary,
|
|
114865
115330
|
label: "Reasoning",
|
|
114866
115331
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
|
|
114867
115332
|
flexDirection: "column",
|
|
114868
|
-
children:
|
|
115333
|
+
children: lines.map((line, idx) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
114869
115334
|
dimColor: true,
|
|
114870
115335
|
wrap: "wrap",
|
|
114871
115336
|
children: line
|
|
@@ -114874,11 +115339,11 @@ function renderReasoning(text) {
|
|
|
114874
115339
|
});
|
|
114875
115340
|
}
|
|
114876
115341
|
function renderAction(action) {
|
|
114877
|
-
const color = action.type === "error" || "error" in action && action.error ?
|
|
115342
|
+
const color = action.type === "error" || "error" in action && action.error ? colors.destructive : colors.success;
|
|
114878
115343
|
switch (action.type) {
|
|
114879
115344
|
case "query": return renderQuery(action.text, action.runId);
|
|
114880
115345
|
case "retry": return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActionRow, {
|
|
114881
|
-
indicatorColor:
|
|
115346
|
+
indicatorColor: colors.warn,
|
|
114882
115347
|
label: "Retry",
|
|
114883
115348
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
114884
115349
|
dimColor: true,
|
|
@@ -114886,22 +115351,22 @@ function renderAction(action) {
|
|
|
114886
115351
|
})
|
|
114887
115352
|
});
|
|
114888
115353
|
case "complete": return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActionRow, {
|
|
114889
|
-
indicatorColor:
|
|
115354
|
+
indicatorColor: colors.success,
|
|
114890
115355
|
label: "Run Results",
|
|
114891
115356
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: action.text })
|
|
114892
115357
|
});
|
|
114893
115358
|
case "attemptCompletion": {
|
|
114894
115359
|
if (action.error) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActionRow, {
|
|
114895
|
-
indicatorColor:
|
|
115360
|
+
indicatorColor: colors.destructive,
|
|
114896
115361
|
label: "Completion Failed",
|
|
114897
115362
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
114898
|
-
color:
|
|
115363
|
+
color: colors.destructive,
|
|
114899
115364
|
children: action.error
|
|
114900
115365
|
})
|
|
114901
115366
|
});
|
|
114902
115367
|
const remaining = action.remainingTodos?.filter((t) => !t.completed) ?? [];
|
|
114903
115368
|
if (remaining.length > 0) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActionRow, {
|
|
114904
|
-
indicatorColor:
|
|
115369
|
+
indicatorColor: colors.warn,
|
|
114905
115370
|
label: "Completion Blocked",
|
|
114906
115371
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
|
|
114907
115372
|
dimColor: true,
|
|
@@ -114913,7 +115378,7 @@ function renderAction(action) {
|
|
|
114913
115378
|
})
|
|
114914
115379
|
});
|
|
114915
115380
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActionRowSimple, {
|
|
114916
|
-
indicatorColor:
|
|
115381
|
+
indicatorColor: colors.success,
|
|
114917
115382
|
text: "Completion Accepted"
|
|
114918
115383
|
});
|
|
114919
115384
|
}
|
|
@@ -114945,7 +115410,7 @@ function renderAction(action) {
|
|
|
114945
115410
|
});
|
|
114946
115411
|
case "exec": return renderExec(action, color);
|
|
114947
115412
|
case "delegate": return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActionRow, {
|
|
114948
|
-
indicatorColor:
|
|
115413
|
+
indicatorColor: colors.warn,
|
|
114949
115414
|
label: action.delegateExpertKey,
|
|
114950
115415
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
114951
115416
|
dimColor: true,
|
|
@@ -114953,17 +115418,49 @@ function renderAction(action) {
|
|
|
114953
115418
|
})
|
|
114954
115419
|
});
|
|
114955
115420
|
case "delegationComplete": return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActionRowSimple, {
|
|
114956
|
-
indicatorColor:
|
|
115421
|
+
indicatorColor: colors.success,
|
|
114957
115422
|
text: `Delegation Complete (${action.count} delegate${action.count > 1 ? "s" : ""} returned)`
|
|
114958
115423
|
});
|
|
114959
115424
|
case "interactiveTool": return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActionRow, {
|
|
114960
|
-
indicatorColor:
|
|
115425
|
+
indicatorColor: colors.warn,
|
|
114961
115426
|
label: `Interactive: ${action.toolName}`,
|
|
114962
115427
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
114963
115428
|
dimColor: true,
|
|
114964
115429
|
children: truncateText(JSON.stringify(action.args), UI_CONSTANTS.TRUNCATE_TEXT_MEDIUM)
|
|
114965
115430
|
})
|
|
114966
115431
|
});
|
|
115432
|
+
case "addSkill": {
|
|
115433
|
+
const skillColor = action.error ? colors.destructive : colors.accent;
|
|
115434
|
+
const toolsSummary = action.tools ? `${action.tools.length} tool${action.tools.length !== 1 ? "s" : ""}: ${action.tools.join(", ")}` : void 0;
|
|
115435
|
+
if (toolsSummary) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActionRow, {
|
|
115436
|
+
indicatorColor: skillColor,
|
|
115437
|
+
label: `Add Skill ${action.name}`,
|
|
115438
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
115439
|
+
dimColor: true,
|
|
115440
|
+
children: truncateText(toolsSummary, UI_CONSTANTS.TRUNCATE_TEXT_MEDIUM)
|
|
115441
|
+
})
|
|
115442
|
+
});
|
|
115443
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActionRowSimple, {
|
|
115444
|
+
indicatorColor: skillColor,
|
|
115445
|
+
text: `Add Skill ${action.name}`
|
|
115446
|
+
});
|
|
115447
|
+
}
|
|
115448
|
+
case "removeSkill": return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActionRowSimple, {
|
|
115449
|
+
indicatorColor: action.error ? colors.destructive : colors.accent,
|
|
115450
|
+
text: `Remove Skill ${action.skillName}`
|
|
115451
|
+
});
|
|
115452
|
+
case "addDelegate": return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActionRowSimple, {
|
|
115453
|
+
indicatorColor: action.error ? colors.destructive : colors.accent,
|
|
115454
|
+
text: `Add Delegate ${action.targetExpertKey}`
|
|
115455
|
+
});
|
|
115456
|
+
case "removeDelegate": return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActionRowSimple, {
|
|
115457
|
+
indicatorColor: action.error ? colors.destructive : colors.accent,
|
|
115458
|
+
text: `Remove Delegate ${action.expertName}`
|
|
115459
|
+
});
|
|
115460
|
+
case "createExpert": return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActionRowSimple, {
|
|
115461
|
+
indicatorColor: action.error ? colors.destructive : colors.accent,
|
|
115462
|
+
text: `Create Expert ${action.description ? `${action.targetKey} - ${truncateText(action.description, UI_CONSTANTS.TRUNCATE_TEXT_MEDIUM)}` : action.targetKey}`
|
|
115463
|
+
});
|
|
114967
115464
|
case "generalTool": return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActionRow, {
|
|
114968
115465
|
indicatorColor: color,
|
|
114969
115466
|
label: action.toolName,
|
|
@@ -114973,10 +115470,10 @@ function renderAction(action) {
|
|
|
114973
115470
|
})
|
|
114974
115471
|
});
|
|
114975
115472
|
case "error": return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActionRow, {
|
|
114976
|
-
indicatorColor:
|
|
115473
|
+
indicatorColor: colors.destructive,
|
|
114977
115474
|
label: action.errorName ?? "Error",
|
|
114978
115475
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
114979
|
-
color:
|
|
115476
|
+
color: colors.destructive,
|
|
114980
115477
|
children: action.error ?? "Unknown error"
|
|
114981
115478
|
})
|
|
114982
115479
|
});
|
|
@@ -115048,7 +115545,7 @@ function renderReadTextFile(action, color) {
|
|
|
115048
115545
|
flexDirection: "row",
|
|
115049
115546
|
gap: 1,
|
|
115050
115547
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
115051
|
-
color:
|
|
115548
|
+
color: colors.primary,
|
|
115052
115549
|
dimColor: true,
|
|
115053
115550
|
children: line
|
|
115054
115551
|
})
|
|
@@ -115069,11 +115566,11 @@ function renderWriteTextFile(action, color) {
|
|
|
115069
115566
|
flexDirection: "row",
|
|
115070
115567
|
gap: 1,
|
|
115071
115568
|
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
115072
|
-
color:
|
|
115569
|
+
color: colors.success,
|
|
115073
115570
|
dimColor: true,
|
|
115074
115571
|
children: "+"
|
|
115075
115572
|
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
115076
|
-
color:
|
|
115573
|
+
color: colors.primary,
|
|
115077
115574
|
dimColor: true,
|
|
115078
115575
|
children: line
|
|
115079
115576
|
})]
|
|
@@ -115095,11 +115592,11 @@ function renderEditTextFile(action, color) {
|
|
|
115095
115592
|
flexDirection: "row",
|
|
115096
115593
|
gap: 1,
|
|
115097
115594
|
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
115098
|
-
color:
|
|
115595
|
+
color: colors.destructive,
|
|
115099
115596
|
dimColor: true,
|
|
115100
115597
|
children: "-"
|
|
115101
115598
|
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
115102
|
-
color:
|
|
115599
|
+
color: colors.primary,
|
|
115103
115600
|
dimColor: true,
|
|
115104
115601
|
children: line
|
|
115105
115602
|
})]
|
|
@@ -115107,7 +115604,7 @@ function renderEditTextFile(action, color) {
|
|
|
115107
115604
|
flexDirection: "row",
|
|
115108
115605
|
gap: 1,
|
|
115109
115606
|
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
115110
|
-
color:
|
|
115607
|
+
color: colors.success,
|
|
115111
115608
|
dimColor: true,
|
|
115112
115609
|
children: "+"
|
|
115113
115610
|
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
@@ -115144,10 +115641,11 @@ function renderExec(action, color) {
|
|
|
115144
115641
|
}
|
|
115145
115642
|
function renderQuery(text, runId) {
|
|
115146
115643
|
const lines = text.split("\n");
|
|
115644
|
+
const shortRunId = runId.slice(0, 8);
|
|
115147
115645
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActionRow, {
|
|
115148
|
-
indicatorColor:
|
|
115646
|
+
indicatorColor: colors.accent,
|
|
115149
115647
|
label: "Query",
|
|
115150
|
-
summary: `(${
|
|
115648
|
+
summary: `(${shortRunId})`,
|
|
115151
115649
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
|
|
115152
115650
|
flexDirection: "column",
|
|
115153
115651
|
children: lines.map((line, idx) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
@@ -115254,15 +115752,15 @@ const InterfacePanel = ({ runtimeInfo, runStatus, streaming, onSubmit }) => {
|
|
|
115254
115752
|
useInput(handleInput);
|
|
115255
115753
|
let statusLabel;
|
|
115256
115754
|
if (runStatus === "waiting") statusLabel = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
115257
|
-
color:
|
|
115755
|
+
color: colors.accent,
|
|
115258
115756
|
children: "Waiting for query..."
|
|
115259
115757
|
});
|
|
115260
115758
|
else if (runStatus === "completed") statusLabel = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
115261
|
-
color:
|
|
115759
|
+
color: colors.success,
|
|
115262
115760
|
children: "Completed"
|
|
115263
115761
|
});
|
|
115264
115762
|
else if (runStatus === "stopped") statusLabel = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
115265
|
-
color:
|
|
115763
|
+
color: colors.warn,
|
|
115266
115764
|
children: "Stopped"
|
|
115267
115765
|
});
|
|
115268
115766
|
else if (streamingPhase === "reasoning") statusLabel = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: "Streaming Reasoning..." });
|
|
@@ -115274,14 +115772,14 @@ const InterfacePanel = ({ runtimeInfo, runStatus, streaming, onSubmit }) => {
|
|
|
115274
115772
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
|
|
115275
115773
|
flexDirection: "column",
|
|
115276
115774
|
borderStyle: "single",
|
|
115277
|
-
borderColor:
|
|
115775
|
+
borderColor: colors.muted,
|
|
115278
115776
|
borderTop: true,
|
|
115279
115777
|
borderBottom: false,
|
|
115280
115778
|
borderLeft: false,
|
|
115281
115779
|
borderRight: false,
|
|
115282
115780
|
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: [
|
|
115283
115781
|
spinner ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
|
|
115284
|
-
color:
|
|
115782
|
+
color: colors.accent,
|
|
115285
115783
|
children: [spinner, " "]
|
|
115286
115784
|
}) : null,
|
|
115287
115785
|
statusLabel,
|
|
@@ -115302,12 +115800,12 @@ const InterfacePanel = ({ runtimeInfo, runStatus, streaming, onSubmit }) => {
|
|
|
115302
115800
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: [usagePercent, "%"] })
|
|
115303
115801
|
] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: [
|
|
115304
115802
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
115305
|
-
color:
|
|
115803
|
+
color: colors.muted,
|
|
115306
115804
|
children: "> "
|
|
115307
115805
|
}),
|
|
115308
115806
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: input }),
|
|
115309
115807
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
115310
|
-
color:
|
|
115808
|
+
color: colors.accent,
|
|
115311
115809
|
children: "_"
|
|
115312
115810
|
})
|
|
115313
115811
|
] })]
|
|
@@ -115335,7 +115833,7 @@ function extractLogEntriesFromEvent(event) {
|
|
|
115335
115833
|
return entries;
|
|
115336
115834
|
}
|
|
115337
115835
|
const useExecutionState = (options) => {
|
|
115338
|
-
const { expertKey, query, config,
|
|
115836
|
+
const { expertKey, query, config, historicalEvents, onReady, onComplete, onQueryReady } = options;
|
|
115339
115837
|
const runState = useRun();
|
|
115340
115838
|
const { runtimeInfo, handleEvent, setQuery } = useRuntimeInfo({
|
|
115341
115839
|
initialExpertName: expertKey,
|
|
@@ -115343,24 +115841,7 @@ const useExecutionState = (options) => {
|
|
|
115343
115841
|
});
|
|
115344
115842
|
const [runStatus, setRunStatus] = (0, import_react.useState)(query ? "running" : "waiting");
|
|
115345
115843
|
const [staticItems, setStaticItems] = (0, import_react.useState)([]);
|
|
115346
|
-
const timeoutRef = (0, import_react.useRef)(null);
|
|
115347
115844
|
const lastSyncedCountRef = (0, import_react.useRef)(0);
|
|
115348
|
-
const clearTimeoutIfExists = (0, import_react.useCallback)(() => {
|
|
115349
|
-
if (timeoutRef.current) {
|
|
115350
|
-
clearTimeout(timeoutRef.current);
|
|
115351
|
-
timeoutRef.current = null;
|
|
115352
|
-
}
|
|
115353
|
-
}, []);
|
|
115354
|
-
const startExitTimeout = (0, import_react.useCallback)(() => {
|
|
115355
|
-
clearTimeoutIfExists();
|
|
115356
|
-
timeoutRef.current = setTimeout(() => {
|
|
115357
|
-
onComplete({ nextQuery: null });
|
|
115358
|
-
}, continueTimeoutMs);
|
|
115359
|
-
}, [
|
|
115360
|
-
clearTimeoutIfExists,
|
|
115361
|
-
continueTimeoutMs,
|
|
115362
|
-
onComplete
|
|
115363
|
-
]);
|
|
115364
115845
|
(0, import_react.useEffect)(() => {
|
|
115365
115846
|
if (query) setQuery(query);
|
|
115366
115847
|
}, [query, setQuery]);
|
|
@@ -115386,25 +115867,16 @@ const useExecutionState = (options) => {
|
|
|
115386
115867
|
const result = handleEvent(event);
|
|
115387
115868
|
const logEntries = extractLogEntriesFromEvent(event);
|
|
115388
115869
|
if (logEntries.length > 0) setStaticItems((prev) => [...prev, ...logEntries]);
|
|
115389
|
-
if (result?.
|
|
115390
|
-
setRunStatus("completed");
|
|
115391
|
-
startExitTimeout();
|
|
115392
|
-
} else if (result?.stopped) {
|
|
115393
|
-
setRunStatus("stopped");
|
|
115394
|
-
startExitTimeout();
|
|
115395
|
-
}
|
|
115870
|
+
if (result?.stopped) setRunStatus("stopped");
|
|
115396
115871
|
});
|
|
115397
115872
|
}, [
|
|
115398
115873
|
onReady,
|
|
115399
115874
|
runState.addEvent,
|
|
115400
|
-
handleEvent
|
|
115401
|
-
startExitTimeout
|
|
115875
|
+
handleEvent
|
|
115402
115876
|
]);
|
|
115403
115877
|
(0, import_react.useEffect)(() => {
|
|
115404
|
-
|
|
115405
|
-
|
|
115406
|
-
};
|
|
115407
|
-
}, [clearTimeoutIfExists]);
|
|
115878
|
+
if (runState.isComplete) setRunStatus("completed");
|
|
115879
|
+
}, [runState.isComplete]);
|
|
115408
115880
|
const handleSubmit = (0, import_react.useCallback)((newQuery) => {
|
|
115409
115881
|
if (!newQuery.trim()) return;
|
|
115410
115882
|
if (runStatus === "waiting") {
|
|
@@ -115414,13 +115886,9 @@ const useExecutionState = (options) => {
|
|
|
115414
115886
|
onQueryReady?.(trimmed);
|
|
115415
115887
|
return;
|
|
115416
115888
|
}
|
|
115417
|
-
if (runStatus !== "running") {
|
|
115418
|
-
clearTimeoutIfExists();
|
|
115419
|
-
onComplete({ nextQuery: newQuery.trim() });
|
|
115420
|
-
}
|
|
115889
|
+
if (runStatus !== "running") onComplete({ nextQuery: newQuery.trim() });
|
|
115421
115890
|
}, [
|
|
115422
115891
|
runStatus,
|
|
115423
|
-
clearTimeoutIfExists,
|
|
115424
115892
|
onComplete,
|
|
115425
115893
|
setQuery,
|
|
115426
115894
|
onQueryReady
|
|
@@ -115430,15 +115898,14 @@ const useExecutionState = (options) => {
|
|
|
115430
115898
|
streaming: runState.streaming,
|
|
115431
115899
|
runtimeInfo,
|
|
115432
115900
|
runStatus,
|
|
115433
|
-
handleSubmit
|
|
115434
|
-
clearTimeout: clearTimeoutIfExists
|
|
115901
|
+
handleSubmit
|
|
115435
115902
|
};
|
|
115436
115903
|
};
|
|
115437
115904
|
|
|
115438
115905
|
//#endregion
|
|
115439
115906
|
//#region ../../packages/tui-components/src/execution/app.tsx
|
|
115440
115907
|
const ExecutionApp = (props) => {
|
|
115441
|
-
const { expertKey, query, config,
|
|
115908
|
+
const { expertKey, query, config, historicalEvents, onReady, onComplete, onQueryReady } = props;
|
|
115442
115909
|
const { exit } = useApp();
|
|
115443
115910
|
const [exitResult, setExitResult] = (0, import_react.useState)(null);
|
|
115444
115911
|
const handleComplete = (0, import_react.useCallback)((result) => {
|
|
@@ -115458,17 +115925,13 @@ const ExecutionApp = (props) => {
|
|
|
115458
115925
|
expertKey,
|
|
115459
115926
|
query,
|
|
115460
115927
|
config,
|
|
115461
|
-
continueTimeoutMs,
|
|
115462
115928
|
historicalEvents,
|
|
115463
115929
|
onReady,
|
|
115464
115930
|
onComplete: handleComplete,
|
|
115465
115931
|
onQueryReady
|
|
115466
115932
|
});
|
|
115467
115933
|
useInput((input, key) => {
|
|
115468
|
-
if (key.ctrl && input === "c")
|
|
115469
|
-
state.clearTimeout();
|
|
115470
|
-
exit();
|
|
115471
|
-
}
|
|
115934
|
+
if (key.ctrl && input === "c") exit();
|
|
115472
115935
|
});
|
|
115473
115936
|
if (exitResult) return null;
|
|
115474
115937
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
|
|
@@ -115731,7 +116194,6 @@ async function renderSelection(params) {
|
|
|
115731
116194
|
|
|
115732
116195
|
//#endregion
|
|
115733
116196
|
//#region ../../packages/tui/src/start-handler.ts
|
|
115734
|
-
const CONTINUE_TIMEOUT_MS = 6e4;
|
|
115735
116197
|
async function startHandler(expertKey, query, options, handlerOptions) {
|
|
115736
116198
|
const input = parseWithFriendlyError(startCommandInputSchema, {
|
|
115737
116199
|
expertKey,
|
|
@@ -115815,7 +116277,6 @@ async function startHandler(expertKey, query, options, handlerOptions) {
|
|
|
115815
116277
|
timeout,
|
|
115816
116278
|
contextWindowUsage: currentCheckpoint?.contextWindowUsage ?? 0
|
|
115817
116279
|
},
|
|
115818
|
-
continueTimeoutMs: CONTINUE_TIMEOUT_MS,
|
|
115819
116280
|
historicalEvents
|
|
115820
116281
|
});
|
|
115821
116282
|
const resolvedQuery = await queryReady;
|
|
@@ -115864,7 +116325,7 @@ async function startHandler(expertKey, query, options, handlerOptions) {
|
|
|
115864
116325
|
//#endregion
|
|
115865
116326
|
//#region package.json
|
|
115866
116327
|
var name = "create-expert";
|
|
115867
|
-
var version = "0.0.
|
|
116328
|
+
var version = "0.0.39";
|
|
115868
116329
|
var description = "Create and modify Perstack expert definitions";
|
|
115869
116330
|
|
|
115870
116331
|
//#endregion
|