@ycodium-ai/agent-opencode 0.2.2169 → 0.2.2488
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 +98 -71
- package/locales/en.json +24 -0
- package/locales/zh-CN.json +24 -0
- package/package.json +4 -2
package/dist/index.js
CHANGED
|
@@ -538,7 +538,6 @@ import { definePlugin } from "@ycodium-ai/plugin-api";
|
|
|
538
538
|
|
|
539
539
|
// src/card.ts
|
|
540
540
|
var OPENCODE_DRIVER_KIND = "opencode";
|
|
541
|
-
var OPENCODE_BINDING_PROVIDER_ID = "ycodium";
|
|
542
541
|
var OPENCODE_CARD = {
|
|
543
542
|
driverKind: OPENCODE_DRIVER_KIND,
|
|
544
543
|
displayName: "OpenCode",
|
|
@@ -565,9 +564,6 @@ var OPENCODE_CARD = {
|
|
|
565
564
|
defaultTextGenerationModel: "openai/gpt-5",
|
|
566
565
|
customModelIdExample: "openai/gpt-5",
|
|
567
566
|
modelSlugAliases: {},
|
|
568
|
-
modelsDevProviderIds: [],
|
|
569
|
-
modelsDevSlugPrefixed: true,
|
|
570
|
-
modelSlugPrefix: "",
|
|
571
567
|
mcpTransports: ["stdio", "http"],
|
|
572
568
|
pluginManaged: true,
|
|
573
569
|
verifiedSkills: true,
|
|
@@ -586,14 +582,47 @@ var OPENCODE_CARD = {
|
|
|
586
582
|
// OpenCode 凭据由 CLI 自己管在 XDG 目录,probe 从已连接 provider 推断,不读 auth.json。
|
|
587
583
|
credentialSources: [],
|
|
588
584
|
diagnostics: [],
|
|
585
|
+
// 设置表单照这份画:带 x-ycodium-form 的属性才进表单(enabled、customModels 等另有入口,不在此列),
|
|
586
|
+
// 顺序看 x-ycodium-form-order;文案键在本插件 locales/<locale>.json 里解析,宿主不兜底。
|
|
589
587
|
configSchema: {
|
|
590
588
|
type: "object",
|
|
589
|
+
"x-ycodium-form-order": ["binaryPath", "serverUrl", "serverPassword", "homePath"],
|
|
591
590
|
properties: {
|
|
592
591
|
enabled: { type: "boolean" },
|
|
593
|
-
binaryPath: {
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
592
|
+
binaryPath: {
|
|
593
|
+
type: "string",
|
|
594
|
+
"x-ycodium-form": {
|
|
595
|
+
titleKey: "form.binaryPath.title",
|
|
596
|
+
descriptionKey: "form.binaryPath.description",
|
|
597
|
+
placeholderKey: "form.binaryPath.placeholder",
|
|
598
|
+
control: "executable-path"
|
|
599
|
+
}
|
|
600
|
+
},
|
|
601
|
+
serverUrl: {
|
|
602
|
+
type: "string",
|
|
603
|
+
"x-ycodium-form": {
|
|
604
|
+
titleKey: "form.serverUrl.title",
|
|
605
|
+
descriptionKey: "form.serverUrl.description",
|
|
606
|
+
placeholderKey: "form.serverUrl.placeholder"
|
|
607
|
+
}
|
|
608
|
+
},
|
|
609
|
+
serverPassword: {
|
|
610
|
+
type: "string",
|
|
611
|
+
"x-ycodium-form": {
|
|
612
|
+
titleKey: "form.serverPassword.title",
|
|
613
|
+
descriptionKey: "form.serverPassword.description",
|
|
614
|
+
placeholderKey: "form.serverPassword.placeholder",
|
|
615
|
+
control: "password"
|
|
616
|
+
}
|
|
617
|
+
},
|
|
618
|
+
homePath: {
|
|
619
|
+
type: "string",
|
|
620
|
+
"x-ycodium-form": {
|
|
621
|
+
titleKey: "form.homePath.title",
|
|
622
|
+
descriptionKey: "form.homePath.description",
|
|
623
|
+
placeholderKey: "form.homePath.placeholder"
|
|
624
|
+
}
|
|
625
|
+
},
|
|
597
626
|
customModels: { type: "array" },
|
|
598
627
|
driver: { type: "string" },
|
|
599
628
|
config: { type: "object" },
|
|
@@ -602,29 +631,26 @@ var OPENCODE_CARD = {
|
|
|
602
631
|
additionalProperties: true
|
|
603
632
|
},
|
|
604
633
|
modelConnectivity: {
|
|
605
|
-
//
|
|
606
|
-
// `/chat/completions
|
|
607
|
-
// 不算——投递不换这一栏。别家的脑经宿主翻译接上;打到别的路由的请求,本机端点按那一笔
|
|
608
|
-
// 的路径另挑翻译对。
|
|
634
|
+
// 只报下面那段配置说的格式:它把 `npm` 定死成 openai-compatible,后缀是
|
|
635
|
+
// `/chat/completions`,请求说 chat。换 `@ai-sdk/anthropic` 能说 messages 不算。
|
|
609
636
|
dialects: ["openai-chat-completions"],
|
|
610
637
|
acceptsExternalEndpoints: true,
|
|
611
638
|
supportsNativeSubscription: true,
|
|
612
639
|
// opencode 不认「地址一个变量、凭据一个变量」——它读的是
|
|
613
|
-
// `provider.<id>.options.{baseURL,apiKey}
|
|
640
|
+
// `provider.<id>.options.{baseURL,apiKey}`,而给这份配置最干净的路是
|
|
614
641
|
// `OPENCODE_CONFIG_CONTENT`(内联 JSON,压过磁盘上的全局与项目配置)。插件本来就在
|
|
615
|
-
// 设这个变量(`cliParse.ts` 的 `resolveOpenCodeConfigContent`),默认 `{}
|
|
642
|
+
// 设这个变量(`cliParse.ts` 的 `resolveOpenCodeConfigContent`),默认 `{}`,
|
|
643
|
+
// 机器环境里已有的值不覆盖。
|
|
616
644
|
//
|
|
617
645
|
// `npm: "@ai-sdk/openai-compatible"` 定死它说 chat-completions;换成
|
|
618
|
-
// `@ai-sdk/anthropic` 就是 messages——那时后缀与 `dialects`
|
|
619
|
-
// 认手说的方言,兼容判定据此挑直通还是翻译。
|
|
646
|
+
// `@ai-sdk/anthropic` 就是 messages——那时后缀与 `dialects` 要跟着一起换。
|
|
620
647
|
//
|
|
621
|
-
// **还有三层压在这个变量之上**:org 远程配置、`/etc/opencode/`、macOS MDM
|
|
622
|
-
// 代理时宿主会 logWarning(`provider.proxy.never-reached`)。
|
|
648
|
+
// **还有三层压在这个变量之上**:org 远程配置、`/etc/opencode/`、macOS MDM。
|
|
623
649
|
nativePathSuffix: "/chat/completions",
|
|
624
650
|
extraEnv: [
|
|
625
651
|
{
|
|
626
652
|
name: "OPENCODE_CONFIG_CONTENT",
|
|
627
|
-
value:
|
|
653
|
+
value: '{"provider":{"ycodium":{"npm":"@ai-sdk/openai-compatible","name":"Ycodium","options":{"baseURL":"$baseUrl","apiKey":"$credential"},"models":{"$model":{"name":"$model"}}}},"model":"ycodium/$model"}'
|
|
628
654
|
}
|
|
629
655
|
]
|
|
630
656
|
}
|
|
@@ -1194,7 +1220,7 @@ function isOpenCodeDefaultTitle(title) {
|
|
|
1194
1220
|
return OPENCODE_DEFAULT_TITLE_PATTERN.test(title);
|
|
1195
1221
|
}
|
|
1196
1222
|
function parseGenericCliVersion(output) {
|
|
1197
|
-
const match = output.match(/\
|
|
1223
|
+
const match = output.match(/\bv?(\d+\.\d+\.\d+)\b/);
|
|
1198
1224
|
return match?.[1] ?? null;
|
|
1199
1225
|
}
|
|
1200
1226
|
function compareSemverVersions(left, right) {
|
|
@@ -1263,12 +1289,6 @@ function modelIdFromSelection(selection) {
|
|
|
1263
1289
|
return typeof model === "string" ? model.trim() || void 0 : void 0;
|
|
1264
1290
|
}
|
|
1265
1291
|
function chooseOpenCodeModel(input) {
|
|
1266
|
-
if (input.boundModelId !== void 0) {
|
|
1267
|
-
const bound = input.match(input.requested, [
|
|
1268
|
-
`${OPENCODE_BINDING_PROVIDER_ID}/${input.boundModelId}`
|
|
1269
|
-
]);
|
|
1270
|
-
return parseOpenCodeModelSlug(bound) ?? void 0;
|
|
1271
|
-
}
|
|
1272
1292
|
const own = parseOpenCodeModelSlug(input.requested);
|
|
1273
1293
|
if (own) return own;
|
|
1274
1294
|
input.match(input.requested, []);
|
|
@@ -1375,6 +1395,22 @@ function openCodeProbeModels(inventory) {
|
|
|
1375
1395
|
...model.capabilities.optionDescriptors.length > 0 ? { capabilities: model.capabilities } : {}
|
|
1376
1396
|
}));
|
|
1377
1397
|
}
|
|
1398
|
+
function flattenOpenCodeSkills(skills) {
|
|
1399
|
+
const flattened = [];
|
|
1400
|
+
for (const skill of skills ?? []) {
|
|
1401
|
+
const name = nonEmptyTrimmed(skill.name);
|
|
1402
|
+
const path = nonEmptyTrimmed(skill.location);
|
|
1403
|
+
if (!name || !path) continue;
|
|
1404
|
+
const description = nonEmptyTrimmed(skill.description);
|
|
1405
|
+
flattened.push({
|
|
1406
|
+
name,
|
|
1407
|
+
path,
|
|
1408
|
+
enabled: true,
|
|
1409
|
+
...description ? { description, shortDescription: description } : {}
|
|
1410
|
+
});
|
|
1411
|
+
}
|
|
1412
|
+
return flattened.toSorted((left, right) => left.name.localeCompare(right.name));
|
|
1413
|
+
}
|
|
1378
1414
|
function formatOpenCodeProbeError(input) {
|
|
1379
1415
|
const raw = toMessage(input.cause, String(input.cause));
|
|
1380
1416
|
const detail = hideGenericEffectText(raw);
|
|
@@ -1532,6 +1568,7 @@ function mapPermissionDecision(reply) {
|
|
|
1532
1568
|
}
|
|
1533
1569
|
|
|
1534
1570
|
// src/probe.ts
|
|
1571
|
+
import * as NodeOS4 from "node:os";
|
|
1535
1572
|
import {
|
|
1536
1573
|
ExecutorSpawnRefusedError as ExecutorSpawnRefusedError2
|
|
1537
1574
|
} from "@ycodium-ai/plugin-api/executor";
|
|
@@ -6946,8 +6983,7 @@ var import_cross_spawn = __toESM(require_cross_spawn(), 1);
|
|
|
6946
6983
|
// src/server.ts
|
|
6947
6984
|
import {
|
|
6948
6985
|
ExecutorSpawnRefusedError,
|
|
6949
|
-
mergeLaunchEnv
|
|
6950
|
-
brainSlotEnvKeys
|
|
6986
|
+
mergeLaunchEnv
|
|
6951
6987
|
} from "@ycodium-ai/plugin-api/executor";
|
|
6952
6988
|
|
|
6953
6989
|
// src/cliParse.ts
|
|
@@ -6959,8 +6995,8 @@ var OPENCODE_EMPTY_CONFIG_CONTENT = "{}";
|
|
|
6959
6995
|
var SLUG_LINE_RE = /^(\S+\/\S+)\s*$/;
|
|
6960
6996
|
var AGENT_HEADER_RE = /^(.+)\s+\((\S+)\)\s*$/;
|
|
6961
6997
|
var KNOWN_HIDDEN_AGENTS = /* @__PURE__ */ new Set(["compaction", "summary", "title"]);
|
|
6962
|
-
function resolveOpenCodeConfigContent(
|
|
6963
|
-
return
|
|
6998
|
+
function resolveOpenCodeConfigContent(inheritedEnvironment) {
|
|
6999
|
+
return inheritedEnvironment.OPENCODE_CONFIG_CONTENT ?? OPENCODE_EMPTY_CONFIG_CONTENT;
|
|
6964
7000
|
}
|
|
6965
7001
|
function parseServerUrlFromOutput(output) {
|
|
6966
7002
|
for (const line of output.split("\n")) {
|
|
@@ -7105,19 +7141,14 @@ async function findAvailablePort() {
|
|
|
7105
7141
|
});
|
|
7106
7142
|
});
|
|
7107
7143
|
}
|
|
7108
|
-
function buildSpawnEnv(
|
|
7109
|
-
const xdgHome = makeOpenCodeEnvironment(
|
|
7144
|
+
function buildSpawnEnv(recipe) {
|
|
7145
|
+
const xdgHome = makeOpenCodeEnvironment(recipe.homePath, {});
|
|
7110
7146
|
return mergeLaunchEnv({
|
|
7111
|
-
brainSlots: brainSlotEnvKeys(OPENCODE_CARD),
|
|
7112
7147
|
accountHome: xdgHome,
|
|
7113
|
-
instanceTable:
|
|
7148
|
+
instanceTable: recipe.environment,
|
|
7114
7149
|
handOverrides: {
|
|
7115
|
-
OPENCODE_CONFIG_CONTENT: resolveOpenCodeConfigContent(
|
|
7116
|
-
|
|
7117
|
-
input.processEnv ?? process.env
|
|
7118
|
-
)
|
|
7119
|
-
},
|
|
7120
|
-
launch: input.processEnv
|
|
7150
|
+
OPENCODE_CONFIG_CONTENT: resolveOpenCodeConfigContent(process.env)
|
|
7151
|
+
}
|
|
7121
7152
|
});
|
|
7122
7153
|
}
|
|
7123
7154
|
async function terminateOwnedProcess(handle) {
|
|
@@ -7149,7 +7180,7 @@ async function terminateOwnedProcess(handle) {
|
|
|
7149
7180
|
async function spawnOpenCodeServer(input) {
|
|
7150
7181
|
const port = await findAvailablePort();
|
|
7151
7182
|
const hostname = DEFAULT_HOSTNAME;
|
|
7152
|
-
const env = buildSpawnEnv(
|
|
7183
|
+
const env = buildSpawnEnv(input.recipe);
|
|
7153
7184
|
const spawned = await input.host.process.spawn({
|
|
7154
7185
|
program: input.program,
|
|
7155
7186
|
args: ["serve", `--hostname=${hostname}`, `--port=${port}`],
|
|
@@ -7241,7 +7272,6 @@ async function connectToOpenCodeServer(input) {
|
|
|
7241
7272
|
return spawnOpenCodeServer({
|
|
7242
7273
|
host: input.host,
|
|
7243
7274
|
recipe: input.recipe,
|
|
7244
|
-
processEnv: input.processEnv,
|
|
7245
7275
|
directory: input.directory,
|
|
7246
7276
|
program,
|
|
7247
7277
|
...input.onSpawn === void 0 ? {} : { onSpawn: input.onSpawn }
|
|
@@ -7265,7 +7295,7 @@ function createOpenCodeSdkClient(input) {
|
|
|
7265
7295
|
});
|
|
7266
7296
|
}
|
|
7267
7297
|
async function runOpenCodeCommand(input) {
|
|
7268
|
-
const env = buildSpawnEnv(
|
|
7298
|
+
const env = buildSpawnEnv(input.recipe);
|
|
7269
7299
|
const spawned = await input.host.process.spawn({
|
|
7270
7300
|
program: input.program,
|
|
7271
7301
|
args: [...input.args],
|
|
@@ -7304,13 +7334,12 @@ function inventoryFromCli(models, agents, skills) {
|
|
|
7304
7334
|
};
|
|
7305
7335
|
}
|
|
7306
7336
|
async function loadInventoryFromCli(input) {
|
|
7307
|
-
const run = (args, maxOutputBytes) => runOpenCodeCommand({
|
|
7337
|
+
const run = (args, maxOutputBytes, cwd = input.cwd) => runOpenCodeCommand({
|
|
7308
7338
|
host: input.host,
|
|
7309
7339
|
recipe: input.recipe,
|
|
7310
|
-
...input.processEnv ? { processEnv: input.processEnv } : {},
|
|
7311
7340
|
program: input.program,
|
|
7312
7341
|
args,
|
|
7313
|
-
...
|
|
7342
|
+
...cwd ? { cwd } : {},
|
|
7314
7343
|
...maxOutputBytes !== void 0 ? { maxOutputBytes } : {}
|
|
7315
7344
|
});
|
|
7316
7345
|
const modelsRun = async () => {
|
|
@@ -7343,7 +7372,11 @@ async function loadInventoryFromCli(input) {
|
|
|
7343
7372
|
const skillsRun = async () => {
|
|
7344
7373
|
try {
|
|
7345
7374
|
const result = await withOneSecondRetry(async () => {
|
|
7346
|
-
const command = await run(
|
|
7375
|
+
const command = await run(
|
|
7376
|
+
["debug", "skill"],
|
|
7377
|
+
OPENCODE_SKILL_DISCOVERY_MAX_OUTPUT_BYTES,
|
|
7378
|
+
input.skillsCwd ?? input.cwd
|
|
7379
|
+
);
|
|
7347
7380
|
if (command.exitCode !== 0) {
|
|
7348
7381
|
throw new Error(`opencode debug skill exited ${command.exitCode}`);
|
|
7349
7382
|
}
|
|
@@ -7358,7 +7391,7 @@ async function loadInventoryFromCli(input) {
|
|
|
7358
7391
|
const [models, agents, skills] = await Promise.all([modelsRun(), agentsRun(), skillsRun()]);
|
|
7359
7392
|
return inventoryFromCli(models, agents, skills);
|
|
7360
7393
|
}
|
|
7361
|
-
async function loadOpenCodeInventory(client2) {
|
|
7394
|
+
async function loadOpenCodeInventory(client2, skillsClient = client2) {
|
|
7362
7395
|
const listed = await client2.provider.list();
|
|
7363
7396
|
const providerList = listed.data;
|
|
7364
7397
|
if (!providerList) {
|
|
@@ -7373,7 +7406,7 @@ async function loadOpenCodeInventory(client2) {
|
|
|
7373
7406
|
}
|
|
7374
7407
|
let skills = [];
|
|
7375
7408
|
try {
|
|
7376
|
-
const listedSkills = await
|
|
7409
|
+
const listedSkills = await skillsClient.app.skills();
|
|
7377
7410
|
skills = (listedSkills.data ?? []).map((skill) => ({
|
|
7378
7411
|
name: skill.name,
|
|
7379
7412
|
...skill.description !== void 0 ? { description: skill.description } : {},
|
|
@@ -7433,7 +7466,6 @@ async function probeOpenCode(input) {
|
|
|
7433
7466
|
const result = await runOpenCodeCommand({
|
|
7434
7467
|
host: input.host,
|
|
7435
7468
|
recipe: input.recipe,
|
|
7436
|
-
...input.processEnv ? { processEnv: input.processEnv } : {},
|
|
7437
7469
|
program,
|
|
7438
7470
|
args: ["--version"]
|
|
7439
7471
|
});
|
|
@@ -7459,7 +7491,6 @@ ${result.stderr}`);
|
|
|
7459
7491
|
const handle = await connectToOpenCodeServer({
|
|
7460
7492
|
host: input.host,
|
|
7461
7493
|
recipe: input.recipe,
|
|
7462
|
-
processEnv: input.processEnv ?? void 0,
|
|
7463
7494
|
directory: "."
|
|
7464
7495
|
});
|
|
7465
7496
|
try {
|
|
@@ -7468,7 +7499,13 @@ ${result.stderr}`);
|
|
|
7468
7499
|
directory: ".",
|
|
7469
7500
|
password: handle.password
|
|
7470
7501
|
});
|
|
7471
|
-
const
|
|
7502
|
+
const skillsClient = createOpenCodeSdkClient({
|
|
7503
|
+
url: handle.url,
|
|
7504
|
+
directory: NodeOS4.homedir(),
|
|
7505
|
+
password: handle.password
|
|
7506
|
+
});
|
|
7507
|
+
const inventory2 = await loadOpenCodeInventory(client2, skillsClient);
|
|
7508
|
+
const skills2 = flattenOpenCodeSkills(inventory2.skills);
|
|
7472
7509
|
const connectedCount2 = inventory2.providerList.connected.length;
|
|
7473
7510
|
if (connectedCount2 > 0) {
|
|
7474
7511
|
return {
|
|
@@ -7477,6 +7514,7 @@ ${result.stderr}`);
|
|
|
7477
7514
|
readiness: "ready",
|
|
7478
7515
|
auth: { status: "authenticated", type: "opencode" },
|
|
7479
7516
|
models: openCodeProbeModels(inventory2),
|
|
7517
|
+
skills: skills2,
|
|
7480
7518
|
...OPENCODE_NATIVE_MODE_REPORT
|
|
7481
7519
|
};
|
|
7482
7520
|
}
|
|
@@ -7485,6 +7523,7 @@ ${result.stderr}`);
|
|
|
7485
7523
|
version,
|
|
7486
7524
|
readiness: "error",
|
|
7487
7525
|
auth: { status: "unauthenticated" },
|
|
7526
|
+
skills: skills2,
|
|
7488
7527
|
...OPENCODE_NATIVE_MODE_REPORT
|
|
7489
7528
|
};
|
|
7490
7529
|
} finally {
|
|
@@ -7494,9 +7533,10 @@ ${result.stderr}`);
|
|
|
7494
7533
|
const inventory = await loadInventoryFromCli({
|
|
7495
7534
|
host: input.host,
|
|
7496
7535
|
recipe: input.recipe,
|
|
7497
|
-
|
|
7498
|
-
|
|
7536
|
+
program,
|
|
7537
|
+
skillsCwd: NodeOS4.homedir()
|
|
7499
7538
|
});
|
|
7539
|
+
const skills = flattenOpenCodeSkills(inventory.skills);
|
|
7500
7540
|
const connectedCount = inventory.providerList.connected.length;
|
|
7501
7541
|
if (connectedCount > 0) {
|
|
7502
7542
|
return {
|
|
@@ -7505,6 +7545,7 @@ ${result.stderr}`);
|
|
|
7505
7545
|
readiness: "ready",
|
|
7506
7546
|
auth: { status: "authenticated", type: "opencode" },
|
|
7507
7547
|
models: openCodeProbeModels(inventory),
|
|
7548
|
+
skills,
|
|
7508
7549
|
...OPENCODE_NATIVE_MODE_REPORT
|
|
7509
7550
|
};
|
|
7510
7551
|
}
|
|
@@ -7513,6 +7554,7 @@ ${result.stderr}`);
|
|
|
7513
7554
|
version,
|
|
7514
7555
|
readiness: "error",
|
|
7515
7556
|
auth: { status: "unauthenticated" },
|
|
7557
|
+
skills,
|
|
7516
7558
|
...OPENCODE_NATIVE_MODE_REPORT
|
|
7517
7559
|
};
|
|
7518
7560
|
} catch (cause) {
|
|
@@ -8552,7 +8594,6 @@ function createOpenCodeTextGeneration(recipe, host) {
|
|
|
8552
8594
|
const handle = await connectToOpenCodeServer({
|
|
8553
8595
|
host,
|
|
8554
8596
|
recipe,
|
|
8555
|
-
processEnv: input.processEnv,
|
|
8556
8597
|
directory: input.cwd
|
|
8557
8598
|
});
|
|
8558
8599
|
shared.handle = handle;
|
|
@@ -8575,7 +8616,6 @@ function createOpenCodeTextGeneration(recipe, host) {
|
|
|
8575
8616
|
const handle = await connectToOpenCodeServer({
|
|
8576
8617
|
host,
|
|
8577
8618
|
recipe,
|
|
8578
|
-
processEnv: input.processEnv,
|
|
8579
8619
|
directory: input.cwd,
|
|
8580
8620
|
program
|
|
8581
8621
|
});
|
|
@@ -8601,15 +8641,10 @@ function createOpenCodeTextGeneration(recipe, host) {
|
|
|
8601
8641
|
const runOpenCodeJson = async (input) => {
|
|
8602
8642
|
const agent = getModelSelectionStringOptionValue(input.modelSelection, "agent");
|
|
8603
8643
|
const variant = getModelSelectionStringOptionValue(input.modelSelection, "variant");
|
|
8604
|
-
const client2 = await acquireClient({
|
|
8605
|
-
cwd: input.cwd,
|
|
8606
|
-
...input.launch?.processEnv ? { processEnv: input.launch.processEnv } : {}
|
|
8607
|
-
});
|
|
8644
|
+
const client2 = await acquireClient({ cwd: input.cwd });
|
|
8608
8645
|
try {
|
|
8609
|
-
const boundModelId = input.launch?.requestedModelId?.trim() || void 0;
|
|
8610
8646
|
const model = chooseOpenCodeModel({
|
|
8611
|
-
requested:
|
|
8612
|
-
boundModelId,
|
|
8647
|
+
requested: modelIdFromSelection(input.modelSelection) ?? "openai/gpt-5",
|
|
8613
8648
|
match: matchModel
|
|
8614
8649
|
});
|
|
8615
8650
|
if (input.signal?.aborted) {
|
|
@@ -8666,7 +8701,6 @@ function createOpenCodeTextGeneration(recipe, host) {
|
|
|
8666
8701
|
prompt,
|
|
8667
8702
|
schemaKeys: includeBranch ? ["subject", "body", "branch"] : ["subject", "body"],
|
|
8668
8703
|
modelSelection: input["modelSelection"],
|
|
8669
|
-
...isRecord2(input["launch"]) ? { launch: input["launch"] } : {},
|
|
8670
8704
|
...signal === void 0 ? {} : { signal }
|
|
8671
8705
|
});
|
|
8672
8706
|
return {
|
|
@@ -8696,7 +8730,6 @@ function createOpenCodeTextGeneration(recipe, host) {
|
|
|
8696
8730
|
prompt,
|
|
8697
8731
|
schemaKeys: ["title", "body"],
|
|
8698
8732
|
modelSelection: input["modelSelection"],
|
|
8699
|
-
...isRecord2(input["launch"]) ? { launch: input["launch"] } : {},
|
|
8700
8733
|
...signal === void 0 ? {} : { signal }
|
|
8701
8734
|
});
|
|
8702
8735
|
return {
|
|
@@ -8721,7 +8754,6 @@ function createOpenCodeTextGeneration(recipe, host) {
|
|
|
8721
8754
|
prompt,
|
|
8722
8755
|
schemaKeys: ["branch"],
|
|
8723
8756
|
modelSelection: input["modelSelection"],
|
|
8724
|
-
...isRecord2(input["launch"]) ? { launch: input["launch"] } : {},
|
|
8725
8757
|
...signal === void 0 ? {} : { signal }
|
|
8726
8758
|
});
|
|
8727
8759
|
return { branch: sanitizeBranchFragment(readString3(generated["branch"])) };
|
|
@@ -8744,7 +8776,6 @@ function createOpenCodeTextGeneration(recipe, host) {
|
|
|
8744
8776
|
prompt,
|
|
8745
8777
|
schemaKeys: ["title"],
|
|
8746
8778
|
modelSelection: input["modelSelection"],
|
|
8747
|
-
...isRecord2(input["launch"]) ? { launch: input["launch"] } : {},
|
|
8748
8779
|
...signal === void 0 ? {} : { signal }
|
|
8749
8780
|
});
|
|
8750
8781
|
return { title: sanitizeThreadTitle(readString3(generated["title"])) };
|
|
@@ -8764,7 +8795,6 @@ function createOpenCodeTextGeneration(recipe, host) {
|
|
|
8764
8795
|
prompt,
|
|
8765
8796
|
schemaKeys: ["summary"],
|
|
8766
8797
|
modelSelection: input["modelSelection"],
|
|
8767
|
-
...isRecord2(input["launch"]) ? { launch: input["launch"] } : {},
|
|
8768
8798
|
...signal === void 0 ? {} : { signal }
|
|
8769
8799
|
});
|
|
8770
8800
|
return { summary: readString3(generated["summary"]).trim() };
|
|
@@ -8887,7 +8917,6 @@ function createOpenCodeInstance(config, host, attachments) {
|
|
|
8887
8917
|
const server = await connectToOpenCodeServer({
|
|
8888
8918
|
host,
|
|
8889
8919
|
recipe,
|
|
8890
|
-
processEnv: input.launch.processEnv,
|
|
8891
8920
|
directory,
|
|
8892
8921
|
program: recipe.binaryPath,
|
|
8893
8922
|
onSpawn: (resource) => {
|
|
@@ -9012,7 +9041,6 @@ function createOpenCodeInstance(config, host, attachments) {
|
|
|
9012
9041
|
compaction: void 0,
|
|
9013
9042
|
attachmentsApi: attachments,
|
|
9014
9043
|
runtimeMode: input.runtimeMode,
|
|
9015
|
-
boundModelId: input.launch.requestedModelId?.trim() || void 0,
|
|
9016
9044
|
matchModel: createCatalogModelMatcher2(host.log)
|
|
9017
9045
|
};
|
|
9018
9046
|
const winner = sessions.get(input.threadId);
|
|
@@ -9056,7 +9084,6 @@ function createOpenCodeInstance(config, host, attachments) {
|
|
|
9056
9084
|
const requestedModel = modelIdFromSelection(input.modelSelection) ?? readString2(input.modelSelection?.model) ?? context.session.model;
|
|
9057
9085
|
const parsedSlug = chooseOpenCodeModel({
|
|
9058
9086
|
requested: requestedModel,
|
|
9059
|
-
boundModelId: context.boundModelId,
|
|
9060
9087
|
match: context.matchModel
|
|
9061
9088
|
});
|
|
9062
9089
|
const queuedDecline = declineRelay.take(input.threadId);
|
package/locales/en.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"form": {
|
|
3
|
+
"binaryPath": {
|
|
4
|
+
"title": "Program path",
|
|
5
|
+
"description": "Path to the OpenCode program this provider runs.",
|
|
6
|
+
"placeholder": "opencode"
|
|
7
|
+
},
|
|
8
|
+
"serverUrl": {
|
|
9
|
+
"title": "Server URL",
|
|
10
|
+
"description": "Leave blank to let Ycodium spawn the server when needed.",
|
|
11
|
+
"placeholder": "http://127.0.0.1:4096"
|
|
12
|
+
},
|
|
13
|
+
"serverPassword": {
|
|
14
|
+
"title": "Server password",
|
|
15
|
+
"description": "Stored in plain text on disk.",
|
|
16
|
+
"placeholder": "Optional"
|
|
17
|
+
},
|
|
18
|
+
"homePath": {
|
|
19
|
+
"title": "Account directory",
|
|
20
|
+
"description": "Where this account's login and history live. Leave empty to use the CLI's default.",
|
|
21
|
+
"placeholder": "e.g. ~/.opencode-work"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"form": {
|
|
3
|
+
"binaryPath": {
|
|
4
|
+
"title": "程序路径",
|
|
5
|
+
"description": "此 provider 运行的 OpenCode 程序的路径。",
|
|
6
|
+
"placeholder": "opencode"
|
|
7
|
+
},
|
|
8
|
+
"serverUrl": {
|
|
9
|
+
"title": "服务器 URL",
|
|
10
|
+
"description": "留空则由 Ycodium 在需要时启动服务器。",
|
|
11
|
+
"placeholder": "http://127.0.0.1:4096"
|
|
12
|
+
},
|
|
13
|
+
"serverPassword": {
|
|
14
|
+
"title": "服务器密码",
|
|
15
|
+
"description": "以明文保存在磁盘上。",
|
|
16
|
+
"placeholder": "可选"
|
|
17
|
+
},
|
|
18
|
+
"homePath": {
|
|
19
|
+
"title": "账户目录",
|
|
20
|
+
"description": "此账户的登录信息与历史记录所在的目录。留空则使用该命令行工具的默认目录。",
|
|
21
|
+
"placeholder": "例如 ~/.opencode-work"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
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.2488",
|
|
4
4
|
"description": "OpenCode executor: OpenCode CLI via @opencode-ai/sdk/v2.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ycodium",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"files": [
|
|
11
11
|
"dist",
|
|
12
12
|
"assets",
|
|
13
|
+
"locales",
|
|
13
14
|
"README.md"
|
|
14
15
|
],
|
|
15
16
|
"type": "module",
|
|
@@ -23,7 +24,8 @@
|
|
|
23
24
|
"@types/node": "24.12.4",
|
|
24
25
|
"esbuild": "0.28.1",
|
|
25
26
|
"vite-plus": "0.2.2",
|
|
26
|
-
"@ycodium-ai/plugin-api": "0.2.
|
|
27
|
+
"@ycodium-ai/plugin-api": "0.2.2488",
|
|
28
|
+
"ycodium-executor-testing": "0.0.0"
|
|
27
29
|
},
|
|
28
30
|
"ycodium": {
|
|
29
31
|
"plugin": "./dist/index.js",
|