@gencode/agents 0.0.11 → 0.0.13

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/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { S as AgentsConfig, _ as saveAgentsConfig, a as listAgents, b as AgentConfig, c as normalizeAgentId, d as resolveAgentDir, f as resolveAgentIdByBinding, g as resolveModelString, h as resolveModelFallbacks, i as getAgentConfig, l as removeAgent, m as resolveDefaultAgentId, n as addBinding, o as listBindings, p as resolveAgentsConfigPath, s as loadAgentsConfig, t as addAgent, u as removeBindings, v as updateAgentIdentity, x as AgentModelConfig, y as AgentBinding } from "./index-BdfpRxFA.js";
2
2
  import { AssistantMessage, Message } from "@mariozechner/pi-ai";
3
- import { AgentTool } from "@mariozechner/pi-agent-core";
4
- import { AgentProgressEvent, AgentProgressEvent as AgentProgressEvent$1, CallbackEventPayload, CallbackEventPayload as CallbackEventPayload$1, Channel, Channel as Channel$1, RunResultPayload, RunResultPayload as RunResultPayload$1 } from "@gencode/shared";
3
+ import { AgentMessage, AgentTool } from "@mariozechner/pi-agent-core";
4
+ import { AgentProgressEvent, AgentProgressEvent as AgentProgressEvent$1, CallbackEventPayload, CallbackEventPayload as CallbackEventPayload$1, Channel, Channel as Channel$1, CollapseSpan, ReadStateRecord, RunResultPayload, RunResultPayload as RunResultPayload$1, SessionContextSnapshot, SessionMemorySnapshot, SnipRecord, ToolResultReference } from "@gencode/shared";
5
5
 
6
6
  //#region src/loop-detection/tool-loop-detection.d.ts
7
7
  type ToolLoopDetectionConfig = {
@@ -212,6 +212,7 @@ type ToolResultEntry = {
212
212
  toolName: string; /** Text output of the tool */
213
213
  content: string;
214
214
  isError: boolean;
215
+ toolResultRef?: ToolResultReference;
215
216
  timestamp: string;
216
217
  };
217
218
  /**
@@ -546,6 +547,33 @@ type SessionSummary = {
546
547
  createdAt: string;
547
548
  updatedAt: string;
548
549
  };
550
+ type SessionInspection = {
551
+ id: string;
552
+ metadata: SessionMetadata | null;
553
+ transcriptPath: string;
554
+ contextSnapshotPath: string;
555
+ sessionMemoryPath: string;
556
+ collapseLogPath: string;
557
+ toolResultsDir: string;
558
+ transcriptEntryCount: number;
559
+ readStateCount: number;
560
+ toolResultRefCount: number;
561
+ transcriptEntries: TranscriptEntry[];
562
+ context: SessionContextSnapshot;
563
+ };
564
+ type SessionExport = {
565
+ id: string;
566
+ metadata: SessionMetadata | null;
567
+ transcript: TranscriptEntry[];
568
+ context: SessionContextSnapshot;
569
+ paths: {
570
+ transcriptPath: string;
571
+ contextSnapshotPath: string;
572
+ sessionMemoryPath: string;
573
+ collapseLogPath: string;
574
+ toolResultsDir: string;
575
+ };
576
+ };
549
577
  /** Resolves the sessions directory path within a data directory */
550
578
  declare function sessionsDir(dataDir: string): string;
551
579
  /** Resolves the directory for a specific session */
@@ -554,6 +582,12 @@ declare function sessionDir(dataDir: string, sessionId: string): string;
554
582
  declare function transcriptPath(dataDir: string, sessionId: string): string;
555
583
  /** Resolves the metadata file path for a session */
556
584
  declare function metadataPath(dataDir: string, sessionId: string): string;
585
+ /** Resolves the persisted context snapshot path for a session */
586
+ declare function contextSnapshotPath(dataDir: string, sessionId: string): string;
587
+ declare function sessionMemoryPath(dataDir: string, sessionId: string): string;
588
+ declare function collapseLogPath(dataDir: string, sessionId: string): string;
589
+ /** Resolves the persisted tool-results directory for a session */
590
+ declare function toolResultsDir(dataDir: string, sessionId: string): string;
557
591
  /** Creates a new session with a generated ID */
558
592
  declare function createSession(dataDir: string, channel: Channel): Promise<string>;
559
593
  /** Ensures a session directory exists (for resuming an existing session) */
@@ -574,6 +608,240 @@ declare function saveSessionMetadata(dataDir: string, metadata: SessionMetadata)
574
608
  declare function loadSessionMetadata(dataDir: string, sessionId: string): Promise<SessionMetadata | null>;
575
609
  /** Lists all sessions with their metadata summaries, optionally filtered by channel */
576
610
  declare function listSessionSummaries(dataDir: string, channel?: Channel): Promise<SessionSummary[]>;
611
+ declare function loadSessionContextSnapshot(dataDir: string, sessionId: string): Promise<SessionContextSnapshot>;
612
+ declare function inspectSession(dataDir: string, sessionId: string): Promise<SessionInspection>;
613
+ declare function exportSession(dataDir: string, sessionId: string): Promise<SessionExport>;
614
+ //#endregion
615
+ //#region src/plugins/hooks.d.ts
616
+ type PluginHookName = "before_model_resolve" | "before_prompt_build" | "after_prompt_build" | "llm_input" | "assistant_message_end" | "llm_output" | "before_tool_call" | "after_tool_call" | "agent_end" | "before_compaction" | "after_compaction" | "session_start" | "session_end" | "session_reset" | "memory_changed";
617
+ type PluginHookAgentContext = {
618
+ agentId?: string;
619
+ sessionId?: string;
620
+ workspaceDir?: string;
621
+ channel?: AgentRunParams["channel"];
622
+ };
623
+ type PluginHookBeforeModelResolveEvent = {
624
+ prompt: string;
625
+ };
626
+ type PluginHookBeforeModelResolveResult = {
627
+ modelOverride?: string;
628
+ };
629
+ type PluginHookBeforePromptBuildEvent = {
630
+ prompt: string;
631
+ };
632
+ type PluginHookBeforePromptBuildResult = {
633
+ systemPrompt?: string;
634
+ prependContext?: string;
635
+ };
636
+ type PluginHookAfterPromptBuildEvent = {
637
+ prompt: string;
638
+ systemPrompt: string;
639
+ };
640
+ type PluginHookLlmInputEvent = {
641
+ sessionId: string;
642
+ model: string;
643
+ prompt: string;
644
+ historyMessages: unknown[];
645
+ };
646
+ type PluginHookAssistantMessageEndEvent = {
647
+ sessionId: string;
648
+ model: string;
649
+ assistantText: string;
650
+ assistantMessage: AssistantMessage;
651
+ hasToolCalls: boolean;
652
+ durationMs?: number;
653
+ usage?: {
654
+ input?: number;
655
+ output?: number;
656
+ total?: number;
657
+ };
658
+ };
659
+ type PluginHookLlmOutputEvent = {
660
+ sessionId: string;
661
+ model: string;
662
+ assistantTexts: string[];
663
+ lastAssistant?: AssistantMessage;
664
+ usage?: {
665
+ input?: number;
666
+ output?: number;
667
+ total?: number;
668
+ };
669
+ };
670
+ type PluginHookBeforeToolCallEvent = {
671
+ toolCallId: string;
672
+ toolName: string;
673
+ params: Record<string, unknown>;
674
+ };
675
+ type PluginHookBeforeToolCallResult = {
676
+ params?: Record<string, unknown>;
677
+ block?: boolean;
678
+ blockReason?: string;
679
+ };
680
+ type PluginHookAfterToolCallEvent = {
681
+ toolCallId: string;
682
+ toolName: string;
683
+ params: Record<string, unknown>;
684
+ result?: unknown;
685
+ error?: string;
686
+ durationMs?: number;
687
+ };
688
+ type PluginHookAgentEndEvent = {
689
+ success: boolean;
690
+ error?: string;
691
+ durationMs?: number;
692
+ };
693
+ type PluginHookBeforeCompactionEvent = {
694
+ messageCount: number;
695
+ compactingCount?: number;
696
+ };
697
+ type PluginHookAfterCompactionEvent = {
698
+ messageCount: number;
699
+ compactedCount: number;
700
+ };
701
+ type PluginHookSessionStartEvent = {
702
+ sessionId: string;
703
+ };
704
+ type PluginHookSessionEndEvent = {
705
+ sessionId: string;
706
+ messageCount: number;
707
+ durationMs?: number;
708
+ };
709
+ type PluginHookSessionResetEvent = {
710
+ action: "new" | "reset";
711
+ sessionId: string;
712
+ previousSessionId?: string;
713
+ message: string;
714
+ };
715
+ type PluginHookMemoryChangedEvent = MemoryChangedEvent;
716
+ type PluginHookHandlerMap = {
717
+ before_model_resolve: (event: PluginHookBeforeModelResolveEvent, ctx: PluginHookAgentContext) => PluginHookBeforeModelResolveResult | void | Promise<PluginHookBeforeModelResolveResult | void>;
718
+ before_prompt_build: (event: PluginHookBeforePromptBuildEvent, ctx: PluginHookAgentContext) => PluginHookBeforePromptBuildResult | void | Promise<PluginHookBeforePromptBuildResult | void>;
719
+ after_prompt_build: (event: PluginHookAfterPromptBuildEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
720
+ llm_input: (event: PluginHookLlmInputEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
721
+ assistant_message_end: (event: PluginHookAssistantMessageEndEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
722
+ llm_output: (event: PluginHookLlmOutputEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
723
+ before_tool_call: (event: PluginHookBeforeToolCallEvent, ctx: PluginHookAgentContext) => PluginHookBeforeToolCallResult | void | Promise<PluginHookBeforeToolCallResult | void>;
724
+ after_tool_call: (event: PluginHookAfterToolCallEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
725
+ agent_end: (event: PluginHookAgentEndEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
726
+ before_compaction: (event: PluginHookBeforeCompactionEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
727
+ after_compaction: (event: PluginHookAfterCompactionEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
728
+ session_start: (event: PluginHookSessionStartEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
729
+ session_end: (event: PluginHookSessionEndEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
730
+ session_reset: (event: PluginHookSessionResetEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
731
+ memory_changed: (event: PluginHookMemoryChangedEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
732
+ };
733
+ type PluginHookRegistration<K extends PluginHookName = PluginHookName> = {
734
+ pluginId: string;
735
+ hookName: K;
736
+ handler: PluginHookHandlerMap[K];
737
+ priority?: number;
738
+ source: string;
739
+ };
740
+ declare class PluginHookRegistry {
741
+ private readonly hooks;
742
+ register<K extends PluginHookName>(registration: PluginHookRegistration<K>): void;
743
+ dispatch<K extends PluginHookName>(hookName: K, event: Parameters<PluginHookHandlerMap[K]>[0], ctx: Parameters<PluginHookHandlerMap[K]>[1]): Promise<Array<Awaited<ReturnType<PluginHookHandlerMap[K]>>>>;
744
+ }
745
+ //#endregion
746
+ //#region src/context/session-context-store.d.ts
747
+ type PersistedToolResult = {
748
+ content: string;
749
+ reference?: ToolResultReference;
750
+ };
751
+ type SessionContextStore = {
752
+ findReusableRead(path: string, offset?: number, limit?: number): Promise<ReadStateRecord | null>;
753
+ recordRead(params: {
754
+ path: string;
755
+ content: string;
756
+ lineCount: number;
757
+ offset?: number;
758
+ limit?: number;
759
+ }): Promise<ReadStateRecord>;
760
+ invalidatePath(path: string): Promise<void>;
761
+ persistToolResult(params: {
762
+ toolCallId: string;
763
+ toolName: string;
764
+ content: string;
765
+ thresholdChars?: number;
766
+ previewChars?: number;
767
+ }): Promise<PersistedToolResult>;
768
+ recordSnip(record: SnipRecord): Promise<void>;
769
+ recordCollapse(span: CollapseSpan): Promise<void>;
770
+ setSessionMemory(snapshot: SessionMemorySnapshot): Promise<void>;
771
+ recordAutocompactResult(params: {
772
+ layer: "L6";
773
+ failed: boolean;
774
+ timestamp: string;
775
+ }): Promise<void>;
776
+ getSnapshot(): SessionContextSnapshot;
777
+ };
778
+ type SessionContextStoreOptions = {
779
+ dataDir: string;
780
+ sessionId: string;
781
+ };
782
+ declare function createSessionContextStore(options: SessionContextStoreOptions): Promise<SessionContextStore>;
783
+ //#endregion
784
+ //#region src/context/context-manager.d.ts
785
+ type ManageLayeredHistoryParams = {
786
+ entries: TranscriptEntry[];
787
+ modelInfo: {
788
+ model: string;
789
+ api: string;
790
+ };
791
+ contextWindowTokens: number;
792
+ llm: {
793
+ baseUrl: string;
794
+ apiKey: string;
795
+ model: string;
796
+ };
797
+ historyLimit?: number;
798
+ compactionEnabled?: boolean;
799
+ signal?: AbortSignal;
800
+ hooks?: PluginHookRegistry;
801
+ hookCtx?: PluginHookAgentContext;
802
+ contextStore?: SessionContextStore;
803
+ dataDir?: string;
804
+ sessionId?: string;
805
+ };
806
+ type ManageLayeredHistoryResult = {
807
+ messages: AgentMessage[];
808
+ priorSummary: string | undefined;
809
+ compactionEntry: CompactionEntry | undefined;
810
+ stats: {
811
+ originalCount: number;
812
+ keptCount: number;
813
+ estimatedTokens: number;
814
+ compacted: boolean;
815
+ };
816
+ compactionEvents: AgentProgressEvent$1[];
817
+ };
818
+ type ContextManager = {
819
+ getReusableRead(path: string, offset?: number, limit?: number): Promise<{
820
+ reused: boolean;
821
+ lineCount?: number;
822
+ }>;
823
+ rememberRead(params: {
824
+ path: string;
825
+ content: string;
826
+ lineCount: number;
827
+ offset?: number;
828
+ limit?: number;
829
+ }): Promise<void>;
830
+ invalidateReadPath(path: string): Promise<void>;
831
+ persistToolResult(params: {
832
+ toolCallId: string;
833
+ toolName: string;
834
+ content: string;
835
+ thresholdChars?: number;
836
+ previewChars?: number;
837
+ }): Promise<PersistedToolResult>;
838
+ manageHistory(params: Omit<ManageLayeredHistoryParams, "contextStore">): Promise<ManageLayeredHistoryResult>;
839
+ getSnapshot: SessionContextStore["getSnapshot"];
840
+ };
841
+ declare function createContextManager(params: {
842
+ dataDir: string;
843
+ sessionId: string;
844
+ }): Promise<ContextManager>;
577
845
  //#endregion
578
846
  //#region src/bootstrap/bootstrap.d.ts
579
847
  /** Maximum characters per bootstrap file before truncation */
@@ -631,6 +899,7 @@ type BootstrapEnsureResult = {
631
899
  performedBootstrap: boolean;
632
900
  result?: BootstrapMountResult;
633
901
  };
902
+ declare function hasBootstrapSentinel(dataDir: string): Promise<boolean>;
634
903
  declare function inspectBootstrapMountLayout(dataDir: string): Promise<BootstrapMountStatus>;
635
904
  declare function isBootstrapMountLayoutReady(dataDir: string): Promise<boolean>;
636
905
  declare function ensureBootstrapMountLayout(dataDir: string): Promise<BootstrapEnsureResult>;
@@ -1064,6 +1333,8 @@ type ProcessSessionSnapshot = {
1064
1333
  exitCode?: number | null;
1065
1334
  exitSignal?: NodeJS.Signals | null;
1066
1335
  outputTail: string;
1336
+ stdoutTail: string;
1337
+ stderrTail: string;
1067
1338
  outputTruncated: boolean;
1068
1339
  };
1069
1340
  type ProcessLogSlice = {
@@ -1076,6 +1347,16 @@ type ProcessLogSlice = {
1076
1347
  exitCode?: number | null;
1077
1348
  exitSignal?: NodeJS.Signals | null;
1078
1349
  };
1350
+ type ProcessOutput = {
1351
+ sessionId: string;
1352
+ status: ProcessStatus;
1353
+ stdout: string;
1354
+ stderr: string;
1355
+ combined: string;
1356
+ truncated: boolean;
1357
+ exitCode?: number | null;
1358
+ exitSignal?: NodeJS.Signals | null;
1359
+ };
1079
1360
  type ProcessStartParams = {
1080
1361
  command: string;
1081
1362
  cwd: string;
@@ -1094,6 +1375,7 @@ type ProcessRegistry = {
1094
1375
  offset?: number;
1095
1376
  limit?: number;
1096
1377
  }): ProcessLogSlice | null;
1378
+ readOutput(sessionId: string, scopeKey?: string): ProcessOutput | null;
1097
1379
  terminate(sessionId: string, scopeKey?: string): Promise<ProcessSessionSnapshot | null>;
1098
1380
  };
1099
1381
  //#endregion
@@ -1110,6 +1392,7 @@ type ExecToolOptions = {
1110
1392
  workspaceDir: string;
1111
1393
  registry: ProcessRegistry;
1112
1394
  scopeKey?: string;
1395
+ contextManager?: ContextManager;
1113
1396
  };
1114
1397
  declare function createExecTool(options: ExecToolOptions): AgentTool<typeof execSchema, Record<string, unknown>>;
1115
1398
  //#endregion
@@ -1145,12 +1428,12 @@ type ReadFileResult = {
1145
1428
  lines: number;
1146
1429
  truncated: boolean;
1147
1430
  };
1148
- declare function createReadFileTool(workspaceDir: string): AgentTool<typeof readFileSchema, ReadFileResult>;
1431
+ declare function createReadFileTool(workspaceDir: string, contextManager?: ContextManager): AgentTool<typeof readFileSchema, ReadFileResult>;
1149
1432
  declare const writeFileSchema: TObject<{
1150
1433
  path: TString;
1151
1434
  content: TString;
1152
1435
  }>;
1153
- declare function createWriteFileTool(workspaceDir: string): AgentTool<typeof writeFileSchema, {
1436
+ declare function createWriteFileTool(workspaceDir: string, contextManager?: ContextManager): AgentTool<typeof writeFileSchema, {
1154
1437
  path: string;
1155
1438
  }>;
1156
1439
  declare const editFileSchema: TObject<{
@@ -1158,7 +1441,7 @@ declare const editFileSchema: TObject<{
1158
1441
  old_string: TString;
1159
1442
  new_string: TString;
1160
1443
  }>;
1161
- declare function createEditFileTool(workspaceDir: string): AgentTool<typeof editFileSchema, {
1444
+ declare function createEditFileTool(workspaceDir: string, contextManager?: ContextManager): AgentTool<typeof editFileSchema, {
1162
1445
  path: string;
1163
1446
  occurrences: number;
1164
1447
  }>;
@@ -1233,7 +1516,7 @@ declare function buildSubagentAnnounceMessage(params: {
1233
1516
  * @param loopDetection Tool-loop detection config inherited from the parent.
1234
1517
  * @param spawnFn Function that actually runs a child agent (injected to avoid circular imports).
1235
1518
  */
1236
- declare function createSessionsSpawnTool(registry: SubagentRegistry, parentSessionId: string, depth: number, dataDir: string, channel: AgentRunParams["channel"], llm: AgentRunParams["llm"], loopDetection: ToolLoopDetectionConfig | undefined, inheritedRunParams: Pick<AgentRunParams, "plugins" | "memory" | "messaging" | "docs" | "historyLimit">, spawnFn: (params: AgentRunParams) => Promise<AgentRunResult>): AgentTool<typeof spawnSchema, SpawnResult>;
1519
+ declare function createSessionsSpawnTool(registry: SubagentRegistry, parentSessionId: string, depth: number, dataDir: string, channel: AgentRunParams["channel"], llm: AgentRunParams["llm"], loopDetection: ToolLoopDetectionConfig | undefined, inheritedRunParams: Pick<AgentRunParams, "plugins" | "memory" | "messaging" | "docs" | "historyLimit" | "onProgress" | "messageId">, spawnFn: (params: AgentRunParams) => Promise<AgentRunResult>): AgentTool<typeof spawnSchema, SpawnResult>;
1237
1520
  //#endregion
1238
1521
  //#region src/tools/subagents.d.ts
1239
1522
  declare const ACTIONS: readonly ["list", "kill"];
@@ -1270,9 +1553,10 @@ type SubagentToolsContext = {
1270
1553
  depth: number;
1271
1554
  channel: AgentRunParams["channel"];
1272
1555
  llm: AgentRunParams["llm"];
1273
- inheritedRunParams?: Pick<AgentRunParams, "plugins" | "memory" | "messaging" | "docs" | "historyLimit">;
1556
+ inheritedRunParams?: Pick<AgentRunParams, "plugins" | "memory" | "messaging" | "docs" | "historyLimit" | "onProgress" | "messageId">;
1274
1557
  loopDetection?: ToolLoopDetectionConfig;
1275
- memoryOptions?: MemoryToolOptions; /** Callback that runs a child agent; injected to avoid circular imports */
1558
+ memoryOptions?: MemoryToolOptions;
1559
+ contextManager?: ContextManager; /** Callback that runs a child agent; injected to avoid circular imports */
1276
1560
  spawnFn: (params: AgentRunParams) => Promise<AgentRunResult>;
1277
1561
  };
1278
1562
  /**
@@ -1327,137 +1611,6 @@ declare const PLUGIN_MANIFEST_FILENAMES: readonly ["aimax.plugin.json"];
1327
1611
  declare function resolvePluginManifestPath(rootDir: string): string;
1328
1612
  declare function loadPluginManifest(rootDir: string, rejectHardlinks?: boolean): PluginManifestLoadResult;
1329
1613
  //#endregion
1330
- //#region src/plugins/hooks.d.ts
1331
- type PluginHookName = "before_model_resolve" | "before_prompt_build" | "after_prompt_build" | "llm_input" | "assistant_message_end" | "llm_output" | "before_tool_call" | "after_tool_call" | "agent_end" | "before_compaction" | "after_compaction" | "session_start" | "session_end" | "session_reset" | "memory_changed";
1332
- type PluginHookAgentContext = {
1333
- agentId?: string;
1334
- sessionId?: string;
1335
- workspaceDir?: string;
1336
- channel?: AgentRunParams["channel"];
1337
- };
1338
- type PluginHookBeforeModelResolveEvent = {
1339
- prompt: string;
1340
- };
1341
- type PluginHookBeforeModelResolveResult = {
1342
- modelOverride?: string;
1343
- };
1344
- type PluginHookBeforePromptBuildEvent = {
1345
- prompt: string;
1346
- };
1347
- type PluginHookBeforePromptBuildResult = {
1348
- systemPrompt?: string;
1349
- prependContext?: string;
1350
- };
1351
- type PluginHookAfterPromptBuildEvent = {
1352
- prompt: string;
1353
- systemPrompt: string;
1354
- };
1355
- type PluginHookLlmInputEvent = {
1356
- sessionId: string;
1357
- model: string;
1358
- prompt: string;
1359
- historyMessages: unknown[];
1360
- };
1361
- type PluginHookAssistantMessageEndEvent = {
1362
- sessionId: string;
1363
- model: string;
1364
- assistantText: string;
1365
- assistantMessage: AssistantMessage;
1366
- hasToolCalls: boolean;
1367
- durationMs?: number;
1368
- usage?: {
1369
- input?: number;
1370
- output?: number;
1371
- total?: number;
1372
- };
1373
- };
1374
- type PluginHookLlmOutputEvent = {
1375
- sessionId: string;
1376
- model: string;
1377
- assistantTexts: string[];
1378
- lastAssistant?: AssistantMessage;
1379
- usage?: {
1380
- input?: number;
1381
- output?: number;
1382
- total?: number;
1383
- };
1384
- };
1385
- type PluginHookBeforeToolCallEvent = {
1386
- toolCallId: string;
1387
- toolName: string;
1388
- params: Record<string, unknown>;
1389
- };
1390
- type PluginHookBeforeToolCallResult = {
1391
- params?: Record<string, unknown>;
1392
- block?: boolean;
1393
- blockReason?: string;
1394
- };
1395
- type PluginHookAfterToolCallEvent = {
1396
- toolCallId: string;
1397
- toolName: string;
1398
- params: Record<string, unknown>;
1399
- result?: unknown;
1400
- error?: string;
1401
- durationMs?: number;
1402
- };
1403
- type PluginHookAgentEndEvent = {
1404
- success: boolean;
1405
- error?: string;
1406
- durationMs?: number;
1407
- };
1408
- type PluginHookBeforeCompactionEvent = {
1409
- messageCount: number;
1410
- compactingCount?: number;
1411
- };
1412
- type PluginHookAfterCompactionEvent = {
1413
- messageCount: number;
1414
- compactedCount: number;
1415
- };
1416
- type PluginHookSessionStartEvent = {
1417
- sessionId: string;
1418
- };
1419
- type PluginHookSessionEndEvent = {
1420
- sessionId: string;
1421
- messageCount: number;
1422
- durationMs?: number;
1423
- };
1424
- type PluginHookSessionResetEvent = {
1425
- action: "new" | "reset";
1426
- sessionId: string;
1427
- previousSessionId?: string;
1428
- message: string;
1429
- };
1430
- type PluginHookMemoryChangedEvent = MemoryChangedEvent;
1431
- type PluginHookHandlerMap = {
1432
- before_model_resolve: (event: PluginHookBeforeModelResolveEvent, ctx: PluginHookAgentContext) => PluginHookBeforeModelResolveResult | void | Promise<PluginHookBeforeModelResolveResult | void>;
1433
- before_prompt_build: (event: PluginHookBeforePromptBuildEvent, ctx: PluginHookAgentContext) => PluginHookBeforePromptBuildResult | void | Promise<PluginHookBeforePromptBuildResult | void>;
1434
- after_prompt_build: (event: PluginHookAfterPromptBuildEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
1435
- llm_input: (event: PluginHookLlmInputEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
1436
- assistant_message_end: (event: PluginHookAssistantMessageEndEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
1437
- llm_output: (event: PluginHookLlmOutputEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
1438
- before_tool_call: (event: PluginHookBeforeToolCallEvent, ctx: PluginHookAgentContext) => PluginHookBeforeToolCallResult | void | Promise<PluginHookBeforeToolCallResult | void>;
1439
- after_tool_call: (event: PluginHookAfterToolCallEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
1440
- agent_end: (event: PluginHookAgentEndEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
1441
- before_compaction: (event: PluginHookBeforeCompactionEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
1442
- after_compaction: (event: PluginHookAfterCompactionEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
1443
- session_start: (event: PluginHookSessionStartEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
1444
- session_end: (event: PluginHookSessionEndEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
1445
- session_reset: (event: PluginHookSessionResetEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
1446
- memory_changed: (event: PluginHookMemoryChangedEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
1447
- };
1448
- type PluginHookRegistration<K extends PluginHookName = PluginHookName> = {
1449
- pluginId: string;
1450
- hookName: K;
1451
- handler: PluginHookHandlerMap[K];
1452
- priority?: number;
1453
- source: string;
1454
- };
1455
- declare class PluginHookRegistry {
1456
- private readonly hooks;
1457
- register<K extends PluginHookName>(registration: PluginHookRegistration<K>): void;
1458
- dispatch<K extends PluginHookName>(hookName: K, event: Parameters<PluginHookHandlerMap[K]>[0], ctx: Parameters<PluginHookHandlerMap[K]>[1]): Promise<Array<Awaited<ReturnType<PluginHookHandlerMap[K]>>>>;
1459
- }
1460
- //#endregion
1461
1614
  //#region src/plugins/tools.d.ts
1462
1615
  type PluginToolOptions = {
1463
1616
  optional?: boolean;
@@ -1602,4 +1755,4 @@ declare function initializePluginSystem(options?: PluginSystemOptions): PluginSy
1602
1755
  //#region src/plugins/tool-hooks.d.ts
1603
1756
  declare function wrapToolsWithHooks(tools: AgentTool[], hooks: PluginHookRegistry, ctx: PluginHookAgentContext): AgentTool[];
1604
1757
  //#endregion
1605
- export { AgentBinding, AgentConfig, AgentModelConfig, type AgentProgressEvent, type AgentRunParams, type AgentRunResult, AgentsConfig, BOOTSTRAP_FILE_NAMES, BOOTSTRAP_MAX_CHARS, BOOTSTRAP_TOTAL_MAX_CHARS, type BootstrapContextFile, type BootstrapEnsureResult, type BootstrapFile, type BootstrapMountResult, type BootstrapMountStatus, type CallbackEventPayload, type CallbackPayload, type Channel, type EmbeddingProvider, type EmbeddingProviderContext, type EmbeddingProviderFactory, type EmbeddingProviderRegistration, MAX_CHILDREN_PER_SESSION, MAX_SUBAGENT_DEPTH, type MemoryCallOptions, type MemoryChangeSource, type MemoryChangedEvent, type MemoryChangedHandler, MemoryIndexManager, type MemoryProvider, type MemoryProviderContext, type MemoryProviderFactory, type MemoryProviderRegistration, type MemoryProviderStatus, type MemorySearchOptions, type MemorySearchResult, type NormalizedPluginsConfig, PLUGIN_MANIFEST_FILENAME, PLUGIN_MANIFEST_FILENAMES, type PersistedSubagentRunRecord, type PluginApi, type PluginCandidate, type PluginConfigUiHint, type PluginDiagnostic, type PluginDiscoveryOptions, type PluginDiscoveryResult, type PluginEntryConfig, type PluginHookAfterCompactionEvent, type PluginHookAfterPromptBuildEvent, type PluginHookAfterToolCallEvent, type PluginHookAgentContext, type PluginHookAgentEndEvent, type PluginHookAssistantMessageEndEvent, type PluginHookBeforeCompactionEvent, type PluginHookBeforeModelResolveEvent, type PluginHookBeforeModelResolveResult, type PluginHookBeforePromptBuildEvent, type PluginHookBeforePromptBuildResult, type PluginHookBeforeToolCallEvent, type PluginHookBeforeToolCallResult, type PluginHookHandlerMap, type PluginHookLlmInputEvent, type PluginHookLlmOutputEvent, type PluginHookMemoryChangedEvent, type PluginHookName, PluginHookRegistry, type PluginHookSessionEndEvent, type PluginHookSessionResetEvent, type PluginHookSessionStartEvent, type PluginKind, type PluginManifest, type PluginManifestLoadResult, type PluginManifestRegistry, type PluginOrigin, type PluginRecord, type PluginRegistry, type PluginRuntime, type PluginRuntimeContext, type PluginSystem, type PluginSystemOptions, type PluginToolOptions, PluginToolRegistry, type PluginsConfig, type PluginsConfigValidationResult, type RegisteredPluginTool, type RunResultPayload, type SessionMetadata, type SessionSummary, type Skill, type SlashCommandList, type SubagentContext, SubagentRegistry, type SubagentRunRecord, type SubagentStatus, type SubagentToolsContext, type SystemPromptParams, type ToolLoopDetectionConfig, type TranscriptEntry, addAgent, addBinding, aimaxDir, appendToMemory, appendTranscriptEntry, bootstrapMountLayout, buildBootstrapContextFiles, buildSkillsPrompt, buildSubagentAnnounceMessage, buildSystemPrompt, cleanupOldSubagentRecords, createAgentTools, createApplyPatchTool, createBashTool, createBuiltinMemoryProvider, createEditFileTool, createExecTool, createImageTool, createListDirTool, createMemoryAppendTool, createMemoryGetTool, createMemorySearchTool, createPluginRuntime, createProcessTool, createReadFileTool, createSession, createSessionsSpawnTool, createSubagentsTool, createWriteFileTool, deleteMemoryFile, discoverAIMaxPlugins, ensureBootstrapMountLayout, ensureSession, generateSessionTitle, getAgentConfig, getMemoryLines, initializePluginSystem, inspectBootstrapMountLayout, isBootstrapMountLayoutReady, listAgents, listAvailableSlashCommands, listBindings, listMemoryFiles, listSessionSummaries, listSessions, listSubagentRunsFromDisk, loadAgentsConfig, loadBootstrapFiles, loadPluginManifest, loadPluginManifestRegistry, loadPlugins, loadSessionMetadata, loadSkills, loadSkillsFromDirs, loadSkillsWithPluginDirs, loadSubagentRegistryFromDisk, loadTranscript, memoryDir, metadataPath, normalizeAgentId, normalizePluginsConfig, primaryMemoryPath, readMemoryFile, readPrimaryMemory, registerEmbeddingProvider, registerMemoryProvider, removeAgent, removeBindings, replaceMemoryFile, resetEmbeddingProviderRegistryForTests, resetMemoryProviderRegistryForTests, resolveAgentDir, resolveAgentIdByBinding, resolveAgentsConfigPath, resolveDefaultAgentId, resolveEmbeddingProvider, resolveMemoryProvider, resolveModelFallbacks, resolveModelString, resolvePluginManifestPath, runAgent, saveAgentsConfig, saveSessionMetadata, saveSubagentRegistryToDisk, searchMemory, sessionDir, sessionsDir, skillsDir, transcriptPath, updateAgentIdentity, validatePluginsConfig, wrapToolsWithHooks };
1758
+ export { AgentBinding, AgentConfig, AgentModelConfig, type AgentProgressEvent, type AgentRunParams, type AgentRunResult, AgentsConfig, BOOTSTRAP_FILE_NAMES, BOOTSTRAP_MAX_CHARS, BOOTSTRAP_TOTAL_MAX_CHARS, type BootstrapContextFile, type BootstrapEnsureResult, type BootstrapFile, type BootstrapMountResult, type BootstrapMountStatus, type CallbackEventPayload, type CallbackPayload, type Channel, type ContextManager, type EmbeddingProvider, type EmbeddingProviderContext, type EmbeddingProviderFactory, type EmbeddingProviderRegistration, MAX_CHILDREN_PER_SESSION, MAX_SUBAGENT_DEPTH, type MemoryCallOptions, type MemoryChangeSource, type MemoryChangedEvent, type MemoryChangedHandler, MemoryIndexManager, type MemoryProvider, type MemoryProviderContext, type MemoryProviderFactory, type MemoryProviderRegistration, type MemoryProviderStatus, type MemorySearchOptions, type MemorySearchResult, type NormalizedPluginsConfig, PLUGIN_MANIFEST_FILENAME, PLUGIN_MANIFEST_FILENAMES, type PersistedSubagentRunRecord, type PersistedToolResult, type PluginApi, type PluginCandidate, type PluginConfigUiHint, type PluginDiagnostic, type PluginDiscoveryOptions, type PluginDiscoveryResult, type PluginEntryConfig, type PluginHookAfterCompactionEvent, type PluginHookAfterPromptBuildEvent, type PluginHookAfterToolCallEvent, type PluginHookAgentContext, type PluginHookAgentEndEvent, type PluginHookAssistantMessageEndEvent, type PluginHookBeforeCompactionEvent, type PluginHookBeforeModelResolveEvent, type PluginHookBeforeModelResolveResult, type PluginHookBeforePromptBuildEvent, type PluginHookBeforePromptBuildResult, type PluginHookBeforeToolCallEvent, type PluginHookBeforeToolCallResult, type PluginHookHandlerMap, type PluginHookLlmInputEvent, type PluginHookLlmOutputEvent, type PluginHookMemoryChangedEvent, type PluginHookName, PluginHookRegistry, type PluginHookSessionEndEvent, type PluginHookSessionResetEvent, type PluginHookSessionStartEvent, type PluginKind, type PluginManifest, type PluginManifestLoadResult, type PluginManifestRegistry, type PluginOrigin, type PluginRecord, type PluginRegistry, type PluginRuntime, type PluginRuntimeContext, type PluginSystem, type PluginSystemOptions, type PluginToolOptions, PluginToolRegistry, type PluginsConfig, type PluginsConfigValidationResult, type RegisteredPluginTool, type RunResultPayload, type SessionContextStore, type SessionExport, type SessionInspection, type SessionMetadata, type SessionSummary, type Skill, type SlashCommandList, type SubagentContext, SubagentRegistry, type SubagentRunRecord, type SubagentStatus, type SubagentToolsContext, type SystemPromptParams, type ToolLoopDetectionConfig, type TranscriptEntry, addAgent, addBinding, aimaxDir, appendToMemory, appendTranscriptEntry, bootstrapMountLayout, buildBootstrapContextFiles, buildSkillsPrompt, buildSubagentAnnounceMessage, buildSystemPrompt, cleanupOldSubagentRecords, collapseLogPath, contextSnapshotPath, createAgentTools, createApplyPatchTool, createBashTool, createBuiltinMemoryProvider, createContextManager, createEditFileTool, createExecTool, createImageTool, createListDirTool, createMemoryAppendTool, createMemoryGetTool, createMemorySearchTool, createPluginRuntime, createProcessTool, createReadFileTool, createSession, createSessionContextStore, createSessionsSpawnTool, createSubagentsTool, createWriteFileTool, deleteMemoryFile, discoverAIMaxPlugins, ensureBootstrapMountLayout, ensureSession, exportSession, generateSessionTitle, getAgentConfig, getMemoryLines, hasBootstrapSentinel, initializePluginSystem, inspectBootstrapMountLayout, inspectSession, isBootstrapMountLayoutReady, listAgents, listAvailableSlashCommands, listBindings, listMemoryFiles, listSessionSummaries, listSessions, listSubagentRunsFromDisk, loadAgentsConfig, loadBootstrapFiles, loadPluginManifest, loadPluginManifestRegistry, loadPlugins, loadSessionContextSnapshot, loadSessionMetadata, loadSkills, loadSkillsFromDirs, loadSkillsWithPluginDirs, loadSubagentRegistryFromDisk, loadTranscript, memoryDir, metadataPath, normalizeAgentId, normalizePluginsConfig, primaryMemoryPath, readMemoryFile, readPrimaryMemory, registerEmbeddingProvider, registerMemoryProvider, removeAgent, removeBindings, replaceMemoryFile, resetEmbeddingProviderRegistryForTests, resetMemoryProviderRegistryForTests, resolveAgentDir, resolveAgentIdByBinding, resolveAgentsConfigPath, resolveDefaultAgentId, resolveEmbeddingProvider, resolveMemoryProvider, resolveModelFallbacks, resolveModelString, resolvePluginManifestPath, runAgent, saveAgentsConfig, saveSessionMetadata, saveSubagentRegistryToDisk, searchMemory, sessionDir, sessionMemoryPath, sessionsDir, skillsDir, toolResultsDir, transcriptPath, updateAgentIdentity, validatePluginsConfig, wrapToolsWithHooks };