ai.matey.types 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 (69) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/adapters.js +16 -0
  3. package/dist/cjs/adapters.js.map +1 -0
  4. package/dist/cjs/bridge.js +32 -0
  5. package/dist/cjs/bridge.js.map +1 -0
  6. package/dist/cjs/errors.js +121 -0
  7. package/dist/cjs/errors.js.map +1 -0
  8. package/dist/cjs/index.js +44 -0
  9. package/dist/cjs/index.js.map +1 -0
  10. package/dist/cjs/ir.js +17 -0
  11. package/dist/cjs/ir.js.map +1 -0
  12. package/dist/cjs/middleware.js +11 -0
  13. package/dist/cjs/middleware.js.map +1 -0
  14. package/dist/cjs/model-runner.js +11 -0
  15. package/dist/cjs/model-runner.js.map +1 -0
  16. package/dist/cjs/model-translation.js +10 -0
  17. package/dist/cjs/model-translation.js.map +1 -0
  18. package/dist/cjs/models.js +11 -0
  19. package/dist/cjs/models.js.map +1 -0
  20. package/dist/cjs/router.js +93 -0
  21. package/dist/cjs/router.js.map +1 -0
  22. package/dist/cjs/streaming.js +28 -0
  23. package/dist/cjs/streaming.js.map +1 -0
  24. package/dist/esm/adapters.js +15 -0
  25. package/dist/esm/adapters.js.map +1 -0
  26. package/dist/esm/bridge.js +29 -0
  27. package/dist/esm/bridge.js.map +1 -0
  28. package/dist/esm/errors.js +118 -0
  29. package/dist/esm/errors.js.map +1 -0
  30. package/dist/esm/index.js +28 -0
  31. package/dist/esm/index.js.map +1 -0
  32. package/dist/esm/ir.js +16 -0
  33. package/dist/esm/ir.js.map +1 -0
  34. package/dist/esm/middleware.js +10 -0
  35. package/dist/esm/middleware.js.map +1 -0
  36. package/dist/esm/model-runner.js +10 -0
  37. package/dist/esm/model-runner.js.map +1 -0
  38. package/dist/esm/model-translation.js +9 -0
  39. package/dist/esm/model-translation.js.map +1 -0
  40. package/dist/esm/models.js +10 -0
  41. package/dist/esm/models.js.map +1 -0
  42. package/dist/esm/router.js +90 -0
  43. package/dist/esm/router.js.map +1 -0
  44. package/dist/esm/streaming.js +25 -0
  45. package/dist/esm/streaming.js.map +1 -0
  46. package/dist/types/adapters.d.ts +377 -0
  47. package/dist/types/adapters.d.ts.map +1 -0
  48. package/dist/types/bridge.d.ts +290 -0
  49. package/dist/types/bridge.d.ts.map +1 -0
  50. package/dist/types/errors.d.ts +380 -0
  51. package/dist/types/errors.d.ts.map +1 -0
  52. package/dist/types/index.d.ts +18 -0
  53. package/dist/types/index.d.ts.map +1 -0
  54. package/dist/types/ir.d.ts +820 -0
  55. package/dist/types/ir.d.ts.map +1 -0
  56. package/dist/types/middleware.d.ts +256 -0
  57. package/dist/types/middleware.d.ts.map +1 -0
  58. package/dist/types/model-runner.d.ts +344 -0
  59. package/dist/types/model-runner.d.ts.map +1 -0
  60. package/dist/types/model-translation.d.ts +76 -0
  61. package/dist/types/model-translation.d.ts.map +1 -0
  62. package/dist/types/models.d.ts +160 -0
  63. package/dist/types/models.d.ts.map +1 -0
  64. package/dist/types/router.d.ts +526 -0
  65. package/dist/types/router.d.ts.map +1 -0
  66. package/dist/types/streaming.d.ts +96 -0
  67. package/dist/types/streaming.d.ts.map +1 -0
  68. package/package.json +64 -0
  69. package/readme.md +84 -0
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Model Translation Types
3
+ *
4
+ * Type definitions for model name translation between AI providers.
5
+ *
6
+ * @module
7
+ */
8
+ /**
9
+ * Model name mapping (source model → target model).
10
+ */
11
+ export type ModelMapping = Record<string, string>;
12
+ /**
13
+ * Translation strategy for Router fallback.
14
+ */
15
+ export type ModelTranslationStrategy = 'exact' | 'pattern' | 'hybrid' | 'none';
16
+ /**
17
+ * Configuration for model translation behavior.
18
+ */
19
+ export interface ModelTranslationConfig {
20
+ /**
21
+ * Translation strategy to use.
22
+ * @default 'hybrid'
23
+ */
24
+ readonly strategy: ModelTranslationStrategy;
25
+ /**
26
+ * Emit warning event when using backend default model.
27
+ * @default true
28
+ */
29
+ readonly warnOnDefault?: boolean;
30
+ /**
31
+ * Throw error if no translation found (instead of returning original).
32
+ * @default false
33
+ */
34
+ readonly strictMode?: boolean;
35
+ }
36
+ /**
37
+ * Options for translateModel function.
38
+ */
39
+ export interface ModelTranslationOptions {
40
+ /**
41
+ * Exact model mappings.
42
+ */
43
+ readonly mapping?: ModelMapping;
44
+ /**
45
+ * Backend default model (used in hybrid strategy).
46
+ */
47
+ readonly defaultModel?: string;
48
+ /**
49
+ * Translation strategy.
50
+ * @default 'exact'
51
+ */
52
+ readonly strategy?: ModelTranslationStrategy;
53
+ /**
54
+ * Throw error if no translation found.
55
+ * @default false
56
+ */
57
+ readonly strictMode?: boolean;
58
+ }
59
+ /**
60
+ * Result of model translation.
61
+ */
62
+ export interface TranslationResult {
63
+ /**
64
+ * Translated model name.
65
+ */
66
+ readonly translated: string;
67
+ /**
68
+ * Source of translation.
69
+ */
70
+ readonly source: 'exact' | 'pattern' | 'default' | 'none';
71
+ /**
72
+ * Whether a translation was applied.
73
+ */
74
+ readonly wasTranslated: boolean;
75
+ }
76
+ //# sourceMappingURL=model-translation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-translation.d.ts","sourceRoot":"","sources":["../../src/model-translation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAElD;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAChC,OAAO,GACP,SAAS,GACT,QAAQ,GACR,MAAM,CAAC;AAEX;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,wBAAwB,CAAC;IAE5C;;;OAGG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;IAEjC;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,YAAY,CAAC;IAEhC;;OAEG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAE/B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,wBAAwB,CAAC;IAE7C;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;IAE1D;;OAEG;IACH,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;CACjC"}
@@ -0,0 +1,160 @@
1
+ /**
2
+ * Model Types
3
+ *
4
+ * Types for representing AI models and model listing functionality.
5
+ * Backend adapters can expose available models through the listModels() method.
6
+ *
7
+ * @module
8
+ */
9
+ /**
10
+ * Represents an AI model available from a provider.
11
+ *
12
+ * This type provides a unified representation of models across different
13
+ * providers, including metadata about capabilities and pricing.
14
+ */
15
+ export interface AIModel {
16
+ /**
17
+ * Unique model identifier (e.g., "gpt-4", "claude-3-opus-20240229").
18
+ * This is the ID used in API requests.
19
+ */
20
+ readonly id: string;
21
+ /**
22
+ * Human-readable model name.
23
+ * May be more descriptive than the ID.
24
+ */
25
+ readonly name: string;
26
+ /**
27
+ * Model description explaining its purpose or characteristics.
28
+ */
29
+ readonly description?: string;
30
+ /**
31
+ * When this model was created (ISO 8601 timestamp).
32
+ */
33
+ readonly created?: string;
34
+ /**
35
+ * Who owns/created this model (e.g., "openai", "anthropic").
36
+ */
37
+ readonly ownedBy?: string;
38
+ /**
39
+ * Model capabilities for filtering and discovery.
40
+ */
41
+ readonly capabilities?: ModelCapabilities;
42
+ /**
43
+ * Provider-specific metadata not covered by standard fields.
44
+ */
45
+ readonly metadata?: Record<string, unknown>;
46
+ }
47
+ /**
48
+ * Capabilities of a specific model.
49
+ *
50
+ * Used for filtering models by feature support and understanding
51
+ * what the model can do.
52
+ */
53
+ export interface ModelCapabilities {
54
+ /**
55
+ * Maximum output tokens the model can generate.
56
+ */
57
+ readonly maxTokens?: number;
58
+ /**
59
+ * Total context window size (input + output).
60
+ */
61
+ readonly contextWindow?: number;
62
+ /**
63
+ * Whether the model supports streaming responses.
64
+ */
65
+ readonly supportsStreaming?: boolean;
66
+ /**
67
+ * Whether the model supports vision/image inputs.
68
+ */
69
+ readonly supportsVision?: boolean;
70
+ /**
71
+ * Whether the model supports function/tool calling.
72
+ */
73
+ readonly supportsTools?: boolean;
74
+ /**
75
+ * Whether the model supports JSON mode for structured outputs.
76
+ */
77
+ readonly supportsJSON?: boolean;
78
+ /**
79
+ * Estimated cost per 1,000 tokens (in USD).
80
+ * Used for cost-based optimization and routing.
81
+ */
82
+ readonly pricing?: {
83
+ readonly input: number;
84
+ readonly output: number;
85
+ };
86
+ /**
87
+ * Estimated latency in milliseconds for typical requests.
88
+ * Used for speed-based optimization.
89
+ */
90
+ readonly latency?: {
91
+ readonly p50?: number;
92
+ readonly p95?: number;
93
+ };
94
+ /**
95
+ * Quality score from 0-100.
96
+ * Higher scores indicate better output quality.
97
+ * Can be user-defined or community-rated.
98
+ */
99
+ readonly qualityScore?: number;
100
+ /**
101
+ * Model family identifier (e.g., "gpt-4", "claude-3", "gemini-1.5").
102
+ * Used for capability inference and similarity matching.
103
+ */
104
+ readonly modelFamily?: string;
105
+ /**
106
+ * Model release date (ISO 8601 format).
107
+ * Used for determining model recency.
108
+ */
109
+ readonly releaseDate?: string;
110
+ }
111
+ /**
112
+ * Options for listing models from a backend.
113
+ */
114
+ export interface ListModelsOptions {
115
+ /**
116
+ * Force refresh from remote source (bypass cache).
117
+ * @default false
118
+ */
119
+ readonly forceRefresh?: boolean;
120
+ /**
121
+ * Filter models by capability requirements.
122
+ * Only models matching ALL specified capabilities will be returned.
123
+ */
124
+ readonly filter?: {
125
+ readonly supportsStreaming?: boolean;
126
+ readonly supportsVision?: boolean;
127
+ readonly supportsTools?: boolean;
128
+ readonly supportsJSON?: boolean;
129
+ };
130
+ }
131
+ /**
132
+ * Result of listing models from a backend.
133
+ *
134
+ * Includes the models plus metadata about where they came from
135
+ * and when they were fetched.
136
+ */
137
+ export interface ListModelsResult {
138
+ /**
139
+ * Available models from this backend.
140
+ */
141
+ readonly models: readonly AIModel[];
142
+ /**
143
+ * Source of the model list.
144
+ * - remote: Fetched from provider API
145
+ * - static: From configuration or hardcoded list
146
+ * - cache: From cached previous fetch
147
+ */
148
+ readonly source: 'remote' | 'static' | 'cache';
149
+ /**
150
+ * Timestamp when this list was fetched (Unix milliseconds).
151
+ * Used for cache invalidation.
152
+ */
153
+ readonly fetchedAt: number;
154
+ /**
155
+ * Whether this list is complete or partial.
156
+ * Partial lists may occur with filters or pagination.
157
+ */
158
+ readonly isComplete: boolean;
159
+ }
160
+ //# sourceMappingURL=models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH;;;;;GAKG;AACH,MAAM,WAAW,OAAO;IACtB;;;OAGG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAE9B;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,iBAAiB,CAAC;IAE1C;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CA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