feat(v2): builder-agent self-modification WIP + container-config as per-group file
Checkpoints the builder-agent dev-agent/worktree/swap flow (create_dev_agent, request_swap, classifier, deadman, promote) before pivoting to a unified draft-activate approach with OS-level RO enforcement. Lifts container_config out of the agent_groups row into groups/<folder>/container.json so install_packages, add_mcp_server, and rebuild flows can eventually route through the same draft path as source edits. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -23,11 +23,18 @@ export interface CommandInfo {
|
||||
/**
|
||||
* Categorize a message as a command or not.
|
||||
* Only applies to chat/chat-sdk messages.
|
||||
*
|
||||
* The extracted `senderId` is compared against `NANOCLAW_ADMIN_USER_IDS`
|
||||
* which stores ids in the namespaced form `<channel_type>:<raw>` (see
|
||||
* src/db/users.ts). chat-sdk-bridge serializes `author.userId` as a raw
|
||||
* platform id with no prefix, so we prefix it here. If the id already
|
||||
* contains a `:` we assume it's pre-namespaced (non-chat-sdk adapters
|
||||
* that populate `senderId` directly) and leave it alone.
|
||||
*/
|
||||
export function categorizeMessage(msg: MessageInRow): CommandInfo {
|
||||
const content = parseContent(msg.content);
|
||||
const text = (content.text || '').trim();
|
||||
const senderId = content.senderId || content.author?.userId || null;
|
||||
const senderId = extractSenderId(msg, content);
|
||||
|
||||
if (!text.startsWith('/')) {
|
||||
return { category: 'none', command: '', text, senderId };
|
||||
@@ -47,6 +54,17 @@ export function categorizeMessage(msg: MessageInRow): CommandInfo {
|
||||
return { category: 'passthrough', command, text, senderId };
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function extractSenderId(msg: MessageInRow, content: any): string | null {
|
||||
const raw: string | null = content?.senderId || content?.author?.userId || null;
|
||||
if (!raw) return null;
|
||||
// Already namespaced (e.g. "telegram:123") — use as-is.
|
||||
if (raw.includes(':')) return raw;
|
||||
// Raw platform id from chat-sdk serialization — prefix with channel type.
|
||||
if (!msg.channel_type) return raw;
|
||||
return `${msg.channel_type}:${raw}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Routing context extracted from messages_in rows.
|
||||
* Copied to messages_out by default so responses go back to the sender.
|
||||
|
||||
Reference in New Issue
Block a user