agent-accelerator 0.1.0 → 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 +83 -112
- package/{SYSTEM_PROMPT_AGENT.md → examples/prompts/SYSTEM_PROMPT_AGENT.md} +1 -1
- package/package.json +14 -9
- package/src/agent/agent.ts +191 -71
- package/src/agent/context.ts +1 -0
- package/src/agent/delegation.ts +61 -12
- package/src/agent/loop.ts +71 -48
- package/src/data/README.md +6 -6
- package/src/index.ts +130 -45
- package/src/models/catalog-cache.ts +60 -9
- package/src/models/catalog.ts +53 -7
- package/src/providers/google.ts +926 -0
- package/src/providers/openai-compat.ts +1147 -0
- package/src/providers/openai.ts +959 -0
- package/src/providers/openrouter-responses.ts +949 -0
- package/src/providers/openrouter.ts +1037 -0
- package/src/{ai-sdk → providers}/registry.ts +43 -55
- package/src/providers.ts +490 -0
- package/src/streaming/sse-parser.ts +6 -4
- package/src/tools/executor.ts +19 -6
- package/src/tools/schema.ts +21 -11
- package/src/types/agent.ts +8 -1
- package/src/types/core.ts +1 -1
- package/src/types/message.ts +5 -0
- package/src/types/model.ts +3 -7
- package/src/types/provider-payloads.ts +2 -84
- package/src/types/tool.ts +6 -0
- package/src/update-models.ts +56 -0
- package/src/utils/cache.ts +1 -1
- package/src/utils/documents.ts +517 -0
- package/src/utils/env.ts +0 -7
- package/src/{ai-sdk → utils}/errors.ts +61 -2
- package/src/utils/headers.ts +10 -20
- package/src/utils/media.ts +5 -2
- package/src/utils/retry.ts +89 -0
- package/src/utils/serialization.ts +15 -0
- package/src/ai-sdk/converters.ts +0 -342
- package/src/ai-sdk/executor.ts +0 -454
- package/src/ai-sdk/index.ts +0 -55
- package/src/ai-sdk/model-provider.ts +0 -303
- package/src/ai-sdk/options.ts +0 -306
- package/src/ai-sdk/provider.ts +0 -415
- package/src/tokens/counter.ts +0 -136
- /package/{SYSTEM_PROMPT.md → examples/prompts/SYSTEM_PROMPT.md} +0 -0
- /package/{SYSTEM_PROMPT_TOOLS.md → examples/prompts/SYSTEM_PROMPT_TOOLS.md} +0 -0
package/src/models/catalog.ts
CHANGED
|
@@ -22,12 +22,10 @@ import type { ThinkingLevel } from "../types/core.ts";
|
|
|
22
22
|
|
|
23
23
|
// ---------------------------------------------------------------------------
|
|
24
24
|
// Provider aliases — maps our internal ids to models.dev keys
|
|
25
|
-
// battle-tested:
|
|
25
|
+
// battle-tested: google covers vertex variants
|
|
26
26
|
// ---------------------------------------------------------------------------
|
|
27
27
|
const PROVIDER_ALIASES: Record<string, string[]> = {
|
|
28
28
|
google: ["google", "google-vertex", "google-vertex-anthropic"],
|
|
29
|
-
opencode: ["opencode", "opencode-go"],
|
|
30
|
-
"opencode-go": ["opencode-go", "opencode"],
|
|
31
29
|
openrouter: ["openrouter"],
|
|
32
30
|
openai: ["openai"],
|
|
33
31
|
};
|
|
@@ -42,6 +40,11 @@ const MODALITY_OVERRIDES: Record<string, { input?: string[]; output?: string[] }
|
|
|
42
40
|
// verified end-to-end via examples/08. If routing changes, the runtime
|
|
43
41
|
// 404 still surfaces as a one-line error.
|
|
44
42
|
"openrouter/nvidia/nemotron-3.5-lightning:free": { input: ["text", "pdf"] },
|
|
43
|
+
// Live-verified 2026-09-24: `stealth/space-bunny-alpha` accepts PDF
|
|
44
|
+
// `input_file` over Responses and PDFs via the file-parser plugin over Chat
|
|
45
|
+
// Completions (Berkshire letter + sample-files PDF both completed), though
|
|
46
|
+
// models.dev lists text/image/video only.
|
|
47
|
+
"openrouter/stealth/space-bunny-alpha": { input: ["text", "image", "video", "pdf"] },
|
|
45
48
|
};
|
|
46
49
|
|
|
47
50
|
function applyModalityOverrides(provider: string, modelId: string, base: ModelModalities): ModelModalities {
|
|
@@ -305,6 +308,11 @@ export function getModelThinkingInfo(provider: string, modelId: string): ModelTh
|
|
|
305
308
|
};
|
|
306
309
|
}
|
|
307
310
|
|
|
311
|
+
// "dynamic" means server default (the level is omitted from the request),
|
|
312
|
+
// so it is expressible on every configurable thinking model regardless of
|
|
313
|
+
// which concrete effort/toggle/budget options the catalog lists.
|
|
314
|
+
allowed.add("dynamic");
|
|
315
|
+
|
|
308
316
|
const allowedLevels = Array.from(allowed);
|
|
309
317
|
const supportsDisable = allowed.has("none") || !!toggleOpt || Boolean(budgetOpt && (budgetOpt.min === undefined || budgetOpt.min <= 0));
|
|
310
318
|
|
|
@@ -437,7 +445,7 @@ export function validateModelThinking(provider: string, modelId: string, request
|
|
|
437
445
|
|
|
438
446
|
// ---------------------------------------------------------------------------
|
|
439
447
|
// getModelsForProvider — battle-tested view for BaseProvider.models
|
|
440
|
-
//
|
|
448
|
+
// Total context length now comes from catalog, not stale hardcoded file.
|
|
441
449
|
// ---------------------------------------------------------------------------
|
|
442
450
|
/**
|
|
443
451
|
* Returns normalized catalog specs for a provider and its configured aliases.
|
|
@@ -466,7 +474,6 @@ export function getModelsForProvider(provider: string): ModelSpec[] {
|
|
|
466
474
|
|
|
467
475
|
export const GOOGLE_MODELS: ModelSpec[] = [...getModelsForProvider("google")];
|
|
468
476
|
export const OPENAI_MODELS: ModelSpec[] = [...getModelsForProvider("openai")];
|
|
469
|
-
export const OPENCODE_MODELS: ModelSpec[] = [...getModelsForProvider("opencode")];
|
|
470
477
|
export const OPENROUTER_MODELS: ModelSpec[] = [...getModelsForProvider("openrouter")];
|
|
471
478
|
|
|
472
479
|
function refreshExportedModels(): void {
|
|
@@ -474,8 +481,6 @@ function refreshExportedModels(): void {
|
|
|
474
481
|
GOOGLE_MODELS.push(...getModelsForProvider("google"));
|
|
475
482
|
OPENAI_MODELS.length = 0;
|
|
476
483
|
OPENAI_MODELS.push(...getModelsForProvider("openai"));
|
|
477
|
-
OPENCODE_MODELS.length = 0;
|
|
478
|
-
OPENCODE_MODELS.push(...getModelsForProvider("opencode"));
|
|
479
484
|
OPENROUTER_MODELS.length = 0;
|
|
480
485
|
OPENROUTER_MODELS.push(...getModelsForProvider("openrouter"));
|
|
481
486
|
}
|
|
@@ -497,7 +502,48 @@ export {
|
|
|
497
502
|
getCatalogTTL,
|
|
498
503
|
getCacheDir,
|
|
499
504
|
getCacheFilePath,
|
|
505
|
+
isValidCatalogPayload,
|
|
500
506
|
DEFAULT_CATALOG_TTL_MS,
|
|
501
507
|
type CatalogStatus,
|
|
502
508
|
type RefreshCatalogOptions,
|
|
503
509
|
} from "./catalog-cache.ts";
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Permissive placeholder so custom endpoints never fail preflight:
|
|
513
|
+
* allows every ThinkingLevel (none -> xhigh + dynamic).
|
|
514
|
+
* @example `const spec = createGenericModelSpec("groq", "llama-3.3-70b-versatile");`
|
|
515
|
+
*/
|
|
516
|
+
export function createGenericModelSpec(provider: string, modelId: string): ModelSpec {
|
|
517
|
+
const clean = modelId.includes("/") ? modelId.split("/").slice(1).join("/") : modelId;
|
|
518
|
+
return {
|
|
519
|
+
id: clean,
|
|
520
|
+
provider: provider as ProviderId,
|
|
521
|
+
name: clean,
|
|
522
|
+
contextWindow: 128000,
|
|
523
|
+
maxOutputTokens: 8192,
|
|
524
|
+
limit: { context: 128000, output: 8192 },
|
|
525
|
+
cost: {},
|
|
526
|
+
modalities: { input: ["text"], output: ["text"] },
|
|
527
|
+
reasoning: true,
|
|
528
|
+
reasoning_options: [
|
|
529
|
+
{ type: "toggle" },
|
|
530
|
+
{ type: "effort", values: ["minimal", "low", "medium", "high", "xhigh"] },
|
|
531
|
+
{ type: "budget_tokens", min: 0, max: 128000 },
|
|
532
|
+
],
|
|
533
|
+
tool_call: true,
|
|
534
|
+
capabilities: {
|
|
535
|
+
supportsThinking: true,
|
|
536
|
+
supportsThinkingLevel: true,
|
|
537
|
+
supportsThinkingBudget: true,
|
|
538
|
+
supportsReasoningToggle: true,
|
|
539
|
+
supportsReasoningEffort: true,
|
|
540
|
+
supportsImplicitCaching: true,
|
|
541
|
+
supportsExplicitCaching: false,
|
|
542
|
+
supportsLongCacheRetention: false,
|
|
543
|
+
supportsParallelToolCalls: true,
|
|
544
|
+
supportsStreaming: true,
|
|
545
|
+
modalities: ["text"],
|
|
546
|
+
},
|
|
547
|
+
pricing: {},
|
|
548
|
+
};
|
|
549
|
+
}
|