@runtypelabs/sdk 5.3.1 → 5.4.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 +437 -68
- package/dist/index.d.cts +752 -1
- package/dist/index.d.ts +752 -1
- package/dist/index.mjs +421 -68
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -99,12 +99,14 @@ __export(index_exports, {
|
|
|
99
99
|
buildSendViewOffloadMarker: () => buildSendViewOffloadMarker,
|
|
100
100
|
compileWorkflowConfig: () => compileWorkflowConfig,
|
|
101
101
|
computeAgentContentHash: () => computeAgentContentHash,
|
|
102
|
+
computeEvalContentHash: () => computeEvalContentHash,
|
|
102
103
|
computeFlowContentHash: () => computeFlowContentHash,
|
|
103
104
|
computeFpoContentHash: () => computeFpoContentHash,
|
|
104
105
|
computeProductContentHash: () => computeProductContentHash,
|
|
105
106
|
computeSkillContentHash: () => computeSkillContentHash,
|
|
106
107
|
computeSurfaceContentHash: () => computeSurfaceContentHash,
|
|
107
108
|
computeToolContentHash: () => computeToolContentHash,
|
|
109
|
+
contains: () => contains,
|
|
108
110
|
createAgentEventTranslator: () => createAgentEventTranslator,
|
|
109
111
|
createClient: () => createClient,
|
|
110
112
|
createExternalTool: () => createExternalTool,
|
|
@@ -112,6 +114,7 @@ __export(index_exports, {
|
|
|
112
114
|
defaultWorkflow: () => defaultWorkflow,
|
|
113
115
|
defaultWorkflowConfig: () => defaultWorkflowConfig,
|
|
114
116
|
defineAgent: () => defineAgent,
|
|
117
|
+
defineEval: () => defineEval,
|
|
115
118
|
defineFlow: () => defineFlow,
|
|
116
119
|
defineFpo: () => defineFpo,
|
|
117
120
|
definePlaybook: () => definePlaybook,
|
|
@@ -121,6 +124,7 @@ __export(index_exports, {
|
|
|
121
124
|
defineTool: () => defineTool,
|
|
122
125
|
deployWorkflow: () => deployWorkflow,
|
|
123
126
|
ensureDefaultWorkflowHooks: () => ensureDefaultWorkflowHooks,
|
|
127
|
+
ensureEval: () => ensureEval,
|
|
124
128
|
ensureFpo: () => ensureFpo,
|
|
125
129
|
evaluateGeneratedRuntimeToolProposal: () => evaluateGeneratedRuntimeToolProposal,
|
|
126
130
|
extractDeclaredToolResultChars: () => extractDeclaredToolResultChars,
|
|
@@ -133,7 +137,14 @@ __export(index_exports, {
|
|
|
133
137
|
isPreservationSensitiveTask: () => isPreservationSensitiveTask,
|
|
134
138
|
isUnifiedEventType: () => isUnifiedEventType,
|
|
135
139
|
isWorkflowHookRef: () => isWorkflowHookRef,
|
|
140
|
+
jsonField: () => jsonField,
|
|
141
|
+
judge: () => judge,
|
|
142
|
+
judges: () => judges,
|
|
143
|
+
latency: () => latency,
|
|
144
|
+
length: () => length,
|
|
136
145
|
listWorkflowHooks: () => listWorkflowHooks,
|
|
146
|
+
matchesExpected: () => matchesExpected,
|
|
147
|
+
noError: () => noError,
|
|
137
148
|
normalizeAgentDefinition: () => normalizeAgentDefinition,
|
|
138
149
|
normalizeCandidatePath: () => normalizeCandidatePath,
|
|
139
150
|
normalizeFpoDefinition: () => normalizeFpoDefinition,
|
|
@@ -141,20 +152,25 @@ __export(index_exports, {
|
|
|
141
152
|
normalizeSkillDefinition: () => normalizeSkillDefinition,
|
|
142
153
|
normalizeSurfaceDefinition: () => normalizeSurfaceDefinition,
|
|
143
154
|
normalizeToolDefinition: () => normalizeToolDefinition,
|
|
155
|
+
notContains: () => notContains,
|
|
144
156
|
parseFinalBuffer: () => parseFinalBuffer,
|
|
145
157
|
parseLedgerArtifactRelativePath: () => parseLedgerArtifactRelativePath,
|
|
146
158
|
parseOffloadedOutputId: () => parseOffloadedOutputId,
|
|
147
159
|
parseSSEChunk: () => parseSSEChunk,
|
|
148
160
|
processStream: () => processStream,
|
|
161
|
+
pullEval: () => pullEval,
|
|
149
162
|
pullFpo: () => pullFpo,
|
|
163
|
+
regex: () => regex,
|
|
150
164
|
registerWorkflowHook: () => registerWorkflowHook,
|
|
151
165
|
resolveStallStopAfter: () => resolveStallStopAfter,
|
|
152
166
|
resolveWorkflowHook: () => resolveWorkflowHook,
|
|
167
|
+
runEvalSuite: () => runEvalSuite,
|
|
153
168
|
sanitizeTaskSlug: () => sanitizeTaskSlug,
|
|
154
169
|
shouldInjectEmptySessionNudge: () => shouldInjectEmptySessionNudge,
|
|
155
170
|
shouldRequestModelEscalation: () => shouldRequestModelEscalation,
|
|
156
171
|
streamEvents: () => streamEvents,
|
|
157
172
|
unregisterWorkflowHook: () => unregisterWorkflowHook,
|
|
173
|
+
validJson: () => validJson,
|
|
158
174
|
withUnifiedEvents: () => withUnifiedEvents
|
|
159
175
|
});
|
|
160
176
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -3437,6 +3453,300 @@ var BatchesNamespace = class {
|
|
|
3437
3453
|
}
|
|
3438
3454
|
};
|
|
3439
3455
|
|
|
3456
|
+
// src/evals-ensure.ts
|
|
3457
|
+
var CHECK_GRADER_KINDS = /* @__PURE__ */ new Set([
|
|
3458
|
+
"contains",
|
|
3459
|
+
"not_contains",
|
|
3460
|
+
"matches_expected",
|
|
3461
|
+
"regex",
|
|
3462
|
+
"valid_json",
|
|
3463
|
+
"json_field",
|
|
3464
|
+
"length",
|
|
3465
|
+
"latency",
|
|
3466
|
+
"no_error"
|
|
3467
|
+
]);
|
|
3468
|
+
function contains(value, opts) {
|
|
3469
|
+
return { kind: "contains", value, ...opts?.caseSensitive ? { caseSensitive: true } : {} };
|
|
3470
|
+
}
|
|
3471
|
+
function notContains(value, opts) {
|
|
3472
|
+
return { kind: "not_contains", value, ...opts?.caseSensitive ? { caseSensitive: true } : {} };
|
|
3473
|
+
}
|
|
3474
|
+
function matchesExpected() {
|
|
3475
|
+
return { kind: "matches_expected" };
|
|
3476
|
+
}
|
|
3477
|
+
function regex(pattern, flags) {
|
|
3478
|
+
return { kind: "regex", pattern, ...flags ? { flags } : {} };
|
|
3479
|
+
}
|
|
3480
|
+
function validJson() {
|
|
3481
|
+
return { kind: "valid_json" };
|
|
3482
|
+
}
|
|
3483
|
+
function jsonField(path, opts) {
|
|
3484
|
+
return {
|
|
3485
|
+
kind: "json_field",
|
|
3486
|
+
path,
|
|
3487
|
+
...opts && "equals" in opts && opts.equals !== void 0 ? { equals: opts.equals } : {},
|
|
3488
|
+
...opts && typeof opts.exists === "boolean" ? { exists: opts.exists } : {}
|
|
3489
|
+
};
|
|
3490
|
+
}
|
|
3491
|
+
function length(opts) {
|
|
3492
|
+
if (!opts || opts.minChars === void 0 && opts.maxChars === void 0) {
|
|
3493
|
+
throw new Error("length() requires at least one of minChars or maxChars");
|
|
3494
|
+
}
|
|
3495
|
+
return {
|
|
3496
|
+
kind: "length",
|
|
3497
|
+
...opts.minChars !== void 0 ? { minChars: opts.minChars } : {},
|
|
3498
|
+
...opts.maxChars !== void 0 ? { maxChars: opts.maxChars } : {}
|
|
3499
|
+
};
|
|
3500
|
+
}
|
|
3501
|
+
function latency(maxMs) {
|
|
3502
|
+
if (!Number.isFinite(maxMs) || maxMs <= 0) {
|
|
3503
|
+
throw new Error("latency() requires a positive maxMs");
|
|
3504
|
+
}
|
|
3505
|
+
return { kind: "latency", maxMs };
|
|
3506
|
+
}
|
|
3507
|
+
function noError() {
|
|
3508
|
+
return { kind: "no_error" };
|
|
3509
|
+
}
|
|
3510
|
+
function judge(criteria, opts) {
|
|
3511
|
+
if (typeof criteria !== "string" || criteria.trim().length === 0) {
|
|
3512
|
+
throw new Error("judge() requires non-empty criteria");
|
|
3513
|
+
}
|
|
3514
|
+
return {
|
|
3515
|
+
kind: "ai",
|
|
3516
|
+
criteria,
|
|
3517
|
+
...opts?.preset ? { preset: opts.preset } : {},
|
|
3518
|
+
...opts?.useExpected ? { useExpected: true } : {},
|
|
3519
|
+
...opts?.model ? { model: opts.model } : {},
|
|
3520
|
+
...opts?.threshold !== void 0 ? { threshold: opts.threshold } : {}
|
|
3521
|
+
};
|
|
3522
|
+
}
|
|
3523
|
+
var judges = {
|
|
3524
|
+
answersQuestion: () => judge(
|
|
3525
|
+
"The response directly addresses what the user asked, without dodging or answering a different question.",
|
|
3526
|
+
{ preset: "answersQuestion" }
|
|
3527
|
+
),
|
|
3528
|
+
matchesExpected: () => judge(
|
|
3529
|
+
"The response conveys the same facts and conclusion as the expected answer. Wording may differ.",
|
|
3530
|
+
{ preset: "matchesExpected", useExpected: true }
|
|
3531
|
+
),
|
|
3532
|
+
followsInstructions: () => judge(
|
|
3533
|
+
"The response obeys every instruction in the system prompt (format, tone, constraints, refusals).",
|
|
3534
|
+
{ preset: "followsInstructions" }
|
|
3535
|
+
),
|
|
3536
|
+
grounded: () => judge(
|
|
3537
|
+
"Every factual claim in the response is supported by the provided context or the expected answer. Flag anything invented.",
|
|
3538
|
+
{ preset: "grounded" }
|
|
3539
|
+
),
|
|
3540
|
+
rightTone: (voice = "{describe the voice you want}") => judge(`The response matches this voice: ${voice}.`, { preset: "rightTone" }),
|
|
3541
|
+
safeToSend: () => judge(
|
|
3542
|
+
"The response contains nothing embarrassing to show a customer: no leaked internals, no hostile tone, no policy violations.",
|
|
3543
|
+
{ preset: "safeToSend" }
|
|
3544
|
+
)
|
|
3545
|
+
};
|
|
3546
|
+
var DEFINE_EVAL_TOP_LEVEL_KEYS = /* @__PURE__ */ new Set([
|
|
3547
|
+
"name",
|
|
3548
|
+
"target",
|
|
3549
|
+
"graders",
|
|
3550
|
+
"cases",
|
|
3551
|
+
"virtual"
|
|
3552
|
+
]);
|
|
3553
|
+
var DEFINE_EVAL_CASE_KEYS = /* @__PURE__ */ new Set(["name", "input", "expected", "expect"]);
|
|
3554
|
+
function isPlainObject2(value) {
|
|
3555
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
3556
|
+
}
|
|
3557
|
+
function normalizeTarget(target) {
|
|
3558
|
+
if (!isPlainObject2(target)) {
|
|
3559
|
+
throw new Error('defineEval requires a "target" object: { flow: name } or { agent: name }');
|
|
3560
|
+
}
|
|
3561
|
+
const hasFlow = typeof target.flow === "string" && target.flow.length > 0;
|
|
3562
|
+
const hasAgent = typeof target.agent === "string" && target.agent.length > 0;
|
|
3563
|
+
if (hasFlow === hasAgent) {
|
|
3564
|
+
throw new Error(
|
|
3565
|
+
'defineEval "target" must name exactly one of flow or agent: { flow: "name" } XOR { agent: "name" }'
|
|
3566
|
+
);
|
|
3567
|
+
}
|
|
3568
|
+
const extraKeys = Object.keys(target).filter((k) => k !== "flow" && k !== "agent");
|
|
3569
|
+
if (extraKeys.length > 0) {
|
|
3570
|
+
throw new Error(`defineEval "target" has unknown field(s): ${extraKeys.join(", ")}`);
|
|
3571
|
+
}
|
|
3572
|
+
return hasFlow ? { flow: target.flow } : { agent: target.agent };
|
|
3573
|
+
}
|
|
3574
|
+
function validateGrader(grader, where) {
|
|
3575
|
+
if (!isPlainObject2(grader) || typeof grader.kind !== "string") {
|
|
3576
|
+
throw new Error(`defineEval: ${where} must be a grader object with a string "kind"`);
|
|
3577
|
+
}
|
|
3578
|
+
if (grader.kind === "ai") {
|
|
3579
|
+
if (typeof grader.criteria !== "string" || grader.criteria.trim().length === 0) {
|
|
3580
|
+
throw new Error(`defineEval: ${where} is an AI grader and requires non-empty "criteria"`);
|
|
3581
|
+
}
|
|
3582
|
+
return grader;
|
|
3583
|
+
}
|
|
3584
|
+
if (!CHECK_GRADER_KINDS.has(grader.kind)) {
|
|
3585
|
+
throw new Error(
|
|
3586
|
+
`defineEval: ${where} has unknown grader kind "${grader.kind}". Known kinds: ${[...CHECK_GRADER_KINDS].join(", ")}, ai. (Trace graders such as called_tool/step_order are not available yet.)`
|
|
3587
|
+
);
|
|
3588
|
+
}
|
|
3589
|
+
return grader;
|
|
3590
|
+
}
|
|
3591
|
+
function normalizeCaseInput(input, where) {
|
|
3592
|
+
if (input === void 0) return {};
|
|
3593
|
+
if (!isPlainObject2(input)) {
|
|
3594
|
+
throw new Error(`defineEval: ${where} "input" must be an object`);
|
|
3595
|
+
}
|
|
3596
|
+
const out = {};
|
|
3597
|
+
if (input.variables !== void 0) {
|
|
3598
|
+
if (!isPlainObject2(input.variables)) {
|
|
3599
|
+
throw new Error(`defineEval: ${where} "input.variables" must be an object`);
|
|
3600
|
+
}
|
|
3601
|
+
out.variables = input.variables;
|
|
3602
|
+
}
|
|
3603
|
+
if (input.messages !== void 0) {
|
|
3604
|
+
if (!Array.isArray(input.messages)) {
|
|
3605
|
+
throw new Error(`defineEval: ${where} "input.messages" must be an array`);
|
|
3606
|
+
}
|
|
3607
|
+
out.messages = input.messages.map((m, i) => {
|
|
3608
|
+
if (!isPlainObject2(m) || typeof m.role !== "string" || typeof m.content !== "string") {
|
|
3609
|
+
throw new Error(`defineEval: ${where} "input.messages[${i}]" must be { role, content }`);
|
|
3610
|
+
}
|
|
3611
|
+
return { role: m.role, content: m.content };
|
|
3612
|
+
});
|
|
3613
|
+
}
|
|
3614
|
+
return out;
|
|
3615
|
+
}
|
|
3616
|
+
function defineEval(input) {
|
|
3617
|
+
if (!input || typeof input !== "object") {
|
|
3618
|
+
throw new Error("defineEval requires a definition object");
|
|
3619
|
+
}
|
|
3620
|
+
const unknownKeys = Object.keys(input).filter((k) => !DEFINE_EVAL_TOP_LEVEL_KEYS.has(k));
|
|
3621
|
+
if (unknownKeys.length > 0) {
|
|
3622
|
+
throw new Error(
|
|
3623
|
+
`defineEval: unknown field(s): ${unknownKeys.join(", ")}. Allowed fields are target, graders, cases, virtual.`
|
|
3624
|
+
);
|
|
3625
|
+
}
|
|
3626
|
+
const target = normalizeTarget(input.target);
|
|
3627
|
+
if (input.name !== void 0 && (typeof input.name !== "string" || input.name.length === 0)) {
|
|
3628
|
+
throw new Error('defineEval "name" must be a non-empty string when provided');
|
|
3629
|
+
}
|
|
3630
|
+
const name = input.name ?? ("flow" in target ? `flow:${target.flow}` : `agent:${target.agent}`);
|
|
3631
|
+
const suiteGraders = (input.graders ?? []).map((g, i) => validateGrader(g, `graders[${i}]`));
|
|
3632
|
+
if (!Array.isArray(input.cases) || input.cases.length === 0) {
|
|
3633
|
+
throw new Error('defineEval requires a non-empty "cases" array');
|
|
3634
|
+
}
|
|
3635
|
+
const seenNames = /* @__PURE__ */ new Set();
|
|
3636
|
+
const cases = input.cases.map((c, index) => {
|
|
3637
|
+
if (!isPlainObject2(c)) {
|
|
3638
|
+
throw new Error(`defineEval: cases[${index}] must be an object`);
|
|
3639
|
+
}
|
|
3640
|
+
if (typeof c.name !== "string" || c.name.length === 0) {
|
|
3641
|
+
throw new Error(`defineEval: cases[${index}] requires a non-empty string "name"`);
|
|
3642
|
+
}
|
|
3643
|
+
if (seenNames.has(c.name)) {
|
|
3644
|
+
throw new Error(`defineEval: duplicate case name "${c.name}" (case names are the identity)`);
|
|
3645
|
+
}
|
|
3646
|
+
seenNames.add(c.name);
|
|
3647
|
+
const unknownCaseKeys = Object.keys(c).filter((k) => !DEFINE_EVAL_CASE_KEYS.has(k));
|
|
3648
|
+
if (unknownCaseKeys.length > 0) {
|
|
3649
|
+
throw new Error(
|
|
3650
|
+
`defineEval: cases[${index}] ("${c.name}") has unknown field(s): ${unknownCaseKeys.join(
|
|
3651
|
+
", "
|
|
3652
|
+
)}. Allowed case fields are name, input, expected, expect.`
|
|
3653
|
+
);
|
|
3654
|
+
}
|
|
3655
|
+
const caseGraders = (c.expect ?? []).map(
|
|
3656
|
+
(g, i) => validateGrader(g, `cases[${index}].expect[${i}]`)
|
|
3657
|
+
);
|
|
3658
|
+
const expect = [...suiteGraders, ...caseGraders];
|
|
3659
|
+
if (expect.length === 0) {
|
|
3660
|
+
throw new Error(
|
|
3661
|
+
`defineEval: cases[${index}] ("${c.name}") has no graders. Add suite-level "graders" or case-level "expect" so there is something to score.`
|
|
3662
|
+
);
|
|
3663
|
+
}
|
|
3664
|
+
if (c.expected !== void 0 && !isPlainObject2(c.expected)) {
|
|
3665
|
+
throw new Error(`defineEval: cases[${index}] ("${c.name}") "expected" must be an object`);
|
|
3666
|
+
}
|
|
3667
|
+
return {
|
|
3668
|
+
name: c.name,
|
|
3669
|
+
input: normalizeCaseInput(c.input, `cases[${index}] ("${c.name}")`),
|
|
3670
|
+
...c.expected !== void 0 ? { expected: c.expected } : {},
|
|
3671
|
+
expect
|
|
3672
|
+
};
|
|
3673
|
+
});
|
|
3674
|
+
return { name, target, cases, virtual: input.virtual === true };
|
|
3675
|
+
}
|
|
3676
|
+
function normalizeForHash(value) {
|
|
3677
|
+
if (Array.isArray(value)) return value.map(normalizeForHash);
|
|
3678
|
+
if (isPlainObject2(value)) {
|
|
3679
|
+
const out = {};
|
|
3680
|
+
for (const key of Object.keys(value).sort()) {
|
|
3681
|
+
const v = value[key];
|
|
3682
|
+
if (v === void 0) continue;
|
|
3683
|
+
out[key] = normalizeForHash(v);
|
|
3684
|
+
}
|
|
3685
|
+
return out;
|
|
3686
|
+
}
|
|
3687
|
+
return value;
|
|
3688
|
+
}
|
|
3689
|
+
async function computeEvalContentHash(definition) {
|
|
3690
|
+
const canonical = {
|
|
3691
|
+
target: normalizeForHash(definition.target),
|
|
3692
|
+
virtual: definition.virtual,
|
|
3693
|
+
cases: [...definition.cases].sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0).map((c) => ({
|
|
3694
|
+
name: c.name,
|
|
3695
|
+
input: normalizeForHash(c.input),
|
|
3696
|
+
...c.expected !== void 0 ? { expected: normalizeForHash(c.expected) } : {},
|
|
3697
|
+
// Grader order preserved on purpose (it maps to the result index).
|
|
3698
|
+
expect: c.expect.map((g) => normalizeForHash(g))
|
|
3699
|
+
}))
|
|
3700
|
+
};
|
|
3701
|
+
const serialized = JSON.stringify(canonical);
|
|
3702
|
+
const encoded = new TextEncoder().encode(serialized);
|
|
3703
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", encoded);
|
|
3704
|
+
return Array.from(new Uint8Array(hashBuffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
3705
|
+
}
|
|
3706
|
+
var serverHashMemo2 = /* @__PURE__ */ new WeakMap();
|
|
3707
|
+
function memoFor2(client) {
|
|
3708
|
+
let memo = serverHashMemo2.get(client);
|
|
3709
|
+
if (!memo) {
|
|
3710
|
+
memo = /* @__PURE__ */ new Map();
|
|
3711
|
+
serverHashMemo2.set(client, memo);
|
|
3712
|
+
}
|
|
3713
|
+
return memo;
|
|
3714
|
+
}
|
|
3715
|
+
async function ensureEval(client, definition) {
|
|
3716
|
+
if (definition.virtual) {
|
|
3717
|
+
throw new Error(
|
|
3718
|
+
"Cannot ensure a virtual eval: virtual evals are ephemeral (nothing is persisted to converge). Remove `virtual: true` to converge a durable suite, or run it directly."
|
|
3719
|
+
);
|
|
3720
|
+
}
|
|
3721
|
+
const memo = memoFor2(client);
|
|
3722
|
+
const localHash = await computeEvalContentHash(definition);
|
|
3723
|
+
const memoKey = `${definition.name} ${localHash}`;
|
|
3724
|
+
const contentHash = memo.get(memoKey) ?? localHash;
|
|
3725
|
+
const probe = await client.post(
|
|
3726
|
+
"/eval/ensure",
|
|
3727
|
+
{ name: definition.name, contentHash }
|
|
3728
|
+
);
|
|
3729
|
+
if (probe.result !== "definitionRequired") {
|
|
3730
|
+
memo.set(memoKey, probe.contentHash);
|
|
3731
|
+
return probe;
|
|
3732
|
+
}
|
|
3733
|
+
const converged = await client.post(
|
|
3734
|
+
"/eval/ensure",
|
|
3735
|
+
{ name: definition.name, definition }
|
|
3736
|
+
);
|
|
3737
|
+
if (converged.result === "definitionRequired") {
|
|
3738
|
+
throw new Error("Server reported definitionRequired for a full-definition request");
|
|
3739
|
+
}
|
|
3740
|
+
memo.set(memoKey, converged.contentHash);
|
|
3741
|
+
return converged;
|
|
3742
|
+
}
|
|
3743
|
+
async function pullEval(client, name) {
|
|
3744
|
+
return client.get("/eval/pull", { name });
|
|
3745
|
+
}
|
|
3746
|
+
async function runEvalSuite(client, input) {
|
|
3747
|
+
return client.post("/eval/run", input);
|
|
3748
|
+
}
|
|
3749
|
+
|
|
3440
3750
|
// src/evals-namespace.ts
|
|
3441
3751
|
var EvalRunner = class {
|
|
3442
3752
|
constructor(getClient, config) {
|
|
@@ -3581,6 +3891,49 @@ var EvalsNamespace = class {
|
|
|
3581
3891
|
run(config) {
|
|
3582
3892
|
return new EvalRunner(this.getClient, config);
|
|
3583
3893
|
}
|
|
3894
|
+
/**
|
|
3895
|
+
* Idempotently converge a `defineEval` suite definition onto the platform —
|
|
3896
|
+
* the deploy-time, non-executing converge for code-colocated evals. Hash-first:
|
|
3897
|
+
* the steady state is one tiny probe request. Upserts the eval suite + replaces
|
|
3898
|
+
* its cases; never runs the eval.
|
|
3899
|
+
*
|
|
3900
|
+
* @example
|
|
3901
|
+
* ```typescript
|
|
3902
|
+
* const suite = defineEval({
|
|
3903
|
+
* target: { flow: 'support-triage' },
|
|
3904
|
+
* graders: [noError()],
|
|
3905
|
+
* cases: [{ name: 'billing', input: { variables: { message: 'I was double charged' } }, expect: [contains('finance')] }],
|
|
3906
|
+
* })
|
|
3907
|
+
* const result = await Runtype.evals.ensure(suite)
|
|
3908
|
+
* ```
|
|
3909
|
+
*/
|
|
3910
|
+
async ensure(definition) {
|
|
3911
|
+
return ensureEval(this.getClient(), definition);
|
|
3912
|
+
}
|
|
3913
|
+
/**
|
|
3914
|
+
* Pull the canonical definition + provenance for an eval suite by name — the
|
|
3915
|
+
* absorb-drift direction of the ensure protocol.
|
|
3916
|
+
*/
|
|
3917
|
+
async pull(name) {
|
|
3918
|
+
return pullEval(this.getClient(), name);
|
|
3919
|
+
}
|
|
3920
|
+
/**
|
|
3921
|
+
* Run an eval suite synchronously and return the suite score + per-case grader
|
|
3922
|
+
* outcomes — the executing counterpart of `ensure`, powering the `runtype
|
|
3923
|
+
* eval` CI gate. Run a saved suite by id (`{ suiteId }`, the post-`ensure`
|
|
3924
|
+
* path) or an inline definition without persisting (`{ definition }`, the
|
|
3925
|
+
* virtual path).
|
|
3926
|
+
*
|
|
3927
|
+
* @example
|
|
3928
|
+
* ```typescript
|
|
3929
|
+
* const { suiteId } = await Runtype.evals.ensure(suite)
|
|
3930
|
+
* const result = await Runtype.evals.runSuite({ suiteId })
|
|
3931
|
+
* if (!result.passed) process.exit(1)
|
|
3932
|
+
* ```
|
|
3933
|
+
*/
|
|
3934
|
+
async runSuite(input) {
|
|
3935
|
+
return runEvalSuite(this.getClient(), input);
|
|
3936
|
+
}
|
|
3584
3937
|
/**
|
|
3585
3938
|
* Get evaluation status by ID
|
|
3586
3939
|
*
|
|
@@ -3699,14 +4052,14 @@ var PromptsNamespace = class {
|
|
|
3699
4052
|
};
|
|
3700
4053
|
|
|
3701
4054
|
// src/skills-ensure.ts
|
|
3702
|
-
function
|
|
4055
|
+
function isPlainObject3(value) {
|
|
3703
4056
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
3704
4057
|
}
|
|
3705
4058
|
function normalizeValue(value) {
|
|
3706
4059
|
if (Array.isArray(value)) {
|
|
3707
4060
|
return value.map((item) => normalizeValue(item));
|
|
3708
4061
|
}
|
|
3709
|
-
if (
|
|
4062
|
+
if (isPlainObject3(value)) {
|
|
3710
4063
|
const normalized = {};
|
|
3711
4064
|
for (const key of Object.keys(value).sort()) {
|
|
3712
4065
|
const entry = value[key];
|
|
@@ -3718,15 +4071,15 @@ function normalizeValue(value) {
|
|
|
3718
4071
|
return value;
|
|
3719
4072
|
}
|
|
3720
4073
|
function normalizeSkillDefinition(definition) {
|
|
3721
|
-
const manifest =
|
|
3722
|
-
const rawFrontmatter =
|
|
4074
|
+
const manifest = isPlainObject3(definition.manifest) ? definition.manifest : {};
|
|
4075
|
+
const rawFrontmatter = isPlainObject3(manifest.frontmatter) ? manifest.frontmatter : {};
|
|
3723
4076
|
const frontmatterWithoutName = {};
|
|
3724
4077
|
for (const key of Object.keys(rawFrontmatter)) {
|
|
3725
4078
|
if (key === "name") continue;
|
|
3726
4079
|
frontmatterWithoutName[key] = rawFrontmatter[key];
|
|
3727
4080
|
}
|
|
3728
4081
|
const frontmatter = normalizeValue(frontmatterWithoutName);
|
|
3729
|
-
const runtype =
|
|
4082
|
+
const runtype = isPlainObject3(manifest.runtype) ? normalizeValue(manifest.runtype) : {};
|
|
3730
4083
|
const body = typeof manifest.body === "string" ? manifest.body : "";
|
|
3731
4084
|
return { frontmatter, runtype, body };
|
|
3732
4085
|
}
|
|
@@ -3744,7 +4097,7 @@ function defineSkill(input) {
|
|
|
3744
4097
|
if (typeof input.name !== "string" || input.name.length === 0) {
|
|
3745
4098
|
throw new Error('defineSkill requires a non-empty string "name"');
|
|
3746
4099
|
}
|
|
3747
|
-
if (!
|
|
4100
|
+
if (!isPlainObject3(input.manifest)) {
|
|
3748
4101
|
throw new Error('defineSkill requires a "manifest" object ({ frontmatter, runtype, body })');
|
|
3749
4102
|
}
|
|
3750
4103
|
const unknownKeys = Object.keys(input).filter((key) => !DEFINE_SKILL_TOP_LEVEL_KEYS.has(key));
|
|
@@ -3754,7 +4107,7 @@ function defineSkill(input) {
|
|
|
3754
4107
|
);
|
|
3755
4108
|
}
|
|
3756
4109
|
const frontmatter = input.manifest.frontmatter;
|
|
3757
|
-
if (!
|
|
4110
|
+
if (!isPlainObject3(frontmatter) || typeof frontmatter.name !== "string") {
|
|
3758
4111
|
throw new Error("defineSkill: manifest.frontmatter.name is required");
|
|
3759
4112
|
}
|
|
3760
4113
|
if (frontmatter.name !== input.name) {
|
|
@@ -3795,19 +4148,19 @@ function parseRequestError2(err) {
|
|
|
3795
4148
|
}
|
|
3796
4149
|
function toConflictError2(err) {
|
|
3797
4150
|
const { status, body } = parseRequestError2(err);
|
|
3798
|
-
if (status !== 409 || !
|
|
4151
|
+
if (status !== 409 || !isPlainObject3(body)) return null;
|
|
3799
4152
|
const code = body.code;
|
|
3800
4153
|
if (code !== "external_modification" && code !== "remote_changed") return null;
|
|
3801
4154
|
return new SkillEnsureConflictError(
|
|
3802
4155
|
body
|
|
3803
4156
|
);
|
|
3804
4157
|
}
|
|
3805
|
-
var
|
|
3806
|
-
function
|
|
3807
|
-
let memo =
|
|
4158
|
+
var serverHashMemo3 = /* @__PURE__ */ new WeakMap();
|
|
4159
|
+
function memoFor3(client) {
|
|
4160
|
+
let memo = serverHashMemo3.get(client);
|
|
3808
4161
|
if (!memo) {
|
|
3809
4162
|
memo = /* @__PURE__ */ new Map();
|
|
3810
|
-
|
|
4163
|
+
serverHashMemo3.set(client, memo);
|
|
3811
4164
|
}
|
|
3812
4165
|
return memo;
|
|
3813
4166
|
}
|
|
@@ -3848,7 +4201,7 @@ async function ensureSkill(client, definition, options = {}) {
|
|
|
3848
4201
|
}
|
|
3849
4202
|
return plan;
|
|
3850
4203
|
}
|
|
3851
|
-
const memo =
|
|
4204
|
+
const memo = memoFor3(client);
|
|
3852
4205
|
const localHash = await computeSkillContentHash(definition);
|
|
3853
4206
|
const memoKey = `${definition.name} ${localHash}`;
|
|
3854
4207
|
const contentHash = memo.get(memoKey) ?? localHash;
|
|
@@ -4143,14 +4496,14 @@ var AGENT_CONFIG_KEYS = [
|
|
|
4143
4496
|
"tenancyStrategy"
|
|
4144
4497
|
];
|
|
4145
4498
|
var AGENT_CONFIG_KEY_LIST = [...AGENT_CONFIG_KEYS].sort();
|
|
4146
|
-
function
|
|
4499
|
+
function isPlainObject4(value) {
|
|
4147
4500
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
4148
4501
|
}
|
|
4149
4502
|
function normalizeValue2(value) {
|
|
4150
4503
|
if (Array.isArray(value)) {
|
|
4151
4504
|
return value.map((item) => normalizeValue2(item));
|
|
4152
4505
|
}
|
|
4153
|
-
if (
|
|
4506
|
+
if (isPlainObject4(value)) {
|
|
4154
4507
|
const normalized = {};
|
|
4155
4508
|
for (const key of Object.keys(value).sort()) {
|
|
4156
4509
|
const entry = value[key];
|
|
@@ -4163,7 +4516,7 @@ function normalizeValue2(value) {
|
|
|
4163
4516
|
}
|
|
4164
4517
|
function normalizeAgentDefinition(definition) {
|
|
4165
4518
|
const config = {};
|
|
4166
|
-
const rawConfig =
|
|
4519
|
+
const rawConfig = isPlainObject4(definition.config) ? definition.config : {};
|
|
4167
4520
|
for (const key of AGENT_CONFIG_KEY_LIST) {
|
|
4168
4521
|
const value = rawConfig[key];
|
|
4169
4522
|
if (value === void 0 || value === null) continue;
|
|
@@ -4185,7 +4538,7 @@ async function computeAgentContentHash(definition) {
|
|
|
4185
4538
|
var DEFINE_TOP_LEVEL_KEYS = /* @__PURE__ */ new Set(["name", "description", "icon", ...AGENT_CONFIG_KEYS]);
|
|
4186
4539
|
function collectNonPortableToolRefs(config) {
|
|
4187
4540
|
const tools = config.tools;
|
|
4188
|
-
if (!
|
|
4541
|
+
if (!isPlainObject4(tools)) return [];
|
|
4189
4542
|
const found = [];
|
|
4190
4543
|
const isAccountScoped = (ref) => typeof ref === "string" && ref.startsWith("tool_");
|
|
4191
4544
|
const scanArray = (value, path) => {
|
|
@@ -4195,7 +4548,7 @@ function collectNonPortableToolRefs(config) {
|
|
|
4195
4548
|
});
|
|
4196
4549
|
};
|
|
4197
4550
|
const scanKeys = (value, path) => {
|
|
4198
|
-
if (!
|
|
4551
|
+
if (!isPlainObject4(value)) return;
|
|
4199
4552
|
for (const key of Object.keys(value)) {
|
|
4200
4553
|
if (isAccountScoped(key)) found.push(`${path}.${key}`);
|
|
4201
4554
|
}
|
|
@@ -4203,16 +4556,16 @@ function collectNonPortableToolRefs(config) {
|
|
|
4203
4556
|
scanArray(tools.toolIds, "tools.toolIds");
|
|
4204
4557
|
scanKeys(tools.toolConfigs, "tools.toolConfigs");
|
|
4205
4558
|
scanKeys(tools.perToolLimits, "tools.perToolLimits");
|
|
4206
|
-
if (
|
|
4207
|
-
if (
|
|
4559
|
+
if (isPlainObject4(tools.approval)) scanArray(tools.approval.require, "tools.approval.require");
|
|
4560
|
+
if (isPlainObject4(tools.subagentConfig)) {
|
|
4208
4561
|
scanArray(tools.subagentConfig.toolPool, "tools.subagentConfig.toolPool");
|
|
4209
4562
|
}
|
|
4210
|
-
if (
|
|
4563
|
+
if (isPlainObject4(tools.codeModeConfig)) {
|
|
4211
4564
|
scanArray(tools.codeModeConfig.toolPool, "tools.codeModeConfig.toolPool");
|
|
4212
4565
|
}
|
|
4213
4566
|
if (Array.isArray(tools.runtimeTools)) {
|
|
4214
4567
|
tools.runtimeTools.forEach((runtimeTool, i) => {
|
|
4215
|
-
if (!
|
|
4568
|
+
if (!isPlainObject4(runtimeTool) || !isPlainObject4(runtimeTool.config)) return;
|
|
4216
4569
|
const base = `tools.runtimeTools[${i}].config`;
|
|
4217
4570
|
const rtConfig = runtimeTool.config;
|
|
4218
4571
|
if (runtimeTool.toolType === "subagent" && typeof rtConfig.agentId === "string" && rtConfig.agentId.startsWith("agent_")) {
|
|
@@ -4286,19 +4639,19 @@ function parseRequestError3(err) {
|
|
|
4286
4639
|
}
|
|
4287
4640
|
function toConflictError3(err) {
|
|
4288
4641
|
const { status, body } = parseRequestError3(err);
|
|
4289
|
-
if (status !== 409 || !
|
|
4642
|
+
if (status !== 409 || !isPlainObject4(body)) return null;
|
|
4290
4643
|
const code = body.code;
|
|
4291
4644
|
if (code !== "external_modification" && code !== "remote_changed") return null;
|
|
4292
4645
|
return new AgentEnsureConflictError(
|
|
4293
4646
|
body
|
|
4294
4647
|
);
|
|
4295
4648
|
}
|
|
4296
|
-
var
|
|
4297
|
-
function
|
|
4298
|
-
let memo =
|
|
4649
|
+
var serverHashMemo4 = /* @__PURE__ */ new WeakMap();
|
|
4650
|
+
function memoFor4(client) {
|
|
4651
|
+
let memo = serverHashMemo4.get(client);
|
|
4299
4652
|
if (!memo) {
|
|
4300
4653
|
memo = /* @__PURE__ */ new Map();
|
|
4301
|
-
|
|
4654
|
+
serverHashMemo4.set(client, memo);
|
|
4302
4655
|
}
|
|
4303
4656
|
return memo;
|
|
4304
4657
|
}
|
|
@@ -4335,7 +4688,7 @@ var AgentsNamespace = class {
|
|
|
4335
4688
|
}
|
|
4336
4689
|
return plan;
|
|
4337
4690
|
}
|
|
4338
|
-
const memo =
|
|
4691
|
+
const memo = memoFor4(client);
|
|
4339
4692
|
const localHash = await computeAgentContentHash({
|
|
4340
4693
|
...definition,
|
|
4341
4694
|
config: definition.config
|
|
@@ -4388,14 +4741,14 @@ var AgentsNamespace = class {
|
|
|
4388
4741
|
};
|
|
4389
4742
|
|
|
4390
4743
|
// src/tools-ensure.ts
|
|
4391
|
-
function
|
|
4744
|
+
function isPlainObject5(value) {
|
|
4392
4745
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
4393
4746
|
}
|
|
4394
4747
|
function normalizeValue3(value) {
|
|
4395
4748
|
if (Array.isArray(value)) {
|
|
4396
4749
|
return value.map((item) => normalizeValue3(item));
|
|
4397
4750
|
}
|
|
4398
|
-
if (
|
|
4751
|
+
if (isPlainObject5(value)) {
|
|
4399
4752
|
const normalized = {};
|
|
4400
4753
|
for (const key of Object.keys(value).sort()) {
|
|
4401
4754
|
const entry = value[key];
|
|
@@ -4407,8 +4760,8 @@ function normalizeValue3(value) {
|
|
|
4407
4760
|
return value;
|
|
4408
4761
|
}
|
|
4409
4762
|
function normalizeToolDefinition(definition) {
|
|
4410
|
-
const parametersSchema =
|
|
4411
|
-
const config =
|
|
4763
|
+
const parametersSchema = isPlainObject5(definition.parametersSchema) ? normalizeValue3(definition.parametersSchema) : {};
|
|
4764
|
+
const config = isPlainObject5(definition.config) ? normalizeValue3(definition.config) : {};
|
|
4412
4765
|
return {
|
|
4413
4766
|
toolType: definition.toolType,
|
|
4414
4767
|
...definition.description ? { description: definition.description } : {},
|
|
@@ -4453,10 +4806,10 @@ function defineTool(input) {
|
|
|
4453
4806
|
`defineTool requires "toolType" to be one of: ${[...TOOL_DEFINITION_TYPES].join(", ")}`
|
|
4454
4807
|
);
|
|
4455
4808
|
}
|
|
4456
|
-
if (!
|
|
4809
|
+
if (!isPlainObject5(input.parametersSchema)) {
|
|
4457
4810
|
throw new Error('defineTool requires a "parametersSchema" object (a JSON Schema)');
|
|
4458
4811
|
}
|
|
4459
|
-
if (!
|
|
4812
|
+
if (!isPlainObject5(input.config)) {
|
|
4460
4813
|
throw new Error('defineTool requires a "config" object');
|
|
4461
4814
|
}
|
|
4462
4815
|
const unknownKeys = Object.keys(input).filter((key) => !DEFINE_TOOL_TOP_LEVEL_KEYS.has(key));
|
|
@@ -4504,19 +4857,19 @@ function parseRequestError4(err) {
|
|
|
4504
4857
|
}
|
|
4505
4858
|
function toConflictError4(err) {
|
|
4506
4859
|
const { status, body } = parseRequestError4(err);
|
|
4507
|
-
if (status !== 409 || !
|
|
4860
|
+
if (status !== 409 || !isPlainObject5(body)) return null;
|
|
4508
4861
|
const code = body.code;
|
|
4509
4862
|
if (code !== "external_modification" && code !== "remote_changed") return null;
|
|
4510
4863
|
return new ToolEnsureConflictError(
|
|
4511
4864
|
body
|
|
4512
4865
|
);
|
|
4513
4866
|
}
|
|
4514
|
-
var
|
|
4515
|
-
function
|
|
4516
|
-
let memo =
|
|
4867
|
+
var serverHashMemo5 = /* @__PURE__ */ new WeakMap();
|
|
4868
|
+
function memoFor5(client) {
|
|
4869
|
+
let memo = serverHashMemo5.get(client);
|
|
4517
4870
|
if (!memo) {
|
|
4518
4871
|
memo = /* @__PURE__ */ new Map();
|
|
4519
|
-
|
|
4872
|
+
serverHashMemo5.set(client, memo);
|
|
4520
4873
|
}
|
|
4521
4874
|
return memo;
|
|
4522
4875
|
}
|
|
@@ -4556,7 +4909,7 @@ async function ensureTool(client, definition, options = {}) {
|
|
|
4556
4909
|
}
|
|
4557
4910
|
return plan;
|
|
4558
4911
|
}
|
|
4559
|
-
const memo =
|
|
4912
|
+
const memo = memoFor5(client);
|
|
4560
4913
|
const localHash = await computeToolContentHash(definition);
|
|
4561
4914
|
const memoKey = `${definition.name} ${localHash}`;
|
|
4562
4915
|
const contentHash = memo.get(memoKey) ?? localHash;
|
|
@@ -4624,14 +4977,14 @@ var ToolsNamespace = class {
|
|
|
4624
4977
|
};
|
|
4625
4978
|
|
|
4626
4979
|
// src/products-ensure.ts
|
|
4627
|
-
function
|
|
4980
|
+
function isPlainObject6(value) {
|
|
4628
4981
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
4629
4982
|
}
|
|
4630
4983
|
function normalizeValue4(value) {
|
|
4631
4984
|
if (Array.isArray(value)) {
|
|
4632
4985
|
return value.map((item) => normalizeValue4(item));
|
|
4633
4986
|
}
|
|
4634
|
-
if (
|
|
4987
|
+
if (isPlainObject6(value)) {
|
|
4635
4988
|
const normalized = {};
|
|
4636
4989
|
for (const key of Object.keys(value).sort()) {
|
|
4637
4990
|
const entry = value[key];
|
|
@@ -4643,7 +4996,7 @@ function normalizeValue4(value) {
|
|
|
4643
4996
|
return value;
|
|
4644
4997
|
}
|
|
4645
4998
|
function normalizeProductDefinition(definition) {
|
|
4646
|
-
const spec =
|
|
4999
|
+
const spec = isPlainObject6(definition.spec) ? normalizeValue4(definition.spec) : {};
|
|
4647
5000
|
return {
|
|
4648
5001
|
...definition.description ? { description: definition.description } : {},
|
|
4649
5002
|
...definition.icon ? { icon: definition.icon } : {},
|
|
@@ -4670,7 +5023,7 @@ function defineProduct(input) {
|
|
|
4670
5023
|
if (input.icon != null && typeof input.icon !== "string") {
|
|
4671
5024
|
throw new Error('defineProduct "icon" must be a string when provided');
|
|
4672
5025
|
}
|
|
4673
|
-
if (input.spec != null && !
|
|
5026
|
+
if (input.spec != null && !isPlainObject6(input.spec)) {
|
|
4674
5027
|
throw new Error('defineProduct "spec" must be an object when provided');
|
|
4675
5028
|
}
|
|
4676
5029
|
const unknownKeys = Object.keys(input).filter((key) => !DEFINE_PRODUCT_TOP_LEVEL_KEYS.has(key));
|
|
@@ -4717,19 +5070,19 @@ function parseRequestError5(err) {
|
|
|
4717
5070
|
}
|
|
4718
5071
|
function toConflictError5(err) {
|
|
4719
5072
|
const { status, body } = parseRequestError5(err);
|
|
4720
|
-
if (status !== 409 || !
|
|
5073
|
+
if (status !== 409 || !isPlainObject6(body)) return null;
|
|
4721
5074
|
const code = body.code;
|
|
4722
5075
|
if (code !== "external_modification" && code !== "remote_changed") return null;
|
|
4723
5076
|
return new ProductEnsureConflictError(
|
|
4724
5077
|
body
|
|
4725
5078
|
);
|
|
4726
5079
|
}
|
|
4727
|
-
var
|
|
4728
|
-
function
|
|
4729
|
-
let memo =
|
|
5080
|
+
var serverHashMemo6 = /* @__PURE__ */ new WeakMap();
|
|
5081
|
+
function memoFor6(client) {
|
|
5082
|
+
let memo = serverHashMemo6.get(client);
|
|
4730
5083
|
if (!memo) {
|
|
4731
5084
|
memo = /* @__PURE__ */ new Map();
|
|
4732
|
-
|
|
5085
|
+
serverHashMemo6.set(client, memo);
|
|
4733
5086
|
}
|
|
4734
5087
|
return memo;
|
|
4735
5088
|
}
|
|
@@ -4769,7 +5122,7 @@ async function ensureProduct(client, definition, options = {}) {
|
|
|
4769
5122
|
}
|
|
4770
5123
|
return plan;
|
|
4771
5124
|
}
|
|
4772
|
-
const memo =
|
|
5125
|
+
const memo = memoFor6(client);
|
|
4773
5126
|
const localHash = await computeProductContentHash(definition);
|
|
4774
5127
|
const memoKey = `${definition.name} ${localHash}`;
|
|
4775
5128
|
const contentHash = memo.get(memoKey) ?? localHash;
|
|
@@ -4798,14 +5151,14 @@ async function pullProduct(client, name) {
|
|
|
4798
5151
|
}
|
|
4799
5152
|
|
|
4800
5153
|
// src/products-ensure-fpo.ts
|
|
4801
|
-
function
|
|
5154
|
+
function isPlainObject7(value) {
|
|
4802
5155
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
4803
5156
|
}
|
|
4804
5157
|
function normalizeValue5(value) {
|
|
4805
5158
|
if (Array.isArray(value)) {
|
|
4806
5159
|
return value.map((item) => normalizeValue5(item));
|
|
4807
5160
|
}
|
|
4808
|
-
if (
|
|
5161
|
+
if (isPlainObject7(value)) {
|
|
4809
5162
|
const normalized = {};
|
|
4810
5163
|
for (const key of Object.keys(value).sort()) {
|
|
4811
5164
|
const entry = value[key];
|
|
@@ -4817,7 +5170,7 @@ function normalizeValue5(value) {
|
|
|
4817
5170
|
return value;
|
|
4818
5171
|
}
|
|
4819
5172
|
function normalizeFpoDefinition(fpo) {
|
|
4820
|
-
const productInput =
|
|
5173
|
+
const productInput = isPlainObject7(fpo.product) ? fpo.product : {};
|
|
4821
5174
|
const { name: _identityName, ...productRest } = productInput;
|
|
4822
5175
|
const product = normalizeValue5(productRest);
|
|
4823
5176
|
return {
|
|
@@ -4838,10 +5191,10 @@ async function computeFpoContentHash(fpo) {
|
|
|
4838
5191
|
return Array.from(new Uint8Array(hashBuffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
4839
5192
|
}
|
|
4840
5193
|
function defineFpo(fpo) {
|
|
4841
|
-
if (!
|
|
5194
|
+
if (!isPlainObject7(fpo)) {
|
|
4842
5195
|
throw new Error("defineFpo requires an FPO object");
|
|
4843
5196
|
}
|
|
4844
|
-
const product =
|
|
5197
|
+
const product = isPlainObject7(fpo.product) ? fpo.product : void 0;
|
|
4845
5198
|
if (!product || typeof product.name !== "string" || product.name.length === 0) {
|
|
4846
5199
|
throw new Error('defineFpo requires a non-empty "product.name" (the converge identity)');
|
|
4847
5200
|
}
|
|
@@ -4937,14 +5290,14 @@ var ProductsNamespace = class {
|
|
|
4937
5290
|
};
|
|
4938
5291
|
|
|
4939
5292
|
// src/surfaces-ensure.ts
|
|
4940
|
-
function
|
|
5293
|
+
function isPlainObject8(value) {
|
|
4941
5294
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
4942
5295
|
}
|
|
4943
5296
|
function normalizeValue6(value) {
|
|
4944
5297
|
if (Array.isArray(value)) {
|
|
4945
5298
|
return value.map((item) => normalizeValue6(item));
|
|
4946
5299
|
}
|
|
4947
|
-
if (
|
|
5300
|
+
if (isPlainObject8(value)) {
|
|
4948
5301
|
const normalized = {};
|
|
4949
5302
|
for (const key of Object.keys(value).sort()) {
|
|
4950
5303
|
const entry = value[key];
|
|
@@ -4956,7 +5309,7 @@ function normalizeValue6(value) {
|
|
|
4956
5309
|
return value;
|
|
4957
5310
|
}
|
|
4958
5311
|
function normalizeSurfaceDefinition(definition) {
|
|
4959
|
-
const behavior =
|
|
5312
|
+
const behavior = isPlainObject8(definition.behavior) ? normalizeValue6(definition.behavior) : { type: definition.type };
|
|
4960
5313
|
return {
|
|
4961
5314
|
type: definition.type,
|
|
4962
5315
|
behavior,
|
|
@@ -5009,13 +5362,13 @@ function defineSurface(input) {
|
|
|
5009
5362
|
`defineSurface requires "type" to be one of: ${[...SURFACE_DEFINITION_TYPES].join(", ")}`
|
|
5010
5363
|
);
|
|
5011
5364
|
}
|
|
5012
|
-
if (input.behavior !== void 0 && !
|
|
5365
|
+
if (input.behavior !== void 0 && !isPlainObject8(input.behavior)) {
|
|
5013
5366
|
throw new Error('defineSurface "behavior" must be an object when provided');
|
|
5014
5367
|
}
|
|
5015
|
-
if (input.inbound !== void 0 && !
|
|
5368
|
+
if (input.inbound !== void 0 && !isPlainObject8(input.inbound)) {
|
|
5016
5369
|
throw new Error('defineSurface "inbound" must be an object when provided');
|
|
5017
5370
|
}
|
|
5018
|
-
if (input.outbound !== void 0 && !
|
|
5371
|
+
if (input.outbound !== void 0 && !isPlainObject8(input.outbound)) {
|
|
5019
5372
|
throw new Error('defineSurface "outbound" must be an object when provided');
|
|
5020
5373
|
}
|
|
5021
5374
|
if (input.status !== void 0 && !["draft", "active", "paused"].includes(input.status)) {
|
|
@@ -5071,19 +5424,19 @@ function parseRequestError6(err) {
|
|
|
5071
5424
|
}
|
|
5072
5425
|
function toConflictError6(err) {
|
|
5073
5426
|
const { status, body } = parseRequestError6(err);
|
|
5074
|
-
if (status !== 409 || !
|
|
5427
|
+
if (status !== 409 || !isPlainObject8(body)) return null;
|
|
5075
5428
|
const code = body.code;
|
|
5076
5429
|
if (code !== "external_modification" && code !== "remote_changed") return null;
|
|
5077
5430
|
return new SurfaceEnsureConflictError(
|
|
5078
5431
|
body
|
|
5079
5432
|
);
|
|
5080
5433
|
}
|
|
5081
|
-
var
|
|
5082
|
-
function
|
|
5083
|
-
let memo =
|
|
5434
|
+
var serverHashMemo7 = /* @__PURE__ */ new WeakMap();
|
|
5435
|
+
function memoFor7(client) {
|
|
5436
|
+
let memo = serverHashMemo7.get(client);
|
|
5084
5437
|
if (!memo) {
|
|
5085
5438
|
memo = /* @__PURE__ */ new Map();
|
|
5086
|
-
|
|
5439
|
+
serverHashMemo7.set(client, memo);
|
|
5087
5440
|
}
|
|
5088
5441
|
return memo;
|
|
5089
5442
|
}
|
|
@@ -5123,7 +5476,7 @@ async function ensureSurface(client, productId, definition, options = {}) {
|
|
|
5123
5476
|
}
|
|
5124
5477
|
return plan;
|
|
5125
5478
|
}
|
|
5126
|
-
const memo =
|
|
5479
|
+
const memo = memoFor7(client);
|
|
5127
5480
|
const localHash = await computeSurfaceContentHash(definition);
|
|
5128
5481
|
const memoKey = `${productId} ${definition.name} ${localHash}`;
|
|
5129
5482
|
const contentHash = memo.get(memoKey) ?? localHash;
|
|
@@ -5672,7 +6025,7 @@ var Runtype = class {
|
|
|
5672
6025
|
|
|
5673
6026
|
// src/version.ts
|
|
5674
6027
|
var FALLBACK_VERSION = "0.0.0";
|
|
5675
|
-
var SDK_VERSION = "5.
|
|
6028
|
+
var SDK_VERSION = "5.4.0".length > 0 ? "5.4.0" : FALLBACK_VERSION;
|
|
5676
6029
|
var RUNTYPE_CLIENT_KIND = "sdk";
|
|
5677
6030
|
var SDK_USER_AGENT = `runtype-sdk/${SDK_VERSION} (typescript)`;
|
|
5678
6031
|
|
|
@@ -13385,12 +13738,14 @@ var STEP_TYPE_TO_METHOD = {
|
|
|
13385
13738
|
buildSendViewOffloadMarker,
|
|
13386
13739
|
compileWorkflowConfig,
|
|
13387
13740
|
computeAgentContentHash,
|
|
13741
|
+
computeEvalContentHash,
|
|
13388
13742
|
computeFlowContentHash,
|
|
13389
13743
|
computeFpoContentHash,
|
|
13390
13744
|
computeProductContentHash,
|
|
13391
13745
|
computeSkillContentHash,
|
|
13392
13746
|
computeSurfaceContentHash,
|
|
13393
13747
|
computeToolContentHash,
|
|
13748
|
+
contains,
|
|
13394
13749
|
createAgentEventTranslator,
|
|
13395
13750
|
createClient,
|
|
13396
13751
|
createExternalTool,
|
|
@@ -13398,6 +13753,7 @@ var STEP_TYPE_TO_METHOD = {
|
|
|
13398
13753
|
defaultWorkflow,
|
|
13399
13754
|
defaultWorkflowConfig,
|
|
13400
13755
|
defineAgent,
|
|
13756
|
+
defineEval,
|
|
13401
13757
|
defineFlow,
|
|
13402
13758
|
defineFpo,
|
|
13403
13759
|
definePlaybook,
|
|
@@ -13407,6 +13763,7 @@ var STEP_TYPE_TO_METHOD = {
|
|
|
13407
13763
|
defineTool,
|
|
13408
13764
|
deployWorkflow,
|
|
13409
13765
|
ensureDefaultWorkflowHooks,
|
|
13766
|
+
ensureEval,
|
|
13410
13767
|
ensureFpo,
|
|
13411
13768
|
evaluateGeneratedRuntimeToolProposal,
|
|
13412
13769
|
extractDeclaredToolResultChars,
|
|
@@ -13419,7 +13776,14 @@ var STEP_TYPE_TO_METHOD = {
|
|
|
13419
13776
|
isPreservationSensitiveTask,
|
|
13420
13777
|
isUnifiedEventType,
|
|
13421
13778
|
isWorkflowHookRef,
|
|
13779
|
+
jsonField,
|
|
13780
|
+
judge,
|
|
13781
|
+
judges,
|
|
13782
|
+
latency,
|
|
13783
|
+
length,
|
|
13422
13784
|
listWorkflowHooks,
|
|
13785
|
+
matchesExpected,
|
|
13786
|
+
noError,
|
|
13423
13787
|
normalizeAgentDefinition,
|
|
13424
13788
|
normalizeCandidatePath,
|
|
13425
13789
|
normalizeFpoDefinition,
|
|
@@ -13427,19 +13791,24 @@ var STEP_TYPE_TO_METHOD = {
|
|
|
13427
13791
|
normalizeSkillDefinition,
|
|
13428
13792
|
normalizeSurfaceDefinition,
|
|
13429
13793
|
normalizeToolDefinition,
|
|
13794
|
+
notContains,
|
|
13430
13795
|
parseFinalBuffer,
|
|
13431
13796
|
parseLedgerArtifactRelativePath,
|
|
13432
13797
|
parseOffloadedOutputId,
|
|
13433
13798
|
parseSSEChunk,
|
|
13434
13799
|
processStream,
|
|
13800
|
+
pullEval,
|
|
13435
13801
|
pullFpo,
|
|
13802
|
+
regex,
|
|
13436
13803
|
registerWorkflowHook,
|
|
13437
13804
|
resolveStallStopAfter,
|
|
13438
13805
|
resolveWorkflowHook,
|
|
13806
|
+
runEvalSuite,
|
|
13439
13807
|
sanitizeTaskSlug,
|
|
13440
13808
|
shouldInjectEmptySessionNudge,
|
|
13441
13809
|
shouldRequestModelEscalation,
|
|
13442
13810
|
streamEvents,
|
|
13443
13811
|
unregisterWorkflowHook,
|
|
13812
|
+
validJson,
|
|
13444
13813
|
withUnifiedEvents
|
|
13445
13814
|
});
|