@x12i/ai-dispatcher 3.1.0 → 3.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 +22 -8
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# @x12i/ai-dispatcher
|
|
2
2
|
|
|
3
|
-
One request shape for OpenRouter, AWS Bedrock, the OpenAI Responses API, and Cloudflare AI. You send the same request shape. The package picks the provider, and `@x12i/ai-profiles
|
|
3
|
+
One request shape for OpenRouter, AWS Bedrock, the OpenAI Responses API, and Cloudflare AI. You send the same request shape. The package picks the provider, and `@x12i/ai-profiles@5.3.0` turns `reasoningEffort` into that provider's wire fields. Callers do not map effort levels onto provider fields or parse provider reasoning channels.
|
|
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` 3.
|
|
7
|
+
The package is `@x12i/ai-dispatcher` 3.2.0. It runs on Node 22 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,21 @@ 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-input@1.1.0`, `@x12i/ai-profiles
|
|
17
|
+
The package depends on `@x12i/ai-input@1.1.0`, `@x12i/ai-profiles@5.3.0`, `@x12i/provider-metadata@^1.2.1`, `@x12i/openrouter-runtime@^2.2.1`, and `@x12i/bedrock-runtime@^2.2.2`. `@x12i/ai-catalogs@1.2.0` comes in through profiles. `gpt-tokenizer` and `ajv` are optional peers of `@x12i/ai-input` and are not installed with the dispatcher. `registerHostIntents` and `resolveAIProfile` are re-exported from this package so a host uses the same `@x12i/ai-profiles` copy the dispatcher resolves with.
|
|
18
|
+
|
|
19
|
+
## AI registry
|
|
20
|
+
|
|
21
|
+
`@x12i/ai-profiles@5.3.0` loads `GET /v1/datasets/profiles` and `GET /v1/datasets/catalog` from `https://ai-registry.app.x12i.com`. A successful response is used as-is and cached briefly. If the registry is unreachable, the JSON shipped in the npm package is used. Do not set `AI_REGISTRY_SOURCE`. Override the origin only when you proxy it: `AI_REGISTRY_URL`.
|
|
22
|
+
|
|
23
|
+
`resolveReasoning` still reads the bundled reasoning catalog. Profile names such as `cheap/default` resolve through the live registry:
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { resolveAIProfile } from "@x12i/ai-dispatcher";
|
|
27
|
+
|
|
28
|
+
const profile = await resolveAIProfile("cheap/default", { catalogLane: "text" });
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Leave `AUTHIX_TOKEN` unset for the published model. Set it only if a host is pinning a profile or role to a catalog id for an Authix subject. Omit `context` / `AI_REGISTRY_CONTEXT` for the default bucket. A stored pin replaces that profile. A key with no pin stays on the published model. If the pin service cannot be reached, the published model is used and a `CUSTOMIZATION_UNAVAILABLE` warning is attached. Resolve does not fail. The token is sent only to `/v1/customization`. This package does not write pins, does not depend on `@x12i/ai-registry-client` or `@x12i/agent-roles`, and does not log the token. A `role` stamp on the request is caller metadata.
|
|
18
32
|
|
|
19
33
|
## One request
|
|
20
34
|
|
|
@@ -56,7 +70,7 @@ Use model ids that belong to the selected catalog target. An OpenRouter id is no
|
|
|
56
70
|
| `openai` | `gpt-5.4` | `reasoning.effort: "low"` on the Responses body |
|
|
57
71
|
| `cloudflare` | `openai/gpt-5.4` | `reasoning.effort: "low"` on the Cloudflare Responses body |
|
|
58
72
|
|
|
59
|
-
Representative catalog results for `@x12i/ai-profiles@5.
|
|
73
|
+
Representative catalog results for `@x12i/ai-profiles@5.3.0`:
|
|
60
74
|
|
|
61
75
|
- OpenRouter `~google/gemini-flash-latest` + `max` is `degraded` and sends `reasoning.effort: "high"`.
|
|
62
76
|
- OpenRouter `aion-labs/aion-2.0` is `ignored` with an empty reasoning body. The call still runs.
|
|
@@ -315,7 +329,7 @@ The rest of the response is the runtime shape: `id`, `status` (`completed`, `fai
|
|
|
315
329
|
|
|
316
330
|
Streaming emits `stream.reasoning.delta` for thought text. That text is not copied into `stream.text.delta`, tool-argument deltas, or structured-output text. If a future catalog asks for think-tag stripping, tags are split out of answer deltas before those deltas are yielded.
|
|
317
331
|
|
|
318
|
-
The dispatcher does not store conversation history. When a directive lists history fields to drop, callers pass those paths to `stripReasoningHistoryFields(message, paths)`. The helper clones the message, deletes only those pointers, and is safe to call twice. Catalog 5.
|
|
332
|
+
The dispatcher does not store conversation history. When a directive lists history fields to drop, callers pass those paths to `stripReasoningHistoryFields(message, paths)`. The helper clones the message, deletes only those pointers, and is safe to call twice. Catalog 5.3.0 paths are empty, so a real directive deletes nothing.
|
|
319
333
|
|
|
320
334
|
## Streaming
|
|
321
335
|
|
|
@@ -511,18 +525,18 @@ OpenAI HTTP failures such as `401` return a failed response from `run()`. `FUNCT
|
|
|
511
525
|
|
|
512
526
|
## Logging
|
|
513
527
|
|
|
514
|
-
Pass `logger` on the dispatcher. `run` and `executeStreamingChat` emit `ai-dispatcher.request.started` at info. `compile` emits `ai-dispatcher.request.compiled` at debug. The record can include `provider`, `entrypoint`, `streaming`, `requestedModel`, `effectiveModel`, `requestId`, `outcome`, and `bypassed`. It does not include credentials, prompts, reasoning text, or raw bodies.
|
|
528
|
+
Pass `logger` on the dispatcher. `run` and `executeStreamingChat` emit `ai-dispatcher.request.started` at info. `compile` emits `ai-dispatcher.request.compiled` at debug. The record can include `provider`, `entrypoint`, `streaming`, `requestedModel`, `effectiveModel`, `requestId`, `outcome`, and `bypassed`. It does not include credentials, `AUTHIX_TOKEN`, prompts, reasoning text, or raw bodies.
|
|
515
529
|
|
|
516
530
|
## Limitations
|
|
517
531
|
|
|
518
|
-
- Catalog 5.
|
|
532
|
+
- Catalog 5.3.0 does not currently emit a prompt prefix, a replacement model, think-tag stripping, history deletions, or a reasoning token budget. Those paths exist for the directive type and are covered by synthetic tests.
|
|
519
533
|
- Prompt caching is a dispatcher profile, not an `@x12i/ai-profiles` field. It writes one breakpoint after `system` or `instructions`. It does not place extra breakpoints on tools or on a prefix that changes in the middle of the call.
|
|
520
534
|
- Provenance notes about output-token headroom are not enforced, because the resolver does not return them as fields.
|
|
521
535
|
- OpenRouter server tools, `apiMode: "chat"`, and `rawOpenRouterOverrides` stay on OpenRouter. Bedrock, direct OpenAI, and Cloudflare reject the server-tool fields and `rawOpenRouterOverrides` keys other than `metadata`. Cloudflare accepts `apiMode: "chat"` as the chat-completions endpoint.
|
|
522
536
|
- Direct OpenAI and Cloudflare streaming do not run the function-tool loop. MCP tools are not attached to `executeStreamingChat` on any provider. Cloudflare `/ai/run` does not stream.
|
|
523
537
|
- OpenRouter advisor, subagent, and fusion cannot call MCP sessions registered on the dispatcher.
|
|
524
538
|
- Bedrock `run()` returns a failed response for `UNSUPPORTED_CONTENT`. `compile()` throws that error.
|
|
525
|
-
- Live provider calls are not part of the package test suite. Tests mock HTTP and the Bedrock client and use the real 5.
|
|
539
|
+
- Live provider calls are not part of the package test suite. Tests mock HTTP and the Bedrock client and use the real 5.3.0 reasoning catalog for contract cases.
|
|
526
540
|
- Input preparation does not claim release gate 9. Automatic TOON and `shared-v1` stay on compact outline or the original string until the caller passes a matching approval and a tokenizer. `codec: "toon"` sends TOON as a caller choice. `codec: "json"` and `mode: "raw"` keep JSON.
|
|
527
541
|
- `gpt-tokenizer` and `ajv` are not installed. A `gpt:*` tokenizer is loaded only when that call requests it.
|
|
528
542
|
- The dispatcher does not read `AI_INPUT_*` or a `.env` file for input preparation.
|
package/dist/index.cjs
CHANGED
|
@@ -42,6 +42,7 @@ __export(index_exports, {
|
|
|
42
42
|
normalizeMetadata: () => import_openrouter_runtime4.normalizeMetadata,
|
|
43
43
|
providerNotImplemented: () => providerNotImplemented,
|
|
44
44
|
registerHostIntents: () => import_ai_profiles2.registerHostIntents,
|
|
45
|
+
resolveAIProfile: () => import_ai_profiles2.resolveAIProfile,
|
|
45
46
|
resolveProvider: () => resolveProvider,
|
|
46
47
|
stripReasoningHistoryFields: () => stripReasoningHistoryFields
|
|
47
48
|
});
|
|
@@ -4046,6 +4047,7 @@ function stripReasoningHistoryFields(message, paths) {
|
|
|
4046
4047
|
normalizeMetadata,
|
|
4047
4048
|
providerNotImplemented,
|
|
4048
4049
|
registerHostIntents,
|
|
4050
|
+
resolveAIProfile,
|
|
4049
4051
|
resolveProvider,
|
|
4050
4052
|
stripReasoningHistoryFields
|
|
4051
4053
|
});
|