@gencode/agents 0.9.3 → 0.10.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/CHANGELOG.md +23 -0
- package/dist/index.d.ts +747 -693
- package/dist/index.js +108 -108
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -18,119 +18,6 @@ type ToolLoopDetectionConfig = {
|
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
20
|
//#endregion
|
|
21
|
-
//#region src/runner/turn-retry.d.ts
|
|
22
|
-
type LlmTurnRetryConfig = {
|
|
23
|
-
enabled?: boolean;
|
|
24
|
-
maxAttempts?: number;
|
|
25
|
-
initialDelayMs?: number;
|
|
26
|
-
maxDelayMs?: number;
|
|
27
|
-
};
|
|
28
|
-
//#endregion
|
|
29
|
-
//#region src/plugins/types.d.ts
|
|
30
|
-
type PluginDiagnostic = {
|
|
31
|
-
level: "warn" | "error";
|
|
32
|
-
message: string;
|
|
33
|
-
pluginId?: string;
|
|
34
|
-
source?: string;
|
|
35
|
-
};
|
|
36
|
-
type PluginOrigin = "bundled" | "global" | "workspace" | "config";
|
|
37
|
-
type PluginKind = "memory";
|
|
38
|
-
type PluginConfigUiHint = {
|
|
39
|
-
label?: string;
|
|
40
|
-
help?: string;
|
|
41
|
-
tags?: string[];
|
|
42
|
-
advanced?: boolean;
|
|
43
|
-
sensitive?: boolean;
|
|
44
|
-
placeholder?: string;
|
|
45
|
-
};
|
|
46
|
-
type PluginManifest = {
|
|
47
|
-
id: string;
|
|
48
|
-
configSchema: Record<string, unknown>;
|
|
49
|
-
kind?: PluginKind;
|
|
50
|
-
skills?: string[];
|
|
51
|
-
name?: string;
|
|
52
|
-
description?: string;
|
|
53
|
-
version?: string;
|
|
54
|
-
uiHints?: Record<string, PluginConfigUiHint>;
|
|
55
|
-
};
|
|
56
|
-
type PluginManifestLoadResult = {
|
|
57
|
-
ok: true;
|
|
58
|
-
manifest: PluginManifest;
|
|
59
|
-
manifestPath: string;
|
|
60
|
-
} | {
|
|
61
|
-
ok: false;
|
|
62
|
-
error: string;
|
|
63
|
-
manifestPath: string;
|
|
64
|
-
};
|
|
65
|
-
type PluginCandidate = {
|
|
66
|
-
idHint: string;
|
|
67
|
-
source: string;
|
|
68
|
-
rootDir: string;
|
|
69
|
-
origin: PluginOrigin;
|
|
70
|
-
workspaceDir?: string;
|
|
71
|
-
packageName?: string;
|
|
72
|
-
packageVersion?: string;
|
|
73
|
-
packageDescription?: string;
|
|
74
|
-
packageDir?: string;
|
|
75
|
-
packageManifest?: AIMaxPackageManifest;
|
|
76
|
-
};
|
|
77
|
-
type AIMaxPackageManifest = {
|
|
78
|
-
extensions?: string[];
|
|
79
|
-
};
|
|
80
|
-
type PluginDiscoveryResult = {
|
|
81
|
-
candidates: PluginCandidate[];
|
|
82
|
-
diagnostics: PluginDiagnostic[];
|
|
83
|
-
};
|
|
84
|
-
//#endregion
|
|
85
|
-
//#region src/plugins/manifest-registry.d.ts
|
|
86
|
-
type PluginManifestRecord = {
|
|
87
|
-
id: string;
|
|
88
|
-
rootDir: string;
|
|
89
|
-
source: string;
|
|
90
|
-
origin: PluginCandidate["origin"];
|
|
91
|
-
manifestPath: string;
|
|
92
|
-
manifest: PluginManifest;
|
|
93
|
-
};
|
|
94
|
-
type PluginManifestRegistry = {
|
|
95
|
-
manifests: Map<string, PluginManifestRecord>;
|
|
96
|
-
diagnostics: PluginDiagnostic[];
|
|
97
|
-
};
|
|
98
|
-
declare function loadPluginManifestRegistry(candidates: PluginCandidate[]): PluginManifestRegistry;
|
|
99
|
-
//#endregion
|
|
100
|
-
//#region src/plugins/config-state.d.ts
|
|
101
|
-
type PluginEntryConfig = {
|
|
102
|
-
enabled?: boolean;
|
|
103
|
-
config?: Record<string, unknown>;
|
|
104
|
-
};
|
|
105
|
-
type PluginsConfig = {
|
|
106
|
-
enabled?: boolean;
|
|
107
|
-
allow?: string[];
|
|
108
|
-
deny?: string[];
|
|
109
|
-
llmAllowlist?: string[];
|
|
110
|
-
load?: {
|
|
111
|
-
paths?: string[];
|
|
112
|
-
};
|
|
113
|
-
entries?: Record<string, PluginEntryConfig>;
|
|
114
|
-
slots?: Partial<Record<PluginKind, string>>;
|
|
115
|
-
};
|
|
116
|
-
type NormalizedPluginsConfig = {
|
|
117
|
-
enabled: boolean;
|
|
118
|
-
allow: string[];
|
|
119
|
-
deny: string[];
|
|
120
|
-
loadPaths: string[];
|
|
121
|
-
entries: Record<string, PluginEntryConfig>;
|
|
122
|
-
slots: Partial<Record<PluginKind, string>>;
|
|
123
|
-
};
|
|
124
|
-
type PluginsConfigValidationResult = {
|
|
125
|
-
ok: boolean;
|
|
126
|
-
diagnostics: PluginDiagnostic[];
|
|
127
|
-
};
|
|
128
|
-
declare function normalizePluginsConfig(input?: PluginsConfig): NormalizedPluginsConfig;
|
|
129
|
-
declare function validatePluginsConfig(params: {
|
|
130
|
-
config: NormalizedPluginsConfig;
|
|
131
|
-
registry: PluginManifestRegistry;
|
|
132
|
-
}): PluginsConfigValidationResult;
|
|
133
|
-
//#endregion
|
|
134
21
|
//#region src/memory/config.d.ts
|
|
135
22
|
type MemorySearchConfig = {
|
|
136
23
|
chunkTokens: number;
|
|
@@ -377,97 +264,310 @@ type MemoryProvider = {
|
|
|
377
264
|
};
|
|
378
265
|
type MemoryProviderFactory = (ctx: MemoryProviderContext) => MemoryProvider;
|
|
379
266
|
//#endregion
|
|
380
|
-
//#region src/
|
|
381
|
-
|
|
382
|
-
type
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
* sub-subagents (depth ≥ 2) inside their parent subagent's own directory.
|
|
392
|
-
*/
|
|
393
|
-
parentDir?: string;
|
|
267
|
+
//#region src/plugins/hooks.d.ts
|
|
268
|
+
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";
|
|
269
|
+
type PluginHookAgentContext = {
|
|
270
|
+
agentId?: string;
|
|
271
|
+
sessionId?: string;
|
|
272
|
+
workspaceDir?: string;
|
|
273
|
+
channel?: AgentRunParams["channel"];
|
|
274
|
+
};
|
|
275
|
+
type PluginExecutionRuntime = {
|
|
276
|
+
eventDispatcher: {
|
|
277
|
+
dispatchProgress: (sessionId: string, event: AgentProgressEvent$1) => Promise<void>;
|
|
394
278
|
};
|
|
395
279
|
};
|
|
396
|
-
type
|
|
397
|
-
|
|
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;
|
|
280
|
+
type PluginHookBeforeModelResolveEvent = {
|
|
281
|
+
prompt: string;
|
|
409
282
|
};
|
|
410
|
-
type
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
283
|
+
type PluginHookBeforeModelResolveResult = {
|
|
284
|
+
modelOverride?: string;
|
|
285
|
+
};
|
|
286
|
+
type PluginHookBeforePromptBuildEvent = {
|
|
287
|
+
prompt: string;
|
|
288
|
+
};
|
|
289
|
+
type PluginHookBeforePromptBuildResult = {
|
|
290
|
+
systemPrompt?: string;
|
|
291
|
+
prependContext?: string;
|
|
292
|
+
};
|
|
293
|
+
type PluginHookAfterPromptBuildEvent = {
|
|
294
|
+
prompt: string;
|
|
295
|
+
systemPrompt: string;
|
|
296
|
+
};
|
|
297
|
+
type PluginHookLlmInputEvent = {
|
|
298
|
+
sessionId: string;
|
|
299
|
+
model: string;
|
|
300
|
+
prompt: string;
|
|
301
|
+
historyMessages: unknown[];
|
|
302
|
+
};
|
|
303
|
+
type PluginHookAssistantMessageEndEvent = {
|
|
304
|
+
sessionId: string;
|
|
305
|
+
model: string;
|
|
306
|
+
assistantText: string;
|
|
307
|
+
assistantMessage: AssistantMessage;
|
|
308
|
+
hasToolCalls: boolean;
|
|
309
|
+
durationMs?: number;
|
|
310
|
+
usage?: {
|
|
311
|
+
input?: number;
|
|
312
|
+
output?: number;
|
|
313
|
+
total?: number;
|
|
421
314
|
};
|
|
422
315
|
};
|
|
423
|
-
type
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
316
|
+
type PluginHookLlmOutputEvent = {
|
|
317
|
+
sessionId: string;
|
|
318
|
+
model: string;
|
|
319
|
+
assistantTexts: string[];
|
|
320
|
+
lastAssistant?: AssistantMessage;
|
|
321
|
+
durationMs?: number;
|
|
322
|
+
usage?: {
|
|
323
|
+
input?: number;
|
|
324
|
+
output?: number;
|
|
325
|
+
total?: number;
|
|
326
|
+
};
|
|
429
327
|
};
|
|
430
|
-
|
|
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;
|
|
328
|
+
type PluginHookBeforeToolCallEvent = {
|
|
439
329
|
toolCallId: string;
|
|
440
|
-
toolName: string;
|
|
441
|
-
|
|
442
|
-
sessionId: string;
|
|
330
|
+
toolName: string;
|
|
331
|
+
params: Record<string, unknown>;
|
|
443
332
|
};
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
truncated: boolean;
|
|
449
|
-
originalChars: number;
|
|
333
|
+
type PluginHookBeforeToolCallResult = {
|
|
334
|
+
params?: Record<string, unknown>;
|
|
335
|
+
block?: boolean;
|
|
336
|
+
blockReason?: string;
|
|
450
337
|
};
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
338
|
+
type PluginHookAfterToolCallEvent = {
|
|
339
|
+
toolCallId: string;
|
|
340
|
+
toolName: string;
|
|
341
|
+
params: Record<string, unknown>;
|
|
342
|
+
result?: unknown;
|
|
343
|
+
error?: string;
|
|
344
|
+
durationMs?: number;
|
|
345
|
+
};
|
|
346
|
+
type PluginHookAgentEndEvent = {
|
|
347
|
+
success: boolean;
|
|
348
|
+
error?: string;
|
|
349
|
+
durationMs?: number;
|
|
350
|
+
};
|
|
351
|
+
type PluginHookBeforeCompactionEvent = {
|
|
352
|
+
messageCount: number;
|
|
353
|
+
compactingCount?: number;
|
|
354
|
+
};
|
|
355
|
+
type PluginHookBeforeCompactionResult = {
|
|
356
|
+
skipPersist?: boolean;
|
|
357
|
+
injectRecall?: string;
|
|
358
|
+
};
|
|
359
|
+
type PluginHookAfterCompactionEvent = {
|
|
360
|
+
messageCount: number;
|
|
361
|
+
compactedCount: number;
|
|
362
|
+
};
|
|
363
|
+
type PluginHookSessionStartEvent = {
|
|
364
|
+
sessionId: string;
|
|
365
|
+
};
|
|
366
|
+
type PluginHookSessionEndEvent = {
|
|
367
|
+
sessionId: string;
|
|
368
|
+
messageCount: number;
|
|
369
|
+
durationMs?: number;
|
|
370
|
+
};
|
|
371
|
+
type PluginHookSessionResetEvent = {
|
|
372
|
+
action: "new" | "reset";
|
|
373
|
+
sessionId: string;
|
|
374
|
+
previousSessionId?: string;
|
|
375
|
+
message: string;
|
|
376
|
+
};
|
|
377
|
+
type PluginHookDreamGateEvent = {
|
|
378
|
+
dataDir: string;
|
|
379
|
+
memoryDir: string;
|
|
380
|
+
providerId: string;
|
|
381
|
+
pluginId?: string;
|
|
382
|
+
trigger: "cli" | "cron";
|
|
383
|
+
dryRun?: boolean;
|
|
384
|
+
};
|
|
385
|
+
type PluginHookDreamGateResult = {
|
|
386
|
+
handled?: boolean;
|
|
387
|
+
status?: "noop" | "completed" | "queued" | "failed";
|
|
388
|
+
summary?: string;
|
|
389
|
+
details?: Record<string, unknown>;
|
|
390
|
+
};
|
|
391
|
+
type PluginHookMemoryChangedEvent = MemoryChangedEvent;
|
|
392
|
+
type PluginHookHandlerMap = {
|
|
393
|
+
before_model_resolve: (event: PluginHookBeforeModelResolveEvent, ctx: PluginHookAgentContext) => PluginHookBeforeModelResolveResult | void | Promise<PluginHookBeforeModelResolveResult | void>;
|
|
394
|
+
before_prompt_build: (event: PluginHookBeforePromptBuildEvent, ctx: PluginHookAgentContext) => PluginHookBeforePromptBuildResult | void | Promise<PluginHookBeforePromptBuildResult | void>;
|
|
395
|
+
after_prompt_build: (event: PluginHookAfterPromptBuildEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
|
|
396
|
+
llm_input: (event: PluginHookLlmInputEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
|
|
397
|
+
assistant_message_end: (event: PluginHookAssistantMessageEndEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
|
|
398
|
+
llm_output: (event: PluginHookLlmOutputEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
|
|
399
|
+
before_tool_call: (event: PluginHookBeforeToolCallEvent, ctx: PluginHookAgentContext) => PluginHookBeforeToolCallResult | void | Promise<PluginHookBeforeToolCallResult | void>;
|
|
400
|
+
after_tool_call: (event: PluginHookAfterToolCallEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
|
|
401
|
+
agent_end: (event: PluginHookAgentEndEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
|
|
402
|
+
before_compaction: (event: PluginHookBeforeCompactionEvent, ctx: PluginHookAgentContext) => PluginHookBeforeCompactionResult | void | Promise<PluginHookBeforeCompactionResult | void>;
|
|
403
|
+
after_compaction: (event: PluginHookAfterCompactionEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
|
|
404
|
+
session_start: (event: PluginHookSessionStartEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
|
|
405
|
+
session_end: (event: PluginHookSessionEndEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
|
|
406
|
+
session_reset: (event: PluginHookSessionResetEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
|
|
407
|
+
dream_gate: (event: PluginHookDreamGateEvent, ctx: PluginHookAgentContext) => PluginHookDreamGateResult | void | Promise<PluginHookDreamGateResult | void>;
|
|
408
|
+
memory_changed: (event: PluginHookMemoryChangedEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
|
|
409
|
+
};
|
|
410
|
+
type PluginHookRegistration<K extends PluginHookName = PluginHookName> = {
|
|
411
|
+
pluginId: string;
|
|
412
|
+
hookName: K;
|
|
413
|
+
handler: PluginHookHandlerMap[K];
|
|
414
|
+
priority?: number;
|
|
415
|
+
source: string;
|
|
416
|
+
};
|
|
417
|
+
declare class PluginHookRegistry {
|
|
418
|
+
private readonly hooks;
|
|
419
|
+
register<K extends PluginHookName>(registration: PluginHookRegistration<K>): void;
|
|
420
|
+
dispatch<K extends PluginHookName>(hookName: K, event: Parameters<PluginHookHandlerMap[K]>[0], ctx: Parameters<PluginHookHandlerMap[K]>[1], runtime?: PluginExecutionRuntime): Promise<Array<Awaited<ReturnType<PluginHookHandlerMap[K]>>>>;
|
|
421
|
+
}
|
|
422
|
+
//#endregion
|
|
423
|
+
//#region src/runner/event-dispatcher.d.ts
|
|
424
|
+
type EventDispatchParams = Pick<AgentRunParams, "onProgress" | "messageId" | "channel" | "subagentContext">;
|
|
425
|
+
/**
|
|
426
|
+
* Emits runner events to in-process listeners.
|
|
427
|
+
*/
|
|
428
|
+
declare class RunEventDispatcher {
|
|
429
|
+
private readonly params;
|
|
430
|
+
constructor(params: EventDispatchParams);
|
|
431
|
+
dispatchProgress(sessionId: string, event: AgentProgressEvent$2): Promise<void>;
|
|
432
|
+
dispatchDiagnostic(sessionId: string, event: Omit<AgentDiagnosticEvent, keyof AgentProgressEventBase | "type">): Promise<void>;
|
|
433
|
+
}
|
|
434
|
+
//#endregion
|
|
435
|
+
//#region src/runner/turn/retry.d.ts
|
|
436
|
+
type LlmTurnRetryConfig = {
|
|
437
|
+
enabled?: boolean;
|
|
438
|
+
maxAttempts?: number;
|
|
439
|
+
initialDelayMs?: number;
|
|
440
|
+
maxDelayMs?: number;
|
|
441
|
+
};
|
|
442
|
+
//#endregion
|
|
443
|
+
//#region src/bootstrap/bootstrap.d.ts
|
|
444
|
+
/** Maximum characters per bootstrap file before truncation */
|
|
445
|
+
declare const BOOTSTRAP_MAX_CHARS = 20000;
|
|
446
|
+
/** Maximum total characters across all bootstrap files */
|
|
447
|
+
declare const BOOTSTRAP_TOTAL_MAX_CHARS = 150000;
|
|
448
|
+
/** Names of bootstrap identity files, in injection order */
|
|
449
|
+
declare const BOOTSTRAP_FILE_NAMES: readonly ["AGENTS.md", "SOUL.md", "TOOLS.md", "IDENTITY.md", "USER.md", "MEMORY.md", "BOOTSTRAP.md"];
|
|
450
|
+
/** A loaded (or missing) bootstrap file */
|
|
451
|
+
type BootstrapFile = {
|
|
452
|
+
name: string;
|
|
453
|
+
path: string;
|
|
454
|
+
content: string | null;
|
|
455
|
+
missing: boolean;
|
|
456
|
+
};
|
|
457
|
+
/** A bootstrap file ready for system prompt injection */
|
|
458
|
+
type BootstrapContextFile = {
|
|
459
|
+
path: string;
|
|
460
|
+
content: string;
|
|
461
|
+
};
|
|
462
|
+
/** Resolves the base .aimax directory within a data directory */
|
|
463
|
+
declare function aimaxDir(dataDir: string): string;
|
|
464
|
+
/**
|
|
465
|
+
* Loads all standard bootstrap identity files from the .aimax directory.
|
|
466
|
+
* Missing files are included as `missing: true` entries.
|
|
467
|
+
* BOOTSTRAP.md is deleted after loading (one-time use).
|
|
468
|
+
*/
|
|
469
|
+
declare function loadBootstrapFiles(dataDir: string): Promise<BootstrapFile[]>;
|
|
470
|
+
/**
|
|
471
|
+
* Converts loaded bootstrap files into context file entries for system prompt injection.
|
|
472
|
+
* Applies per-file and total character budget limits.
|
|
473
|
+
*/
|
|
474
|
+
declare function buildBootstrapContextFiles(files: BootstrapFile[], opts?: {
|
|
475
|
+
maxChars?: number;
|
|
476
|
+
totalMaxChars?: number;
|
|
477
|
+
warn?: (message: string) => void;
|
|
478
|
+
}): BootstrapContextFile[];
|
|
479
|
+
//#endregion
|
|
480
|
+
//#region src/session/session.d.ts
|
|
481
|
+
declare const DEFAULT_SESSION_STORE_NAME = "sessions";
|
|
482
|
+
type SessionPathOptions = {
|
|
483
|
+
storeName?: string; /** Whether session data should be encrypted at rest. */
|
|
484
|
+
encryptSessions?: boolean;
|
|
485
|
+
subagent?: {
|
|
486
|
+
parentSessionId: string;
|
|
487
|
+
/**
|
|
488
|
+
* Absolute filesystem path of the parent session's directory.
|
|
489
|
+
* When set, the child path is resolved as `path.join(parentDir, "subagents", childSessionId)`
|
|
490
|
+
* rather than anchoring at `sessionsDir`. This is required for correctly nesting
|
|
491
|
+
* sub-subagents (depth ≥ 2) inside their parent subagent's own directory.
|
|
492
|
+
*/
|
|
493
|
+
parentDir?: string;
|
|
494
|
+
};
|
|
495
|
+
};
|
|
496
|
+
type SessionInspection = {
|
|
497
|
+
id: string;
|
|
498
|
+
metadata: SessionMetadata$1 | null;
|
|
499
|
+
transcriptPath: string;
|
|
500
|
+
contextSnapshotPath: string;
|
|
501
|
+
sessionMemoryPath: string;
|
|
502
|
+
collapseLogPath: string;
|
|
503
|
+
toolResultsDir: string;
|
|
504
|
+
transcriptEntryCount: number;
|
|
505
|
+
readStateCount: number;
|
|
506
|
+
toolResultRefCount: number;
|
|
507
|
+
transcriptEntries: TranscriptEntry[];
|
|
508
|
+
context: SessionContextSnapshot;
|
|
509
|
+
};
|
|
510
|
+
type SessionExport = {
|
|
511
|
+
id: string;
|
|
512
|
+
metadata: SessionMetadata$1 | null;
|
|
513
|
+
transcript: TranscriptEntry[];
|
|
514
|
+
context: SessionContextSnapshot;
|
|
515
|
+
paths: {
|
|
516
|
+
transcriptPath: string;
|
|
517
|
+
contextSnapshotPath: string;
|
|
518
|
+
sessionMemoryPath: string;
|
|
519
|
+
collapseLogPath: string;
|
|
520
|
+
toolResultsDir: string;
|
|
521
|
+
};
|
|
522
|
+
};
|
|
523
|
+
type CronExecutionRecord = {
|
|
524
|
+
task: string;
|
|
525
|
+
status: "done" | "error" | "killed";
|
|
526
|
+
content: string;
|
|
527
|
+
childSessionId?: string;
|
|
528
|
+
createdAt: string;
|
|
529
|
+
};
|
|
530
|
+
declare const MAX_ARTIFACT_CONTENT_CHARS = 2000;
|
|
531
|
+
type ArtifactOperationType = "write" | "edit" | "delete" | "move";
|
|
532
|
+
type ArtifactOperationName = "write_file" | "edit_file" | "patch_add" | "patch_update" | "patch_delete" | "patch_move";
|
|
533
|
+
type ArtifactOperationInput = {
|
|
534
|
+
type: ArtifactOperationType;
|
|
535
|
+
operation: ArtifactOperationName;
|
|
536
|
+
file: string;
|
|
537
|
+
sourceFile?: string;
|
|
538
|
+
content: string;
|
|
539
|
+
toolCallId: string;
|
|
540
|
+
toolName: string; /** Whether this operation was performed by the agent itself or a subagent */
|
|
541
|
+
source: "agent" | "subagent"; /** The session that actually performed this operation */
|
|
542
|
+
sessionId: string;
|
|
543
|
+
};
|
|
544
|
+
/** Operation shape that tool implementations provide before the recorder enriches it with source/sessionId. */
|
|
545
|
+
type ArtifactOpInput = Omit<ArtifactOperationInput, "source" | "sessionId">;
|
|
546
|
+
type ArtifactOperation = ArtifactOperationInput & {
|
|
547
|
+
timestamp: string;
|
|
548
|
+
truncated: boolean;
|
|
549
|
+
originalChars: number;
|
|
550
|
+
};
|
|
551
|
+
/** Resolves the sessions directory path within a data directory */
|
|
552
|
+
declare function normalizeSessionStoreName(storeName?: string): string;
|
|
553
|
+
/** Resolves the sessions directory path within a data directory */
|
|
554
|
+
declare function sessionsDir(dataDir: string, options?: SessionPathOptions): string;
|
|
555
|
+
/** Resolves the directory for a specific session */
|
|
556
|
+
declare function sessionDir(dataDir: string, sessionId: string, options?: SessionPathOptions): string;
|
|
557
|
+
/** Resolves the transcript file path for a session */
|
|
558
|
+
declare function transcriptPath(dataDir: string, sessionId: string, options?: SessionPathOptions): string;
|
|
559
|
+
/** Resolves the artifact operation log path for a session */
|
|
560
|
+
declare function artifactsPath(dataDir: string, sessionId: string, options?: SessionPathOptions): string;
|
|
561
|
+
/** Resolves the metadata file path for a session */
|
|
562
|
+
declare function metadataPath(dataDir: string, sessionId: string, options?: SessionPathOptions): string;
|
|
563
|
+
/** Resolves the persisted context snapshot path for a session */
|
|
564
|
+
declare function contextSnapshotPath(dataDir: string, sessionId: string, options?: SessionPathOptions): string;
|
|
565
|
+
declare function sessionMemoryPath(dataDir: string, sessionId: string, options?: SessionPathOptions): string;
|
|
566
|
+
declare function collapseLogPath(dataDir: string, sessionId: string, options?: SessionPathOptions): string;
|
|
567
|
+
/** Resolves the persisted tool-results directory for a session */
|
|
568
|
+
declare function toolResultsDir(dataDir: string, sessionId: string, options?: SessionPathOptions): string;
|
|
569
|
+
declare function cronExecutionsPath(dataDir: string, sessionId: string, options?: SessionPathOptions): string;
|
|
570
|
+
/** Creates a new session with a generated ID */
|
|
471
571
|
declare function createSession(dataDir: string, channel: Channel, options?: SessionPathOptions & {
|
|
472
572
|
sessionId?: string;
|
|
473
573
|
}): Promise<string>;
|
|
@@ -511,6 +611,7 @@ type LlmApiFormat = "openai-completions" | "anthropic-messages";
|
|
|
511
611
|
//#region src/history/topic-segmentation.d.ts
|
|
512
612
|
type TopicSegmentationConfig = {
|
|
513
613
|
enabled?: boolean;
|
|
614
|
+
embeddingModelDir?: string;
|
|
514
615
|
minUserTurns?: number;
|
|
515
616
|
minEstimatedTokens?: number;
|
|
516
617
|
recentProtectedTurnCount?: number;
|
|
@@ -524,29 +625,141 @@ type TopicSegmentationConfig = {
|
|
|
524
625
|
maxTokens?: number;
|
|
525
626
|
};
|
|
526
627
|
//#endregion
|
|
527
|
-
//#region src/
|
|
528
|
-
|
|
529
|
-
declare function skillsDir(dataDir: string): string;
|
|
530
|
-
/** Represents a loaded skill */
|
|
531
|
-
type Skill = {
|
|
532
|
-
name: string;
|
|
533
|
-
description: string;
|
|
534
|
-
location: string;
|
|
535
|
-
version: string;
|
|
536
|
-
skillFileMtime: string;
|
|
537
|
-
};
|
|
538
|
-
type SkillDirectory = {
|
|
539
|
-
skill: Skill;
|
|
540
|
-
rootDir: string;
|
|
541
|
-
};
|
|
542
|
-
type SkillViewResult = {
|
|
543
|
-
skill: Skill;
|
|
628
|
+
//#region src/context/session-context-store.d.ts
|
|
629
|
+
type PersistedToolResult = {
|
|
544
630
|
content: string;
|
|
631
|
+
reference?: ToolResultReference;
|
|
545
632
|
};
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
633
|
+
type SessionContextStore = {
|
|
634
|
+
findReusableRead(path: string, offset?: number, limit?: number): Promise<ReadStateRecord | null>;
|
|
635
|
+
recordRead(params: {
|
|
636
|
+
path: string;
|
|
637
|
+
content: string;
|
|
638
|
+
lineCount: number;
|
|
639
|
+
offset?: number;
|
|
640
|
+
limit?: number;
|
|
641
|
+
}): Promise<ReadStateRecord>;
|
|
642
|
+
invalidatePath(path: string): Promise<void>;
|
|
643
|
+
persistToolResult(params: {
|
|
644
|
+
toolCallId: string;
|
|
645
|
+
toolName: string;
|
|
646
|
+
content: string;
|
|
647
|
+
thresholdChars?: number;
|
|
648
|
+
previewChars?: number;
|
|
649
|
+
}): Promise<PersistedToolResult>;
|
|
650
|
+
recordSnip(record: SnipRecord): Promise<void>;
|
|
651
|
+
recordCollapse(span: CollapseSpan): Promise<void>;
|
|
652
|
+
setSessionMemory(snapshot: SessionMemorySnapshot): Promise<void>;
|
|
653
|
+
recordModelUsage(checkpoint: ModelUsageCheckpoint): Promise<void>;
|
|
654
|
+
recordAutocompactResult(params: {
|
|
655
|
+
layer: "L6";
|
|
656
|
+
failed: boolean;
|
|
657
|
+
timestamp: string;
|
|
658
|
+
}): Promise<void>;
|
|
659
|
+
getSnapshot(): SessionContextSnapshot;
|
|
660
|
+
};
|
|
661
|
+
type SessionContextStoreOptions = {
|
|
662
|
+
dataDir: string;
|
|
663
|
+
sessionId: string;
|
|
664
|
+
} & SessionPathOptions;
|
|
665
|
+
declare function createSessionContextStore(options: SessionContextStoreOptions): Promise<SessionContextStore>;
|
|
666
|
+
//#endregion
|
|
667
|
+
//#region src/context/context-manager.d.ts
|
|
668
|
+
type ManageLayeredHistoryParams = {
|
|
669
|
+
entries: TranscriptEntry[];
|
|
670
|
+
modelInfo: {
|
|
671
|
+
model: string;
|
|
672
|
+
api: string;
|
|
673
|
+
};
|
|
674
|
+
contextWindowTokens: number;
|
|
675
|
+
llm: Pick<AgentRunParams["llm"], "apiFormat" | "baseUrl" | "apiKey" | "model" | "flashModel">;
|
|
676
|
+
historyLimit?: number;
|
|
677
|
+
compactionEnabled?: boolean;
|
|
678
|
+
pendingUserMessage?: string;
|
|
679
|
+
topicSegmentation?: TopicSegmentationConfig;
|
|
680
|
+
signal?: AbortSignal;
|
|
681
|
+
hooks?: PluginHookRegistry;
|
|
682
|
+
hookCtx?: PluginHookAgentContext;
|
|
683
|
+
contextStore?: SessionContextStore;
|
|
684
|
+
dataDir?: string;
|
|
685
|
+
sessionId?: string;
|
|
686
|
+
sessionStoreName?: string;
|
|
687
|
+
sessionPathScope?: Pick<SessionPathOptions, "subagent">;
|
|
688
|
+
channel?: Channel$1;
|
|
689
|
+
isSubagent?: boolean;
|
|
690
|
+
};
|
|
691
|
+
type ManageLayeredHistoryResult = {
|
|
692
|
+
messages: AgentMessage[];
|
|
693
|
+
priorSummary: string | undefined;
|
|
694
|
+
compactionEntry: CompactionEntry | undefined;
|
|
695
|
+
stats: {
|
|
696
|
+
originalCount: number;
|
|
697
|
+
keptCount: number;
|
|
698
|
+
estimatedTokens: number;
|
|
699
|
+
compacted: boolean;
|
|
700
|
+
};
|
|
701
|
+
compactionEvents: AgentProgressEvent$1[];
|
|
702
|
+
};
|
|
703
|
+
type ContextManager = {
|
|
704
|
+
getReusableRead(path: string, offset?: number, limit?: number): Promise<{
|
|
705
|
+
reused: boolean;
|
|
706
|
+
lineCount?: number;
|
|
707
|
+
}>;
|
|
708
|
+
rememberRead(params: {
|
|
709
|
+
path: string;
|
|
710
|
+
content: string;
|
|
711
|
+
lineCount: number;
|
|
712
|
+
offset?: number;
|
|
713
|
+
limit?: number;
|
|
714
|
+
}): Promise<void>;
|
|
715
|
+
invalidateReadPath(path: string): Promise<void>;
|
|
716
|
+
persistToolResult(params: {
|
|
717
|
+
toolCallId: string;
|
|
718
|
+
toolName: string;
|
|
719
|
+
content: string;
|
|
720
|
+
thresholdChars?: number;
|
|
721
|
+
previewChars?: number;
|
|
722
|
+
}): Promise<PersistedToolResult>;
|
|
723
|
+
recordModelUsage(params: {
|
|
724
|
+
model: string;
|
|
725
|
+
inputTokens: number;
|
|
726
|
+
outputTokens: number;
|
|
727
|
+
totalTokens: number;
|
|
728
|
+
coveredTranscriptEntryCount: number;
|
|
729
|
+
}): Promise<void>;
|
|
730
|
+
manageHistory(params: Omit<ManageLayeredHistoryParams, "contextStore">): Promise<ManageLayeredHistoryResult>;
|
|
731
|
+
getSnapshot: SessionContextStore["getSnapshot"];
|
|
732
|
+
};
|
|
733
|
+
declare function createContextManager(params: {
|
|
734
|
+
dataDir: string;
|
|
735
|
+
sessionId: string;
|
|
736
|
+
sessionStoreName?: string;
|
|
737
|
+
sessionPathScope?: Pick<SessionPathOptions, "subagent">;
|
|
738
|
+
}): Promise<ContextManager>;
|
|
739
|
+
//#endregion
|
|
740
|
+
//#region src/skills/skills.d.ts
|
|
741
|
+
/** Resolves the skills directory path within a data directory */
|
|
742
|
+
declare function skillsDir(dataDir: string): string;
|
|
743
|
+
/** Represents a loaded skill */
|
|
744
|
+
type Skill = {
|
|
745
|
+
name: string;
|
|
746
|
+
description: string;
|
|
747
|
+
location: string;
|
|
748
|
+
version: string;
|
|
749
|
+
skillFileMtime: string;
|
|
750
|
+
};
|
|
751
|
+
type SkillDirectory = {
|
|
752
|
+
skill: Skill;
|
|
753
|
+
rootDir: string;
|
|
754
|
+
};
|
|
755
|
+
type SkillViewResult = {
|
|
756
|
+
skill: Skill;
|
|
757
|
+
content: string;
|
|
758
|
+
};
|
|
759
|
+
/**
|
|
760
|
+
* Loads all installed skills from the skills directory.
|
|
761
|
+
* Each skill is a directory containing a SKILL.md file.
|
|
762
|
+
* Returns at most MAX_SKILLS_IN_PROMPT skills.
|
|
550
763
|
*/
|
|
551
764
|
declare function loadSkills(dataDir: string): Promise<Skill[]>;
|
|
552
765
|
declare function loadSkillsWithPluginDirs(dataDir: string, pluginDirs: string[], skillsLoadPaths?: string[]): Promise<Skill[]>;
|
|
@@ -560,6 +773,258 @@ declare function loadSkillView(dirs: string[], requestedName: string, skillPath?
|
|
|
560
773
|
*/
|
|
561
774
|
declare function buildSkillsPrompt(skills: Skill[]): string;
|
|
562
775
|
//#endregion
|
|
776
|
+
//#region src/auto-skills/types.d.ts
|
|
777
|
+
type AutoSkillSource = "auto";
|
|
778
|
+
type AutoSkillStatus = "active" | "archived";
|
|
779
|
+
type AutoSkillCategory = {
|
|
780
|
+
path: string;
|
|
781
|
+
name: string;
|
|
782
|
+
description: string;
|
|
783
|
+
createdBy?: string;
|
|
784
|
+
};
|
|
785
|
+
type AutoSkillIndexEntry = {
|
|
786
|
+
skillId: string;
|
|
787
|
+
name: string;
|
|
788
|
+
description: string;
|
|
789
|
+
categoryPath: string;
|
|
790
|
+
source: AutoSkillSource;
|
|
791
|
+
status: AutoSkillStatus;
|
|
792
|
+
rootDir: string;
|
|
793
|
+
skillDir: string;
|
|
794
|
+
skillFile: string;
|
|
795
|
+
metadataFile?: string;
|
|
796
|
+
tags: string[];
|
|
797
|
+
relatedSkills: string[];
|
|
798
|
+
confidence?: number;
|
|
799
|
+
createdAt?: string;
|
|
800
|
+
updatedAt?: string;
|
|
801
|
+
};
|
|
802
|
+
type AutoSkillListItem = {
|
|
803
|
+
skillId: string;
|
|
804
|
+
name: string;
|
|
805
|
+
description: string;
|
|
806
|
+
categoryPath: string;
|
|
807
|
+
source: AutoSkillSource;
|
|
808
|
+
};
|
|
809
|
+
type AutoSkillSearchResult = AutoSkillListItem & {
|
|
810
|
+
score: number;
|
|
811
|
+
};
|
|
812
|
+
type AutoSkillViewResult = AutoSkillListItem & {
|
|
813
|
+
status: AutoSkillStatus;
|
|
814
|
+
content: string;
|
|
815
|
+
path: string;
|
|
816
|
+
skillDir: string;
|
|
817
|
+
filePath?: string;
|
|
818
|
+
tags?: string[];
|
|
819
|
+
relatedSkills?: string[];
|
|
820
|
+
};
|
|
821
|
+
type AutoSkillsLoaderOptions = {
|
|
822
|
+
dataDir?: string;
|
|
823
|
+
rootDir?: string;
|
|
824
|
+
includeArchived?: boolean;
|
|
825
|
+
maxSkillBytes?: number;
|
|
826
|
+
maxResourceBytes?: number;
|
|
827
|
+
};
|
|
828
|
+
type AutoSkillListOptions = {
|
|
829
|
+
categoryPath?: string;
|
|
830
|
+
recursive?: boolean;
|
|
831
|
+
};
|
|
832
|
+
type AutoSkillSearchOptions = {
|
|
833
|
+
query: string;
|
|
834
|
+
limit?: number;
|
|
835
|
+
};
|
|
836
|
+
type AutoSkillViewOptions = {
|
|
837
|
+
skillId: string;
|
|
838
|
+
filePath?: string;
|
|
839
|
+
};
|
|
840
|
+
//#endregion
|
|
841
|
+
//#region src/subagent/types.d.ts
|
|
842
|
+
/** Status of a spawned subagent run */
|
|
843
|
+
type SubagentStatus = "running" | "done" | "error" | "killed";
|
|
844
|
+
/** Record tracking a single subagent run */
|
|
845
|
+
type SubagentRunRecord = {
|
|
846
|
+
runId: string;
|
|
847
|
+
childSessionId: string;
|
|
848
|
+
parentSessionId: string;
|
|
849
|
+
task: string;
|
|
850
|
+
label?: string; /** Nesting depth: parent is depth N, child is N+1 */
|
|
851
|
+
depth: number;
|
|
852
|
+
status: SubagentStatus;
|
|
853
|
+
result?: string;
|
|
854
|
+
error?: string;
|
|
855
|
+
startedAt: number;
|
|
856
|
+
endedAt?: number; /** Used to cancel the subagent run */
|
|
857
|
+
abortController: AbortController;
|
|
858
|
+
};
|
|
859
|
+
//#endregion
|
|
860
|
+
//#region src/subagent/registry.d.ts
|
|
861
|
+
declare const MAX_SUBAGENT_DEPTH = 2;
|
|
862
|
+
declare const MAX_CHILDREN_PER_SESSION = 5;
|
|
863
|
+
/**
|
|
864
|
+
* In-memory registry for subagent runs scoped to a single parent runAgent call.
|
|
865
|
+
* Child spawns create their own SubagentRegistry instances for their children.
|
|
866
|
+
*/
|
|
867
|
+
declare class SubagentRegistry {
|
|
868
|
+
private readonly entries;
|
|
869
|
+
/** RunIds whose terminal result has already been delivered to the parent. */
|
|
870
|
+
private readonly announced;
|
|
871
|
+
register(record: SubagentRunRecord, promise: Promise<void>): void;
|
|
872
|
+
complete(runId: string, result: string): void;
|
|
873
|
+
fail(runId: string, error: string): void;
|
|
874
|
+
/** Aborts and marks a specific run as killed. Returns false if not found or already ended. */
|
|
875
|
+
kill(runId: string): boolean;
|
|
876
|
+
/** Aborts all running subagents for the given parent session. Returns count killed. */
|
|
877
|
+
killAll(parentSessionId: string): number;
|
|
878
|
+
/** Lists all runs registered for the given parent session. */
|
|
879
|
+
list(parentSessionId: string): SubagentRunRecord[];
|
|
880
|
+
/** Returns true if any subagents for this session are still running. */
|
|
881
|
+
hasPending(parentSessionId: string): boolean;
|
|
882
|
+
/** Count of currently running children for a session. */
|
|
883
|
+
countActive(parentSessionId: string): number;
|
|
884
|
+
/**
|
|
885
|
+
* Waits until all currently-running subagents for the given session settle.
|
|
886
|
+
* Returns immediately if nothing is pending.
|
|
887
|
+
*/
|
|
888
|
+
waitForAll(parentSessionId: string): Promise<void>;
|
|
889
|
+
/**
|
|
890
|
+
* Returns all finished runs whose terminal result has not yet been delivered.
|
|
891
|
+
* This is a read-only snapshot; callers must explicitly mark delivery after
|
|
892
|
+
* the result has been handed back to the parent.
|
|
893
|
+
*/
|
|
894
|
+
peekCompleted(parentSessionId: string): SubagentRunRecord[];
|
|
895
|
+
/**
|
|
896
|
+
* Returns all finished runs that have not yet been returned by this method,
|
|
897
|
+
* and marks them as announced so they are not returned again.
|
|
898
|
+
*/
|
|
899
|
+
consumeCompleted(parentSessionId: string): SubagentRunRecord[];
|
|
900
|
+
/** Marks a finished run as already delivered to its parent. */
|
|
901
|
+
markAnnounced(runId: string | string[]): void;
|
|
902
|
+
/** Returns whether a run's terminal result has already been delivered. */
|
|
903
|
+
isAnnounced(runId: string): boolean;
|
|
904
|
+
/** Returns true if there are completed runs not yet returned by consumeCompleted. */
|
|
905
|
+
hasUnannounced(parentSessionId: string): boolean;
|
|
906
|
+
/**
|
|
907
|
+
* Returns true if the announce loop should run another iteration:
|
|
908
|
+
* either subagents are still running, or completed runs await announcement.
|
|
909
|
+
*/
|
|
910
|
+
needsAnnounce(parentSessionId: string): boolean;
|
|
911
|
+
/** Checks whether a new child can be spawned given depth and active-children limits. */
|
|
912
|
+
checkSpawnAllowed(parentSessionId: string, depth: number): {
|
|
913
|
+
allowed: true;
|
|
914
|
+
} | {
|
|
915
|
+
allowed: false;
|
|
916
|
+
reason: string;
|
|
917
|
+
};
|
|
918
|
+
/** Returns the current status snapshot for a single run, or null if not found. */
|
|
919
|
+
getStatus(runId: string): SubagentStatus | null;
|
|
920
|
+
private logTerminalStatus;
|
|
921
|
+
}
|
|
922
|
+
//#endregion
|
|
923
|
+
//#region src/plugins/types.d.ts
|
|
924
|
+
type PluginDiagnostic = {
|
|
925
|
+
level: "warn" | "error";
|
|
926
|
+
message: string;
|
|
927
|
+
pluginId?: string;
|
|
928
|
+
source?: string;
|
|
929
|
+
};
|
|
930
|
+
type PluginOrigin = "bundled" | "global" | "workspace" | "config";
|
|
931
|
+
type PluginKind = "memory";
|
|
932
|
+
type PluginConfigUiHint = {
|
|
933
|
+
label?: string;
|
|
934
|
+
help?: string;
|
|
935
|
+
tags?: string[];
|
|
936
|
+
advanced?: boolean;
|
|
937
|
+
sensitive?: boolean;
|
|
938
|
+
placeholder?: string;
|
|
939
|
+
};
|
|
940
|
+
type PluginManifest = {
|
|
941
|
+
id: string;
|
|
942
|
+
configSchema: Record<string, unknown>;
|
|
943
|
+
kind?: PluginKind;
|
|
944
|
+
skills?: string[];
|
|
945
|
+
name?: string;
|
|
946
|
+
description?: string;
|
|
947
|
+
version?: string;
|
|
948
|
+
uiHints?: Record<string, PluginConfigUiHint>;
|
|
949
|
+
};
|
|
950
|
+
type PluginManifestLoadResult = {
|
|
951
|
+
ok: true;
|
|
952
|
+
manifest: PluginManifest;
|
|
953
|
+
manifestPath: string;
|
|
954
|
+
} | {
|
|
955
|
+
ok: false;
|
|
956
|
+
error: string;
|
|
957
|
+
manifestPath: string;
|
|
958
|
+
};
|
|
959
|
+
type PluginCandidate = {
|
|
960
|
+
idHint: string;
|
|
961
|
+
source: string;
|
|
962
|
+
rootDir: string;
|
|
963
|
+
origin: PluginOrigin;
|
|
964
|
+
workspaceDir?: string;
|
|
965
|
+
packageName?: string;
|
|
966
|
+
packageVersion?: string;
|
|
967
|
+
packageDescription?: string;
|
|
968
|
+
packageDir?: string;
|
|
969
|
+
packageManifest?: AIMaxPackageManifest;
|
|
970
|
+
};
|
|
971
|
+
type AIMaxPackageManifest = {
|
|
972
|
+
extensions?: string[];
|
|
973
|
+
};
|
|
974
|
+
type PluginDiscoveryResult = {
|
|
975
|
+
candidates: PluginCandidate[];
|
|
976
|
+
diagnostics: PluginDiagnostic[];
|
|
977
|
+
};
|
|
978
|
+
//#endregion
|
|
979
|
+
//#region src/plugins/manifest-registry.d.ts
|
|
980
|
+
type PluginManifestRecord = {
|
|
981
|
+
id: string;
|
|
982
|
+
rootDir: string;
|
|
983
|
+
source: string;
|
|
984
|
+
origin: PluginCandidate["origin"];
|
|
985
|
+
manifestPath: string;
|
|
986
|
+
manifest: PluginManifest;
|
|
987
|
+
};
|
|
988
|
+
type PluginManifestRegistry = {
|
|
989
|
+
manifests: Map<string, PluginManifestRecord>;
|
|
990
|
+
diagnostics: PluginDiagnostic[];
|
|
991
|
+
};
|
|
992
|
+
declare function loadPluginManifestRegistry(candidates: PluginCandidate[]): PluginManifestRegistry;
|
|
993
|
+
//#endregion
|
|
994
|
+
//#region src/plugins/config-state.d.ts
|
|
995
|
+
type PluginEntryConfig = {
|
|
996
|
+
enabled?: boolean;
|
|
997
|
+
config?: Record<string, unknown>;
|
|
998
|
+
};
|
|
999
|
+
type PluginsConfig = {
|
|
1000
|
+
enabled?: boolean;
|
|
1001
|
+
allow?: string[];
|
|
1002
|
+
deny?: string[];
|
|
1003
|
+
llmAllowlist?: string[];
|
|
1004
|
+
load?: {
|
|
1005
|
+
paths?: string[];
|
|
1006
|
+
};
|
|
1007
|
+
entries?: Record<string, PluginEntryConfig>;
|
|
1008
|
+
slots?: Partial<Record<PluginKind, string>>;
|
|
1009
|
+
};
|
|
1010
|
+
type NormalizedPluginsConfig = {
|
|
1011
|
+
enabled: boolean;
|
|
1012
|
+
allow: string[];
|
|
1013
|
+
deny: string[];
|
|
1014
|
+
loadPaths: string[];
|
|
1015
|
+
entries: Record<string, PluginEntryConfig>;
|
|
1016
|
+
slots: Partial<Record<PluginKind, string>>;
|
|
1017
|
+
};
|
|
1018
|
+
type PluginsConfigValidationResult = {
|
|
1019
|
+
ok: boolean;
|
|
1020
|
+
diagnostics: PluginDiagnostic[];
|
|
1021
|
+
};
|
|
1022
|
+
declare function normalizePluginsConfig(input?: PluginsConfig): NormalizedPluginsConfig;
|
|
1023
|
+
declare function validatePluginsConfig(params: {
|
|
1024
|
+
config: NormalizedPluginsConfig;
|
|
1025
|
+
registry: PluginManifestRegistry;
|
|
1026
|
+
}): PluginsConfigValidationResult;
|
|
1027
|
+
//#endregion
|
|
563
1028
|
//#region src/agents/definitions.d.ts
|
|
564
1029
|
declare const SYSTEM_AGENTS_DIR = "/aimax/agents";
|
|
565
1030
|
type AgentConfigSource = "system" | "user" | "project";
|
|
@@ -680,7 +1145,7 @@ type AgentRunParamsBase = {
|
|
|
680
1145
|
maxTokens?: number; /** Flash model for lightweight tasks (e.g. title generation) */
|
|
681
1146
|
flashModel?: string;
|
|
682
1147
|
}; /** In-process progress callback */
|
|
683
|
-
onProgress?: (event: AgentProgressEvent$1) => Promise<void>; /** Execution timeout in milliseconds;
|
|
1148
|
+
onProgress?: (event: AgentProgressEvent$1) => Promise<void>; /** Execution timeout in milliseconds; omitted means no agent-loop timeout */
|
|
684
1149
|
timeoutMs?: number; /** Present when this run is itself a subagent; controls depth limits */
|
|
685
1150
|
subagentContext?: SubagentContext; /** AbortSignal to cancel this run from outside (used by parent kill) */
|
|
686
1151
|
abortSignal?: AbortSignal; /** Structured HITL resume state injected by CLI resume path. */
|
|
@@ -732,7 +1197,20 @@ type AgentRunParamsBase = {
|
|
|
732
1197
|
* Older turns are dropped before the history is sent to the LLM.
|
|
733
1198
|
* 0 or undefined means no limit.
|
|
734
1199
|
*/
|
|
735
|
-
historyLimit?: number;
|
|
1200
|
+
historyLimit?: number;
|
|
1201
|
+
/**
|
|
1202
|
+
* Optional session-scoped environment variables to inject into child processes
|
|
1203
|
+
* spawned by the `exec` / `process` tools and exposed to plugin scripts via
|
|
1204
|
+
* the plugin runtime context.
|
|
1205
|
+
*
|
|
1206
|
+
* Merge order (later entries win):
|
|
1207
|
+
* process.env < run-level `env` < per-call `exec.env` params
|
|
1208
|
+
*
|
|
1209
|
+
* The values are kept in memory only for the duration of the run; they are
|
|
1210
|
+
* never written to disk and never cross a session boundary. Subagent runs
|
|
1211
|
+
* inherit this map via the standard `subagent_spawn` plumbing.
|
|
1212
|
+
*/
|
|
1213
|
+
env?: Record<string, string>; /** Optional IM-style topic segmentation prefilter. Enabled by default unless enabled=false. */
|
|
736
1214
|
topicSegmentation?: TopicSegmentationConfig;
|
|
737
1215
|
/**
|
|
738
1216
|
* Goal to create when this run establishes a new session (CLI `run --goal` without --session-id).
|
|
@@ -807,254 +1285,16 @@ type ToolResultEntry = {
|
|
|
807
1285
|
* `content` holds the summary text so it is accessible via the common
|
|
808
1286
|
* `.content` property without narrowing on `role`.
|
|
809
1287
|
*/
|
|
810
|
-
type CompactionEntry = {
|
|
811
|
-
role: "compaction"; /** Summary of the dropped conversation history */
|
|
812
|
-
content: string;
|
|
813
|
-
keptCount: number;
|
|
814
|
-
droppedCount: number;
|
|
815
|
-
timestamp: string;
|
|
816
|
-
source?: "cron";
|
|
817
|
-
};
|
|
818
|
-
/** Union of all persisted transcript entry types */
|
|
819
|
-
type TranscriptEntry = UserEntry | AssistantEntry | ToolResultEntry | CompactionEntry;
|
|
820
|
-
//#endregion
|
|
821
|
-
//#region src/subagent/types.d.ts
|
|
822
|
-
/** Status of a spawned subagent run */
|
|
823
|
-
type SubagentStatus = "running" | "done" | "error" | "killed";
|
|
824
|
-
/** Record tracking a single subagent run */
|
|
825
|
-
type SubagentRunRecord = {
|
|
826
|
-
runId: string;
|
|
827
|
-
childSessionId: string;
|
|
828
|
-
parentSessionId: string;
|
|
829
|
-
task: string;
|
|
830
|
-
label?: string; /** Nesting depth: parent is depth N, child is N+1 */
|
|
831
|
-
depth: number;
|
|
832
|
-
status: SubagentStatus;
|
|
833
|
-
result?: string;
|
|
834
|
-
error?: string;
|
|
835
|
-
startedAt: number;
|
|
836
|
-
endedAt?: number; /** Used to cancel the subagent run */
|
|
837
|
-
abortController: AbortController;
|
|
838
|
-
};
|
|
839
|
-
//#endregion
|
|
840
|
-
//#region src/subagent/registry.d.ts
|
|
841
|
-
declare const MAX_SUBAGENT_DEPTH = 2;
|
|
842
|
-
declare const MAX_CHILDREN_PER_SESSION = 5;
|
|
843
|
-
/**
|
|
844
|
-
* In-memory registry for subagent runs scoped to a single parent runAgent call.
|
|
845
|
-
* Child spawns create their own SubagentRegistry instances for their children.
|
|
846
|
-
*/
|
|
847
|
-
declare class SubagentRegistry {
|
|
848
|
-
private readonly entries;
|
|
849
|
-
/** RunIds whose terminal result has already been delivered to the parent. */
|
|
850
|
-
private readonly announced;
|
|
851
|
-
register(record: SubagentRunRecord, promise: Promise<void>): void;
|
|
852
|
-
complete(runId: string, result: string): void;
|
|
853
|
-
fail(runId: string, error: string): void;
|
|
854
|
-
/** Aborts and marks a specific run as killed. Returns false if not found or already ended. */
|
|
855
|
-
kill(runId: string): boolean;
|
|
856
|
-
/** Aborts all running subagents for the given parent session. Returns count killed. */
|
|
857
|
-
killAll(parentSessionId: string): number;
|
|
858
|
-
/** Lists all runs registered for the given parent session. */
|
|
859
|
-
list(parentSessionId: string): SubagentRunRecord[];
|
|
860
|
-
/** Returns true if any subagents for this session are still running. */
|
|
861
|
-
hasPending(parentSessionId: string): boolean;
|
|
862
|
-
/** Count of currently running children for a session. */
|
|
863
|
-
countActive(parentSessionId: string): number;
|
|
864
|
-
/**
|
|
865
|
-
* Waits until all currently-running subagents for the given session settle.
|
|
866
|
-
* Returns immediately if nothing is pending.
|
|
867
|
-
*/
|
|
868
|
-
waitForAll(parentSessionId: string): Promise<void>;
|
|
869
|
-
/**
|
|
870
|
-
* Returns all finished runs whose terminal result has not yet been delivered.
|
|
871
|
-
* This is a read-only snapshot; callers must explicitly mark delivery after
|
|
872
|
-
* the result has been handed back to the parent.
|
|
873
|
-
*/
|
|
874
|
-
peekCompleted(parentSessionId: string): SubagentRunRecord[];
|
|
875
|
-
/**
|
|
876
|
-
* Returns all finished runs that have not yet been returned by this method,
|
|
877
|
-
* and marks them as announced so they are not returned again.
|
|
878
|
-
*/
|
|
879
|
-
consumeCompleted(parentSessionId: string): SubagentRunRecord[];
|
|
880
|
-
/** Marks a finished run as already delivered to its parent. */
|
|
881
|
-
markAnnounced(runId: string | string[]): void;
|
|
882
|
-
/** Returns whether a run's terminal result has already been delivered. */
|
|
883
|
-
isAnnounced(runId: string): boolean;
|
|
884
|
-
/** Returns true if there are completed runs not yet returned by consumeCompleted. */
|
|
885
|
-
hasUnannounced(parentSessionId: string): boolean;
|
|
886
|
-
/**
|
|
887
|
-
* Returns true if the announce loop should run another iteration:
|
|
888
|
-
* either subagents are still running, or completed runs await announcement.
|
|
889
|
-
*/
|
|
890
|
-
needsAnnounce(parentSessionId: string): boolean;
|
|
891
|
-
/** Checks whether a new child can be spawned given depth and active-children limits. */
|
|
892
|
-
checkSpawnAllowed(parentSessionId: string, depth: number): {
|
|
893
|
-
allowed: true;
|
|
894
|
-
} | {
|
|
895
|
-
allowed: false;
|
|
896
|
-
reason: string;
|
|
897
|
-
};
|
|
898
|
-
/** Returns the current status snapshot for a single run, or null if not found. */
|
|
899
|
-
getStatus(runId: string): SubagentStatus | null;
|
|
900
|
-
private logTerminalStatus;
|
|
901
|
-
}
|
|
902
|
-
//#endregion
|
|
903
|
-
//#region src/plugins/hooks.d.ts
|
|
904
|
-
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";
|
|
905
|
-
type PluginHookAgentContext = {
|
|
906
|
-
agentId?: string;
|
|
907
|
-
sessionId?: string;
|
|
908
|
-
workspaceDir?: string;
|
|
909
|
-
channel?: AgentRunParams["channel"];
|
|
910
|
-
};
|
|
911
|
-
type PluginExecutionRuntime = {
|
|
912
|
-
eventDispatcher: {
|
|
913
|
-
dispatchProgress: (sessionId: string, event: AgentProgressEvent$1) => Promise<void>;
|
|
914
|
-
};
|
|
915
|
-
};
|
|
916
|
-
type PluginHookBeforeModelResolveEvent = {
|
|
917
|
-
prompt: string;
|
|
918
|
-
};
|
|
919
|
-
type PluginHookBeforeModelResolveResult = {
|
|
920
|
-
modelOverride?: string;
|
|
921
|
-
};
|
|
922
|
-
type PluginHookBeforePromptBuildEvent = {
|
|
923
|
-
prompt: string;
|
|
924
|
-
};
|
|
925
|
-
type PluginHookBeforePromptBuildResult = {
|
|
926
|
-
systemPrompt?: string;
|
|
927
|
-
prependContext?: string;
|
|
928
|
-
};
|
|
929
|
-
type PluginHookAfterPromptBuildEvent = {
|
|
930
|
-
prompt: string;
|
|
931
|
-
systemPrompt: string;
|
|
932
|
-
};
|
|
933
|
-
type PluginHookLlmInputEvent = {
|
|
934
|
-
sessionId: string;
|
|
935
|
-
model: string;
|
|
936
|
-
prompt: string;
|
|
937
|
-
historyMessages: unknown[];
|
|
938
|
-
};
|
|
939
|
-
type PluginHookAssistantMessageEndEvent = {
|
|
940
|
-
sessionId: string;
|
|
941
|
-
model: string;
|
|
942
|
-
assistantText: string;
|
|
943
|
-
assistantMessage: AssistantMessage;
|
|
944
|
-
hasToolCalls: boolean;
|
|
945
|
-
durationMs?: number;
|
|
946
|
-
usage?: {
|
|
947
|
-
input?: number;
|
|
948
|
-
output?: number;
|
|
949
|
-
total?: number;
|
|
950
|
-
};
|
|
951
|
-
};
|
|
952
|
-
type PluginHookLlmOutputEvent = {
|
|
953
|
-
sessionId: string;
|
|
954
|
-
model: string;
|
|
955
|
-
assistantTexts: string[];
|
|
956
|
-
lastAssistant?: AssistantMessage;
|
|
957
|
-
durationMs?: number;
|
|
958
|
-
usage?: {
|
|
959
|
-
input?: number;
|
|
960
|
-
output?: number;
|
|
961
|
-
total?: number;
|
|
962
|
-
};
|
|
963
|
-
};
|
|
964
|
-
type PluginHookBeforeToolCallEvent = {
|
|
965
|
-
toolCallId: string;
|
|
966
|
-
toolName: string;
|
|
967
|
-
params: Record<string, unknown>;
|
|
968
|
-
};
|
|
969
|
-
type PluginHookBeforeToolCallResult = {
|
|
970
|
-
params?: Record<string, unknown>;
|
|
971
|
-
block?: boolean;
|
|
972
|
-
blockReason?: string;
|
|
973
|
-
};
|
|
974
|
-
type PluginHookAfterToolCallEvent = {
|
|
975
|
-
toolCallId: string;
|
|
976
|
-
toolName: string;
|
|
977
|
-
params: Record<string, unknown>;
|
|
978
|
-
result?: unknown;
|
|
979
|
-
error?: string;
|
|
980
|
-
durationMs?: number;
|
|
981
|
-
};
|
|
982
|
-
type PluginHookAgentEndEvent = {
|
|
983
|
-
success: boolean;
|
|
984
|
-
error?: string;
|
|
985
|
-
durationMs?: number;
|
|
986
|
-
};
|
|
987
|
-
type PluginHookBeforeCompactionEvent = {
|
|
988
|
-
messageCount: number;
|
|
989
|
-
compactingCount?: number;
|
|
990
|
-
};
|
|
991
|
-
type PluginHookBeforeCompactionResult = {
|
|
992
|
-
skipPersist?: boolean;
|
|
993
|
-
injectRecall?: string;
|
|
994
|
-
};
|
|
995
|
-
type PluginHookAfterCompactionEvent = {
|
|
996
|
-
messageCount: number;
|
|
997
|
-
compactedCount: number;
|
|
998
|
-
};
|
|
999
|
-
type PluginHookSessionStartEvent = {
|
|
1000
|
-
sessionId: string;
|
|
1001
|
-
};
|
|
1002
|
-
type PluginHookSessionEndEvent = {
|
|
1003
|
-
sessionId: string;
|
|
1004
|
-
messageCount: number;
|
|
1005
|
-
durationMs?: number;
|
|
1006
|
-
};
|
|
1007
|
-
type PluginHookSessionResetEvent = {
|
|
1008
|
-
action: "new" | "reset";
|
|
1009
|
-
sessionId: string;
|
|
1010
|
-
previousSessionId?: string;
|
|
1011
|
-
message: string;
|
|
1012
|
-
};
|
|
1013
|
-
type PluginHookDreamGateEvent = {
|
|
1014
|
-
dataDir: string;
|
|
1015
|
-
memoryDir: string;
|
|
1016
|
-
providerId: string;
|
|
1017
|
-
pluginId?: string;
|
|
1018
|
-
trigger: "cli" | "cron";
|
|
1019
|
-
dryRun?: boolean;
|
|
1020
|
-
};
|
|
1021
|
-
type PluginHookDreamGateResult = {
|
|
1022
|
-
handled?: boolean;
|
|
1023
|
-
status?: "noop" | "completed" | "queued" | "failed";
|
|
1024
|
-
summary?: string;
|
|
1025
|
-
details?: Record<string, unknown>;
|
|
1026
|
-
};
|
|
1027
|
-
type PluginHookMemoryChangedEvent = MemoryChangedEvent;
|
|
1028
|
-
type PluginHookHandlerMap = {
|
|
1029
|
-
before_model_resolve: (event: PluginHookBeforeModelResolveEvent, ctx: PluginHookAgentContext) => PluginHookBeforeModelResolveResult | void | Promise<PluginHookBeforeModelResolveResult | void>;
|
|
1030
|
-
before_prompt_build: (event: PluginHookBeforePromptBuildEvent, ctx: PluginHookAgentContext) => PluginHookBeforePromptBuildResult | void | Promise<PluginHookBeforePromptBuildResult | void>;
|
|
1031
|
-
after_prompt_build: (event: PluginHookAfterPromptBuildEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
|
|
1032
|
-
llm_input: (event: PluginHookLlmInputEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
|
|
1033
|
-
assistant_message_end: (event: PluginHookAssistantMessageEndEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
|
|
1034
|
-
llm_output: (event: PluginHookLlmOutputEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
|
|
1035
|
-
before_tool_call: (event: PluginHookBeforeToolCallEvent, ctx: PluginHookAgentContext) => PluginHookBeforeToolCallResult | void | Promise<PluginHookBeforeToolCallResult | void>;
|
|
1036
|
-
after_tool_call: (event: PluginHookAfterToolCallEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
|
|
1037
|
-
agent_end: (event: PluginHookAgentEndEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
|
|
1038
|
-
before_compaction: (event: PluginHookBeforeCompactionEvent, ctx: PluginHookAgentContext) => PluginHookBeforeCompactionResult | void | Promise<PluginHookBeforeCompactionResult | void>;
|
|
1039
|
-
after_compaction: (event: PluginHookAfterCompactionEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
|
|
1040
|
-
session_start: (event: PluginHookSessionStartEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
|
|
1041
|
-
session_end: (event: PluginHookSessionEndEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
|
|
1042
|
-
session_reset: (event: PluginHookSessionResetEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
|
|
1043
|
-
dream_gate: (event: PluginHookDreamGateEvent, ctx: PluginHookAgentContext) => PluginHookDreamGateResult | void | Promise<PluginHookDreamGateResult | void>;
|
|
1044
|
-
memory_changed: (event: PluginHookMemoryChangedEvent, ctx: PluginHookAgentContext) => void | Promise<void>;
|
|
1045
|
-
};
|
|
1046
|
-
type PluginHookRegistration<K extends PluginHookName = PluginHookName> = {
|
|
1047
|
-
pluginId: string;
|
|
1048
|
-
hookName: K;
|
|
1049
|
-
handler: PluginHookHandlerMap[K];
|
|
1050
|
-
priority?: number;
|
|
1051
|
-
source: string;
|
|
1288
|
+
type CompactionEntry = {
|
|
1289
|
+
role: "compaction"; /** Summary of the dropped conversation history */
|
|
1290
|
+
content: string;
|
|
1291
|
+
keptCount: number;
|
|
1292
|
+
droppedCount: number;
|
|
1293
|
+
timestamp: string;
|
|
1294
|
+
source?: "cron";
|
|
1052
1295
|
};
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
register<K extends PluginHookName>(registration: PluginHookRegistration<K>): void;
|
|
1056
|
-
dispatch<K extends PluginHookName>(hookName: K, event: Parameters<PluginHookHandlerMap[K]>[0], ctx: Parameters<PluginHookHandlerMap[K]>[1], runtime?: PluginExecutionRuntime): Promise<Array<Awaited<ReturnType<PluginHookHandlerMap[K]>>>>;
|
|
1057
|
-
}
|
|
1296
|
+
/** Union of all persisted transcript entry types */
|
|
1297
|
+
type TranscriptEntry = UserEntry | AssistantEntry | ToolResultEntry | CompactionEntry;
|
|
1058
1298
|
//#endregion
|
|
1059
1299
|
//#region src/runner/title.d.ts
|
|
1060
1300
|
type GenerateTitleParams = {
|
|
@@ -1086,155 +1326,6 @@ declare function appendSessionFile(filePath: string, line: string, encrypt?: boo
|
|
|
1086
1326
|
declare function atomicWriteSessionFile(filePath: string, content: string, encrypt?: boolean): Promise<void>;
|
|
1087
1327
|
declare function readSessionFileContent(filePath: string): Promise<string | null>;
|
|
1088
1328
|
//#endregion
|
|
1089
|
-
//#region src/context/session-context-store.d.ts
|
|
1090
|
-
type PersistedToolResult = {
|
|
1091
|
-
content: string;
|
|
1092
|
-
reference?: ToolResultReference;
|
|
1093
|
-
};
|
|
1094
|
-
type SessionContextStore = {
|
|
1095
|
-
findReusableRead(path: string, offset?: number, limit?: number): Promise<ReadStateRecord | null>;
|
|
1096
|
-
recordRead(params: {
|
|
1097
|
-
path: string;
|
|
1098
|
-
content: string;
|
|
1099
|
-
lineCount: number;
|
|
1100
|
-
offset?: number;
|
|
1101
|
-
limit?: number;
|
|
1102
|
-
}): Promise<ReadStateRecord>;
|
|
1103
|
-
invalidatePath(path: string): Promise<void>;
|
|
1104
|
-
persistToolResult(params: {
|
|
1105
|
-
toolCallId: string;
|
|
1106
|
-
toolName: string;
|
|
1107
|
-
content: string;
|
|
1108
|
-
thresholdChars?: number;
|
|
1109
|
-
previewChars?: number;
|
|
1110
|
-
}): Promise<PersistedToolResult>;
|
|
1111
|
-
recordSnip(record: SnipRecord): Promise<void>;
|
|
1112
|
-
recordCollapse(span: CollapseSpan): Promise<void>;
|
|
1113
|
-
setSessionMemory(snapshot: SessionMemorySnapshot): Promise<void>;
|
|
1114
|
-
recordModelUsage(checkpoint: ModelUsageCheckpoint): Promise<void>;
|
|
1115
|
-
recordAutocompactResult(params: {
|
|
1116
|
-
layer: "L6";
|
|
1117
|
-
failed: boolean;
|
|
1118
|
-
timestamp: string;
|
|
1119
|
-
}): Promise<void>;
|
|
1120
|
-
getSnapshot(): SessionContextSnapshot;
|
|
1121
|
-
};
|
|
1122
|
-
type SessionContextStoreOptions = {
|
|
1123
|
-
dataDir: string;
|
|
1124
|
-
sessionId: string;
|
|
1125
|
-
} & SessionPathOptions;
|
|
1126
|
-
declare function createSessionContextStore(options: SessionContextStoreOptions): Promise<SessionContextStore>;
|
|
1127
|
-
//#endregion
|
|
1128
|
-
//#region src/context/context-manager.d.ts
|
|
1129
|
-
type ManageLayeredHistoryParams = {
|
|
1130
|
-
entries: TranscriptEntry[];
|
|
1131
|
-
modelInfo: {
|
|
1132
|
-
model: string;
|
|
1133
|
-
api: string;
|
|
1134
|
-
};
|
|
1135
|
-
contextWindowTokens: number;
|
|
1136
|
-
llm: Pick<AgentRunParams["llm"], "apiFormat" | "baseUrl" | "apiKey" | "model" | "flashModel">;
|
|
1137
|
-
historyLimit?: number;
|
|
1138
|
-
compactionEnabled?: boolean;
|
|
1139
|
-
pendingUserMessage?: string;
|
|
1140
|
-
topicSegmentation?: TopicSegmentationConfig;
|
|
1141
|
-
signal?: AbortSignal;
|
|
1142
|
-
hooks?: PluginHookRegistry;
|
|
1143
|
-
hookCtx?: PluginHookAgentContext;
|
|
1144
|
-
contextStore?: SessionContextStore;
|
|
1145
|
-
dataDir?: string;
|
|
1146
|
-
sessionId?: string;
|
|
1147
|
-
sessionStoreName?: string;
|
|
1148
|
-
sessionPathScope?: Pick<SessionPathOptions, "subagent">;
|
|
1149
|
-
channel?: Channel$1;
|
|
1150
|
-
isSubagent?: boolean;
|
|
1151
|
-
};
|
|
1152
|
-
type ManageLayeredHistoryResult = {
|
|
1153
|
-
messages: AgentMessage[];
|
|
1154
|
-
priorSummary: string | undefined;
|
|
1155
|
-
compactionEntry: CompactionEntry | undefined;
|
|
1156
|
-
stats: {
|
|
1157
|
-
originalCount: number;
|
|
1158
|
-
keptCount: number;
|
|
1159
|
-
estimatedTokens: number;
|
|
1160
|
-
compacted: boolean;
|
|
1161
|
-
};
|
|
1162
|
-
compactionEvents: AgentProgressEvent$1[];
|
|
1163
|
-
};
|
|
1164
|
-
type ContextManager = {
|
|
1165
|
-
getReusableRead(path: string, offset?: number, limit?: number): Promise<{
|
|
1166
|
-
reused: boolean;
|
|
1167
|
-
lineCount?: number;
|
|
1168
|
-
}>;
|
|
1169
|
-
rememberRead(params: {
|
|
1170
|
-
path: string;
|
|
1171
|
-
content: string;
|
|
1172
|
-
lineCount: number;
|
|
1173
|
-
offset?: number;
|
|
1174
|
-
limit?: number;
|
|
1175
|
-
}): Promise<void>;
|
|
1176
|
-
invalidateReadPath(path: string): Promise<void>;
|
|
1177
|
-
persistToolResult(params: {
|
|
1178
|
-
toolCallId: string;
|
|
1179
|
-
toolName: string;
|
|
1180
|
-
content: string;
|
|
1181
|
-
thresholdChars?: number;
|
|
1182
|
-
previewChars?: number;
|
|
1183
|
-
}): Promise<PersistedToolResult>;
|
|
1184
|
-
recordModelUsage(params: {
|
|
1185
|
-
model: string;
|
|
1186
|
-
inputTokens: number;
|
|
1187
|
-
outputTokens: number;
|
|
1188
|
-
totalTokens: number;
|
|
1189
|
-
coveredTranscriptEntryCount: number;
|
|
1190
|
-
}): Promise<void>;
|
|
1191
|
-
manageHistory(params: Omit<ManageLayeredHistoryParams, "contextStore">): Promise<ManageLayeredHistoryResult>;
|
|
1192
|
-
getSnapshot: SessionContextStore["getSnapshot"];
|
|
1193
|
-
};
|
|
1194
|
-
declare function createContextManager(params: {
|
|
1195
|
-
dataDir: string;
|
|
1196
|
-
sessionId: string;
|
|
1197
|
-
sessionStoreName?: string;
|
|
1198
|
-
sessionPathScope?: Pick<SessionPathOptions, "subagent">;
|
|
1199
|
-
}): Promise<ContextManager>;
|
|
1200
|
-
//#endregion
|
|
1201
|
-
//#region src/bootstrap/bootstrap.d.ts
|
|
1202
|
-
/** Maximum characters per bootstrap file before truncation */
|
|
1203
|
-
declare const BOOTSTRAP_MAX_CHARS = 20000;
|
|
1204
|
-
/** Maximum total characters across all bootstrap files */
|
|
1205
|
-
declare const BOOTSTRAP_TOTAL_MAX_CHARS = 150000;
|
|
1206
|
-
/** Names of bootstrap identity files, in injection order */
|
|
1207
|
-
declare const BOOTSTRAP_FILE_NAMES: readonly ["AGENTS.md", "SOUL.md", "TOOLS.md", "IDENTITY.md", "USER.md", "MEMORY.md", "BOOTSTRAP.md"];
|
|
1208
|
-
/** A loaded (or missing) bootstrap file */
|
|
1209
|
-
type BootstrapFile = {
|
|
1210
|
-
name: string;
|
|
1211
|
-
path: string;
|
|
1212
|
-
content: string | null;
|
|
1213
|
-
missing: boolean;
|
|
1214
|
-
};
|
|
1215
|
-
/** A bootstrap file ready for system prompt injection */
|
|
1216
|
-
type BootstrapContextFile = {
|
|
1217
|
-
path: string;
|
|
1218
|
-
content: string;
|
|
1219
|
-
};
|
|
1220
|
-
/** Resolves the base .aimax directory within a data directory */
|
|
1221
|
-
declare function aimaxDir(dataDir: string): string;
|
|
1222
|
-
/**
|
|
1223
|
-
* Loads all standard bootstrap identity files from the .aimax directory.
|
|
1224
|
-
* Missing files are included as `missing: true` entries.
|
|
1225
|
-
* BOOTSTRAP.md is deleted after loading (one-time use).
|
|
1226
|
-
*/
|
|
1227
|
-
declare function loadBootstrapFiles(dataDir: string): Promise<BootstrapFile[]>;
|
|
1228
|
-
/**
|
|
1229
|
-
* Converts loaded bootstrap files into context file entries for system prompt injection.
|
|
1230
|
-
* Applies per-file and total character budget limits.
|
|
1231
|
-
*/
|
|
1232
|
-
declare function buildBootstrapContextFiles(files: BootstrapFile[], opts?: {
|
|
1233
|
-
maxChars?: number;
|
|
1234
|
-
totalMaxChars?: number;
|
|
1235
|
-
warn?: (message: string) => void;
|
|
1236
|
-
}): BootstrapContextFile[];
|
|
1237
|
-
//#endregion
|
|
1238
1329
|
//#region src/bootstrap/bootstrap-layout.d.ts
|
|
1239
1330
|
type BootstrapMountResult = {
|
|
1240
1331
|
dataDir: string;
|
|
@@ -1393,71 +1484,6 @@ declare function resetMemoryProviderRegistryForTests(): void;
|
|
|
1393
1484
|
//#region src/auto-skills/paths.d.ts
|
|
1394
1485
|
declare function autoSkillsDir(dataDir: string): string;
|
|
1395
1486
|
//#endregion
|
|
1396
|
-
//#region src/auto-skills/types.d.ts
|
|
1397
|
-
type AutoSkillSource = "auto";
|
|
1398
|
-
type AutoSkillStatus = "active" | "archived";
|
|
1399
|
-
type AutoSkillCategory = {
|
|
1400
|
-
path: string;
|
|
1401
|
-
name: string;
|
|
1402
|
-
description: string;
|
|
1403
|
-
createdBy?: string;
|
|
1404
|
-
};
|
|
1405
|
-
type AutoSkillIndexEntry = {
|
|
1406
|
-
skillId: string;
|
|
1407
|
-
name: string;
|
|
1408
|
-
description: string;
|
|
1409
|
-
categoryPath: string;
|
|
1410
|
-
source: AutoSkillSource;
|
|
1411
|
-
status: AutoSkillStatus;
|
|
1412
|
-
rootDir: string;
|
|
1413
|
-
skillDir: string;
|
|
1414
|
-
skillFile: string;
|
|
1415
|
-
metadataFile?: string;
|
|
1416
|
-
tags: string[];
|
|
1417
|
-
relatedSkills: string[];
|
|
1418
|
-
confidence?: number;
|
|
1419
|
-
createdAt?: string;
|
|
1420
|
-
updatedAt?: string;
|
|
1421
|
-
};
|
|
1422
|
-
type AutoSkillListItem = {
|
|
1423
|
-
skillId: string;
|
|
1424
|
-
name: string;
|
|
1425
|
-
description: string;
|
|
1426
|
-
categoryPath: string;
|
|
1427
|
-
source: AutoSkillSource;
|
|
1428
|
-
};
|
|
1429
|
-
type AutoSkillSearchResult = AutoSkillListItem & {
|
|
1430
|
-
score: number;
|
|
1431
|
-
};
|
|
1432
|
-
type AutoSkillViewResult = AutoSkillListItem & {
|
|
1433
|
-
status: AutoSkillStatus;
|
|
1434
|
-
content: string;
|
|
1435
|
-
path: string;
|
|
1436
|
-
skillDir: string;
|
|
1437
|
-
filePath?: string;
|
|
1438
|
-
tags?: string[];
|
|
1439
|
-
relatedSkills?: string[];
|
|
1440
|
-
};
|
|
1441
|
-
type AutoSkillsLoaderOptions = {
|
|
1442
|
-
dataDir?: string;
|
|
1443
|
-
rootDir?: string;
|
|
1444
|
-
includeArchived?: boolean;
|
|
1445
|
-
maxSkillBytes?: number;
|
|
1446
|
-
maxResourceBytes?: number;
|
|
1447
|
-
};
|
|
1448
|
-
type AutoSkillListOptions = {
|
|
1449
|
-
categoryPath?: string;
|
|
1450
|
-
recursive?: boolean;
|
|
1451
|
-
};
|
|
1452
|
-
type AutoSkillSearchOptions = {
|
|
1453
|
-
query: string;
|
|
1454
|
-
limit?: number;
|
|
1455
|
-
};
|
|
1456
|
-
type AutoSkillViewOptions = {
|
|
1457
|
-
skillId: string;
|
|
1458
|
-
filePath?: string;
|
|
1459
|
-
};
|
|
1460
|
-
//#endregion
|
|
1461
1487
|
//#region src/auto-skills/loader.d.ts
|
|
1462
1488
|
declare function createAutoSkillsLoader(options: AutoSkillsLoaderOptions): AutoSkillsLoader;
|
|
1463
1489
|
declare class AutoSkillsLoader {
|
|
@@ -1835,18 +1861,6 @@ declare function createMemoryUpdateTool(dataDir: string, options?: MemoryToolOpt
|
|
|
1835
1861
|
id: string;
|
|
1836
1862
|
}>;
|
|
1837
1863
|
//#endregion
|
|
1838
|
-
//#region src/runner/event-dispatcher.d.ts
|
|
1839
|
-
type EventDispatchParams = Pick<AgentRunParams, "onProgress" | "messageId" | "channel" | "subagentContext">;
|
|
1840
|
-
/**
|
|
1841
|
-
* Emits runner events to in-process listeners.
|
|
1842
|
-
*/
|
|
1843
|
-
declare class RunEventDispatcher {
|
|
1844
|
-
private readonly params;
|
|
1845
|
-
constructor(params: EventDispatchParams);
|
|
1846
|
-
dispatchProgress(sessionId: string, event: AgentProgressEvent$2): Promise<void>;
|
|
1847
|
-
dispatchDiagnostic(sessionId: string, event: Omit<AgentDiagnosticEvent, keyof AgentProgressEventBase | "type">): Promise<void>;
|
|
1848
|
-
}
|
|
1849
|
-
//#endregion
|
|
1850
1864
|
//#region src/tools/process-registry.d.ts
|
|
1851
1865
|
type ProcessStatus = "running" | "completed" | "failed" | "killed" | "timeout";
|
|
1852
1866
|
type ProcessSessionSnapshot = {
|
|
@@ -1889,6 +1903,12 @@ type ProcessStartParams = {
|
|
|
1889
1903
|
command: string;
|
|
1890
1904
|
cwd: string;
|
|
1891
1905
|
env?: Record<string, string>;
|
|
1906
|
+
/**
|
|
1907
|
+
* Run-level baseline env, applied after `process.env` but before `env`.
|
|
1908
|
+
* Used to carry session-scoped env from the AgentRunParams through to
|
|
1909
|
+
* the spawned child process.
|
|
1910
|
+
*/
|
|
1911
|
+
baseEnv?: Record<string, string>;
|
|
1892
1912
|
timeoutSec: number;
|
|
1893
1913
|
scopeKey?: string;
|
|
1894
1914
|
};
|
|
@@ -1923,6 +1943,12 @@ type ExecToolOptions = {
|
|
|
1923
1943
|
scopeKey?: string;
|
|
1924
1944
|
contextManager?: ContextManager;
|
|
1925
1945
|
hitlResume?: AgentRunParams["hitlResume"];
|
|
1946
|
+
/**
|
|
1947
|
+
* Run-level baseline environment variables, applied after `process.env`
|
|
1948
|
+
* but before any per-call `params.env`. Used to carry session-scoped
|
|
1949
|
+
* env from `AgentRunParams.env` to the spawned child process.
|
|
1950
|
+
*/
|
|
1951
|
+
baseEnv?: Record<string, string>;
|
|
1926
1952
|
};
|
|
1927
1953
|
declare function createExecTool(options: ExecToolOptions): AgentTool<typeof execSchema, Record<string, unknown>>;
|
|
1928
1954
|
//#endregion
|
|
@@ -2153,7 +2179,7 @@ type BatchSpawnResult = {
|
|
|
2153
2179
|
status: "done" | "partial_error" | "error";
|
|
2154
2180
|
results: BatchSpawnItemResult[];
|
|
2155
2181
|
};
|
|
2156
|
-
type InheritedRunParams = Pick<AgentRunParams, "plugins" | "skillsLoadPaths" | "memory" | "messaging" | "historyLimit" | "topicSegmentation" | "onProgress" | "messageId" | "sessionStoreName" | "autoSkills" | "agentPolicy">;
|
|
2182
|
+
type InheritedRunParams = Pick<AgentRunParams, "plugins" | "skillsLoadPaths" | "memory" | "messaging" | "historyLimit" | "topicSegmentation" | "onProgress" | "messageId" | "sessionStoreName" | "autoSkills" | "agentPolicy" | "projectDir" | "env">;
|
|
2157
2183
|
/** Formats the announce message injected into the parent session when a subagent completes. */
|
|
2158
2184
|
declare function buildSubagentAnnounceMessage(params: {
|
|
2159
2185
|
task: string;
|
|
@@ -2300,7 +2326,7 @@ type SubagentToolsContext = {
|
|
|
2300
2326
|
depth: number;
|
|
2301
2327
|
channel: AgentRunParams["channel"];
|
|
2302
2328
|
llm: AgentRunParams["llm"];
|
|
2303
|
-
inheritedRunParams?: Pick<AgentRunParams, "plugins" | "skillsLoadPaths" | "memory" | "messaging" | "historyLimit" | "topicSegmentation" | "onProgress" | "messageId" | "sessionStoreName" | "autoSkills" | "agentPolicy">;
|
|
2329
|
+
inheritedRunParams?: Pick<AgentRunParams, "plugins" | "skillsLoadPaths" | "memory" | "messaging" | "historyLimit" | "topicSegmentation" | "onProgress" | "messageId" | "sessionStoreName" | "autoSkills" | "agentPolicy" | "projectDir" | "env">;
|
|
2304
2330
|
loopDetection?: ToolLoopDetectionConfig;
|
|
2305
2331
|
autoSkillsLoadEnabled?: boolean;
|
|
2306
2332
|
memoryOptions?: MemoryToolOptions;
|
|
@@ -2313,6 +2339,11 @@ type SubagentToolsContext = {
|
|
|
2313
2339
|
hitlResume?: AgentRunParams["hitlResume"];
|
|
2314
2340
|
eventDispatcher?: RunEventDispatcher; /** Callback that runs a child agent; injected to avoid circular imports */
|
|
2315
2341
|
spawnFn: (params: AgentRunParams) => Promise<AgentRunResult>;
|
|
2342
|
+
/**
|
|
2343
|
+
* Run-level baseline env applied to every spawned child process. Sourced
|
|
2344
|
+
* from `AgentRunParams.env` and inherited by subagent runs.
|
|
2345
|
+
*/
|
|
2346
|
+
baseEnv?: Record<string, string>;
|
|
2316
2347
|
};
|
|
2317
2348
|
/**
|
|
2318
2349
|
* Creates the full set of agent tools for a given data directory.
|
|
@@ -2448,9 +2479,22 @@ type PluginRuntime = {
|
|
|
2448
2479
|
error: (message: string) => void;
|
|
2449
2480
|
};
|
|
2450
2481
|
};
|
|
2482
|
+
/**
|
|
2483
|
+
* Read-only view of session-scoped state. Exposed to plugins so they can
|
|
2484
|
+
* discover per-run configuration (e.g. environment variables passed via
|
|
2485
|
+
* `AgentRunParams.env`) without re-plumbing the data through config.
|
|
2486
|
+
*/
|
|
2487
|
+
session: {
|
|
2488
|
+
env: Record<string, string>;
|
|
2489
|
+
};
|
|
2451
2490
|
};
|
|
2452
2491
|
type CreatePluginRuntimeOptions = {
|
|
2453
2492
|
pluginId: string;
|
|
2493
|
+
/**
|
|
2494
|
+
* Session-scoped env map mirrored from the current run. Frozen to
|
|
2495
|
+
* prevent plugins from mutating shared state.
|
|
2496
|
+
*/
|
|
2497
|
+
env?: Record<string, string>;
|
|
2454
2498
|
};
|
|
2455
2499
|
declare function createPluginRuntime(options: CreatePluginRuntimeOptions): PluginRuntime;
|
|
2456
2500
|
//#endregion
|
|
@@ -2501,6 +2545,16 @@ type PluginRuntimeContext = {
|
|
|
2501
2545
|
};
|
|
2502
2546
|
hookCtx?: PluginHookAgentContext;
|
|
2503
2547
|
llmAllowlist?: string[];
|
|
2548
|
+
/**
|
|
2549
|
+
* Session-scoped environment variables supplied via `AgentRunParams.env`.
|
|
2550
|
+
* Plugins that spawn child processes (e.g. via the `exec` tool) should
|
|
2551
|
+
* merge this map into the child process environment. Plugins may also
|
|
2552
|
+
* read values from this map to discover session-scoped configuration.
|
|
2553
|
+
*
|
|
2554
|
+
* The map is held in memory only for the duration of the run and is
|
|
2555
|
+
* never written to disk; it does not cross session boundaries.
|
|
2556
|
+
*/
|
|
2557
|
+
env?: Record<string, string>;
|
|
2504
2558
|
};
|
|
2505
2559
|
//#endregion
|
|
2506
2560
|
//#region src/plugins/loader.d.ts
|