@runtypelabs/sdk 5.9.0 → 5.10.0

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/index.cjs CHANGED
@@ -2125,6 +2125,31 @@ function resolveBatchExecutionId(pausedTools) {
2125
2125
  return "";
2126
2126
  }
2127
2127
 
2128
+ // src/content-hash.ts
2129
+ function isPlainObject(value) {
2130
+ return value !== null && typeof value === "object" && !Array.isArray(value);
2131
+ }
2132
+ function normalizeValue(value) {
2133
+ if (Array.isArray(value)) {
2134
+ return value.map((item) => normalizeValue(item));
2135
+ }
2136
+ if (isPlainObject(value)) {
2137
+ const normalized = {};
2138
+ for (const key of Object.keys(value).sort()) {
2139
+ const entry = value[key];
2140
+ if (entry === void 0 || entry === null) continue;
2141
+ normalized[key] = normalizeValue(entry);
2142
+ }
2143
+ return normalized;
2144
+ }
2145
+ return value;
2146
+ }
2147
+ async function sha256Hex(serialized) {
2148
+ const encoded = new TextEncoder().encode(serialized);
2149
+ const hashBuffer = await crypto.subtle.digest("SHA-256", encoded);
2150
+ return Array.from(new Uint8Array(hashBuffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
2151
+ }
2152
+
2128
2153
  // src/evals-ensure.ts
2129
2154
  var CHECK_GRADER_KINDS = /* @__PURE__ */ new Set([
2130
2155
  "contains",
@@ -2343,9 +2368,6 @@ var DEFINE_EVAL_TOP_LEVEL_KEYS = /* @__PURE__ */ new Set([
2343
2368
  "virtual"
2344
2369
  ]);
2345
2370
  var DEFINE_EVAL_CASE_KEYS = /* @__PURE__ */ new Set(["name", "input", "expected", "expect"]);
2346
- function isPlainObject(value) {
2347
- return value !== null && typeof value === "object" && !Array.isArray(value);
2348
- }
2349
2371
  function normalizeTarget(target) {
2350
2372
  if (!isPlainObject(target)) {
2351
2373
  throw new Error('defineEval requires a "target" object: { flow: name } or { agent: name }');
@@ -2490,10 +2512,7 @@ async function computeEvalContentHash(definition) {
2490
2512
  expect: c.expect.map((g) => normalizeForHash(g))
2491
2513
  }))
2492
2514
  };
2493
- const serialized = JSON.stringify(canonical);
2494
- const encoded = new TextEncoder().encode(serialized);
2495
- const hashBuffer = await crypto.subtle.digest("SHA-256", encoded);
2496
- return Array.from(new Uint8Array(hashBuffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
2515
+ return sha256Hex(JSON.stringify(canonical));
2497
2516
  }
2498
2517
  var serverHashMemo = /* @__PURE__ */ new WeakMap();
2499
2518
  function memoFor(client) {
@@ -2540,11 +2559,8 @@ async function runEvalSuite(client, input) {
2540
2559
  }
2541
2560
 
2542
2561
  // src/flows-ensure.ts
2543
- function isPlainObject2(value) {
2544
- return value !== null && typeof value === "object" && !Array.isArray(value);
2545
- }
2546
2562
  function normalizeConfigForHash(config) {
2547
- if (!isPlainObject2(config)) return {};
2563
+ if (!isPlainObject(config)) return {};
2548
2564
  const normalized = {};
2549
2565
  for (const key of Object.keys(config).sort()) {
2550
2566
  const value = config[key];
@@ -2565,7 +2581,7 @@ function normalizeConfigForHash(config) {
2565
2581
  return normalized;
2566
2582
  }
2567
2583
  function normalizeStepForHash(step) {
2568
- const stepObj = isPlainObject2(step) ? step : {};
2584
+ const stepObj = isPlainObject(step) ? step : {};
2569
2585
  return {
2570
2586
  type: typeof stepObj.type === "string" ? stepObj.type : "",
2571
2587
  name: typeof stepObj.name === "string" ? stepObj.name : "",
@@ -2577,14 +2593,11 @@ function normalizeStepForHash(step) {
2577
2593
  }
2578
2594
  async function computeFlowContentHash(steps) {
2579
2595
  const normalized = [...steps].sort((a, b) => {
2580
- const orderA = isPlainObject2(a) && typeof a.order === "number" ? a.order : 0;
2581
- const orderB = isPlainObject2(b) && typeof b.order === "number" ? b.order : 0;
2596
+ const orderA = isPlainObject(a) && typeof a.order === "number" ? a.order : 0;
2597
+ const orderB = isPlainObject(b) && typeof b.order === "number" ? b.order : 0;
2582
2598
  return orderA - orderB;
2583
2599
  }).map(normalizeStepForHash);
2584
- const serialized = JSON.stringify(normalized);
2585
- const encoded = new TextEncoder().encode(serialized);
2586
- const hashBuffer = await crypto.subtle.digest("SHA-256", encoded);
2587
- return Array.from(new Uint8Array(hashBuffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
2600
+ return sha256Hex(JSON.stringify(normalized));
2588
2601
  }
2589
2602
  var DEFINE_FLOW_TOP_LEVEL_KEYS = /* @__PURE__ */ new Set(["name", "steps", "evals"]);
2590
2603
  var DEFINE_FLOW_STEP_KEYS = /* @__PURE__ */ new Set([
@@ -2607,27 +2620,27 @@ function collectStepNonPortableToolRefs(config, path) {
2607
2620
  });
2608
2621
  };
2609
2622
  const scanKeys = (value, subPath) => {
2610
- if (!isPlainObject2(value)) return;
2623
+ if (!isPlainObject(value)) return;
2611
2624
  for (const key of Object.keys(value)) {
2612
2625
  if (isAccountScoped(key)) found.push(`${subPath}.${key}`);
2613
2626
  }
2614
2627
  };
2615
- if (isPlainObject2(tools)) {
2628
+ if (isPlainObject(tools)) {
2616
2629
  scanArray(tools.toolIds, `${path}.tools.toolIds`);
2617
2630
  scanKeys(tools.toolConfigs, `${path}.tools.toolConfigs`);
2618
2631
  scanKeys(tools.perToolLimits, `${path}.tools.perToolLimits`);
2619
- if (isPlainObject2(tools.approval)) {
2632
+ if (isPlainObject(tools.approval)) {
2620
2633
  scanArray(tools.approval.require, `${path}.tools.approval.require`);
2621
2634
  }
2622
- if (isPlainObject2(tools.subagentConfig)) {
2635
+ if (isPlainObject(tools.subagentConfig)) {
2623
2636
  scanArray(tools.subagentConfig.toolPool, `${path}.tools.subagentConfig.toolPool`);
2624
2637
  }
2625
- if (isPlainObject2(tools.codeModeConfig)) {
2638
+ if (isPlainObject(tools.codeModeConfig)) {
2626
2639
  scanArray(tools.codeModeConfig.toolPool, `${path}.tools.codeModeConfig.toolPool`);
2627
2640
  }
2628
2641
  if (Array.isArray(tools.runtimeTools)) {
2629
2642
  tools.runtimeTools.forEach((runtimeTool, i) => {
2630
- if (!isPlainObject2(runtimeTool) || !isPlainObject2(runtimeTool.config)) return;
2643
+ if (!isPlainObject(runtimeTool) || !isPlainObject(runtimeTool.config)) return;
2631
2644
  const base = `${path}.tools.runtimeTools[${i}].config`;
2632
2645
  const rtConfig = runtimeTool.config;
2633
2646
  if (runtimeTool.toolType === "subagent" && isRawId(rtConfig.agentId, "agent_")) {
@@ -2648,7 +2661,7 @@ function collectStepNonPortableToolRefs(config, path) {
2648
2661
  const nested = config[branch];
2649
2662
  if (!Array.isArray(nested)) continue;
2650
2663
  nested.forEach((nestedStep, i) => {
2651
- if (isPlainObject2(nestedStep) && isPlainObject2(nestedStep.config)) {
2664
+ if (isPlainObject(nestedStep) && isPlainObject(nestedStep.config)) {
2652
2665
  found.push(
2653
2666
  ...collectStepNonPortableToolRefs(nestedStep.config, `${path}.${branch}[${i}].config`)
2654
2667
  );
@@ -2674,7 +2687,7 @@ function defineFlow(input) {
2674
2687
  throw new Error('defineFlow requires a non-empty "steps" array');
2675
2688
  }
2676
2689
  const steps = input.steps.map((step, index) => {
2677
- if (!isPlainObject2(step)) {
2690
+ if (!isPlainObject(step)) {
2678
2691
  throw new Error(`defineFlow: steps[${index}] must be an object`);
2679
2692
  }
2680
2693
  if (typeof step.type !== "string" || step.type.length === 0) {
@@ -2689,7 +2702,7 @@ function defineFlow(input) {
2689
2702
  `defineFlow: steps[${index}] has unknown field(s): ${unknownStepKeys.join(", ")}. Allowed step fields are type, name, order, enabled, when, config. (Step ids are server artifacts and not part of a portable definition.)`
2690
2703
  );
2691
2704
  }
2692
- const config = isPlainObject2(step.config) ? step.config : void 0;
2705
+ const config = isPlainObject(step.config) ? step.config : void 0;
2693
2706
  if (config) {
2694
2707
  const nonPortable = collectStepNonPortableToolRefs(config, `steps[${index}].config`);
2695
2708
  if (nonPortable.length > 0) {
@@ -2716,7 +2729,7 @@ function defineFlow(input) {
2716
2729
  }
2717
2730
  const seenEvalNames = /* @__PURE__ */ new Set();
2718
2731
  evals = input.evals.map((evalInput, i) => {
2719
- if (!isPlainObject2(evalInput)) {
2732
+ if (!isPlainObject(evalInput)) {
2720
2733
  throw new Error(`defineFlow: evals[${i}] must be an object`);
2721
2734
  }
2722
2735
  if (evalInput.virtual === true) {
@@ -2780,7 +2793,7 @@ function parseRequestError(err) {
2780
2793
  }
2781
2794
  function toConflictError(err) {
2782
2795
  const { status, body } = parseRequestError(err);
2783
- if (status !== 409 || !isPlainObject2(body)) return null;
2796
+ if (status !== 409 || !isPlainObject(body)) return null;
2784
2797
  const code = body.code;
2785
2798
  if (code !== "external_modification" && code !== "remote_changed") return null;
2786
2799
  return new FlowEnsureConflictError(
@@ -4075,6 +4088,18 @@ var EvalSuitesNamespace = class {
4075
4088
  cases
4076
4089
  });
4077
4090
  }
4091
+ /**
4092
+ * Capture a test case from a real agent run ("fork here and test the next
4093
+ * step"): freezes the run's conversation history up to a fork point, attaches
4094
+ * every recorded tool result as an editable mock, and saves it with origin
4095
+ * `saved_from_run`. Capture only — reads the run, never re-executes it.
4096
+ */
4097
+ async addCaseFromExecution(suiteId, input) {
4098
+ return this.getClient().post(
4099
+ `/eval/suites/${suiteId}/cases/from-execution`,
4100
+ input
4101
+ );
4102
+ }
4078
4103
  /** Edit, enable, or disable a test case. */
4079
4104
  async updateCase(suiteId, caseId, input) {
4080
4105
  return this.getClient().patch(
@@ -4261,6 +4286,30 @@ var EvalsNamespace = class {
4261
4286
  async pull(name) {
4262
4287
  return pullEval(this.getClient(), name);
4263
4288
  }
4289
+ /**
4290
+ * Split one plain-language AI-grader criterion carrying several obligations
4291
+ * into focused, independently judgeable sub-checks. Authoring assist only:
4292
+ * nothing is persisted — review the proposal, then save each accepted
4293
+ * sub-check as its own AI grader row. A single returned sub-check means the
4294
+ * criterion is already focused.
4295
+ *
4296
+ * @example
4297
+ * ```typescript
4298
+ * const { subChecks } = await Runtype.evals.decomposeCriteria(
4299
+ * 'Confirms the order number before issuing a refund, and never promises a delivery date.'
4300
+ * )
4301
+ * // In a defineEval suite, each accepted sub-check becomes its own judge row:
4302
+ * const graders = subChecks.map((s) => judge(s.criteria))
4303
+ * ```
4304
+ */
4305
+ async decomposeCriteria(criteria) {
4306
+ if (typeof criteria !== "string" || criteria.trim().length === 0) {
4307
+ throw new Error("decomposeCriteria() requires non-empty criteria");
4308
+ }
4309
+ return this.getClient().post("/eval/graders/decompose", {
4310
+ criteria
4311
+ });
4312
+ }
4264
4313
  /**
4265
4314
  * Run an eval suite synchronously and return the suite score + per-case grader
4266
4315
  * outcomes — the executing counterpart of `ensure`, powering the `runtype
@@ -4413,42 +4462,21 @@ var PromptsNamespace = class {
4413
4462
  };
4414
4463
 
4415
4464
  // src/skills-ensure.ts
4416
- function isPlainObject3(value) {
4417
- return value !== null && typeof value === "object" && !Array.isArray(value);
4418
- }
4419
- function normalizeValue(value) {
4420
- if (Array.isArray(value)) {
4421
- return value.map((item) => normalizeValue(item));
4422
- }
4423
- if (isPlainObject3(value)) {
4424
- const normalized = {};
4425
- for (const key of Object.keys(value).sort()) {
4426
- const entry = value[key];
4427
- if (entry === void 0 || entry === null) continue;
4428
- normalized[key] = normalizeValue(entry);
4429
- }
4430
- return normalized;
4431
- }
4432
- return value;
4433
- }
4434
4465
  function normalizeSkillDefinition(definition) {
4435
- const manifest = isPlainObject3(definition.manifest) ? definition.manifest : {};
4436
- const rawFrontmatter = isPlainObject3(manifest.frontmatter) ? manifest.frontmatter : {};
4466
+ const manifest = isPlainObject(definition.manifest) ? definition.manifest : {};
4467
+ const rawFrontmatter = isPlainObject(manifest.frontmatter) ? manifest.frontmatter : {};
4437
4468
  const frontmatterWithoutName = {};
4438
4469
  for (const key of Object.keys(rawFrontmatter)) {
4439
4470
  if (key === "name") continue;
4440
4471
  frontmatterWithoutName[key] = rawFrontmatter[key];
4441
4472
  }
4442
4473
  const frontmatter = normalizeValue(frontmatterWithoutName);
4443
- const runtype = isPlainObject3(manifest.runtype) ? normalizeValue(manifest.runtype) : {};
4474
+ const runtype = isPlainObject(manifest.runtype) ? normalizeValue(manifest.runtype) : {};
4444
4475
  const body = typeof manifest.body === "string" ? manifest.body : "";
4445
4476
  return { frontmatter, runtype, body };
4446
4477
  }
4447
4478
  async function computeSkillContentHash(definition) {
4448
- const serialized = JSON.stringify(normalizeSkillDefinition(definition));
4449
- const encoded = new TextEncoder().encode(serialized);
4450
- const hashBuffer = await crypto.subtle.digest("SHA-256", encoded);
4451
- return Array.from(new Uint8Array(hashBuffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
4479
+ return sha256Hex(JSON.stringify(normalizeSkillDefinition(definition)));
4452
4480
  }
4453
4481
  var DEFINE_SKILL_TOP_LEVEL_KEYS = /* @__PURE__ */ new Set(["name", "manifest"]);
4454
4482
  function defineSkill(input) {
@@ -4458,7 +4486,7 @@ function defineSkill(input) {
4458
4486
  if (typeof input.name !== "string" || input.name.length === 0) {
4459
4487
  throw new Error('defineSkill requires a non-empty string "name"');
4460
4488
  }
4461
- if (!isPlainObject3(input.manifest)) {
4489
+ if (!isPlainObject(input.manifest)) {
4462
4490
  throw new Error('defineSkill requires a "manifest" object ({ frontmatter, runtype, body })');
4463
4491
  }
4464
4492
  const unknownKeys = Object.keys(input).filter((key) => !DEFINE_SKILL_TOP_LEVEL_KEYS.has(key));
@@ -4468,7 +4496,7 @@ function defineSkill(input) {
4468
4496
  );
4469
4497
  }
4470
4498
  const frontmatter = input.manifest.frontmatter;
4471
- if (!isPlainObject3(frontmatter) || typeof frontmatter.name !== "string") {
4499
+ if (!isPlainObject(frontmatter) || typeof frontmatter.name !== "string") {
4472
4500
  throw new Error("defineSkill: manifest.frontmatter.name is required");
4473
4501
  }
4474
4502
  if (frontmatter.name !== input.name) {
@@ -4509,7 +4537,7 @@ function parseRequestError2(err) {
4509
4537
  }
4510
4538
  function toConflictError2(err) {
4511
4539
  const { status, body } = parseRequestError2(err);
4512
- if (status !== 409 || !isPlainObject3(body)) return null;
4540
+ if (status !== 409 || !isPlainObject(body)) return null;
4513
4541
  const code = body.code;
4514
4542
  if (code !== "external_modification" && code !== "remote_changed") return null;
4515
4543
  return new SkillEnsureConflictError(
@@ -4858,14 +4886,14 @@ var AGENT_CONFIG_KEYS = [
4858
4886
  "tenancyStrategy"
4859
4887
  ];
4860
4888
  var AGENT_CONFIG_KEY_LIST = [...AGENT_CONFIG_KEYS].sort();
4861
- function isPlainObject4(value) {
4889
+ function isPlainObject2(value) {
4862
4890
  return value !== null && typeof value === "object" && !Array.isArray(value);
4863
4891
  }
4864
4892
  function normalizeValue2(value) {
4865
4893
  if (Array.isArray(value)) {
4866
4894
  return value.map((item) => normalizeValue2(item));
4867
4895
  }
4868
- if (isPlainObject4(value)) {
4896
+ if (isPlainObject2(value)) {
4869
4897
  const normalized = {};
4870
4898
  for (const key of Object.keys(value).sort()) {
4871
4899
  const entry = value[key];
@@ -4878,7 +4906,7 @@ function normalizeValue2(value) {
4878
4906
  }
4879
4907
  function normalizeAgentDefinition(definition) {
4880
4908
  const config = {};
4881
- const rawConfig = isPlainObject4(definition.config) ? definition.config : {};
4909
+ const rawConfig = isPlainObject2(definition.config) ? definition.config : {};
4882
4910
  for (const key of AGENT_CONFIG_KEY_LIST) {
4883
4911
  const value = rawConfig[key];
4884
4912
  if (value === void 0 || value === null) continue;
@@ -4900,7 +4928,7 @@ async function computeAgentContentHash(definition) {
4900
4928
  var DEFINE_TOP_LEVEL_KEYS = /* @__PURE__ */ new Set(["name", "description", "icon", ...AGENT_CONFIG_KEYS]);
4901
4929
  function collectNonPortableToolRefs(config) {
4902
4930
  const tools = config.tools;
4903
- if (!isPlainObject4(tools)) return [];
4931
+ if (!isPlainObject2(tools)) return [];
4904
4932
  const found = [];
4905
4933
  const isAccountScoped = (ref) => typeof ref === "string" && ref.startsWith("tool_");
4906
4934
  const scanArray = (value, path) => {
@@ -4910,7 +4938,7 @@ function collectNonPortableToolRefs(config) {
4910
4938
  });
4911
4939
  };
4912
4940
  const scanKeys = (value, path) => {
4913
- if (!isPlainObject4(value)) return;
4941
+ if (!isPlainObject2(value)) return;
4914
4942
  for (const key of Object.keys(value)) {
4915
4943
  if (isAccountScoped(key)) found.push(`${path}.${key}`);
4916
4944
  }
@@ -4918,16 +4946,16 @@ function collectNonPortableToolRefs(config) {
4918
4946
  scanArray(tools.toolIds, "tools.toolIds");
4919
4947
  scanKeys(tools.toolConfigs, "tools.toolConfigs");
4920
4948
  scanKeys(tools.perToolLimits, "tools.perToolLimits");
4921
- if (isPlainObject4(tools.approval)) scanArray(tools.approval.require, "tools.approval.require");
4922
- if (isPlainObject4(tools.subagentConfig)) {
4949
+ if (isPlainObject2(tools.approval)) scanArray(tools.approval.require, "tools.approval.require");
4950
+ if (isPlainObject2(tools.subagentConfig)) {
4923
4951
  scanArray(tools.subagentConfig.toolPool, "tools.subagentConfig.toolPool");
4924
4952
  }
4925
- if (isPlainObject4(tools.codeModeConfig)) {
4953
+ if (isPlainObject2(tools.codeModeConfig)) {
4926
4954
  scanArray(tools.codeModeConfig.toolPool, "tools.codeModeConfig.toolPool");
4927
4955
  }
4928
4956
  if (Array.isArray(tools.runtimeTools)) {
4929
4957
  tools.runtimeTools.forEach((runtimeTool, i) => {
4930
- if (!isPlainObject4(runtimeTool) || !isPlainObject4(runtimeTool.config)) return;
4958
+ if (!isPlainObject2(runtimeTool) || !isPlainObject2(runtimeTool.config)) return;
4931
4959
  const base = `tools.runtimeTools[${i}].config`;
4932
4960
  const rtConfig = runtimeTool.config;
4933
4961
  if (runtimeTool.toolType === "subagent" && typeof rtConfig.agentId === "string" && rtConfig.agentId.startsWith("agent_")) {
@@ -5001,7 +5029,7 @@ function parseRequestError3(err) {
5001
5029
  }
5002
5030
  function toConflictError3(err) {
5003
5031
  const { status, body } = parseRequestError3(err);
5004
- if (status !== 409 || !isPlainObject4(body)) return null;
5032
+ if (status !== 409 || !isPlainObject2(body)) return null;
5005
5033
  const code = body.code;
5006
5034
  if (code !== "external_modification" && code !== "remote_changed") return null;
5007
5035
  return new AgentEnsureConflictError(
@@ -5103,27 +5131,9 @@ var AgentsNamespace = class {
5103
5131
  };
5104
5132
 
5105
5133
  // src/tools-ensure.ts
5106
- function isPlainObject5(value) {
5107
- return value !== null && typeof value === "object" && !Array.isArray(value);
5108
- }
5109
- function normalizeValue3(value) {
5110
- if (Array.isArray(value)) {
5111
- return value.map((item) => normalizeValue3(item));
5112
- }
5113
- if (isPlainObject5(value)) {
5114
- const normalized = {};
5115
- for (const key of Object.keys(value).sort()) {
5116
- const entry = value[key];
5117
- if (entry === void 0 || entry === null) continue;
5118
- normalized[key] = normalizeValue3(entry);
5119
- }
5120
- return normalized;
5121
- }
5122
- return value;
5123
- }
5124
5134
  function normalizeToolDefinition(definition) {
5125
- const parametersSchema = isPlainObject5(definition.parametersSchema) ? normalizeValue3(definition.parametersSchema) : {};
5126
- const config = isPlainObject5(definition.config) ? normalizeValue3(definition.config) : {};
5135
+ const parametersSchema = isPlainObject(definition.parametersSchema) ? normalizeValue(definition.parametersSchema) : {};
5136
+ const config = isPlainObject(definition.config) ? normalizeValue(definition.config) : {};
5127
5137
  return {
5128
5138
  toolType: definition.toolType,
5129
5139
  ...definition.description ? { description: definition.description } : {},
@@ -5132,10 +5142,7 @@ function normalizeToolDefinition(definition) {
5132
5142
  };
5133
5143
  }
5134
5144
  async function computeToolContentHash(definition) {
5135
- const serialized = JSON.stringify(normalizeToolDefinition(definition));
5136
- const encoded = new TextEncoder().encode(serialized);
5137
- const hashBuffer = await crypto.subtle.digest("SHA-256", encoded);
5138
- return Array.from(new Uint8Array(hashBuffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
5145
+ return sha256Hex(JSON.stringify(normalizeToolDefinition(definition)));
5139
5146
  }
5140
5147
  var DEFINE_TOOL_TOP_LEVEL_KEYS = /* @__PURE__ */ new Set([
5141
5148
  "name",
@@ -5168,10 +5175,10 @@ function defineTool(input) {
5168
5175
  `defineTool requires "toolType" to be one of: ${[...TOOL_DEFINITION_TYPES].join(", ")}`
5169
5176
  );
5170
5177
  }
5171
- if (!isPlainObject5(input.parametersSchema)) {
5178
+ if (!isPlainObject(input.parametersSchema)) {
5172
5179
  throw new Error('defineTool requires a "parametersSchema" object (a JSON Schema)');
5173
5180
  }
5174
- if (!isPlainObject5(input.config)) {
5181
+ if (!isPlainObject(input.config)) {
5175
5182
  throw new Error('defineTool requires a "config" object');
5176
5183
  }
5177
5184
  const unknownKeys = Object.keys(input).filter((key) => !DEFINE_TOOL_TOP_LEVEL_KEYS.has(key));
@@ -5219,7 +5226,7 @@ function parseRequestError4(err) {
5219
5226
  }
5220
5227
  function toConflictError4(err) {
5221
5228
  const { status, body } = parseRequestError4(err);
5222
- if (status !== 409 || !isPlainObject5(body)) return null;
5229
+ if (status !== 409 || !isPlainObject(body)) return null;
5223
5230
  const code = body.code;
5224
5231
  if (code !== "external_modification" && code !== "remote_changed") return null;
5225
5232
  return new ToolEnsureConflictError(
@@ -5339,26 +5346,8 @@ var ToolsNamespace = class {
5339
5346
  };
5340
5347
 
5341
5348
  // src/products-ensure.ts
5342
- function isPlainObject6(value) {
5343
- return value !== null && typeof value === "object" && !Array.isArray(value);
5344
- }
5345
- function normalizeValue4(value) {
5346
- if (Array.isArray(value)) {
5347
- return value.map((item) => normalizeValue4(item));
5348
- }
5349
- if (isPlainObject6(value)) {
5350
- const normalized = {};
5351
- for (const key of Object.keys(value).sort()) {
5352
- const entry = value[key];
5353
- if (entry === void 0 || entry === null) continue;
5354
- normalized[key] = normalizeValue4(entry);
5355
- }
5356
- return normalized;
5357
- }
5358
- return value;
5359
- }
5360
5349
  function normalizeProductDefinition(definition) {
5361
- const spec = isPlainObject6(definition.spec) ? normalizeValue4(definition.spec) : {};
5350
+ const spec = isPlainObject(definition.spec) ? normalizeValue(definition.spec) : {};
5362
5351
  return {
5363
5352
  ...definition.description ? { description: definition.description } : {},
5364
5353
  ...definition.icon ? { icon: definition.icon } : {},
@@ -5366,10 +5355,7 @@ function normalizeProductDefinition(definition) {
5366
5355
  };
5367
5356
  }
5368
5357
  async function computeProductContentHash(definition) {
5369
- const serialized = JSON.stringify(normalizeProductDefinition(definition));
5370
- const encoded = new TextEncoder().encode(serialized);
5371
- const hashBuffer = await crypto.subtle.digest("SHA-256", encoded);
5372
- return Array.from(new Uint8Array(hashBuffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
5358
+ return sha256Hex(JSON.stringify(normalizeProductDefinition(definition)));
5373
5359
  }
5374
5360
  var DEFINE_PRODUCT_TOP_LEVEL_KEYS = /* @__PURE__ */ new Set(["name", "description", "icon", "spec"]);
5375
5361
  function defineProduct(input) {
@@ -5385,7 +5371,7 @@ function defineProduct(input) {
5385
5371
  if (input.icon != null && typeof input.icon !== "string") {
5386
5372
  throw new Error('defineProduct "icon" must be a string when provided');
5387
5373
  }
5388
- if (input.spec != null && !isPlainObject6(input.spec)) {
5374
+ if (input.spec != null && !isPlainObject(input.spec)) {
5389
5375
  throw new Error('defineProduct "spec" must be an object when provided');
5390
5376
  }
5391
5377
  const unknownKeys = Object.keys(input).filter((key) => !DEFINE_PRODUCT_TOP_LEVEL_KEYS.has(key));
@@ -5432,7 +5418,7 @@ function parseRequestError5(err) {
5432
5418
  }
5433
5419
  function toConflictError5(err) {
5434
5420
  const { status, body } = parseRequestError5(err);
5435
- if (status !== 409 || !isPlainObject6(body)) return null;
5421
+ if (status !== 409 || !isPlainObject(body)) return null;
5436
5422
  const code = body.code;
5437
5423
  if (code !== "external_modification" && code !== "remote_changed") return null;
5438
5424
  return new ProductEnsureConflictError(
@@ -5513,50 +5499,29 @@ async function pullProduct(client, name) {
5513
5499
  }
5514
5500
 
5515
5501
  // src/products-ensure-fpo.ts
5516
- function isPlainObject7(value) {
5517
- return value !== null && typeof value === "object" && !Array.isArray(value);
5518
- }
5519
- function normalizeValue5(value) {
5520
- if (Array.isArray(value)) {
5521
- return value.map((item) => normalizeValue5(item));
5522
- }
5523
- if (isPlainObject7(value)) {
5524
- const normalized = {};
5525
- for (const key of Object.keys(value).sort()) {
5526
- const entry = value[key];
5527
- if (entry === void 0 || entry === null) continue;
5528
- normalized[key] = normalizeValue5(entry);
5529
- }
5530
- return normalized;
5531
- }
5532
- return value;
5533
- }
5534
5502
  function normalizeFpoDefinition(fpo) {
5535
- const productInput = isPlainObject7(fpo.product) ? fpo.product : {};
5503
+ const productInput = isPlainObject(fpo.product) ? fpo.product : {};
5536
5504
  const { name: _identityName, ...productRest } = productInput;
5537
- const product = normalizeValue5(productRest);
5505
+ const product = normalizeValue(productRest);
5538
5506
  return {
5539
- ...fpo.version !== void 0 && fpo.version !== null ? { version: normalizeValue5(fpo.version) } : {},
5507
+ ...fpo.version !== void 0 && fpo.version !== null ? { version: normalizeValue(fpo.version) } : {},
5540
5508
  product,
5541
- capabilities: normalizeValue5(fpo.capabilities ?? []),
5542
- tools: normalizeValue5(fpo.tools ?? []),
5543
- surfaces: normalizeValue5(fpo.surfaces ?? []),
5544
- ...fpo.records !== void 0 && fpo.records !== null ? { records: normalizeValue5(fpo.records) } : {},
5545
- ...fpo.schedules !== void 0 && fpo.schedules !== null ? { schedules: normalizeValue5(fpo.schedules) } : {},
5546
- ...fpo.secrets !== void 0 && fpo.secrets !== null ? { secrets: normalizeValue5(fpo.secrets) } : {}
5509
+ capabilities: normalizeValue(fpo.capabilities ?? []),
5510
+ tools: normalizeValue(fpo.tools ?? []),
5511
+ surfaces: normalizeValue(fpo.surfaces ?? []),
5512
+ ...fpo.records !== void 0 && fpo.records !== null ? { records: normalizeValue(fpo.records) } : {},
5513
+ ...fpo.schedules !== void 0 && fpo.schedules !== null ? { schedules: normalizeValue(fpo.schedules) } : {},
5514
+ ...fpo.secrets !== void 0 && fpo.secrets !== null ? { secrets: normalizeValue(fpo.secrets) } : {}
5547
5515
  };
5548
5516
  }
5549
5517
  async function computeFpoContentHash(fpo) {
5550
- const serialized = JSON.stringify(normalizeFpoDefinition(fpo));
5551
- const encoded = new TextEncoder().encode(serialized);
5552
- const hashBuffer = await crypto.subtle.digest("SHA-256", encoded);
5553
- return Array.from(new Uint8Array(hashBuffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
5518
+ return sha256Hex(JSON.stringify(normalizeFpoDefinition(fpo)));
5554
5519
  }
5555
5520
  function defineFpo(fpo) {
5556
- if (!isPlainObject7(fpo)) {
5521
+ if (!isPlainObject(fpo)) {
5557
5522
  throw new Error("defineFpo requires an FPO object");
5558
5523
  }
5559
- const product = isPlainObject7(fpo.product) ? fpo.product : void 0;
5524
+ const product = isPlainObject(fpo.product) ? fpo.product : void 0;
5560
5525
  if (!product || typeof product.name !== "string" || product.name.length === 0) {
5561
5526
  throw new Error('defineFpo requires a non-empty "product.name" (the converge identity)');
5562
5527
  }
@@ -5652,26 +5617,8 @@ var ProductsNamespace = class {
5652
5617
  };
5653
5618
 
5654
5619
  // src/surfaces-ensure.ts
5655
- function isPlainObject8(value) {
5656
- return value !== null && typeof value === "object" && !Array.isArray(value);
5657
- }
5658
- function normalizeValue6(value) {
5659
- if (Array.isArray(value)) {
5660
- return value.map((item) => normalizeValue6(item));
5661
- }
5662
- if (isPlainObject8(value)) {
5663
- const normalized = {};
5664
- for (const key of Object.keys(value).sort()) {
5665
- const entry = value[key];
5666
- if (entry === void 0 || entry === null) continue;
5667
- normalized[key] = normalizeValue6(entry);
5668
- }
5669
- return normalized;
5670
- }
5671
- return value;
5672
- }
5673
5620
  function normalizeSurfaceDefinition(definition) {
5674
- const behavior = isPlainObject8(definition.behavior) ? normalizeValue6({ type: definition.type, ...definition.behavior }) : { type: definition.type };
5621
+ const behavior = isPlainObject(definition.behavior) ? normalizeValue({ type: definition.type, ...definition.behavior }) : { type: definition.type };
5675
5622
  return {
5676
5623
  type: definition.type,
5677
5624
  behavior,
@@ -5680,10 +5627,7 @@ function normalizeSurfaceDefinition(definition) {
5680
5627
  };
5681
5628
  }
5682
5629
  async function computeSurfaceContentHash(definition) {
5683
- const serialized = JSON.stringify(normalizeSurfaceDefinition(definition));
5684
- const encoded = new TextEncoder().encode(serialized);
5685
- const hashBuffer = await crypto.subtle.digest("SHA-256", encoded);
5686
- return Array.from(new Uint8Array(hashBuffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
5630
+ return sha256Hex(JSON.stringify(normalizeSurfaceDefinition(definition)));
5687
5631
  }
5688
5632
  var DEFINE_SURFACE_TOP_LEVEL_KEYS = /* @__PURE__ */ new Set([
5689
5633
  "name",
@@ -5724,13 +5668,13 @@ function defineSurface(input) {
5724
5668
  `defineSurface requires "type" to be one of: ${[...SURFACE_DEFINITION_TYPES].join(", ")}`
5725
5669
  );
5726
5670
  }
5727
- if (input.behavior !== void 0 && !isPlainObject8(input.behavior)) {
5671
+ if (input.behavior !== void 0 && !isPlainObject(input.behavior)) {
5728
5672
  throw new Error('defineSurface "behavior" must be an object when provided');
5729
5673
  }
5730
- if (input.inbound !== void 0 && !isPlainObject8(input.inbound)) {
5674
+ if (input.inbound !== void 0 && !isPlainObject(input.inbound)) {
5731
5675
  throw new Error('defineSurface "inbound" must be an object when provided');
5732
5676
  }
5733
- if (input.outbound !== void 0 && !isPlainObject8(input.outbound)) {
5677
+ if (input.outbound !== void 0 && !isPlainObject(input.outbound)) {
5734
5678
  throw new Error('defineSurface "outbound" must be an object when provided');
5735
5679
  }
5736
5680
  if (input.status !== void 0 && !["draft", "active", "paused"].includes(input.status)) {
@@ -5786,7 +5730,7 @@ function parseRequestError6(err) {
5786
5730
  }
5787
5731
  function toConflictError6(err) {
5788
5732
  const { status, body } = parseRequestError6(err);
5789
- if (status !== 409 || !isPlainObject8(body)) return null;
5733
+ if (status !== 409 || !isPlainObject(body)) return null;
5790
5734
  const code = body.code;
5791
5735
  if (code !== "external_modification" && code !== "remote_changed") return null;
5792
5736
  return new SurfaceEnsureConflictError(
@@ -6399,7 +6343,7 @@ var Runtype = class {
6399
6343
 
6400
6344
  // src/version.ts
6401
6345
  var FALLBACK_VERSION = "0.0.0";
6402
- var SDK_VERSION = "5.9.0".length > 0 ? "5.9.0" : FALLBACK_VERSION;
6346
+ var SDK_VERSION = "5.10.0".length > 0 ? "5.10.0" : FALLBACK_VERSION;
6403
6347
  var RUNTYPE_CLIENT_KIND = "sdk";
6404
6348
  var SDK_USER_AGENT = `runtype-sdk/${SDK_VERSION} (typescript)`;
6405
6349