@ycodium-ai/agent-opencode 0.2.3671 → 0.2.3710

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 +34 -5
  2. package/package.json +2 -2
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" });
@@ -4857,7 +4886,7 @@ var executors = [
4857
4886
  ];
4858
4887
  var index_default = definePlugin({
4859
4888
  id: "agent-opencode",
4860
- apiVersion: 51,
4889
+ apiVersion: 53,
4861
4890
  executors,
4862
4891
  activate(ctx) {
4863
4892
  capturedAttachments = ctx.attachments;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-opencode",
3
- "version": "0.2.3671",
3
+ "version": "0.2.3710",
4
4
  "description": "OpenCode executor: OpenCode CLI (2.x) over its HTTP API.",
5
5
  "keywords": [
6
6
  "ycodium",
@@ -21,8 +21,8 @@
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.3671",
25
24
  "ycodium-executor-testing": "0.0.0",
25
+ "@ycodium-ai/plugin-api": "0.2.3710",
26
26
  "ycodium-sse-stream": "0.0.0",
27
27
  "ycodium-fetch-ports": "0.0.0"
28
28
  },