ak-gemini 2.0.9 → 2.1.3

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.
Files changed (5) hide show
  1. package/chat.js +29 -0
  2. package/code-agent.js +435 -173
  3. package/index.cjs +431 -121
  4. package/package.json +1 -1
  5. package/types.d.ts +52 -23
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "ak-gemini",
3
3
  "author": "ak@mixpanel.com",
4
4
  "description": "AK's Generative AI Helper for doing... everything",
5
- "version": "2.0.9",
5
+ "version": "2.1.3",
6
6
  "main": "index.js",
7
7
  "files": [
8
8
  "index.js",
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?: (code: string) => Promise<boolean>;
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
- /** All code executions during this interaction */
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
- /** For 'done' events: token usage */
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 ──────────────────────────────────────────────────────
@@ -395,6 +421,13 @@ export interface ChatResponse {
395
421
  usage: UsageData | null;
396
422
  }
397
423
 
424
+ export interface ChatStreamEvent {
425
+ type: 'text' | 'done';
426
+ text?: string;
427
+ fullText?: string;
428
+ usage?: UsageData | null;
429
+ }
430
+
398
431
  export interface MessageResponse {
399
432
  /** The model's text response */
400
433
  text: string;
@@ -522,6 +555,7 @@ export declare class Chat extends BaseGemini {
522
555
  constructor(options?: ChatOptions);
523
556
 
524
557
  send(message: string, opts?: { labels?: Record<string, string> }): Promise<ChatResponse>;
558
+ stream(message: string, opts?: { labels?: Record<string, string> }): AsyncGenerator<ChatStreamEvent, void, unknown>;
525
559
  }
526
560
 
527
561
  export declare class Message extends BaseGemini {
@@ -582,25 +616,20 @@ export declare class CodeAgent extends BaseGemini {
582
616
  workingDirectory: string;
583
617
  maxRounds: number;
584
618
  timeout: number;
585
- onBeforeExecution: ((code: string) => Promise<boolean>) | null;
619
+ onBeforeExecution: ((content: string, toolName: string) => Promise<boolean> | boolean) | null;
586
620
  onCodeExecution: ((code: string, output: { stdout: string; stderr: string; exitCode: number }) => void) | null;
587
- /** Files whose contents are included in the system prompt */
588
621
  importantFiles: string[];
589
- /** Directory for writing script files */
590
622
  writeDir: string;
591
- /** Keep script files on disk after execution */
592
623
  keepArtifacts: boolean;
593
- /** Whether the model writes comments in generated code */
594
624
  comments: boolean;
595
- /** Max consecutive failed executions before stopping */
596
625
  maxRetries: number;
626
+ skills: string[];
627
+ envOverview: string;
597
628
 
598
629
  init(force?: boolean): Promise<void>;
599
630
  chat(message: string, opts?: { labels?: Record<string, string> }): Promise<CodeAgentResponse>;
600
631
  stream(message: string, opts?: { labels?: Record<string, string> }): AsyncGenerator<CodeAgentStreamEvent, void, unknown>;
601
- /** Returns all code scripts written across all chat/stream calls. */
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. */
632
+ dump(): Array<{ fileName: string; purpose: string | null; script: string; filePath: string | null; tool: string }>;
604
633
  stop(): void;
605
634
  }
606
635