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
99 lines • 3.74 kB
TypeScript
/**
* Agent Router
*
* Capability-based and load-aware agent routing for task dispatch (#916).
* Selects the best available agent for a task based on declared filters
* (framework requirements, inventory, resource thresholds) and real-time
* metrics (CPU/memory load from #911).
*
* Also exposes routeMission() for executor-level routing (#1179).
*/
import type { SandboxAgent } from './sandbox-registry.js';
import type { ExecutorRegistration, ExecutorFilter } from './executor-registry.js';
export interface ExecutorCandidate {
executor: ExecutorRegistration;
matchReason: string;
rejected: Array<{
executorId: string;
reason: string;
}>;
}
export interface ExecutorRoutingResult {
selected?: ExecutorCandidate;
candidates: ExecutorCandidate[];
filter: ExecutorFilter;
}
/**
* Select the best executor from the provided list using filter criteria.
*
* Default-selection policy (per ADR §3):
* 1. Sandbox-first: prefer any executor with isolation:vm or isolation:container
* 2. Local fallback: isolation:none or isolation:host
* 3. 503 if no executor is connected and matching
*
* `long_running: true` requires the 'resumable' capability.
*
* Returns an ExecutorRoutingResult with the selected executor and full candidate list.
*/
export declare function routeMission(executors: ExecutorRegistration[], filter: ExecutorFilter, longRunning?: boolean): ExecutorRoutingResult;
/** Filter criteria for selecting an agent to run a task (#916). */
export interface AgentFilter {
/** Target a specific sandbox by ID */
sandbox_id?: string;
/** Target a specific agent by agentId, instanceId, or logicalName (#917) */
agent_id?: string;
/** Target an agent by its persistent logicalName (#917) */
agent_name?: string;
/** Required AIWG platform (e.g. "claude") */
platform?: string;
/** Agent must have ALL of these frameworks installed */
frameworks?: string[];
/** Agent must have ALL of these named agents in its inventory */
agents?: string[];
/** Agent must have ALL of these named skills in its inventory */
skills?: string[];
/** Agent must have at least this much free memory (GB) */
min_memory_gb?: number;
/** Agent must have CPU percent below this threshold */
max_cpu_percent?: number;
/** Fallback policy when preferred agent is unavailable */
fallback?: AgentFilterFallback;
}
export interface AgentFilterFallback {
/** "any_with_framework" | "any" | "none" */
strategy: 'any_with_framework' | 'any' | 'none';
/** Seconds to wait before falling back (not implemented — for future retry loop) */
retry_after_seconds?: number;
max_retries?: number;
}
export interface AgentCandidate {
sandboxId: string;
sandboxName: string;
agent: SandboxAgent;
/** Why this agent was selected or rejected */
matchReason: string;
/** Agents that did NOT match, with rejection reasons */
rejected?: Array<{
agentId: string;
reason: string;
}>;
}
export interface RoutingResult {
selected?: AgentCandidate;
candidates: AgentCandidate[];
filter: AgentFilter;
}
/** Returns a rejection reason string, or null if the agent matches. */
export declare function matchAgent(agent: SandboxAgent & {
sandboxId: string;
sandboxName: string;
}, filter: AgentFilter): string | null;
/**
* Select the best agent from candidates using filter criteria.
* Returns a RoutingResult with selected agent and full candidate list.
*/
export declare function routeTask(agents: Array<SandboxAgent & {
sandboxId: string;
sandboxName: string;
}>, filter: AgentFilter): RoutingResult;
//# sourceMappingURL=agent-router.d.ts.map