coding-agent-adapters 0.2.19 → 0.4.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/dist/index.d.cts CHANGED
@@ -1,5 +1,61 @@
1
1
  import { BaseCLIAdapter, SpawnConfig, AutoResponseRule, LoginDetection, BlockingPromptDetection, ParsedOutput } from 'pty-manager';
2
2
 
3
+ /**
4
+ * Shared types for coding-agent-adapters
5
+ */
6
+ /**
7
+ * Supported adapter types
8
+ */
9
+ type AdapterType = 'claude' | 'gemini' | 'codex' | 'aider';
10
+
11
+ /**
12
+ * Approval Presets
13
+ *
14
+ * Unified preset system for controlling tool permissions across all supported
15
+ * coding agent CLIs. Each preset translates to the correct per-CLI config
16
+ * format (JSON settings files, CLI flags, env vars).
17
+ */
18
+
19
+ type ToolCategory = 'file_read' | 'file_write' | 'shell' | 'web' | 'agent' | 'planning' | 'user_interaction';
20
+ type RiskLevel = 'low' | 'medium' | 'high';
21
+ type ApprovalPreset = 'readonly' | 'standard' | 'permissive' | 'autonomous';
22
+ interface ToolCategoryInfo {
23
+ category: ToolCategory;
24
+ risk: RiskLevel;
25
+ description: string;
26
+ }
27
+ interface PresetDefinition {
28
+ preset: ApprovalPreset;
29
+ description: string;
30
+ autoApprove: ToolCategory[];
31
+ requireApproval: ToolCategory[];
32
+ blocked: ToolCategory[];
33
+ }
34
+ interface ApprovalConfig {
35
+ preset: ApprovalPreset;
36
+ cliFlags: string[];
37
+ workspaceFiles: Array<{
38
+ relativePath: string;
39
+ content: string;
40
+ format: 'json' | 'yaml' | 'toml';
41
+ }>;
42
+ envVars: Record<string, string>;
43
+ summary: string;
44
+ }
45
+ declare const TOOL_CATEGORIES: ToolCategoryInfo[];
46
+ declare const PRESET_DEFINITIONS: PresetDefinition[];
47
+ declare const CLAUDE_TOOL_CATEGORIES: Record<string, ToolCategory>;
48
+ declare const GEMINI_TOOL_CATEGORIES: Record<string, ToolCategory>;
49
+ declare const CODEX_TOOL_CATEGORIES: Record<string, ToolCategory>;
50
+ declare const AIDER_COMMAND_CATEGORIES: Record<string, ToolCategory>;
51
+ declare function generateClaudeApprovalConfig(preset: ApprovalPreset): ApprovalConfig;
52
+ declare function generateGeminiApprovalConfig(preset: ApprovalPreset): ApprovalConfig;
53
+ declare function generateCodexApprovalConfig(preset: ApprovalPreset): ApprovalConfig;
54
+ declare function generateAiderApprovalConfig(preset: ApprovalPreset): ApprovalConfig;
55
+ declare function generateApprovalConfig(adapterType: AdapterType, preset: ApprovalPreset): ApprovalConfig;
56
+ declare function listPresets(): PresetDefinition[];
57
+ declare function getPresetDefinition(preset: ApprovalPreset): PresetDefinition;
58
+
3
59
  /**
4
60
  * Base Coding Agent Adapter
5
61
  *
@@ -80,6 +136,11 @@ interface CodingAgentConfig extends SpawnConfig {
80
136
  * pick its best model for that provider automatically.
81
137
  */
82
138
  provider?: 'anthropic' | 'openai' | 'google';
139
+ /**
140
+ * Approval preset controlling tool permissions.
141
+ * Translates to CLI-specific config files and flags.
142
+ */
143
+ approvalPreset?: ApprovalPreset;
83
144
  } & Record<string, unknown>;
84
145
  }
85
146
  /**
@@ -146,6 +207,27 @@ declare abstract class BaseCodingAdapter extends BaseCLIAdapter {
146
207
  * Extract the main content from CLI output, removing common artifacts
147
208
  */
148
209
  protected extractContent(output: string, promptPattern: RegExp): string;
210
+ /**
211
+ * Detect if the CLI has completed a task and returned to its idle prompt.
212
+ * More specific than detectReady() — matches high-confidence completion indicators
213
+ * (e.g. duration summaries, explicit "done" messages) alongside the idle prompt.
214
+ *
215
+ * Used as a fast-path in stall detection to avoid expensive LLM classifier calls.
216
+ */
217
+ abstract detectTaskComplete(output: string): boolean;
218
+ /**
219
+ * Extract the approval preset from a spawn config, if set.
220
+ */
221
+ protected getApprovalPreset(config: SpawnConfig): ApprovalPreset | undefined;
222
+ /**
223
+ * Generate the approval config for this adapter, if a preset is set.
224
+ */
225
+ getApprovalConfig(config: SpawnConfig): ApprovalConfig | null;
226
+ /**
227
+ * Write approval config files to a workspace directory.
228
+ * Returns the list of files written (absolute paths).
229
+ */
230
+ writeApprovalConfig(workspacePath: string, config: SpawnConfig): Promise<string[]>;
149
231
  /**
150
232
  * Write content to this agent's memory file in a workspace.
151
233
  * Creates parent directories as needed.
@@ -184,6 +266,18 @@ declare class ClaudeAdapter extends BaseCodingAdapter {
184
266
  * Detect blocking prompts specific to Claude Code CLI
185
267
  */
186
268
  detectBlockingPrompt(output: string): BlockingPromptDetection;
269
+ /**
270
+ * Detect task completion for Claude Code.
271
+ *
272
+ * High-confidence pattern: turn duration summary + idle prompt.
273
+ * Claude Code shows "<Verb> for Xm Ys" (e.g. "Cooked for 3m 12s")
274
+ * when a turn completes, followed by the ❯ input prompt.
275
+ *
276
+ * Patterns from: AGENT_LOADING_STATUS_PATTERNS.json
277
+ * - claude_completed_turn_duration
278
+ * - claude_completed_turn_duration_custom_verb
279
+ */
280
+ detectTaskComplete(output: string): boolean;
187
281
  detectReady(output: string): boolean;
188
282
  parseOutput(output: string): ParsedOutput | null;
189
283
  getPromptPattern(): RegExp;
@@ -213,6 +307,17 @@ declare class GeminiAdapter extends BaseCodingAdapter {
213
307
  getEnv(config: SpawnConfig): Record<string, string>;
214
308
  detectLogin(output: string): LoginDetection;
215
309
  detectBlockingPrompt(output: string): BlockingPromptDetection;
310
+ /**
311
+ * Detect task completion for Gemini CLI.
312
+ *
313
+ * High-confidence patterns:
314
+ * - "◇ Ready" window title signal (OSC sequence, may survive ANSI stripping)
315
+ * - "Type your message" composer placeholder after agent output
316
+ *
317
+ * Patterns from: AGENT_LOADING_STATUS_PATTERNS.json
318
+ * - gemini_ready_title
319
+ */
320
+ detectTaskComplete(output: string): boolean;
216
321
  detectReady(output: string): boolean;
217
322
  parseOutput(output: string): ParsedOutput | null;
218
323
  /**
@@ -255,6 +360,18 @@ declare class CodexAdapter extends BaseCodingAdapter {
255
360
  * Source: approval_overlay.rs, chatwidget.rs, request_user_input/mod.rs
256
361
  */
257
362
  detectBlockingPrompt(output: string): BlockingPromptDetection;
363
+ /**
364
+ * Detect task completion for Codex CLI.
365
+ *
366
+ * High-confidence patterns:
367
+ * - "Worked for Xm Ys" separator after work-heavy turns
368
+ * - "› Ask Codex to do anything" ready prompt
369
+ *
370
+ * Patterns from: AGENT_LOADING_STATUS_PATTERNS.json
371
+ * - codex_completed_worked_for_separator
372
+ * - codex_ready_prompt
373
+ */
374
+ detectTaskComplete(output: string): boolean;
258
375
  detectReady(output: string): boolean;
259
376
  parseOutput(output: string): ParsedOutput | null;
260
377
  /**
@@ -304,6 +421,17 @@ declare class AiderAdapter extends BaseCodingAdapter {
304
421
  * Source: io.py, onboarding.py, base_coder.py, report.py
305
422
  */
306
423
  detectBlockingPrompt(output: string): BlockingPromptDetection;
424
+ /**
425
+ * Detect task completion for Aider.
426
+ *
427
+ * High-confidence patterns:
428
+ * - "Aider is waiting for your input" notification (bell message)
429
+ * - Edit-format mode prompts (ask>, code>, architect>) after output
430
+ *
431
+ * Patterns from: AGENT_LOADING_STATUS_PATTERNS.json
432
+ * - aider_completed_llm_response_ready
433
+ */
434
+ detectTaskComplete(output: string): boolean;
307
435
  detectReady(output: string): boolean;
308
436
  parseOutput(output: string): ParsedOutput | null;
309
437
  /**
@@ -319,14 +447,6 @@ declare class AiderAdapter extends BaseCodingAdapter {
319
447
  getHealthCheckCommand(): string;
320
448
  }
321
449
 
322
- /**
323
- * Shared types for coding-agent-adapters
324
- */
325
- /**
326
- * Supported adapter types
327
- */
328
- type AdapterType = 'claude' | 'gemini' | 'codex' | 'aider';
329
-
330
450
  /**
331
451
  * Dynamic Pattern Loader
332
452
  *
@@ -481,4 +601,4 @@ declare function checkAllAdapters(): Promise<PreflightResult[]>;
481
601
  */
482
602
  declare function printMissingAdapters(types?: AdapterType[]): Promise<void>;
483
603
 
484
- export { ADAPTER_TYPES, type AdapterPatterns, type AdapterType, type AgentCredentials, type AgentFileDescriptor, AiderAdapter, BaseCodingAdapter, ClaudeAdapter, CodexAdapter, type CodingAgentConfig, GeminiAdapter, type InstallationInfo, type ModelRecommendations, type PreflightResult, type WriteMemoryOptions, checkAdapters, checkAllAdapters, clearPatternCache, createAdapter, createAllAdapters, getBaselinePatterns, hasDynamicPatterns, loadPatterns, loadPatternsSync, preloadAllPatterns, printMissingAdapters };
604
+ export { ADAPTER_TYPES, AIDER_COMMAND_CATEGORIES, type AdapterPatterns, type AdapterType, type AgentCredentials, type AgentFileDescriptor, AiderAdapter, type ApprovalConfig, type ApprovalPreset, BaseCodingAdapter, CLAUDE_TOOL_CATEGORIES, CODEX_TOOL_CATEGORIES, ClaudeAdapter, CodexAdapter, type CodingAgentConfig, GEMINI_TOOL_CATEGORIES, GeminiAdapter, type InstallationInfo, type ModelRecommendations, PRESET_DEFINITIONS, type PreflightResult, type PresetDefinition, type RiskLevel, TOOL_CATEGORIES, type ToolCategory, type ToolCategoryInfo, type WriteMemoryOptions, checkAdapters, checkAllAdapters, clearPatternCache, createAdapter, createAllAdapters, generateAiderApprovalConfig, generateApprovalConfig, generateClaudeApprovalConfig, generateCodexApprovalConfig, generateGeminiApprovalConfig, getBaselinePatterns, getPresetDefinition, hasDynamicPatterns, listPresets, loadPatterns, loadPatternsSync, preloadAllPatterns, printMissingAdapters };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,61 @@
1
1
  import { BaseCLIAdapter, SpawnConfig, AutoResponseRule, LoginDetection, BlockingPromptDetection, ParsedOutput } from 'pty-manager';
2
2
 
3
+ /**
4
+ * Shared types for coding-agent-adapters
5
+ */
6
+ /**
7
+ * Supported adapter types
8
+ */
9
+ type AdapterType = 'claude' | 'gemini' | 'codex' | 'aider';
10
+
11
+ /**
12
+ * Approval Presets
13
+ *
14
+ * Unified preset system for controlling tool permissions across all supported
15
+ * coding agent CLIs. Each preset translates to the correct per-CLI config
16
+ * format (JSON settings files, CLI flags, env vars).
17
+ */
18
+
19
+ type ToolCategory = 'file_read' | 'file_write' | 'shell' | 'web' | 'agent' | 'planning' | 'user_interaction';
20
+ type RiskLevel = 'low' | 'medium' | 'high';
21
+ type ApprovalPreset = 'readonly' | 'standard' | 'permissive' | 'autonomous';
22
+ interface ToolCategoryInfo {
23
+ category: ToolCategory;
24
+ risk: RiskLevel;
25
+ description: string;
26
+ }
27
+ interface PresetDefinition {
28
+ preset: ApprovalPreset;
29
+ description: string;
30
+ autoApprove: ToolCategory[];
31
+ requireApproval: ToolCategory[];
32
+ blocked: ToolCategory[];
33
+ }
34
+ interface ApprovalConfig {
35
+ preset: ApprovalPreset;
36
+ cliFlags: string[];
37
+ workspaceFiles: Array<{
38
+ relativePath: string;
39
+ content: string;
40
+ format: 'json' | 'yaml' | 'toml';
41
+ }>;
42
+ envVars: Record<string, string>;
43
+ summary: string;
44
+ }
45
+ declare const TOOL_CATEGORIES: ToolCategoryInfo[];
46
+ declare const PRESET_DEFINITIONS: PresetDefinition[];
47
+ declare const CLAUDE_TOOL_CATEGORIES: Record<string, ToolCategory>;
48
+ declare const GEMINI_TOOL_CATEGORIES: Record<string, ToolCategory>;
49
+ declare const CODEX_TOOL_CATEGORIES: Record<string, ToolCategory>;
50
+ declare const AIDER_COMMAND_CATEGORIES: Record<string, ToolCategory>;
51
+ declare function generateClaudeApprovalConfig(preset: ApprovalPreset): ApprovalConfig;
52
+ declare function generateGeminiApprovalConfig(preset: ApprovalPreset): ApprovalConfig;
53
+ declare function generateCodexApprovalConfig(preset: ApprovalPreset): ApprovalConfig;
54
+ declare function generateAiderApprovalConfig(preset: ApprovalPreset): ApprovalConfig;
55
+ declare function generateApprovalConfig(adapterType: AdapterType, preset: ApprovalPreset): ApprovalConfig;
56
+ declare function listPresets(): PresetDefinition[];
57
+ declare function getPresetDefinition(preset: ApprovalPreset): PresetDefinition;
58
+
3
59
  /**
4
60
  * Base Coding Agent Adapter
5
61
  *
@@ -80,6 +136,11 @@ interface CodingAgentConfig extends SpawnConfig {
80
136
  * pick its best model for that provider automatically.
81
137
  */
82
138
  provider?: 'anthropic' | 'openai' | 'google';
139
+ /**
140
+ * Approval preset controlling tool permissions.
141
+ * Translates to CLI-specific config files and flags.
142
+ */
143
+ approvalPreset?: ApprovalPreset;
83
144
  } & Record<string, unknown>;
84
145
  }
85
146
  /**
@@ -146,6 +207,27 @@ declare abstract class BaseCodingAdapter extends BaseCLIAdapter {
146
207
  * Extract the main content from CLI output, removing common artifacts
147
208
  */
148
209
  protected extractContent(output: string, promptPattern: RegExp): string;
210
+ /**
211
+ * Detect if the CLI has completed a task and returned to its idle prompt.
212
+ * More specific than detectReady() — matches high-confidence completion indicators
213
+ * (e.g. duration summaries, explicit "done" messages) alongside the idle prompt.
214
+ *
215
+ * Used as a fast-path in stall detection to avoid expensive LLM classifier calls.
216
+ */
217
+ abstract detectTaskComplete(output: string): boolean;
218
+ /**
219
+ * Extract the approval preset from a spawn config, if set.
220
+ */
221
+ protected getApprovalPreset(config: SpawnConfig): ApprovalPreset | undefined;
222
+ /**
223
+ * Generate the approval config for this adapter, if a preset is set.
224
+ */
225
+ getApprovalConfig(config: SpawnConfig): ApprovalConfig | null;
226
+ /**
227
+ * Write approval config files to a workspace directory.
228
+ * Returns the list of files written (absolute paths).
229
+ */
230
+ writeApprovalConfig(workspacePath: string, config: SpawnConfig): Promise<string[]>;
149
231
  /**
150
232
  * Write content to this agent's memory file in a workspace.
151
233
  * Creates parent directories as needed.
@@ -184,6 +266,18 @@ declare class ClaudeAdapter extends BaseCodingAdapter {
184
266
  * Detect blocking prompts specific to Claude Code CLI
185
267
  */
186
268
  detectBlockingPrompt(output: string): BlockingPromptDetection;
269
+ /**
270
+ * Detect task completion for Claude Code.
271
+ *
272
+ * High-confidence pattern: turn duration summary + idle prompt.
273
+ * Claude Code shows "<Verb> for Xm Ys" (e.g. "Cooked for 3m 12s")
274
+ * when a turn completes, followed by the ❯ input prompt.
275
+ *
276
+ * Patterns from: AGENT_LOADING_STATUS_PATTERNS.json
277
+ * - claude_completed_turn_duration
278
+ * - claude_completed_turn_duration_custom_verb
279
+ */
280
+ detectTaskComplete(output: string): boolean;
187
281
  detectReady(output: string): boolean;
188
282
  parseOutput(output: string): ParsedOutput | null;
189
283
  getPromptPattern(): RegExp;
@@ -213,6 +307,17 @@ declare class GeminiAdapter extends BaseCodingAdapter {
213
307
  getEnv(config: SpawnConfig): Record<string, string>;
214
308
  detectLogin(output: string): LoginDetection;
215
309
  detectBlockingPrompt(output: string): BlockingPromptDetection;
310
+ /**
311
+ * Detect task completion for Gemini CLI.
312
+ *
313
+ * High-confidence patterns:
314
+ * - "◇ Ready" window title signal (OSC sequence, may survive ANSI stripping)
315
+ * - "Type your message" composer placeholder after agent output
316
+ *
317
+ * Patterns from: AGENT_LOADING_STATUS_PATTERNS.json
318
+ * - gemini_ready_title
319
+ */
320
+ detectTaskComplete(output: string): boolean;
216
321
  detectReady(output: string): boolean;
217
322
  parseOutput(output: string): ParsedOutput | null;
218
323
  /**
@@ -255,6 +360,18 @@ declare class CodexAdapter extends BaseCodingAdapter {
255
360
  * Source: approval_overlay.rs, chatwidget.rs, request_user_input/mod.rs
256
361
  */
257
362
  detectBlockingPrompt(output: string): BlockingPromptDetection;
363
+ /**
364
+ * Detect task completion for Codex CLI.
365
+ *
366
+ * High-confidence patterns:
367
+ * - "Worked for Xm Ys" separator after work-heavy turns
368
+ * - "› Ask Codex to do anything" ready prompt
369
+ *
370
+ * Patterns from: AGENT_LOADING_STATUS_PATTERNS.json
371
+ * - codex_completed_worked_for_separator
372
+ * - codex_ready_prompt
373
+ */
374
+ detectTaskComplete(output: string): boolean;
258
375
  detectReady(output: string): boolean;
259
376
  parseOutput(output: string): ParsedOutput | null;
260
377
  /**
@@ -304,6 +421,17 @@ declare class AiderAdapter extends BaseCodingAdapter {
304
421
  * Source: io.py, onboarding.py, base_coder.py, report.py
305
422
  */
306
423
  detectBlockingPrompt(output: string): BlockingPromptDetection;
424
+ /**
425
+ * Detect task completion for Aider.
426
+ *
427
+ * High-confidence patterns:
428
+ * - "Aider is waiting for your input" notification (bell message)
429
+ * - Edit-format mode prompts (ask>, code>, architect>) after output
430
+ *
431
+ * Patterns from: AGENT_LOADING_STATUS_PATTERNS.json
432
+ * - aider_completed_llm_response_ready
433
+ */
434
+ detectTaskComplete(output: string): boolean;
307
435
  detectReady(output: string): boolean;
308
436
  parseOutput(output: string): ParsedOutput | null;
309
437
  /**
@@ -319,14 +447,6 @@ declare class AiderAdapter extends BaseCodingAdapter {
319
447
  getHealthCheckCommand(): string;
320
448
  }
321
449
 
322
- /**
323
- * Shared types for coding-agent-adapters
324
- */
325
- /**
326
- * Supported adapter types
327
- */
328
- type AdapterType = 'claude' | 'gemini' | 'codex' | 'aider';
329
-
330
450
  /**
331
451
  * Dynamic Pattern Loader
332
452
  *
@@ -481,4 +601,4 @@ declare function checkAllAdapters(): Promise<PreflightResult[]>;
481
601
  */
482
602
  declare function printMissingAdapters(types?: AdapterType[]): Promise<void>;
483
603
 
484
- export { ADAPTER_TYPES, type AdapterPatterns, type AdapterType, type AgentCredentials, type AgentFileDescriptor, AiderAdapter, BaseCodingAdapter, ClaudeAdapter, CodexAdapter, type CodingAgentConfig, GeminiAdapter, type InstallationInfo, type ModelRecommendations, type PreflightResult, type WriteMemoryOptions, checkAdapters, checkAllAdapters, clearPatternCache, createAdapter, createAllAdapters, getBaselinePatterns, hasDynamicPatterns, loadPatterns, loadPatternsSync, preloadAllPatterns, printMissingAdapters };
604
+ export { ADAPTER_TYPES, AIDER_COMMAND_CATEGORIES, type AdapterPatterns, type AdapterType, type AgentCredentials, type AgentFileDescriptor, AiderAdapter, type ApprovalConfig, type ApprovalPreset, BaseCodingAdapter, CLAUDE_TOOL_CATEGORIES, CODEX_TOOL_CATEGORIES, ClaudeAdapter, CodexAdapter, type CodingAgentConfig, GEMINI_TOOL_CATEGORIES, GeminiAdapter, type InstallationInfo, type ModelRecommendations, PRESET_DEFINITIONS, type PreflightResult, type PresetDefinition, type RiskLevel, TOOL_CATEGORIES, type ToolCategory, type ToolCategoryInfo, type WriteMemoryOptions, checkAdapters, checkAllAdapters, clearPatternCache, createAdapter, createAllAdapters, generateAiderApprovalConfig, generateApprovalConfig, generateClaudeApprovalConfig, generateCodexApprovalConfig, generateGeminiApprovalConfig, getBaselinePatterns, getPresetDefinition, hasDynamicPatterns, listPresets, loadPatterns, loadPatternsSync, preloadAllPatterns, printMissingAdapters };