agentix-cli 0.2.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/README.md +226 -0
- package/agentx.example.json +85 -0
- package/dist/agent-AI6DUEPU.js +2 -0
- package/dist/agent-AI6DUEPU.js.map +1 -0
- package/dist/chunk-6PVFYFUE.js +32 -0
- package/dist/chunk-6PVFYFUE.js.map +1 -0
- package/dist/chunk-FRFR27IN.js +3 -0
- package/dist/chunk-FRFR27IN.js.map +1 -0
- package/dist/chunk-FUYKPFUV.js +46 -0
- package/dist/chunk-FUYKPFUV.js.map +1 -0
- package/dist/chunk-NZ6W33BD.js +116 -0
- package/dist/chunk-NZ6W33BD.js.map +1 -0
- package/dist/chunk-SFQUP3BP.js +15 -0
- package/dist/chunk-SFQUP3BP.js.map +1 -0
- package/dist/chunk-THMHQELC.js +106 -0
- package/dist/chunk-THMHQELC.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +157 -0
- package/dist/cli.js.map +1 -0
- package/dist/heal-MJLBETRV.js +2 -0
- package/dist/heal-MJLBETRV.js.map +1 -0
- package/dist/index.d.ts +2105 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/loader-PHU6STSZ.js +2 -0
- package/dist/loader-PHU6STSZ.js.map +1 -0
- package/dist/providers-MPYTYJVB.js +2 -0
- package/dist/providers-MPYTYJVB.js.map +1 -0
- package/package.json +83 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,2105 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { PackageJson } from 'type-fest';
|
|
3
|
+
|
|
4
|
+
interface GenerationMessage {
|
|
5
|
+
role: "user" | "assistant" | "system";
|
|
6
|
+
content: string;
|
|
7
|
+
}
|
|
8
|
+
interface GenerationResult {
|
|
9
|
+
content: string;
|
|
10
|
+
files: GeneratedFile[];
|
|
11
|
+
followUp?: string;
|
|
12
|
+
tokensUsed?: number;
|
|
13
|
+
}
|
|
14
|
+
interface GeneratedFile {
|
|
15
|
+
path: string;
|
|
16
|
+
content: string;
|
|
17
|
+
language?: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
}
|
|
20
|
+
interface ProviderOptions {
|
|
21
|
+
model?: string;
|
|
22
|
+
maxTokens?: number;
|
|
23
|
+
temperature?: number;
|
|
24
|
+
apiKey?: string;
|
|
25
|
+
}
|
|
26
|
+
type StreamEvent = {
|
|
27
|
+
type: "text_delta";
|
|
28
|
+
text: string;
|
|
29
|
+
} | {
|
|
30
|
+
type: "tool_use_start";
|
|
31
|
+
name: string;
|
|
32
|
+
id: string;
|
|
33
|
+
} | {
|
|
34
|
+
type: "tool_use_delta";
|
|
35
|
+
json: string;
|
|
36
|
+
} | {
|
|
37
|
+
type: "tool_use_end";
|
|
38
|
+
name: string;
|
|
39
|
+
} | {
|
|
40
|
+
type: "done";
|
|
41
|
+
result: GenerationResult;
|
|
42
|
+
} | {
|
|
43
|
+
type: "error";
|
|
44
|
+
error: string;
|
|
45
|
+
};
|
|
46
|
+
interface AnthropicMessage {
|
|
47
|
+
role: "user" | "assistant";
|
|
48
|
+
content: string | ContentBlock[];
|
|
49
|
+
}
|
|
50
|
+
type ContentBlock = {
|
|
51
|
+
type: "text";
|
|
52
|
+
text: string;
|
|
53
|
+
} | {
|
|
54
|
+
type: "tool_use";
|
|
55
|
+
id: string;
|
|
56
|
+
name: string;
|
|
57
|
+
input: Record<string, unknown>;
|
|
58
|
+
} | {
|
|
59
|
+
type: "tool_result";
|
|
60
|
+
tool_use_id: string;
|
|
61
|
+
content: string;
|
|
62
|
+
is_error?: boolean;
|
|
63
|
+
};
|
|
64
|
+
interface RawGenerationResult {
|
|
65
|
+
content: ContentBlock[];
|
|
66
|
+
stop_reason: "end_turn" | "tool_use" | "max_tokens" | "stop_sequence";
|
|
67
|
+
usage: {
|
|
68
|
+
input_tokens: number;
|
|
69
|
+
output_tokens: number;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
interface AgentProvider {
|
|
73
|
+
name: string;
|
|
74
|
+
generate(messages: GenerationMessage[], options?: ProviderOptions): Promise<GenerationResult>;
|
|
75
|
+
stream?(messages: GenerationMessage[], options?: ProviderOptions): AsyncIterable<StreamEvent>;
|
|
76
|
+
/** Low-level method returning raw content blocks for the agentic tool_result loop */
|
|
77
|
+
generateRaw?(messages: AnthropicMessage[], systemPrompt: string, tools: Array<{
|
|
78
|
+
name: string;
|
|
79
|
+
description: string;
|
|
80
|
+
input_schema: Record<string, unknown>;
|
|
81
|
+
}>, options?: ProviderOptions): Promise<RawGenerationResult>;
|
|
82
|
+
}
|
|
83
|
+
declare const agentConfigSchema$1: z.ZodObject<{
|
|
84
|
+
provider: z.ZodDefault<z.ZodEnum<["claude-code", "claude", "openai", "ollama", "custom"]>>;
|
|
85
|
+
model: z.ZodOptional<z.ZodString>;
|
|
86
|
+
apiKey: z.ZodOptional<z.ZodString>;
|
|
87
|
+
skills: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
88
|
+
output: z.ZodDefault<z.ZodObject<{
|
|
89
|
+
dir: z.ZodDefault<z.ZodString>;
|
|
90
|
+
}, "strip", z.ZodTypeAny, {
|
|
91
|
+
dir: string;
|
|
92
|
+
}, {
|
|
93
|
+
dir?: string | undefined;
|
|
94
|
+
}>>;
|
|
95
|
+
context7: z.ZodDefault<z.ZodObject<{
|
|
96
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
97
|
+
apiKey: z.ZodOptional<z.ZodString>;
|
|
98
|
+
}, "strip", z.ZodTypeAny, {
|
|
99
|
+
enabled: boolean;
|
|
100
|
+
apiKey?: string | undefined;
|
|
101
|
+
}, {
|
|
102
|
+
apiKey?: string | undefined;
|
|
103
|
+
enabled?: boolean | undefined;
|
|
104
|
+
}>>;
|
|
105
|
+
agentic: z.ZodDefault<z.ZodObject<{
|
|
106
|
+
maxIterations: z.ZodDefault<z.ZodNumber>;
|
|
107
|
+
enabledTools: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
108
|
+
disabledTools: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
109
|
+
}, "strip", z.ZodTypeAny, {
|
|
110
|
+
maxIterations: number;
|
|
111
|
+
enabledTools: string[];
|
|
112
|
+
disabledTools: string[];
|
|
113
|
+
}, {
|
|
114
|
+
maxIterations?: number | undefined;
|
|
115
|
+
enabledTools?: string[] | undefined;
|
|
116
|
+
disabledTools?: string[] | undefined;
|
|
117
|
+
}>>;
|
|
118
|
+
}, "strip", z.ZodTypeAny, {
|
|
119
|
+
provider: "claude-code" | "claude" | "openai" | "ollama" | "custom";
|
|
120
|
+
skills: string[];
|
|
121
|
+
output: {
|
|
122
|
+
dir: string;
|
|
123
|
+
};
|
|
124
|
+
context7: {
|
|
125
|
+
enabled: boolean;
|
|
126
|
+
apiKey?: string | undefined;
|
|
127
|
+
};
|
|
128
|
+
agentic: {
|
|
129
|
+
maxIterations: number;
|
|
130
|
+
enabledTools: string[];
|
|
131
|
+
disabledTools: string[];
|
|
132
|
+
};
|
|
133
|
+
model?: string | undefined;
|
|
134
|
+
apiKey?: string | undefined;
|
|
135
|
+
}, {
|
|
136
|
+
provider?: "claude-code" | "claude" | "openai" | "ollama" | "custom" | undefined;
|
|
137
|
+
model?: string | undefined;
|
|
138
|
+
apiKey?: string | undefined;
|
|
139
|
+
skills?: string[] | undefined;
|
|
140
|
+
output?: {
|
|
141
|
+
dir?: string | undefined;
|
|
142
|
+
} | undefined;
|
|
143
|
+
context7?: {
|
|
144
|
+
apiKey?: string | undefined;
|
|
145
|
+
enabled?: boolean | undefined;
|
|
146
|
+
} | undefined;
|
|
147
|
+
agentic?: {
|
|
148
|
+
maxIterations?: number | undefined;
|
|
149
|
+
enabledTools?: string[] | undefined;
|
|
150
|
+
disabledTools?: string[] | undefined;
|
|
151
|
+
} | undefined;
|
|
152
|
+
}>;
|
|
153
|
+
type AgentConfig = z.infer<typeof agentConfigSchema$1>;
|
|
154
|
+
declare const OUTPUT_TYPES: readonly ["component", "page", "api", "website", "document", "script", "config", "skill", "media", "report", "test", "workflow", "schema", "email", "diagram", "auto"];
|
|
155
|
+
type OutputType = (typeof OUTPUT_TYPES)[number];
|
|
156
|
+
declare const outputTypeDescriptions: Record<OutputType, string>;
|
|
157
|
+
|
|
158
|
+
declare class ClaudeProvider implements AgentProvider {
|
|
159
|
+
name: string;
|
|
160
|
+
private apiKey;
|
|
161
|
+
private authType;
|
|
162
|
+
constructor(apiKey?: string);
|
|
163
|
+
generate(messages: GenerationMessage[], options?: ProviderOptions): Promise<GenerationResult>;
|
|
164
|
+
generateRaw(messages: AnthropicMessage[], systemPrompt: string, tools: Array<{
|
|
165
|
+
name: string;
|
|
166
|
+
description: string;
|
|
167
|
+
input_schema: Record<string, unknown>;
|
|
168
|
+
}>, options?: ProviderOptions): Promise<RawGenerationResult>;
|
|
169
|
+
stream(messages: GenerationMessage[], options?: ProviderOptions): AsyncIterable<StreamEvent>;
|
|
170
|
+
private buildHeaders;
|
|
171
|
+
private callApi;
|
|
172
|
+
private parseResponse;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
declare class ClaudeCodeProvider implements AgentProvider {
|
|
176
|
+
name: string;
|
|
177
|
+
private credential;
|
|
178
|
+
constructor();
|
|
179
|
+
generate(messages: GenerationMessage[], options?: ProviderOptions): Promise<GenerationResult>;
|
|
180
|
+
/**
|
|
181
|
+
* generateRaw() for the agentic tool_result loop.
|
|
182
|
+
* Only available for API key auth — the CLI binary has its own agent loop.
|
|
183
|
+
*/
|
|
184
|
+
generateRaw(messages: AnthropicMessage[], systemPrompt: string, tools: Array<{
|
|
185
|
+
name: string;
|
|
186
|
+
description: string;
|
|
187
|
+
input_schema: Record<string, unknown>;
|
|
188
|
+
}>, options?: ProviderOptions): Promise<RawGenerationResult>;
|
|
189
|
+
/**
|
|
190
|
+
* Returns true if this provider can use the agentic tool loop.
|
|
191
|
+
* Only available for API key auth (CLI mode falls back to legacy loop).
|
|
192
|
+
*/
|
|
193
|
+
get supportsAgenticLoop(): boolean;
|
|
194
|
+
/**
|
|
195
|
+
* Generate via the `claude` CLI binary.
|
|
196
|
+
* This is how subscription billing works — the CLI handles auth internally.
|
|
197
|
+
*/
|
|
198
|
+
private generateViaCli;
|
|
199
|
+
/**
|
|
200
|
+
* Generate via direct Anthropic API call (for API key auth).
|
|
201
|
+
*/
|
|
202
|
+
private generateViaApi;
|
|
203
|
+
/**
|
|
204
|
+
* Stream responses. For OAuth, uses CLI with --output-format stream-json.
|
|
205
|
+
* For API keys, uses SSE streaming.
|
|
206
|
+
*/
|
|
207
|
+
stream(messages: GenerationMessage[], options?: ProviderOptions): AsyncIterable<StreamEvent>;
|
|
208
|
+
private streamViaCli;
|
|
209
|
+
private streamViaApi;
|
|
210
|
+
/**
|
|
211
|
+
* Parse JSON output from the `claude` CLI.
|
|
212
|
+
*/
|
|
213
|
+
private parseCliOutput;
|
|
214
|
+
/**
|
|
215
|
+
* Extract file blocks from CLI text output.
|
|
216
|
+
* Looks for patterns like: ```path/to/file.ts ... ```
|
|
217
|
+
*/
|
|
218
|
+
private extractFilesFromText;
|
|
219
|
+
/**
|
|
220
|
+
* Claude CLI (OAuth/subscription) doesn't always emit structured ask_user tool blocks.
|
|
221
|
+
* When it's obviously asking for clarification, infer a follow-up question from the tail.
|
|
222
|
+
*/
|
|
223
|
+
private inferFollowUpFromText;
|
|
224
|
+
/**
|
|
225
|
+
* Parse Anthropic API response (tool-use format).
|
|
226
|
+
*/
|
|
227
|
+
private parseApiResponse;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
type ProviderName = "claude-code" | "claude" | "openai" | "ollama" | "custom";
|
|
231
|
+
declare function createProvider(name?: ProviderName, apiKey?: string): AgentProvider;
|
|
232
|
+
|
|
233
|
+
interface MemoryEntry {
|
|
234
|
+
id: string;
|
|
235
|
+
timestamp: number;
|
|
236
|
+
type: "generation" | "evolution" | "heal" | "skill" | "feedback" | "pattern";
|
|
237
|
+
task: string;
|
|
238
|
+
outputType?: string;
|
|
239
|
+
files: string[];
|
|
240
|
+
success: boolean;
|
|
241
|
+
error?: string;
|
|
242
|
+
userFeedback?: "positive" | "negative" | "neutral";
|
|
243
|
+
context: {
|
|
244
|
+
techStack?: string[];
|
|
245
|
+
frameworks?: string[];
|
|
246
|
+
skillsUsed?: string[];
|
|
247
|
+
};
|
|
248
|
+
metadata?: Record<string, unknown>;
|
|
249
|
+
}
|
|
250
|
+
interface LearnedPattern {
|
|
251
|
+
id: string;
|
|
252
|
+
description: string;
|
|
253
|
+
frequency: number;
|
|
254
|
+
lastUsed: number;
|
|
255
|
+
techStack: string[];
|
|
256
|
+
example?: string;
|
|
257
|
+
}
|
|
258
|
+
interface UserPreference {
|
|
259
|
+
key: string;
|
|
260
|
+
value: string;
|
|
261
|
+
confidence: number;
|
|
262
|
+
source: string;
|
|
263
|
+
}
|
|
264
|
+
interface MemoryStore {
|
|
265
|
+
version: number;
|
|
266
|
+
entries: MemoryEntry[];
|
|
267
|
+
patterns: LearnedPattern[];
|
|
268
|
+
preferences: UserPreference[];
|
|
269
|
+
stats: {
|
|
270
|
+
totalGenerations: number;
|
|
271
|
+
successRate: number;
|
|
272
|
+
totalHeals: number;
|
|
273
|
+
skillsGenerated: number;
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
declare class Memory {
|
|
277
|
+
private cwd;
|
|
278
|
+
private store;
|
|
279
|
+
private memoryPath;
|
|
280
|
+
private dirty;
|
|
281
|
+
constructor(cwd: string);
|
|
282
|
+
load(): Promise<void>;
|
|
283
|
+
save(): Promise<void>;
|
|
284
|
+
recordGeneration(entry: Omit<MemoryEntry, "id" | "timestamp" | "type"> & {
|
|
285
|
+
type?: MemoryEntry["type"];
|
|
286
|
+
}): Promise<string>;
|
|
287
|
+
recordHeal(originalEntryId: string, error: string, fixed: boolean, fixFiles: string[]): Promise<void>;
|
|
288
|
+
recordFeedback(entryId: string, feedback: "positive" | "negative" | "neutral"): Promise<void>;
|
|
289
|
+
learnPreference(key: string, value: string, source: string): Promise<void>;
|
|
290
|
+
getRecentGenerations(limit?: number): MemoryEntry[];
|
|
291
|
+
getFailedGenerations(limit?: number): MemoryEntry[];
|
|
292
|
+
getSimilarTasks(task: string, limit?: number): MemoryEntry[];
|
|
293
|
+
getPatterns(): LearnedPattern[];
|
|
294
|
+
getPreferences(): UserPreference[];
|
|
295
|
+
getStats(): MemoryStore["stats"];
|
|
296
|
+
buildMemoryContext(task: string): string;
|
|
297
|
+
private extractPattern;
|
|
298
|
+
private updateSuccessRate;
|
|
299
|
+
private trimEntries;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
interface HealConfig {
|
|
303
|
+
enabled: boolean;
|
|
304
|
+
testCommand?: string;
|
|
305
|
+
buildCommand?: string;
|
|
306
|
+
lintCommand?: string;
|
|
307
|
+
maxAttempts: number;
|
|
308
|
+
provider: ProviderName;
|
|
309
|
+
model?: string;
|
|
310
|
+
apiKey?: string;
|
|
311
|
+
}
|
|
312
|
+
interface HealResult {
|
|
313
|
+
healed: boolean;
|
|
314
|
+
attempts: number;
|
|
315
|
+
error: string;
|
|
316
|
+
fix?: string;
|
|
317
|
+
filesChanged: string[];
|
|
318
|
+
}
|
|
319
|
+
declare class HealEngine {
|
|
320
|
+
private cwd;
|
|
321
|
+
private config;
|
|
322
|
+
private memory;
|
|
323
|
+
constructor(cwd: string, config?: Partial<HealConfig>, memory?: Memory);
|
|
324
|
+
detectAndHeal(generatedFiles: string[], originalTask: string, entryId?: string): Promise<HealResult>;
|
|
325
|
+
private runVerification;
|
|
326
|
+
private detectCommands;
|
|
327
|
+
private generateFix;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
interface TechStack {
|
|
331
|
+
languages: Language[];
|
|
332
|
+
frameworks: Framework[];
|
|
333
|
+
packageManager?: string;
|
|
334
|
+
databases: string[];
|
|
335
|
+
styling: string[];
|
|
336
|
+
testing: string[];
|
|
337
|
+
deployment: string[];
|
|
338
|
+
monorepo: boolean;
|
|
339
|
+
dependencies: Record<string, string>;
|
|
340
|
+
devDependencies: Record<string, string>;
|
|
341
|
+
scripts: Record<string, string>;
|
|
342
|
+
projectRoot: string;
|
|
343
|
+
srcDir: string | null;
|
|
344
|
+
configFiles: string[];
|
|
345
|
+
}
|
|
346
|
+
interface Language {
|
|
347
|
+
name: string;
|
|
348
|
+
version?: string;
|
|
349
|
+
configFile?: string;
|
|
350
|
+
}
|
|
351
|
+
interface Framework {
|
|
352
|
+
name: string;
|
|
353
|
+
version?: string;
|
|
354
|
+
type: "frontend" | "backend" | "fullstack" | "mobile" | "cli" | "library";
|
|
355
|
+
}
|
|
356
|
+
declare function detectTechStack(cwd: string): Promise<TechStack>;
|
|
357
|
+
declare function formatTechStack(stack: TechStack): string;
|
|
358
|
+
|
|
359
|
+
interface ProjectSchemas {
|
|
360
|
+
database?: DatabaseSchema;
|
|
361
|
+
api?: ApiSchema;
|
|
362
|
+
env?: EnvSchema;
|
|
363
|
+
models?: ModelFile[];
|
|
364
|
+
}
|
|
365
|
+
interface DatabaseSchema {
|
|
366
|
+
type: string;
|
|
367
|
+
content: string;
|
|
368
|
+
tables?: string[];
|
|
369
|
+
}
|
|
370
|
+
interface ApiSchema {
|
|
371
|
+
type: string;
|
|
372
|
+
content: string;
|
|
373
|
+
endpoints?: string[];
|
|
374
|
+
}
|
|
375
|
+
interface EnvSchema {
|
|
376
|
+
variables: {
|
|
377
|
+
key: string;
|
|
378
|
+
description?: string;
|
|
379
|
+
required: boolean;
|
|
380
|
+
}[];
|
|
381
|
+
}
|
|
382
|
+
interface ModelFile {
|
|
383
|
+
path: string;
|
|
384
|
+
content: string;
|
|
385
|
+
type: string;
|
|
386
|
+
}
|
|
387
|
+
declare function detectSchemas(cwd: string): Promise<ProjectSchemas>;
|
|
388
|
+
declare function formatSchemas(schemas: ProjectSchemas): string;
|
|
389
|
+
|
|
390
|
+
interface WriteResult {
|
|
391
|
+
written: string[];
|
|
392
|
+
skipped: string[];
|
|
393
|
+
errors: string[];
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
declare const skillFrontmatterSchema: z.ZodObject<{
|
|
397
|
+
name: z.ZodString;
|
|
398
|
+
description: z.ZodString;
|
|
399
|
+
version: z.ZodOptional<z.ZodString>;
|
|
400
|
+
author: z.ZodOptional<z.ZodString>;
|
|
401
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
402
|
+
globs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
403
|
+
triggers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
404
|
+
pattern: z.ZodString;
|
|
405
|
+
description: z.ZodOptional<z.ZodString>;
|
|
406
|
+
}, "strip", z.ZodTypeAny, {
|
|
407
|
+
pattern: string;
|
|
408
|
+
description?: string | undefined;
|
|
409
|
+
}, {
|
|
410
|
+
pattern: string;
|
|
411
|
+
description?: string | undefined;
|
|
412
|
+
}>, "many">>;
|
|
413
|
+
}, "strip", z.ZodTypeAny, {
|
|
414
|
+
name: string;
|
|
415
|
+
description: string;
|
|
416
|
+
version?: string | undefined;
|
|
417
|
+
author?: string | undefined;
|
|
418
|
+
tags?: string[] | undefined;
|
|
419
|
+
globs?: string[] | undefined;
|
|
420
|
+
triggers?: {
|
|
421
|
+
pattern: string;
|
|
422
|
+
description?: string | undefined;
|
|
423
|
+
}[] | undefined;
|
|
424
|
+
}, {
|
|
425
|
+
name: string;
|
|
426
|
+
description: string;
|
|
427
|
+
version?: string | undefined;
|
|
428
|
+
author?: string | undefined;
|
|
429
|
+
tags?: string[] | undefined;
|
|
430
|
+
globs?: string[] | undefined;
|
|
431
|
+
triggers?: {
|
|
432
|
+
pattern: string;
|
|
433
|
+
description?: string | undefined;
|
|
434
|
+
}[] | undefined;
|
|
435
|
+
}>;
|
|
436
|
+
type SkillFrontmatter = z.infer<typeof skillFrontmatterSchema>;
|
|
437
|
+
interface Skill {
|
|
438
|
+
frontmatter: SkillFrontmatter;
|
|
439
|
+
instructions: string;
|
|
440
|
+
source: "local" | "remote" | "generated";
|
|
441
|
+
path?: string;
|
|
442
|
+
packageId?: string;
|
|
443
|
+
}
|
|
444
|
+
interface SkillMatch {
|
|
445
|
+
skill: Skill;
|
|
446
|
+
relevance: number;
|
|
447
|
+
matchReason: string;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
interface AgentContext {
|
|
451
|
+
techStack: TechStack;
|
|
452
|
+
schemas: ProjectSchemas;
|
|
453
|
+
skills: Skill[];
|
|
454
|
+
docs: string;
|
|
455
|
+
config: AgentConfig;
|
|
456
|
+
memoryContext: string;
|
|
457
|
+
projectInstructions: string;
|
|
458
|
+
}
|
|
459
|
+
interface GenerateOptions {
|
|
460
|
+
task: string;
|
|
461
|
+
outputType?: OutputType;
|
|
462
|
+
outputDir?: string;
|
|
463
|
+
overwrite?: boolean;
|
|
464
|
+
dryRun?: boolean;
|
|
465
|
+
provider?: ProviderName;
|
|
466
|
+
model?: string;
|
|
467
|
+
apiKey?: string;
|
|
468
|
+
cwd: string;
|
|
469
|
+
context7?: boolean;
|
|
470
|
+
interactive?: boolean;
|
|
471
|
+
skills?: string[];
|
|
472
|
+
maxSteps?: number;
|
|
473
|
+
sessionMessages?: GenerationMessage[];
|
|
474
|
+
heal?: boolean;
|
|
475
|
+
healConfig?: {
|
|
476
|
+
testCommand?: string;
|
|
477
|
+
buildCommand?: string;
|
|
478
|
+
lintCommand?: string;
|
|
479
|
+
maxAttempts?: number;
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
interface GenerateResult {
|
|
483
|
+
files: WriteResult;
|
|
484
|
+
content: string;
|
|
485
|
+
outputType: OutputType;
|
|
486
|
+
followUp?: string;
|
|
487
|
+
tokensUsed?: number;
|
|
488
|
+
healResult?: HealResult;
|
|
489
|
+
}
|
|
490
|
+
declare function createAgentContext(cwd: string, task: string, config?: Partial<AgentConfig>): Promise<AgentContext>;
|
|
491
|
+
declare function generate(options: GenerateOptions): Promise<GenerateResult>;
|
|
492
|
+
type GenerateStreamEvent = StreamEvent | {
|
|
493
|
+
type: "context_ready";
|
|
494
|
+
outputType: OutputType;
|
|
495
|
+
} | {
|
|
496
|
+
type: "step_complete";
|
|
497
|
+
step: number;
|
|
498
|
+
filesCount: number;
|
|
499
|
+
} | {
|
|
500
|
+
type: "tool_call";
|
|
501
|
+
name: string;
|
|
502
|
+
id: string;
|
|
503
|
+
} | {
|
|
504
|
+
type: "tool_result";
|
|
505
|
+
name: string;
|
|
506
|
+
id: string;
|
|
507
|
+
is_error?: boolean;
|
|
508
|
+
} | {
|
|
509
|
+
type: "iteration";
|
|
510
|
+
iteration: number;
|
|
511
|
+
} | {
|
|
512
|
+
type: "generate_result";
|
|
513
|
+
result: GenerateResult;
|
|
514
|
+
};
|
|
515
|
+
declare function generateStream(options: GenerateOptions): AsyncGenerator<GenerateStreamEvent>;
|
|
516
|
+
|
|
517
|
+
declare function gatherContext7Docs(stack: TechStack, topic: string, apiKey?: string): Promise<string>;
|
|
518
|
+
|
|
519
|
+
declare function loadLocalSkills(cwd: string): Promise<Skill[]>;
|
|
520
|
+
declare function parseSkillFile(filePath: string): Promise<Skill | null>;
|
|
521
|
+
declare function parseSkillContent(content: string): Skill | null;
|
|
522
|
+
declare function matchSkillsToTask(skills: Skill[], taskDescription: string, outputType?: string): SkillMatch[];
|
|
523
|
+
|
|
524
|
+
declare function installSkillPackage(packageId: string, cwd: string): Promise<Skill[]>;
|
|
525
|
+
declare function generateSkillMd(name: string, description: string, instructions: string, tags?: string[], globs?: string[]): Promise<string>;
|
|
526
|
+
declare function listInstalledSkills(cwd: string): Promise<Skill[]>;
|
|
527
|
+
|
|
528
|
+
declare function generateSkill(provider: AgentProvider, name: string, description: string, techStack: TechStack, options?: {
|
|
529
|
+
tags?: string[];
|
|
530
|
+
outputType?: string;
|
|
531
|
+
}): Promise<{
|
|
532
|
+
skill: Skill;
|
|
533
|
+
content: string;
|
|
534
|
+
}>;
|
|
535
|
+
|
|
536
|
+
interface OutputConfig {
|
|
537
|
+
type: OutputType;
|
|
538
|
+
baseDir: string;
|
|
539
|
+
filePatterns: string[];
|
|
540
|
+
description: string;
|
|
541
|
+
}
|
|
542
|
+
declare const OUTPUT_CONFIGS: Record<string, OutputConfig>;
|
|
543
|
+
declare function resolveOutputType(userHint: string | undefined, taskDescription: string): OutputType;
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* Get all tool definitions in Anthropic API format (for generateRaw()).
|
|
547
|
+
* Optionally filter by enabled tool names.
|
|
548
|
+
*/
|
|
549
|
+
declare function getAnthropicTools(enabledTools?: string[]): Array<{
|
|
550
|
+
name: string;
|
|
551
|
+
description: string;
|
|
552
|
+
input_schema: Record<string, unknown>;
|
|
553
|
+
}>;
|
|
554
|
+
/**
|
|
555
|
+
* Get the legacy tools (create_files + ask_user) for backward compatibility.
|
|
556
|
+
*/
|
|
557
|
+
declare function getLegacyTools(): Array<{
|
|
558
|
+
name: string;
|
|
559
|
+
description: string;
|
|
560
|
+
input_schema: Record<string, unknown>;
|
|
561
|
+
}>;
|
|
562
|
+
/**
|
|
563
|
+
* Format tool descriptions for inclusion in a system prompt.
|
|
564
|
+
* Used when the `claude` CLI binary handles its own tools —
|
|
565
|
+
* we describe our additional tools as text so the binary's built-in
|
|
566
|
+
* capabilities (read, write, bash) handle them natively.
|
|
567
|
+
*/
|
|
568
|
+
declare function formatToolsForSystemPrompt(): string;
|
|
569
|
+
declare const ALL_TOOL_NAMES: string[];
|
|
570
|
+
|
|
571
|
+
interface ToolCallInput {
|
|
572
|
+
name: string;
|
|
573
|
+
id: string;
|
|
574
|
+
input: Record<string, unknown>;
|
|
575
|
+
}
|
|
576
|
+
interface ToolResult {
|
|
577
|
+
tool_use_id: string;
|
|
578
|
+
content: string;
|
|
579
|
+
is_error?: boolean;
|
|
580
|
+
/** Files collected from create_files calls */
|
|
581
|
+
files?: GeneratedFile[];
|
|
582
|
+
/** Question from ask_user calls */
|
|
583
|
+
followUp?: string;
|
|
584
|
+
}
|
|
585
|
+
interface ToolExecutorOptions {
|
|
586
|
+
interactive?: boolean;
|
|
587
|
+
overwrite?: boolean;
|
|
588
|
+
dryRun?: boolean;
|
|
589
|
+
}
|
|
590
|
+
declare class ToolExecutor {
|
|
591
|
+
private cwd;
|
|
592
|
+
private options;
|
|
593
|
+
constructor(cwd: string, options?: ToolExecutorOptions);
|
|
594
|
+
execute(call: ToolCallInput): Promise<ToolResult>;
|
|
595
|
+
private readFile;
|
|
596
|
+
private searchFiles;
|
|
597
|
+
private listDirectory;
|
|
598
|
+
private runCommand;
|
|
599
|
+
private editFile;
|
|
600
|
+
private createFiles;
|
|
601
|
+
private askUser;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
interface EnhanceConfig {
|
|
605
|
+
enabled: boolean;
|
|
606
|
+
autoSkills: boolean;
|
|
607
|
+
minFrequency: number;
|
|
608
|
+
provider: ProviderName;
|
|
609
|
+
model?: string;
|
|
610
|
+
apiKey?: string;
|
|
611
|
+
}
|
|
612
|
+
interface EnhanceResult {
|
|
613
|
+
skillsCreated: string[];
|
|
614
|
+
skillsUpdated: string[];
|
|
615
|
+
insights: string[];
|
|
616
|
+
}
|
|
617
|
+
declare class EnhanceEngine {
|
|
618
|
+
private cwd;
|
|
619
|
+
private memory;
|
|
620
|
+
private config;
|
|
621
|
+
constructor(cwd: string, memory: Memory, config?: Partial<EnhanceConfig>);
|
|
622
|
+
enhance(): Promise<EnhanceResult>;
|
|
623
|
+
private createSkillsFromPatterns;
|
|
624
|
+
private generateSkillFromPattern;
|
|
625
|
+
private analyzeFailures;
|
|
626
|
+
private analyzePreferences;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
interface PipelineRequest {
|
|
630
|
+
id: string;
|
|
631
|
+
task: string;
|
|
632
|
+
outputType?: string;
|
|
633
|
+
outputDir?: string;
|
|
634
|
+
provider?: string;
|
|
635
|
+
model?: string;
|
|
636
|
+
apiKey?: string;
|
|
637
|
+
cwd: string;
|
|
638
|
+
overwrite?: boolean;
|
|
639
|
+
metadata?: Record<string, unknown>;
|
|
640
|
+
}
|
|
641
|
+
interface PipelineResponse {
|
|
642
|
+
id: string;
|
|
643
|
+
success: boolean;
|
|
644
|
+
files: {
|
|
645
|
+
path: string;
|
|
646
|
+
content?: string;
|
|
647
|
+
}[];
|
|
648
|
+
content: string;
|
|
649
|
+
outputType: string;
|
|
650
|
+
error?: string;
|
|
651
|
+
healed?: boolean;
|
|
652
|
+
healAttempts?: number;
|
|
653
|
+
tokensUsed?: number;
|
|
654
|
+
memoryEntryId?: string;
|
|
655
|
+
insights?: string[];
|
|
656
|
+
duration: number;
|
|
657
|
+
}
|
|
658
|
+
type MiddlewareFn = (req: PipelineRequest, res: PipelineResponse, context: PipelineContext, next: () => Promise<void>) => Promise<void>;
|
|
659
|
+
interface PipelineContext {
|
|
660
|
+
agentContext?: AgentContext;
|
|
661
|
+
memory?: Memory;
|
|
662
|
+
startTime: number;
|
|
663
|
+
[key: string]: unknown;
|
|
664
|
+
}
|
|
665
|
+
declare class Pipeline {
|
|
666
|
+
private middleware;
|
|
667
|
+
use(name: string, fn: MiddlewareFn): Pipeline;
|
|
668
|
+
execute(req: PipelineRequest): Promise<PipelineResponse>;
|
|
669
|
+
getMiddlewareNames(): string[];
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
interface RuntimeConfig {
|
|
673
|
+
port: number;
|
|
674
|
+
host: string;
|
|
675
|
+
provider: ProviderName;
|
|
676
|
+
model?: string;
|
|
677
|
+
apiKey?: string;
|
|
678
|
+
cwd: string;
|
|
679
|
+
memory: {
|
|
680
|
+
enabled: boolean;
|
|
681
|
+
};
|
|
682
|
+
heal: {
|
|
683
|
+
enabled: boolean;
|
|
684
|
+
testCommand?: string;
|
|
685
|
+
buildCommand?: string;
|
|
686
|
+
};
|
|
687
|
+
enhance: {
|
|
688
|
+
enabled: boolean;
|
|
689
|
+
autoSkills: boolean;
|
|
690
|
+
};
|
|
691
|
+
cors: boolean;
|
|
692
|
+
}
|
|
693
|
+
declare class AgentXRuntime {
|
|
694
|
+
private config;
|
|
695
|
+
private memory;
|
|
696
|
+
private healEngine;
|
|
697
|
+
private enhanceEngine;
|
|
698
|
+
private pipeline;
|
|
699
|
+
private requestCount;
|
|
700
|
+
private log;
|
|
701
|
+
constructor(config?: Partial<RuntimeConfig>);
|
|
702
|
+
private buildPipeline;
|
|
703
|
+
start(): Promise<void>;
|
|
704
|
+
private handleRequest;
|
|
705
|
+
private handleGenerate;
|
|
706
|
+
private handleEvolve;
|
|
707
|
+
private handleInspect;
|
|
708
|
+
private handleMemory;
|
|
709
|
+
private handleFeedback;
|
|
710
|
+
private handleEnhance;
|
|
711
|
+
private memoryMiddleware;
|
|
712
|
+
private contextMiddleware;
|
|
713
|
+
private generateMiddleware;
|
|
714
|
+
private healMiddleware;
|
|
715
|
+
private recordMiddleware;
|
|
716
|
+
private enhanceMiddleware;
|
|
717
|
+
private sendJson;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
declare function startMcpServer(): Promise<void>;
|
|
721
|
+
|
|
722
|
+
declare class MemoryHierarchy {
|
|
723
|
+
private cwd;
|
|
724
|
+
private userMemory;
|
|
725
|
+
private projectMemory;
|
|
726
|
+
constructor(cwd: string);
|
|
727
|
+
load(): Promise<void>;
|
|
728
|
+
save(): Promise<void>;
|
|
729
|
+
/**
|
|
730
|
+
* Build merged memory context for the agent. Project overrides user.
|
|
731
|
+
*/
|
|
732
|
+
buildMemoryContext(task: string): string;
|
|
733
|
+
/**
|
|
734
|
+
* Learn a preference at user level (global).
|
|
735
|
+
*/
|
|
736
|
+
learnPreference(key: string, value: string, source: string): Promise<void>;
|
|
737
|
+
/**
|
|
738
|
+
* Record a generation at project level (task-specific).
|
|
739
|
+
*/
|
|
740
|
+
recordGeneration(entry: Omit<MemoryEntry, "id" | "timestamp" | "type"> & {
|
|
741
|
+
type?: MemoryEntry["type"];
|
|
742
|
+
}): Promise<string>;
|
|
743
|
+
/**
|
|
744
|
+
* Get combined preferences (project overrides user for same keys).
|
|
745
|
+
*/
|
|
746
|
+
getPreferences(): UserPreference[];
|
|
747
|
+
/**
|
|
748
|
+
* Get combined patterns from both levels.
|
|
749
|
+
*/
|
|
750
|
+
getPatterns(): LearnedPattern[];
|
|
751
|
+
/**
|
|
752
|
+
* Get stats from both levels.
|
|
753
|
+
*/
|
|
754
|
+
getStats(): {
|
|
755
|
+
user: MemoryStore["stats"];
|
|
756
|
+
project: MemoryStore["stats"];
|
|
757
|
+
};
|
|
758
|
+
/**
|
|
759
|
+
* Get recent generations from project level.
|
|
760
|
+
*/
|
|
761
|
+
getRecentGenerations(limit?: number): MemoryEntry[];
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
/**
|
|
765
|
+
* Resolve @-imports in content: replace @path/to/file with file contents.
|
|
766
|
+
*/
|
|
767
|
+
declare function resolveAtImports(content: string, basedir: string): string;
|
|
768
|
+
/**
|
|
769
|
+
* Load project instructions from SHADXN.md or CLAUDE.md.
|
|
770
|
+
*/
|
|
771
|
+
declare function loadProjectInstructions(cwd: string): string;
|
|
772
|
+
declare class ContextBuilder {
|
|
773
|
+
private sections;
|
|
774
|
+
addSection(label: string, content: string, priority?: number): void;
|
|
775
|
+
/**
|
|
776
|
+
* Build final context, trimming lowest-relevance sections if over budget.
|
|
777
|
+
*/
|
|
778
|
+
buildContext(task: string, maxTokens?: number): string;
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
interface StepUsage {
|
|
782
|
+
step: number;
|
|
783
|
+
model: string;
|
|
784
|
+
inputTokens: number;
|
|
785
|
+
outputTokens: number;
|
|
786
|
+
cost: number;
|
|
787
|
+
timestamp: number;
|
|
788
|
+
}
|
|
789
|
+
interface ModelUsage {
|
|
790
|
+
inputTokens: number;
|
|
791
|
+
outputTokens: number;
|
|
792
|
+
cost: number;
|
|
793
|
+
steps: number;
|
|
794
|
+
}
|
|
795
|
+
interface UsageSummary {
|
|
796
|
+
totalInputTokens: number;
|
|
797
|
+
totalOutputTokens: number;
|
|
798
|
+
totalTokens: number;
|
|
799
|
+
totalCost: number;
|
|
800
|
+
steps: StepUsage[];
|
|
801
|
+
models: Record<string, ModelUsage>;
|
|
802
|
+
}
|
|
803
|
+
declare class UsageTracker {
|
|
804
|
+
private steps;
|
|
805
|
+
private models;
|
|
806
|
+
recordStep(step: number, model: string, inputTokens: number, outputTokens: number): void;
|
|
807
|
+
getSummary(): UsageSummary;
|
|
808
|
+
reset(): void;
|
|
809
|
+
}
|
|
810
|
+
declare const globalTracker: UsageTracker;
|
|
811
|
+
|
|
812
|
+
declare function setDebug(enabled: boolean): void;
|
|
813
|
+
declare function isDebug(): boolean;
|
|
814
|
+
declare const debug: {
|
|
815
|
+
log(...args: unknown[]): void;
|
|
816
|
+
step(step: number, message: string): void;
|
|
817
|
+
hook(name: string, duration: number, result: string): void;
|
|
818
|
+
api(method: string, model: string, tokens?: number): void;
|
|
819
|
+
tokens(input: number, output: number, cost: number): void;
|
|
820
|
+
context(label: string, detail: string): void;
|
|
821
|
+
};
|
|
822
|
+
|
|
823
|
+
interface Session {
|
|
824
|
+
id: string;
|
|
825
|
+
createdAt: string;
|
|
826
|
+
updatedAt: string;
|
|
827
|
+
cwd: string;
|
|
828
|
+
messages: GenerationMessage[];
|
|
829
|
+
tokensUsed: number;
|
|
830
|
+
filesGenerated: string[];
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* Create a new session.
|
|
834
|
+
*/
|
|
835
|
+
declare function createSession(cwd: string): Session;
|
|
836
|
+
/**
|
|
837
|
+
* Save a session to disk.
|
|
838
|
+
*/
|
|
839
|
+
declare function saveSession(session: Session): void;
|
|
840
|
+
/**
|
|
841
|
+
* Load a session from disk.
|
|
842
|
+
*/
|
|
843
|
+
declare function loadSession(id: string): Session | null;
|
|
844
|
+
/**
|
|
845
|
+
* Load the most recent session.
|
|
846
|
+
*/
|
|
847
|
+
declare function loadLatestSession(): Session | null;
|
|
848
|
+
/**
|
|
849
|
+
* List all saved sessions.
|
|
850
|
+
*/
|
|
851
|
+
declare function listSessions(): Session[];
|
|
852
|
+
|
|
853
|
+
declare function exportSession(session: Session, usage?: UsageSummary): string;
|
|
854
|
+
|
|
855
|
+
declare const PERMISSION_MODES: readonly ["default", "acceptEdits", "plan", "yolo"];
|
|
856
|
+
type PermissionMode = (typeof PERMISSION_MODES)[number];
|
|
857
|
+
declare const permissionModeSchema: z.ZodEnum<["default", "acceptEdits", "plan", "yolo"]>;
|
|
858
|
+
interface PermissionRule {
|
|
859
|
+
pattern: string;
|
|
860
|
+
action: "allow" | "deny" | "confirm";
|
|
861
|
+
}
|
|
862
|
+
declare const permissionConfigSchema: z.ZodObject<{
|
|
863
|
+
mode: z.ZodDefault<z.ZodEnum<["default", "acceptEdits", "plan", "yolo"]>>;
|
|
864
|
+
allow: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
865
|
+
deny: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
866
|
+
confirm: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
867
|
+
}, "strip", z.ZodTypeAny, {
|
|
868
|
+
confirm: string[];
|
|
869
|
+
allow: string[];
|
|
870
|
+
deny: string[];
|
|
871
|
+
mode: "default" | "acceptEdits" | "plan" | "yolo";
|
|
872
|
+
}, {
|
|
873
|
+
confirm?: string[] | undefined;
|
|
874
|
+
allow?: string[] | undefined;
|
|
875
|
+
deny?: string[] | undefined;
|
|
876
|
+
mode?: "default" | "acceptEdits" | "plan" | "yolo" | undefined;
|
|
877
|
+
}>;
|
|
878
|
+
type PermissionConfig = z.infer<typeof permissionConfigSchema>;
|
|
879
|
+
|
|
880
|
+
type PermissionAction = "allow" | "deny" | "skip";
|
|
881
|
+
declare class PermissionManager {
|
|
882
|
+
private mode;
|
|
883
|
+
private allowPatterns;
|
|
884
|
+
private denyPatterns;
|
|
885
|
+
private confirmPatterns;
|
|
886
|
+
private autoAllowAll;
|
|
887
|
+
constructor(config?: Partial<PermissionConfig>);
|
|
888
|
+
getMode(): PermissionMode;
|
|
889
|
+
setMode(mode: PermissionMode): void;
|
|
890
|
+
/**
|
|
891
|
+
* Check whether a file write should proceed.
|
|
892
|
+
*/
|
|
893
|
+
checkFileWrite(filePath: string): Promise<PermissionAction>;
|
|
894
|
+
/**
|
|
895
|
+
* Check whether a command should proceed (for pre:command hook).
|
|
896
|
+
*/
|
|
897
|
+
checkCommand(command: string): Promise<"allow" | "deny">;
|
|
898
|
+
private matchesAny;
|
|
899
|
+
private promptUser;
|
|
900
|
+
}
|
|
901
|
+
declare const globalPermissions: PermissionManager;
|
|
902
|
+
|
|
903
|
+
declare const HOOK_EVENTS: readonly ["pre:generate", "post:generate", "pre:file-write", "post:file-write", "pre:prompt", "post:response", "pre:command", "on:error", "pre:tool-call", "post:tool-call", "pre:channel-message", "post:channel-message", "pre:a2a-task", "pre:cron-run", "post:cron-run"];
|
|
904
|
+
type HookEvent = (typeof HOOK_EVENTS)[number];
|
|
905
|
+
declare const BLOCKING_EVENTS: HookEvent[];
|
|
906
|
+
declare const hookDefinitionSchema: z.ZodObject<{
|
|
907
|
+
name: z.ZodString;
|
|
908
|
+
type: z.ZodEnum<["command", "prompt", "script"]>;
|
|
909
|
+
command: z.ZodOptional<z.ZodString>;
|
|
910
|
+
prompt: z.ZodOptional<z.ZodString>;
|
|
911
|
+
provider: z.ZodOptional<z.ZodEnum<["claude-code", "claude", "openai", "ollama", "custom"]>>;
|
|
912
|
+
model: z.ZodOptional<z.ZodString>;
|
|
913
|
+
script: z.ZodOptional<z.ZodString>;
|
|
914
|
+
priority: z.ZodDefault<z.ZodNumber>;
|
|
915
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
916
|
+
}, "strip", z.ZodTypeAny, {
|
|
917
|
+
type: "script" | "command" | "prompt";
|
|
918
|
+
enabled: boolean;
|
|
919
|
+
name: string;
|
|
920
|
+
priority: number;
|
|
921
|
+
provider?: "claude-code" | "claude" | "openai" | "ollama" | "custom" | undefined;
|
|
922
|
+
model?: string | undefined;
|
|
923
|
+
script?: string | undefined;
|
|
924
|
+
command?: string | undefined;
|
|
925
|
+
prompt?: string | undefined;
|
|
926
|
+
}, {
|
|
927
|
+
type: "script" | "command" | "prompt";
|
|
928
|
+
name: string;
|
|
929
|
+
provider?: "claude-code" | "claude" | "openai" | "ollama" | "custom" | undefined;
|
|
930
|
+
model?: string | undefined;
|
|
931
|
+
enabled?: boolean | undefined;
|
|
932
|
+
script?: string | undefined;
|
|
933
|
+
command?: string | undefined;
|
|
934
|
+
prompt?: string | undefined;
|
|
935
|
+
priority?: number | undefined;
|
|
936
|
+
}>;
|
|
937
|
+
type HookDefinition = z.infer<typeof hookDefinitionSchema>;
|
|
938
|
+
interface HookContext {
|
|
939
|
+
event: HookEvent;
|
|
940
|
+
task?: string;
|
|
941
|
+
file?: string;
|
|
942
|
+
fileContent?: string;
|
|
943
|
+
content?: string;
|
|
944
|
+
command?: string;
|
|
945
|
+
error?: Error;
|
|
946
|
+
cwd?: string;
|
|
947
|
+
[key: string]: unknown;
|
|
948
|
+
}
|
|
949
|
+
interface HookResult {
|
|
950
|
+
blocked?: boolean;
|
|
951
|
+
message?: string;
|
|
952
|
+
modified?: Record<string, unknown>;
|
|
953
|
+
}
|
|
954
|
+
type HookHandler = (context: HookContext) => Promise<HookResult>;
|
|
955
|
+
|
|
956
|
+
declare class HookRegistry {
|
|
957
|
+
private hooks;
|
|
958
|
+
/**
|
|
959
|
+
* Register a hook for an event.
|
|
960
|
+
*/
|
|
961
|
+
register(event: HookEvent, definition: HookDefinition): void;
|
|
962
|
+
/**
|
|
963
|
+
* Execute all hooks for an event. Returns combined result.
|
|
964
|
+
* For blocking events, stops at the first hook that returns { blocked: true }.
|
|
965
|
+
*/
|
|
966
|
+
execute(event: HookEvent, context: HookContext): Promise<HookResult>;
|
|
967
|
+
/**
|
|
968
|
+
* Check if any hooks are registered for an event.
|
|
969
|
+
*/
|
|
970
|
+
has(event: HookEvent): boolean;
|
|
971
|
+
/**
|
|
972
|
+
* Clear all hooks (useful for testing).
|
|
973
|
+
*/
|
|
974
|
+
clear(): void;
|
|
975
|
+
/**
|
|
976
|
+
* Create a HookHandler from a HookDefinition.
|
|
977
|
+
*/
|
|
978
|
+
private createHandler;
|
|
979
|
+
/**
|
|
980
|
+
* Command hook: runs a shell command with {{variable}} interpolation.
|
|
981
|
+
* Exit code 0 = success, non-zero = blocked (for blocking events).
|
|
982
|
+
*/
|
|
983
|
+
private createCommandHandler;
|
|
984
|
+
/**
|
|
985
|
+
* Script hook: imports and runs a JS/TS module that exports a handler function.
|
|
986
|
+
*/
|
|
987
|
+
private createScriptHandler;
|
|
988
|
+
/**
|
|
989
|
+
* Prompt hook: single-turn LLM call that can block or modify the operation.
|
|
990
|
+
* The prompt template supports {{variable}} interpolation from hook context.
|
|
991
|
+
* The LLM must respond with JSON: { "action": "allow"|"block", "message": "...", "modified": {...} }
|
|
992
|
+
*/
|
|
993
|
+
private createPromptHandler;
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
/**
|
|
997
|
+
* Load hooks from agentx.config.json and .agentx/hooks/ directory.
|
|
998
|
+
*/
|
|
999
|
+
declare function loadHooks(cwd: string, registry: HookRegistry): void;
|
|
1000
|
+
|
|
1001
|
+
declare const globalHooks: HookRegistry;
|
|
1002
|
+
|
|
1003
|
+
interface GitStatus {
|
|
1004
|
+
staged: string[];
|
|
1005
|
+
modified: string[];
|
|
1006
|
+
untracked: string[];
|
|
1007
|
+
deleted: string[];
|
|
1008
|
+
branch: string;
|
|
1009
|
+
isClean: boolean;
|
|
1010
|
+
}
|
|
1011
|
+
interface GitLogEntry {
|
|
1012
|
+
hash: string;
|
|
1013
|
+
shortHash: string;
|
|
1014
|
+
message: string;
|
|
1015
|
+
author: string;
|
|
1016
|
+
date: string;
|
|
1017
|
+
}
|
|
1018
|
+
interface GitDiffFile {
|
|
1019
|
+
path: string;
|
|
1020
|
+
status: "added" | "modified" | "deleted" | "renamed";
|
|
1021
|
+
additions: number;
|
|
1022
|
+
deletions: number;
|
|
1023
|
+
}
|
|
1024
|
+
interface GitCommitResult {
|
|
1025
|
+
hash: string;
|
|
1026
|
+
message: string;
|
|
1027
|
+
filesChanged: number;
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
declare class GitManager {
|
|
1031
|
+
private cwd;
|
|
1032
|
+
constructor(cwd: string);
|
|
1033
|
+
/**
|
|
1034
|
+
* Check if the current directory is a git repository.
|
|
1035
|
+
*/
|
|
1036
|
+
isRepo(): Promise<boolean>;
|
|
1037
|
+
/**
|
|
1038
|
+
* Get current git status.
|
|
1039
|
+
*/
|
|
1040
|
+
status(): Promise<GitStatus>;
|
|
1041
|
+
/**
|
|
1042
|
+
* Get git diff (staged or unstaged).
|
|
1043
|
+
*/
|
|
1044
|
+
diff(staged?: boolean): Promise<string>;
|
|
1045
|
+
/**
|
|
1046
|
+
* Get diff summary with file-level stats.
|
|
1047
|
+
*/
|
|
1048
|
+
diffStat(staged?: boolean): Promise<GitDiffFile[]>;
|
|
1049
|
+
/**
|
|
1050
|
+
* Get recent git log entries.
|
|
1051
|
+
*/
|
|
1052
|
+
log(count?: number): Promise<GitLogEntry[]>;
|
|
1053
|
+
/**
|
|
1054
|
+
* Stage files.
|
|
1055
|
+
*/
|
|
1056
|
+
add(files: string[]): Promise<void>;
|
|
1057
|
+
/**
|
|
1058
|
+
* Stage all changes.
|
|
1059
|
+
*/
|
|
1060
|
+
addAll(): Promise<void>;
|
|
1061
|
+
/**
|
|
1062
|
+
* Commit with a message.
|
|
1063
|
+
*/
|
|
1064
|
+
commit(message: string): Promise<GitCommitResult>;
|
|
1065
|
+
/**
|
|
1066
|
+
* Get current branch name.
|
|
1067
|
+
*/
|
|
1068
|
+
currentBranch(): Promise<string>;
|
|
1069
|
+
/**
|
|
1070
|
+
* Create and switch to a new branch.
|
|
1071
|
+
*/
|
|
1072
|
+
createBranch(name: string): Promise<void>;
|
|
1073
|
+
/**
|
|
1074
|
+
* Switch to an existing branch.
|
|
1075
|
+
*/
|
|
1076
|
+
checkout(name: string): Promise<void>;
|
|
1077
|
+
/**
|
|
1078
|
+
* Stash current changes.
|
|
1079
|
+
*/
|
|
1080
|
+
stash(message?: string): Promise<void>;
|
|
1081
|
+
/**
|
|
1082
|
+
* Pop the latest stash.
|
|
1083
|
+
*/
|
|
1084
|
+
stashPop(): Promise<void>;
|
|
1085
|
+
/**
|
|
1086
|
+
* Generate an AI commit message from staged changes.
|
|
1087
|
+
* Returns a conventional commit message based on the diff.
|
|
1088
|
+
*/
|
|
1089
|
+
generateCommitMessage(provider?: {
|
|
1090
|
+
generate: (messages: any[], options?: any) => Promise<any>;
|
|
1091
|
+
}): Promise<string>;
|
|
1092
|
+
private fallbackCommitMessage;
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
interface ReplOptions {
|
|
1096
|
+
cwd: string;
|
|
1097
|
+
provider?: string;
|
|
1098
|
+
model?: string;
|
|
1099
|
+
apiKey?: string;
|
|
1100
|
+
resume?: boolean;
|
|
1101
|
+
sessionId?: string;
|
|
1102
|
+
version: string;
|
|
1103
|
+
}
|
|
1104
|
+
declare class ReplEngine {
|
|
1105
|
+
private rl;
|
|
1106
|
+
private session;
|
|
1107
|
+
private options;
|
|
1108
|
+
private running;
|
|
1109
|
+
constructor(options: ReplOptions);
|
|
1110
|
+
/**
|
|
1111
|
+
* Start the REPL loop.
|
|
1112
|
+
*/
|
|
1113
|
+
start(): Promise<void>;
|
|
1114
|
+
/**
|
|
1115
|
+
* Stop the REPL and save session.
|
|
1116
|
+
*/
|
|
1117
|
+
private stop;
|
|
1118
|
+
/**
|
|
1119
|
+
* Handle a slash command.
|
|
1120
|
+
*/
|
|
1121
|
+
private handleCommand;
|
|
1122
|
+
/**
|
|
1123
|
+
* Handle a natural language generation prompt.
|
|
1124
|
+
* Uses streaming to render text in real-time instead of blocking with a spinner.
|
|
1125
|
+
*/
|
|
1126
|
+
private handleGeneration;
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
interface CommandContext {
|
|
1130
|
+
session: Session;
|
|
1131
|
+
cwd: string;
|
|
1132
|
+
onSessionChange: (session: Session) => void;
|
|
1133
|
+
}
|
|
1134
|
+
type SlashCommandHandler = (args: string, ctx: CommandContext) => Promise<boolean>;
|
|
1135
|
+
declare function registerCommand(name: string, handler: SlashCommandHandler): void;
|
|
1136
|
+
declare function getCommand(name: string): SlashCommandHandler | undefined;
|
|
1137
|
+
declare function isCommand(input: string): boolean;
|
|
1138
|
+
declare function parseCommand(input: string): {
|
|
1139
|
+
name: string;
|
|
1140
|
+
args: string;
|
|
1141
|
+
};
|
|
1142
|
+
|
|
1143
|
+
interface A2AServerConfig {
|
|
1144
|
+
port: number;
|
|
1145
|
+
host: string;
|
|
1146
|
+
provider: ProviderName;
|
|
1147
|
+
model?: string;
|
|
1148
|
+
apiKey?: string;
|
|
1149
|
+
cwd: string;
|
|
1150
|
+
cors: boolean;
|
|
1151
|
+
}
|
|
1152
|
+
declare class A2AServer {
|
|
1153
|
+
private config;
|
|
1154
|
+
private tasks;
|
|
1155
|
+
private activeCancellations;
|
|
1156
|
+
private log;
|
|
1157
|
+
constructor(config?: Partial<A2AServerConfig>);
|
|
1158
|
+
start(): Promise<void>;
|
|
1159
|
+
private getAgentCard;
|
|
1160
|
+
private handleRequest;
|
|
1161
|
+
private handleJsonRpc;
|
|
1162
|
+
private handleTaskSend;
|
|
1163
|
+
private handleTaskSendSubscribe;
|
|
1164
|
+
private handleTaskGet;
|
|
1165
|
+
private handleTaskCancel;
|
|
1166
|
+
private sendJson;
|
|
1167
|
+
private sendJsonRpc;
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
interface AgentCard {
|
|
1171
|
+
name: string;
|
|
1172
|
+
description: string;
|
|
1173
|
+
url: string;
|
|
1174
|
+
version: string;
|
|
1175
|
+
capabilities: {
|
|
1176
|
+
streaming: boolean;
|
|
1177
|
+
pushNotifications: boolean;
|
|
1178
|
+
stateTransitionHistory: boolean;
|
|
1179
|
+
};
|
|
1180
|
+
skills: AgentSkill[];
|
|
1181
|
+
defaultInputModes: string[];
|
|
1182
|
+
defaultOutputModes: string[];
|
|
1183
|
+
}
|
|
1184
|
+
interface AgentSkill {
|
|
1185
|
+
id: string;
|
|
1186
|
+
name: string;
|
|
1187
|
+
description: string;
|
|
1188
|
+
tags: string[];
|
|
1189
|
+
examples?: string[];
|
|
1190
|
+
}
|
|
1191
|
+
type TaskState = "submitted" | "working" | "input-required" | "completed" | "failed" | "canceled";
|
|
1192
|
+
interface Task {
|
|
1193
|
+
id: string;
|
|
1194
|
+
state: TaskState;
|
|
1195
|
+
messages: TaskMessage[];
|
|
1196
|
+
artifacts: TaskArtifact[];
|
|
1197
|
+
metadata?: Record<string, unknown>;
|
|
1198
|
+
createdAt: string;
|
|
1199
|
+
updatedAt: string;
|
|
1200
|
+
}
|
|
1201
|
+
interface TaskMessage {
|
|
1202
|
+
role: "user" | "agent";
|
|
1203
|
+
parts: MessagePart[];
|
|
1204
|
+
}
|
|
1205
|
+
type MessagePart = TextPart | FilePart | DataPart;
|
|
1206
|
+
interface TextPart {
|
|
1207
|
+
type: "text";
|
|
1208
|
+
text: string;
|
|
1209
|
+
}
|
|
1210
|
+
interface FilePart {
|
|
1211
|
+
type: "file";
|
|
1212
|
+
file: {
|
|
1213
|
+
name: string;
|
|
1214
|
+
mimeType?: string;
|
|
1215
|
+
bytes?: string;
|
|
1216
|
+
uri?: string;
|
|
1217
|
+
};
|
|
1218
|
+
}
|
|
1219
|
+
interface DataPart {
|
|
1220
|
+
type: "data";
|
|
1221
|
+
data: Record<string, unknown>;
|
|
1222
|
+
}
|
|
1223
|
+
interface TaskArtifact {
|
|
1224
|
+
name: string;
|
|
1225
|
+
description?: string;
|
|
1226
|
+
parts: MessagePart[];
|
|
1227
|
+
index: number;
|
|
1228
|
+
}
|
|
1229
|
+
interface TaskStatusUpdate {
|
|
1230
|
+
id: string;
|
|
1231
|
+
state: TaskState;
|
|
1232
|
+
message?: TaskMessage;
|
|
1233
|
+
artifact?: TaskArtifact;
|
|
1234
|
+
final: boolean;
|
|
1235
|
+
metadata?: Record<string, unknown>;
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
declare class A2AClient {
|
|
1239
|
+
private baseUrl;
|
|
1240
|
+
private token?;
|
|
1241
|
+
constructor(baseUrl: string, token?: string);
|
|
1242
|
+
/**
|
|
1243
|
+
* Fetch the remote agent's card.
|
|
1244
|
+
*/
|
|
1245
|
+
getAgentCard(): Promise<AgentCard>;
|
|
1246
|
+
/**
|
|
1247
|
+
* Send a task synchronously and wait for completion.
|
|
1248
|
+
*/
|
|
1249
|
+
sendTask(text: string, metadata?: Record<string, unknown>): Promise<Task>;
|
|
1250
|
+
/**
|
|
1251
|
+
* Send a task with SSE streaming.
|
|
1252
|
+
*/
|
|
1253
|
+
sendTaskStream(text: string, metadata?: Record<string, unknown>): AsyncIterable<{
|
|
1254
|
+
state: string;
|
|
1255
|
+
message?: string;
|
|
1256
|
+
final: boolean;
|
|
1257
|
+
}>;
|
|
1258
|
+
/**
|
|
1259
|
+
* Get task status by ID.
|
|
1260
|
+
*/
|
|
1261
|
+
getTask(taskId: string): Promise<Task>;
|
|
1262
|
+
/**
|
|
1263
|
+
* Cancel a running task.
|
|
1264
|
+
*/
|
|
1265
|
+
cancelTask(taskId: string): Promise<Task>;
|
|
1266
|
+
private rpc;
|
|
1267
|
+
private headers;
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
declare const agentConfigSchema: z.ZodObject<{
|
|
1271
|
+
name: z.ZodString;
|
|
1272
|
+
workspace: z.ZodString;
|
|
1273
|
+
tier: z.ZodDefault<z.ZodEnum<["claude-code", "sdk", "orchestrator"]>>;
|
|
1274
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
1275
|
+
model: z.ZodOptional<z.ZodString>;
|
|
1276
|
+
systemPrompt: z.ZodOptional<z.ZodString>;
|
|
1277
|
+
mentions: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
1278
|
+
maxConcurrent: z.ZodDefault<z.ZodNumber>;
|
|
1279
|
+
permissionMode: z.ZodDefault<z.ZodString>;
|
|
1280
|
+
}, "strip", z.ZodTypeAny, {
|
|
1281
|
+
name: string;
|
|
1282
|
+
workspace: string;
|
|
1283
|
+
tier: "claude-code" | "sdk" | "orchestrator";
|
|
1284
|
+
mentions: string[];
|
|
1285
|
+
maxConcurrent: number;
|
|
1286
|
+
permissionMode: string;
|
|
1287
|
+
provider?: string | undefined;
|
|
1288
|
+
model?: string | undefined;
|
|
1289
|
+
systemPrompt?: string | undefined;
|
|
1290
|
+
}, {
|
|
1291
|
+
name: string;
|
|
1292
|
+
workspace: string;
|
|
1293
|
+
provider?: string | undefined;
|
|
1294
|
+
model?: string | undefined;
|
|
1295
|
+
systemPrompt?: string | undefined;
|
|
1296
|
+
tier?: "claude-code" | "sdk" | "orchestrator" | undefined;
|
|
1297
|
+
mentions?: string[] | undefined;
|
|
1298
|
+
maxConcurrent?: number | undefined;
|
|
1299
|
+
permissionMode?: string | undefined;
|
|
1300
|
+
}>;
|
|
1301
|
+
declare const cronJobSchema: z.ZodObject<{
|
|
1302
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
1303
|
+
schedule: z.ZodString;
|
|
1304
|
+
timezone: z.ZodDefault<z.ZodString>;
|
|
1305
|
+
agent: z.ZodString;
|
|
1306
|
+
prompt: z.ZodString;
|
|
1307
|
+
timeout: z.ZodDefault<z.ZodNumber>;
|
|
1308
|
+
model: z.ZodOptional<z.ZodString>;
|
|
1309
|
+
onError: z.ZodDefault<z.ZodEnum<["log", "notify", "disable"]>>;
|
|
1310
|
+
}, "strip", z.ZodTypeAny, {
|
|
1311
|
+
enabled: boolean;
|
|
1312
|
+
agent: string;
|
|
1313
|
+
timeout: number;
|
|
1314
|
+
prompt: string;
|
|
1315
|
+
schedule: string;
|
|
1316
|
+
timezone: string;
|
|
1317
|
+
onError: "log" | "notify" | "disable";
|
|
1318
|
+
model?: string | undefined;
|
|
1319
|
+
}, {
|
|
1320
|
+
agent: string;
|
|
1321
|
+
prompt: string;
|
|
1322
|
+
schedule: string;
|
|
1323
|
+
model?: string | undefined;
|
|
1324
|
+
enabled?: boolean | undefined;
|
|
1325
|
+
timeout?: number | undefined;
|
|
1326
|
+
timezone?: string | undefined;
|
|
1327
|
+
onError?: "log" | "notify" | "disable" | undefined;
|
|
1328
|
+
}>;
|
|
1329
|
+
declare const meshPeerSchema: z.ZodObject<{
|
|
1330
|
+
url: z.ZodString;
|
|
1331
|
+
name: z.ZodString;
|
|
1332
|
+
token: z.ZodOptional<z.ZodString>;
|
|
1333
|
+
}, "strip", z.ZodTypeAny, {
|
|
1334
|
+
name: string;
|
|
1335
|
+
url: string;
|
|
1336
|
+
token?: string | undefined;
|
|
1337
|
+
}, {
|
|
1338
|
+
name: string;
|
|
1339
|
+
url: string;
|
|
1340
|
+
token?: string | undefined;
|
|
1341
|
+
}>;
|
|
1342
|
+
declare const daemonConfigSchema: z.ZodObject<{
|
|
1343
|
+
node: z.ZodObject<{
|
|
1344
|
+
id: z.ZodString;
|
|
1345
|
+
name: z.ZodString;
|
|
1346
|
+
bind: z.ZodDefault<z.ZodString>;
|
|
1347
|
+
}, "strip", z.ZodTypeAny, {
|
|
1348
|
+
id: string;
|
|
1349
|
+
name: string;
|
|
1350
|
+
bind: string;
|
|
1351
|
+
}, {
|
|
1352
|
+
id: string;
|
|
1353
|
+
name: string;
|
|
1354
|
+
bind?: string | undefined;
|
|
1355
|
+
}>;
|
|
1356
|
+
providers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
1357
|
+
apiKey: z.ZodOptional<z.ZodString>;
|
|
1358
|
+
defaultModel: z.ZodOptional<z.ZodString>;
|
|
1359
|
+
baseUrl: z.ZodOptional<z.ZodString>;
|
|
1360
|
+
}, "strip", z.ZodTypeAny, {
|
|
1361
|
+
apiKey?: string | undefined;
|
|
1362
|
+
defaultModel?: string | undefined;
|
|
1363
|
+
baseUrl?: string | undefined;
|
|
1364
|
+
}, {
|
|
1365
|
+
apiKey?: string | undefined;
|
|
1366
|
+
defaultModel?: string | undefined;
|
|
1367
|
+
baseUrl?: string | undefined;
|
|
1368
|
+
}>>>;
|
|
1369
|
+
agents: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
1370
|
+
name: z.ZodString;
|
|
1371
|
+
workspace: z.ZodString;
|
|
1372
|
+
tier: z.ZodDefault<z.ZodEnum<["claude-code", "sdk", "orchestrator"]>>;
|
|
1373
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
1374
|
+
model: z.ZodOptional<z.ZodString>;
|
|
1375
|
+
systemPrompt: z.ZodOptional<z.ZodString>;
|
|
1376
|
+
mentions: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
1377
|
+
maxConcurrent: z.ZodDefault<z.ZodNumber>;
|
|
1378
|
+
permissionMode: z.ZodDefault<z.ZodString>;
|
|
1379
|
+
}, "strip", z.ZodTypeAny, {
|
|
1380
|
+
name: string;
|
|
1381
|
+
workspace: string;
|
|
1382
|
+
tier: "claude-code" | "sdk" | "orchestrator";
|
|
1383
|
+
mentions: string[];
|
|
1384
|
+
maxConcurrent: number;
|
|
1385
|
+
permissionMode: string;
|
|
1386
|
+
provider?: string | undefined;
|
|
1387
|
+
model?: string | undefined;
|
|
1388
|
+
systemPrompt?: string | undefined;
|
|
1389
|
+
}, {
|
|
1390
|
+
name: string;
|
|
1391
|
+
workspace: string;
|
|
1392
|
+
provider?: string | undefined;
|
|
1393
|
+
model?: string | undefined;
|
|
1394
|
+
systemPrompt?: string | undefined;
|
|
1395
|
+
tier?: "claude-code" | "sdk" | "orchestrator" | undefined;
|
|
1396
|
+
mentions?: string[] | undefined;
|
|
1397
|
+
maxConcurrent?: number | undefined;
|
|
1398
|
+
permissionMode?: string | undefined;
|
|
1399
|
+
}>>>;
|
|
1400
|
+
channels: z.ZodDefault<z.ZodObject<{
|
|
1401
|
+
telegram: z.ZodDefault<z.ZodObject<{
|
|
1402
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
1403
|
+
accounts: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
1404
|
+
token: z.ZodString;
|
|
1405
|
+
agentBinding: z.ZodString;
|
|
1406
|
+
}, "strip", z.ZodTypeAny, {
|
|
1407
|
+
token: string;
|
|
1408
|
+
agentBinding: string;
|
|
1409
|
+
}, {
|
|
1410
|
+
token: string;
|
|
1411
|
+
agentBinding: string;
|
|
1412
|
+
}>>>;
|
|
1413
|
+
policy: z.ZodDefault<z.ZodObject<{
|
|
1414
|
+
dm: z.ZodDefault<z.ZodEnum<["pair", "block"]>>;
|
|
1415
|
+
group: z.ZodDefault<z.ZodEnum<["mention-required", "all"]>>;
|
|
1416
|
+
}, "strip", z.ZodTypeAny, {
|
|
1417
|
+
dm: "block" | "pair";
|
|
1418
|
+
group: "all" | "mention-required";
|
|
1419
|
+
}, {
|
|
1420
|
+
dm?: "block" | "pair" | undefined;
|
|
1421
|
+
group?: "all" | "mention-required" | undefined;
|
|
1422
|
+
}>>;
|
|
1423
|
+
}, "strip", z.ZodTypeAny, {
|
|
1424
|
+
enabled: boolean;
|
|
1425
|
+
accounts: Record<string, {
|
|
1426
|
+
token: string;
|
|
1427
|
+
agentBinding: string;
|
|
1428
|
+
}>;
|
|
1429
|
+
policy: {
|
|
1430
|
+
dm: "block" | "pair";
|
|
1431
|
+
group: "all" | "mention-required";
|
|
1432
|
+
};
|
|
1433
|
+
}, {
|
|
1434
|
+
enabled?: boolean | undefined;
|
|
1435
|
+
accounts?: Record<string, {
|
|
1436
|
+
token: string;
|
|
1437
|
+
agentBinding: string;
|
|
1438
|
+
}> | undefined;
|
|
1439
|
+
policy?: {
|
|
1440
|
+
dm?: "block" | "pair" | undefined;
|
|
1441
|
+
group?: "all" | "mention-required" | undefined;
|
|
1442
|
+
} | undefined;
|
|
1443
|
+
}>>;
|
|
1444
|
+
whatsapp: z.ZodDefault<z.ZodObject<{
|
|
1445
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
1446
|
+
sessionDir: z.ZodDefault<z.ZodString>;
|
|
1447
|
+
agentBinding: z.ZodOptional<z.ZodString>;
|
|
1448
|
+
}, "strip", z.ZodTypeAny, {
|
|
1449
|
+
enabled: boolean;
|
|
1450
|
+
sessionDir: string;
|
|
1451
|
+
agentBinding?: string | undefined;
|
|
1452
|
+
}, {
|
|
1453
|
+
enabled?: boolean | undefined;
|
|
1454
|
+
agentBinding?: string | undefined;
|
|
1455
|
+
sessionDir?: string | undefined;
|
|
1456
|
+
}>>;
|
|
1457
|
+
}, "strip", z.ZodTypeAny, {
|
|
1458
|
+
telegram: {
|
|
1459
|
+
enabled: boolean;
|
|
1460
|
+
accounts: Record<string, {
|
|
1461
|
+
token: string;
|
|
1462
|
+
agentBinding: string;
|
|
1463
|
+
}>;
|
|
1464
|
+
policy: {
|
|
1465
|
+
dm: "block" | "pair";
|
|
1466
|
+
group: "all" | "mention-required";
|
|
1467
|
+
};
|
|
1468
|
+
};
|
|
1469
|
+
whatsapp: {
|
|
1470
|
+
enabled: boolean;
|
|
1471
|
+
sessionDir: string;
|
|
1472
|
+
agentBinding?: string | undefined;
|
|
1473
|
+
};
|
|
1474
|
+
}, {
|
|
1475
|
+
telegram?: {
|
|
1476
|
+
enabled?: boolean | undefined;
|
|
1477
|
+
accounts?: Record<string, {
|
|
1478
|
+
token: string;
|
|
1479
|
+
agentBinding: string;
|
|
1480
|
+
}> | undefined;
|
|
1481
|
+
policy?: {
|
|
1482
|
+
dm?: "block" | "pair" | undefined;
|
|
1483
|
+
group?: "all" | "mention-required" | undefined;
|
|
1484
|
+
} | undefined;
|
|
1485
|
+
} | undefined;
|
|
1486
|
+
whatsapp?: {
|
|
1487
|
+
enabled?: boolean | undefined;
|
|
1488
|
+
agentBinding?: string | undefined;
|
|
1489
|
+
sessionDir?: string | undefined;
|
|
1490
|
+
} | undefined;
|
|
1491
|
+
}>>;
|
|
1492
|
+
crons: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
1493
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
1494
|
+
schedule: z.ZodString;
|
|
1495
|
+
timezone: z.ZodDefault<z.ZodString>;
|
|
1496
|
+
agent: z.ZodString;
|
|
1497
|
+
prompt: z.ZodString;
|
|
1498
|
+
timeout: z.ZodDefault<z.ZodNumber>;
|
|
1499
|
+
model: z.ZodOptional<z.ZodString>;
|
|
1500
|
+
onError: z.ZodDefault<z.ZodEnum<["log", "notify", "disable"]>>;
|
|
1501
|
+
}, "strip", z.ZodTypeAny, {
|
|
1502
|
+
enabled: boolean;
|
|
1503
|
+
agent: string;
|
|
1504
|
+
timeout: number;
|
|
1505
|
+
prompt: string;
|
|
1506
|
+
schedule: string;
|
|
1507
|
+
timezone: string;
|
|
1508
|
+
onError: "log" | "notify" | "disable";
|
|
1509
|
+
model?: string | undefined;
|
|
1510
|
+
}, {
|
|
1511
|
+
agent: string;
|
|
1512
|
+
prompt: string;
|
|
1513
|
+
schedule: string;
|
|
1514
|
+
model?: string | undefined;
|
|
1515
|
+
enabled?: boolean | undefined;
|
|
1516
|
+
timeout?: number | undefined;
|
|
1517
|
+
timezone?: string | undefined;
|
|
1518
|
+
onError?: "log" | "notify" | "disable" | undefined;
|
|
1519
|
+
}>>>;
|
|
1520
|
+
mesh: z.ZodDefault<z.ZodObject<{
|
|
1521
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
1522
|
+
peers: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
1523
|
+
url: z.ZodString;
|
|
1524
|
+
name: z.ZodString;
|
|
1525
|
+
token: z.ZodOptional<z.ZodString>;
|
|
1526
|
+
}, "strip", z.ZodTypeAny, {
|
|
1527
|
+
name: string;
|
|
1528
|
+
url: string;
|
|
1529
|
+
token?: string | undefined;
|
|
1530
|
+
}, {
|
|
1531
|
+
name: string;
|
|
1532
|
+
url: string;
|
|
1533
|
+
token?: string | undefined;
|
|
1534
|
+
}>, "many">>;
|
|
1535
|
+
discovery: z.ZodDefault<z.ZodEnum<["static", "mdns"]>>;
|
|
1536
|
+
healthCheck: z.ZodDefault<z.ZodObject<{
|
|
1537
|
+
interval: z.ZodDefault<z.ZodNumber>;
|
|
1538
|
+
timeout: z.ZodDefault<z.ZodNumber>;
|
|
1539
|
+
}, "strip", z.ZodTypeAny, {
|
|
1540
|
+
timeout: number;
|
|
1541
|
+
interval: number;
|
|
1542
|
+
}, {
|
|
1543
|
+
timeout?: number | undefined;
|
|
1544
|
+
interval?: number | undefined;
|
|
1545
|
+
}>>;
|
|
1546
|
+
}, "strip", z.ZodTypeAny, {
|
|
1547
|
+
enabled: boolean;
|
|
1548
|
+
peers: {
|
|
1549
|
+
name: string;
|
|
1550
|
+
url: string;
|
|
1551
|
+
token?: string | undefined;
|
|
1552
|
+
}[];
|
|
1553
|
+
discovery: "static" | "mdns";
|
|
1554
|
+
healthCheck: {
|
|
1555
|
+
timeout: number;
|
|
1556
|
+
interval: number;
|
|
1557
|
+
};
|
|
1558
|
+
}, {
|
|
1559
|
+
enabled?: boolean | undefined;
|
|
1560
|
+
peers?: {
|
|
1561
|
+
name: string;
|
|
1562
|
+
url: string;
|
|
1563
|
+
token?: string | undefined;
|
|
1564
|
+
}[] | undefined;
|
|
1565
|
+
discovery?: "static" | "mdns" | undefined;
|
|
1566
|
+
healthCheck?: {
|
|
1567
|
+
timeout?: number | undefined;
|
|
1568
|
+
interval?: number | undefined;
|
|
1569
|
+
} | undefined;
|
|
1570
|
+
}>>;
|
|
1571
|
+
}, "strip", z.ZodTypeAny, {
|
|
1572
|
+
agents: Record<string, {
|
|
1573
|
+
name: string;
|
|
1574
|
+
workspace: string;
|
|
1575
|
+
tier: "claude-code" | "sdk" | "orchestrator";
|
|
1576
|
+
mentions: string[];
|
|
1577
|
+
maxConcurrent: number;
|
|
1578
|
+
permissionMode: string;
|
|
1579
|
+
provider?: string | undefined;
|
|
1580
|
+
model?: string | undefined;
|
|
1581
|
+
systemPrompt?: string | undefined;
|
|
1582
|
+
}>;
|
|
1583
|
+
node: {
|
|
1584
|
+
id: string;
|
|
1585
|
+
name: string;
|
|
1586
|
+
bind: string;
|
|
1587
|
+
};
|
|
1588
|
+
providers: Record<string, {
|
|
1589
|
+
apiKey?: string | undefined;
|
|
1590
|
+
defaultModel?: string | undefined;
|
|
1591
|
+
baseUrl?: string | undefined;
|
|
1592
|
+
}>;
|
|
1593
|
+
channels: {
|
|
1594
|
+
telegram: {
|
|
1595
|
+
enabled: boolean;
|
|
1596
|
+
accounts: Record<string, {
|
|
1597
|
+
token: string;
|
|
1598
|
+
agentBinding: string;
|
|
1599
|
+
}>;
|
|
1600
|
+
policy: {
|
|
1601
|
+
dm: "block" | "pair";
|
|
1602
|
+
group: "all" | "mention-required";
|
|
1603
|
+
};
|
|
1604
|
+
};
|
|
1605
|
+
whatsapp: {
|
|
1606
|
+
enabled: boolean;
|
|
1607
|
+
sessionDir: string;
|
|
1608
|
+
agentBinding?: string | undefined;
|
|
1609
|
+
};
|
|
1610
|
+
};
|
|
1611
|
+
crons: Record<string, {
|
|
1612
|
+
enabled: boolean;
|
|
1613
|
+
agent: string;
|
|
1614
|
+
timeout: number;
|
|
1615
|
+
prompt: string;
|
|
1616
|
+
schedule: string;
|
|
1617
|
+
timezone: string;
|
|
1618
|
+
onError: "log" | "notify" | "disable";
|
|
1619
|
+
model?: string | undefined;
|
|
1620
|
+
}>;
|
|
1621
|
+
mesh: {
|
|
1622
|
+
enabled: boolean;
|
|
1623
|
+
peers: {
|
|
1624
|
+
name: string;
|
|
1625
|
+
url: string;
|
|
1626
|
+
token?: string | undefined;
|
|
1627
|
+
}[];
|
|
1628
|
+
discovery: "static" | "mdns";
|
|
1629
|
+
healthCheck: {
|
|
1630
|
+
timeout: number;
|
|
1631
|
+
interval: number;
|
|
1632
|
+
};
|
|
1633
|
+
};
|
|
1634
|
+
}, {
|
|
1635
|
+
node: {
|
|
1636
|
+
id: string;
|
|
1637
|
+
name: string;
|
|
1638
|
+
bind?: string | undefined;
|
|
1639
|
+
};
|
|
1640
|
+
agents?: Record<string, {
|
|
1641
|
+
name: string;
|
|
1642
|
+
workspace: string;
|
|
1643
|
+
provider?: string | undefined;
|
|
1644
|
+
model?: string | undefined;
|
|
1645
|
+
systemPrompt?: string | undefined;
|
|
1646
|
+
tier?: "claude-code" | "sdk" | "orchestrator" | undefined;
|
|
1647
|
+
mentions?: string[] | undefined;
|
|
1648
|
+
maxConcurrent?: number | undefined;
|
|
1649
|
+
permissionMode?: string | undefined;
|
|
1650
|
+
}> | undefined;
|
|
1651
|
+
providers?: Record<string, {
|
|
1652
|
+
apiKey?: string | undefined;
|
|
1653
|
+
defaultModel?: string | undefined;
|
|
1654
|
+
baseUrl?: string | undefined;
|
|
1655
|
+
}> | undefined;
|
|
1656
|
+
channels?: {
|
|
1657
|
+
telegram?: {
|
|
1658
|
+
enabled?: boolean | undefined;
|
|
1659
|
+
accounts?: Record<string, {
|
|
1660
|
+
token: string;
|
|
1661
|
+
agentBinding: string;
|
|
1662
|
+
}> | undefined;
|
|
1663
|
+
policy?: {
|
|
1664
|
+
dm?: "block" | "pair" | undefined;
|
|
1665
|
+
group?: "all" | "mention-required" | undefined;
|
|
1666
|
+
} | undefined;
|
|
1667
|
+
} | undefined;
|
|
1668
|
+
whatsapp?: {
|
|
1669
|
+
enabled?: boolean | undefined;
|
|
1670
|
+
agentBinding?: string | undefined;
|
|
1671
|
+
sessionDir?: string | undefined;
|
|
1672
|
+
} | undefined;
|
|
1673
|
+
} | undefined;
|
|
1674
|
+
crons?: Record<string, {
|
|
1675
|
+
agent: string;
|
|
1676
|
+
prompt: string;
|
|
1677
|
+
schedule: string;
|
|
1678
|
+
model?: string | undefined;
|
|
1679
|
+
enabled?: boolean | undefined;
|
|
1680
|
+
timeout?: number | undefined;
|
|
1681
|
+
timezone?: string | undefined;
|
|
1682
|
+
onError?: "log" | "notify" | "disable" | undefined;
|
|
1683
|
+
}> | undefined;
|
|
1684
|
+
mesh?: {
|
|
1685
|
+
enabled?: boolean | undefined;
|
|
1686
|
+
peers?: {
|
|
1687
|
+
name: string;
|
|
1688
|
+
url: string;
|
|
1689
|
+
token?: string | undefined;
|
|
1690
|
+
}[] | undefined;
|
|
1691
|
+
discovery?: "static" | "mdns" | undefined;
|
|
1692
|
+
healthCheck?: {
|
|
1693
|
+
timeout?: number | undefined;
|
|
1694
|
+
interval?: number | undefined;
|
|
1695
|
+
} | undefined;
|
|
1696
|
+
} | undefined;
|
|
1697
|
+
}>;
|
|
1698
|
+
type DaemonConfig = z.infer<typeof daemonConfigSchema>;
|
|
1699
|
+
type AgentDef = z.infer<typeof agentConfigSchema>;
|
|
1700
|
+
type CronJobDef = z.infer<typeof cronJobSchema>;
|
|
1701
|
+
type MeshPeer = z.infer<typeof meshPeerSchema>;
|
|
1702
|
+
/**
|
|
1703
|
+
* Load daemon config from agentx.json, with env var expansion and validation.
|
|
1704
|
+
*/
|
|
1705
|
+
declare function loadDaemonConfig(configPath?: string): DaemonConfig;
|
|
1706
|
+
/**
|
|
1707
|
+
* Validate agent workspace directories exist and have .claude/ setup.
|
|
1708
|
+
*/
|
|
1709
|
+
declare function validateWorkspaces(config: DaemonConfig): string[];
|
|
1710
|
+
|
|
1711
|
+
interface PeerState {
|
|
1712
|
+
peer: MeshPeer;
|
|
1713
|
+
client: A2AClient;
|
|
1714
|
+
healthy: boolean;
|
|
1715
|
+
lastCheck?: Date;
|
|
1716
|
+
agentCard?: AgentCard;
|
|
1717
|
+
agents: AgentSkill[];
|
|
1718
|
+
}
|
|
1719
|
+
declare class A2AMesh {
|
|
1720
|
+
private peers;
|
|
1721
|
+
private healthTimer?;
|
|
1722
|
+
private config;
|
|
1723
|
+
private log;
|
|
1724
|
+
constructor(config: DaemonConfig, log?: (...args: unknown[]) => void);
|
|
1725
|
+
/**
|
|
1726
|
+
* Start the mesh: discover peers and begin health checks.
|
|
1727
|
+
*/
|
|
1728
|
+
start(): Promise<void>;
|
|
1729
|
+
stop(): Promise<void>;
|
|
1730
|
+
/**
|
|
1731
|
+
* Discover agent cards from all peers.
|
|
1732
|
+
*/
|
|
1733
|
+
discoverAll(): Promise<void>;
|
|
1734
|
+
private discoverPeer;
|
|
1735
|
+
/**
|
|
1736
|
+
* Send a task to a remote peer by name.
|
|
1737
|
+
* Uses the peer's /task HTTP endpoint (agentx daemon API).
|
|
1738
|
+
* If no agent specified, uses the first available agent on the peer.
|
|
1739
|
+
*/
|
|
1740
|
+
sendTask(peerName: string, text: string, agentId?: string): Promise<string>;
|
|
1741
|
+
/**
|
|
1742
|
+
* Find a peer that has a specific skill.
|
|
1743
|
+
*/
|
|
1744
|
+
findPeerWithSkill(skillId: string): PeerState | undefined;
|
|
1745
|
+
/**
|
|
1746
|
+
* Get the combined agent directory across all healthy peers.
|
|
1747
|
+
*/
|
|
1748
|
+
directory(): Array<{
|
|
1749
|
+
peer: string;
|
|
1750
|
+
peerUrl: string;
|
|
1751
|
+
healthy: boolean;
|
|
1752
|
+
skills: AgentSkill[];
|
|
1753
|
+
lastCheck?: Date;
|
|
1754
|
+
}>;
|
|
1755
|
+
}
|
|
1756
|
+
|
|
1757
|
+
declare class AgentXDaemon {
|
|
1758
|
+
private config;
|
|
1759
|
+
private registry;
|
|
1760
|
+
private router;
|
|
1761
|
+
private cron;
|
|
1762
|
+
private mesh?;
|
|
1763
|
+
private hooks;
|
|
1764
|
+
private httpServer?;
|
|
1765
|
+
private log;
|
|
1766
|
+
constructor(configPath?: string);
|
|
1767
|
+
start(): Promise<void>;
|
|
1768
|
+
stop(): Promise<void>;
|
|
1769
|
+
private startChannels;
|
|
1770
|
+
private startHttpApi;
|
|
1771
|
+
private handleHttp;
|
|
1772
|
+
private json;
|
|
1773
|
+
}
|
|
1774
|
+
|
|
1775
|
+
interface AgentPeer {
|
|
1776
|
+
id: string;
|
|
1777
|
+
name: string;
|
|
1778
|
+
handle?: string;
|
|
1779
|
+
role?: string;
|
|
1780
|
+
}
|
|
1781
|
+
interface AgentTask {
|
|
1782
|
+
message: string;
|
|
1783
|
+
agentId: string;
|
|
1784
|
+
context?: {
|
|
1785
|
+
channel?: string;
|
|
1786
|
+
sender?: string;
|
|
1787
|
+
group?: string;
|
|
1788
|
+
conversationHistory?: Array<{
|
|
1789
|
+
role: string;
|
|
1790
|
+
content: string;
|
|
1791
|
+
}>;
|
|
1792
|
+
/** This agent's own handle on the current channel */
|
|
1793
|
+
myHandle?: string;
|
|
1794
|
+
/** Other available agents and their handles */
|
|
1795
|
+
peers?: AgentPeer[];
|
|
1796
|
+
};
|
|
1797
|
+
}
|
|
1798
|
+
interface AgentResponse {
|
|
1799
|
+
content: string;
|
|
1800
|
+
error?: string;
|
|
1801
|
+
tokensUsed?: number;
|
|
1802
|
+
duration?: number;
|
|
1803
|
+
claudeSessionId?: string;
|
|
1804
|
+
}
|
|
1805
|
+
/** Callback for streaming text deltas */
|
|
1806
|
+
type StreamCallback = (delta: string, fullText: string) => void;
|
|
1807
|
+
/**
|
|
1808
|
+
* Execute a task using the Claude Code CLI (tier: "claude-code").
|
|
1809
|
+
* Non-streaming — waits for full response.
|
|
1810
|
+
*/
|
|
1811
|
+
declare function executeClaudeCode(agent: AgentDef, task: AgentTask, historyContext?: string, resumeSessionId?: string): Promise<AgentResponse>;
|
|
1812
|
+
/**
|
|
1813
|
+
* Execute a task using the Claude Agent SDK (tier: "sdk").
|
|
1814
|
+
*/
|
|
1815
|
+
declare function executeSdk(agent: AgentDef, task: AgentTask, apiKey: string): Promise<AgentResponse>;
|
|
1816
|
+
/**
|
|
1817
|
+
* Execute a task using agentx's own orchestrator (tier: "orchestrator").
|
|
1818
|
+
*/
|
|
1819
|
+
declare function executeOrchestrator(agent: AgentDef, task: AgentTask, apiKey?: string): Promise<AgentResponse>;
|
|
1820
|
+
/**
|
|
1821
|
+
* Route a task to the correct execution tier.
|
|
1822
|
+
*/
|
|
1823
|
+
declare function executeTask(agent: AgentDef, task: AgentTask, providers: Record<string, {
|
|
1824
|
+
apiKey?: string;
|
|
1825
|
+
}>, onDelta?: StreamCallback, historyContext?: string, resumeSessionId?: string): Promise<AgentResponse>;
|
|
1826
|
+
|
|
1827
|
+
declare class AgentRegistry {
|
|
1828
|
+
private agents;
|
|
1829
|
+
private config;
|
|
1830
|
+
private providers;
|
|
1831
|
+
private sessions;
|
|
1832
|
+
private log;
|
|
1833
|
+
constructor(config: DaemonConfig, log?: (...args: unknown[]) => void);
|
|
1834
|
+
/**
|
|
1835
|
+
* Get agent definition by ID.
|
|
1836
|
+
*/
|
|
1837
|
+
getAgent(id: string): AgentDef | undefined;
|
|
1838
|
+
/**
|
|
1839
|
+
* Find agent by mention pattern (e.g., "@nadia" -> "marketing-agent").
|
|
1840
|
+
* Returns the agent with the longest (most specific) mention match.
|
|
1841
|
+
*/
|
|
1842
|
+
findByMention(text: string): string | undefined;
|
|
1843
|
+
/**
|
|
1844
|
+
* Find ALL agents mentioned in text (for bot-to-bot detection).
|
|
1845
|
+
*/
|
|
1846
|
+
findAllMentioned(text: string): string[];
|
|
1847
|
+
/**
|
|
1848
|
+
* Get the primary channel handle for an agent (e.g. "@noqta_devops_bot" on telegram).
|
|
1849
|
+
*/
|
|
1850
|
+
private getChannelHandle;
|
|
1851
|
+
/**
|
|
1852
|
+
* Enrich the task context with peer roster and channel handles.
|
|
1853
|
+
*/
|
|
1854
|
+
private enrichTaskContext;
|
|
1855
|
+
/**
|
|
1856
|
+
* Execute a task on an agent. Respects maxConcurrent limit.
|
|
1857
|
+
*/
|
|
1858
|
+
execute(task: AgentTask, onDelta?: StreamCallback): Promise<AgentResponse>;
|
|
1859
|
+
/**
|
|
1860
|
+
* List all agents and their status.
|
|
1861
|
+
*/
|
|
1862
|
+
list(): Array<{
|
|
1863
|
+
id: string;
|
|
1864
|
+
name: string;
|
|
1865
|
+
tier: string;
|
|
1866
|
+
workspace: string;
|
|
1867
|
+
active: number;
|
|
1868
|
+
total: number;
|
|
1869
|
+
errors: number;
|
|
1870
|
+
lastActive?: Date;
|
|
1871
|
+
}>;
|
|
1872
|
+
}
|
|
1873
|
+
|
|
1874
|
+
interface IncomingMessage {
|
|
1875
|
+
id: string;
|
|
1876
|
+
channel: string;
|
|
1877
|
+
accountId: string;
|
|
1878
|
+
sender: {
|
|
1879
|
+
id: string;
|
|
1880
|
+
name: string;
|
|
1881
|
+
username?: string;
|
|
1882
|
+
};
|
|
1883
|
+
group?: {
|
|
1884
|
+
id: string;
|
|
1885
|
+
name: string;
|
|
1886
|
+
};
|
|
1887
|
+
text: string;
|
|
1888
|
+
replyTo?: string;
|
|
1889
|
+
timestamp: Date;
|
|
1890
|
+
raw?: unknown;
|
|
1891
|
+
}
|
|
1892
|
+
interface OutgoingMessage {
|
|
1893
|
+
channel: string;
|
|
1894
|
+
chatId: string;
|
|
1895
|
+
text: string;
|
|
1896
|
+
replyTo?: string;
|
|
1897
|
+
parseMode?: "markdown" | "html" | "plain";
|
|
1898
|
+
}
|
|
1899
|
+
interface ChannelAdapter {
|
|
1900
|
+
readonly name: string;
|
|
1901
|
+
/** Start polling or webhook listener */
|
|
1902
|
+
start(): Promise<void>;
|
|
1903
|
+
/** Stop the adapter gracefully */
|
|
1904
|
+
stop(): Promise<void>;
|
|
1905
|
+
/** Send a message back to a chat */
|
|
1906
|
+
send(msg: OutgoingMessage): Promise<string | void>;
|
|
1907
|
+
/** Edit an existing message (returns false if not supported) */
|
|
1908
|
+
editMessage?(chatId: string, messageId: string, text: string, parseMode?: string): Promise<boolean>;
|
|
1909
|
+
/** Send typing/action indicator */
|
|
1910
|
+
sendTyping?(chatId: string): Promise<void>;
|
|
1911
|
+
/** React to a message with an emoji (e.g., 👀 for seen) */
|
|
1912
|
+
react?(chatId: string, messageId: string, emoji?: string): Promise<void>;
|
|
1913
|
+
/** Register handler for incoming messages */
|
|
1914
|
+
onMessage(handler: (msg: IncomingMessage) => Promise<void>): void;
|
|
1915
|
+
}
|
|
1916
|
+
|
|
1917
|
+
declare class MessageRouter {
|
|
1918
|
+
private registry;
|
|
1919
|
+
private config;
|
|
1920
|
+
private channels;
|
|
1921
|
+
private hooks?;
|
|
1922
|
+
private log;
|
|
1923
|
+
constructor(registry: AgentRegistry, config: DaemonConfig, hooks?: HookRegistry, log?: (...args: unknown[]) => void);
|
|
1924
|
+
addChannel(adapter: ChannelAdapter): void;
|
|
1925
|
+
startAll(): Promise<void>;
|
|
1926
|
+
stopAll(): Promise<void>;
|
|
1927
|
+
private handleMessage;
|
|
1928
|
+
/**
|
|
1929
|
+
* Check if an agent's response mentions another agent.
|
|
1930
|
+
* If so, route the response as a new task to that agent.
|
|
1931
|
+
*/
|
|
1932
|
+
private handleBotToBotMentions;
|
|
1933
|
+
private adapterSend;
|
|
1934
|
+
private adapterEdit;
|
|
1935
|
+
private adapterReact;
|
|
1936
|
+
private startTypingLoop;
|
|
1937
|
+
private getAccountForAgent;
|
|
1938
|
+
private resolveAgent;
|
|
1939
|
+
}
|
|
1940
|
+
|
|
1941
|
+
interface TelegramAccountConfig {
|
|
1942
|
+
token: string;
|
|
1943
|
+
agentBinding: string;
|
|
1944
|
+
}
|
|
1945
|
+
declare class TelegramAdapter implements ChannelAdapter {
|
|
1946
|
+
readonly name = "telegram";
|
|
1947
|
+
private accounts;
|
|
1948
|
+
private offsets;
|
|
1949
|
+
private handler?;
|
|
1950
|
+
private polling;
|
|
1951
|
+
private log;
|
|
1952
|
+
constructor(accounts: Record<string, TelegramAccountConfig>, log?: (...args: unknown[]) => void);
|
|
1953
|
+
onMessage(handler: (msg: IncomingMessage) => Promise<void>): void;
|
|
1954
|
+
start(): Promise<void>;
|
|
1955
|
+
stop(): Promise<void>;
|
|
1956
|
+
/**
|
|
1957
|
+
* Get token for a specific account ID. Used by router to send from correct bot.
|
|
1958
|
+
*/
|
|
1959
|
+
getTokenForAccount(accountId: string): string | undefined;
|
|
1960
|
+
/**
|
|
1961
|
+
* Get the default (first) account token as fallback.
|
|
1962
|
+
*/
|
|
1963
|
+
private getDefaultToken;
|
|
1964
|
+
/**
|
|
1965
|
+
* Resolve which token to use: prefer accountId, fall back to chatAccountMap, then default.
|
|
1966
|
+
*/
|
|
1967
|
+
private resolveToken;
|
|
1968
|
+
/** Track which account a chat was last seen on (for DMs) */
|
|
1969
|
+
private chatAccountMap;
|
|
1970
|
+
/**
|
|
1971
|
+
* Send a message. Returns the sent message ID.
|
|
1972
|
+
* Pass accountId to send from a specific bot account.
|
|
1973
|
+
*/
|
|
1974
|
+
send(msg: OutgoingMessage & {
|
|
1975
|
+
accountId?: string;
|
|
1976
|
+
}): Promise<string>;
|
|
1977
|
+
/**
|
|
1978
|
+
* Edit an existing message (for streaming updates).
|
|
1979
|
+
*/
|
|
1980
|
+
editMessage(chatId: string, messageId: string, text: string, parseMode?: string, accountId?: string): Promise<boolean>;
|
|
1981
|
+
/**
|
|
1982
|
+
* React to a message with an emoji.
|
|
1983
|
+
*/
|
|
1984
|
+
react(chatId: string, messageId: string, emoji?: string, accountId?: string): Promise<void>;
|
|
1985
|
+
/**
|
|
1986
|
+
* Send typing indicator.
|
|
1987
|
+
*/
|
|
1988
|
+
sendTyping(chatId: string, accountId?: string): Promise<void>;
|
|
1989
|
+
private pollLoop;
|
|
1990
|
+
private apiCall;
|
|
1991
|
+
}
|
|
1992
|
+
|
|
1993
|
+
declare class WhatsAppAdapter implements ChannelAdapter {
|
|
1994
|
+
readonly name = "whatsapp";
|
|
1995
|
+
private sessionDir;
|
|
1996
|
+
private agentBinding?;
|
|
1997
|
+
private handler?;
|
|
1998
|
+
private log;
|
|
1999
|
+
constructor(config: {
|
|
2000
|
+
sessionDir: string;
|
|
2001
|
+
agentBinding?: string;
|
|
2002
|
+
}, log?: (...args: unknown[]) => void);
|
|
2003
|
+
onMessage(handler: (msg: IncomingMessage) => Promise<void>): void;
|
|
2004
|
+
start(): Promise<void>;
|
|
2005
|
+
stop(): Promise<void>;
|
|
2006
|
+
send(msg: OutgoingMessage): Promise<void>;
|
|
2007
|
+
}
|
|
2008
|
+
|
|
2009
|
+
interface CronJobState {
|
|
2010
|
+
id: string;
|
|
2011
|
+
enabled: boolean;
|
|
2012
|
+
schedule: string;
|
|
2013
|
+
timezone: string;
|
|
2014
|
+
agent: string;
|
|
2015
|
+
prompt: string;
|
|
2016
|
+
timeout: number;
|
|
2017
|
+
model?: string;
|
|
2018
|
+
onError: "log" | "notify" | "disable";
|
|
2019
|
+
lastRun?: Date;
|
|
2020
|
+
nextRun?: Date;
|
|
2021
|
+
consecutiveErrors: number;
|
|
2022
|
+
totalRuns: number;
|
|
2023
|
+
}
|
|
2024
|
+
interface CronRunResult {
|
|
2025
|
+
jobId: string;
|
|
2026
|
+
startedAt: Date;
|
|
2027
|
+
completedAt: Date;
|
|
2028
|
+
success: boolean;
|
|
2029
|
+
response?: string;
|
|
2030
|
+
error?: string;
|
|
2031
|
+
duration: number;
|
|
2032
|
+
}
|
|
2033
|
+
|
|
2034
|
+
declare class CronScheduler {
|
|
2035
|
+
private jobs;
|
|
2036
|
+
private timers;
|
|
2037
|
+
private registry;
|
|
2038
|
+
private hooks?;
|
|
2039
|
+
private runsDir;
|
|
2040
|
+
private running;
|
|
2041
|
+
private log;
|
|
2042
|
+
constructor(config: DaemonConfig, registry: AgentRegistry, hooks?: HookRegistry, log?: (...args: unknown[]) => void);
|
|
2043
|
+
start(): Promise<void>;
|
|
2044
|
+
stop(): Promise<void>;
|
|
2045
|
+
private scheduleNext;
|
|
2046
|
+
private executeJob;
|
|
2047
|
+
private logRun;
|
|
2048
|
+
/**
|
|
2049
|
+
* List all jobs and their status.
|
|
2050
|
+
*/
|
|
2051
|
+
list(): CronJobState[];
|
|
2052
|
+
}
|
|
2053
|
+
|
|
2054
|
+
interface ProviderCapabilities {
|
|
2055
|
+
streaming: boolean;
|
|
2056
|
+
tools: boolean;
|
|
2057
|
+
vision: boolean;
|
|
2058
|
+
thinking: boolean;
|
|
2059
|
+
maxContext: number;
|
|
2060
|
+
}
|
|
2061
|
+
declare const PROVIDER_CAPABILITIES: Record<string, ProviderCapabilities>;
|
|
2062
|
+
/**
|
|
2063
|
+
* Check provider capabilities and return warnings for missing features.
|
|
2064
|
+
*/
|
|
2065
|
+
declare function checkCapabilities(providerName: string, requiredFeatures?: string[]): string[];
|
|
2066
|
+
|
|
2067
|
+
interface AuthConfig {
|
|
2068
|
+
provider: "claude" | "claude-code";
|
|
2069
|
+
authType: "api-key" | "oauth";
|
|
2070
|
+
token: string;
|
|
2071
|
+
model: string;
|
|
2072
|
+
}
|
|
2073
|
+
declare function loadAuthConfig(): AuthConfig | null;
|
|
2074
|
+
declare function saveAuthConfig(config: AuthConfig): void;
|
|
2075
|
+
/**
|
|
2076
|
+
* Resolve a token for the Anthropic API.
|
|
2077
|
+
* Priority: (1) explicit token, (2) env vars, (3) ~/.agentx/auth.json, (4) OpenClaw auth stores
|
|
2078
|
+
*/
|
|
2079
|
+
declare function resolveToken(explicitKey?: string): {
|
|
2080
|
+
token: string;
|
|
2081
|
+
authType: "api-key" | "oauth";
|
|
2082
|
+
} | null;
|
|
2083
|
+
/**
|
|
2084
|
+
* Reusable interactive setup flow. Returns the saved config, or null if the user cancelled.
|
|
2085
|
+
*/
|
|
2086
|
+
declare function runModelSetup(): Promise<AuthConfig | null>;
|
|
2087
|
+
/**
|
|
2088
|
+
* Ensure credentials are available. If not, auto-prompt the interactive setup.
|
|
2089
|
+
* Returns true if credentials are ready, false if user cancelled.
|
|
2090
|
+
*/
|
|
2091
|
+
declare function ensureCredentials(explicitKey?: string): Promise<boolean>;
|
|
2092
|
+
|
|
2093
|
+
declare const logger: {
|
|
2094
|
+
error(...args: unknown[]): void;
|
|
2095
|
+
warn(...args: unknown[]): void;
|
|
2096
|
+
info(...args: unknown[]): void;
|
|
2097
|
+
success(...args: unknown[]): void;
|
|
2098
|
+
break(): void;
|
|
2099
|
+
};
|
|
2100
|
+
|
|
2101
|
+
declare function handleError(error: unknown): void;
|
|
2102
|
+
|
|
2103
|
+
declare function getPackageInfo(): PackageJson;
|
|
2104
|
+
|
|
2105
|
+
export { A2AClient, A2AMesh, A2AServer, A2AServerConfig, ALL_TOOL_NAMES, AgentCard, AgentConfig, AgentContext, AgentDef, AgentProvider, AgentRegistry, AgentResponse, AgentTask, AgentXDaemon, AgentXRuntime, AnthropicMessage, AuthConfig, BLOCKING_EVENTS, ChannelAdapter, ClaudeCodeProvider, ClaudeProvider, ContentBlock, ContextBuilder, CronJobDef, CronJobState, CronRunResult, CronScheduler, DaemonConfig, EnhanceConfig, EnhanceEngine, EnhanceResult, GenerateOptions, GenerateResult, GenerateStreamEvent, GeneratedFile, GenerationMessage, GenerationResult, GitCommitResult, GitDiffFile, GitLogEntry, GitManager, GitStatus, HOOK_EVENTS, HealConfig, HealEngine, HealResult, HookContext, HookDefinition, HookEvent, HookHandler, HookRegistry, HookResult, IncomingMessage, Memory, MemoryEntry, MemoryHierarchy, MemoryStore, MeshPeer, MessageRouter, MiddlewareFn, ModelUsage, OUTPUT_CONFIGS, OUTPUT_TYPES, OutgoingMessage, OutputConfig, OutputType, PERMISSION_MODES, PROVIDER_CAPABILITIES, PermissionAction, PermissionConfig, PermissionManager, PermissionMode, PermissionRule, Pipeline, PipelineRequest, PipelineResponse, ProjectSchemas, ProviderCapabilities, ProviderName, ProviderOptions, RawGenerationResult, ReplEngine, ReplOptions, RuntimeConfig, Session, StepUsage, StreamEvent, Task, TaskArtifact, TaskMessage, TaskState, TaskStatusUpdate, TechStack, TelegramAdapter, ToolCallInput, ToolExecutor, ToolExecutorOptions, ToolResult, UsageSummary, UsageTracker, WhatsAppAdapter, agentConfigSchema$1 as agentConfigSchema, checkCapabilities, createAgentContext, createProvider, createSession, daemonConfigSchema, debug, detectSchemas, detectTechStack, ensureCredentials, executeClaudeCode, executeOrchestrator, executeSdk, executeTask, exportSession, formatSchemas, formatTechStack, formatToolsForSystemPrompt, gatherContext7Docs, generate, generateSkill, generateSkillMd, generateStream, getAnthropicTools, getCommand, getLegacyTools, getPackageInfo, globalHooks, globalPermissions, globalTracker, handleError, installSkillPackage, isCommand, isDebug, listInstalledSkills, listSessions, loadAuthConfig, loadDaemonConfig, loadHooks, loadLatestSession, loadLocalSkills, loadProjectInstructions, loadSession, logger, matchSkillsToTask, outputTypeDescriptions, parseCommand, parseSkillContent, parseSkillFile, permissionConfigSchema, permissionModeSchema, registerCommand, resolveAtImports, resolveOutputType, resolveToken, runModelSetup, saveAuthConfig, saveSession, setDebug, startMcpServer, validateWorkspaces };
|