# The deepseek-tui bundle patch: terminal-surface mode directly over dsh-base.
# It mounts no Host, HTTP server, Web runtime, or browser plugin. An ordinary
# provider plugin parses --resume/--cwd and the task positional, then the
# terminal driver creates an Agent through the core registry and prints its
# durable result. Unlike the web surface, the agent plane stays process-wide:
# dsh-base keeps tool-bash/tool-fs/tool-todo and friends because the TUI is
# single-session and composes its agent process-wide.

- id: system-prompt
  config:
    persona: >-
      You are a coding agent powered by the {{model}} model. Your working directory is {{cwd}}.
      You are interacting with the user through the deepseek-tui terminal interface.

# The shared module-reload HMR row stays off; the launcher's watch-only
# fallback still keeps the user patch layers live until the run exits.
- id: hmr
  disabled: true

- id: tools
  config:
    # Keep the same temporary process-wide Code Mode opt-in as the Web surface.
    mode: !!js process.env.DSH_TOOLS_MODE

- id: approval
  config:
    policy: !!js "(process.env.DSH_PERMISSION_MODE ?? 'workspace-write') === 'danger-full-access' ? 'never' : 'ask'"

# Full-text session search stays disabled until the first Ctrl+K search (the
# base row's `openAt: never`). The TUI has no browser-latency concern, so the
# node:sqlite import and in-memory handle open lazily on first search.
- id: session-query-sqlite
  config:
    path: ':memory:'
    openAt: first-search

- id: llm-deepseek
  config:
    models:
      - id: deepseek-v4-flash
        name: DeepSeek-V4-Flash
        description: Fast, efficient, and economical; suited to focused, routine, or parallel tasks.
        contextWindow: 1000000
      - id: deepseek-v4-pro
        name: DeepSeek-V4-Pro
        description: Stronger agentic coding, knowledge, and difficult reasoning; suited to complex or quality-critical tasks at higher cost.
        contextWindow: 1000000
      - id: deepseek-v4-flash-vision-exp
        name: DeepSeek-V4-Flash-Vision-Exp
        contextWindow: 1000000
        inputModalities: [text, image]
      - id: deepseek-v4.1-flash-expires-on-0910
        name: DeepSeek-V4.1-Flash
        description: DeepSeek V4.1 Flash intermediate beta with native multimodal support, higher capability, faster speed, and lower cost.
        contextWindow: 1000000
        inputModalities: [text, image]

- id: agent-default-model
  config:
    provider: deepseek-official
    model: !!js "process.env.DSH_MODEL ?? 'deepseek-v4-flash'"

- insert:
    - id: tool-ask-user
      name: "@deepseek-ai/dsh-tool-ask-user"

    # In-process OpenCode Zen header proxy (vendored from
    # zhangyang-crazy-one/dsh-zen-proxy, MIT). Listens on localhost
    # only; point an opencode provider baseURL at
    # http://127.0.0.1:4097/v1 to reach the Zen free tier.
    # Remove this row to disable the listener.
    - id: zen-proxy
      name: "./dist/zen-proxy.js"
      config:
        host: 127.0.0.1
        port: 4097

    - id: tui-startup
      name: "./dist/startup.js"

    # Reads its task from the ordinary tuiStartup provider.
    - id: tui-runtime
      name: "./dist/index.js"
      inject: [tuiStartup]
      config:
        task: !!js ctx.tuiStartup.task
        resume: !!js ctx.tuiStartup.resume
        cwd: !!js ctx.tuiStartup.cwd
        model: !!js ctx.tuiStartup.model
        frameStats: !!js ctx.tuiStartup.frameStats
        # Render policy (overscan + stream pacing + scroll pacing + cache budgets).
        # Loaded by the runtime Config schema; the values below mirror the
        # schema defaults so the deployment layer owns the tunables. Override
        # here to retune without touching the plugin.
        renderPolicy:
          transcriptOverscan: 16
          stream:
            frameIntervalMs: 16
            entryDepth: 64
            exitDepth: 32
            entryOldestAgeMs: 500
            exitOldestAgeMs: 250
            entryDrainBackpressureMs: 100
            exitDrainBackpressureMs: 50
            catchUpRowsPerFrame: 16
          scroll:
            frameIntervalMs: 16
            stepPerFrame: 1
            wheelRows: 3
            catchUpThreshold: 10
            maxCatchUpStep: 8
          cache:
            maxRows: 4096
            maxBytes: 4194304
