nexus-ai-pro 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.
Files changed (171) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1249 -0
  3. package/assets/nexus-ai-pro-presentation.jpg +0 -0
  4. package/dist/agent/loop.d.ts +12 -0
  5. package/dist/agent/loop.js +89 -0
  6. package/dist/agent/tool.d.ts +16 -0
  7. package/dist/agent/tool.js +43 -0
  8. package/dist/cache/adapters.d.ts +42 -0
  9. package/dist/cache/adapters.js +76 -0
  10. package/dist/cache/memory-cache.d.ts +20 -0
  11. package/dist/cache/memory-cache.js +63 -0
  12. package/dist/cache/semantic-cache.d.ts +19 -0
  13. package/dist/cache/semantic-cache.js +71 -0
  14. package/dist/connectors/web.d.ts +8 -0
  15. package/dist/connectors/web.js +60 -0
  16. package/dist/core/nexus.d.ts +71 -0
  17. package/dist/core/nexus.js +477 -0
  18. package/dist/core/response-format.d.ts +8 -0
  19. package/dist/core/response-format.js +121 -0
  20. package/dist/core/secure-stream.d.ts +3 -0
  21. package/dist/core/secure-stream.js +41 -0
  22. package/dist/core/streaming.d.ts +4 -0
  23. package/dist/core/streaming.js +30 -0
  24. package/dist/embeddings/providers.d.ts +20 -0
  25. package/dist/embeddings/providers.js +60 -0
  26. package/dist/evals/metrics.d.ts +75 -0
  27. package/dist/evals/metrics.js +157 -0
  28. package/dist/evals/runner.d.ts +35 -0
  29. package/dist/evals/runner.js +47 -0
  30. package/dist/hallucination/consistency.d.ts +14 -0
  31. package/dist/hallucination/consistency.js +58 -0
  32. package/dist/hallucination/factual.d.ts +14 -0
  33. package/dist/hallucination/factual.js +35 -0
  34. package/dist/hallucination/knowledge-graph.d.ts +27 -0
  35. package/dist/hallucination/knowledge-graph.js +70 -0
  36. package/dist/hallucination/rag.d.ts +21 -0
  37. package/dist/hallucination/rag.js +46 -0
  38. package/dist/hallucination/retrieval.d.ts +24 -0
  39. package/dist/hallucination/retrieval.js +71 -0
  40. package/dist/hallucination/verification.d.ts +36 -0
  41. package/dist/hallucination/verification.js +110 -0
  42. package/dist/index.d.ts +62 -0
  43. package/dist/index.js +53 -0
  44. package/dist/jobs/batch.d.ts +11 -0
  45. package/dist/jobs/batch.js +32 -0
  46. package/dist/jobs/durable-adapters.d.ts +48 -0
  47. package/dist/jobs/durable-adapters.js +50 -0
  48. package/dist/jobs/queue.d.ts +24 -0
  49. package/dist/jobs/queue.js +57 -0
  50. package/dist/models/registry.d.ts +15 -0
  51. package/dist/models/registry.js +43 -0
  52. package/dist/next/route-handler.d.ts +6 -0
  53. package/dist/next/route-handler.js +35 -0
  54. package/dist/ops/audit-logger.d.ts +6 -0
  55. package/dist/ops/audit-logger.js +19 -0
  56. package/dist/ops/health.d.ts +29 -0
  57. package/dist/ops/health.js +69 -0
  58. package/dist/ops/metrics.d.ts +53 -0
  59. package/dist/ops/metrics.js +122 -0
  60. package/dist/ops/otel-tracing.d.ts +20 -0
  61. package/dist/ops/otel-tracing.js +50 -0
  62. package/dist/ops/rate-limiter.d.ts +11 -0
  63. package/dist/ops/rate-limiter.js +33 -0
  64. package/dist/optimizer/budget.d.ts +19 -0
  65. package/dist/optimizer/budget.js +88 -0
  66. package/dist/optimizer/cost.d.ts +13 -0
  67. package/dist/optimizer/cost.js +31 -0
  68. package/dist/optimizer/densifier.d.ts +10 -0
  69. package/dist/optimizer/densifier.js +77 -0
  70. package/dist/optimizer/index.d.ts +12 -0
  71. package/dist/optimizer/index.js +59 -0
  72. package/dist/pipeline/pipeline.d.ts +14 -0
  73. package/dist/pipeline/pipeline.js +106 -0
  74. package/dist/pipeline/types.d.ts +46 -0
  75. package/dist/pipeline/types.js +1 -0
  76. package/dist/providers/anthropic.d.ts +15 -0
  77. package/dist/providers/anthropic.js +183 -0
  78. package/dist/providers/base.d.ts +19 -0
  79. package/dist/providers/base.js +75 -0
  80. package/dist/providers/cohere.d.ts +16 -0
  81. package/dist/providers/cohere.js +104 -0
  82. package/dist/providers/google.d.ts +22 -0
  83. package/dist/providers/google.js +226 -0
  84. package/dist/providers/groq.d.ts +15 -0
  85. package/dist/providers/groq.js +50 -0
  86. package/dist/providers/mistral.d.ts +15 -0
  87. package/dist/providers/mistral.js +50 -0
  88. package/dist/providers/ollama.d.ts +15 -0
  89. package/dist/providers/ollama.js +108 -0
  90. package/dist/providers/openai.d.ts +21 -0
  91. package/dist/providers/openai.js +304 -0
  92. package/dist/providers/openrouter.d.ts +14 -0
  93. package/dist/providers/openrouter.js +19 -0
  94. package/dist/rag/file-ingestion.d.ts +20 -0
  95. package/dist/rag/file-ingestion.js +55 -0
  96. package/dist/rag/ingestion.d.ts +21 -0
  97. package/dist/rag/ingestion.js +47 -0
  98. package/dist/router/auto-router.d.ts +17 -0
  99. package/dist/router/auto-router.js +228 -0
  100. package/dist/router/failover.d.ts +21 -0
  101. package/dist/router/failover.js +126 -0
  102. package/dist/router/index.d.ts +12 -0
  103. package/dist/router/index.js +31 -0
  104. package/dist/router/rules-router.d.ts +7 -0
  105. package/dist/router/rules-router.js +68 -0
  106. package/dist/router/types.d.ts +19 -0
  107. package/dist/router/types.js +1 -0
  108. package/dist/security/index.d.ts +31 -0
  109. package/dist/security/index.js +173 -0
  110. package/dist/security/injection-calibration.d.ts +17 -0
  111. package/dist/security/injection-calibration.js +48 -0
  112. package/dist/security/injection-detector.d.ts +8 -0
  113. package/dist/security/injection-detector.js +66 -0
  114. package/dist/security/input-guard.d.ts +7 -0
  115. package/dist/security/input-guard.js +109 -0
  116. package/dist/security/output-guard.d.ts +6 -0
  117. package/dist/security/output-guard.js +144 -0
  118. package/dist/security/pii-detector.d.ts +8 -0
  119. package/dist/security/pii-detector.js +66 -0
  120. package/dist/security/policies.d.ts +4 -0
  121. package/dist/security/policies.js +61 -0
  122. package/dist/security/prompt-hardening.d.ts +6 -0
  123. package/dist/security/prompt-hardening.js +18 -0
  124. package/dist/security/schema-validator.d.ts +234 -0
  125. package/dist/security/schema-validator.js +68 -0
  126. package/dist/security/semantic-injection-classifier.d.ts +19 -0
  127. package/dist/security/semantic-injection-classifier.js +75 -0
  128. package/dist/security/upload-scanner.d.ts +29 -0
  129. package/dist/security/upload-scanner.js +72 -0
  130. package/dist/testing/provider-conformance.d.ts +24 -0
  131. package/dist/testing/provider-conformance.js +97 -0
  132. package/dist/types/agent.d.ts +34 -0
  133. package/dist/types/agent.js +1 -0
  134. package/dist/types/config.d.ts +171 -0
  135. package/dist/types/config.js +1 -0
  136. package/dist/types/messages.d.ts +96 -0
  137. package/dist/types/messages.js +1 -0
  138. package/dist/types/optimizer.d.ts +30 -0
  139. package/dist/types/optimizer.js +1 -0
  140. package/dist/types/planning.d.ts +27 -0
  141. package/dist/types/planning.js +1 -0
  142. package/dist/types/providers.d.ts +39 -0
  143. package/dist/types/providers.js +479 -0
  144. package/dist/types/response.d.ts +55 -0
  145. package/dist/types/response.js +1 -0
  146. package/dist/types/security.d.ts +87 -0
  147. package/dist/types/security.js +1 -0
  148. package/dist/utils/ids.d.ts +1 -0
  149. package/dist/utils/ids.js +4 -0
  150. package/dist/utils/logger.d.ts +7 -0
  151. package/dist/utils/logger.js +17 -0
  152. package/dist/utils/tokenizer.d.ts +6 -0
  153. package/dist/utils/tokenizer.js +38 -0
  154. package/dist/workflow/chains.d.ts +53 -0
  155. package/dist/workflow/chains.js +117 -0
  156. package/dist/workflow/domain.d.ts +22 -0
  157. package/dist/workflow/domain.js +96 -0
  158. package/examples/agent.ts +69 -0
  159. package/examples/basic.ts +37 -0
  160. package/examples/bullmq-worker.ts +36 -0
  161. package/examples/classifier-calibration.ts +7 -0
  162. package/examples/domain-workflows.ts +38 -0
  163. package/examples/feature-flags.ts +65 -0
  164. package/examples/minimal.ts +45 -0
  165. package/examples/ocr-pdf-ingestion.ts +42 -0
  166. package/examples/optimizer.ts +43 -0
  167. package/examples/otel-express.ts +47 -0
  168. package/examples/otel-node-http.ts +46 -0
  169. package/examples/persisted-vector-store.ts +42 -0
  170. package/examples/security.ts +69 -0
  171. package/package.json +165 -0
@@ -0,0 +1,97 @@
1
+ export const PROVIDER_CONFORMANCE_FIXTURES = {
2
+ openai: baseFixtures('gpt-5.4-mini'),
3
+ anthropic: baseFixtures('claude-sonnet-4'),
4
+ google: baseFixtures('gemini-2.5-flash'),
5
+ groq: baseFixtures('groq/openai/gpt-oss-20b'),
6
+ mistral: baseFixtures('mistral/mistral-small-2603'),
7
+ cohere: baseFixtures('cohere/command-r7b-12-2024'),
8
+ ollama: baseFixtures('ollama/llama3.2'),
9
+ openrouter: baseFixtures('openrouter/openai/gpt-5.4-mini'),
10
+ };
11
+ export async function runProviderConformance(providerName, provider, options = {}) {
12
+ const fixtures = options.fixtures || PROVIDER_CONFORMANCE_FIXTURES[providerName] || baseFixtures(options.model || 'auto');
13
+ const results = [];
14
+ const healthOk = options.testHealth ? await provider.healthCheck() : undefined;
15
+ for (const fixture of fixtures) {
16
+ const request = {
17
+ ...fixture.request,
18
+ model: options.model || fixture.request.model,
19
+ };
20
+ try {
21
+ const response = await provider.complete(request);
22
+ const completeOk = await fixture.validate(response);
23
+ let streamOk;
24
+ if (options.testStream) {
25
+ streamOk = await validateStream(provider.stream(request));
26
+ }
27
+ results.push({
28
+ providerName,
29
+ model: request.model,
30
+ caseName: fixture.name,
31
+ completeOk,
32
+ streamOk,
33
+ healthOk,
34
+ });
35
+ }
36
+ catch (error) {
37
+ results.push({
38
+ providerName,
39
+ model: request.model,
40
+ caseName: fixture.name,
41
+ completeOk: false,
42
+ healthOk,
43
+ error: error instanceof Error ? error.message : String(error),
44
+ });
45
+ }
46
+ }
47
+ return results;
48
+ }
49
+ function baseFixtures(model) {
50
+ return [
51
+ {
52
+ name: 'basic-text-completion',
53
+ request: {
54
+ model,
55
+ messages: [{ role: 'user', content: 'Reply with the word ok.' }],
56
+ temperature: 0,
57
+ maxTokens: 16,
58
+ },
59
+ validate: (response) => response.role === 'assistant' && typeof response.content === 'string',
60
+ },
61
+ {
62
+ name: 'json-response-shape',
63
+ request: {
64
+ model,
65
+ messages: [{ role: 'user', content: 'Return JSON with {"ok": true}.' }],
66
+ temperature: 0,
67
+ maxTokens: 64,
68
+ responseFormat: {
69
+ type: 'json_schema',
70
+ schema: {
71
+ type: 'object',
72
+ required: ['ok'],
73
+ properties: { ok: { type: 'boolean' } },
74
+ },
75
+ },
76
+ },
77
+ validate: (response) => {
78
+ try {
79
+ const parsed = JSON.parse(response.content);
80
+ return typeof parsed.ok === 'boolean';
81
+ }
82
+ catch {
83
+ return false;
84
+ }
85
+ },
86
+ },
87
+ ];
88
+ }
89
+ async function validateStream(stream) {
90
+ for await (const chunk of stream) {
91
+ if (chunk.type === 'text' || chunk.type === 'done' || chunk.type === 'tool_call')
92
+ return true;
93
+ if (chunk.type === 'error')
94
+ return false;
95
+ }
96
+ return false;
97
+ }
@@ -0,0 +1,34 @@
1
+ import type { Message, ToolDefinition } from './messages.js';
2
+ import type { NexusResponse } from './response.js';
3
+ export interface AgentStep {
4
+ iteration: number;
5
+ type: 'model' | 'tool' | 'final';
6
+ message: string;
7
+ toolName?: string;
8
+ toolArgs?: Record<string, unknown>;
9
+ toolResult?: unknown;
10
+ }
11
+ export interface AgentConfig {
12
+ model: string;
13
+ goal: string;
14
+ systemPrompt?: string;
15
+ tools?: ToolDefinition[];
16
+ maxIterations?: number;
17
+ temperature?: number;
18
+ maxTokens?: number;
19
+ metadata?: Record<string, unknown>;
20
+ onStep?: (step: AgentStep) => void | Promise<void>;
21
+ onToolCall?: (step: AgentStep) => void | Promise<void>;
22
+ }
23
+ export interface AgentResult {
24
+ content: string;
25
+ steps: AgentStep[];
26
+ iterations: number;
27
+ response: NexusResponse;
28
+ messages: Message[];
29
+ }
30
+ export interface ToolExecutionResult {
31
+ ok: boolean;
32
+ result?: unknown;
33
+ error?: string;
34
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,171 @@
1
+ import type { SecurityConfig, SecurityLevel } from './security.js';
2
+ import type { TokenOptimizerConfig } from './optimizer.js';
3
+ import type { Modality, ModelCapabilities, ModelStatus, RoutingModelPreference } from './providers.js';
4
+ import type { PipelineConfig } from '../pipeline/types.js';
5
+ import type { CacheAdapter } from '../cache/adapters.js';
6
+ import type { SemanticCacheOptions } from '../cache/semantic-cache.js';
7
+ import type { MetricsConfig } from '../ops/metrics.js';
8
+ import type { HealthConfig } from '../ops/health.js';
9
+ export interface OpenAIProviderConfig {
10
+ apiKey: string;
11
+ baseUrl?: string;
12
+ organization?: string;
13
+ }
14
+ export interface AnthropicProviderConfig {
15
+ apiKey: string;
16
+ baseUrl?: string;
17
+ }
18
+ export interface GoogleProviderConfig {
19
+ apiKey: string;
20
+ baseUrl?: string;
21
+ projectId?: string;
22
+ }
23
+ export interface OllamaProviderConfig {
24
+ baseUrl?: string;
25
+ timeout?: number;
26
+ }
27
+ export interface GroqProviderConfig {
28
+ apiKey: string;
29
+ baseUrl?: string;
30
+ }
31
+ export interface MistralProviderConfig {
32
+ apiKey: string;
33
+ baseUrl?: string;
34
+ }
35
+ export interface CohereProviderConfig {
36
+ apiKey: string;
37
+ baseUrl?: string;
38
+ }
39
+ export interface OpenRouterProviderConfig {
40
+ apiKey: string;
41
+ baseUrl?: string;
42
+ appName?: string;
43
+ siteUrl?: string;
44
+ }
45
+ export interface CustomProviderConfig {
46
+ name: string;
47
+ baseUrl: string;
48
+ apiKey?: string;
49
+ format: 'openai' | 'anthropic';
50
+ }
51
+ export interface ProvidersConfig {
52
+ openai?: OpenAIProviderConfig;
53
+ anthropic?: AnthropicProviderConfig;
54
+ google?: GoogleProviderConfig;
55
+ ollama?: OllamaProviderConfig;
56
+ groq?: GroqProviderConfig;
57
+ mistral?: MistralProviderConfig;
58
+ cohere?: CohereProviderConfig;
59
+ openrouter?: OpenRouterProviderConfig;
60
+ custom?: CustomProviderConfig[];
61
+ }
62
+ export interface ModelRegistryConfig {
63
+ aliases?: Record<string, string>;
64
+ registry?: Record<string, ModelCapabilities>;
65
+ includeDefaults?: boolean;
66
+ }
67
+ export interface CacheConfig {
68
+ enabled?: boolean;
69
+ ttlSeconds?: number;
70
+ maxEntries?: number;
71
+ strategy?: 'exact' | 'semantic' | 'hybrid';
72
+ adapter?: CacheAdapter;
73
+ semantic?: SemanticCacheOptions;
74
+ }
75
+ export interface ResponseFormatConfig {
76
+ type: 'text' | 'json' | 'json_schema';
77
+ schema?: Record<string, unknown>;
78
+ }
79
+ export interface RateLimitConfig {
80
+ enabled?: boolean;
81
+ maxRequests: number;
82
+ windowMs: number;
83
+ key?: 'userId' | 'model' | 'global';
84
+ }
85
+ export interface AuditLogConfig {
86
+ enabled?: boolean;
87
+ includeInput?: boolean;
88
+ includeOutput?: boolean;
89
+ sink?: (event: AuditLogEvent) => void | Promise<void>;
90
+ }
91
+ export interface AuditLogEvent {
92
+ type: 'request' | 'response' | 'blocked';
93
+ requestId?: string;
94
+ userId?: string;
95
+ model?: string;
96
+ provider?: string;
97
+ timestamp: string;
98
+ metadata?: Record<string, unknown>;
99
+ }
100
+ export interface RetryConfig {
101
+ enabled?: boolean;
102
+ maxRetries?: number;
103
+ baseDelayMs?: number;
104
+ maxDelayMs?: number;
105
+ backoff?: 'fixed' | 'exponential';
106
+ retryOn?: Array<'timeout' | 'rate-limit' | 'server-error' | 'network' | 'unknown'>;
107
+ }
108
+ export interface CostBudgetConfig {
109
+ enabled?: boolean;
110
+ maxEstimatedCost?: number;
111
+ estimatedOutputTokens?: number;
112
+ onExceeded?: 'error' | 'warn';
113
+ }
114
+ export type RoutingStrategy = 'cost' | 'speed' | 'quality' | 'privacy';
115
+ export interface RoutingRule {
116
+ when: Record<string, unknown> | '*';
117
+ use: string;
118
+ }
119
+ export interface FallbackConfig {
120
+ onError?: string[];
121
+ onTimeout?: {
122
+ after: number;
123
+ fallbackTo: string;
124
+ };
125
+ onRateLimit?: {
126
+ retryAfter: number;
127
+ maxRetries: number;
128
+ thenFallbackTo: string;
129
+ };
130
+ }
131
+ export interface RoutingConfig {
132
+ mode: 'auto' | 'rules' | 'hybrid' | 'direct';
133
+ strategy?: RoutingStrategy;
134
+ candidateModels?: string[];
135
+ allowModels?: string[];
136
+ denyModels?: string[];
137
+ requiredCapabilities?: {
138
+ modalities?: Modality[];
139
+ streaming?: boolean;
140
+ toolCalling?: boolean;
141
+ structuredOutputs?: boolean;
142
+ jsonMode?: boolean;
143
+ reasoning?: boolean;
144
+ minContextTokens?: number;
145
+ maxInputCostPer1k?: number;
146
+ maxOutputCostPer1k?: number;
147
+ statuses?: ModelStatus[];
148
+ };
149
+ modelPreferences?: Partial<Record<RoutingStrategy, RoutingModelPreference[]>>;
150
+ rules?: RoutingRule[];
151
+ fallback?: FallbackConfig;
152
+ }
153
+ export interface NexusAIConfig {
154
+ providers: ProvidersConfig;
155
+ routing?: RoutingConfig;
156
+ security?: SecurityLevel | SecurityConfig;
157
+ tokenOptimizer?: TokenOptimizerConfig;
158
+ models?: ModelRegistryConfig;
159
+ cache?: CacheConfig;
160
+ rateLimit?: RateLimitConfig;
161
+ auditLog?: AuditLogConfig;
162
+ responseFormat?: ResponseFormatConfig;
163
+ retry?: RetryConfig;
164
+ costBudget?: CostBudgetConfig;
165
+ pipeline?: PipelineConfig;
166
+ metrics?: MetricsConfig;
167
+ health?: HealthConfig;
168
+ defaultModel?: string;
169
+ timeout?: number;
170
+ debug?: boolean;
171
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,96 @@
1
+ export type MessageRole = 'system' | 'user' | 'assistant' | 'tool';
2
+ export interface TextContent {
3
+ type: 'text';
4
+ text: string;
5
+ }
6
+ export interface ImageContent {
7
+ type: 'image';
8
+ source: {
9
+ path: string;
10
+ } | {
11
+ url: string;
12
+ } | {
13
+ buffer: Buffer;
14
+ mimeType?: string;
15
+ } | {
16
+ base64: string;
17
+ mimeType?: string;
18
+ };
19
+ }
20
+ export interface AudioContent {
21
+ type: 'audio';
22
+ source: {
23
+ path: string;
24
+ } | {
25
+ buffer: Buffer;
26
+ format?: string;
27
+ } | {
28
+ stream: NodeJS.ReadableStream;
29
+ format?: string;
30
+ sampleRate?: number;
31
+ } | {
32
+ transcript: string;
33
+ };
34
+ }
35
+ export interface VideoContent {
36
+ type: 'video';
37
+ source: {
38
+ path: string;
39
+ frameExtractionMode?: 'keyframes' | 'uniform' | 'all';
40
+ maxFrames?: number;
41
+ includeAudio?: boolean;
42
+ };
43
+ }
44
+ export type ContentPart = TextContent | ImageContent | AudioContent | VideoContent;
45
+ export interface ToolDefinition {
46
+ name: string;
47
+ description: string;
48
+ parameters: Record<string, unknown>;
49
+ execute?: (args: Record<string, unknown>) => Promise<unknown>;
50
+ }
51
+ export interface ToolCallResult {
52
+ toolCallId: string;
53
+ name: string;
54
+ result: unknown;
55
+ }
56
+ export interface Message {
57
+ role: MessageRole;
58
+ content: string | ContentPart[];
59
+ name?: string;
60
+ toolCallId?: string;
61
+ toolCalls?: Array<{
62
+ id: string;
63
+ type: 'function';
64
+ function: {
65
+ name: string;
66
+ arguments: string;
67
+ };
68
+ }>;
69
+ }
70
+ export interface CompletionRequest {
71
+ model: string;
72
+ messages: Message[];
73
+ tools?: ToolDefinition[];
74
+ temperature?: number;
75
+ maxTokens?: number;
76
+ topP?: number;
77
+ logitBias?: Record<string, number>;
78
+ timeoutMs?: number;
79
+ maxEstimatedCost?: number;
80
+ estimatedOutputTokens?: number;
81
+ retry?: {
82
+ enabled?: boolean;
83
+ maxRetries?: number;
84
+ baseDelayMs?: number;
85
+ maxDelayMs?: number;
86
+ backoff?: 'fixed' | 'exponential';
87
+ };
88
+ responseFormat?: {
89
+ type: 'json' | 'json_schema';
90
+ schema?: Record<string, unknown>;
91
+ };
92
+ stop?: string | string[];
93
+ stream?: boolean;
94
+ userId?: string;
95
+ metadata?: Record<string, unknown>;
96
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,30 @@
1
+ export type BudgetExceededAction = 'error' | 'truncate' | 'densify' | 'allow';
2
+ export interface DensificationConfig {
3
+ enabled?: boolean;
4
+ preserveCodeBlocks?: boolean;
5
+ preserveMarkdown?: boolean;
6
+ techniques?: Array<'whitespace-cleanup' | 'phrase-compression' | 'list-compaction'>;
7
+ }
8
+ export interface BudgetConfig {
9
+ enabled?: boolean;
10
+ maxInputTokens?: number;
11
+ warnAt?: number;
12
+ onExceeded?: BudgetExceededAction;
13
+ }
14
+ export interface TokenOptimizerConfig {
15
+ enabled?: boolean;
16
+ densification?: DensificationConfig;
17
+ budget?: BudgetConfig;
18
+ }
19
+ export interface TokenUsageSnapshot {
20
+ beforeTokens: number;
21
+ afterTokens: number;
22
+ savedTokens: number;
23
+ savedPercent: number;
24
+ }
25
+ export interface OptimizationResult<T> {
26
+ value: T;
27
+ usage: TokenUsageSnapshot;
28
+ techniquesApplied: string[];
29
+ warnings: string[];
30
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,27 @@
1
+ import type { RouteDecision } from '../router/types.js';
2
+ import type { TokenUsageSnapshot } from './optimizer.js';
3
+ import type { SecurityFinding } from './security.js';
4
+ export interface CostEstimate {
5
+ model: string;
6
+ inputTokens: number;
7
+ outputTokens: number;
8
+ inputCost: number;
9
+ outputCost: number;
10
+ totalCost: number;
11
+ formatted: string;
12
+ }
13
+ export interface NexusPlan {
14
+ requestModel: string;
15
+ providerName: string;
16
+ model: string;
17
+ route: RouteDecision;
18
+ tokenUsage: TokenUsageSnapshot;
19
+ estimatedCost: CostEstimate;
20
+ maxContextTokens?: number;
21
+ fitsContext: boolean;
22
+ cacheEligible: boolean;
23
+ wouldBlock: boolean;
24
+ securityFindings: SecurityFinding[];
25
+ warnings: string[];
26
+ guardrailsApplied: string[];
27
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,39 @@
1
+ export type Modality = 'text' | 'vision' | 'audio' | 'video' | 'image' | 'pdf';
2
+ export type ModelStatus = 'stable' | 'preview' | 'latest' | 'deprecated';
3
+ export type ModelEndpoint = 'chat' | 'responses' | 'messages' | 'generateContent' | 'realtime';
4
+ export type ReasoningEffort = 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
5
+ export type RoutingModelPreference = string | {
6
+ model: string;
7
+ weight?: number;
8
+ };
9
+ export interface ModelCapabilities {
10
+ provider?: string;
11
+ family?: string;
12
+ modalities: Modality[];
13
+ streaming: boolean;
14
+ toolCalling: boolean;
15
+ structuredOutputs?: boolean;
16
+ jsonMode?: boolean;
17
+ reasoning?: boolean | {
18
+ efforts?: ReasoningEffort[];
19
+ };
20
+ maxContextTokens: number;
21
+ maxOutputTokens?: number;
22
+ costPer1kInput: number;
23
+ costPer1kOutput: number;
24
+ qualityScore?: number;
25
+ speedScore?: number;
26
+ release?: string;
27
+ knowledgeCutoff?: string;
28
+ status?: ModelStatus;
29
+ endpoints?: ModelEndpoint[];
30
+ notes?: string;
31
+ }
32
+ export interface ProviderCapabilities {
33
+ name: string;
34
+ isLocal: boolean;
35
+ models: Record<string, ModelCapabilities>;
36
+ }
37
+ export declare const KNOWN_MODELS: Record<string, ModelCapabilities>;
38
+ export declare const MODEL_ALIASES: Record<string, string>;
39
+ export declare function resolveProvider(model: string): string | null;