@cotal-ai/connector-opencode 0.11.3 → 0.11.4
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/dist/index.js +604 -2
- package/dist/plugin.bundle.js +390 -97
- package/dist/plugin.d.ts.map +1 -1
- package/dist/serve.js +145 -208
- package/dist/tools.d.ts +2 -3
- package/dist/tools.d.ts.map +1 -1
- package/package.json +5 -7
- package/dist/extension.js +0 -231
- package/dist/extension.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/plugin.js +0 -501
- package/dist/plugin.js.map +0 -1
- package/dist/serve.js.map +0 -1
- package/dist/tools.js +0 -42
- package/dist/tools.js.map +0 -1
- package/dist/transcript.js +0 -107
- package/dist/transcript.js.map +0 -1
package/dist/plugin.js
DELETED
|
@@ -1,501 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The Cotal OpenCode plugin — loaded in-process by `opencode serve` (via the inline config the
|
|
3
|
-
* connector sets). The serve shim attaches a foreground `opencode` TUI to the session this plugin
|
|
4
|
-
* owns, so the human watches (and can type into) the exact session the agent drives. It turns the
|
|
5
|
-
* session into a first-class mesh peer, at parity with the Claude Code connector:
|
|
6
|
-
*
|
|
7
|
-
* • holds the {@link MeshAgent} (NATS endpoint, inbox, presence) for the server's lifetime;
|
|
8
|
-
* • registers the cotal_* tools natively, rendered from the SHARED {@link cotalToolSpecs}
|
|
9
|
-
* (`./tools.ts`) — same surface as Claude Code, incl. channels / join / leave / channel_info;
|
|
10
|
-
* • maps OpenCode bus events to presence (idle | working | waiting | offline);
|
|
11
|
-
* • owns ONE session (created at boot) and drives it: it injects each inbox batch as a turn through
|
|
12
|
-
* the authenticated OpenCode server HTTP API (the same server the TUI is attached to), acking ON
|
|
13
|
-
* TURN COMPLETION (so a crash/error redelivers). Pending peer messages are also injected into
|
|
14
|
-
* the next native prompt creation when a human/API prompt starts in the attached session.
|
|
15
|
-
* Delivery is **attention-aware** (open/dnd/focus) and never interrupts a running turn.
|
|
16
|
-
*
|
|
17
|
-
* Identity comes from COTAL_* env (the plugin runs in the opencode process and inherits it).
|
|
18
|
-
* No identity → inert, so an operator's own `opencode` never joins as a stray peer.
|
|
19
|
-
*/
|
|
20
|
-
import { loadAgentFile } from "@cotal-ai/core";
|
|
21
|
-
import { configFromEnv, hasIdentity, MeshAgent, startControlServer, formatInjection, fmtFrom, ORIENTATION_BOOTSTRAP, transcriptChannel, } from "@cotal-ai/connector-core";
|
|
22
|
-
import { buildCotalTools } from "./tools.js";
|
|
23
|
-
import { createTranscriptMirror } from "./transcript.js";
|
|
24
|
-
function log(msg) {
|
|
25
|
-
process.stderr.write(`[cotal-connector] ${msg}\n`);
|
|
26
|
-
}
|
|
27
|
-
/** Process-global guard: opencode loads the plugin once per app/worktree scope, so the function
|
|
28
|
-
* can run more than once in a single process. We want exactly one mesh endpoint — so the first
|
|
29
|
-
* call wires up the agent, and every call returns the *same* hooks (the same tools, bound to that
|
|
30
|
-
* one agent), whichever scope opencode ends up using. */
|
|
31
|
-
const guard = globalThis;
|
|
32
|
-
const ERROR_RETRY_INITIAL_MS = 1_000;
|
|
33
|
-
const ERROR_RETRY_MAX_MS = 30_000;
|
|
34
|
-
const INTERRUPT_INTENT_TTL_MS = 30_000;
|
|
35
|
-
export const cotal = async () => {
|
|
36
|
-
// No identity → a plain `opencode`, not a launcher-spawned agent. Stay inert.
|
|
37
|
-
if (!hasIdentity()) {
|
|
38
|
-
log("no COTAL_NAME — not a managed session; staying off the mesh");
|
|
39
|
-
return {};
|
|
40
|
-
}
|
|
41
|
-
if (guard.__cotalOpencodeHooks)
|
|
42
|
-
return guard.__cotalOpencodeHooks; // one agent; reuse the hooks
|
|
43
|
-
const config = configFromEnv();
|
|
44
|
-
config.connector = "opencode"; // advertise the host harness on our AgentCard (meta.connector)
|
|
45
|
-
const serverUrl = process.env.COTAL_OPENCODE_SERVER_URL?.trim();
|
|
46
|
-
const serverUsername = process.env.OPENCODE_SERVER_USERNAME?.trim() || "opencode";
|
|
47
|
-
const serverPassword = process.env.OPENCODE_SERVER_PASSWORD?.trim();
|
|
48
|
-
if (!serverUrl || !serverPassword)
|
|
49
|
-
throw new Error("opencode connector: missing COTAL_OPENCODE_SERVER_URL/OPENCODE_SERVER_PASSWORD");
|
|
50
|
-
const serverAuth = `Basic ${Buffer.from(`${serverUsername}:${serverPassword}`).toString("base64")}`;
|
|
51
|
-
const agent = new MeshAgent(config);
|
|
52
|
-
agent.start(); // background connect with retry — never blocks startup
|
|
53
|
-
async function opencodeApi(path, init, timeoutMs = 10_000) {
|
|
54
|
-
const res = await fetch(`${serverUrl}${path}`, {
|
|
55
|
-
...init,
|
|
56
|
-
signal: init?.signal ?? AbortSignal.timeout(timeoutMs),
|
|
57
|
-
headers: {
|
|
58
|
-
authorization: serverAuth,
|
|
59
|
-
"content-type": "application/json",
|
|
60
|
-
...(init?.headers ?? {}),
|
|
61
|
-
},
|
|
62
|
-
});
|
|
63
|
-
if (!res.ok)
|
|
64
|
-
throw new Error(`OpenCode HTTP ${res.status} ${res.statusText} for ${path}`);
|
|
65
|
-
if (res.status === 204)
|
|
66
|
-
return undefined;
|
|
67
|
-
return (await res.json());
|
|
68
|
-
}
|
|
69
|
-
const def = process.env.COTAL_AGENT_FILE?.trim() ? loadAgentFile(process.env.COTAL_AGENT_FILE.trim()) : undefined;
|
|
70
|
-
const persona = def?.persona || undefined;
|
|
71
|
-
// This agent OWNS one top-level OpenCode session at a time. The serve shim attaches the foreground
|
|
72
|
-
// TUI to the boot session; if the human runs `/new` in that same TUI/process, OpenCode creates a
|
|
73
|
-
// replacement top-level session. We adopt that as a context reset while keeping the same MeshAgent
|
|
74
|
-
// and creds alive. Used to match our turn-end (idle) vs subagent idles.
|
|
75
|
-
let sessionID;
|
|
76
|
-
let busy = false; // a turn is running (ours via drive(), OR the human's via session.status) → don't
|
|
77
|
-
// prompt: opencode would COALESCE onto it (no reject). Released at EVERY turn end (completeTurn).
|
|
78
|
-
let driving = false; // re-entrancy guard around an in-flight server prompt
|
|
79
|
-
let primed = false; // persona is prepended to the first turn's text once
|
|
80
|
-
let briefed = false; // the boot channel briefing is prepended once, on the first turn
|
|
81
|
-
let surfaced = []; // ids surfaced into the current turn, acked on completion (by id, not count)
|
|
82
|
-
let awaitingTurnEnd = false; // a turn is in flight → ignore a duplicate idle that isn't its end
|
|
83
|
-
let errorRetryTimer;
|
|
84
|
-
let errorRetryMs = ERROR_RETRY_INITIAL_MS;
|
|
85
|
-
let interruptIntent;
|
|
86
|
-
// Transcript mirror → `tr-<name>`: opt-in via COTAL_TRANSCRIPT (the connector's buildLaunch / the
|
|
87
|
-
// manager set it for managed sessions; a personal opencode never mirrors). EVENT-DRIVEN — fed from
|
|
88
|
-
// the OpenCode event hook below (message.updated → assistant roles, message.part.updated → parts)
|
|
89
|
-
// and flushed at session.idle, so it never re-reads the whole session. The manager grants this agent
|
|
90
|
-
// pub rights on the same `tr-<name>` channel.
|
|
91
|
-
const transcript = /^(1|true|yes|on)$/i.test(process.env.COTAL_TRANSCRIPT ?? "")
|
|
92
|
-
? createTranscriptMirror(agent, transcriptChannel(config.name))
|
|
93
|
-
: undefined;
|
|
94
|
-
const safeStatus = async (status, activity) => {
|
|
95
|
-
try {
|
|
96
|
-
if (agent.connected)
|
|
97
|
-
await agent.setStatus(status, activity);
|
|
98
|
-
}
|
|
99
|
-
catch {
|
|
100
|
-
/* presence is best-effort — never throw into opencode */
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
// Cooperative shutdown. The manager sends an authenticated {op:"shutdown"} to this agent's local
|
|
104
|
-
// control endpoint on a signal-less runtime (ConPTY/Windows), where a hard kill would skip cleanup
|
|
105
|
-
// and leave the agent online until its presence TTL expires. We leave the mesh cleanly instead, then
|
|
106
|
-
// exit (the runtime hard-kills as a backstop). The endpoint (path + token) is minted by the
|
|
107
|
-
// connector's buildLaunch and arrives in the child env; the plugin runs inside the opencode server
|
|
108
|
-
// process, so it reads it there. Hooks are in-process (no external relay connects), so only the
|
|
109
|
-
// shutdown op is used — the handle path is inert. fatalBind: a managed agent MUST own its control
|
|
110
|
-
// endpoint, so a squatter (or a runtime that can't host the pipe) fails loud rather than running a
|
|
111
|
-
// hijacked or absent control plane.
|
|
112
|
-
let controlServer;
|
|
113
|
-
const shutdown = async () => {
|
|
114
|
-
try {
|
|
115
|
-
controlServer?.close();
|
|
116
|
-
}
|
|
117
|
-
catch {
|
|
118
|
-
/* ignore */
|
|
119
|
-
}
|
|
120
|
-
try {
|
|
121
|
-
await safeStatus("offline");
|
|
122
|
-
await agent.stop();
|
|
123
|
-
}
|
|
124
|
-
finally {
|
|
125
|
-
process.exit(0);
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
const controlPath = process.env.COTAL_CONTROL_SOCKET?.trim();
|
|
129
|
-
const controlToken = process.env.COTAL_CONTROL_TOKEN?.trim();
|
|
130
|
-
if (controlPath && controlToken) {
|
|
131
|
-
const handle = async () => ({
|
|
132
|
-
ok: false,
|
|
133
|
-
error: "opencode runs cotal hooks in-process; only the shutdown control op is supported",
|
|
134
|
-
});
|
|
135
|
-
controlServer = startControlServer(agent, { path: controlPath, token: controlToken }, handle, {
|
|
136
|
-
fatalBind: true,
|
|
137
|
-
onShutdown: () => void shutdown(),
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
function pendingForWake() {
|
|
141
|
-
return agent.pendingWake(); // mode-and-channel-aware: excludes held dnd/quiet ambient
|
|
142
|
-
}
|
|
143
|
-
function clearErrorRetry(resetDelay = false) {
|
|
144
|
-
if (errorRetryTimer)
|
|
145
|
-
clearTimeout(errorRetryTimer);
|
|
146
|
-
errorRetryTimer = undefined;
|
|
147
|
-
if (resetDelay)
|
|
148
|
-
errorRetryMs = ERROR_RETRY_INITIAL_MS;
|
|
149
|
-
}
|
|
150
|
-
function markInterruptIntent(sessionID) {
|
|
151
|
-
if (!busy && !awaitingTurnEnd)
|
|
152
|
-
return;
|
|
153
|
-
interruptIntent = { sessionID, expires: Date.now() + INTERRUPT_INTENT_TTL_MS };
|
|
154
|
-
}
|
|
155
|
-
function clearInterruptIntent() {
|
|
156
|
-
interruptIntent = undefined;
|
|
157
|
-
}
|
|
158
|
-
function consumeInterruptIntent(sessionID) {
|
|
159
|
-
const intent = interruptIntent;
|
|
160
|
-
interruptIntent = undefined;
|
|
161
|
-
if (!intent || Date.now() > intent.expires)
|
|
162
|
-
return false;
|
|
163
|
-
return !intent.sessionID || !sessionID || intent.sessionID === sessionID;
|
|
164
|
-
}
|
|
165
|
-
function isMessageAbortedError(error) {
|
|
166
|
-
return typeof error === "object" && error !== null && error.name === "MessageAbortedError";
|
|
167
|
-
}
|
|
168
|
-
function scheduleErrorRetry() {
|
|
169
|
-
if (errorRetryTimer || pendingForWake() === 0)
|
|
170
|
-
return;
|
|
171
|
-
const delay = errorRetryMs;
|
|
172
|
-
errorRetryMs = Math.min(errorRetryMs * 2, ERROR_RETRY_MAX_MS);
|
|
173
|
-
errorRetryTimer = setTimeout(() => {
|
|
174
|
-
errorRetryTimer = undefined;
|
|
175
|
-
if (!busy && pendingForWake() > 0)
|
|
176
|
-
void drive();
|
|
177
|
-
}, delay);
|
|
178
|
-
errorRetryTimer.unref?.();
|
|
179
|
-
}
|
|
180
|
-
function adoptSession(id, reason) {
|
|
181
|
-
if (sessionID === id)
|
|
182
|
-
return;
|
|
183
|
-
const previous = sessionID;
|
|
184
|
-
sessionID = id;
|
|
185
|
-
agent.setContextId(id);
|
|
186
|
-
busy = false;
|
|
187
|
-
driving = false;
|
|
188
|
-
primed = false;
|
|
189
|
-
briefed = false;
|
|
190
|
-
surfaced = [];
|
|
191
|
-
awaitingTurnEnd = false;
|
|
192
|
-
clearInterruptIntent();
|
|
193
|
-
clearErrorRetry(true);
|
|
194
|
-
transcript?.reset(); // hard session boundary: drop any buffered parts so `/new` never mirrors them
|
|
195
|
-
if (previous) {
|
|
196
|
-
log(`adopted opencode session ${id} after ${reason}; mesh identity unchanged`);
|
|
197
|
-
if (pendingForWake() > 0)
|
|
198
|
-
void drive();
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
/** Create the session this agent owns and announce its id to the serve shim, which attaches the
|
|
202
|
-
* foreground TUI to it. The handshake line on stderr (`[cotal-session] <id>`) is how the shim
|
|
203
|
-
* learns *which* session to open — by exact id, so a stale same-titled session from a prior run
|
|
204
|
-
* can't be picked. Awaited by ensureSession before the first drive. */
|
|
205
|
-
const sessionReady = (async () => {
|
|
206
|
-
try {
|
|
207
|
-
const res = await opencodeApi("/session", {
|
|
208
|
-
method: "POST",
|
|
209
|
-
body: JSON.stringify({ title: `cotal:${config.space}:${config.name}` }),
|
|
210
|
-
}, 10_000);
|
|
211
|
-
const id = res.id;
|
|
212
|
-
if (id) {
|
|
213
|
-
adoptSession(id, "boot");
|
|
214
|
-
process.stderr.write(`[cotal-session] ${id}\n`);
|
|
215
|
-
}
|
|
216
|
-
else
|
|
217
|
-
log("session.create returned no id");
|
|
218
|
-
}
|
|
219
|
-
catch (e) {
|
|
220
|
-
log(`session.create failed: ${e.message}`);
|
|
221
|
-
}
|
|
222
|
-
return sessionID;
|
|
223
|
-
})();
|
|
224
|
-
/** The session to drive — the one we created and the TUI is attached to. */
|
|
225
|
-
async function ensureSession() {
|
|
226
|
-
return sessionID ?? (await sessionReady);
|
|
227
|
-
}
|
|
228
|
-
/** Drive a turn carrying the current inbox batch (and the boot briefing once) into the visible
|
|
229
|
-
* session via the server API — server-side, so it can't race like the TUI input box, and the TUI
|
|
230
|
-
* renders it live (it subscribes to that session's events). Surfaces the items but does NOT ack
|
|
231
|
-
* them — ackSurfaced runs on turn completion, so a crash/error redelivers. `override` replaces
|
|
232
|
-
* the body (a bare nudge, e.g. a focus @mention pull) and surfaces nothing to ack. Self-guards
|
|
233
|
-
* re-entrancy and never prompts into a running turn (opencode would COALESCE onto it). */
|
|
234
|
-
async function drive(override) {
|
|
235
|
-
if (driving || busy)
|
|
236
|
-
return;
|
|
237
|
-
driving = true;
|
|
238
|
-
try {
|
|
239
|
-
const id = await ensureSession();
|
|
240
|
-
if (!id)
|
|
241
|
-
return; // no visible session yet — retry on the next event/wake
|
|
242
|
-
const parts = [];
|
|
243
|
-
let ids = [];
|
|
244
|
-
if (override) {
|
|
245
|
-
parts.push({ type: "text", text: override });
|
|
246
|
-
}
|
|
247
|
-
else {
|
|
248
|
-
const items = agent.peekInbox();
|
|
249
|
-
if (items.length === 0)
|
|
250
|
-
return;
|
|
251
|
-
ids = items.map((i) => i.id);
|
|
252
|
-
const inj = formatInjection(items);
|
|
253
|
-
if (inj)
|
|
254
|
-
parts.push({ type: "text", text: inj });
|
|
255
|
-
}
|
|
256
|
-
if (!briefed) {
|
|
257
|
-
briefed = true;
|
|
258
|
-
const brief = agent.channelBriefing();
|
|
259
|
-
if (brief)
|
|
260
|
-
parts.unshift({ type: "text", text: brief });
|
|
261
|
-
}
|
|
262
|
-
if (parts.length === 0)
|
|
263
|
-
return;
|
|
264
|
-
const body = { parts };
|
|
265
|
-
// persona once, as system (no --append-system-prompt). Append the orientation bootstrap so the
|
|
266
|
-
// agent is told to orient first — gated on persona so we never replace OpenCode's default system.
|
|
267
|
-
if (!primed && persona)
|
|
268
|
-
body.system = `${persona}\n\n${ORIENTATION_BOOTSTRAP}`;
|
|
269
|
-
busy = true;
|
|
270
|
-
surfaced = ids;
|
|
271
|
-
// Arm BEFORE the await: a turn-end signal can land before the server request resolves, and
|
|
272
|
-
// completeTurn bails unless armed — arming after would drop it and wedge the agent.
|
|
273
|
-
awaitingTurnEnd = true;
|
|
274
|
-
await opencodeApi(`/session/${encodeURIComponent(id)}/prompt_async`, { method: "POST", body: JSON.stringify(body) }, 10_000);
|
|
275
|
-
primed = true;
|
|
276
|
-
}
|
|
277
|
-
catch (e) {
|
|
278
|
-
busy = false;
|
|
279
|
-
surfaced = [];
|
|
280
|
-
awaitingTurnEnd = false;
|
|
281
|
-
log(`drive failed: ${e.message}`);
|
|
282
|
-
scheduleErrorRetry();
|
|
283
|
-
}
|
|
284
|
-
finally {
|
|
285
|
-
driving = false;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
/** Ack the surfaced batch — but only the leading run STILL at the front of the inbox, matched by
|
|
289
|
-
* id. MeshAgent evicts from the FRONT at MAX_INBOX, so a long turn on a chatty channel can shift
|
|
290
|
-
* our surfaced prefix out; matching by id (not a raw count) means we never ack the wrong, newer
|
|
291
|
-
* messages. Evicted items were already acked by the overflow; any surfaced survivor that no
|
|
292
|
-
* longer leads is left unacked → redelivered (re-answered, never lost). */
|
|
293
|
-
function ackSurfaced() {
|
|
294
|
-
if (surfaced.length === 0)
|
|
295
|
-
return;
|
|
296
|
-
const front = agent.peekInbox();
|
|
297
|
-
let n = 0;
|
|
298
|
-
while (n < surfaced.length && n < front.length && front[n].id === surfaced[n])
|
|
299
|
-
n++;
|
|
300
|
-
if (n > 0)
|
|
301
|
-
agent.drainInbox(n);
|
|
302
|
-
surfaced = [];
|
|
303
|
-
}
|
|
304
|
-
function abandonSurfaced() {
|
|
305
|
-
surfaced = [];
|
|
306
|
-
}
|
|
307
|
-
/** Native TUI / API prompts enter through OpenCode's chat.message hook before the model loop
|
|
308
|
-
* starts. This is the real "next turn" boundary for human-typed input: prepend the buffered Cotal
|
|
309
|
-
* batch to the user's text, then ack it when the resulting turn ends. We only mutate an existing
|
|
310
|
-
* text part so we don't need to manufacture OpenCode's internal part IDs. */
|
|
311
|
-
function injectIntoPrompt(output) {
|
|
312
|
-
if (driving || awaitingTurnEnd)
|
|
313
|
-
return; // drive() already injected, or one surfaced batch is open
|
|
314
|
-
const items = agent.peekInbox();
|
|
315
|
-
if (items.length === 0)
|
|
316
|
-
return;
|
|
317
|
-
const inj = formatInjection(items);
|
|
318
|
-
if (!inj)
|
|
319
|
-
return;
|
|
320
|
-
const textPart = output.parts?.find((p) => typeof p === "object" && p !== null && p.type === "text" && typeof p.text === "string");
|
|
321
|
-
if (!textPart)
|
|
322
|
-
return;
|
|
323
|
-
textPart.text = `${inj}\n\n${textPart.text}`;
|
|
324
|
-
surfaced = items.map((i) => i.id);
|
|
325
|
-
awaitingTurnEnd = true;
|
|
326
|
-
busy = true;
|
|
327
|
-
}
|
|
328
|
-
/** A turn ended — ANY turn, ours (a driven inbox batch) OR the human's (typing into the attached
|
|
329
|
-
* TUI, a `/reconnect`, etc). Clear `busy` regardless of who drove it: it's the COALESCE guard, so
|
|
330
|
-
* a turn the connector didn't drive must still release it or every later push wedges behind a
|
|
331
|
-
* finished turn. Ack only what WE surfaced (gated on awaitingTurnEnd — a human turn surfaced
|
|
332
|
-
* nothing), then flush the next buffered batch — mode-aware, so bare ambient (dnd/focus) doesn't
|
|
333
|
-
* self-wake (it rides the next directed/human turn). A truly stray idle (nothing was running and
|
|
334
|
-
* we drove nothing) is ignored, so it can't mis-ack or empty-drive. */
|
|
335
|
-
function completeTurn() {
|
|
336
|
-
if (!busy && !awaitingTurnEnd)
|
|
337
|
-
return; // stray/duplicate idle — no turn to close
|
|
338
|
-
busy = false;
|
|
339
|
-
if (awaitingTurnEnd) {
|
|
340
|
-
awaitingTurnEnd = false;
|
|
341
|
-
ackSurfaced(); // our driven turn: ack the surfaced batch (the sole ack site)
|
|
342
|
-
}
|
|
343
|
-
clearInterruptIntent();
|
|
344
|
-
clearErrorRetry(true);
|
|
345
|
-
if (pendingForWake() > 0)
|
|
346
|
-
void drive();
|
|
347
|
-
}
|
|
348
|
-
// Inbound mesh → drive (never interrupt a running turn — matches Claude). A directed message
|
|
349
|
-
// (DM / anycast / @mention) drives when idle; ambient channel chatter drives only in `open` while
|
|
350
|
-
// idle (dnd/focus hold it for the next turn), and a per-channel `quiet` channel never ambient-drives
|
|
351
|
-
// (read on the agent's terms; a `quiet` @mention still drives). `muted` ambient never reaches here
|
|
352
|
-
// (ack-dropped at ingest); in `focus`, ambient/@mentions never reach "incoming" either.
|
|
353
|
-
agent.on("incoming", (item) => {
|
|
354
|
-
if (busy)
|
|
355
|
-
return; // buffer; chat.message or completeTurn drives at the next safe boundary
|
|
356
|
-
const directed = item.kind !== "channel" || item.mentionsMe;
|
|
357
|
-
const quiet = item.kind === "channel" && agent.channelMode(item.channel) === "quiet";
|
|
358
|
-
if (directed || (!quiet && agent.attention === "open"))
|
|
359
|
-
void drive();
|
|
360
|
-
});
|
|
361
|
-
agent.on("mention-wake", (item) => {
|
|
362
|
-
// Focus: the @mention body was acked-and-dropped at ingest — wake a turn to PULL it (recall).
|
|
363
|
-
if (!busy)
|
|
364
|
-
void drive(`📨 You were mentioned by ${fmtFrom(item)} on #${item.channel ?? "?"} — read it with cotal_inbox.`);
|
|
365
|
-
});
|
|
366
|
-
agent.on("wake", () => {
|
|
367
|
-
if (!busy)
|
|
368
|
-
void drive();
|
|
369
|
-
});
|
|
370
|
-
/** Match an event's session against the one we drive. Adopt the first session id we see, then
|
|
371
|
-
* filter to it; later top-level `session.created` events adopt explicitly as reset-in-place. */
|
|
372
|
-
const ours = (id) => {
|
|
373
|
-
if (!id)
|
|
374
|
-
return !sessionID; // a session-less event counts as ours only before we've adopted one
|
|
375
|
-
if (!sessionID)
|
|
376
|
-
adoptSession(id, "first event");
|
|
377
|
-
return id === sessionID;
|
|
378
|
-
};
|
|
379
|
-
const hooks = {
|
|
380
|
-
tool: buildCotalTools(agent, config),
|
|
381
|
-
"chat.message": async (input, output) => {
|
|
382
|
-
if (!ours(input.sessionID))
|
|
383
|
-
return;
|
|
384
|
-
injectIntoPrompt(output);
|
|
385
|
-
},
|
|
386
|
-
event: async ({ event }) => {
|
|
387
|
-
// The server emits `permission.asked` (the SDK's `permission.updated` type ships but never
|
|
388
|
-
// fires — #11616), so match the real runtime name out of band. With permission:"allow" this
|
|
389
|
-
// rarely triggers, but it keeps presence correct if the posture tightens.
|
|
390
|
-
if (event.type === "permission.asked") {
|
|
391
|
-
const p = event.properties;
|
|
392
|
-
if (!p.sessionID || ours(p.sessionID))
|
|
393
|
-
await safeStatus("waiting", p.title);
|
|
394
|
-
return;
|
|
395
|
-
}
|
|
396
|
-
switch (event.type) {
|
|
397
|
-
case "session.created":
|
|
398
|
-
// Adopt every top-level session created in this OpenCode process. That makes `/new` a
|
|
399
|
-
// Cotal-aware context reset: same mesh identity, new OpenCode context/session id.
|
|
400
|
-
if (!event.properties.info.parentID)
|
|
401
|
-
adoptSession(event.properties.info.id, "top-level session create");
|
|
402
|
-
break;
|
|
403
|
-
case "message.updated":
|
|
404
|
-
// Feed the transcript mirror: which messages on OUR session are assistant-authored.
|
|
405
|
-
if (transcript && ours(event.properties.info.sessionID))
|
|
406
|
-
transcript.record(event.properties.info);
|
|
407
|
-
break;
|
|
408
|
-
case "message.part.updated":
|
|
409
|
-
// Feed the transcript mirror: buffer each part as it streams (no per-turn refetch).
|
|
410
|
-
if (transcript && ours(event.properties.part.sessionID))
|
|
411
|
-
transcript.observe(event.properties.part);
|
|
412
|
-
break;
|
|
413
|
-
case "session.idle": {
|
|
414
|
-
const idleSession = event.properties.sessionID;
|
|
415
|
-
if (!ours(idleSession))
|
|
416
|
-
return;
|
|
417
|
-
await safeStatus("idle");
|
|
418
|
-
// Publish what the agent did this turn BEFORE driving the next batch, so a fresh turn's parts
|
|
419
|
-
// don't bleed in. The mirror is an observability side-channel: surface a publish failure but
|
|
420
|
-
// keep it OFF the turn loop, so a transport hiccup can never wedge the agent.
|
|
421
|
-
if (transcript)
|
|
422
|
-
await transcript.flush().catch((e) => log(`transcript mirror publish failed: ${e.message}`));
|
|
423
|
-
completeTurn(); // the sole turn-end site: ack-on-surface + drive the next batch
|
|
424
|
-
break;
|
|
425
|
-
}
|
|
426
|
-
case "session.status": {
|
|
427
|
-
if (!ours(event.properties.sessionID))
|
|
428
|
-
return;
|
|
429
|
-
const s = event.properties.status;
|
|
430
|
-
// Presence only — session.idle owns ack + drive (so a duplicate idle can't mis-ack).
|
|
431
|
-
if (s.type === "busy") {
|
|
432
|
-
busy = true;
|
|
433
|
-
await safeStatus("working");
|
|
434
|
-
}
|
|
435
|
-
else if (s.type === "idle") {
|
|
436
|
-
await safeStatus("idle");
|
|
437
|
-
}
|
|
438
|
-
else if (s.type === "retry") {
|
|
439
|
-
await safeStatus("working", `retrying: ${s.message}`);
|
|
440
|
-
}
|
|
441
|
-
break;
|
|
442
|
-
}
|
|
443
|
-
case "session.error":
|
|
444
|
-
// session.error's sessionID is OPTIONAL; skip only a DIFFERENT session's error — a
|
|
445
|
-
// session-less one (id undefined) during an in-flight turn must still close it, else
|
|
446
|
-
// `busy` stays stuck and every later push is buffered behind a turn that already failed.
|
|
447
|
-
if (event.properties.sessionID && !ours(event.properties.sessionID))
|
|
448
|
-
return;
|
|
449
|
-
if (!busy && !awaitingTurnEnd)
|
|
450
|
-
return; // no turn to fail — stray error
|
|
451
|
-
const interrupted = consumeInterruptIntent(event.properties.sessionID) || isMessageAbortedError(event.properties.error);
|
|
452
|
-
busy = false;
|
|
453
|
-
if (awaitingTurnEnd) {
|
|
454
|
-
awaitingTurnEnd = false;
|
|
455
|
-
if (interrupted)
|
|
456
|
-
ackSurfaced(); // explicit user Stop/Cancel: treat the surfaced batch as dismissed, not failed
|
|
457
|
-
else
|
|
458
|
-
abandonSurfaced(); // failed turn: leave inbox unacked so the batch can retry on a later safe turn
|
|
459
|
-
}
|
|
460
|
-
await safeStatus("idle");
|
|
461
|
-
if (!interrupted)
|
|
462
|
-
scheduleErrorRetry();
|
|
463
|
-
else
|
|
464
|
-
clearErrorRetry(true);
|
|
465
|
-
break;
|
|
466
|
-
case "tui.command.execute": {
|
|
467
|
-
const p = event.properties;
|
|
468
|
-
if (p.command === "session.interrupt")
|
|
469
|
-
markInterruptIntent(p.sessionID);
|
|
470
|
-
break;
|
|
471
|
-
}
|
|
472
|
-
case "session.deleted":
|
|
473
|
-
if (!ours(event.properties.info.id))
|
|
474
|
-
return;
|
|
475
|
-
await safeStatus("offline");
|
|
476
|
-
break;
|
|
477
|
-
}
|
|
478
|
-
},
|
|
479
|
-
// Surface the running tool as presence activity (parity with Claude's PreToolUse).
|
|
480
|
-
"tool.execute.before": async (input) => {
|
|
481
|
-
if (!ours(input.sessionID))
|
|
482
|
-
return;
|
|
483
|
-
await safeStatus("working", input.tool);
|
|
484
|
-
},
|
|
485
|
-
dispose: async () => {
|
|
486
|
-
try {
|
|
487
|
-
controlServer?.close();
|
|
488
|
-
}
|
|
489
|
-
catch {
|
|
490
|
-
/* ignore */
|
|
491
|
-
}
|
|
492
|
-
await safeStatus("offline");
|
|
493
|
-
clearErrorRetry(true);
|
|
494
|
-
await agent.stop();
|
|
495
|
-
},
|
|
496
|
-
};
|
|
497
|
-
guard.__cotalOpencodeHooks = hooks;
|
|
498
|
-
log(`opencode plugin ready — space="${config.space}" name="${config.name}"${config.role ? ` role="${config.role}"` : ""}`);
|
|
499
|
-
return hooks;
|
|
500
|
-
};
|
|
501
|
-
//# sourceMappingURL=plugin.js.map
|
package/dist/plugin.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,aAAa,EAAuB,MAAM,gBAAgB,CAAC;AACpE,OAAO,EACL,aAAa,EACb,WAAW,EACX,SAAS,EACT,kBAAkB,EAClB,eAAe,EACf,OAAO,EACP,qBAAqB,EACrB,iBAAiB,GAElB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,SAAS,GAAG,CAAC,GAAW;IACtB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,qBAAqB,GAAG,IAAI,CAAC,CAAC;AACrD,CAAC;AAED;;;0DAG0D;AAC1D,MAAM,KAAK,GAAG,UAA8C,CAAC;AAC7D,MAAM,sBAAsB,GAAG,KAAK,CAAC;AACrC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAClC,MAAM,uBAAuB,GAAG,MAAM,CAAC;AAEvC,MAAM,CAAC,MAAM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wB,EAAE,MAAM;QAChC,WAAW,EAAE,MAAM;KACpB,CAAC;IACF,OAAO,MAAM,CAAC,uBAAuB,CAAC,CAAC,wDAAwD;IAC/F,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;QAAE,IAAI,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC;YAAE,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;IAClF,QAAQ,GAAG,IAAI,CAAC;IAChB,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,WAAW,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,CAAC,EAAE;QAC7E,GAAG,EAAE,MAAM;QACX,KAAK,EAAE,SAAS;KACjB,CAAC,CAAC;IAEH,KAAK,MAAM,GAAG,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAU;QAC9C,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE;YACnB,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACd,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;QAC9B,kFAAkF;QAClF,KAAK,SAAS,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3E,CAAC,CAAC,CAAC;AACL,CAAC;AAED,KAAK,IAAI,EAAE,CAAC"}
|
package/dist/tools.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The Cotal tool surface for OpenCode, rendered from the **shared** {@link cotalToolSpecs}
|
|
3
|
-
* (the same source the Claude Code MCP connector renders) as OpenCode-native plugin
|
|
4
|
-
* tools (the `tool()` helper). One source of truth → the cotal_* surface can't drift across
|
|
5
|
-
* adapters: an OpenCode peer gets the same tools (incl. channels / join / leave / channel_info).
|
|
6
|
-
*
|
|
7
|
-
* The one OpenCode-specific tool is `cotal_inbox`: this connector DRIVES delivery (it surfaces
|
|
8
|
-
* each batch into a turn and acks on completion), so the agent's inbox tool is READ-ONLY — it
|
|
9
|
-
* peeks (never drains), or it would race the connector's ack. It still honors focus-mode recall.
|
|
10
|
-
*/
|
|
11
|
-
import { tool } from "@opencode-ai/plugin";
|
|
12
|
-
import { cotalToolSpecs } from "@cotal-ai/connector-core";
|
|
13
|
-
/** Build the cotal_* tool map wired to one mesh agent, rendered from the shared specs. */
|
|
14
|
-
export function buildCotalTools(agent, config) {
|
|
15
|
-
const tools = {};
|
|
16
|
-
for (const spec of cotalToolSpecs(config, "opencode")) {
|
|
17
|
-
if (spec.name === "cotal_inbox") {
|
|
18
|
-
// Read-only: this connector delivers + acks each turn, so the tool must never drain. Force
|
|
19
|
-
// peek (still surfaces focus-mode recall), and reframe push-primary / pull-secondary. (norman)
|
|
20
|
-
tools.cotal_inbox = tool({
|
|
21
|
-
description: "Show the peer messages currently waiting for you (incl. focus-mode recall). You don't normally need this — the connector delivers peer messages into your turns automatically; use it to re-check what's pending mid-task. Read-only: it never consumes them.",
|
|
22
|
-
args: {},
|
|
23
|
-
async execute() {
|
|
24
|
-
const r = await spec.run(agent, config, { peek: true });
|
|
25
|
-
return r.isError ? `⚠ ${r.text}` : r.text;
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
tools[spec.name] = tool({
|
|
31
|
-
description: spec.description,
|
|
32
|
-
// The shared spec carries a Zod raw shape; OpenCode's tool() takes the same (zod via tool.schema).
|
|
33
|
-
args: (spec.schema ?? {}),
|
|
34
|
-
async execute(args) {
|
|
35
|
-
const r = await spec.run(agent, config, (args ?? {}));
|
|
36
|
-
return r.isError ? `⚠ ${r.text}` : r.text;
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
return tools;
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=tools.js.map
|
package/dist/tools.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,IAAI,EAAuB,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAoC,MAAM,0BAA0B,CAAC;AAE5F,0FAA0F;AAC1F,MAAM,UAAU,eAAe,CAAC,KAAgB,EAAE,MAAmB;IACnE,MAAM,KAAK,GAAmC,EAAE,CAAC;IACjD,KAAK,MAAM,IAAI,IAAI,cAAc,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE,CAAC;QACtD,IAAI,IAAI,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;YAChC,2FAA2F;YAC3F,+FAA+F;YAC/F,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;gBACvB,WAAW,EACT,+PAA+P;gBACjQ,IAAI,EAAE,EAAE;gBACR,KAAK,CAAC,OAAO;oBACX,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;oBACxD,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;gBAC5C,CAAC;aACF,CAAC,CAAC;YACH,SAAS;QACX,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;YACtB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,mGAAmG;YACnG,IAAI,EAAE,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAA0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