@cotal-ai/connector-opencode 0.68.0 → 0.70.0
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/agui-map.d.ts +1 -14
- package/dist/agui-map.d.ts.map +1 -1
- package/dist/extension.d.ts +1 -1
- package/dist/index.js +16 -8
- package/dist/launch.d.ts +14 -0
- package/dist/launch.d.ts.map +1 -0
- package/dist/launch.js +195 -0
- package/dist/opencode-line.d.ts +1 -1
- package/dist/plugin/index.js +3506 -3458
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin2.d.ts.map +1 -1
- package/dist/serve.js +20 -10
- package/package.json +4 -4
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAuCA,OAAO,EAGL,SAAS,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAuCA,OAAO,EAGL,SAAS,EAqBV,MAAM,0BAA0B,CAAC;AAMlC,OAAO,KAAK,EAAE,MAAM,EAAyB,MAAM,qBAAqB,CAAC;AAgBzE;;;0EAG0E;AAC1E,eAAO,MAAM,eAAe,6BAA6B,CAAC;AAC1D,gGAAgG;AAChG,eAAO,MAAM,gBAAgB,8BAA8B,CAAC;AAC5D;iEACiE;AACjE,eAAO,MAAM,UAAU,wBAAwB,CAAC;AAChD;;gCAEgC;AAChC,eAAO,MAAM,QAAQ,sBAAsB,CAAC;AAC5C;;0EAE0E;AAC1E,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAElF;AACD,wBAAsB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAYnH;AA8BD;;;;GAIG;AACH,iBAAe,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAqB1G;AACD,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,GAAG;IAClD,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,GAAG,SAAS,CAQZ;AAED,eAAO,MAAM,KAAK,EAAE,MA4vCnB,CAAC"}
|
package/dist/plugin2.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin2.d.ts","sourceRoot":"","sources":["../src/plugin2.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAiB7D;;;;;;8EAM8E;AAC9E,eAAO,MAAM,oBAAoB,QAAS,CAAC;AAoC3C,4CAA4C;AAC5C,wBAAsB,UAAU,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"plugin2.d.ts","sourceRoot":"","sources":["../src/plugin2.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAiB7D;;;;;;8EAM8E;AAC9E,eAAO,MAAM,oBAAoB,QAAS,CAAC;AAoC3C,4CAA4C;AAC5C,wBAAsB,UAAU,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAmT7F"}
|
package/dist/serve.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/launch.ts
|
|
2
2
|
import { execFileSync, spawn } from "node:child_process";
|
|
3
3
|
import { createServer } from "node:net";
|
|
4
4
|
import { once } from "node:events";
|
|
@@ -16,7 +16,7 @@ function opencodeLine(raw, bin) {
|
|
|
16
16
|
);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
// src/
|
|
19
|
+
// src/launch.ts
|
|
20
20
|
function resolveOpencodeBin() {
|
|
21
21
|
const override = process.env.COTAL_OPENCODE_BIN?.trim() || process.env.COTAL_OPENCODE_RESOLVED_BIN?.trim();
|
|
22
22
|
if (override) return override;
|
|
@@ -31,7 +31,7 @@ function resolveOpencodeBin() {
|
|
|
31
31
|
}
|
|
32
32
|
var BIN = resolveOpencodeBin();
|
|
33
33
|
var USERNAME = "opencode";
|
|
34
|
-
var SECRET = randomBytes(24).toString("hex");
|
|
34
|
+
var SECRET = process.env.OPENCODE_SERVER_PASSWORD || randomBytes(24).toString("hex");
|
|
35
35
|
async function freePort() {
|
|
36
36
|
const srv = createServer();
|
|
37
37
|
srv.listen(0, "127.0.0.1");
|
|
@@ -81,7 +81,7 @@ function isLiveOpencodeServe(pid) {
|
|
|
81
81
|
if (!cmd) return true;
|
|
82
82
|
return /\bserve\b/.test(cmd) && (/(?:^|[\\/\s])opencode(?:\.exe)?(?:\s|$)/i.test(cmd) || /--hostname\s+127\.0\.0\.1\b/.test(cmd) && /--port\s+\d+\b/.test(cmd));
|
|
83
83
|
}
|
|
84
|
-
async function
|
|
84
|
+
async function launch(tuiArgv, serveEnv) {
|
|
85
85
|
const port = process.env.COTAL_OPENCODE_PORT?.trim() || String(await freePort());
|
|
86
86
|
const url = `http://127.0.0.1:${port}`;
|
|
87
87
|
const name = process.env.COTAL_NAME?.trim() || "agent";
|
|
@@ -90,11 +90,17 @@ async function main() {
|
|
|
90
90
|
const agentHome = join(dataRoot, ".cotal", "opencode", name);
|
|
91
91
|
const dbPath = join(agentHome, "opencode.db");
|
|
92
92
|
const pidFile = join(agentHome, "serve.pid");
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
let recorded;
|
|
94
|
+
try {
|
|
95
|
+
recorded = readFileSync(pidFile, "utf8");
|
|
96
|
+
} catch (e) {
|
|
97
|
+
if (e.code !== "ENOENT") throw e;
|
|
98
|
+
}
|
|
99
|
+
if (recorded !== void 0) {
|
|
100
|
+
const pid = Number(recorded);
|
|
95
101
|
if (isLiveOpencodeServe(pid))
|
|
96
102
|
throw new Error(`agent "${name}" is already running (opencode serve pid ${pid}) \u2014 kill it first`);
|
|
97
|
-
rmSync(pidFile);
|
|
103
|
+
rmSync(pidFile, { force: true });
|
|
98
104
|
}
|
|
99
105
|
const versionRaw = execFileSync(BIN, ["--version"], { encoding: "utf8" }).trim();
|
|
100
106
|
const line = opencodeLine(versionRaw, BIN);
|
|
@@ -102,6 +108,7 @@ async function main() {
|
|
|
102
108
|
const serve = spawn(BIN, ["serve", "--hostname", "127.0.0.1", "--port", port], {
|
|
103
109
|
env: {
|
|
104
110
|
...process.env,
|
|
111
|
+
...serveEnv?.(agentHome),
|
|
105
112
|
COTAL_OPENCODE_SERVER_URL: url,
|
|
106
113
|
COTAL_OPENCODE_LINE: String(line),
|
|
107
114
|
OPENCODE_SERVER_USERNAME: USERNAME,
|
|
@@ -155,7 +162,7 @@ async function main() {
|
|
|
155
162
|
process.exit(1);
|
|
156
163
|
}
|
|
157
164
|
if (process.env.COTAL_SERVE_HEADLESS?.trim() === "1") {
|
|
158
|
-
process.stdout.write(`[cotal-serve] ${JSON.stringify({ port: Number(port), session: id
|
|
165
|
+
process.stdout.write(`[cotal-serve] ${JSON.stringify({ port: Number(port), session: id })}
|
|
159
166
|
`);
|
|
160
167
|
for (const sig of ["SIGINT", "SIGTERM"])
|
|
161
168
|
process.on(sig, () => void terminate(serve).then(() => process.exit(0)));
|
|
@@ -170,7 +177,8 @@ async function main() {
|
|
|
170
177
|
delete tuiEnv.OPENCODE_CONFIG_CONTENT;
|
|
171
178
|
for (const k of Object.keys(tuiEnv)) if (k.startsWith("COTAL_")) delete tuiEnv[k];
|
|
172
179
|
attached = true;
|
|
173
|
-
const
|
|
180
|
+
const [command, ...args] = tuiArgv({ url, session: id, line });
|
|
181
|
+
const tui = spawn(command, args, { env: tuiEnv, stdio: "inherit" });
|
|
174
182
|
for (const sig of ["SIGINT", "SIGTERM"])
|
|
175
183
|
process.on(sig, () => {
|
|
176
184
|
tui.kill(sig);
|
|
@@ -181,4 +189,6 @@ async function main() {
|
|
|
181
189
|
void terminate(serve).then(() => process.exit(code ?? (signal ? 1 : 0)));
|
|
182
190
|
});
|
|
183
191
|
}
|
|
184
|
-
|
|
192
|
+
|
|
193
|
+
// src/serve.ts
|
|
194
|
+
void launch(({ url, session, line }) => line === 2 ? [BIN, "--server", url, "--session", session] : [BIN, "attach", url, "--session", session]);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cotal-ai/connector-opencode",
|
|
3
3
|
"description": "Cotal connector for OpenCode: a native in-process plugin that joins a session to the mesh.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.70.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"@cotal-ai/core": ">=0.1.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@cotal-ai/connector-core": "0.
|
|
25
|
-
"@cotal-ai/core": "0.
|
|
24
|
+
"@cotal-ai/connector-core": "0.70.0",
|
|
25
|
+
"@cotal-ai/core": "0.70.0",
|
|
26
26
|
"@cotal-ai/smoke-kit": "0.0.0",
|
|
27
27
|
"@nats-io/transport-node": "^3.4.0",
|
|
28
28
|
"@opencode-ai/plugin": "^1.16.2",
|
|
@@ -39,6 +39,6 @@
|
|
|
39
39
|
"test": "tsx smoke/tool-input-closed.smoke.ts",
|
|
40
40
|
"typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.smoke.json",
|
|
41
41
|
"build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.json --emitDeclarationOnly && pnpm run bundle",
|
|
42
|
-
"bundle": "esbuild src/index.ts --bundle --platform=node --format=esm --target=node20 --outfile=dist/index.js --external:@cotal-ai/core && esbuild src/plugin.entry.ts --bundle --platform=node --format=esm --target=node20 --outfile=dist/plugin/index.js && esbuild src/serve.ts --bundle --platform=node --format=esm --target=node20 --outfile=dist/serve.js"
|
|
42
|
+
"bundle": "esbuild src/index.ts --bundle --platform=node --format=esm --target=node20 --outfile=dist/index.js --external:@cotal-ai/core && esbuild src/plugin.entry.ts --bundle --platform=node --format=esm --target=node20 --outfile=dist/plugin/index.js && esbuild src/serve.ts --bundle --platform=node --format=esm --target=node20 --outfile=dist/serve.js && esbuild src/launch.ts --bundle --platform=node --format=esm --target=node20 --outfile=dist/launch.js"
|
|
43
43
|
}
|
|
44
44
|
}
|