@xenosystem/agent-sdk 0.10.35 → 0.10.36

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.
@@ -780,6 +780,44 @@ declare class PermissionEngine {
780
780
  private normalizeCommandText;
781
781
  private resolveTargetPath;
782
782
  }
783
+ type HookEventName = "SessionStart" | "UserPromptSubmit" | "PermissionRequest" | "PreToolUse" | "PostToolUse" | "PreCompact" | "PostCompact" | "Stop" | "StopFailure" | "SubagentStart" | "SubagentStop";
784
+ interface BaseHookDefinition {
785
+ name?: string;
786
+ events?: HookEventName[];
787
+ timeoutMs?: number;
788
+ maxOutputBytes?: number;
789
+ failClosed?: boolean;
790
+ async?: boolean;
791
+ }
792
+ interface CommandHookDefinition extends BaseHookDefinition {
793
+ type: "command";
794
+ command: string;
795
+ args?: string[];
796
+ cwd?: string;
797
+ shell?: boolean;
798
+ env?: Record<string, string>;
799
+ }
800
+ interface HttpHookDefinition extends BaseHookDefinition {
801
+ type: "http";
802
+ url: string;
803
+ method?: "POST";
804
+ headers?: Record<string, string>;
805
+ }
806
+ interface PromptHookDefinition extends BaseHookDefinition {
807
+ type: "prompt";
808
+ prompt: string;
809
+ }
810
+ interface AgentHookDefinition extends BaseHookDefinition {
811
+ type: "agent";
812
+ prompt: string;
813
+ agent?: string;
814
+ model?: string;
815
+ }
816
+ type HookDefinition = CommandHookDefinition | HttpHookDefinition | PromptHookDefinition | AgentHookDefinition;
817
+ interface HookConfig {
818
+ hooks?: HookDefinition[];
819
+ events?: Partial<Record<HookEventName, HookDefinition[]>>;
820
+ }
783
821
  type ToolFailureCategory = "schema" | "missing_path" | "permission_denied" | "transport" | "timeout" | "tool_failure";
784
822
  interface ToolFailureGuardTrip {
785
823
  category: ToolFailureCategory;
@@ -1558,6 +1596,7 @@ interface AgentLoopConfig {
1558
1596
  onIteration?: (iteration: number, totalTokens: number) => void;
1559
1597
  modelWorkAccounting?: ModelWorkAccounting;
1560
1598
  runAuthority?: RunAuthority;
1599
+ hooks?: HookConfig;
1561
1600
  onError?: (error: Error, context: string) => void;
1562
1601
  onTranscriptError?: (error: Error, context: string) => void;
1563
1602
  onModeSwitchRequest?: (request: ModeSwitchRequest) => Promise<boolean>;
@@ -1682,6 +1721,7 @@ declare class AgentLoop {
1682
1721
  private readonly promptSections;
1683
1722
  private readonly completionGuards;
1684
1723
  private readonly toolFailureGuard;
1724
+ private readonly preToolUseGate;
1685
1725
  private turnToolCalls;
1686
1726
  private turnToolFailures;
1687
1727
  private turnFailuresByTool;
@@ -780,6 +780,44 @@ declare class PermissionEngine {
780
780
  private normalizeCommandText;
781
781
  private resolveTargetPath;
782
782
  }
783
+ type HookEventName = "SessionStart" | "UserPromptSubmit" | "PermissionRequest" | "PreToolUse" | "PostToolUse" | "PreCompact" | "PostCompact" | "Stop" | "StopFailure" | "SubagentStart" | "SubagentStop";
784
+ interface BaseHookDefinition {
785
+ name?: string;
786
+ events?: HookEventName[];
787
+ timeoutMs?: number;
788
+ maxOutputBytes?: number;
789
+ failClosed?: boolean;
790
+ async?: boolean;
791
+ }
792
+ interface CommandHookDefinition extends BaseHookDefinition {
793
+ type: "command";
794
+ command: string;
795
+ args?: string[];
796
+ cwd?: string;
797
+ shell?: boolean;
798
+ env?: Record<string, string>;
799
+ }
800
+ interface HttpHookDefinition extends BaseHookDefinition {
801
+ type: "http";
802
+ url: string;
803
+ method?: "POST";
804
+ headers?: Record<string, string>;
805
+ }
806
+ interface PromptHookDefinition extends BaseHookDefinition {
807
+ type: "prompt";
808
+ prompt: string;
809
+ }
810
+ interface AgentHookDefinition extends BaseHookDefinition {
811
+ type: "agent";
812
+ prompt: string;
813
+ agent?: string;
814
+ model?: string;
815
+ }
816
+ type HookDefinition = CommandHookDefinition | HttpHookDefinition | PromptHookDefinition | AgentHookDefinition;
817
+ interface HookConfig {
818
+ hooks?: HookDefinition[];
819
+ events?: Partial<Record<HookEventName, HookDefinition[]>>;
820
+ }
783
821
  type ToolFailureCategory = "schema" | "missing_path" | "permission_denied" | "transport" | "timeout" | "tool_failure";
784
822
  interface ToolFailureGuardTrip {
785
823
  category: ToolFailureCategory;
@@ -1558,6 +1596,7 @@ interface AgentLoopConfig {
1558
1596
  onIteration?: (iteration: number, totalTokens: number) => void;
1559
1597
  modelWorkAccounting?: ModelWorkAccounting;
1560
1598
  runAuthority?: RunAuthority;
1599
+ hooks?: HookConfig;
1561
1600
  onError?: (error: Error, context: string) => void;
1562
1601
  onTranscriptError?: (error: Error, context: string) => void;
1563
1602
  onModeSwitchRequest?: (request: ModeSwitchRequest) => Promise<boolean>;
@@ -1682,6 +1721,7 @@ declare class AgentLoop {
1682
1721
  private readonly promptSections;
1683
1722
  private readonly completionGuards;
1684
1723
  private readonly toolFailureGuard;
1724
+ private readonly preToolUseGate;
1685
1725
  private turnToolCalls;
1686
1726
  private turnToolFailures;
1687
1727
  private turnFailuresByTool;