@granular-software/sdk 0.4.72 → 0.4.73
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/agent-evals.d.mts +2 -2
- package/dist/agent-evals.d.ts +2 -2
- package/dist/agent-evals.js +53 -18
- package/dist/agent-evals.js.map +1 -1
- package/dist/agent-evals.mjs +53 -18
- package/dist/agent-evals.mjs.map +1 -1
- package/dist/cli/index.js +69 -18
- package/dist/{client-p5EhOwpP.d.mts → client-U0rb2nG5.d.mts} +1 -1
- package/dist/{client-JCISbded.d.ts → client-WJrPOw6N.d.ts} +1 -1
- package/dist/index.d.mts +27 -4
- package/dist/index.d.ts +27 -4
- package/dist/index.js +466 -398
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +466 -399
- package/dist/index.mjs.map +1 -1
- package/dist/{spend-lJDtuAr6.d.mts → spend-k8V2Y1Tt.d.mts} +18 -1
- package/dist/{spend-lJDtuAr6.d.ts → spend-k8V2Y1Tt.d.ts} +18 -1
- package/dist/spend.d.mts +1 -1
- package/dist/spend.d.ts +1 -1
- package/package.json +1 -1
package/dist/agent-evals.mjs
CHANGED
|
@@ -13146,6 +13146,31 @@ var effectBehaviorsMetamodelPackage = defineMetamodelPackage({
|
|
|
13146
13146
|
}
|
|
13147
13147
|
}
|
|
13148
13148
|
});
|
|
13149
|
+
function assertRecordSnapshotTransitionMapping(transition) {
|
|
13150
|
+
if (!transition)
|
|
13151
|
+
throw new Error("A transition commit has no authored transition context.");
|
|
13152
|
+
if (!transition.outcomes || !Object.keys(transition.outcomes).length) {
|
|
13153
|
+
throw new Error(
|
|
13154
|
+
"Automatic product-state mapping requires at least one declared outcome."
|
|
13155
|
+
);
|
|
13156
|
+
}
|
|
13157
|
+
const destinations = /* @__PURE__ */ new Map();
|
|
13158
|
+
for (const [key, outcome] of Object.entries(transition.outcomes)) {
|
|
13159
|
+
if (!outcome || typeof outcome.to !== "string" || !outcome.to) {
|
|
13160
|
+
throw new Error(
|
|
13161
|
+
`Automatic product-state mapping requires a destination for outcome ${key}.`
|
|
13162
|
+
);
|
|
13163
|
+
}
|
|
13164
|
+
const destination = outcome.to === "$current" ? transition.from : outcome.to;
|
|
13165
|
+
const previous = destinations.get(destination);
|
|
13166
|
+
if (previous !== void 0) {
|
|
13167
|
+
throw new Error(
|
|
13168
|
+
`Ambiguous product-state mapping for ${transition.machine}.${transition.transition}: outcomes ${previous} and ${key} both resolve to ${destination}; automatic mapping requires distinct outcome destinations.`
|
|
13169
|
+
);
|
|
13170
|
+
}
|
|
13171
|
+
destinations.set(destination, key);
|
|
13172
|
+
}
|
|
13173
|
+
}
|
|
13149
13174
|
|
|
13150
13175
|
// src/commit.ts
|
|
13151
13176
|
var MAX_PROJECTION_CHANGES = 1e3;
|
|
@@ -13704,6 +13729,11 @@ async function invokeRegisteredEffect(effectMap, request, options = {}) {
|
|
|
13704
13729
|
`Transition effect ${request.effectKey} has no resolved transition context; customer code was not invoked`
|
|
13705
13730
|
);
|
|
13706
13731
|
}
|
|
13732
|
+
if (commitRequired && declaration?.kind === "transition" && declaration.outcomeSelection === "product_state") {
|
|
13733
|
+
assertRecordSnapshotTransitionMapping(
|
|
13734
|
+
request.context?.invocation?.transition
|
|
13735
|
+
);
|
|
13736
|
+
}
|
|
13707
13737
|
const idempotencyKey = commitRequired ? await resolveInvocationIdempotencyKey(request) : request.context?.idempotencyKey;
|
|
13708
13738
|
let commitStarted = false;
|
|
13709
13739
|
let commitPromise = null;
|
|
@@ -15082,7 +15112,7 @@ function buildMachineTypes(classSummary, machine) {
|
|
|
15082
15112
|
];
|
|
15083
15113
|
}
|
|
15084
15114
|
function buildMachineMethods(classSummary, machine) {
|
|
15085
|
-
const
|
|
15115
|
+
const stateName2 = stateTypeName(classSummary.name, machine.name);
|
|
15086
15116
|
const transitionName = transitionTypeName(classSummary.name, machine.name);
|
|
15087
15117
|
pathTypeName(classSummary.name, machine.name);
|
|
15088
15118
|
const docsPrefix = `${classSummary.name}.${machine.name}`;
|
|
@@ -15092,12 +15122,12 @@ function buildMachineMethods(classSummary, machine) {
|
|
|
15092
15122
|
docs: [`Get the current ${docsPrefix} state.`],
|
|
15093
15123
|
static: false,
|
|
15094
15124
|
params: [],
|
|
15095
|
-
returnType: `Promise<${
|
|
15125
|
+
returnType: `Promise<${stateName2} | null>`,
|
|
15096
15126
|
runtime: {
|
|
15097
15127
|
kind: "state_machine",
|
|
15098
15128
|
machineName: machine.name,
|
|
15099
15129
|
className: classSummary.name,
|
|
15100
|
-
stateTypeName:
|
|
15130
|
+
stateTypeName: stateName2,
|
|
15101
15131
|
transitionTypeName: transitionName,
|
|
15102
15132
|
operation: "get_current"
|
|
15103
15133
|
}
|
|
@@ -15108,13 +15138,13 @@ function buildMachineMethods(classSummary, machine) {
|
|
|
15108
15138
|
`Reach a ${docsPrefix} state through the shortest allowed transition path.`
|
|
15109
15139
|
],
|
|
15110
15140
|
static: false,
|
|
15111
|
-
params: [{ name: "target", type:
|
|
15141
|
+
params: [{ name: "target", type: stateName2 }],
|
|
15112
15142
|
returnType: `Promise<${toPascalCase2(classSummary.name)}>`,
|
|
15113
15143
|
runtime: {
|
|
15114
15144
|
kind: "state_machine",
|
|
15115
15145
|
machineName: machine.name,
|
|
15116
15146
|
className: classSummary.name,
|
|
15117
|
-
stateTypeName:
|
|
15147
|
+
stateTypeName: stateName2,
|
|
15118
15148
|
transitionTypeName: transitionName,
|
|
15119
15149
|
operation: "reach"
|
|
15120
15150
|
}
|
|
@@ -15129,7 +15159,7 @@ function buildMachineMethods(classSummary, machine) {
|
|
|
15129
15159
|
kind: "state_machine",
|
|
15130
15160
|
machineName: machine.name,
|
|
15131
15161
|
className: classSummary.name,
|
|
15132
|
-
stateTypeName:
|
|
15162
|
+
stateTypeName: stateName2,
|
|
15133
15163
|
transitionTypeName: transitionName,
|
|
15134
15164
|
operation: "list_transitions"
|
|
15135
15165
|
}
|
|
@@ -15139,12 +15169,12 @@ function buildMachineMethods(classSummary, machine) {
|
|
|
15139
15169
|
docs: [`List reachable states for ${docsPrefix} from the current state.`],
|
|
15140
15170
|
static: false,
|
|
15141
15171
|
params: [],
|
|
15142
|
-
returnType: `Promise<${
|
|
15172
|
+
returnType: `Promise<${stateName2}[]>`,
|
|
15143
15173
|
runtime: {
|
|
15144
15174
|
kind: "state_machine",
|
|
15145
15175
|
machineName: machine.name,
|
|
15146
15176
|
className: classSummary.name,
|
|
15147
|
-
stateTypeName:
|
|
15177
|
+
stateTypeName: stateName2,
|
|
15148
15178
|
transitionTypeName: transitionName,
|
|
15149
15179
|
operation: "list_reachable_states"
|
|
15150
15180
|
}
|
|
@@ -15159,7 +15189,7 @@ function buildMachineMethods(classSummary, machine) {
|
|
|
15159
15189
|
kind: "state_machine",
|
|
15160
15190
|
machineName: machine.name,
|
|
15161
15191
|
className: classSummary.name,
|
|
15162
|
-
stateTypeName:
|
|
15192
|
+
stateTypeName: stateName2,
|
|
15163
15193
|
transitionTypeName: transitionName,
|
|
15164
15194
|
operation: "is_final"
|
|
15165
15195
|
}
|
|
@@ -15170,13 +15200,13 @@ function buildMachineMethods(classSummary, machine) {
|
|
|
15170
15200
|
`List shortest transition paths from the current ${docsPrefix} state to a target state.`
|
|
15171
15201
|
],
|
|
15172
15202
|
static: false,
|
|
15173
|
-
params: [{ name: "target", type:
|
|
15174
|
-
returnType: `Promise<Array<{ states: ${
|
|
15203
|
+
params: [{ name: "target", type: stateName2 }],
|
|
15204
|
+
returnType: `Promise<Array<{ states: ${stateName2}[]; transitions: ${transitionName}[] }>>`,
|
|
15175
15205
|
runtime: {
|
|
15176
15206
|
kind: "state_machine",
|
|
15177
15207
|
machineName: machine.name,
|
|
15178
15208
|
className: classSummary.name,
|
|
15179
|
-
stateTypeName:
|
|
15209
|
+
stateTypeName: stateName2,
|
|
15180
15210
|
transitionTypeName: transitionName,
|
|
15181
15211
|
operation: "paths_to"
|
|
15182
15212
|
}
|
|
@@ -15200,7 +15230,7 @@ function buildMachineMethods(classSummary, machine) {
|
|
|
15200
15230
|
kind: "state_machine",
|
|
15201
15231
|
machineName: machine.name,
|
|
15202
15232
|
className: classSummary.name,
|
|
15203
|
-
stateTypeName:
|
|
15233
|
+
stateTypeName: stateName2,
|
|
15204
15234
|
transitionTypeName: transitionName,
|
|
15205
15235
|
operation: "reach",
|
|
15206
15236
|
targetState: stateNameValue,
|
|
@@ -15219,7 +15249,7 @@ function buildMachineMethods(classSummary, machine) {
|
|
|
15219
15249
|
kind: "state_machine",
|
|
15220
15250
|
machineName: machine.name,
|
|
15221
15251
|
className: classSummary.name,
|
|
15222
|
-
stateTypeName:
|
|
15252
|
+
stateTypeName: stateName2,
|
|
15223
15253
|
transitionTypeName: transitionName,
|
|
15224
15254
|
operation: "prepare_reach",
|
|
15225
15255
|
targetState: stateNameValue,
|
|
@@ -15232,7 +15262,7 @@ function buildMachineMethods(classSummary, machine) {
|
|
|
15232
15262
|
kind: "state_machine",
|
|
15233
15263
|
machineName: machine.name,
|
|
15234
15264
|
className: classSummary.name,
|
|
15235
|
-
stateTypeName:
|
|
15265
|
+
stateTypeName: stateName2,
|
|
15236
15266
|
transitionTypeName: transitionName,
|
|
15237
15267
|
operation: "prepare_create_reach",
|
|
15238
15268
|
targetState: stateNameValue,
|
|
@@ -16688,8 +16718,8 @@ var Environment = class _Environment {
|
|
|
16688
16718
|
* `await env.recordState({ className: "spend_request", id, machine: "lifecycle", state: "policy_review", source: "customer_backend" })`
|
|
16689
16719
|
*/
|
|
16690
16720
|
state(target) {
|
|
16691
|
-
const observe = async (machineName,
|
|
16692
|
-
const observedState = input.observedState || input.state ||
|
|
16721
|
+
const observe = async (machineName, stateName2, input = {}) => {
|
|
16722
|
+
const observedState = input.observedState || input.state || stateName2;
|
|
16693
16723
|
if (!observedState) {
|
|
16694
16724
|
throw new Error("State observation requires a target state");
|
|
16695
16725
|
}
|
|
@@ -16715,7 +16745,7 @@ var Environment = class _Environment {
|
|
|
16715
16745
|
{
|
|
16716
16746
|
get: (_machineTarget, stateProperty) => {
|
|
16717
16747
|
if (stateProperty === "to") {
|
|
16718
|
-
return (
|
|
16748
|
+
return (stateName2, input) => observe(machineProperty, stateName2, input || {});
|
|
16719
16749
|
}
|
|
16720
16750
|
if (typeof stateProperty !== "string") return void 0;
|
|
16721
16751
|
return (input) => observe(
|
|
@@ -17008,6 +17038,11 @@ var Environment = class _Environment {
|
|
|
17008
17038
|
classNames: options.classNames?.length ? options.classNames : []
|
|
17009
17039
|
}
|
|
17010
17040
|
);
|
|
17041
|
+
if (response.errors?.length) {
|
|
17042
|
+
throw new Error(
|
|
17043
|
+
`Record search failed: ${response.errors.map((error) => error.message).join("; ")}`
|
|
17044
|
+
);
|
|
17045
|
+
}
|
|
17011
17046
|
const seen = /* @__PURE__ */ new Set();
|
|
17012
17047
|
const results = (response.data?.record_search || []).flatMap((entry) => {
|
|
17013
17048
|
const className = entry.className?.trim();
|