@ycodium-ai/agent-opencode 0.2.3236 → 0.2.3240

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 -20
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -3986,6 +3986,8 @@ function createOpenCodeInstance(config, host, attachments, lifecycleOptions) {
3986
3986
  eventAbort: new AbortController(),
3987
3987
  pump: void 0,
3988
3988
  stopped: false,
3989
+ interruptGeneration: 0,
3990
+ pendingInterrupts: 0,
3989
3991
  usageByMessageId: /* @__PURE__ */ new Map(),
3990
3992
  assistantTextByPartId: /* @__PURE__ */ new Map(),
3991
3993
  completedTextParts: /* @__PURE__ */ new Set(),
@@ -4036,13 +4038,18 @@ function createOpenCodeInstance(config, host, attachments, lifecycleOptions) {
4036
4038
  },
4037
4039
  sendTurn: async (input) => {
4038
4040
  const context = requireSession(input.threadId);
4039
- if (input.expectedTurnId !== void 0 && context.session.activeTurnId !== input.expectedTurnId) {
4041
+ const interruptGeneration = context.interruptGeneration;
4042
+ const validateSteeringTarget = () => {
4043
+ if (input.expectedTurnId === void 0) return;
4044
+ if (sessions.get(input.threadId) === context && context.session.activeTurnId === input.expectedTurnId && !context.stopped && !context.lifecycle?.closing && context.pendingInterrupts === 0 && context.interruptGeneration === interruptGeneration)
4045
+ return;
4040
4046
  const rejected = Object.assign(
4041
4047
  new Error("The target turn has ended. The message was not sent."),
4042
4048
  { code: "provider-rejected" }
4043
4049
  );
4044
4050
  throw rejected;
4045
- }
4051
+ };
4052
+ validateSteeringTarget();
4046
4053
  const selectedInstanceId = boundInstanceIdFromSelection(input.modelSelection);
4047
4054
  if (selectedInstanceId !== void 0 && selectedInstanceId !== boundInstanceId) {
4048
4055
  throw new Error("OpenCode sendTurn rejected a model selection for another instance.");
@@ -4086,6 +4093,7 @@ function createOpenCodeInstance(config, host, attachments, lifecycleOptions) {
4086
4093
  interactionMode: input.interactionMode
4087
4094
  });
4088
4095
  }
4096
+ validateSteeringTarget();
4089
4097
  await context.api.prompt(context.sessionId, { text: text4, files });
4090
4098
  } catch (cause) {
4091
4099
  if (!steering) {
@@ -4123,23 +4131,29 @@ function createOpenCodeInstance(config, host, attachments, lifecycleOptions) {
4123
4131
  if (turnId !== void 0 && context.session.activeTurnId !== turnId) {
4124
4132
  return;
4125
4133
  }
4126
- await context.api.interrupt(context.sessionId);
4127
- await Promise.all(
4128
- [...context.childSessionIds].map(
4129
- (child) => context.api.interrupt(child).catch(() => void 0)
4130
- )
4131
- );
4132
- const active = context.session.activeTurnId;
4133
- if (active && (turnId === void 0 || turnId === active)) {
4134
- finishOpenCodeTurn(events, context, {
4135
- state: "interrupted",
4136
- reason: "Interrupted by user."
4137
- });
4138
- context.session = {
4139
- ...context.session,
4140
- status: "ready",
4141
- updatedAt: nowIso()
4142
- };
4134
+ context.interruptGeneration += 1;
4135
+ context.pendingInterrupts += 1;
4136
+ try {
4137
+ await context.api.interrupt(context.sessionId);
4138
+ await Promise.all(
4139
+ [...context.childSessionIds].map(
4140
+ (child) => context.api.interrupt(child).catch(() => void 0)
4141
+ )
4142
+ );
4143
+ const active = context.session.activeTurnId;
4144
+ if (active && (turnId === void 0 || turnId === active)) {
4145
+ finishOpenCodeTurn(events, context, {
4146
+ state: "interrupted",
4147
+ reason: "Interrupted by user."
4148
+ });
4149
+ context.session = {
4150
+ ...context.session,
4151
+ status: "ready",
4152
+ updatedAt: nowIso()
4153
+ };
4154
+ }
4155
+ } finally {
4156
+ context.pendingInterrupts -= 1;
4143
4157
  }
4144
4158
  },
4145
4159
  respondToRequest: async (threadId, requestId, decision, reason) => {
@@ -4231,7 +4245,7 @@ var executors = [
4231
4245
  ];
4232
4246
  var index_default = definePlugin({
4233
4247
  id: "agent-opencode",
4234
- apiVersion: 25,
4248
+ apiVersion: 26,
4235
4249
  executors,
4236
4250
  activate(ctx) {
4237
4251
  capturedAttachments = ctx.attachments;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-opencode",
3
- "version": "0.2.3236",
3
+ "version": "0.2.3240",
4
4
  "description": "OpenCode executor: OpenCode CLI (2.x) over its HTTP API.",
5
5
  "keywords": [
6
6
  "ycodium",
@@ -21,10 +21,10 @@
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.3236",
25
- "ycodium-sse-stream": "0.0.0",
24
+ "@ycodium-ai/plugin-api": "0.2.3240",
26
25
  "ycodium-executor-testing": "0.0.0",
27
- "ycodium-fetch-ports": "0.0.0"
26
+ "ycodium-fetch-ports": "0.0.0",
27
+ "ycodium-sse-stream": "0.0.0"
28
28
  },
29
29
  "ycodium": {
30
30
  "plugin": "./dist/index.js",