/** * @license * Copyright 2026 Qwen * SPDX-License-Identifier: Apache-2.0 */ import type { ProactiveTask } from './task-manager.js'; export type ProactiveReceiptOperation = 'create_task' | 'update_task' | 'cancel_task' | 'list_tasks'; export type ProactiveFailureCode = 'capacity' | 'missing_target' | 'target_not_found' | 'ambiguous_target' | 'task_busy' | 'invalid_arguments' | 'validation_error' | 'execution_error'; export interface ProactiveTaskSnapshot { task_id: string; title: string; task_type: ProactiveTask['taskType']; status: ProactiveTask['status']; monitor_mode: ProactiveTask['monitorMode']; repeat: boolean; modalities?: string[]; user_intent_text?: string; intervention_text?: string; narration_preferences?: { source_request: string; fallback_language: 'en' | 'zh-CN'; style_override?: string; }; duration_sec?: number; reminder_text?: string; remaining_sec?: number; pending_delivery_count?: number; } export interface ProactiveReceiptResult { op: ProactiveReceiptOperation; success: boolean; atomic?: true; task_id?: string; title?: string; task_type?: ProactiveTask['taskType']; status?: ProactiveTask['status']; monitor_mode?: ProactiveTask['monitorMode']; repeat?: boolean; modalities?: string[]; user_intent_text?: string; intervention_text?: string; duration_sec?: number; reminder_text?: string; cancelled_count?: number; cancelled_ids?: string[]; cancelled_tasks?: Array<{ title: string; }>; tasks?: ProactiveTaskSnapshot[]; error?: string; } /** * Internal authoritative receipt. Keep this structure for state/diagnostics; * submit only `renderProactiveToolReceipt(receipt)` to the realtime model. */ export interface ProactiveToolReceipt { results: ProactiveReceiptResult[]; active_tasks: ProactiveTaskSnapshot[]; atomic: true; committed: boolean; failure_code?: ProactiveFailureCode; error?: string; } export declare const PROACTIVE_ARGUMENT_RULES: { readonly invalidJson: "Tool arguments must be valid JSON."; readonly notObject: "Tool arguments must be an object."; readonly selectorlessUpdateRepeatOnly: "An adjacent selector-less update may only set repeat=true."; readonly selectorlessUpdateNoAdjacent: "Selector-less update has no adjacent active task."; readonly selectorlessCancelEmptyOnly: "An adjacent selector-less cancel must have no arguments."; readonly selectorlessCancelNoAdjacent: "Selector-less cancel has no adjacent active task."; readonly narrationSourceUnavailable: "The original user request for narration is unavailable. No narration task was created; please repeat the request and any language or style preferences."; }; export declare function snapshotProactiveTask(task: ProactiveTask): ProactiveTaskSnapshot; export declare function buildProactiveCreateReceipt(task: ProactiveTask, activeTasks: readonly ProactiveTask[]): ProactiveToolReceipt; export declare function buildProactiveUpdateReceipt(task: ProactiveTask, activeTasks: readonly ProactiveTask[]): ProactiveToolReceipt; export declare function buildProactiveCancelReceipt(cancelledTasks: readonly ProactiveTask[], activeTasks: readonly ProactiveTask[]): ProactiveToolReceipt; export declare function buildProactiveListReceipt(activeTasks: readonly ProactiveTask[]): ProactiveToolReceipt; export declare function buildProactiveFailureReceipt(operation: ProactiveReceiptOperation, error: unknown, activeTasks: readonly ProactiveTask[], failureCode?: ProactiveFailureCode): ProactiveToolReceipt; export declare function classifyProactiveFailure(error: unknown): ProactiveFailureCode; /** Render only speakable authoritative facts; never serialize the envelope. */ export declare function renderProactiveToolReceipt(receipt: unknown): string;