@ycodium-ai/agent-opencode 0.2.2706 → 0.2.2729
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 +125 -23
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -1772,7 +1772,6 @@ import {
|
|
|
1772
1772
|
} from "@ycodium-ai/plugin-api/executor";
|
|
1773
1773
|
|
|
1774
1774
|
// src/server.ts
|
|
1775
|
-
import * as NodeNet from "node:net";
|
|
1776
1775
|
import * as NodeOS4 from "node:os";
|
|
1777
1776
|
|
|
1778
1777
|
// ../../node_modules/.pnpm/@opencode-ai+sdk@1.18.31/node_modules/@opencode-ai/sdk/dist/v2/gen/core/serverSentEvents.gen.js
|
|
@@ -7184,6 +7183,129 @@ import {
|
|
|
7184
7183
|
mergeLaunchEnv as mergeLaunchEnv2
|
|
7185
7184
|
} from "@ycodium-ai/plugin-api/executor";
|
|
7186
7185
|
|
|
7186
|
+
// ../../packages/ycodium-fetch-ports/src/fetchPorts.ts
|
|
7187
|
+
import * as NodeNet from "node:net";
|
|
7188
|
+
var FETCH_BLOCKED_PORTS = /* @__PURE__ */ new Set([
|
|
7189
|
+
1,
|
|
7190
|
+
7,
|
|
7191
|
+
9,
|
|
7192
|
+
11,
|
|
7193
|
+
13,
|
|
7194
|
+
15,
|
|
7195
|
+
17,
|
|
7196
|
+
19,
|
|
7197
|
+
20,
|
|
7198
|
+
21,
|
|
7199
|
+
22,
|
|
7200
|
+
23,
|
|
7201
|
+
25,
|
|
7202
|
+
37,
|
|
7203
|
+
42,
|
|
7204
|
+
43,
|
|
7205
|
+
53,
|
|
7206
|
+
69,
|
|
7207
|
+
77,
|
|
7208
|
+
79,
|
|
7209
|
+
87,
|
|
7210
|
+
95,
|
|
7211
|
+
101,
|
|
7212
|
+
102,
|
|
7213
|
+
103,
|
|
7214
|
+
104,
|
|
7215
|
+
109,
|
|
7216
|
+
110,
|
|
7217
|
+
111,
|
|
7218
|
+
113,
|
|
7219
|
+
115,
|
|
7220
|
+
117,
|
|
7221
|
+
119,
|
|
7222
|
+
123,
|
|
7223
|
+
135,
|
|
7224
|
+
137,
|
|
7225
|
+
139,
|
|
7226
|
+
143,
|
|
7227
|
+
161,
|
|
7228
|
+
179,
|
|
7229
|
+
389,
|
|
7230
|
+
427,
|
|
7231
|
+
465,
|
|
7232
|
+
512,
|
|
7233
|
+
513,
|
|
7234
|
+
514,
|
|
7235
|
+
515,
|
|
7236
|
+
526,
|
|
7237
|
+
530,
|
|
7238
|
+
531,
|
|
7239
|
+
532,
|
|
7240
|
+
540,
|
|
7241
|
+
548,
|
|
7242
|
+
554,
|
|
7243
|
+
556,
|
|
7244
|
+
563,
|
|
7245
|
+
587,
|
|
7246
|
+
601,
|
|
7247
|
+
636,
|
|
7248
|
+
989,
|
|
7249
|
+
990,
|
|
7250
|
+
993,
|
|
7251
|
+
995,
|
|
7252
|
+
1719,
|
|
7253
|
+
1720,
|
|
7254
|
+
1723,
|
|
7255
|
+
2049,
|
|
7256
|
+
3659,
|
|
7257
|
+
4045,
|
|
7258
|
+
4190,
|
|
7259
|
+
5060,
|
|
7260
|
+
5061,
|
|
7261
|
+
6e3,
|
|
7262
|
+
6566,
|
|
7263
|
+
6665,
|
|
7264
|
+
6666,
|
|
7265
|
+
6667,
|
|
7266
|
+
6668,
|
|
7267
|
+
6669,
|
|
7268
|
+
6679,
|
|
7269
|
+
6697,
|
|
7270
|
+
10080
|
|
7271
|
+
]);
|
|
7272
|
+
var isFetchSafePort = (port) => !FETCH_BLOCKED_PORTS.has(port);
|
|
7273
|
+
var MAX_SAFE_PORT_ATTEMPTS = 50;
|
|
7274
|
+
var systemAssigned = () => 0;
|
|
7275
|
+
var listenOnce = (server, host, port) => new Promise((resolve2, reject) => {
|
|
7276
|
+
server.once("error", reject);
|
|
7277
|
+
server.listen(port, host, () => {
|
|
7278
|
+
server.off("error", reject);
|
|
7279
|
+
const address = server.address();
|
|
7280
|
+
resolve2(typeof address === "object" && address !== null ? address.port : 0);
|
|
7281
|
+
});
|
|
7282
|
+
});
|
|
7283
|
+
var listenOnSafePort = async (server, options = {}) => {
|
|
7284
|
+
const host = options.host ?? "127.0.0.1";
|
|
7285
|
+
const portForAttempt = options.portForAttempt ?? systemAssigned;
|
|
7286
|
+
for (let attempt = 0; attempt < MAX_SAFE_PORT_ATTEMPTS; attempt++) {
|
|
7287
|
+
const port = await listenOnce(server, host, portForAttempt(attempt));
|
|
7288
|
+
if (isFetchSafePort(port)) return port;
|
|
7289
|
+
await new Promise((resolve2) => server.close(() => resolve2()));
|
|
7290
|
+
}
|
|
7291
|
+
throw new Error(`\u8FDE\u7EED ${String(MAX_SAFE_PORT_ATTEMPTS)} \u6B21\u5206\u5230 fetch \u7684\u574F\u7AEF\u53E3`);
|
|
7292
|
+
};
|
|
7293
|
+
var reserveFetchSafePort = async (options = {}) => {
|
|
7294
|
+
const probe = NodeNet.createServer();
|
|
7295
|
+
try {
|
|
7296
|
+
const port = await listenOnSafePort(probe, options);
|
|
7297
|
+
await new Promise((resolve2) => probe.close(() => resolve2()));
|
|
7298
|
+
if (port <= 0) throw new Error("\u65E0\u6CD5\u53D6\u5F97\u76D1\u542C\u7AEF\u53E3");
|
|
7299
|
+
return port;
|
|
7300
|
+
} catch (cause) {
|
|
7301
|
+
try {
|
|
7302
|
+
probe.close();
|
|
7303
|
+
} catch {
|
|
7304
|
+
}
|
|
7305
|
+
throw cause;
|
|
7306
|
+
}
|
|
7307
|
+
};
|
|
7308
|
+
|
|
7187
7309
|
// src/cliParse.ts
|
|
7188
7310
|
var DEFAULT_OPENCODE_SERVER_TIMEOUT_MS = 3e4;
|
|
7189
7311
|
var DEFAULT_HOSTNAME = "127.0.0.1";
|
|
@@ -7315,26 +7437,6 @@ async function collectText(stream, maxBytes = Number.POSITIVE_INFINITY) {
|
|
|
7315
7437
|
}
|
|
7316
7438
|
return Buffer.concat(chunks).toString("utf8");
|
|
7317
7439
|
}
|
|
7318
|
-
async function findAvailablePort() {
|
|
7319
|
-
return await new Promise((resolve2, reject) => {
|
|
7320
|
-
const server = NodeNet.createServer();
|
|
7321
|
-
server.once("error", reject);
|
|
7322
|
-
server.listen(0, "127.0.0.1", () => {
|
|
7323
|
-
const address = server.address();
|
|
7324
|
-
server.close((error) => {
|
|
7325
|
-
if (error) {
|
|
7326
|
-
reject(error);
|
|
7327
|
-
return;
|
|
7328
|
-
}
|
|
7329
|
-
if (address === null || typeof address === "string") {
|
|
7330
|
-
reject(new Error("OpenCode could not allocate a local port."));
|
|
7331
|
-
return;
|
|
7332
|
-
}
|
|
7333
|
-
resolve2(address.port);
|
|
7334
|
-
});
|
|
7335
|
-
});
|
|
7336
|
-
});
|
|
7337
|
-
}
|
|
7338
7440
|
function buildSpawnEnv(recipe) {
|
|
7339
7441
|
const xdgHome = makeOpenCodeEnvironment(recipe.homePath, {});
|
|
7340
7442
|
return mergeLaunchEnv2({
|
|
@@ -7372,7 +7474,7 @@ async function terminateOwnedProcess(handle) {
|
|
|
7372
7474
|
}
|
|
7373
7475
|
}
|
|
7374
7476
|
async function spawnOpenCodeServer(input) {
|
|
7375
|
-
const port = await
|
|
7477
|
+
const port = await reserveFetchSafePort();
|
|
7376
7478
|
const hostname = DEFAULT_HOSTNAME;
|
|
7377
7479
|
const env = buildSpawnEnv(input.recipe);
|
|
7378
7480
|
const spawned = await input.host.process.spawn({
|
|
@@ -9910,7 +10012,7 @@ var executors = [
|
|
|
9910
10012
|
];
|
|
9911
10013
|
var index_default = definePlugin({
|
|
9912
10014
|
id: "agent-opencode",
|
|
9913
|
-
apiVersion:
|
|
10015
|
+
apiVersion: 3,
|
|
9914
10016
|
executors,
|
|
9915
10017
|
activate(ctx) {
|
|
9916
10018
|
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.2729",
|
|
4
4
|
"description": "OpenCode executor: OpenCode CLI via @opencode-ai/sdk/v2.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ycodium",
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"@types/node": "24.12.4",
|
|
25
25
|
"esbuild": "0.28.1",
|
|
26
26
|
"vite-plus": "0.2.2",
|
|
27
|
-
"@ycodium-ai/plugin-api": "0.2.
|
|
27
|
+
"@ycodium-ai/plugin-api": "0.2.2729",
|
|
28
|
+
"ycodium-fetch-ports": "0.0.0",
|
|
28
29
|
"ycodium-executor-testing": "0.0.0"
|
|
29
30
|
},
|
|
30
31
|
"ycodium": {
|