fix: salvage EJClaw runtime hardening
- add dist freshness guard to deploy flow - preserve message source provenance for IPC injection - harden Codex usage fallback and workspace package manager detection - document owner branch return protocol
This commit is contained in:
49
src/index.ts
49
src/index.ts
@@ -61,6 +61,10 @@ import {
|
||||
hasAvailableClaudeToken,
|
||||
initTokenRotation,
|
||||
} from './token-rotation.js';
|
||||
import {
|
||||
isBotMessageSourceKind,
|
||||
resolveInjectedMessageSourceKind,
|
||||
} from './message-source.js';
|
||||
import { parseVisibleVerdict } from './paired-execution-context-shared.js';
|
||||
|
||||
export function isTerminalStatusMessage(text: string): boolean {
|
||||
@@ -412,6 +416,51 @@ async function main(): Promise<void> {
|
||||
queue.noteDirectTerminalDelivery(jid, senderRole, text);
|
||||
}
|
||||
},
|
||||
injectInboundMessage: async (payload) => {
|
||||
const jid = payload.chatJid;
|
||||
const binding = runtimeState.getRoomBindings()[jid];
|
||||
if (!binding) {
|
||||
logger.warn(
|
||||
{ chatJid: jid, sender: payload.sender ?? null },
|
||||
'inject_inbound_message: no room binding, dropping',
|
||||
);
|
||||
return;
|
||||
}
|
||||
const ts = payload.timestamp || new Date().toISOString();
|
||||
const msgId =
|
||||
payload.messageId ||
|
||||
`ipc-inject-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
||||
const treatAsHuman = payload.treatAsHuman === true;
|
||||
const messageSourceKind = resolveInjectedMessageSourceKind({
|
||||
treatAsHuman,
|
||||
sourceKind: payload.sourceKind,
|
||||
});
|
||||
storeChatMetadata(jid, ts, binding.name, 'discord', true);
|
||||
storeMessage({
|
||||
id: msgId,
|
||||
chat_jid: jid,
|
||||
sender: payload.sender || 'ipc-inject',
|
||||
sender_name: payload.senderName || payload.sender || 'IPC Inject',
|
||||
content: payload.text,
|
||||
timestamp: ts,
|
||||
is_from_me: false,
|
||||
is_bot_message: isBotMessageSourceKind(messageSourceKind),
|
||||
message_source_kind: messageSourceKind,
|
||||
});
|
||||
queue.enqueueMessageCheck(jid, resolveGroupIpcPath(binding.folder));
|
||||
logger.info(
|
||||
{
|
||||
chatJid: jid,
|
||||
sender: payload.sender ?? null,
|
||||
senderName: payload.senderName ?? null,
|
||||
treatAsHuman,
|
||||
messageSourceKind,
|
||||
messageId: msgId,
|
||||
groupFolder: binding.folder,
|
||||
},
|
||||
'Injected inbound message via IPC',
|
||||
);
|
||||
},
|
||||
nudgeScheduler: nudgeSchedulerLoop,
|
||||
roomBindings: runtimeState.getRoomBindings,
|
||||
assignRoom: runtimeState.assignRoomForIpc,
|
||||
|
||||
Reference in New Issue
Block a user