style: format after runtime unification
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -22,9 +22,7 @@ import {
|
|||||||
getChannelFactory,
|
getChannelFactory,
|
||||||
getRegisteredChannelNames,
|
getRegisteredChannelNames,
|
||||||
} from './channels/registry.js';
|
} from './channels/registry.js';
|
||||||
import {
|
import { writeGroupsSnapshot } from './agent-runner.js';
|
||||||
writeGroupsSnapshot,
|
|
||||||
} from './agent-runner.js';
|
|
||||||
import {
|
import {
|
||||||
getAllChats,
|
getAllChats,
|
||||||
getAllRegisteredGroups,
|
getAllRegisteredGroups,
|
||||||
|
|||||||
@@ -31,76 +31,78 @@ vi.mock('./db.js', () => {
|
|||||||
const withSeqs = (messages: Array<Record<string, unknown>>) =>
|
const withSeqs = (messages: Array<Record<string, unknown>>) =>
|
||||||
messages.map((message, index) => ({
|
messages.map((message, index) => ({
|
||||||
...message,
|
...message,
|
||||||
seq:
|
seq: typeof message.seq === 'number' ? message.seq : index + 1,
|
||||||
typeof message.seq === 'number'
|
|
||||||
? message.seq
|
|
||||||
: index + 1,
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
getAllChats: vi.fn(() => []),
|
getAllChats: vi.fn(() => []),
|
||||||
getAllTasks: vi.fn(() => []),
|
getAllTasks: vi.fn(() => []),
|
||||||
getLastHumanMessageTimestamp: vi.fn(() => null),
|
getLastHumanMessageTimestamp: vi.fn(() => null),
|
||||||
getMessagesSince,
|
getMessagesSince,
|
||||||
getNewMessages,
|
getNewMessages,
|
||||||
getLatestMessageSeqAtOrBefore: vi.fn(() => 0),
|
getLatestMessageSeqAtOrBefore: vi.fn(() => 0),
|
||||||
getMessagesSinceSeq: vi.fn(
|
getMessagesSinceSeq: vi.fn(
|
||||||
(
|
(
|
||||||
chatJid: string,
|
chatJid: string,
|
||||||
sinceSeqCursor: string,
|
sinceSeqCursor: string,
|
||||||
botPrefix: string,
|
botPrefix: string,
|
||||||
limit?: number,
|
limit?: number,
|
||||||
) => withSeqs(getMessagesSince(chatJid, sinceSeqCursor, botPrefix, limit)),
|
) =>
|
||||||
),
|
withSeqs(getMessagesSince(chatJid, sinceSeqCursor, botPrefix, limit)),
|
||||||
getNewMessagesBySeq: vi.fn(
|
),
|
||||||
(
|
getNewMessagesBySeq: vi.fn(
|
||||||
jids: string[],
|
(
|
||||||
lastSeqCursor: string,
|
jids: string[],
|
||||||
botPrefix: string,
|
lastSeqCursor: string,
|
||||||
limit?: number,
|
botPrefix: string,
|
||||||
) => {
|
limit?: number,
|
||||||
const result:
|
) => {
|
||||||
| {
|
const result:
|
||||||
messages?: Array<Record<string, unknown>>;
|
| {
|
||||||
newSeqCursor?: string;
|
messages?: Array<Record<string, unknown>>;
|
||||||
newTimestamp?: string;
|
newSeqCursor?: string;
|
||||||
}
|
newTimestamp?: string;
|
||||||
| undefined =
|
}
|
||||||
getNewMessages(jids, lastSeqCursor, botPrefix, limit) || {
|
| undefined = getNewMessages(
|
||||||
messages: [],
|
jids,
|
||||||
newSeqCursor: '0',
|
lastSeqCursor,
|
||||||
};
|
botPrefix,
|
||||||
const messages = withSeqs(result.messages || []);
|
limit,
|
||||||
const lastSeq =
|
) || {
|
||||||
messages.length > 0
|
messages: [],
|
||||||
? String(messages[messages.length - 1].seq)
|
newSeqCursor: '0',
|
||||||
: String(lastSeqCursor || '0');
|
};
|
||||||
return {
|
const messages = withSeqs(result.messages || []);
|
||||||
messages,
|
const lastSeq =
|
||||||
newSeqCursor: result.newSeqCursor || result.newTimestamp || lastSeq,
|
messages.length > 0
|
||||||
};
|
? String(messages[messages.length - 1].seq)
|
||||||
},
|
: String(lastSeqCursor || '0');
|
||||||
),
|
return {
|
||||||
getOpenWorkItem: vi.fn(() => undefined),
|
messages,
|
||||||
createProducedWorkItem: vi.fn((input) => ({
|
newSeqCursor: result.newSeqCursor || result.newTimestamp || lastSeq,
|
||||||
id: 1,
|
};
|
||||||
group_folder: input.group_folder,
|
},
|
||||||
chat_jid: input.chat_jid,
|
),
|
||||||
agent_type: input.agent_type || 'claude-code',
|
getOpenWorkItem: vi.fn(() => undefined),
|
||||||
status: 'produced',
|
createProducedWorkItem: vi.fn((input) => ({
|
||||||
start_seq: input.start_seq,
|
id: 1,
|
||||||
end_seq: input.end_seq,
|
group_folder: input.group_folder,
|
||||||
result_payload: input.result_payload,
|
chat_jid: input.chat_jid,
|
||||||
delivery_attempts: 0,
|
agent_type: input.agent_type || 'claude-code',
|
||||||
created_at: new Date().toISOString(),
|
status: 'produced',
|
||||||
updated_at: new Date().toISOString(),
|
start_seq: input.start_seq,
|
||||||
delivered_at: null,
|
end_seq: input.end_seq,
|
||||||
delivery_message_id: null,
|
result_payload: input.result_payload,
|
||||||
last_error: null,
|
delivery_attempts: 0,
|
||||||
})),
|
created_at: new Date().toISOString(),
|
||||||
markWorkItemDelivered: vi.fn(),
|
updated_at: new Date().toISOString(),
|
||||||
markWorkItemDeliveryRetry: vi.fn(),
|
delivered_at: null,
|
||||||
isPairedRoomJid: vi.fn(() => false),
|
delivery_message_id: null,
|
||||||
|
last_error: null,
|
||||||
|
})),
|
||||||
|
markWorkItemDelivered: vi.fn(),
|
||||||
|
markWorkItemDeliveryRetry: vi.fn(),
|
||||||
|
isPairedRoomJid: vi.fn(() => false),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1096,7 +1096,7 @@ export function createMessageRuntime(deps: MessageRuntimeDeps): {
|
|||||||
|
|
||||||
if (idleTimer) clearTimeout(idleTimer);
|
if (idleTimer) clearTimeout(idleTimer);
|
||||||
clearPendingFollowUpDiagnostics();
|
clearPendingFollowUpDiagnostics();
|
||||||
deps.queue.setActivityTouch?.(chatJid, null);
|
deps.queue.setActivityTouch?.(chatJid, null);
|
||||||
|
|
||||||
if (hadError) {
|
if (hadError) {
|
||||||
if (
|
if (
|
||||||
|
|||||||
Reference in New Issue
Block a user