@defend-tech/opencode-optima 0.1.53 → 0.1.54
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 +17 -9
- package/dist/sanitize_cli.js +17 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9256,17 +9256,20 @@ function clickUpWebhookLocationCompatible(webhook = {}, config = {}) {
|
|
|
9256
9256
|
}
|
|
9257
9257
|
return true;
|
|
9258
9258
|
}
|
|
9259
|
-
async function findReusableClickUpWebhook(config, clickupClient = null) {
|
|
9259
|
+
async function findReusableClickUpWebhook(config, clickupClient = null, existingState = null) {
|
|
9260
9260
|
if (!clickupClient?.listWebhooks) return null;
|
|
9261
9261
|
const listed = await clickupClient.listWebhooks({ teamId: config.teamId });
|
|
9262
|
+
let secretlessMatch = null;
|
|
9262
9263
|
for (const webhook of clickUpWebhookListItems(listed)) {
|
|
9263
9264
|
const remote = normalizeClickUpWebhookApiResponse(webhook, config);
|
|
9264
9265
|
if (remote.publicUrl !== config.webhook.publicUrl) continue;
|
|
9265
9266
|
if (!clickUpWebhookLocationCompatible(webhook, config)) continue;
|
|
9266
|
-
|
|
9267
|
-
|
|
9267
|
+
const existingSecret = existingState?.webhookId === remote.webhookId ? existingState.secret : "";
|
|
9268
|
+
const reusable = remote.secret ? remote : { ...remote, secret: existingSecret };
|
|
9269
|
+
if (isClickUpWebhookStateActive(reusable, config)) return reusable;
|
|
9270
|
+
if (remote.webhookId && !secretlessMatch) secretlessMatch = { ...remote, active: false, reason: "remote_secret_unavailable" };
|
|
9268
9271
|
}
|
|
9269
|
-
return
|
|
9272
|
+
return secretlessMatch;
|
|
9270
9273
|
}
|
|
9271
9274
|
async function validateClickUpWebhookState(state, config, clickupClient = null, { allowRemoteUnhealthyLocalRecovery = false } = {}) {
|
|
9272
9275
|
if (!isClickUpWebhookStateActive(state, config)) return { valid: false, reason: "state_incomplete" };
|
|
@@ -9311,11 +9314,16 @@ async function ensureClickUpWebhookSubscription({ validation, worktree, clickupC
|
|
|
9311
9314
|
clickUpWebhookLifecycleLog(worktree, { type: "remote_webhook_reused", webhookId: state.webhookId, mode: existingValidation.mode });
|
|
9312
9315
|
return { active: true, valid: true, mode: existingValidation.mode, limitation: existingValidation.limitation, state };
|
|
9313
9316
|
}
|
|
9314
|
-
const reusableRemote = await findReusableClickUpWebhook(config, clickupClient);
|
|
9317
|
+
const reusableRemote = await findReusableClickUpWebhook(config, clickupClient, existing);
|
|
9315
9318
|
if (reusableRemote) {
|
|
9316
|
-
|
|
9317
|
-
|
|
9318
|
-
|
|
9319
|
+
if (isClickUpWebhookStateActive(reusableRemote, config)) {
|
|
9320
|
+
const state = writeClickUpWebhookState(worktree, { ...reusableRemote, recentEventKeys: existing.recentEventKeys || [] }, config);
|
|
9321
|
+
const mode2 = reusableRemote.secret === existing.secret && existing.webhookId === reusableRemote.webhookId ? "remote_discovered_local_secret" : "remote_discovered";
|
|
9322
|
+
clickUpWebhookLifecycleLog(worktree, { type: "remote_webhook_reused", webhookId: state.webhookId, mode: mode2 });
|
|
9323
|
+
return { active: true, valid: true, mode: mode2, state };
|
|
9324
|
+
}
|
|
9325
|
+
clickUpWebhookLifecycleLog(worktree, { type: "remote_webhook_preserved", webhookId: reusableRemote.webhookId, reason: reusableRemote.reason || "remote_webhook_exists_without_secret" });
|
|
9326
|
+
return { active: false, valid: false, reason: reusableRemote.reason || "remote_webhook_exists_without_secret", state: existing, remote: reusableRemote };
|
|
9319
9327
|
}
|
|
9320
9328
|
if (existing.webhookId && clickupClient?.deleteWebhook) {
|
|
9321
9329
|
await deleteClickUpWebhookBestEffort({ webhookId: existing.webhookId, clickupClient, worktree, reason: existingValidation.reason || "startup_self_heal" });
|
|
@@ -11471,7 +11479,7 @@ function isSameOrNestedPath(candidate, root) {
|
|
|
11471
11479
|
function shouldRegisterWorkflowProductManager(options = {}, worktree = process.cwd()) {
|
|
11472
11480
|
if (options.clickUpWebhookActive === true) return true;
|
|
11473
11481
|
const validation = options.clickUpWebhookValidation;
|
|
11474
|
-
return validation?.complete === true && isSameOrNestedPath(worktree, validation.config?.basePath);
|
|
11482
|
+
return validation?.complete === true && validation?.ok !== false && isSameOrNestedPath(worktree, validation.config?.basePath);
|
|
11475
11483
|
}
|
|
11476
11484
|
function buildOptimaAgents(repoCfg, operatingTeamMode, worktree, debugDir, options = {}) {
|
|
11477
11485
|
const optimaActive = repoCfg && repoCfg.enabled === true;
|
package/dist/sanitize_cli.js
CHANGED
|
@@ -9263,17 +9263,20 @@ function clickUpWebhookLocationCompatible(webhook = {}, config = {}) {
|
|
|
9263
9263
|
}
|
|
9264
9264
|
return true;
|
|
9265
9265
|
}
|
|
9266
|
-
async function findReusableClickUpWebhook(config, clickupClient = null) {
|
|
9266
|
+
async function findReusableClickUpWebhook(config, clickupClient = null, existingState = null) {
|
|
9267
9267
|
if (!clickupClient?.listWebhooks) return null;
|
|
9268
9268
|
const listed = await clickupClient.listWebhooks({ teamId: config.teamId });
|
|
9269
|
+
let secretlessMatch = null;
|
|
9269
9270
|
for (const webhook of clickUpWebhookListItems(listed)) {
|
|
9270
9271
|
const remote = normalizeClickUpWebhookApiResponse(webhook, config);
|
|
9271
9272
|
if (remote.publicUrl !== config.webhook.publicUrl) continue;
|
|
9272
9273
|
if (!clickUpWebhookLocationCompatible(webhook, config)) continue;
|
|
9273
|
-
|
|
9274
|
-
|
|
9274
|
+
const existingSecret = existingState?.webhookId === remote.webhookId ? existingState.secret : "";
|
|
9275
|
+
const reusable = remote.secret ? remote : { ...remote, secret: existingSecret };
|
|
9276
|
+
if (isClickUpWebhookStateActive(reusable, config)) return reusable;
|
|
9277
|
+
if (remote.webhookId && !secretlessMatch) secretlessMatch = { ...remote, active: false, reason: "remote_secret_unavailable" };
|
|
9275
9278
|
}
|
|
9276
|
-
return
|
|
9279
|
+
return secretlessMatch;
|
|
9277
9280
|
}
|
|
9278
9281
|
async function validateClickUpWebhookState(state, config, clickupClient = null, { allowRemoteUnhealthyLocalRecovery = false } = {}) {
|
|
9279
9282
|
if (!isClickUpWebhookStateActive(state, config)) return { valid: false, reason: "state_incomplete" };
|
|
@@ -9318,11 +9321,16 @@ async function ensureClickUpWebhookSubscription({ validation, worktree, clickupC
|
|
|
9318
9321
|
clickUpWebhookLifecycleLog(worktree, { type: "remote_webhook_reused", webhookId: state.webhookId, mode: existingValidation.mode });
|
|
9319
9322
|
return { active: true, valid: true, mode: existingValidation.mode, limitation: existingValidation.limitation, state };
|
|
9320
9323
|
}
|
|
9321
|
-
const reusableRemote = await findReusableClickUpWebhook(config, clickupClient);
|
|
9324
|
+
const reusableRemote = await findReusableClickUpWebhook(config, clickupClient, existing);
|
|
9322
9325
|
if (reusableRemote) {
|
|
9323
|
-
|
|
9324
|
-
|
|
9325
|
-
|
|
9326
|
+
if (isClickUpWebhookStateActive(reusableRemote, config)) {
|
|
9327
|
+
const state = writeClickUpWebhookState(worktree, { ...reusableRemote, recentEventKeys: existing.recentEventKeys || [] }, config);
|
|
9328
|
+
const mode2 = reusableRemote.secret === existing.secret && existing.webhookId === reusableRemote.webhookId ? "remote_discovered_local_secret" : "remote_discovered";
|
|
9329
|
+
clickUpWebhookLifecycleLog(worktree, { type: "remote_webhook_reused", webhookId: state.webhookId, mode: mode2 });
|
|
9330
|
+
return { active: true, valid: true, mode: mode2, state };
|
|
9331
|
+
}
|
|
9332
|
+
clickUpWebhookLifecycleLog(worktree, { type: "remote_webhook_preserved", webhookId: reusableRemote.webhookId, reason: reusableRemote.reason || "remote_webhook_exists_without_secret" });
|
|
9333
|
+
return { active: false, valid: false, reason: reusableRemote.reason || "remote_webhook_exists_without_secret", state: existing, remote: reusableRemote };
|
|
9326
9334
|
}
|
|
9327
9335
|
if (existing.webhookId && clickupClient?.deleteWebhook) {
|
|
9328
9336
|
await deleteClickUpWebhookBestEffort({ webhookId: existing.webhookId, clickupClient, worktree, reason: existingValidation.reason || "startup_self_heal" });
|
|
@@ -11478,7 +11486,7 @@ function isSameOrNestedPath(candidate, root) {
|
|
|
11478
11486
|
function shouldRegisterWorkflowProductManager(options = {}, worktree = process.cwd()) {
|
|
11479
11487
|
if (options.clickUpWebhookActive === true) return true;
|
|
11480
11488
|
const validation = options.clickUpWebhookValidation;
|
|
11481
|
-
return validation?.complete === true && isSameOrNestedPath(worktree, validation.config?.basePath);
|
|
11489
|
+
return validation?.complete === true && validation?.ok !== false && isSameOrNestedPath(worktree, validation.config?.basePath);
|
|
11482
11490
|
}
|
|
11483
11491
|
function buildOptimaAgents(repoCfg, operatingTeamMode, worktree, debugDir, options = {}) {
|
|
11484
11492
|
const optimaActive = repoCfg && repoCfg.enabled === true;
|