@defend-tech/opencode-optima 0.1.52 → 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 +34 -45
- package/dist/sanitize_cli.js +34 -45
- 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" });
|
|
@@ -9648,23 +9656,16 @@ function extractOpenCodeSessionId(result) {
|
|
|
9648
9656
|
return data?.id || data?.sessionID || data?.sessionId || result?.id || result?.sessionID || result?.sessionId;
|
|
9649
9657
|
}
|
|
9650
9658
|
async function createOpenCodeSession(client, { title, directory, agent } = {}) {
|
|
9651
|
-
const flatPayload = { directory, title };
|
|
9652
|
-
if (agent) flatPayload.agent = agent;
|
|
9653
9659
|
const body = { title };
|
|
9654
9660
|
if (agent) body.agent = agent;
|
|
9655
|
-
|
|
9656
|
-
|
|
9657
|
-
|
|
9658
|
-
|
|
9659
|
-
|
|
9660
|
-
|
|
9661
|
-
|
|
9662
|
-
firstError ??= new Error("OpenCode session create response did not include a session id.");
|
|
9663
|
-
} catch (error) {
|
|
9664
|
-
firstError ??= error;
|
|
9665
|
-
}
|
|
9661
|
+
try {
|
|
9662
|
+
const result = await client.session.create({ query: { directory }, body });
|
|
9663
|
+
const sessionId = extractOpenCodeSessionId(result);
|
|
9664
|
+
if (sessionId) return sessionId;
|
|
9665
|
+
throw new Error("OpenCode session create response did not include a session id.");
|
|
9666
|
+
} catch (error) {
|
|
9667
|
+
throw error || new Error("OpenCode session create failed.");
|
|
9666
9668
|
}
|
|
9667
|
-
throw firstError || new Error("OpenCode session create failed.");
|
|
9668
9669
|
}
|
|
9669
9670
|
async function waitForOpenCodeReadiness(client, { worktree = process.cwd(), attempts = 10, delayMs = 500, now = () => /* @__PURE__ */ new Date() } = {}) {
|
|
9670
9671
|
if (typeof client?.session?.create !== "function") return { ok: true, skipped: true, reason: "session_create_probe_unavailable" };
|
|
@@ -9778,8 +9779,8 @@ function tagOpenCodePromptResult(result, deliveryMethod) {
|
|
|
9778
9779
|
return result;
|
|
9779
9780
|
}
|
|
9780
9781
|
async function callOpenCodePromptWithFallbacks(method, sessionId, flatPayload, structuredPayload, deliveryMethod) {
|
|
9781
|
-
const attempts = [
|
|
9782
|
-
|
|
9782
|
+
const attempts = deliveryMethod === "prompt" ? [structuredPayload] : [
|
|
9783
|
+
structuredPayload,
|
|
9783
9784
|
{ ...structuredPayload, path: { sessionID: sessionId } },
|
|
9784
9785
|
{ sessionID: sessionId, ...flatPayload },
|
|
9785
9786
|
{ id: sessionId, ...flatPayload }
|
|
@@ -9829,23 +9830,11 @@ function normalizeOpenCodeSessionMessages(result) {
|
|
|
9829
9830
|
if (Array.isArray(data?.items)) return [...data.items];
|
|
9830
9831
|
return [];
|
|
9831
9832
|
}
|
|
9832
|
-
async function readOpenCodeSessionMessages(client, { sessionId, limit = 20 } = {}) {
|
|
9833
|
+
async function readOpenCodeSessionMessages(client, { sessionId, directory, limit = 20 } = {}) {
|
|
9833
9834
|
if (typeof client?.session?.messages !== "function") return null;
|
|
9834
|
-
const
|
|
9835
|
-
|
|
9836
|
-
|
|
9837
|
-
{ sessionID: sessionId, limit },
|
|
9838
|
-
{ id: sessionId, limit }
|
|
9839
|
-
];
|
|
9840
|
-
let firstError = null;
|
|
9841
|
-
for (const attempt of attempts) {
|
|
9842
|
-
try {
|
|
9843
|
-
return normalizeOpenCodeSessionMessages(await client.session.messages(attempt));
|
|
9844
|
-
} catch (error) {
|
|
9845
|
-
firstError ??= error;
|
|
9846
|
-
}
|
|
9847
|
-
}
|
|
9848
|
-
throw firstError;
|
|
9835
|
+
const query = { limit };
|
|
9836
|
+
if (directory) query.directory = directory;
|
|
9837
|
+
return normalizeOpenCodeSessionMessages(await client.session.messages({ path: { id: sessionId }, query }));
|
|
9849
9838
|
}
|
|
9850
9839
|
function openCodeMessageText(message) {
|
|
9851
9840
|
const parts = [message?.text, message?.content, message?.message, message?.body?.text, message?.data?.text];
|
|
@@ -9858,11 +9847,11 @@ function openCodeMessageStableKey(message, index = 0) {
|
|
|
9858
9847
|
if (id) return `id:${id}`;
|
|
9859
9848
|
return `idx:${index}:text:${openCodeMessageText(message)}`;
|
|
9860
9849
|
}
|
|
9861
|
-
async function verifyOpenCodeSessionEventDelivery(client, { sessionId, beforeMessages = null, expectedText = "", markers = [], attempts = 8, delayMs = 250 } = {}) {
|
|
9850
|
+
async function verifyOpenCodeSessionEventDelivery(client, { sessionId, directory, beforeMessages = null, expectedText = "", markers = [], attempts = 8, delayMs = 250 } = {}) {
|
|
9862
9851
|
let lastError = "message_verification_unavailable";
|
|
9863
9852
|
for (let attempt = 0; attempt < Math.max(1, attempts); attempt += 1) {
|
|
9864
9853
|
try {
|
|
9865
|
-
const afterMessages = await readOpenCodeSessionMessages(client, { sessionId, limit: 50 });
|
|
9854
|
+
const afterMessages = await readOpenCodeSessionMessages(client, { sessionId, directory, limit: 50 });
|
|
9866
9855
|
if (!afterMessages) return { ok: false, reason: "message_verification_unavailable" };
|
|
9867
9856
|
const beforeCount = Array.isArray(beforeMessages) ? beforeMessages.length : null;
|
|
9868
9857
|
const beforeKeys = Array.isArray(beforeMessages) ? new Set(beforeMessages.map(openCodeMessageStableKey)) : null;
|
|
@@ -9910,7 +9899,7 @@ function openCodeBlockingPromptVerification(result, sessionId) {
|
|
|
9910
9899
|
return null;
|
|
9911
9900
|
}
|
|
9912
9901
|
async function deliverClickUpSessionEventWithVerification({ openCodeClient, sendSessionEvent, clickupClient, worktree, taskId, sessionId, agent, text, directory, opencodeBaseUrl, eventMarkers = [], verifySessionEventDelivery = verifyOpenCodeSessionEventDelivery, applyBlockerOnFailure = true } = {}) {
|
|
9913
|
-
const beforeMessages = await readOpenCodeSessionMessages(openCodeClient, { sessionId, limit: 50 }).catch(() => null);
|
|
9902
|
+
const beforeMessages = await readOpenCodeSessionMessages(openCodeClient, { sessionId, directory, limit: 50 }).catch(() => null);
|
|
9914
9903
|
const sendResult = await sendSessionEvent(openCodeClient, { sessionId, agent, text, directory, opencodeBaseUrl, allowDirectFallback: false });
|
|
9915
9904
|
let blockingPromptVerification = null;
|
|
9916
9905
|
let admissionVerification = null;
|
|
@@ -9924,7 +9913,7 @@ async function deliverClickUpSessionEventWithVerification({ openCodeClient, send
|
|
|
9924
9913
|
return { ok: false, action: "message_delivery_failed", reason: error.message, taskId, sessionId, fallbackAttempted: false, blockerTag: blocker2 };
|
|
9925
9914
|
}
|
|
9926
9915
|
if (blockingPromptVerification) return { ok: true, verification: blockingPromptVerification, admissionVerification: null, fallback: false };
|
|
9927
|
-
let verification = await verifySessionEventDelivery(openCodeClient, { sessionId, beforeMessages, expectedText: text, markers: eventMarkers });
|
|
9916
|
+
let verification = await verifySessionEventDelivery(openCodeClient, { sessionId, directory, beforeMessages, expectedText: text, markers: eventMarkers });
|
|
9928
9917
|
if (verification?.ok) return { ok: true, verification, admissionVerification, fallback: false };
|
|
9929
9918
|
if (admissionVerification) {
|
|
9930
9919
|
appendClickUpWebhookLocalLog(worktree, { type: "message_delivery_admitted_but_invisible", taskId, sessionId, admission: admissionVerification, reason: verification?.reason || "message_not_visible" });
|
|
@@ -11490,7 +11479,7 @@ function isSameOrNestedPath(candidate, root) {
|
|
|
11490
11479
|
function shouldRegisterWorkflowProductManager(options = {}, worktree = process.cwd()) {
|
|
11491
11480
|
if (options.clickUpWebhookActive === true) return true;
|
|
11492
11481
|
const validation = options.clickUpWebhookValidation;
|
|
11493
|
-
return validation?.complete === true && isSameOrNestedPath(worktree, validation.config?.basePath);
|
|
11482
|
+
return validation?.complete === true && validation?.ok !== false && isSameOrNestedPath(worktree, validation.config?.basePath);
|
|
11494
11483
|
}
|
|
11495
11484
|
function buildOptimaAgents(repoCfg, operatingTeamMode, worktree, debugDir, options = {}) {
|
|
11496
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" });
|
|
@@ -9655,23 +9663,16 @@ function extractOpenCodeSessionId(result) {
|
|
|
9655
9663
|
return data?.id || data?.sessionID || data?.sessionId || result?.id || result?.sessionID || result?.sessionId;
|
|
9656
9664
|
}
|
|
9657
9665
|
async function createOpenCodeSession(client, { title, directory, agent } = {}) {
|
|
9658
|
-
const flatPayload = { directory, title };
|
|
9659
|
-
if (agent) flatPayload.agent = agent;
|
|
9660
9666
|
const body = { title };
|
|
9661
9667
|
if (agent) body.agent = agent;
|
|
9662
|
-
|
|
9663
|
-
|
|
9664
|
-
|
|
9665
|
-
|
|
9666
|
-
|
|
9667
|
-
|
|
9668
|
-
|
|
9669
|
-
firstError ??= new Error("OpenCode session create response did not include a session id.");
|
|
9670
|
-
} catch (error) {
|
|
9671
|
-
firstError ??= error;
|
|
9672
|
-
}
|
|
9668
|
+
try {
|
|
9669
|
+
const result = await client.session.create({ query: { directory }, body });
|
|
9670
|
+
const sessionId = extractOpenCodeSessionId(result);
|
|
9671
|
+
if (sessionId) return sessionId;
|
|
9672
|
+
throw new Error("OpenCode session create response did not include a session id.");
|
|
9673
|
+
} catch (error) {
|
|
9674
|
+
throw error || new Error("OpenCode session create failed.");
|
|
9673
9675
|
}
|
|
9674
|
-
throw firstError || new Error("OpenCode session create failed.");
|
|
9675
9676
|
}
|
|
9676
9677
|
async function waitForOpenCodeReadiness(client, { worktree = process.cwd(), attempts = 10, delayMs = 500, now = () => /* @__PURE__ */ new Date() } = {}) {
|
|
9677
9678
|
if (typeof client?.session?.create !== "function") return { ok: true, skipped: true, reason: "session_create_probe_unavailable" };
|
|
@@ -9785,8 +9786,8 @@ function tagOpenCodePromptResult(result, deliveryMethod) {
|
|
|
9785
9786
|
return result;
|
|
9786
9787
|
}
|
|
9787
9788
|
async function callOpenCodePromptWithFallbacks(method, sessionId, flatPayload, structuredPayload, deliveryMethod) {
|
|
9788
|
-
const attempts = [
|
|
9789
|
-
|
|
9789
|
+
const attempts = deliveryMethod === "prompt" ? [structuredPayload] : [
|
|
9790
|
+
structuredPayload,
|
|
9790
9791
|
{ ...structuredPayload, path: { sessionID: sessionId } },
|
|
9791
9792
|
{ sessionID: sessionId, ...flatPayload },
|
|
9792
9793
|
{ id: sessionId, ...flatPayload }
|
|
@@ -9836,23 +9837,11 @@ function normalizeOpenCodeSessionMessages(result) {
|
|
|
9836
9837
|
if (Array.isArray(data?.items)) return [...data.items];
|
|
9837
9838
|
return [];
|
|
9838
9839
|
}
|
|
9839
|
-
async function readOpenCodeSessionMessages(client, { sessionId, limit = 20 } = {}) {
|
|
9840
|
+
async function readOpenCodeSessionMessages(client, { sessionId, directory, limit = 20 } = {}) {
|
|
9840
9841
|
if (typeof client?.session?.messages !== "function") return null;
|
|
9841
|
-
const
|
|
9842
|
-
|
|
9843
|
-
|
|
9844
|
-
{ sessionID: sessionId, limit },
|
|
9845
|
-
{ id: sessionId, limit }
|
|
9846
|
-
];
|
|
9847
|
-
let firstError = null;
|
|
9848
|
-
for (const attempt of attempts) {
|
|
9849
|
-
try {
|
|
9850
|
-
return normalizeOpenCodeSessionMessages(await client.session.messages(attempt));
|
|
9851
|
-
} catch (error) {
|
|
9852
|
-
firstError ??= error;
|
|
9853
|
-
}
|
|
9854
|
-
}
|
|
9855
|
-
throw firstError;
|
|
9842
|
+
const query = { limit };
|
|
9843
|
+
if (directory) query.directory = directory;
|
|
9844
|
+
return normalizeOpenCodeSessionMessages(await client.session.messages({ path: { id: sessionId }, query }));
|
|
9856
9845
|
}
|
|
9857
9846
|
function openCodeMessageText(message) {
|
|
9858
9847
|
const parts = [message?.text, message?.content, message?.message, message?.body?.text, message?.data?.text];
|
|
@@ -9865,11 +9854,11 @@ function openCodeMessageStableKey(message, index = 0) {
|
|
|
9865
9854
|
if (id) return `id:${id}`;
|
|
9866
9855
|
return `idx:${index}:text:${openCodeMessageText(message)}`;
|
|
9867
9856
|
}
|
|
9868
|
-
async function verifyOpenCodeSessionEventDelivery(client, { sessionId, beforeMessages = null, expectedText = "", markers = [], attempts = 8, delayMs = 250 } = {}) {
|
|
9857
|
+
async function verifyOpenCodeSessionEventDelivery(client, { sessionId, directory, beforeMessages = null, expectedText = "", markers = [], attempts = 8, delayMs = 250 } = {}) {
|
|
9869
9858
|
let lastError = "message_verification_unavailable";
|
|
9870
9859
|
for (let attempt = 0; attempt < Math.max(1, attempts); attempt += 1) {
|
|
9871
9860
|
try {
|
|
9872
|
-
const afterMessages = await readOpenCodeSessionMessages(client, { sessionId, limit: 50 });
|
|
9861
|
+
const afterMessages = await readOpenCodeSessionMessages(client, { sessionId, directory, limit: 50 });
|
|
9873
9862
|
if (!afterMessages) return { ok: false, reason: "message_verification_unavailable" };
|
|
9874
9863
|
const beforeCount = Array.isArray(beforeMessages) ? beforeMessages.length : null;
|
|
9875
9864
|
const beforeKeys = Array.isArray(beforeMessages) ? new Set(beforeMessages.map(openCodeMessageStableKey)) : null;
|
|
@@ -9917,7 +9906,7 @@ function openCodeBlockingPromptVerification(result, sessionId) {
|
|
|
9917
9906
|
return null;
|
|
9918
9907
|
}
|
|
9919
9908
|
async function deliverClickUpSessionEventWithVerification({ openCodeClient, sendSessionEvent, clickupClient, worktree, taskId, sessionId, agent, text, directory, opencodeBaseUrl, eventMarkers = [], verifySessionEventDelivery = verifyOpenCodeSessionEventDelivery, applyBlockerOnFailure = true } = {}) {
|
|
9920
|
-
const beforeMessages = await readOpenCodeSessionMessages(openCodeClient, { sessionId, limit: 50 }).catch(() => null);
|
|
9909
|
+
const beforeMessages = await readOpenCodeSessionMessages(openCodeClient, { sessionId, directory, limit: 50 }).catch(() => null);
|
|
9921
9910
|
const sendResult = await sendSessionEvent(openCodeClient, { sessionId, agent, text, directory, opencodeBaseUrl, allowDirectFallback: false });
|
|
9922
9911
|
let blockingPromptVerification = null;
|
|
9923
9912
|
let admissionVerification = null;
|
|
@@ -9931,7 +9920,7 @@ async function deliverClickUpSessionEventWithVerification({ openCodeClient, send
|
|
|
9931
9920
|
return { ok: false, action: "message_delivery_failed", reason: error.message, taskId, sessionId, fallbackAttempted: false, blockerTag: blocker2 };
|
|
9932
9921
|
}
|
|
9933
9922
|
if (blockingPromptVerification) return { ok: true, verification: blockingPromptVerification, admissionVerification: null, fallback: false };
|
|
9934
|
-
let verification = await verifySessionEventDelivery(openCodeClient, { sessionId, beforeMessages, expectedText: text, markers: eventMarkers });
|
|
9923
|
+
let verification = await verifySessionEventDelivery(openCodeClient, { sessionId, directory, beforeMessages, expectedText: text, markers: eventMarkers });
|
|
9935
9924
|
if (verification?.ok) return { ok: true, verification, admissionVerification, fallback: false };
|
|
9936
9925
|
if (admissionVerification) {
|
|
9937
9926
|
appendClickUpWebhookLocalLog(worktree, { type: "message_delivery_admitted_but_invisible", taskId, sessionId, admission: admissionVerification, reason: verification?.reason || "message_not_visible" });
|
|
@@ -11497,7 +11486,7 @@ function isSameOrNestedPath(candidate, root) {
|
|
|
11497
11486
|
function shouldRegisterWorkflowProductManager(options = {}, worktree = process.cwd()) {
|
|
11498
11487
|
if (options.clickUpWebhookActive === true) return true;
|
|
11499
11488
|
const validation = options.clickUpWebhookValidation;
|
|
11500
|
-
return validation?.complete === true && isSameOrNestedPath(worktree, validation.config?.basePath);
|
|
11489
|
+
return validation?.complete === true && validation?.ok !== false && isSameOrNestedPath(worktree, validation.config?.basePath);
|
|
11501
11490
|
}
|
|
11502
11491
|
function buildOptimaAgents(repoCfg, operatingTeamMode, worktree, debugDir, options = {}) {
|
|
11503
11492
|
const optimaActive = repoCfg && repoCfg.enabled === true;
|