ai-runtime-engine 1.1.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.
Files changed (269) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/LICENSE +15 -0
  3. package/README.md +489 -0
  4. package/dist/artifacts/artifacts.d.ts +28 -0
  5. package/dist/artifacts/artifacts.js +46 -0
  6. package/dist/benchmark/benchmark.d.ts +23 -0
  7. package/dist/benchmark/benchmark.js +40 -0
  8. package/dist/cli/cli.d.ts +6 -0
  9. package/dist/cli/cli.js +161 -0
  10. package/dist/cli/commands/cleanup.d.ts +47 -0
  11. package/dist/cli/commands/cleanup.js +96 -0
  12. package/dist/cli/commands/config.d.ts +8 -0
  13. package/dist/cli/commands/config.js +28 -0
  14. package/dist/cli/commands/doctor.d.ts +57 -0
  15. package/dist/cli/commands/doctor.js +86 -0
  16. package/dist/cli/commands/executions.d.ts +9 -0
  17. package/dist/cli/commands/executions.js +25 -0
  18. package/dist/cli/commands/info.d.ts +43 -0
  19. package/dist/cli/commands/info.js +53 -0
  20. package/dist/cli/commands/init.d.ts +5 -0
  21. package/dist/cli/commands/init.js +75 -0
  22. package/dist/cli/commands/inspect.d.ts +16 -0
  23. package/dist/cli/commands/inspect.js +60 -0
  24. package/dist/cli/commands/phase2.d.ts +22 -0
  25. package/dist/cli/commands/phase2.js +83 -0
  26. package/dist/cli/commands/route.d.ts +14 -0
  27. package/dist/cli/commands/route.js +49 -0
  28. package/dist/cli/commands/run.d.ts +11 -0
  29. package/dist/cli/commands/run.js +37 -0
  30. package/dist/cli/commands/setup.d.ts +34 -0
  31. package/dist/cli/commands/setup.js +104 -0
  32. package/dist/cli/commands/skills.d.ts +28 -0
  33. package/dist/cli/commands/skills.js +48 -0
  34. package/dist/cli/commands/test.d.ts +7 -0
  35. package/dist/cli/commands/test.js +29 -0
  36. package/dist/cli/context.d.ts +12 -0
  37. package/dist/cli/context.js +16 -0
  38. package/dist/cli/interactive/repl.d.ts +6 -0
  39. package/dist/cli/interactive/repl.js +45 -0
  40. package/dist/cli/interactive/session.d.ts +36 -0
  41. package/dist/cli/interactive/session.js +356 -0
  42. package/dist/cli/prompt.d.ts +6 -0
  43. package/dist/cli/prompt.js +18 -0
  44. package/dist/cli/render.d.ts +7 -0
  45. package/dist/cli/render.js +14 -0
  46. package/dist/comparison/analysis.d.ts +46 -0
  47. package/dist/comparison/analysis.js +177 -0
  48. package/dist/comparison/comparator.d.ts +46 -0
  49. package/dist/comparison/comparator.js +270 -0
  50. package/dist/comparison/comparison.d.ts +140 -0
  51. package/dist/comparison/comparison.js +9 -0
  52. package/dist/comparison/render.d.ts +7 -0
  53. package/dist/comparison/render.js +66 -0
  54. package/dist/config/defaults.d.ts +52 -0
  55. package/dist/config/defaults.js +56 -0
  56. package/dist/config/load.d.ts +17 -0
  57. package/dist/config/load.js +50 -0
  58. package/dist/config/providerDefaults.d.ts +17 -0
  59. package/dist/config/providerDefaults.js +61 -0
  60. package/dist/config/schema.d.ts +9 -0
  61. package/dist/config/schema.js +78 -0
  62. package/dist/context/budget.d.ts +13 -0
  63. package/dist/context/budget.js +17 -0
  64. package/dist/context/compiler.d.ts +61 -0
  65. package/dist/context/compiler.js +125 -0
  66. package/dist/context/tokens.d.ts +19 -0
  67. package/dist/context/tokens.js +38 -0
  68. package/dist/conversations/conversations.d.ts +38 -0
  69. package/dist/conversations/conversations.js +64 -0
  70. package/dist/core/capabilities/evidence.d.ts +40 -0
  71. package/dist/core/capabilities/evidence.js +102 -0
  72. package/dist/core/capabilities/overlay.d.ts +15 -0
  73. package/dist/core/capabilities/overlay.js +0 -0
  74. package/dist/core/capabilities/taxonomy.d.ts +19 -0
  75. package/dist/core/capabilities/taxonomy.js +25 -0
  76. package/dist/core/fallback/errors.d.ts +30 -0
  77. package/dist/core/fallback/errors.js +80 -0
  78. package/dist/core/fallback/fallback.d.ts +40 -0
  79. package/dist/core/fallback/fallback.js +82 -0
  80. package/dist/core/fallback/retryPolicy.d.ts +11 -0
  81. package/dist/core/fallback/retryPolicy.js +14 -0
  82. package/dist/core/health/health.d.ts +3 -0
  83. package/dist/core/health/health.js +5 -0
  84. package/dist/core/health/monitor.d.ts +23 -0
  85. package/dist/core/health/monitor.js +82 -0
  86. package/dist/core/policies/budget.d.ts +19 -0
  87. package/dist/core/policies/budget.js +37 -0
  88. package/dist/core/registry/builtinTasks.d.ts +8 -0
  89. package/dist/core/registry/builtinTasks.js +54 -0
  90. package/dist/core/registry/registry.d.ts +18 -0
  91. package/dist/core/registry/registry.js +33 -0
  92. package/dist/core/registry/taskRegistry.d.ts +15 -0
  93. package/dist/core/registry/taskRegistry.js +30 -0
  94. package/dist/core/router/confidence.d.ts +7 -0
  95. package/dist/core/router/confidence.js +20 -0
  96. package/dist/core/router/dimensions.d.ts +16 -0
  97. package/dist/core/router/dimensions.js +60 -0
  98. package/dist/core/router/executor.d.ts +16 -0
  99. package/dist/core/router/executor.js +25 -0
  100. package/dist/core/router/filter.d.ts +34 -0
  101. package/dist/core/router/filter.js +113 -0
  102. package/dist/core/router/normalize.d.ts +30 -0
  103. package/dist/core/router/normalize.js +119 -0
  104. package/dist/core/router/request.d.ts +4 -0
  105. package/dist/core/router/request.js +21 -0
  106. package/dist/core/router/router.d.ts +32 -0
  107. package/dist/core/router/router.js +195 -0
  108. package/dist/core/router/routingPrefs.d.ts +11 -0
  109. package/dist/core/router/routingPrefs.js +30 -0
  110. package/dist/core/router/scorer.d.ts +19 -0
  111. package/dist/core/router/scorer.js +50 -0
  112. package/dist/core/router/weights.d.ts +9 -0
  113. package/dist/core/router/weights.js +31 -0
  114. package/dist/core/validation/validator.d.ts +16 -0
  115. package/dist/core/validation/validator.js +33 -0
  116. package/dist/discovery/modelCatalog.d.ts +28 -0
  117. package/dist/discovery/modelCatalog.js +105 -0
  118. package/dist/discovery/openapi.d.ts +25 -0
  119. package/dist/discovery/openapi.js +76 -0
  120. package/dist/executions/checkpoint.d.ts +26 -0
  121. package/dist/executions/checkpoint.js +114 -0
  122. package/dist/executions/execution.d.ts +51 -0
  123. package/dist/executions/execution.js +8 -0
  124. package/dist/executions/store.d.ts +52 -0
  125. package/dist/executions/store.js +124 -0
  126. package/dist/generation/generateAdapter.d.ts +17 -0
  127. package/dist/generation/generateAdapter.js +30 -0
  128. package/dist/index.d.ts +147 -0
  129. package/dist/index.js +107 -0
  130. package/dist/learning/feedback.d.ts +9 -0
  131. package/dist/learning/feedback.js +18 -0
  132. package/dist/learning/learningStore.d.ts +68 -0
  133. package/dist/learning/learningStore.js +138 -0
  134. package/dist/learning/performanceStore.d.ts +27 -0
  135. package/dist/learning/performanceStore.js +0 -0
  136. package/dist/marketplace/presets.d.ts +24 -0
  137. package/dist/marketplace/presets.js +52 -0
  138. package/dist/mcp/mcp.d.ts +31 -0
  139. package/dist/mcp/mcp.js +54 -0
  140. package/dist/memory/bm25.d.ts +16 -0
  141. package/dist/memory/bm25.js +56 -0
  142. package/dist/memory/classifier.d.ts +14 -0
  143. package/dist/memory/classifier.js +17 -0
  144. package/dist/memory/memory.d.ts +80 -0
  145. package/dist/memory/memory.js +191 -0
  146. package/dist/orchestration/executor.d.ts +35 -0
  147. package/dist/orchestration/executor.js +65 -0
  148. package/dist/orchestration/orchestrator.d.ts +42 -0
  149. package/dist/orchestration/orchestrator.js +63 -0
  150. package/dist/orchestration/plan.d.ts +37 -0
  151. package/dist/orchestration/plan.js +70 -0
  152. package/dist/orchestration/planner.d.ts +29 -0
  153. package/dist/orchestration/planner.js +69 -0
  154. package/dist/plugin/ai.d.ts +82 -0
  155. package/dist/plugin/ai.js +167 -0
  156. package/dist/probing/probe.d.ts +25 -0
  157. package/dist/probing/probe.js +63 -0
  158. package/dist/providers/factory.d.ts +18 -0
  159. package/dist/providers/factory.js +54 -0
  160. package/dist/providers/httpClient.d.ts +34 -0
  161. package/dist/providers/httpClient.js +80 -0
  162. package/dist/providers/httpProvider.d.ts +49 -0
  163. package/dist/providers/httpProvider.js +135 -0
  164. package/dist/providers/mock/demo.d.ts +13 -0
  165. package/dist/providers/mock/demo.js +58 -0
  166. package/dist/providers/mock/mockProvider.d.ts +35 -0
  167. package/dist/providers/mock/mockProvider.js +121 -0
  168. package/dist/providers/mock/scenarios.d.ts +44 -0
  169. package/dist/providers/mock/scenarios.js +30 -0
  170. package/dist/providers/provider.d.ts +26 -0
  171. package/dist/providers/provider.js +11 -0
  172. package/dist/providers/wire/anthropicWire.d.ts +6 -0
  173. package/dist/providers/wire/anthropicWire.js +83 -0
  174. package/dist/providers/wire/openaiWire.d.ts +7 -0
  175. package/dist/providers/wire/openaiWire.js +81 -0
  176. package/dist/providers/wire/registry.d.ts +8 -0
  177. package/dist/providers/wire/registry.js +20 -0
  178. package/dist/providers/wire/types.d.ts +39 -0
  179. package/dist/providers/wire/types.js +24 -0
  180. package/dist/runtime/config.d.ts +31 -0
  181. package/dist/runtime/config.js +121 -0
  182. package/dist/runtime/context.d.ts +34 -0
  183. package/dist/runtime/context.js +11 -0
  184. package/dist/runtime/events.d.ts +99 -0
  185. package/dist/runtime/events.js +82 -0
  186. package/dist/runtime/host.d.ts +27 -0
  187. package/dist/runtime/host.js +7 -0
  188. package/dist/runtime/intent/classifier.d.ts +30 -0
  189. package/dist/runtime/intent/classifier.js +60 -0
  190. package/dist/runtime/intent/signals.d.ts +19 -0
  191. package/dist/runtime/intent/signals.js +46 -0
  192. package/dist/runtime/modes/availability.d.ts +11 -0
  193. package/dist/runtime/modes/availability.js +17 -0
  194. package/dist/runtime/modes/chat.d.ts +18 -0
  195. package/dist/runtime/modes/chat.js +67 -0
  196. package/dist/runtime/modes/modeResolver.d.ts +43 -0
  197. package/dist/runtime/modes/modeResolver.js +78 -0
  198. package/dist/runtime/policy.d.ts +72 -0
  199. package/dist/runtime/policy.js +59 -0
  200. package/dist/runtime/providerView.d.ts +62 -0
  201. package/dist/runtime/providerView.js +105 -0
  202. package/dist/runtime/routing.d.ts +26 -0
  203. package/dist/runtime/routing.js +65 -0
  204. package/dist/runtime/runtime.d.ts +191 -0
  205. package/dist/runtime/runtime.js +718 -0
  206. package/dist/runtime/types.d.ts +153 -0
  207. package/dist/runtime/types.js +9 -0
  208. package/dist/runtime/workspace/detectors.d.ts +15 -0
  209. package/dist/runtime/workspace/detectors.js +57 -0
  210. package/dist/runtime/workspace/workspace.d.ts +29 -0
  211. package/dist/runtime/workspace/workspace.js +116 -0
  212. package/dist/security/credentials.d.ts +26 -0
  213. package/dist/security/credentials.js +34 -0
  214. package/dist/security/redact.d.ts +16 -0
  215. package/dist/security/redact.js +57 -0
  216. package/dist/skills/builtins/fileAnalyzer.d.ts +7 -0
  217. package/dist/skills/builtins/fileAnalyzer.js +47 -0
  218. package/dist/skills/builtins/repositoryAnalyzer.d.ts +6 -0
  219. package/dist/skills/builtins/repositoryAnalyzer.js +47 -0
  220. package/dist/skills/discovery.d.ts +61 -0
  221. package/dist/skills/discovery.js +211 -0
  222. package/dist/skills/manifest.d.ts +30 -0
  223. package/dist/skills/manifest.js +75 -0
  224. package/dist/skills/registry.d.ts +15 -0
  225. package/dist/skills/registry.js +22 -0
  226. package/dist/skills/skill.d.ts +64 -0
  227. package/dist/skills/skill.js +8 -0
  228. package/dist/store/area.d.ts +54 -0
  229. package/dist/store/area.js +164 -0
  230. package/dist/store/paths.d.ts +15 -0
  231. package/dist/store/paths.js +48 -0
  232. package/dist/store/store.d.ts +59 -0
  233. package/dist/store/store.js +140 -0
  234. package/dist/telemetry/sinks/file.d.ts +12 -0
  235. package/dist/telemetry/sinks/file.js +28 -0
  236. package/dist/telemetry/telemetry.d.ts +36 -0
  237. package/dist/telemetry/telemetry.js +63 -0
  238. package/dist/tools/builtins/filesystem.d.ts +7 -0
  239. package/dist/tools/builtins/filesystem.js +53 -0
  240. package/dist/tools/builtins/git.d.ts +10 -0
  241. package/dist/tools/builtins/git.js +66 -0
  242. package/dist/tools/builtins/shell.d.ts +17 -0
  243. package/dist/tools/builtins/shell.js +91 -0
  244. package/dist/tools/jail.d.ts +12 -0
  245. package/dist/tools/jail.js +98 -0
  246. package/dist/tools/permissions.d.ts +25 -0
  247. package/dist/tools/permissions.js +24 -0
  248. package/dist/tools/registry.d.ts +10 -0
  249. package/dist/tools/registry.js +20 -0
  250. package/dist/tools/runner.d.ts +23 -0
  251. package/dist/tools/runner.js +64 -0
  252. package/dist/tools/tool.d.ts +53 -0
  253. package/dist/tools/tool.js +24 -0
  254. package/dist/tools/untrusted.d.ts +13 -0
  255. package/dist/tools/untrusted.js +30 -0
  256. package/dist/types.d.ts +460 -0
  257. package/dist/types.js +12 -0
  258. package/dist/util/clock.d.ts +6 -0
  259. package/dist/util/clock.js +4 -0
  260. package/dist/util/extractJson.d.ts +8 -0
  261. package/dist/util/extractJson.js +54 -0
  262. package/dist/verification/verify.d.ts +26 -0
  263. package/dist/verification/verify.js +67 -0
  264. package/docs/GUIDE.md +358 -0
  265. package/docs/README.md +21 -0
  266. package/docs/architecture.md +78 -0
  267. package/docs/router.md +376 -0
  268. package/docs/security.md +55 -0
  269. package/package.json +67 -0
@@ -0,0 +1,147 @@
1
+ /**
2
+ * Public entry point for ai-runtime.
3
+ *
4
+ * import { AI } from 'ai-runtime-engine';
5
+ * const ai = new AI(config).registerProvider(myProvider);
6
+ * const result = await ai.run({ task: 'generate-playwright-tests', input: ticket });
7
+ */
8
+ export { AI } from './plugin/ai.js';
9
+ export type { AIOptions, ProviderInfo } from './plugin/ai.js';
10
+ export type { AIProvider } from './providers/provider.js';
11
+ export { MockProvider } from './providers/mock/mockProvider.js';
12
+ export type { MockProviderConfig } from './providers/mock/mockProvider.js';
13
+ export { makeModel } from './providers/mock/scenarios.js';
14
+ export type { MakeModelInput, MockBehavior } from './providers/mock/scenarios.js';
15
+ export { HttpProvider } from './providers/httpProvider.js';
16
+ export type { HttpProviderConfig } from './providers/httpProvider.js';
17
+ export { buildProvider } from './providers/factory.js';
18
+ export type { BuildOptions } from './providers/factory.js';
19
+ export type { FetchLike } from './providers/httpClient.js';
20
+ export { PROVIDER_DEFAULTS } from './config/providerDefaults.js';
21
+ export { resolveModelMetadata } from './discovery/modelCatalog.js';
22
+ export { registerWire } from './providers/wire/registry.js';
23
+ export type { WireModule, WireShape } from './providers/wire/types.js';
24
+ export { AIError, isRetryable, statusToCategory, toAIError } from './core/fallback/errors.js';
25
+ export { capabilitySatisfies, emptyProfile, getCapability, mergeProfiles, profileFromDeclared, rankOf, } from './core/capabilities/evidence.js';
26
+ export { AGENT_CAPABILITIES, INPUT_MODALITIES, INTELLIGENCE_SKILLS, OUTPUT_MODALITIES, } from './core/capabilities/taxonomy.js';
27
+ export { BUILTIN_TASKS } from './core/registry/builtinTasks.js';
28
+ export { DEFAULT_WEIGHTS, resolveConfig } from './config/defaults.js';
29
+ export type { ResolvedConfig } from './config/defaults.js';
30
+ export { loadConfig, findConfigFile } from './config/load.js';
31
+ export { parseConfig } from './config/schema.js';
32
+ export { HealthMonitor } from './core/health/monitor.js';
33
+ export { isRoutableState } from './core/health/health.js';
34
+ export { validate } from './core/validation/validator.js';
35
+ export { PerformanceStore } from './learning/performanceStore.js';
36
+ export type { ObservedPerf } from './learning/performanceStore.js';
37
+ export { CapabilityOverlay } from './core/capabilities/overlay.js';
38
+ export { BudgetTracker } from './core/policies/budget.js';
39
+ export { probeModel, ALL_PROBES } from './probing/probe.js';
40
+ export type { ProbeName, ProbeReport, ProbeResult } from './probing/probe.js';
41
+ export { runVerification } from './verification/verify.js';
42
+ export type { VerificationReport } from './types.js';
43
+ export { analyzeOpenApi, analyzeOpenApiFile } from './discovery/openapi.js';
44
+ export type { OpenApiAnalysis } from './discovery/openapi.js';
45
+ export { benchmark } from './benchmark/benchmark.js';
46
+ export type { BenchResult, BenchTaskSpec } from './benchmark/benchmark.js';
47
+ export { generateProviderConfig, generateProviderConfigFromFile } from './generation/generateAdapter.js';
48
+ export type { GenerateOptions } from './generation/generateAdapter.js';
49
+ export { McpRegistry, StaticMcpSource } from './mcp/mcp.js';
50
+ export type { McpToolSource } from './mcp/mcp.js';
51
+ export { setCredentialResolver, Credential } from './security/credentials.js';
52
+ export type { CredentialResolver } from './security/credentials.js';
53
+ export { CallbackSink, MemorySink, MultiSink, NullSink } from './telemetry/telemetry.js';
54
+ export type { TelemetrySink } from './telemetry/telemetry.js';
55
+ export { MARKETPLACE, listPresets, findPreset, presetToConfig } from './marketplace/presets.js';
56
+ export type { ProviderPreset } from './marketplace/presets.js';
57
+ export { loadRemoteConfig, loadConfigAsync } from './config/load.js';
58
+ export { Runtime } from './runtime/runtime.js';
59
+ export type { RuntimeOptions } from './runtime/runtime.js';
60
+ export { RUNTIME_MODES } from './runtime/types.js';
61
+ export type { RuntimeMode, ExecutableMode, ModeSource, ModeResolution, RuntimeConfig, RuntimeSettings, RuntimeRunInput, RuntimeResult, RuntimeStatus, Clarification, ArtifactRef } from './runtime/types.js';
62
+ export type { RuntimeContext } from './runtime/context.js';
63
+ export { resolvePolicy, defaultAutonomyForMode } from './runtime/policy.js';
64
+ export type { ExecutionPolicy, PermissionPolicy, Autonomy, ApprovalLevel, PolicyOverrides } from './runtime/policy.js';
65
+ export { parseRuntimeConfig, loadRuntimeConfig, findRuntimeConfigFile } from './runtime/config.js';
66
+ export { HeuristicIntentClassifier } from './runtime/intent/classifier.js';
67
+ export type { IntentClassifier, IntentClassification, IntentInput } from './runtime/intent/classifier.js';
68
+ export { detectWorkspace, summarizeWorkspace } from './runtime/workspace/workspace.js';
69
+ export type { WorkspaceInfo } from './runtime/workspace/workspace.js';
70
+ export { MODE_AVAILABILITY, IMPLEMENTED_MODES } from './runtime/modes/availability.js';
71
+ export { CHAT_TASK } from './runtime/modes/chat.js';
72
+ export { RuntimeEmitter, MemoryEventSink, CallbackEventSink } from './runtime/events.js';
73
+ export type { RuntimeEvent, RuntimeEventInput, RuntimeEventSink } from './runtime/events.js';
74
+ export type { RuntimeHost, ApprovalProvider, ApprovalRequest } from './runtime/host.js';
75
+ export { deriveAccessState, buildProviderViews, ProviderViewCache } from './runtime/providerView.js';
76
+ export type { AccessState, ProviderView, ModelView, ProviderViewSource } from './runtime/providerView.js';
77
+ export { RuntimeStore, STORE_VERSION } from './store/store.js';
78
+ export type { RuntimeStoreOptions, StorePaths } from './store/store.js';
79
+ export { FileArea, NullArea } from './store/area.js';
80
+ export type { Area, IntegrityIssue } from './store/area.js';
81
+ export { resolveHome, projectId, repositoryId, findRepoRoot } from './store/paths.js';
82
+ export type { StoreScope } from './store/paths.js';
83
+ export { ConversationStore } from './conversations/conversations.js';
84
+ export type { ConversationTurn, ConversationMeta, TurnRole } from './conversations/conversations.js';
85
+ export { MemoryStore } from './memory/memory.js';
86
+ export type { MemoryRecord, MemoryScope, MemorySource, RememberInput, SearchOptions, DeletionAudit, EmbeddingProvider } from './memory/memory.js';
87
+ export { classifyMemory } from './memory/classifier.js';
88
+ export type { MemoryCandidate } from './memory/classifier.js';
89
+ export { bm25Search, tokenize } from './memory/bm25.js';
90
+ export type { MemoryTrace } from './runtime/types.js';
91
+ export { compileContext } from './context/compiler.js';
92
+ export type { ContextBlock, CompiledBlock, CompiledContext, CompileMetrics, CompileOptions, ContextValidation, RetentionLevel } from './context/compiler.js';
93
+ export { TokenEstimator, estimateTokens } from './context/tokens.js';
94
+ export { resolveContextBudget, DEFAULT_CONTEXT_TOKENS } from './context/budget.js';
95
+ export type { ContextBudgetInputs } from './context/budget.js';
96
+ export type { ContextReport } from './runtime/types.js';
97
+ export { ToolRegistry } from './tools/registry.js';
98
+ export { authorize, denied } from './tools/tool.js';
99
+ export type { Tool, ToolContext, ToolResult, ToolErrorCode } from './tools/tool.js';
100
+ export { resolvePermissions } from './tools/permissions.js';
101
+ export type { ResolvedPermissions } from './tools/permissions.js';
102
+ export { resolveInJail, JailError } from './tools/jail.js';
103
+ export { defaultRunner, safeEnv } from './tools/runner.js';
104
+ export type { CommandRunner, RunOptions, RunResult } from './tools/runner.js';
105
+ export { filesystemTool } from './tools/builtins/filesystem.js';
106
+ export { shellTool, createShellTool, isDestructive } from './tools/builtins/shell.js';
107
+ export { gitTool, createGitTool } from './tools/builtins/git.js';
108
+ export { wrapUntrusted, looksLikeInjection } from './tools/untrusted.js';
109
+ export { SkillRegistry } from './skills/registry.js';
110
+ export type { Skill, SkillContext, SkillPlan, SkillResult, SkillValidation } from './skills/skill.js';
111
+ export { fileAnalyzerSkill } from './skills/builtins/fileAnalyzer.js';
112
+ export { repositoryAnalyzerSkill } from './skills/builtins/repositoryAnalyzer.js';
113
+ export { parseManifest, manifestToSkill } from './skills/manifest.js';
114
+ export type { SkillManifest, ManifestStep } from './skills/manifest.js';
115
+ export { discoverSkills, scanRepoForSkills, loadSkillSource, loadSkillPackage, isSkill } from './skills/discovery.js';
116
+ export type { SkillSource, SkillSourceKind, LoadedSource } from './skills/discovery.js';
117
+ export { validatePlan, executionWaves } from './orchestration/plan.js';
118
+ export type { ExecutionPlan, PlanStep, PlanStepStatus, PlanValidation } from './orchestration/plan.js';
119
+ export { generatePlan } from './orchestration/planner.js';
120
+ export type { PlannerInput, PlannerResult } from './orchestration/planner.js';
121
+ export { executePlan } from './orchestration/executor.js';
122
+ export type { ExecuteResult, ExecuteDeps, StepObservation } from './orchestration/executor.js';
123
+ export { orchestrate } from './orchestration/orchestrator.js';
124
+ export type { OrchestrateInput, OrchestrateOutcome, OrchestrationStatus } from './orchestration/orchestrator.js';
125
+ export { ExecutionStore } from './executions/store.js';
126
+ export type { ExecutionStoreOptions, AcquireResult } from './executions/store.js';
127
+ export type { Execution, ExecutionStatus, Lease, Checkpoint, PendingInput } from './executions/execution.js';
128
+ export { RESUMABLE, TERMINAL } from './executions/execution.js';
129
+ export { captureCheckpoint, reconcile, gitHead } from './executions/checkpoint.js';
130
+ export type { Reconciliation } from './executions/checkpoint.js';
131
+ export { ArtifactStore } from './artifacts/artifacts.js';
132
+ export type { PutArtifactInput } from './artifacts/artifacts.js';
133
+ export { compare } from './comparison/comparator.js';
134
+ export type { CompareInput } from './comparison/comparator.js';
135
+ export { analyze, similarity, jaccard, clusterByAgreement, structuredContradictions, missingPoints } from './comparison/analysis.js';
136
+ export { renderComparison } from './comparison/render.js';
137
+ export type { ComparisonPin, ComparisonCandidate, ComparisonResult, ComparisonAnalysis, ComparisonRanking, ComparisonMethod, ComparisonSignal, ComparisonDifference, Contradiction, MissingPoint, AgreementCluster, EvidenceResult, } from './comparison/comparison.js';
138
+ export type { CompareRunOptions } from './runtime/types.js';
139
+ export { LearningStore } from './learning/learningStore.js';
140
+ export type { LearningOutcome, LearnedStat, SkillRef } from './learning/learningStore.js';
141
+ export { classifyFeedback } from './learning/feedback.js';
142
+ export type { FeedbackSignal } from './learning/feedback.js';
143
+ export { resolveRoutingPrefs, withPreferredProviders } from './runtime/routing.js';
144
+ export type { RoutingSources } from './runtime/routing.js';
145
+ export { isExcluded, isPreferred } from './core/router/routingPrefs.js';
146
+ export type { RoutingPreferences } from './types.js';
147
+ export type * from './types.js';
package/dist/index.js ADDED
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Public entry point for ai-runtime.
3
+ *
4
+ * import { AI } from 'ai-runtime-engine';
5
+ * const ai = new AI(config).registerProvider(myProvider);
6
+ * const result = await ai.run({ task: 'generate-playwright-tests', input: ticket });
7
+ */
8
+ // Facade
9
+ export { AI } from './plugin/ai.js';
10
+ export { MockProvider } from './providers/mock/mockProvider.js';
11
+ export { makeModel } from './providers/mock/scenarios.js';
12
+ // Concrete adapter + factory (build providers from config, or construct directly)
13
+ export { HttpProvider } from './providers/httpProvider.js';
14
+ export { buildProvider } from './providers/factory.js';
15
+ export { PROVIDER_DEFAULTS } from './config/providerDefaults.js';
16
+ export { resolveModelMetadata } from './discovery/modelCatalog.js';
17
+ export { registerWire } from './providers/wire/registry.js';
18
+ // Errors
19
+ export { AIError, isRetryable, statusToCategory, toAIError } from './core/fallback/errors.js';
20
+ // Capability helpers (for adapters/catalogs building CapabilityProfiles)
21
+ export { capabilitySatisfies, emptyProfile, getCapability, mergeProfiles, profileFromDeclared, rankOf, } from './core/capabilities/evidence.js';
22
+ export { AGENT_CAPABILITIES, INPUT_MODALITIES, INTELLIGENCE_SKILLS, OUTPUT_MODALITIES, } from './core/capabilities/taxonomy.js';
23
+ // Task defaults
24
+ export { BUILTIN_TASKS } from './core/registry/builtinTasks.js';
25
+ // Config resolution + defaults + loading
26
+ export { DEFAULT_WEIGHTS, resolveConfig } from './config/defaults.js';
27
+ export { loadConfig, findConfigFile } from './config/load.js';
28
+ export { parseConfig } from './config/schema.js';
29
+ // Health monitoring
30
+ export { HealthMonitor } from './core/health/monitor.js';
31
+ export { isRoutableState } from './core/health/health.js';
32
+ // Validation
33
+ export { validate } from './core/validation/validator.js';
34
+ // Learning & verification — learning, probing, verification, OpenAPI discovery, benchmarking
35
+ export { PerformanceStore } from './learning/performanceStore.js';
36
+ export { CapabilityOverlay } from './core/capabilities/overlay.js';
37
+ export { BudgetTracker } from './core/policies/budget.js';
38
+ export { probeModel, ALL_PROBES } from './probing/probe.js';
39
+ export { runVerification } from './verification/verify.js';
40
+ export { analyzeOpenApi, analyzeOpenApiFile } from './discovery/openapi.js';
41
+ export { benchmark } from './benchmark/benchmark.js';
42
+ // Enterprise & extensibility — dynamic adapters, MCP, enterprise credentials, observability, policy, marketplace, remote
43
+ export { generateProviderConfig, generateProviderConfigFromFile } from './generation/generateAdapter.js';
44
+ export { McpRegistry, StaticMcpSource } from './mcp/mcp.js';
45
+ export { setCredentialResolver, Credential } from './security/credentials.js';
46
+ export { CallbackSink, MemorySink, MultiSink, NullSink } from './telemetry/telemetry.js';
47
+ export { MARKETPLACE, listPresets, findPreset, presetToConfig } from './marketplace/presets.js';
48
+ export { loadRemoteConfig, loadConfigAsync } from './config/load.js';
49
+ // ── Runtime (Phase 1) — high-level facade over the router: modes, workspace, policy ──
50
+ export { Runtime } from './runtime/runtime.js';
51
+ export { RUNTIME_MODES } from './runtime/types.js';
52
+ export { resolvePolicy, defaultAutonomyForMode } from './runtime/policy.js';
53
+ export { parseRuntimeConfig, loadRuntimeConfig, findRuntimeConfigFile } from './runtime/config.js';
54
+ export { HeuristicIntentClassifier } from './runtime/intent/classifier.js';
55
+ export { detectWorkspace, summarizeWorkspace } from './runtime/workspace/workspace.js';
56
+ export { MODE_AVAILABILITY, IMPLEMENTED_MODES } from './runtime/modes/availability.js';
57
+ export { CHAT_TASK } from './runtime/modes/chat.js';
58
+ // ── Runtime (Phase 2) — events, host contract, provider views ──
59
+ export { RuntimeEmitter, MemoryEventSink, CallbackEventSink } from './runtime/events.js';
60
+ export { deriveAccessState, buildProviderViews, ProviderViewCache } from './runtime/providerView.js';
61
+ // ── Runtime (Phase 3) — local store, conversations, memory ──
62
+ export { RuntimeStore, STORE_VERSION } from './store/store.js';
63
+ export { FileArea, NullArea } from './store/area.js';
64
+ export { resolveHome, projectId, repositoryId, findRepoRoot } from './store/paths.js';
65
+ export { ConversationStore } from './conversations/conversations.js';
66
+ export { MemoryStore } from './memory/memory.js';
67
+ export { classifyMemory } from './memory/classifier.js';
68
+ export { bm25Search, tokenize } from './memory/bm25.js';
69
+ // ── Runtime (Phase 4) — context compiler + token budgets ──
70
+ export { compileContext } from './context/compiler.js';
71
+ export { TokenEstimator, estimateTokens } from './context/tokens.js';
72
+ export { resolveContextBudget, DEFAULT_CONTEXT_TOKENS } from './context/budget.js';
73
+ // ── Runtime (Phase 5) — tools, permissions, skills, untrusted-data boundary ──
74
+ export { ToolRegistry } from './tools/registry.js';
75
+ export { authorize, denied } from './tools/tool.js';
76
+ export { resolvePermissions } from './tools/permissions.js';
77
+ export { resolveInJail, JailError } from './tools/jail.js';
78
+ export { defaultRunner, safeEnv } from './tools/runner.js';
79
+ export { filesystemTool } from './tools/builtins/filesystem.js';
80
+ export { shellTool, createShellTool, isDestructive } from './tools/builtins/shell.js';
81
+ export { gitTool, createGitTool } from './tools/builtins/git.js';
82
+ export { wrapUntrusted, looksLikeInjection } from './tools/untrusted.js';
83
+ export { SkillRegistry } from './skills/registry.js';
84
+ export { fileAnalyzerSkill } from './skills/builtins/fileAnalyzer.js';
85
+ export { repositoryAnalyzerSkill } from './skills/builtins/repositoryAnalyzer.js';
86
+ // ── Runtime (Phase 11) — local skill discovery (manifests + module skills) ──
87
+ export { parseManifest, manifestToSkill } from './skills/manifest.js';
88
+ export { discoverSkills, scanRepoForSkills, loadSkillSource, loadSkillPackage, isSkill } from './skills/discovery.js';
89
+ // ── Runtime (Phase 6) — planner, executor, orchestrator ──
90
+ export { validatePlan, executionWaves } from './orchestration/plan.js';
91
+ export { generatePlan } from './orchestration/planner.js';
92
+ export { executePlan } from './orchestration/executor.js';
93
+ export { orchestrate } from './orchestration/orchestrator.js';
94
+ // ── Runtime (Phase 7) — persistent executions, artifacts, checkpoints ──
95
+ export { ExecutionStore } from './executions/store.js';
96
+ export { RESUMABLE, TERMINAL } from './executions/execution.js';
97
+ export { captureCheckpoint, reconcile, gitHead } from './executions/checkpoint.js';
98
+ export { ArtifactStore } from './artifacts/artifacts.js';
99
+ // ── Runtime (Phase 8) — comparison engine (fan-out pins → agreement/differences/contradictions/missing) ──
100
+ export { compare } from './comparison/comparator.js';
101
+ export { analyze, similarity, jaccard, clusterByAgreement, structuredContradictions, missingPoints } from './comparison/analysis.js';
102
+ export { renderComparison } from './comparison/render.js';
103
+ // ── Runtime (Phase 9) — learning (skill/workflow/plan) + feedback + exclude/prefer routing ──
104
+ export { LearningStore } from './learning/learningStore.js';
105
+ export { classifyFeedback } from './learning/feedback.js';
106
+ export { resolveRoutingPrefs, withPreferredProviders } from './runtime/routing.js';
107
+ export { isExcluded, isPreferred } from './core/router/routingPrefs.js';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Deterministic feedback classification — turns free-text user feedback ("that worked", "wrong root
3
+ * cause") into a positive/negative/neutral signal for the learning store. Negation dominates: if the
4
+ * text reads negative it is negative even when it also contains a positive word (e.g. "not working"
5
+ * contains "working"). Ambiguous or unrecognized text is neutral — never guessed.
6
+ */
7
+ export type FeedbackSignal = 'positive' | 'negative' | 'neutral';
8
+ /** Classify user feedback text. Negation wins over a co-occurring positive token. */
9
+ export declare function classifyFeedback(text: string): FeedbackSignal;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Deterministic feedback classification — turns free-text user feedback ("that worked", "wrong root
3
+ * cause") into a positive/negative/neutral signal for the learning store. Negation dominates: if the
4
+ * text reads negative it is negative even when it also contains a positive word (e.g. "not working"
5
+ * contains "working"). Ambiguous or unrecognized text is neutral — never guessed.
6
+ */
7
+ const NEGATIVE = /\b(wrong|incorrect|(did|does|is|was|are|has)(n'?t| not) work\w*|failed|failing|broken|useless|wrong root cause|off base|nope|no good|bad)\b/i;
8
+ /** A positive term negated within a short window — e.g. "not good", "isn't correct", "no longer working". */
9
+ const NEG_POSITIVE = /(?:\b(?:not|never|no longer)\b|n'?t)\s+(?:\w+\s+){0,2}(?:worked|works|working|correct|great|good|fixed|resolved|perfect|nice|helpful|right|useful)\b/i;
10
+ const POSITIVE = /\b(worked|works|working|correct|great|good|fixed|resolved|perfect|nice|helpful|thanks|thank you|spot on|exactly|that'?s right|well done)\b/i;
11
+ /** Classify user feedback text. Negation wins over a co-occurring positive token. */
12
+ export function classifyFeedback(text) {
13
+ if (NEGATIVE.test(text) || NEG_POSITIVE.test(text))
14
+ return 'negative';
15
+ if (POSITIVE.test(text))
16
+ return 'positive';
17
+ return 'neutral';
18
+ }
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Runtime-level learning (spec §34). Records outcomes at several granularities — provider,
3
+ * provider/model, skill (with EXACT version), workflow (goal pattern → skills), plan (goal pattern →
4
+ * mode) — behind a minimum-sample gate, and turns strong provider records into SOFT prefer signals.
5
+ *
6
+ * Learning only ever produces soft signals: `preferredProviders()` feeds the scorer's userPreference
7
+ * dimension. It can never re-admit an excluded/incapable/unhealthy provider (those are dropped by the
8
+ * hard filter) — the safety-rail test proves this. Stats persist in the store's cross-project `learning`
9
+ * area; a stateless store makes this a no-op.
10
+ */
11
+ import type { Area } from '../store/area.js';
12
+ import type { FeedbackSignal } from './feedback.js';
13
+ import type { ComparisonSignal } from '../comparison/comparison.js';
14
+ export interface LearnedStat {
15
+ attempts: number;
16
+ successes: number;
17
+ totalLatencyMs: number;
18
+ positive: number;
19
+ negative: number;
20
+ }
21
+ export interface SkillRef {
22
+ id: string;
23
+ version: string;
24
+ }
25
+ export interface LearningOutcome {
26
+ /** Coarse goal pattern (e.g. the first few significant tokens) for workflow/plan learning. */
27
+ goalType?: string;
28
+ mode?: string;
29
+ providerId?: string;
30
+ model?: string;
31
+ /** Skills used, referenced by EXACT version so a skill update lowers historical confidence. */
32
+ skills?: SkillRef[];
33
+ ok: boolean;
34
+ latencyMs?: number;
35
+ }
36
+ export declare class LearningStore {
37
+ private readonly area;
38
+ readonly enabled: boolean;
39
+ private readonly stats;
40
+ /** Keys touched by the most recent record/ingest — the target of a bare `feedback(text)`. */
41
+ private lastKeys;
42
+ constructor(area: Area);
43
+ private get;
44
+ private bump;
45
+ private keysFor;
46
+ /** Record one outcome across every granularity it touches. No-op when learning is disabled. */
47
+ record(o: LearningOutcome): void;
48
+ /** Ingest Phase-8 comparison signals: each ran candidate is an outcome; an evidence winner is a positive. */
49
+ ingestComparisonSignals(signals: ComparisonSignal[]): void;
50
+ /** Apply free-text feedback to the most-recent outcome, or to an explicit provider/model. */
51
+ feedback(text: string, opts?: {
52
+ providerId?: string;
53
+ model?: string;
54
+ }): FeedbackSignal;
55
+ /**
56
+ * Providers whose blended success rate clears `minRate` with at least `minSamples` observations —
57
+ * surfaced as SOFT prefer signals only. An excluded/incapable provider that appears here is still
58
+ * dropped by the hard filter; this never forces a selection.
59
+ */
60
+ preferredProviders(opts?: {
61
+ minSamples?: number;
62
+ minRate?: number;
63
+ }): string[];
64
+ snapshot(): Array<{
65
+ key: string;
66
+ } & LearnedStat>;
67
+ private persist;
68
+ }
@@ -0,0 +1,138 @@
1
+ /**
2
+ * Runtime-level learning (spec §34). Records outcomes at several granularities — provider,
3
+ * provider/model, skill (with EXACT version), workflow (goal pattern → skills), plan (goal pattern →
4
+ * mode) — behind a minimum-sample gate, and turns strong provider records into SOFT prefer signals.
5
+ *
6
+ * Learning only ever produces soft signals: `preferredProviders()` feeds the scorer's userPreference
7
+ * dimension. It can never re-admit an excluded/incapable/unhealthy provider (those are dropped by the
8
+ * hard filter) — the safety-rail test proves this. Stats persist in the store's cross-project `learning`
9
+ * area; a stateless store makes this a no-op.
10
+ */
11
+ import { classifyFeedback } from './feedback.js';
12
+ const RECORD_ID = 'stats';
13
+ const MIN_SAMPLES = 3;
14
+ function emptyStat() {
15
+ return { attempts: 0, successes: 0, totalLatencyMs: 0, positive: 0, negative: 0 };
16
+ }
17
+ export class LearningStore {
18
+ area;
19
+ enabled;
20
+ stats = new Map();
21
+ /** Keys touched by the most recent record/ingest — the target of a bare `feedback(text)`. */
22
+ lastKeys = [];
23
+ constructor(area) {
24
+ this.area = area;
25
+ this.enabled = area.enabled;
26
+ const saved = area.tryReadJson(RECORD_ID);
27
+ if (saved)
28
+ for (const [k, v] of Object.entries(saved))
29
+ this.stats.set(k, { ...emptyStat(), ...v });
30
+ }
31
+ get(key) {
32
+ let s = this.stats.get(key);
33
+ if (!s) {
34
+ s = emptyStat();
35
+ this.stats.set(key, s);
36
+ }
37
+ return s;
38
+ }
39
+ bump(key, ok, latencyMs = 0) {
40
+ const s = this.get(key);
41
+ s.attempts += 1;
42
+ if (ok)
43
+ s.successes += 1;
44
+ s.totalLatencyMs += latencyMs;
45
+ return s;
46
+ }
47
+ keysFor(o) {
48
+ const keys = [];
49
+ if (o.providerId)
50
+ keys.push(`provider:${o.providerId}`);
51
+ if (o.providerId && o.model)
52
+ keys.push(`pm:${o.providerId}/${o.model}`);
53
+ for (const s of o.skills ?? [])
54
+ keys.push(`skill:${s.id}@${s.version}`);
55
+ if (o.goalType && o.skills?.length)
56
+ keys.push(`workflow:${o.goalType}`);
57
+ if (o.goalType && o.mode)
58
+ keys.push(`plan:${o.goalType}`);
59
+ return keys;
60
+ }
61
+ /** Record one outcome across every granularity it touches. No-op when learning is disabled. */
62
+ record(o) {
63
+ if (!this.enabled)
64
+ return;
65
+ const keys = this.keysFor(o);
66
+ for (const k of keys)
67
+ this.bump(k, o.ok, o.latencyMs);
68
+ this.lastKeys = keys;
69
+ this.persist();
70
+ }
71
+ /** Ingest Phase-8 comparison signals: each ran candidate is an outcome; an evidence winner is a positive. */
72
+ ingestComparisonSignals(signals) {
73
+ if (!this.enabled)
74
+ return;
75
+ const touched = [];
76
+ for (const s of signals) {
77
+ if (!s.ran)
78
+ continue;
79
+ const keys = [`provider:${s.providerId}`, `pm:${s.providerId}/${s.model}`];
80
+ for (const k of keys) {
81
+ const stat = this.bump(k, s.ok, s.latencyMs);
82
+ if (s.preferred)
83
+ stat.positive += 1; // an evidence-established winner is explicit positive signal
84
+ }
85
+ touched.push(...keys);
86
+ }
87
+ this.lastKeys = touched;
88
+ this.persist();
89
+ }
90
+ /** Apply free-text feedback to the most-recent outcome, or to an explicit provider/model. */
91
+ feedback(text, opts = {}) {
92
+ const sig = classifyFeedback(text);
93
+ if (!this.enabled || sig === 'neutral')
94
+ return sig;
95
+ const keys = opts.providerId
96
+ ? [`provider:${opts.providerId}`, ...(opts.model ? [`pm:${opts.providerId}/${opts.model}`] : [])]
97
+ : this.lastKeys;
98
+ for (const k of keys) {
99
+ const s = this.get(k);
100
+ if (sig === 'positive')
101
+ s.positive += 1;
102
+ else
103
+ s.negative += 1;
104
+ }
105
+ if (keys.length)
106
+ this.persist();
107
+ return sig;
108
+ }
109
+ /**
110
+ * Providers whose blended success rate clears `minRate` with at least `minSamples` observations —
111
+ * surfaced as SOFT prefer signals only. An excluded/incapable provider that appears here is still
112
+ * dropped by the hard filter; this never forces a selection.
113
+ */
114
+ preferredProviders(opts = {}) {
115
+ const minSamples = opts.minSamples ?? MIN_SAMPLES;
116
+ const minRate = opts.minRate ?? 0.6;
117
+ const ranked = [];
118
+ for (const [k, s] of this.stats) {
119
+ if (!k.startsWith('provider:'))
120
+ continue;
121
+ const signals = s.attempts + s.positive + s.negative;
122
+ if (signals < minSamples)
123
+ continue;
124
+ const rate = (s.successes + s.positive) / signals;
125
+ if (rate >= minRate)
126
+ ranked.push({ id: k.slice('provider:'.length), rate });
127
+ }
128
+ return ranked.sort((a, b) => b.rate - a.rate).map((x) => x.id);
129
+ }
130
+ snapshot() {
131
+ return [...this.stats.entries()].map(([key, s]) => ({ key, ...s }));
132
+ }
133
+ persist() {
134
+ if (!this.enabled)
135
+ return;
136
+ this.area.writeJson(RECORD_ID, Object.fromEntries(this.stats));
137
+ }
138
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Learning-based routing (PRD §31/§50). Records observed outcomes per (task, provider, model) and
3
+ * exposes observed success-rate and latency so the scorer can prefer what actually works for a task,
4
+ * not just what the catalog advertised. It only feeds SOFT scoring dimensions — it can never override
5
+ * a hard constraint (capability, privacy, cost, disabled). Observations need a minimum sample count
6
+ * before they are trusted, to avoid over-reacting to noise.
7
+ */
8
+ export interface ObservedPerf {
9
+ samples: number;
10
+ successRate: number;
11
+ avgLatencyMs: number;
12
+ }
13
+ export declare class PerformanceStore {
14
+ private readonly stats;
15
+ private key;
16
+ record(taskId: string, providerId: string, model: string, ok: boolean, latencyMs: number): void;
17
+ /** Observed performance for a (task, provider, model), or undefined until MIN_SAMPLES is reached. */
18
+ forTask(taskId: string, providerId: string, model: string): ObservedPerf | undefined;
19
+ /** Full snapshot for inspection / persistence. */
20
+ snapshot(): Array<{
21
+ taskId: string;
22
+ providerId: string;
23
+ model: string;
24
+ } & ObservedPerf>;
25
+ }
26
+ /** A lookup bound to the current task, handed to the scorer. */
27
+ export type HistoryLookup = (providerId: string, model: string) => ObservedPerf | undefined;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Provider marketplace. A curated catalog of ready-to-use provider presets so a user can
3
+ * add a provider by name instead of hand-writing baseUrl/wireShape/env. Most entries are OpenAI-
4
+ * compatible and therefore ride the same single HTTP path; the native ones name their wire shape.
5
+ * A preset resolves to a plain ProviderConfig the operator can drop into their config.
6
+ */
7
+ import type { PrivacyClass, ProviderConfig, ProviderKind } from '../types.js';
8
+ import type { WireShape } from '../providers/wire/types.js';
9
+ export interface ProviderPreset {
10
+ id: string;
11
+ kind: ProviderKind;
12
+ name: string;
13
+ description: string;
14
+ baseUrl?: string;
15
+ wireShape: WireShape;
16
+ privacyClass: PrivacyClass;
17
+ apiKeyEnv?: string;
18
+ defaultModels: string[];
19
+ }
20
+ export declare const MARKETPLACE: ProviderPreset[];
21
+ export declare function listPresets(): ProviderPreset[];
22
+ export declare function findPreset(id: string): ProviderPreset | undefined;
23
+ /** Resolve a preset (plus optional overrides) into a ProviderConfig ready to register. */
24
+ export declare function presetToConfig(presetId: string, overrides?: Partial<ProviderConfig>): ProviderConfig;
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Provider marketplace. A curated catalog of ready-to-use provider presets so a user can
3
+ * add a provider by name instead of hand-writing baseUrl/wireShape/env. Most entries are OpenAI-
4
+ * compatible and therefore ride the same single HTTP path; the native ones name their wire shape.
5
+ * A preset resolves to a plain ProviderConfig the operator can drop into their config.
6
+ */
7
+ import { PROVIDER_DEFAULTS } from '../config/providerDefaults.js';
8
+ const nativePresets = ['gemini', 'groq', 'anthropic', 'ollama'].map((kind) => {
9
+ const d = PROVIDER_DEFAULTS[kind];
10
+ return {
11
+ id: kind,
12
+ kind,
13
+ name: d.name,
14
+ description: `${d.name} via its ${d.wireShape === 'anthropic' ? 'native' : 'OpenAI-compatible'} API`,
15
+ ...(d.baseUrl ? { baseUrl: d.baseUrl } : {}),
16
+ wireShape: d.wireShape,
17
+ privacyClass: d.privacyClass,
18
+ ...(d.apiKeyEnv ? { apiKeyEnv: d.apiKeyEnv } : {}),
19
+ defaultModels: d.defaultModels,
20
+ };
21
+ });
22
+ const communityPresets = [
23
+ { id: 'openrouter', kind: 'openai-compatible', name: 'OpenRouter', description: 'Aggregator of many models via one OpenAI-compatible endpoint', baseUrl: 'https://openrouter.ai/api/v1', wireShape: 'openai', privacyClass: 'cloud', apiKeyEnv: 'OPENROUTER_API_KEY', defaultModels: [] },
24
+ { id: 'cerebras', kind: 'openai-compatible', name: 'Cerebras', description: 'Fast inference, OpenAI-compatible', baseUrl: 'https://api.cerebras.ai/v1', wireShape: 'openai', privacyClass: 'cloud', apiKeyEnv: 'CEREBRAS_API_KEY', defaultModels: [] },
25
+ { id: 'mistral', kind: 'openai-compatible', name: 'Mistral', description: 'Mistral models, OpenAI-compatible', baseUrl: 'https://api.mistral.ai/v1', wireShape: 'openai', privacyClass: 'cloud', apiKeyEnv: 'MISTRAL_API_KEY', defaultModels: [] },
26
+ { id: 'together', kind: 'openai-compatible', name: 'Together AI', description: 'Open models, OpenAI-compatible', baseUrl: 'https://api.together.xyz/v1', wireShape: 'openai', privacyClass: 'cloud', apiKeyEnv: 'TOGETHER_API_KEY', defaultModels: [] },
27
+ { id: 'deepseek', kind: 'openai-compatible', name: 'DeepSeek', description: 'DeepSeek models, OpenAI-compatible', baseUrl: 'https://api.deepseek.com/v1', wireShape: 'openai', privacyClass: 'cloud', apiKeyEnv: 'DEEPSEEK_API_KEY', defaultModels: [] },
28
+ ];
29
+ export const MARKETPLACE = [...nativePresets, ...communityPresets];
30
+ export function listPresets() {
31
+ return MARKETPLACE;
32
+ }
33
+ export function findPreset(id) {
34
+ return MARKETPLACE.find((p) => p.id === id);
35
+ }
36
+ /** Resolve a preset (plus optional overrides) into a ProviderConfig ready to register. */
37
+ export function presetToConfig(presetId, overrides = {}) {
38
+ const preset = findPreset(presetId);
39
+ if (!preset)
40
+ throw new Error(`unknown provider preset '${presetId}'`);
41
+ const config = {
42
+ id: preset.id,
43
+ kind: preset.kind,
44
+ ...(preset.baseUrl ? { baseUrl: preset.baseUrl } : {}),
45
+ ...(preset.apiKeyEnv ? { apiKeyEnv: preset.apiKeyEnv } : {}),
46
+ wireShape: preset.wireShape,
47
+ privacyClass: preset.privacyClass,
48
+ ...(preset.defaultModels.length ? { models: preset.defaultModels } : {}),
49
+ ...overrides,
50
+ };
51
+ return config;
52
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * MCP integration. MCP is treated as an INTEGRATION LAYER for tools/context, NOT as another
3
+ * model provider. A source exposes tools (as normalized
4
+ * ToolSpecs) that the router hands to whichever model it selects; the model's tool_calling capability
5
+ * is what carries them. Sources are pluggable; a StaticMcpSource covers in-process tools and tests.
6
+ *
7
+ * This is a minimal, transport-agnostic surface: real stdio/HTTP MCP clients implement `McpToolSource`.
8
+ */
9
+ import type { ToolSpec } from '../types.js';
10
+ export interface McpToolSource {
11
+ readonly id: string;
12
+ listTools(): Promise<ToolSpec[]>;
13
+ callTool?(name: string, args: unknown): Promise<unknown>;
14
+ }
15
+ export declare class StaticMcpSource implements McpToolSource {
16
+ readonly id: string;
17
+ private readonly tools;
18
+ private readonly handlers;
19
+ constructor(id: string, tools: ToolSpec[], handlers?: Record<string, (args: unknown) => unknown | Promise<unknown>>);
20
+ listTools(): Promise<ToolSpec[]>;
21
+ callTool(name: string, args: unknown): Promise<unknown>;
22
+ }
23
+ export declare class McpRegistry {
24
+ private readonly sources;
25
+ register(source: McpToolSource): void;
26
+ list(): McpToolSource[];
27
+ /** Aggregate tools across all registered sources. Tool names are namespaced by source to avoid clashes. */
28
+ allTools(): Promise<ToolSpec[]>;
29
+ /** Route a (namespaced) tool call to its source. */
30
+ call(name: string, args: unknown): Promise<unknown>;
31
+ }