@ycodium-ai/agent-opencode 0.2.3158 → 0.2.3168
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 +41 -3
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1407,16 +1407,20 @@ async function spawnOpenCodeServer(input) {
|
|
|
1407
1407
|
const hostname = DEFAULT_HOSTNAME;
|
|
1408
1408
|
const password = NodeCrypto2.randomBytes(32).toString("base64url");
|
|
1409
1409
|
const env = buildSpawnEnv(input.recipe, input.configContent, password);
|
|
1410
|
+
const args = ["serve", `--hostname=${hostname}`, `--port=${port}`];
|
|
1410
1411
|
const spawned = await input.host.process.spawn({
|
|
1411
1412
|
program: input.program,
|
|
1412
|
-
args
|
|
1413
|
+
args,
|
|
1413
1414
|
cwd: input.directory,
|
|
1414
1415
|
env,
|
|
1415
1416
|
owner: { bindingId: input.host.bindingId }
|
|
1416
1417
|
});
|
|
1417
1418
|
const processHandle = {
|
|
1418
1419
|
kill: spawned.kill,
|
|
1419
|
-
exited: spawned.exited
|
|
1420
|
+
exited: spawned.exited,
|
|
1421
|
+
pid: spawned.pid,
|
|
1422
|
+
program: input.program,
|
|
1423
|
+
args
|
|
1420
1424
|
};
|
|
1421
1425
|
input.onSpawn?.({ external: false, process: processHandle });
|
|
1422
1426
|
const timeoutMs = input.timeoutMs ?? DEFAULT_OPENCODE_SERVER_TIMEOUT_MS;
|
|
@@ -2463,6 +2467,10 @@ async function handleOpenCodeToolEvent(input) {
|
|
|
2463
2467
|
const callId = text2(data, "id");
|
|
2464
2468
|
if (callId === void 0 || !isRecord2(data["metadata"])) return true;
|
|
2465
2469
|
const toolInput = context.toolInputs.get(callId);
|
|
2470
|
+
const command = toolInput?.["command"];
|
|
2471
|
+
if (context.toolNames.get(callId) === "shell" && text2(data["metadata"], "shellID") !== void 0 && typeof command === "string" && !context.openShells.has(callId)) {
|
|
2472
|
+
context.openShells.set(callId, { command, startedAtMs: Date.now() });
|
|
2473
|
+
}
|
|
2466
2474
|
emitTool(events, context, callId, "item.updated", "inProgress", "running", {
|
|
2467
2475
|
data: {
|
|
2468
2476
|
...toolInput === void 0 ? {} : { input: toolInput },
|
|
@@ -2501,6 +2509,7 @@ async function handleOpenCodeToolEvent(input) {
|
|
|
2501
2509
|
);
|
|
2502
2510
|
context.toolNames.delete(callId);
|
|
2503
2511
|
context.toolInputs.delete(callId);
|
|
2512
|
+
context.openShells.delete(callId);
|
|
2504
2513
|
return true;
|
|
2505
2514
|
}
|
|
2506
2515
|
default:
|
|
@@ -2514,6 +2523,7 @@ function finishOpenCodeTurn(events, context, outcome) {
|
|
|
2514
2523
|
const usage = takeTurnUsage(context.usageByMessageId, context.sessionId);
|
|
2515
2524
|
context.abortedByDecline = false;
|
|
2516
2525
|
context.declinedToolCalls.clear();
|
|
2526
|
+
context.openShells.clear();
|
|
2517
2527
|
context.stepModels.clear();
|
|
2518
2528
|
context.assistantTextByPartId.clear();
|
|
2519
2529
|
context.completedTextParts.clear();
|
|
@@ -3114,6 +3124,32 @@ function startEventPump(input) {
|
|
|
3114
3124
|
return ready;
|
|
3115
3125
|
}
|
|
3116
3126
|
|
|
3127
|
+
// src/openCommands.ts
|
|
3128
|
+
import { sameArgv } from "@ycodium-ai/plugin-api/executor";
|
|
3129
|
+
var programName = (path) => (path.split(/[\\/]/).at(-1) ?? "").toLowerCase().replace(/\.(exe|cmd)$/, "");
|
|
3130
|
+
function opencodeCommandMatcher(command) {
|
|
3131
|
+
return (argv, platform) => platform === "win32" && argv.length === 3 && programName(argv[0] ?? "") === "bash" && argv[1] === "-c" && argv[2] === command;
|
|
3132
|
+
}
|
|
3133
|
+
function opencodeSessionProcessMatcher(program, args) {
|
|
3134
|
+
return (argv) => programName(argv[0] ?? "") === programName(program) && sameArgv(argv.slice(1), args);
|
|
3135
|
+
}
|
|
3136
|
+
function opencodeOpenCommands(context) {
|
|
3137
|
+
if (context === void 0 || context.stopped) return void 0;
|
|
3138
|
+
const owned = context.server.process;
|
|
3139
|
+
if (context.server.external || owned === void 0) return void 0;
|
|
3140
|
+
const commands = [...context.openShells].map(([toolCallId, shell]) => ({
|
|
3141
|
+
toolCallId,
|
|
3142
|
+
startedAtMs: shell.startedAtMs,
|
|
3143
|
+
matches: opencodeCommandMatcher(shell.command)
|
|
3144
|
+
}));
|
|
3145
|
+
if (commands.length === 0) return void 0;
|
|
3146
|
+
return {
|
|
3147
|
+
rootPid: owned.pid,
|
|
3148
|
+
sessionProcess: opencodeSessionProcessMatcher(owned.program, owned.args),
|
|
3149
|
+
commands
|
|
3150
|
+
};
|
|
3151
|
+
}
|
|
3152
|
+
|
|
3117
3153
|
// src/textGeneration.ts
|
|
3118
3154
|
import {
|
|
3119
3155
|
createCatalogModelMatcher
|
|
@@ -3956,6 +3992,7 @@ function createOpenCodeInstance(config, host, attachments, lifecycleOptions) {
|
|
|
3956
3992
|
stepModels: /* @__PURE__ */ new Map(),
|
|
3957
3993
|
toolNames: /* @__PURE__ */ new Map(),
|
|
3958
3994
|
toolInputs: /* @__PURE__ */ new Map(),
|
|
3995
|
+
openShells: /* @__PURE__ */ new Map(),
|
|
3959
3996
|
pendingPermissions: /* @__PURE__ */ new Map(),
|
|
3960
3997
|
pendingForms: /* @__PURE__ */ new Map(),
|
|
3961
3998
|
childSessionIds: /* @__PURE__ */ new Set(),
|
|
@@ -4080,6 +4117,7 @@ function createOpenCodeInstance(config, host, attachments, lifecycleOptions) {
|
|
|
4080
4117
|
await staged.cleanup();
|
|
4081
4118
|
}
|
|
4082
4119
|
},
|
|
4120
|
+
openCommandProcesses: async (threadId) => opencodeOpenCommands(sessions.get(threadId)),
|
|
4083
4121
|
interruptTurn: async (threadId, turnId) => {
|
|
4084
4122
|
const context = requireSession(threadId);
|
|
4085
4123
|
if (turnId !== void 0 && context.session.activeTurnId !== turnId) {
|
|
@@ -4193,7 +4231,7 @@ var executors = [
|
|
|
4193
4231
|
];
|
|
4194
4232
|
var index_default = definePlugin({
|
|
4195
4233
|
id: "agent-opencode",
|
|
4196
|
-
apiVersion:
|
|
4234
|
+
apiVersion: 16,
|
|
4197
4235
|
executors,
|
|
4198
4236
|
activate(ctx) {
|
|
4199
4237
|
capturedAttachments = ctx.attachments;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ycodium-ai/agent-opencode",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3168",
|
|
4
4
|
"description": "OpenCode executor: OpenCode CLI (2.x) over its HTTP API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ycodium",
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"@types/node": "24.12.4",
|
|
22
22
|
"esbuild": "0.28.1",
|
|
23
23
|
"vite-plus": "0.2.2",
|
|
24
|
-
"ycodium-
|
|
24
|
+
"@ycodium-ai/plugin-api": "0.2.3168",
|
|
25
25
|
"ycodium-sse-stream": "0.0.0",
|
|
26
|
-
"
|
|
27
|
-
"ycodium-
|
|
26
|
+
"ycodium-fetch-ports": "0.0.0",
|
|
27
|
+
"ycodium-executor-testing": "0.0.0"
|
|
28
28
|
},
|
|
29
29
|
"ycodium": {
|
|
30
30
|
"plugin": "./dist/index.js",
|