{"_id":"@buckeyestudio/toh-sdk-protocol","name":"@buckeyestudio/toh-sdk-protocol","dist-tags":{"next":"0.1.1-rc.2","latest":"0.1.1-rc.2"},"versions":{"0.1.1-rc.2":{"name":"@buckeyestudio/toh-sdk-protocol","description":"Shared wire protocol for the TheOpen Harness SDK runtime: the newline-delimited JSON-RPC stdio transport and the named request, result, and notification types spoken between the runtime server and SDK clients","version":"0.1.1-rc.2","publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/dustinwloring1988/theopen-harness.git","directory":"packages/sdk/protocol"},"type":"module","main":"lib/index.js","types":"lib/types/index.d.ts","exports":{".":{"types":"./lib/types/index.d.ts","default":"./lib/index.js"},"./invariant":{"types":"./lib/types/invariant.d.ts","default":"./lib/invariant.js"},"./package.json":"./package.json"},"license":"MIT","author":{"name":"buckeyestudio"},"peerDependencies":{"@buckeyestudio/toh-invariants":"^0.1.1-rc.2","@buckeyestudio/toh-llm":"^0.1.1-rc.2","@buckeyestudio/cordis":"^4.0.1","@buckeyestudio/toh-subagent":"^0.1.1-rc.2","@buckeyestudio/toh-session":"^0.1.1-rc.2"},"devDependencies":{"@buckeyestudio/toh-invariants":"^0.1.1-rc.2","@buckeyestudio/toh-llm":"^0.1.1-rc.2","@buckeyestudio/toh-subagent":"^0.1.1-rc.2","@buckeyestudio/cordis":"^4.0.1","@buckeyestudio/toh-session":"^0.1.1-rc.2"},"_id":"@buckeyestudio/toh-sdk-protocol@0.1.1-rc.2","bugs":{"url":"https://github.com/dustinwloring1988/theopen-harness/issues"},"homepage":"https://github.com/dustinwloring1988/theopen-harness#readme","_integrity":"sha512-pRagu3M3cxNOS7CSZqib6zV1VBtC3ipjELVerCQBkpDPPMs7LNdEYON7NSFrc76sAQUQpL9oQJkUZBoHidj8ag==","_resolved":"/home/runner/work/theopen-harness/theopen-harness/dist/npm/buckeyestudio-toh-sdk-protocol-0.1.1-rc.2.tgz","_from":"file:/home/runner/work/theopen-harness/theopen-harness/dist/npm/buckeyestudio-toh-sdk-protocol-0.1.1-rc.2.tgz","_nodeVersion":"24.19.0","_npmVersion":"11.17.0","dist":{"integrity":"sha512-pRagu3M3cxNOS7CSZqib6zV1VBtC3ipjELVerCQBkpDPPMs7LNdEYON7NSFrc76sAQUQpL9oQJkUZBoHidj8ag==","shasum":"a58cfe8c4f152ac200cd02f765b5af3733139617","tarball":"https://registry.npmjs.org/@buckeyestudio/toh-sdk-protocol/-/toh-sdk-protocol-0.1.1-rc.2.tgz","fileCount":11,"unpackedSize":29882,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCaesclNCxi1YfKY2jLmLFoa3vcwUNK8tcvGD/f8k1AqAIgY8Bzhmgb34kbr5K9DIom4HvC7a/RfTpJgfIKfytug0o="}]},"_npmUser":{"name":"buckeyestudio","email":"dustinwloring1988@gmail.com"},"directories":{},"maintainers":[{"name":"buckeyestudio","email":"dustinwloring1988@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/toh-sdk-protocol_0.1.1-rc.2_1787489821966_0.9081882650129887"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-23T12:57:01.763Z","0.1.1-rc.2":"2026-08-23T12:57:02.107Z","modified":"2026-08-23T12:57:02.405Z"},"maintainers":[{"name":"buckeyestudio","email":"dustinwloring1988@gmail.com"}],"description":"Shared wire protocol for the TheOpen Harness SDK runtime: the newline-delimited JSON-RPC stdio transport and the named request, result, and notification types spoken between the runtime server and SDK clients","homepage":"https://github.com/dustinwloring1988/theopen-harness#readme","repository":{"type":"git","url":"git+https://github.com/dustinwloring1988/theopen-harness.git","directory":"packages/sdk/protocol"},"author":{"name":"buckeyestudio"},"bugs":{"url":"https://github.com/dustinwloring1988/theopen-harness/issues"},"license":"MIT","readme":"# @buckeyestudio/toh-sdk-protocol\n\n[English](README.md) | 中文\n\nTheOpen Harness SDK 运行时的共享协议格式（wire format）：一个按换行分帧的 JSON-RPC 2.0 传输类，加上协议两端共同使用的具名请求、结果与通知类型。包根枚举协议消费方接口；源模块不支持深层导入。服务端是 [`toh-sdk-jsonrpc-server`](../server/README.zh.md) 插件；客户端是 [`toh-sdk-client`](../client/README.zh.md)（TypeScript）与 [Python SDK](../../../python/README.zh.md)（后者复现这些结构但不导入它们）。纯库——无插件、无 Config、无注册。\n\n## 传输\n\n`JsonRpcLineTransport` 在调用方持有的字节流上为 JSON-RPC 2.0 分帧，每行一个紧凑 JSON 帧、以 `\\n` 结尾。带 `id` 与 `method` 的帧是请求，仅 `id` 是响应，仅 `method` 是通知；非法 JSON 行被忽略。`start()` 挂接流监听器，`close()` 移除监听器并拒绝挂起请求，但不销毁流。缺失请求处理器时应答 `-32601`；处理器返回的 Promise 被拒绝时，则应答携带错误消息的 `-32603`。错误响应会以 `JsonRpcResponseError` 拒绝挂起的 `request()` Promise，并保留协议格式中的 `code` 与可选 `data`。`JsonRpcTransportPeer` 是服务器类据以进行类型声明的出站接口（request/notify）。\n\n## 协议类型\n\n`types.ts` 为 `HarnessSdkJsonRpcServer` 所服务协议的每个载荷命名：\n\n| 方向 | 方法 | 类型 |\n|---|---|---|\n| client→server | `initialize` | `InitializeParams` → `InitializeResult` |\n| client→server | `session/prompt` | `SessionPromptParams` → `SessionPromptResult`（持久入队回执） |\n| client→server | `shutdown` | 无参数 → `{}` |\n| server→client | `session.event` | `SessionEventNotification`（运行时内每个会话，不过滤） |\n| server→client | `session.status` | `SessionStatusNotification`（整个 agent（智能体）的 `running`/`idle` 转换） |\n| server→client | `subagent.started` | `SubagentStartedNotification` |\n| server→client | `subagent.finished` | `SubagentFinishedNotification`（仅进程内运行） |\n\n`HarnessSdkRequestMap` 与 `HarnessSdkNotificationMap` 按方法名索引这些类型。`SessionPromptResult.messageId` 标识已排队的 `UserMessage`；它不标识后续的助手消息、轮次结束或提示词结果。客户端根据自己对活动区间的所有权，组合持续开放的 `session.event` 流与 agent 级的 `session.status`。`SubagentFinishedNotification.lastAssistantMessage` 包含子 agent 最后一条非空 assistant 消息；若不存在这类消息，则包含其累积的 assistant 文本；子 agent 两种输出均未产生时，该字段缺省。`InitializeParams.maxTokens` 是可选的正的安全整数，用于限制 SDK 创建的 agent 及其进程内后代的每次对话模型输出；省略时会应用所选适配器的确切模型默认值，否则提供方行为保持不变。通知载荷类型依赖 `SessionEvent`（`toh-session`）、`ContentBlock`（`toh-llm`）与 `SubagentStopReason`（`toh-subagent`）——协议以完整会话日志封套进行流式传输，因此会话词汇是协议格式约定的一部分。`serverInfo.name` 的协议值固定为 `theopen-harness-sdk-runtime`。\n\n## 模型体验\n\n无，因为此包定义面向客户端的协议格式；模型可见接口属于组合在对外服务入口 [`toh-sdk-jsonrpc-server`](../server/README.zh.md) 后方的运行时插件。\n\n#### KV Cache 影响\n\n无；此包既不组装也不发送提供方请求。\n\n## 已知限制与暂缓事项\n\n- **无协议版本协商**——握手只携带 `serverInfo.version`（`0.0.1`，客户端不校验）；处于预发布阶段，无兼容承诺。\n- **无取消与会话关闭方法**——客户端放弃轮次的方式是关闭运行时进程；见 [`toh-sdk-jsonrpc-server` README](../server/README.zh.md)。\n- **server→client 请求是未使用的功能**——传输层支持，但服务器从不发送；Python SDK 的应答接口为未来审批流程预留。\n","readmeFilename":"README.zh.md","_rev":"1-ff1f31f1cbafe4df008c9fa493f61c21"}