coding-agent-adapters 0.2.2 → 0.2.5
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.cjs +221 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +94 -11
- package/dist/index.d.ts +94 -11
- package/dist/index.js +216 -22
- package/dist/index.js.map +1 -1
- package/package.json +8 -2
package/dist/index.d.ts
CHANGED
|
@@ -30,6 +30,15 @@ interface InstallationInfo {
|
|
|
30
30
|
/** Minimum required version (if known) */
|
|
31
31
|
minVersion?: string;
|
|
32
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Model tier recommendations for an adapter
|
|
35
|
+
*/
|
|
36
|
+
interface ModelRecommendations {
|
|
37
|
+
/** Most capable model for complex tasks */
|
|
38
|
+
powerful: string;
|
|
39
|
+
/** Fastest/cheapest model for simple tasks */
|
|
40
|
+
fast: string;
|
|
41
|
+
}
|
|
33
42
|
/**
|
|
34
43
|
* Extended config with credentials and mode support
|
|
35
44
|
*/
|
|
@@ -40,6 +49,12 @@ interface CodingAgentConfig extends SpawnConfig {
|
|
|
40
49
|
* Use this when you want the full interactive CLI experience.
|
|
41
50
|
*/
|
|
42
51
|
interactive?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Preferred provider for multi-provider adapters (e.g., Aider).
|
|
54
|
+
* Only the API key for this provider is passed, letting the CLI
|
|
55
|
+
* pick its best model for that provider automatically.
|
|
56
|
+
*/
|
|
57
|
+
provider?: 'anthropic' | 'openai' | 'google';
|
|
43
58
|
} & Record<string, unknown>;
|
|
44
59
|
}
|
|
45
60
|
/**
|
|
@@ -59,6 +74,11 @@ declare abstract class BaseCodingAdapter extends BaseCLIAdapter {
|
|
|
59
74
|
* When true, skip non-interactive flags (--print, --quiet, etc.)
|
|
60
75
|
*/
|
|
61
76
|
protected isInteractive(config: SpawnConfig): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Get recommended models for this adapter.
|
|
79
|
+
* Returns powerful (most capable) and fast (cheapest/fastest) model names.
|
|
80
|
+
*/
|
|
81
|
+
abstract getRecommendedModels(credentials?: AgentCredentials): ModelRecommendations;
|
|
62
82
|
/**
|
|
63
83
|
* Override detectExit to include installation instructions
|
|
64
84
|
*/
|
|
@@ -96,6 +116,7 @@ declare class ClaudeAdapter extends BaseCodingAdapter {
|
|
|
96
116
|
* These handle common prompts that can be safely auto-responded.
|
|
97
117
|
*/
|
|
98
118
|
readonly autoResponseRules: AutoResponseRule[];
|
|
119
|
+
getRecommendedModels(_credentials?: AgentCredentials): ModelRecommendations;
|
|
99
120
|
getCommand(): string;
|
|
100
121
|
getArgs(config: SpawnConfig): string[];
|
|
101
122
|
getEnv(config: SpawnConfig): Record<string, string>;
|
|
@@ -120,6 +141,7 @@ declare class GeminiAdapter extends BaseCodingAdapter {
|
|
|
120
141
|
readonly adapterType = "gemini";
|
|
121
142
|
readonly displayName = "Google Gemini";
|
|
122
143
|
readonly installation: InstallationInfo;
|
|
144
|
+
getRecommendedModels(_credentials?: AgentCredentials): ModelRecommendations;
|
|
123
145
|
getCommand(): string;
|
|
124
146
|
getArgs(config: SpawnConfig): string[];
|
|
125
147
|
getEnv(config: SpawnConfig): Record<string, string>;
|
|
@@ -145,6 +167,7 @@ declare class CodexAdapter extends BaseCodingAdapter {
|
|
|
145
167
|
* Auto-response rules for OpenAI Codex CLI.
|
|
146
168
|
*/
|
|
147
169
|
readonly autoResponseRules: AutoResponseRule[];
|
|
170
|
+
getRecommendedModels(_credentials?: AgentCredentials): ModelRecommendations;
|
|
148
171
|
getCommand(): string;
|
|
149
172
|
getArgs(config: SpawnConfig): string[];
|
|
150
173
|
getEnv(config: SpawnConfig): Record<string, string>;
|
|
@@ -174,6 +197,7 @@ declare class AiderAdapter extends BaseCodingAdapter {
|
|
|
174
197
|
* Auto-response rules for Aider CLI.
|
|
175
198
|
*/
|
|
176
199
|
readonly autoResponseRules: AutoResponseRule[];
|
|
200
|
+
getRecommendedModels(credentials?: AgentCredentials): ModelRecommendations;
|
|
177
201
|
getCommand(): string;
|
|
178
202
|
getArgs(config: SpawnConfig): string[];
|
|
179
203
|
getEnv(config: SpawnConfig): Record<string, string>;
|
|
@@ -185,6 +209,73 @@ declare class AiderAdapter extends BaseCodingAdapter {
|
|
|
185
209
|
getHealthCheckCommand(): string;
|
|
186
210
|
}
|
|
187
211
|
|
|
212
|
+
/**
|
|
213
|
+
* Shared types for coding-agent-adapters
|
|
214
|
+
*/
|
|
215
|
+
/**
|
|
216
|
+
* Supported adapter types
|
|
217
|
+
*/
|
|
218
|
+
type AdapterType = 'claude' | 'gemini' | 'codex' | 'aider';
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Dynamic Pattern Loader
|
|
222
|
+
*
|
|
223
|
+
* Loads adapter patterns from @parallax/adapter-monitor snapshots when available,
|
|
224
|
+
* with fallback to hardcoded baseline patterns.
|
|
225
|
+
*/
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Pattern set for an adapter
|
|
229
|
+
*/
|
|
230
|
+
interface AdapterPatterns {
|
|
231
|
+
/** Ready state detection patterns */
|
|
232
|
+
ready: string[];
|
|
233
|
+
/** Auth/login detection patterns */
|
|
234
|
+
auth: string[];
|
|
235
|
+
/** Blocking prompt detection patterns */
|
|
236
|
+
blocking: string[];
|
|
237
|
+
/** Source of patterns */
|
|
238
|
+
source: 'snapshot' | 'baseline';
|
|
239
|
+
/** Version these patterns are from (if from snapshot) */
|
|
240
|
+
version?: string;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Load patterns for an adapter
|
|
244
|
+
*
|
|
245
|
+
* Tries to load from @parallax/adapter-monitor snapshots first,
|
|
246
|
+
* falls back to hardcoded baseline patterns.
|
|
247
|
+
*
|
|
248
|
+
* @param adapter - Adapter type
|
|
249
|
+
* @param version - Optional specific CLI version to load patterns for
|
|
250
|
+
* @param forceRefresh - Skip cache and reload
|
|
251
|
+
*/
|
|
252
|
+
declare function loadPatterns(adapter: AdapterType, version?: string, forceRefresh?: boolean): Promise<AdapterPatterns>;
|
|
253
|
+
/**
|
|
254
|
+
* Load patterns synchronously (uses cache or baseline only)
|
|
255
|
+
*
|
|
256
|
+
* Use this in constructors or synchronous code paths.
|
|
257
|
+
* For best results, call loadPatterns() asynchronously during init.
|
|
258
|
+
*/
|
|
259
|
+
declare function loadPatternsSync(adapter: AdapterType): AdapterPatterns;
|
|
260
|
+
/**
|
|
261
|
+
* Preload patterns for all adapters
|
|
262
|
+
*
|
|
263
|
+
* Call this during application startup to warm the cache.
|
|
264
|
+
*/
|
|
265
|
+
declare function preloadAllPatterns(): Promise<void>;
|
|
266
|
+
/**
|
|
267
|
+
* Clear the pattern cache
|
|
268
|
+
*/
|
|
269
|
+
declare function clearPatternCache(): void;
|
|
270
|
+
/**
|
|
271
|
+
* Get baseline patterns (always available, no async)
|
|
272
|
+
*/
|
|
273
|
+
declare function getBaselinePatterns(adapter: AdapterType): AdapterPatterns;
|
|
274
|
+
/**
|
|
275
|
+
* Check if dynamic patterns are available
|
|
276
|
+
*/
|
|
277
|
+
declare function hasDynamicPatterns(adapter: AdapterType): Promise<boolean>;
|
|
278
|
+
|
|
188
279
|
/**
|
|
189
280
|
* coding-agent-adapters
|
|
190
281
|
*
|
|
@@ -227,16 +318,8 @@ declare class AiderAdapter extends BaseCodingAdapter {
|
|
|
227
318
|
* Create instances of all available adapters
|
|
228
319
|
*/
|
|
229
320
|
declare function createAllAdapters(): (ClaudeAdapter | GeminiAdapter | CodexAdapter | AiderAdapter)[];
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
*/
|
|
233
|
-
declare const ADAPTER_TYPES: {
|
|
234
|
-
readonly claude: typeof ClaudeAdapter;
|
|
235
|
-
readonly gemini: typeof GeminiAdapter;
|
|
236
|
-
readonly codex: typeof CodexAdapter;
|
|
237
|
-
readonly aider: typeof AiderAdapter;
|
|
238
|
-
};
|
|
239
|
-
type AdapterType = keyof typeof ADAPTER_TYPES;
|
|
321
|
+
|
|
322
|
+
declare const ADAPTER_TYPES: Record<AdapterType, typeof ClaudeAdapter | typeof GeminiAdapter | typeof CodexAdapter | typeof AiderAdapter>;
|
|
240
323
|
/**
|
|
241
324
|
* Create a specific adapter by type
|
|
242
325
|
*/
|
|
@@ -288,4 +371,4 @@ declare function checkAllAdapters(): Promise<PreflightResult[]>;
|
|
|
288
371
|
*/
|
|
289
372
|
declare function printMissingAdapters(types?: AdapterType[]): Promise<void>;
|
|
290
373
|
|
|
291
|
-
export { ADAPTER_TYPES, type AdapterType, type AgentCredentials, AiderAdapter, BaseCodingAdapter, ClaudeAdapter, CodexAdapter, type CodingAgentConfig, GeminiAdapter, type InstallationInfo, type PreflightResult, checkAdapters, checkAllAdapters, createAdapter, createAllAdapters, printMissingAdapters };
|
|
374
|
+
export { ADAPTER_TYPES, type AdapterPatterns, type AdapterType, type AgentCredentials, AiderAdapter, BaseCodingAdapter, ClaudeAdapter, CodexAdapter, type CodingAgentConfig, GeminiAdapter, type InstallationInfo, type ModelRecommendations, type PreflightResult, checkAdapters, checkAllAdapters, clearPatternCache, createAdapter, createAllAdapters, getBaselinePatterns, hasDynamicPatterns, loadPatterns, loadPatternsSync, preloadAllPatterns, printMissingAdapters };
|
package/dist/index.js
CHANGED
|
@@ -141,6 +141,12 @@ var ClaudeAdapter = class extends BaseCodingAdapter {
|
|
|
141
141
|
safe: true
|
|
142
142
|
}
|
|
143
143
|
];
|
|
144
|
+
getRecommendedModels(_credentials) {
|
|
145
|
+
return {
|
|
146
|
+
powerful: "claude-sonnet-4-20250514",
|
|
147
|
+
fast: "claude-haiku-4-5-20251001"
|
|
148
|
+
};
|
|
149
|
+
}
|
|
144
150
|
getCommand() {
|
|
145
151
|
return "claude";
|
|
146
152
|
}
|
|
@@ -204,6 +210,15 @@ var ClaudeAdapter = class extends BaseCodingAdapter {
|
|
|
204
210
|
instructions: loginDetection.instructions
|
|
205
211
|
};
|
|
206
212
|
}
|
|
213
|
+
if (/Do you want to|wants? (your )?permission|needs your permission/i.test(stripped)) {
|
|
214
|
+
return {
|
|
215
|
+
detected: true,
|
|
216
|
+
type: "permission",
|
|
217
|
+
prompt: "Claude tool permission",
|
|
218
|
+
canAutoRespond: false,
|
|
219
|
+
instructions: "Claude is asking permission to use a tool"
|
|
220
|
+
};
|
|
221
|
+
}
|
|
207
222
|
if (/choose.*model|select.*model|available models/i.test(stripped) && /\d+\)|claude-/i.test(stripped)) {
|
|
208
223
|
return {
|
|
209
224
|
detected: true,
|
|
@@ -246,9 +261,8 @@ var ClaudeAdapter = class extends BaseCodingAdapter {
|
|
|
246
261
|
}
|
|
247
262
|
detectReady(output) {
|
|
248
263
|
const stripped = this.stripAnsi(output);
|
|
249
|
-
return stripped.includes("Claude Code") || stripped.includes("How can I help") || stripped.includes("What would you like") || //
|
|
250
|
-
|
|
251
|
-
stripped.includes("Ready");
|
|
264
|
+
return stripped.includes("Claude Code") || stripped.includes("How can I help") || stripped.includes("What would you like") || stripped.includes("Ready") || // Match "claude> " or similar specific prompts, not bare ">"
|
|
265
|
+
/claude>\s*$/i.test(stripped);
|
|
252
266
|
}
|
|
253
267
|
parseOutput(output) {
|
|
254
268
|
const stripped = this.stripAnsi(output);
|
|
@@ -269,7 +283,7 @@ var ClaudeAdapter = class extends BaseCodingAdapter {
|
|
|
269
283
|
};
|
|
270
284
|
}
|
|
271
285
|
getPromptPattern() {
|
|
272
|
-
return /
|
|
286
|
+
return /claude>\s*$/i;
|
|
273
287
|
}
|
|
274
288
|
getHealthCheckCommand() {
|
|
275
289
|
return "claude --version";
|
|
@@ -287,6 +301,12 @@ var GeminiAdapter = class extends BaseCodingAdapter {
|
|
|
287
301
|
],
|
|
288
302
|
docsUrl: "https://github.com/anthropics/gemini-cli#installation"
|
|
289
303
|
};
|
|
304
|
+
getRecommendedModels(_credentials) {
|
|
305
|
+
return {
|
|
306
|
+
powerful: "gemini-2.5-pro",
|
|
307
|
+
fast: "gemini-2.5-flash"
|
|
308
|
+
};
|
|
309
|
+
}
|
|
290
310
|
getCommand() {
|
|
291
311
|
return "gemini";
|
|
292
312
|
}
|
|
@@ -356,6 +376,15 @@ var GeminiAdapter = class extends BaseCodingAdapter {
|
|
|
356
376
|
instructions: loginDetection.instructions
|
|
357
377
|
};
|
|
358
378
|
}
|
|
379
|
+
if (/Apply this change\?/i.test(stripped) || /Waiting for user confirmation/i.test(stripped)) {
|
|
380
|
+
return {
|
|
381
|
+
detected: true,
|
|
382
|
+
type: "permission",
|
|
383
|
+
prompt: "Gemini tool execution confirmation",
|
|
384
|
+
canAutoRespond: false,
|
|
385
|
+
instructions: "Gemini is asking to apply a change (file write, shell command, etc.)"
|
|
386
|
+
};
|
|
387
|
+
}
|
|
359
388
|
if (/select.*model|choose.*model|gemini-/i.test(stripped) && /\d+\)/i.test(stripped)) {
|
|
360
389
|
return {
|
|
361
390
|
detected: true,
|
|
@@ -387,8 +416,8 @@ var GeminiAdapter = class extends BaseCodingAdapter {
|
|
|
387
416
|
}
|
|
388
417
|
detectReady(output) {
|
|
389
418
|
const stripped = this.stripAnsi(output);
|
|
390
|
-
return stripped.includes("
|
|
391
|
-
|
|
419
|
+
return stripped.includes("Ready") || stripped.includes("Type your message") || stripped.includes("How can I help") || stripped.includes("What would you like") || // Match "gemini> " prompt specifically, not bare ">"
|
|
420
|
+
/gemini>\s*$/i.test(stripped);
|
|
392
421
|
}
|
|
393
422
|
parseOutput(output) {
|
|
394
423
|
const stripped = this.stripAnsi(output);
|
|
@@ -410,7 +439,7 @@ var GeminiAdapter = class extends BaseCodingAdapter {
|
|
|
410
439
|
};
|
|
411
440
|
}
|
|
412
441
|
getPromptPattern() {
|
|
413
|
-
return /
|
|
442
|
+
return /gemini>\s*$/i;
|
|
414
443
|
}
|
|
415
444
|
getHealthCheckCommand() {
|
|
416
445
|
return "gemini --version";
|
|
@@ -461,6 +490,12 @@ var CodexAdapter = class extends BaseCodingAdapter {
|
|
|
461
490
|
safe: true
|
|
462
491
|
}
|
|
463
492
|
];
|
|
493
|
+
getRecommendedModels(_credentials) {
|
|
494
|
+
return {
|
|
495
|
+
powerful: "o3",
|
|
496
|
+
fast: "gpt-4o-mini"
|
|
497
|
+
};
|
|
498
|
+
}
|
|
464
499
|
getCommand() {
|
|
465
500
|
return "codex";
|
|
466
501
|
}
|
|
@@ -623,6 +658,30 @@ var AiderAdapter = class extends BaseCodingAdapter {
|
|
|
623
658
|
safe: true
|
|
624
659
|
}
|
|
625
660
|
];
|
|
661
|
+
getRecommendedModels(credentials) {
|
|
662
|
+
if (credentials?.anthropicKey) {
|
|
663
|
+
return {
|
|
664
|
+
powerful: "anthropic/claude-sonnet-4-20250514",
|
|
665
|
+
fast: "anthropic/claude-haiku-4-5-20251001"
|
|
666
|
+
};
|
|
667
|
+
}
|
|
668
|
+
if (credentials?.openaiKey) {
|
|
669
|
+
return {
|
|
670
|
+
powerful: "openai/o3",
|
|
671
|
+
fast: "openai/gpt-4o-mini"
|
|
672
|
+
};
|
|
673
|
+
}
|
|
674
|
+
if (credentials?.googleKey) {
|
|
675
|
+
return {
|
|
676
|
+
powerful: "gemini/gemini-2.5-pro",
|
|
677
|
+
fast: "gemini/gemini-2.5-flash"
|
|
678
|
+
};
|
|
679
|
+
}
|
|
680
|
+
return {
|
|
681
|
+
powerful: "anthropic/claude-sonnet-4-20250514",
|
|
682
|
+
fast: "anthropic/claude-haiku-4-5-20251001"
|
|
683
|
+
};
|
|
684
|
+
}
|
|
626
685
|
getCommand() {
|
|
627
686
|
return "aider";
|
|
628
687
|
}
|
|
@@ -633,27 +692,24 @@ var AiderAdapter = class extends BaseCodingAdapter {
|
|
|
633
692
|
args.push("--no-pretty");
|
|
634
693
|
args.push("--no-show-diffs");
|
|
635
694
|
}
|
|
636
|
-
const
|
|
695
|
+
const provider = config.adapterConfig?.provider;
|
|
637
696
|
if (config.env?.AIDER_MODEL) {
|
|
638
697
|
args.push("--model", config.env.AIDER_MODEL);
|
|
698
|
+
} else if (provider === "anthropic") {
|
|
699
|
+
args.push("--model", "sonnet");
|
|
700
|
+
} else if (provider === "openai") {
|
|
701
|
+
args.push("--model", "4o");
|
|
702
|
+
} else if (provider === "google") {
|
|
703
|
+
args.push("--model", "gemini");
|
|
639
704
|
}
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
}
|
|
705
|
+
const credentials = this.getCredentials(config);
|
|
706
|
+
if (credentials.anthropicKey) args.push("--api-key", `anthropic=${credentials.anthropicKey}`);
|
|
707
|
+
if (credentials.openaiKey) args.push("--api-key", `openai=${credentials.openaiKey}`);
|
|
708
|
+
if (credentials.googleKey) args.push("--api-key", `google=${credentials.googleKey}`);
|
|
643
709
|
return args;
|
|
644
710
|
}
|
|
645
711
|
getEnv(config) {
|
|
646
712
|
const env = {};
|
|
647
|
-
const credentials = this.getCredentials(config);
|
|
648
|
-
if (credentials.anthropicKey) {
|
|
649
|
-
env.ANTHROPIC_API_KEY = credentials.anthropicKey;
|
|
650
|
-
}
|
|
651
|
-
if (credentials.openaiKey) {
|
|
652
|
-
env.OPENAI_API_KEY = credentials.openaiKey;
|
|
653
|
-
}
|
|
654
|
-
if (credentials.googleKey) {
|
|
655
|
-
env.GOOGLE_API_KEY = credentials.googleKey;
|
|
656
|
-
}
|
|
657
713
|
if (!this.isInteractive(config)) {
|
|
658
714
|
env.NO_COLOR = "1";
|
|
659
715
|
}
|
|
@@ -755,6 +811,144 @@ var AiderAdapter = class extends BaseCodingAdapter {
|
|
|
755
811
|
}
|
|
756
812
|
};
|
|
757
813
|
|
|
814
|
+
// src/pattern-loader.ts
|
|
815
|
+
var BASELINE_PATTERNS = {
|
|
816
|
+
claude: {
|
|
817
|
+
ready: [
|
|
818
|
+
"Claude Code",
|
|
819
|
+
"How can I help",
|
|
820
|
+
"What would you like",
|
|
821
|
+
"Ready"
|
|
822
|
+
],
|
|
823
|
+
auth: [
|
|
824
|
+
"ANTHROPIC_API_KEY",
|
|
825
|
+
"API key not found",
|
|
826
|
+
"authentication required",
|
|
827
|
+
"Please sign in",
|
|
828
|
+
"Invalid API key"
|
|
829
|
+
],
|
|
830
|
+
blocking: [
|
|
831
|
+
"update available",
|
|
832
|
+
"[y/n]"
|
|
833
|
+
],
|
|
834
|
+
source: "baseline"
|
|
835
|
+
},
|
|
836
|
+
gemini: {
|
|
837
|
+
ready: [
|
|
838
|
+
"Type your message",
|
|
839
|
+
"How can I help",
|
|
840
|
+
"What would you like",
|
|
841
|
+
"Ready"
|
|
842
|
+
],
|
|
843
|
+
auth: [
|
|
844
|
+
"GOOGLE_API_KEY",
|
|
845
|
+
"GEMINI_API_KEY",
|
|
846
|
+
"API key not found",
|
|
847
|
+
"Sign in with Google",
|
|
848
|
+
"gcloud auth",
|
|
849
|
+
"Application Default Credentials"
|
|
850
|
+
],
|
|
851
|
+
blocking: [
|
|
852
|
+
"update available",
|
|
853
|
+
"[y/n]"
|
|
854
|
+
],
|
|
855
|
+
source: "baseline"
|
|
856
|
+
},
|
|
857
|
+
codex: {
|
|
858
|
+
ready: [
|
|
859
|
+
"Codex",
|
|
860
|
+
"How can I help",
|
|
861
|
+
"Ready"
|
|
862
|
+
],
|
|
863
|
+
auth: [
|
|
864
|
+
"OPENAI_API_KEY",
|
|
865
|
+
"API key not found",
|
|
866
|
+
"Unauthorized",
|
|
867
|
+
"Invalid API key"
|
|
868
|
+
],
|
|
869
|
+
blocking: [
|
|
870
|
+
"update available",
|
|
871
|
+
"[y/n]"
|
|
872
|
+
],
|
|
873
|
+
source: "baseline"
|
|
874
|
+
},
|
|
875
|
+
aider: {
|
|
876
|
+
ready: [
|
|
877
|
+
"Aider",
|
|
878
|
+
"What would you like",
|
|
879
|
+
"Ready"
|
|
880
|
+
],
|
|
881
|
+
auth: [
|
|
882
|
+
"API key",
|
|
883
|
+
"OPENAI_API_KEY",
|
|
884
|
+
"ANTHROPIC_API_KEY",
|
|
885
|
+
"No API key"
|
|
886
|
+
],
|
|
887
|
+
blocking: [
|
|
888
|
+
"(Y)es/(N)o",
|
|
889
|
+
"[y/n]"
|
|
890
|
+
],
|
|
891
|
+
source: "baseline"
|
|
892
|
+
}
|
|
893
|
+
};
|
|
894
|
+
var patternCache = /* @__PURE__ */ new Map();
|
|
895
|
+
async function tryLoadFromMonitor(adapter, version) {
|
|
896
|
+
try {
|
|
897
|
+
const moduleName = "agent-adapter-monitor";
|
|
898
|
+
const monitor = await import(
|
|
899
|
+
/* webpackIgnore: true */
|
|
900
|
+
moduleName
|
|
901
|
+
);
|
|
902
|
+
const patterns = version ? await monitor.getPatternsForVersion(adapter, version) : await monitor.getPatternsForVersion(adapter, "latest");
|
|
903
|
+
if (patterns) {
|
|
904
|
+
return {
|
|
905
|
+
ready: patterns.readyPatterns || [],
|
|
906
|
+
auth: patterns.authPatterns || [],
|
|
907
|
+
blocking: patterns.blockingPatterns || [],
|
|
908
|
+
source: "snapshot",
|
|
909
|
+
version: patterns.version
|
|
910
|
+
};
|
|
911
|
+
}
|
|
912
|
+
} catch {
|
|
913
|
+
}
|
|
914
|
+
return null;
|
|
915
|
+
}
|
|
916
|
+
async function loadPatterns(adapter, version, forceRefresh = false) {
|
|
917
|
+
const cacheKey = `${adapter}:${version || "latest"}`;
|
|
918
|
+
if (!forceRefresh && patternCache.has(cacheKey)) {
|
|
919
|
+
return patternCache.get(cacheKey);
|
|
920
|
+
}
|
|
921
|
+
const monitorPatterns = await tryLoadFromMonitor(adapter, version);
|
|
922
|
+
if (monitorPatterns && monitorPatterns.ready.length > 0) {
|
|
923
|
+
patternCache.set(cacheKey, monitorPatterns);
|
|
924
|
+
return monitorPatterns;
|
|
925
|
+
}
|
|
926
|
+
const baseline = BASELINE_PATTERNS[adapter];
|
|
927
|
+
patternCache.set(cacheKey, baseline);
|
|
928
|
+
return baseline;
|
|
929
|
+
}
|
|
930
|
+
function loadPatternsSync(adapter) {
|
|
931
|
+
const cacheKey = `${adapter}:latest`;
|
|
932
|
+
if (patternCache.has(cacheKey)) {
|
|
933
|
+
return patternCache.get(cacheKey);
|
|
934
|
+
}
|
|
935
|
+
return BASELINE_PATTERNS[adapter];
|
|
936
|
+
}
|
|
937
|
+
async function preloadAllPatterns() {
|
|
938
|
+
const adapters = ["claude", "gemini", "codex", "aider"];
|
|
939
|
+
await Promise.all(adapters.map((adapter) => loadPatterns(adapter)));
|
|
940
|
+
}
|
|
941
|
+
function clearPatternCache() {
|
|
942
|
+
patternCache.clear();
|
|
943
|
+
}
|
|
944
|
+
function getBaselinePatterns(adapter) {
|
|
945
|
+
return BASELINE_PATTERNS[adapter];
|
|
946
|
+
}
|
|
947
|
+
async function hasDynamicPatterns(adapter) {
|
|
948
|
+
const patterns = await tryLoadFromMonitor(adapter);
|
|
949
|
+
return patterns !== null;
|
|
950
|
+
}
|
|
951
|
+
|
|
758
952
|
// src/index.ts
|
|
759
953
|
function createAllAdapters() {
|
|
760
954
|
return [
|
|
@@ -815,6 +1009,6 @@ async function printMissingAdapters(types) {
|
|
|
815
1009
|
}
|
|
816
1010
|
}
|
|
817
1011
|
|
|
818
|
-
export { ADAPTER_TYPES, AiderAdapter, BaseCodingAdapter, ClaudeAdapter, CodexAdapter, GeminiAdapter, checkAdapters, checkAllAdapters, createAdapter, createAllAdapters, printMissingAdapters };
|
|
1012
|
+
export { ADAPTER_TYPES, AiderAdapter, BaseCodingAdapter, ClaudeAdapter, CodexAdapter, GeminiAdapter, checkAdapters, checkAllAdapters, clearPatternCache, createAdapter, createAllAdapters, getBaselinePatterns, hasDynamicPatterns, loadPatterns, loadPatternsSync, preloadAllPatterns, printMissingAdapters };
|
|
819
1013
|
//# sourceMappingURL=index.js.map
|
|
820
1014
|
//# sourceMappingURL=index.js.map
|