@runtypelabs/sdk 4.14.0 → 4.15.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 +308 -52
- package/dist/index.d.cts +519 -1
- package/dist/index.d.ts +519 -1
- package/dist/index.mjs +302 -52
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -57,6 +57,9 @@ __export(index_exports, {
|
|
|
57
57
|
LEDGER_ARTIFACT_LINE_PREFIX: () => LEDGER_ARTIFACT_LINE_PREFIX,
|
|
58
58
|
LogsEndpoint: () => LogsEndpoint,
|
|
59
59
|
ModelConfigsEndpoint: () => ModelConfigsEndpoint,
|
|
60
|
+
ProductDriftError: () => ProductDriftError,
|
|
61
|
+
ProductEnsureConflictError: () => ProductEnsureConflictError,
|
|
62
|
+
ProductsNamespace: () => ProductsNamespace,
|
|
60
63
|
PromptRunner: () => PromptRunner,
|
|
61
64
|
PromptsEndpoint: () => PromptsEndpoint,
|
|
62
65
|
PromptsNamespace: () => PromptsNamespace,
|
|
@@ -88,6 +91,7 @@ __export(index_exports, {
|
|
|
88
91
|
compileWorkflowConfig: () => compileWorkflowConfig,
|
|
89
92
|
computeAgentContentHash: () => computeAgentContentHash,
|
|
90
93
|
computeFlowContentHash: () => computeFlowContentHash,
|
|
94
|
+
computeProductContentHash: () => computeProductContentHash,
|
|
91
95
|
computeToolContentHash: () => computeToolContentHash,
|
|
92
96
|
createClient: () => createClient,
|
|
93
97
|
createExternalTool: () => createExternalTool,
|
|
@@ -96,6 +100,7 @@ __export(index_exports, {
|
|
|
96
100
|
defineAgent: () => defineAgent,
|
|
97
101
|
defineFlow: () => defineFlow,
|
|
98
102
|
definePlaybook: () => definePlaybook,
|
|
103
|
+
defineProduct: () => defineProduct,
|
|
99
104
|
defineTool: () => defineTool,
|
|
100
105
|
deployWorkflow: () => deployWorkflow,
|
|
101
106
|
ensureDefaultWorkflowHooks: () => ensureDefaultWorkflowHooks,
|
|
@@ -112,6 +117,7 @@ __export(index_exports, {
|
|
|
112
117
|
listWorkflowHooks: () => listWorkflowHooks,
|
|
113
118
|
normalizeAgentDefinition: () => normalizeAgentDefinition,
|
|
114
119
|
normalizeCandidatePath: () => normalizeCandidatePath,
|
|
120
|
+
normalizeProductDefinition: () => normalizeProductDefinition,
|
|
115
121
|
normalizeToolDefinition: () => normalizeToolDefinition,
|
|
116
122
|
parseFinalBuffer: () => parseFinalBuffer,
|
|
117
123
|
parseLedgerArtifactRelativePath: () => parseLedgerArtifactRelativePath,
|
|
@@ -1225,20 +1231,20 @@ var FlowBuilder = class {
|
|
|
1225
1231
|
*/
|
|
1226
1232
|
build() {
|
|
1227
1233
|
const flow = this.existingFlowId ? { id: this.existingFlowId } : { name: this.flowConfig.name, steps: this.steps };
|
|
1228
|
-
const
|
|
1234
|
+
const request4 = { flow };
|
|
1229
1235
|
if (this.recordConfig) {
|
|
1230
|
-
|
|
1236
|
+
request4.record = this.recordConfig;
|
|
1231
1237
|
}
|
|
1232
1238
|
if (this.messagesConfig) {
|
|
1233
|
-
|
|
1239
|
+
request4.messages = this.messagesConfig;
|
|
1234
1240
|
}
|
|
1235
1241
|
if (this.inputsConfig) {
|
|
1236
|
-
|
|
1242
|
+
request4.inputs = this.inputsConfig;
|
|
1237
1243
|
}
|
|
1238
1244
|
if (Object.keys(this.optionsConfig).length > 0) {
|
|
1239
|
-
|
|
1245
|
+
request4.options = this.optionsConfig;
|
|
1240
1246
|
}
|
|
1241
|
-
return
|
|
1247
|
+
return request4;
|
|
1242
1248
|
}
|
|
1243
1249
|
/**
|
|
1244
1250
|
* Validate this prospective flow against the public validation endpoint
|
|
@@ -2632,15 +2638,15 @@ var RuntypeFlowBuilder = class {
|
|
|
2632
2638
|
build() {
|
|
2633
2639
|
const flowMode = this.mode === "existing" ? "existing" : this.mode;
|
|
2634
2640
|
const flow = this.existingFlowId ? { id: this.existingFlowId } : { name: this.flowConfig.name, steps: this.steps };
|
|
2635
|
-
const
|
|
2641
|
+
const request4 = { flow };
|
|
2636
2642
|
if (this.recordConfig) {
|
|
2637
|
-
|
|
2643
|
+
request4.record = this.recordConfig;
|
|
2638
2644
|
}
|
|
2639
2645
|
if (this.messagesConfig) {
|
|
2640
|
-
|
|
2646
|
+
request4.messages = this.messagesConfig;
|
|
2641
2647
|
}
|
|
2642
2648
|
if (this.inputsConfig) {
|
|
2643
|
-
|
|
2649
|
+
request4.inputs = this.inputsConfig;
|
|
2644
2650
|
}
|
|
2645
2651
|
const options = {
|
|
2646
2652
|
flowMode,
|
|
@@ -2658,8 +2664,8 @@ var RuntypeFlowBuilder = class {
|
|
|
2658
2664
|
if (this.mode === "upsert" && Object.keys(this.upsertOptions).length > 0) {
|
|
2659
2665
|
options.upsertOptions = this.upsertOptions;
|
|
2660
2666
|
}
|
|
2661
|
-
|
|
2662
|
-
return
|
|
2667
|
+
request4.options = options;
|
|
2668
|
+
return request4;
|
|
2663
2669
|
}
|
|
2664
2670
|
/**
|
|
2665
2671
|
* Validate this prospective flow against the public validation endpoint
|
|
@@ -3940,6 +3946,219 @@ var ToolsNamespace = class {
|
|
|
3940
3946
|
}
|
|
3941
3947
|
};
|
|
3942
3948
|
|
|
3949
|
+
// src/products-ensure.ts
|
|
3950
|
+
function isPlainObject4(value) {
|
|
3951
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
3952
|
+
}
|
|
3953
|
+
function normalizeValue3(value) {
|
|
3954
|
+
if (Array.isArray(value)) {
|
|
3955
|
+
return value.map((item) => normalizeValue3(item));
|
|
3956
|
+
}
|
|
3957
|
+
if (isPlainObject4(value)) {
|
|
3958
|
+
const normalized = {};
|
|
3959
|
+
for (const key of Object.keys(value).sort()) {
|
|
3960
|
+
const entry = value[key];
|
|
3961
|
+
if (entry === void 0 || entry === null) continue;
|
|
3962
|
+
normalized[key] = normalizeValue3(entry);
|
|
3963
|
+
}
|
|
3964
|
+
return normalized;
|
|
3965
|
+
}
|
|
3966
|
+
return value;
|
|
3967
|
+
}
|
|
3968
|
+
function normalizeProductDefinition(definition) {
|
|
3969
|
+
const spec = isPlainObject4(definition.spec) ? normalizeValue3(definition.spec) : {};
|
|
3970
|
+
return {
|
|
3971
|
+
...definition.description ? { description: definition.description } : {},
|
|
3972
|
+
...definition.icon ? { icon: definition.icon } : {},
|
|
3973
|
+
spec
|
|
3974
|
+
};
|
|
3975
|
+
}
|
|
3976
|
+
async function computeProductContentHash(definition) {
|
|
3977
|
+
const serialized = JSON.stringify(normalizeProductDefinition(definition));
|
|
3978
|
+
const encoded = new TextEncoder().encode(serialized);
|
|
3979
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", encoded);
|
|
3980
|
+
return Array.from(new Uint8Array(hashBuffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
3981
|
+
}
|
|
3982
|
+
var DEFINE_PRODUCT_TOP_LEVEL_KEYS = /* @__PURE__ */ new Set(["name", "description", "icon", "spec"]);
|
|
3983
|
+
function defineProduct(input) {
|
|
3984
|
+
if (!input || typeof input !== "object") {
|
|
3985
|
+
throw new Error("defineProduct requires a definition object");
|
|
3986
|
+
}
|
|
3987
|
+
if (typeof input.name !== "string" || input.name.length === 0) {
|
|
3988
|
+
throw new Error('defineProduct requires a non-empty string "name"');
|
|
3989
|
+
}
|
|
3990
|
+
if (input.description != null && typeof input.description !== "string") {
|
|
3991
|
+
throw new Error('defineProduct "description" must be a string when provided');
|
|
3992
|
+
}
|
|
3993
|
+
if (input.icon != null && typeof input.icon !== "string") {
|
|
3994
|
+
throw new Error('defineProduct "icon" must be a string when provided');
|
|
3995
|
+
}
|
|
3996
|
+
if (input.spec != null && !isPlainObject4(input.spec)) {
|
|
3997
|
+
throw new Error('defineProduct "spec" must be an object when provided');
|
|
3998
|
+
}
|
|
3999
|
+
const unknownKeys = Object.keys(input).filter((key) => !DEFINE_PRODUCT_TOP_LEVEL_KEYS.has(key));
|
|
4000
|
+
if (unknownKeys.length > 0) {
|
|
4001
|
+
throw new Error(
|
|
4002
|
+
`defineProduct: unknown field(s): ${unknownKeys.join(", ")}. Allowed fields are name, description, icon, spec. (canvas / nested capabilities and surfaces are not converged by ensure.)`
|
|
4003
|
+
);
|
|
4004
|
+
}
|
|
4005
|
+
return {
|
|
4006
|
+
name: input.name,
|
|
4007
|
+
...input.description !== void 0 ? { description: input.description } : {},
|
|
4008
|
+
...input.icon !== void 0 ? { icon: input.icon } : {},
|
|
4009
|
+
...input.spec !== void 0 ? { spec: input.spec } : {}
|
|
4010
|
+
};
|
|
4011
|
+
}
|
|
4012
|
+
var ProductEnsureConflictError = class extends Error {
|
|
4013
|
+
constructor(body) {
|
|
4014
|
+
super(body.error ?? `Product ensure conflict: ${body.code}`);
|
|
4015
|
+
this.name = "ProductEnsureConflictError";
|
|
4016
|
+
this.code = body.code;
|
|
4017
|
+
this.lastModifiedSource = body.lastModifiedSource;
|
|
4018
|
+
this.modifiedAt = body.modifiedAt;
|
|
4019
|
+
this.currentHash = body.currentHash;
|
|
4020
|
+
}
|
|
4021
|
+
};
|
|
4022
|
+
var ProductDriftError = class extends Error {
|
|
4023
|
+
constructor(plan) {
|
|
4024
|
+
super(
|
|
4025
|
+
`Product "${plan.productId ?? "definition"}" drifted: plan is '${plan.changes}' (changed: ${plan.changedKeys.join(", ") || "n/a"}). Run client.products.pull(name) to absorb the remote edit into your repo, or re-run ensure to converge.`
|
|
4026
|
+
);
|
|
4027
|
+
this.name = "ProductDriftError";
|
|
4028
|
+
this.plan = plan;
|
|
4029
|
+
}
|
|
4030
|
+
};
|
|
4031
|
+
function parseRequestError4(err) {
|
|
4032
|
+
if (!(err instanceof Error)) return { status: null, body: null };
|
|
4033
|
+
const match = err.message.match(/^API request failed: (\d{3}) .*? - ([\s\S]*)$/);
|
|
4034
|
+
if (!match) return { status: null, body: null };
|
|
4035
|
+
try {
|
|
4036
|
+
return { status: Number(match[1]), body: JSON.parse(match[2]) };
|
|
4037
|
+
} catch {
|
|
4038
|
+
return { status: Number(match[1]), body: null };
|
|
4039
|
+
}
|
|
4040
|
+
}
|
|
4041
|
+
function toConflictError4(err) {
|
|
4042
|
+
const { status, body } = parseRequestError4(err);
|
|
4043
|
+
if (status !== 409 || !isPlainObject4(body)) return null;
|
|
4044
|
+
const code = body.code;
|
|
4045
|
+
if (code !== "external_modification" && code !== "remote_changed") return null;
|
|
4046
|
+
return new ProductEnsureConflictError(
|
|
4047
|
+
body
|
|
4048
|
+
);
|
|
4049
|
+
}
|
|
4050
|
+
var serverHashMemo4 = /* @__PURE__ */ new WeakMap();
|
|
4051
|
+
function memoFor4(client) {
|
|
4052
|
+
let memo = serverHashMemo4.get(client);
|
|
4053
|
+
if (!memo) {
|
|
4054
|
+
memo = /* @__PURE__ */ new Map();
|
|
4055
|
+
serverHashMemo4.set(client, memo);
|
|
4056
|
+
}
|
|
4057
|
+
return memo;
|
|
4058
|
+
}
|
|
4059
|
+
function memoize3(memo, memoKey, result) {
|
|
4060
|
+
if (result.result !== "plan") memo.set(memoKey, result.contentHash);
|
|
4061
|
+
}
|
|
4062
|
+
async function request3(client, body) {
|
|
4063
|
+
try {
|
|
4064
|
+
return await client.post(
|
|
4065
|
+
"/products/ensure",
|
|
4066
|
+
body
|
|
4067
|
+
);
|
|
4068
|
+
} catch (err) {
|
|
4069
|
+
const conflict = toConflictError4(err);
|
|
4070
|
+
if (conflict) throw conflict;
|
|
4071
|
+
throw err;
|
|
4072
|
+
}
|
|
4073
|
+
}
|
|
4074
|
+
async function ensureProduct(client, definition, options = {}) {
|
|
4075
|
+
const { dryRun, onConflict, expectedRemoteHash, expectNoChanges } = options;
|
|
4076
|
+
const passthrough = {
|
|
4077
|
+
...onConflict ? { onConflict } : {},
|
|
4078
|
+
...expectedRemoteHash ? { expectedRemoteHash } : {}
|
|
4079
|
+
};
|
|
4080
|
+
if (dryRun || expectNoChanges) {
|
|
4081
|
+
const plan = await request3(client, {
|
|
4082
|
+
name: definition.name,
|
|
4083
|
+
definition,
|
|
4084
|
+
dryRun: true,
|
|
4085
|
+
...passthrough
|
|
4086
|
+
});
|
|
4087
|
+
if (plan.result !== "plan") {
|
|
4088
|
+
throw new Error(`Expected a plan result from dryRun, got '${plan.result}'`);
|
|
4089
|
+
}
|
|
4090
|
+
if (expectNoChanges && plan.changes !== "none") {
|
|
4091
|
+
throw new ProductDriftError(plan);
|
|
4092
|
+
}
|
|
4093
|
+
return plan;
|
|
4094
|
+
}
|
|
4095
|
+
const memo = memoFor4(client);
|
|
4096
|
+
const localHash = await computeProductContentHash(definition);
|
|
4097
|
+
const memoKey = `${definition.name} ${localHash}`;
|
|
4098
|
+
const contentHash = memo.get(memoKey) ?? localHash;
|
|
4099
|
+
const probe = await request3(client, {
|
|
4100
|
+
name: definition.name,
|
|
4101
|
+
contentHash,
|
|
4102
|
+
...passthrough
|
|
4103
|
+
});
|
|
4104
|
+
if (probe.result !== "definitionRequired") {
|
|
4105
|
+
memoize3(memo, memoKey, probe);
|
|
4106
|
+
return probe;
|
|
4107
|
+
}
|
|
4108
|
+
const converged = await request3(client, {
|
|
4109
|
+
name: definition.name,
|
|
4110
|
+
definition,
|
|
4111
|
+
...passthrough
|
|
4112
|
+
});
|
|
4113
|
+
if (converged.result === "definitionRequired") {
|
|
4114
|
+
throw new Error("Server reported definitionRequired for a full-definition request");
|
|
4115
|
+
}
|
|
4116
|
+
memoize3(memo, memoKey, converged);
|
|
4117
|
+
return converged;
|
|
4118
|
+
}
|
|
4119
|
+
async function pullProduct(client, name) {
|
|
4120
|
+
return client.get("/products/pull", { name });
|
|
4121
|
+
}
|
|
4122
|
+
|
|
4123
|
+
// src/products-namespace.ts
|
|
4124
|
+
var ProductsNamespace = class {
|
|
4125
|
+
constructor(getClient) {
|
|
4126
|
+
this.getClient = getClient;
|
|
4127
|
+
}
|
|
4128
|
+
/**
|
|
4129
|
+
* Idempotently converge a `defineProduct` definition onto the platform.
|
|
4130
|
+
* Hash-first: the steady state is one tiny probe request. Creates or updates
|
|
4131
|
+
* the top-level product record; never deletes. Identity is name + account
|
|
4132
|
+
* scope.
|
|
4133
|
+
*
|
|
4134
|
+
* @example
|
|
4135
|
+
* ```typescript
|
|
4136
|
+
* const product = defineProduct({
|
|
4137
|
+
* name: 'Support Copilot',
|
|
4138
|
+
* description: 'An AI support assistant',
|
|
4139
|
+
* icon: '🤖',
|
|
4140
|
+
* spec: { productGoal: 'Deflect tier-1 tickets', productStage: 'beta' },
|
|
4141
|
+
* })
|
|
4142
|
+
*
|
|
4143
|
+
* // Converge (CI/deploy).
|
|
4144
|
+
* const result = await Runtype.products.ensure(product)
|
|
4145
|
+
*
|
|
4146
|
+
* // PR drift gate.
|
|
4147
|
+
* await Runtype.products.ensure(product, { expectNoChanges: true })
|
|
4148
|
+
* ```
|
|
4149
|
+
*/
|
|
4150
|
+
async ensure(definition, options = {}) {
|
|
4151
|
+
return ensureProduct(this.getClient(), definition, options);
|
|
4152
|
+
}
|
|
4153
|
+
/**
|
|
4154
|
+
* Pull the canonical definition + provenance for a product by name — the
|
|
4155
|
+
* absorb-drift direction of the ensure protocol.
|
|
4156
|
+
*/
|
|
4157
|
+
async pull(name) {
|
|
4158
|
+
return pullProduct(this.getClient(), name);
|
|
4159
|
+
}
|
|
4160
|
+
};
|
|
4161
|
+
|
|
3943
4162
|
// src/transform.ts
|
|
3944
4163
|
function transformResponse(data) {
|
|
3945
4164
|
return data;
|
|
@@ -4356,6 +4575,37 @@ var Runtype = class {
|
|
|
4356
4575
|
static get tools() {
|
|
4357
4576
|
return new ToolsNamespace(() => this.getClient());
|
|
4358
4577
|
}
|
|
4578
|
+
/**
|
|
4579
|
+
* Products namespace - Product config-as-code (define / ensure / pull)
|
|
4580
|
+
*
|
|
4581
|
+
* Converges the top-level product record (description, icon, spec). Nested
|
|
4582
|
+
* capabilities/surfaces/tools and the canvas UI layout state are not
|
|
4583
|
+
* converged by ensure.
|
|
4584
|
+
*
|
|
4585
|
+
* @example
|
|
4586
|
+
* ```typescript
|
|
4587
|
+
* import { defineProduct, Runtype } from '@runtypelabs/sdk'
|
|
4588
|
+
*
|
|
4589
|
+
* const product = defineProduct({
|
|
4590
|
+
* name: 'Support Copilot',
|
|
4591
|
+
* description: 'An AI support assistant',
|
|
4592
|
+
* icon: '🤖',
|
|
4593
|
+
* spec: { productGoal: 'Deflect tier-1 tickets', productStage: 'beta' },
|
|
4594
|
+
* })
|
|
4595
|
+
*
|
|
4596
|
+
* // Converge at deploy time (idempotent; one tiny probe in steady state)
|
|
4597
|
+
* await Runtype.products.ensure(product)
|
|
4598
|
+
*
|
|
4599
|
+
* // CI drift gate
|
|
4600
|
+
* await Runtype.products.ensure(product, { expectNoChanges: true })
|
|
4601
|
+
*
|
|
4602
|
+
* // Absorb a dashboard edit back into the repo
|
|
4603
|
+
* const { definition } = await Runtype.products.pull('Support Copilot')
|
|
4604
|
+
* ```
|
|
4605
|
+
*/
|
|
4606
|
+
static get products() {
|
|
4607
|
+
return new ProductsNamespace(() => this.getClient());
|
|
4608
|
+
}
|
|
4359
4609
|
};
|
|
4360
4610
|
|
|
4361
4611
|
// src/generated-tool-gate.ts
|
|
@@ -4578,8 +4828,8 @@ function buildGeneratedRuntimeToolGateOutput(proposal, options = {}) {
|
|
|
4578
4828
|
...decision.tool ? { tool: decision.tool } : {}
|
|
4579
4829
|
};
|
|
4580
4830
|
}
|
|
4581
|
-
function attachRuntimeToolsToDispatchRequest(
|
|
4582
|
-
const stepList =
|
|
4831
|
+
function attachRuntimeToolsToDispatchRequest(request4, runtimeTools, options = {}) {
|
|
4832
|
+
const stepList = request4.flow.steps;
|
|
4583
4833
|
if (!stepList || !Array.isArray(stepList) || stepList.length === 0) {
|
|
4584
4834
|
throw new Error("Cannot attach runtime tools: dispatch request must include flow.steps");
|
|
4585
4835
|
}
|
|
@@ -4622,9 +4872,9 @@ function attachRuntimeToolsToDispatchRequest(request3, runtimeTools, options = {
|
|
|
4622
4872
|
}
|
|
4623
4873
|
};
|
|
4624
4874
|
return {
|
|
4625
|
-
...
|
|
4875
|
+
...request4,
|
|
4626
4876
|
flow: {
|
|
4627
|
-
...
|
|
4877
|
+
...request4.flow,
|
|
4628
4878
|
// `clonedSteps` is a structural clone of `request.flow.steps` (already
|
|
4629
4879
|
// `FlowStepDefinition[]`); only the prompt step's `config.tools` was
|
|
4630
4880
|
// merged, so every step's `type` discriminant is preserved. The clone is
|
|
@@ -4634,12 +4884,12 @@ function attachRuntimeToolsToDispatchRequest(request3, runtimeTools, options = {
|
|
|
4634
4884
|
}
|
|
4635
4885
|
};
|
|
4636
4886
|
}
|
|
4637
|
-
function applyGeneratedRuntimeToolProposalToDispatchRequest(
|
|
4887
|
+
function applyGeneratedRuntimeToolProposalToDispatchRequest(request4, proposal, options = {}) {
|
|
4638
4888
|
const decision = evaluateGeneratedRuntimeToolProposal(proposal, options.gate);
|
|
4639
4889
|
if (!decision.approved || !decision.tool) {
|
|
4640
|
-
return { decision, request:
|
|
4890
|
+
return { decision, request: request4 };
|
|
4641
4891
|
}
|
|
4642
|
-
const nextRequest = attachRuntimeToolsToDispatchRequest(
|
|
4892
|
+
const nextRequest = attachRuntimeToolsToDispatchRequest(request4, [decision.tool], options.attach);
|
|
4643
4893
|
return {
|
|
4644
4894
|
decision,
|
|
4645
4895
|
request: nextRequest
|
|
@@ -6889,15 +7139,15 @@ var DispatchEndpoint = class {
|
|
|
6889
7139
|
* Attach approved runtime tools to a prompt step in a redispatch request.
|
|
6890
7140
|
* Returns a new request object and does not mutate the original.
|
|
6891
7141
|
*/
|
|
6892
|
-
attachApprovedRuntimeTools(
|
|
6893
|
-
return attachRuntimeToolsToDispatchRequest(
|
|
7142
|
+
attachApprovedRuntimeTools(request4, runtimeTools, options) {
|
|
7143
|
+
return attachRuntimeToolsToDispatchRequest(request4, runtimeTools, options);
|
|
6894
7144
|
}
|
|
6895
7145
|
/**
|
|
6896
7146
|
* Validate a generated runtime tool proposal and attach it to the redispatch
|
|
6897
7147
|
* request if approved, in one call.
|
|
6898
7148
|
*/
|
|
6899
|
-
applyGeneratedRuntimeToolProposal(
|
|
6900
|
-
return applyGeneratedRuntimeToolProposalToDispatchRequest(
|
|
7149
|
+
applyGeneratedRuntimeToolProposal(request4, proposal, options) {
|
|
7150
|
+
return applyGeneratedRuntimeToolProposalToDispatchRequest(request4, proposal, options);
|
|
6901
7151
|
}
|
|
6902
7152
|
};
|
|
6903
7153
|
var ChatEndpoint = class {
|
|
@@ -7449,8 +7699,8 @@ var GENERATED_RUNTIME_TOOL_PROPOSAL_SCHEMA = {
|
|
|
7449
7699
|
},
|
|
7450
7700
|
required: ["name", "description", "toolType", "parametersSchema", "config"]
|
|
7451
7701
|
};
|
|
7452
|
-
function appendRuntimeToolsToAgentRequest(
|
|
7453
|
-
const existing =
|
|
7702
|
+
function appendRuntimeToolsToAgentRequest(request4, runtimeTools) {
|
|
7703
|
+
const existing = request4.tools?.runtimeTools || [];
|
|
7454
7704
|
const existingNames = new Set(existing.map((tool) => tool.name));
|
|
7455
7705
|
const converted = runtimeTools.filter((tool) => !existingNames.has(tool.name)).map((tool) => ({
|
|
7456
7706
|
name: tool.name,
|
|
@@ -7460,9 +7710,9 @@ function appendRuntimeToolsToAgentRequest(request3, runtimeTools) {
|
|
|
7460
7710
|
...tool.config ? { config: tool.config } : {}
|
|
7461
7711
|
}));
|
|
7462
7712
|
return {
|
|
7463
|
-
...
|
|
7713
|
+
...request4,
|
|
7464
7714
|
tools: {
|
|
7465
|
-
...
|
|
7715
|
+
...request4.tools,
|
|
7466
7716
|
runtimeTools: [...existing, ...converted]
|
|
7467
7717
|
}
|
|
7468
7718
|
};
|
|
@@ -7538,21 +7788,21 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
7538
7788
|
* Attach approved runtime tools to an agent execute request.
|
|
7539
7789
|
* Returns a new request object and does not mutate the original.
|
|
7540
7790
|
*/
|
|
7541
|
-
attachApprovedRuntimeTools(
|
|
7542
|
-
return appendRuntimeToolsToAgentRequest(
|
|
7791
|
+
attachApprovedRuntimeTools(request4, runtimeTools) {
|
|
7792
|
+
return appendRuntimeToolsToAgentRequest(request4, runtimeTools);
|
|
7543
7793
|
}
|
|
7544
7794
|
/**
|
|
7545
7795
|
* Validate a generated runtime tool proposal and append it to an agent execute
|
|
7546
7796
|
* request if approved, in one call.
|
|
7547
7797
|
*/
|
|
7548
|
-
applyGeneratedRuntimeToolProposal(
|
|
7798
|
+
applyGeneratedRuntimeToolProposal(request4, proposal, options) {
|
|
7549
7799
|
const decision = evaluateGeneratedRuntimeToolProposal(proposal, options);
|
|
7550
7800
|
if (!decision.approved || !decision.tool) {
|
|
7551
|
-
return { decision, request:
|
|
7801
|
+
return { decision, request: request4 };
|
|
7552
7802
|
}
|
|
7553
7803
|
return {
|
|
7554
7804
|
decision,
|
|
7555
|
-
request: appendRuntimeToolsToAgentRequest(
|
|
7805
|
+
request: appendRuntimeToolsToAgentRequest(request4, [decision.tool])
|
|
7556
7806
|
};
|
|
7557
7807
|
}
|
|
7558
7808
|
/**
|
|
@@ -10788,7 +11038,7 @@ var RuntypeClient2 = class {
|
|
|
10788
11038
|
clearApiKey() {
|
|
10789
11039
|
delete this.headers.Authorization;
|
|
10790
11040
|
}
|
|
10791
|
-
async runWithLocalTools(
|
|
11041
|
+
async runWithLocalTools(request4, localTools, arg3, arg4) {
|
|
10792
11042
|
const isOptionsObject = (val) => typeof val === "object" && val !== null && "scope" in val;
|
|
10793
11043
|
const callbacks = isOptionsObject(arg3) ? void 0 : arg3;
|
|
10794
11044
|
const options = (isOptionsObject(arg3) ? arg3 : arg4) ?? {};
|
|
@@ -10802,12 +11052,12 @@ var RuntypeClient2 = class {
|
|
|
10802
11052
|
...entry.pageOrigin ? { pageOrigin: entry.pageOrigin } : {}
|
|
10803
11053
|
})) : [];
|
|
10804
11054
|
const modifiedRequest = {
|
|
10805
|
-
...
|
|
11055
|
+
...request4,
|
|
10806
11056
|
...derivedClientTools.length > 0 ? {
|
|
10807
|
-
clientTools: [...
|
|
11057
|
+
clientTools: [...request4.clientTools ?? [], ...derivedClientTools]
|
|
10808
11058
|
} : {},
|
|
10809
11059
|
options: {
|
|
10810
|
-
...
|
|
11060
|
+
...request4.options || {},
|
|
10811
11061
|
streamResponse: isStreaming
|
|
10812
11062
|
}
|
|
10813
11063
|
};
|
|
@@ -11245,20 +11495,20 @@ var BatchBuilder = class {
|
|
|
11245
11495
|
if (!this.recordType) {
|
|
11246
11496
|
throw new Error("BatchBuilder: recordType is required. Call .forRecordType(type) first.");
|
|
11247
11497
|
}
|
|
11248
|
-
const
|
|
11498
|
+
const request4 = {
|
|
11249
11499
|
flowId: this.flowId,
|
|
11250
11500
|
recordType: this.recordType
|
|
11251
11501
|
};
|
|
11252
11502
|
if (Object.keys(this.batchOptions).length > 0) {
|
|
11253
|
-
|
|
11503
|
+
request4.options = this.batchOptions;
|
|
11254
11504
|
}
|
|
11255
11505
|
if (this.filterConfig) {
|
|
11256
|
-
|
|
11506
|
+
request4.filter = this.filterConfig;
|
|
11257
11507
|
}
|
|
11258
11508
|
if (this.limitConfig !== void 0) {
|
|
11259
|
-
|
|
11509
|
+
request4.limit = this.limitConfig;
|
|
11260
11510
|
}
|
|
11261
|
-
return
|
|
11511
|
+
return request4;
|
|
11262
11512
|
}
|
|
11263
11513
|
/**
|
|
11264
11514
|
* Execute the batch operation
|
|
@@ -11415,32 +11665,32 @@ var EvalBuilder = class {
|
|
|
11415
11665
|
"EvalBuilder: records are required. Call .forRecordType(type) or .withRecords([...]) first."
|
|
11416
11666
|
);
|
|
11417
11667
|
}
|
|
11418
|
-
const
|
|
11668
|
+
const request4 = {};
|
|
11419
11669
|
if (this.flowId) {
|
|
11420
|
-
|
|
11670
|
+
request4.flowId = this.flowId;
|
|
11421
11671
|
} else if (this.virtualFlow) {
|
|
11422
|
-
|
|
11672
|
+
request4.flow = this.virtualFlow;
|
|
11423
11673
|
}
|
|
11424
11674
|
if (this.recordType) {
|
|
11425
|
-
|
|
11675
|
+
request4.recordType = this.recordType;
|
|
11426
11676
|
} else if (this.inlineRecords) {
|
|
11427
|
-
|
|
11677
|
+
request4.records = this.inlineRecords;
|
|
11428
11678
|
}
|
|
11429
11679
|
if (this.modelOverrides) {
|
|
11430
|
-
|
|
11680
|
+
request4.modelOverrides = this.modelOverrides;
|
|
11431
11681
|
} else if (this.modelConfigs) {
|
|
11432
|
-
|
|
11682
|
+
request4.modelConfigs = this.modelConfigs;
|
|
11433
11683
|
}
|
|
11434
11684
|
if (Object.keys(this.evalOptions).length > 0) {
|
|
11435
|
-
|
|
11685
|
+
request4.options = this.evalOptions;
|
|
11436
11686
|
}
|
|
11437
11687
|
if (this.filterConfig) {
|
|
11438
|
-
|
|
11688
|
+
request4.filter = this.filterConfig;
|
|
11439
11689
|
}
|
|
11440
11690
|
if (this.limitConfig !== void 0) {
|
|
11441
|
-
|
|
11691
|
+
request4.limit = this.limitConfig;
|
|
11442
11692
|
}
|
|
11443
|
-
return
|
|
11693
|
+
return request4;
|
|
11444
11694
|
}
|
|
11445
11695
|
/**
|
|
11446
11696
|
* Execute the evaluation
|
|
@@ -11944,6 +12194,9 @@ var STEP_TYPE_TO_METHOD = {
|
|
|
11944
12194
|
LEDGER_ARTIFACT_LINE_PREFIX,
|
|
11945
12195
|
LogsEndpoint,
|
|
11946
12196
|
ModelConfigsEndpoint,
|
|
12197
|
+
ProductDriftError,
|
|
12198
|
+
ProductEnsureConflictError,
|
|
12199
|
+
ProductsNamespace,
|
|
11947
12200
|
PromptRunner,
|
|
11948
12201
|
PromptsEndpoint,
|
|
11949
12202
|
PromptsNamespace,
|
|
@@ -11975,6 +12228,7 @@ var STEP_TYPE_TO_METHOD = {
|
|
|
11975
12228
|
compileWorkflowConfig,
|
|
11976
12229
|
computeAgentContentHash,
|
|
11977
12230
|
computeFlowContentHash,
|
|
12231
|
+
computeProductContentHash,
|
|
11978
12232
|
computeToolContentHash,
|
|
11979
12233
|
createClient,
|
|
11980
12234
|
createExternalTool,
|
|
@@ -11983,6 +12237,7 @@ var STEP_TYPE_TO_METHOD = {
|
|
|
11983
12237
|
defineAgent,
|
|
11984
12238
|
defineFlow,
|
|
11985
12239
|
definePlaybook,
|
|
12240
|
+
defineProduct,
|
|
11986
12241
|
defineTool,
|
|
11987
12242
|
deployWorkflow,
|
|
11988
12243
|
ensureDefaultWorkflowHooks,
|
|
@@ -11999,6 +12254,7 @@ var STEP_TYPE_TO_METHOD = {
|
|
|
11999
12254
|
listWorkflowHooks,
|
|
12000
12255
|
normalizeAgentDefinition,
|
|
12001
12256
|
normalizeCandidatePath,
|
|
12257
|
+
normalizeProductDefinition,
|
|
12002
12258
|
normalizeToolDefinition,
|
|
12003
12259
|
parseFinalBuffer,
|
|
12004
12260
|
parseLedgerArtifactRelativePath,
|