@ycodium-ai/agent-opencode 0.2.4486 → 0.2.5004
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 +44 -2
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ const require = __ycodiumCreateRequire(import.meta.url);
|
|
|
5
5
|
import { definePlugin } from "@ycodium-ai/plugin-api";
|
|
6
6
|
|
|
7
7
|
// ../../packages/plugin-api/src/version.ts
|
|
8
|
-
var PLUGIN_API_VERSION =
|
|
8
|
+
var PLUGIN_API_VERSION = 142;
|
|
9
9
|
|
|
10
10
|
// src/card.ts
|
|
11
11
|
var OPENCODE_DRIVER_KIND = "opencode";
|
|
@@ -39,6 +39,7 @@ var OPENCODE_CARD = {
|
|
|
39
39
|
modelSlugAliases: null,
|
|
40
40
|
// 型号全在用户自己的 OpenCode 配置里:目录外的型号这只手起不来。
|
|
41
41
|
modelCatalogAuthoritative: true,
|
|
42
|
+
mcpToolCallCeilingSeconds: 300,
|
|
42
43
|
mcpTransports: ["stdio", "http"],
|
|
43
44
|
pluginManaged: true,
|
|
44
45
|
// 会话 server 的配置里 `skills` 加上会话技能目录:OpenCode 2.0.26 实测 `GET /api/skill` 列得出只在那个
|
|
@@ -107,6 +108,7 @@ var OPENCODE_CARD = {
|
|
|
107
108
|
type: "string",
|
|
108
109
|
"x-ycodium-form": {
|
|
109
110
|
titleKey: "form.homePath.title",
|
|
111
|
+
machineLocal: true,
|
|
110
112
|
descriptionKey: "form.homePath.description",
|
|
111
113
|
placeholderKey: "form.homePath.placeholder"
|
|
112
114
|
}
|
|
@@ -2039,15 +2041,18 @@ function createOpenCodeApi(server) {
|
|
|
2039
2041
|
// src/mcpServers.ts
|
|
2040
2042
|
function toOpenCodeMcpConfig(server) {
|
|
2041
2043
|
const transport = server.transport;
|
|
2044
|
+
const timeout = server.toolTimeoutSeconds === void 0 ? {} : { timeout: { execution: server.toolTimeoutSeconds * 1e3 } };
|
|
2042
2045
|
if (transport.type === "stdio") {
|
|
2043
2046
|
return {
|
|
2044
2047
|
type: "local",
|
|
2048
|
+
...timeout,
|
|
2045
2049
|
command: [transport.command, ...transport.args ?? []],
|
|
2046
2050
|
...transport.env ? { environment: { ...transport.env } } : {}
|
|
2047
2051
|
};
|
|
2048
2052
|
}
|
|
2049
2053
|
return {
|
|
2050
2054
|
type: "remote",
|
|
2055
|
+
...timeout,
|
|
2051
2056
|
url: transport.url,
|
|
2052
2057
|
...transport.headers ? { headers: { ...transport.headers } } : {},
|
|
2053
2058
|
// 带着宿主给的凭据,别让 OpenCode 碰到 401 就去走 OAuth 发现。
|
|
@@ -2828,6 +2833,33 @@ function handleOpenCodeCompactionEvent(input) {
|
|
|
2828
2833
|
}
|
|
2829
2834
|
}
|
|
2830
2835
|
|
|
2836
|
+
// src/permissionStatement.ts
|
|
2837
|
+
var RESOURCE_ARG_BY_ACTION = {
|
|
2838
|
+
external_directory: "path",
|
|
2839
|
+
webfetch: "url",
|
|
2840
|
+
websearch: "query"
|
|
2841
|
+
};
|
|
2842
|
+
var PATCH_METADATA_ARGS = ["files", "diff"];
|
|
2843
|
+
var nonEmpty = (value) => typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
2844
|
+
function openCodePermissionRequest(input) {
|
|
2845
|
+
const metadata = isRecord2(input.metadata) ? input.metadata : void 0;
|
|
2846
|
+
const resourceArg = RESOURCE_ARG_BY_ACTION[input.action];
|
|
2847
|
+
const resource = resourceArg !== void 0 && metadata?.[resourceArg] === void 0 && input.resources.length > 0 ? { [resourceArg]: input.resources.join("\n") } : void 0;
|
|
2848
|
+
const args = metadata === void 0 && resource === void 0 ? void 0 : { ...resource, ...metadata };
|
|
2849
|
+
const itemType = input.toolItemType;
|
|
2850
|
+
const description = itemType === "command_execution" || itemType === "collab_agent_tool_call" ? nonEmpty(input.toolInput?.["description"]) : void 0;
|
|
2851
|
+
const command = input.action === "shell" ? nonEmpty(input.toolInput?.["command"]) ?? nonEmpty(input.resources.join("\n")) : void 0;
|
|
2852
|
+
const coveredArgs = input.hasFileChanges && metadata !== void 0 ? PATCH_METADATA_ARGS.filter((name) => metadata[name] !== void 0) : [];
|
|
2853
|
+
return {
|
|
2854
|
+
args,
|
|
2855
|
+
statement: {
|
|
2856
|
+
...description !== void 0 ? { description } : {},
|
|
2857
|
+
...command !== void 0 ? { command } : {},
|
|
2858
|
+
...coveredArgs.length > 0 ? { coveredArgs } : {}
|
|
2859
|
+
}
|
|
2860
|
+
};
|
|
2861
|
+
}
|
|
2862
|
+
|
|
2831
2863
|
// src/toolEvents.ts
|
|
2832
2864
|
var text2 = (data, key) => {
|
|
2833
2865
|
const value = data[key];
|
|
@@ -2936,6 +2968,15 @@ async function openPermission(context, data) {
|
|
|
2936
2968
|
const fileChanges = fileChangesOf(data["metadata"]);
|
|
2937
2969
|
const source = data["source"];
|
|
2938
2970
|
const toolCallId = isRecord2(source) ? text2(source, "id") : void 0;
|
|
2971
|
+
const toolName = toolCallId === void 0 ? void 0 : context.toolNames.get(toolCallId);
|
|
2972
|
+
const { args, statement } = openCodePermissionRequest({
|
|
2973
|
+
action,
|
|
2974
|
+
resources,
|
|
2975
|
+
metadata: data["metadata"],
|
|
2976
|
+
hasFileChanges: fileChanges !== void 0,
|
|
2977
|
+
toolItemType: toolName === void 0 ? void 0 : openCodeToolItemType(toolName),
|
|
2978
|
+
toolInput: toolCallId === void 0 ? void 0 : context.toolInputs.get(toolCallId)
|
|
2979
|
+
});
|
|
2939
2980
|
context.pendingPermissions.set(requestId, {
|
|
2940
2981
|
action,
|
|
2941
2982
|
sessionId,
|
|
@@ -2948,8 +2989,9 @@ async function openPermission(context, data) {
|
|
|
2948
2989
|
requestType,
|
|
2949
2990
|
detail: resources.length > 0 ? resources.join("\n") : action,
|
|
2950
2991
|
...requestType === "unknown" ? { toolName: action } : {},
|
|
2951
|
-
...
|
|
2992
|
+
...args === void 0 ? {} : { args },
|
|
2952
2993
|
...fileChanges ? { fileChanges } : {},
|
|
2994
|
+
statement,
|
|
2953
2995
|
declineReasonRelay: "native"
|
|
2954
2996
|
},
|
|
2955
2997
|
{ requestId }
|
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.5004",
|
|
4
4
|
"description": "OpenCode executor: OpenCode CLI (2.x) over its HTTP API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ycodium",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"@types/node": "24.12.4",
|
|
22
22
|
"esbuild": "0.28.1",
|
|
23
23
|
"vite-plus": "0.2.2",
|
|
24
|
-
"@ycodium-ai/plugin-api": "0.2.4486",
|
|
25
|
-
"ycodium-executor-testing": "0.0.0",
|
|
26
24
|
"ycodium-fetch-ports": "0.0.0",
|
|
25
|
+
"ycodium-executor-testing": "0.0.0",
|
|
26
|
+
"@ycodium-ai/plugin-api": "0.2.5004",
|
|
27
27
|
"ycodium-sse-stream": "0.0.0"
|
|
28
28
|
},
|
|
29
29
|
"ycodium": {
|