@runtypelabs/sdk 10.15.1 → 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 +39 -4
- package/dist/index.d.cts +381 -4
- package/dist/index.d.ts +381 -4
- package/dist/index.mjs +39 -4
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -9329,7 +9329,8 @@ const DEFINE_EVAL_TOP_LEVEL_KEYS = /* @__PURE__ */ new Set([
|
|
|
9329
9329
|
"cases",
|
|
9330
9330
|
"virtual",
|
|
9331
9331
|
"recordedToolMode",
|
|
9332
|
-
"recordedToolUnmatchedPolicy"
|
|
9332
|
+
"recordedToolUnmatchedPolicy",
|
|
9333
|
+
"identityDefaults"
|
|
9333
9334
|
]);
|
|
9334
9335
|
const DEFINE_EVAL_CASE_KEYS = /* @__PURE__ */ new Set([
|
|
9335
9336
|
"name",
|
|
@@ -9355,6 +9356,24 @@ function validateGrader(grader, where) {
|
|
|
9355
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.`);
|
|
9356
9357
|
return grader;
|
|
9357
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
|
+
}
|
|
9358
9377
|
function normalizeCaseInput(input, where) {
|
|
9359
9378
|
if (input === void 0) return {};
|
|
9360
9379
|
if (!isPlainObject$1(input)) throw new Error(`defineEval: ${where} "input" must be an object`);
|
|
@@ -9389,6 +9408,8 @@ function normalizeCaseInput(input, where) {
|
|
|
9389
9408
|
return mock;
|
|
9390
9409
|
});
|
|
9391
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"`);
|
|
9392
9413
|
return out;
|
|
9393
9414
|
}
|
|
9394
9415
|
/**
|
|
@@ -9418,10 +9439,11 @@ function normalizeCaseInput(input, where) {
|
|
|
9418
9439
|
function defineEval(input) {
|
|
9419
9440
|
if (!input || typeof input !== "object") throw new Error("defineEval requires a definition object");
|
|
9420
9441
|
const unknownKeys = Object.keys(input).filter((k) => !DEFINE_EVAL_TOP_LEVEL_KEYS.has(k));
|
|
9421
|
-
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.`);
|
|
9422
9443
|
if (input.recordedToolMode !== void 0 && input.recordedToolMode !== "next_step" && input.recordedToolMode !== "continue") throw new Error("defineEval \"recordedToolMode\" must be \"next_step\" or \"continue\"");
|
|
9423
9444
|
if (input.recordedToolUnmatchedPolicy !== void 0 && input.recordedToolUnmatchedPolicy !== "fail" && input.recordedToolUnmatchedPolicy !== "stub") throw new Error("defineEval \"recordedToolUnmatchedPolicy\" must be \"fail\" or \"stub\"");
|
|
9424
9445
|
const target = normalizeTarget(input.target);
|
|
9446
|
+
const identityDefaults = input.identityDefaults !== void 0 ? normalizeIdentityDefaults(input.identityDefaults) : void 0;
|
|
9425
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");
|
|
9426
9448
|
const name = input.name ?? ("flow" in target ? `flow:${target.flow}` : `agent:${target.agent}`);
|
|
9427
9449
|
const suiteGraders = (input.graders ?? []).map((g, i) => validateGrader(g, `graders[${i}]`));
|
|
@@ -9450,7 +9472,8 @@ function defineEval(input) {
|
|
|
9450
9472
|
}),
|
|
9451
9473
|
virtual: input.virtual === true,
|
|
9452
9474
|
...input.recordedToolMode !== void 0 ? { recordedToolMode: input.recordedToolMode } : {},
|
|
9453
|
-
...input.recordedToolUnmatchedPolicy !== void 0 ? { recordedToolUnmatchedPolicy: input.recordedToolUnmatchedPolicy } : {}
|
|
9475
|
+
...input.recordedToolUnmatchedPolicy !== void 0 ? { recordedToolUnmatchedPolicy: input.recordedToolUnmatchedPolicy } : {},
|
|
9476
|
+
...identityDefaults !== void 0 ? { identityDefaults } : {}
|
|
9454
9477
|
};
|
|
9455
9478
|
}
|
|
9456
9479
|
function normalizeForHash(value) {
|
|
@@ -9466,6 +9489,12 @@ function normalizeForHash(value) {
|
|
|
9466
9489
|
}
|
|
9467
9490
|
return value;
|
|
9468
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
|
+
}
|
|
9469
9498
|
/**
|
|
9470
9499
|
* SHA-256 (hex) over the canonical normalized definition. Cases are sorted by
|
|
9471
9500
|
* name (name is the case identity); grader order WITHIN a case is preserved
|
|
@@ -9475,11 +9504,13 @@ function normalizeForHash(value) {
|
|
|
9475
9504
|
async function computeEvalContentHash(definition) {
|
|
9476
9505
|
const recordedToolMode = definition.recordedToolMode ?? "next_step";
|
|
9477
9506
|
const recordedToolUnmatchedPolicy = definition.recordedToolUnmatchedPolicy ?? "fail";
|
|
9507
|
+
const identityDefaults = canonicalIdentityDefaults(definition.identityDefaults);
|
|
9478
9508
|
const canonical = {
|
|
9479
9509
|
target: normalizeForHash(definition.target),
|
|
9480
9510
|
virtual: definition.virtual,
|
|
9481
9511
|
...recordedToolMode !== "next_step" ? { recordedToolMode } : {},
|
|
9482
9512
|
...recordedToolUnmatchedPolicy !== "fail" ? { recordedToolUnmatchedPolicy } : {},
|
|
9513
|
+
...identityDefaults !== void 0 ? { identityDefaults } : {},
|
|
9483
9514
|
cases: [...definition.cases].sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0).map((c) => ({
|
|
9484
9515
|
name: c.name,
|
|
9485
9516
|
input: normalizeForHash(c.input),
|
|
@@ -14458,7 +14489,7 @@ function transformQueryParams(params) {
|
|
|
14458
14489
|
}
|
|
14459
14490
|
//#endregion
|
|
14460
14491
|
//#region src/version.ts
|
|
14461
|
-
const SDK_VERSION = "10.
|
|
14492
|
+
const SDK_VERSION = "10.16.0";
|
|
14462
14493
|
/**
|
|
14463
14494
|
* Canonical client identity the API uses for attribution
|
|
14464
14495
|
* (`detectActorSource` in apps/api/src/lib/audit-log.ts keys `'sdk'` off the
|
|
@@ -14494,6 +14525,10 @@ function isPausedLocalActionResult(value) {
|
|
|
14494
14525
|
return isObjectRecord(value) && value.status === "paused" && Array.isArray(value.pausedTools) && value.pausedTools.length > 0;
|
|
14495
14526
|
}
|
|
14496
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
|
+
}
|
|
14497
14532
|
constructor(config = {}) {
|
|
14498
14533
|
const baseUrl = config.baseUrl || "https://api.runtype.com";
|
|
14499
14534
|
this.apiVersion = config.apiVersion || "v1";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runtypelabs/sdk",
|
|
3
|
-
"version": "10.
|
|
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.
|
|
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",
|