@defend-tech/opencode-optima 0.1.21 → 0.1.23

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
@@ -9088,16 +9088,16 @@ async function ensureClickUpWebhookSubscription({ validation, worktree, clickupC
9088
9088
  clickUpWebhookLifecycleLog(worktree, { type: "remote_webhook_reused", webhookId: state.webhookId, mode: existingValidation.mode });
9089
9089
  return { active: true, valid: true, mode: existingValidation.mode, limitation: existingValidation.limitation, state };
9090
9090
  }
9091
- if (existing.webhookId && clickupClient?.deleteWebhook) {
9092
- await deleteClickUpWebhookBestEffort({ webhookId: existing.webhookId, clickupClient, worktree, reason: existingValidation.reason || "startup_self_heal" });
9093
- markClickUpWebhookInactive(worktree, existing, config);
9094
- }
9095
9091
  const reusableRemote = await findReusableClickUpWebhook(config, clickupClient);
9096
9092
  if (reusableRemote) {
9097
9093
  const state = writeClickUpWebhookState(worktree, { ...reusableRemote, recentEventKeys: existing.recentEventKeys || [] }, config);
9098
9094
  clickUpWebhookLifecycleLog(worktree, { type: "remote_webhook_reused", webhookId: state.webhookId, mode: "remote_discovered" });
9099
9095
  return { active: true, valid: true, mode: "remote_discovered", state };
9100
9096
  }
9097
+ if (existing.webhookId && clickupClient?.deleteWebhook) {
9098
+ await deleteClickUpWebhookBestEffort({ webhookId: existing.webhookId, clickupClient, worktree, reason: existingValidation.reason || "startup_self_heal" });
9099
+ markClickUpWebhookInactive(worktree, existing, config);
9100
+ }
9101
9101
  if (!clickupClient?.createWebhook) {
9102
9102
  return { active: false, valid: false, reason: "clickup_client_unavailable", state: existing };
9103
9103
  }
@@ -9382,11 +9382,12 @@ async function cleanupManagedClickUpWebhook(entry = {}, { timeoutMs = CLICKUP_WE
9382
9382
  clickUpWebhookLifecycleLog(entry.worktree, { type: "cleanup_started", reason, key: entry.key, webhookId: entry.state?.webhookId });
9383
9383
  const closeResult = await closeClickUpWebhookServer(entry.listener?.server);
9384
9384
  if (entry.listenerRegistry && entry.listener?.key) entry.listenerRegistry.delete(entry.listener.key);
9385
- const deleteResult = await deleteClickUpWebhookBestEffort({ webhookId: entry.state?.webhookId, clickupClient: entry.clickupClient, worktree: entry.worktree, reason });
9386
- if (deleteResult.ok) markClickUpWebhookInactive(entry.worktree, entry.state, entry.config);
9385
+ const preservedResult = { ok: true, skipped: true, reason: "remote_webhook_preserved" };
9386
+ clickUpWebhookLifecycleLog(entry.worktree, { type: "remote_webhook_preserved", reason, webhookId: entry.state?.webhookId });
9387
+ markClickUpWebhookInactive(entry.worktree, entry.state, entry.config);
9387
9388
  activeClickUpWebhookLifecycleRegistry.delete(entry.key);
9388
- clickUpWebhookLifecycleLog(entry.worktree, { type: "cleanup_finished", reason, close_ok: closeResult.ok, delete_ok: deleteResult.ok, delete_reason: deleteResult.reason });
9389
- return { ok: closeResult.ok !== false && deleteResult.ok !== false, closeResult, deleteResult };
9389
+ clickUpWebhookLifecycleLog(entry.worktree, { type: "cleanup_finished", reason, close_ok: closeResult.ok, remote_webhook: "preserved" });
9390
+ return { ok: closeResult.ok !== false, closeResult, deleteResult: preservedResult, preserveResult: preservedResult };
9390
9391
  })();
9391
9392
  const result = await promiseWithTimeout(cleanup, timeoutMs, { ok: false, timeout: true, reason: "cleanup_timeout" });
9392
9393
  if (result?.timeout) clickUpWebhookLifecycleLog(entry.worktree, { type: "cleanup_timeout", reason, webhookId: entry.state?.webhookId });
@@ -10762,15 +10763,14 @@ async function OptimaPlugin(input = {}, pluginOptions = {}) {
10762
10763
  }, clickUpWebhookValidation.config);
10763
10764
  registerClickUpWebhookLifecycle({ config: clickUpWebhookValidation.config, state: activeState, worktree, clickupClient: lifecycleClickUpClient, listener: readyListener, listenerRegistry });
10764
10765
  } else {
10765
- await deleteClickUpWebhookBestEffort({ webhookId: listenerState.webhookId, clickupClient: lifecycleClickUpClient, worktree, reason: readyListener.reason || "listener_unavailable" });
10766
+ clickUpWebhookLifecycleLog(worktree, { type: "remote_webhook_preserved", reason: readyListener.reason || "listener_unavailable", webhookId: listenerState.webhookId });
10766
10767
  markClickUpWebhookInactive(worktree, listenerState, clickUpWebhookValidation.config);
10767
10768
  clickUpWebhookActive = false;
10768
10769
  clickUpWebhookRuntime = { ...clickUpWebhookRuntime, active: false, valid: false, reason: readyListener.reason || "listener_unavailable" };
10769
10770
  }
10770
10771
  } catch (error) {
10771
10772
  const failureState = clickUpWebhookRuntime.state || readClickUpWebhookState(worktree, clickUpWebhookValidation.config);
10772
- const failureClient = input.clickupClient || createClickUpApiClient(clickUpWebhookValidation.config, input.fetch);
10773
- await deleteClickUpWebhookBestEffort({ webhookId: failureState.webhookId, clickupClient: failureClient, worktree, reason: "listener_failed" });
10773
+ clickUpWebhookLifecycleLog(worktree, { type: "remote_webhook_preserved", reason: "listener_failed", webhookId: failureState.webhookId });
10774
10774
  markClickUpWebhookInactive(worktree, failureState, clickUpWebhookValidation.config);
10775
10775
  clickUpWebhookActive = false;
10776
10776
  clickUpWebhookRuntime = { ...clickUpWebhookRuntime, active: false, valid: false, reason: "listener_failed", error: error.message };
@@ -9095,16 +9095,16 @@ async function ensureClickUpWebhookSubscription({ validation, worktree, clickupC
9095
9095
  clickUpWebhookLifecycleLog(worktree, { type: "remote_webhook_reused", webhookId: state.webhookId, mode: existingValidation.mode });
9096
9096
  return { active: true, valid: true, mode: existingValidation.mode, limitation: existingValidation.limitation, state };
9097
9097
  }
9098
- if (existing.webhookId && clickupClient?.deleteWebhook) {
9099
- await deleteClickUpWebhookBestEffort({ webhookId: existing.webhookId, clickupClient, worktree, reason: existingValidation.reason || "startup_self_heal" });
9100
- markClickUpWebhookInactive(worktree, existing, config);
9101
- }
9102
9098
  const reusableRemote = await findReusableClickUpWebhook(config, clickupClient);
9103
9099
  if (reusableRemote) {
9104
9100
  const state = writeClickUpWebhookState(worktree, { ...reusableRemote, recentEventKeys: existing.recentEventKeys || [] }, config);
9105
9101
  clickUpWebhookLifecycleLog(worktree, { type: "remote_webhook_reused", webhookId: state.webhookId, mode: "remote_discovered" });
9106
9102
  return { active: true, valid: true, mode: "remote_discovered", state };
9107
9103
  }
9104
+ if (existing.webhookId && clickupClient?.deleteWebhook) {
9105
+ await deleteClickUpWebhookBestEffort({ webhookId: existing.webhookId, clickupClient, worktree, reason: existingValidation.reason || "startup_self_heal" });
9106
+ markClickUpWebhookInactive(worktree, existing, config);
9107
+ }
9108
9108
  if (!clickupClient?.createWebhook) {
9109
9109
  return { active: false, valid: false, reason: "clickup_client_unavailable", state: existing };
9110
9110
  }
@@ -9389,11 +9389,12 @@ async function cleanupManagedClickUpWebhook(entry = {}, { timeoutMs = CLICKUP_WE
9389
9389
  clickUpWebhookLifecycleLog(entry.worktree, { type: "cleanup_started", reason, key: entry.key, webhookId: entry.state?.webhookId });
9390
9390
  const closeResult = await closeClickUpWebhookServer(entry.listener?.server);
9391
9391
  if (entry.listenerRegistry && entry.listener?.key) entry.listenerRegistry.delete(entry.listener.key);
9392
- const deleteResult = await deleteClickUpWebhookBestEffort({ webhookId: entry.state?.webhookId, clickupClient: entry.clickupClient, worktree: entry.worktree, reason });
9393
- if (deleteResult.ok) markClickUpWebhookInactive(entry.worktree, entry.state, entry.config);
9392
+ const preservedResult = { ok: true, skipped: true, reason: "remote_webhook_preserved" };
9393
+ clickUpWebhookLifecycleLog(entry.worktree, { type: "remote_webhook_preserved", reason, webhookId: entry.state?.webhookId });
9394
+ markClickUpWebhookInactive(entry.worktree, entry.state, entry.config);
9394
9395
  activeClickUpWebhookLifecycleRegistry.delete(entry.key);
9395
- clickUpWebhookLifecycleLog(entry.worktree, { type: "cleanup_finished", reason, close_ok: closeResult.ok, delete_ok: deleteResult.ok, delete_reason: deleteResult.reason });
9396
- return { ok: closeResult.ok !== false && deleteResult.ok !== false, closeResult, deleteResult };
9396
+ clickUpWebhookLifecycleLog(entry.worktree, { type: "cleanup_finished", reason, close_ok: closeResult.ok, remote_webhook: "preserved" });
9397
+ return { ok: closeResult.ok !== false, closeResult, deleteResult: preservedResult, preserveResult: preservedResult };
9397
9398
  })();
9398
9399
  const result = await promiseWithTimeout(cleanup, timeoutMs, { ok: false, timeout: true, reason: "cleanup_timeout" });
9399
9400
  if (result?.timeout) clickUpWebhookLifecycleLog(entry.worktree, { type: "cleanup_timeout", reason, webhookId: entry.state?.webhookId });
@@ -10769,15 +10770,14 @@ async function OptimaPlugin(input = {}, pluginOptions = {}) {
10769
10770
  }, clickUpWebhookValidation.config);
10770
10771
  registerClickUpWebhookLifecycle({ config: clickUpWebhookValidation.config, state: activeState, worktree, clickupClient: lifecycleClickUpClient, listener: readyListener, listenerRegistry });
10771
10772
  } else {
10772
- await deleteClickUpWebhookBestEffort({ webhookId: listenerState.webhookId, clickupClient: lifecycleClickUpClient, worktree, reason: readyListener.reason || "listener_unavailable" });
10773
+ clickUpWebhookLifecycleLog(worktree, { type: "remote_webhook_preserved", reason: readyListener.reason || "listener_unavailable", webhookId: listenerState.webhookId });
10773
10774
  markClickUpWebhookInactive(worktree, listenerState, clickUpWebhookValidation.config);
10774
10775
  clickUpWebhookActive = false;
10775
10776
  clickUpWebhookRuntime = { ...clickUpWebhookRuntime, active: false, valid: false, reason: readyListener.reason || "listener_unavailable" };
10776
10777
  }
10777
10778
  } catch (error) {
10778
10779
  const failureState = clickUpWebhookRuntime.state || readClickUpWebhookState(worktree, clickUpWebhookValidation.config);
10779
- const failureClient = input.clickupClient || createClickUpApiClient(clickUpWebhookValidation.config, input.fetch);
10780
- await deleteClickUpWebhookBestEffort({ webhookId: failureState.webhookId, clickupClient: failureClient, worktree, reason: "listener_failed" });
10780
+ clickUpWebhookLifecycleLog(worktree, { type: "remote_webhook_preserved", reason: "listener_failed", webhookId: failureState.webhookId });
10781
10781
  markClickUpWebhookInactive(worktree, failureState, clickUpWebhookValidation.config);
10782
10782
  clickUpWebhookActive = false;
10783
10783
  clickUpWebhookRuntime = { ...clickUpWebhookRuntime, active: false, valid: false, reason: "listener_failed", error: error.message };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defend-tech/opencode-optima",
3
- "version": "0.1.21",
3
+ "version": "0.1.23",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+ssh://git@github.com/defend-tech/opencode-optima.git"