@ycodium-ai/agent-opencode 0.2.3681 → 0.2.3766

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 CHANGED
@@ -387,6 +387,9 @@ function withLastError(session, lastError, failureCategory) {
387
387
  void previous;
388
388
  return { ...rest, lastError, ...failureCategoryField(failureCategory) };
389
389
  }
390
+ function openCodeModelLabel(ref) {
391
+ return `${ref.providerID}/${ref.id}`;
392
+ }
390
393
  function emitEvent(events, context, type2, payload, extra) {
391
394
  if (context.lifecycle?.canEmit === false) return;
392
395
  const turnId = extra?.turnId ?? context.session.activeTurnId;
@@ -405,6 +408,15 @@ function emitEvent(events, context, type2, payload, extra) {
405
408
  };
406
409
  events.push(event);
407
410
  }
411
+ function reportOpenCodeModel(events, context, ref) {
412
+ const turnId = context.session.activeTurnId;
413
+ if (turnId === void 0) return;
414
+ const model = openCodeModelLabel(ref);
415
+ const key = `${turnId}|${model}`;
416
+ if (context.reportedModelKey === key) return;
417
+ context.reportedModelKey = key;
418
+ emitEvent(events, context, "thread.metadata.updated", { model, modelSource: "reported" });
419
+ }
408
420
 
409
421
  // src/formEvents.ts
410
422
  var text = (data, key) => {
@@ -3166,6 +3178,8 @@ function handleOpenCodeTurnEvent(input) {
3166
3178
  context.abortedByDecline = false;
3167
3179
  const messageId = text3(data, "assistantMessageID");
3168
3180
  const model = data["model"];
3181
+ const stepModel = decodeOpenCodeModelRef(model);
3182
+ if (stepModel !== void 0) reportOpenCodeModel(events, context, stepModel);
3169
3183
  if (messageId === void 0 || !isRecord2(model)) return true;
3170
3184
  const providerId = model["providerID"];
3171
3185
  const modelId = model["id"];
@@ -3569,7 +3583,12 @@ function startEventPump(input) {
3569
3583
  }
3570
3584
  if (event.sessionId === context.sessionId) noteParentSequence(context, event);
3571
3585
  if (handleOpenCodeTurnEvent({ events, context, event })) return;
3572
- if (noteOpenCodeSelectionEvent(context, event)) return;
3586
+ if (noteOpenCodeSelectionEvent(context, event)) {
3587
+ if (event.type === "session.model.selected" && context.selectedModel !== void 0) {
3588
+ reportOpenCodeModel(events, context, context.selectedModel);
3589
+ }
3590
+ return;
3591
+ }
3573
3592
  if (handleOpenCodeCompactionEvent({ events, context, event })) return;
3574
3593
  if (handleOpenCodeFormEvent({ events, context, event })) return;
3575
3594
  if (reportSubagentInbox(events, context, event)) return;
@@ -4553,7 +4572,10 @@ function createOpenCodeInstance(config, host, attachments, lifecycleOptions) {
4553
4572
  }
4554
4573
  const createdAt = nowIso();
4555
4574
  const resumeCursor = makeOpenCodeResumeCursor(sessionId);
4556
- const initialModel = requestedModelOf(input.modelSelection);
4575
+ const requestedInitial = requestedModelOf(input.modelSelection);
4576
+ const serverModel = selection.selectedModel === void 0 ? void 0 : openCodeModelLabel(selection.selectedModel);
4577
+ const aligned = serverModel !== void 0 && (requestedInitial === void 0 || requestedInitial === serverModel);
4578
+ const initialModel = aligned ? serverModel : requestedInitial;
4557
4579
  const session = {
4558
4580
  provider: OPENCODE_DRIVER_KIND,
4559
4581
  providerInstanceId: boundInstanceId,
@@ -4565,7 +4587,10 @@ function createOpenCodeInstance(config, host, attachments, lifecycleOptions) {
4565
4587
  resumeCursor,
4566
4588
  createdAt,
4567
4589
  updatedAt: createdAt,
4568
- ...initialModel ? { model: initialModel } : {}
4590
+ ...initialModel ? {
4591
+ model: initialModel,
4592
+ modelSource: aligned ? "reported" : "echo"
4593
+ } : {}
4569
4594
  };
4570
4595
  const context = {
4571
4596
  threadId: input.threadId,
@@ -4671,7 +4696,11 @@ function createOpenCodeInstance(config, host, attachments, lifecycleOptions) {
4671
4696
  events,
4672
4697
  context,
4673
4698
  "turn.started",
4674
- requestedModel ? { model: requestedModel } : {},
4699
+ requestedModel ? {
4700
+ model: requestedModel,
4701
+ // 请求的就是 server 上已定的型号才算读回的;要换型号的,等切换后 server 的回报。
4702
+ ...context.selectedModel !== void 0 && openCodeModelLabel(context.selectedModel) === requestedModel ? { modelSource: "reported" } : {}
4703
+ } : {},
4675
4704
  { turnId }
4676
4705
  );
4677
4706
  emitEvent(events, context, "session.state.changed", { state: "running" });
@@ -4849,6 +4878,7 @@ var capturedAttachments;
4849
4878
  var executors = [
4850
4879
  {
4851
4880
  card: OPENCODE_CARD,
4881
+ lifecycle: [{ kind: "detect", reversible: true }],
4852
4882
  createInstance: async (config, host) => {
4853
4883
  host.log.info("createInstance");
4854
4884
  return createOpenCodeInstance(config, host, capturedAttachments);
@@ -4857,7 +4887,7 @@ var executors = [
4857
4887
  ];
4858
4888
  var index_default = definePlugin({
4859
4889
  id: "agent-opencode",
4860
- apiVersion: 52,
4890
+ apiVersion: 56,
4861
4891
  executors,
4862
4892
  activate(ctx) {
4863
4893
  capturedAttachments = ctx.attachments;
package/locales/en.json CHANGED
@@ -1,4 +1,8 @@
1
1
  {
2
+ "presentation": {
3
+ "name": "OpenCode",
4
+ "description": "Use OpenCode in Ycodium, switching models mid-session."
5
+ },
2
6
  "form": {
3
7
  "binaryPath": {
4
8
  "title": "Program path",
@@ -8,7 +12,7 @@
8
12
  "serverUrl": {
9
13
  "title": "Server URL",
10
14
  "description": "Leave blank to let Ycodium spawn the server when needed.",
11
- "placeholder": "http://127.0.0.1:4096"
15
+ "placeholder": "Started by Ycodium when needed"
12
16
  },
13
17
  "serverPassword": {
14
18
  "title": "Server password",
@@ -18,7 +22,7 @@
18
22
  "homePath": {
19
23
  "title": "Account directory",
20
24
  "description": "Where this account's login and history live. Leave empty to use the CLI's default.",
21
- "placeholder": "e.g. ~/.opencode-work"
25
+ "placeholder": "OpenCode's default (XDG directories)"
22
26
  }
23
27
  },
24
28
  "usage": {
@@ -1,4 +1,8 @@
1
1
  {
2
+ "presentation": {
3
+ "name": "OpenCode",
4
+ "description": "在 Ycodium 里使用 OpenCode,会话中途也能换模型。"
5
+ },
2
6
  "form": {
3
7
  "binaryPath": {
4
8
  "title": "程序路径",
@@ -8,7 +12,7 @@
8
12
  "serverUrl": {
9
13
  "title": "服务器 URL",
10
14
  "description": "留空则由 Ycodium 在需要时启动服务器。",
11
- "placeholder": "http://127.0.0.1:4096"
15
+ "placeholder": "需要时由 Ycodium 启动"
12
16
  },
13
17
  "serverPassword": {
14
18
  "title": "服务器密码",
@@ -18,7 +22,7 @@
18
22
  "homePath": {
19
23
  "title": "账号目录",
20
24
  "description": "此账号的登录信息与历史记录所在的目录。留空则使用该命令行工具的默认目录。",
21
- "placeholder": "例如 ~/.opencode-work"
25
+ "placeholder": "OpenCode 的默认位置(XDG 目录)"
22
26
  }
23
27
  },
24
28
  "usage": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-opencode",
3
- "version": "0.2.3681",
3
+ "version": "0.2.3766",
4
4
  "description": "OpenCode executor: OpenCode CLI (2.x) over its HTTP API.",
5
5
  "keywords": [
6
6
  "ycodium",
@@ -21,15 +21,17 @@
21
21
  "@types/node": "24.12.4",
22
22
  "esbuild": "0.28.1",
23
23
  "vite-plus": "0.2.2",
24
- "ycodium-sse-stream": "0.0.0",
24
+ "@ycodium-ai/plugin-api": "0.2.3766",
25
25
  "ycodium-executor-testing": "0.0.0",
26
- "ycodium-fetch-ports": "0.0.0",
27
- "@ycodium-ai/plugin-api": "0.2.3681"
26
+ "ycodium-sse-stream": "0.0.0",
27
+ "ycodium-fetch-ports": "0.0.0"
28
28
  },
29
29
  "ycodium": {
30
30
  "plugin": "./dist/index.js",
31
31
  "displayName": "OpenCode",
32
- "description": "Run OpenCode with in-session model switching, native compaction, and turn steering.",
32
+ "displayNameKey": "presentation.name",
33
+ "description": "Use OpenCode in Ycodium, switching models mid-session.",
34
+ "descriptionKey": "presentation.description",
33
35
  "icon": "./assets/icon.svg",
34
36
  "permissions": [
35
37
  {