basant307/AI_Governance_Project
048
1/**2 * @license3 * Copyright 2025 Google LLC4 * SPDX-License-Identifier: Apache-2.05 */6import type { Config, CronJob, CronScheduler } from '@qwen-code/qwen-code-core';7import type { LoadedSettings } from './config/settings.js';8import { SendMessageType } from '@qwen-code/qwen-code-core';9import type { CLIUserMessage } from './nonInteractive/types.js';10import type { JsonOutputAdapterInterface } from './nonInteractive/io/BaseJsonOutputAdapter.js';11import type { ControlService } from './nonInteractive/control/ControlService.js';12/**13 * Headless handling for fired loop sentinels. loop.md and autonomous sentinel14 * expansion is interactive-only for now, so a bare sentinel can't be turned into15 * a real prompt here — the tick is skipped (no-op) rather than sent to the model16 * as empty content. Returns true when `job` was a sentinel so the caller skips17 * enqueuing it.18 *19 * A recurring SESSION (non-durable) loop.md job would otherwise stay in20 * `scheduler.sessionSize` and re-fire every interval, pinning the headless run21 * open forever (the hold-open resolves only when sessionSize hits zero); delete22 * it so the run can terminate. Durable jobs are left untouched here — they23 * persist for a future owning session and never count toward sessionSize — and24 * a one-shot job is already removed before it fires.25 *26 * Note: a DURABLE loop.md sentinel never even reaches this callback in headless,27 * because `setSkipDurableFire` filters it at the scheduler before any fire or28 * lastFiredAt persist (otherwise the tick would be marked fired while the work29 * is skipped — silent loss). This guard's durable branch is kept defensive.30 */31export declare function skipHeadlessLoopSentinel(scheduler: CronScheduler, job: CronJob): boolean;32/**33 * Provides optional overrides for `runNonInteractive` execution.34 *35 * @param abortController - Optional abort controller for cancellation.36 * @param adapter - Optional JSON output adapter for structured output formats.37 * @param userMessage - Optional CLI user message payload for preformatted input.38 * @param controlService - Optional control service for future permission handling.39 */40export interface RunNonInteractiveOptions {41 abortController?: AbortController;42 adapter?: JsonOutputAdapterInterface;43 userMessage?: CLIUserMessage;44 controlService?: ControlService;45 sendMessageType?: SendMessageType;46 notificationDisplayText?: string;47 captureMonitorNotifications?: boolean;48 captureMonitorRegistrations?: boolean;49 onResultEmitted?: () => void;50 /**51 * Continue the most recent unfinished turn from chat history instead of52 * submitting `input` (which is ignored). No new user message enters the53 * transcript: an orphaned trailing user entry is re-submitted with Retry54 * semantics, and dangling tool calls are closed with synthesized error55 * functionResponses sent as a ToolResult. When the last turn ended56 * cleanly the run emits a no-op result and exits 0.57 */58 continueInterrupted?: boolean;59}60/**61 * Executes the non-interactive CLI flow for a single request.62 */63export declare function runNonInteractive(config: Config, settings: LoadedSettings, input: string, prompt_id: string, options?: RunNonInteractiveOptions): Promise<number>;64 