@ailib-official/ai-protocol 0.8.4

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 (194) hide show
  1. package/LICENSE +6 -0
  2. package/README.md +415 -0
  3. package/dist/index.json +8 -0
  4. package/dist/v1/models/ai21.json +140 -0
  5. package/dist/v1/models/baichuan.json +138 -0
  6. package/dist/v1/models/cerebras.json +147 -0
  7. package/dist/v1/models/claude.json +114 -0
  8. package/dist/v1/models/cohere.json +235 -0
  9. package/dist/v1/models/deepinfra.json +43 -0
  10. package/dist/v1/models/deepseek-chat.json +55 -0
  11. package/dist/v1/models/doubao.json +197 -0
  12. package/dist/v1/models/ernie.json +223 -0
  13. package/dist/v1/models/fireworks.json +222 -0
  14. package/dist/v1/models/gemini.json +58 -0
  15. package/dist/v1/models/gpt.json +166 -0
  16. package/dist/v1/models/grok.json +138 -0
  17. package/dist/v1/models/huggingface.json +183 -0
  18. package/dist/v1/models/hunyuan.json +255 -0
  19. package/dist/v1/models/jina.json +139 -0
  20. package/dist/v1/models/lepton.json +188 -0
  21. package/dist/v1/models/llama.json +143 -0
  22. package/dist/v1/models/minimax.json +194 -0
  23. package/dist/v1/models/mistral.json +177 -0
  24. package/dist/v1/models/moonshot.json +144 -0
  25. package/dist/v1/models/nvidia.json +212 -0
  26. package/dist/v1/models/palmyra.json +103 -0
  27. package/dist/v1/models/perplexity.json +143 -0
  28. package/dist/v1/models/qwen.json +49 -0
  29. package/dist/v1/models/replicate.json +206 -0
  30. package/dist/v1/models/sensenova.json +144 -0
  31. package/dist/v1/models/siliconflow.json +44 -0
  32. package/dist/v1/models/spark.json +173 -0
  33. package/dist/v1/models/stable-diffusion.json +161 -0
  34. package/dist/v1/models/tiangong.json +169 -0
  35. package/dist/v1/models/together.json +43 -0
  36. package/dist/v1/models/yi.json +199 -0
  37. package/dist/v1/models/zhipu.json +250 -0
  38. package/dist/v1/providers/ai21.json +215 -0
  39. package/dist/v1/providers/anthropic.json +253 -0
  40. package/dist/v1/providers/anyscale.json +115 -0
  41. package/dist/v1/providers/azure.json +188 -0
  42. package/dist/v1/providers/baichuan.json +205 -0
  43. package/dist/v1/providers/baidu.json +205 -0
  44. package/dist/v1/providers/cerebras.json +216 -0
  45. package/dist/v1/providers/cohere.json +209 -0
  46. package/dist/v1/providers/deepinfra.json +196 -0
  47. package/dist/v1/providers/deepseek.json +221 -0
  48. package/dist/v1/providers/doubao.json +209 -0
  49. package/dist/v1/providers/fireworks.json +227 -0
  50. package/dist/v1/providers/gemini.json +279 -0
  51. package/dist/v1/providers/groq.json +218 -0
  52. package/dist/v1/providers/huggingface.json +181 -0
  53. package/dist/v1/providers/hunyuan.json +198 -0
  54. package/dist/v1/providers/jina.json +202 -0
  55. package/dist/v1/providers/lepton.json +221 -0
  56. package/dist/v1/providers/minimax.json +209 -0
  57. package/dist/v1/providers/mistral.json +214 -0
  58. package/dist/v1/providers/moonshot.json +214 -0
  59. package/dist/v1/providers/nvidia.json +213 -0
  60. package/dist/v1/providers/openai.json +267 -0
  61. package/dist/v1/providers/openrouter.json +220 -0
  62. package/dist/v1/providers/perplexity.json +172 -0
  63. package/dist/v1/providers/qwen.json +231 -0
  64. package/dist/v1/providers/replicate.json +192 -0
  65. package/dist/v1/providers/sensenova.json +185 -0
  66. package/dist/v1/providers/siliconflow.json +197 -0
  67. package/dist/v1/providers/spark.json +204 -0
  68. package/dist/v1/providers/stability.json +221 -0
  69. package/dist/v1/providers/tiangong.json +207 -0
  70. package/dist/v1/providers/together.json +196 -0
  71. package/dist/v1/providers/writer.json +253 -0
  72. package/dist/v1/providers/xai.json +238 -0
  73. package/dist/v1/providers/yi.json +205 -0
  74. package/dist/v1/providers/zhipu.json +208 -0
  75. package/dist/v1/spec.json +783 -0
  76. package/dist/v2/providers/anthropic.json +372 -0
  77. package/dist/v2/providers/cohere.json +109 -0
  78. package/dist/v2/providers/deepseek.json +272 -0
  79. package/dist/v2/providers/doubao.json +260 -0
  80. package/dist/v2/providers/google.json +388 -0
  81. package/dist/v2/providers/jina.json +71 -0
  82. package/dist/v2/providers/moonshot.json +284 -0
  83. package/dist/v2/providers/openai.json +419 -0
  84. package/dist/v2/providers/qwen.json +274 -0
  85. package/dist/v2/providers/zhipu.json +257 -0
  86. package/dist/v2-alpha/providers/anthropic.json +182 -0
  87. package/dist/v2-alpha/providers/gemini.json +187 -0
  88. package/dist/v2-alpha/providers/openai.json +215 -0
  89. package/dist/v2-alpha/spec.json +644 -0
  90. package/package.json +61 -0
  91. package/schemas/spec.json +186 -0
  92. package/schemas/v1.json +1116 -0
  93. package/schemas/v2/availability.json +66 -0
  94. package/schemas/v2/capabilities.json +182 -0
  95. package/schemas/v2/capability-profile.json +174 -0
  96. package/schemas/v2/computer-use.json +222 -0
  97. package/schemas/v2/context-policy.json +148 -0
  98. package/schemas/v2/endpoint.json +2 -0
  99. package/schemas/v2/error-codes.yaml +225 -0
  100. package/schemas/v2/errors.json +250 -0
  101. package/schemas/v2/execution-metadata.json +59 -0
  102. package/schemas/v2/mcp.json +225 -0
  103. package/schemas/v2/message-roles.json +10 -0
  104. package/schemas/v2/multimodal.json +297 -0
  105. package/schemas/v2/pricing.json +14 -0
  106. package/schemas/v2/provider-contract.json +317 -0
  107. package/schemas/v2/provider.json +203 -0
  108. package/schemas/v2/regions.json +14 -0
  109. package/v1/models/ai21.yaml +97 -0
  110. package/v1/models/baichuan.yaml +95 -0
  111. package/v1/models/cerebras.yaml +99 -0
  112. package/v1/models/claude.yaml +59 -0
  113. package/v1/models/cohere.yaml +165 -0
  114. package/v1/models/deepinfra.yaml +29 -0
  115. package/v1/models/deepseek-chat.yaml +32 -0
  116. package/v1/models/doubao.yaml +129 -0
  117. package/v1/models/ernie.yaml +146 -0
  118. package/v1/models/fireworks.yaml +145 -0
  119. package/v1/models/gemini.yaml +32 -0
  120. package/v1/models/gpt.yaml +90 -0
  121. package/v1/models/grok.yaml +74 -0
  122. package/v1/models/huggingface.yaml +110 -0
  123. package/v1/models/hunyuan.yaml +164 -0
  124. package/v1/models/jina.yaml +98 -0
  125. package/v1/models/lepton.yaml +130 -0
  126. package/v1/models/llama.yaml +91 -0
  127. package/v1/models/minimax.yaml +132 -0
  128. package/v1/models/mistral.yaml +100 -0
  129. package/v1/models/moonshot.yaml +97 -0
  130. package/v1/models/nvidia.yaml +118 -0
  131. package/v1/models/palmyra.yaml +59 -0
  132. package/v1/models/perplexity.yaml +97 -0
  133. package/v1/models/qwen.yaml +27 -0
  134. package/v1/models/replicate.yaml +136 -0
  135. package/v1/models/sensenova.yaml +97 -0
  136. package/v1/models/siliconflow.yaml +29 -0
  137. package/v1/models/spark.yaml +114 -0
  138. package/v1/models/stable-diffusion.yaml +113 -0
  139. package/v1/models/tiangong.yaml +114 -0
  140. package/v1/models/together.yaml +29 -0
  141. package/v1/models/yi.yaml +132 -0
  142. package/v1/models/zhipu.yaml +163 -0
  143. package/v1/providers/ai21.yaml +176 -0
  144. package/v1/providers/anthropic.yaml +209 -0
  145. package/v1/providers/anyscale.yaml +106 -0
  146. package/v1/providers/azure.yaml +155 -0
  147. package/v1/providers/baichuan.yaml +168 -0
  148. package/v1/providers/baidu.yaml +173 -0
  149. package/v1/providers/cerebras.yaml +178 -0
  150. package/v1/providers/cohere.yaml +175 -0
  151. package/v1/providers/deepinfra.yaml +156 -0
  152. package/v1/providers/deepseek.yaml +189 -0
  153. package/v1/providers/doubao.yaml +172 -0
  154. package/v1/providers/fireworks.yaml +187 -0
  155. package/v1/providers/gemini.yaml +229 -0
  156. package/v1/providers/groq.yaml +181 -0
  157. package/v1/providers/huggingface.yaml +157 -0
  158. package/v1/providers/hunyuan.yaml +162 -0
  159. package/v1/providers/jina.yaml +171 -0
  160. package/v1/providers/lepton.yaml +183 -0
  161. package/v1/providers/minimax.yaml +172 -0
  162. package/v1/providers/mistral.yaml +186 -0
  163. package/v1/providers/moonshot.yaml +176 -0
  164. package/v1/providers/nvidia.yaml +172 -0
  165. package/v1/providers/openai.yaml +224 -0
  166. package/v1/providers/openrouter.yaml +181 -0
  167. package/v1/providers/perplexity.yaml +144 -0
  168. package/v1/providers/qwen.yaml +192 -0
  169. package/v1/providers/replicate.yaml +159 -0
  170. package/v1/providers/sensenova.yaml +153 -0
  171. package/v1/providers/siliconflow.yaml +156 -0
  172. package/v1/providers/spark.yaml +167 -0
  173. package/v1/providers/stability.yaml +185 -0
  174. package/v1/providers/tiangong.yaml +170 -0
  175. package/v1/providers/together.yaml +156 -0
  176. package/v1/providers/writer.yaml +212 -0
  177. package/v1/providers/xai.yaml +206 -0
  178. package/v1/providers/yi.yaml +168 -0
  179. package/v1/providers/zhipu.yaml +171 -0
  180. package/v1/spec.yaml +637 -0
  181. package/v2/providers/anthropic.yaml +244 -0
  182. package/v2/providers/cohere.yaml +75 -0
  183. package/v2/providers/deepseek.yaml +176 -0
  184. package/v2/providers/doubao.yaml +169 -0
  185. package/v2/providers/google.yaml +245 -0
  186. package/v2/providers/jina.yaml +55 -0
  187. package/v2/providers/moonshot.yaml +186 -0
  188. package/v2/providers/openai.yaml +266 -0
  189. package/v2/providers/qwen.yaml +174 -0
  190. package/v2/providers/zhipu.yaml +176 -0
  191. package/v2-alpha/providers/anthropic.yaml +134 -0
  192. package/v2-alpha/providers/gemini.yaml +144 -0
  193. package/v2-alpha/providers/openai.yaml +154 -0
  194. package/v2-alpha/spec.yaml +512 -0
package/LICENSE ADDED
@@ -0,0 +1,6 @@
1
+ Licensed under either of
2
+
3
+ * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
4
+ * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
5
+
6
+ at your option.
package/README.md ADDED
@@ -0,0 +1,415 @@
1
+ # AI-Protocol: Data-State Rulebook
2
+
3
+ **AI-Protocol is a provider-agnostic specification for all AI models, standardizing how we interact with intelligence, regardless of modality** (text, vision, audio, video). We decouple the "data-state rulebook" from the "language-state runtime" to provide unified infrastructure for the AI ecosystem.
4
+
5
+ **We complement standards like [MCP](https://modelcontextprotocol.io) by providing a declarative runtime for raw API normalization.** While MCP focuses on high-level protocols for tool calling and context management, AI-Protocol focuses on standardizing and normalizing low-level API calls, enabling runtimes to uniformly handle APIs from different providers.
6
+
7
+ ## 🎯 Project Vision
8
+
9
+ - **Data-State Rulebook**: Focuses on defining standardized interfaces and behavioral norms for AI models
10
+ - **Language-State Runtime**: Focuses on implementing efficient, scalable AI model runtimes (like ai-lib-rust)
11
+ - **Ecosystem Decoupling**: Protocol specifications are separated from implementations, supporting unified ecosystems across multiple languages and frameworks
12
+ - **Provider-Agnostic**: Unifies APIs from different AI providers, enabling true cross-provider interoperability
13
+ - **Cross-Modality Support**: Standardizes interactions across text, vision, audio, video, and other modalities
14
+
15
+ ## 📁 Project Structure
16
+
17
+ ```
18
+ ai-protocol/
19
+ ├── schemas/ # JSON Schema validation specifications
20
+ │ ├── v1.json # v1.x provider/model configuration Schema
21
+ │ ├── spec.json # Specification file (spec.yaml) Schema
22
+ │ └── v2/ # V2 protocol schemas
23
+ │ ├── provider.json # V2 provider manifest schema (three-ring model)
24
+ │ ├── capabilities.json # Capability declaration schema
25
+ │ ├── errors.json # Standard error code definitions (13 codes)
26
+ │ ├── endpoint.json # Endpoint configuration schema
27
+ │ ├── availability.json # Availability schema
28
+ │ ├── regions.json # Region configuration schema
29
+ │ ├── mcp.json # MCP integration schema
30
+ │ ├── computer-use.json # Computer Use abstraction schema
31
+ │ ├── multimodal.json # Extended multimodal capabilities schema
32
+ │ ├── provider-contract.json # Provider contract schema
33
+ │ ├── capability-profile.json # Experimental I/O/S phase metadata schema
34
+ │ └── context-policy.json # Context management policy schema
35
+ ├── v1/ # v1.x stable version specification
36
+ │ ├── spec.yaml # Basic specifications: standard parameters, event enumeration
37
+ │ ├── providers/ # Provider configurations (split by vendor for easy PR)
38
+ │ │ ├── openai.yaml # OpenAI compatible interface
39
+ │ │ ├── anthropic.yaml # Anthropic Claude interface
40
+ │ │ ├── gemini.yaml # Google Gemini interface
41
+ │ │ └── ... # 30+ providers (see full list below)
42
+ │ └── models/ # Model instance registry
43
+ │ ├── gpt.yaml # GPT series models
44
+ │ ├── claude.yaml # Claude series models
45
+ │ └── ... # More models
46
+ ├── v2/ # v2 formal provider manifests
47
+ │ └── providers/ # 6 V2 provider manifests (OpenAI, Anthropic, Google, etc.)
48
+ ├── v2-alpha/ # v2-alpha experimental version
49
+ │ └── spec.yaml # Experimental operator definitions
50
+ ├── tests/ # Cross-runtime compliance test suite
51
+ │ └── compliance/ # YAML-defined test cases for Rust/Python consistency
52
+ ├── examples/ # Configuration examples
53
+ ├── docs/ # Documentation
54
+ │ ├── V2_ARCHITECTURE.md # V2 three-layer pyramid architecture design
55
+ │ ├── SPEC.md # Provider manifest specification
56
+ │ └── ... # More documentation
57
+ ├── research/ # Research documents (official API excerpts and verification)
58
+ │ └── providers/ # Provider-specific official documentation research
59
+ └── scripts/ # Maintenance scripts
60
+ ```
61
+
62
+ ## 🔧 Core Concepts
63
+
64
+ ### 1. Operator-based Design
65
+
66
+ AI-Protocol standardizes AI model behavior through the concept of **operators**:
67
+
68
+ - **Parameter Operators**: Standardized parameter mapping (`temperature`, `max_tokens`, `stream`, etc.)
69
+ - **Event Operators**: Standardized streaming events (`PartialContentDelta`, `ToolCallStarted`, `StreamError`, etc.)
70
+ - **Capability Operators**: Standardized capability declarations (`chat`, `vision`, `tools`, `streaming`, `multimodal`, etc.)
71
+ - **Error Handling Operators**: Standardized error classification, rate limiting, and retry strategies (`error_classification`, `retry_policy`, `rate_limit_headers`)
72
+
73
+ ### 2. Version Isolation
74
+
75
+ - **v1.x**: Production environment stable version, supporting current mainstream AI models
76
+ - **v2-alpha**: Experimental version, exploring multimodal streams, real-time instructions, and other cutting-edge features
77
+ - **Schema Constraints**: Every configuration file is strictly validated through JSON Schema
78
+
79
+ ### 3. Modular Maintenance
80
+
81
+ - **Provider Independence**: Each AI provider's configuration is maintained independently, facilitating community contributions
82
+ - **Model Registration**: Model instances are registered as configuration files referencing provider definitions
83
+ - **PR Friendly**: Modifying a single provider won't affect other configurations
84
+
85
+ ## 🚀 Quick Start
86
+
87
+ ### 1. Provider Configuration Example
88
+
89
+ ```yaml
90
+ # v1/providers/anthropic.yaml
91
+ $schema: "https://raw.githubusercontent.com/ailib-official/ai-protocol/main/schemas/v1.json"
92
+
93
+ id: anthropic
94
+ protocol_version: "1.5"
95
+
96
+ streaming:
97
+ decoder:
98
+ format: "anthropic_sse"
99
+ strategy: "anthropic_event_stream"
100
+
101
+ event_map:
102
+ - match: "$.type == 'content_block_delta' && $.delta.type == 'text_delta'"
103
+ emit: "PartialContentDelta"
104
+ extract:
105
+ content: "$.delta.text"
106
+ ```
107
+
108
+ > **Schema URL Best Practice**: You can pin the `$schema` URL to a specific release tag for version stability:
109
+ > - `https://raw.githubusercontent.com/ailib-official/ai-protocol/v0.2.1/schemas/v1.json` (pinned to release)
110
+ > - `https://raw.githubusercontent.com/ailib-official/ai-protocol/main/schemas/v1.json` (latest on main)
111
+
112
+ ### 2. Error Handling and Rate Limiting Example
113
+
114
+ ```yaml
115
+ # v1/providers/openai.yaml (excerpt)
116
+ error_classification:
117
+ by_http_status:
118
+ "400": "invalid_request"
119
+ "401": "authentication"
120
+ "429": "rate_limited" # Could be rate limit or quota exhausted
121
+ "500": "server_error"
122
+
123
+ rate_limit_headers:
124
+ requests_limit: "x-ratelimit-limit-requests"
125
+ requests_remaining: "x-ratelimit-remaining-requests"
126
+ retry_after: null # OpenAI doesn't use standard Retry-After
127
+
128
+ retry_policy:
129
+ strategy: "exponential_backoff"
130
+ min_delay_ms: 1000
131
+ jitter: "full"
132
+ retry_on_http_status: [429, 500]
133
+ notes:
134
+ - "429 may be rate limit or quota exhausted; runtimes should inspect error messages"
135
+ ```
136
+
137
+ ### 3. Model Registration Example
138
+
139
+ ```yaml
140
+ # v1/models/claude.yaml
141
+ $schema: "https://raw.githubusercontent.com/ailib-official/ai-protocol/main/schemas/v1.json"
142
+
143
+ models:
144
+ claude-3-5-sonnet:
145
+ provider: anthropic
146
+ model_id: "claude-3-5-sonnet-20241022"
147
+ context_window: 200000
148
+ capabilities: [chat, vision, tools, streaming, agentic, reasoning]
149
+ pricing:
150
+ input_per_token: 0.000003
151
+ output_per_token: 0.000015
152
+ ```
153
+
154
+ ### 4. Runtime Integration
155
+
156
+ ```rust
157
+ // Dynamic loading example in ai-lib-rust
158
+ use ai_lib_rust::protocol::ProtocolLoader;
159
+
160
+ // By default, the loader prioritizes the `dist/` directory (JSON) for production efficiency,
161
+ // falling back to `v1/` (YAML) for development convenience if JSON is missing.
162
+ let loader = ProtocolLoader::new();
163
+ let provider = loader.load_provider("anthropic").await?;
164
+ let model = loader.load_model("anthropic/claude-3-5-sonnet").await?;
165
+ ```
166
+
167
+ ## 📋 Validation and Testing
168
+
169
+ ```bash
170
+ # Install dependencies
171
+ npm install
172
+
173
+ # Run JSON Schema validation (all)
174
+ npm run validate
175
+
176
+ # Run specific validations
177
+ npm run validate:providers # Validate provider configs only
178
+ npm run validate:models # Validate model configs only
179
+ npm run validate:examples # Validate examples only
180
+ npm run validate:specs # Validate spec files only
181
+ npm run validate:schemas # Validate JSON schema syntax only
182
+
183
+ # Execution governance automation
184
+ npm run drift:check # Detect P0 provider/fixture/case drift
185
+ npm run gate:manifest-consumption # Cross-repo latest-manifest consumption gate
186
+ npm run gate:compliance-matrix # Cross-repo full compliance matrix gate
187
+ npm run gate:fullchain # One-shot governance fullchain gate
188
+ npm run gate:fullchain:with-rollback # Fullchain + fail-fast rollback drill
189
+ npm run gate:fullchain:with-rollback:required-drill # Fullchain + required drill
190
+ npm run gate:fullchain:with-rollback:both-drill # Fullchain + both required/report-only drill
191
+ npm run release:gate # Evaluate release gate status
192
+ node scripts/drift-detect.js --report-only # Advisory drift report (non-blocking)
193
+ node scripts/release-gate.js --report-only # Advisory release gate report (non-blocking)
194
+ ```
195
+
196
+ The canonical validation script is `scripts/validate.js`, which uses AJV v8 with JSON Schema 2020-12 and ajv-formats.
197
+ Execution governance scripts:
198
+ - `scripts/drift-detect.js`: verifies P0 provider readiness coverage across v2 manifests, compliance fixtures, and loading cases
199
+ - `scripts/gate-manifest-consumption.js`: runs protocol + Rust/Python/TS latest-manifest consumption checks and writes gate report (`reports/manifest-gates/`)
200
+ - `scripts/gate-compliance-matrix.js`: runs protocol + Rust/Python/TS compliance matrix checks and writes gate report (`reports/compliance-gates/`)
201
+ - `scripts/gate-fullchain.js`: orchestrates drift + manifest + compliance + release gates in one run (`reports/fullchain-gates/`)
202
+ - `scripts/rehearse-compliance-rollback.js`: deterministic negative rehearsal proving required block vs report-only pass (`reports/rollback-rehearsals/`)
203
+ - rollback drill mode can be selected via `--mode=report-only|required|both` (default `both`), while fullchain integration defaults to `report-only` unless explicitly switched
204
+ - `scripts/release-gate.js`: computes pass/blocked decision from rollout metrics input (default: `scripts/release-gate-input.example.json`)
205
+ - `report-only` mode (`--report-only`) is available for drift/release gates to support advisory CI rollout without immediate hard blocking
206
+ Optional runtime model verification (document-first; no API keys required for the registry): see [docs/FACT_CHECKING_MODELS.md](docs/FACT_CHECKING_MODELS.md).
207
+
208
+ ### Wave-3 Gate Promotion Policy (PT-035)
209
+
210
+ Required/report-only governance boundaries:
211
+
212
+ - **PR / manual review path**: run report-only gates for trend visibility and low-friction iteration.
213
+ - **`main` push path**: run required fullchain gate (`node scripts/gate-fullchain.js`) as blocking baseline.
214
+ - **Release readiness baseline**: keep both required and report-only evidence artifacts for every promotion cycle.
215
+
216
+ Rollback policy:
217
+
218
+ - If a production-critical gate starts failing due to transient infra or dependency outages, temporarily downgrade to report-only while preserving evidence artifacts.
219
+ - Downgrade decisions must include explicit closure target and recovery command path (`npm run gate:fullchain`).
220
+ - Return to required mode immediately after recovery evidence is recorded.
221
+
222
+ ## 📦 Build & Distribution
223
+
224
+ AI-Protocol is distributed as pre-compiled JSON files to ensure runtime efficiency and zero-parsing overhead.
225
+
226
+ ```bash
227
+ # Validate first, then build JSON artifacts
228
+ npm run validate
229
+ npm run build
230
+ ```
231
+
232
+ Build: run `npm run validate` first. This command then:
233
+ 1. Cleans the `dist/` directory to remove stale files from previous builds.
234
+ 2. Converts all YAML under `v1/`, `v2/`, and `v2-alpha/` into JSON in `dist/`.
235
+ 3. Generates a `dist/index.json` manifest index with version information.
236
+
237
+ Runtimes (like `ai-lib-rust`) should consume the `dist/` directory directly.
238
+
239
+ ### CI/CD Pipeline
240
+
241
+ The GitHub Actions workflow (`validate.yml`) automatically:
242
+ - Validates all configurations using `npm ci` + `npm run validate`
243
+ - Builds JSON artifacts using `npm run build`
244
+ - Uploads the `dist/` folder as a build artifact
245
+ - Runs additional yamllint checks for YAML style (non-blocking)
246
+ - `governance-report.yml` runs drift/release gates in report-only mode and archives JSON evidence artifacts
247
+
248
+ See [docs/CI_VALIDATION_EXPLAINED.md](docs/CI_VALIDATION_EXPLAINED.md) for detailed CI documentation.
249
+
250
+ ## 🛣️ Roadmap
251
+
252
+ ### v1.x (Current Stable)
253
+ - ✅ **30+ AI providers** supported across global and China regions
254
+ - ✅ Standardized parameters and event normalization
255
+ - ✅ Tool calling and streaming response support
256
+ - ✅ JSON Schema constraints
257
+ - ✅ Error handling and classification standardization (`error_classification`, 13 standard error classes)
258
+ - ✅ Rate limiting and retry policy standardization (`rate_limit_headers`, `retry_policy`)
259
+ - ✅ API family declarations (`api_families`, `endpoints`) to avoid request/response model confusion
260
+ - ✅ Termination reason normalization (`termination_reasons`) unified across providers
261
+
262
+ #### Supported Providers
263
+
264
+ **Global Providers:**
265
+ - OpenAI, Anthropic, Google Gemini, Groq, Mistral, Cohere, Perplexity
266
+ - Together AI, DeepInfra, OpenRouter, Azure OpenAI, NVIDIA API Catalog (NVIDIA Build)
267
+ - Fireworks AI, Replicate, AI21 Labs, Cerebras, Lepton AI
268
+
269
+ **China Region Providers:**
270
+ - Qwen (Alibaba), DeepSeek, Zhipu GLM
271
+ - Doubao (ByteDance), Baidu ERNIE, iFlytek Spark
272
+ - Tencent Hunyuan, SenseNova, Tiangong
273
+ - Moonshot/Kimi, MiniMax, Baichuan, Yi
274
+ - SiliconFlow
275
+
276
+ ### v2 (In Progress)
277
+ - 🔄 **V2 Three-Layer Pyramid Architecture** (L1 Core / L2 Extensions / L3 Environment)
278
+ - 🔄 **Unified Error Code System** — standardized error codes across all providers
279
+ - 🔄 **Capability Declaration Mechanism** — structured `required`/`optional` capabilities
280
+ - 🔄 **Feature Flag Mechanism** — load only what you need
281
+ - 🔄 **STT / TTS / Rerank** — speech-to-text, text-to-speech, document reranking (OpenAI, Cohere, Jina)
282
+ - 🔄 **Compliance Test Suite** — machine-verified cross-runtime consistency
283
+
284
+ ### v2-alpha (Experimental)
285
+ - 🔄 Multimodal stream interleaving (`FrameInterleave` operator)
286
+ - 🔄 Real-time instructions (`StateSync` operator)
287
+ - 🔄 Schema-less mapping
288
+ - 🔄 Advanced tool accumulation patterns
289
+
290
+ ### v2.x (Future Plans)
291
+ - 📅 ProviderContract abstraction
292
+ - 📅 CLI toolchain (`init`, `validate`, `convert`, `check-compat`)
293
+ - 📅 WASM support for browser/Edge execution
294
+ - 📅 Framework integrations (LangChain, LlamaIndex)
295
+
296
+ ## 🤝 Contribution Guide
297
+
298
+ ### Adding New Providers
299
+
300
+ 1. Create a new file under `v1/providers/` (e.g., `new-provider.yaml`)
301
+ 2. Follow JSON Schema specifications (`schemas/v1.json`)
302
+ 3. Add official documentation research under `research/providers/` (`new-provider.md`) with VERIFIED evidence
303
+ 4. Add corresponding model configurations under `v1/models/`
304
+ 5. Submit PR with test cases and validation results
305
+
306
+ **All configurations are hosted in this repository**, where community contributions follow the same version control and validation process as official configurations.
307
+
308
+ ### Adding New Operators
309
+
310
+ 1. Define new operators in the corresponding version's `spec.yaml`
311
+ 2. Update JSON Schema
312
+ 3. Implement operator logic in runtime
313
+ 4. Add example configurations
314
+
315
+ ## 📄 License
316
+
317
+ This project is licensed under either of
318
+
319
+ - Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
320
+ - MIT License ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
321
+
322
+ at your option.
323
+
324
+ ### Contribution
325
+
326
+ Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.
327
+
328
+ ## 🔗 Related Projects & Runtime Installation
329
+
330
+ AI-Protocol has official runtime implementations in multiple languages:
331
+
332
+ ### Python Runtime (v0.7.1)
333
+
334
+ ```bash
335
+ # Install from PyPI
336
+ pip install ai-lib-python
337
+
338
+ # Or with optional dependencies
339
+ pip install ai-lib-python[all]
340
+ ```
341
+
342
+ ```python
343
+ from ai_lib import Client
344
+
345
+ # Unified API across all providers
346
+ client = Client(provider="openai")
347
+ response = client.chat.completions.create(
348
+ model="gpt-4o",
349
+ messages=[{"role": "user", "content": "Hello!"}]
350
+ )
351
+ ```
352
+
353
+ 📦 **PyPI**: [ai-lib-python](https://pypi.org/project/ai-lib-python/) | 📖 **Docs**: [github.com/ailib-official/ai-lib-python](https://github.com/ailib-official/ai-lib-python)
354
+
355
+ ### Rust Runtime (v0.8.1)
356
+
357
+ ```toml
358
+ # Add to Cargo.toml
359
+ [dependencies]
360
+ ai-lib-rust = "0.8.1"
361
+ ```
362
+
363
+ ```rust
364
+ use ai_lib_rust::Client;
365
+
366
+ // Unified API across all providers
367
+ let client = Client::new("anthropic")?;
368
+ let response = client.chat()
369
+ .model("claude-3-5-sonnet-20241022")
370
+ .message("user", "Hello!")
371
+ .send()
372
+ .await?;
373
+ ```
374
+
375
+ 📦 **Crates.io**: [ai-lib-rust](https://crates.io/crates/ai-lib-rust) | 📖 **Docs**: [github.com/ailib-official/ai-lib-rust](https://github.com/ailib-official/ai-lib-rust)
376
+
377
+ ### ai-protocol-mock (v0.1.3)
378
+
379
+ Unified mock server for testing runtimes without real API calls. Provides manifest-driven HTTP mock (OpenAI/Anthropic formats), STT/TTS/Rerank endpoints, and MCP JSON-RPC mock.
380
+
381
+ ```bash
382
+ # Start mock server
383
+ cd ai-protocol-mock && docker-compose up -d
384
+
385
+ # Use with runtimes
386
+ MOCK_HTTP_URL=http://localhost:4010 pytest tests/ # ai-lib-python
387
+ MOCK_HTTP_URL=http://localhost:4010 cargo test -- --ignored # ai-lib-rust
388
+ ```
389
+
390
+ 📖 **Repo**: [github.com/ailib-official/ai-protocol-mock](https://github.com/ailib-official/ai-protocol-mock)
391
+
392
+ ### Ecosystem Overview
393
+
394
+ ```
395
+ ┌─────────────────────────────────────────────────────────────┐
396
+ │ AI-Protocol │
397
+ │ (Provider-agnostic Specification) │
398
+ ├─────────────────────────────────────────────────────────────┤
399
+ │ schemas/ │ v1/providers/ │ v1/models/ │
400
+ │ JSON Schema │ 30+ Providers │ Model Registry │
401
+ └───────────────┴────────────────┴───────────────────────────┘
402
+
403
+ ┌─────────────┼─────────────┬─────────────┐
404
+ ▼ ▼ ▼ ▼
405
+ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐
406
+ │ ai-lib-rust │ │ai-lib-python │ │ai-protocol- │ │ Your App │
407
+ │ (Rust) │ │ (Python) │ │mock (tests) │ │ (Any) │
408
+ └──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘
409
+ ```
410
+
411
+ > **Note**: AI-Protocol itself already includes configuration registry functionality. Community contributions for new provider configurations and model registrations can be submitted directly via PRs to this repository's `v1/providers/` and `v1/models/` directories, without needing a separate configuration repository.
412
+
413
+ ---
414
+
415
+ **AI-Protocol** abstracts the complexity of AI models into standardized protocols, allowing developers to focus on business logic rather than provider adaptation.
@@ -0,0 +1,8 @@
1
+ {
2
+ "versions": [
3
+ "v1",
4
+ "v2",
5
+ "v2-alpha"
6
+ ],
7
+ "latest": "v2"
8
+ }
@@ -0,0 +1,140 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/ailib-official/ai-protocol/main/schemas/v1.json",
3
+ "protocol_version": "1.1",
4
+ "models": {
5
+ "jamba-1.5-mini": {
6
+ "provider": "ai21",
7
+ "model_id": "jamba-1.5-mini",
8
+ "display_name": "Jamba 1.5 Mini",
9
+ "verification": {
10
+ "status": "unverified",
11
+ "verified_at": "2026-01-29",
12
+ "source": "documentation",
13
+ "notes": "Based on public documentation. Runtime verification recommended."
14
+ },
15
+ "context_window": 256000,
16
+ "capabilities": [
17
+ "chat",
18
+ "tools",
19
+ "streaming"
20
+ ],
21
+ "status": "active",
22
+ "tags": [
23
+ "ai21",
24
+ "jamba",
25
+ "ssm",
26
+ "long_context"
27
+ ],
28
+ "pricing": {
29
+ "input_per_token": 2e-7,
30
+ "output_per_token": 4e-7
31
+ }
32
+ },
33
+ "jamba-1.5-large": {
34
+ "provider": "ai21",
35
+ "model_id": "jamba-1.5-large",
36
+ "display_name": "Jamba 1.5 Large",
37
+ "verification": {
38
+ "status": "unverified",
39
+ "verified_at": "2026-01-29",
40
+ "source": "documentation"
41
+ },
42
+ "context_window": 256000,
43
+ "capabilities": [
44
+ "chat",
45
+ "tools",
46
+ "streaming"
47
+ ],
48
+ "status": "active",
49
+ "tags": [
50
+ "ai21",
51
+ "jamba",
52
+ "ssm",
53
+ "long_context",
54
+ "flagship"
55
+ ],
56
+ "pricing": {
57
+ "input_per_token": 0.000002,
58
+ "output_per_token": 0.000008
59
+ }
60
+ },
61
+ "jamba-instruct": {
62
+ "provider": "ai21",
63
+ "model_id": "jamba-instruct",
64
+ "display_name": "Jamba Instruct",
65
+ "verification": {
66
+ "status": "unverified",
67
+ "verified_at": "2026-01-29",
68
+ "source": "documentation"
69
+ },
70
+ "context_window": 256000,
71
+ "capabilities": [
72
+ "chat",
73
+ "streaming"
74
+ ],
75
+ "status": "active",
76
+ "tags": [
77
+ "ai21",
78
+ "jamba",
79
+ "ssm",
80
+ "instruct"
81
+ ],
82
+ "pricing": {
83
+ "input_per_token": 5e-7,
84
+ "output_per_token": 7e-7
85
+ }
86
+ },
87
+ "j2-ultra": {
88
+ "provider": "ai21",
89
+ "model_id": "j2-ultra",
90
+ "display_name": "Jurassic-2 Ultra",
91
+ "verification": {
92
+ "status": "unverified",
93
+ "verified_at": "2026-01-29",
94
+ "source": "documentation",
95
+ "notes": "Legacy model; Jamba recommended for new projects."
96
+ },
97
+ "context_window": 8192,
98
+ "capabilities": [
99
+ "completion",
100
+ "streaming"
101
+ ],
102
+ "status": "deprecated",
103
+ "tags": [
104
+ "ai21",
105
+ "jurassic",
106
+ "legacy"
107
+ ],
108
+ "pricing": {
109
+ "input_per_token": 0.000015,
110
+ "output_per_token": 0.000015
111
+ }
112
+ },
113
+ "j2-mid": {
114
+ "provider": "ai21",
115
+ "model_id": "j2-mid",
116
+ "display_name": "Jurassic-2 Mid",
117
+ "verification": {
118
+ "status": "unverified",
119
+ "verified_at": "2026-01-29",
120
+ "source": "documentation",
121
+ "notes": "Legacy model; Jamba recommended for new projects."
122
+ },
123
+ "context_window": 8192,
124
+ "capabilities": [
125
+ "completion",
126
+ "streaming"
127
+ ],
128
+ "status": "deprecated",
129
+ "tags": [
130
+ "ai21",
131
+ "jurassic",
132
+ "legacy"
133
+ ],
134
+ "pricing": {
135
+ "input_per_token": 0.00001,
136
+ "output_per_token": 0.00001
137
+ }
138
+ }
139
+ }
140
+ }