@runtypelabs/sdk 10.15.1 → 10.17.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
@@ -9330,7 +9330,8 @@ const DEFINE_EVAL_TOP_LEVEL_KEYS = /* @__PURE__ */ new Set([
9330
9330
  "cases",
9331
9331
  "virtual",
9332
9332
  "recordedToolMode",
9333
- "recordedToolUnmatchedPolicy"
9333
+ "recordedToolUnmatchedPolicy",
9334
+ "identityDefaults"
9334
9335
  ]);
9335
9336
  const DEFINE_EVAL_CASE_KEYS = /* @__PURE__ */ new Set([
9336
9337
  "name",
@@ -9356,6 +9357,24 @@ function validateGrader(grader, where) {
9356
9357
  if (!CHECK_GRADER_KINDS.has(grader.kind)) throw new Error(`defineEval: ${where} has unknown grader kind "${grader.kind}". Known kinds: ${[...CHECK_GRADER_KINDS].join(", ")}, ai.`);
9357
9358
  return grader;
9358
9359
  }
9360
+ function normalizeEndUserIdentity(value, where) {
9361
+ if (!isPlainObject$1(value) || typeof value.id !== "string" || value.id.length === 0) throw new Error(`defineEval: ${where} must be an object with a non-empty string "id"`);
9362
+ if (value.email !== void 0 && typeof value.email !== "string") throw new Error(`defineEval: ${where} "email" must be a string`);
9363
+ return { ...value };
9364
+ }
9365
+ function normalizeTenantIdentity(value, where) {
9366
+ if (!isPlainObject$1(value) || typeof value.id !== "string" || value.id.length === 0) throw new Error(`defineEval: ${where} must be an object with a non-empty string "id"`);
9367
+ return { ...value };
9368
+ }
9369
+ function normalizeIdentityDefaults(value) {
9370
+ if (!isPlainObject$1(value)) throw new Error("defineEval \"identityDefaults\" must be an object: { endUser?, tenant? }");
9371
+ const extraKeys = Object.keys(value).filter((k) => k !== "endUser" && k !== "tenant");
9372
+ if (extraKeys.length > 0) throw new Error(`defineEval "identityDefaults" has unknown field(s): ${extraKeys.join(", ")}`);
9373
+ const out = {};
9374
+ if (value.endUser !== void 0) out.endUser = normalizeEndUserIdentity(value.endUser, "\"identityDefaults.endUser\"");
9375
+ if (value.tenant !== void 0) out.tenant = normalizeTenantIdentity(value.tenant, "\"identityDefaults.tenant\"");
9376
+ return out;
9377
+ }
9359
9378
  function normalizeCaseInput(input, where) {
9360
9379
  if (input === void 0) return {};
9361
9380
  if (!isPlainObject$1(input)) throw new Error(`defineEval: ${where} "input" must be an object`);
@@ -9390,6 +9409,8 @@ function normalizeCaseInput(input, where) {
9390
9409
  return mock;
9391
9410
  });
9392
9411
  }
9412
+ if (input.endUser !== void 0) out.endUser = normalizeEndUserIdentity(input.endUser, `${where} "input.endUser"`);
9413
+ if (input.tenant !== void 0) out.tenant = normalizeTenantIdentity(input.tenant, `${where} "input.tenant"`);
9393
9414
  return out;
9394
9415
  }
9395
9416
  /**
@@ -9419,10 +9440,11 @@ function normalizeCaseInput(input, where) {
9419
9440
  function defineEval(input) {
9420
9441
  if (!input || typeof input !== "object") throw new Error("defineEval requires a definition object");
9421
9442
  const unknownKeys = Object.keys(input).filter((k) => !DEFINE_EVAL_TOP_LEVEL_KEYS.has(k));
9422
- if (unknownKeys.length > 0) throw new Error(`defineEval: unknown field(s): ${unknownKeys.join(", ")}. Allowed fields are target, graders, cases, virtual, recordedToolMode, recordedToolUnmatchedPolicy.`);
9443
+ if (unknownKeys.length > 0) throw new Error(`defineEval: unknown field(s): ${unknownKeys.join(", ")}. Allowed fields are target, graders, cases, virtual, recordedToolMode, recordedToolUnmatchedPolicy, identityDefaults.`);
9423
9444
  if (input.recordedToolMode !== void 0 && input.recordedToolMode !== "next_step" && input.recordedToolMode !== "continue") throw new Error("defineEval \"recordedToolMode\" must be \"next_step\" or \"continue\"");
9424
9445
  if (input.recordedToolUnmatchedPolicy !== void 0 && input.recordedToolUnmatchedPolicy !== "fail" && input.recordedToolUnmatchedPolicy !== "stub") throw new Error("defineEval \"recordedToolUnmatchedPolicy\" must be \"fail\" or \"stub\"");
9425
9446
  const target = normalizeTarget(input.target);
9447
+ const identityDefaults = input.identityDefaults !== void 0 ? normalizeIdentityDefaults(input.identityDefaults) : void 0;
9426
9448
  if (input.name !== void 0 && (typeof input.name !== "string" || input.name.length === 0)) throw new Error("defineEval \"name\" must be a non-empty string when provided");
9427
9449
  const name = input.name ?? ("flow" in target ? `flow:${target.flow}` : `agent:${target.agent}`);
9428
9450
  const suiteGraders = (input.graders ?? []).map((g, i) => validateGrader(g, `graders[${i}]`));
@@ -9451,7 +9473,8 @@ function defineEval(input) {
9451
9473
  }),
9452
9474
  virtual: input.virtual === true,
9453
9475
  ...input.recordedToolMode !== void 0 ? { recordedToolMode: input.recordedToolMode } : {},
9454
- ...input.recordedToolUnmatchedPolicy !== void 0 ? { recordedToolUnmatchedPolicy: input.recordedToolUnmatchedPolicy } : {}
9476
+ ...input.recordedToolUnmatchedPolicy !== void 0 ? { recordedToolUnmatchedPolicy: input.recordedToolUnmatchedPolicy } : {},
9477
+ ...identityDefaults !== void 0 ? { identityDefaults } : {}
9455
9478
  };
9456
9479
  }
9457
9480
  function normalizeForHash(value) {
@@ -9467,6 +9490,12 @@ function normalizeForHash(value) {
9467
9490
  }
9468
9491
  return value;
9469
9492
  }
9493
+ /** Normalized suite identity defaults, or undefined when absent or empty (so `{}` hashes like no defaults). */
9494
+ function canonicalIdentityDefaults(value) {
9495
+ if (!isPlainObject$1(value)) return void 0;
9496
+ const normalized = normalizeForHash(value);
9497
+ return Object.keys(normalized).length > 0 ? normalized : void 0;
9498
+ }
9470
9499
  /**
9471
9500
  * SHA-256 (hex) over the canonical normalized definition. Cases are sorted by
9472
9501
  * name (name is the case identity); grader order WITHIN a case is preserved
@@ -9476,11 +9505,13 @@ function normalizeForHash(value) {
9476
9505
  async function computeEvalContentHash(definition) {
9477
9506
  const recordedToolMode = definition.recordedToolMode ?? "next_step";
9478
9507
  const recordedToolUnmatchedPolicy = definition.recordedToolUnmatchedPolicy ?? "fail";
9508
+ const identityDefaults = canonicalIdentityDefaults(definition.identityDefaults);
9479
9509
  const canonical = {
9480
9510
  target: normalizeForHash(definition.target),
9481
9511
  virtual: definition.virtual,
9482
9512
  ...recordedToolMode !== "next_step" ? { recordedToolMode } : {},
9483
9513
  ...recordedToolUnmatchedPolicy !== "fail" ? { recordedToolUnmatchedPolicy } : {},
9514
+ ...identityDefaults !== void 0 ? { identityDefaults } : {},
9484
9515
  cases: [...definition.cases].sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0).map((c) => ({
9485
9516
  name: c.name,
9486
9517
  input: normalizeForHash(c.input),
@@ -11880,6 +11911,7 @@ const AGENT_CONFIG_KEYS = [
11880
11911
  "sandbox",
11881
11912
  "tenancyStrategy",
11882
11913
  "durability",
11914
+ "busyMessageRouting",
11883
11915
  "state"
11884
11916
  ];
11885
11917
  const AGENT_CONFIG_KEY_LIST = [...AGENT_CONFIG_KEYS].sort();
@@ -14459,7 +14491,7 @@ function transformQueryParams(params) {
14459
14491
  }
14460
14492
  //#endregion
14461
14493
  //#region src/version.ts
14462
- const SDK_VERSION = "10.15.1";
14494
+ const SDK_VERSION = "10.17.0";
14463
14495
  /**
14464
14496
  * Canonical client identity the API uses for attribution
14465
14497
  * (`detectActorSource` in apps/api/src/lib/audit-log.ts keys `'sdk'` off the
@@ -14495,6 +14527,10 @@ function isPausedLocalActionResult(value) {
14495
14527
  return isObjectRecord(value) && value.status === "paused" && Array.isArray(value.pausedTools) && value.pausedTools.length > 0;
14496
14528
  }
14497
14529
  var RuntypeClient = class {
14530
+ /** List supported decision models; credentials and spending policy are checked at execution. */
14531
+ async listDecisionModels() {
14532
+ return this.get("/decision-models");
14533
+ }
14498
14534
  constructor(config = {}) {
14499
14535
  const baseUrl = config.baseUrl || "https://api.runtype.com";
14500
14536
  this.apiVersion = config.apiVersion || "v1";