ak-gemini 2.0.9 → 2.1.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/code-agent.js +435 -173
- package/index.cjs +407 -121
- package/package.json +1 -1
- package/types.d.ts +44 -23
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -306,9 +306,9 @@ export interface CodeAgentOptions extends BaseGeminiOptions {
|
|
|
306
306
|
maxRounds?: number;
|
|
307
307
|
/** Per-execution timeout in milliseconds (default: 30000) */
|
|
308
308
|
timeout?: number;
|
|
309
|
-
/** Async callback before code execution; return false to deny */
|
|
310
|
-
onBeforeExecution?: (
|
|
311
|
-
/** Notification callback after code execution */
|
|
309
|
+
/** Async callback before code/bash execution; return false to deny. Receives (content, toolName). */
|
|
310
|
+
onBeforeExecution?: (content: string, toolName: string) => Promise<boolean> | boolean;
|
|
311
|
+
/** Notification callback after code/bash execution */
|
|
312
312
|
onCodeExecution?: (code: string, output: { stdout: string; stderr: string; exitCode: number }) => void;
|
|
313
313
|
/** Files whose contents are included in the system prompt for project context */
|
|
314
314
|
importantFiles?: string[];
|
|
@@ -320,6 +320,10 @@ export interface CodeAgentOptions extends BaseGeminiOptions {
|
|
|
320
320
|
comments?: boolean;
|
|
321
321
|
/** Max consecutive failed executions before stopping (default: 3) */
|
|
322
322
|
maxRetries?: number;
|
|
323
|
+
/** Paths to skill files (markdown) loaded dynamically via the use_skill tool */
|
|
324
|
+
skills?: string[];
|
|
325
|
+
/** Plain text environment overview appended to the system prompt — describe the project, stack, conventions, etc. */
|
|
326
|
+
envOverview?: string;
|
|
323
327
|
}
|
|
324
328
|
|
|
325
329
|
export interface CodeExecution {
|
|
@@ -335,35 +339,57 @@ export interface CodeExecution {
|
|
|
335
339
|
exitCode: number;
|
|
336
340
|
}
|
|
337
341
|
|
|
342
|
+
export interface ToolCallResult {
|
|
343
|
+
tool: 'write_code' | 'execute_code' | 'write_and_run_code' | 'fix_code' | 'run_bash' | 'use_skill';
|
|
344
|
+
code?: string;
|
|
345
|
+
purpose?: string;
|
|
346
|
+
language?: string;
|
|
347
|
+
originalCode?: string;
|
|
348
|
+
fixedCode?: string;
|
|
349
|
+
explanation?: string;
|
|
350
|
+
executed?: boolean;
|
|
351
|
+
command?: string;
|
|
352
|
+
skillName?: string;
|
|
353
|
+
content?: string;
|
|
354
|
+
found?: boolean;
|
|
355
|
+
stdout?: string;
|
|
356
|
+
stderr?: string;
|
|
357
|
+
exitCode?: number;
|
|
358
|
+
denied?: boolean;
|
|
359
|
+
}
|
|
360
|
+
|
|
338
361
|
export interface CodeAgentResponse {
|
|
339
362
|
/** The agent's final text response */
|
|
340
363
|
text: string;
|
|
341
|
-
/**
|
|
364
|
+
/** Backward-compatible: only code executions (execute_code, write_and_run_code, fix_code with execute) */
|
|
342
365
|
codeExecutions: CodeExecution[];
|
|
366
|
+
/** All tool calls made during this chat turn */
|
|
367
|
+
toolCalls: ToolCallResult[];
|
|
343
368
|
/** Token usage data */
|
|
344
369
|
usage: UsageData | null;
|
|
345
370
|
}
|
|
346
371
|
|
|
347
372
|
export interface CodeAgentStreamEvent {
|
|
348
|
-
type: 'text' | 'code' | 'output' | 'done';
|
|
349
|
-
/** For 'text' events: the text chunk */
|
|
373
|
+
type: 'text' | 'code' | 'output' | 'write' | 'fix' | 'bash' | 'skill' | 'done';
|
|
350
374
|
text?: string;
|
|
351
|
-
/** For 'code' events: the code about to be executed */
|
|
352
375
|
code?: string;
|
|
353
|
-
/** For 'output' events: stdout from execution */
|
|
354
376
|
stdout?: string;
|
|
355
|
-
/** For 'output' events: stderr from execution */
|
|
356
377
|
stderr?: string;
|
|
357
|
-
/** For 'output' events: process exit code */
|
|
358
378
|
exitCode?: number;
|
|
359
|
-
/** For 'done' events: complete accumulated text */
|
|
360
379
|
fullText?: string;
|
|
361
|
-
/** For 'done' events: all code executions */
|
|
362
380
|
codeExecutions?: CodeExecution[];
|
|
363
|
-
|
|
381
|
+
toolCalls?: ToolCallResult[];
|
|
364
382
|
usage?: UsageData | null;
|
|
365
|
-
/** For 'done' events: e.g. "Max tool rounds reached" or "Agent was stopped" */
|
|
366
383
|
warning?: string;
|
|
384
|
+
purpose?: string;
|
|
385
|
+
language?: string;
|
|
386
|
+
originalCode?: string;
|
|
387
|
+
fixedCode?: string;
|
|
388
|
+
explanation?: string;
|
|
389
|
+
command?: string;
|
|
390
|
+
skillName?: string;
|
|
391
|
+
content?: string;
|
|
392
|
+
found?: boolean;
|
|
367
393
|
}
|
|
368
394
|
|
|
369
395
|
// ── Per-Message Options ──────────────────────────────────────────────────────
|
|
@@ -582,25 +608,20 @@ export declare class CodeAgent extends BaseGemini {
|
|
|
582
608
|
workingDirectory: string;
|
|
583
609
|
maxRounds: number;
|
|
584
610
|
timeout: number;
|
|
585
|
-
onBeforeExecution: ((
|
|
611
|
+
onBeforeExecution: ((content: string, toolName: string) => Promise<boolean> | boolean) | null;
|
|
586
612
|
onCodeExecution: ((code: string, output: { stdout: string; stderr: string; exitCode: number }) => void) | null;
|
|
587
|
-
/** Files whose contents are included in the system prompt */
|
|
588
613
|
importantFiles: string[];
|
|
589
|
-
/** Directory for writing script files */
|
|
590
614
|
writeDir: string;
|
|
591
|
-
/** Keep script files on disk after execution */
|
|
592
615
|
keepArtifacts: boolean;
|
|
593
|
-
/** Whether the model writes comments in generated code */
|
|
594
616
|
comments: boolean;
|
|
595
|
-
/** Max consecutive failed executions before stopping */
|
|
596
617
|
maxRetries: number;
|
|
618
|
+
skills: string[];
|
|
619
|
+
envOverview: string;
|
|
597
620
|
|
|
598
621
|
init(force?: boolean): Promise<void>;
|
|
599
622
|
chat(message: string, opts?: { labels?: Record<string, string> }): Promise<CodeAgentResponse>;
|
|
600
623
|
stream(message: string, opts?: { labels?: Record<string, string> }): AsyncGenerator<CodeAgentStreamEvent, void, unknown>;
|
|
601
|
-
|
|
602
|
-
dump(): Array<{ fileName: string; purpose: string | null; script: string; filePath: string | null }>;
|
|
603
|
-
/** Stop the agent before the next code execution. Kills any running child process. */
|
|
624
|
+
dump(): Array<{ fileName: string; purpose: string | null; script: string; filePath: string | null; tool: string }>;
|
|
604
625
|
stop(): void;
|
|
605
626
|
}
|
|
606
627
|
|