@ycodium-ai/agent-opencode 0.2.2743 → 0.2.2745

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 +44 -24
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -8077,6 +8077,30 @@ function normalizeQuestionRequest(request) {
8077
8077
  }));
8078
8078
  }
8079
8079
 
8080
+ // src/sessionContext.ts
8081
+ function withoutActiveTurn(session) {
8082
+ const { activeTurnId, ...rest } = session;
8083
+ void activeTurnId;
8084
+ return rest;
8085
+ }
8086
+ function emitEvent(events, context, type3, payload, extra) {
8087
+ const turnId = extra?.turnId ?? context.session.activeTurnId;
8088
+ const event = {
8089
+ eventId: randomUUID(),
8090
+ provider: OPENCODE_DRIVER_KIND,
8091
+ ...context.session.providerInstanceId ? { providerInstanceId: context.session.providerInstanceId } : {},
8092
+ threadId: context.threadId,
8093
+ createdAt: nowIso(),
8094
+ type: type3,
8095
+ payload,
8096
+ ...turnId ? { turnId } : {},
8097
+ ...extra?.itemId ? { itemId: extra.itemId } : {},
8098
+ ...extra?.requestId ? { requestId: extra.requestId } : {},
8099
+ providerRefs: {}
8100
+ };
8101
+ events.push(event);
8102
+ }
8103
+
8080
8104
  // src/textMerge.ts
8081
8105
  function commonPrefixLength(left, right) {
8082
8106
  let index = 0;
@@ -8229,28 +8253,6 @@ function takeTurnUsage(usageByMessageId, sessionId) {
8229
8253
  }
8230
8254
 
8231
8255
  // src/sessionEvents.ts
8232
- function withoutActiveTurn(session) {
8233
- const { activeTurnId, ...rest } = session;
8234
- void activeTurnId;
8235
- return rest;
8236
- }
8237
- function emitEvent(events, context, type3, payload, extra) {
8238
- const turnId = extra?.turnId ?? context.session.activeTurnId;
8239
- const event = {
8240
- eventId: randomUUID(),
8241
- provider: OPENCODE_DRIVER_KIND,
8242
- ...context.session.providerInstanceId ? { providerInstanceId: context.session.providerInstanceId } : {},
8243
- threadId: context.threadId,
8244
- createdAt: nowIso(),
8245
- type: type3,
8246
- payload,
8247
- ...turnId ? { turnId } : {},
8248
- ...extra?.itemId ? { itemId: extra.itemId } : {},
8249
- ...extra?.requestId ? { requestId: extra.requestId } : {},
8250
- providerRefs: {}
8251
- };
8252
- events.push(event);
8253
- }
8254
8256
  function openCodeEventSessionId(event) {
8255
8257
  const properties = event.properties;
8256
8258
  if (!isRecord2(properties)) return void 0;
@@ -8355,6 +8357,7 @@ function emitToolLifecycle(events, context, part) {
8355
8357
  function completeActiveTurn(events, context, state, extra) {
8356
8358
  const turnId = context.session.activeTurnId;
8357
8359
  const usage = takeTurnUsage(context.usageByMessageId, context.sessionId);
8360
+ context.pendingTurnError = void 0;
8358
8361
  if (!turnId) return usage;
8359
8362
  if (state === "interrupted") {
8360
8363
  emitEvent(
@@ -8772,7 +8775,16 @@ async function handleSubscribedEvent(input) {
8772
8775
  return;
8773
8776
  }
8774
8777
  if (status.type === "idle") {
8775
- completeActiveTurn(events, context, "completed");
8778
+ const turnError = context.pendingTurnError;
8779
+ if (turnError === void 0) {
8780
+ completeActiveTurn(events, context, "completed");
8781
+ } else {
8782
+ completeActiveTurn(events, context, "failed", { errorMessage: turnError });
8783
+ emitEvent(events, context, "runtime.error", {
8784
+ message: turnError,
8785
+ class: "provider_error"
8786
+ });
8787
+ }
8776
8788
  context.session = { ...context.session, status: "ready", updatedAt: nowIso() };
8777
8789
  emitEvent(events, context, "session.state.changed", { state: "ready" });
8778
8790
  }
@@ -8784,7 +8796,14 @@ async function handleSubscribedEvent(input) {
8784
8796
  return;
8785
8797
  }
8786
8798
  const message = sessionErrorMessage(event.properties.error);
8787
- completeActiveTurn(events, context, "failed", { errorMessage: message });
8799
+ if (event.properties.sessionID === void 0) {
8800
+ emitEvent(events, context, "runtime.warning", { message });
8801
+ return;
8802
+ }
8803
+ if (context.session.activeTurnId !== void 0) {
8804
+ context.pendingTurnError ??= message;
8805
+ return;
8806
+ }
8788
8807
  emitEvent(events, context, "runtime.error", {
8789
8808
  message,
8790
8809
  class: "provider_error"
@@ -9818,6 +9837,7 @@ function createOpenCodeInstance(config, host, attachments) {
9818
9837
  completedTextParts: /* @__PURE__ */ new Set(),
9819
9838
  startedToolItems: /* @__PURE__ */ new Set(),
9820
9839
  compaction: void 0,
9840
+ pendingTurnError: void 0,
9821
9841
  attachmentsApi: attachments,
9822
9842
  runtimeMode: input.runtimeMode,
9823
9843
  matchModel: createCatalogModelMatcher2(host.log)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-opencode",
3
- "version": "0.2.2743",
3
+ "version": "0.2.2745",
4
4
  "description": "OpenCode executor: OpenCode CLI via @opencode-ai/sdk/v2.",
5
5
  "keywords": [
6
6
  "ycodium",
@@ -24,8 +24,8 @@
24
24
  "@types/node": "24.12.4",
25
25
  "esbuild": "0.28.1",
26
26
  "vite-plus": "0.2.2",
27
+ "@ycodium-ai/plugin-api": "0.2.0",
27
28
  "ycodium-fetch-ports": "0.0.0",
28
- "@ycodium-ai/plugin-api": "0.2.2743",
29
29
  "ycodium-executor-testing": "0.0.0"
30
30
  },
31
31
  "ycodium": {