@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.mjs CHANGED
@@ -196,7 +196,8 @@ function createFlowEventTranslator() {
196
196
  parameters: data.parameters,
197
197
  awaitedAt: data.awaitedAt,
198
198
  origin: data.origin,
199
- pageOrigin: data.pageOrigin
199
+ pageOrigin: data.pageOrigin,
200
+ annotations: data.annotations
200
201
  })];
201
202
  default: return [];
202
203
  }
@@ -305,7 +306,8 @@ function createAgentEventTranslator() {
305
306
  parameters: data.parameters,
306
307
  hiddenParameterNames: data.hiddenParameterNames,
307
308
  origin: data.origin,
308
- pageOrigin: data.pageOrigin
309
+ pageOrigin: data.pageOrigin,
310
+ annotations: data.annotations
309
311
  })];
310
312
  case "tool_output_delta": return [compact({
311
313
  type: "agent_tool_delta",
@@ -420,6 +422,7 @@ function createAgentEventTranslator() {
420
422
  awaitedAt: data.awaitedAt,
421
423
  origin: data.origin,
422
424
  pageOrigin: data.pageOrigin,
425
+ annotations: data.annotations,
423
426
  awaitReason: data.awaitReason,
424
427
  elicitation: data.elicitation,
425
428
  externalAgent: data.externalAgent
@@ -9326,7 +9329,8 @@ const DEFINE_EVAL_TOP_LEVEL_KEYS = /* @__PURE__ */ new Set([
9326
9329
  "cases",
9327
9330
  "virtual",
9328
9331
  "recordedToolMode",
9329
- "recordedToolUnmatchedPolicy"
9332
+ "recordedToolUnmatchedPolicy",
9333
+ "identityDefaults"
9330
9334
  ]);
9331
9335
  const DEFINE_EVAL_CASE_KEYS = /* @__PURE__ */ new Set([
9332
9336
  "name",
@@ -9352,6 +9356,24 @@ function validateGrader(grader, where) {
9352
9356
  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.`);
9353
9357
  return grader;
9354
9358
  }
9359
+ function normalizeEndUserIdentity(value, where) {
9360
+ 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"`);
9361
+ if (value.email !== void 0 && typeof value.email !== "string") throw new Error(`defineEval: ${where} "email" must be a string`);
9362
+ return { ...value };
9363
+ }
9364
+ function normalizeTenantIdentity(value, where) {
9365
+ 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"`);
9366
+ return { ...value };
9367
+ }
9368
+ function normalizeIdentityDefaults(value) {
9369
+ if (!isPlainObject$1(value)) throw new Error("defineEval \"identityDefaults\" must be an object: { endUser?, tenant? }");
9370
+ const extraKeys = Object.keys(value).filter((k) => k !== "endUser" && k !== "tenant");
9371
+ if (extraKeys.length > 0) throw new Error(`defineEval "identityDefaults" has unknown field(s): ${extraKeys.join(", ")}`);
9372
+ const out = {};
9373
+ if (value.endUser !== void 0) out.endUser = normalizeEndUserIdentity(value.endUser, "\"identityDefaults.endUser\"");
9374
+ if (value.tenant !== void 0) out.tenant = normalizeTenantIdentity(value.tenant, "\"identityDefaults.tenant\"");
9375
+ return out;
9376
+ }
9355
9377
  function normalizeCaseInput(input, where) {
9356
9378
  if (input === void 0) return {};
9357
9379
  if (!isPlainObject$1(input)) throw new Error(`defineEval: ${where} "input" must be an object`);
@@ -9386,6 +9408,8 @@ function normalizeCaseInput(input, where) {
9386
9408
  return mock;
9387
9409
  });
9388
9410
  }
9411
+ if (input.endUser !== void 0) out.endUser = normalizeEndUserIdentity(input.endUser, `${where} "input.endUser"`);
9412
+ if (input.tenant !== void 0) out.tenant = normalizeTenantIdentity(input.tenant, `${where} "input.tenant"`);
9389
9413
  return out;
9390
9414
  }
9391
9415
  /**
@@ -9415,10 +9439,11 @@ function normalizeCaseInput(input, where) {
9415
9439
  function defineEval(input) {
9416
9440
  if (!input || typeof input !== "object") throw new Error("defineEval requires a definition object");
9417
9441
  const unknownKeys = Object.keys(input).filter((k) => !DEFINE_EVAL_TOP_LEVEL_KEYS.has(k));
9418
- if (unknownKeys.length > 0) throw new Error(`defineEval: unknown field(s): ${unknownKeys.join(", ")}. Allowed fields are target, graders, cases, virtual, recordedToolMode, recordedToolUnmatchedPolicy.`);
9442
+ if (unknownKeys.length > 0) throw new Error(`defineEval: unknown field(s): ${unknownKeys.join(", ")}. Allowed fields are target, graders, cases, virtual, recordedToolMode, recordedToolUnmatchedPolicy, identityDefaults.`);
9419
9443
  if (input.recordedToolMode !== void 0 && input.recordedToolMode !== "next_step" && input.recordedToolMode !== "continue") throw new Error("defineEval \"recordedToolMode\" must be \"next_step\" or \"continue\"");
9420
9444
  if (input.recordedToolUnmatchedPolicy !== void 0 && input.recordedToolUnmatchedPolicy !== "fail" && input.recordedToolUnmatchedPolicy !== "stub") throw new Error("defineEval \"recordedToolUnmatchedPolicy\" must be \"fail\" or \"stub\"");
9421
9445
  const target = normalizeTarget(input.target);
9446
+ const identityDefaults = input.identityDefaults !== void 0 ? normalizeIdentityDefaults(input.identityDefaults) : void 0;
9422
9447
  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");
9423
9448
  const name = input.name ?? ("flow" in target ? `flow:${target.flow}` : `agent:${target.agent}`);
9424
9449
  const suiteGraders = (input.graders ?? []).map((g, i) => validateGrader(g, `graders[${i}]`));
@@ -9447,7 +9472,8 @@ function defineEval(input) {
9447
9472
  }),
9448
9473
  virtual: input.virtual === true,
9449
9474
  ...input.recordedToolMode !== void 0 ? { recordedToolMode: input.recordedToolMode } : {},
9450
- ...input.recordedToolUnmatchedPolicy !== void 0 ? { recordedToolUnmatchedPolicy: input.recordedToolUnmatchedPolicy } : {}
9475
+ ...input.recordedToolUnmatchedPolicy !== void 0 ? { recordedToolUnmatchedPolicy: input.recordedToolUnmatchedPolicy } : {},
9476
+ ...identityDefaults !== void 0 ? { identityDefaults } : {}
9451
9477
  };
9452
9478
  }
9453
9479
  function normalizeForHash(value) {
@@ -9463,6 +9489,12 @@ function normalizeForHash(value) {
9463
9489
  }
9464
9490
  return value;
9465
9491
  }
9492
+ /** Normalized suite identity defaults, or undefined when absent or empty (so `{}` hashes like no defaults). */
9493
+ function canonicalIdentityDefaults(value) {
9494
+ if (!isPlainObject$1(value)) return void 0;
9495
+ const normalized = normalizeForHash(value);
9496
+ return Object.keys(normalized).length > 0 ? normalized : void 0;
9497
+ }
9466
9498
  /**
9467
9499
  * SHA-256 (hex) over the canonical normalized definition. Cases are sorted by
9468
9500
  * name (name is the case identity); grader order WITHIN a case is preserved
@@ -9472,11 +9504,13 @@ function normalizeForHash(value) {
9472
9504
  async function computeEvalContentHash(definition) {
9473
9505
  const recordedToolMode = definition.recordedToolMode ?? "next_step";
9474
9506
  const recordedToolUnmatchedPolicy = definition.recordedToolUnmatchedPolicy ?? "fail";
9507
+ const identityDefaults = canonicalIdentityDefaults(definition.identityDefaults);
9475
9508
  const canonical = {
9476
9509
  target: normalizeForHash(definition.target),
9477
9510
  virtual: definition.virtual,
9478
9511
  ...recordedToolMode !== "next_step" ? { recordedToolMode } : {},
9479
9512
  ...recordedToolUnmatchedPolicy !== "fail" ? { recordedToolUnmatchedPolicy } : {},
9513
+ ...identityDefaults !== void 0 ? { identityDefaults } : {},
9480
9514
  cases: [...definition.cases].sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0).map((c) => ({
9481
9515
  name: c.name,
9482
9516
  input: normalizeForHash(c.input),
@@ -14455,7 +14489,7 @@ function transformQueryParams(params) {
14455
14489
  }
14456
14490
  //#endregion
14457
14491
  //#region src/version.ts
14458
- const SDK_VERSION = "10.15.0";
14492
+ const SDK_VERSION = "10.16.0";
14459
14493
  /**
14460
14494
  * Canonical client identity the API uses for attribution
14461
14495
  * (`detectActorSource` in apps/api/src/lib/audit-log.ts keys `'sdk'` off the
@@ -14491,6 +14525,10 @@ function isPausedLocalActionResult(value) {
14491
14525
  return isObjectRecord(value) && value.status === "paused" && Array.isArray(value.pausedTools) && value.pausedTools.length > 0;
14492
14526
  }
14493
14527
  var RuntypeClient = class {
14528
+ /** List supported decision models; credentials and spending policy are checked at execution. */
14529
+ async listDecisionModels() {
14530
+ return this.get("/decision-models");
14531
+ }
14494
14532
  constructor(config = {}) {
14495
14533
  const baseUrl = config.baseUrl || "https://api.runtype.com";
14496
14534
  this.apiVersion = config.apiVersion || "v1";
@@ -14576,6 +14614,7 @@ var RuntypeClient = class {
14576
14614
  parametersSchema: entry.parametersSchema,
14577
14615
  ...entry.origin ? { origin: entry.origin } : {},
14578
14616
  ...entry.pageOrigin ? { pageOrigin: entry.pageOrigin } : {},
14617
+ ...entry.annotations ? { annotations: entry.annotations } : {},
14579
14618
  ...entry.untrustedContentHint ? { untrustedContentHint: true } : {}
14580
14619
  })) : [];
14581
14620
  const modifiedRequest = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runtypelabs/sdk",
3
- "version": "10.15.0",
3
+ "version": "10.16.0",
4
4
  "type": "module",
5
5
  "description": "TypeScript SDK for the Runtype API with fluent methods. Use it to quickly realize AI products, agents, and workflows.",
6
6
  "main": "dist/index.cjs",
@@ -24,7 +24,7 @@
24
24
  ],
25
25
  "dependencies": {},
26
26
  "devDependencies": {
27
- "@runtypelabs/shared": "3.81.0",
27
+ "@runtypelabs/shared": "3.82.0",
28
28
  "openapi-typescript": "^7.13.0",
29
29
  "tsdown": "^0.23.0",
30
30
  "typescript": "^6.0.3",