perstack 0.0.91 → 0.0.93

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.
@@ -1577,7 +1577,6 @@ const expertNameRegex$1 = /^(@[a-z0-9][a-z0-9_-]*\/)?[a-z0-9][a-z0-9_-]*$/;
1577
1577
  const expertVersionRegex$1 = /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[\w.-]+)?(?:\+[\w.-]+)?$/;
1578
1578
  const tagNameRegex$1 = /^[a-z0-9][a-z0-9_-]*$/;
1579
1579
  const maxExpertNameLength$1 = 255;
1580
- const defaultMaxSteps = 100;
1581
1580
  const defaultMaxRetries = 5;
1582
1581
  const defaultTimeout = 5 * 1e3 * 60;
1583
1582
  const maxSkillNameLength$1 = 255;
@@ -6246,6 +6245,26 @@ function preprocess(fn, schema) {
6246
6245
  return pipe(transform(fn), schema);
6247
6246
  }
6248
6247
 
6248
+ //#endregion
6249
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/compat.js
6250
+ /** @deprecated Use the raw string literal codes instead, e.g. "invalid_type". */
6251
+ const ZodIssueCode = {
6252
+ invalid_type: "invalid_type",
6253
+ too_big: "too_big",
6254
+ too_small: "too_small",
6255
+ invalid_format: "invalid_format",
6256
+ not_multiple_of: "not_multiple_of",
6257
+ unrecognized_keys: "unrecognized_keys",
6258
+ invalid_union: "invalid_union",
6259
+ invalid_key: "invalid_key",
6260
+ invalid_element: "invalid_element",
6261
+ invalid_value: "invalid_value",
6262
+ custom: "custom"
6263
+ };
6264
+ /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
6265
+ var ZodFirstPartyTypeKind;
6266
+ (function(ZodFirstPartyTypeKind) {})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
6267
+
6249
6268
  //#endregion
6250
6269
  //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/coerce.js
6251
6270
  function number(params) {
@@ -6296,7 +6315,7 @@ const toolCallPartSchema = basePartSchema.extend({
6296
6315
  type: literal("toolCallPart"),
6297
6316
  toolCallId: string(),
6298
6317
  toolName: string(),
6299
- args: unknown()
6318
+ args: record(string(), unknown())
6300
6319
  });
6301
6320
  const thinkingPartSchema = basePartSchema.extend({
6302
6321
  type: literal("thinkingPart"),
@@ -6451,6 +6470,36 @@ const generalToolActivitySchema = baseActivitySchema.extend({
6451
6470
  result: array(messagePartSchema).optional(),
6452
6471
  error: string().optional()
6453
6472
  });
6473
+ const addSkillActivitySchema = baseActivitySchema.extend({
6474
+ type: literal("addSkill"),
6475
+ name: string(),
6476
+ skillType: string(),
6477
+ tools: array(string()).optional(),
6478
+ error: string().optional()
6479
+ });
6480
+ const removeSkillActivitySchema = baseActivitySchema.extend({
6481
+ type: literal("removeSkill"),
6482
+ skillName: string(),
6483
+ error: string().optional()
6484
+ });
6485
+ const addDelegateActivitySchema = baseActivitySchema.extend({
6486
+ type: literal("addDelegate"),
6487
+ targetExpertKey: string(),
6488
+ delegateToolName: string().optional(),
6489
+ error: string().optional()
6490
+ });
6491
+ const removeDelegateActivitySchema = baseActivitySchema.extend({
6492
+ type: literal("removeDelegate"),
6493
+ expertName: string(),
6494
+ error: string().optional()
6495
+ });
6496
+ const createExpertActivitySchema = baseActivitySchema.extend({
6497
+ type: literal("createExpert"),
6498
+ targetKey: string(),
6499
+ description: string().optional(),
6500
+ resultExpertKey: string().optional(),
6501
+ error: string().optional()
6502
+ });
6454
6503
  const activitySchema = discriminatedUnion("type", [
6455
6504
  queryActivitySchema,
6456
6505
  retryActivitySchema,
@@ -6468,7 +6517,12 @@ const activitySchema = discriminatedUnion("type", [
6468
6517
  delegateActivitySchema,
6469
6518
  delegationCompleteActivitySchema,
6470
6519
  interactiveToolActivitySchema,
6471
- generalToolActivitySchema
6520
+ generalToolActivitySchema,
6521
+ addSkillActivitySchema,
6522
+ removeSkillActivitySchema,
6523
+ addDelegateActivitySchema,
6524
+ removeDelegateActivitySchema,
6525
+ createExpertActivitySchema
6472
6526
  ]);
6473
6527
  const parallelActivitiesGroupSchema = object({
6474
6528
  type: literal("parallelGroup"),
@@ -6558,7 +6612,6 @@ const checkpointStatusSchema = _enum([
6558
6612
  "completed",
6559
6613
  "stoppedByInteractiveTool",
6560
6614
  "stoppedByDelegate",
6561
- "stoppedByExceededMaxSteps",
6562
6615
  "stoppedByError",
6563
6616
  "stoppedByCancellation"
6564
6617
  ]);
@@ -6611,6 +6664,61 @@ const checkpointSchema = object({
6611
6664
  retryCount: number$1().optional()
6612
6665
  });
6613
6666
 
6667
+ //#endregion
6668
+ //#region ../../packages/core/src/utils/expert-type.ts
6669
+ function getExpertType(expertName) {
6670
+ return expertName.startsWith("@") ? "delegate" : "coordinator";
6671
+ }
6672
+ function isCoordinatorExpert(expertName) {
6673
+ return getExpertType(expertName) === "coordinator";
6674
+ }
6675
+ function isDelegateExpert(expertName) {
6676
+ return getExpertType(expertName) === "delegate";
6677
+ }
6678
+ /**
6679
+ * Returns the scope of an expert.
6680
+ * - Coordinator "game-producer" -> "game-producer"
6681
+ * - Delegate "@game-producer/designer" -> "game-producer"
6682
+ */
6683
+ function getExpertScope(expertName) {
6684
+ if (isDelegateExpert(expertName)) {
6685
+ const withoutAt = expertName.slice(1);
6686
+ const slashIndex = withoutAt.indexOf("/");
6687
+ return slashIndex === -1 ? withoutAt : withoutAt.slice(0, slashIndex);
6688
+ }
6689
+ return expertName;
6690
+ }
6691
+ /**
6692
+ * Validates whether a delegation from source to target is allowed.
6693
+ * Returns null if valid, an error message string if invalid.
6694
+ *
6695
+ * Rules:
6696
+ * - No self-delegation
6697
+ * - If target is a delegate (@scope/name), source must be in the same scope
6698
+ * - A delegate cannot delegate to its own coordinator
6699
+ */
6700
+ function validateDelegation(source, target) {
6701
+ if (source === target) return `Expert "${source}" cannot delegate to itself`;
6702
+ const sourceScope = getExpertScope(source);
6703
+ if (isDelegateExpert(target)) {
6704
+ if (sourceScope !== getExpertScope(target)) return `Expert "${source}" cannot delegate to out-of-scope delegate "${target}"`;
6705
+ }
6706
+ if (isDelegateExpert(source) && isCoordinatorExpert(target) && target === sourceScope) return `Delegate "${source}" cannot delegate to its own coordinator "${target}"`;
6707
+ return null;
6708
+ }
6709
+ /**
6710
+ * Validates all delegations for an expert.
6711
+ * Returns an array of error messages (empty if all valid).
6712
+ */
6713
+ function validateAllDelegations(expertName, delegates) {
6714
+ const errors = [];
6715
+ for (const delegate of delegates) {
6716
+ const error = validateDelegation(expertName, delegate);
6717
+ if (error) errors.push(error);
6718
+ }
6719
+ return errors;
6720
+ }
6721
+
6614
6722
  //#endregion
6615
6723
  //#region ../../packages/core/src/schemas/provider-tools.ts
6616
6724
  const anthropicProviderToolNameSchema = _enum([
@@ -6756,7 +6864,11 @@ const skillSchema$1 = discriminatedUnion("type", [
6756
6864
 
6757
6865
  //#endregion
6758
6866
  //#region ../../packages/core/src/schemas/expert.ts
6759
- const expertSchema$1 = object({
6867
+ /**
6868
+ * Base object schema for Expert. Use this for `.omit()` / `.pick()` operations.
6869
+ * For parsing with delegation validation, use `expertSchema` instead.
6870
+ */
6871
+ const expertBaseSchema = object({
6760
6872
  key: string().regex(expertKeyRegex$1).min(1),
6761
6873
  name: string().regex(expertNameRegex$1).min(1).max(maxExpertNameLength$1),
6762
6874
  version: string().regex(expertVersionRegex$1),
@@ -6791,13 +6903,24 @@ const expertSchema$1 = object({
6791
6903
  providerSkills: array(anthropicProviderSkillSchema).optional(),
6792
6904
  providerToolOptions: providerToolOptionsSchema
6793
6905
  });
6906
+ /**
6907
+ * Expert schema with delegation rule validation.
6908
+ * Rejects self-delegation, out-of-scope delegates, and delegate-to-own-coordinator.
6909
+ */
6910
+ const expertSchema$1 = expertBaseSchema.superRefine((data, ctx) => {
6911
+ const errors = validateAllDelegations(data.key, data.delegates);
6912
+ for (const error of errors) ctx.addIssue({
6913
+ code: ZodIssueCode.custom,
6914
+ message: error,
6915
+ path: ["delegates"]
6916
+ });
6917
+ });
6794
6918
 
6795
6919
  //#endregion
6796
6920
  //#region ../../packages/core/src/schemas/job.ts
6797
6921
  const jobStatusSchema$1 = _enum([
6798
6922
  "running",
6799
6923
  "completed",
6800
- "stoppedByMaxSteps",
6801
6924
  "stoppedByInteractiveTool",
6802
6925
  "stoppedByError",
6803
6926
  "stoppedByCancellation"
@@ -6808,7 +6931,6 @@ const jobSchema$1 = object({
6808
6931
  coordinatorExpertKey: string(),
6809
6932
  runtimeVersion: runtimeVersionSchema$1,
6810
6933
  totalSteps: number$1(),
6811
- maxSteps: number$1().optional(),
6812
6934
  usage: usageSchema,
6813
6935
  startedAt: number$1(),
6814
6936
  finishedAt: number$1().optional()
@@ -7019,7 +7141,6 @@ const perstackConfigSchema = object({
7019
7141
  provider: providerTableSchema.optional(),
7020
7142
  model: string().optional(),
7021
7143
  reasoningBudget: reasoningBudgetSchema$1.optional(),
7022
- maxSteps: number$1().optional(),
7023
7144
  maxRetries: number$1().optional(),
7024
7145
  timeout: number$1().optional(),
7025
7146
  experts: record(string(), object({
@@ -7089,12 +7210,6 @@ const commandOptionsSchema = object({
7089
7210
  if (Number.isNaN(parsedValue)) return void 0;
7090
7211
  return parsedValue;
7091
7212
  }).pipe(reasoningBudgetSchema$1.optional()),
7092
- maxSteps: string().optional().transform((value) => {
7093
- if (value === void 0) return void 0;
7094
- const parsedValue = Number.parseInt(value, 10);
7095
- if (Number.isNaN(parsedValue)) return void 0;
7096
- return parsedValue;
7097
- }),
7098
7213
  maxRetries: string().optional().transform((value) => {
7099
7214
  if (value === void 0) return void 0;
7100
7215
  const parsedValue = Number.parseInt(value, 10);
@@ -7133,6 +7248,19 @@ const startCommandInputSchema = object({
7133
7248
 
7134
7249
  //#endregion
7135
7250
  //#region ../../packages/core/src/schemas/runtime.ts
7251
+ /** Parse an expert key into its components */
7252
+ function parseExpertKey(expertKey) {
7253
+ const match = expertKey.match(expertKeyRegex$1);
7254
+ if (!match) throw new PerstackError(`Invalid expert key format: ${expertKey}`);
7255
+ const [key, name, version, tag] = match;
7256
+ if (!name) throw new PerstackError(`Invalid expert key format: ${expertKey}`);
7257
+ return {
7258
+ key,
7259
+ name,
7260
+ version,
7261
+ tag
7262
+ };
7263
+ }
7136
7264
  const runSettingSchema = object({
7137
7265
  model: string(),
7138
7266
  providerConfig: providerConfigSchema,
@@ -7150,7 +7278,6 @@ const runSettingSchema = object({
7150
7278
  }),
7151
7279
  experts: record(string(), expertSchema$1),
7152
7280
  reasoningBudget: reasoningBudgetSchema$1.default(defaultReasoningBudget),
7153
- maxSteps: number$1().min(1).optional().default(defaultMaxSteps),
7154
7281
  maxRetries: number$1().min(0),
7155
7282
  timeout: number$1().min(0),
7156
7283
  startedAt: number$1(),
@@ -7178,12 +7305,11 @@ const runParamsSchema = object({
7178
7305
  text: string()
7179
7306
  }).optional()
7180
7307
  }),
7181
- experts: record(string().min(1).regex(expertKeyRegex$1), expertSchema$1.omit({ key: true })).optional().default({}).transform((experts) => Object.fromEntries(Object.entries(experts).map(([key, expertWithoutKey]) => [key, expertSchema$1.parse({
7308
+ experts: record(string().min(1).regex(expertKeyRegex$1), expertBaseSchema.omit({ key: true })).optional().default({}).transform((experts) => Object.fromEntries(Object.entries(experts).map(([key, expertWithoutKey]) => [key, expertSchema$1.parse({
7182
7309
  ...expertWithoutKey,
7183
7310
  key
7184
7311
  })]))),
7185
7312
  reasoningBudget: reasoningBudgetSchema$1.optional().default(defaultReasoningBudget),
7186
- maxSteps: number$1().min(1).optional().default(defaultMaxSteps),
7187
7313
  maxRetries: number$1().min(0).optional().default(defaultMaxRetries),
7188
7314
  timeout: number$1().min(0).optional().default(defaultTimeout),
7189
7315
  startedAt: number$1().optional().default(Date.now()),
@@ -7234,13 +7360,11 @@ const callTools = createEvent("callTools");
7234
7360
  const finishMcpTools = createEvent("finishMcpTools");
7235
7361
  const skipDelegates = createEvent("skipDelegates");
7236
7362
  const resolveToolResults = createEvent("resolveToolResults");
7237
- const attemptCompletion = createEvent("attemptCompletion");
7238
7363
  const finishToolCall = createEvent("finishToolCall");
7239
7364
  const resumeToolCalls = createEvent("resumeToolCalls");
7240
7365
  const completeRun = createEvent("completeRun");
7241
7366
  const stopRunByInteractiveTool = createEvent("stopRunByInteractiveTool");
7242
7367
  const stopRunByDelegate = createEvent("stopRunByDelegate");
7243
- const stopRunByExceededMaxSteps = createEvent("stopRunByExceededMaxSteps");
7244
7368
  const stopRunByError = createEvent("stopRunByError");
7245
7369
  const continueToNextStep = createEvent("continueToNextStep");
7246
7370
  /** Factory function to create runtime events */
@@ -7267,13 +7391,11 @@ const EXPERT_STATE_EVENT_TYPES = new Set([
7267
7391
  "finishMcpTools",
7268
7392
  "skipDelegates",
7269
7393
  "resolveToolResults",
7270
- "attemptCompletion",
7271
7394
  "finishToolCall",
7272
7395
  "resumeToolCalls",
7273
7396
  "continueToNextStep",
7274
7397
  "stopRunByInteractiveTool",
7275
7398
  "stopRunByDelegate",
7276
- "stopRunByExceededMaxSteps",
7277
7399
  "stopRunByError",
7278
7400
  "completeRun"
7279
7401
  ]);
@@ -7416,6 +7538,41 @@ function createBaseToolActivity(toolName, toolCall, toolResult, reasoning) {
7416
7538
  stdout: parseStringField(resultContents, "stdout"),
7417
7539
  stderr: parseStringField(resultContents, "stderr")
7418
7540
  };
7541
+ case "addSkill": return {
7542
+ type: "addSkill",
7543
+ ...baseFields,
7544
+ name: String(args["name"] ?? ""),
7545
+ skillType: String(args["type"] ?? ""),
7546
+ tools: parseStringArrayField(resultContents, "tools"),
7547
+ error: errorText
7548
+ };
7549
+ case "removeSkill": return {
7550
+ type: "removeSkill",
7551
+ ...baseFields,
7552
+ skillName: String(args["skillName"] ?? ""),
7553
+ error: errorText
7554
+ };
7555
+ case "addDelegate": return {
7556
+ type: "addDelegate",
7557
+ ...baseFields,
7558
+ targetExpertKey: String(args["expertKey"] ?? ""),
7559
+ delegateToolName: parseStringField(resultContents, "delegateToolName"),
7560
+ error: errorText
7561
+ };
7562
+ case "removeDelegate": return {
7563
+ type: "removeDelegate",
7564
+ ...baseFields,
7565
+ expertName: String(args["expertName"] ?? ""),
7566
+ error: errorText
7567
+ };
7568
+ case "createExpert": return {
7569
+ type: "createExpert",
7570
+ ...baseFields,
7571
+ targetKey: String(args["key"] ?? ""),
7572
+ description: typeof args["description"] === "string" ? args["description"] : void 0,
7573
+ resultExpertKey: parseStringField(resultContents, "expertKey"),
7574
+ error: errorText
7575
+ };
7419
7576
  default: return createGeneralToolActivity(toolCall.skillName, toolName, toolCall, toolResult, reasoning);
7420
7577
  }
7421
7578
  }
@@ -7465,6 +7622,14 @@ function parseNumberField(result, field) {
7465
7622
  return;
7466
7623
  }
7467
7624
  }
7625
+ function parseStringArrayField(result, field) {
7626
+ const textPart = result.find((p) => p.type === "textPart");
7627
+ if (!textPart?.text) return void 0;
7628
+ try {
7629
+ const parsed = JSON.parse(textPart.text);
7630
+ if (Array.isArray(parsed[field])) return parsed[field].map(String);
7631
+ } catch {}
7632
+ }
7468
7633
  function parseRemainingTodosFromResult(result) {
7469
7634
  const textPart = result.find((p) => p.type === "textPart");
7470
7635
  if (!textPart?.text) return void 0;
@@ -7571,34 +7736,37 @@ function parseWithFriendlyError(schema, data, context) {
7571
7736
  }
7572
7737
 
7573
7738
  //#endregion
7574
- //#region ../../node_modules/.pnpm/@perstack+api-client@0.0.55_@perstack+core@packages+core_zod@4.3.6/node_modules/@perstack/api-client/dist/index.mjs
7739
+ //#region ../../node_modules/.pnpm/@perstack+api-client@0.0.56_@perstack+core@packages+core_zod@4.3.6/node_modules/@perstack/api-client/dist/index.mjs
7575
7740
  function createValidationError(error) {
7576
7741
  return {
7577
- errorType: "validation",
7578
- code: 400,
7742
+ type: "validation",
7579
7743
  message: `Validation failed: ${error.issues.map((issue) => `${issue.path.join(".")}: ${issue.message}`).join("; ")}`,
7580
7744
  reason: error.issues
7581
7745
  };
7582
7746
  }
7747
+ function validationErrorResult(error) {
7748
+ return {
7749
+ ok: false,
7750
+ status: 0,
7751
+ headers: new Headers(),
7752
+ error: createValidationError(error)
7753
+ };
7754
+ }
7583
7755
  function createAbortError() {
7584
7756
  return {
7585
- errorType: "abort",
7586
- code: 0,
7587
- message: "Request aborted",
7588
- aborted: true
7757
+ type: "abort",
7758
+ message: "Request aborted"
7589
7759
  };
7590
7760
  }
7591
7761
  function createTimeoutError() {
7592
7762
  return {
7593
- errorType: "timeout",
7594
- code: 0,
7763
+ type: "timeout",
7595
7764
  message: "Request timed out"
7596
7765
  };
7597
7766
  }
7598
7767
  function createNetworkError(error) {
7599
7768
  return {
7600
- errorType: "network",
7601
- code: 0,
7769
+ type: "network",
7602
7770
  message: error instanceof Error ? error.message : "Network error",
7603
7771
  reason: error,
7604
7772
  cause: error instanceof Error ? error : void 0
@@ -7613,38 +7781,37 @@ async function handleHttpError(response) {
7613
7781
  }
7614
7782
  return {
7615
7783
  ok: false,
7616
- error: createHttpError(response.status, response.statusText, errorBody)
7784
+ status: response.status,
7785
+ headers: response.headers,
7786
+ error: createHttpError(response.statusText, errorBody)
7617
7787
  };
7618
7788
  }
7619
- function createHttpError(status, statusText, body) {
7789
+ function createHttpError(statusText, body) {
7620
7790
  if (typeof body === "object" && body !== null) {
7621
7791
  const hasReason = "reason" in body;
7622
7792
  if ("error" in body && typeof body.error === "string") return {
7623
- errorType: "http",
7624
- code: status,
7793
+ type: "http",
7625
7794
  message: body.error,
7626
7795
  reason: hasReason ? body.reason : void 0
7627
7796
  };
7628
7797
  if (hasReason) return {
7629
- errorType: "http",
7630
- code: status,
7798
+ type: "http",
7631
7799
  message: statusText,
7632
7800
  reason: body.reason
7633
7801
  };
7634
7802
  }
7635
7803
  return {
7636
- errorType: "http",
7637
- code: status,
7804
+ type: "http",
7638
7805
  message: statusText
7639
7806
  };
7640
7807
  }
7641
7808
  const DEFAULT_BASE_URL = "https://api.perstack.ai";
7642
- const DEFAULT_TIMEOUT = 3e4;
7809
+ const DEFAULT_TIMEOUT = 6e4;
7643
7810
  function createFetcher(config) {
7644
7811
  const baseUrl = config.baseUrl ?? DEFAULT_BASE_URL;
7645
7812
  const timeout = config.timeout ?? DEFAULT_TIMEOUT;
7646
- const useCredentials = "credentials" in config && config.credentials === "include";
7647
- const apiKey = "apiKey" in config ? config.apiKey : void 0;
7813
+ const useCredentials = config.credentials === "include";
7814
+ const apiKey = config.apiKey;
7648
7815
  function buildUrl(path) {
7649
7816
  return `${baseUrl}${path}`;
7650
7817
  }
@@ -7740,23 +7907,32 @@ function createFetcher(config) {
7740
7907
  credentials: getCredentials()
7741
7908
  });
7742
7909
  if (!response.ok) return handleHttpError(response);
7910
+ const json = await response.json();
7743
7911
  return {
7744
7912
  ok: true,
7745
- data: await response.json()
7913
+ status: response.status,
7914
+ headers: response.headers,
7915
+ data: json
7746
7916
  };
7747
7917
  } catch (error) {
7748
7918
  if (error instanceof Error && error.name === "AbortError") {
7749
7919
  if (isTimeout()) return {
7750
7920
  ok: false,
7921
+ status: 0,
7922
+ headers: new Headers(),
7751
7923
  error: createTimeoutError()
7752
7924
  };
7753
7925
  return {
7754
7926
  ok: false,
7927
+ status: 0,
7928
+ headers: new Headers(),
7755
7929
  error: createAbortError()
7756
7930
  };
7757
7931
  }
7758
7932
  return {
7759
7933
  ok: false,
7934
+ status: 0,
7935
+ headers: new Headers(),
7760
7936
  error: createNetworkError(error)
7761
7937
  };
7762
7938
  } finally {
@@ -7773,23 +7949,32 @@ function createFetcher(config) {
7773
7949
  credentials: getCredentials()
7774
7950
  });
7775
7951
  if (!response.ok) return handleHttpError(response);
7952
+ const blob = await response.blob();
7776
7953
  return {
7777
7954
  ok: true,
7778
- data: await response.blob()
7955
+ status: response.status,
7956
+ headers: response.headers,
7957
+ data: blob
7779
7958
  };
7780
7959
  } catch (error) {
7781
7960
  if (error instanceof Error && error.name === "AbortError") {
7782
7961
  if (isTimeout()) return {
7783
7962
  ok: false,
7963
+ status: 0,
7964
+ headers: new Headers(),
7784
7965
  error: createTimeoutError()
7785
7966
  };
7786
7967
  return {
7787
7968
  ok: false,
7969
+ status: 0,
7970
+ headers: new Headers(),
7788
7971
  error: createAbortError()
7789
7972
  };
7790
7973
  }
7791
7974
  return {
7792
7975
  ok: false,
7976
+ status: 0,
7977
+ headers: new Headers(),
7793
7978
  error: createNetworkError(error)
7794
7979
  };
7795
7980
  } finally {
@@ -7813,29 +7998,40 @@ function createFetcher(config) {
7813
7998
  cleanup();
7814
7999
  return {
7815
8000
  ok: false,
8001
+ status: response.status,
8002
+ headers: response.headers,
7816
8003
  error: createNetworkError(/* @__PURE__ */ new Error("Response body is null"))
7817
8004
  };
7818
8005
  }
7819
8006
  cleanup();
7820
8007
  const idleTimeout = options?.streamIdleTimeout ?? timeout;
8008
+ const wrappedStream = wrapStreamWithIdleTimeout(response.body, idleTimeout, options?.signal);
7821
8009
  return {
7822
8010
  ok: true,
7823
- data: wrapStreamWithIdleTimeout(response.body, idleTimeout, options?.signal)
8011
+ status: response.status,
8012
+ headers: response.headers,
8013
+ data: wrappedStream
7824
8014
  };
7825
8015
  } catch (error) {
7826
8016
  cleanup();
7827
8017
  if (error instanceof Error && error.name === "AbortError") {
7828
8018
  if (isTimeout()) return {
7829
8019
  ok: false,
8020
+ status: 0,
8021
+ headers: new Headers(),
7830
8022
  error: createTimeoutError()
7831
8023
  };
7832
8024
  return {
7833
8025
  ok: false,
8026
+ status: 0,
8027
+ headers: new Headers(),
7834
8028
  error: createAbortError()
7835
8029
  };
7836
8030
  }
7837
8031
  return {
7838
8032
  ok: false,
8033
+ status: 0,
8034
+ headers: new Headers(),
7839
8035
  error: createNetworkError(error)
7840
8036
  };
7841
8037
  }
@@ -7852,21 +8048,29 @@ function createFetcher(config) {
7852
8048
  if (!response.ok) return handleHttpError(response);
7853
8049
  return {
7854
8050
  ok: true,
8051
+ status: response.status,
8052
+ headers: response.headers,
7855
8053
  data: void 0
7856
8054
  };
7857
8055
  } catch (error) {
7858
8056
  if (error instanceof Error && error.name === "AbortError") {
7859
8057
  if (isTimeout()) return {
7860
8058
  ok: false,
8059
+ status: 0,
8060
+ headers: new Headers(),
7861
8061
  error: createTimeoutError()
7862
8062
  };
7863
8063
  return {
7864
8064
  ok: false,
8065
+ status: 0,
8066
+ headers: new Headers(),
7865
8067
  error: createAbortError()
7866
8068
  };
7867
8069
  }
7868
8070
  return {
7869
8071
  ok: false,
8072
+ status: 0,
8073
+ headers: new Headers(),
7870
8074
  error: createNetworkError(error)
7871
8075
  };
7872
8076
  } finally {
@@ -8116,12 +8320,12 @@ const applicationSchema = object({
8116
8320
  totalJobs: number$1().describe("Total number of jobs executed for this application").optional(),
8117
8321
  lastJobExecutionAt: string().datetime({ offset: true }).nullable().describe("Timestamp of the most recent job execution").optional()
8118
8322
  });
8119
- const request$17 = { body: object({
8323
+ const request$21 = { body: object({
8120
8324
  name: applicationNameSchema,
8121
8325
  applicationGroupId: cuidSchema.optional()
8122
8326
  }) };
8123
8327
  object({ data: object({ application: applicationSchema }) });
8124
- const request$16 = { query: object({
8328
+ const request$20 = { query: object({
8125
8329
  name: preprocess((val) => Array.isArray(val) ? val.join(",") : val, string().optional()),
8126
8330
  sort: _enum([
8127
8331
  "name",
@@ -8136,7 +8340,7 @@ object({
8136
8340
  data: object({ applications: array(applicationSchema) }),
8137
8341
  meta: paginationMeta
8138
8342
  });
8139
- const request$15 = {
8343
+ const request$19 = {
8140
8344
  params: object({ applicationId: cuidSchema }),
8141
8345
  body: object({
8142
8346
  name: applicationNameSchema.optional(),
@@ -8159,15 +8363,25 @@ object({
8159
8363
  createdAt: datetimeSchema,
8160
8364
  updatedAt: datetimeSchema
8161
8365
  });
8162
- const request$14 = { body: object({
8366
+ const request$18 = { body: object({
8163
8367
  applicationId: cuidSchema,
8164
8368
  name: secretNameSchema,
8165
8369
  value: secretValueSchema
8166
8370
  }) };
8167
8371
  object({ data: object({ secret: secretMetadataSchema }) });
8168
- const request$13 = { query: object({ applicationId: cuidSchema.optional() }) };
8372
+ const request$17 = {
8373
+ params: object({ name: string().min(1) }),
8374
+ query: object({ applicationId: cuidSchema })
8375
+ };
8376
+ _null();
8377
+ const request$16 = {
8378
+ params: object({ name: string().min(1) }),
8379
+ query: object({ applicationId: cuidSchema })
8380
+ };
8381
+ object({ data: object({ secret: secretMetadataSchema }) });
8382
+ const request$15 = { query: object({ applicationId: cuidSchema.optional() }) };
8169
8383
  object({ data: object({ secrets: array(secretMetadataSchema) }) });
8170
- const request$12 = {
8384
+ const request$14 = {
8171
8385
  params: object({ name: string().min(1) }),
8172
8386
  body: object({
8173
8387
  applicationId: cuidSchema,
@@ -8192,12 +8406,22 @@ const variableResponseSchema = object({
8192
8406
  createdAt: datetimeSchema,
8193
8407
  updatedAt: datetimeSchema
8194
8408
  });
8195
- const request$11 = { body: object({
8409
+ const request$13 = { body: object({
8196
8410
  applicationId: cuidSchema,
8197
8411
  name: variableNameSchema,
8198
8412
  value: variableValueSchema
8199
8413
  }) };
8200
8414
  object({ data: object({ variable: variableResponseSchema }) });
8415
+ const request$12 = {
8416
+ params: object({ name: string().min(1) }),
8417
+ query: object({ applicationId: cuidSchema })
8418
+ };
8419
+ _null();
8420
+ const request$11 = {
8421
+ params: object({ name: string().min(1) }),
8422
+ query: object({ applicationId: cuidSchema })
8423
+ };
8424
+ object({ data: object({ variable: variableResponseSchema }) });
8201
8425
  const request$10 = { query: object({ applicationId: cuidSchema }) };
8202
8426
  object({ data: object({ variables: array(variableResponseSchema) }) });
8203
8427
  const request$9 = {
@@ -8316,7 +8540,7 @@ const expertSchema = object({
8316
8540
  skills: record(skillNameSchema, skillSchema).optional().default({}),
8317
8541
  delegates: array(expertKeyFieldSchema).min(0).max(maxExpertDelegateItems).optional().default([]),
8318
8542
  tags: array(expertTagFieldSchema).min(0).max(maxExpertTagItems).optional().default([]),
8319
- minRuntimeVersion: runtimeVersionSchema.optional()
8543
+ minRuntimeVersion: runtimeVersionSchema.optional().default("v1.0")
8320
8544
  });
8321
8545
  object({
8322
8546
  scope: expertScopeSchema,
@@ -8328,14 +8552,7 @@ const expertWithMetadataSchema = expertSchema.extend({
8328
8552
  });
8329
8553
  const request$8 = { query: object({
8330
8554
  filter: string().describe("Filter by scope name (partial match)").optional(),
8331
- category: _enum([
8332
- "general",
8333
- "coding",
8334
- "research",
8335
- "writing",
8336
- "data",
8337
- "automation"
8338
- ]).describe("Filter by category").optional(),
8555
+ category: expertCategoryFieldSchema.describe("Filter by category").optional(),
8339
8556
  includeDrafts: boolean().default(false).describe("Include unpublished scopes (owner only)").optional(),
8340
8557
  take: number().min(1).max(100).default(20),
8341
8558
  skip: number().min(0).default(0)
@@ -8345,6 +8562,12 @@ object({
8345
8562
  meta: paginationMeta
8346
8563
  });
8347
8564
  const anthropicSupportModels = [
8565
+ {
8566
+ modelId: "claude-opus-4-6",
8567
+ default: false,
8568
+ provider: "anthropic",
8569
+ contextWindow: 2e5
8570
+ },
8348
8571
  {
8349
8572
  modelId: "claude-opus-4-5",
8350
8573
  default: false,
@@ -8418,6 +8641,12 @@ const googleSupportModels = [
8418
8641
  default: false,
8419
8642
  provider: "google",
8420
8643
  contextWindow: 1e6
8644
+ },
8645
+ {
8646
+ modelId: "gemini-3-flash-preview",
8647
+ default: false,
8648
+ provider: "google",
8649
+ contextWindow: 1e6
8421
8650
  }
8422
8651
  ];
8423
8652
  const openAiSupportModels = [
@@ -8468,6 +8697,24 @@ const openAiSupportModels = [
8468
8697
  default: false,
8469
8698
  provider: "openai",
8470
8699
  contextWindow: 1e6
8700
+ },
8701
+ {
8702
+ modelId: "gpt-5.1",
8703
+ default: false,
8704
+ provider: "openai",
8705
+ contextWindow: 4e5
8706
+ },
8707
+ {
8708
+ modelId: "gpt-5.2",
8709
+ default: false,
8710
+ provider: "openai",
8711
+ contextWindow: 4e5
8712
+ },
8713
+ {
8714
+ modelId: "gpt-5.2-pro",
8715
+ default: false,
8716
+ provider: "openai",
8717
+ contextWindow: 4e5
8471
8718
  }
8472
8719
  ];
8473
8720
  const deepseekSupportModels = [{
@@ -8523,6 +8770,7 @@ const jobBaseSchema = object({
8523
8770
  updatedAt: datetimeSchema,
8524
8771
  status: jobStatusSchema,
8525
8772
  currentExecutionId: cuidSchema.optional(),
8773
+ machineId: cuidSchema.nullable(),
8526
8774
  coordinatorExpertKey: expertKeyFieldSchema,
8527
8775
  query: string().min(1).max(maxExpertJobQueryLength).optional(),
8528
8776
  expert: expertWithMetadataSchema,
@@ -8584,7 +8832,7 @@ const request$5 = { query: object({
8584
8832
  expertScopeId: cuidSchema.optional(),
8585
8833
  expertDraftScopeId: cuidSchema.optional(),
8586
8834
  applicationId: cuidSchema.optional(),
8587
- statuses: preprocess((val) => typeof val === "string" ? val.split(",") : val, array(jobStatusSchema).optional()),
8835
+ statuses: preprocess((val) => typeof val === "string" ? val.split(",") : val, array(jobStatusSchema)).optional(),
8588
8836
  expertKeyFilter: string().max(100).optional()
8589
8837
  }) };
8590
8838
  object({
@@ -8619,7 +8867,8 @@ const apiCheckpointSchema = object({
8619
8867
  "stoppedByInteractiveTool",
8620
8868
  "stoppedByDelegate",
8621
8869
  "stoppedByExceededMaxSteps",
8622
- "stoppedByError"
8870
+ "stoppedByError",
8871
+ "stoppedByCancellation"
8623
8872
  ]),
8624
8873
  expert: expertSchema,
8625
8874
  delegateTo: array(delegationTargetSchema).optional(),
@@ -8671,16 +8920,7 @@ object({
8671
8920
  data: object({ checkpoints: array(apiCheckpointSchema) }),
8672
8921
  meta: paginationMeta
8673
8922
  });
8674
- const runStatusSchema = _enum([
8675
- "queued",
8676
- "processing",
8677
- "completed",
8678
- "stoppedByInteractiveTool",
8679
- "stoppedByDelegate",
8680
- "stoppedByExceededMaxSteps",
8681
- "stoppedByError"
8682
- ]);
8683
- const runSchema = object({
8923
+ const runTreeNodeSchema = object({
8684
8924
  type: literal("run"),
8685
8925
  id: cuidSchema,
8686
8926
  jobId: cuidSchema,
@@ -8689,11 +8929,14 @@ const runSchema = object({
8689
8929
  organizationId: cuidSchema,
8690
8930
  createdAt: datetimeSchema,
8691
8931
  updatedAt: datetimeSchema,
8692
- status: runStatusSchema,
8693
8932
  expertKey: expertKeyFieldSchema,
8694
8933
  expert: expertWithMetadataSchema,
8695
8934
  stepNumber: number$1().int().min(0),
8696
8935
  usage: usageSchema
8936
+ }).extend({
8937
+ lastCheckpointId: cuidSchema.nullable(),
8938
+ checkpointIds: array(cuidSchema),
8939
+ childRuns: lazy(() => array(runTreeNodeSchema))
8697
8940
  });
8698
8941
  const request$3 = {
8699
8942
  params: object({ jobId: cuidSchema }),
@@ -8701,11 +8944,12 @@ const request$3 = {
8701
8944
  sort: _enum(["createdAt", "updatedAt"]).optional(),
8702
8945
  order: _enum(["asc", "desc"]).optional(),
8703
8946
  take: number().min(1).max(100).default(20),
8704
- skip: number().min(0).default(0)
8947
+ skip: number().min(0).default(0),
8948
+ depth: number().int().min(0).max(10).default(0)
8705
8949
  })
8706
8950
  };
8707
8951
  object({
8708
- data: object({ runs: array(runSchema) }),
8952
+ data: object({ runs: array(runTreeNodeSchema) }),
8709
8953
  meta: paginationMeta
8710
8954
  });
8711
8955
  const baseUrlSchema = string().url().max(maxProviderBaseUrlLength).optional();
@@ -8810,10 +9054,7 @@ function createRunCheckpointsApi(fetcher, basePath) {
8810
9054
  async list(jobId, runId, params, options) {
8811
9055
  if (params) {
8812
9056
  const result = request$4.query.safeParse(params);
8813
- if (!result.success) return {
8814
- ok: false,
8815
- error: createValidationError(result.error)
8816
- };
9057
+ if (!result.success) return validationErrorResult(result.error);
8817
9058
  }
8818
9059
  const queryString = buildQueryString(params);
8819
9060
  return fetcher.get(`${basePath}/${jobId}/runs/${runId}/checkpoints${queryString}`, options);
@@ -8823,26 +9064,26 @@ function createRunCheckpointsApi(fetcher, basePath) {
8823
9064
  }
8824
9065
  };
8825
9066
  }
9067
+ function createListFn(fetcher, basePath) {
9068
+ return async function list(jobId, params, options) {
9069
+ if (params) {
9070
+ const result = request$3.query.safeParse(params);
9071
+ if (!result.success) return validationErrorResult(result.error);
9072
+ }
9073
+ const queryString = buildQueryString(params);
9074
+ return fetcher.get(`${basePath}/${jobId}/runs${queryString}`, options);
9075
+ };
9076
+ }
8826
9077
  function createRunsApi(fetcher, basePath) {
8827
9078
  return {
8828
- async list(jobId, params, options) {
8829
- if (params) {
8830
- const result = request$3.query.safeParse(params);
8831
- if (!result.success) return {
8832
- ok: false,
8833
- error: createValidationError(result.error)
8834
- };
8835
- }
8836
- const queryString = buildQueryString(params);
8837
- return fetcher.get(`${basePath}/${jobId}/runs${queryString}`, options);
8838
- },
9079
+ list: createListFn(fetcher, basePath),
8839
9080
  async get(jobId, runId, options) {
8840
9081
  return fetcher.get(`${basePath}/${jobId}/runs/${runId}`, options);
8841
9082
  },
8842
9083
  checkpoints: createRunCheckpointsApi(fetcher, basePath)
8843
9084
  };
8844
9085
  }
8845
- const BASE_PATH$5 = "/api/v1/jobs";
9086
+ const BASE_PATH$6 = "/api/v1/jobs";
8846
9087
  /**
8847
9088
  * Error thrown when stream ends abnormally.
8848
9089
  */
@@ -8874,168 +9115,152 @@ function createJobsApi(fetcher) {
8874
9115
  async list(params, options) {
8875
9116
  if (params) {
8876
9117
  const result = request$5.query.safeParse(params);
8877
- if (!result.success) return {
8878
- ok: false,
8879
- error: createValidationError(result.error)
8880
- };
9118
+ if (!result.success) return validationErrorResult(result.error);
8881
9119
  }
8882
9120
  const queryString = buildQueryString(params);
8883
- return fetcher.get(`${BASE_PATH$5}${queryString}`, options);
9121
+ return fetcher.get(`${BASE_PATH$6}${queryString}`, options);
8884
9122
  },
8885
9123
  async get(id, options) {
8886
- return fetcher.get(`${BASE_PATH$5}/${id}`, options);
9124
+ return fetcher.get(`${BASE_PATH$6}/${id}`, options);
8887
9125
  },
8888
9126
  async start(input, options) {
8889
9127
  const result = request$6.body.safeParse(input);
8890
- if (!result.success) return {
8891
- ok: false,
8892
- error: createValidationError(result.error)
8893
- };
8894
- return fetcher.post(BASE_PATH$5, input, options);
9128
+ if (!result.success) return validationErrorResult(result.error);
9129
+ return fetcher.post(BASE_PATH$6, input, options);
8895
9130
  },
8896
9131
  async continue(id, input, options) {
8897
9132
  const result = request$7.body.safeParse(input);
8898
- if (!result.success) return {
8899
- ok: false,
8900
- error: createValidationError(result.error)
8901
- };
8902
- return fetcher.post(`${BASE_PATH$5}/${id}/continue`, input, options);
9133
+ if (!result.success) return validationErrorResult(result.error);
9134
+ return fetcher.post(`${BASE_PATH$6}/${id}/continue`, input, options);
8903
9135
  },
8904
9136
  async cancel(id, options) {
8905
- return fetcher.post(`${BASE_PATH$5}/${id}/cancel`, {}, options);
9137
+ return fetcher.post(`${BASE_PATH$6}/${id}/cancel`, {}, options);
8906
9138
  },
8907
- async *stream(id, options) {
8908
- const result = await fetcher.getStream(`${BASE_PATH$5}/${id}/stream`, options);
8909
- if (!result.ok) throw new StreamConnectionError(result.error.message);
8910
- const reader = result.data.getReader();
8911
- try {
8912
- for await (const sseEvent of parseSSEEvents(reader)) if (sseEvent.event === "message") yield sseEvent.data;
8913
- else if (sseEvent.event === "error" && isErrorEventData(sseEvent.data)) throw new StreamError(sseEvent.data.type, sseEvent.data.jobId, sseEvent.data.message);
8914
- else if (sseEvent.event === "complete" && isCompleteEventData(sseEvent.data)) return;
8915
- } catch (error) {
8916
- if (error instanceof StreamError || error instanceof StreamConnectionError) throw error;
8917
- if (error instanceof DOMException && error.name === "AbortError") throw error;
8918
- throw new StreamConnectionError(error instanceof Error ? error.message : "Stream read error");
9139
+ async stream(id, options) {
9140
+ const result = await fetcher.getStream(`${BASE_PATH$6}/${id}/stream`, options);
9141
+ if (!result.ok) return result;
9142
+ async function* createEventGenerator(reader) {
9143
+ try {
9144
+ for await (const sseEvent of parseSSEEvents(reader)) if (sseEvent.event === "message") yield sseEvent.data;
9145
+ else if (sseEvent.event === "error" && isErrorEventData(sseEvent.data)) throw new StreamError(sseEvent.data.type, sseEvent.data.jobId, sseEvent.data.message);
9146
+ else if (sseEvent.event === "complete" && isCompleteEventData(sseEvent.data)) return;
9147
+ } catch (error) {
9148
+ if (error instanceof StreamError || error instanceof StreamConnectionError) throw error;
9149
+ if (error instanceof DOMException && error.name === "AbortError") throw error;
9150
+ throw new StreamConnectionError(error instanceof Error ? error.message : "Stream read error");
9151
+ }
8919
9152
  }
9153
+ const reader = result.data.getReader();
9154
+ return {
9155
+ ok: true,
9156
+ status: result.status,
9157
+ headers: result.headers,
9158
+ data: { events: createEventGenerator(reader) }
9159
+ };
8920
9160
  },
8921
- runs: createRunsApi(fetcher, BASE_PATH$5)
9161
+ runs: createRunsApi(fetcher, BASE_PATH$6)
8922
9162
  };
8923
9163
  }
8924
- const BASE_PATH$4 = "/api/v1/applications";
9164
+ const BASE_PATH$5 = "/api/v1/applications";
8925
9165
  function createApplicationsApi(fetcher) {
8926
9166
  return {
8927
9167
  async list(params, options) {
8928
9168
  if (params) {
8929
- const result = request$16.query.safeParse(params);
8930
- if (!result.success) return {
8931
- ok: false,
8932
- error: createValidationError(result.error)
8933
- };
9169
+ const result = request$20.query.safeParse(params);
9170
+ if (!result.success) return validationErrorResult(result.error);
8934
9171
  }
8935
9172
  const queryString = buildQueryString(params);
8936
- return fetcher.get(`${BASE_PATH$4}${queryString}`, options);
9173
+ return fetcher.get(`${BASE_PATH$5}${queryString}`, options);
8937
9174
  },
8938
9175
  async get(id, options) {
8939
- return fetcher.get(`${BASE_PATH$4}/${id}`, options);
9176
+ return fetcher.get(`${BASE_PATH$5}/${id}`, options);
8940
9177
  },
8941
9178
  async create(input, options) {
8942
- const result = request$17.body.safeParse(input);
8943
- if (!result.success) return {
8944
- ok: false,
8945
- error: createValidationError(result.error)
8946
- };
8947
- return fetcher.post(BASE_PATH$4, input, options);
9179
+ const result = request$21.body.safeParse(input);
9180
+ if (!result.success) return validationErrorResult(result.error);
9181
+ return fetcher.post(BASE_PATH$5, input, options);
8948
9182
  },
8949
9183
  async update(id, input, options) {
8950
- const result = request$15.body.safeParse(input);
8951
- if (!result.success) return {
8952
- ok: false,
8953
- error: createValidationError(result.error)
8954
- };
8955
- return fetcher.post(`${BASE_PATH$4}/${id}`, input, options);
9184
+ const result = request$19.body.safeParse(input);
9185
+ if (!result.success) return validationErrorResult(result.error);
9186
+ return fetcher.post(`${BASE_PATH$5}/${id}`, input, options);
8956
9187
  },
8957
9188
  async delete(id, options) {
8958
- return fetcher.delete(`${BASE_PATH$4}/${id}`, options);
9189
+ return fetcher.delete(`${BASE_PATH$5}/${id}`, options);
8959
9190
  }
8960
9191
  };
8961
9192
  }
8962
- const BASE_PATH$3 = "/api/v1/env/secrets";
9193
+ const BASE_PATH$4 = "/api/v1/env/secrets";
8963
9194
  function createSecretsApi(fetcher) {
8964
9195
  return {
8965
9196
  async list(params, options) {
8966
9197
  if (params) {
8967
- const result = request$13.query.safeParse(params);
8968
- if (!result.success) return {
8969
- ok: false,
8970
- error: createValidationError(result.error)
8971
- };
9198
+ const result = request$15.query.safeParse(params);
9199
+ if (!result.success) return validationErrorResult(result.error);
8972
9200
  }
8973
9201
  const queryString = buildQueryString(params);
8974
- return fetcher.get(`${BASE_PATH$3}${queryString}`, options);
9202
+ return fetcher.get(`${BASE_PATH$4}${queryString}`, options);
8975
9203
  },
8976
- async get(name, options) {
9204
+ async get(name, params, options) {
9205
+ const result = request$16.query.safeParse(params);
9206
+ if (!result.success) return validationErrorResult(result.error);
8977
9207
  const encodedName = encodeURIComponent(name);
8978
- return fetcher.get(`${BASE_PATH$3}/${encodedName}`, options);
9208
+ const queryString = buildQueryString(params);
9209
+ return fetcher.get(`${BASE_PATH$4}/${encodedName}${queryString}`, options);
8979
9210
  },
8980
9211
  async create(input, options) {
8981
- const result = request$14.body.safeParse(input);
8982
- if (!result.success) return {
8983
- ok: false,
8984
- error: createValidationError(result.error)
8985
- };
8986
- return fetcher.post(BASE_PATH$3, input, options);
9212
+ const result = request$18.body.safeParse(input);
9213
+ if (!result.success) return validationErrorResult(result.error);
9214
+ return fetcher.post(BASE_PATH$4, input, options);
8987
9215
  },
8988
9216
  async update(name, input, options) {
8989
- const result = request$12.body.safeParse(input);
8990
- if (!result.success) return {
8991
- ok: false,
8992
- error: createValidationError(result.error)
8993
- };
9217
+ const result = request$14.body.safeParse(input);
9218
+ if (!result.success) return validationErrorResult(result.error);
8994
9219
  const encodedName = encodeURIComponent(name);
8995
- return fetcher.put(`${BASE_PATH$3}/${encodedName}`, input, options);
9220
+ return fetcher.post(`${BASE_PATH$4}/${encodedName}`, input, options);
8996
9221
  },
8997
- async delete(name, options) {
9222
+ async delete(name, params, options) {
9223
+ const result = request$17.query.safeParse(params);
9224
+ if (!result.success) return validationErrorResult(result.error);
8998
9225
  const encodedName = encodeURIComponent(name);
8999
- return fetcher.deleteNoContent(`${BASE_PATH$3}/${encodedName}`, options);
9226
+ const queryString = buildQueryString(params);
9227
+ return fetcher.deleteNoContent(`${BASE_PATH$4}/${encodedName}${queryString}`, options);
9000
9228
  }
9001
9229
  };
9002
9230
  }
9003
- const BASE_PATH$2 = "/api/v1/env/variables";
9231
+ const BASE_PATH$3 = "/api/v1/env/variables";
9004
9232
  function createVariablesApi(fetcher) {
9005
9233
  return {
9006
9234
  async list(params, options) {
9007
9235
  const result = request$10.query.safeParse(params);
9008
- if (!result.success) return {
9009
- ok: false,
9010
- error: createValidationError(result.error)
9011
- };
9236
+ if (!result.success) return validationErrorResult(result.error);
9012
9237
  const queryString = buildQueryString(params);
9013
- return fetcher.get(`${BASE_PATH$2}${queryString}`, options);
9238
+ return fetcher.get(`${BASE_PATH$3}${queryString}`, options);
9014
9239
  },
9015
- async get(name, options) {
9240
+ async get(name, params, options) {
9241
+ const result = request$11.query.safeParse(params);
9242
+ if (!result.success) return validationErrorResult(result.error);
9016
9243
  const encodedName = encodeURIComponent(name);
9017
- return fetcher.get(`${BASE_PATH$2}/${encodedName}`, options);
9244
+ const queryString = buildQueryString(params);
9245
+ return fetcher.get(`${BASE_PATH$3}/${encodedName}${queryString}`, options);
9018
9246
  },
9019
9247
  async create(input, options) {
9020
- const result = request$11.body.safeParse(input);
9021
- if (!result.success) return {
9022
- ok: false,
9023
- error: createValidationError(result.error)
9024
- };
9025
- return fetcher.post(BASE_PATH$2, input, options);
9248
+ const result = request$13.body.safeParse(input);
9249
+ if (!result.success) return validationErrorResult(result.error);
9250
+ return fetcher.post(BASE_PATH$3, input, options);
9026
9251
  },
9027
9252
  async update(name, input, options) {
9028
9253
  const result = request$9.body.safeParse(input);
9029
- if (!result.success) return {
9030
- ok: false,
9031
- error: createValidationError(result.error)
9032
- };
9254
+ if (!result.success) return validationErrorResult(result.error);
9033
9255
  const encodedName = encodeURIComponent(name);
9034
- return fetcher.put(`${BASE_PATH$2}/${encodedName}`, input, options);
9256
+ return fetcher.post(`${BASE_PATH$3}/${encodedName}`, input, options);
9035
9257
  },
9036
- async delete(name, options) {
9258
+ async delete(name, params, options) {
9259
+ const result = request$12.query.safeParse(params);
9260
+ if (!result.success) return validationErrorResult(result.error);
9037
9261
  const encodedName = encodeURIComponent(name);
9038
- return fetcher.deleteNoContent(`${BASE_PATH$2}/${encodedName}`, options);
9262
+ const queryString = buildQueryString(params);
9263
+ return fetcher.deleteNoContent(`${BASE_PATH$3}/${encodedName}${queryString}`, options);
9039
9264
  }
9040
9265
  };
9041
9266
  }
@@ -9051,46 +9276,49 @@ function createVersionsApi(fetcher, basePath) {
9051
9276
  return fetcher.get(`${basePath}/${encodedScopeName}/versions`, options);
9052
9277
  } };
9053
9278
  }
9054
- const BASE_PATH$1 = "/api/v1/experts";
9279
+ const BASE_PATH$2 = "/api/v1/experts";
9055
9280
  function createExpertsApi(fetcher) {
9056
9281
  return {
9057
9282
  async list(params, options) {
9058
9283
  if (params) {
9059
9284
  const result = request$8.query.safeParse(params);
9060
- if (!result.success) return {
9061
- ok: false,
9062
- error: createValidationError(result.error)
9063
- };
9285
+ if (!result.success) return validationErrorResult(result.error);
9064
9286
  }
9065
9287
  const queryString = buildQueryString(params);
9066
- return fetcher.get(`${BASE_PATH$1}${queryString}`, options);
9288
+ return fetcher.get(`${BASE_PATH$2}${queryString}`, options);
9067
9289
  },
9068
9290
  async get(key, options) {
9069
9291
  const encodedKey = encodeURIComponent(key);
9070
- return fetcher.get(`${BASE_PATH$1}/${encodedKey}`, options);
9292
+ return fetcher.get(`${BASE_PATH$2}/${encodedKey}`, options);
9071
9293
  },
9072
9294
  async getFeatured(options) {
9073
- return fetcher.get(`${BASE_PATH$1}/featured`, options);
9295
+ return fetcher.get(`${BASE_PATH$2}/featured`, options);
9074
9296
  },
9075
9297
  async getMeta(key, options) {
9076
9298
  const encodedKey = encodeURIComponent(key);
9077
- return fetcher.get(`${BASE_PATH$1}/${encodedKey}/meta`, options);
9299
+ return fetcher.get(`${BASE_PATH$2}/${encodedKey}/meta`, options);
9078
9300
  },
9079
9301
  async publish(scopeName, options) {
9080
9302
  const encodedScopeName = encodeURIComponent(scopeName);
9081
- return fetcher.post(`${BASE_PATH$1}/${encodedScopeName}/publish`, {}, options);
9303
+ return fetcher.post(`${BASE_PATH$2}/${encodedScopeName}/publish`, {}, options);
9082
9304
  },
9083
9305
  async unpublish(scopeName, options) {
9084
9306
  const encodedScopeName = encodeURIComponent(scopeName);
9085
- return fetcher.post(`${BASE_PATH$1}/${encodedScopeName}/unpublish`, {}, options);
9307
+ return fetcher.post(`${BASE_PATH$2}/${encodedScopeName}/unpublish`, {}, options);
9086
9308
  },
9087
9309
  async yank(key, options) {
9088
9310
  const encodedKey = encodeURIComponent(key);
9089
- return fetcher.delete(`${BASE_PATH$1}/${encodedKey}`, options);
9311
+ return fetcher.delete(`${BASE_PATH$2}/${encodedKey}`, options);
9090
9312
  },
9091
- versions: createVersionsApi(fetcher, BASE_PATH$1)
9313
+ versions: createVersionsApi(fetcher, BASE_PATH$2)
9092
9314
  };
9093
9315
  }
9316
+ const BASE_PATH$1 = "/api/v1/organizations";
9317
+ function createOrganizationsApi(fetcher) {
9318
+ return { async getCurrent(options) {
9319
+ return fetcher.get(`${BASE_PATH$1}/current`, options);
9320
+ } };
9321
+ }
9094
9322
  const BASE_PATH = "/api/v1/applications";
9095
9323
  function createProviderSettingsApi(fetcher) {
9096
9324
  return {
@@ -9103,18 +9331,12 @@ function createProviderSettingsApi(fetcher) {
9103
9331
  },
9104
9332
  async create(applicationId, input, options) {
9105
9333
  const result = request$1.body.safeParse(input);
9106
- if (!result.success) return {
9107
- ok: false,
9108
- error: createValidationError(result.error)
9109
- };
9334
+ if (!result.success) return validationErrorResult(result.error);
9110
9335
  return fetcher.post(`${BASE_PATH}/${applicationId}/provider_settings`, input, options);
9111
9336
  },
9112
9337
  async update(applicationId, provider, input, options) {
9113
9338
  const result = request.body.safeParse(input);
9114
- if (!result.success) return {
9115
- ok: false,
9116
- error: createValidationError(result.error)
9117
- };
9339
+ if (!result.success) return validationErrorResult(result.error);
9118
9340
  const encodedProvider = encodeURIComponent(provider);
9119
9341
  return fetcher.post(`${BASE_PATH}/${applicationId}/provider_settings/${encodedProvider}`, input, options);
9120
9342
  },
@@ -9128,10 +9350,7 @@ function createProviderSettingsApi(fetcher) {
9128
9350
  },
9129
9351
  async createApiKey(applicationId, provider, input, options) {
9130
9352
  const result = request$2.body.safeParse(input);
9131
- if (!result.success) return {
9132
- ok: false,
9133
- error: createValidationError(result.error)
9134
- };
9353
+ if (!result.success) return validationErrorResult(result.error);
9135
9354
  const encodedProvider = encodeURIComponent(provider);
9136
9355
  return fetcher.post(`${BASE_PATH}/${applicationId}/provider_settings/${encodedProvider}/api_keys`, input, options);
9137
9356
  },
@@ -9149,10 +9368,11 @@ function createApiClient(config) {
9149
9368
  env: createEnvApi(fetcher),
9150
9369
  jobs: createJobsApi(fetcher),
9151
9370
  experts: createExpertsApi(fetcher),
9371
+ organizations: createOrganizationsApi(fetcher),
9152
9372
  providerSettings: createProviderSettingsApi(fetcher)
9153
9373
  };
9154
9374
  }
9155
9375
 
9156
9376
  //#endregion
9157
- export { object as $, runCommandInputSchema as A, createId as At, _instanceof as B, skipDelegates as C, $constructor as Ct, stopRunByError as D, defaultMaxRetries as Dt, stopRunByDelegate as E, PerstackError as Et, expertSchema$1 as F, custom as G, any as H, checkpointSchema as I, lazy as J, discriminatedUnion as K, number as L, perstackConfigSchema as M, lockfileSchema as N, stopRunByExceededMaxSteps as O, defaultPerstackApiBaseUrl as Ot, jobSchema$1 as P, number$1 as Q, ZodOptional as R, runSettingSchema as S, normalizeParams as St, startRun as T, knownModels as Tt, array as U, _null as V, boolean$1 as W, looseObject as X, literal as Y, never as Z, proceedToInteractiveTools as _, parseAsync$1 as _t, getFilteredEnv as a, tuple as at, retry as b, clone as bt, createGeneralToolActivity as c, url as ct, completeRun as d, toJSONSchema as dt, optional as et, continueToNextStep as f, describe$1 as ft, finishToolCall as g, parse$1 as gt, finishMcpTools as h, $ZodType as ht, validateEventFilter as i, string as it, startCommandInputSchema as j, stopRunByInteractiveTool as k, defaultTimeout as kt, attemptCompletion as l, safeParseAsync as lt, createStreamingEvent as m, $ZodObject as mt, parseWithFriendlyError as n, record as nt, BASE_SKILL_PREFIX as o, union as ot, createRuntimeEvent as p, meta$1 as pt, intersection as q, createFilteredEventListener as r, strictObject as rt, createBaseToolActivity as s, unknown as st, createApiClient as t, preprocess as tt, callTools as u, datetime as ut, resolveToolResults as v, safeParse$1 as vt, startGeneration as w, NEVER as wt, runParamsSchema as x, defineLazy as xt, resumeFromStop as y, safeParseAsync$1 as yt, _enum as z };
9158
- //# sourceMappingURL=dist-Bww5wViz.js.map
9377
+ export { never as $, startCommandInputSchema as A, defaultPerstackApiBaseUrl as At, ZodOptional as B, skipDelegates as C, defineLazy as Ct, stopRunByError as D, knownModels as Dt, stopRunByDelegate as E, NEVER as Et, isCoordinatorExpert as F, array as G, _instanceof as H, validateDelegation as I, discriminatedUnion as J, boolean$1 as K, checkpointSchema as L, lockfileSchema as M, createId as Mt, jobSchema$1 as N, stopRunByInteractiveTool as O, PerstackError as Ot, expertSchema$1 as P, looseObject as Q, number as R, runSettingSchema as S, clone as St, startRun as T, $constructor as Tt, _null as U, _enum as V, any as W, lazy as X, intersection as Y, literal as Z, proceedToInteractiveTools as _, $ZodType as _t, getFilteredEnv as a, strictObject as at, retry as b, safeParse$1 as bt, createGeneralToolActivity as c, union as ct, continueToNextStep as d, safeParseAsync as dt, number$1 as et, createRuntimeEvent as f, datetime as ft, parseExpertKey as g, $ZodObject as gt, finishToolCall as h, meta$1 as ht, validateEventFilter as i, record as it, perstackConfigSchema as j, defaultTimeout as jt, runCommandInputSchema as k, defaultMaxRetries as kt, callTools as l, unknown as lt, finishMcpTools as m, describe$1 as mt, parseWithFriendlyError as n, optional as nt, BASE_SKILL_PREFIX as o, string as ot, createStreamingEvent as p, toJSONSchema as pt, custom as q, createFilteredEventListener as r, preprocess as rt, createBaseToolActivity as s, tuple as st, createApiClient as t, object as tt, completeRun as u, url as ut, resolveToolResults as v, parse$1 as vt, startGeneration as w, normalizeParams as wt, runParamsSchema as x, safeParseAsync$1 as xt, resumeFromStop as y, parseAsync$1 as yt, ZodIssueCode as z };
9378
+ //# sourceMappingURL=dist-BTAd9SVm.js.map