create-expert 0.0.38 → 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 CHANGED
@@ -3,7 +3,7 @@ import { a as __toCommonJS, i as __require, n as __esmMin, o as __toESM, r as __
3
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, mkdirSync, readFileSync, readdirSync, realpathSync, writeFileSync } from "node:fs";
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
- if (!existsSync(jobDir)) mkdirSync(jobDir, { recursive: true });
1026
- writeFileSync(path.resolve(jobDir, "job.json"), JSON.stringify(job, null, 2));
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
- if (!existsSync(jobPath)) return;
1032
- const content = readFileSync(jobPath, "utf-8");
1033
- return jobSchema.parse(JSON.parse(content));
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();
@@ -19746,10 +19750,19 @@ 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) => sm.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) => {
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
+ }
19753
19766
  const skills = input.skills ? {
19754
19767
  "@perstack/base": input.skills["@perstack/base"] ?? {
19755
19768
  type: "mcpStdioSkill",
@@ -19759,7 +19772,7 @@ var SkillManager = class SkillManager {
19759
19772
  },
19760
19773
  ...input.skills
19761
19774
  } : void 0;
19762
- const expert = expertSchema.parse({
19775
+ const newExpert = expertSchema.parse({
19763
19776
  key: input.key,
19764
19777
  name: input.key,
19765
19778
  version: input.version ?? "1.0.0",
@@ -19770,8 +19783,8 @@ var SkillManager = class SkillManager {
19770
19783
  tags: input.tags,
19771
19784
  providerTools: input.providerTools
19772
19785
  });
19773
- experts[expert.key] = expert;
19774
- return { expertKey: expert.key };
19786
+ experts[newExpert.key] = newExpert;
19787
+ return { expertKey: newExpert.key };
19775
19788
  }
19776
19789
  });
19777
19790
  break;
@@ -19926,7 +19939,7 @@ var SkillManager = class SkillManager {
19926
19939
 
19927
19940
  //#endregion
19928
19941
  //#region ../../packages/runtime/package.json
19929
- var version$1 = "0.0.108";
19942
+ var version$1 = "0.0.110";
19930
19943
 
19931
19944
  //#endregion
19932
19945
  //#region ../../packages/runtime/src/helpers/usage.ts
@@ -22136,7 +22149,7 @@ async function* executeTool({ execute, input, options }) {
22136
22149
  }
22137
22150
 
22138
22151
  //#endregion
22139
- //#region ../../node_modules/.pnpm/@ai-sdk+anthropic@3.0.44_zod@4.3.6/node_modules/@ai-sdk/anthropic/dist/internal/index.mjs
22152
+ //#region ../../node_modules/.pnpm/@ai-sdk+anthropic@3.0.45_zod@4.3.6/node_modules/@ai-sdk/anthropic/dist/internal/index.mjs
22140
22153
  var anthropicFailedResponseHandler$1 = createJsonErrorResponseHandler({
22141
22154
  errorSchema: lazySchema(() => zodSchema(object$2({
22142
22155
  type: literal("error"),
@@ -25268,7 +25281,7 @@ function guessServiceRegion(url, headers) {
25268
25281
  }
25269
25282
 
25270
25283
  //#endregion
25271
- //#region ../../node_modules/.pnpm/@ai-sdk+amazon-bedrock@4.0.60_zod@4.3.6/node_modules/@ai-sdk/amazon-bedrock/dist/index.mjs
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
25272
25285
  var BEDROCK_STOP_REASONS = [
25273
25286
  "stop",
25274
25287
  "stop_sequence",
@@ -26668,7 +26681,7 @@ var bedrockImageResponseSchema = object$2({
26668
26681
  details: record(string(), unknown()).optional(),
26669
26682
  preview: unknown().optional()
26670
26683
  });
26671
- var VERSION$9 = "4.0.60";
26684
+ var VERSION$9 = "4.0.61";
26672
26685
  function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
26673
26686
  return async (input, init) => {
26674
26687
  var _a, _b;
@@ -26914,8 +26927,8 @@ Original error: ${errorMessage}`);
26914
26927
  var bedrock = createAmazonBedrock();
26915
26928
 
26916
26929
  //#endregion
26917
- //#region ../../node_modules/.pnpm/@ai-sdk+anthropic@3.0.44_zod@4.3.6/node_modules/@ai-sdk/anthropic/dist/index.mjs
26918
- var VERSION$8 = "3.0.44";
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";
26919
26932
  var anthropicFailedResponseHandler = createJsonErrorResponseHandler({
26920
26933
  errorSchema: lazySchema(() => zodSchema(object$2({
26921
26934
  type: literal("error"),
@@ -30113,7 +30126,7 @@ var AnthropicMessagesLanguageModel = class {
30113
30126
  }
30114
30127
  };
30115
30128
  function getModelCapabilities(modelId) {
30116
- if (modelId.includes("claude-opus-4-6")) return {
30129
+ if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) return {
30117
30130
  maxOutputTokens: 128e3,
30118
30131
  supportsStructuredOutput: true,
30119
30132
  isKnownModel: true
@@ -30469,7 +30482,7 @@ function createAnthropic(options = {}) {
30469
30482
  var anthropic = createAnthropic();
30470
30483
 
30471
30484
  //#endregion
30472
- //#region ../../node_modules/.pnpm/@ai-sdk+openai@3.0.29_zod@4.3.6/node_modules/@ai-sdk/openai/dist/internal/index.mjs
30485
+ //#region ../../node_modules/.pnpm/@ai-sdk+openai@3.0.30_zod@4.3.6/node_modules/@ai-sdk/openai/dist/internal/index.mjs
30473
30486
  var openaiErrorDataSchema$1 = object$2({ error: object$2({
30474
30487
  message: string(),
30475
30488
  type: string().nullish(),
@@ -32250,6 +32263,54 @@ var shellOutputSchema$1 = lazySchema(() => zodSchema(object$2({ output: array$1(
32250
32263
  exitCode: number()
32251
32264
  })])
32252
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() })));
32253
32314
  createProviderToolFactoryWithOutputSchema({
32254
32315
  id: "openai.shell",
32255
32316
  inputSchema: shellInputSchema$1,
@@ -32427,11 +32488,33 @@ async function convertToOpenAIResponsesInput$1({ prompt, toolNameMapping, system
32427
32488
  });
32428
32489
  break;
32429
32490
  }
32430
- case "tool-result":
32491
+ case "tool-result": {
32431
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;
32432
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
+ }
32433
32516
  if (store) {
32434
- const itemId = (_j = (_i = (_h = part.providerMetadata) == null ? void 0 : _h[providerOptionsName]) == null ? void 0 : _i.itemId) != null ? _j : part.toolCallId;
32517
+ const itemId = (_j = (_i = (_h = part.providerOptions) == null ? void 0 : _h[providerOptionsName]) == null ? void 0 : _i.itemId) != null ? _j : part.toolCallId;
32435
32518
  input.push({
32436
32519
  type: "item_reference",
32437
32520
  id: itemId
@@ -32441,6 +32524,7 @@ async function convertToOpenAIResponsesInput$1({ prompt, toolNameMapping, system
32441
32524
  message: `Results for OpenAI tool ${part.toolName} are not sent to the API when store is false`
32442
32525
  });
32443
32526
  break;
32527
+ }
32444
32528
  case "reasoning": {
32445
32529
  const providerOptions = await parseProviderOptions({
32446
32530
  provider: providerOptionsName,
@@ -32769,6 +32853,24 @@ var openaiResponsesChunkSchema$1 = lazySchema(() => zodSchema(union([
32769
32853
  "incomplete"
32770
32854
  ]),
32771
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
+ }))
32772
32874
  })
32773
32875
  ])
32774
32876
  }),
@@ -32943,6 +33045,24 @@ var openaiResponsesChunkSchema$1 = lazySchema(() => zodSchema(union([
32943
33045
  "incomplete"
32944
33046
  ]),
32945
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
+ }))
32946
33066
  })
32947
33067
  ])
32948
33068
  }),
@@ -33267,6 +33387,24 @@ var openaiResponsesResponseSchema$1 = lazySchema(() => zodSchema(object$2({
33267
33387
  "incomplete"
33268
33388
  ]),
33269
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
+ }))
33270
33408
  })
33271
33409
  ])).optional(),
33272
33410
  service_tier: string().nullish(),
@@ -33581,9 +33719,17 @@ async function prepareResponsesTools$2({ tools, toolChoice }) {
33581
33719
  case "openai.local_shell":
33582
33720
  openaiTools.push({ type: "local_shell" });
33583
33721
  break;
33584
- case "openai.shell":
33585
- openaiTools.push({ type: "shell" });
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
+ });
33586
33731
  break;
33732
+ }
33587
33733
  case "openai.apply_patch":
33588
33734
  openaiTools.push({ type: "apply_patch" });
33589
33735
  break;
@@ -33711,6 +33857,46 @@ async function prepareResponsesTools$2({ tools, toolChoice }) {
33711
33857
  default: throw new UnsupportedFunctionalityError({ functionality: `tool choice type: ${type}` });
33712
33858
  }
33713
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
+ }
33714
33900
  function extractApprovalRequestIdToToolCallIdMapping$1(prompt) {
33715
33901
  var _a, _b;
33716
33902
  const mapping = {};
@@ -33738,7 +33924,7 @@ var OpenAIResponsesLanguageModel$1 = class {
33738
33924
  return this.config.provider;
33739
33925
  }
33740
33926
  async getArgs({ maxOutputTokens, temperature, stopSequences, topP, topK, presencePenalty, frequencyPenalty, seed, prompt, providerOptions, tools, toolChoice, responseFormat }) {
33741
- var _a, _b, _c, _d, _e, _f;
33927
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
33742
33928
  const warnings = [];
33743
33929
  const modelCapabilities = getOpenAILanguageModelCapabilities$1(this.modelId);
33744
33930
  if (topK != null) warnings.push({
@@ -33908,6 +34094,8 @@ var OpenAIResponsesLanguageModel$1 = class {
33908
34094
  tools,
33909
34095
  toolChoice
33910
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";
33911
34099
  return {
33912
34100
  webSearchToolName,
33913
34101
  args: {
@@ -33918,12 +34106,13 @@ var OpenAIResponsesLanguageModel$1 = class {
33918
34106
  warnings: [...warnings, ...toolWarnings],
33919
34107
  store,
33920
34108
  toolNameMapping,
33921
- providerOptionsName
34109
+ providerOptionsName,
34110
+ isShellProviderExecuted
33922
34111
  };
33923
34112
  }
33924
34113
  async doGenerate(options) {
33925
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;
33926
- const { args: body, warnings, webSearchToolName, toolNameMapping, providerOptionsName } = await this.getArgs(options);
34115
+ const { args: body, warnings, webSearchToolName, toolNameMapping, providerOptionsName, isShellProviderExecuted } = await this.getArgs(options);
33927
34116
  const url = this.config.url({
33928
34117
  path: "/responses",
33929
34118
  modelId: this.modelId
@@ -33995,9 +34184,25 @@ var OpenAIResponsesLanguageModel$1 = class {
33995
34184
  toolCallId: part.call_id,
33996
34185
  toolName: toolNameMapping.toCustomToolName("shell"),
33997
34186
  input: JSON.stringify({ action: { commands: part.action.commands } }),
34187
+ ...isShellProviderExecuted && { providerExecuted: true },
33998
34188
  providerMetadata: { [providerOptionsName]: { itemId: part.id } }
33999
34189
  });
34000
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;
34001
34206
  case "message":
34002
34207
  for (const contentPart of part.content) {
34003
34208
  if (((_c = (_b = options.providerOptions) == null ? void 0 : _b[providerOptionsName]) == null ? void 0 : _c.logprobs) && contentPart.logprobs) logprobs.push(contentPart.logprobs);
@@ -34232,7 +34437,7 @@ var OpenAIResponsesLanguageModel$1 = class {
34232
34437
  };
34233
34438
  }
34234
34439
  async doStream(options) {
34235
- 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);
34236
34441
  const { responseHeaders, value: response } = await postJsonToApi({
34237
34442
  url: this.config.url({
34238
34443
  path: "/responses",
@@ -34402,7 +34607,7 @@ var OpenAIResponsesLanguageModel$1 = class {
34402
34607
  toolName: toolNameMapping.toCustomToolName("shell"),
34403
34608
  toolCallId: value.item.call_id
34404
34609
  };
34405
- else if (value.item.type === "message") {
34610
+ else if (value.item.type === "shell_call_output") {} else if (value.item.type === "message") {
34406
34611
  ongoingAnnotations.splice(0, ongoingAnnotations.length);
34407
34612
  controller.enqueue({
34408
34613
  type: "text-start",
@@ -34607,9 +34812,23 @@ var OpenAIResponsesLanguageModel$1 = class {
34607
34812
  toolCallId: value.item.call_id,
34608
34813
  toolName: toolNameMapping.toCustomToolName("shell"),
34609
34814
  input: JSON.stringify({ action: { commands: value.item.action.commands } }),
34815
+ ...isShellProviderExecuted && { providerExecuted: true },
34610
34816
  providerMetadata: { [providerOptionsName]: { itemId: value.item.id } }
34611
34817
  });
34612
- } else if (value.item.type === "reasoning") {
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") {
34613
34832
  const activeReasoningPart = activeReasoning[value.item.id];
34614
34833
  const summaryPartIndices = Object.entries(activeReasoningPart.summaryParts).filter(([_, status]) => status === "active" || status === "can-conclude").map(([summaryIndex]) => summaryIndex);
34615
34834
  for (const summaryIndex of summaryPartIndices) controller.enqueue({
@@ -34895,14 +35114,14 @@ function escapeJSONDelta$1(delta) {
34895
35114
  }
34896
35115
 
34897
35116
  //#endregion
34898
- //#region ../../node_modules/.pnpm/@ai-sdk+azure@3.0.30_zod@4.3.6/node_modules/@ai-sdk/azure/dist/index.mjs
35117
+ //#region ../../node_modules/.pnpm/@ai-sdk+azure@3.0.31_zod@4.3.6/node_modules/@ai-sdk/azure/dist/index.mjs
34899
35118
  var azureOpenaiTools = {
34900
35119
  codeInterpreter: codeInterpreter$1,
34901
35120
  fileSearch: fileSearch$3,
34902
35121
  imageGeneration: imageGeneration$1,
34903
35122
  webSearchPreview: webSearchPreview$1
34904
35123
  };
34905
- var VERSION$7 = "3.0.30";
35124
+ var VERSION$7 = "3.0.31";
34906
35125
  function createAzure(options = {}) {
34907
35126
  var _a;
34908
35127
  const getHeaders = () => {
@@ -48353,7 +48572,7 @@ var googleTools = {
48353
48572
  };
48354
48573
 
48355
48574
  //#endregion
48356
- //#region ../../node_modules/.pnpm/@ai-sdk+google-vertex@4.0.58_zod@4.3.6/node_modules/@ai-sdk/google-vertex/dist/index.mjs
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
48357
48576
  var authInstance = null;
48358
48577
  var authOptions = null;
48359
48578
  function getAuth(options) {
@@ -48370,7 +48589,7 @@ async function generateAuthToken(options) {
48370
48589
  const token = await (await getAuth(options || {}).getClient()).getAccessToken();
48371
48590
  return (token == null ? void 0 : token.token) || null;
48372
48591
  }
48373
- var VERSION$4 = "4.0.58";
48592
+ var VERSION$4 = "4.0.59";
48374
48593
  var googleVertexFailedResponseHandler = createJsonErrorResponseHandler({
48375
48594
  errorSchema: object$2({ error: object$2({
48376
48595
  code: number().nullable(),
@@ -48968,7 +49187,7 @@ function createVertex2(options = {}) {
48968
49187
  var vertex = createVertex2();
48969
49188
 
48970
49189
  //#endregion
48971
- //#region ../../node_modules/.pnpm/@ai-sdk+openai@3.0.29_zod@4.3.6/node_modules/@ai-sdk/openai/dist/index.mjs
49190
+ //#region ../../node_modules/.pnpm/@ai-sdk+openai@3.0.30_zod@4.3.6/node_modules/@ai-sdk/openai/dist/index.mjs
48972
49191
  var openaiErrorDataSchema = object$2({ error: object$2({
48973
49192
  message: string(),
48974
49193
  type: string().nullish(),
@@ -50569,6 +50788,54 @@ var shellOutputSchema = lazySchema(() => zodSchema(object$2({ output: array$1(ob
50569
50788
  exitCode: number()
50570
50789
  })])
50571
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() })));
50572
50839
  var shell = createProviderToolFactoryWithOutputSchema({
50573
50840
  id: "openai.shell",
50574
50841
  inputSchema: shellInputSchema,
@@ -50904,11 +51171,33 @@ async function convertToOpenAIResponsesInput({ prompt, toolNameMapping, systemMe
50904
51171
  });
50905
51172
  break;
50906
51173
  }
50907
- case "tool-result":
51174
+ case "tool-result": {
50908
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;
50909
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
+ }
50910
51199
  if (store) {
50911
- const itemId = (_j = (_i = (_h = part.providerMetadata) == null ? void 0 : _h[providerOptionsName]) == null ? void 0 : _i.itemId) != null ? _j : part.toolCallId;
51200
+ const itemId = (_j = (_i = (_h = part.providerOptions) == null ? void 0 : _h[providerOptionsName]) == null ? void 0 : _i.itemId) != null ? _j : part.toolCallId;
50912
51201
  input.push({
50913
51202
  type: "item_reference",
50914
51203
  id: itemId
@@ -50918,6 +51207,7 @@ async function convertToOpenAIResponsesInput({ prompt, toolNameMapping, systemMe
50918
51207
  message: `Results for OpenAI tool ${part.toolName} are not sent to the API when store is false`
50919
51208
  });
50920
51209
  break;
51210
+ }
50921
51211
  case "reasoning": {
50922
51212
  const providerOptions = await parseProviderOptions({
50923
51213
  provider: providerOptionsName,
@@ -51246,6 +51536,24 @@ var openaiResponsesChunkSchema = lazySchema(() => zodSchema(union([
51246
51536
  "incomplete"
51247
51537
  ]),
51248
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
+ }))
51249
51557
  })
51250
51558
  ])
51251
51559
  }),
@@ -51420,6 +51728,24 @@ var openaiResponsesChunkSchema = lazySchema(() => zodSchema(union([
51420
51728
  "incomplete"
51421
51729
  ]),
51422
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
+ }))
51423
51749
  })
51424
51750
  ])
51425
51751
  }),
@@ -51744,6 +52070,24 @@ var openaiResponsesResponseSchema = lazySchema(() => zodSchema(object$2({
51744
52070
  "incomplete"
51745
52071
  ]),
51746
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
+ }))
51747
52091
  })
51748
52092
  ])).optional(),
51749
52093
  service_tier: string().nullish(),
@@ -51837,9 +52181,17 @@ async function prepareResponsesTools$1({ tools, toolChoice }) {
51837
52181
  case "openai.local_shell":
51838
52182
  openaiTools2.push({ type: "local_shell" });
51839
52183
  break;
51840
- case "openai.shell":
51841
- openaiTools2.push({ type: "shell" });
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
+ });
51842
52193
  break;
52194
+ }
51843
52195
  case "openai.apply_patch":
51844
52196
  openaiTools2.push({ type: "apply_patch" });
51845
52197
  break;
@@ -51967,6 +52319,46 @@ async function prepareResponsesTools$1({ tools, toolChoice }) {
51967
52319
  default: throw new UnsupportedFunctionalityError({ functionality: `tool choice type: ${type}` });
51968
52320
  }
51969
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
+ }
51970
52362
  function extractApprovalRequestIdToToolCallIdMapping(prompt) {
51971
52363
  var _a, _b;
51972
52364
  const mapping = {};
@@ -51994,7 +52386,7 @@ var OpenAIResponsesLanguageModel = class {
51994
52386
  return this.config.provider;
51995
52387
  }
51996
52388
  async getArgs({ maxOutputTokens, temperature, stopSequences, topP, topK, presencePenalty, frequencyPenalty, seed, prompt, providerOptions, tools, toolChoice, responseFormat }) {
51997
- var _a, _b, _c, _d, _e, _f;
52389
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
51998
52390
  const warnings = [];
51999
52391
  const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
52000
52392
  if (topK != null) warnings.push({
@@ -52164,6 +52556,8 @@ var OpenAIResponsesLanguageModel = class {
52164
52556
  tools,
52165
52557
  toolChoice
52166
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";
52167
52561
  return {
52168
52562
  webSearchToolName,
52169
52563
  args: {
@@ -52174,12 +52568,13 @@ var OpenAIResponsesLanguageModel = class {
52174
52568
  warnings: [...warnings, ...toolWarnings],
52175
52569
  store,
52176
52570
  toolNameMapping,
52177
- providerOptionsName
52571
+ providerOptionsName,
52572
+ isShellProviderExecuted
52178
52573
  };
52179
52574
  }
52180
52575
  async doGenerate(options) {
52181
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;
52182
- const { args: body, warnings, webSearchToolName, toolNameMapping, providerOptionsName } = await this.getArgs(options);
52577
+ const { args: body, warnings, webSearchToolName, toolNameMapping, providerOptionsName, isShellProviderExecuted } = await this.getArgs(options);
52183
52578
  const url = this.config.url({
52184
52579
  path: "/responses",
52185
52580
  modelId: this.modelId
@@ -52251,9 +52646,25 @@ var OpenAIResponsesLanguageModel = class {
52251
52646
  toolCallId: part.call_id,
52252
52647
  toolName: toolNameMapping.toCustomToolName("shell"),
52253
52648
  input: JSON.stringify({ action: { commands: part.action.commands } }),
52649
+ ...isShellProviderExecuted && { providerExecuted: true },
52254
52650
  providerMetadata: { [providerOptionsName]: { itemId: part.id } }
52255
52651
  });
52256
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;
52257
52668
  case "message":
52258
52669
  for (const contentPart of part.content) {
52259
52670
  if (((_c = (_b = options.providerOptions) == null ? void 0 : _b[providerOptionsName]) == null ? void 0 : _c.logprobs) && contentPart.logprobs) logprobs.push(contentPart.logprobs);
@@ -52488,7 +52899,7 @@ var OpenAIResponsesLanguageModel = class {
52488
52899
  };
52489
52900
  }
52490
52901
  async doStream(options) {
52491
- 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);
52492
52903
  const { responseHeaders, value: response } = await postJsonToApi({
52493
52904
  url: this.config.url({
52494
52905
  path: "/responses",
@@ -52658,7 +53069,7 @@ var OpenAIResponsesLanguageModel = class {
52658
53069
  toolName: toolNameMapping.toCustomToolName("shell"),
52659
53070
  toolCallId: value.item.call_id
52660
53071
  };
52661
- else if (value.item.type === "message") {
53072
+ else if (value.item.type === "shell_call_output") {} else if (value.item.type === "message") {
52662
53073
  ongoingAnnotations.splice(0, ongoingAnnotations.length);
52663
53074
  controller.enqueue({
52664
53075
  type: "text-start",
@@ -52863,9 +53274,23 @@ var OpenAIResponsesLanguageModel = class {
52863
53274
  toolCallId: value.item.call_id,
52864
53275
  toolName: toolNameMapping.toCustomToolName("shell"),
52865
53276
  input: JSON.stringify({ action: { commands: value.item.action.commands } }),
53277
+ ...isShellProviderExecuted && { providerExecuted: true },
52866
53278
  providerMetadata: { [providerOptionsName]: { itemId: value.item.id } }
52867
53279
  });
52868
- } else if (value.item.type === "reasoning") {
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") {
52869
53294
  const activeReasoningPart = activeReasoning[value.item.id];
52870
53295
  const summaryPartIndices = Object.entries(activeReasoningPart.summaryParts).filter(([_, status]) => status === "active" || status === "can-conclude").map(([summaryIndex]) => summaryIndex);
52871
53296
  for (const summaryIndex of summaryPartIndices) controller.enqueue({
@@ -53402,7 +53827,7 @@ var OpenAITranscriptionModel = class {
53402
53827
  };
53403
53828
  }
53404
53829
  };
53405
- var VERSION$3 = "3.0.29";
53830
+ var VERSION$3 = "3.0.30";
53406
53831
  function createOpenAI(options = {}) {
53407
53832
  var _a, _b;
53408
53833
  const baseURL = (_a = withoutTrailingSlash(loadOptionalSetting({
@@ -53493,7 +53918,7 @@ function createOpenAI(options = {}) {
53493
53918
  var openai = createOpenAI();
53494
53919
 
53495
53920
  //#endregion
53496
- //#region ../../node_modules/.pnpm/ollama-ai-provider-v2@3.3.1_ai@6.0.87_zod@4.3.6__zod@4.3.6/node_modules/ollama-ai-provider-v2/dist/index.mjs
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
53497
53922
  function convertToOllamaCompletionPrompt({ prompt, user = "user", assistant = "assistant" }) {
53498
53923
  let text = "";
53499
53924
  if (prompt[0].role === "system") {
@@ -75777,7 +76202,7 @@ var require_dist$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
75777
76202
  }));
75778
76203
 
75779
76204
  //#endregion
75780
- //#region ../../node_modules/.pnpm/@ai-sdk+gateway@3.0.47_zod@4.3.6/node_modules/@ai-sdk/gateway/dist/index.mjs
76205
+ //#region ../../node_modules/.pnpm/@ai-sdk+gateway@3.0.50_zod@4.3.6/node_modules/@ai-sdk/gateway/dist/index.mjs
75781
76206
  var import_dist$1 = require_dist$1();
75782
76207
  var symbol$1 = Symbol.for("vercel.ai.gateway.error");
75783
76208
  var _a$1, _b;
@@ -76661,7 +77086,7 @@ async function getVercelRequestId() {
76661
77086
  var _a9;
76662
77087
  return (_a9 = (0, import_dist$1.getContext)().headers) == null ? void 0 : _a9["x-vercel-id"];
76663
77088
  }
76664
- var VERSION$2 = "3.0.47";
77089
+ var VERSION$2 = "3.0.50";
76665
77090
  var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
76666
77091
  function createGatewayProvider(options = {}) {
76667
77092
  var _a9, _b9;
@@ -77682,7 +78107,7 @@ var TraceAPI = function() {
77682
78107
  var trace = TraceAPI.getInstance();
77683
78108
 
77684
78109
  //#endregion
77685
- //#region ../../node_modules/.pnpm/ai@6.0.87_zod@4.3.6/node_modules/ai/dist/index.mjs
78110
+ //#region ../../node_modules/.pnpm/ai@6.0.91_zod@4.3.6/node_modules/ai/dist/index.mjs
77686
78111
  var __defProp = Object.defineProperty;
77687
78112
  var __export = (target, all) => {
77688
78113
  for (var name21 in all) __defProp(target, name21, {
@@ -78218,7 +78643,7 @@ function detectMediaType({ data, signatures }) {
78218
78643
  const bytes = typeof processedData === "string" ? convertBase64ToUint8Array(processedData.substring(0, Math.min(processedData.length, 24))) : processedData;
78219
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;
78220
78645
  }
78221
- var VERSION = "6.0.87";
78646
+ var VERSION = "6.0.91";
78222
78647
  var download = async ({ url, maxBytes, abortSignal }) => {
78223
78648
  var _a21;
78224
78649
  const urlText = url.toString();
@@ -87815,7 +88240,7 @@ async function callingMcpToolsLogic({ setting, checkpoint, step, skillManager })
87815
88240
  ...checkpoint,
87816
88241
  messages: [...checkpoint.messages, ...newMessages],
87817
88242
  usage: newUsage,
87818
- contextWindowUsage: checkpoint.contextWindow ? calculateContextWindowUsage(newUsage, checkpoint.contextWindow) : void 0,
88243
+ contextWindowUsage: checkpoint.contextWindowUsage,
87819
88244
  status: "completed",
87820
88245
  pendingToolCalls: void 0,
87821
88246
  partialToolResults: void 0
@@ -87979,9 +88404,10 @@ async function generatingRunResultLogic({ setting, checkpoint, step, eventListen
87979
88404
  const { text, reasoning } = generationResult;
87980
88405
  const thinkingParts = extractThinkingParts(reasoning);
87981
88406
  const thinkingText = extractThinkingText(reasoning);
88407
+ const resultText = text || "OK";
87982
88408
  const newMessages = [toolMessage, createExpertMessage([...thinkingParts, {
87983
88409
  type: "textPart",
87984
- text: text ?? ""
88410
+ text: resultText
87985
88411
  }])];
87986
88412
  if (thinkingText && !reasoningCompletedViaCallback) await eventListener(createStreamingEvent("completeStreamingReasoning", setting, checkpoint, { text: thinkingText }));
87987
88413
  const newUsage = sumUsage(checkpoint.usage, usage);
@@ -87990,7 +88416,7 @@ async function generatingRunResultLogic({ setting, checkpoint, step, eventListen
87990
88416
  ...checkpoint,
87991
88417
  messages: [...messages, ...newMessages],
87992
88418
  usage: newUsage,
87993
- contextWindowUsage: checkpoint.contextWindow ? calculateContextWindowUsage(newUsage, checkpoint.contextWindow) : void 0,
88419
+ contextWindowUsage: checkpoint.contextWindow ? calculateContextWindowUsage(usage, checkpoint.contextWindow) : void 0,
87994
88420
  status: "completed",
87995
88421
  pendingToolCalls: void 0,
87996
88422
  partialToolResults: void 0
@@ -88001,7 +88427,7 @@ async function generatingRunResultLogic({ setting, checkpoint, step, eventListen
88001
88427
  finishedAt: Date.now(),
88002
88428
  usage: sumUsage(step.usage, usage)
88003
88429
  },
88004
- text,
88430
+ text: resultText,
88005
88431
  usage
88006
88432
  });
88007
88433
  }
@@ -88592,7 +89018,7 @@ const runtimeStateMachine = setup({ types: {
88592
89018
  ...context.checkpoint,
88593
89019
  messages: [...context.checkpoint.messages, event.newMessage],
88594
89020
  usage: newUsage,
88595
- contextWindowUsage: context.checkpoint.contextWindow ? calculateContextWindowUsage(newUsage, context.checkpoint.contextWindow) : void 0,
89021
+ contextWindowUsage: context.checkpoint.contextWindow ? calculateContextWindowUsage(event.usage, context.checkpoint.contextWindow) : void 0,
88596
89022
  retryCount: 0
88597
89023
  };
88598
89024
  },
@@ -89206,19 +89632,19 @@ const defaultCreateJob = (jobId, expertKey, maxSteps, runtimeVersion = getCurren
89206
89632
  */
89207
89633
  async function run(runInput, options) {
89208
89634
  let { setting, checkpoint } = runParamsSchema.parse(runInput);
89209
- const storeJob = options?.storeJob ?? (() => {});
89210
- const retrieveJob = options?.retrieveJob ?? (() => void 0);
89635
+ const storeJob = options?.storeJob ?? (async () => {});
89636
+ const retrieveJob = options?.retrieveJob ?? (async () => void 0);
89211
89637
  const retrieveCheckpoint = options?.retrieveCheckpoint ?? (async () => {
89212
89638
  throw new Error("retrieveCheckpoint not provided");
89213
89639
  });
89214
89640
  const createJob = options?.createJob ?? defaultCreateJob;
89215
- 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);
89216
89642
  if (job.status !== "running") job = {
89217
89643
  ...job,
89218
89644
  status: "running",
89219
89645
  finishedAt: void 0
89220
89646
  };
89221
- storeJob(job);
89647
+ await storeJob(job);
89222
89648
  const runExecutor = new CoordinatorExecutor({
89223
89649
  shouldContinueRun: options?.shouldContinueRun,
89224
89650
  storeCheckpoint: options?.storeCheckpoint,
@@ -89238,31 +89664,31 @@ async function run(runInput, options) {
89238
89664
  switch (resultCheckpoint.status) {
89239
89665
  case "completed":
89240
89666
  if (options?.returnOnDelegationComplete) {
89241
- storeJob(job);
89667
+ await storeJob(job);
89242
89668
  return resultCheckpoint;
89243
89669
  }
89244
89670
  if (resultCheckpoint.delegatedBy) {
89245
- storeJob(job);
89671
+ await storeJob(job);
89246
89672
  const parentCheckpoint = await retrieveCheckpoint(setting.jobId, resultCheckpoint.delegatedBy.checkpointId);
89247
89673
  const result = buildReturnFromDelegation(setting, resultCheckpoint, parentCheckpoint);
89248
89674
  setting = result.setting;
89249
89675
  checkpoint = result.checkpoint;
89250
89676
  break;
89251
89677
  }
89252
- storeJob({
89678
+ await storeJob({
89253
89679
  ...job,
89254
89680
  status: "completed",
89255
89681
  finishedAt: Date.now()
89256
89682
  });
89257
89683
  return resultCheckpoint;
89258
89684
  case "stoppedByInteractiveTool":
89259
- storeJob({
89685
+ await storeJob({
89260
89686
  ...job,
89261
89687
  status: "stoppedByInteractiveTool"
89262
89688
  });
89263
89689
  return resultCheckpoint;
89264
89690
  case "stoppedByDelegate": {
89265
- storeJob(job);
89691
+ await storeJob(job);
89266
89692
  const { delegateTo } = resultCheckpoint;
89267
89693
  if (!delegateTo || delegateTo.length === 0) throw new Error("No delegations found in checkpoint");
89268
89694
  const executor = new DelegationExecutor();
@@ -89277,21 +89703,21 @@ async function run(runInput, options) {
89277
89703
  break;
89278
89704
  }
89279
89705
  case "stoppedByExceededMaxSteps":
89280
- storeJob({
89706
+ await storeJob({
89281
89707
  ...job,
89282
89708
  status: "stoppedByMaxSteps",
89283
89709
  finishedAt: Date.now()
89284
89710
  });
89285
89711
  return resultCheckpoint;
89286
89712
  case "stoppedByError":
89287
- storeJob({
89713
+ await storeJob({
89288
89714
  ...job,
89289
89715
  status: "stoppedByError",
89290
89716
  finishedAt: Date.now()
89291
89717
  });
89292
89718
  return resultCheckpoint;
89293
89719
  case "stoppedByCancellation":
89294
- storeJob({
89720
+ await storeJob({
89295
89721
  ...job,
89296
89722
  status: "stoppedByCancellation",
89297
89723
  finishedAt: Date.now()
@@ -113461,11 +113887,7 @@ const INDICATOR = {
113461
113887
  BULLET: "●",
113462
113888
  ELLIPSIS: "..."
113463
113889
  };
113464
- const STOP_EVENT_TYPES = [
113465
- "stopRunByInteractiveTool",
113466
- "stopRunByDelegate",
113467
- "stopRunByExceededMaxSteps"
113468
- ];
113890
+ const STOP_EVENT_TYPES = ["stopRunByInteractiveTool", "stopRunByExceededMaxSteps"];
113469
113891
  const KEY_BINDINGS = {
113470
113892
  NAVIGATE_UP: "↑",
113471
113893
  NAVIGATE_DOWN: "↓",
@@ -115411,7 +115833,7 @@ function extractLogEntriesFromEvent(event) {
115411
115833
  return entries;
115412
115834
  }
115413
115835
  const useExecutionState = (options) => {
115414
- const { expertKey, query, config, continueTimeoutMs, historicalEvents, onReady, onComplete, onQueryReady } = options;
115836
+ const { expertKey, query, config, historicalEvents, onReady, onComplete, onQueryReady } = options;
115415
115837
  const runState = useRun();
115416
115838
  const { runtimeInfo, handleEvent, setQuery } = useRuntimeInfo({
115417
115839
  initialExpertName: expertKey,
@@ -115419,24 +115841,7 @@ const useExecutionState = (options) => {
115419
115841
  });
115420
115842
  const [runStatus, setRunStatus] = (0, import_react.useState)(query ? "running" : "waiting");
115421
115843
  const [staticItems, setStaticItems] = (0, import_react.useState)([]);
115422
- const timeoutRef = (0, import_react.useRef)(null);
115423
115844
  const lastSyncedCountRef = (0, import_react.useRef)(0);
115424
- const clearTimeoutIfExists = (0, import_react.useCallback)(() => {
115425
- if (timeoutRef.current) {
115426
- clearTimeout(timeoutRef.current);
115427
- timeoutRef.current = null;
115428
- }
115429
- }, []);
115430
- const startExitTimeout = (0, import_react.useCallback)(() => {
115431
- clearTimeoutIfExists();
115432
- timeoutRef.current = setTimeout(() => {
115433
- onComplete({ nextQuery: null });
115434
- }, continueTimeoutMs);
115435
- }, [
115436
- clearTimeoutIfExists,
115437
- continueTimeoutMs,
115438
- onComplete
115439
- ]);
115440
115845
  (0, import_react.useEffect)(() => {
115441
115846
  if (query) setQuery(query);
115442
115847
  }, [query, setQuery]);
@@ -115462,25 +115867,16 @@ const useExecutionState = (options) => {
115462
115867
  const result = handleEvent(event);
115463
115868
  const logEntries = extractLogEntriesFromEvent(event);
115464
115869
  if (logEntries.length > 0) setStaticItems((prev) => [...prev, ...logEntries]);
115465
- if (result?.completed) {
115466
- setRunStatus("completed");
115467
- startExitTimeout();
115468
- } else if (result?.stopped) {
115469
- setRunStatus("stopped");
115470
- startExitTimeout();
115471
- }
115870
+ if (result?.stopped) setRunStatus("stopped");
115472
115871
  });
115473
115872
  }, [
115474
115873
  onReady,
115475
115874
  runState.addEvent,
115476
- handleEvent,
115477
- startExitTimeout
115875
+ handleEvent
115478
115876
  ]);
115479
115877
  (0, import_react.useEffect)(() => {
115480
- return () => {
115481
- clearTimeoutIfExists();
115482
- };
115483
- }, [clearTimeoutIfExists]);
115878
+ if (runState.isComplete) setRunStatus("completed");
115879
+ }, [runState.isComplete]);
115484
115880
  const handleSubmit = (0, import_react.useCallback)((newQuery) => {
115485
115881
  if (!newQuery.trim()) return;
115486
115882
  if (runStatus === "waiting") {
@@ -115490,13 +115886,9 @@ const useExecutionState = (options) => {
115490
115886
  onQueryReady?.(trimmed);
115491
115887
  return;
115492
115888
  }
115493
- if (runStatus !== "running") {
115494
- clearTimeoutIfExists();
115495
- onComplete({ nextQuery: newQuery.trim() });
115496
- }
115889
+ if (runStatus !== "running") onComplete({ nextQuery: newQuery.trim() });
115497
115890
  }, [
115498
115891
  runStatus,
115499
- clearTimeoutIfExists,
115500
115892
  onComplete,
115501
115893
  setQuery,
115502
115894
  onQueryReady
@@ -115506,15 +115898,14 @@ const useExecutionState = (options) => {
115506
115898
  streaming: runState.streaming,
115507
115899
  runtimeInfo,
115508
115900
  runStatus,
115509
- handleSubmit,
115510
- clearTimeout: clearTimeoutIfExists
115901
+ handleSubmit
115511
115902
  };
115512
115903
  };
115513
115904
 
115514
115905
  //#endregion
115515
115906
  //#region ../../packages/tui-components/src/execution/app.tsx
115516
115907
  const ExecutionApp = (props) => {
115517
- const { expertKey, query, config, continueTimeoutMs, historicalEvents, onReady, onComplete, onQueryReady } = props;
115908
+ const { expertKey, query, config, historicalEvents, onReady, onComplete, onQueryReady } = props;
115518
115909
  const { exit } = useApp();
115519
115910
  const [exitResult, setExitResult] = (0, import_react.useState)(null);
115520
115911
  const handleComplete = (0, import_react.useCallback)((result) => {
@@ -115534,17 +115925,13 @@ const ExecutionApp = (props) => {
115534
115925
  expertKey,
115535
115926
  query,
115536
115927
  config,
115537
- continueTimeoutMs,
115538
115928
  historicalEvents,
115539
115929
  onReady,
115540
115930
  onComplete: handleComplete,
115541
115931
  onQueryReady
115542
115932
  });
115543
115933
  useInput((input, key) => {
115544
- if (key.ctrl && input === "c") {
115545
- state.clearTimeout();
115546
- exit();
115547
- }
115934
+ if (key.ctrl && input === "c") exit();
115548
115935
  });
115549
115936
  if (exitResult) return null;
115550
115937
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
@@ -115807,7 +116194,6 @@ async function renderSelection(params) {
115807
116194
 
115808
116195
  //#endregion
115809
116196
  //#region ../../packages/tui/src/start-handler.ts
115810
- const CONTINUE_TIMEOUT_MS = 6e4;
115811
116197
  async function startHandler(expertKey, query, options, handlerOptions) {
115812
116198
  const input = parseWithFriendlyError(startCommandInputSchema, {
115813
116199
  expertKey,
@@ -115891,7 +116277,6 @@ async function startHandler(expertKey, query, options, handlerOptions) {
115891
116277
  timeout,
115892
116278
  contextWindowUsage: currentCheckpoint?.contextWindowUsage ?? 0
115893
116279
  },
115894
- continueTimeoutMs: CONTINUE_TIMEOUT_MS,
115895
116280
  historicalEvents
115896
116281
  });
115897
116282
  const resolvedQuery = await queryReady;
@@ -115940,7 +116325,7 @@ async function startHandler(expertKey, query, options, handlerOptions) {
115940
116325
  //#endregion
115941
116326
  //#region package.json
115942
116327
  var name = "create-expert";
115943
- var version = "0.0.38";
116328
+ var version = "0.0.39";
115944
116329
  var description = "Create and modify Perstack expert definitions";
115945
116330
 
115946
116331
  //#endregion