omk-agent-core 0.80.8 → 0.90.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reverse-skill.js","sourceRoot":"","sources":["../../src/harness/reverse-skill.ts"],"names":[],"mappings":"AAoFA,MAAM,yBAAyB,GAAG,CAAC,CAAC;AACpC,MAAM,yBAAyB,GAAG,CAAC,CAAC;AACpC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAClC,MAAM,0BAA0B,GAAG,CAAC,CAAC;AACrC,MAAM,4BAA4B,GAAG,CAAC,CAAC;AACvC,MAAM,kCAAkC,GAAG,EAAE,CAAC;AAE9C,MAAM,CAAC,MAAM,oBAAoB,GAAwB;IACxD;QACC,EAAE,EAAE,aAAa;QACjB,KAAK,EAAE,mCAAmC;QAC1C,SAAS,EAAE,6BAA6B;QACxC,cAAc,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,iBAAO,EAAE,WAAK,CAAC;QAChF,cAAc,EAAE;YACf,WAAW;YACX,QAAQ;YACR,QAAQ;YACR,UAAU;YACV,OAAO;YACP,MAAM;YACN,aAAa;YACb,gBAAgB;YAChB,SAAS;YACT,MAAM;YACN,QAAI;YACJ,cAAM;SACN;QACD,YAAY,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,CAAC;QACvF,QAAQ,EAAE,CAAC,aAAa,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,EAAE,KAAK,EAAE,qBAAqB,EAAE,OAAO,CAAC;QAC7G,aAAa,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC;QAClC,aAAa,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,CAAC;QACrE,UAAU,EAAE,CAAC,aAAa,EA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E,8DAA8D;QAC9D,6EAA6E;QAC7E,2DAA2D;KAC3D,CAAC;IAEF,OAAO,0BAA0B,CAAC;QACjC,IAAI;QACJ,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,cAAc;QACd,QAAQ;QACR,aAAa;QACb,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,UAAU,EAAE,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,UAAU,EAAE,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;KAC5E,CAAC,CAAC;AAAA,CACH","sourcesContent":["export type ReverseSkillPlatform = \"windows\" | \"linux\" | \"macos\" | \"kali\" | \"unknown\";\n\nexport type ReverseSkillRisk = \"passive-analysis\" | \"local-tooling\" | \"active-security\" | \"exploit-development\";\n\nexport interface ReverseSkillRoute {\n\tid: string;\n\tlabel: string;\n\tskillPath: string;\n\ttargetPatterns: string[];\n\tintentPatterns: string[];\n\ttoolPatterns: string[];\n\tkeywords: string[];\n\trequiredTools: string[];\n\toptionalTools: string[];\n\tskillHints: string[];\n\tmcpHints: string[];\n\thookHints: string[];\n\tacceptance: string[];\n\tfirstActions: string[];\n\trisk: ReverseSkillRisk;\n}\n\nexport interface ReverseSkillRouteInput {\n\tquery: string;\n\ttargetType?: string;\n\tintent?: string;\n\ttoolchain?: string;\n\tplatform?: ReverseSkillPlatform;\n\tmaxAlternatives?: number;\n}\n\nexport interface ReverseSkillRouteScore {\n\troute: ReverseSkillRoute;\n\tscore: number;\n\tconfidence: number;\n\tmatched: {\n\t\ttarget: string[];\n\t\tintent: string[];\n\t\ttoolchain: string[];\n\t\tkeywords: string[];\n\t};\n\tmissingDimensions: string[];\n}\n\nexport interface ReverseSkillRouteDecision {\n\tquery: string;\n\tplatform: ReverseSkillPlatform;\n\tnormalizedQuery: string;\n\tprimary?: ReverseSkillRouteScore;\n\talternatives: ReverseSkillRouteScore[];\n\tunmatched: boolean;\n\tnextAction: string;\n}\n\nexport interface ReverseSkillSpecInput {\n\tname: string;\n\tdescription?: string;\n\ttriggerSummary: string;\n\trouteIds?: string[];\n\tworkflowSteps?: string[];\n\ttools?: string[];\n\tmcpServers?: string[];\n\thooks?: string[];\n\tacceptance?: string[];\n\treferences?: string[];\n\tsafetyNotes?: string[];\n}\n\nexport interface ReverseSkillSourceFacts {\n\theadings: string[];\n\tskillPaths: string[];\n\tscriptPaths: string[];\n\ttools: string[];\n\tmcpServers: string[];\n\ttriggerTerms: string[];\n}\n\nexport interface ReverseSkillSourceInput {\n\tname?: string;\n\tdescription?: string;\n\tsourceText: string;\n\ttriggerSummary?: string;\n}\n\nconst ROUTE_SCORE_TARGET_WEIGHT = 4;\nconst ROUTE_SCORE_INTENT_WEIGHT = 3;\nconst ROUTE_SCORE_TOOL_WEIGHT = 2;\nconst ROUTE_SCORE_KEYWORD_WEIGHT = 1;\nconst ROUTE_SCORE_FULL_TRIAD_BONUS = 4;\nconst ROUTE_SCORE_CONFIDENCE_DENOMINATOR = 14;\n\nexport const REVERSE_SKILL_ROUTES: ReverseSkillRoute[] = [\n\t{\n\t\tid: \"apk-reverse\",\n\t\tlabel: \"APK / Android reverse engineering\",\n\t\tskillPath: \"skills/apk-reverse/SKILL.md\",\n\t\ttargetPatterns: [\"apk\", \"android\", \"aab\", \"smali\", \"jni\", \"dex\", \"안드로이드\", \"反编译\"],\n\t\tintentPatterns: [\n\t\t\t\"decompile\",\n\t\t\t\"unpack\",\n\t\t\t\"repack\",\n\t\t\t\"manifest\",\n\t\t\t\"frida\",\n\t\t\t\"hook\",\n\t\t\t\"ssl pinning\",\n\t\t\t\"root detection\",\n\t\t\t\"rebuild\",\n\t\t\t\"sign\",\n\t\t\t\"설치\",\n\t\t\t\"리패키징\",\n\t\t],\n\t\ttoolPatterns: [\"jadx\", \"apktool\", \"adb\", \"frida\", \"apksigner\", \"zipalign\", \"objection\"],\n\t\tkeywords: [\"classes.dex\", \"androidmanifest\", \"native library\", \"lib/\", \".so\", \"certificate pinning\", \"smali\"],\n\t\trequiredTools: [\"jadx\", \"apktool\"],\n\t\toptionalTools: [\"adb\", \"frida\", \"apksigner\", \"zipalign\", \"objection\"],\n\t\tskillHints: [\"apk-reverse\", \"reverse-engineering\", \"docs-generator\"],\n\t\tmcpHints: [\"filesystem\", \"playwright for app docs only\", \"idapro if native .so becomes dominant\"],\n\t\thookHints: [\"pre-shell-guard\", \"protect-secrets\", \"subagent-stop-audit\"],\n\t\tacceptance: [\n\t\t\t\"Target package structure is identified\",\n\t\t\t\"Static findings cite class/method/file paths\",\n\t\t\t\"Any dynamic step is scoped to a local test device or emulator\",\n\t\t],\n\t\tfirstActions: [\n\t\t\t\"Confirm target artifact path\",\n\t\t\t\"Decode APK metadata\",\n\t\t\t\"Route native .so files to binary analysis when needed\",\n\t\t],\n\t\trisk: \"local-tooling\",\n\t},\n\t{\n\t\tid: \"ida-reverse\",\n\t\tlabel: \"Binary reverse engineering with decompiler-first workflow\",\n\t\tskillPath: \"skills/ida-reverse/SKILL.md\",\n\t\ttargetPatterns: [\n\t\t\t\"exe\",\n\t\t\t\"dll\",\n\t\t\t\"elf\",\n\t\t\t\"so\",\n\t\t\t\"dylib\",\n\t\t\t\"macho\",\n\t\t\t\"pe\",\n\t\t\t\"binary\",\n\t\t\t\"firmware blob\",\n\t\t\t\"바이너리\",\n\t\t\t\"二进制\",\n\t\t],\n\t\tintentPatterns: [\n\t\t\t\"decompile\",\n\t\t\t\"disassemble\",\n\t\t\t\"xref\",\n\t\t\t\"call graph\",\n\t\t\t\"data flow\",\n\t\t\t\"rename\",\n\t\t\t\"symbol\",\n\t\t\t\"recover\",\n\t\t\t\"pseudocode\",\n\t\t\t\"함수\",\n\t\t\t\"反汇编\",\n\t\t],\n\t\ttoolPatterns: [\"ida\", \"idapro\", \"idalib\", \"ida-pro-mcp\", \"ghidra\", \"r2\", \"radare2\"],\n\t\tkeywords: [\"imports\", \"exports\", \"strings\", \"function\", \"offset\", \"xref\", \"pdb\", \"symbols\"],\n\t\trequiredTools: [\"idapro\"],\n\t\toptionalTools: [\"idalib-mcp\", \"ghidra\", \"radare2\", \"rabin2\"],\n\t\tskillHints: [\"ida-reverse\", \"radare2\", \"reverse-engineering\", \"binary-diff\"],\n\t\tmcpHints: [\"idapro\", \"filesystem\", \"serena\"],\n\t\thookHints: [\"pre-shell-guard\", \"protect-secrets\", \"stop-verify\"],\n\t\tacceptance: [\n\t\t\t\"Functions are cited by address/name\",\n\t\t\t\"Hypotheses cite disassembly, decompiler, xref, or string evidence\",\n\t\t\t\"Output distinguishes evidence from inference\",\n\t\t],\n\t\tfirstActions: [\n\t\t\t\"Collect file metadata\",\n\t\t\t\"Run strings/imports reconnaissance\",\n\t\t\t\"Choose IDA or CLI path based on available tools\",\n\t\t],\n\t\trisk: \"passive-analysis\",\n\t},\n\t{\n\t\tid: \"radare2\",\n\t\tlabel: \"Binary reconnaissance with radare2 CLI\",\n\t\tskillPath: \"skills/radare2/SKILL.md\",\n\t\ttargetPatterns: [\"binary\", \"elf\", \"pe\", \"macho\", \"so\", \"dll\", \"firmware\", \"바이너리\"],\n\t\tintentPatterns: [\"quick recon\", \"strings\", \"imports\", \"exports\", \"patch\", \"offset\", \"cli\", \"headless\"],\n\t\ttoolPatterns: [\"radare2\", \"r2\", \"rabin2\", \"rasm2\", \"radiff2\"],\n\t\tkeywords: [\"entrypoint\", \"section\", \"symbol\", \"hex\", \"disassembly\", \"patch bytes\"],\n\t\trequiredTools: [\"radare2\", \"rabin2\"],\n\t\toptionalTools: [\"rasm2\", \"radiff2\", \"r2pipe\"],\n\t\tskillHints: [\"radare2\", \"ida-reverse\", \"reverse-engineering\"],\n\t\tmcpHints: [\"filesystem\"],\n\t\thookHints: [\"pre-shell-guard\", \"protect-secrets\"],\n\t\tacceptance: [\n\t\t\t\"Recon output names sections, imports, symbols, and notable strings\",\n\t\t\t\"Patch guidance includes offset and before/after bytes\",\n\t\t],\n\t\tfirstActions: [\n\t\t\t\"Run file metadata\",\n\t\t\t\"Run rabin2-style reconnaissance\",\n\t\t\t\"Escalate to decompiler if CLI evidence is insufficient\",\n\t\t],\n\t\trisk: \"passive-analysis\",\n\t},\n\t{\n\t\tid: \"js-reverse\",\n\t\tlabel: \"Frontend JavaScript signature and request reconstruction\",\n\t\tskillPath: \"skills/js-reverse/SKILL.md\",\n\t\ttargetPatterns: [\n\t\t\t\"javascript\",\n\t\t\t\"js\",\n\t\t\t\"frontend\",\n\t\t\t\"webpack\",\n\t\t\t\"source map\",\n\t\t\t\"sourcemap\",\n\t\t\t\"web\",\n\t\t\t\"browser\",\n\t\t\t\"前端\",\n\t\t\t\"프론트\",\n\t\t],\n\t\tintentPatterns: [\n\t\t\t\"signature\",\n\t\t\t\"encrypted params\",\n\t\t\t\"request replay\",\n\t\t\t\"token\",\n\t\t\t\"decrypt\",\n\t\t\t\"environment patch\",\n\t\t\t\"ast\",\n\t\t\t\"breakpoint\",\n\t\t\t\"hook\",\n\t\t\t\"서명\",\n\t\t\t\"암호화\",\n\t\t],\n\t\ttoolPatterns: [\"playwright\", \"chrome\", \"cdp\", \"jshook\", \"jshookmcp\", \"node\", \"anything-analyzer\"],\n\t\tkeywords: [\n\t\t\t\"sign\",\n\t\t\t\"nonce\",\n\t\t\t\"timestamp\",\n\t\t\t\"crypto\",\n\t\t\t\"axios\",\n\t\t\t\"fetch\",\n\t\t\t\"xhr\",\n\t\t\t\"webpackJsonp\",\n\t\t\t\"localStorage\",\n\t\t\t\"cookie\",\n\t\t],\n\t\trequiredTools: [\"node\"],\n\t\toptionalTools: [\"playwright\", \"jshookmcp\", \"anything-analyzer\", \"chrome\"],\n\t\tskillHints: [\"js-reverse\", \"browser-automation\", \"docs-generator\"],\n\t\tmcpHints: [\"chrome-devtools\", \"playwright\", \"fetch\", \"filesystem\"],\n\t\thookHints: [\"pre-shell-guard\", \"protect-secrets\", \"session-context\"],\n\t\tacceptance: [\n\t\t\t\"Target request and parameter names are identified\",\n\t\t\t\"Recovered algorithm has a local reproduction or explicit blocker\",\n\t\t\t\"Browser/runtime observations are tied to request evidence\",\n\t\t],\n\t\tfirstActions: [\"Identify target request\", \"Find producer function\", \"Rebuild the minimum local reproduction\"],\n\t\trisk: \"local-tooling\",\n\t},\n\t{\n\t\tid: \"browser-automation\",\n\t\tlabel: \"Browser or desktop evidence collection\",\n\t\tskillPath: \"skills/browser-automation/SKILL.md\",\n\t\ttargetPatterns: [\"website\", \"browser\", \"web app\", \"desktop app\", \"page\", \"form\", \"웹\", \"브라우저\"],\n\t\tintentPatterns: [\n\t\t\t\"open\",\n\t\t\t\"screenshot\",\n\t\t\t\"fill\",\n\t\t\t\"crawl\",\n\t\t\t\"capture\",\n\t\t\t\"network\",\n\t\t\t\"login\",\n\t\t\t\"observe\",\n\t\t\t\"click\",\n\t\t\t\"샷\",\n\t\t\t\"스크린샷\",\n\t\t],\n\t\ttoolPatterns: [\"playwright\", \"chrome-devtools\", \"agent-browser\", \"openreverse\", \"anything-analyzer\"],\n\t\tkeywords: [\"dom\", \"selector\", \"network log\", \"console\", \"cookie\", \"screenshot\", \"trace\"],\n\t\trequiredTools: [\"playwright\"],\n\t\toptionalTools: [\"chrome\", \"agent-browser\", \"anything-analyzer\"],\n\t\tskillHints: [\"browser-automation\", \"js-reverse\", \"docs-generator\"],\n\t\tmcpHints: [\"playwright\", \"chrome-devtools\", \"filesystem\"],\n\t\thookHints: [\"pre-shell-guard\", \"protect-secrets\"],\n\t\tacceptance: [\n\t\t\t\"Browser state is captured with URL and selector evidence\",\n\t\t\t\"Screenshots or logs are saved as artifacts when visual proof matters\",\n\t\t],\n\t\tfirstActions: [\n\t\t\t\"Open the target in an isolated browser context\",\n\t\t\t\"Capture visible state\",\n\t\t\t\"Record console/network evidence\",\n\t\t],\n\t\trisk: \"local-tooling\",\n\t},\n\t{\n\t\tid: \"ctf-sandbox-orchestrator\",\n\t\tlabel: \"CTF challenge routing\",\n\t\tskillPath: \"../CTF-Sandbox-Orchestrator/ctf-sandbox-orchestrator/SKILL.md\",\n\t\ttargetPatterns: [\"ctf\", \"challenge\", \"flag\", \"pwn\", \"crypto challenge\", \"forensics\", \"misc\", \"rev\", \"대회\"],\n\t\tintentPatterns: [\"solve\", \"find flag\", \"exploit\", \"writeup\", \"sandbox\", \"analyze challenge\"],\n\t\ttoolPatterns: [\"pwntools\", \"gdb\", \"python\", \"sage\", \"z3\", \"binwalk\", \"wireshark\"],\n\t\tkeywords: [\"flag{\", \"ctf\", \"nc \", \"remote\", \"proof\", \"challenge files\"],\n\t\trequiredTools: [],\n\t\toptionalTools: [\"python\", \"gdb\", \"pwntools\", \"z3\", \"binwalk\"],\n\t\tskillHints: [\"ctf-sandbox-orchestrator\", \"reverse-engineering\", \"pwn-chain\", \"docs-generator\"],\n\t\tmcpHints: [\"filesystem\", \"memory\"],\n\t\thookHints: [\"pre-shell-guard\", \"protect-secrets\", \"stop-verify\"],\n\t\tacceptance: [\n\t\t\t\"Challenge category is justified by evidence\",\n\t\t\t\"Solution artifacts are reproducible\",\n\t\t\t\"Writeup includes the shortest verified path\",\n\t\t],\n\t\tfirstActions: [\n\t\t\t\"Inventory challenge files\",\n\t\t\t\"Classify dominant evidence\",\n\t\t\t\"Dispatch to the narrowest CTF sub-skill\",\n\t\t],\n\t\trisk: \"exploit-development\",\n\t},\n\t{\n\t\tid: \"api-security\",\n\t\tlabel: \"API security review and authorized test planning\",\n\t\tskillPath: \"skills/api-security/SKILL.md\",\n\t\ttargetPatterns: [\"api\", \"rest\", \"graphql\", \"websocket\", \"jwt\", \"oauth\", \"endpoint\"],\n\t\tintentPatterns: [\"review\", \"test\", \"auth\", \"idor\", \"bola\", \"bfla\", \"rate limit\", \"schema\", \"권한\", \"越权\"],\n\t\ttoolPatterns: [\"burp\", \"postman\", \"nuclei\", \"zap\", \"curl\", \"graphql\"],\n\t\tkeywords: [\"authorization\", \"authentication\", \"tenant\", \"object id\", \"jwt\", \"scope\", \"graphql\"],\n\t\trequiredTools: [],\n\t\toptionalTools: [\"burpsuite\", \"nuclei\", \"zap\", \"node\", \"python\"],\n\t\tskillHints: [\"api-security\", \"pentest-tools\", \"docs-generator\"],\n\t\tmcpHints: [\"filesystem\", \"github\", \"playwright\"],\n\t\thookHints: [\"pre-shell-guard\", \"protect-secrets\", \"stop-verify\"],\n\t\tacceptance: [\n\t\t\t\"Scope boundary is explicit\",\n\t\t\t\"Findings include request/response evidence or code references\",\n\t\t\t\"High-risk active steps require explicit target scope\",\n\t\t],\n\t\tfirstActions: [\n\t\t\t\"Identify API surface\",\n\t\t\t\"Map auth and tenant boundaries\",\n\t\t\t\"Choose static review or scoped dynamic testing\",\n\t\t],\n\t\trisk: \"active-security\",\n\t},\n\t{\n\t\tid: \"supply-chain-security\",\n\t\tlabel: \"Supply-chain and CI/CD security analysis\",\n\t\tskillPath: \"skills/supply-chain-security/SKILL.md\",\n\t\ttargetPatterns: [\n\t\t\t\"dependency\",\n\t\t\t\"package\",\n\t\t\t\"sbom\",\n\t\t\t\"container\",\n\t\t\t\"docker\",\n\t\t\t\"ci\",\n\t\t\t\"workflow\",\n\t\t\t\"github actions\",\n\t\t\t\"supply chain\",\n\t\t],\n\t\tintentPatterns: [\"scan\", \"audit\", \"gitleaks\", \"trivy\", \"osv\", \"syft\", \"secret\", \"provenance\", \"attestation\"],\n\t\ttoolPatterns: [\"trivy\", \"syft\", \"gitleaks\", \"osv-scanner\", \"npm audit\", \"semgrep\"],\n\t\tkeywords: [\"package-lock\", \"npm-shrinkwrap\", \"dockerfile\", \"workflow\", \"actions\", \"secret\", \"sbom\"],\n\t\trequiredTools: [],\n\t\toptionalTools: [\"trivy\", \"syft\", \"gitleaks\", \"osv-scanner\", \"semgrep\"],\n\t\tskillHints: [\"supply-chain-security\", \"security-review\", \"docs-generator\"],\n\t\tmcpHints: [\"filesystem\", \"github\"],\n\t\thookHints: [\"protect-secrets\", \"pre-shell-guard\", \"npm-audit-summary\"],\n\t\tacceptance: [\n\t\t\t\"Dependency, workflow, and secret surfaces are separated\",\n\t\t\t\"Findings cite exact files and lockfile evidence\",\n\t\t],\n\t\tfirstActions: [\n\t\t\t\"Inventory package managers and workflows\",\n\t\t\t\"Run non-mutating scans first\",\n\t\t\t\"Triangulate tool output with source evidence\",\n\t\t],\n\t\trisk: \"passive-analysis\",\n\t},\n\t{\n\t\tid: \"docs-generator\",\n\t\tlabel: \"Security or reverse-engineering report generation\",\n\t\tskillPath: \"skills/docs-generator/SKILL.md\",\n\t\ttargetPatterns: [\"report\", \"writeup\", \"documentation\", \"diagram\", \"flowchart\", \"보고서\", \"문서\"],\n\t\tintentPatterns: [\"write\", \"summarize\", \"generate\", \"document\", \"explain\", \"diagram\", \"publish\"],\n\t\ttoolPatterns: [\"markdown\", \"mermaid\", \"graphviz\", \"plantuml\", \"pdf\"],\n\t\tkeywords: [\"executive summary\", \"reproduction\", \"impact\", \"timeline\", \"artifact\", \"evidence\"],\n\t\trequiredTools: [],\n\t\toptionalTools: [\"graphviz\", \"plantuml\", \"pandoc\"],\n\t\tskillHints: [\"docs-generator\", \"diagram-generator\"],\n\t\tmcpHints: [\"filesystem\"],\n\t\thookHints: [\"protect-secrets\"],\n\t\tacceptance: [\n\t\t\t\"Report separates facts, analysis, and recommendations\",\n\t\t\t\"Artifacts and commands are reproducible\",\n\t\t\t\"Sensitive values are redacted\",\n\t\t],\n\t\tfirstActions: [\n\t\t\t\"Collect evidence paths\",\n\t\t\t\"Choose report template\",\n\t\t\t\"Add at least one flow or evidence diagram when useful\",\n\t\t],\n\t\trisk: \"passive-analysis\",\n\t},\n];\n\nconst TOOL_ALIASES: Record<string, string[]> = {\n\t\"anything-analyzer\": [\"anything-analyzer\"],\n\tadb: [\"adb\"],\n\tapktool: [\"apktool\"],\n\tapksigner: [\"apksigner\"],\n\tbinwalk: [\"binwalk\"],\n\tburpsuite: [\"burpsuite\"],\n\tchrome: [\"google-chrome\", \"chromium\", \"chrome\"],\n\tfrida: [\"frida\", \"frida-ps\"],\n\tgdb: [\"gdb\"],\n\tghidra: [\"ghidraRun\", \"analyzeHeadless\"],\n\tgitleaks: [\"gitleaks\"],\n\tgraphviz: [\"dot\"],\n\tidapro: [\"ida\", \"idat\", \"idat64\"],\n\t\"idalib-mcp\": [\"ida-pro-mcp\", \"idalib-mcp\"],\n\tjadx: [\"jadx\"],\n\tjshookmcp: [\"jshook\", \"npx\"],\n\tnode: [\"node\"],\n\tnuclei: [\"nuclei\"],\n\tpandoc: [\"pandoc\"],\n\tplantuml: [\"plantuml\"],\n\tplaywright: [\"playwright\", \"npx\"],\n\tpwntools: [\"python\"],\n\tpython: [\"python3\", \"python\"],\n\tradare2: [\"radare2\", \"r2\"],\n\trabin2: [\"rabin2\"],\n\tradiff2: [\"radiff2\"],\n\trasm2: [\"rasm2\"],\n\tsemgrep: [\"semgrep\"],\n\tsyft: [\"syft\"],\n\ttrivy: [\"trivy\"],\n\tzap: [\"zap.sh\", \"zap-baseline.py\"],\n\tzipalign: [\"zipalign\"],\n\tz3: [\"z3\"],\n};\n\nexport function getReverseSkillToolAliases(tool: string): string[] {\n\treturn TOOL_ALIASES[tool] ?? [tool];\n}\n\nexport function normalizeReverseSkillText(text: string | undefined): string {\n\treturn (text ?? \"\")\n\t\t.normalize(\"NFKC\")\n\t\t.toLowerCase()\n\t\t.replace(/[\\u2018\\u2019]/g, \"'\")\n\t\t.replace(/[\\u201c\\u201d]/g, '\"')\n\t\t.replace(/[_./\\\\:-]+/g, \" \")\n\t\t.replace(/\\s+/g, \" \")\n\t\t.trim();\n}\n\nfunction findPatternMatches(text: string, patterns: string[]): string[] {\n\tconst matches: string[] = [];\n\tfor (const pattern of patterns) {\n\t\tconst normalizedPattern = normalizeReverseSkillText(pattern);\n\t\tif (!normalizedPattern) continue;\n\t\tif (text.includes(normalizedPattern)) matches.push(pattern);\n\t}\n\treturn matches;\n}\n\nfunction unique(items: string[]): string[] {\n\treturn Array.from(new Set(items.filter((item) => item.trim().length > 0)));\n}\n\nfunction clampConfidence(score: number): number {\n\tif (score <= 0) return 0;\n\treturn Math.min(0.99, Number((score / ROUTE_SCORE_CONFIDENCE_DENOMINATOR).toFixed(2)));\n}\n\nfunction scoreRoute(\n\troute: ReverseSkillRoute,\n\tinput: ReverseSkillRouteInput,\n\tnormalizedQuery: string,\n): ReverseSkillRouteScore {\n\tconst targetText = normalizeReverseSkillText(`${input.targetType ?? \"\"} ${normalizedQuery}`);\n\tconst intentText = normalizeReverseSkillText(`${input.intent ?? \"\"} ${normalizedQuery}`);\n\tconst toolText = normalizeReverseSkillText(`${input.toolchain ?? \"\"} ${normalizedQuery}`);\n\n\tconst target = findPatternMatches(targetText, route.targetPatterns);\n\tconst intent = findPatternMatches(intentText, route.intentPatterns);\n\tconst toolchain = findPatternMatches(toolText, route.toolPatterns);\n\tconst keywords = findPatternMatches(normalizedQuery, route.keywords);\n\n\tlet score =\n\t\ttarget.length * ROUTE_SCORE_TARGET_WEIGHT +\n\t\tintent.length * ROUTE_SCORE_INTENT_WEIGHT +\n\t\ttoolchain.length * ROUTE_SCORE_TOOL_WEIGHT +\n\t\tkeywords.length * ROUTE_SCORE_KEYWORD_WEIGHT;\n\n\tif (target.length > 0 && intent.length > 0 && toolchain.length > 0) {\n\t\tscore += ROUTE_SCORE_FULL_TRIAD_BONUS;\n\t}\n\n\tconst missingDimensions: string[] = [];\n\tif (target.length === 0) missingDimensions.push(\"target\");\n\tif (intent.length === 0) missingDimensions.push(\"intent\");\n\tif (toolchain.length === 0) missingDimensions.push(\"toolchain\");\n\n\treturn {\n\t\troute,\n\t\tscore,\n\t\tconfidence: clampConfidence(score),\n\t\tmatched: { target, intent, toolchain, keywords },\n\t\tmissingDimensions,\n\t};\n}\n\nexport function routeReverseSkill(input: ReverseSkillRouteInput): ReverseSkillRouteDecision {\n\tconst normalizedQuery = normalizeReverseSkillText(input.query);\n\tconst platform = input.platform ?? \"unknown\";\n\tconst maxAlternatives = input.maxAlternatives ?? 3;\n\tconst scored = REVERSE_SKILL_ROUTES.map((route) => scoreRoute(route, input, normalizedQuery))\n\t\t.filter((candidate) => candidate.score > 0)\n\t\t.sort(\n\t\t\t(a, b) => b.score - a.score || REVERSE_SKILL_ROUTES.indexOf(a.route) - REVERSE_SKILL_ROUTES.indexOf(b.route),\n\t\t);\n\n\tconst primary = scored[0];\n\tconst alternatives = scored.slice(1, maxAlternatives + 1);\n\tconst unmatched = !primary || primary.score < ROUTE_SCORE_TARGET_WEIGHT || primary.confidence < 0.18;\n\tconst nextAction = unmatched\n\t\t? \"No strong route matched. Create or extend a reverse-skill route before executing specialized tooling.\"\n\t\t: `Read ${primary.route.skillPath}, then execute first action: ${primary.route.firstActions[0] ?? \"classify target\"}.`;\n\n\treturn {\n\t\tquery: input.query,\n\t\tplatform,\n\t\tnormalizedQuery,\n\t\tprimary: unmatched ? undefined : primary,\n\t\talternatives,\n\t\tunmatched,\n\t\tnextAction,\n\t};\n}\n\nfunction formatMatches(score: ReverseSkillRouteScore): string {\n\tconst parts = [\n\t\t`target=${score.matched.target.join(\", \") || \"—\"}`,\n\t\t`intent=${score.matched.intent.join(\", \") || \"—\"}`,\n\t\t`toolchain=${score.matched.toolchain.join(\", \") || \"—\"}`,\n\t\t`keywords=${score.matched.keywords.join(\", \") || \"—\"}`,\n\t];\n\treturn parts.join(\"; \");\n}\n\nexport function formatReverseSkillRouteDecision(decision: ReverseSkillRouteDecision): string {\n\tif (decision.unmatched || !decision.primary) {\n\t\treturn [\n\t\t\t\"# Reverse Skill Route\",\n\t\t\t\"\",\n\t\t\t`Query: ${decision.query}`,\n\t\t\t\"\",\n\t\t\t\"No strong route matched.\",\n\t\t\t\"Next action: create or extend a route before specialized execution.\",\n\t\t].join(\"\\n\");\n\t}\n\n\tconst primary = decision.primary;\n\tconst lines = [\n\t\t\"# Reverse Skill Route\",\n\t\t\"\",\n\t\t`Query: ${decision.query}`,\n\t\t`Platform: ${decision.platform}`,\n\t\t\"\",\n\t\t`## Primary: ${primary.route.label}`,\n\t\t`- Route ID: ${primary.route.id}`,\n\t\t`- Skill path: ${primary.route.skillPath}`,\n\t\t`- Confidence: ${primary.confidence}`,\n\t\t`- Score: ${primary.score}`,\n\t\t`- Matches: ${formatMatches(primary)}`,\n\t\t`- Risk: ${primary.route.risk}`,\n\t\t`- Required tools: ${primary.route.requiredTools.join(\", \") || \"none\"}`,\n\t\t`- Optional tools: ${primary.route.optionalTools.join(\", \") || \"none\"}`,\n\t\t`- Skill hints: ${primary.route.skillHints.join(\", \")}`,\n\t\t`- MCP hints: ${primary.route.mcpHints.join(\", \")}`,\n\t\t`- Hooks: ${primary.route.hookHints.join(\", \")}`,\n\t\t\"\",\n\t\t\"## First actions\",\n\t\t...primary.route.firstActions.map((action, index) => `${index + 1}. ${action}`),\n\t\t\"\",\n\t\t\"## Acceptance\",\n\t\t...primary.route.acceptance.map((item) => `- ${item}`),\n\t];\n\n\tif (decision.alternatives.length > 0) {\n\t\tlines.push(\"\", \"## Alternatives\");\n\t\tfor (const alternative of decision.alternatives) {\n\t\t\tlines.push(`- ${alternative.route.id} (${alternative.confidence}): ${formatMatches(alternative)}`);\n\t\t}\n\t}\n\n\tlines.push(\"\", `Next action: ${decision.nextAction}`);\n\treturn lines.join(\"\\n\");\n}\n\nexport function planReverseSkillToolChecks(decision: ReverseSkillRouteDecision, maxTools = 12): string[] {\n\tconst routes = [decision.primary, ...decision.alternatives].filter((score): score is ReverseSkillRouteScore =>\n\t\tBoolean(score),\n\t);\n\tconst tools: string[] = [];\n\tfor (const score of routes) {\n\t\ttools.push(...score.route.requiredTools, ...score.route.optionalTools);\n\t}\n\treturn unique(tools).slice(0, maxTools);\n}\n\nexport function normalizeReverseSkillName(name: string): string {\n\tconst normalized = normalizeReverseSkillText(name)\n\t\t.replace(/[^a-z0-9-]+/g, \"-\")\n\t\t.replace(/-+/g, \"-\")\n\t\t.replace(/^-|-$/g, \"\")\n\t\t.slice(0, 64)\n\t\t.replace(/-$/g, \"\");\n\treturn normalized || \"reverse-skill\";\n}\n\nfunction yamlString(value: string): string {\n\treturn JSON.stringify(value);\n}\n\nfunction compactDescription(input: ReverseSkillSpecInput, routes: ReverseSkillRoute[]): string {\n\tconst fallback = `Use when ${input.triggerSummary}`;\n\tconst base = input.description?.trim() || fallback;\n\tconst routeNames = routes.map((route) => route.id).join(\", \");\n\tconst suffix = routeNames ? ` Routes through ${routeNames}.` : \"\";\n\tconst description = `${base}${suffix}`;\n\treturn description.length <= 1024 ? description : `${description.slice(0, 1021).trimEnd()}...`;\n}\n\nfunction routesFromIds(routeIds: string[] | undefined): ReverseSkillRoute[] {\n\tif (!routeIds) return [];\n\treturn routeIds\n\t\t.map((routeId) => REVERSE_SKILL_ROUTES.find((route) => route.id === routeId))\n\t\t.filter((route): route is ReverseSkillRoute => Boolean(route));\n}\n\nexport function formatReverseSkillMarkdown(input: ReverseSkillSpecInput): string {\n\tconst routes = routesFromIds(input.routeIds);\n\tconst name = normalizeReverseSkillName(input.name);\n\tconst description = compactDescription(input, routes);\n\tconst workflowSteps = input.workflowSteps?.length\n\t\t? input.workflowSteps\n\t\t: [\n\t\t\t\t\"Classify target, intent, and available toolchain before execution\",\n\t\t\t\t\"Read the routed sub-skill or reference\",\n\t\t\t\t\"Collect evidence and record blockers\",\n\t\t\t\t\"Verify output against acceptance criteria\",\n\t\t\t];\n\tconst tools = unique([\n\t\t...(input.tools ?? []),\n\t\t...routes.flatMap((route) => [...route.requiredTools, ...route.optionalTools]),\n\t]);\n\tconst mcpServers = unique([...(input.mcpServers ?? []), ...routes.flatMap((route) => route.mcpHints)]);\n\tconst hooks = unique([...(input.hooks ?? []), ...routes.flatMap((route) => route.hookHints)]);\n\tconst acceptance = unique([...(input.acceptance ?? []), ...routes.flatMap((route) => route.acceptance)]);\n\tconst safetyNotes = input.safetyNotes?.length\n\t\t? input.safetyNotes\n\t\t: [\n\t\t\t\t\"Operate only on user-provided local artifacts or explicitly scoped targets\",\n\t\t\t\t\"Do not write secrets, tokens, credentials, or raw private data into skill artifacts\",\n\t\t\t];\n\n\tconst lines = [\n\t\t\"---\",\n\t\t`name: ${name}`,\n\t\t`description: ${yamlString(description)}`,\n\t\t\"---\",\n\t\t\"\",\n\t\t`# ${name}`,\n\t\t\"\",\n\t\t\"## Routing contract\",\n\t\t\"\",\n\t\t`Trigger this skill when ${input.triggerSummary}.`,\n\t\t\"\",\n\t\t\"1. Classify the target type, user intent, and toolchain signals before choosing tools.\",\n\t\t\"2. Read the narrowest referenced sub-skill or reference before running specialized tooling.\",\n\t\t\"3. Prefer passive/local evidence collection first; escalate only when the task scope requires it.\",\n\t\t\"4. Save evidence paths and blockers in the final response.\",\n\t\t\"\",\n\t\t\"## Workflow\",\n\t\t\"\",\n\t\t...workflowSteps.map((step, index) => `${index + 1}. ${step}`),\n\t\t\"\",\n\t\t\"## Tool selection\",\n\t\t\"\",\n\t\t`- Tools: ${tools.join(\", \") || \"none required\"}`,\n\t\t`- MCP: ${mcpServers.join(\", \") || \"filesystem/read-only\"}`,\n\t\t`- Hooks: ${hooks.join(\", \") || \"pre-shell-guard, protect-secrets\"}`,\n\t\t\"\",\n\t\t\"## Acceptance\",\n\t\t\"\",\n\t\t...(acceptance.length > 0\n\t\t\t? acceptance.map((item) => `- ${item}`)\n\t\t\t: [\"- Output includes routed skill, evidence, commands, and remaining blockers\"]),\n\t\t\"\",\n\t\t\"## Safety constraints\",\n\t\t\"\",\n\t\t...safetyNotes.map((note) => `- ${note}`),\n\t];\n\n\tif (routes.length > 0) {\n\t\tlines.push(\"\", \"## Built-in routes\", \"\");\n\t\tfor (const route of routes) {\n\t\t\tlines.push(`- ${route.id}: ${route.skillPath}`);\n\t\t}\n\t}\n\n\tif (input.references?.length) {\n\t\tlines.push(\"\", \"## References\", \"\");\n\t\tfor (const reference of input.references) lines.push(`- ${reference}`);\n\t}\n\n\treturn `${lines.join(\"\\n\").trimEnd()}\\n`;\n}\n\nexport function extractReverseSkillFactsFromMarkdown(sourceText: string): ReverseSkillSourceFacts {\n\tconst headings = unique(\n\t\tArray.from(sourceText.matchAll(/^#{1,4}\\s+(.+)$/gm)).map((match) => match[1]?.trim() ?? \"\"),\n\t).slice(0, 24);\n\tconst skillPaths = unique(\n\t\tArray.from(sourceText.matchAll(/[`(\\s]([^`\\s)]+SKILL\\.md)/g)).map((match) => match[1] ?? \"\"),\n\t);\n\tconst scriptPaths = unique(\n\t\tArray.from(sourceText.matchAll(/[`(\\s]([^`\\s)]+\\.(?:ps1|sh|py|js|ts))/g)).map((match) => match[1] ?? \"\"),\n\t);\n\tconst knownTools = Object.keys(TOOL_ALIASES);\n\tconst normalizedSource = normalizeReverseSkillText(sourceText);\n\tconst tools = knownTools.filter((tool) => normalizedSource.includes(normalizeReverseSkillText(tool)));\n\tconst mcpServers = unique(\n\t\tArray.from(sourceText.matchAll(/\\b([a-z0-9-]+)\\s+MCP\\b/gi)).map((match) => match[1]?.toLowerCase() ?? \"\"),\n\t);\n\tconst triggerTerms = unique(\n\t\tREVERSE_SKILL_ROUTES.flatMap((route) => [\n\t\t\t...route.targetPatterns,\n\t\t\t...route.intentPatterns,\n\t\t\t...route.toolPatterns,\n\t\t]).filter((term) => normalizedSource.includes(normalizeReverseSkillText(term))),\n\t).slice(0, 40);\n\n\treturn { headings, skillPaths, scriptPaths, tools, mcpServers, triggerTerms };\n}\n\nexport function formatReverseSkillFromSource(input: ReverseSkillSourceInput): string {\n\tconst facts = extractReverseSkillFactsFromMarkdown(input.sourceText);\n\tconst query = [input.triggerSummary, facts.triggerTerms.slice(0, 12).join(\" \"), facts.headings.slice(0, 8).join(\" \")]\n\t\t.filter(Boolean)\n\t\t.join(\" \");\n\tconst decision = routeReverseSkill({ query: query || input.sourceText.slice(0, 500) });\n\tconst routeIds = [decision.primary?.route.id, ...decision.alternatives.map((item) => item.route.id)].filter(\n\t\t(routeId): routeId is string => Boolean(routeId),\n\t);\n\tconst name = input.name ?? (decision.primary ? `${decision.primary.route.id}-workflow` : \"reverse-skill-workflow\");\n\tconst triggerSummary =\n\t\tinput.triggerSummary ??\n\t\t(facts.triggerTerms.slice(0, 8).join(\", \") || \"reverse-engineering or security routing is needed\");\n\tconst workflowSteps = [\n\t\t\"Classify the incoming request against target, intent, and toolchain signals\",\n\t\t\"Load the routed sub-skill before running specialized tooling\",\n\t\t\"Check local tool availability only for tools required by the selected route\",\n\t\t\"Return evidence paths, commands, confidence, and blockers\",\n\t];\n\n\treturn formatReverseSkillMarkdown({\n\t\tname,\n\t\tdescription: input.description,\n\t\ttriggerSummary,\n\t\trouteIds,\n\t\tworkflowSteps,\n\t\ttools: facts.tools,\n\t\tmcpServers: facts.mcpServers,\n\t\treferences: unique([...facts.skillPaths, ...facts.scriptPaths]).slice(0, 20),\n\t});\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -5,6 +5,7 @@ export { type BranchPreparation, type BranchSummaryDetails, type CollectEntriesR
5
5
  export { calculateContextTokens, compact, DEFAULT_COMPACTION_SETTINGS, estimateContextTokens, estimateTokens, findCutPoint, findTurnStartIndex, generateSummary, getLastAssistantUsage, prepareCompaction, serializeConversation, shouldCompact, } from "./harness/compaction/compaction.ts";
6
6
  export * from "./harness/messages.ts";
7
7
  export * from "./harness/prompt-templates.ts";
8
+ export * from "./harness/reverse-skill.ts";
8
9
  export * from "./harness/session/jsonl-repo.ts";
9
10
  export * from "./harness/session/memory-repo.ts";
10
11
  export * from "./harness/session/repo-utils.ts";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAC;AAE3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EACN,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,8BAA8B,EAC9B,qBAAqB,EACrB,oBAAoB,GACpB,MAAM,8CAA8C,CAAC;AACtD,OAAO,EACN,sBAAsB,EACtB,OAAO,EACP,2BAA2B,EAC3B,qBAAqB,EACrB,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,EACrB,aAAa,GACb,MAAM,oCAAoC,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC;AACjD,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAE3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,iCAAiC,CAAC;AAChD,cAAc,6BAA6B,CAAC;AAE5C,cAAc,YAAY,CAAC;AAE3B,cAAc,YAAY,CAAC","sourcesContent":["// Core Agent\nexport * from \"./agent.ts\";\n// Loop functions\nexport * from \"./agent-loop.ts\";\nexport * from \"./harness/agent-harness.ts\";\nexport {\n\ttype BranchPreparation,\n\ttype BranchSummaryDetails,\n\ttype CollectEntriesResult,\n\tcollectEntriesForBranchSummary,\n\tgenerateBranchSummary,\n\tprepareBranchEntries,\n} from \"./harness/compaction/branch-summarization.ts\";\nexport {\n\tcalculateContextTokens,\n\tcompact,\n\tDEFAULT_COMPACTION_SETTINGS,\n\testimateContextTokens,\n\testimateTokens,\n\tfindCutPoint,\n\tfindTurnStartIndex,\n\tgenerateSummary,\n\tgetLastAssistantUsage,\n\tprepareCompaction,\n\tserializeConversation,\n\tshouldCompact,\n} from \"./harness/compaction/compaction.ts\";\nexport * from \"./harness/messages.ts\";\nexport * from \"./harness/prompt-templates.ts\";\nexport * from \"./harness/session/jsonl-repo.ts\";\nexport * from \"./harness/session/memory-repo.ts\";\nexport * from \"./harness/session/repo-utils.ts\";\nexport * from \"./harness/session/session.ts\";\nexport { uuidv7 } from \"./harness/session/uuid.ts\";\nexport * from \"./harness/skills.ts\";\nexport * from \"./harness/system-prompt.ts\";\n// Harness\nexport * from \"./harness/types.ts\";\nexport * from \"./harness/utils/shell-output.ts\";\nexport * from \"./harness/utils/truncate.ts\";\n// Proxy utilities\nexport * from \"./proxy.ts\";\n// Types\nexport * from \"./types.ts\";\n"]}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAC;AAE3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EACN,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,8BAA8B,EAC9B,qBAAqB,EACrB,oBAAoB,GACpB,MAAM,8CAA8C,CAAC;AACtD,OAAO,EACN,sBAAsB,EACtB,OAAO,EACP,2BAA2B,EAC3B,qBAAqB,EACrB,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,EACrB,aAAa,GACb,MAAM,oCAAoC,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC;AACjD,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAE3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,iCAAiC,CAAC;AAChD,cAAc,6BAA6B,CAAC;AAE5C,cAAc,YAAY,CAAC;AAE3B,cAAc,YAAY,CAAC","sourcesContent":["// Core Agent\nexport * from \"./agent.ts\";\n// Loop functions\nexport * from \"./agent-loop.ts\";\nexport * from \"./harness/agent-harness.ts\";\nexport {\n\ttype BranchPreparation,\n\ttype BranchSummaryDetails,\n\ttype CollectEntriesResult,\n\tcollectEntriesForBranchSummary,\n\tgenerateBranchSummary,\n\tprepareBranchEntries,\n} from \"./harness/compaction/branch-summarization.ts\";\nexport {\n\tcalculateContextTokens,\n\tcompact,\n\tDEFAULT_COMPACTION_SETTINGS,\n\testimateContextTokens,\n\testimateTokens,\n\tfindCutPoint,\n\tfindTurnStartIndex,\n\tgenerateSummary,\n\tgetLastAssistantUsage,\n\tprepareCompaction,\n\tserializeConversation,\n\tshouldCompact,\n} from \"./harness/compaction/compaction.ts\";\nexport * from \"./harness/messages.ts\";\nexport * from \"./harness/prompt-templates.ts\";\nexport * from \"./harness/reverse-skill.ts\";\nexport * from \"./harness/session/jsonl-repo.ts\";\nexport * from \"./harness/session/memory-repo.ts\";\nexport * from \"./harness/session/repo-utils.ts\";\nexport * from \"./harness/session/session.ts\";\nexport { uuidv7 } from \"./harness/session/uuid.ts\";\nexport * from \"./harness/skills.ts\";\nexport * from \"./harness/system-prompt.ts\";\n// Harness\nexport * from \"./harness/types.ts\";\nexport * from \"./harness/utils/shell-output.ts\";\nexport * from \"./harness/utils/truncate.ts\";\n// Proxy utilities\nexport * from \"./proxy.ts\";\n// Types\nexport * from \"./types.ts\";\n"]}
package/dist/index.js CHANGED
@@ -7,6 +7,7 @@ export { collectEntriesForBranchSummary, generateBranchSummary, prepareBranchEnt
7
7
  export { calculateContextTokens, compact, DEFAULT_COMPACTION_SETTINGS, estimateContextTokens, estimateTokens, findCutPoint, findTurnStartIndex, generateSummary, getLastAssistantUsage, prepareCompaction, serializeConversation, shouldCompact, } from "./harness/compaction/compaction.js";
8
8
  export * from "./harness/messages.js";
9
9
  export * from "./harness/prompt-templates.js";
10
+ export * from "./harness/reverse-skill.js";
10
11
  export * from "./harness/session/jsonl-repo.js";
11
12
  export * from "./harness/session/memory-repo.js";
12
13
  export * from "./harness/session/repo-utils.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,cAAc,YAAY,CAAC;AAC3B,iBAAiB;AACjB,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAIN,8BAA8B,EAC9B,qBAAqB,EACrB,oBAAoB,GACpB,MAAM,8CAA8C,CAAC;AACtD,OAAO,EACN,sBAAsB,EACtB,OAAO,EACP,2BAA2B,EAC3B,qBAAqB,EACrB,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,EACrB,aAAa,GACb,MAAM,oCAAoC,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC;AACjD,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,UAAU;AACV,cAAc,oBAAoB,CAAC;AACnC,cAAc,iCAAiC,CAAC;AAChD,cAAc,6BAA6B,CAAC;AAC5C,kBAAkB;AAClB,cAAc,YAAY,CAAC;AAC3B,QAAQ;AACR,cAAc,YAAY,CAAC","sourcesContent":["// Core Agent\nexport * from \"./agent.ts\";\n// Loop functions\nexport * from \"./agent-loop.ts\";\nexport * from \"./harness/agent-harness.ts\";\nexport {\n\ttype BranchPreparation,\n\ttype BranchSummaryDetails,\n\ttype CollectEntriesResult,\n\tcollectEntriesForBranchSummary,\n\tgenerateBranchSummary,\n\tprepareBranchEntries,\n} from \"./harness/compaction/branch-summarization.ts\";\nexport {\n\tcalculateContextTokens,\n\tcompact,\n\tDEFAULT_COMPACTION_SETTINGS,\n\testimateContextTokens,\n\testimateTokens,\n\tfindCutPoint,\n\tfindTurnStartIndex,\n\tgenerateSummary,\n\tgetLastAssistantUsage,\n\tprepareCompaction,\n\tserializeConversation,\n\tshouldCompact,\n} from \"./harness/compaction/compaction.ts\";\nexport * from \"./harness/messages.ts\";\nexport * from \"./harness/prompt-templates.ts\";\nexport * from \"./harness/session/jsonl-repo.ts\";\nexport * from \"./harness/session/memory-repo.ts\";\nexport * from \"./harness/session/repo-utils.ts\";\nexport * from \"./harness/session/session.ts\";\nexport { uuidv7 } from \"./harness/session/uuid.ts\";\nexport * from \"./harness/skills.ts\";\nexport * from \"./harness/system-prompt.ts\";\n// Harness\nexport * from \"./harness/types.ts\";\nexport * from \"./harness/utils/shell-output.ts\";\nexport * from \"./harness/utils/truncate.ts\";\n// Proxy utilities\nexport * from \"./proxy.ts\";\n// Types\nexport * from \"./types.ts\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,cAAc,YAAY,CAAC;AAC3B,iBAAiB;AACjB,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAIN,8BAA8B,EAC9B,qBAAqB,EACrB,oBAAoB,GACpB,MAAM,8CAA8C,CAAC;AACtD,OAAO,EACN,sBAAsB,EACtB,OAAO,EACP,2BAA2B,EAC3B,qBAAqB,EACrB,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,EACrB,aAAa,GACb,MAAM,oCAAoC,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC;AACjD,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,UAAU;AACV,cAAc,oBAAoB,CAAC;AACnC,cAAc,iCAAiC,CAAC;AAChD,cAAc,6BAA6B,CAAC;AAC5C,kBAAkB;AAClB,cAAc,YAAY,CAAC;AAC3B,QAAQ;AACR,cAAc,YAAY,CAAC","sourcesContent":["// Core Agent\nexport * from \"./agent.ts\";\n// Loop functions\nexport * from \"./agent-loop.ts\";\nexport * from \"./harness/agent-harness.ts\";\nexport {\n\ttype BranchPreparation,\n\ttype BranchSummaryDetails,\n\ttype CollectEntriesResult,\n\tcollectEntriesForBranchSummary,\n\tgenerateBranchSummary,\n\tprepareBranchEntries,\n} from \"./harness/compaction/branch-summarization.ts\";\nexport {\n\tcalculateContextTokens,\n\tcompact,\n\tDEFAULT_COMPACTION_SETTINGS,\n\testimateContextTokens,\n\testimateTokens,\n\tfindCutPoint,\n\tfindTurnStartIndex,\n\tgenerateSummary,\n\tgetLastAssistantUsage,\n\tprepareCompaction,\n\tserializeConversation,\n\tshouldCompact,\n} from \"./harness/compaction/compaction.ts\";\nexport * from \"./harness/messages.ts\";\nexport * from \"./harness/prompt-templates.ts\";\nexport * from \"./harness/reverse-skill.ts\";\nexport * from \"./harness/session/jsonl-repo.ts\";\nexport * from \"./harness/session/memory-repo.ts\";\nexport * from \"./harness/session/repo-utils.ts\";\nexport * from \"./harness/session/session.ts\";\nexport { uuidv7 } from \"./harness/session/uuid.ts\";\nexport * from \"./harness/skills.ts\";\nexport * from \"./harness/system-prompt.ts\";\n// Harness\nexport * from \"./harness/types.ts\";\nexport * from \"./harness/utils/shell-output.ts\";\nexport * from \"./harness/utils/truncate.ts\";\n// Proxy utilities\nexport * from \"./proxy.ts\";\n// Types\nexport * from \"./types.ts\";\n"]}
package/dist/types.d.ts CHANGED
@@ -243,10 +243,10 @@ export interface AgentLoopConfig extends SimpleStreamOptions {
243
243
  }
244
244
  /**
245
245
  * Thinking/reasoning level for models that support it.
246
- * Note: "xhigh" is only supported by selected model families. Use model thinking-level metadata
247
- * from omk-ai to detect support for a concrete model.
246
+ * Note: "xhigh" and "max" are only supported by selected model families. Use model thinking-level
247
+ * metadata from omk-ai to detect support for a concrete model.
248
248
  */
249
- export type ThinkingLevel = "off" | "minimal" | "low" | "medium" | "high" | "xhigh";
249
+ export type ThinkingLevel = "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
250
250
  /**
251
251
  * Extensible interface for custom app messages.
252
252
  * Apps can extend via declaration merging:
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,EACZ,OAAO,EACP,KAAK,EACL,mBAAmB,EACnB,YAAY,EACZ,WAAW,EACX,IAAI,EACJ,iBAAiB,EACjB,MAAM,QAAQ,CAAC;AAChB,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAE/C;;;;;;;;GAQG;AACH,MAAM,MAAM,QAAQ,GAAG,CACtB,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,KACpC,UAAU,CAAC,OAAO,YAAY,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC,CAAC;AAEhF;;;;;;;GAOG;AACH,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG,UAAU,CAAC;AAE1D;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,eAAe,CAAC;AAEhD,wEAAwE;AACxE,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,CAAC;AAE/F;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACpC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,mBAAmB;IACnC,OAAO,CAAC,EAAE,CAAC,WAAW,GAAG,YAAY,CAAC,EAAE,CAAC;IACzC,OAAO,CAAC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GACtB;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,OAAO,EAAE,YAAY,CAAC;IAAC,WAAW,EAAE,iBAAiB,EAAE,CAAA;CAAE,GAE7E;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,OAAO,EAAE,YAAY,CAAA;CAAE,GAEhD;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,OAAO,EAAE,YAAY,CAAC;IAAC,qBAAqB,EAAE,qBAAqB,CAAA;CAAE,GAC/F;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,OAAO,EAAE,YAAY,CAAA;CAAE,GAE9C;IAAE,IAAI,EAAE,sBAAsB,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,GAAG,CAAA;CAAE,GACjF;IAAE,IAAI,EAAE,uBAAuB,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,GAAG,CAAC;IAAC,aAAa,EAAE,GAAG,CAAA;CAAE,GACtG;IAAE,IAAI,EAAE,oBAAoB,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,GAAG,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC","sourcesContent":["import type {\n\tAssistantMessage,\n\tAssistantMessageEvent,\n\tImageContent,\n\tMessage,\n\tModel,\n\tSimpleStreamOptions,\n\tstreamSimple,\n\tTextContent,\n\tTool,\n\tToolResultMessage,\n} from \"omk-ai\";\nimport type { Static, TSchema } from \"typebox\";\n\n/**\n * Stream function used by the agent loop.\n *\n * Contract:\n * - Must not throw or return a rejected promise for request/model/runtime failures.\n * - Must return an AssistantMessageEventStream.\n * - Failures must be encoded in the returned stream via protocol events and a\n * final AssistantMessage with stopReason \"error\" or \"aborted\" and errorMessage.\n */\nexport type StreamFn = (\n\t...args: Parameters<typeof streamSimple>\n) => ReturnType<typeof streamSimple> | Promise<ReturnType<typeof streamSimple>>;\n\n/**\n * Configuration for how tool calls from a single assistant message are executed.\n *\n * - \"sequential\": each tool call is prepared, executed, and finalized before the next one starts.\n * - \"parallel\": tool calls are prepared sequentially, then allowed tools execute concurrently.\n * `tool_execution_end` is emitted in tool completion order after each tool is finalized,\n * while tool-result message artifacts are emitted later in assistant source order.\n */\nexport type ToolExecutionMode = \"sequential\" | \"parallel\";\n\n/**\n * Controls how many queued user messages are injected when the agent loop reaches a queue drain point.\n *\n * - \"all\": drain and inject every queued message at that point.\n * - \"one-at-a-time\": drain and inject only the oldest queued message, leaving the rest queued for later drain points.\n */\nexport type QueueMode = \"all\" | \"one-at-a-time\";\n\n/** A single tool call content block emitted by an assistant message. */\nexport type AgentToolCall = Extract<AssistantMessage[\"content\"][number], { type: \"toolCall\" }>;\n\n/**\n * Result returned from `beforeToolCall`.\n *\n * Returning `{ block: true }` prevents the tool from executing. The loop emits an error tool result instead.\n * `reason` becomes the text shown in that error result. If omitted, a default blocked message is used.\n */\nexport interface BeforeToolCallResult {\n\tblock?: boolean;\n\treason?: string;\n}\n\n/**\n * Partial override returned from `afterToolCall`.\n *\n * Merge semantics are field-by-field:\n * - `content`: if provided, replaces the tool result content array in full\n * - `details`: if provided, replaces the tool result details value in full\n * - `isError`: if provided, replaces the tool result error flag\n * - `terminate`: if provided, replaces the early-termination hint\n *\n * Omitted fields keep the original executed tool result values.\n * There is no deep merge for `content` or `details`.\n */\nexport interface AfterToolCallResult {\n\tcontent?: (TextContent | ImageContent)[];\n\tdetails?: unknown;\n\tisError?: boolean;\n\t/**\n\t * Hint that the agent should stop after the current tool batch.\n\t * Early termination only happens when every finalized tool result in the batch sets this to true.\n\t */\n\tterminate?: boolean;\n}\n\n/** Context passed to `beforeToolCall`. */\nexport interface BeforeToolCallContext {\n\t/** The assistant message that requested the tool call. */\n\tassistantMessage: AssistantMessage;\n\t/** The raw tool call block from `assistantMessage.content`. */\n\ttoolCall: AgentToolCall;\n\t/** Validated tool arguments for the target tool schema. */\n\targs: unknown;\n\t/** Current agent context at the time the tool call is prepared. */\n\tcontext: AgentContext;\n}\n\n/** Context passed to `afterToolCall`. */\nexport interface AfterToolCallContext {\n\t/** The assistant message that requested the tool call. */\n\tassistantMessage: AssistantMessage;\n\t/** The raw tool call block from `assistantMessage.content`. */\n\ttoolCall: AgentToolCall;\n\t/** Validated tool arguments for the target tool schema. */\n\targs: unknown;\n\t/** The executed tool result before any `afterToolCall` overrides are applied. */\n\tresult: AgentToolResult<any>;\n\t/** Whether the executed tool result is currently treated as an error. */\n\tisError: boolean;\n\t/** Current agent context at the time the tool call is finalized. */\n\tcontext: AgentContext;\n}\n\n/** Context passed to `shouldStopAfterTurn`. */\nexport interface ShouldStopAfterTurnContext {\n\t/** The assistant message that completed the turn. */\n\tmessage: AssistantMessage;\n\t/** Tool result messages passed to the preceding `turn_end` event. */\n\ttoolResults: ToolResultMessage[];\n\t/** Current agent context after the turn's assistant message and tool results have been appended. */\n\tcontext: AgentContext;\n\t/** Messages that this loop invocation will return if it exits at this point. Prompt runs include the initial prompt messages; continuation runs do not include pre-existing context messages. */\n\tnewMessages: AgentMessage[];\n}\n\n/** Replacement runtime state used by the agent loop before starting another provider request. */\nexport interface AgentLoopTurnUpdate {\n\t/** Context for the next provider request. */\n\tcontext?: AgentContext;\n\t/** Model for the next provider request. */\n\tmodel?: Model<any>;\n\t/** Thinking level for the next provider request. */\n\tthinkingLevel?: ThinkingLevel;\n}\n\nexport interface PrepareNextTurnContext extends ShouldStopAfterTurnContext {}\n\nexport interface AgentLoopConfig extends SimpleStreamOptions {\n\tmodel: Model<any>;\n\n\t/**\n\t * Converts AgentMessage[] to LLM-compatible Message[] before each LLM call.\n\t *\n\t * Each AgentMessage must be converted to a UserMessage, AssistantMessage, or ToolResultMessage\n\t * that the LLM can understand. AgentMessages that cannot be converted (e.g., UI-only notifications,\n\t * status messages) should be filtered out.\n\t *\n\t * Contract: must not throw or reject. Return a safe fallback value instead.\n\t * Throwing interrupts the low-level agent loop without producing a normal event sequence.\n\t *\n\t * @example\n\t * ```typescript\n\t * convertToLlm: (messages) => messages.flatMap(m => {\n\t * if (m.role === \"custom\") {\n\t * // Convert custom message to user message\n\t * return [{ role: \"user\", content: m.content, timestamp: m.timestamp }];\n\t * }\n\t * if (m.role === \"notification\") {\n\t * // Filter out UI-only messages\n\t * return [];\n\t * }\n\t * // Pass through standard LLM messages\n\t * return [m];\n\t * })\n\t * ```\n\t */\n\tconvertToLlm: (messages: AgentMessage[]) => Message[] | Promise<Message[]>;\n\n\t/**\n\t * Optional transform applied to the context before `convertToLlm`.\n\t *\n\t * Use this for operations that work at the AgentMessage level:\n\t * - Context window management (pruning old messages)\n\t * - Injecting context from external sources\n\t *\n\t * Contract: must not throw or reject. Return the original messages or another\n\t * safe fallback value instead.\n\t *\n\t * @example\n\t * ```typescript\n\t * transformContext: async (messages) => {\n\t * if (estimateTokens(messages) > MAX_TOKENS) {\n\t * return pruneOldMessages(messages);\n\t * }\n\t * return messages;\n\t * }\n\t * ```\n\t */\n\ttransformContext?: (messages: AgentMessage[], signal?: AbortSignal) => Promise<AgentMessage[]>;\n\n\t/**\n\t * Resolves an API key dynamically for each LLM call.\n\t *\n\t * Useful for short-lived OAuth tokens (e.g., GitHub Copilot) that may expire\n\t * during long-running tool execution phases.\n\t *\n\t * Contract: must not throw or reject. Return undefined when no key is available.\n\t */\n\tgetApiKey?: (provider: string) => Promise<string | undefined> | string | undefined;\n\n\t/**\n\t * Called after each turn fully completes and `turn_end` has been emitted.\n\t *\n\t * If it returns true, the loop emits `agent_end` and exits before polling steering or follow-up queues,\n\t * without starting another LLM call. The current assistant response and any tool executions finish normally.\n\t *\n\t * Use this to request a graceful stop after the current turn, e.g. before context gets too full.\n\t *\n\t * Contract: must not throw or reject. Throwing interrupts the low-level agent loop without producing a normal event sequence.\n\t */\n\tshouldStopAfterTurn?: (context: ShouldStopAfterTurnContext) => boolean | Promise<boolean>;\n\n\t/**\n\t * Called after `turn_end` and before the loop decides whether another provider request should start.\n\t * Return replacement context/model/thinking state to affect the next turn in this run.\n\t * Return undefined to keep using the current context/config.\n\t */\n\tprepareNextTurn?: (\n\t\tcontext: PrepareNextTurnContext,\n\t) => AgentLoopTurnUpdate | undefined | Promise<AgentLoopTurnUpdate | undefined>;\n\n\t/**\n\t * Returns steering messages to inject into the conversation mid-run.\n\t *\n\t * Called after the current assistant turn finishes executing its tool calls, unless `shouldStopAfterTurn` exits first.\n\t * If messages are returned, they are added to the context before the next LLM call.\n\t * Tool calls from the current assistant message are not skipped.\n\t *\n\t * Use this for \"steering\" the agent while it's working.\n\t *\n\t * Contract: must not throw or reject. Return [] when no steering messages are available.\n\t */\n\tgetSteeringMessages?: () => Promise<AgentMessage[]>;\n\n\t/**\n\t * Returns follow-up messages to process after the agent would otherwise stop.\n\t *\n\t * Called when the agent has no more tool calls and no steering messages.\n\t * If messages are returned, they're added to the context and the agent\n\t * continues with another turn.\n\t *\n\t * Use this for follow-up messages that should wait until the agent finishes.\n\t *\n\t * Contract: must not throw or reject. Return [] when no follow-up messages are available.\n\t */\n\tgetFollowUpMessages?: () => Promise<AgentMessage[]>;\n\n\t/**\n\t * Tool execution mode.\n\t * - \"sequential\": execute tool calls one by one\n\t * - \"parallel\": preflight tool calls sequentially, then execute allowed tools concurrently;\n\t * emit `tool_execution_end` in tool completion order after each tool is finalized,\n\t * then emit tool-result message artifacts later in assistant source order\n\t *\n\t * Default: \"parallel\"\n\t */\n\ttoolExecution?: ToolExecutionMode;\n\n\t/**\n\t * Called before a tool is executed, after arguments have been validated.\n\t *\n\t * Return `{ block: true }` to prevent execution. The loop emits an error tool result instead.\n\t * The hook receives the agent abort signal and is responsible for honoring it.\n\t */\n\tbeforeToolCall?: (context: BeforeToolCallContext, signal?: AbortSignal) => Promise<BeforeToolCallResult | undefined>;\n\n\t/**\n\t * Called after a tool finishes executing, before `tool_execution_end` and tool-result message events are emitted.\n\t *\n\t * Return an `AfterToolCallResult` to override parts of the executed tool result:\n\t * - `content` replaces the full content array\n\t * - `details` replaces the full details payload\n\t * - `isError` replaces the error flag\n\t * - `terminate` replaces the early-termination hint\n\t *\n\t * Any omitted fields keep their original values. No deep merge is performed.\n\t * The hook receives the agent abort signal and is responsible for honoring it.\n\t */\n\tafterToolCall?: (context: AfterToolCallContext, signal?: AbortSignal) => Promise<AfterToolCallResult | undefined>;\n}\n\n/**\n * Thinking/reasoning level for models that support it.\n * Note: \"xhigh\" is only supported by selected model families. Use model thinking-level metadata\n * from omk-ai to detect support for a concrete model.\n */\nexport type ThinkingLevel = \"off\" | \"minimal\" | \"low\" | \"medium\" | \"high\" | \"xhigh\";\n\n/**\n * Extensible interface for custom app messages.\n * Apps can extend via declaration merging:\n *\n * @example\n * ```typescript\n * declare module \"@mariozechner/agent\" {\n * interface CustomAgentMessages {\n * artifact: ArtifactMessage;\n * notification: NotificationMessage;\n * }\n * }\n * ```\n */\nexport interface CustomAgentMessages {\n\t// Empty by default - apps extend via declaration merging\n}\n\n/**\n * AgentMessage: Union of LLM messages + custom messages.\n * This abstraction allows apps to add custom message types while maintaining\n * type safety and compatibility with the base LLM messages.\n */\nexport type AgentMessage = Message | CustomAgentMessages[keyof CustomAgentMessages];\n\n/**\n * Public agent state.\n *\n * `tools` and `messages` use accessor properties so implementations can copy\n * assigned arrays before storing them.\n */\nexport interface AgentState {\n\t/** System prompt sent with each model request. */\n\tsystemPrompt: string;\n\t/** Active model used for future turns. */\n\tmodel: Model<any>;\n\t/** Requested reasoning level for future turns. */\n\tthinkingLevel: ThinkingLevel;\n\t/** Available tools. Assigning a new array copies the top-level array. */\n\tset tools(tools: AgentTool<any>[]);\n\tget tools(): AgentTool<any>[];\n\t/** Conversation transcript. Assigning a new array copies the top-level array. */\n\tset messages(messages: AgentMessage[]);\n\tget messages(): AgentMessage[];\n\t/**\n\t * True while the agent is processing a prompt or continuation.\n\t *\n\t * This remains true until awaited `agent_end` listeners settle.\n\t */\n\treadonly isStreaming: boolean;\n\t/** Partial assistant message for the current streamed response, if any. */\n\treadonly streamingMessage?: AgentMessage;\n\t/** Tool call ids currently executing. */\n\treadonly pendingToolCalls: ReadonlySet<string>;\n\t/** Error message from the most recent failed or aborted assistant turn, if any. */\n\treadonly errorMessage?: string;\n}\n\n/** Final or partial result produced by a tool. */\nexport interface AgentToolResult<T> {\n\t/** Text or image content returned to the model. */\n\tcontent: (TextContent | ImageContent)[];\n\t/** Arbitrary structured details for logs or UI rendering. */\n\tdetails: T;\n\t/**\n\t * Hint that the agent should stop after the current tool batch.\n\t * Early termination only happens when every finalized tool result in the batch sets this to true.\n\t */\n\tterminate?: boolean;\n}\n\n/** Callback used by tools to stream partial execution updates. */\nexport type AgentToolUpdateCallback<T = any> = (partialResult: AgentToolResult<T>) => void;\n\n/** Tool definition used by the agent runtime. */\nexport interface AgentTool<TParameters extends TSchema = TSchema, TDetails = any> extends Tool<TParameters> {\n\t/** Human-readable label for UI display. */\n\tlabel: string;\n\t/**\n\t * Optional compatibility shim for raw tool-call arguments before schema validation.\n\t * Must return an object that matches `TParameters`.\n\t */\n\tprepareArguments?: (args: unknown) => Static<TParameters>;\n\t/** Execute the tool call. Throw on failure instead of encoding errors in `content`. */\n\texecute: (\n\t\ttoolCallId: string,\n\t\tparams: Static<TParameters>,\n\t\tsignal?: AbortSignal,\n\t\tonUpdate?: AgentToolUpdateCallback<TDetails>,\n\t) => Promise<AgentToolResult<TDetails>>;\n\t/**\n\t * Per-tool execution mode override.\n\t * - \"sequential\": this tool must execute one at a time with other tool calls.\n\t * - \"parallel\": this tool can execute concurrently with other tool calls.\n\t *\n\t * If omitted, the default execution mode applies.\n\t */\n\texecutionMode?: ToolExecutionMode;\n}\n\n/** Context snapshot passed into the low-level agent loop. */\nexport interface AgentContext {\n\t/** System prompt included with the request. */\n\tsystemPrompt: string;\n\t/** Transcript visible to the model. */\n\tmessages: AgentMessage[];\n\t/** Tools available for this run. */\n\ttools?: AgentTool<any>[];\n}\n\n/**\n * Events emitted by the Agent for UI updates.\n *\n * `agent_end` is the last event emitted for a run, but awaited `Agent.subscribe()`\n * listeners for that event are still part of run settlement. The agent becomes\n * idle only after those listeners finish.\n */\nexport type AgentEvent =\n\t// Agent lifecycle\n\t| { type: \"agent_start\" }\n\t| { type: \"agent_end\"; messages: AgentMessage[] }\n\t// Turn lifecycle - a turn is one assistant response + any tool calls/results\n\t| { type: \"turn_start\" }\n\t| { type: \"turn_end\"; message: AgentMessage; toolResults: ToolResultMessage[] }\n\t// Message lifecycle - emitted for user, assistant, and toolResult messages\n\t| { type: \"message_start\"; message: AgentMessage }\n\t// Only emitted for assistant messages during streaming\n\t| { type: \"message_update\"; message: AgentMessage; assistantMessageEvent: AssistantMessageEvent }\n\t| { type: \"message_end\"; message: AgentMessage }\n\t// Tool execution lifecycle\n\t| { type: \"tool_execution_start\"; toolCallId: string; toolName: string; args: any }\n\t| { type: \"tool_execution_update\"; toolCallId: string; toolName: string; args: any; partialResult: any }\n\t| { type: \"tool_execution_end\"; toolCallId: string; toolName: string; result: any; isError: boolean };\n"]}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,EACZ,OAAO,EACP,KAAK,EACL,mBAAmB,EACnB,YAAY,EACZ,WAAW,EACX,IAAI,EACJ,iBAAiB,EACjB,MAAM,QAAQ,CAAC;AAChB,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAE/C;;;;;;;;GAQG;AACH,MAAM,MAAM,QAAQ,GAAG,CACtB,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,KACpC,UAAU,CAAC,OAAO,YAAY,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC,CAAC;AAEhF;;;;;;;GAOG;AACH,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG,UAAU,C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AAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,GAAG,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC","sourcesContent":["import type {\n\tAssistantMessage,\n\tAssistantMessageEvent,\n\tImageContent,\n\tMessage,\n\tModel,\n\tSimpleStreamOptions,\n\tstreamSimple,\n\tTextContent,\n\tTool,\n\tToolResultMessage,\n} from \"omk-ai\";\nimport type { Static, TSchema } from \"typebox\";\n\n/**\n * Stream function used by the agent loop.\n *\n * Contract:\n * - Must not throw or return a rejected promise for request/model/runtime failures.\n * - Must return an AssistantMessageEventStream.\n * - Failures must be encoded in the returned stream via protocol events and a\n * final AssistantMessage with stopReason \"error\" or \"aborted\" and errorMessage.\n */\nexport type StreamFn = (\n\t...args: Parameters<typeof streamSimple>\n) => ReturnType<typeof streamSimple> | Promise<ReturnType<typeof streamSimple>>;\n\n/**\n * Configuration for how tool calls from a single assistant message are executed.\n *\n * - \"sequential\": each tool call is prepared, executed, and finalized before the next one starts.\n * - \"parallel\": tool calls are prepared sequentially, then allowed tools execute concurrently.\n * `tool_execution_end` is emitted in tool completion order after each tool is finalized,\n * while tool-result message artifacts are emitted later in assistant source order.\n */\nexport type ToolExecutionMode = \"sequential\" | \"parallel\";\n\n/**\n * Controls how many queued user messages are injected when the agent loop reaches a queue drain point.\n *\n * - \"all\": drain and inject every queued message at that point.\n * - \"one-at-a-time\": drain and inject only the oldest queued message, leaving the rest queued for later drain points.\n */\nexport type QueueMode = \"all\" | \"one-at-a-time\";\n\n/** A single tool call content block emitted by an assistant message. */\nexport type AgentToolCall = Extract<AssistantMessage[\"content\"][number], { type: \"toolCall\" }>;\n\n/**\n * Result returned from `beforeToolCall`.\n *\n * Returning `{ block: true }` prevents the tool from executing. The loop emits an error tool result instead.\n * `reason` becomes the text shown in that error result. If omitted, a default blocked message is used.\n */\nexport interface BeforeToolCallResult {\n\tblock?: boolean;\n\treason?: string;\n}\n\n/**\n * Partial override returned from `afterToolCall`.\n *\n * Merge semantics are field-by-field:\n * - `content`: if provided, replaces the tool result content array in full\n * - `details`: if provided, replaces the tool result details value in full\n * - `isError`: if provided, replaces the tool result error flag\n * - `terminate`: if provided, replaces the early-termination hint\n *\n * Omitted fields keep the original executed tool result values.\n * There is no deep merge for `content` or `details`.\n */\nexport interface AfterToolCallResult {\n\tcontent?: (TextContent | ImageContent)[];\n\tdetails?: unknown;\n\tisError?: boolean;\n\t/**\n\t * Hint that the agent should stop after the current tool batch.\n\t * Early termination only happens when every finalized tool result in the batch sets this to true.\n\t */\n\tterminate?: boolean;\n}\n\n/** Context passed to `beforeToolCall`. */\nexport interface BeforeToolCallContext {\n\t/** The assistant message that requested the tool call. */\n\tassistantMessage: AssistantMessage;\n\t/** The raw tool call block from `assistantMessage.content`. */\n\ttoolCall: AgentToolCall;\n\t/** Validated tool arguments for the target tool schema. */\n\targs: unknown;\n\t/** Current agent context at the time the tool call is prepared. */\n\tcontext: AgentContext;\n}\n\n/** Context passed to `afterToolCall`. */\nexport interface AfterToolCallContext {\n\t/** The assistant message that requested the tool call. */\n\tassistantMessage: AssistantMessage;\n\t/** The raw tool call block from `assistantMessage.content`. */\n\ttoolCall: AgentToolCall;\n\t/** Validated tool arguments for the target tool schema. */\n\targs: unknown;\n\t/** The executed tool result before any `afterToolCall` overrides are applied. */\n\tresult: AgentToolResult<any>;\n\t/** Whether the executed tool result is currently treated as an error. */\n\tisError: boolean;\n\t/** Current agent context at the time the tool call is finalized. */\n\tcontext: AgentContext;\n}\n\n/** Context passed to `shouldStopAfterTurn`. */\nexport interface ShouldStopAfterTurnContext {\n\t/** The assistant message that completed the turn. */\n\tmessage: AssistantMessage;\n\t/** Tool result messages passed to the preceding `turn_end` event. */\n\ttoolResults: ToolResultMessage[];\n\t/** Current agent context after the turn's assistant message and tool results have been appended. */\n\tcontext: AgentContext;\n\t/** Messages that this loop invocation will return if it exits at this point. Prompt runs include the initial prompt messages; continuation runs do not include pre-existing context messages. */\n\tnewMessages: AgentMessage[];\n}\n\n/** Replacement runtime state used by the agent loop before starting another provider request. */\nexport interface AgentLoopTurnUpdate {\n\t/** Context for the next provider request. */\n\tcontext?: AgentContext;\n\t/** Model for the next provider request. */\n\tmodel?: Model<any>;\n\t/** Thinking level for the next provider request. */\n\tthinkingLevel?: ThinkingLevel;\n}\n\nexport interface PrepareNextTurnContext extends ShouldStopAfterTurnContext {}\n\nexport interface AgentLoopConfig extends SimpleStreamOptions {\n\tmodel: Model<any>;\n\n\t/**\n\t * Converts AgentMessage[] to LLM-compatible Message[] before each LLM call.\n\t *\n\t * Each AgentMessage must be converted to a UserMessage, AssistantMessage, or ToolResultMessage\n\t * that the LLM can understand. AgentMessages that cannot be converted (e.g., UI-only notifications,\n\t * status messages) should be filtered out.\n\t *\n\t * Contract: must not throw or reject. Return a safe fallback value instead.\n\t * Throwing interrupts the low-level agent loop without producing a normal event sequence.\n\t *\n\t * @example\n\t * ```typescript\n\t * convertToLlm: (messages) => messages.flatMap(m => {\n\t * if (m.role === \"custom\") {\n\t * // Convert custom message to user message\n\t * return [{ role: \"user\", content: m.content, timestamp: m.timestamp }];\n\t * }\n\t * if (m.role === \"notification\") {\n\t * // Filter out UI-only messages\n\t * return [];\n\t * }\n\t * // Pass through standard LLM messages\n\t * return [m];\n\t * })\n\t * ```\n\t */\n\tconvertToLlm: (messages: AgentMessage[]) => Message[] | Promise<Message[]>;\n\n\t/**\n\t * Optional transform applied to the context before `convertToLlm`.\n\t *\n\t * Use this for operations that work at the AgentMessage level:\n\t * - Context window management (pruning old messages)\n\t * - Injecting context from external sources\n\t *\n\t * Contract: must not throw or reject. Return the original messages or another\n\t * safe fallback value instead.\n\t *\n\t * @example\n\t * ```typescript\n\t * transformContext: async (messages) => {\n\t * if (estimateTokens(messages) > MAX_TOKENS) {\n\t * return pruneOldMessages(messages);\n\t * }\n\t * return messages;\n\t * }\n\t * ```\n\t */\n\ttransformContext?: (messages: AgentMessage[], signal?: AbortSignal) => Promise<AgentMessage[]>;\n\n\t/**\n\t * Resolves an API key dynamically for each LLM call.\n\t *\n\t * Useful for short-lived OAuth tokens (e.g., GitHub Copilot) that may expire\n\t * during long-running tool execution phases.\n\t *\n\t * Contract: must not throw or reject. Return undefined when no key is available.\n\t */\n\tgetApiKey?: (provider: string) => Promise<string | undefined> | string | undefined;\n\n\t/**\n\t * Called after each turn fully completes and `turn_end` has been emitted.\n\t *\n\t * If it returns true, the loop emits `agent_end` and exits before polling steering or follow-up queues,\n\t * without starting another LLM call. The current assistant response and any tool executions finish normally.\n\t *\n\t * Use this to request a graceful stop after the current turn, e.g. before context gets too full.\n\t *\n\t * Contract: must not throw or reject. Throwing interrupts the low-level agent loop without producing a normal event sequence.\n\t */\n\tshouldStopAfterTurn?: (context: ShouldStopAfterTurnContext) => boolean | Promise<boolean>;\n\n\t/**\n\t * Called after `turn_end` and before the loop decides whether another provider request should start.\n\t * Return replacement context/model/thinking state to affect the next turn in this run.\n\t * Return undefined to keep using the current context/config.\n\t */\n\tprepareNextTurn?: (\n\t\tcontext: PrepareNextTurnContext,\n\t) => AgentLoopTurnUpdate | undefined | Promise<AgentLoopTurnUpdate | undefined>;\n\n\t/**\n\t * Returns steering messages to inject into the conversation mid-run.\n\t *\n\t * Called after the current assistant turn finishes executing its tool calls, unless `shouldStopAfterTurn` exits first.\n\t * If messages are returned, they are added to the context before the next LLM call.\n\t * Tool calls from the current assistant message are not skipped.\n\t *\n\t * Use this for \"steering\" the agent while it's working.\n\t *\n\t * Contract: must not throw or reject. Return [] when no steering messages are available.\n\t */\n\tgetSteeringMessages?: () => Promise<AgentMessage[]>;\n\n\t/**\n\t * Returns follow-up messages to process after the agent would otherwise stop.\n\t *\n\t * Called when the agent has no more tool calls and no steering messages.\n\t * If messages are returned, they're added to the context and the agent\n\t * continues with another turn.\n\t *\n\t * Use this for follow-up messages that should wait until the agent finishes.\n\t *\n\t * Contract: must not throw or reject. Return [] when no follow-up messages are available.\n\t */\n\tgetFollowUpMessages?: () => Promise<AgentMessage[]>;\n\n\t/**\n\t * Tool execution mode.\n\t * - \"sequential\": execute tool calls one by one\n\t * - \"parallel\": preflight tool calls sequentially, then execute allowed tools concurrently;\n\t * emit `tool_execution_end` in tool completion order after each tool is finalized,\n\t * then emit tool-result message artifacts later in assistant source order\n\t *\n\t * Default: \"parallel\"\n\t */\n\ttoolExecution?: ToolExecutionMode;\n\n\t/**\n\t * Called before a tool is executed, after arguments have been validated.\n\t *\n\t * Return `{ block: true }` to prevent execution. The loop emits an error tool result instead.\n\t * The hook receives the agent abort signal and is responsible for honoring it.\n\t */\n\tbeforeToolCall?: (context: BeforeToolCallContext, signal?: AbortSignal) => Promise<BeforeToolCallResult | undefined>;\n\n\t/**\n\t * Called after a tool finishes executing, before `tool_execution_end` and tool-result message events are emitted.\n\t *\n\t * Return an `AfterToolCallResult` to override parts of the executed tool result:\n\t * - `content` replaces the full content array\n\t * - `details` replaces the full details payload\n\t * - `isError` replaces the error flag\n\t * - `terminate` replaces the early-termination hint\n\t *\n\t * Any omitted fields keep their original values. No deep merge is performed.\n\t * The hook receives the agent abort signal and is responsible for honoring it.\n\t */\n\tafterToolCall?: (context: AfterToolCallContext, signal?: AbortSignal) => Promise<AfterToolCallResult | undefined>;\n}\n\n/**\n * Thinking/reasoning level for models that support it.\n * Note: \"xhigh\" and \"max\" are only supported by selected model families. Use model thinking-level\n * metadata from omk-ai to detect support for a concrete model.\n */\nexport type ThinkingLevel = \"off\" | \"minimal\" | \"low\" | \"medium\" | \"high\" | \"xhigh\" | \"max\";\n\n/**\n * Extensible interface for custom app messages.\n * Apps can extend via declaration merging:\n *\n * @example\n * ```typescript\n * declare module \"@mariozechner/agent\" {\n * interface CustomAgentMessages {\n * artifact: ArtifactMessage;\n * notification: NotificationMessage;\n * }\n * }\n * ```\n */\nexport interface CustomAgentMessages {\n\t// Empty by default - apps extend via declaration merging\n}\n\n/**\n * AgentMessage: Union of LLM messages + custom messages.\n * This abstraction allows apps to add custom message types while maintaining\n * type safety and compatibility with the base LLM messages.\n */\nexport type AgentMessage = Message | CustomAgentMessages[keyof CustomAgentMessages];\n\n/**\n * Public agent state.\n *\n * `tools` and `messages` use accessor properties so implementations can copy\n * assigned arrays before storing them.\n */\nexport interface AgentState {\n\t/** System prompt sent with each model request. */\n\tsystemPrompt: string;\n\t/** Active model used for future turns. */\n\tmodel: Model<any>;\n\t/** Requested reasoning level for future turns. */\n\tthinkingLevel: ThinkingLevel;\n\t/** Available tools. Assigning a new array copies the top-level array. */\n\tset tools(tools: AgentTool<any>[]);\n\tget tools(): AgentTool<any>[];\n\t/** Conversation transcript. Assigning a new array copies the top-level array. */\n\tset messages(messages: AgentMessage[]);\n\tget messages(): AgentMessage[];\n\t/**\n\t * True while the agent is processing a prompt or continuation.\n\t *\n\t * This remains true until awaited `agent_end` listeners settle.\n\t */\n\treadonly isStreaming: boolean;\n\t/** Partial assistant message for the current streamed response, if any. */\n\treadonly streamingMessage?: AgentMessage;\n\t/** Tool call ids currently executing. */\n\treadonly pendingToolCalls: ReadonlySet<string>;\n\t/** Error message from the most recent failed or aborted assistant turn, if any. */\n\treadonly errorMessage?: string;\n}\n\n/** Final or partial result produced by a tool. */\nexport interface AgentToolResult<T> {\n\t/** Text or image content returned to the model. */\n\tcontent: (TextContent | ImageContent)[];\n\t/** Arbitrary structured details for logs or UI rendering. */\n\tdetails: T;\n\t/**\n\t * Hint that the agent should stop after the current tool batch.\n\t * Early termination only happens when every finalized tool result in the batch sets this to true.\n\t */\n\tterminate?: boolean;\n}\n\n/** Callback used by tools to stream partial execution updates. */\nexport type AgentToolUpdateCallback<T = any> = (partialResult: AgentToolResult<T>) => void;\n\n/** Tool definition used by the agent runtime. */\nexport interface AgentTool<TParameters extends TSchema = TSchema, TDetails = any> extends Tool<TParameters> {\n\t/** Human-readable label for UI display. */\n\tlabel: string;\n\t/**\n\t * Optional compatibility shim for raw tool-call arguments before schema validation.\n\t * Must return an object that matches `TParameters`.\n\t */\n\tprepareArguments?: (args: unknown) => Static<TParameters>;\n\t/** Execute the tool call. Throw on failure instead of encoding errors in `content`. */\n\texecute: (\n\t\ttoolCallId: string,\n\t\tparams: Static<TParameters>,\n\t\tsignal?: AbortSignal,\n\t\tonUpdate?: AgentToolUpdateCallback<TDetails>,\n\t) => Promise<AgentToolResult<TDetails>>;\n\t/**\n\t * Per-tool execution mode override.\n\t * - \"sequential\": this tool must execute one at a time with other tool calls.\n\t * - \"parallel\": this tool can execute concurrently with other tool calls.\n\t *\n\t * If omitted, the default execution mode applies.\n\t */\n\texecutionMode?: ToolExecutionMode;\n}\n\n/** Context snapshot passed into the low-level agent loop. */\nexport interface AgentContext {\n\t/** System prompt included with the request. */\n\tsystemPrompt: string;\n\t/** Transcript visible to the model. */\n\tmessages: AgentMessage[];\n\t/** Tools available for this run. */\n\ttools?: AgentTool<any>[];\n}\n\n/**\n * Events emitted by the Agent for UI updates.\n *\n * `agent_end` is the last event emitted for a run, but awaited `Agent.subscribe()`\n * listeners for that event are still part of run settlement. The agent becomes\n * idle only after those listeners finish.\n */\nexport type AgentEvent =\n\t// Agent lifecycle\n\t| { type: \"agent_start\" }\n\t| { type: \"agent_end\"; messages: AgentMessage[] }\n\t// Turn lifecycle - a turn is one assistant response + any tool calls/results\n\t| { type: \"turn_start\" }\n\t| { type: \"turn_end\"; message: AgentMessage; toolResults: ToolResultMessage[] }\n\t// Message lifecycle - emitted for user, assistant, and toolResult messages\n\t| { type: \"message_start\"; message: AgentMessage }\n\t// Only emitted for assistant messages during streaming\n\t| { type: \"message_update\"; message: AgentMessage; assistantMessageEvent: AssistantMessageEvent }\n\t| { type: \"message_end\"; message: AgentMessage }\n\t// Tool execution lifecycle\n\t| { type: \"tool_execution_start\"; toolCallId: string; toolName: string; args: any }\n\t| { type: \"tool_execution_update\"; toolCallId: string; toolName: string; args: any; partialResult: any }\n\t| { type: \"tool_execution_end\"; toolCallId: string; toolName: string; result: any; isError: boolean };\n"]}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n\tAssistantMessage,\n\tAssistantMessageEvent,\n\tImageContent,\n\tMessage,\n\tModel,\n\tSimpleStreamOptions,\n\tstreamSimple,\n\tTextContent,\n\tTool,\n\tToolResultMessage,\n} from \"omk-ai\";\nimport type { Static, TSchema } from \"typebox\";\n\n/**\n * Stream function used by the agent loop.\n *\n * Contract:\n * - Must not throw or return a rejected promise for request/model/runtime failures.\n * - Must return an AssistantMessageEventStream.\n * - Failures must be encoded in the returned stream via protocol events and a\n * final AssistantMessage with stopReason \"error\" or \"aborted\" and errorMessage.\n */\nexport type StreamFn = (\n\t...args: Parameters<typeof streamSimple>\n) => ReturnType<typeof streamSimple> | Promise<ReturnType<typeof streamSimple>>;\n\n/**\n * Configuration for how tool calls from a single assistant message are executed.\n *\n * - \"sequential\": each tool call is prepared, executed, and finalized before the next one starts.\n * - \"parallel\": tool calls are prepared sequentially, then allowed tools execute concurrently.\n * `tool_execution_end` is emitted in tool completion order after each tool is finalized,\n * while tool-result message artifacts are emitted later in assistant source order.\n */\nexport type ToolExecutionMode = \"sequential\" | \"parallel\";\n\n/**\n * Controls how many queued user messages are injected when the agent loop reaches a queue drain point.\n *\n * - \"all\": drain and inject every queued message at that point.\n * - \"one-at-a-time\": drain and inject only the oldest queued message, leaving the rest queued for later drain points.\n */\nexport type QueueMode = \"all\" | \"one-at-a-time\";\n\n/** A single tool call content block emitted by an assistant message. */\nexport type AgentToolCall = Extract<AssistantMessage[\"content\"][number], { type: \"toolCall\" }>;\n\n/**\n * Result returned from `beforeToolCall`.\n *\n * Returning `{ block: true }` prevents the tool from executing. The loop emits an error tool result instead.\n * `reason` becomes the text shown in that error result. If omitted, a default blocked message is used.\n */\nexport interface BeforeToolCallResult {\n\tblock?: boolean;\n\treason?: string;\n}\n\n/**\n * Partial override returned from `afterToolCall`.\n *\n * Merge semantics are field-by-field:\n * - `content`: if provided, replaces the tool result content array in full\n * - `details`: if provided, replaces the tool result details value in full\n * - `isError`: if provided, replaces the tool result error flag\n * - `terminate`: if provided, replaces the early-termination hint\n *\n * Omitted fields keep the original executed tool result values.\n * There is no deep merge for `content` or `details`.\n */\nexport interface AfterToolCallResult {\n\tcontent?: (TextContent | ImageContent)[];\n\tdetails?: unknown;\n\tisError?: boolean;\n\t/**\n\t * Hint that the agent should stop after the current tool batch.\n\t * Early termination only happens when every finalized tool result in the batch sets this to true.\n\t */\n\tterminate?: boolean;\n}\n\n/** Context passed to `beforeToolCall`. */\nexport interface BeforeToolCallContext {\n\t/** The assistant message that requested the tool call. */\n\tassistantMessage: AssistantMessage;\n\t/** The raw tool call block from `assistantMessage.content`. */\n\ttoolCall: AgentToolCall;\n\t/** Validated tool arguments for the target tool schema. */\n\targs: unknown;\n\t/** Current agent context at the time the tool call is prepared. */\n\tcontext: AgentContext;\n}\n\n/** Context passed to `afterToolCall`. */\nexport interface AfterToolCallContext {\n\t/** The assistant message that requested the tool call. */\n\tassistantMessage: AssistantMessage;\n\t/** The raw tool call block from `assistantMessage.content`. */\n\ttoolCall: AgentToolCall;\n\t/** Validated tool arguments for the target tool schema. */\n\targs: unknown;\n\t/** The executed tool result before any `afterToolCall` overrides are applied. */\n\tresult: AgentToolResult<any>;\n\t/** Whether the executed tool result is currently treated as an error. */\n\tisError: boolean;\n\t/** Current agent context at the time the tool call is finalized. */\n\tcontext: AgentContext;\n}\n\n/** Context passed to `shouldStopAfterTurn`. */\nexport interface ShouldStopAfterTurnContext {\n\t/** The assistant message that completed the turn. */\n\tmessage: AssistantMessage;\n\t/** Tool result messages passed to the preceding `turn_end` event. */\n\ttoolResults: ToolResultMessage[];\n\t/** Current agent context after the turn's assistant message and tool results have been appended. */\n\tcontext: AgentContext;\n\t/** Messages that this loop invocation will return if it exits at this point. Prompt runs include the initial prompt messages; continuation runs do not include pre-existing context messages. */\n\tnewMessages: AgentMessage[];\n}\n\n/** Replacement runtime state used by the agent loop before starting another provider request. */\nexport interface AgentLoopTurnUpdate {\n\t/** Context for the next provider request. */\n\tcontext?: AgentContext;\n\t/** Model for the next provider request. */\n\tmodel?: Model<any>;\n\t/** Thinking level for the next provider request. */\n\tthinkingLevel?: ThinkingLevel;\n}\n\nexport interface PrepareNextTurnContext extends ShouldStopAfterTurnContext {}\n\nexport interface AgentLoopConfig extends SimpleStreamOptions {\n\tmodel: Model<any>;\n\n\t/**\n\t * Converts AgentMessage[] to LLM-compatible Message[] before each LLM call.\n\t *\n\t * Each AgentMessage must be converted to a UserMessage, AssistantMessage, or ToolResultMessage\n\t * that the LLM can understand. AgentMessages that cannot be converted (e.g., UI-only notifications,\n\t * status messages) should be filtered out.\n\t *\n\t * Contract: must not throw or reject. Return a safe fallback value instead.\n\t * Throwing interrupts the low-level agent loop without producing a normal event sequence.\n\t *\n\t * @example\n\t * ```typescript\n\t * convertToLlm: (messages) => messages.flatMap(m => {\n\t * if (m.role === \"custom\") {\n\t * // Convert custom message to user message\n\t * return [{ role: \"user\", content: m.content, timestamp: m.timestamp }];\n\t * }\n\t * if (m.role === \"notification\") {\n\t * // Filter out UI-only messages\n\t * return [];\n\t * }\n\t * // Pass through standard LLM messages\n\t * return [m];\n\t * })\n\t * ```\n\t */\n\tconvertToLlm: (messages: AgentMessage[]) => Message[] | Promise<Message[]>;\n\n\t/**\n\t * Optional transform applied to the context before `convertToLlm`.\n\t *\n\t * Use this for operations that work at the AgentMessage level:\n\t * - Context window management (pruning old messages)\n\t * - Injecting context from external sources\n\t *\n\t * Contract: must not throw or reject. Return the original messages or another\n\t * safe fallback value instead.\n\t *\n\t * @example\n\t * ```typescript\n\t * transformContext: async (messages) => {\n\t * if (estimateTokens(messages) > MAX_TOKENS) {\n\t * return pruneOldMessages(messages);\n\t * }\n\t * return messages;\n\t * }\n\t * ```\n\t */\n\ttransformContext?: (messages: AgentMessage[], signal?: AbortSignal) => Promise<AgentMessage[]>;\n\n\t/**\n\t * Resolves an API key dynamically for each LLM call.\n\t *\n\t * Useful for short-lived OAuth tokens (e.g., GitHub Copilot) that may expire\n\t * during long-running tool execution phases.\n\t *\n\t * Contract: must not throw or reject. Return undefined when no key is available.\n\t */\n\tgetApiKey?: (provider: string) => Promise<string | undefined> | string | undefined;\n\n\t/**\n\t * Called after each turn fully completes and `turn_end` has been emitted.\n\t *\n\t * If it returns true, the loop emits `agent_end` and exits before polling steering or follow-up queues,\n\t * without starting another LLM call. The current assistant response and any tool executions finish normally.\n\t *\n\t * Use this to request a graceful stop after the current turn, e.g. before context gets too full.\n\t *\n\t * Contract: must not throw or reject. Throwing interrupts the low-level agent loop without producing a normal event sequence.\n\t */\n\tshouldStopAfterTurn?: (context: ShouldStopAfterTurnContext) => boolean | Promise<boolean>;\n\n\t/**\n\t * Called after `turn_end` and before the loop decides whether another provider request should start.\n\t * Return replacement context/model/thinking state to affect the next turn in this run.\n\t * Return undefined to keep using the current context/config.\n\t */\n\tprepareNextTurn?: (\n\t\tcontext: PrepareNextTurnContext,\n\t) => AgentLoopTurnUpdate | undefined | Promise<AgentLoopTurnUpdate | undefined>;\n\n\t/**\n\t * Returns steering messages to inject into the conversation mid-run.\n\t *\n\t * Called after the current assistant turn finishes executing its tool calls, unless `shouldStopAfterTurn` exits first.\n\t * If messages are returned, they are added to the context before the next LLM call.\n\t * Tool calls from the current assistant message are not skipped.\n\t *\n\t * Use this for \"steering\" the agent while it's working.\n\t *\n\t * Contract: must not throw or reject. Return [] when no steering messages are available.\n\t */\n\tgetSteeringMessages?: () => Promise<AgentMessage[]>;\n\n\t/**\n\t * Returns follow-up messages to process after the agent would otherwise stop.\n\t *\n\t * Called when the agent has no more tool calls and no steering messages.\n\t * If messages are returned, they're added to the context and the agent\n\t * continues with another turn.\n\t *\n\t * Use this for follow-up messages that should wait until the agent finishes.\n\t *\n\t * Contract: must not throw or reject. Return [] when no follow-up messages are available.\n\t */\n\tgetFollowUpMessages?: () => Promise<AgentMessage[]>;\n\n\t/**\n\t * Tool execution mode.\n\t * - \"sequential\": execute tool calls one by one\n\t * - \"parallel\": preflight tool calls sequentially, then execute allowed tools concurrently;\n\t * emit `tool_execution_end` in tool completion order after each tool is finalized,\n\t * then emit tool-result message artifacts later in assistant source order\n\t *\n\t * Default: \"parallel\"\n\t */\n\ttoolExecution?: ToolExecutionMode;\n\n\t/**\n\t * Called before a tool is executed, after arguments have been validated.\n\t *\n\t * Return `{ block: true }` to prevent execution. The loop emits an error tool result instead.\n\t * The hook receives the agent abort signal and is responsible for honoring it.\n\t */\n\tbeforeToolCall?: (context: BeforeToolCallContext, signal?: AbortSignal) => Promise<BeforeToolCallResult | undefined>;\n\n\t/**\n\t * Called after a tool finishes executing, before `tool_execution_end` and tool-result message events are emitted.\n\t *\n\t * Return an `AfterToolCallResult` to override parts of the executed tool result:\n\t * - `content` replaces the full content array\n\t * - `details` replaces the full details payload\n\t * - `isError` replaces the error flag\n\t * - `terminate` replaces the early-termination hint\n\t *\n\t * Any omitted fields keep their original values. No deep merge is performed.\n\t * The hook receives the agent abort signal and is responsible for honoring it.\n\t */\n\tafterToolCall?: (context: AfterToolCallContext, signal?: AbortSignal) => Promise<AfterToolCallResult | undefined>;\n}\n\n/**\n * Thinking/reasoning level for models that support it.\n * Note: \"xhigh\" is only supported by selected model families. Use model thinking-level metadata\n * from omk-ai to detect support for a concrete model.\n */\nexport type ThinkingLevel = \"off\" | \"minimal\" | \"low\" | \"medium\" | \"high\" | \"xhigh\";\n\n/**\n * Extensible interface for custom app messages.\n * Apps can extend via declaration merging:\n *\n * @example\n * ```typescript\n * declare module \"@mariozechner/agent\" {\n * interface CustomAgentMessages {\n * artifact: ArtifactMessage;\n * notification: NotificationMessage;\n * }\n * }\n * ```\n */\nexport interface CustomAgentMessages {\n\t// Empty by default - apps extend via declaration merging\n}\n\n/**\n * AgentMessage: Union of LLM messages + custom messages.\n * This abstraction allows apps to add custom message types while maintaining\n * type safety and compatibility with the base LLM messages.\n */\nexport type AgentMessage = Message | CustomAgentMessages[keyof CustomAgentMessages];\n\n/**\n * Public agent state.\n *\n * `tools` and `messages` use accessor properties so implementations can copy\n * assigned arrays before storing them.\n */\nexport interface AgentState {\n\t/** System prompt sent with each model request. */\n\tsystemPrompt: string;\n\t/** Active model used for future turns. */\n\tmodel: Model<any>;\n\t/** Requested reasoning level for future turns. */\n\tthinkingLevel: ThinkingLevel;\n\t/** Available tools. Assigning a new array copies the top-level array. */\n\tset tools(tools: AgentTool<any>[]);\n\tget tools(): AgentTool<any>[];\n\t/** Conversation transcript. Assigning a new array copies the top-level array. */\n\tset messages(messages: AgentMessage[]);\n\tget messages(): AgentMessage[];\n\t/**\n\t * True while the agent is processing a prompt or continuation.\n\t *\n\t * This remains true until awaited `agent_end` listeners settle.\n\t */\n\treadonly isStreaming: boolean;\n\t/** Partial assistant message for the current streamed response, if any. */\n\treadonly streamingMessage?: AgentMessage;\n\t/** Tool call ids currently executing. */\n\treadonly pendingToolCalls: ReadonlySet<string>;\n\t/** Error message from the most recent failed or aborted assistant turn, if any. */\n\treadonly errorMessage?: string;\n}\n\n/** Final or partial result produced by a tool. */\nexport interface AgentToolResult<T> {\n\t/** Text or image content returned to the model. */\n\tcontent: (TextContent | ImageContent)[];\n\t/** Arbitrary structured details for logs or UI rendering. */\n\tdetails: T;\n\t/**\n\t * Hint that the agent should stop after the current tool batch.\n\t * Early termination only happens when every finalized tool result in the batch sets this to true.\n\t */\n\tterminate?: boolean;\n}\n\n/** Callback used by tools to stream partial execution updates. */\nexport type AgentToolUpdateCallback<T = any> = (partialResult: AgentToolResult<T>) => void;\n\n/** Tool definition used by the agent runtime. */\nexport interface AgentTool<TParameters extends TSchema = TSchema, TDetails = any> extends Tool<TParameters> {\n\t/** Human-readable label for UI display. */\n\tlabel: string;\n\t/**\n\t * Optional compatibility shim for raw tool-call arguments before schema validation.\n\t * Must return an object that matches `TParameters`.\n\t */\n\tprepareArguments?: (args: unknown) => Static<TParameters>;\n\t/** Execute the tool call. Throw on failure instead of encoding errors in `content`. */\n\texecute: (\n\t\ttoolCallId: string,\n\t\tparams: Static<TParameters>,\n\t\tsignal?: AbortSignal,\n\t\tonUpdate?: AgentToolUpdateCallback<TDetails>,\n\t) => Promise<AgentToolResult<TDetails>>;\n\t/**\n\t * Per-tool execution mode override.\n\t * - \"sequential\": this tool must execute one at a time with other tool calls.\n\t * - \"parallel\": this tool can execute concurrently with other tool calls.\n\t *\n\t * If omitted, the default execution mode applies.\n\t */\n\texecutionMode?: ToolExecutionMode;\n}\n\n/** Context snapshot passed into the low-level agent loop. */\nexport interface AgentContext {\n\t/** System prompt included with the request. */\n\tsystemPrompt: string;\n\t/** Transcript visible to the model. */\n\tmessages: AgentMessage[];\n\t/** Tools available for this run. */\n\ttools?: AgentTool<any>[];\n}\n\n/**\n * Events emitted by the Agent for UI updates.\n *\n * `agent_end` is the last event emitted for a run, but awaited `Agent.subscribe()`\n * listeners for that event are still part of run settlement. The agent becomes\n * idle only after those listeners finish.\n */\nexport type AgentEvent =\n\t// Agent lifecycle\n\t| { type: \"agent_start\" }\n\t| { type: \"agent_end\"; messages: AgentMessage[] }\n\t// Turn lifecycle - a turn is one assistant response + any tool calls/results\n\t| { type: \"turn_start\" }\n\t| { type: \"turn_end\"; message: AgentMessage; toolResults: ToolResultMessage[] }\n\t// Message lifecycle - emitted for user, assistant, and toolResult messages\n\t| { type: \"message_start\"; message: AgentMessage }\n\t// Only emitted for assistant messages during streaming\n\t| { type: \"message_update\"; message: AgentMessage; assistantMessageEvent: AssistantMessageEvent }\n\t| { type: \"message_end\"; message: AgentMessage }\n\t// Tool execution lifecycle\n\t| { type: \"tool_execution_start\"; toolCallId: string; toolName: string; args: any }\n\t| { type: \"tool_execution_update\"; toolCallId: string; toolName: string; args: any; partialResult: any }\n\t| { type: \"tool_execution_end\"; toolCallId: string; toolName: string; result: any; isError: boolean };\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n\tAssistantMessage,\n\tAssistantMessageEvent,\n\tImageContent,\n\tMessage,\n\tModel,\n\tSimpleStreamOptions,\n\tstreamSimple,\n\tTextContent,\n\tTool,\n\tToolResultMessage,\n} from \"omk-ai\";\nimport type { Static, TSchema } from \"typebox\";\n\n/**\n * Stream function used by the agent loop.\n *\n * Contract:\n * - Must not throw or return a rejected promise for request/model/runtime failures.\n * - Must return an AssistantMessageEventStream.\n * - Failures must be encoded in the returned stream via protocol events and a\n * final AssistantMessage with stopReason \"error\" or \"aborted\" and errorMessage.\n */\nexport type StreamFn = (\n\t...args: Parameters<typeof streamSimple>\n) => ReturnType<typeof streamSimple> | Promise<ReturnType<typeof streamSimple>>;\n\n/**\n * Configuration for how tool calls from a single assistant message are executed.\n *\n * - \"sequential\": each tool call is prepared, executed, and finalized before the next one starts.\n * - \"parallel\": tool calls are prepared sequentially, then allowed tools execute concurrently.\n * `tool_execution_end` is emitted in tool completion order after each tool is finalized,\n * while tool-result message artifacts are emitted later in assistant source order.\n */\nexport type ToolExecutionMode = \"sequential\" | \"parallel\";\n\n/**\n * Controls how many queued user messages are injected when the agent loop reaches a queue drain point.\n *\n * - \"all\": drain and inject every queued message at that point.\n * - \"one-at-a-time\": drain and inject only the oldest queued message, leaving the rest queued for later drain points.\n */\nexport type QueueMode = \"all\" | \"one-at-a-time\";\n\n/** A single tool call content block emitted by an assistant message. */\nexport type AgentToolCall = Extract<AssistantMessage[\"content\"][number], { type: \"toolCall\" }>;\n\n/**\n * Result returned from `beforeToolCall`.\n *\n * Returning `{ block: true }` prevents the tool from executing. The loop emits an error tool result instead.\n * `reason` becomes the text shown in that error result. If omitted, a default blocked message is used.\n */\nexport interface BeforeToolCallResult {\n\tblock?: boolean;\n\treason?: string;\n}\n\n/**\n * Partial override returned from `afterToolCall`.\n *\n * Merge semantics are field-by-field:\n * - `content`: if provided, replaces the tool result content array in full\n * - `details`: if provided, replaces the tool result details value in full\n * - `isError`: if provided, replaces the tool result error flag\n * - `terminate`: if provided, replaces the early-termination hint\n *\n * Omitted fields keep the original executed tool result values.\n * There is no deep merge for `content` or `details`.\n */\nexport interface AfterToolCallResult {\n\tcontent?: (TextContent | ImageContent)[];\n\tdetails?: unknown;\n\tisError?: boolean;\n\t/**\n\t * Hint that the agent should stop after the current tool batch.\n\t * Early termination only happens when every finalized tool result in the batch sets this to true.\n\t */\n\tterminate?: boolean;\n}\n\n/** Context passed to `beforeToolCall`. */\nexport interface BeforeToolCallContext {\n\t/** The assistant message that requested the tool call. */\n\tassistantMessage: AssistantMessage;\n\t/** The raw tool call block from `assistantMessage.content`. */\n\ttoolCall: AgentToolCall;\n\t/** Validated tool arguments for the target tool schema. */\n\targs: unknown;\n\t/** Current agent context at the time the tool call is prepared. */\n\tcontext: AgentContext;\n}\n\n/** Context passed to `afterToolCall`. */\nexport interface AfterToolCallContext {\n\t/** The assistant message that requested the tool call. */\n\tassistantMessage: AssistantMessage;\n\t/** The raw tool call block from `assistantMessage.content`. */\n\ttoolCall: AgentToolCall;\n\t/** Validated tool arguments for the target tool schema. */\n\targs: unknown;\n\t/** The executed tool result before any `afterToolCall` overrides are applied. */\n\tresult: AgentToolResult<any>;\n\t/** Whether the executed tool result is currently treated as an error. */\n\tisError: boolean;\n\t/** Current agent context at the time the tool call is finalized. */\n\tcontext: AgentContext;\n}\n\n/** Context passed to `shouldStopAfterTurn`. */\nexport interface ShouldStopAfterTurnContext {\n\t/** The assistant message that completed the turn. */\n\tmessage: AssistantMessage;\n\t/** Tool result messages passed to the preceding `turn_end` event. */\n\ttoolResults: ToolResultMessage[];\n\t/** Current agent context after the turn's assistant message and tool results have been appended. */\n\tcontext: AgentContext;\n\t/** Messages that this loop invocation will return if it exits at this point. Prompt runs include the initial prompt messages; continuation runs do not include pre-existing context messages. */\n\tnewMessages: AgentMessage[];\n}\n\n/** Replacement runtime state used by the agent loop before starting another provider request. */\nexport interface AgentLoopTurnUpdate {\n\t/** Context for the next provider request. */\n\tcontext?: AgentContext;\n\t/** Model for the next provider request. */\n\tmodel?: Model<any>;\n\t/** Thinking level for the next provider request. */\n\tthinkingLevel?: ThinkingLevel;\n}\n\nexport interface PrepareNextTurnContext extends ShouldStopAfterTurnContext {}\n\nexport interface AgentLoopConfig extends SimpleStreamOptions {\n\tmodel: Model<any>;\n\n\t/**\n\t * Converts AgentMessage[] to LLM-compatible Message[] before each LLM call.\n\t *\n\t * Each AgentMessage must be converted to a UserMessage, AssistantMessage, or ToolResultMessage\n\t * that the LLM can understand. AgentMessages that cannot be converted (e.g., UI-only notifications,\n\t * status messages) should be filtered out.\n\t *\n\t * Contract: must not throw or reject. Return a safe fallback value instead.\n\t * Throwing interrupts the low-level agent loop without producing a normal event sequence.\n\t *\n\t * @example\n\t * ```typescript\n\t * convertToLlm: (messages) => messages.flatMap(m => {\n\t * if (m.role === \"custom\") {\n\t * // Convert custom message to user message\n\t * return [{ role: \"user\", content: m.content, timestamp: m.timestamp }];\n\t * }\n\t * if (m.role === \"notification\") {\n\t * // Filter out UI-only messages\n\t * return [];\n\t * }\n\t * // Pass through standard LLM messages\n\t * return [m];\n\t * })\n\t * ```\n\t */\n\tconvertToLlm: (messages: AgentMessage[]) => Message[] | Promise<Message[]>;\n\n\t/**\n\t * Optional transform applied to the context before `convertToLlm`.\n\t *\n\t * Use this for operations that work at the AgentMessage level:\n\t * - Context window management (pruning old messages)\n\t * - Injecting context from external sources\n\t *\n\t * Contract: must not throw or reject. Return the original messages or another\n\t * safe fallback value instead.\n\t *\n\t * @example\n\t * ```typescript\n\t * transformContext: async (messages) => {\n\t * if (estimateTokens(messages) > MAX_TOKENS) {\n\t * return pruneOldMessages(messages);\n\t * }\n\t * return messages;\n\t * }\n\t * ```\n\t */\n\ttransformContext?: (messages: AgentMessage[], signal?: AbortSignal) => Promise<AgentMessage[]>;\n\n\t/**\n\t * Resolves an API key dynamically for each LLM call.\n\t *\n\t * Useful for short-lived OAuth tokens (e.g., GitHub Copilot) that may expire\n\t * during long-running tool execution phases.\n\t *\n\t * Contract: must not throw or reject. Return undefined when no key is available.\n\t */\n\tgetApiKey?: (provider: string) => Promise<string | undefined> | string | undefined;\n\n\t/**\n\t * Called after each turn fully completes and `turn_end` has been emitted.\n\t *\n\t * If it returns true, the loop emits `agent_end` and exits before polling steering or follow-up queues,\n\t * without starting another LLM call. The current assistant response and any tool executions finish normally.\n\t *\n\t * Use this to request a graceful stop after the current turn, e.g. before context gets too full.\n\t *\n\t * Contract: must not throw or reject. Throwing interrupts the low-level agent loop without producing a normal event sequence.\n\t */\n\tshouldStopAfterTurn?: (context: ShouldStopAfterTurnContext) => boolean | Promise<boolean>;\n\n\t/**\n\t * Called after `turn_end` and before the loop decides whether another provider request should start.\n\t * Return replacement context/model/thinking state to affect the next turn in this run.\n\t * Return undefined to keep using the current context/config.\n\t */\n\tprepareNextTurn?: (\n\t\tcontext: PrepareNextTurnContext,\n\t) => AgentLoopTurnUpdate | undefined | Promise<AgentLoopTurnUpdate | undefined>;\n\n\t/**\n\t * Returns steering messages to inject into the conversation mid-run.\n\t *\n\t * Called after the current assistant turn finishes executing its tool calls, unless `shouldStopAfterTurn` exits first.\n\t * If messages are returned, they are added to the context before the next LLM call.\n\t * Tool calls from the current assistant message are not skipped.\n\t *\n\t * Use this for \"steering\" the agent while it's working.\n\t *\n\t * Contract: must not throw or reject. Return [] when no steering messages are available.\n\t */\n\tgetSteeringMessages?: () => Promise<AgentMessage[]>;\n\n\t/**\n\t * Returns follow-up messages to process after the agent would otherwise stop.\n\t *\n\t * Called when the agent has no more tool calls and no steering messages.\n\t * If messages are returned, they're added to the context and the agent\n\t * continues with another turn.\n\t *\n\t * Use this for follow-up messages that should wait until the agent finishes.\n\t *\n\t * Contract: must not throw or reject. Return [] when no follow-up messages are available.\n\t */\n\tgetFollowUpMessages?: () => Promise<AgentMessage[]>;\n\n\t/**\n\t * Tool execution mode.\n\t * - \"sequential\": execute tool calls one by one\n\t * - \"parallel\": preflight tool calls sequentially, then execute allowed tools concurrently;\n\t * emit `tool_execution_end` in tool completion order after each tool is finalized,\n\t * then emit tool-result message artifacts later in assistant source order\n\t *\n\t * Default: \"parallel\"\n\t */\n\ttoolExecution?: ToolExecutionMode;\n\n\t/**\n\t * Called before a tool is executed, after arguments have been validated.\n\t *\n\t * Return `{ block: true }` to prevent execution. The loop emits an error tool result instead.\n\t * The hook receives the agent abort signal and is responsible for honoring it.\n\t */\n\tbeforeToolCall?: (context: BeforeToolCallContext, signal?: AbortSignal) => Promise<BeforeToolCallResult | undefined>;\n\n\t/**\n\t * Called after a tool finishes executing, before `tool_execution_end` and tool-result message events are emitted.\n\t *\n\t * Return an `AfterToolCallResult` to override parts of the executed tool result:\n\t * - `content` replaces the full content array\n\t * - `details` replaces the full details payload\n\t * - `isError` replaces the error flag\n\t * - `terminate` replaces the early-termination hint\n\t *\n\t * Any omitted fields keep their original values. No deep merge is performed.\n\t * The hook receives the agent abort signal and is responsible for honoring it.\n\t */\n\tafterToolCall?: (context: AfterToolCallContext, signal?: AbortSignal) => Promise<AfterToolCallResult | undefined>;\n}\n\n/**\n * Thinking/reasoning level for models that support it.\n * Note: \"xhigh\" and \"max\" are only supported by selected model families. Use model thinking-level\n * metadata from omk-ai to detect support for a concrete model.\n */\nexport type ThinkingLevel = \"off\" | \"minimal\" | \"low\" | \"medium\" | \"high\" | \"xhigh\" | \"max\";\n\n/**\n * Extensible interface for custom app messages.\n * Apps can extend via declaration merging:\n *\n * @example\n * ```typescript\n * declare module \"@mariozechner/agent\" {\n * interface CustomAgentMessages {\n * artifact: ArtifactMessage;\n * notification: NotificationMessage;\n * }\n * }\n * ```\n */\nexport interface CustomAgentMessages {\n\t// Empty by default - apps extend via declaration merging\n}\n\n/**\n * AgentMessage: Union of LLM messages + custom messages.\n * This abstraction allows apps to add custom message types while maintaining\n * type safety and compatibility with the base LLM messages.\n */\nexport type AgentMessage = Message | CustomAgentMessages[keyof CustomAgentMessages];\n\n/**\n * Public agent state.\n *\n * `tools` and `messages` use accessor properties so implementations can copy\n * assigned arrays before storing them.\n */\nexport interface AgentState {\n\t/** System prompt sent with each model request. */\n\tsystemPrompt: string;\n\t/** Active model used for future turns. */\n\tmodel: Model<any>;\n\t/** Requested reasoning level for future turns. */\n\tthinkingLevel: ThinkingLevel;\n\t/** Available tools. Assigning a new array copies the top-level array. */\n\tset tools(tools: AgentTool<any>[]);\n\tget tools(): AgentTool<any>[];\n\t/** Conversation transcript. Assigning a new array copies the top-level array. */\n\tset messages(messages: AgentMessage[]);\n\tget messages(): AgentMessage[];\n\t/**\n\t * True while the agent is processing a prompt or continuation.\n\t *\n\t * This remains true until awaited `agent_end` listeners settle.\n\t */\n\treadonly isStreaming: boolean;\n\t/** Partial assistant message for the current streamed response, if any. */\n\treadonly streamingMessage?: AgentMessage;\n\t/** Tool call ids currently executing. */\n\treadonly pendingToolCalls: ReadonlySet<string>;\n\t/** Error message from the most recent failed or aborted assistant turn, if any. */\n\treadonly errorMessage?: string;\n}\n\n/** Final or partial result produced by a tool. */\nexport interface AgentToolResult<T> {\n\t/** Text or image content returned to the model. */\n\tcontent: (TextContent | ImageContent)[];\n\t/** Arbitrary structured details for logs or UI rendering. */\n\tdetails: T;\n\t/**\n\t * Hint that the agent should stop after the current tool batch.\n\t * Early termination only happens when every finalized tool result in the batch sets this to true.\n\t */\n\tterminate?: boolean;\n}\n\n/** Callback used by tools to stream partial execution updates. */\nexport type AgentToolUpdateCallback<T = any> = (partialResult: AgentToolResult<T>) => void;\n\n/** Tool definition used by the agent runtime. */\nexport interface AgentTool<TParameters extends TSchema = TSchema, TDetails = any> extends Tool<TParameters> {\n\t/** Human-readable label for UI display. */\n\tlabel: string;\n\t/**\n\t * Optional compatibility shim for raw tool-call arguments before schema validation.\n\t * Must return an object that matches `TParameters`.\n\t */\n\tprepareArguments?: (args: unknown) => Static<TParameters>;\n\t/** Execute the tool call. Throw on failure instead of encoding errors in `content`. */\n\texecute: (\n\t\ttoolCallId: string,\n\t\tparams: Static<TParameters>,\n\t\tsignal?: AbortSignal,\n\t\tonUpdate?: AgentToolUpdateCallback<TDetails>,\n\t) => Promise<AgentToolResult<TDetails>>;\n\t/**\n\t * Per-tool execution mode override.\n\t * - \"sequential\": this tool must execute one at a time with other tool calls.\n\t * - \"parallel\": this tool can execute concurrently with other tool calls.\n\t *\n\t * If omitted, the default execution mode applies.\n\t */\n\texecutionMode?: ToolExecutionMode;\n}\n\n/** Context snapshot passed into the low-level agent loop. */\nexport interface AgentContext {\n\t/** System prompt included with the request. */\n\tsystemPrompt: string;\n\t/** Transcript visible to the model. */\n\tmessages: AgentMessage[];\n\t/** Tools available for this run. */\n\ttools?: AgentTool<any>[];\n}\n\n/**\n * Events emitted by the Agent for UI updates.\n *\n * `agent_end` is the last event emitted for a run, but awaited `Agent.subscribe()`\n * listeners for that event are still part of run settlement. The agent becomes\n * idle only after those listeners finish.\n */\nexport type AgentEvent =\n\t// Agent lifecycle\n\t| { type: \"agent_start\" }\n\t| { type: \"agent_end\"; messages: AgentMessage[] }\n\t// Turn lifecycle - a turn is one assistant response + any tool calls/results\n\t| { type: \"turn_start\" }\n\t| { type: \"turn_end\"; message: AgentMessage; toolResults: ToolResultMessage[] }\n\t// Message lifecycle - emitted for user, assistant, and toolResult messages\n\t| { type: \"message_start\"; message: AgentMessage }\n\t// Only emitted for assistant messages during streaming\n\t| { type: \"message_update\"; message: AgentMessage; assistantMessageEvent: AssistantMessageEvent }\n\t| { type: \"message_end\"; message: AgentMessage }\n\t// Tool execution lifecycle\n\t| { type: \"tool_execution_start\"; toolCallId: string; toolName: string; args: any }\n\t| { type: \"tool_execution_update\"; toolCallId: string; toolName: string; args: any; partialResult: any }\n\t| { type: \"tool_execution_end\"; toolCallId: string; toolName: string; result: any; isError: boolean };\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omk-agent-core",
3
- "version": "0.80.8",
3
+ "version": "0.90.3",
4
4
  "description": "General-purpose agent with transport abstraction, state management, and attachment support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -29,7 +29,7 @@
29
29
  "prepublishOnly": "npm run clean && npm run build"
30
30
  },
31
31
  "dependencies": {
32
- "omk-ai": "^0.80.8",
32
+ "omk-ai": "^0.90.3",
33
33
  "ignore": "7.0.5",
34
34
  "typebox": "1.1.38",
35
35
  "yaml": "2.9.0"