feat(attachments): route opencode image delivery
This commit is contained in:
parent
ee9d08a7a4
commit
f400fddb8f
1 changed files with 16 additions and 56 deletions
|
|
@ -1,7 +1,9 @@
|
||||||
import {
|
import {
|
||||||
buildClaudeAttachmentDeliveryParts,
|
buildClaudeAttachmentDeliveryParts,
|
||||||
buildCodexNativeAttachmentDeliveryParts,
|
buildCodexNativeAttachmentDeliveryParts,
|
||||||
|
buildOpenCodeAttachmentDeliveryParts,
|
||||||
type CodexNativeImageArgPart,
|
type CodexNativeImageArgPart,
|
||||||
|
type OpenCodeFilePart,
|
||||||
} from '@features/agent-attachments/main';
|
} from '@features/agent-attachments/main';
|
||||||
import {
|
import {
|
||||||
resolveAnthropicFastMode,
|
resolveAnthropicFastMode,
|
||||||
|
|
@ -8557,14 +8559,6 @@ export class TeamProvisioningService {
|
||||||
}),
|
}),
|
||||||
now,
|
now,
|
||||||
});
|
});
|
||||||
if (message.attachments?.length) {
|
|
||||||
await ledger.markFailedTerminal({
|
|
||||||
id: record.id,
|
|
||||||
reason: 'opencode_attachments_not_supported_for_secondary_runtime',
|
|
||||||
failedAt: now,
|
|
||||||
});
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const recovered = await ledger.markAcceptanceUnknown({
|
const recovered = await ledger.markAcceptanceUnknown({
|
||||||
id: record.id,
|
id: record.id,
|
||||||
reason: 'opencode_prompt_delivery_ledger_rebuilt_from_unread_inbox',
|
reason: 'opencode_prompt_delivery_ledger_rebuilt_from_unread_inbox',
|
||||||
|
|
@ -8599,6 +8593,7 @@ export class TeamProvisioningService {
|
||||||
actionMode?: AgentActionMode;
|
actionMode?: AgentActionMode;
|
||||||
messageKind?: InboxMessage['messageKind'];
|
messageKind?: InboxMessage['messageKind'];
|
||||||
taskRefs?: TaskRef[];
|
taskRefs?: TaskRef[];
|
||||||
|
attachments?: AttachmentPayload[];
|
||||||
source?: OpenCodeMemberInboxRelayOptions['source'];
|
source?: OpenCodeMemberInboxRelayOptions['source'];
|
||||||
inboxTimestamp?: string;
|
inboxTimestamp?: string;
|
||||||
}
|
}
|
||||||
|
|
@ -8787,6 +8782,15 @@ export class TeamProvisioningService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const openCodeFileParts: OpenCodeFilePart[] =
|
||||||
|
input.attachments?.length && laneIdentity.laneOwnerProviderId === 'opencode'
|
||||||
|
? buildOpenCodeAttachmentDeliveryParts({
|
||||||
|
text: input.text,
|
||||||
|
model: metaMember?.model ?? configMember?.model ?? '',
|
||||||
|
attachments: input.attachments,
|
||||||
|
}).fileParts
|
||||||
|
: [];
|
||||||
|
|
||||||
if (!this.isOpenCodePromptDeliveryWatchdogEnabled()) {
|
if (!this.isOpenCodePromptDeliveryWatchdogEnabled()) {
|
||||||
const result = await adapter.sendMessageToMember({
|
const result = await adapter.sendMessageToMember({
|
||||||
...(runtimeRunId ? { runId: runtimeRunId } : {}),
|
...(runtimeRunId ? { runId: runtimeRunId } : {}),
|
||||||
|
|
@ -8796,6 +8800,7 @@ export class TeamProvisioningService {
|
||||||
cwd,
|
cwd,
|
||||||
text: input.text,
|
text: input.text,
|
||||||
messageId: input.messageId,
|
messageId: input.messageId,
|
||||||
|
fileParts: openCodeFileParts,
|
||||||
replyRecipient: input.replyRecipient,
|
replyRecipient: input.replyRecipient,
|
||||||
actionMode: input.actionMode,
|
actionMode: input.actionMode,
|
||||||
messageKind: input.messageKind,
|
messageKind: input.messageKind,
|
||||||
|
|
@ -8912,6 +8917,7 @@ export class TeamProvisioningService {
|
||||||
replyRecipient: input.replyRecipient ?? 'user',
|
replyRecipient: input.replyRecipient ?? 'user',
|
||||||
actionMode: input.actionMode ?? null,
|
actionMode: input.actionMode ?? null,
|
||||||
taskRefs: input.taskRefs ?? [],
|
taskRefs: input.taskRefs ?? [],
|
||||||
|
attachments: input.attachments,
|
||||||
source: input.source,
|
source: input.source,
|
||||||
}),
|
}),
|
||||||
now,
|
now,
|
||||||
|
|
@ -9191,6 +9197,7 @@ export class TeamProvisioningService {
|
||||||
cwd,
|
cwd,
|
||||||
text: deliveryText,
|
text: deliveryText,
|
||||||
messageId: input.messageId,
|
messageId: input.messageId,
|
||||||
|
fileParts: openCodeFileParts,
|
||||||
replyRecipient: input.replyRecipient,
|
replyRecipient: input.replyRecipient,
|
||||||
actionMode: input.actionMode,
|
actionMode: input.actionMode,
|
||||||
messageKind: input.messageKind,
|
messageKind: input.messageKind,
|
||||||
|
|
@ -20202,54 +20209,6 @@ export class TeamProvisioningService {
|
||||||
existingRecord?.taskRefs ?? options.deliveryMetadata?.taskRefs ?? message.taskRefs ?? [];
|
existingRecord?.taskRefs ?? options.deliveryMetadata?.taskRefs ?? message.taskRefs ?? [];
|
||||||
const effectiveSource = existingRecord?.source ?? options.source ?? 'watcher';
|
const effectiveSource = existingRecord?.source ?? options.source ?? 'watcher';
|
||||||
result.attempted += 1;
|
result.attempted += 1;
|
||||||
if (message.attachments?.length) {
|
|
||||||
const reason = 'opencode_attachments_not_supported_for_secondary_runtime';
|
|
||||||
const now = nowIso();
|
|
||||||
const record = await promptLedger.ensurePending({
|
|
||||||
teamName,
|
|
||||||
memberName: memberIdentity.canonicalMemberName,
|
|
||||||
laneId: memberIdentity.laneId,
|
|
||||||
runId: await this.resolveCurrentOpenCodeRuntimeRunId(teamName, memberIdentity.laneId),
|
|
||||||
inboxMessageId: message.messageId,
|
|
||||||
inboxTimestamp: message.timestamp,
|
|
||||||
source: effectiveSource,
|
|
||||||
replyRecipient: effectiveReplyRecipient,
|
|
||||||
actionMode: effectiveActionMode,
|
|
||||||
messageKind: message.messageKind ?? null,
|
|
||||||
taskRefs: effectiveTaskRefs,
|
|
||||||
payloadHash: hashOpenCodePromptDeliveryPayload({
|
|
||||||
text: message.text,
|
|
||||||
replyRecipient: effectiveReplyRecipient,
|
|
||||||
actionMode: effectiveActionMode,
|
|
||||||
taskRefs: effectiveTaskRefs,
|
|
||||||
attachments: message.attachments,
|
|
||||||
source: effectiveSource,
|
|
||||||
}),
|
|
||||||
now,
|
|
||||||
});
|
|
||||||
const failed = await promptLedger.markFailedTerminal({
|
|
||||||
id: record.id,
|
|
||||||
reason,
|
|
||||||
failedAt: now,
|
|
||||||
});
|
|
||||||
this.logOpenCodePromptDeliveryEvent('opencode_prompt_delivery_terminal_failure', failed);
|
|
||||||
const diagnostics = failed.diagnostics.length ? failed.diagnostics : [reason];
|
|
||||||
result.failed += 1;
|
|
||||||
result.lastDelivery = {
|
|
||||||
delivered: false,
|
|
||||||
accepted: false,
|
|
||||||
ledgerStatus: failed.status,
|
|
||||||
ledgerRecordId: failed.id,
|
|
||||||
laneId: memberIdentity.laneId,
|
|
||||||
reason,
|
|
||||||
diagnostics,
|
|
||||||
};
|
|
||||||
result.diagnostics = [...(result.diagnostics ?? []), ...diagnostics];
|
|
||||||
logger.warn(
|
|
||||||
`[${teamName}] OpenCode inbox relay refused attachment-only unsupported delivery for ${memberName}/${message.messageId}: ${reason}`
|
|
||||||
);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const delivery = await this.deliverOpenCodeMemberMessage(teamName, {
|
const delivery = await this.deliverOpenCodeMemberMessage(teamName, {
|
||||||
memberName,
|
memberName,
|
||||||
text: message.text,
|
text: message.text,
|
||||||
|
|
@ -20258,6 +20217,7 @@ export class TeamProvisioningService {
|
||||||
actionMode: effectiveActionMode ?? undefined,
|
actionMode: effectiveActionMode ?? undefined,
|
||||||
messageKind: message.messageKind,
|
messageKind: message.messageKind,
|
||||||
taskRefs: effectiveTaskRefs,
|
taskRefs: effectiveTaskRefs,
|
||||||
|
attachments: message.attachments,
|
||||||
source: effectiveSource,
|
source: effectiveSource,
|
||||||
inboxTimestamp: message.timestamp,
|
inboxTimestamp: message.timestamp,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue