@gitgov/core 2.5.0 → 2.7.0
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/LICENSE +374 -0
- package/README.md +2 -1
- package/dist/src/agent_runner-CHDkBfPZ.d.ts +610 -0
- package/dist/src/fs.d.ts +9 -25
- package/dist/src/fs.js +3 -0
- package/dist/src/fs.js.map +1 -1
- package/dist/src/github.d.ts +117 -3
- package/dist/src/github.js +651 -10
- package/dist/src/github.js.map +1 -1
- package/dist/src/{index-Bhc341pf.d.ts → index-LULVRsCZ.d.ts} +180 -1
- package/dist/src/index.d.ts +16 -11
- package/dist/src/index.js +5 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/memory.d.ts +5 -6
- package/dist/src/{memory_file_lister-BIIcVXLw.d.ts → memory_file_lister-BCY4ZYGW.d.ts} +1 -2
- package/dist/src/prisma.d.ts +108 -26
- package/dist/src/prisma.js +268 -32
- package/dist/src/prisma.js.map +1 -1
- package/dist/src/{record_projection.types-B8AM7u8U.d.ts → record_projection.types-Dz9YU3r9.d.ts} +64 -4
- package/dist/src/session_store-I4Z6PW2c.d.ts +50 -0
- package/dist/src/{agent_runner-pr7h-9cV.d.ts → sync_state-Bn_LogJ2.d.ts} +5 -592
- package/package.json +7 -1
- package/dist/src/key_provider-jjWek3w1.d.ts +0 -227
- package/dist/src/record_store-BXKWqon5.d.ts +0 -64
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SessionManager Types
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Sync status for an actor's synchronization state.
|
|
6
|
-
*/
|
|
7
|
-
type SyncStatus = {
|
|
8
|
-
lastSyncPush?: string;
|
|
9
|
-
lastSyncPull?: string;
|
|
10
|
-
status?: 'synced' | 'pending' | 'pulling' | 'pushing' | 'conflict';
|
|
11
|
-
lastError?: string;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* State for a specific actor on this machine.
|
|
15
|
-
*/
|
|
16
|
-
type ActorState = {
|
|
17
|
-
activeTaskId?: string | undefined;
|
|
18
|
-
activeCycleId?: string | undefined;
|
|
19
|
-
lastSync?: string;
|
|
20
|
-
syncStatus?: SyncStatus;
|
|
21
|
-
[key: string]: unknown;
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* GitGovernance Session State
|
|
25
|
-
* Based on session_state.md blueprint
|
|
26
|
-
*/
|
|
27
|
-
type GitGovSession = {
|
|
28
|
-
cloud?: {
|
|
29
|
-
sessionToken?: string;
|
|
30
|
-
};
|
|
31
|
-
lastSession?: {
|
|
32
|
-
actorId: string;
|
|
33
|
-
timestamp: string;
|
|
34
|
-
};
|
|
35
|
-
actorState?: Record<string, ActorState>;
|
|
36
|
-
syncPreferences?: {
|
|
37
|
-
pullScheduler?: {
|
|
38
|
-
enabled?: boolean;
|
|
39
|
-
pullIntervalSeconds?: number;
|
|
40
|
-
continueOnNetworkError?: boolean;
|
|
41
|
-
stopOnConflict?: boolean;
|
|
42
|
-
};
|
|
43
|
-
fileWatcher?: {
|
|
44
|
-
enabled?: boolean;
|
|
45
|
-
debounceMs?: number;
|
|
46
|
-
ignoredPatterns?: string[];
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Sync preferences update payload
|
|
52
|
-
*/
|
|
53
|
-
type SyncPreferencesUpdate = {
|
|
54
|
-
pullScheduler?: Partial<{
|
|
55
|
-
enabled: boolean;
|
|
56
|
-
pullIntervalSeconds: number;
|
|
57
|
-
continueOnNetworkError: boolean;
|
|
58
|
-
stopOnConflict: boolean;
|
|
59
|
-
}>;
|
|
60
|
-
fileWatcher?: Partial<{
|
|
61
|
-
enabled: boolean;
|
|
62
|
-
debounceMs: number;
|
|
63
|
-
ignoredPatterns: string[];
|
|
64
|
-
}>;
|
|
65
|
-
};
|
|
66
|
-
/**
|
|
67
|
-
* ISessionManager interface
|
|
68
|
-
*
|
|
69
|
-
* Provides typed access to GitGovernance session state.
|
|
70
|
-
* Session state is ephemeral, machine-local, and NOT versioned in Git.
|
|
71
|
-
*/
|
|
72
|
-
interface ISessionManager {
|
|
73
|
-
/**
|
|
74
|
-
* Load GitGovernance session state
|
|
75
|
-
* [EARS-B9] Auto-detects actor from .key files if no session or no actorId exists
|
|
76
|
-
*/
|
|
77
|
-
loadSession(): Promise<GitGovSession | null>;
|
|
78
|
-
/**
|
|
79
|
-
* [EARS-B9] Detect actor from .key files in .gitgov/actors/
|
|
80
|
-
*/
|
|
81
|
-
detectActorFromKeyFiles(): Promise<string | null>;
|
|
82
|
-
/**
|
|
83
|
-
* Get actor state for a specific actor
|
|
84
|
-
*/
|
|
85
|
-
getActorState(actorId: string): Promise<ActorState | null>;
|
|
86
|
-
/**
|
|
87
|
-
* Update actor state for a specific actor
|
|
88
|
-
*/
|
|
89
|
-
updateActorState(actorId: string, state: Partial<ActorState>): Promise<void>;
|
|
90
|
-
/**
|
|
91
|
-
* Get cloud session token
|
|
92
|
-
*/
|
|
93
|
-
getCloudSessionToken(): Promise<string | null>;
|
|
94
|
-
/**
|
|
95
|
-
* Get sync preferences from session
|
|
96
|
-
*/
|
|
97
|
-
getSyncPreferences(): Promise<GitGovSession['syncPreferences'] | null>;
|
|
98
|
-
/**
|
|
99
|
-
* Update sync preferences in .session.json
|
|
100
|
-
* These are local machine preferences that override project defaults
|
|
101
|
-
*/
|
|
102
|
-
updateSyncPreferences(preferences: SyncPreferencesUpdate): Promise<void>;
|
|
103
|
-
/**
|
|
104
|
-
* Get last session info (last human who interacted)
|
|
105
|
-
*/
|
|
106
|
-
getLastSession(): Promise<{
|
|
107
|
-
actorId: string;
|
|
108
|
-
timestamp: string;
|
|
109
|
-
} | null>;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* SessionStore - Session persistence abstraction
|
|
114
|
-
*
|
|
115
|
-
* Interface for storing and retrieving local session state (.session.json).
|
|
116
|
-
* Session state is ephemeral, machine-local, and NOT versioned in Git.
|
|
117
|
-
*
|
|
118
|
-
* Implementations:
|
|
119
|
-
* - FsSessionStore: Filesystem-based (production)
|
|
120
|
-
* - MemorySessionStore: In-memory (tests, serverless)
|
|
121
|
-
*/
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Interface for session state persistence.
|
|
125
|
-
*
|
|
126
|
-
* Session state includes:
|
|
127
|
-
* - Actor state (activeTaskId, activeCycleId, syncStatus)
|
|
128
|
-
* - Sync preferences (pullScheduler, fileWatcher settings)
|
|
129
|
-
* - Cloud session tokens
|
|
130
|
-
* - Last session information
|
|
131
|
-
*
|
|
132
|
-
* Unlike ConfigStore, SessionStore handles ephemeral, machine-local state
|
|
133
|
-
* that is NOT shared between collaborators.
|
|
134
|
-
*/
|
|
135
|
-
interface SessionStore {
|
|
136
|
-
/**
|
|
137
|
-
* Load session state from storage.
|
|
138
|
-
*
|
|
139
|
-
* @returns GitGovSession object or null if not found
|
|
140
|
-
*/
|
|
141
|
-
loadSession(): Promise<GitGovSession | null>;
|
|
142
|
-
/**
|
|
143
|
-
* Save session state to storage.
|
|
144
|
-
*
|
|
145
|
-
* @param session - The session state to persist
|
|
146
|
-
*/
|
|
147
|
-
saveSession(session: GitGovSession): Promise<void>;
|
|
148
|
-
/**
|
|
149
|
-
* Detect actor from private key files.
|
|
150
|
-
*
|
|
151
|
-
* Optional method for implementations that support actor auto-detection
|
|
152
|
-
* from .key files in the actors directory.
|
|
153
|
-
*
|
|
154
|
-
* @returns Actor ID (e.g., "human:camilo-v2") or null if not detectable
|
|
155
|
-
*/
|
|
156
|
-
detectActorFromKeyFiles?(): Promise<string | null>;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* KeyProvider Interface
|
|
161
|
-
*
|
|
162
|
-
* Abstracts private key storage for Actor signing operations.
|
|
163
|
-
* Enables different backends: filesystem (development), environment variables (serverless),
|
|
164
|
-
* or cloud KMS (enterprise).
|
|
165
|
-
*
|
|
166
|
-
* @module key_provider
|
|
167
|
-
*/
|
|
168
|
-
/**
|
|
169
|
-
* Error codes for KeyProvider operations.
|
|
170
|
-
*/
|
|
171
|
-
type KeyProviderErrorCode = 'KEY_NOT_FOUND' | 'KEY_READ_ERROR' | 'KEY_WRITE_ERROR' | 'KEY_DELETE_ERROR' | 'INVALID_KEY_FORMAT' | 'INVALID_ACTOR_ID';
|
|
172
|
-
/**
|
|
173
|
-
* Error thrown when key operations fail.
|
|
174
|
-
*/
|
|
175
|
-
declare class KeyProviderError extends Error {
|
|
176
|
-
readonly code: KeyProviderErrorCode;
|
|
177
|
-
readonly actorId?: string | undefined;
|
|
178
|
-
constructor(message: string, code: KeyProviderErrorCode, actorId?: string | undefined);
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Interface for managing private key storage.
|
|
182
|
-
* Implementations handle the actual persistence mechanism.
|
|
183
|
-
*
|
|
184
|
-
* @example
|
|
185
|
-
* ```typescript
|
|
186
|
-
* // Filesystem backend (development)
|
|
187
|
-
* const provider = new FsKeyProvider({ keysDir: '.gitgov/keys' });
|
|
188
|
-
*
|
|
189
|
-
* // Environment backend (serverless)
|
|
190
|
-
* const provider = new EnvKeyProvider({ prefix: 'GITGOV_KEY_' });
|
|
191
|
-
*
|
|
192
|
-
* // Usage
|
|
193
|
-
* const privateKey = await provider.getPrivateKey('actor:human:alice');
|
|
194
|
-
* if (privateKey) {
|
|
195
|
-
* const signature = signPayload(payload, privateKey, actorId, role);
|
|
196
|
-
* }
|
|
197
|
-
* ```
|
|
198
|
-
*/
|
|
199
|
-
interface KeyProvider {
|
|
200
|
-
/**
|
|
201
|
-
* Retrieves the private key for an actor.
|
|
202
|
-
* @param actorId - The actor's ID (e.g., 'actor:human:alice')
|
|
203
|
-
* @returns The base64-encoded private key, or null if not found
|
|
204
|
-
*/
|
|
205
|
-
getPrivateKey(actorId: string): Promise<string | null>;
|
|
206
|
-
/**
|
|
207
|
-
* Stores a private key for an actor.
|
|
208
|
-
* @param actorId - The actor's ID
|
|
209
|
-
* @param privateKey - The base64-encoded private key
|
|
210
|
-
* @throws KeyProviderError if write fails
|
|
211
|
-
*/
|
|
212
|
-
setPrivateKey(actorId: string, privateKey: string): Promise<void>;
|
|
213
|
-
/**
|
|
214
|
-
* Checks if a private key exists for an actor.
|
|
215
|
-
* @param actorId - The actor's ID
|
|
216
|
-
* @returns true if key exists, false otherwise
|
|
217
|
-
*/
|
|
218
|
-
hasPrivateKey(actorId: string): Promise<boolean>;
|
|
219
|
-
/**
|
|
220
|
-
* Deletes the private key for an actor.
|
|
221
|
-
* @param actorId - The actor's ID
|
|
222
|
-
* @returns true if key was deleted, false if it didn't exist
|
|
223
|
-
*/
|
|
224
|
-
deletePrivateKey(actorId: string): Promise<boolean>;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
export { type ActorState as A, type GitGovSession as G, type ISessionManager as I, type KeyProvider as K, type SessionStore as S, type SyncPreferencesUpdate as a, type SyncStatus as b, KeyProviderError as c, type KeyProviderErrorCode as d };
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* IdEncoder for transforming IDs to storage-safe filenames.
|
|
3
|
-
* Useful for characters not allowed in filesystem (e.g., `:` on Windows)
|
|
4
|
-
* or URL-unsafe characters in remote backends.
|
|
5
|
-
*/
|
|
6
|
-
interface IdEncoder {
|
|
7
|
-
/** Transform ID to storage-safe string */
|
|
8
|
-
encode: (id: string) => string;
|
|
9
|
-
/** Recover original ID from encoded string */
|
|
10
|
-
decode: (encoded: string) => string;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Default encoder: `:` → `_` (for IDs like "human:camilo")
|
|
14
|
-
* Reversible because IDs cannot contain `_` (see id_generator.ts)
|
|
15
|
-
*/
|
|
16
|
-
declare const DEFAULT_ID_ENCODER: IdEncoder;
|
|
17
|
-
/**
|
|
18
|
-
* RecordStore<V, R, O> - Generic interface for record persistence
|
|
19
|
-
*
|
|
20
|
-
* Abstracts CRUD operations without assuming storage backend.
|
|
21
|
-
* Each implementation decides how to persist (fs, memory, db, remote).
|
|
22
|
-
*
|
|
23
|
-
* @typeParam V - Value type (the record being stored)
|
|
24
|
-
* @typeParam R - Return type for write operations (default: void for local, GitHubWriteResult for GitHub)
|
|
25
|
-
* @typeParam O - Options type for write operations (default: void for local, GitHubWriteOpts for GitHub)
|
|
26
|
-
*/
|
|
27
|
-
interface RecordStore<V, R = void, O = void> {
|
|
28
|
-
/**
|
|
29
|
-
* Gets a record by ID
|
|
30
|
-
* @returns The record or null if it doesn't exist
|
|
31
|
-
*/
|
|
32
|
-
get(id: string): Promise<V | null>;
|
|
33
|
-
/**
|
|
34
|
-
* Persists a record
|
|
35
|
-
* @param id - Unique identifier
|
|
36
|
-
* @param value - The record to persist
|
|
37
|
-
*/
|
|
38
|
-
put(id: string, value: V, ...opts: O extends void ? [] : [opts?: O]): Promise<R>;
|
|
39
|
-
/**
|
|
40
|
-
* Persists multiple records in a single operation.
|
|
41
|
-
* Local backends iterate sequentially; GitHub backend uses atomic commits.
|
|
42
|
-
*/
|
|
43
|
-
putMany(entries: Array<{
|
|
44
|
-
id: string;
|
|
45
|
-
value: V;
|
|
46
|
-
}>, ...opts: O extends void ? [] : [opts?: O]): Promise<R>;
|
|
47
|
-
/**
|
|
48
|
-
* Deletes a record
|
|
49
|
-
* @param id - Identifier of the record to delete
|
|
50
|
-
*/
|
|
51
|
-
delete(id: string, ...opts: O extends void ? [] : [opts?: O]): Promise<R>;
|
|
52
|
-
/**
|
|
53
|
-
* Lists all record IDs
|
|
54
|
-
* @returns Array of IDs
|
|
55
|
-
*/
|
|
56
|
-
list(): Promise<string[]>;
|
|
57
|
-
/**
|
|
58
|
-
* Checks if a record exists
|
|
59
|
-
* @param id - Identifier to check
|
|
60
|
-
*/
|
|
61
|
-
exists(id: string): Promise<boolean>;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export { DEFAULT_ID_ENCODER as D, type IdEncoder as I, type RecordStore as R };
|