Asosiy tarkibga o'tish

boshqa kontekstlardan qayta foydalanish (mahalliy skriptlar, kelajakdagi desktop ilova va h.k.)

OpenClaw runs shell commands through the exec tool and keeps long‑running tasks in memory. The process tool manages those background sessions.

exec tool

Key parameters:
  • command (required)
  • yieldMs (default 10000): auto‑background after this delay
  • background (bool): background immediately
  • timeout (seconds, default 1800): kill the process after this timeout
  • elevated (bool): run on host if elevated mode is enabled/allowed
  • Fon ijrosi + Jarayon asbobi Set pty: true.
  • Haqiqiy TTY kerakmi?
Behavior:
  • Foreground runs return output directly.
  • When backgrounded (explicit or timeout), the tool returns status: "running" + sessionId and a short tail.
  • Output is kept in memory until the session is polled or cleared.
  • If the process tool is disallowed, exec runs synchronously and ignores yieldMs/background.

Child process bridging

When spawning long-running child processes outside the exec/process tools (for example, CLI respawns or gateway helpers), attach the child-process bridge helper so termination signals are forwarded and listeners are detached on exit/error. This avoids orphaned processes on systemd and keeps shutdown behavior consistent across platforms. Environment overrides:
  • PI_BASH_YIELD_MS: default yield (ms)
  • PI_BASH_MAX_OUTPUT_CHARS: in‑memory output cap (chars)
  • OPENCLAW_BASH_PENDING_MAX_OUTPUT_CHARS: pending stdout/stderr cap per stream (chars)
    1. PI_BASH_JOB_TTL_MS: yakunlangan sessiyalar uchun TTL (ms, 1 daqiqa–3 soat oralig‘ida cheklangan)
  1. Konfiguratsiya (tavsiya etiladi):
    1. tools.exec.backgroundMs (standart 10000)
    1. tools.exec.timeoutSec (standart 1800)
    1. tools.exec.cleanupMs (standart 1800000)
    1. tools.exec.notifyOnExit (standart true): fon rejimidagi exec yakunlanganda tizim hodisasini navbatga qo‘shadi va heartbeat so‘raydi.
  • tools.exec.notifyOnExitEmptySuccess (standart false): true bo‘lganda, hech qanday chiqish bermagan muvaffaqiyatli background rejimdagi ishga tushirishlar uchun ham yakunlanish hodisalarini navbatga qo‘shadi.

7. process vositasi

  1. Amallar:
    1. list: ishlayotgan + yakunlangan sessiyalar
    1. poll: sessiya uchun yangi chiqishni chiqarib tashlash (shuningdek chiqish holatini bildiradi)
    1. log: yig‘ilgan chiqishni o‘qish (offset + limit qo‘llab-quvvatlanadi)
    1. write: stdin yuborish (data, ixtiyoriy eof)
    1. kill: fon sessiyasini to‘xtatish
    1. clear: yakunlangan sessiyani xotiradan olib tashlash
    1. remove: agar ishlayotgan bo‘lsa o‘ldiradi, aks holda yakunlangan bo‘lsa tozalaydi
  1. Eslatmalar:
    1. Faqat fon rejimidagi sessiyalar ro‘yxatga olinadi va xotirada saqlanadi.
    1. Jarayon qayta ishga tushirilganda sessiyalar yo‘qoladi (diskda saqlanmaydi).
    1. Sessiya jurnallari faqat process poll/log ishga tushirilganda va vosita natijasi yozib olinganda chat tarixiga saqlanadi.
    1. process agent bo‘yicha cheklangan; u faqat shu agent boshlagan sessiyalarni ko‘radi.
    1. process list tez ko‘zdan kechirish uchun hosila name (buyruq fe’li + maqsad) ni o‘z ichiga oladi.
  • process log qatorga asoslangan offset/limit dan foydalanadi.
  • offset va limit ikkalasi ham ko‘rsatilmasa, oxirgi 200 qatorni qaytaradi va sahifalash bo‘yicha ko‘rsatma qo‘shadi.
  • offset ko‘rsatilgan va limit ko‘rsatilmagan bo‘lsa, offset dan oxirigacha qaytaradi (200 bilan cheklanmaydi).

23. Misollar

  1. Uzoq vazifani ishga tushiring va keyinroq so‘rov qiling:
25. { "tool": "exec", "command": "sleep 5 && echo done", "yieldMs": 1000 }
26. { "tool": "process", "action": "poll", "sessionId": "<id>" }
  1. Darhol fon rejimida boshlash:
28. { "tool": "exec", "command": "npm run build", "background": true }
  1. stdin yuborish:
30. { "tool": "process", "action": "write", "sessionId": "<id>", "data": "y\n" }