Files
ai_orchestrator/docs/contracts/LOCAL_WORKER_PROTOCOL.md
2026-07-03 20:51:36 +03:00

2.6 KiB

Local Worker Protocol

Назначение

Local Worker — тонкий исполнитель команд на локальном компьютере.

Он не планирует задачу и не принимает интеллектуальных решений.

Он:

- подключается к серверу;
- сообщает capabilities;
- получает команды;
- выполняет;
- возвращает статус, результат, ошибки, артефакты.

Соединение

Предпочтительно:

Local Worker → outbound WebSocket → Server

Capabilities

Пример:

{
  "worker_id": "home_pc",
  "machine": "DESKTOP-1",
  "os": "windows",
  "version": "0.1.0",
  "capabilities": [
    "file.read",
    "file.write",
    "file.search",
    "file.apply_patch",
    "command.run",
    "process.status",
    "task.cancel"
  ]
}

Command envelope

{
  "command_id": "cmd_123",
  "task_id": "task_456",
  "tool": "file.read",
  "args": {
    "path": "D:/Projects/test.bsl"
  },
  "timeout_ms": 30000,
  "policy_context": {
    "approved": true,
    "approval_id": "conf_1"
  }
}

Result envelope

{
  "command_id": "cmd_123",
  "task_id": "task_456",
  "tool": "file.read",
  "status": "success",
  "started_at": "2026-07-03T10:00:00Z",
  "finished_at": "2026-07-03T10:00:01Z",
  "duration_ms": 1000,
  "stdout": "",
  "stderr": "",
  "result": {
    "content": "...",
    "encoding": "utf-8",
    "size": 1024,
    "sha256": "..."
  },
  "artifacts": [],
  "error": null
}

Error result

{
  "command_id": "cmd_123",
  "status": "error",
  "error": {
    "code": "FILE_NOT_FOUND",
    "message": "File not found",
    "details": {
      "path": "D:/Projects/test.bsl"
    }
  }
}

Progress events

{
  "event": "progress",
  "command_id": "cmd_123",
  "progress": {
    "percent": 45,
    "message": "Searching files"
  }
}

Минимальный набор tools

worker.ping
worker.capabilities
file.read
file.write
file.search
file.apply_patch
command.run
process.status
task.cancel

Важное правило

Local Worker не должен сам вызывать модель и не должен сам решать следующий шаг.

Он может выполнять локальные проверки:

- проверить существование файла;
- сделать backup;
- посчитать hash;
- применить patch;
- вернуть diff;
- выполнить command timeout;
- вернуть stdout/stderr.