@defend-tech/opencode-optima 0.1.13 → 0.1.14
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 +21 -5
- package/dist/sanitize_cli.js +21 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9207,10 +9207,26 @@ async function createOpenCodeSession(client, { title, directory } = {}) {
|
|
|
9207
9207
|
const result = await client.session.create({ query: { directory }, body: { title } });
|
|
9208
9208
|
return result?.data?.id || result?.id;
|
|
9209
9209
|
}
|
|
9210
|
+
async function callOpenCodePromptWithPathFallback(method, sessionId, payload) {
|
|
9211
|
+
try {
|
|
9212
|
+
return await method({ ...payload, path: { sessionID: sessionId } });
|
|
9213
|
+
} catch (error) {
|
|
9214
|
+
try {
|
|
9215
|
+
return await method({ ...payload, path: { id: sessionId } });
|
|
9216
|
+
} catch {
|
|
9217
|
+
throw error;
|
|
9218
|
+
}
|
|
9219
|
+
}
|
|
9220
|
+
}
|
|
9210
9221
|
async function sendOpenCodeSessionEvent(client, { sessionId, agent, text, directory } = {}) {
|
|
9211
|
-
const payload = {
|
|
9212
|
-
if (typeof client?.session?.
|
|
9213
|
-
|
|
9222
|
+
const payload = { query: { directory }, body: { agent, parts: [{ type: "text", text }] } };
|
|
9223
|
+
if (typeof client?.session?.prompt === "function") {
|
|
9224
|
+
return callOpenCodePromptWithPathFallback(client.session.prompt.bind(client.session), sessionId, payload);
|
|
9225
|
+
}
|
|
9226
|
+
if (typeof client?.session?.promptAsync === "function") {
|
|
9227
|
+
return callOpenCodePromptWithPathFallback(client.session.promptAsync.bind(client.session), sessionId, payload);
|
|
9228
|
+
}
|
|
9229
|
+
throw new Error("OpenCode client does not expose session.prompt or session.promptAsync.");
|
|
9214
9230
|
}
|
|
9215
9231
|
function formatClickUpWebhookPrompt({ eventType, taskId, payload }) {
|
|
9216
9232
|
const comment = clickUpCommentFromPayload(payload);
|
|
@@ -9367,9 +9383,9 @@ async function routeClickUpWebhookEventUnlocked({ payload, config, state = {}, w
|
|
|
9367
9383
|
appendClickUpWebhookLocalLog(worktree, { type: "pending_session_metadata_failed", taskId, sessionId: pendingSessionId, message: error.message });
|
|
9368
9384
|
throw error;
|
|
9369
9385
|
}
|
|
9386
|
+
await sendSessionEvent(openCodeClient, { sessionId: pendingSessionId, agent: config.routing.targetAgent, text: prompt, directory: config.basePath });
|
|
9370
9387
|
const nextMetadata = clearClickUpPendingSessionMetadata(setClickUpSessionMetadata(pendingMetadata, config.routing.metadataKey, pendingSessionId), config.routing.metadataKey);
|
|
9371
9388
|
await clickupClient.updateTaskMetadata({ taskId, fieldId: config.routing.metadataFieldId, value: nextMetadata });
|
|
9372
|
-
await sendSessionEvent(openCodeClient, { sessionId: pendingSessionId, agent: config.routing.targetAgent, text: prompt, directory: config.basePath });
|
|
9373
9389
|
const { [taskId]: _completedPending, ...remainingPending } = stateToPersist.pendingSessions || {};
|
|
9374
9390
|
stateToPersist = { ...stateToPersist, pendingSessions: remainingPending };
|
|
9375
9391
|
return finish({ ok: true, action: "created_session", taskId, sessionId: pendingSessionId, eventKey });
|
|
@@ -11117,7 +11133,7 @@ Follow-up: use optima_prompt_workflow with session_id '${sessionId}' to check in
|
|
|
11117
11133
|
}
|
|
11118
11134
|
};
|
|
11119
11135
|
}
|
|
11120
|
-
OptimaPlugin.__internals = { buildClickUpApplyPayloadResult, buildClickUpCreateSubtasksPayload, buildClickUpStartTaskPayload, buildClickUpSummaryPayload, buildClickUpTransitionPayload, buildOptimaAgents, clickUpCommentMentionsProductManager, clickUpWebhookAuditLogDir, clickUpWebhookAuditLogPath, createClickUpApiClient, ensureClickUpWebhookSubscription, handleClickUpWebhookRequest, isClickUpWebhookStateActive, normalizeClickUpWebhookConfig, normalizeClickUpWebhookLogLevel, readClickUpWebhookState, resolveOptimaPluginOptions, resolveSecretReference, routeClickUpWebhookEvent, startClickUpWebhookListener, validateClickUpWebhookState, verifyClickUpSignature, writeClickUpWebhookState, decideClickUpStatusAction, deriveClickUpBranchName, deriveClickUpPendingSubtaskBranch, deriveClickUpPrTarget, deriveClickUpWorktree, determineClickUpMergeAuthority, ensureOptimaGitignoreRules, explicitSafeInputWorktree, finalApprovalAssignees, formatValidationResult, isIgnoredClickUpTaskType, isOptimaPluginPackageWorktree, isSafeWritableDirectory, loadHumansRegistry, mergeClickUpAgentMetadata, mergeClickUpSessionMetadata, migrateLegacyOptimaLayout, normalizeAgentMetadataJson, normalizeClickUpStatus, normalizeClickUpTaskType, normalizePromptResponseParts, normalizeWorkflowTaskPath, parseClickUpSubtasksMarkdown, parseHumansRegistry, parseMarkdownArtifact, parseMarkdownSections, preEstimateClickUpWork, readMarkdownArtifact, resolveHumanRoles, resolveSafeWorktree, safeWorktreeOrFailure, stripRawLogSections, validateMainWorkspaceBranchSafety, workflowFinalMessageFromPromptResponse };
|
|
11136
|
+
OptimaPlugin.__internals = { buildClickUpApplyPayloadResult, buildClickUpCreateSubtasksPayload, buildClickUpStartTaskPayload, buildClickUpSummaryPayload, buildClickUpTransitionPayload, buildOptimaAgents, clickUpCommentMentionsProductManager, clickUpWebhookAuditLogDir, clickUpWebhookAuditLogPath, createClickUpApiClient, ensureClickUpWebhookSubscription, handleClickUpWebhookRequest, isClickUpWebhookStateActive, normalizeClickUpWebhookConfig, normalizeClickUpWebhookLogLevel, readClickUpWebhookState, resolveOptimaPluginOptions, resolveSecretReference, routeClickUpWebhookEvent, sendOpenCodeSessionEvent, startClickUpWebhookListener, validateClickUpWebhookState, verifyClickUpSignature, writeClickUpWebhookState, decideClickUpStatusAction, deriveClickUpBranchName, deriveClickUpPendingSubtaskBranch, deriveClickUpPrTarget, deriveClickUpWorktree, determineClickUpMergeAuthority, ensureOptimaGitignoreRules, explicitSafeInputWorktree, finalApprovalAssignees, formatValidationResult, isIgnoredClickUpTaskType, isOptimaPluginPackageWorktree, isSafeWritableDirectory, loadHumansRegistry, mergeClickUpAgentMetadata, mergeClickUpSessionMetadata, migrateLegacyOptimaLayout, normalizeAgentMetadataJson, normalizeClickUpStatus, normalizeClickUpTaskType, normalizePromptResponseParts, normalizeWorkflowTaskPath, parseClickUpSubtasksMarkdown, parseHumansRegistry, parseMarkdownArtifact, parseMarkdownSections, preEstimateClickUpWork, readMarkdownArtifact, resolveHumanRoles, resolveSafeWorktree, safeWorktreeOrFailure, stripRawLogSections, validateMainWorkspaceBranchSafety, workflowFinalMessageFromPromptResponse };
|
|
11121
11137
|
export {
|
|
11122
11138
|
OptimaPlugin as default
|
|
11123
11139
|
};
|
package/dist/sanitize_cli.js
CHANGED
|
@@ -9214,10 +9214,26 @@ async function createOpenCodeSession(client, { title, directory } = {}) {
|
|
|
9214
9214
|
const result = await client.session.create({ query: { directory }, body: { title } });
|
|
9215
9215
|
return result?.data?.id || result?.id;
|
|
9216
9216
|
}
|
|
9217
|
+
async function callOpenCodePromptWithPathFallback(method, sessionId, payload) {
|
|
9218
|
+
try {
|
|
9219
|
+
return await method({ ...payload, path: { sessionID: sessionId } });
|
|
9220
|
+
} catch (error) {
|
|
9221
|
+
try {
|
|
9222
|
+
return await method({ ...payload, path: { id: sessionId } });
|
|
9223
|
+
} catch {
|
|
9224
|
+
throw error;
|
|
9225
|
+
}
|
|
9226
|
+
}
|
|
9227
|
+
}
|
|
9217
9228
|
async function sendOpenCodeSessionEvent(client, { sessionId, agent, text, directory } = {}) {
|
|
9218
|
-
const payload = {
|
|
9219
|
-
if (typeof client?.session?.
|
|
9220
|
-
|
|
9229
|
+
const payload = { query: { directory }, body: { agent, parts: [{ type: "text", text }] } };
|
|
9230
|
+
if (typeof client?.session?.prompt === "function") {
|
|
9231
|
+
return callOpenCodePromptWithPathFallback(client.session.prompt.bind(client.session), sessionId, payload);
|
|
9232
|
+
}
|
|
9233
|
+
if (typeof client?.session?.promptAsync === "function") {
|
|
9234
|
+
return callOpenCodePromptWithPathFallback(client.session.promptAsync.bind(client.session), sessionId, payload);
|
|
9235
|
+
}
|
|
9236
|
+
throw new Error("OpenCode client does not expose session.prompt or session.promptAsync.");
|
|
9221
9237
|
}
|
|
9222
9238
|
function formatClickUpWebhookPrompt({ eventType, taskId, payload }) {
|
|
9223
9239
|
const comment = clickUpCommentFromPayload(payload);
|
|
@@ -9374,9 +9390,9 @@ async function routeClickUpWebhookEventUnlocked({ payload, config, state = {}, w
|
|
|
9374
9390
|
appendClickUpWebhookLocalLog(worktree, { type: "pending_session_metadata_failed", taskId, sessionId: pendingSessionId, message: error.message });
|
|
9375
9391
|
throw error;
|
|
9376
9392
|
}
|
|
9393
|
+
await sendSessionEvent(openCodeClient, { sessionId: pendingSessionId, agent: config.routing.targetAgent, text: prompt, directory: config.basePath });
|
|
9377
9394
|
const nextMetadata = clearClickUpPendingSessionMetadata(setClickUpSessionMetadata(pendingMetadata, config.routing.metadataKey, pendingSessionId), config.routing.metadataKey);
|
|
9378
9395
|
await clickupClient.updateTaskMetadata({ taskId, fieldId: config.routing.metadataFieldId, value: nextMetadata });
|
|
9379
|
-
await sendSessionEvent(openCodeClient, { sessionId: pendingSessionId, agent: config.routing.targetAgent, text: prompt, directory: config.basePath });
|
|
9380
9396
|
const { [taskId]: _completedPending, ...remainingPending } = stateToPersist.pendingSessions || {};
|
|
9381
9397
|
stateToPersist = { ...stateToPersist, pendingSessions: remainingPending };
|
|
9382
9398
|
return finish({ ok: true, action: "created_session", taskId, sessionId: pendingSessionId, eventKey });
|
|
@@ -11124,7 +11140,7 @@ Follow-up: use optima_prompt_workflow with session_id '${sessionId}' to check in
|
|
|
11124
11140
|
}
|
|
11125
11141
|
};
|
|
11126
11142
|
}
|
|
11127
|
-
OptimaPlugin.__internals = { buildClickUpApplyPayloadResult, buildClickUpCreateSubtasksPayload, buildClickUpStartTaskPayload, buildClickUpSummaryPayload, buildClickUpTransitionPayload, buildOptimaAgents, clickUpCommentMentionsProductManager, clickUpWebhookAuditLogDir, clickUpWebhookAuditLogPath, createClickUpApiClient, ensureClickUpWebhookSubscription, handleClickUpWebhookRequest, isClickUpWebhookStateActive, normalizeClickUpWebhookConfig, normalizeClickUpWebhookLogLevel, readClickUpWebhookState, resolveOptimaPluginOptions, resolveSecretReference, routeClickUpWebhookEvent, startClickUpWebhookListener, validateClickUpWebhookState, verifyClickUpSignature, writeClickUpWebhookState, decideClickUpStatusAction, deriveClickUpBranchName, deriveClickUpPendingSubtaskBranch, deriveClickUpPrTarget, deriveClickUpWorktree, determineClickUpMergeAuthority, ensureOptimaGitignoreRules, explicitSafeInputWorktree, finalApprovalAssignees, formatValidationResult, isIgnoredClickUpTaskType, isOptimaPluginPackageWorktree, isSafeWritableDirectory, loadHumansRegistry, mergeClickUpAgentMetadata, mergeClickUpSessionMetadata, migrateLegacyOptimaLayout, normalizeAgentMetadataJson, normalizeClickUpStatus, normalizeClickUpTaskType, normalizePromptResponseParts, normalizeWorkflowTaskPath, parseClickUpSubtasksMarkdown, parseHumansRegistry, parseMarkdownArtifact, parseMarkdownSections, preEstimateClickUpWork, readMarkdownArtifact, resolveHumanRoles, resolveSafeWorktree, safeWorktreeOrFailure, stripRawLogSections, validateMainWorkspaceBranchSafety, workflowFinalMessageFromPromptResponse };
|
|
11143
|
+
OptimaPlugin.__internals = { buildClickUpApplyPayloadResult, buildClickUpCreateSubtasksPayload, buildClickUpStartTaskPayload, buildClickUpSummaryPayload, buildClickUpTransitionPayload, buildOptimaAgents, clickUpCommentMentionsProductManager, clickUpWebhookAuditLogDir, clickUpWebhookAuditLogPath, createClickUpApiClient, ensureClickUpWebhookSubscription, handleClickUpWebhookRequest, isClickUpWebhookStateActive, normalizeClickUpWebhookConfig, normalizeClickUpWebhookLogLevel, readClickUpWebhookState, resolveOptimaPluginOptions, resolveSecretReference, routeClickUpWebhookEvent, sendOpenCodeSessionEvent, startClickUpWebhookListener, validateClickUpWebhookState, verifyClickUpSignature, writeClickUpWebhookState, decideClickUpStatusAction, deriveClickUpBranchName, deriveClickUpPendingSubtaskBranch, deriveClickUpPrTarget, deriveClickUpWorktree, determineClickUpMergeAuthority, ensureOptimaGitignoreRules, explicitSafeInputWorktree, finalApprovalAssignees, formatValidationResult, isIgnoredClickUpTaskType, isOptimaPluginPackageWorktree, isSafeWritableDirectory, loadHumansRegistry, mergeClickUpAgentMetadata, mergeClickUpSessionMetadata, migrateLegacyOptimaLayout, normalizeAgentMetadataJson, normalizeClickUpStatus, normalizeClickUpTaskType, normalizePromptResponseParts, normalizeWorkflowTaskPath, parseClickUpSubtasksMarkdown, parseHumansRegistry, parseMarkdownArtifact, parseMarkdownSections, preEstimateClickUpWork, readMarkdownArtifact, resolveHumanRoles, resolveSafeWorktree, safeWorktreeOrFailure, stripRawLogSections, validateMainWorkspaceBranchSafety, workflowFinalMessageFromPromptResponse };
|
|
11128
11144
|
|
|
11129
11145
|
// src/sanitize_cli.js
|
|
11130
11146
|
var { migrateLegacyOptimaLayout: migrateLegacyOptimaLayout2 } = OptimaPlugin.__internals;
|