{"id":50942153,"url":"https://github.com/openclaw/libterminal","last_synced_at":"2026-06-17T16:01:47.965Z","repository":{"id":365398947,"uuid":"1271827230","full_name":"openclaw/libterminal","owner":"openclaw","description":"Shared TypeScript terminal protocol, streaming, browser, Node, and Worker primitives.","archived":false,"fork":false,"pushed_at":"2026-06-17T06:48:08.000Z","size":174,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-17T08:09:41.042Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/openclaw.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null},"funding":{"github":["moltbot"]}},"created_at":"2026-06-17T03:39:30.000Z","updated_at":"2026-06-17T06:46:07.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/openclaw/libterminal","commit_stats":null,"previous_names":["openclaw/libterminal"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/openclaw/libterminal","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openclaw%2Flibterminal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openclaw%2Flibterminal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openclaw%2Flibterminal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openclaw%2Flibterminal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/openclaw","download_url":"https://codeload.github.com/openclaw/libterminal/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openclaw%2Flibterminal/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34453446,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-17T02:00:05.408Z","response_time":127,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-17T16:01:01.767Z","updated_at":"2026-06-17T16:01:47.960Z","avatar_url":"https://github.com/openclaw.png","language":"Python","funding_links":["https://github.com/sponsors/moltbot"],"categories":[],"sub_categories":[],"readme":"# @openclaw/libterminal\n\nShared TypeScript primitives for streaming, rendering, and bridging terminals\nacross browsers, Node.js, and Cloudflare Workers.\n\n```ts\nimport { BoundedReplayBuffer } from \"@openclaw/libterminal/stream\";\nimport { decodeTerminalFrame } from \"@openclaw/libterminal/protocol\";\n```\n\nThe package deliberately does not own authentication, public listeners,\nterminal transcripts, or product-specific room/session state.\n\n## Install\n\n```sh\npnpm add @openclaw/libterminal\n```\n\nInstall `node-pty` in applications that use the Node.js PTY adapter:\n\n```sh\npnpm add node-pty\n```\n\n## Exports\n\n- `@openclaw/libterminal`: universal terminal types and errors\n- `@openclaw/libterminal/protocol`: terminal protocol v2 codecs\n- `@openclaw/libterminal/stream`: bounded replay, fanout, and batching\n- `@openclaw/libterminal/browser`: Ghostty WASM browser terminal integration\n- `@openclaw/libterminal/node`: local PTY, raw stdin, and asset helpers\n- `@openclaw/libterminal/worker`: Worker-compatible WebSocket bridging\n- `@openclaw/libterminal/testing`: deterministic terminal test doubles\n\n## Browser\n\nGhostty terminals default to read-only. The application owns authorization,\nthe byte source, and the WASM asset route.\n\n```ts\nimport { createGhosttyTerminal } from \"@openclaw/libterminal/browser\";\n\nconst terminal = await createGhosttyTerminal({\n  parent: document.querySelector(\"#terminal\")!,\n  runtimeOptions: { wasmUrl: \"/vendor/ghostty-vt.wasm\" },\n  signal: controller.signal,\n});\n\nawait terminal.attach(output);\n```\n\nUse `GHOSTTY_ASSET_PATHS` and `readGhosttyAsset()` from the Node.js export to\nserve the pinned `ghostty-web` module, WASM, and browser-external shim under\ntheir canonical `/vendor` routes.\n\n## Node.js\n\nThe built-in adapter dynamically imports the optional `node-pty` peer. Inject a\ncompatible driver in tests or applications that own their PTY runtime.\n\n```ts\nimport { attachLocalStdio, spawnLocalPty } from \"@openclaw/libterminal/node\";\n\nconst terminal = await spawnLocalPty({\n  command: \"codex\",\n  args: [\"--yolo\"],\n  cwd: process.cwd(),\n});\n\nawait attachLocalStdio(terminal);\n```\n\nPTY output queues are bounded by default. Raw stdin mode is restored when the\nsession ends, errors, or aborts.\n\n## Workers\n\nThe Worker bridge forwards both directions in order and can revalidate control\nbefore every left-to-right message and on a periodic fail-closed timer.\n\n```ts\nimport { bridgeWebSockets } from \"@openclaw/libterminal/worker\";\n\nconst bridge = bridgeWebSockets(viewer, terminal, {\n  canSendLeft: async () =\u003e capabilities.canControl(sessionId),\n  sanitizeCloseReason: redactCredentials,\n});\n\nawait bridge.completed;\n```\n\nThe product remains responsible for authenticating both sockets and deciding\nwhich capabilities grant control.\n\n## Protocol\n\n`@openclaw/libterminal/protocol` owns terminal protocol v2 codecs and golden\nvectors. Strict decoders throw `LibterminalError`; `tryDecodeTerminalFrame()`\nis available for nullable migration paths.\n\nSubscribe payloads may use zero columns and rows together to ask the terminal\nservice to select default dimensions. Resize payloads always require real\ndimensions.\n\nWire-protocol versions and npm package versions are independent compatibility\nsurfaces.\n\n## Safety\n\n- Terminal bytes are never logged or persisted by the package.\n- Browser terminals default to read-only.\n- Replay, subscriber, and PTY output buffers are bounded.\n- Protocol frames and terminal dimensions are validated.\n- Authorization, public listeners, storage, and transcripts stay in consumers.\n\n## Development\n\n```sh\npnpm install\npnpm check\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenclaw%2Flibterminal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenclaw%2Flibterminal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenclaw%2Flibterminal/lists"}