@ycodium-ai/agent-opencode 0.2.2729 → 0.2.2743

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.
Files changed (2) hide show
  1. package/dist/index.js +56 -0
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -7917,6 +7917,57 @@ ${result.stderr}`);
7917
7917
  }
7918
7918
  }
7919
7919
 
7920
+ // src/mcpServers.ts
7921
+ function toOpenCodeMcpConfig(server) {
7922
+ const transport = server.transport;
7923
+ if (transport.type === "stdio") {
7924
+ return {
7925
+ type: "local",
7926
+ command: [transport.command, ...transport.args ?? []],
7927
+ ...transport.env ? { environment: { ...transport.env } } : {}
7928
+ };
7929
+ }
7930
+ return {
7931
+ type: "remote",
7932
+ url: transport.url,
7933
+ ...transport.headers ? { headers: { ...transport.headers } } : {},
7934
+ // 带着宿主给的凭据,别让 OpenCode 碰到 401 就去走 OAuth 发现。
7935
+ oauth: false
7936
+ };
7937
+ }
7938
+ function failureSummary(cause) {
7939
+ if (cause instanceof Error) return { error: cause.name, message: cause.message };
7940
+ if (cause !== null && typeof cause === "object") {
7941
+ const record = cause;
7942
+ return {
7943
+ error: typeof record.name === "string" ? record.name : "unknown",
7944
+ ...typeof record.status === "number" ? { status: record.status } : {}
7945
+ };
7946
+ }
7947
+ return { error: typeof cause };
7948
+ }
7949
+ async function addOpenCodeMcpServers(input) {
7950
+ for (const server of input.servers ?? []) {
7951
+ let failure;
7952
+ try {
7953
+ const added = await input.client.mcp.add({
7954
+ name: server.name,
7955
+ config: toOpenCodeMcpConfig(server)
7956
+ });
7957
+ const status = added.data?.[server.name]?.status;
7958
+ if (status !== "connected") failure = status === void 0 ? {} : { status };
7959
+ } catch (cause) {
7960
+ failure = failureSummary(cause);
7961
+ }
7962
+ if (failure === void 0) continue;
7963
+ input.log.warn("OpenCode could not attach an MCP server; the session continues without it.", {
7964
+ name: server.name,
7965
+ transport: server.transport.type,
7966
+ ...failure
7967
+ });
7968
+ }
7969
+ }
7970
+
7920
7971
  // src/workspaceInventory.ts
7921
7972
  import * as NodePath5 from "node:path";
7922
7973
  var isInside = (directory, file) => {
@@ -9645,6 +9696,11 @@ function createOpenCodeInstance(config, host, attachments) {
9645
9696
  if (server.external) {
9646
9697
  const tooOld = openCodeTooOldDetail(await readOpenCodeServerVersion(client2));
9647
9698
  if (tooOld) throw new Error(tooOld);
9699
+ if ((input.mcpServers?.length ?? 0) > 0) {
9700
+ host.log.info("OpenCode runs on an external server; Ycodium does not add MCP servers.");
9701
+ }
9702
+ } else {
9703
+ await addOpenCodeMcpServers({ client: client2, servers: input.mcpServers, log: host.log });
9648
9704
  }
9649
9705
  const nativeModeId = openCodeNativeModeFor(input.runtimeMode, input.nativeModeId);
9650
9706
  const permission = openCodePermissionRulesForNativeMode(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-opencode",
3
- "version": "0.2.2729",
3
+ "version": "0.2.2743",
4
4
  "description": "OpenCode executor: OpenCode CLI via @opencode-ai/sdk/v2.",
5
5
  "keywords": [
6
6
  "ycodium",
@@ -24,8 +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.2729",
28
27
  "ycodium-fetch-ports": "0.0.0",
28
+ "@ycodium-ai/plugin-api": "0.2.2743",
29
29
  "ycodium-executor-testing": "0.0.0"
30
30
  },
31
31
  "ycodium": {