version: 1
kind: AgentRunConfig
metadata:
  name: agentrun

manager:
  baseUrl: https://agentrun.74-48-78-17.nip.io/
  timeoutMs: 15000

publicExposure:
  enabled: true
  proxyName: agentrun-v01-frpc
  remotePort: 22880
  publicBaseUrl: https://agentrun.74-48-78-17.nip.io/
  masterBaseUrl: http://127.0.0.1:22880
  masterFrps:
    configPath: /opt/hwlab-frp/frps.dev.toml
    containerName: hwlab-frps-dev
  masterCaddy:
    enabled: true
    domain: agentrun.74-48-78-17.nip.io
    configPath: /etc/caddy/Caddyfile
    serviceName: caddy
    upstreamBaseUrl: http://127.0.0.1:22880
    responseHeaderTimeoutSeconds: 60

auth:
  env: HWLAB_API_KEY
  file: /root/.config/hwlab-v02/master-server-admin-api-key.env
  header: Authorization
  scheme: Bearer

client:
  role: render-only
  transport: direct-http
  sessionPolicy:
    tenantId: unidesk
    projectId: default
    providerId: G14
    backendProfile: codex
    workspaceRef:
      kind: opaque
      path: .
    executionPolicy:
      sandbox: workspace-write
      approval: never
      timeoutMs: 900000
      network: enabled
      secretScope:
        allowCredentialEcho: false

controlPlane:
  default:
    node: G14
    lane: v01

  nodes:
    G14:
      route: G14
      kubeRoute: G14:k3s
    D601:
      route: D601
      kubeRoute: D601:k3s

  lanes:
    v01:
      node: G14
      version: v0.1
      source:
        repository: pikasTech/agentrun
        branch: v0.1
        bootstrapFromBranch: v0.1
        bootstrapTimeoutSeconds: 900
        bootstrapPollSeconds: 15
        remote: git@github.com:pikasTech/agentrun.git
        workspace: /root/agentrun-v01
      runtime:
        namespace: agentrun-v01
        managerDeployment: agentrun-mgr
        managerService: agentrun-mgr
        managerPort: 8080
        internalBaseUrl: http://agentrun-mgr.agentrun-v01.svc.cluster.local:8080
      ci:
        namespace: agentrun-ci
        pipeline: agentrun-v01-ci-image-publish
        pipelineRunPrefix: agentrun-v01-ci
        serviceAccountName: agentrun-v01-tekton-runner
        registryPrefix: 127.0.0.1:5000/agentrun
        toolsImage: 127.0.0.1:5000/hwlab/hwlab-ci-node-tools:node22-alpine-bun-v1
      gitops:
        branch: v0.1-gitops
        path: deploy/gitops/g14/runtime-v01
        argoNamespace: argocd
        argoApplication: agentrun-g14-v01
        repoURL: http://git-mirror-http.devops-infra.svc.cluster.local/pikasTech/agentrun.git
      deployment:
        format: unidesk-yaml-only
        gitopsRoot: deploy/gitops/g14
        runtimeRenderDir: runtime-v01
        artifactCatalogPath: deploy/artifact-catalog.v01.json
        argocd:
          project: agentrun-v01
          applicationFile: application-v01.yaml
        manager:
          serviceAccount: agentrun-v01-mgr
          apiKeySecretRef:
            name: agentrun-v01-api-key
            key: HWLAB_API_KEY
          unideskSshEndpointEnv:
            name: UNIDESK_MAIN_SERVER_IP
            value: 74.48.78.17
          bootRepoUrl: http://git-mirror-http.devops-infra.svc.cluster.local/pikasTech/agentrun.git
          imageBuild:
            context: .
            containerfile: deploy/container/Containerfile
            repository: agentrun-mgr-env
            network: host
            buildArgs:
              BUN_IMAGE: oven/bun:1.2.15-alpine
            httpProxy: http://127.0.0.1:10808
            httpsProxy: http://127.0.0.1:10808
            noProxy:
              - localhost
              - 127.0.0.1
              - ::1
              - 127.0.0.1:5000
              - localhost:5000
              - .svc
              - .svc.cluster.local
              - .cluster.local
              - hyueapi.com
              - .hyueapi.com
            envIdentityFiles:
              - deploy/container/Containerfile
              - deploy/runtime/boot/agentrun-boot.sh
              - deploy/runtime/boot/agentrun-mgr.sh
              - deploy/runtime/boot/agentrun-runner.sh
              - package.json
              - bun.lock
              - tsconfig.json
            timeoutSeconds: 1800
            pollSeconds: 15
          resources:
            requests:
              cpu: 100m
              memory: 256Mi
            limits:
              cpu: 800m
              memory: 1Gi
        runner:
          serviceAccount: agentrun-v01-runner
          jobNamePrefix: agentrun-v01-runner
          idleTimeoutMs: 600000
          missingTerminalAfterToolTimeoutMs: 60000
          backendRetry:
            maxAttempts: 1
            initialBackoffMs: 1000
            maxBackoffMs: 30000
          apiKeySecretRef:
            name: agentrun-v01-api-key
            key: HWLAB_API_KEY
          retention:
            maxRunners: 20
            cleanupOrder: oldest-inactive-last-active-first
            activeHeartbeatMaxAgeMs: 900000
            selectors:
              matchLabels:
                app.kubernetes.io/part-of: agentrun
                app.kubernetes.io/name: agentrun-runner
                app.kubernetes.io/component: runner
              jobNamePrefixes:
                - agentrun-v01-runner
            ageBasedCleanup:
              enabled: false
              maxAgeHours: 48
        localPostgres:
          enabled: true
          serviceName: agentrun-v01-postgres
          image: postgres:16-alpine
          storage: 5Gi
          port: 5432
      gitMirror:
        namespace: devops-infra
        readService: git-mirror-http
        readDeployment: git-mirror-http
        writeService: git-mirror-write
        writeDeployment: git-mirror-write
        readUrl: http://git-mirror-http.devops-infra.svc.cluster.local/pikasTech/agentrun.git
        writeUrl: http://git-mirror-write.devops-infra.svc.cluster.local/pikasTech/agentrun.git
        cachePvc: git-mirror-cache
        cacheHostPath: null
        sshSecretName: git-mirror-github-ssh
        githubProxy:
          host: 127.0.0.1
          port: 10808
        toolsImage: 127.0.0.1:5000/hwlab/hwlab-ci-node-tools:node22-alpine-bun-v1
        syncJobPrefix: git-mirror-agentrun-sync-manual
        flushJobPrefix: git-mirror-agentrun-flush-manual
        repositories:
          - key: agentrun
            repository: pikasTech/agentrun
            sourceBranch: v0.1
            gitopsBranch: v0.1-gitops
          - key: unidesk
            repository: pikasTech/unidesk
            sourceBranch: master
          - key: agent_skills
            repository: pikasTech/agent_skills
            sourceBranch: master
      database:
        mode: local-postgres
        secretRef:
          name: agentrun-v01-mgr-db
          key: DATABASE_URL
        localPostgresExpectedAbsent: false
      secrets:
        - id: provider-codex-auth-json
          sourceMode: file
          sourceRef: /root/.codex/auth.json
          targetRef:
            namespace: agentrun-v01
            name: agentrun-v01-provider-codex
            key: auth.json
          providerCredential:
            profile: codex
        - id: provider-codex-config
          sourceMode: file
          sourceRef: /root/.codex/config.toml
          targetRef:
            namespace: agentrun-v01
            name: agentrun-v01-provider-codex
            key: config.toml
          providerCredential:
            profile: codex

    v02:
      node: D601
      version: v0.2
      source:
        repository: pikasTech/agentrun
        branch: v0.2
        bootstrapFromBranch: v0.1
        bootstrapTimeoutSeconds: 900
        bootstrapPollSeconds: 15
        remote: git@github.com:pikasTech/agentrun.git
        workspace: /home/ubuntu/workspace/agentrun-v02
      runtime:
        namespace: agentrun-v02
        managerDeployment: agentrun-mgr
        managerService: agentrun-mgr
        managerPort: 8080
        internalBaseUrl: http://agentrun-mgr.agentrun-v02.svc.cluster.local:8080
      ci:
        namespace: agentrun-ci
        pipeline: agentrun-v02-ci-image-publish
        pipelineRunPrefix: agentrun-v02-ci
        serviceAccountName: agentrun-v02-tekton-runner
        registryPrefix: 127.0.0.1:5000/agentrun
        toolsImage: 127.0.0.1:5000/hwlab/hwlab-ci-node-tools:node22-alpine-bun-v1
      gitops:
        branch: v0.2-gitops
        path: deploy/gitops/node/d601/runtime-v02
        argoNamespace: argocd
        argoApplication: agentrun-d601-v02
        repoURL: http://git-mirror-http.devops-infra.svc.cluster.local:8080/pikasTech/agentrun.git
      deployment:
        format: unidesk-yaml-only
        gitopsRoot: deploy/gitops/node/d601
        runtimeRenderDir: runtime-v02
        artifactCatalogPath: deploy/artifact-catalog.v02.json
        argocd:
          project: agentrun-v02
          applicationFile: application-v02.yaml
        manager:
          serviceAccount: agentrun-v02-mgr
          apiKeySecretRef:
            name: agentrun-v02-api-key
            key: HWLAB_API_KEY
          env:
            AGENTRUN_POSTGRES_POOL_MAX: "4"
            AGENTRUN_MANAGER_RECONCILER_BATCH_SIZE: "20"
            AGENTRUN_MANAGER_RECONCILER_ENABLED: "true"
            AGENTRUN_MANAGER_RECONCILER_INTERVAL_MS: "30000"
            OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: http://otel-collector.platform-infra.svc.cluster.local:4318/v1/traces
            OTEL_SERVICE_NAME: agentrun-manager
            UNIDESK_NODE_ID: D601
            HWLAB_RUNTIME_LANE: v0.3
          unideskSshEndpointEnv:
            name: UNIDESK_MAIN_SERVER_IP
            value: 74.48.78.17
          bootRepoUrl: http://git-mirror-http.devops-infra.svc.cluster.local:8080/pikasTech/agentrun.git
          imageBuild:
            context: .
            containerfile: deploy/container/Containerfile
            repository: agentrun-mgr-env
            network: host
            buildArgs:
              BUN_IMAGE: oven/bun:1-alpine
            httpProxy: http://127.0.0.1:18789
            httpsProxy: http://127.0.0.1:18789
            noProxy:
              - localhost
              - 127.0.0.1
              - ::1
              - 127.0.0.1:5000
              - localhost:5000
              - .svc
              - .svc.cluster.local
              - .cluster.local
              - hyueapi.com
              - .hyueapi.com
            envIdentityFiles:
              - deploy/container/Containerfile
              - deploy/runtime/boot/agentrun-boot.sh
              - deploy/runtime/boot/agentrun-mgr.sh
              - deploy/runtime/boot/agentrun-runner.sh
              - package.json
              - bun.lock
              - tsconfig.json
            timeoutSeconds: 1800
            pollSeconds: 15
          resources:
            requests:
              cpu: 100m
              memory: 256Mi
            limits:
              cpu: 800m
              memory: 1Gi
        runner:
          serviceAccount: agentrun-v02-runner
          jobNamePrefix: agentrun-v02-runner
          idleTimeoutMs: 172800000
          missingTerminalAfterToolTimeoutMs: 180000
          backendRetry:
            maxAttempts: 5
            initialBackoffMs: 1000
            maxBackoffMs: 30000
          apiKeySecretRef:
            name: agentrun-v02-api-key
            key: HWLAB_API_KEY
          egressProxyUrl: http://sub2api-egress-proxy.platform-infra.svc.cluster.local:10808
          noProxyExtra:
            - sub2api-egress-proxy
            - sub2api-egress-proxy.platform-infra
            - sub2api-egress-proxy.platform-infra.svc
            - sub2api-egress-proxy.platform-infra.svc.cluster.local
          retention:
            maxRunners: 20
            cleanupOrder: oldest-inactive-last-active-first
            activeHeartbeatMaxAgeMs: 900000
            selectors:
              matchLabels:
                app.kubernetes.io/part-of: agentrun
                app.kubernetes.io/name: agentrun-runner
                app.kubernetes.io/component: runner
              jobNamePrefixes:
                - agentrun-v02-runner
                - agentrun-v01-runner
            ageBasedCleanup:
              enabled: false
              maxAgeHours: 48
        localPostgres:
          enabled: false
      gitMirror:
        namespace: devops-infra
        readService: git-mirror-http
        readDeployment: git-mirror-http
        writeService: git-mirror-write
        writeDeployment: git-mirror-write
        readUrl: http://git-mirror-http.devops-infra.svc.cluster.local:8080/pikasTech/agentrun.git
        writeUrl: http://git-mirror-write.devops-infra.svc.cluster.local:8080/pikasTech/agentrun.git
        cachePvc: hwlab-git-mirror-cache
        cacheHostPath: /var/lib/rancher/k3s/storage/hwlab-d601-v03-git-mirror-cache
        sshSecretName: git-mirror-github-ssh
        githubProxy:
          host: sub2api-egress-proxy.platform-infra.svc.cluster.local
          port: 10808
        toolsImage: 127.0.0.1:5000/hwlab/hwlab-ci-node-tools:node22-alpine-bun-v1
        syncJobPrefix: git-mirror-agentrun-d601-v02-sync-manual
        flushJobPrefix: git-mirror-agentrun-d601-v02-flush-manual
        repositories:
          - key: agentrun
            repository: pikasTech/agentrun
            sourceBranch: v0.2
            gitopsBranch: v0.2-gitops
          - key: unidesk
            repository: pikasTech/unidesk
            sourceBranch: master
          - key: agent_skills
            repository: pikasTech/agent_skills
            sourceBranch: master
      database:
        mode: external-postgres
        provider: PK01
        configRef: config/platform-db/postgres-pk01.yaml
        database: agentrun_v02
        user: agentrun_v02
        sslmode: require
        secretSourceRef: agentrun/d601-v02-mgr-db.env
        secretRef:
          name: agentrun-v02-mgr-db
          key: DATABASE_URL
        localPostgresExpectedAbsent: true
      secrets:
        - id: manager-api-key
          sourceRef: /root/.config/hwlab-v03/master-server-admin-api-key.env
          sourceKey: HWLAB_API_KEY
          targetRef:
            namespace: agentrun-v02
            name: agentrun-v02-api-key
            key: HWLAB_API_KEY
        - id: runner-api-key-legacy-name
          sourceRef: /root/.config/hwlab-v03/master-server-admin-api-key.env
          sourceKey: HWLAB_API_KEY
          targetRef:
            namespace: agentrun-v02
            name: agentrun-v01-api-key
            key: HWLAB_API_KEY
        - id: provider-codex-auth-json
          sourceMode: file
          sourceRef: /root/.codex/auth.json
          targetRef:
            namespace: agentrun-v02
            name: agentrun-v01-provider-codex
            key: auth.json
          providerCredential:
            profile: codex
        - id: provider-codex-config
          sourceMode: file
          sourceRef: agentrun/d601-v02-provider-codex-config.toml
          targetRef:
            namespace: agentrun-v02
            name: agentrun-v01-provider-codex
            key: config.toml
          providerCredential:
            profile: codex
        - id: provider-deepseek-auth-json
          sourceMode: file
          sourceRef: /root/.codex-deepseek-v4-pro/auth.json
          targetRef:
            namespace: agentrun-v02
            name: agentrun-v01-provider-deepseek
            key: auth.json
          providerCredential:
            profile: deepseek
        - id: provider-deepseek-config
          sourceMode: file
          sourceRef: agentrun/d601-v02-provider-deepseek-config.toml
          targetRef:
            namespace: agentrun-v02
            name: agentrun-v01-provider-deepseek
            key: config.toml
          providerCredential:
            profile: deepseek
        - id: provider-dsflash-go-auth-json
          sourceMode: file
          sourceRef: /root/.codex-opencode-go-all/auth.json
          targetRef:
            namespace: agentrun-v02
            name: agentrun-v01-provider-dsflash-go
            key: auth.json
          providerCredential:
            profile: dsflash-go
        - id: provider-dsflash-go-config
          sourceMode: file
          sourceRef: agentrun/d601-v02-provider-dsflash-go-config.toml
          targetRef:
            namespace: agentrun-v02
            name: agentrun-v01-provider-dsflash-go
            key: config.toml
          providerCredential:
            profile: dsflash-go
        - id: provider-dsflash-go-model-catalog
          sourceMode: file
          sourceRef: /root/.codex-opencode-go-all/model-catalog.json
          targetRef:
            namespace: agentrun-v02
            name: agentrun-v01-provider-dsflash-go
            key: model-catalog.json
          providerCredential:
            profile: dsflash-go
        - id: tool-github-pr-token
          sourceRef: /root/.config/unidesk/github.env
          sourceKey: GH_TOKEN
          targetRef:
            namespace: agentrun-v02
            name: agentrun-v01-tool-github-pr
            key: GH_TOKEN
        - id: tool-unidesk-ssh-token
          sourceRef: /root/unidesk/.state/docker-compose.env
          sourceKey: UNIDESK_SSH_CLIENT_TOKEN
          targetRef:
            namespace: agentrun-v02
            name: agentrun-v01-tool-unidesk-ssh
            key: UNIDESK_SSH_CLIENT_TOKEN
