opencode-collaboration 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -27,7 +27,7 @@ Run several opencode terminals in parallel (different repos, worktrees, or tasks
27
27
  - **Explicit TUI controls**: palette actions use host dialogs for selection and confirmation; slash wrappers remain available for automation and compatibility
28
28
  - Local only: everything stays on your machine (Unix-domain sockets on macOS/Linux, loopback TCP on Windows, plus a compatibility loopback listener for v1 peers)
29
29
  - The peer name is appended to this process's root session titles, so every opencode window shows who it is at a glance
30
- - Peer-triggered turns run under the receiving session's selected agent/mode (e.g. a custom `teacher`) instead of opencode's default `build`, so that agent's model, tools and permission rules apply. The mode is taken from the session's last human input (message or command) and its server-persisted agent; if none is known yet, the default agent is used
30
+ - Peer-triggered turns run under the receiving session's selected agent/mode (e.g. a custom `teacher`) instead of opencode's default `build`, so that agent's model, tools and permission rules apply. The mode is the agent recorded server-side at session creation and by prompts (messages/commands); if none is known yet, the default agent is used. If the recorded agent is later removed, the next peer message falls back to the default agent
31
31
 
32
32
  ## Install
33
33
 
package/README.zh-CN.md CHANGED
@@ -27,7 +27,7 @@
27
27
  - **明确的 TUI 控制**:面板操作使用宿主对话框进行选择确认;斜杠命令封装仍可用于自动化和兼容性场景
28
28
  - 纯本地运行:一切都在你的机器上(macOS/Linux 使用 Unix 域套接字,Windows 使用回环 TCP,另有一个兼容 v1 对端的回环监听器)
29
29
  - 本进程的 peer 名字会追加到根会话标题后面,一眼就能看出每个 opencode 窗口是谁
30
- - peer 触发的回合会沿用接收方会话当前选中的 agent/模式(如自定义的 `teacher`),而不是 opencode 默认的 `build`,因此该 agent 的模型、工具与权限规则都会生效。模式取自该会话最近一条人类输入(消息或命令)及其服务端持久化的 agent;若尚无所知则使用默认 agent
30
+ - peer 触发的回合会沿用接收方会话当前选中的 agent/模式(如自定义的 `teacher`),而不是 opencode 默认的 `build`,因此该 agent 的模型、工具与权限规则都会生效。模式取自服务端记录的 agent(会话创建时写入,并随消息/命令的 prompt 更新);若尚无所知则使用默认 agent。若记录的 agent 之后被删除,下一条 peer 消息会回退到默认 agent
31
31
 
32
32
  ## 安装
33
33
 
package/dist/delivery.js CHANGED
@@ -89,18 +89,21 @@ export function Delivery(opts) {
89
89
  }));
90
90
  assertPromptSucceeded(result);
91
91
  }
92
- function isAgentNotFoundError(err) {
93
- const source = err;
94
- const text = [
95
- err instanceof Error ? err.message : String(err),
96
- source?.data?.message,
97
- source?.responseBody,
98
- source?.body,
99
- ]
100
- .filter((value) => typeof value === "string" && value.length > 0)
101
- .join(" ")
102
- .toLowerCase();
103
- return text.includes("agent not found");
92
+ async function agentStillExists(agent) {
93
+ // opencode reports an unknown agent as a generic 500 whose body has no
94
+ // "Agent not found" text, so decide by asking the server for the live list.
95
+ // If the list is unavailable, assume the agent is fine and let the caller
96
+ // requeue as before (only a definite miss triggers the downgrade).
97
+ try {
98
+ const response = await opts.client.app.agents();
99
+ const agents = response.data;
100
+ if (!Array.isArray(agents))
101
+ return true;
102
+ return agents.some((entry) => entry?.name === agent);
103
+ }
104
+ catch {
105
+ return true;
106
+ }
104
107
  }
105
108
  async function inject(sessionId, text, message) {
106
109
  const messageID = message ? deterministicPeerMessageId(sessionId, message) : undefined;
@@ -129,9 +132,10 @@ export function Delivery(opts) {
129
132
  await sendPrompt(sessionId, buildBody(agent));
130
133
  }
131
134
  catch (err) {
132
- // The recorded agent no longer exists (e.g. removed from config). Drop it
133
- // and retry once under opencode's default agent instead of requeue-looping.
134
- if (!agent || !isAgentNotFoundError(err))
135
+ // The recorded agent may no longer exist (removed from config). Verify
136
+ // against the live agent list, and only then drop the record and retry
137
+ // once under opencode's default agent instead of requeue-looping.
138
+ if (!agent || (await agentStillExists(agent)))
135
139
  throw err;
136
140
  opts.onAgentRejected?.();
137
141
  await sendPrompt(sessionId, buildBody(undefined));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-collaboration",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Cross-session messaging for opencode — let independent sessions discover and text each other, modeled after Claude Code's cross-session messaging",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",