UNPKG

aiwg

Version:

Deployment tool and support utility for AI context. Copies agents, skills, commands, rules, and behaviors into the paths each AI platform reads (Claude Code, Codex, Copilot, Cursor, Warp, OpenClaw, and 6 more) so one source of truth works across 10 platfo

80 lines 3.61 kB
/** * Dispatch Router — outbound mission dispatch with A2A-first + v1 fallback. * * AIWG exposes `POST /api/v1/sessions/:id/dispatch` as its public mission * intake. The original implementation forwarded to the executor's v1 * `/dispatch` endpoint (`${rest}/dispatch`). Per #1252, AIWG should now * try the A2A path first (`POST /agents/{a2aInstanceId}/v1/messages:send`) * and fall back to v1 on 404 with a structured deprecation warning. * * Wire-shape mapping (v1 dispatch payload → A2A Message): * * v1 payload → A2A Message * -------------------------------- -------------------------------------- * mission_id message.messageId (idempotency key) * objective parts[0] = { kind: 'text', text: ... } * completion metadata.completion * executor_filter metadata.executor_filter * long_running metadata.long_running * <any other field> metadata.<field> * * @issue #1252 #1254 #1259 */ import { type DeprecationInfo } from '../a2a/http.js'; import type { JsonValue, Task } from '../a2a/types.js'; import type { ExecutorRegistration } from './executor-registry.js'; /** Per-call dispatch options. */ export interface DispatchRouterOptions { /** Custom fetch (for tests). */ fetch?: typeof fetch; /** Force a specific path; mostly used by tests. */ forceV1?: boolean; /** Called when the v1 fallback fires (drives `v1.dispatch.fallback` event). */ onV1Fallback?: (info: { executorId: string; reason: string; sunset?: string; }) => void; /** Called when the http wrapper sees `Sunset` / `Deprecated` headers * on any forwarded request (drives `v1.deprecation.observed` event). */ onDeprecation?: (info: DeprecationInfo) => void; /** Required A2A extensions to advertise on v2 calls. Defaults to runtime+idempotency. */ requiredExtensions?: readonly string[]; /** Optional A2A extensions to additionally advertise (e.g. hitl-prompt). */ optionalExtensions?: readonly string[]; /** Explicit A2A sandbox instance id. Overrides payload/register defaults. */ a2aInstanceId?: string; } /** Wire shape of the v1 dispatch payload AIWG accepts on * POST /api/v1/sessions/:id/dispatch. */ export interface V1DispatchPayload { mission_id: string; objective: string; completion?: string; long_running?: boolean; a2a_instance_id?: string; executor_filter?: Record<string, JsonValue>; /** Anything else flows through to A2A `Message.metadata`. */ [key: string]: JsonValue | boolean | undefined; } /** Normalized result returned by the router. */ export interface DispatchResult { missionId: string; executorId: string; a2aInstanceId?: string; /** Which path served the dispatch. */ dispatchPath: 'v2' | 'v1-fallback'; /** A2A Task (when v2). */ task?: Task; /** Estimated start (when v1 fallback returns one). */ estimatedStart?: string; /** True when the executor served an idempotency replay (v2 only). */ idempotentReplayed: boolean; } /** * Route a dispatch to an executor. Tries v2 first, falls back to v1 on 404 * or when `forceV1` is set. Throws on all other failure modes — caller is * responsible for surfacing 5xx to the inbound caller. */ export declare function routeDispatch(executor: ExecutorRegistration, payload: V1DispatchPayload, opts?: DispatchRouterOptions): Promise<DispatchResult>; //# sourceMappingURL=dispatch-router.d.ts.map