@ycodium-ai/agent-opencode 0.2.2488 → 0.2.2510
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 +71 -16
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1475,14 +1475,47 @@ function isOpenCodeNativeModeId(value) {
|
|
|
1475
1475
|
function openCodeNativeModeFor(runtimeMode, nativeModeId) {
|
|
1476
1476
|
return nativeModeId !== void 0 && isOpenCodeNativeModeId(nativeModeId) ? nativeModeId : OPENCODE_NATIVE_MODE_BY_RUNTIME_MODE[runtimeMode];
|
|
1477
1477
|
}
|
|
1478
|
-
function openCodePermissionRulesForNativeMode(nativeModeId) {
|
|
1478
|
+
function openCodePermissionRulesForNativeMode(nativeModeId, readOnlyDirectories) {
|
|
1479
1479
|
if (nativeModeId === "allow-all") {
|
|
1480
1480
|
return buildOpenCodePermissionRules("full-access");
|
|
1481
1481
|
}
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1482
|
+
const base = buildOpenCodePermissionRules(
|
|
1483
|
+
nativeModeId === "accept-edits" ? "auto-accept-edits" : "approval-required"
|
|
1484
|
+
);
|
|
1485
|
+
const readOnly = openCodeReadOnlyDirectoryRules(readOnlyDirectories);
|
|
1486
|
+
return readOnly.length === 0 ? base : [...base, ...readOnly];
|
|
1487
|
+
}
|
|
1488
|
+
function openCodeReadOnlyDirectoryRules(directories) {
|
|
1489
|
+
const rules = [];
|
|
1490
|
+
for (const directory of directories ?? []) {
|
|
1491
|
+
const patterns = openCodeDirectoryPatterns(directory);
|
|
1492
|
+
if (patterns === void 0) continue;
|
|
1493
|
+
rules.push({ permission: "external_directory", pattern: patterns.absolute, action: "allow" });
|
|
1494
|
+
rules.push({ permission: "read", pattern: patterns.absolute, action: "allow" });
|
|
1495
|
+
rules.push({ permission: "edit", pattern: patterns.absolute, action: "ask" });
|
|
1496
|
+
for (const suffix of patterns.suffixes) {
|
|
1497
|
+
rules.push({ permission: "read", pattern: suffix, action: "allow" });
|
|
1498
|
+
rules.push({ permission: "edit", pattern: suffix, action: "ask" });
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
return rules;
|
|
1502
|
+
}
|
|
1503
|
+
function openCodeDirectoryPatterns(directory) {
|
|
1504
|
+
const trimmed = directory.trim();
|
|
1505
|
+
if (/[*?]/.test(trimmed)) return void 0;
|
|
1506
|
+
const isWindowsPath = /^[A-Za-z]:[\\/]/.test(trimmed) || trimmed.startsWith("\\\\");
|
|
1507
|
+
const isPosixPath = /^\/[^/]/.test(trimmed);
|
|
1508
|
+
if (!isWindowsPath && !isPosixPath) return void 0;
|
|
1509
|
+
const separatorPattern = isWindowsPath ? /[\\/]+/ : /\/+/;
|
|
1510
|
+
const separator = isWindowsPath && trimmed.includes("\\") ? "\\" : "/";
|
|
1511
|
+
const segments = trimmed.split(separatorPattern).filter((segment) => segment !== "");
|
|
1512
|
+
const absolute = `${trimmed.replace(new RegExp(`${separatorPattern.source}$`), "")}${separator}*`;
|
|
1513
|
+
const tail = segments.slice(-2);
|
|
1514
|
+
const suffixSeparators = isWindowsPath ? ["/", "\\"] : ["/"];
|
|
1515
|
+
return {
|
|
1516
|
+
absolute,
|
|
1517
|
+
suffixes: tail.length === 2 ? suffixSeparators.map((sep) => `*${tail.join(sep)}${sep}*`) : []
|
|
1518
|
+
};
|
|
1486
1519
|
}
|
|
1487
1520
|
function buildOpenCodePermissionRules(runtimeMode) {
|
|
1488
1521
|
if (runtimeMode === "full-access") {
|
|
@@ -6987,7 +7020,6 @@ import {
|
|
|
6987
7020
|
} from "@ycodium-ai/plugin-api/executor";
|
|
6988
7021
|
|
|
6989
7022
|
// src/cliParse.ts
|
|
6990
|
-
var OPENCODE_SERVER_READY_PREFIX = "opencode server listening";
|
|
6991
7023
|
var DEFAULT_OPENCODE_SERVER_TIMEOUT_MS = 3e4;
|
|
6992
7024
|
var DEFAULT_HOSTNAME = "127.0.0.1";
|
|
6993
7025
|
var OPENCODE_SKILL_DISCOVERY_MAX_OUTPUT_BYTES = 8 * 1024 * 1024;
|
|
@@ -7000,11 +7032,8 @@ function resolveOpenCodeConfigContent(inheritedEnvironment) {
|
|
|
7000
7032
|
}
|
|
7001
7033
|
function parseServerUrlFromOutput(output) {
|
|
7002
7034
|
for (const line of output.split("\n")) {
|
|
7003
|
-
|
|
7004
|
-
|
|
7005
|
-
}
|
|
7006
|
-
const match = line.match(/on\s+(https?:\/\/[^\s]+)/);
|
|
7007
|
-
return match?.[1] ?? null;
|
|
7035
|
+
const match = line.match(/server listening on\s+(https?:\/\/[^\s]+)/i);
|
|
7036
|
+
if (match?.[1]) return match[1];
|
|
7008
7037
|
}
|
|
7009
7038
|
return null;
|
|
7010
7039
|
}
|
|
@@ -7303,12 +7332,31 @@ async function runOpenCodeCommand(input) {
|
|
|
7303
7332
|
env,
|
|
7304
7333
|
owner: { bindingId: input.host.bindingId }
|
|
7305
7334
|
});
|
|
7306
|
-
const
|
|
7335
|
+
const collected = Promise.all([
|
|
7307
7336
|
collectText(spawned.stdout, input.maxOutputBytes ?? Number.POSITIVE_INFINITY),
|
|
7308
7337
|
collectText(spawned.stderr, input.maxOutputBytes ?? Number.POSITIVE_INFINITY),
|
|
7309
7338
|
spawned.exited
|
|
7310
7339
|
]);
|
|
7311
|
-
|
|
7340
|
+
if (input.timeoutMs === void 0) {
|
|
7341
|
+
const [stdout, stderr, exitCode] = await collected;
|
|
7342
|
+
return { stdout, stderr, exitCode };
|
|
7343
|
+
}
|
|
7344
|
+
let timer;
|
|
7345
|
+
const timedOut = new Promise((resolve2) => {
|
|
7346
|
+
timer = setTimeout(() => resolve2("timeout"), input.timeoutMs);
|
|
7347
|
+
});
|
|
7348
|
+
try {
|
|
7349
|
+
const settled = await Promise.race([collected, timedOut]);
|
|
7350
|
+
if (settled === "timeout") {
|
|
7351
|
+
collected.catch(() => void 0);
|
|
7352
|
+
await spawned.kill("SIGKILL").catch(() => void 0);
|
|
7353
|
+
throw new Error(`OpenCode CLI ${input.args.join(" ")} timed out after ${input.timeoutMs}ms.`);
|
|
7354
|
+
}
|
|
7355
|
+
const [stdout, stderr, exitCode] = settled;
|
|
7356
|
+
return { stdout, stderr, exitCode };
|
|
7357
|
+
} finally {
|
|
7358
|
+
clearTimeout(timer);
|
|
7359
|
+
}
|
|
7312
7360
|
}
|
|
7313
7361
|
async function withOneSecondRetry(run) {
|
|
7314
7362
|
try {
|
|
@@ -7388,7 +7436,9 @@ async function loadInventoryFromCli(input) {
|
|
|
7388
7436
|
return [];
|
|
7389
7437
|
}
|
|
7390
7438
|
};
|
|
7391
|
-
const
|
|
7439
|
+
const models = await modelsRun();
|
|
7440
|
+
const agents = await agentsRun();
|
|
7441
|
+
const skills = await skillsRun();
|
|
7392
7442
|
return inventoryFromCli(models, agents, skills);
|
|
7393
7443
|
}
|
|
7394
7444
|
async function loadOpenCodeInventory(client2, skillsClient = client2) {
|
|
@@ -7430,6 +7480,7 @@ async function loadOpenCodeInventory(client2, skillsClient = client2) {
|
|
|
7430
7480
|
}
|
|
7431
7481
|
|
|
7432
7482
|
// src/probe.ts
|
|
7483
|
+
var OPENCODE_VERSION_PROBE_TIMEOUT_MS = 4e3;
|
|
7433
7484
|
var OPENCODE_NATIVE_MODE_REPORT = {
|
|
7434
7485
|
nativeModes: OPENCODE_NATIVE_MODES.map((mode) => ({
|
|
7435
7486
|
id: mode.id,
|
|
@@ -7467,7 +7518,8 @@ async function probeOpenCode(input) {
|
|
|
7467
7518
|
host: input.host,
|
|
7468
7519
|
recipe: input.recipe,
|
|
7469
7520
|
program,
|
|
7470
|
-
args: ["--version"]
|
|
7521
|
+
args: ["--version"],
|
|
7522
|
+
timeoutMs: OPENCODE_VERSION_PROBE_TIMEOUT_MS
|
|
7471
7523
|
});
|
|
7472
7524
|
version = parseGenericCliVersion(`${result.stdout}
|
|
7473
7525
|
${result.stderr}`);
|
|
@@ -8932,7 +8984,10 @@ function createOpenCodeInstance(config, host, attachments) {
|
|
|
8932
8984
|
password: server.password
|
|
8933
8985
|
});
|
|
8934
8986
|
const nativeModeId = openCodeNativeModeFor(input.runtimeMode, input.nativeModeId);
|
|
8935
|
-
const permission = openCodePermissionRulesForNativeMode(
|
|
8987
|
+
const permission = openCodePermissionRulesForNativeMode(
|
|
8988
|
+
nativeModeId,
|
|
8989
|
+
input.readOnlyDirectories
|
|
8990
|
+
);
|
|
8936
8991
|
const resume = input.discardResumeCursor === true ? void 0 : parseOpenCodeResume(input.resumeCursor);
|
|
8937
8992
|
let sessionId;
|
|
8938
8993
|
let createdSession = false;
|
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.2510",
|
|
4
4
|
"description": "OpenCode executor: OpenCode CLI via @opencode-ai/sdk/v2.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ycodium",
|
|
@@ -24,7 +24,7 @@
|
|
|
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.2510",
|
|
28
28
|
"ycodium-executor-testing": "0.0.0"
|
|
29
29
|
},
|
|
30
30
|
"ycodium": {
|