/** * Local Qwen orchestration planner adapter. * * Implements the `OrchestrationPlanner` contract on top of the normal * `createAgentSession()` path: an explicit local Qwen model resolved from the * ModelRegistry, read-only tools, and the normal session stream (no direct * HTTP or provider calls here). The adapter sends one bounded structured-JSON * prompt and returns the machine JSON object parsed from the final assistant * message. * * This adapter is not yet wired into the CLI or the orchestrator lifecycle; * callers construct it explicitly and pass it to * `OrchestratorService.createFromPlanner()`. The adapter exposes the roster * it derives from (`roster()`, `allowedAgents()`) so callers can pass the * same operator set to `validateOrchestrationPlan` through its explicit * `operatorAgents` hook. */ import type { StreamFn } from "@apholdings/jensen-agent-core"; import { AuthStorage } from "../auth-storage.js"; import { ModelRegistry } from "../model-registry.js"; import { type OperatorRoster } from "../operator-roster.js"; import type { ResourceLoader } from "../resource-loader.js"; import { SessionManager } from "../session-manager.js"; import type { SettingsManager } from "../settings-manager.js"; import type { OrchestrationPlanner, OrchestrationProposalInput } from "./types.js"; /** Maximum characters for the whole planner prompt. */ export declare const DEFAULT_QWEN_PLANNER_PROMPT_BUDGET = 8000; export interface QwenPlannerOptions { /** Working directory for project-local discovery. Default: process.cwd() */ cwd?: string; /** Global config directory. Default: getAgentDir() */ agentDir?: string; /** Auth storage. Default: AuthStorage.create(agentDir/auth.json) */ authStorage?: AuthStorage; /** Model registry. Default: new ModelRegistry(authStorage, agentDir/models.json) */ modelRegistry?: ModelRegistry; /** * Session manager. When omitted, each `propose()` call creates a fresh * in-memory SessionManager (one-shot planner: no session file, and no * state carried between proposals). Pass a persistent manager explicitly * when lifecycle integration owns the session. */ sessionManager?: SessionManager; /** Settings manager. Default: SettingsManager.create(cwd, agentDir) */ settingsManager?: SettingsManager; /** Resource loader. When omitted, createAgentSession uses its default. */ resourceLoader?: ResourceLoader; /** * Test seam. When omitted the session uses the normal shared-inference * stream (or the default provider stream when shared inference is off). */ streamFn?: StreamFn; /** * Agent names the planner may assign to nodes. * Default: the canonical operator roster names for agentDir. */ allowedAgents?: readonly string[]; /** Maximum characters for the whole planner prompt. Default: 8000. */ maxPromptCharacters?: number; } export interface QwenPlannerPromptInput { parentMissionId: string; objective: string; constraints: readonly string[]; maxTotalLogicalAgents: number; allowedAgents: readonly string[]; maxCharacters?: number; } /** * Smallest prompt size possible for this input: empty objective, only the * most recent constraint (when any exist), and the feedback notes that would * then be visible. A budget below this cannot be honored. */ export declare function minQwenPlannerPromptBudget(input: QwenPlannerPromptInput): number; /** * Build the bounded structured-JSON prompt for the planner model. * * The prompt always fits within `maxCharacters` (default 8000). Constraint * lines are capped individually; when the count cap or the budget omits * constraints, a "Prompt feedback" note in the prompt says so, and the most * recent constraint is always shown. The objective is cut exactly to the * remaining budget, with a visible truncation note. If `maxCharacters` is * below the fixed template floor for this input (see * `minQwenPlannerPromptBudget`), the call throws * ORCHESTRATION_PLANNER_BUDGET_BELOW_FLOOR instead of silently exceeding the * budget. Deterministic for identical inputs. */ export declare function buildQwenPlannerPrompt(input: QwenPlannerPromptInput): string; /** * Extract the machine JSON object from the final assistant message text. * * Accepts bare JSON, fenced ```json blocks, and JSON embedded in prose (the * outermost `{...}` span). Throws ORCHESTRATION_PLANNER_OUTPUT_INVALID when no * JSON object can be recovered. */ export declare function parseQwenPlannerOutput(text: string): unknown; export declare class QwenPlannerAdapter implements OrchestrationPlanner { private readonly _cwd; private readonly _agentDir; private readonly _authStorage; private readonly _modelRegistry; private readonly _sessionManager?; private readonly _settingsManager?; private readonly _resourceLoader?; private readonly _streamFn?; private readonly _allowedAgents?; private readonly _maxPromptCharacters; constructor(options?: QwenPlannerOptions); /** * The operator roster this planner derives from (agents plus diagnostics). * Rebuilt on every call, mirroring the canonical registry's no-cache * authority rule. */ roster(): OperatorRoster; /** * Agent names the planner may assign to nodes: the explicit * `allowedAgents` option when supplied, otherwise the roster names. Pass * this set to `validateOrchestrationPlan` as `operatorAgents` so roster * definitions and plan validation stay in sync. */ allowedAgents(): readonly string[]; propose(input: OrchestrationProposalInput): Promise; } export declare function createQwenPlanner(options?: QwenPlannerOptions): QwenPlannerAdapter; //# sourceMappingURL=qwen-planner.d.ts.map