@gencode/agents 0.7.6 → 0.8.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/CHANGELOG.md +12 -0
- package/dist/index.d.ts +586 -568
- package/dist/index.js +92 -91
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -131,6 +131,394 @@ declare function validatePluginsConfig(params: {
|
|
|
131
131
|
registry: PluginManifestRegistry;
|
|
132
132
|
}): PluginsConfigValidationResult;
|
|
133
133
|
//#endregion
|
|
134
|
+
//#region src/memory/config.d.ts
|
|
135
|
+
type MemorySearchConfig = {
|
|
136
|
+
chunkTokens: number;
|
|
137
|
+
chunkOverlap: number;
|
|
138
|
+
maxResults: number;
|
|
139
|
+
minScore: number;
|
|
140
|
+
fallback: {
|
|
141
|
+
enabled: boolean;
|
|
142
|
+
};
|
|
143
|
+
embedding: {
|
|
144
|
+
providerId?: string;
|
|
145
|
+
};
|
|
146
|
+
experimental: {
|
|
147
|
+
sessionMemory: boolean;
|
|
148
|
+
};
|
|
149
|
+
sources: Array<"memory" | "sessions">;
|
|
150
|
+
store: {
|
|
151
|
+
sessionStoreName?: string;
|
|
152
|
+
vector: {
|
|
153
|
+
enabled: boolean;
|
|
154
|
+
extensionPath?: string;
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
hybrid: {
|
|
158
|
+
enabled: boolean;
|
|
159
|
+
vectorWeight: number;
|
|
160
|
+
textWeight: number;
|
|
161
|
+
candidateMultiplier: number;
|
|
162
|
+
mmr: {
|
|
163
|
+
enabled: boolean;
|
|
164
|
+
lambda: number;
|
|
165
|
+
};
|
|
166
|
+
temporalDecay: {
|
|
167
|
+
enabled: boolean;
|
|
168
|
+
halfLifeDays: number;
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
cache: {
|
|
172
|
+
enabled: boolean;
|
|
173
|
+
maxEntries?: number;
|
|
174
|
+
};
|
|
175
|
+
sync: {
|
|
176
|
+
onSessionStart: boolean;
|
|
177
|
+
onSearch: boolean;
|
|
178
|
+
watch: boolean;
|
|
179
|
+
watchDebounceMs: number;
|
|
180
|
+
sessions: {
|
|
181
|
+
deltaBytes: number;
|
|
182
|
+
deltaMessages: number;
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
citations: "off" | "auto" | "on";
|
|
186
|
+
};
|
|
187
|
+
//#endregion
|
|
188
|
+
//#region src/memory/manager.d.ts
|
|
189
|
+
type MemorySearchResult$1 = {
|
|
190
|
+
id?: string;
|
|
191
|
+
path: string;
|
|
192
|
+
startLine: number;
|
|
193
|
+
endLine: number;
|
|
194
|
+
score: number;
|
|
195
|
+
snippet: string;
|
|
196
|
+
source: "memory" | "sessions";
|
|
197
|
+
citation?: string;
|
|
198
|
+
};
|
|
199
|
+
type MemoryProviderStatus = {
|
|
200
|
+
backend: "builtin";
|
|
201
|
+
provider: string;
|
|
202
|
+
model?: string;
|
|
203
|
+
files?: number;
|
|
204
|
+
chunks?: number;
|
|
205
|
+
dirty?: boolean;
|
|
206
|
+
workspaceDir?: string;
|
|
207
|
+
dbPath?: string;
|
|
208
|
+
sources?: Array<"memory" | "sessions">;
|
|
209
|
+
sourceCounts?: Array<{
|
|
210
|
+
source: "memory" | "sessions";
|
|
211
|
+
files: number;
|
|
212
|
+
chunks: number;
|
|
213
|
+
}>;
|
|
214
|
+
cache?: {
|
|
215
|
+
enabled: boolean;
|
|
216
|
+
entries?: number;
|
|
217
|
+
maxEntries?: number;
|
|
218
|
+
};
|
|
219
|
+
fts?: {
|
|
220
|
+
enabled: boolean;
|
|
221
|
+
available: boolean;
|
|
222
|
+
error?: string;
|
|
223
|
+
rows?: number;
|
|
224
|
+
};
|
|
225
|
+
vector?: {
|
|
226
|
+
enabled: boolean;
|
|
227
|
+
available?: boolean;
|
|
228
|
+
extensionPath?: string;
|
|
229
|
+
loadError?: string;
|
|
230
|
+
dims?: number;
|
|
231
|
+
};
|
|
232
|
+
custom?: Record<string, unknown>;
|
|
233
|
+
};
|
|
234
|
+
type MemoryRebuildSummary = {
|
|
235
|
+
reason: string;
|
|
236
|
+
memoryFilesIndexed: number;
|
|
237
|
+
sessionFilesIndexed: number;
|
|
238
|
+
staleMemoryFilesRemoved: number;
|
|
239
|
+
staleSessionFilesRemoved: number;
|
|
240
|
+
chunks: number;
|
|
241
|
+
ftsRows?: number;
|
|
242
|
+
fallbackActive: boolean;
|
|
243
|
+
needsFullReindex: boolean;
|
|
244
|
+
};
|
|
245
|
+
declare class MemoryIndexManager {
|
|
246
|
+
private readonly dataDir;
|
|
247
|
+
private readonly memoryRoot;
|
|
248
|
+
private readonly storePath;
|
|
249
|
+
private readonly config;
|
|
250
|
+
private sessionStoreName;
|
|
251
|
+
private provider;
|
|
252
|
+
private providerKey;
|
|
253
|
+
private embeddingProviderId?;
|
|
254
|
+
private db;
|
|
255
|
+
private dirty;
|
|
256
|
+
private ftsAvailable;
|
|
257
|
+
private ftsError?;
|
|
258
|
+
private vector;
|
|
259
|
+
private vectorReady;
|
|
260
|
+
private watchers;
|
|
261
|
+
private watchTimer;
|
|
262
|
+
private sessionWatchTimer;
|
|
263
|
+
private sessionsDirty;
|
|
264
|
+
private sessionsDirtyFiles;
|
|
265
|
+
private sessionPendingFiles;
|
|
266
|
+
private searchFallbackOnly;
|
|
267
|
+
private lastRebuildSummary?;
|
|
268
|
+
private sessionDeltas;
|
|
269
|
+
static get(dataDir: string, config?: Partial<MemorySearchConfig>): MemoryIndexManager;
|
|
270
|
+
private constructor();
|
|
271
|
+
private applyConfig;
|
|
272
|
+
warmSession(): void;
|
|
273
|
+
noteSessionUpdate(sessionFile: string): void;
|
|
274
|
+
status(): MemoryProviderStatus;
|
|
275
|
+
probeEmbeddingAvailability(): Promise<{
|
|
276
|
+
ok: boolean;
|
|
277
|
+
error?: string;
|
|
278
|
+
}>;
|
|
279
|
+
probeVectorAvailability(): Promise<boolean>;
|
|
280
|
+
search(query: string): Promise<MemorySearchResult$1[]>;
|
|
281
|
+
readFile(params: {
|
|
282
|
+
relPath: string;
|
|
283
|
+
from?: number;
|
|
284
|
+
lines?: number;
|
|
285
|
+
}): Promise<{
|
|
286
|
+
text: string;
|
|
287
|
+
path: string;
|
|
288
|
+
}>;
|
|
289
|
+
replaceFile(params: {
|
|
290
|
+
relPath: string;
|
|
291
|
+
content: string;
|
|
292
|
+
}): Promise<void>;
|
|
293
|
+
deleteFile(relPath: string): Promise<void>;
|
|
294
|
+
appendToMemory(content: string): Promise<void>;
|
|
295
|
+
private openDatabase;
|
|
296
|
+
private ensureSchema;
|
|
297
|
+
private ensureVectorReady;
|
|
298
|
+
private loadVectorExtension;
|
|
299
|
+
private ensureVectorTable;
|
|
300
|
+
private dropVectorTable;
|
|
301
|
+
private withTimeout;
|
|
302
|
+
private ensureWatcher;
|
|
303
|
+
private scheduleWatchSync;
|
|
304
|
+
private ensureSessionListener;
|
|
305
|
+
private scheduleSessionDirty;
|
|
306
|
+
private processSessionDeltaBatch;
|
|
307
|
+
private updateSessionDelta;
|
|
308
|
+
private countNewlines;
|
|
309
|
+
private computeProviderKey;
|
|
310
|
+
private resolveMemoryFilePath;
|
|
311
|
+
private applyEmbeddingProvider;
|
|
312
|
+
private readMeta;
|
|
313
|
+
private writeMeta;
|
|
314
|
+
private loadEmbeddingCache;
|
|
315
|
+
private upsertEmbeddingCache;
|
|
316
|
+
private embedChunks;
|
|
317
|
+
private indexFile;
|
|
318
|
+
private buildSourceFilter;
|
|
319
|
+
private searchVector;
|
|
320
|
+
private searchKeyword;
|
|
321
|
+
private resetIndex;
|
|
322
|
+
private syncAndPostCheck;
|
|
323
|
+
private indexHasSearchableData;
|
|
324
|
+
private fileScanSearch;
|
|
325
|
+
private getFtsRowCount;
|
|
326
|
+
private buildRebuildSummary;
|
|
327
|
+
rebuild(reason?: string): Promise<MemoryRebuildSummary>;
|
|
328
|
+
sync(params?: {
|
|
329
|
+
reason?: string;
|
|
330
|
+
forceFullReindex?: boolean;
|
|
331
|
+
}): Promise<void>;
|
|
332
|
+
private syncSessionFiles;
|
|
333
|
+
private resetSessionDelta;
|
|
334
|
+
private decorateCitations;
|
|
335
|
+
private decorateEntryIds;
|
|
336
|
+
}
|
|
337
|
+
//#endregion
|
|
338
|
+
//#region src/memory/provider.d.ts
|
|
339
|
+
type MemoryProviderContext = {
|
|
340
|
+
dataDir: string;
|
|
341
|
+
memoryDir: string;
|
|
342
|
+
sessionId?: string;
|
|
343
|
+
sessionStoreName?: string;
|
|
344
|
+
pluginId?: string;
|
|
345
|
+
config?: Record<string, unknown>;
|
|
346
|
+
rootDir?: string;
|
|
347
|
+
source?: string;
|
|
348
|
+
};
|
|
349
|
+
type MemorySearchOptions = {
|
|
350
|
+
limit?: number;
|
|
351
|
+
sources?: Array<"memory" | "sessions">;
|
|
352
|
+
};
|
|
353
|
+
type MemoryChangeSource = "memory" | "sessions";
|
|
354
|
+
type MemoryChangedEvent = {
|
|
355
|
+
reason: string;
|
|
356
|
+
files: string[];
|
|
357
|
+
source: MemoryChangeSource;
|
|
358
|
+
sessionId?: string;
|
|
359
|
+
providerId?: string;
|
|
360
|
+
timestamp: string;
|
|
361
|
+
};
|
|
362
|
+
type MemoryChangedHandler = (event: MemoryChangedEvent) => void | Promise<void>;
|
|
363
|
+
type MemoryProvider = {
|
|
364
|
+
id: string;
|
|
365
|
+
name?: string;
|
|
366
|
+
status: () => MemoryProviderStatus;
|
|
367
|
+
search: (query: string, options?: MemorySearchOptions) => Promise<MemorySearchResult$1[]>;
|
|
368
|
+
getLines: (file: string, startLine: number, endLine: number) => Promise<string[] | null>;
|
|
369
|
+
listFiles: () => Promise<string[]>;
|
|
370
|
+
append: (content: string) => Promise<void>; /** Write a daily or session log entry. Falls back to append() if not implemented. */
|
|
371
|
+
appendRecent?: (content: string, scope: "daily" | "session") => Promise<void>;
|
|
372
|
+
updateFile: (file: string, content: string) => Promise<void>;
|
|
373
|
+
deleteFile: (file: string) => Promise<void>;
|
|
374
|
+
sync?: (reason?: string) => Promise<void>;
|
|
375
|
+
noteSessionUpdate?: (sessionFile: string) => void;
|
|
376
|
+
onMemoryChanged?: MemoryChangedHandler;
|
|
377
|
+
};
|
|
378
|
+
type MemoryProviderFactory = (ctx: MemoryProviderContext) => MemoryProvider;
|
|
379
|
+
//#endregion
|
|
380
|
+
//#region src/session/session.d.ts
|
|
381
|
+
declare const DEFAULT_SESSION_STORE_NAME = "sessions";
|
|
382
|
+
type SessionPathOptions = {
|
|
383
|
+
storeName?: string; /** Whether session data should be encrypted at rest. */
|
|
384
|
+
encryptSessions?: boolean;
|
|
385
|
+
subagent?: {
|
|
386
|
+
parentSessionId: string;
|
|
387
|
+
/**
|
|
388
|
+
* Absolute filesystem path of the parent session's directory.
|
|
389
|
+
* When set, the child path is resolved as `path.join(parentDir, "subagents", childSessionId)`
|
|
390
|
+
* rather than anchoring at `sessionsDir`. This is required for correctly nesting
|
|
391
|
+
* sub-subagents (depth ≥ 2) inside their parent subagent's own directory.
|
|
392
|
+
*/
|
|
393
|
+
parentDir?: string;
|
|
394
|
+
};
|
|
395
|
+
};
|
|
396
|
+
type SessionInspection = {
|
|
397
|
+
id: string;
|
|
398
|
+
metadata: SessionMetadata$1 | null;
|
|
399
|
+
transcriptPath: string;
|
|
400
|
+
contextSnapshotPath: string;
|
|
401
|
+
sessionMemoryPath: string;
|
|
402
|
+
collapseLogPath: string;
|
|
403
|
+
toolResultsDir: string;
|
|
404
|
+
transcriptEntryCount: number;
|
|
405
|
+
readStateCount: number;
|
|
406
|
+
toolResultRefCount: number;
|
|
407
|
+
transcriptEntries: TranscriptEntry[];
|
|
408
|
+
context: SessionContextSnapshot;
|
|
409
|
+
};
|
|
410
|
+
type SessionExport = {
|
|
411
|
+
id: string;
|
|
412
|
+
metadata: SessionMetadata$1 | null;
|
|
413
|
+
transcript: TranscriptEntry[];
|
|
414
|
+
context: SessionContextSnapshot;
|
|
415
|
+
paths: {
|
|
416
|
+
transcriptPath: string;
|
|
417
|
+
contextSnapshotPath: string;
|
|
418
|
+
sessionMemoryPath: string;
|
|
419
|
+
collapseLogPath: string;
|
|
420
|
+
toolResultsDir: string;
|
|
421
|
+
};
|
|
422
|
+
};
|
|
423
|
+
type CronExecutionRecord = {
|
|
424
|
+
task: string;
|
|
425
|
+
status: "done" | "error" | "killed";
|
|
426
|
+
content: string;
|
|
427
|
+
childSessionId?: string;
|
|
428
|
+
createdAt: string;
|
|
429
|
+
};
|
|
430
|
+
declare const MAX_ARTIFACT_CONTENT_CHARS = 2000;
|
|
431
|
+
type ArtifactOperationType = "write" | "edit" | "delete" | "move";
|
|
432
|
+
type ArtifactOperationName = "write_file" | "edit_file" | "patch_add" | "patch_update" | "patch_delete" | "patch_move";
|
|
433
|
+
type ArtifactOperationInput = {
|
|
434
|
+
type: ArtifactOperationType;
|
|
435
|
+
operation: ArtifactOperationName;
|
|
436
|
+
file: string;
|
|
437
|
+
sourceFile?: string;
|
|
438
|
+
content: string;
|
|
439
|
+
toolCallId: string;
|
|
440
|
+
toolName: string; /** Whether this operation was performed by the agent itself or a subagent */
|
|
441
|
+
source: "agent" | "subagent"; /** The session that actually performed this operation */
|
|
442
|
+
sessionId: string;
|
|
443
|
+
};
|
|
444
|
+
/** Operation shape that tool implementations provide before the recorder enriches it with source/sessionId. */
|
|
445
|
+
type ArtifactOpInput = Omit<ArtifactOperationInput, "source" | "sessionId">;
|
|
446
|
+
type ArtifactOperation = ArtifactOperationInput & {
|
|
447
|
+
timestamp: string;
|
|
448
|
+
truncated: boolean;
|
|
449
|
+
originalChars: number;
|
|
450
|
+
};
|
|
451
|
+
/** Resolves the sessions directory path within a data directory */
|
|
452
|
+
declare function normalizeSessionStoreName(storeName?: string): string;
|
|
453
|
+
/** Resolves the sessions directory path within a data directory */
|
|
454
|
+
declare function sessionsDir(dataDir: string, options?: SessionPathOptions): string;
|
|
455
|
+
/** Resolves the directory for a specific session */
|
|
456
|
+
declare function sessionDir(dataDir: string, sessionId: string, options?: SessionPathOptions): string;
|
|
457
|
+
/** Resolves the transcript file path for a session */
|
|
458
|
+
declare function transcriptPath(dataDir: string, sessionId: string, options?: SessionPathOptions): string;
|
|
459
|
+
/** Resolves the artifact operation log path for a session */
|
|
460
|
+
declare function artifactsPath(dataDir: string, sessionId: string, options?: SessionPathOptions): string;
|
|
461
|
+
/** Resolves the metadata file path for a session */
|
|
462
|
+
declare function metadataPath(dataDir: string, sessionId: string, options?: SessionPathOptions): string;
|
|
463
|
+
/** Resolves the persisted context snapshot path for a session */
|
|
464
|
+
declare function contextSnapshotPath(dataDir: string, sessionId: string, options?: SessionPathOptions): string;
|
|
465
|
+
declare function sessionMemoryPath(dataDir: string, sessionId: string, options?: SessionPathOptions): string;
|
|
466
|
+
declare function collapseLogPath(dataDir: string, sessionId: string, options?: SessionPathOptions): string;
|
|
467
|
+
/** Resolves the persisted tool-results directory for a session */
|
|
468
|
+
declare function toolResultsDir(dataDir: string, sessionId: string, options?: SessionPathOptions): string;
|
|
469
|
+
declare function cronExecutionsPath(dataDir: string, sessionId: string, options?: SessionPathOptions): string;
|
|
470
|
+
/** Creates a new session with a generated ID */
|
|
471
|
+
declare function createSession(dataDir: string, channel: Channel, options?: SessionPathOptions & {
|
|
472
|
+
sessionId?: string;
|
|
473
|
+
}): Promise<string>;
|
|
474
|
+
/** Ensures a session directory exists (for resuming an existing session) */
|
|
475
|
+
declare function ensureSession(dataDir: string, sessionId: string, options?: SessionPathOptions): Promise<void>;
|
|
476
|
+
/** Loads all transcript entries from a session */
|
|
477
|
+
declare function loadTranscript(dataDir: string, sessionId: string, options?: SessionPathOptions): Promise<TranscriptEntry[]>;
|
|
478
|
+
declare function appendArtifactOperation(dataDir: string, sessionId: string, operation: ArtifactOperationInput, options?: SessionPathOptions): Promise<void>;
|
|
479
|
+
declare function loadArtifactOperations(dataDir: string, sessionId: string, options?: SessionPathOptions): Promise<ArtifactOperation[]>;
|
|
480
|
+
/** Appends a single entry to the transcript file */
|
|
481
|
+
declare function appendTranscriptEntry(dataDir: string, sessionId: string, entry: TranscriptEntry, options?: SessionPathOptions & {
|
|
482
|
+
providerId?: string;
|
|
483
|
+
pluginId?: string;
|
|
484
|
+
onMemoryChanged?: MemoryChangedHandler;
|
|
485
|
+
}): Promise<void>;
|
|
486
|
+
/** Rewrites the full transcript atomically using the provided updater. */
|
|
487
|
+
declare function rewriteTranscript(dataDir: string, sessionId: string, updater: (entries: TranscriptEntry[]) => TranscriptEntry[], options?: SessionPathOptions & {
|
|
488
|
+
providerId?: string;
|
|
489
|
+
pluginId?: string;
|
|
490
|
+
onMemoryChanged?: MemoryChangedHandler;
|
|
491
|
+
}): Promise<TranscriptEntry[]>;
|
|
492
|
+
declare function appendCronExecutionRecord(dataDir: string, sessionId: string, record: CronExecutionRecord, options?: SessionPathOptions): Promise<void>;
|
|
493
|
+
declare function loadCronExecutionRecords(dataDir: string, sessionId: string, options?: SessionPathOptions): Promise<CronExecutionRecord[]>;
|
|
494
|
+
/** Lists all session IDs within a data directory */
|
|
495
|
+
declare function listSessions(dataDir: string, options?: SessionPathOptions): Promise<string[]>;
|
|
496
|
+
/** Saves session metadata to disk */
|
|
497
|
+
declare function saveSessionMetadata(dataDir: string, metadata: SessionMetadata$1, options?: SessionPathOptions): Promise<void>;
|
|
498
|
+
type SessionMetadataUpdate = Partial<Omit<SessionMetadata$1, "id" | "createdAt">>;
|
|
499
|
+
declare function updateSessionMetadata(dataDir: string, sessionId: string, updates: SessionMetadataUpdate, options?: SessionPathOptions): Promise<SessionMetadata$1 | null>;
|
|
500
|
+
/** Loads session metadata from disk; returns null if not found */
|
|
501
|
+
declare function loadSessionMetadata(dataDir: string, sessionId: string, options?: SessionPathOptions): Promise<SessionMetadata$1 | null>;
|
|
502
|
+
/** Lists all sessions with their metadata summaries, optionally filtered by channel */
|
|
503
|
+
declare function listSessionSummaries(dataDir: string, channel?: Channel, options?: SessionPathOptions): Promise<SessionSummary$1[]>;
|
|
504
|
+
declare function loadSessionContextSnapshot(dataDir: string, sessionId: string, options?: SessionPathOptions): Promise<SessionContextSnapshot>;
|
|
505
|
+
declare function inspectSession(dataDir: string, sessionId: string, options?: SessionPathOptions): Promise<SessionInspection>;
|
|
506
|
+
declare function exportSession(dataDir: string, sessionId: string, options?: SessionPathOptions): Promise<SessionExport>;
|
|
507
|
+
//#endregion
|
|
508
|
+
//#region src/history/topic-segmentation.d.ts
|
|
509
|
+
type TopicSegmentationConfig = {
|
|
510
|
+
enabled?: boolean;
|
|
511
|
+
minUserTurns?: number;
|
|
512
|
+
minEstimatedTokens?: number;
|
|
513
|
+
recentProtectedTurnCount?: number;
|
|
514
|
+
maxCandidates?: number;
|
|
515
|
+
maxSelectedTurns?: number;
|
|
516
|
+
maxCandidateUserChars?: number;
|
|
517
|
+
maxCandidateAssistantChars?: number;
|
|
518
|
+
timeoutMs?: number;
|
|
519
|
+
maxTokens?: number;
|
|
520
|
+
};
|
|
521
|
+
//#endregion
|
|
134
522
|
//#region src/skills/skills.d.ts
|
|
135
523
|
/** Resolves the skills directory path within a data directory */
|
|
136
524
|
declare function skillsDir(dataDir: string): string;
|
|
@@ -300,456 +688,211 @@ type AgentRunParamsBase = {
|
|
|
300
688
|
loopDetection?: ToolLoopDetectionConfig; /** LLM turn retry policy for transient provider/network failures. Enabled by default. */
|
|
301
689
|
llmRetry?: LlmTurnRetryConfig; /** Plugin system options (optional) */
|
|
302
690
|
plugins?: {
|
|
303
|
-
/** Plugin config structure (allow/deny/entries/slots/load.paths) */config?: PluginsConfig; /** Data dir used to resolve .aimax extensions */
|
|
304
|
-
dataDir?: string; /** Workspace dir exposed to plugin runtime/hooks */
|
|
305
|
-
workspaceDir?: string; /** Bundled plugins directory (disabled unless explicitly enabled) */
|
|
306
|
-
bundledDir?: string; /** Optional ownership uid override for security checks */
|
|
307
|
-
ownershipUid?: number | null; /** Optional tool allowlist for plugin tools */
|
|
308
|
-
toolAllowlist?: string[]; /** Optional allowlist for plugin LLM access (plugin id or tool name) */
|
|
309
|
-
llmAllowlist?: string[];
|
|
310
|
-
};
|
|
311
|
-
/**
|
|
312
|
-
* Additional skill registry directories supplied by the CLI.
|
|
313
|
-
* Each directory contains skill child directories such as <dir>/<skill-name>/SKILL.md.
|
|
314
|
-
*/
|
|
315
|
-
skillsLoadPaths?: string[]; /** Whether the CLI should prepare an encrypted .aimax mount before this run. */
|
|
316
|
-
encryptSessions?: boolean; /** Memory system options (optional) */
|
|
317
|
-
memory?: {
|
|
318
|
-
/** Explicit memory provider id (overrides plugins.slots.memory) */providerId?: string; /** Explicit plugin id for memory provider (used when providerId not set) */
|
|
319
|
-
pluginId?: string; /** Whether memory replies should include source path/line hints */
|
|
320
|
-
citationsMode?: "off" | "on";
|
|
321
|
-
}; /** Messaging prompt controls */
|
|
322
|
-
messaging?: {
|
|
323
|
-
enabled?: boolean; /** Human-readable configured channel list */
|
|
324
|
-
channels?: string[];
|
|
325
|
-
}; /** Internal auto-skill controls. CLI wiring is intentionally separate. */
|
|
326
|
-
autoSkills?: {
|
|
327
|
-
load?: {
|
|
328
|
-
/** Defaults to false. When false, the main agent cannot see or load learned auto-skills. */enabled?: boolean;
|
|
329
|
-
};
|
|
330
|
-
review?: {
|
|
331
|
-
/** Defaults to "write": run post-run auto-skill review when gates pass unless explicitly disabled. */mode?: AutoSkillReviewMode; /** Defaults to 1. Hard cap for review attempts that complete per session. */
|
|
332
|
-
maxReviewsPerSession?: number; /** Scope-based all-AND gates for session, current run, and review window statistics. */
|
|
333
|
-
gates?: AutoSkillReviewGatesConfig;
|
|
334
|
-
};
|
|
335
|
-
};
|
|
336
|
-
/**
|
|
337
|
-
* Maximum number of recent user turns to include in context.
|
|
338
|
-
* Older turns are dropped before the history is sent to the LLM.
|
|
339
|
-
* 0 or undefined means no limit.
|
|
340
|
-
*/
|
|
341
|
-
historyLimit?: number;
|
|
342
|
-
/**
|
|
343
|
-
* Goal to create when this run establishes a new session (CLI `run --goal` without --session-id).
|
|
344
|
-
* Applied in runner after sessionId is assigned; not passed to the model as a tool.
|
|
345
|
-
*/
|
|
346
|
-
pendingGoal?: {
|
|
347
|
-
objective: string;
|
|
348
|
-
tokenBudget: number | null;
|
|
349
|
-
}; /** Internal multi-agent prompt/model/tool policy resolved at run time. */
|
|
350
|
-
agentPolicy?: AgentRuntimePolicyInput;
|
|
351
|
-
};
|
|
352
|
-
/** Parameters for running an agent session */
|
|
353
|
-
type AgentRunParams = AgentRunParamsBase & ({
|
|
354
|
-
/** The user message to process */message: string; /** Structured messages to process for file-based runs */
|
|
355
|
-
messages?: never;
|
|
356
|
-
} | {
|
|
357
|
-
/** Structured messages to process for file-based runs */messages: Message[]; /** The user message to process */
|
|
358
|
-
message?: never;
|
|
359
|
-
});
|
|
360
|
-
/** Final result returned after agent execution completes */
|
|
361
|
-
type AgentRunResult = RunResultPayload$1 & {
|
|
362
|
-
sessionId: string; /** Present when the run was paused for HITL. */
|
|
363
|
-
paused?: {
|
|
364
|
-
requestId: string;
|
|
365
|
-
kind: _gencode_shared0.HitlKind;
|
|
366
|
-
title: string;
|
|
367
|
-
}; /** Present when the run was paused for a UI tool awaiting user input. */
|
|
368
|
-
uiToolPending?: {
|
|
369
|
-
requestId: string;
|
|
370
|
-
toolName: string;
|
|
371
|
-
toolCallId: string;
|
|
372
|
-
outputSchema: _gencode_shared0.UiToolOutputSchema;
|
|
373
|
-
extra?: _gencode_shared0.UiToolExtra;
|
|
374
|
-
};
|
|
375
|
-
};
|
|
376
|
-
/** HTTP callback body formats */
|
|
377
|
-
type CallbackPayload = CallbackEventPayload$1;
|
|
378
|
-
/** A user message turn */
|
|
379
|
-
type UserEntry = {
|
|
380
|
-
role: "user";
|
|
381
|
-
content: string;
|
|
382
|
-
timestamp: string;
|
|
383
|
-
source?: "cron";
|
|
384
|
-
};
|
|
385
|
-
/** An assistant message turn; may include tool calls when the LLM used tools */
|
|
386
|
-
type AssistantEntry = {
|
|
387
|
-
role: "assistant"; /** Text response from the assistant (may be empty when the turn is tool-only) */
|
|
388
|
-
content: string; /** Persisted SDK stop reason when the assistant turn ended abnormally. */
|
|
389
|
-
stopReason?: "stop" | "length" | "toolUse" | "error" | "aborted"; /** Pi-compatible assistant error text for failed model turns. */
|
|
390
|
-
errorMessage?: string; /** Tool calls issued by the assistant during this turn */
|
|
391
|
-
toolCalls?: Array<{
|
|
392
|
-
id: string;
|
|
393
|
-
name: string;
|
|
394
|
-
arguments: Record<string, unknown>;
|
|
395
|
-
}>;
|
|
396
|
-
timestamp: string;
|
|
397
|
-
source?: "cron";
|
|
398
|
-
};
|
|
399
|
-
/** The result returned by a single tool execution */
|
|
400
|
-
type ToolResultEntry = {
|
|
401
|
-
role: "tool_result"; /** Matches AssistantEntry.toolCalls[].id */
|
|
402
|
-
toolCallId: string;
|
|
403
|
-
toolName: string; /** Text output of the tool */
|
|
404
|
-
content: string;
|
|
405
|
-
isError: boolean;
|
|
406
|
-
toolResultRef?: ToolResultReference;
|
|
407
|
-
timestamp: string;
|
|
408
|
-
source?: "cron";
|
|
409
|
-
};
|
|
410
|
-
/**
|
|
411
|
-
* A compaction record written after LLM-based history summarisation.
|
|
412
|
-
* `content` holds the summary text so it is accessible via the common
|
|
413
|
-
* `.content` property without narrowing on `role`.
|
|
414
|
-
*/
|
|
415
|
-
type CompactionEntry = {
|
|
416
|
-
role: "compaction"; /** Summary of the dropped conversation history */
|
|
417
|
-
content: string;
|
|
418
|
-
keptCount: number;
|
|
419
|
-
droppedCount: number;
|
|
420
|
-
timestamp: string;
|
|
421
|
-
source?: "cron";
|
|
422
|
-
};
|
|
423
|
-
/** Union of all persisted transcript entry types */
|
|
424
|
-
type TranscriptEntry = UserEntry | AssistantEntry | ToolResultEntry | CompactionEntry;
|
|
425
|
-
//#endregion
|
|
426
|
-
//#region src/subagent/types.d.ts
|
|
427
|
-
/** Status of a spawned subagent run */
|
|
428
|
-
type SubagentStatus = "running" | "done" | "error" | "killed";
|
|
429
|
-
/** Record tracking a single subagent run */
|
|
430
|
-
type SubagentRunRecord = {
|
|
431
|
-
runId: string;
|
|
432
|
-
childSessionId: string;
|
|
433
|
-
parentSessionId: string;
|
|
434
|
-
task: string;
|
|
435
|
-
label?: string; /** Nesting depth: parent is depth N, child is N+1 */
|
|
436
|
-
depth: number;
|
|
437
|
-
status: SubagentStatus;
|
|
438
|
-
result?: string;
|
|
439
|
-
error?: string;
|
|
440
|
-
startedAt: number;
|
|
441
|
-
endedAt?: number; /** Used to cancel the subagent run */
|
|
442
|
-
abortController: AbortController;
|
|
443
|
-
};
|
|
444
|
-
//#endregion
|
|
445
|
-
//#region src/subagent/registry.d.ts
|
|
446
|
-
declare const MAX_SUBAGENT_DEPTH = 2;
|
|
447
|
-
declare const MAX_CHILDREN_PER_SESSION = 5;
|
|
448
|
-
/**
|
|
449
|
-
* In-memory registry for subagent runs scoped to a single parent runAgent call.
|
|
450
|
-
* Child spawns create their own SubagentRegistry instances for their children.
|
|
451
|
-
*/
|
|
452
|
-
declare class SubagentRegistry {
|
|
453
|
-
private readonly entries;
|
|
454
|
-
/** RunIds whose terminal result has already been delivered to the parent. */
|
|
455
|
-
private readonly announced;
|
|
456
|
-
register(record: SubagentRunRecord, promise: Promise<void>): void;
|
|
457
|
-
complete(runId: string, result: string): void;
|
|
458
|
-
fail(runId: string, error: string): void;
|
|
459
|
-
/** Aborts and marks a specific run as killed. Returns false if not found or already ended. */
|
|
460
|
-
kill(runId: string): boolean;
|
|
461
|
-
/** Aborts all running subagents for the given parent session. Returns count killed. */
|
|
462
|
-
killAll(parentSessionId: string): number;
|
|
463
|
-
/** Lists all runs registered for the given parent session. */
|
|
464
|
-
list(parentSessionId: string): SubagentRunRecord[];
|
|
465
|
-
/** Returns true if any subagents for this session are still running. */
|
|
466
|
-
hasPending(parentSessionId: string): boolean;
|
|
467
|
-
/** Count of currently running children for a session. */
|
|
468
|
-
countActive(parentSessionId: string): number;
|
|
469
|
-
/**
|
|
470
|
-
* Waits until all currently-running subagents for the given session settle.
|
|
471
|
-
* Returns immediately if nothing is pending.
|
|
472
|
-
*/
|
|
473
|
-
waitForAll(parentSessionId: string): Promise<void>;
|
|
474
|
-
/**
|
|
475
|
-
* Returns all finished runs whose terminal result has not yet been delivered.
|
|
476
|
-
* This is a read-only snapshot; callers must explicitly mark delivery after
|
|
477
|
-
* the result has been handed back to the parent.
|
|
478
|
-
*/
|
|
479
|
-
peekCompleted(parentSessionId: string): SubagentRunRecord[];
|
|
480
|
-
/**
|
|
481
|
-
* Returns all finished runs that have not yet been returned by this method,
|
|
482
|
-
* and marks them as announced so they are not returned again.
|
|
483
|
-
*/
|
|
484
|
-
consumeCompleted(parentSessionId: string): SubagentRunRecord[];
|
|
485
|
-
/** Marks a finished run as already delivered to its parent. */
|
|
486
|
-
markAnnounced(runId: string | string[]): void;
|
|
487
|
-
/** Returns whether a run's terminal result has already been delivered. */
|
|
488
|
-
isAnnounced(runId: string): boolean;
|
|
489
|
-
/** Returns true if there are completed runs not yet returned by consumeCompleted. */
|
|
490
|
-
hasUnannounced(parentSessionId: string): boolean;
|
|
491
|
-
/**
|
|
492
|
-
* Returns true if the announce loop should run another iteration:
|
|
493
|
-
* either subagents are still running, or completed runs await announcement.
|
|
494
|
-
*/
|
|
495
|
-
needsAnnounce(parentSessionId: string): boolean;
|
|
496
|
-
/** Checks whether a new child can be spawned given depth and active-children limits. */
|
|
497
|
-
checkSpawnAllowed(parentSessionId: string, depth: number): {
|
|
498
|
-
allowed: true;
|
|
499
|
-
} | {
|
|
500
|
-
allowed: false;
|
|
501
|
-
reason: string;
|
|
502
|
-
};
|
|
503
|
-
/** Returns the current status snapshot for a single run, or null if not found. */
|
|
504
|
-
getStatus(runId: string): SubagentStatus | null;
|
|
505
|
-
private logTerminalStatus;
|
|
506
|
-
}
|
|
507
|
-
//#endregion
|
|
508
|
-
//#region src/memory/config.d.ts
|
|
509
|
-
type MemorySearchConfig = {
|
|
510
|
-
chunkTokens: number;
|
|
511
|
-
chunkOverlap: number;
|
|
512
|
-
maxResults: number;
|
|
513
|
-
minScore: number;
|
|
514
|
-
fallback: {
|
|
515
|
-
enabled: boolean;
|
|
516
|
-
};
|
|
517
|
-
embedding: {
|
|
518
|
-
providerId?: string;
|
|
519
|
-
};
|
|
520
|
-
experimental: {
|
|
521
|
-
sessionMemory: boolean;
|
|
522
|
-
};
|
|
523
|
-
sources: Array<"memory" | "sessions">;
|
|
524
|
-
store: {
|
|
525
|
-
sessionStoreName?: string;
|
|
526
|
-
vector: {
|
|
527
|
-
enabled: boolean;
|
|
528
|
-
extensionPath?: string;
|
|
529
|
-
};
|
|
530
|
-
};
|
|
531
|
-
hybrid: {
|
|
532
|
-
enabled: boolean;
|
|
533
|
-
vectorWeight: number;
|
|
534
|
-
textWeight: number;
|
|
535
|
-
candidateMultiplier: number;
|
|
536
|
-
mmr: {
|
|
537
|
-
enabled: boolean;
|
|
538
|
-
lambda: number;
|
|
539
|
-
};
|
|
540
|
-
temporalDecay: {
|
|
541
|
-
enabled: boolean;
|
|
542
|
-
halfLifeDays: number;
|
|
543
|
-
};
|
|
544
|
-
};
|
|
545
|
-
cache: {
|
|
546
|
-
enabled: boolean;
|
|
547
|
-
maxEntries?: number;
|
|
691
|
+
/** Plugin config structure (allow/deny/entries/slots/load.paths) */config?: PluginsConfig; /** Data dir used to resolve .aimax extensions */
|
|
692
|
+
dataDir?: string; /** Workspace dir exposed to plugin runtime/hooks */
|
|
693
|
+
workspaceDir?: string; /** Bundled plugins directory (disabled unless explicitly enabled) */
|
|
694
|
+
bundledDir?: string; /** Optional ownership uid override for security checks */
|
|
695
|
+
ownershipUid?: number | null; /** Optional tool allowlist for plugin tools */
|
|
696
|
+
toolAllowlist?: string[]; /** Optional allowlist for plugin LLM access (plugin id or tool name) */
|
|
697
|
+
llmAllowlist?: string[];
|
|
548
698
|
};
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
699
|
+
/**
|
|
700
|
+
* Additional skill registry directories supplied by the CLI.
|
|
701
|
+
* Each directory contains skill child directories such as <dir>/<skill-name>/SKILL.md.
|
|
702
|
+
*/
|
|
703
|
+
skillsLoadPaths?: string[]; /** Whether the CLI should prepare an encrypted .aimax mount before this run. */
|
|
704
|
+
encryptSessions?: boolean; /** Memory system options (optional) */
|
|
705
|
+
memory?: {
|
|
706
|
+
/** Explicit memory provider id (overrides plugins.slots.memory) */providerId?: string; /** Explicit plugin id for memory provider (used when providerId not set) */
|
|
707
|
+
pluginId?: string; /** Whether memory replies should include source path/line hints */
|
|
708
|
+
citationsMode?: "off" | "on";
|
|
709
|
+
}; /** Messaging prompt controls */
|
|
710
|
+
messaging?: {
|
|
711
|
+
enabled?: boolean; /** Human-readable configured channel list */
|
|
712
|
+
channels?: string[];
|
|
713
|
+
}; /** Internal auto-skill controls. CLI wiring is intentionally separate. */
|
|
714
|
+
autoSkills?: {
|
|
715
|
+
load?: {
|
|
716
|
+
/** Defaults to false. When false, the main agent cannot see or load learned auto-skills. */enabled?: boolean;
|
|
717
|
+
};
|
|
718
|
+
review?: {
|
|
719
|
+
/** Defaults to "write": run post-run auto-skill review when gates pass unless explicitly disabled. */mode?: AutoSkillReviewMode; /** Defaults to 1. Hard cap for review attempts that complete per session. */
|
|
720
|
+
maxReviewsPerSession?: number; /** Scope-based all-AND gates for session, current run, and review window statistics. */
|
|
721
|
+
gates?: AutoSkillReviewGatesConfig;
|
|
557
722
|
};
|
|
558
723
|
};
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
724
|
+
/**
|
|
725
|
+
* Maximum number of recent user turns to include in context.
|
|
726
|
+
* Older turns are dropped before the history is sent to the LLM.
|
|
727
|
+
* 0 or undefined means no limit.
|
|
728
|
+
*/
|
|
729
|
+
historyLimit?: number; /** Optional IM-style topic segmentation prefilter. Disabled unless enabled=true. */
|
|
730
|
+
topicSegmentation?: TopicSegmentationConfig;
|
|
731
|
+
/**
|
|
732
|
+
* Goal to create when this run establishes a new session (CLI `run --goal` without --session-id).
|
|
733
|
+
* Applied in runner after sessionId is assigned; not passed to the model as a tool.
|
|
734
|
+
*/
|
|
735
|
+
pendingGoal?: {
|
|
736
|
+
objective: string;
|
|
737
|
+
tokenBudget: number | null;
|
|
738
|
+
}; /** Internal multi-agent prompt/model/tool policy resolved at run time. */
|
|
739
|
+
agentPolicy?: AgentRuntimePolicyInput;
|
|
572
740
|
};
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
available: boolean;
|
|
596
|
-
error?: string;
|
|
597
|
-
rows?: number;
|
|
598
|
-
};
|
|
599
|
-
vector?: {
|
|
600
|
-
enabled: boolean;
|
|
601
|
-
available?: boolean;
|
|
602
|
-
extensionPath?: string;
|
|
603
|
-
loadError?: string;
|
|
604
|
-
dims?: number;
|
|
741
|
+
/** Parameters for running an agent session */
|
|
742
|
+
type AgentRunParams = AgentRunParamsBase & ({
|
|
743
|
+
/** The user message to process */message: string; /** Structured messages to process for file-based runs */
|
|
744
|
+
messages?: never;
|
|
745
|
+
} | {
|
|
746
|
+
/** Structured messages to process for file-based runs */messages: Message[]; /** The user message to process */
|
|
747
|
+
message?: never;
|
|
748
|
+
});
|
|
749
|
+
/** Final result returned after agent execution completes */
|
|
750
|
+
type AgentRunResult = RunResultPayload$1 & {
|
|
751
|
+
sessionId: string; /** Present when the run was paused for HITL. */
|
|
752
|
+
paused?: {
|
|
753
|
+
requestId: string;
|
|
754
|
+
kind: _gencode_shared0.HitlKind;
|
|
755
|
+
title: string;
|
|
756
|
+
}; /** Present when the run was paused for a UI tool awaiting user input. */
|
|
757
|
+
uiToolPending?: {
|
|
758
|
+
requestId: string;
|
|
759
|
+
toolName: string;
|
|
760
|
+
toolCallId: string;
|
|
761
|
+
outputSchema: _gencode_shared0.UiToolOutputSchema;
|
|
762
|
+
extra?: _gencode_shared0.UiToolExtra;
|
|
605
763
|
};
|
|
606
|
-
custom?: Record<string, unknown>;
|
|
607
764
|
};
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
fallbackActive: boolean;
|
|
617
|
-
needsFullReindex: boolean;
|
|
765
|
+
/** HTTP callback body formats */
|
|
766
|
+
type CallbackPayload = CallbackEventPayload$1;
|
|
767
|
+
/** A user message turn */
|
|
768
|
+
type UserEntry = {
|
|
769
|
+
role: "user";
|
|
770
|
+
content: string;
|
|
771
|
+
timestamp: string;
|
|
772
|
+
source?: "cron";
|
|
618
773
|
};
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
private dirty;
|
|
630
|
-
private ftsAvailable;
|
|
631
|
-
private ftsError?;
|
|
632
|
-
private vector;
|
|
633
|
-
private vectorReady;
|
|
634
|
-
private watchers;
|
|
635
|
-
private watchTimer;
|
|
636
|
-
private sessionWatchTimer;
|
|
637
|
-
private sessionsDirty;
|
|
638
|
-
private sessionsDirtyFiles;
|
|
639
|
-
private sessionPendingFiles;
|
|
640
|
-
private searchFallbackOnly;
|
|
641
|
-
private lastRebuildSummary?;
|
|
642
|
-
private sessionDeltas;
|
|
643
|
-
static get(dataDir: string, config?: Partial<MemorySearchConfig>): MemoryIndexManager;
|
|
644
|
-
private constructor();
|
|
645
|
-
private applyConfig;
|
|
646
|
-
warmSession(): void;
|
|
647
|
-
noteSessionUpdate(sessionFile: string): void;
|
|
648
|
-
status(): MemoryProviderStatus;
|
|
649
|
-
probeEmbeddingAvailability(): Promise<{
|
|
650
|
-
ok: boolean;
|
|
651
|
-
error?: string;
|
|
652
|
-
}>;
|
|
653
|
-
probeVectorAvailability(): Promise<boolean>;
|
|
654
|
-
search(query: string): Promise<MemorySearchResult$1[]>;
|
|
655
|
-
readFile(params: {
|
|
656
|
-
relPath: string;
|
|
657
|
-
from?: number;
|
|
658
|
-
lines?: number;
|
|
659
|
-
}): Promise<{
|
|
660
|
-
text: string;
|
|
661
|
-
path: string;
|
|
774
|
+
/** An assistant message turn; may include tool calls when the LLM used tools */
|
|
775
|
+
type AssistantEntry = {
|
|
776
|
+
role: "assistant"; /** Text response from the assistant (may be empty when the turn is tool-only) */
|
|
777
|
+
content: string; /** Persisted SDK stop reason when the assistant turn ended abnormally. */
|
|
778
|
+
stopReason?: "stop" | "length" | "toolUse" | "error" | "aborted"; /** Pi-compatible assistant error text for failed model turns. */
|
|
779
|
+
errorMessage?: string; /** Tool calls issued by the assistant during this turn */
|
|
780
|
+
toolCalls?: Array<{
|
|
781
|
+
id: string;
|
|
782
|
+
name: string;
|
|
783
|
+
arguments: Record<string, unknown>;
|
|
662
784
|
}>;
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
content: string;
|
|
666
|
-
}): Promise<void>;
|
|
667
|
-
deleteFile(relPath: string): Promise<void>;
|
|
668
|
-
appendToMemory(content: string): Promise<void>;
|
|
669
|
-
private openDatabase;
|
|
670
|
-
private ensureSchema;
|
|
671
|
-
private ensureVectorReady;
|
|
672
|
-
private loadVectorExtension;
|
|
673
|
-
private ensureVectorTable;
|
|
674
|
-
private dropVectorTable;
|
|
675
|
-
private withTimeout;
|
|
676
|
-
private ensureWatcher;
|
|
677
|
-
private scheduleWatchSync;
|
|
678
|
-
private ensureSessionListener;
|
|
679
|
-
private scheduleSessionDirty;
|
|
680
|
-
private processSessionDeltaBatch;
|
|
681
|
-
private updateSessionDelta;
|
|
682
|
-
private countNewlines;
|
|
683
|
-
private computeProviderKey;
|
|
684
|
-
private resolveMemoryFilePath;
|
|
685
|
-
private applyEmbeddingProvider;
|
|
686
|
-
private readMeta;
|
|
687
|
-
private writeMeta;
|
|
688
|
-
private loadEmbeddingCache;
|
|
689
|
-
private upsertEmbeddingCache;
|
|
690
|
-
private embedChunks;
|
|
691
|
-
private indexFile;
|
|
692
|
-
private buildSourceFilter;
|
|
693
|
-
private searchVector;
|
|
694
|
-
private searchKeyword;
|
|
695
|
-
private resetIndex;
|
|
696
|
-
private syncAndPostCheck;
|
|
697
|
-
private indexHasSearchableData;
|
|
698
|
-
private fileScanSearch;
|
|
699
|
-
private getFtsRowCount;
|
|
700
|
-
private buildRebuildSummary;
|
|
701
|
-
rebuild(reason?: string): Promise<MemoryRebuildSummary>;
|
|
702
|
-
sync(params?: {
|
|
703
|
-
reason?: string;
|
|
704
|
-
forceFullReindex?: boolean;
|
|
705
|
-
}): Promise<void>;
|
|
706
|
-
private syncSessionFiles;
|
|
707
|
-
private resetSessionDelta;
|
|
708
|
-
private decorateCitations;
|
|
709
|
-
private decorateEntryIds;
|
|
710
|
-
}
|
|
711
|
-
//#endregion
|
|
712
|
-
//#region src/memory/provider.d.ts
|
|
713
|
-
type MemoryProviderContext = {
|
|
714
|
-
dataDir: string;
|
|
715
|
-
memoryDir: string;
|
|
716
|
-
sessionId?: string;
|
|
717
|
-
sessionStoreName?: string;
|
|
718
|
-
pluginId?: string;
|
|
719
|
-
config?: Record<string, unknown>;
|
|
720
|
-
rootDir?: string;
|
|
721
|
-
source?: string;
|
|
722
|
-
};
|
|
723
|
-
type MemorySearchOptions = {
|
|
724
|
-
limit?: number;
|
|
725
|
-
sources?: Array<"memory" | "sessions">;
|
|
785
|
+
timestamp: string;
|
|
786
|
+
source?: "cron";
|
|
726
787
|
};
|
|
727
|
-
|
|
728
|
-
type
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
788
|
+
/** The result returned by a single tool execution */
|
|
789
|
+
type ToolResultEntry = {
|
|
790
|
+
role: "tool_result"; /** Matches AssistantEntry.toolCalls[].id */
|
|
791
|
+
toolCallId: string;
|
|
792
|
+
toolName: string; /** Text output of the tool */
|
|
793
|
+
content: string;
|
|
794
|
+
isError: boolean;
|
|
795
|
+
toolResultRef?: ToolResultReference;
|
|
734
796
|
timestamp: string;
|
|
797
|
+
source?: "cron";
|
|
735
798
|
};
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
sync?: (reason?: string) => Promise<void>;
|
|
749
|
-
noteSessionUpdate?: (sessionFile: string) => void;
|
|
750
|
-
onMemoryChanged?: MemoryChangedHandler;
|
|
799
|
+
/**
|
|
800
|
+
* A compaction record written after LLM-based history summarisation.
|
|
801
|
+
* `content` holds the summary text so it is accessible via the common
|
|
802
|
+
* `.content` property without narrowing on `role`.
|
|
803
|
+
*/
|
|
804
|
+
type CompactionEntry = {
|
|
805
|
+
role: "compaction"; /** Summary of the dropped conversation history */
|
|
806
|
+
content: string;
|
|
807
|
+
keptCount: number;
|
|
808
|
+
droppedCount: number;
|
|
809
|
+
timestamp: string;
|
|
810
|
+
source?: "cron";
|
|
751
811
|
};
|
|
752
|
-
|
|
812
|
+
/** Union of all persisted transcript entry types */
|
|
813
|
+
type TranscriptEntry = UserEntry | AssistantEntry | ToolResultEntry | CompactionEntry;
|
|
814
|
+
//#endregion
|
|
815
|
+
//#region src/subagent/types.d.ts
|
|
816
|
+
/** Status of a spawned subagent run */
|
|
817
|
+
type SubagentStatus = "running" | "done" | "error" | "killed";
|
|
818
|
+
/** Record tracking a single subagent run */
|
|
819
|
+
type SubagentRunRecord = {
|
|
820
|
+
runId: string;
|
|
821
|
+
childSessionId: string;
|
|
822
|
+
parentSessionId: string;
|
|
823
|
+
task: string;
|
|
824
|
+
label?: string; /** Nesting depth: parent is depth N, child is N+1 */
|
|
825
|
+
depth: number;
|
|
826
|
+
status: SubagentStatus;
|
|
827
|
+
result?: string;
|
|
828
|
+
error?: string;
|
|
829
|
+
startedAt: number;
|
|
830
|
+
endedAt?: number; /** Used to cancel the subagent run */
|
|
831
|
+
abortController: AbortController;
|
|
832
|
+
};
|
|
833
|
+
//#endregion
|
|
834
|
+
//#region src/subagent/registry.d.ts
|
|
835
|
+
declare const MAX_SUBAGENT_DEPTH = 2;
|
|
836
|
+
declare const MAX_CHILDREN_PER_SESSION = 5;
|
|
837
|
+
/**
|
|
838
|
+
* In-memory registry for subagent runs scoped to a single parent runAgent call.
|
|
839
|
+
* Child spawns create their own SubagentRegistry instances for their children.
|
|
840
|
+
*/
|
|
841
|
+
declare class SubagentRegistry {
|
|
842
|
+
private readonly entries;
|
|
843
|
+
/** RunIds whose terminal result has already been delivered to the parent. */
|
|
844
|
+
private readonly announced;
|
|
845
|
+
register(record: SubagentRunRecord, promise: Promise<void>): void;
|
|
846
|
+
complete(runId: string, result: string): void;
|
|
847
|
+
fail(runId: string, error: string): void;
|
|
848
|
+
/** Aborts and marks a specific run as killed. Returns false if not found or already ended. */
|
|
849
|
+
kill(runId: string): boolean;
|
|
850
|
+
/** Aborts all running subagents for the given parent session. Returns count killed. */
|
|
851
|
+
killAll(parentSessionId: string): number;
|
|
852
|
+
/** Lists all runs registered for the given parent session. */
|
|
853
|
+
list(parentSessionId: string): SubagentRunRecord[];
|
|
854
|
+
/** Returns true if any subagents for this session are still running. */
|
|
855
|
+
hasPending(parentSessionId: string): boolean;
|
|
856
|
+
/** Count of currently running children for a session. */
|
|
857
|
+
countActive(parentSessionId: string): number;
|
|
858
|
+
/**
|
|
859
|
+
* Waits until all currently-running subagents for the given session settle.
|
|
860
|
+
* Returns immediately if nothing is pending.
|
|
861
|
+
*/
|
|
862
|
+
waitForAll(parentSessionId: string): Promise<void>;
|
|
863
|
+
/**
|
|
864
|
+
* Returns all finished runs whose terminal result has not yet been delivered.
|
|
865
|
+
* This is a read-only snapshot; callers must explicitly mark delivery after
|
|
866
|
+
* the result has been handed back to the parent.
|
|
867
|
+
*/
|
|
868
|
+
peekCompleted(parentSessionId: string): SubagentRunRecord[];
|
|
869
|
+
/**
|
|
870
|
+
* Returns all finished runs that have not yet been returned by this method,
|
|
871
|
+
* and marks them as announced so they are not returned again.
|
|
872
|
+
*/
|
|
873
|
+
consumeCompleted(parentSessionId: string): SubagentRunRecord[];
|
|
874
|
+
/** Marks a finished run as already delivered to its parent. */
|
|
875
|
+
markAnnounced(runId: string | string[]): void;
|
|
876
|
+
/** Returns whether a run's terminal result has already been delivered. */
|
|
877
|
+
isAnnounced(runId: string): boolean;
|
|
878
|
+
/** Returns true if there are completed runs not yet returned by consumeCompleted. */
|
|
879
|
+
hasUnannounced(parentSessionId: string): boolean;
|
|
880
|
+
/**
|
|
881
|
+
* Returns true if the announce loop should run another iteration:
|
|
882
|
+
* either subagents are still running, or completed runs await announcement.
|
|
883
|
+
*/
|
|
884
|
+
needsAnnounce(parentSessionId: string): boolean;
|
|
885
|
+
/** Checks whether a new child can be spawned given depth and active-children limits. */
|
|
886
|
+
checkSpawnAllowed(parentSessionId: string, depth: number): {
|
|
887
|
+
allowed: true;
|
|
888
|
+
} | {
|
|
889
|
+
allowed: false;
|
|
890
|
+
reason: string;
|
|
891
|
+
};
|
|
892
|
+
/** Returns the current status snapshot for a single run, or null if not found. */
|
|
893
|
+
getStatus(runId: string): SubagentStatus | null;
|
|
894
|
+
private logTerminalStatus;
|
|
895
|
+
}
|
|
753
896
|
//#endregion
|
|
754
897
|
//#region src/plugins/hooks.d.ts
|
|
755
898
|
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" | "dream_gate" | "memory_changed";
|
|
@@ -934,134 +1077,6 @@ declare function generateSessionTitle(params: GenerateTitleParams): Promise<stri
|
|
|
934
1077
|
*/
|
|
935
1078
|
declare function runAgent(params: AgentRunParams, _registryForTesting?: SubagentRegistry): Promise<AgentRunResult>;
|
|
936
1079
|
//#endregion
|
|
937
|
-
//#region src/session/session.d.ts
|
|
938
|
-
declare const DEFAULT_SESSION_STORE_NAME = "sessions";
|
|
939
|
-
type SessionPathOptions = {
|
|
940
|
-
storeName?: string; /** Whether session data should be encrypted at rest. */
|
|
941
|
-
encryptSessions?: boolean;
|
|
942
|
-
subagent?: {
|
|
943
|
-
parentSessionId: string;
|
|
944
|
-
/**
|
|
945
|
-
* Absolute filesystem path of the parent session's directory.
|
|
946
|
-
* When set, the child path is resolved as `path.join(parentDir, "subagents", childSessionId)`
|
|
947
|
-
* rather than anchoring at `sessionsDir`. This is required for correctly nesting
|
|
948
|
-
* sub-subagents (depth ≥ 2) inside their parent subagent's own directory.
|
|
949
|
-
*/
|
|
950
|
-
parentDir?: string;
|
|
951
|
-
};
|
|
952
|
-
};
|
|
953
|
-
type SessionInspection = {
|
|
954
|
-
id: string;
|
|
955
|
-
metadata: SessionMetadata$1 | null;
|
|
956
|
-
transcriptPath: string;
|
|
957
|
-
contextSnapshotPath: string;
|
|
958
|
-
sessionMemoryPath: string;
|
|
959
|
-
collapseLogPath: string;
|
|
960
|
-
toolResultsDir: string;
|
|
961
|
-
transcriptEntryCount: number;
|
|
962
|
-
readStateCount: number;
|
|
963
|
-
toolResultRefCount: number;
|
|
964
|
-
transcriptEntries: TranscriptEntry[];
|
|
965
|
-
context: SessionContextSnapshot;
|
|
966
|
-
};
|
|
967
|
-
type SessionExport = {
|
|
968
|
-
id: string;
|
|
969
|
-
metadata: SessionMetadata$1 | null;
|
|
970
|
-
transcript: TranscriptEntry[];
|
|
971
|
-
context: SessionContextSnapshot;
|
|
972
|
-
paths: {
|
|
973
|
-
transcriptPath: string;
|
|
974
|
-
contextSnapshotPath: string;
|
|
975
|
-
sessionMemoryPath: string;
|
|
976
|
-
collapseLogPath: string;
|
|
977
|
-
toolResultsDir: string;
|
|
978
|
-
};
|
|
979
|
-
};
|
|
980
|
-
type CronExecutionRecord = {
|
|
981
|
-
task: string;
|
|
982
|
-
status: "done" | "error" | "killed";
|
|
983
|
-
content: string;
|
|
984
|
-
childSessionId?: string;
|
|
985
|
-
createdAt: string;
|
|
986
|
-
};
|
|
987
|
-
declare const MAX_ARTIFACT_CONTENT_CHARS = 2000;
|
|
988
|
-
type ArtifactOperationType = "write" | "edit" | "delete" | "move";
|
|
989
|
-
type ArtifactOperationName = "write_file" | "edit_file" | "patch_add" | "patch_update" | "patch_delete" | "patch_move";
|
|
990
|
-
type ArtifactOperationInput = {
|
|
991
|
-
type: ArtifactOperationType;
|
|
992
|
-
operation: ArtifactOperationName;
|
|
993
|
-
file: string;
|
|
994
|
-
sourceFile?: string;
|
|
995
|
-
content: string;
|
|
996
|
-
toolCallId: string;
|
|
997
|
-
toolName: string; /** Whether this operation was performed by the agent itself or a subagent */
|
|
998
|
-
source: "agent" | "subagent"; /** The session that actually performed this operation */
|
|
999
|
-
sessionId: string;
|
|
1000
|
-
};
|
|
1001
|
-
/** Operation shape that tool implementations provide before the recorder enriches it with source/sessionId. */
|
|
1002
|
-
type ArtifactOpInput = Omit<ArtifactOperationInput, "source" | "sessionId">;
|
|
1003
|
-
type ArtifactOperation = ArtifactOperationInput & {
|
|
1004
|
-
timestamp: string;
|
|
1005
|
-
truncated: boolean;
|
|
1006
|
-
originalChars: number;
|
|
1007
|
-
};
|
|
1008
|
-
/** Resolves the sessions directory path within a data directory */
|
|
1009
|
-
declare function normalizeSessionStoreName(storeName?: string): string;
|
|
1010
|
-
/** Resolves the sessions directory path within a data directory */
|
|
1011
|
-
declare function sessionsDir(dataDir: string, options?: SessionPathOptions): string;
|
|
1012
|
-
/** Resolves the directory for a specific session */
|
|
1013
|
-
declare function sessionDir(dataDir: string, sessionId: string, options?: SessionPathOptions): string;
|
|
1014
|
-
/** Resolves the transcript file path for a session */
|
|
1015
|
-
declare function transcriptPath(dataDir: string, sessionId: string, options?: SessionPathOptions): string;
|
|
1016
|
-
/** Resolves the artifact operation log path for a session */
|
|
1017
|
-
declare function artifactsPath(dataDir: string, sessionId: string, options?: SessionPathOptions): string;
|
|
1018
|
-
/** Resolves the metadata file path for a session */
|
|
1019
|
-
declare function metadataPath(dataDir: string, sessionId: string, options?: SessionPathOptions): string;
|
|
1020
|
-
/** Resolves the persisted context snapshot path for a session */
|
|
1021
|
-
declare function contextSnapshotPath(dataDir: string, sessionId: string, options?: SessionPathOptions): string;
|
|
1022
|
-
declare function sessionMemoryPath(dataDir: string, sessionId: string, options?: SessionPathOptions): string;
|
|
1023
|
-
declare function collapseLogPath(dataDir: string, sessionId: string, options?: SessionPathOptions): string;
|
|
1024
|
-
/** Resolves the persisted tool-results directory for a session */
|
|
1025
|
-
declare function toolResultsDir(dataDir: string, sessionId: string, options?: SessionPathOptions): string;
|
|
1026
|
-
declare function cronExecutionsPath(dataDir: string, sessionId: string, options?: SessionPathOptions): string;
|
|
1027
|
-
/** Creates a new session with a generated ID */
|
|
1028
|
-
declare function createSession(dataDir: string, channel: Channel, options?: SessionPathOptions & {
|
|
1029
|
-
sessionId?: string;
|
|
1030
|
-
}): Promise<string>;
|
|
1031
|
-
/** Ensures a session directory exists (for resuming an existing session) */
|
|
1032
|
-
declare function ensureSession(dataDir: string, sessionId: string, options?: SessionPathOptions): Promise<void>;
|
|
1033
|
-
/** Loads all transcript entries from a session */
|
|
1034
|
-
declare function loadTranscript(dataDir: string, sessionId: string, options?: SessionPathOptions): Promise<TranscriptEntry[]>;
|
|
1035
|
-
declare function appendArtifactOperation(dataDir: string, sessionId: string, operation: ArtifactOperationInput, options?: SessionPathOptions): Promise<void>;
|
|
1036
|
-
declare function loadArtifactOperations(dataDir: string, sessionId: string, options?: SessionPathOptions): Promise<ArtifactOperation[]>;
|
|
1037
|
-
/** Appends a single entry to the transcript file */
|
|
1038
|
-
declare function appendTranscriptEntry(dataDir: string, sessionId: string, entry: TranscriptEntry, options?: SessionPathOptions & {
|
|
1039
|
-
providerId?: string;
|
|
1040
|
-
pluginId?: string;
|
|
1041
|
-
onMemoryChanged?: MemoryChangedHandler;
|
|
1042
|
-
}): Promise<void>;
|
|
1043
|
-
/** Rewrites the full transcript atomically using the provided updater. */
|
|
1044
|
-
declare function rewriteTranscript(dataDir: string, sessionId: string, updater: (entries: TranscriptEntry[]) => TranscriptEntry[], options?: SessionPathOptions & {
|
|
1045
|
-
providerId?: string;
|
|
1046
|
-
pluginId?: string;
|
|
1047
|
-
onMemoryChanged?: MemoryChangedHandler;
|
|
1048
|
-
}): Promise<TranscriptEntry[]>;
|
|
1049
|
-
declare function appendCronExecutionRecord(dataDir: string, sessionId: string, record: CronExecutionRecord, options?: SessionPathOptions): Promise<void>;
|
|
1050
|
-
declare function loadCronExecutionRecords(dataDir: string, sessionId: string, options?: SessionPathOptions): Promise<CronExecutionRecord[]>;
|
|
1051
|
-
/** Lists all session IDs within a data directory */
|
|
1052
|
-
declare function listSessions(dataDir: string, options?: SessionPathOptions): Promise<string[]>;
|
|
1053
|
-
/** Saves session metadata to disk */
|
|
1054
|
-
declare function saveSessionMetadata(dataDir: string, metadata: SessionMetadata$1, options?: SessionPathOptions): Promise<void>;
|
|
1055
|
-
type SessionMetadataUpdate = Partial<Omit<SessionMetadata$1, "id" | "createdAt">>;
|
|
1056
|
-
declare function updateSessionMetadata(dataDir: string, sessionId: string, updates: SessionMetadataUpdate, options?: SessionPathOptions): Promise<SessionMetadata$1 | null>;
|
|
1057
|
-
/** Loads session metadata from disk; returns null if not found */
|
|
1058
|
-
declare function loadSessionMetadata(dataDir: string, sessionId: string, options?: SessionPathOptions): Promise<SessionMetadata$1 | null>;
|
|
1059
|
-
/** Lists all sessions with their metadata summaries, optionally filtered by channel */
|
|
1060
|
-
declare function listSessionSummaries(dataDir: string, channel?: Channel, options?: SessionPathOptions): Promise<SessionSummary$1[]>;
|
|
1061
|
-
declare function loadSessionContextSnapshot(dataDir: string, sessionId: string, options?: SessionPathOptions): Promise<SessionContextSnapshot>;
|
|
1062
|
-
declare function inspectSession(dataDir: string, sessionId: string, options?: SessionPathOptions): Promise<SessionInspection>;
|
|
1063
|
-
declare function exportSession(dataDir: string, sessionId: string, options?: SessionPathOptions): Promise<SessionExport>;
|
|
1064
|
-
//#endregion
|
|
1065
1080
|
//#region src/session/session-storage.d.ts
|
|
1066
1081
|
declare function readSessionFile(filePath: string): Promise<string | null>;
|
|
1067
1082
|
declare function writeSessionFile(filePath: string, content: string, encrypt?: boolean): Promise<void>;
|
|
@@ -1124,6 +1139,7 @@ type ManageLayeredHistoryParams = {
|
|
|
1124
1139
|
historyLimit?: number;
|
|
1125
1140
|
compactionEnabled?: boolean;
|
|
1126
1141
|
pendingUserMessage?: string;
|
|
1142
|
+
topicSegmentation?: TopicSegmentationConfig;
|
|
1127
1143
|
signal?: AbortSignal;
|
|
1128
1144
|
hooks?: PluginHookRegistry;
|
|
1129
1145
|
hookCtx?: PluginHookAgentContext;
|
|
@@ -1132,6 +1148,8 @@ type ManageLayeredHistoryParams = {
|
|
|
1132
1148
|
sessionId?: string;
|
|
1133
1149
|
sessionStoreName?: string;
|
|
1134
1150
|
sessionPathScope?: Pick<SessionPathOptions, "subagent">;
|
|
1151
|
+
channel?: Channel$1;
|
|
1152
|
+
isSubagent?: boolean;
|
|
1135
1153
|
};
|
|
1136
1154
|
type ManageLayeredHistoryResult = {
|
|
1137
1155
|
messages: AgentMessage[];
|
|
@@ -2133,7 +2151,7 @@ type BatchSpawnResult = {
|
|
|
2133
2151
|
status: "done" | "partial_error" | "error";
|
|
2134
2152
|
results: BatchSpawnItemResult[];
|
|
2135
2153
|
};
|
|
2136
|
-
type InheritedRunParams = Pick<AgentRunParams, "plugins" | "skillsLoadPaths" | "memory" | "messaging" | "historyLimit" | "onProgress" | "messageId" | "sessionStoreName" | "autoSkills" | "agentPolicy">;
|
|
2154
|
+
type InheritedRunParams = Pick<AgentRunParams, "plugins" | "skillsLoadPaths" | "memory" | "messaging" | "historyLimit" | "topicSegmentation" | "onProgress" | "messageId" | "sessionStoreName" | "autoSkills" | "agentPolicy">;
|
|
2137
2155
|
/** Formats the announce message injected into the parent session when a subagent completes. */
|
|
2138
2156
|
declare function buildSubagentAnnounceMessage(params: {
|
|
2139
2157
|
task: string;
|
|
@@ -2280,7 +2298,7 @@ type SubagentToolsContext = {
|
|
|
2280
2298
|
depth: number;
|
|
2281
2299
|
channel: AgentRunParams["channel"];
|
|
2282
2300
|
llm: AgentRunParams["llm"];
|
|
2283
|
-
inheritedRunParams?: Pick<AgentRunParams, "plugins" | "skillsLoadPaths" | "memory" | "messaging" | "historyLimit" | "onProgress" | "messageId" | "sessionStoreName" | "autoSkills" | "agentPolicy">;
|
|
2301
|
+
inheritedRunParams?: Pick<AgentRunParams, "plugins" | "skillsLoadPaths" | "memory" | "messaging" | "historyLimit" | "topicSegmentation" | "onProgress" | "messageId" | "sessionStoreName" | "autoSkills" | "agentPolicy">;
|
|
2284
2302
|
loopDetection?: ToolLoopDetectionConfig;
|
|
2285
2303
|
autoSkillsLoadEnabled?: boolean;
|
|
2286
2304
|
memoryOptions?: MemoryToolOptions;
|