@x12i/ai-dispatcher 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/dist/index.cjs +6 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ One request shape for OpenRouter, AWS Bedrock, the OpenAI Responses API, and Clo
|
|
|
4
4
|
|
|
5
5
|
**Implemented providers:** `openrouter`, `bedrock`, `openai`, `cloudflare`. Any other provider throws `PROVIDER_NOT_IMPLEMENTED`.
|
|
6
6
|
|
|
7
|
-
The package is `@x12i/ai-dispatcher` 2.
|
|
7
|
+
The package is `@x12i/ai-dispatcher` 2.2.0. It runs on Node 20 or newer and publishes ESM and CommonJS from the same entry.
|
|
8
8
|
|
|
9
9
|
Connected MCP servers can be passed to `createAiDispatcher`. `run()` and `compile()` expose those tools to the model. `executeStreamingChat` does not. Details are in [MCP tools](#mcp-tools).
|
|
10
10
|
|
|
@@ -14,7 +14,7 @@ Connected MCP servers can be passed to `createAiDispatcher`. `run()` and `compil
|
|
|
14
14
|
npm install @x12i/ai-dispatcher
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
The package depends on `@x12i/ai-profiles@5.0.0`, `@x12i/provider-metadata
|
|
17
|
+
The package depends on `@x12i/ai-profiles@5.0.0`, `@x12i/provider-metadata@^1.2.0`, `@x12i/openrouter-runtime@^2.2.0`, and `@x12i/bedrock-runtime@^2.2.0`.
|
|
18
18
|
|
|
19
19
|
## One request
|
|
20
20
|
|
|
@@ -179,6 +179,8 @@ const record = decodeProviderMetadata(logMetadata);
|
|
|
179
179
|
|
|
180
180
|
Every provider writes that record as `m.0`, `m.1`, and so on: one base64 string, 256 characters per piece, at most 16 pieces. The base64 is the UTF-8 JSON object of the string map, with keys sorted. `decodeProviderMetadata` reads those pieces from OpenRouter body `metadata`, OpenAI Responses `metadata`, Bedrock `requestMetadata`, or Cloudflare body `metadata` and `cf-aig-metadata`. The pieces are the same on every provider. The dispatcher trims on every call. Pass `metadataPriority` (highest priority first) to choose what stays. The default keeps `agentId`, `orgId`, `stepId`, `skillId`, `recordId`, and `objectType`. A trimmed call adds a `METADATA_RECORD_TRIMMED` warning.
|
|
181
181
|
|
|
182
|
+
Repeating vendor fields normalize to one key. Prefer `metadata.api_key_name` over `metadata.openrouter.api_key_name`. `normalizeMetadata` and `decodeProviderMetadata` promote known aliases and keep the vendor key. Grow `METADATA_NORMALIZATION_MAP` as more shared fields appear.
|
|
183
|
+
|
|
182
184
|
OpenRouter also puts `agentId` in `X-Title` and `X-OpenRouter-Title`, ahead of `appAttribution.appName` and `defaultHeaders`. That header is the activity-log App name. `appAttribution.siteUrl` is still `HTTP-Referer` when set. The App header is not a second metadata record.
|
|
183
185
|
|
|
184
186
|
OpenAI compilation order: `instructions` wins, then `system`, then system messages joined with newlines. `input` is sent as written. Otherwise non-system messages are converted, and a string `prompt` is appended as a user item. Tool messages become `function_call_output`. Image parts become `input_image`. A file part with `url` becomes `input_file` `file_url`. A file part with `data` becomes `input_file` `file_data`. `fileName` becomes `filename`. A file part with neither `url` nor `data` throws `UNSUPPORTED_REQUEST_FIELD`.
|
package/dist/index.cjs
CHANGED
|
@@ -23,9 +23,12 @@ __export(index_exports, {
|
|
|
23
23
|
AiDispatcherError: () => AiDispatcherError,
|
|
24
24
|
DEFAULT_METADATA_PRIORITY: () => DEFAULT_METADATA_PRIORITY,
|
|
25
25
|
IMPLEMENTED_AI_PROVIDERS: () => IMPLEMENTED_AI_PROVIDERS,
|
|
26
|
+
METADATA_NORMALIZATION_MAP: () => import_openrouter_runtime4.METADATA_NORMALIZATION_MAP,
|
|
27
|
+
canonicalMetadataKey: () => import_openrouter_runtime4.canonicalMetadataKey,
|
|
26
28
|
createAiDispatcher: () => createAiDispatcher,
|
|
27
29
|
decodeProviderMetadata: () => import_openrouter_runtime4.decodeProviderMetadata,
|
|
28
30
|
isImplementedAiProvider: () => isImplementedAiProvider,
|
|
31
|
+
normalizeMetadata: () => import_openrouter_runtime4.normalizeMetadata,
|
|
29
32
|
providerNotImplemented: () => providerNotImplemented,
|
|
30
33
|
resolveProvider: () => resolveProvider,
|
|
31
34
|
stripReasoningHistoryFields: () => stripReasoningHistoryFields
|
|
@@ -3684,9 +3687,12 @@ function stripReasoningHistoryFields(message, paths) {
|
|
|
3684
3687
|
AiDispatcherError,
|
|
3685
3688
|
DEFAULT_METADATA_PRIORITY,
|
|
3686
3689
|
IMPLEMENTED_AI_PROVIDERS,
|
|
3690
|
+
METADATA_NORMALIZATION_MAP,
|
|
3691
|
+
canonicalMetadataKey,
|
|
3687
3692
|
createAiDispatcher,
|
|
3688
3693
|
decodeProviderMetadata,
|
|
3689
3694
|
isImplementedAiProvider,
|
|
3695
|
+
normalizeMetadata,
|
|
3690
3696
|
providerNotImplemented,
|
|
3691
3697
|
resolveProvider,
|
|
3692
3698
|
stripReasoningHistoryFields
|