@gitgov/core 2.6.0 → 2.7.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/README.md CHANGED
@@ -107,6 +107,7 @@ graph LR
107
107
  GhGit["GitHubGitModule"]
108
108
  GhConfig["GitHubConfigStore"]
109
109
  GhFiles["GitHubFileLister"]
110
+ GhSync["GithubSyncStateModule"]
110
111
  end
111
112
 
112
113
  subgraph "@gitgov/core/memory — Testing"
@@ -144,7 +145,7 @@ graph LR
144
145
  |--------|----------|-----|
145
146
  | `@gitgov/core` | Interfaces, types, pure logic, factories, validators | No |
146
147
  | `@gitgov/core/fs` | Filesystem implementations (FsRecordStore, FsRecordProjection, LocalGitModule, FsLintModule, ...) | Local |
147
- | `@gitgov/core/github` | GitHub API implementations (GitHubRecordStore, GitHubGitModule, GitHubConfigStore, GitHubFileLister) | Remote |
148
+ | `@gitgov/core/github` | GitHub API implementations (GitHubRecordStore, GitHubGitModule, GitHubConfigStore, GitHubFileLister, GithubSyncStateModule) | Remote |
148
149
  | `@gitgov/core/memory` | In-memory implementations for testing (MemoryRecordStore, MemoryRecordProjection, MemoryGitModule, ...) | No |
149
150
  | `@gitgov/core/prisma` | Database-backed implementations via Prisma-compatible client (PrismaRecordProjection) | Remote |
150
151
 
@@ -0,0 +1,610 @@
1
+ import { S as SessionStore } from './session_store-I4Z6PW2c.js';
2
+ import { k as ISessionManager, a as GitGovSession, A as ActorState, S as SyncPreferencesUpdate, K as KeyProvider, h as FileLister, F as FsFileListerOptions, i as FileListOptions, j as FileStats, G as GitGovConfig } from './index-LULVRsCZ.js';
3
+ import { q as IIdentityAdapter, u as IdentityAdapterDependencies, S as SyncStateModuleDependencies, p as IEventStream } from './sync_state-C2a2RuBQ.js';
4
+ import { A as ActorPayload, d as ActorRecord, G as GitGovRecord, l as ExecutionRecord, y as RecordStores, f as AgentRecord } from './record_projection.types-D9NkQbL_.js';
5
+
6
+ /**
7
+ * SessionManager - Local Session State Manager
8
+ *
9
+ * Provides typed access to GitGovernance session state (.session.json).
10
+ * Session state is ephemeral, machine-local, and NOT versioned in Git.
11
+ *
12
+ * Uses SessionStore abstraction for backend-agnostic persistence.
13
+ */
14
+
15
+ /**
16
+ * Session Manager Class
17
+ *
18
+ * Provides typed access to GitGovernance session state.
19
+ * Uses SessionStore abstraction for backend-agnostic persistence.
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * // Production usage
24
+ * import { FsSessionStore } from '@gitgov/core/fs';
25
+ * const sessionStore = new FsSessionStore('/path/to/project');
26
+ * const sessionManager = new SessionManager(sessionStore);
27
+ *
28
+ * // Test usage
29
+ * import { MemorySessionStore } from '@gitgov/core/memory';
30
+ * const sessionStore = new MemorySessionStore();
31
+ * sessionStore.setSession({ ... });
32
+ * const sessionManager = new SessionManager(sessionStore);
33
+ * ```
34
+ */
35
+ declare class SessionManager implements ISessionManager {
36
+ private readonly sessionStore;
37
+ constructor(sessionStore: SessionStore);
38
+ /**
39
+ * Load GitGovernance session state
40
+ * [EARS-E1] Auto-detects actor from .key files if no session or no actorId exists
41
+ */
42
+ loadSession(): Promise<GitGovSession | null>;
43
+ /**
44
+ * [EARS-E1] Detect actor from .key files in .gitgov/actors/
45
+ */
46
+ detectActorFromKeyFiles(): Promise<string | null>;
47
+ /**
48
+ * Get actor state for a specific actor
49
+ */
50
+ getActorState(actorId: string): Promise<ActorState | null>;
51
+ /**
52
+ * Update actor state for a specific actor
53
+ */
54
+ updateActorState(actorId: string, state: Partial<ActorState>): Promise<void>;
55
+ /**
56
+ * Get cloud session token
57
+ */
58
+ getCloudSessionToken(): Promise<string | null>;
59
+ /**
60
+ * Get sync preferences from session
61
+ */
62
+ getSyncPreferences(): Promise<GitGovSession['syncPreferences'] | null>;
63
+ /**
64
+ * Update sync preferences in .session.json
65
+ * These are local machine preferences that override project defaults
66
+ */
67
+ updateSyncPreferences(preferences: SyncPreferencesUpdate): Promise<void>;
68
+ /**
69
+ * Get last session info (last human who interacted)
70
+ */
71
+ getLastSession(): Promise<{
72
+ actorId: string;
73
+ timestamp: string;
74
+ } | null>;
75
+ }
76
+
77
+ /**
78
+ * FsKeyProvider - Filesystem-based KeyProvider implementation
79
+ *
80
+ * Stores private keys in .gitgov/keys/{actorId}.key
81
+ * Used in development and CLI environments.
82
+ *
83
+ * @module key_provider/fs/fs_key_provider
84
+ */
85
+
86
+ /**
87
+ * Options for FsKeyProvider.
88
+ */
89
+ interface FsKeyProviderOptions {
90
+ /** Directory where key files are stored (e.g., .gitgov/keys) */
91
+ keysDir: string;
92
+ /** File extension for key files (default: '.key') */
93
+ extension?: string;
94
+ /** File permissions for key files (default: 0o600 - owner read/write only) */
95
+ fileMode?: number;
96
+ }
97
+ /**
98
+ * Filesystem-based KeyProvider implementation.
99
+ * Keys are stored in a dedicated directory with .key extension.
100
+ *
101
+ * @example
102
+ * ```typescript
103
+ * const provider = new FsKeyProvider({ keysDir: '.gitgov/keys' });
104
+ * await provider.setPrivateKey('actor:human:alice', 'base64PrivateKey...');
105
+ * const key = await provider.getPrivateKey('actor:human:alice');
106
+ * ```
107
+ */
108
+ declare class FsKeyProvider implements KeyProvider {
109
+ private readonly keysDir;
110
+ private readonly extension;
111
+ private readonly fileMode;
112
+ constructor(options: FsKeyProviderOptions);
113
+ /**
114
+ * [EARS-KP01] Retrieves the private key for an actor.
115
+ * [EARS-FKP07] Trims whitespace from content.
116
+ * [EARS-FKP08] Returns null for empty key file.
117
+ */
118
+ getPrivateKey(actorId: string): Promise<string | null>;
119
+ /**
120
+ * [EARS-KP03] Stores a private key for an actor.
121
+ * [EARS-FKP01] Creates keysDir if not exists.
122
+ * [EARS-FKP02] Writes key to {keysDir}/{actorId}.key.
123
+ * [EARS-FKP03] Sets secure file permissions (0600).
124
+ */
125
+ setPrivateKey(actorId: string, privateKey: string): Promise<void>;
126
+ /**
127
+ * [EARS-FKP06] Checks if a private key exists for an actor.
128
+ */
129
+ hasPrivateKey(actorId: string): Promise<boolean>;
130
+ /**
131
+ * [EARS-KP04] Deletes the private key for an actor.
132
+ */
133
+ deletePrivateKey(actorId: string): Promise<boolean>;
134
+ /**
135
+ * [EARS-FKP04] Builds the key file path, sanitizing actorId to prevent path traversal.
136
+ * [EARS-FKP05] Replaces slashes with underscores.
137
+ */
138
+ private getKeyPath;
139
+ /**
140
+ * [EARS-FKP04] Sanitizes actorId to prevent directory traversal.
141
+ * [EARS-FKP05] Replaces path separators with underscores.
142
+ * [EARS-FKP09] Throws INVALID_ACTOR_ID for empty actorId.
143
+ */
144
+ private sanitizeActorId;
145
+ /**
146
+ * Sanitizes actorId for logging (removes potential secrets).
147
+ */
148
+ private sanitizeForLog;
149
+ }
150
+
151
+ /**
152
+ * FsFileLister - Filesystem-based FileLister implementation
153
+ *
154
+ * Uses fast-glob for pattern matching and fs/promises for file operations.
155
+ * Used in CLI and development environments.
156
+ *
157
+ * @module file_lister/fs/fs_file_lister
158
+ */
159
+
160
+ /**
161
+ * Filesystem-based FileLister implementation.
162
+ * Uses fast-glob for pattern matching and fs/promises for file operations.
163
+ *
164
+ * @example
165
+ * ```typescript
166
+ * const lister = new FsFileLister({ cwd: '/path/to/project' });
167
+ * const files = await lister.list(['**\/*.ts'], { ignore: ['node_modules/**'] });
168
+ * const content = await lister.read('src/index.ts');
169
+ * ```
170
+ */
171
+ declare class FsFileLister implements FileLister {
172
+ private readonly cwd;
173
+ constructor(options: FsFileListerOptions);
174
+ /**
175
+ * [EARS-FL01] Lists files matching glob patterns.
176
+ * [EARS-FFL01] Excludes files matching ignore patterns.
177
+ */
178
+ list(patterns: string[], options?: FileListOptions): Promise<string[]>;
179
+ /**
180
+ * [EARS-FL02] Checks if a file exists.
181
+ */
182
+ exists(filePath: string): Promise<boolean>;
183
+ /**
184
+ * [EARS-FL03] Reads file content as string.
185
+ * [EARS-FFL03] Throws FILE_NOT_FOUND for missing files.
186
+ */
187
+ read(filePath: string): Promise<string>;
188
+ /**
189
+ * [EARS-FL04] Gets file statistics.
190
+ * [EARS-FFL03] Throws FILE_NOT_FOUND for missing files.
191
+ */
192
+ stat(filePath: string): Promise<FileStats>;
193
+ /**
194
+ * [EARS-FFL04] Validates that the path doesn't contain traversal characters.
195
+ * [EARS-FFL05] Validates that the path is not absolute.
196
+ */
197
+ private validatePath;
198
+ }
199
+
200
+ /**
201
+ * Environment validation result.
202
+ * Used by filesystem implementations to check prerequisites.
203
+ */
204
+ type EnvironmentValidation = {
205
+ /** Whether environment is valid for initialization */
206
+ isValid: boolean;
207
+ /** Whether directory contains Git repository (fs-only) */
208
+ isGitRepo: boolean;
209
+ /** Whether process has write permissions */
210
+ hasWritePermissions: boolean;
211
+ /** Whether GitGovernance is already initialized */
212
+ isAlreadyInitialized: boolean;
213
+ /** Path to .gitgov directory (if already initialized) */
214
+ gitgovPath?: string;
215
+ /** List of validation warnings */
216
+ warnings: string[];
217
+ /** Actionable suggestions for user */
218
+ suggestions: string[];
219
+ /** Whether a remote 'origin' is configured */
220
+ hasRemote?: boolean;
221
+ /** Whether the current branch has commits */
222
+ hasCommits?: boolean;
223
+ /** Name of the current branch */
224
+ currentBranch?: string;
225
+ };
226
+
227
+ /**
228
+ * Public interface for project initialization operations (pure - no I/O assumptions).
229
+ *
230
+ * This interface defines the contract for initializing GitGovernance projects
231
+ * across different backends (filesystem, database, API).
232
+ *
233
+ * The project context (path, tenant ID, etc.) is injected at construction time,
234
+ * so methods operate on the pre-configured project without needing explicit paths.
235
+ *
236
+ * Implementations:
237
+ * - FsProjectInitializer: Local filesystem (.gitgov/ directory)
238
+ * - DbProjectInitializer: Database (SaaS multi-tenant)
239
+ * - ApiProjectInitializer: Remote API (agents, serverless)
240
+ *
241
+ * @example
242
+ * ```typescript
243
+ * // CLI uses FsProjectInitializer with projectRoot injected
244
+ * const initializer: IProjectInitializer = new FsProjectInitializer('/path/to/project');
245
+ * await initializer.createProjectStructure();
246
+ *
247
+ * // SaaS uses DbProjectInitializer with tenant injected
248
+ * const initializer: IProjectInitializer = new DbProjectInitializer(pool, 'tenant-123');
249
+ * await initializer.createProjectStructure();
250
+ * ```
251
+ */
252
+ interface IProjectInitializer {
253
+ /**
254
+ * Creates the project structure (directories for fs, tables for db, etc).
255
+ */
256
+ createProjectStructure(): Promise<void>;
257
+ /**
258
+ * Checks if a project is already initialized.
259
+ *
260
+ * @returns true if already initialized
261
+ */
262
+ isInitialized(): Promise<boolean>;
263
+ /**
264
+ * Writes the project configuration.
265
+ *
266
+ * @param config - GitGovConfig to persist
267
+ */
268
+ writeConfig(config: GitGovConfig): Promise<void>;
269
+ /**
270
+ * Initializes a session for the bootstrap actor.
271
+ *
272
+ * @param actorId - ID of the bootstrap actor
273
+ */
274
+ initializeSession(actorId: string): Promise<void>;
275
+ /**
276
+ * Cleans up partial setup if initialization fails.
277
+ */
278
+ rollback(): Promise<void>;
279
+ /**
280
+ * Validates environment for project initialization.
281
+ *
282
+ * @returns Validation result with warnings and suggestions
283
+ */
284
+ validateEnvironment(): Promise<EnvironmentValidation>;
285
+ /**
286
+ * Reads a file from the project context.
287
+ *
288
+ * @param filePath - Path to the file (relative or absolute depending on backend)
289
+ * @returns File contents as string
290
+ */
291
+ readFile(filePath: string): Promise<string>;
292
+ /**
293
+ * Copies the agent prompt to the project root for IDE access.
294
+ */
295
+ copyAgentPrompt(): Promise<void>;
296
+ /**
297
+ * Sets up version control integration (e.g., .gitignore for fs).
298
+ */
299
+ setupGitIntegration(): Promise<void>;
300
+ /**
301
+ * Gets the path/identifier for an actor record.
302
+ *
303
+ * @param actorId - Actor ID
304
+ * @returns Path or identifier for the actor
305
+ */
306
+ getActorPath(actorId: string): string;
307
+ }
308
+
309
+ declare class IdentityAdapter implements IIdentityAdapter {
310
+ private stores;
311
+ private keyProvider;
312
+ private sessionManager;
313
+ private eventBus;
314
+ constructor(dependencies: IdentityAdapterDependencies);
315
+ /**
316
+ * Get actor public key for validation - used by other adapters
317
+ */
318
+ getActorPublicKey(keyId: string): Promise<string | null>;
319
+ createActor(payload: ActorPayload, _signerId: string): Promise<ActorRecord>;
320
+ getActor(actorId: string): Promise<ActorRecord | null>;
321
+ listActors(): Promise<ActorRecord[]>;
322
+ signRecord<T extends GitGovRecord>(record: T, actorId: string, role: string, notes: string): Promise<T>;
323
+ /**
324
+ * Resolves the current active ActorRecord ID by following the succession chain.
325
+ * This is critical for AgentRecord operations after key rotation.
326
+ *
327
+ * @param originalActorId - The original actor ID (may be revoked)
328
+ * @returns Promise<string> - The current active actor ID
329
+ */
330
+ resolveCurrentActorId(originalActorId: string): Promise<string>;
331
+ /**
332
+ * Gets the current ActorRecord of the system based on active session or fallback.
333
+ * This is critical for CLI commands that need to know "who is the current user".
334
+ *
335
+ * @returns Promise<ActorRecord> - The current active ActorRecord
336
+ */
337
+ getCurrentActor(): Promise<ActorRecord>;
338
+ /**
339
+ * Gets the effective (current active) ActorRecord for an AgentRecord.
340
+ * This resolves the succession chain to get the current cryptographic identity.
341
+ *
342
+ * @param agentId - The AgentRecord ID (may reference revoked ActorRecord)
343
+ * @returns Promise<ActorRecord | null> - The current active ActorRecord or null
344
+ */
345
+ getEffectiveActorForAgent(agentId: string): Promise<ActorRecord | null>;
346
+ rotateActorKey(actorId: string): Promise<{
347
+ oldActor: ActorRecord;
348
+ newActor: ActorRecord;
349
+ }>;
350
+ revokeActor(actorId: string, revokedBy?: string, reason?: "compromised" | "rotation" | "manual", supersededBy?: string): Promise<ActorRecord>;
351
+ authenticate(_sessionToken: string): Promise<void>;
352
+ }
353
+
354
+ /**
355
+ * Reutiliza las mismas dependencias que FsSyncStateModule.
356
+ * No requiere dependencias adicionales.
357
+ */
358
+ type FsWorktreeSyncStateDependencies = SyncStateModuleDependencies;
359
+ /**
360
+ * Configuration for worktree-based sync module.
361
+ */
362
+ type FsWorktreeSyncStateConfig = {
363
+ /** Root directory of the git repository */
364
+ repoRoot: string;
365
+ /** State branch name (default: "gitgov-state") */
366
+ stateBranchName?: string;
367
+ /** Absolute path to worktree. Default: path.join(repoRoot, '.gitgov-worktree') */
368
+ worktreePath?: string;
369
+ };
370
+ /** Default state branch name */
371
+ declare const DEFAULT_STATE_BRANCH: "gitgov-state";
372
+
373
+ /**
374
+ * ExecutionAdapter Dependencies - Facade + Dependency Injection Pattern
375
+ */
376
+ type ExecutionAdapterDependencies = {
377
+ stores: Required<Pick<RecordStores, 'tasks' | 'executions'>>;
378
+ identity: IdentityAdapter;
379
+ eventBus: IEventStream;
380
+ };
381
+ /**
382
+ * ExecutionAdapter Interface - The Chronicler of the System
383
+ */
384
+ interface IExecutionAdapter {
385
+ /**
386
+ * Records a new execution event.
387
+ */
388
+ create(payload: Partial<ExecutionRecord>, actorId: string): Promise<ExecutionRecord>;
389
+ /**
390
+ * Gets a specific ExecutionRecord by its ID.
391
+ */
392
+ getExecution(executionId: string): Promise<ExecutionRecord | null>;
393
+ /**
394
+ * Gets all ExecutionRecords for a specific Task.
395
+ */
396
+ getExecutionsByTask(taskId: string): Promise<ExecutionRecord[]>;
397
+ /**
398
+ * Gets all ExecutionRecords in the system.
399
+ */
400
+ getAllExecutions(): Promise<ExecutionRecord[]>;
401
+ }
402
+
403
+ /**
404
+ * Union type of all supported engines.
405
+ */
406
+ type Engine = AgentRecord["engine"];
407
+ /**
408
+ * Supported engine types by the runner.
409
+ */
410
+ type EngineType = Engine["type"];
411
+ /**
412
+ * Local engine configuration.
413
+ * Agent executes in the same process.
414
+ */
415
+ type LocalEngine = Extract<Engine, {
416
+ type: "local";
417
+ }>;
418
+ /**
419
+ * API engine configuration.
420
+ * Agent executes on a remote server via HTTP.
421
+ */
422
+ type ApiEngine = Extract<Engine, {
423
+ type: "api";
424
+ }>;
425
+ /**
426
+ * MCP engine configuration.
427
+ * Agent executes as MCP server (Model Context Protocol).
428
+ */
429
+ type McpEngine = Extract<Engine, {
430
+ type: "mcp";
431
+ }>;
432
+ /**
433
+ * Custom engine configuration.
434
+ * Allows extensibility via registered protocol handlers.
435
+ */
436
+ type CustomEngine = Extract<Engine, {
437
+ type: "custom";
438
+ }>;
439
+ /**
440
+ * Authentication configuration for remote backends (API/MCP).
441
+ * Extracted from the API engine's auth field.
442
+ */
443
+ type AuthConfig = NonNullable<ApiEngine["auth"]>;
444
+ /**
445
+ * Authentication types for remote backends.
446
+ */
447
+ type AuthType = NonNullable<AuthConfig["type"]>;
448
+ /**
449
+ * Execution context passed to each agent.
450
+ * Includes all information needed for traceability.
451
+ */
452
+ type AgentExecutionContext = {
453
+ /** Agent ID being executed (e.g., "agent:source-audit") */
454
+ agentId: string;
455
+ /** ActorRecord executing (type "agent") */
456
+ actorId: string;
457
+ /** TaskRecord that triggered this execution (required) */
458
+ taskId: string;
459
+ /** Unique UUID for this execution */
460
+ runId: string;
461
+ /** Optional input passed to the agent (from RunOptions.input) */
462
+ input?: unknown;
463
+ };
464
+ /**
465
+ * Options for executing an agent.
466
+ */
467
+ type RunOptions = {
468
+ /** Agent ID to execute (e.g., "agent:source-audit") */
469
+ agentId: string;
470
+ /** TaskRecord that triggers this execution (required) */
471
+ taskId: string;
472
+ /** Actor executing. If not provided, uses agentId */
473
+ actorId?: string;
474
+ /** Specific tool to invoke (MCP engines only) */
475
+ tool?: string;
476
+ /** Input to pass to the agent */
477
+ input?: unknown;
478
+ };
479
+ /**
480
+ * Structured output from the agent.
481
+ * Captured by the runner from each backend.
482
+ */
483
+ type AgentOutput = {
484
+ /** Response data from agent (free structure) */
485
+ data?: unknown;
486
+ /** Text message (summary or description) */
487
+ message?: string;
488
+ /** Generated artifacts (file paths, record IDs, etc.) */
489
+ artifacts?: string[];
490
+ /** Additional agent metadata */
491
+ metadata?: Record<string, unknown>;
492
+ };
493
+ /**
494
+ * Complete response from an agent execution.
495
+ * Returned by runner.runOnce().
496
+ */
497
+ type AgentResponse = {
498
+ /** Unique UUID for this execution */
499
+ runId: string;
500
+ /** Executed agent ID */
501
+ agentId: string;
502
+ /** Execution status */
503
+ status: "success" | "error";
504
+ /** Agent output (only if status: "success") */
505
+ output?: AgentOutput;
506
+ /** Error message (only if status: "error") */
507
+ error?: string;
508
+ /** Created ExecutionRecord ID */
509
+ executionRecordId: string;
510
+ /** Start timestamp */
511
+ startedAt: string;
512
+ /** Completion timestamp */
513
+ completedAt: string;
514
+ /** Duration in milliseconds */
515
+ durationMs: number;
516
+ };
517
+ /**
518
+ * AgentRunner module dependencies (filesystem implementation).
519
+ */
520
+ type AgentRunnerDependencies = {
521
+ /** Path to project root (REQUIRED, injected from CLI/bootstrap) */
522
+ projectRoot: string;
523
+ /** Path to .gitgov directory (optional, defaults to projectRoot/.gitgov) */
524
+ gitgovPath?: string;
525
+ /** IdentityAdapter for actor-signature auth (required if that auth type is used) */
526
+ identityAdapter?: IIdentityAdapter;
527
+ /** ExecutionAdapter for persisting executions (REQUIRED) */
528
+ executionAdapter: IExecutionAdapter;
529
+ /** EventBus for emitting events (optional, no events if not provided) */
530
+ eventBus?: IEventStream;
531
+ /** Protocol handler registry (for engine.type: "custom") */
532
+ protocolHandlers?: ProtocolHandlerRegistry;
533
+ /** Runtime handler registry (for engine.runtime in local engines) */
534
+ runtimeHandlers?: RuntimeHandlerRegistry;
535
+ };
536
+ /**
537
+ * Events emitted by the runner via EventBus.
538
+ */
539
+ type AgentRunnerEvent = {
540
+ type: "agent:started";
541
+ payload: {
542
+ runId: string;
543
+ agentId: string;
544
+ taskId: string;
545
+ startedAt: string;
546
+ };
547
+ } | {
548
+ type: "agent:completed";
549
+ payload: {
550
+ runId: string;
551
+ agentId: string;
552
+ taskId: string;
553
+ status: "success";
554
+ durationMs: number;
555
+ executionRecordId: string;
556
+ };
557
+ } | {
558
+ type: "agent:error";
559
+ payload: {
560
+ runId: string;
561
+ agentId: string;
562
+ taskId: string;
563
+ status: "error";
564
+ error: string;
565
+ durationMs: number;
566
+ executionRecordId: string;
567
+ };
568
+ };
569
+
570
+ /**
571
+ * Interface for agent loader (allows mocking in tests).
572
+ */
573
+ interface IAgentLoader {
574
+ loadAgent(agentId: string): Promise<AgentRecord>;
575
+ }
576
+ /**
577
+ * Interface for AgentRunner implementations.
578
+ * Allows different backends (filesystem, memory, serverless).
579
+ */
580
+ interface IAgentRunner {
581
+ /**
582
+ * Executes an agent once and returns the response.
583
+ * TaskRecord must exist before calling this method.
584
+ */
585
+ runOnce(opts: RunOptions): Promise<AgentResponse>;
586
+ }
587
+ /**
588
+ * Registry for protocol handlers (engine.type: "custom").
589
+ */
590
+ interface ProtocolHandlerRegistry {
591
+ register(protocol: string, handler: ProtocolHandler): void;
592
+ get(protocol: string): ProtocolHandler | undefined;
593
+ }
594
+ /**
595
+ * Handler for engine.type: "custom".
596
+ */
597
+ type ProtocolHandler = (engine: CustomEngine, ctx: AgentExecutionContext) => Promise<AgentOutput>;
598
+ /**
599
+ * Registry for runtime handlers (engine.runtime in local engines).
600
+ */
601
+ interface RuntimeHandlerRegistry {
602
+ register(runtime: string, handler: RuntimeHandler): void;
603
+ get(runtime: string): RuntimeHandler | undefined;
604
+ }
605
+ /**
606
+ * Handler for engine.runtime in local engines.
607
+ */
608
+ type RuntimeHandler = (engine: LocalEngine, ctx: AgentExecutionContext) => Promise<AgentOutput>;
609
+
610
+ export { type AgentRunnerDependencies as A, type CustomEngine as C, DEFAULT_STATE_BRANCH as D, type EnvironmentValidation as E, type FsWorktreeSyncStateDependencies as F, type IProjectInitializer as I, type LocalEngine as L, type McpEngine as M, type ProtocolHandlerRegistry as P, type RunOptions as R, SessionManager as S, type FsWorktreeSyncStateConfig as a, type IAgentRunner as b, type AgentResponse as c, FsKeyProvider as d, type FsKeyProviderOptions as e, FsFileLister as f, IdentityAdapter as g, type IExecutionAdapter as h, type ExecutionAdapterDependencies as i, type AgentExecutionContext as j, type AgentOutput as k, type AgentRunnerEvent as l, type ApiEngine as m, type AuthConfig as n, type AuthType as o, type Engine as p, type EngineType as q, type IAgentLoader as r, type ProtocolHandler as s, type RuntimeHandler as t, type RuntimeHandlerRegistry as u };
package/dist/src/fs.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { R as RecordStore, I as IdEncoder } from './record_store-BXKWqon5.js';
2
- export { D as DEFAULT_ID_ENCODER } from './record_store-BXKWqon5.js';
3
- import { C as ConfigStore, G as GitGovConfig, I as IGitModule, a as GitModuleDependencies, E as ExecOptions, b as ExecResult, c as ChangedFile, d as GetCommitHistoryOptions, e as CommitInfo, f as CommitAuthor } from './index-Bhc341pf.js';
4
- export { F as FsFileListerOptions } from './index-Bhc341pf.js';
5
- import { C as ConfigManager, S as SessionManager, I as ILintModule, L as LintOptions, a as LintReport, F as FixRecordOptions, b as FixReport, R as RecordStores, c as LintRecordContext, d as LintResult, e as IProjectInitializer, E as EnvironmentValidation, f as ISyncStateModule, g as SyncStateModuleDependencies, h as StateDeltaFile, i as ConflictDiff, j as IntegrityViolation, A as AuditStateOptions, k as AuditStateReport, l as SyncStatePushOptions, m as SyncStatePushResult, n as SyncStatePullOptions, o as SyncStatePullResult, p as SyncStateResolveOptions, q as SyncStateResolveResult, r as IEventStream, s as IAgentRunner, P as ProtocolHandlerRegistry, t as AgentRunnerDependencies, u as RunOptions, v as AgentResponse } from './agent_runner-pr7h-9cV.js';
6
- export { y as FsFileLister, w as FsKeyProvider, x as FsKeyProviderOptions } from './agent_runner-pr7h-9cV.js';
7
- import { S as SessionStore, G as GitGovSession } from './key_provider-jjWek3w1.js';
8
- import { I as IRecordProjector, G as GitGovRecord, a as IRecordProjection, b as IndexData, P as ProjectionContext } from './record_projection.types-B8AM7u8U.js';
1
+ import { R as RecordStore, I as IdEncoder, a as IRecordProjector, G as GitGovRecord, b as IRecordProjection, c as IndexData, P as ProjectionContext } from './record_projection.types-D9NkQbL_.js';
2
+ export { D as DEFAULT_ID_ENCODER } from './record_projection.types-D9NkQbL_.js';
3
+ import { C as ConfigStore, G as GitGovConfig, a as GitGovSession, I as IGitModule, b as GitModuleDependencies, E as ExecOptions, c as ExecResult, d as ChangedFile, e as GetCommitHistoryOptions, f as CommitInfo, g as CommitAuthor } from './index-LULVRsCZ.js';
4
+ export { F as FsFileListerOptions } from './index-LULVRsCZ.js';
5
+ import { C as ConfigManager, I as ILintModule, L as LintOptions, a as LintReport, F as FixRecordOptions, b as FixReport, R as RecordStores, c as LintRecordContext, d as LintResult, e as ISyncStateModule, S as SyncStateModuleDependencies, f as StateDeltaFile, g as ConflictDiff, h as IntegrityViolation, A as AuditStateOptions, i as AuditStateReport, j as SyncStatePushOptions, k as SyncStatePushResult, l as SyncStatePullOptions, m as SyncStatePullResult, n as SyncStateResolveOptions, o as SyncStateResolveResult, p as IEventStream } from './sync_state-C2a2RuBQ.js';
6
+ import { S as SessionStore } from './session_store-I4Z6PW2c.js';
7
+ import { S as SessionManager, I as IProjectInitializer, E as EnvironmentValidation, F as FsWorktreeSyncStateDependencies, a as FsWorktreeSyncStateConfig, b as IAgentRunner, P as ProtocolHandlerRegistry, A as AgentRunnerDependencies, R as RunOptions, c as AgentResponse } from './agent_runner-DijNVjaF.js';
8
+ export { f as FsFileLister, d as FsKeyProvider, e as FsKeyProviderOptions } from './agent_runner-DijNVjaF.js';
9
9
 
10
10
  /**
11
11
  * Serializer for FsRecordStore - allows custom serialization
@@ -313,6 +313,10 @@ declare class FsLintModule implements IFsLintModule {
313
313
  * Delegates to LintModule.lintRecord() for pure validation.
314
314
  */
315
315
  lintRecord(record: GitGovRecord, context: LintRecordContext): LintResult[];
316
+ /**
317
+ * Delegates to LintModule.lintRecordReferences() for prefix validation.
318
+ */
319
+ lintRecordReferences(record: GitGovRecord, context: LintRecordContext): LintResult[];
316
320
  /**
317
321
  * Delegates to LintModule.fixRecord() for pure fix.
318
322
  */
@@ -1224,23 +1228,6 @@ declare class FsSyncStateModule implements ISyncStateModule {
1224
1228
  resolveConflict(options: SyncStateResolveOptions): Promise<SyncStateResolveResult>;
1225
1229
  }
1226
1230
 
1227
- /**
1228
- * Reutiliza las mismas dependencias que FsSyncStateModule.
1229
- * No requiere dependencias adicionales.
1230
- */
1231
- type FsWorktreeSyncStateDependencies = SyncStateModuleDependencies;
1232
- /**
1233
- * Configuration for worktree-based sync module.
1234
- */
1235
- type FsWorktreeSyncStateConfig = {
1236
- /** Root directory of the git repository */
1237
- repoRoot: string;
1238
- /** State branch name (default: "gitgov-state") */
1239
- stateBranchName?: string;
1240
- /** Absolute path to worktree. Default: path.join(repoRoot, '.gitgov-worktree') */
1241
- worktreePath?: string;
1242
- };
1243
-
1244
1231
  /**
1245
1232
  * Worktree-based implementation of ISyncStateModule.
1246
1233
  *
@@ -1451,6 +1438,7 @@ declare function createAgentRunner(deps: AgentRunnerDependencies): IAgentRunner;
1451
1438
  type FsRecordProjectionOptions = {
1452
1439
  basePath: string;
1453
1440
  };
1441
+
1454
1442
  /**
1455
1443
  * FsRecordProjection - Filesystem IRecordProjection for CLI.
1456
1444
  *