@runtypelabs/sdk 5.9.0 → 5.10.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 +124 -180
- package/dist/index.d.cts +370 -1
- package/dist/index.d.ts +370 -1
- package/dist/index.mjs +124 -180
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1938,6 +1938,31 @@ function resolveBatchExecutionId(pausedTools) {
|
|
|
1938
1938
|
return "";
|
|
1939
1939
|
}
|
|
1940
1940
|
|
|
1941
|
+
// src/content-hash.ts
|
|
1942
|
+
function isPlainObject(value) {
|
|
1943
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
1944
|
+
}
|
|
1945
|
+
function normalizeValue(value) {
|
|
1946
|
+
if (Array.isArray(value)) {
|
|
1947
|
+
return value.map((item) => normalizeValue(item));
|
|
1948
|
+
}
|
|
1949
|
+
if (isPlainObject(value)) {
|
|
1950
|
+
const normalized = {};
|
|
1951
|
+
for (const key of Object.keys(value).sort()) {
|
|
1952
|
+
const entry = value[key];
|
|
1953
|
+
if (entry === void 0 || entry === null) continue;
|
|
1954
|
+
normalized[key] = normalizeValue(entry);
|
|
1955
|
+
}
|
|
1956
|
+
return normalized;
|
|
1957
|
+
}
|
|
1958
|
+
return value;
|
|
1959
|
+
}
|
|
1960
|
+
async function sha256Hex(serialized) {
|
|
1961
|
+
const encoded = new TextEncoder().encode(serialized);
|
|
1962
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", encoded);
|
|
1963
|
+
return Array.from(new Uint8Array(hashBuffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
1964
|
+
}
|
|
1965
|
+
|
|
1941
1966
|
// src/evals-ensure.ts
|
|
1942
1967
|
var CHECK_GRADER_KINDS = /* @__PURE__ */ new Set([
|
|
1943
1968
|
"contains",
|
|
@@ -2156,9 +2181,6 @@ var DEFINE_EVAL_TOP_LEVEL_KEYS = /* @__PURE__ */ new Set([
|
|
|
2156
2181
|
"virtual"
|
|
2157
2182
|
]);
|
|
2158
2183
|
var DEFINE_EVAL_CASE_KEYS = /* @__PURE__ */ new Set(["name", "input", "expected", "expect"]);
|
|
2159
|
-
function isPlainObject(value) {
|
|
2160
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
2161
|
-
}
|
|
2162
2184
|
function normalizeTarget(target) {
|
|
2163
2185
|
if (!isPlainObject(target)) {
|
|
2164
2186
|
throw new Error('defineEval requires a "target" object: { flow: name } or { agent: name }');
|
|
@@ -2303,10 +2325,7 @@ async function computeEvalContentHash(definition) {
|
|
|
2303
2325
|
expect: c.expect.map((g) => normalizeForHash(g))
|
|
2304
2326
|
}))
|
|
2305
2327
|
};
|
|
2306
|
-
|
|
2307
|
-
const encoded = new TextEncoder().encode(serialized);
|
|
2308
|
-
const hashBuffer = await crypto.subtle.digest("SHA-256", encoded);
|
|
2309
|
-
return Array.from(new Uint8Array(hashBuffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
2328
|
+
return sha256Hex(JSON.stringify(canonical));
|
|
2310
2329
|
}
|
|
2311
2330
|
var serverHashMemo = /* @__PURE__ */ new WeakMap();
|
|
2312
2331
|
function memoFor(client) {
|
|
@@ -2353,11 +2372,8 @@ async function runEvalSuite(client, input) {
|
|
|
2353
2372
|
}
|
|
2354
2373
|
|
|
2355
2374
|
// src/flows-ensure.ts
|
|
2356
|
-
function isPlainObject2(value) {
|
|
2357
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
2358
|
-
}
|
|
2359
2375
|
function normalizeConfigForHash(config) {
|
|
2360
|
-
if (!
|
|
2376
|
+
if (!isPlainObject(config)) return {};
|
|
2361
2377
|
const normalized = {};
|
|
2362
2378
|
for (const key of Object.keys(config).sort()) {
|
|
2363
2379
|
const value = config[key];
|
|
@@ -2378,7 +2394,7 @@ function normalizeConfigForHash(config) {
|
|
|
2378
2394
|
return normalized;
|
|
2379
2395
|
}
|
|
2380
2396
|
function normalizeStepForHash(step) {
|
|
2381
|
-
const stepObj =
|
|
2397
|
+
const stepObj = isPlainObject(step) ? step : {};
|
|
2382
2398
|
return {
|
|
2383
2399
|
type: typeof stepObj.type === "string" ? stepObj.type : "",
|
|
2384
2400
|
name: typeof stepObj.name === "string" ? stepObj.name : "",
|
|
@@ -2390,14 +2406,11 @@ function normalizeStepForHash(step) {
|
|
|
2390
2406
|
}
|
|
2391
2407
|
async function computeFlowContentHash(steps) {
|
|
2392
2408
|
const normalized = [...steps].sort((a, b) => {
|
|
2393
|
-
const orderA =
|
|
2394
|
-
const orderB =
|
|
2409
|
+
const orderA = isPlainObject(a) && typeof a.order === "number" ? a.order : 0;
|
|
2410
|
+
const orderB = isPlainObject(b) && typeof b.order === "number" ? b.order : 0;
|
|
2395
2411
|
return orderA - orderB;
|
|
2396
2412
|
}).map(normalizeStepForHash);
|
|
2397
|
-
|
|
2398
|
-
const encoded = new TextEncoder().encode(serialized);
|
|
2399
|
-
const hashBuffer = await crypto.subtle.digest("SHA-256", encoded);
|
|
2400
|
-
return Array.from(new Uint8Array(hashBuffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
2413
|
+
return sha256Hex(JSON.stringify(normalized));
|
|
2401
2414
|
}
|
|
2402
2415
|
var DEFINE_FLOW_TOP_LEVEL_KEYS = /* @__PURE__ */ new Set(["name", "steps", "evals"]);
|
|
2403
2416
|
var DEFINE_FLOW_STEP_KEYS = /* @__PURE__ */ new Set([
|
|
@@ -2420,27 +2433,27 @@ function collectStepNonPortableToolRefs(config, path) {
|
|
|
2420
2433
|
});
|
|
2421
2434
|
};
|
|
2422
2435
|
const scanKeys = (value, subPath) => {
|
|
2423
|
-
if (!
|
|
2436
|
+
if (!isPlainObject(value)) return;
|
|
2424
2437
|
for (const key of Object.keys(value)) {
|
|
2425
2438
|
if (isAccountScoped(key)) found.push(`${subPath}.${key}`);
|
|
2426
2439
|
}
|
|
2427
2440
|
};
|
|
2428
|
-
if (
|
|
2441
|
+
if (isPlainObject(tools)) {
|
|
2429
2442
|
scanArray(tools.toolIds, `${path}.tools.toolIds`);
|
|
2430
2443
|
scanKeys(tools.toolConfigs, `${path}.tools.toolConfigs`);
|
|
2431
2444
|
scanKeys(tools.perToolLimits, `${path}.tools.perToolLimits`);
|
|
2432
|
-
if (
|
|
2445
|
+
if (isPlainObject(tools.approval)) {
|
|
2433
2446
|
scanArray(tools.approval.require, `${path}.tools.approval.require`);
|
|
2434
2447
|
}
|
|
2435
|
-
if (
|
|
2448
|
+
if (isPlainObject(tools.subagentConfig)) {
|
|
2436
2449
|
scanArray(tools.subagentConfig.toolPool, `${path}.tools.subagentConfig.toolPool`);
|
|
2437
2450
|
}
|
|
2438
|
-
if (
|
|
2451
|
+
if (isPlainObject(tools.codeModeConfig)) {
|
|
2439
2452
|
scanArray(tools.codeModeConfig.toolPool, `${path}.tools.codeModeConfig.toolPool`);
|
|
2440
2453
|
}
|
|
2441
2454
|
if (Array.isArray(tools.runtimeTools)) {
|
|
2442
2455
|
tools.runtimeTools.forEach((runtimeTool, i) => {
|
|
2443
|
-
if (!
|
|
2456
|
+
if (!isPlainObject(runtimeTool) || !isPlainObject(runtimeTool.config)) return;
|
|
2444
2457
|
const base = `${path}.tools.runtimeTools[${i}].config`;
|
|
2445
2458
|
const rtConfig = runtimeTool.config;
|
|
2446
2459
|
if (runtimeTool.toolType === "subagent" && isRawId(rtConfig.agentId, "agent_")) {
|
|
@@ -2461,7 +2474,7 @@ function collectStepNonPortableToolRefs(config, path) {
|
|
|
2461
2474
|
const nested = config[branch];
|
|
2462
2475
|
if (!Array.isArray(nested)) continue;
|
|
2463
2476
|
nested.forEach((nestedStep, i) => {
|
|
2464
|
-
if (
|
|
2477
|
+
if (isPlainObject(nestedStep) && isPlainObject(nestedStep.config)) {
|
|
2465
2478
|
found.push(
|
|
2466
2479
|
...collectStepNonPortableToolRefs(nestedStep.config, `${path}.${branch}[${i}].config`)
|
|
2467
2480
|
);
|
|
@@ -2487,7 +2500,7 @@ function defineFlow(input) {
|
|
|
2487
2500
|
throw new Error('defineFlow requires a non-empty "steps" array');
|
|
2488
2501
|
}
|
|
2489
2502
|
const steps = input.steps.map((step, index) => {
|
|
2490
|
-
if (!
|
|
2503
|
+
if (!isPlainObject(step)) {
|
|
2491
2504
|
throw new Error(`defineFlow: steps[${index}] must be an object`);
|
|
2492
2505
|
}
|
|
2493
2506
|
if (typeof step.type !== "string" || step.type.length === 0) {
|
|
@@ -2502,7 +2515,7 @@ function defineFlow(input) {
|
|
|
2502
2515
|
`defineFlow: steps[${index}] has unknown field(s): ${unknownStepKeys.join(", ")}. Allowed step fields are type, name, order, enabled, when, config. (Step ids are server artifacts and not part of a portable definition.)`
|
|
2503
2516
|
);
|
|
2504
2517
|
}
|
|
2505
|
-
const config =
|
|
2518
|
+
const config = isPlainObject(step.config) ? step.config : void 0;
|
|
2506
2519
|
if (config) {
|
|
2507
2520
|
const nonPortable = collectStepNonPortableToolRefs(config, `steps[${index}].config`);
|
|
2508
2521
|
if (nonPortable.length > 0) {
|
|
@@ -2529,7 +2542,7 @@ function defineFlow(input) {
|
|
|
2529
2542
|
}
|
|
2530
2543
|
const seenEvalNames = /* @__PURE__ */ new Set();
|
|
2531
2544
|
evals = input.evals.map((evalInput, i) => {
|
|
2532
|
-
if (!
|
|
2545
|
+
if (!isPlainObject(evalInput)) {
|
|
2533
2546
|
throw new Error(`defineFlow: evals[${i}] must be an object`);
|
|
2534
2547
|
}
|
|
2535
2548
|
if (evalInput.virtual === true) {
|
|
@@ -2593,7 +2606,7 @@ function parseRequestError(err) {
|
|
|
2593
2606
|
}
|
|
2594
2607
|
function toConflictError(err) {
|
|
2595
2608
|
const { status, body } = parseRequestError(err);
|
|
2596
|
-
if (status !== 409 || !
|
|
2609
|
+
if (status !== 409 || !isPlainObject(body)) return null;
|
|
2597
2610
|
const code = body.code;
|
|
2598
2611
|
if (code !== "external_modification" && code !== "remote_changed") return null;
|
|
2599
2612
|
return new FlowEnsureConflictError(
|
|
@@ -3888,6 +3901,18 @@ var EvalSuitesNamespace = class {
|
|
|
3888
3901
|
cases
|
|
3889
3902
|
});
|
|
3890
3903
|
}
|
|
3904
|
+
/**
|
|
3905
|
+
* Capture a test case from a real agent run ("fork here and test the next
|
|
3906
|
+
* step"): freezes the run's conversation history up to a fork point, attaches
|
|
3907
|
+
* every recorded tool result as an editable mock, and saves it with origin
|
|
3908
|
+
* `saved_from_run`. Capture only — reads the run, never re-executes it.
|
|
3909
|
+
*/
|
|
3910
|
+
async addCaseFromExecution(suiteId, input) {
|
|
3911
|
+
return this.getClient().post(
|
|
3912
|
+
`/eval/suites/${suiteId}/cases/from-execution`,
|
|
3913
|
+
input
|
|
3914
|
+
);
|
|
3915
|
+
}
|
|
3891
3916
|
/** Edit, enable, or disable a test case. */
|
|
3892
3917
|
async updateCase(suiteId, caseId, input) {
|
|
3893
3918
|
return this.getClient().patch(
|
|
@@ -4074,6 +4099,30 @@ var EvalsNamespace = class {
|
|
|
4074
4099
|
async pull(name) {
|
|
4075
4100
|
return pullEval(this.getClient(), name);
|
|
4076
4101
|
}
|
|
4102
|
+
/**
|
|
4103
|
+
* Split one plain-language AI-grader criterion carrying several obligations
|
|
4104
|
+
* into focused, independently judgeable sub-checks. Authoring assist only:
|
|
4105
|
+
* nothing is persisted — review the proposal, then save each accepted
|
|
4106
|
+
* sub-check as its own AI grader row. A single returned sub-check means the
|
|
4107
|
+
* criterion is already focused.
|
|
4108
|
+
*
|
|
4109
|
+
* @example
|
|
4110
|
+
* ```typescript
|
|
4111
|
+
* const { subChecks } = await Runtype.evals.decomposeCriteria(
|
|
4112
|
+
* 'Confirms the order number before issuing a refund, and never promises a delivery date.'
|
|
4113
|
+
* )
|
|
4114
|
+
* // In a defineEval suite, each accepted sub-check becomes its own judge row:
|
|
4115
|
+
* const graders = subChecks.map((s) => judge(s.criteria))
|
|
4116
|
+
* ```
|
|
4117
|
+
*/
|
|
4118
|
+
async decomposeCriteria(criteria) {
|
|
4119
|
+
if (typeof criteria !== "string" || criteria.trim().length === 0) {
|
|
4120
|
+
throw new Error("decomposeCriteria() requires non-empty criteria");
|
|
4121
|
+
}
|
|
4122
|
+
return this.getClient().post("/eval/graders/decompose", {
|
|
4123
|
+
criteria
|
|
4124
|
+
});
|
|
4125
|
+
}
|
|
4077
4126
|
/**
|
|
4078
4127
|
* Run an eval suite synchronously and return the suite score + per-case grader
|
|
4079
4128
|
* outcomes — the executing counterpart of `ensure`, powering the `runtype
|
|
@@ -4226,42 +4275,21 @@ var PromptsNamespace = class {
|
|
|
4226
4275
|
};
|
|
4227
4276
|
|
|
4228
4277
|
// src/skills-ensure.ts
|
|
4229
|
-
function isPlainObject3(value) {
|
|
4230
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
4231
|
-
}
|
|
4232
|
-
function normalizeValue(value) {
|
|
4233
|
-
if (Array.isArray(value)) {
|
|
4234
|
-
return value.map((item) => normalizeValue(item));
|
|
4235
|
-
}
|
|
4236
|
-
if (isPlainObject3(value)) {
|
|
4237
|
-
const normalized = {};
|
|
4238
|
-
for (const key of Object.keys(value).sort()) {
|
|
4239
|
-
const entry = value[key];
|
|
4240
|
-
if (entry === void 0 || entry === null) continue;
|
|
4241
|
-
normalized[key] = normalizeValue(entry);
|
|
4242
|
-
}
|
|
4243
|
-
return normalized;
|
|
4244
|
-
}
|
|
4245
|
-
return value;
|
|
4246
|
-
}
|
|
4247
4278
|
function normalizeSkillDefinition(definition) {
|
|
4248
|
-
const manifest =
|
|
4249
|
-
const rawFrontmatter =
|
|
4279
|
+
const manifest = isPlainObject(definition.manifest) ? definition.manifest : {};
|
|
4280
|
+
const rawFrontmatter = isPlainObject(manifest.frontmatter) ? manifest.frontmatter : {};
|
|
4250
4281
|
const frontmatterWithoutName = {};
|
|
4251
4282
|
for (const key of Object.keys(rawFrontmatter)) {
|
|
4252
4283
|
if (key === "name") continue;
|
|
4253
4284
|
frontmatterWithoutName[key] = rawFrontmatter[key];
|
|
4254
4285
|
}
|
|
4255
4286
|
const frontmatter = normalizeValue(frontmatterWithoutName);
|
|
4256
|
-
const runtype =
|
|
4287
|
+
const runtype = isPlainObject(manifest.runtype) ? normalizeValue(manifest.runtype) : {};
|
|
4257
4288
|
const body = typeof manifest.body === "string" ? manifest.body : "";
|
|
4258
4289
|
return { frontmatter, runtype, body };
|
|
4259
4290
|
}
|
|
4260
4291
|
async function computeSkillContentHash(definition) {
|
|
4261
|
-
|
|
4262
|
-
const encoded = new TextEncoder().encode(serialized);
|
|
4263
|
-
const hashBuffer = await crypto.subtle.digest("SHA-256", encoded);
|
|
4264
|
-
return Array.from(new Uint8Array(hashBuffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
4292
|
+
return sha256Hex(JSON.stringify(normalizeSkillDefinition(definition)));
|
|
4265
4293
|
}
|
|
4266
4294
|
var DEFINE_SKILL_TOP_LEVEL_KEYS = /* @__PURE__ */ new Set(["name", "manifest"]);
|
|
4267
4295
|
function defineSkill(input) {
|
|
@@ -4271,7 +4299,7 @@ function defineSkill(input) {
|
|
|
4271
4299
|
if (typeof input.name !== "string" || input.name.length === 0) {
|
|
4272
4300
|
throw new Error('defineSkill requires a non-empty string "name"');
|
|
4273
4301
|
}
|
|
4274
|
-
if (!
|
|
4302
|
+
if (!isPlainObject(input.manifest)) {
|
|
4275
4303
|
throw new Error('defineSkill requires a "manifest" object ({ frontmatter, runtype, body })');
|
|
4276
4304
|
}
|
|
4277
4305
|
const unknownKeys = Object.keys(input).filter((key) => !DEFINE_SKILL_TOP_LEVEL_KEYS.has(key));
|
|
@@ -4281,7 +4309,7 @@ function defineSkill(input) {
|
|
|
4281
4309
|
);
|
|
4282
4310
|
}
|
|
4283
4311
|
const frontmatter = input.manifest.frontmatter;
|
|
4284
|
-
if (!
|
|
4312
|
+
if (!isPlainObject(frontmatter) || typeof frontmatter.name !== "string") {
|
|
4285
4313
|
throw new Error("defineSkill: manifest.frontmatter.name is required");
|
|
4286
4314
|
}
|
|
4287
4315
|
if (frontmatter.name !== input.name) {
|
|
@@ -4322,7 +4350,7 @@ function parseRequestError2(err) {
|
|
|
4322
4350
|
}
|
|
4323
4351
|
function toConflictError2(err) {
|
|
4324
4352
|
const { status, body } = parseRequestError2(err);
|
|
4325
|
-
if (status !== 409 || !
|
|
4353
|
+
if (status !== 409 || !isPlainObject(body)) return null;
|
|
4326
4354
|
const code = body.code;
|
|
4327
4355
|
if (code !== "external_modification" && code !== "remote_changed") return null;
|
|
4328
4356
|
return new SkillEnsureConflictError(
|
|
@@ -4671,14 +4699,14 @@ var AGENT_CONFIG_KEYS = [
|
|
|
4671
4699
|
"tenancyStrategy"
|
|
4672
4700
|
];
|
|
4673
4701
|
var AGENT_CONFIG_KEY_LIST = [...AGENT_CONFIG_KEYS].sort();
|
|
4674
|
-
function
|
|
4702
|
+
function isPlainObject2(value) {
|
|
4675
4703
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
4676
4704
|
}
|
|
4677
4705
|
function normalizeValue2(value) {
|
|
4678
4706
|
if (Array.isArray(value)) {
|
|
4679
4707
|
return value.map((item) => normalizeValue2(item));
|
|
4680
4708
|
}
|
|
4681
|
-
if (
|
|
4709
|
+
if (isPlainObject2(value)) {
|
|
4682
4710
|
const normalized = {};
|
|
4683
4711
|
for (const key of Object.keys(value).sort()) {
|
|
4684
4712
|
const entry = value[key];
|
|
@@ -4691,7 +4719,7 @@ function normalizeValue2(value) {
|
|
|
4691
4719
|
}
|
|
4692
4720
|
function normalizeAgentDefinition(definition) {
|
|
4693
4721
|
const config = {};
|
|
4694
|
-
const rawConfig =
|
|
4722
|
+
const rawConfig = isPlainObject2(definition.config) ? definition.config : {};
|
|
4695
4723
|
for (const key of AGENT_CONFIG_KEY_LIST) {
|
|
4696
4724
|
const value = rawConfig[key];
|
|
4697
4725
|
if (value === void 0 || value === null) continue;
|
|
@@ -4713,7 +4741,7 @@ async function computeAgentContentHash(definition) {
|
|
|
4713
4741
|
var DEFINE_TOP_LEVEL_KEYS = /* @__PURE__ */ new Set(["name", "description", "icon", ...AGENT_CONFIG_KEYS]);
|
|
4714
4742
|
function collectNonPortableToolRefs(config) {
|
|
4715
4743
|
const tools = config.tools;
|
|
4716
|
-
if (!
|
|
4744
|
+
if (!isPlainObject2(tools)) return [];
|
|
4717
4745
|
const found = [];
|
|
4718
4746
|
const isAccountScoped = (ref) => typeof ref === "string" && ref.startsWith("tool_");
|
|
4719
4747
|
const scanArray = (value, path) => {
|
|
@@ -4723,7 +4751,7 @@ function collectNonPortableToolRefs(config) {
|
|
|
4723
4751
|
});
|
|
4724
4752
|
};
|
|
4725
4753
|
const scanKeys = (value, path) => {
|
|
4726
|
-
if (!
|
|
4754
|
+
if (!isPlainObject2(value)) return;
|
|
4727
4755
|
for (const key of Object.keys(value)) {
|
|
4728
4756
|
if (isAccountScoped(key)) found.push(`${path}.${key}`);
|
|
4729
4757
|
}
|
|
@@ -4731,16 +4759,16 @@ function collectNonPortableToolRefs(config) {
|
|
|
4731
4759
|
scanArray(tools.toolIds, "tools.toolIds");
|
|
4732
4760
|
scanKeys(tools.toolConfigs, "tools.toolConfigs");
|
|
4733
4761
|
scanKeys(tools.perToolLimits, "tools.perToolLimits");
|
|
4734
|
-
if (
|
|
4735
|
-
if (
|
|
4762
|
+
if (isPlainObject2(tools.approval)) scanArray(tools.approval.require, "tools.approval.require");
|
|
4763
|
+
if (isPlainObject2(tools.subagentConfig)) {
|
|
4736
4764
|
scanArray(tools.subagentConfig.toolPool, "tools.subagentConfig.toolPool");
|
|
4737
4765
|
}
|
|
4738
|
-
if (
|
|
4766
|
+
if (isPlainObject2(tools.codeModeConfig)) {
|
|
4739
4767
|
scanArray(tools.codeModeConfig.toolPool, "tools.codeModeConfig.toolPool");
|
|
4740
4768
|
}
|
|
4741
4769
|
if (Array.isArray(tools.runtimeTools)) {
|
|
4742
4770
|
tools.runtimeTools.forEach((runtimeTool, i) => {
|
|
4743
|
-
if (!
|
|
4771
|
+
if (!isPlainObject2(runtimeTool) || !isPlainObject2(runtimeTool.config)) return;
|
|
4744
4772
|
const base = `tools.runtimeTools[${i}].config`;
|
|
4745
4773
|
const rtConfig = runtimeTool.config;
|
|
4746
4774
|
if (runtimeTool.toolType === "subagent" && typeof rtConfig.agentId === "string" && rtConfig.agentId.startsWith("agent_")) {
|
|
@@ -4814,7 +4842,7 @@ function parseRequestError3(err) {
|
|
|
4814
4842
|
}
|
|
4815
4843
|
function toConflictError3(err) {
|
|
4816
4844
|
const { status, body } = parseRequestError3(err);
|
|
4817
|
-
if (status !== 409 || !
|
|
4845
|
+
if (status !== 409 || !isPlainObject2(body)) return null;
|
|
4818
4846
|
const code = body.code;
|
|
4819
4847
|
if (code !== "external_modification" && code !== "remote_changed") return null;
|
|
4820
4848
|
return new AgentEnsureConflictError(
|
|
@@ -4916,27 +4944,9 @@ var AgentsNamespace = class {
|
|
|
4916
4944
|
};
|
|
4917
4945
|
|
|
4918
4946
|
// src/tools-ensure.ts
|
|
4919
|
-
function isPlainObject5(value) {
|
|
4920
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
4921
|
-
}
|
|
4922
|
-
function normalizeValue3(value) {
|
|
4923
|
-
if (Array.isArray(value)) {
|
|
4924
|
-
return value.map((item) => normalizeValue3(item));
|
|
4925
|
-
}
|
|
4926
|
-
if (isPlainObject5(value)) {
|
|
4927
|
-
const normalized = {};
|
|
4928
|
-
for (const key of Object.keys(value).sort()) {
|
|
4929
|
-
const entry = value[key];
|
|
4930
|
-
if (entry === void 0 || entry === null) continue;
|
|
4931
|
-
normalized[key] = normalizeValue3(entry);
|
|
4932
|
-
}
|
|
4933
|
-
return normalized;
|
|
4934
|
-
}
|
|
4935
|
-
return value;
|
|
4936
|
-
}
|
|
4937
4947
|
function normalizeToolDefinition(definition) {
|
|
4938
|
-
const parametersSchema =
|
|
4939
|
-
const config =
|
|
4948
|
+
const parametersSchema = isPlainObject(definition.parametersSchema) ? normalizeValue(definition.parametersSchema) : {};
|
|
4949
|
+
const config = isPlainObject(definition.config) ? normalizeValue(definition.config) : {};
|
|
4940
4950
|
return {
|
|
4941
4951
|
toolType: definition.toolType,
|
|
4942
4952
|
...definition.description ? { description: definition.description } : {},
|
|
@@ -4945,10 +4955,7 @@ function normalizeToolDefinition(definition) {
|
|
|
4945
4955
|
};
|
|
4946
4956
|
}
|
|
4947
4957
|
async function computeToolContentHash(definition) {
|
|
4948
|
-
|
|
4949
|
-
const encoded = new TextEncoder().encode(serialized);
|
|
4950
|
-
const hashBuffer = await crypto.subtle.digest("SHA-256", encoded);
|
|
4951
|
-
return Array.from(new Uint8Array(hashBuffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
4958
|
+
return sha256Hex(JSON.stringify(normalizeToolDefinition(definition)));
|
|
4952
4959
|
}
|
|
4953
4960
|
var DEFINE_TOOL_TOP_LEVEL_KEYS = /* @__PURE__ */ new Set([
|
|
4954
4961
|
"name",
|
|
@@ -4981,10 +4988,10 @@ function defineTool(input) {
|
|
|
4981
4988
|
`defineTool requires "toolType" to be one of: ${[...TOOL_DEFINITION_TYPES].join(", ")}`
|
|
4982
4989
|
);
|
|
4983
4990
|
}
|
|
4984
|
-
if (!
|
|
4991
|
+
if (!isPlainObject(input.parametersSchema)) {
|
|
4985
4992
|
throw new Error('defineTool requires a "parametersSchema" object (a JSON Schema)');
|
|
4986
4993
|
}
|
|
4987
|
-
if (!
|
|
4994
|
+
if (!isPlainObject(input.config)) {
|
|
4988
4995
|
throw new Error('defineTool requires a "config" object');
|
|
4989
4996
|
}
|
|
4990
4997
|
const unknownKeys = Object.keys(input).filter((key) => !DEFINE_TOOL_TOP_LEVEL_KEYS.has(key));
|
|
@@ -5032,7 +5039,7 @@ function parseRequestError4(err) {
|
|
|
5032
5039
|
}
|
|
5033
5040
|
function toConflictError4(err) {
|
|
5034
5041
|
const { status, body } = parseRequestError4(err);
|
|
5035
|
-
if (status !== 409 || !
|
|
5042
|
+
if (status !== 409 || !isPlainObject(body)) return null;
|
|
5036
5043
|
const code = body.code;
|
|
5037
5044
|
if (code !== "external_modification" && code !== "remote_changed") return null;
|
|
5038
5045
|
return new ToolEnsureConflictError(
|
|
@@ -5152,26 +5159,8 @@ var ToolsNamespace = class {
|
|
|
5152
5159
|
};
|
|
5153
5160
|
|
|
5154
5161
|
// src/products-ensure.ts
|
|
5155
|
-
function isPlainObject6(value) {
|
|
5156
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
5157
|
-
}
|
|
5158
|
-
function normalizeValue4(value) {
|
|
5159
|
-
if (Array.isArray(value)) {
|
|
5160
|
-
return value.map((item) => normalizeValue4(item));
|
|
5161
|
-
}
|
|
5162
|
-
if (isPlainObject6(value)) {
|
|
5163
|
-
const normalized = {};
|
|
5164
|
-
for (const key of Object.keys(value).sort()) {
|
|
5165
|
-
const entry = value[key];
|
|
5166
|
-
if (entry === void 0 || entry === null) continue;
|
|
5167
|
-
normalized[key] = normalizeValue4(entry);
|
|
5168
|
-
}
|
|
5169
|
-
return normalized;
|
|
5170
|
-
}
|
|
5171
|
-
return value;
|
|
5172
|
-
}
|
|
5173
5162
|
function normalizeProductDefinition(definition) {
|
|
5174
|
-
const spec =
|
|
5163
|
+
const spec = isPlainObject(definition.spec) ? normalizeValue(definition.spec) : {};
|
|
5175
5164
|
return {
|
|
5176
5165
|
...definition.description ? { description: definition.description } : {},
|
|
5177
5166
|
...definition.icon ? { icon: definition.icon } : {},
|
|
@@ -5179,10 +5168,7 @@ function normalizeProductDefinition(definition) {
|
|
|
5179
5168
|
};
|
|
5180
5169
|
}
|
|
5181
5170
|
async function computeProductContentHash(definition) {
|
|
5182
|
-
|
|
5183
|
-
const encoded = new TextEncoder().encode(serialized);
|
|
5184
|
-
const hashBuffer = await crypto.subtle.digest("SHA-256", encoded);
|
|
5185
|
-
return Array.from(new Uint8Array(hashBuffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
5171
|
+
return sha256Hex(JSON.stringify(normalizeProductDefinition(definition)));
|
|
5186
5172
|
}
|
|
5187
5173
|
var DEFINE_PRODUCT_TOP_LEVEL_KEYS = /* @__PURE__ */ new Set(["name", "description", "icon", "spec"]);
|
|
5188
5174
|
function defineProduct(input) {
|
|
@@ -5198,7 +5184,7 @@ function defineProduct(input) {
|
|
|
5198
5184
|
if (input.icon != null && typeof input.icon !== "string") {
|
|
5199
5185
|
throw new Error('defineProduct "icon" must be a string when provided');
|
|
5200
5186
|
}
|
|
5201
|
-
if (input.spec != null && !
|
|
5187
|
+
if (input.spec != null && !isPlainObject(input.spec)) {
|
|
5202
5188
|
throw new Error('defineProduct "spec" must be an object when provided');
|
|
5203
5189
|
}
|
|
5204
5190
|
const unknownKeys = Object.keys(input).filter((key) => !DEFINE_PRODUCT_TOP_LEVEL_KEYS.has(key));
|
|
@@ -5245,7 +5231,7 @@ function parseRequestError5(err) {
|
|
|
5245
5231
|
}
|
|
5246
5232
|
function toConflictError5(err) {
|
|
5247
5233
|
const { status, body } = parseRequestError5(err);
|
|
5248
|
-
if (status !== 409 || !
|
|
5234
|
+
if (status !== 409 || !isPlainObject(body)) return null;
|
|
5249
5235
|
const code = body.code;
|
|
5250
5236
|
if (code !== "external_modification" && code !== "remote_changed") return null;
|
|
5251
5237
|
return new ProductEnsureConflictError(
|
|
@@ -5326,50 +5312,29 @@ async function pullProduct(client, name) {
|
|
|
5326
5312
|
}
|
|
5327
5313
|
|
|
5328
5314
|
// src/products-ensure-fpo.ts
|
|
5329
|
-
function isPlainObject7(value) {
|
|
5330
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
5331
|
-
}
|
|
5332
|
-
function normalizeValue5(value) {
|
|
5333
|
-
if (Array.isArray(value)) {
|
|
5334
|
-
return value.map((item) => normalizeValue5(item));
|
|
5335
|
-
}
|
|
5336
|
-
if (isPlainObject7(value)) {
|
|
5337
|
-
const normalized = {};
|
|
5338
|
-
for (const key of Object.keys(value).sort()) {
|
|
5339
|
-
const entry = value[key];
|
|
5340
|
-
if (entry === void 0 || entry === null) continue;
|
|
5341
|
-
normalized[key] = normalizeValue5(entry);
|
|
5342
|
-
}
|
|
5343
|
-
return normalized;
|
|
5344
|
-
}
|
|
5345
|
-
return value;
|
|
5346
|
-
}
|
|
5347
5315
|
function normalizeFpoDefinition(fpo) {
|
|
5348
|
-
const productInput =
|
|
5316
|
+
const productInput = isPlainObject(fpo.product) ? fpo.product : {};
|
|
5349
5317
|
const { name: _identityName, ...productRest } = productInput;
|
|
5350
|
-
const product =
|
|
5318
|
+
const product = normalizeValue(productRest);
|
|
5351
5319
|
return {
|
|
5352
|
-
...fpo.version !== void 0 && fpo.version !== null ? { version:
|
|
5320
|
+
...fpo.version !== void 0 && fpo.version !== null ? { version: normalizeValue(fpo.version) } : {},
|
|
5353
5321
|
product,
|
|
5354
|
-
capabilities:
|
|
5355
|
-
tools:
|
|
5356
|
-
surfaces:
|
|
5357
|
-
...fpo.records !== void 0 && fpo.records !== null ? { records:
|
|
5358
|
-
...fpo.schedules !== void 0 && fpo.schedules !== null ? { schedules:
|
|
5359
|
-
...fpo.secrets !== void 0 && fpo.secrets !== null ? { secrets:
|
|
5322
|
+
capabilities: normalizeValue(fpo.capabilities ?? []),
|
|
5323
|
+
tools: normalizeValue(fpo.tools ?? []),
|
|
5324
|
+
surfaces: normalizeValue(fpo.surfaces ?? []),
|
|
5325
|
+
...fpo.records !== void 0 && fpo.records !== null ? { records: normalizeValue(fpo.records) } : {},
|
|
5326
|
+
...fpo.schedules !== void 0 && fpo.schedules !== null ? { schedules: normalizeValue(fpo.schedules) } : {},
|
|
5327
|
+
...fpo.secrets !== void 0 && fpo.secrets !== null ? { secrets: normalizeValue(fpo.secrets) } : {}
|
|
5360
5328
|
};
|
|
5361
5329
|
}
|
|
5362
5330
|
async function computeFpoContentHash(fpo) {
|
|
5363
|
-
|
|
5364
|
-
const encoded = new TextEncoder().encode(serialized);
|
|
5365
|
-
const hashBuffer = await crypto.subtle.digest("SHA-256", encoded);
|
|
5366
|
-
return Array.from(new Uint8Array(hashBuffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
5331
|
+
return sha256Hex(JSON.stringify(normalizeFpoDefinition(fpo)));
|
|
5367
5332
|
}
|
|
5368
5333
|
function defineFpo(fpo) {
|
|
5369
|
-
if (!
|
|
5334
|
+
if (!isPlainObject(fpo)) {
|
|
5370
5335
|
throw new Error("defineFpo requires an FPO object");
|
|
5371
5336
|
}
|
|
5372
|
-
const product =
|
|
5337
|
+
const product = isPlainObject(fpo.product) ? fpo.product : void 0;
|
|
5373
5338
|
if (!product || typeof product.name !== "string" || product.name.length === 0) {
|
|
5374
5339
|
throw new Error('defineFpo requires a non-empty "product.name" (the converge identity)');
|
|
5375
5340
|
}
|
|
@@ -5465,26 +5430,8 @@ var ProductsNamespace = class {
|
|
|
5465
5430
|
};
|
|
5466
5431
|
|
|
5467
5432
|
// src/surfaces-ensure.ts
|
|
5468
|
-
function isPlainObject8(value) {
|
|
5469
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
5470
|
-
}
|
|
5471
|
-
function normalizeValue6(value) {
|
|
5472
|
-
if (Array.isArray(value)) {
|
|
5473
|
-
return value.map((item) => normalizeValue6(item));
|
|
5474
|
-
}
|
|
5475
|
-
if (isPlainObject8(value)) {
|
|
5476
|
-
const normalized = {};
|
|
5477
|
-
for (const key of Object.keys(value).sort()) {
|
|
5478
|
-
const entry = value[key];
|
|
5479
|
-
if (entry === void 0 || entry === null) continue;
|
|
5480
|
-
normalized[key] = normalizeValue6(entry);
|
|
5481
|
-
}
|
|
5482
|
-
return normalized;
|
|
5483
|
-
}
|
|
5484
|
-
return value;
|
|
5485
|
-
}
|
|
5486
5433
|
function normalizeSurfaceDefinition(definition) {
|
|
5487
|
-
const behavior =
|
|
5434
|
+
const behavior = isPlainObject(definition.behavior) ? normalizeValue({ type: definition.type, ...definition.behavior }) : { type: definition.type };
|
|
5488
5435
|
return {
|
|
5489
5436
|
type: definition.type,
|
|
5490
5437
|
behavior,
|
|
@@ -5493,10 +5440,7 @@ function normalizeSurfaceDefinition(definition) {
|
|
|
5493
5440
|
};
|
|
5494
5441
|
}
|
|
5495
5442
|
async function computeSurfaceContentHash(definition) {
|
|
5496
|
-
|
|
5497
|
-
const encoded = new TextEncoder().encode(serialized);
|
|
5498
|
-
const hashBuffer = await crypto.subtle.digest("SHA-256", encoded);
|
|
5499
|
-
return Array.from(new Uint8Array(hashBuffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
5443
|
+
return sha256Hex(JSON.stringify(normalizeSurfaceDefinition(definition)));
|
|
5500
5444
|
}
|
|
5501
5445
|
var DEFINE_SURFACE_TOP_LEVEL_KEYS = /* @__PURE__ */ new Set([
|
|
5502
5446
|
"name",
|
|
@@ -5537,13 +5481,13 @@ function defineSurface(input) {
|
|
|
5537
5481
|
`defineSurface requires "type" to be one of: ${[...SURFACE_DEFINITION_TYPES].join(", ")}`
|
|
5538
5482
|
);
|
|
5539
5483
|
}
|
|
5540
|
-
if (input.behavior !== void 0 && !
|
|
5484
|
+
if (input.behavior !== void 0 && !isPlainObject(input.behavior)) {
|
|
5541
5485
|
throw new Error('defineSurface "behavior" must be an object when provided');
|
|
5542
5486
|
}
|
|
5543
|
-
if (input.inbound !== void 0 && !
|
|
5487
|
+
if (input.inbound !== void 0 && !isPlainObject(input.inbound)) {
|
|
5544
5488
|
throw new Error('defineSurface "inbound" must be an object when provided');
|
|
5545
5489
|
}
|
|
5546
|
-
if (input.outbound !== void 0 && !
|
|
5490
|
+
if (input.outbound !== void 0 && !isPlainObject(input.outbound)) {
|
|
5547
5491
|
throw new Error('defineSurface "outbound" must be an object when provided');
|
|
5548
5492
|
}
|
|
5549
5493
|
if (input.status !== void 0 && !["draft", "active", "paused"].includes(input.status)) {
|
|
@@ -5599,7 +5543,7 @@ function parseRequestError6(err) {
|
|
|
5599
5543
|
}
|
|
5600
5544
|
function toConflictError6(err) {
|
|
5601
5545
|
const { status, body } = parseRequestError6(err);
|
|
5602
|
-
if (status !== 409 || !
|
|
5546
|
+
if (status !== 409 || !isPlainObject(body)) return null;
|
|
5603
5547
|
const code = body.code;
|
|
5604
5548
|
if (code !== "external_modification" && code !== "remote_changed") return null;
|
|
5605
5549
|
return new SurfaceEnsureConflictError(
|
|
@@ -6212,7 +6156,7 @@ var Runtype = class {
|
|
|
6212
6156
|
|
|
6213
6157
|
// src/version.ts
|
|
6214
6158
|
var FALLBACK_VERSION = "0.0.0";
|
|
6215
|
-
var SDK_VERSION = "5.
|
|
6159
|
+
var SDK_VERSION = "5.10.0".length > 0 ? "5.10.0" : FALLBACK_VERSION;
|
|
6216
6160
|
var RUNTYPE_CLIENT_KIND = "sdk";
|
|
6217
6161
|
var SDK_USER_AGENT = `runtype-sdk/${SDK_VERSION} (typescript)`;
|
|
6218
6162
|
|
package/package.json
CHANGED