feat(atlas): support plugin tools with metadata.sessionId in orchestration hook
The tool-execute-after hook only processed the built-in 'task' tool.
Plugin tools (e.g. custom-agent-bridge delegate) that set
context.metadata({ metadata: { sessionId } }) were ignored by atlas
orchestration (boulder tracking, verification reminders).
- Add extractSessionIdFromMetadata() to read sessionId from tool
metadata, preferred over text-based extraction
- Extend tool-execute-after guard to also process any tool that has
metadata.sessionId set (not just tool === 'task')
- Recognize 'Background delegate launched' as a background launch
- Add tests for metadata-based session ID extraction
This commit is contained in:
@@ -3,6 +3,16 @@ import { log } from "../../shared/logger"
|
||||
import { isSessionInBoulderLineage } from "./boulder-session-lineage"
|
||||
import { HOOK_NAME } from "./hook-name"
|
||||
|
||||
export function extractSessionIdFromMetadata(metadata: unknown): string | undefined {
|
||||
if (metadata && typeof metadata === "object" && "sessionId" in metadata) {
|
||||
const value = (metadata as Record<string, unknown>).sessionId
|
||||
if (typeof value === "string" && value.startsWith("ses_")) {
|
||||
return value
|
||||
}
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
export function extractSessionIdFromOutput(output: string): string | undefined {
|
||||
const taskMetadataBlocks = [...output.matchAll(/<task_metadata>([\s\S]*?)<\/task_metadata>/gi)]
|
||||
const lastTaskMetadataBlock = taskMetadataBlocks.at(-1)?.[1]
|
||||
|
||||
Reference in New Issue
Block a user