@tbrandenburg/opencode-a2a-lite 0.4.0 → 0.4.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 +10 -4
- package/dist/package.json +1 -1
- package/dist/src/acp-client.js +6 -13
- package/dist/src/activity.js +23 -0
- package/dist/src/cli.js +2 -1
- package/dist/src/executor.js +6 -2
- package/dist/src/server.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -128,10 +128,16 @@ reusing the ACP session for that context.
|
|
|
128
128
|
underlying OpenCode diagnostic is never published. A bridge failure is permanent until restart.
|
|
129
129
|
- Every task's metadata carries `opencode.sessionId` and `opencode.stopReason` (after a session
|
|
130
130
|
exists). The session id is the key for finding the full transcript in OpenCode itself.
|
|
131
|
-
- `--publish-activity` (off by default) adds an `activity` artifact of data parts
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
131
|
+
- `--publish-activity` (off by default) adds an `activity` artifact of data parts: tool call id,
|
|
132
|
+
title, kind and status, plus the model's reasoning text as `{"thought": "..."}` when OpenCode
|
|
133
|
+
emits it. Tool inputs and outputs are never published. Titles and reasoning may reveal paths,
|
|
134
|
+
commands or workspace data, so enable it only for clients you trust. The Agent Card then
|
|
135
|
+
declares the `urn:opencode-a2a-lite:activity:v1` extension. Reasoning appears only for models
|
|
136
|
+
and effort settings that emit it (for example Claude Haiku 5.5 with `effort=high`).
|
|
137
|
+
- The gateway never approves permission requests. A turn stopped by a rejection ends `canceled`
|
|
138
|
+
with the message "Permission request rejected" and `opencode.permissionDenied: "true"` in the
|
|
139
|
+
task metadata; a client cancellation carries neither. Permissions that OpenCode's own configuration
|
|
140
|
+
allows are never asked, so they are never rejected.
|
|
135
141
|
- Defaults: 30-second startup/session allocation, 120-second prompt, 5-second
|
|
136
142
|
cancellation and 5-second ACP shutdown. Failure retires the unhealthy bridge.
|
|
137
143
|
- Streaming sends stable artifact IDs and ordered append events. Task states are
|
package/dist/package.json
CHANGED
package/dist/src/acp-client.js
CHANGED
|
@@ -3,20 +3,10 @@ import { isAbsolute } from "node:path";
|
|
|
3
3
|
import { Readable, Writable } from "node:stream";
|
|
4
4
|
import * as acp from "@agentclientprotocol/sdk";
|
|
5
5
|
import manifest from "../package.json" with { type: "json" };
|
|
6
|
+
import { activityOf } from "./activity.js";
|
|
6
7
|
import { BridgeError } from "./bridge-error.js";
|
|
7
8
|
import { supportedOpenCode } from "./opencode-version.js";
|
|
8
9
|
import { StartupError } from "./startup-error.js";
|
|
9
|
-
// Only identifying fields are forwarded; tool inputs and outputs never leave the bridge.
|
|
10
|
-
function toolActivity(update) {
|
|
11
|
-
if (update.sessionUpdate !== "tool_call" && update.sessionUpdate !== "tool_call_update")
|
|
12
|
-
return;
|
|
13
|
-
return {
|
|
14
|
-
toolCallId: update.toolCallId,
|
|
15
|
-
...(update.title ? { title: update.title } : {}),
|
|
16
|
-
...(update.kind ? { kind: update.kind } : {}),
|
|
17
|
-
...(update.status ? { status: update.status } : {}),
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
10
|
export function createAcpBridge(options) {
|
|
21
11
|
if (!isAbsolute(options.cwd))
|
|
22
12
|
throw new Error("ACP workspace must be absolute");
|
|
@@ -139,6 +129,7 @@ export function createAcpBridge(options) {
|
|
|
139
129
|
turn.cancelled ||
|
|
140
130
|
request.params.sessionId !== turn.sessionId)
|
|
141
131
|
return { outcome: { outcome: "cancelled" } };
|
|
132
|
+
turn.denied = true;
|
|
142
133
|
const reject = request.params.options.find((option) => option.kind === "reject_once" || option.kind === "reject_always");
|
|
143
134
|
return {
|
|
144
135
|
outcome: reject
|
|
@@ -156,7 +147,7 @@ export function createAcpBridge(options) {
|
|
|
156
147
|
if (notification.params._meta?.["opencode/child-session"] !== undefined ||
|
|
157
148
|
update._meta?.["opencode/child-session"] !== undefined)
|
|
158
149
|
return;
|
|
159
|
-
const activity =
|
|
150
|
+
const activity = activityOf(update);
|
|
160
151
|
if (activity) {
|
|
161
152
|
try {
|
|
162
153
|
turn.onActivity?.(activity);
|
|
@@ -213,6 +204,7 @@ export function createAcpBridge(options) {
|
|
|
213
204
|
sessionId,
|
|
214
205
|
onText,
|
|
215
206
|
onActivity,
|
|
207
|
+
denied: false,
|
|
216
208
|
cancelled: false,
|
|
217
209
|
settled: false,
|
|
218
210
|
cancellation: undefined,
|
|
@@ -224,7 +216,8 @@ export function createAcpBridge(options) {
|
|
|
224
216
|
prompt: [{ type: "text", text }],
|
|
225
217
|
}), promptTimeout, "prompt");
|
|
226
218
|
try {
|
|
227
|
-
|
|
219
|
+
const response = await active.completion;
|
|
220
|
+
return active.denied ? { ...response, permissionDenied: true } : response;
|
|
228
221
|
}
|
|
229
222
|
finally {
|
|
230
223
|
active.settled = true;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
function thoughtOf(update) {
|
|
2
|
+
if (update.sessionUpdate !== "agent_thought_chunk")
|
|
3
|
+
return;
|
|
4
|
+
if (update.content.type !== "text" || !update.content.text)
|
|
5
|
+
return;
|
|
6
|
+
if (update.content._meta?.["opencode/child-session"] !== undefined)
|
|
7
|
+
return;
|
|
8
|
+
return { thought: update.content.text };
|
|
9
|
+
}
|
|
10
|
+
function toolOf(update) {
|
|
11
|
+
if (update.sessionUpdate !== "tool_call" && update.sessionUpdate !== "tool_call_update")
|
|
12
|
+
return;
|
|
13
|
+
return {
|
|
14
|
+
toolCallId: update.toolCallId,
|
|
15
|
+
...(update.title ? { title: update.title } : {}),
|
|
16
|
+
...(update.kind ? { kind: update.kind } : {}),
|
|
17
|
+
...(update.status ? { status: update.status } : {}),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
// Tool inputs and outputs never leave the bridge: only identifying fields and thought text do.
|
|
21
|
+
export function activityOf(update) {
|
|
22
|
+
return thoughtOf(update) ?? toolOf(update);
|
|
23
|
+
}
|
package/dist/src/cli.js
CHANGED
|
@@ -13,7 +13,8 @@ Linux or macOS (experimental), Bun 1.4.4, stable OpenCode 2.2.7 or newer on PATH
|
|
|
13
13
|
--workspace <path> Explicitly trust this directory; relative paths are resolved.
|
|
14
14
|
--port <0..65535> Port (default 41241; 0 selects a free port).
|
|
15
15
|
--publish-activity Also publish an "activity" artifact with tool call ids, titles, kinds and
|
|
16
|
-
statuses (no inputs or outputs)
|
|
16
|
+
statuses (no inputs or outputs) and the model's reasoning text.
|
|
17
|
+
May reveal paths, commands or workspace data.
|
|
17
18
|
--help, -h Show help without starting OpenCode.
|
|
18
19
|
--version, -v Print package version without starting OpenCode.
|
|
19
20
|
|
package/dist/src/executor.js
CHANGED
|
@@ -85,7 +85,7 @@ export function createAgentExecutor(bridge, options = {}) {
|
|
|
85
85
|
artifact: {
|
|
86
86
|
artifactId: activityId,
|
|
87
87
|
name: "activity",
|
|
88
|
-
description: "Tool
|
|
88
|
+
description: "Tool call summaries and reasoning text",
|
|
89
89
|
parts: [entry ? dataPart(entry) : textPart("")],
|
|
90
90
|
metadata: undefined,
|
|
91
91
|
extensions: [ACTIVITY_EXTENSION],
|
|
@@ -169,12 +169,16 @@ export function createAgentExecutor(bridge, options = {}) {
|
|
|
169
169
|
}
|
|
170
170
|
: undefined);
|
|
171
171
|
meta["opencode.stopReason"] = response.stopReason;
|
|
172
|
+
if (response.permissionDenied)
|
|
173
|
+
meta["opencode.permissionDenied"] = "true";
|
|
172
174
|
if (response.stopReason === "end_turn") {
|
|
173
175
|
finish(TaskState.TASK_STATE_COMPLETED);
|
|
174
176
|
return;
|
|
175
177
|
}
|
|
176
178
|
if (response.stopReason === "cancelled") {
|
|
177
|
-
finish(TaskState.TASK_STATE_CANCELED
|
|
179
|
+
finish(TaskState.TASK_STATE_CANCELED, response.permissionDenied && !record.cancellation
|
|
180
|
+
? "Permission request rejected; the gateway never approves tool permissions"
|
|
181
|
+
: undefined);
|
|
178
182
|
return;
|
|
179
183
|
}
|
|
180
184
|
sessions.delete(contextId);
|
package/dist/src/server.js
CHANGED
|
@@ -108,7 +108,7 @@ export function createGateway(options) {
|
|
|
108
108
|
? [
|
|
109
109
|
{
|
|
110
110
|
uri: ACTIVITY_EXTENSION,
|
|
111
|
-
description: "Adds an optional 'activity' artifact of tool call ids, titles, kinds and
|
|
111
|
+
description: "Adds an optional 'activity' artifact of tool call ids, titles, kinds, statuses and reasoning text.",
|
|
112
112
|
required: false,
|
|
113
113
|
params: undefined,
|
|
114
114
|
},
|
|
@@ -201,7 +201,7 @@ export async function launchGateway(options) {
|
|
|
201
201
|
status("ready", `gateway · ${ready.url}`);
|
|
202
202
|
status("workspace", options.workspace);
|
|
203
203
|
if (options.executor?.activity)
|
|
204
|
-
status("activity", "tool
|
|
204
|
+
status("activity", "tool calls and reasoning text are published; they may reveal paths, commands or workspace data");
|
|
205
205
|
status("agent card", cardUrl);
|
|
206
206
|
status("connect", `a2a send -a ${ready.url} "Reply with a short greeting." --stream`);
|
|
207
207
|
status("stop", "press Ctrl-C to stop the gateway");
|