@botpress/runtime 1.3.15 → 1.3.17

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/library.js CHANGED
@@ -48,7 +48,7 @@ var init_define_BUILD = __esm({
48
48
  var define_PACKAGE_VERSIONS_default;
49
49
  var init_define_PACKAGE_VERSIONS = __esm({
50
50
  "<define:__PACKAGE_VERSIONS__>"() {
51
- define_PACKAGE_VERSIONS_default = { runtime: "1.3.15", adk: "not-installed", sdk: "4.17.3", llmz: "0.0.27", zai: "2.1.20", cognitive: "0.1.50" };
51
+ define_PACKAGE_VERSIONS_default = { runtime: "1.3.17", adk: "not-installed", sdk: "4.17.3", llmz: "0.0.27", zai: "2.1.20", cognitive: "0.1.50" };
52
52
  }
53
53
  });
54
54
 
@@ -40453,7 +40453,7 @@ Always prefer information from the knowledge bases over general knowledge when a
40453
40453
  "autonomous.tool.input": args
40454
40454
  },
40455
40455
  async (s) => {
40456
- const value = tool.execute(args, ctx2).catch((e) => {
40456
+ const value = await tool.execute(args, ctx2).catch((e) => {
40457
40457
  err = e;
40458
40458
  if (err && err?.constructor && err?.constructor?.name && err?.constructor?.name === "ThinkSignal") {
40459
40459
  s.setAttributes({
@@ -40518,7 +40518,7 @@ Always prefer information from the knowledge bases over general knowledge when a
40518
40518
  "autonomous.tool.input": args
40519
40519
  },
40520
40520
  async (s) => {
40521
- const value = tool.execute(args, ctx2).catch((e) => {
40521
+ const value = await tool.execute(args, ctx2).catch((e) => {
40522
40522
  err = e;
40523
40523
  if (err && err?.constructor && err?.constructor?.name && err?.constructor?.name === "ThinkSignal") {
40524
40524
  s.setAttributes({
@@ -41312,6 +41312,9 @@ async function _step(name, run, { maxAttempts = DEFAULT_MAX_ATTEMPTS } = {}, {
41312
41312
  startedAt: (/* @__PURE__ */ new Date()).toISOString()
41313
41313
  };
41314
41314
  if (steps[name].finishedAt) {
41315
+ if (steps[name].error) {
41316
+ throw new Error(steps[name].error.message);
41317
+ }
41315
41318
  return steps[name].output;
41316
41319
  }
41317
41320
  while (true) {
@@ -41340,17 +41343,24 @@ async function _step(name, run, { maxAttempts = DEFAULT_MAX_ATTEMPTS } = {}, {
41340
41343
  return;
41341
41344
  }
41342
41345
  if (steps[name].attempts >= maxAttempts - 1) {
41346
+ const errorMessage = e instanceof Error ? e.message : String(e);
41347
+ steps[name].error = {
41348
+ message: errorMessage,
41349
+ failedAt: (/* @__PURE__ */ new Date()).toISOString(),
41350
+ maxAttemptsReached: true
41351
+ };
41352
+ steps[name].finishedAt = (/* @__PURE__ */ new Date()).toISOString();
41343
41353
  stepSpan.setAttributes({
41344
- "workflow.step.error": e instanceof Error ? e.message : String(e)
41354
+ "workflow.step.error": errorMessage,
41355
+ "workflow.step.max_attempts": maxAttempts
41345
41356
  });
41346
41357
  stepSpan.setStatus({
41347
41358
  code: 2,
41348
41359
  message: `Step "${name}" failed after max attempts (${maxAttempts})`
41349
41360
  });
41350
- workflowControlContext.fail(
41351
- `Step "${name}" failed after max attempts (${maxAttempts})`
41352
- );
41353
- return;
41361
+ state.value.revision++;
41362
+ await workflowControlContext.ack();
41363
+ throw e;
41354
41364
  } else {
41355
41365
  steps[name].attempts++;
41356
41366
  stepSpan.setAttributes({
@@ -41683,7 +41693,12 @@ var workflowStepContextSchema = z7.lazy(
41683
41693
  i: z7.number().optional(),
41684
41694
  startedAt: z7.string(),
41685
41695
  finishedAt: z7.string().optional(),
41686
- steps: z7.record(z7.string(), workflowStepContextSchema).optional()
41696
+ steps: z7.record(z7.string(), workflowStepContextSchema).optional(),
41697
+ error: z7.object({
41698
+ message: z7.string(),
41699
+ failedAt: z7.string(),
41700
+ maxAttemptsReached: z7.boolean()
41701
+ }).optional()
41687
41702
  })
41688
41703
  );
41689
41704
  var workflowExecutionContextSchema = z7.object({