@runtypelabs/sdk 10.15.0 → 10.16.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
@@ -197,7 +197,8 @@ function createFlowEventTranslator() {
197
197
  parameters: data.parameters,
198
198
  awaitedAt: data.awaitedAt,
199
199
  origin: data.origin,
200
- pageOrigin: data.pageOrigin
200
+ pageOrigin: data.pageOrigin,
201
+ annotations: data.annotations
201
202
  })];
202
203
  default: return [];
203
204
  }
@@ -306,7 +307,8 @@ function createAgentEventTranslator() {
306
307
  parameters: data.parameters,
307
308
  hiddenParameterNames: data.hiddenParameterNames,
308
309
  origin: data.origin,
309
- pageOrigin: data.pageOrigin
310
+ pageOrigin: data.pageOrigin,
311
+ annotations: data.annotations
310
312
  })];
311
313
  case "tool_output_delta": return [compact({
312
314
  type: "agent_tool_delta",
@@ -421,6 +423,7 @@ function createAgentEventTranslator() {
421
423
  awaitedAt: data.awaitedAt,
422
424
  origin: data.origin,
423
425
  pageOrigin: data.pageOrigin,
426
+ annotations: data.annotations,
424
427
  awaitReason: data.awaitReason,
425
428
  elicitation: data.elicitation,
426
429
  externalAgent: data.externalAgent
@@ -9327,7 +9330,8 @@ const DEFINE_EVAL_TOP_LEVEL_KEYS = /* @__PURE__ */ new Set([
9327
9330
  "cases",
9328
9331
  "virtual",
9329
9332
  "recordedToolMode",
9330
- "recordedToolUnmatchedPolicy"
9333
+ "recordedToolUnmatchedPolicy",
9334
+ "identityDefaults"
9331
9335
  ]);
9332
9336
  const DEFINE_EVAL_CASE_KEYS = /* @__PURE__ */ new Set([
9333
9337
  "name",
@@ -9353,6 +9357,24 @@ function validateGrader(grader, where) {
9353
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.`);
9354
9358
  return grader;
9355
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
+ }
9356
9378
  function normalizeCaseInput(input, where) {
9357
9379
  if (input === void 0) return {};
9358
9380
  if (!isPlainObject$1(input)) throw new Error(`defineEval: ${where} "input" must be an object`);
@@ -9387,6 +9409,8 @@ function normalizeCaseInput(input, where) {
9387
9409
  return mock;
9388
9410
  });
9389
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"`);
9390
9414
  return out;
9391
9415
  }
9392
9416
  /**
@@ -9416,10 +9440,11 @@ function normalizeCaseInput(input, where) {
9416
9440
  function defineEval(input) {
9417
9441
  if (!input || typeof input !== "object") throw new Error("defineEval requires a definition object");
9418
9442
  const unknownKeys = Object.keys(input).filter((k) => !DEFINE_EVAL_TOP_LEVEL_KEYS.has(k));
9419
- 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.`);
9420
9444
  if (input.recordedToolMode !== void 0 && input.recordedToolMode !== "next_step" && input.recordedToolMode !== "continue") throw new Error("defineEval \"recordedToolMode\" must be \"next_step\" or \"continue\"");
9421
9445
  if (input.recordedToolUnmatchedPolicy !== void 0 && input.recordedToolUnmatchedPolicy !== "fail" && input.recordedToolUnmatchedPolicy !== "stub") throw new Error("defineEval \"recordedToolUnmatchedPolicy\" must be \"fail\" or \"stub\"");
9422
9446
  const target = normalizeTarget(input.target);
9447
+ const identityDefaults = input.identityDefaults !== void 0 ? normalizeIdentityDefaults(input.identityDefaults) : void 0;
9423
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");
9424
9449
  const name = input.name ?? ("flow" in target ? `flow:${target.flow}` : `agent:${target.agent}`);
9425
9450
  const suiteGraders = (input.graders ?? []).map((g, i) => validateGrader(g, `graders[${i}]`));
@@ -9448,7 +9473,8 @@ function defineEval(input) {
9448
9473
  }),
9449
9474
  virtual: input.virtual === true,
9450
9475
  ...input.recordedToolMode !== void 0 ? { recordedToolMode: input.recordedToolMode } : {},
9451
- ...input.recordedToolUnmatchedPolicy !== void 0 ? { recordedToolUnmatchedPolicy: input.recordedToolUnmatchedPolicy } : {}
9476
+ ...input.recordedToolUnmatchedPolicy !== void 0 ? { recordedToolUnmatchedPolicy: input.recordedToolUnmatchedPolicy } : {},
9477
+ ...identityDefaults !== void 0 ? { identityDefaults } : {}
9452
9478
  };
9453
9479
  }
9454
9480
  function normalizeForHash(value) {
@@ -9464,6 +9490,12 @@ function normalizeForHash(value) {
9464
9490
  }
9465
9491
  return value;
9466
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
+ }
9467
9499
  /**
9468
9500
  * SHA-256 (hex) over the canonical normalized definition. Cases are sorted by
9469
9501
  * name (name is the case identity); grader order WITHIN a case is preserved
@@ -9473,11 +9505,13 @@ function normalizeForHash(value) {
9473
9505
  async function computeEvalContentHash(definition) {
9474
9506
  const recordedToolMode = definition.recordedToolMode ?? "next_step";
9475
9507
  const recordedToolUnmatchedPolicy = definition.recordedToolUnmatchedPolicy ?? "fail";
9508
+ const identityDefaults = canonicalIdentityDefaults(definition.identityDefaults);
9476
9509
  const canonical = {
9477
9510
  target: normalizeForHash(definition.target),
9478
9511
  virtual: definition.virtual,
9479
9512
  ...recordedToolMode !== "next_step" ? { recordedToolMode } : {},
9480
9513
  ...recordedToolUnmatchedPolicy !== "fail" ? { recordedToolUnmatchedPolicy } : {},
9514
+ ...identityDefaults !== void 0 ? { identityDefaults } : {},
9481
9515
  cases: [...definition.cases].sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0).map((c) => ({
9482
9516
  name: c.name,
9483
9517
  input: normalizeForHash(c.input),
@@ -14456,7 +14490,7 @@ function transformQueryParams(params) {
14456
14490
  }
14457
14491
  //#endregion
14458
14492
  //#region src/version.ts
14459
- const SDK_VERSION = "10.15.0";
14493
+ const SDK_VERSION = "10.16.0";
14460
14494
  /**
14461
14495
  * Canonical client identity the API uses for attribution
14462
14496
  * (`detectActorSource` in apps/api/src/lib/audit-log.ts keys `'sdk'` off the
@@ -14492,6 +14526,10 @@ function isPausedLocalActionResult(value) {
14492
14526
  return isObjectRecord(value) && value.status === "paused" && Array.isArray(value.pausedTools) && value.pausedTools.length > 0;
14493
14527
  }
14494
14528
  var RuntypeClient = class {
14529
+ /** List supported decision models; credentials and spending policy are checked at execution. */
14530
+ async listDecisionModels() {
14531
+ return this.get("/decision-models");
14532
+ }
14495
14533
  constructor(config = {}) {
14496
14534
  const baseUrl = config.baseUrl || "https://api.runtype.com";
14497
14535
  this.apiVersion = config.apiVersion || "v1";
@@ -14577,6 +14615,7 @@ var RuntypeClient = class {
14577
14615
  parametersSchema: entry.parametersSchema,
14578
14616
  ...entry.origin ? { origin: entry.origin } : {},
14579
14617
  ...entry.pageOrigin ? { pageOrigin: entry.pageOrigin } : {},
14618
+ ...entry.annotations ? { annotations: entry.annotations } : {},
14580
14619
  ...entry.untrustedContentHint ? { untrustedContentHint: true } : {}
14581
14620
  })) : [];
14582
14621
  const modifiedRequest = {