Turn lifecycle orchestration.
This module is the high-level place where model calls, tool calls, transcript commits and fat-prompt transitions meet. api.nim should stay transport/protocol focused; visual consequences of model/tool progress should flow through this layer.
Imports
-
types, util, prompts, session, compact, config, actions, api, display, fatprompt, streamexec, toolstream, transcript, engine
Procs
proc onTurnInterrupted() {....raises: [IOError, IOError, IOError, Exception], tags: [ ReadEnvEffect, ReadIOEffect, TimeEffect, WriteIOEffect, WriteDirEffect, RootEffect], forbids: [].}
-
Single response to a user-triggered interrupt (Ctrl-C, ESC, or any other trigger wired to requestTurnInterrupt). Emits the notice to scrollback as a plain harness line and clears the interrupt flag so the editor resumes normally on the next input.
This is the only place that renders an interrupt. Whether the interrupt was noticed mid-stream, after a tool call, or propagated up as an ApiError once the stream had already torn itself down, the response is identical.
proc runTurns(p: Profile; messages: var JsonNode; session: var Session) {....raises: [ ResourceExhaustedError, IOError, Exception, KeyError, ValueError, ApiError, IOError, IOError, IOError, IOError, Exception, KeyError, OSError, ResourceExhaustedError, ValueError, SessionLocked], tags: [TimeEffect, WriteIOEffect, ReadEnvEffect, RootEffect, ReadIOEffect, ReadDirEffect, WriteDirEffect, ExecIOEffect], forbids: [].}
proc runTurnsInteractive(p: Profile; messages: var JsonNode; session: var Session) {....raises: [IOError, ResourceExhaustedError, IOError, Exception, KeyError, ValueError, SessionLocked], tags: [WriteIOEffect, TimeEffect, ReadEnvEffect, RootEffect, ReadIOEffect, ReadDirEffect, WriteDirEffect, ExecIOEffect], forbids: [].}