@x12i/ai-dispatcher 3.0.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/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ReasoningEffort, ReasoningOutcome } from '@x12i/ai-profiles';
2
- export { ReasoningEffort, ReasoningOutcome, registerHostIntents } from '@x12i/ai-profiles';
2
+ export { ReasoningEffort, ReasoningOutcome, registerHostIntents, resolveAIProfile } from '@x12i/ai-profiles';
3
3
  import * as _x12i_openrouter_runtime from '@x12i/openrouter-runtime';
4
4
  import { RuntimeToolExecutor, RuntimeLogger, RuntimeRequest, RuntimeResponse, RuntimeUsage, RuntimeStreamEvent, CompiledOpenRouterRequest, OpenRouterRuntimeOptions } from '@x12i/openrouter-runtime';
5
5
  export { CompiledOpenRouterRequest, METADATA_NORMALIZATION_MAP, NormalizedMetadataKey, OpenRouterRuntimeOptions, RuntimeDefaults, RuntimeLogger, RuntimeMessage, RuntimeRequest, RuntimeResponse, RuntimeServerToolsPolicy, RuntimeStreamEvent, canonicalMetadataKey, decodeProviderMetadata, normalizeMetadata } from '@x12i/openrouter-runtime';
@@ -214,8 +214,9 @@ interface AiDispatcherRequest extends RuntimeRequest {
214
214
  */
215
215
  role?: RoleStamp;
216
216
  /**
217
- * Provider-neutral reasoning intent. The bundled catalog chooses the wire action.
218
- * An explicit provider control on the same request wins and the catalog is not called.
217
+ * Provider-neutral reasoning intent. `@x12i/ai-profiles` chooses the wire action
218
+ * from its reasoning catalog. An explicit provider control on the same request
219
+ * wins and the catalog is not called.
219
220
  */
220
221
  reasoningEffort?: ReasoningEffort;
221
222
  /**
@@ -289,6 +290,9 @@ interface AiDispatcherOptions {
289
290
  * The dispatcher trims on every call and adds a `METADATA_RECORD_TRIMMED` warning when it drops keys.
290
291
  * The default keeps `agentId`, `orgId`, `stepId`, `skillId`, `role`, `roleLayer`,
291
292
  * `roleDigest`, `profileChoice`, `recordId`, and `objectType`.
293
+ * A custom list replaces that default. Include `session_id`, `xtivix.caller`, and `xtivix.gate` when you pass one.
294
+ * With the default list, those short values stay until every longer unlisted value,
295
+ * including `xtivix.execution`, has been dropped.
292
296
  */
293
297
  metadataPriority?: readonly string[];
294
298
  logger?: RuntimeLogger;
@@ -380,10 +384,16 @@ interface AiDispatcher {
380
384
  readonly provider: AiProviderId;
381
385
  }
382
386
 
383
- /** Identity keys stay when a record has to be trimmed. Earlier entries are kept ahead of later ones. */
387
+ /**
388
+ * Identity keys stay when a record has to be trimmed. Earlier entries are kept ahead of later ones.
389
+ * `session_id`, `xtivix.caller`, and `xtivix.gate` stay off this list. A custom `metadataPriority` should include them.
390
+ */
384
391
  declare const DEFAULT_METADATA_PRIORITY: readonly ["agentId", "orgId", "stepId", "skillId", "role", "roleLayer", "roleDigest", "profileChoice", "recordId", "objectType"];
385
392
  declare function createAiDispatcher(options?: AiDispatcherOptions): AiDispatcher;
386
393
 
394
+ /** Stored as `xtivix.gate` on every call this package packs. */
395
+ declare const AI_DISPATCHER_GATE = "ai-dispatcher";
396
+
387
397
  declare class AiDispatcherError extends Error {
388
398
  readonly code: string;
389
399
  readonly details?: unknown | undefined;
@@ -399,4 +409,4 @@ declare function stripReasoningHistoryFields<T>(message: T, paths: readonly stri
399
409
 
400
410
  declare function resolveProvider(requestProvider: AiProviderId | undefined, defaultProvider: AiProviderId): ImplementedAiProvider;
401
411
 
402
- export { type AiDispatcher, AiDispatcherError, type AiDispatcherOptions, type AiDispatcherRequest, type AiDispatcherResponse, type AiDispatcherUsage, type AiInputCodec, type AiInputCodecChoice, type AiInputFraming, type AiInputMode, type AiInputReadableFormat, type AiInputSettings, type AiInputSharing, type AiInputTokenizer, type AiProviderAdapter, type AiProviderId, type CacheMode, type CacheOutcome, type CachePolicy, type CacheResolution, type CacheTtl, type CloudflareBackoff, type CloudflareCallContext, type CloudflareEndpoint, type CloudflareEndpointChoice, type CloudflareGatewayControls, type CloudflareRequestOptions, type CloudflareRunOptions, type CloudflareRuntimeOptions, type CloudflareWebhookFormat, type CompiledAiRequest, type CompiledCloudflareRequest, type CompiledOpenAiRequest, DEFAULT_METADATA_PRIORITY, type DispatcherMcpOptions, type DispatcherMcpServer, type DispatcherMcpTool, IMPLEMENTED_AI_PROVIDERS, type ImplementedAiProvider, type InputResolution, type OpenAiRuntimeOptions, type ReasoningResolution, type RoleStamp, createAiDispatcher, isImplementedAiProvider, providerNotImplemented, resolveProvider, stripReasoningHistoryFields };
412
+ export { AI_DISPATCHER_GATE, type AiDispatcher, AiDispatcherError, type AiDispatcherOptions, type AiDispatcherRequest, type AiDispatcherResponse, type AiDispatcherUsage, type AiInputCodec, type AiInputCodecChoice, type AiInputFraming, type AiInputMode, type AiInputReadableFormat, type AiInputSettings, type AiInputSharing, type AiInputTokenizer, type AiProviderAdapter, type AiProviderId, type CacheMode, type CacheOutcome, type CachePolicy, type CacheResolution, type CacheTtl, type CloudflareBackoff, type CloudflareCallContext, type CloudflareEndpoint, type CloudflareEndpointChoice, type CloudflareGatewayControls, type CloudflareRequestOptions, type CloudflareRunOptions, type CloudflareRuntimeOptions, type CloudflareWebhookFormat, type CompiledAiRequest, type CompiledCloudflareRequest, type CompiledOpenAiRequest, DEFAULT_METADATA_PRIORITY, type DispatcherMcpOptions, type DispatcherMcpServer, type DispatcherMcpTool, IMPLEMENTED_AI_PROVIDERS, type ImplementedAiProvider, type InputResolution, type OpenAiRuntimeOptions, type ReasoningResolution, type RoleStamp, createAiDispatcher, isImplementedAiProvider, providerNotImplemented, resolveProvider, stripReasoningHistoryFields };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ReasoningEffort, ReasoningOutcome } from '@x12i/ai-profiles';
2
- export { ReasoningEffort, ReasoningOutcome, registerHostIntents } from '@x12i/ai-profiles';
2
+ export { ReasoningEffort, ReasoningOutcome, registerHostIntents, resolveAIProfile } from '@x12i/ai-profiles';
3
3
  import * as _x12i_openrouter_runtime from '@x12i/openrouter-runtime';
4
4
  import { RuntimeToolExecutor, RuntimeLogger, RuntimeRequest, RuntimeResponse, RuntimeUsage, RuntimeStreamEvent, CompiledOpenRouterRequest, OpenRouterRuntimeOptions } from '@x12i/openrouter-runtime';
5
5
  export { CompiledOpenRouterRequest, METADATA_NORMALIZATION_MAP, NormalizedMetadataKey, OpenRouterRuntimeOptions, RuntimeDefaults, RuntimeLogger, RuntimeMessage, RuntimeRequest, RuntimeResponse, RuntimeServerToolsPolicy, RuntimeStreamEvent, canonicalMetadataKey, decodeProviderMetadata, normalizeMetadata } from '@x12i/openrouter-runtime';
@@ -214,8 +214,9 @@ interface AiDispatcherRequest extends RuntimeRequest {
214
214
  */
215
215
  role?: RoleStamp;
216
216
  /**
217
- * Provider-neutral reasoning intent. The bundled catalog chooses the wire action.
218
- * An explicit provider control on the same request wins and the catalog is not called.
217
+ * Provider-neutral reasoning intent. `@x12i/ai-profiles` chooses the wire action
218
+ * from its reasoning catalog. An explicit provider control on the same request
219
+ * wins and the catalog is not called.
219
220
  */
220
221
  reasoningEffort?: ReasoningEffort;
221
222
  /**
@@ -289,6 +290,9 @@ interface AiDispatcherOptions {
289
290
  * The dispatcher trims on every call and adds a `METADATA_RECORD_TRIMMED` warning when it drops keys.
290
291
  * The default keeps `agentId`, `orgId`, `stepId`, `skillId`, `role`, `roleLayer`,
291
292
  * `roleDigest`, `profileChoice`, `recordId`, and `objectType`.
293
+ * A custom list replaces that default. Include `session_id`, `xtivix.caller`, and `xtivix.gate` when you pass one.
294
+ * With the default list, those short values stay until every longer unlisted value,
295
+ * including `xtivix.execution`, has been dropped.
292
296
  */
293
297
  metadataPriority?: readonly string[];
294
298
  logger?: RuntimeLogger;
@@ -380,10 +384,16 @@ interface AiDispatcher {
380
384
  readonly provider: AiProviderId;
381
385
  }
382
386
 
383
- /** Identity keys stay when a record has to be trimmed. Earlier entries are kept ahead of later ones. */
387
+ /**
388
+ * Identity keys stay when a record has to be trimmed. Earlier entries are kept ahead of later ones.
389
+ * `session_id`, `xtivix.caller`, and `xtivix.gate` stay off this list. A custom `metadataPriority` should include them.
390
+ */
384
391
  declare const DEFAULT_METADATA_PRIORITY: readonly ["agentId", "orgId", "stepId", "skillId", "role", "roleLayer", "roleDigest", "profileChoice", "recordId", "objectType"];
385
392
  declare function createAiDispatcher(options?: AiDispatcherOptions): AiDispatcher;
386
393
 
394
+ /** Stored as `xtivix.gate` on every call this package packs. */
395
+ declare const AI_DISPATCHER_GATE = "ai-dispatcher";
396
+
387
397
  declare class AiDispatcherError extends Error {
388
398
  readonly code: string;
389
399
  readonly details?: unknown | undefined;
@@ -399,4 +409,4 @@ declare function stripReasoningHistoryFields<T>(message: T, paths: readonly stri
399
409
 
400
410
  declare function resolveProvider(requestProvider: AiProviderId | undefined, defaultProvider: AiProviderId): ImplementedAiProvider;
401
411
 
402
- export { type AiDispatcher, AiDispatcherError, type AiDispatcherOptions, type AiDispatcherRequest, type AiDispatcherResponse, type AiDispatcherUsage, type AiInputCodec, type AiInputCodecChoice, type AiInputFraming, type AiInputMode, type AiInputReadableFormat, type AiInputSettings, type AiInputSharing, type AiInputTokenizer, type AiProviderAdapter, type AiProviderId, type CacheMode, type CacheOutcome, type CachePolicy, type CacheResolution, type CacheTtl, type CloudflareBackoff, type CloudflareCallContext, type CloudflareEndpoint, type CloudflareEndpointChoice, type CloudflareGatewayControls, type CloudflareRequestOptions, type CloudflareRunOptions, type CloudflareRuntimeOptions, type CloudflareWebhookFormat, type CompiledAiRequest, type CompiledCloudflareRequest, type CompiledOpenAiRequest, DEFAULT_METADATA_PRIORITY, type DispatcherMcpOptions, type DispatcherMcpServer, type DispatcherMcpTool, IMPLEMENTED_AI_PROVIDERS, type ImplementedAiProvider, type InputResolution, type OpenAiRuntimeOptions, type ReasoningResolution, type RoleStamp, createAiDispatcher, isImplementedAiProvider, providerNotImplemented, resolveProvider, stripReasoningHistoryFields };
412
+ export { AI_DISPATCHER_GATE, type AiDispatcher, AiDispatcherError, type AiDispatcherOptions, type AiDispatcherRequest, type AiDispatcherResponse, type AiDispatcherUsage, type AiInputCodec, type AiInputCodecChoice, type AiInputFraming, type AiInputMode, type AiInputReadableFormat, type AiInputSettings, type AiInputSharing, type AiInputTokenizer, type AiProviderAdapter, type AiProviderId, type CacheMode, type CacheOutcome, type CachePolicy, type CacheResolution, type CacheTtl, type CloudflareBackoff, type CloudflareCallContext, type CloudflareEndpoint, type CloudflareEndpointChoice, type CloudflareGatewayControls, type CloudflareRequestOptions, type CloudflareRunOptions, type CloudflareRuntimeOptions, type CloudflareWebhookFormat, type CompiledAiRequest, type CompiledCloudflareRequest, type CompiledOpenAiRequest, DEFAULT_METADATA_PRIORITY, type DispatcherMcpOptions, type DispatcherMcpServer, type DispatcherMcpTool, IMPLEMENTED_AI_PROVIDERS, type ImplementedAiProvider, type InputResolution, type OpenAiRuntimeOptions, type ReasoningResolution, type RoleStamp, createAiDispatcher, isImplementedAiProvider, providerNotImplemented, resolveProvider, stripReasoningHistoryFields };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/index.ts
2
- import { registerHostIntents } from "@x12i/ai-profiles";
2
+ import { registerHostIntents, resolveAIProfile } from "@x12i/ai-profiles";
3
3
  import {
4
4
  decodeProviderMetadata,
5
5
  METADATA_NORMALIZATION_MAP,
@@ -2619,6 +2619,7 @@ function prepareDispatchRequest(params) {
2619
2619
  applyRoleStamp(cloned);
2620
2620
  applyDispatchIdentity(cloned);
2621
2621
  absorbOverrideMetadata(cloned);
2622
+ applyDispatchGate(cloned);
2622
2623
  const provider = params.provider;
2623
2624
  const reasoningEffort = cloned.reasoningEffort;
2624
2625
  const bedrockControls = cloned.bedrockControls;
@@ -2971,6 +2972,12 @@ function applyDispatchIdentity(request) {
2971
2972
  for (const key of Object.keys(identity)) delete rest[key];
2972
2973
  request.metadata = { ...identity, ...rest };
2973
2974
  }
2975
+ var AI_DISPATCHER_GATE = "ai-dispatcher";
2976
+ function applyDispatchGate(request) {
2977
+ const rest = { ...request.metadata ?? {} };
2978
+ delete rest["xtivix.gate"];
2979
+ request.metadata = { "xtivix.gate": AI_DISPATCHER_GATE, ...rest };
2980
+ }
2974
2981
  function cloneRequest(request) {
2975
2982
  const functionTools = request.functionTools?.map((tool) => ({ ...tool }));
2976
2983
  const cloned = JSON.parse(JSON.stringify(request));
@@ -4000,6 +4007,7 @@ function stripReasoningHistoryFields(message, paths) {
4000
4007
  return clone;
4001
4008
  }
4002
4009
  export {
4010
+ AI_DISPATCHER_GATE,
4003
4011
  AiDispatcherError,
4004
4012
  DEFAULT_METADATA_PRIORITY,
4005
4013
  IMPLEMENTED_AI_PROVIDERS,
@@ -4011,6 +4019,7 @@ export {
4011
4019
  normalizeMetadata,
4012
4020
  providerNotImplemented,
4013
4021
  registerHostIntents,
4022
+ resolveAIProfile,
4014
4023
  resolveProvider,
4015
4024
  stripReasoningHistoryFields
4016
4025
  };