@standardagents/builder 0.22.0 → 0.22.1

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/runtime.js CHANGED
@@ -6057,9 +6057,10 @@ var init_context = __esm({
6057
6057
  // src/agents/FlowEngine.ts
6058
6058
  var FlowEngine_exports = {};
6059
6059
  __export(FlowEngine_exports, {
6060
- FlowEngine: () => FlowEngine
6060
+ FlowEngine: () => FlowEngine,
6061
+ HookBlockedExecutionError: () => HookBlockedExecutionError
6061
6062
  });
6062
- var IMMEDIATE_BOOTSTRAP_TOOL_NAME, FlowEngine;
6063
+ var IMMEDIATE_BOOTSTRAP_TOOL_NAME, HookBlockedExecutionError, FlowEngine;
6063
6064
  var init_FlowEngine = __esm({
6064
6065
  "src/agents/FlowEngine.ts"() {
6065
6066
  init_types();
@@ -6070,6 +6071,12 @@ var init_FlowEngine = __esm({
6070
6071
  init_sessionTools();
6071
6072
  init_ThreadStateImpl();
6072
6073
  IMMEDIATE_BOOTSTRAP_TOOL_NAME = "bootstrap_immediate_subagent";
6074
+ HookBlockedExecutionError = class extends Error {
6075
+ constructor(message) {
6076
+ super(message);
6077
+ this.name = "HookBlockedExecutionError";
6078
+ }
6079
+ };
6073
6080
  FlowEngine = class _FlowEngine {
6074
6081
  static IMMEDIATE_SCOPED_ENV_CONTEXT_KEY = "__immediate_scoped_env_by_call_id";
6075
6082
  /**
@@ -6617,7 +6624,26 @@ This usually points to something I can't fix from here \u2014 for example the wo
6617
6624
  state.messageHistory = await this.loadMessageHistory(state);
6618
6625
  const context = await this.assembleContext(state);
6619
6626
  state.allowedTools = context.tools;
6620
- context.messages = await this.runPrefilterLLMHistoryHook(state, context.messages);
6627
+ try {
6628
+ context.messages = await this.runPrefilterLLMHistoryHook(state, context.messages);
6629
+ } catch (error) {
6630
+ if (error instanceof HookBlockedExecutionError) {
6631
+ const threadState = ThreadStateImpl.fromFlowState(state);
6632
+ await threadState.injectMessage({ role: "assistant", content: error.message });
6633
+ state.stopped = true;
6634
+ state.stoppedBy = state.currentSide;
6635
+ state.stopReason = error.message;
6636
+ state.stopReasonCode = "hook_blocked";
6637
+ state.emitTelemetry?.({
6638
+ type: "stopped",
6639
+ reason: state.stopReason,
6640
+ side: state.currentSide,
6641
+ timestamp: Date.now()
6642
+ });
6643
+ return;
6644
+ }
6645
+ throw error;
6646
+ }
6621
6647
  const pendingMessageId = await this.createPendingMessage(state);
6622
6648
  state.pendingMessageId = pendingMessageId;
6623
6649
  let responseStatus = "completed";
@@ -8773,6 +8799,9 @@ ${lines.join("\n\n")}`
8773
8799
  try {
8774
8800
  result = await executor(threadState, result);
8775
8801
  } catch (error) {
8802
+ if (error && typeof error === "object" && error.block === true) {
8803
+ throw new HookBlockedExecutionError(error instanceof Error ? error.message : String(error));
8804
+ }
8776
8805
  console.error("[Hooks] \u2717 Error running prefilter_llm_history hook:", error);
8777
8806
  }
8778
8807
  }