@cotal-ai/connector-opencode 0.3.1 → 0.4.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/README.md +11 -0
- package/dist/extension.d.ts.map +1 -1
- package/dist/extension.js +31 -2
- package/dist/extension.js.map +1 -1
- package/dist/plugin.bundle.js +647 -198
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +62 -28
- package/dist/plugin.js.map +1 -1
- package/dist/serve.js +15 -11
- package/dist/serve.js.map +1 -1
- package/package.json +4 -3
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# @cotal-ai/connector-opencode
|
|
2
|
+
|
|
3
|
+
The OpenCode adapter: a native in-process plugin injected at launch via
|
|
4
|
+
`OPENCODE_CONFIG_CONTENT`, rendering the shared `cotal_*` tools as plugin tools. A thin client
|
|
5
|
+
over [`@cotal-ai/connector-core`](../connector-core).
|
|
6
|
+
|
|
7
|
+
**Tier:** `extensions/`. Peer-depends [`@cotal-ai/core`](../../packages/core); self-registers on
|
|
8
|
+
import.
|
|
9
|
+
|
|
10
|
+
See [docs/architecture.md](../../docs/architecture.md) (*Integration surfaces*) and the
|
|
11
|
+
[root AGENTS.md](../../AGENTS.md) for the tier rules.
|
package/dist/extension.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":"AAEA,OAAO,EAA2B,KAAK,SAAS,EAAoC,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":"AAEA,OAAO,EAA2B,KAAK,SAAS,EAAoC,MAAM,gBAAgB,CAAC;AAa3G;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAsE/B,CAAC"}
|
package/dist/extension.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { fileURLToPath } from "node:url";
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
3
|
import { loadAgentFile, registry } from "@cotal-ai/core";
|
|
4
|
+
import { launchEnv, MODEL_PROVIDER_KEYS } from "@cotal-ai/connector-core";
|
|
4
5
|
/** The bundled in-process plugin (esbuild → `dist/plugin.bundle.js`). `opencode serve` loads it by
|
|
5
6
|
* absolute path from the inline config, so it runs *inside* the server and shares its SDK client.
|
|
6
7
|
* Resolved relative to this module — beside the built `dist/extension.js`, so the connector must be
|
|
@@ -27,9 +28,25 @@ export const opencodeConnector = {
|
|
|
27
28
|
kind: "connector",
|
|
28
29
|
name: "opencode",
|
|
29
30
|
buildLaunch(opts) {
|
|
31
|
+
// Tool-sharing isn't wired for opencode: its OPENCODE_CONFIG_CONTENT is a merge layer, so an
|
|
32
|
+
// opencode agent already INHERITS the operator's MCP servers (the opposite default to Claude's
|
|
33
|
+
// strict isolation). A `connectors.opencode.mcpServers` entry would need inverse (opt-OUT)
|
|
34
|
+
// semantics that don't exist yet — throw rather than silently ignore it (no fallbacks).
|
|
35
|
+
if (opts.mcpServers && Object.keys(opts.mcpServers).length > 0)
|
|
36
|
+
throw new Error("opencode connector: tool-sharing (connectors.opencode.mcpServers) is not implemented. " +
|
|
37
|
+
"opencode agents currently inherit the operator's MCP servers through its config merge " +
|
|
38
|
+
"layer; restricting that down to a chosen subset needs an inverse opt-out filter, which " +
|
|
39
|
+
"is a separate feature.");
|
|
30
40
|
// Identity rides the process env: the plugin runs in the opencode process and inherits it
|
|
31
|
-
// (unlike the Claude Code MCP server, which gets none of the parent env).
|
|
32
|
-
|
|
41
|
+
// (unlike the Claude Code MCP server, which gets none of the parent env). The OS allow-list +
|
|
42
|
+
// the named model-provider key (opencode's hosted models read OPENCODE_API_KEY; other
|
|
43
|
+
// providers read their own) are forwarded BY NAME — never `...process.env` — so the operator's
|
|
44
|
+
// unrelated secrets don't reach the child (P3).
|
|
45
|
+
const env = {
|
|
46
|
+
...launchEnv({ providerKeys: MODEL_PROVIDER_KEYS }),
|
|
47
|
+
COTAL_SPACE: opts.space,
|
|
48
|
+
COTAL_NAME: opts.name,
|
|
49
|
+
};
|
|
33
50
|
if (opts.role)
|
|
34
51
|
env.COTAL_ROLE = opts.role;
|
|
35
52
|
if (opts.id)
|
|
@@ -42,6 +59,18 @@ export const opencodeConnector = {
|
|
|
42
59
|
$schema: "https://opencode.ai/config.json",
|
|
43
60
|
permission: "allow",
|
|
44
61
|
plugin: [PLUGIN_ENTRY],
|
|
62
|
+
// `/reconnect` — the manual recovery surface for a wedged mesh link. OpenCode has no
|
|
63
|
+
// host reconnect (unlike Claude Code's /mcp reconnect), and a plugin can't register a
|
|
64
|
+
// slash command via the Hooks API, so inject it through the config layer we already own.
|
|
65
|
+
// It's a TOOL-FORCING template: the human types /reconnect → one model turn whose only
|
|
66
|
+
// move is to call `cotal_reconnect` (in-process, local — it never rides the wedged link).
|
|
67
|
+
// The leading "Reconnecting…" reads as immediate TUI status; the rest is the imperative.
|
|
68
|
+
command: {
|
|
69
|
+
reconnect: {
|
|
70
|
+
description: "Rebuild this session's Cotal mesh connection (recovery from a wedged link)",
|
|
71
|
+
template: "Reconnecting to the Cotal mesh… Call the cotal_reconnect tool now — do not explain, do not ask, just invoke it. Do not summarize — the tool reports its own status.",
|
|
72
|
+
},
|
|
73
|
+
},
|
|
45
74
|
};
|
|
46
75
|
// An agent file carries identity (read in-session via COTAL_AGENT_FILE) plus persona + model.
|
|
47
76
|
// The model is a config default (the session — and the attached TUI — use it); the persona is
|
package/dist/extension.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAoD,MAAM,gBAAgB,CAAC;
|
|
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