@stigmer/runner-slim 3.12.4 → 3.12.6

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.
Files changed (3) hide show
  1. package/main.js +586 -697
  2. package/package.json +6 -6
  3. package/workflow-bundle.js +44 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stigmer/runner-slim",
3
- "version": "3.12.4",
3
+ "version": "3.12.6",
4
4
  "description": "Self-contained Stigmer runner build for embedding in desktop apps — the bundle-friendly @stigmer/runner",
5
5
  "license": "Apache-2.0",
6
6
  "engines": {
@@ -16,11 +16,11 @@
16
16
  "jq-wasm": "^1.1.0-jq-1.8.1"
17
17
  },
18
18
  "optionalDependencies": {
19
- "@stigmer/runner-slim-darwin-arm64": "3.12.4",
20
- "@stigmer/runner-slim-darwin-x64": "3.12.4",
21
- "@stigmer/runner-slim-linux-x64": "3.12.4",
22
- "@stigmer/runner-slim-linux-arm64": "3.12.4",
23
- "@stigmer/runner-slim-win32-x64": "3.12.4"
19
+ "@stigmer/runner-slim-darwin-arm64": "3.12.6",
20
+ "@stigmer/runner-slim-darwin-x64": "3.12.6",
21
+ "@stigmer/runner-slim-linux-x64": "3.12.6",
22
+ "@stigmer/runner-slim-linux-arm64": "3.12.6",
23
+ "@stigmer/runner-slim-win32-x64": "3.12.6"
24
24
  },
25
25
  "keywords": [
26
26
  "stigmer",
@@ -26909,7 +26909,8 @@ __webpack_require__.r(__webpack_exports__);
26909
26909
  * Human input task executor — HITL approval gate.
26910
26910
  *
26911
26911
  * Pauses workflow execution until a human reviewer responds via signal.
26912
- * Supports configurable timeout with policies (fail, auto-approve, auto-deny).
26912
+ * Supports configurable timeout with policies (fail, auto-approve,
26913
+ * auto-deny, escalate).
26913
26914
  *
26914
26915
  * The kernel validates the config and delegates to `ctx.awaitHumanInput()`
26915
26916
  * which is wired to the Temporal workflow layer's signal/timer selector.
@@ -26979,11 +26980,11 @@ async function executeHumanInputTask(taskDef, taskName, state, ctx) {
26979
26980
  ...review.artifactEvents,
26980
26981
  ]);
26981
26982
  }
26982
- const result = await ctx.awaitHumanInput({
26983
+ const result = applyTimeoutOutcomeContract(await ctx.awaitHumanInput({
26983
26984
  signalName,
26984
26985
  timeoutSeconds,
26985
26986
  onTimeout,
26986
- });
26987
+ }), config.outcomes);
26987
26988
  if (ctx.emitEvents) {
26988
26989
  await ctx.emitEvents([{
26989
26990
  type: "approval_resolved",
@@ -27009,6 +27010,33 @@ function validateConfig(config, taskName) {
27009
27010
  throw new Error(`human_input task '${taskName}': 'prompt' is required`);
27010
27011
  }
27011
27012
  }
27013
+ /**
27014
+ * Applies the proto contract for timeout auto-resolution with custom
27015
+ * outcomes (HumanInputTaskConfig.outcomes doc): auto-approve resolves to
27016
+ * the FIRST declared outcome and auto-deny to the LAST, so `then` routing
27017
+ * and downstream outcome switches see declared outcome names — never the
27018
+ * orchestrator's internal approve/deny words, which a reviewer of a
27019
+ * custom-outcome gate was never offered. Binary gates (no custom outcomes)
27020
+ * keep the plain approve/deny result.
27021
+ *
27022
+ * Escalate needs no remapping by construction (stigmer/stigmer#781): its
27023
+ * policy word IS the declared outcome's name — the loader (and the server
27024
+ * validator) only accept the escalate policy when an outcome named
27025
+ * "escalate" with `then` exists, so the caller's ordinary name lookup
27026
+ * routes the escalation branch.
27027
+ */
27028
+ function applyTimeoutOutcomeContract(result, outcomes) {
27029
+ if (!result.auto_resolved || result.reason !== "timeout" || !outcomes?.length) {
27030
+ return result;
27031
+ }
27032
+ if (result.outcome === "approve") {
27033
+ return { ...result, outcome: outcomes[0].name };
27034
+ }
27035
+ if (result.outcome === "deny") {
27036
+ return { ...result, outcome: outcomes[outcomes.length - 1].name };
27037
+ }
27038
+ return result;
27039
+ }
27012
27040
  const NO_REVIEW_PAYLOAD = { artifactEvents: [] };
27013
27041
  /**
27014
27042
  * Resolves the review payload's `${ ... }` expressions and decides how it
@@ -28956,6 +28984,10 @@ __webpack_require__.r(__webpack_exports__);
28956
28984
  * - "fail": throws an error
28957
28985
  * - "approve": returns auto-approved output
28958
28986
  * - "deny": returns auto-denied output
28987
+ * - "escalate": returns the "escalate" outcome — by the outcome-by-name
28988
+ * contract (stigmer/stigmer#781) the loader guarantees the gate declares
28989
+ * an outcome with that exact name and a `then` branch, so the executor's
28990
+ * ordinary outcome routing takes the escalation path.
28959
28991
  *
28960
28992
  * Signal payload shape:
28961
28993
  * { outcome, form_data?, reviewer, reviewer_actor?, responded_at }
@@ -29001,6 +29033,15 @@ function handleTimeout(signalName, policy) {
29001
29033
  auto_resolved: true,
29002
29034
  reason: "timeout",
29003
29035
  };
29036
+ case "escalate":
29037
+ // The outcome word IS the declared outcome's name (loader-enforced),
29038
+ // so no positional remapping happens downstream — the executor's name
29039
+ // lookup routes the escalation branch directly.
29040
+ return {
29041
+ outcome: "escalate",
29042
+ auto_resolved: true,
29043
+ reason: "timeout",
29044
+ };
29004
29045
  case "fail":
29005
29046
  default:
29006
29047
  throw new Error(`human_input task timed out waiting for signal '${signalName}'`);