version: 1
kind: platform-infra-wechat-archive

metadata:
  id: wechat-baidu-archive
  owner: unidesk
  relatedIssues:
    - 313
    - 326

target:
  id: G14
  route: G14:k3s
  namespace: platform-infra

langbot:
  configRef: config/platform-infra/langbot.yaml
  publicBaseUrl: https://langbot.pikapython.com
  expectedAdapter: openclaw-weixin
  callbackPath: /callback/command
  readOnlyRecord:
    enabled: true
    mode: webhook-skip-pipeline
    webhookName: UniDesk WeChat Archive Read Only
    webhookDescription: Archive LangBot/OpenClaw inbound messages and return skip_pipeline=true so personal WeChat never receives automated replies.
    discardPipelineUuid: __discard__
  pipeline:
    name: UniDesk WeChat Baidu Archive
    description: Forward WeChat/OpenClaw messages to the UniDesk n8n archive workflow.
    runner: n8n-service-api
    outputKey: response
    timeoutSeconds: 120
  notes:
    - LangBot receives WeChat/OpenClaw messages and forwards archive events to the n8n workflow webhook.
    - Credentials for real WeChat channels are bound in LangBot runtime and are not stored in this YAML.

n8n:
  configRef: config/platform-infra/n8n.yaml
  publicBaseUrl: https://n8n.pikapython.com
  workflow:
    name: UniDesk WeChat Baidu Archive
    id: unidesk-wechat-baidu-archive
    webhookPath: unidesk-wechat-baidu-archive
    active: true
    timezone: Asia/Shanghai

archiveCallback:
  publicUrl: http://74.48.78.17:18081/webhooks/wechat-archive
  secretRoot: /root/unidesk/.state/secrets
  tokenSourceRef: platform-infra/wechat-archive.env
  tokenKey: UNIDESK_WECHAT_ARCHIVE_TOKEN
  timeoutMs: 90000

personalWechatIngress:
  enabled: true
  mode: d601-windows-wcf-host-with-k3s-collector
  target:
    id: D601
    windowsRoute: D601:win
    hostRoute: D601
    kubeRoute: D601:k3s
  pcWechat:
    isolation: dedicated-install
    requiredVersion: 3.9.12.51
    installerAsset: WeChatSetup-3.9.12.51.exe
    installMode: silent-nsis-with-ui-fallback
    installRoot: C:/UniDesk/personal-wechat/wechat-3.9.12.51
    dataRoot: C:/UniDesk/personal-wechat/data/profile
    autoUpdatePolicy: disabled
  wcfHost:
    releaseTag: v39.5.2
    requiredWechatVersion: 3.9.12.51
    releaseUrl: https://github.com/lich0821/WeChatFerry/releases/tag/v39.5.2
    sdkRoot: C:/UniDesk/personal-wechat/wcf/v39.5.2
    stateRoot: C:/UniDesk/personal-wechat/wcf-state
    commandPort: 10086
    messagePort: 10087
    bindHost: 0.0.0.0
    supervisor: windows-task-scheduler-user-session
    rdpPolicy: disconnect-not-logout
    firewall:
      publicExposure: false
      allowedClientRefs:
        - windows-loopback
        - d601-wsl
        - d601-k3s-platform-infra
  collector:
    runtime: d601-k3s
    namespace: platform-infra
    createNamespace: false
    workload:
      kind: Deployment
      name: personal-wechat-collector
      serviceAccountName: personal-wechat-collector
      # Paused after the 2026-06-13 login probe: WeChat 3.9.12.51 is rejected as too old.
      replicas: 0
      containerName: personal-wechat-collector
    storage:
      kind: PersistentVolumeClaim
      name: personal-wechat-collector-state
      mountPath: /var/lib/unidesk/personal-wechat
      size: 1Gi
      create: true
    image:
      repository: 127.0.0.1:5000/platform-infra/personal-wechat-collector
      tag: wcferry-39.5.2.0
      pullPolicy: IfNotPresent
      context: src/components/platform-infra/personal-wechat-collector
      dockerfile: src/components/platform-infra/personal-wechat-collector/Dockerfile
      wcferryVersion: 39.5.2.0
      pip:
        indexUrl: http://mirrors.aliyun.com/pypi/simple/
        trustedHost: mirrors.aliyun.com
        timeoutSeconds: 120
        retries: 8
    wcfHost: 172.26.16.1
    commandPort: 10086
    messagePort: 10087
    stateRoot: /var/lib/unidesk/personal-wechat
    queueMode: sqlite-wal
    outboxMode: archive-callback
    archiveCallbackRef: archiveCallback
    secretName: personal-wechat-collector-secrets
    readOnly:
      enabled: true
      sendCapability: false
      allowedMethods:
        - is_login
        - get_self_wxid
        - enable_receiving_msg
        - get_msg
        - download_attach
        - decrypt_image
      forbiddenMethods:
        - send_text
        - send_image
        - send_file
        - send_xml
        - send_emotion
        - send_rich_text
        - send_pat_msg
        - forward_msg
        - accept_friend
        - add_room_members
        - del_room_members
        - invite_room_members
        - exec_db_query
        - refresh_pyq
        - receive_transfer
  poc:
    accountPolicy: test-account-first
    observationWindowHours: 48
    requiredMessageTypes:
      - text
      - image
      - file

baiduNetdisk:
  serviceId: baidu-netdisk
  proxyMode: backend-core-microservice-proxy
  configRef: config.json#microservices.baidu-netdisk
  staging:
    hostRoot: /root/unidesk/.state/baidu-netdisk/staging
    containerRoot: /data/staging
    outboxDir: wechat-archive/outbox
    pullDir: wechat-archive/pulls
  archive:
    remoteRoot: /UniDesk/WeChatArchive
    timezone: Asia/Shanghai
    textExtension: txt
    imageExtension: png
    pathTemplate: "{{remoteRoot}}/{{date}}/{{conversationId}}/{{messageId}}.{{extension}}"
    maxInlineBytes: 10485760

messageTypes:
  text:
    enabled: true
    contentField: text
    mediaMode: none
  image:
    enabled: true
    contentField: media.dataBase64
    mediaMode: base64
    filenameField: media.filename
    mimeTypeField: media.mimeType

validate:
  timeoutMs: 120000
  pollIntervalMs: 1000
  fixtures:
    text:
      conversationId: unidesk-validate
      senderId: cli-smoke
      text: UniDesk WeChat archive validation text fixture.
    image:
      conversationId: unidesk-validate
      senderId: cli-smoke
      filename: pixel.png
      mimeType: image/png
      dataBase64: iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+/p9sAAAAASUVORK5CYII=
