version: 1
kind: platform-infra-webterm

metadata:
  id: webterm-public
  owner: unidesk

sessionStartModes:
  defaultMode: mycx
  options:
    bash:
      label: Bash
      command: exec bash -l
    mycx:
      label: mycx
      command: mycx
    oncx:
      label: oncx
      command: oncx

autoResumePrompt:
  enabled: false
  prompt: "[自动提醒]如果有未完成任务则继续，没有则直接结束"
  sendEnter: true
  enterDelayMs: 500
  readiness:
    minDelayMs: 2000
    minOutputBytes: 64
    quietPeriodMs: 1500
    timeoutMs: 60000

browserTerminalHistory:
  desktopScrollbackLines: 8000
  mobileScrollbackLines: 500
  mobileMaxWidthPx: 899

browserOutputPolicy:
  maxFramesPerSecond: 10
  maxFrameBytes: 65536
  compression:
    enabled: true
    thresholdBytes: 1024
    level: 3
    memLevel: 7
    concurrencyLimit: 4
    serverContextTakeover: true
    clientContextTakeover: false

browserPerformance:
  animationsEnabled: true
  defaultBackgroundMode: receive-only
  backgroundModes:
    disconnect:
      label: 断开后台连接
    receive-only:
      label: 只接收数据
    live:
      label: 实时渲染
  deferredOutputMaxBytes: 524288
  dashboardSampleWindowSeconds: 60
  dashboardRefreshIntervalMs: 1000

defaults:
  targetId: local-7683

targets:
  - id: local-7681
    enabled: true
    runtime:
      mode: host-docker
      workDir: /root/webterm
      composePath: /root/webterm/build/docker-compose.7681.yaml
      composeProject: webterm-7681
      serviceName: web-terminal
      containerName: web-terminal
      image: webterm-web-terminal-7681:latest
      envFile: /root/webterm/.env
      hostPort: 7681
      containerPort: 7681
      privileged: true
      pid: host
      sourceMounts:
        - source: /root/webterm/src
          target: /app/src
          readOnly: true
        - source: /root/webterm/public
          target: /app/public
          readOnly: true
        - source: /root/webterm/scripts/host-shell.sh
          target: /usr/local/bin/host-shell
          readOnly: true
        - source: /root/user_uploads
          target: /root/user_uploads
          readOnly: false
      autoStartSessions:
        - title: TERM
          cwd: /root/unidesk
          command: mycx resume 019f4eeb-bbb3-7e32-bb98-d10753561516
          cols: 100
          rows: 30
          resumePrompt: true
          fallbackShell: true
      environment:
        HOST: 0.0.0.0
        PORT: "7681"
        SESSION_COOKIE_NAME: webterm_session_7681
        SESSION_MAX_AGE_SECONDS: "604800"
        SERVER_PROVIDER_ID: remote-server
        SERVER_PROVIDER_NAME: Remote Server
        TERMINAL_SHELL: /usr/local/bin/host-shell
        TERMINAL_CWD: /root
        TERMINAL_REMOTE_CWD: /root/unidesk
        TERMINAL_START_COMMAND: ""
        TERMINAL_HISTORY_BYTES: "2097152"
        TERMINAL_SNAPSHOT_BYTES: "0"
        TERMINAL_SNAPSHOT_POLICY: tail
        BROWSER_SNAPSHOT_WRITE_CHUNK_BYTES: "8192"
        BROWSER_MANUAL_REDRAW_MODE: double
        BROWSER_MANUAL_REDRAW_DELAY_MS: "60"
        BROWSER_KEEPALIVE_ENABLED: "true"
        BROWSER_RESUME_PROBE_ENABLED: "false"
        BROWSER_KEEPALIVE_INTERVAL_MS: "30000"
        BROWSER_STALE_TIMEOUT_MS: "180000"
        BROWSER_SESSION_OUTPUT_IDLE_MS: "3000"
        BROWSER_OUTPUT_PULSE_MIN_INTERVAL_MS: "250"
        PROTOCOL_METRICS_ENABLED: "true"
        PROTOCOL_METRICS_WINDOW: "400"
        FILE_UPLOAD_DIR: /root/user_uploads
        FILE_UPLOAD_MAX_BYTES: "104857600"
    publicExposure:
      enabled: false
      publicBaseUrl: https://term.pikapython.com
      dns:
        hostname: term.pikapython.com
        expectedA: 82.156.23.220
        resolvers: [1.1.1.1, 8.8.8.8, 223.5.5.5, 114.114.114.114]
      upstream:
        host: 152.53.229.148
        port: 7681
      pk01:
        route: PK01
        caddyConfigPath: /etc/caddy/Caddyfile
        caddyServiceName: caddy
        responseHeaderTimeoutSeconds: 600

  - id: local-7682
    enabled: true
    runtime:
      mode: host-docker
      workDir: /root/webterm
      composePath: /root/webterm/build/docker-compose.7682.yaml
      composeProject: webterm-7682
      serviceName: web-terminal
      containerName: web-terminal-7682
      image: webterm-web-terminal-7682:latest
      envFile: /root/webterm/.env
      hostPort: 7682
      containerPort: 7681
      privileged: true
      pid: host
      sourceMounts:
        - source: /root/webterm/src
          target: /app/src
          readOnly: true
        - source: /root/webterm/public
          target: /app/public
          readOnly: true
        - source: /root/webterm/scripts/host-shell.sh
          target: /usr/local/bin/host-shell
          readOnly: true
        - source: /root/user_uploads
          target: /root/user_uploads
          readOnly: false
      autoStartSessions:
        - title: TERM
          cwd: /root/unidesk
          command: mycx resume 019f4eeb-bbb3-7e32-bb98-d10753561516
          cols: 100
          rows: 30
          resumePrompt: true
          fallbackShell: true
      environment:
        HOST: 0.0.0.0
        PORT: "7681"
        SESSION_COOKIE_NAME: webterm_session_7682
        SESSION_MAX_AGE_SECONDS: "604800"
        SERVER_PROVIDER_ID: remote-server
        SERVER_PROVIDER_NAME: Remote Server 7682
        TERMINAL_SHELL: /usr/local/bin/host-shell
        TERMINAL_CWD: /root
        TERMINAL_REMOTE_CWD: /root/unidesk
        TERMINAL_START_COMMAND: ""
        TERMINAL_HISTORY_BYTES: "2097152"
        TERMINAL_SNAPSHOT_BYTES: "131072"
        TERMINAL_SNAPSHOT_POLICY: tail
        BROWSER_SNAPSHOT_WRITE_CHUNK_BYTES: "8192"
        BROWSER_MANUAL_REDRAW_MODE: double
        BROWSER_MANUAL_REDRAW_DELAY_MS: "60"
        BROWSER_KEEPALIVE_ENABLED: "true"
        BROWSER_RESUME_PROBE_ENABLED: "false"
        BROWSER_KEEPALIVE_INTERVAL_MS: "15000"
        BROWSER_STALE_TIMEOUT_MS: "180000"
        BROWSER_SESSION_OUTPUT_IDLE_MS: "3000"
        BROWSER_OUTPUT_PULSE_MIN_INTERVAL_MS: "250"
        PROTOCOL_METRICS_ENABLED: "true"
        PROTOCOL_METRICS_WINDOW: "400"
        FILE_UPLOAD_DIR: /root/user_uploads
        FILE_UPLOAD_MAX_BYTES: "104857600"
    publicExposure:
      enabled: false
      publicBaseUrl: https://term.pikapython.com
      dns:
        hostname: term.pikapython.com
        expectedA: 82.156.23.220
        resolvers: [1.1.1.1, 8.8.8.8, 223.5.5.5, 114.114.114.114]
      upstream:
        host: 152.53.229.148
        port: 7682
      pk01:
        route: PK01
        caddyConfigPath: /etc/caddy/Caddyfile
        caddyServiceName: caddy
        responseHeaderTimeoutSeconds: 600

  - id: local-7683
    enabled: true
    runtime:
      mode: host-docker
      workDir: /root/webterm
      composePath: /root/webterm/build/docker-compose.7683.yaml
      composeProject: webterm-7683
      serviceName: web-terminal
      containerName: web-terminal-7683
      image: webterm-web-terminal-7682:latest
      envFile: /root/webterm/.env
      hostPort: 7683
      containerPort: 7681
      privileged: true
      pid: host
      sourceMounts:
        - source: /root/webterm/src
          target: /app/src
          readOnly: true
        - source: /root/webterm/public
          target: /app/public
          readOnly: true
        - source: /root/webterm/scripts/host-shell.sh
          target: /usr/local/bin/host-shell
          readOnly: true
        - source: /root/user_uploads
          target: /root/user_uploads
          readOnly: false
      networkSpeedTest:
        enabled: true
        containerName: web-terminal-7683-speed-test
        hostPort: 7783
        containerPort: 7781
        publicUrl: "http://{hostname}:7783"
        downloadBytes: 16777216
        uploadBytes: 8388608
        maxDurationMs: 10000
      autoStartSessions:
        - title: 决策中心
          cwd: /root/unidesk
          command: mycx resume 019f4937-9820-7b31-9178-344ae93d5a4c
          cols: 100
          rows: 30
          resumePrompt: true
          fallbackShell: true
        - title: CONSTAR
          cwd: /root/unidesk
          command: mycx resume 019f4b5f-b5ce-76b3-8ccb-508790e9662d
          cols: 100
          rows: 30
          resumePrompt: true
          fallbackShell: true
        - title: WORKBENCH
          cwd: /root/unidesk
          command: mycx resume 019f4a1a-fd46-7662-8dc2-bf628210739d
          cols: 100
          rows: 30
          resumePrompt: true
          fallbackShell: true
      environment:
        HOST: 0.0.0.0
        PORT: "7681"
        SERVER_PROVIDER_ID: remote-server
        SERVER_PROVIDER_NAME: Remote Server 7683
        TERMINAL_SHELL: /usr/local/bin/host-shell
        TERMINAL_CWD: /root
        TERMINAL_REMOTE_CWD: /root/unidesk
        TERMINAL_START_COMMAND: mycx
        TERMINAL_HISTORY_BYTES: "2097152"
        TERMINAL_SNAPSHOT_BYTES: "524288"
        BROWSER_KEEPALIVE_INTERVAL_MS: "30000"
        BROWSER_STALE_TIMEOUT_MS: "180000"
        BROWSER_SESSION_OUTPUT_IDLE_MS: "3000"
        BROWSER_OUTPUT_PULSE_MIN_INTERVAL_MS: "250"
        FILE_UPLOAD_DIR: /root/user_uploads
        FILE_UPLOAD_MAX_BYTES: "104857600"
    publicExposure:
      enabled: true
      publicBaseUrl: https://term.pikapython.com
      dns:
        hostname: term.pikapython.com
        expectedA: 82.156.23.220
        resolvers: [1.1.1.1, 8.8.8.8, 223.5.5.5, 114.114.114.114]
      upstream:
        host: 152.53.229.148
        port: 7683
      pk01:
        route: PK01
        caddyConfigPath: /etc/caddy/Caddyfile
        caddyServiceName: caddy
        responseHeaderTimeoutSeconds: 600
