{"version":3,"file":"deferred-tools-BD4g5QUx.mjs","names":[],"sources":["../node_modules/.pnpm/@earendil-works+pi-ai@0.84.1_ws@8.21.3_zod@4.4.3/node_modules/@earendil-works/pi-ai/dist/utils/deferred-tools.js"],"sourcesContent":["const identityToolName = (name) => name;\n/** Split current tools into prefix and transcript-loaded definitions. */\nexport function splitDeferredTools(context, enabled, normalizeName = identityToolName) {\n    const uniqueTools = new Map();\n    for (const tool of context.tools ?? [])\n        uniqueTools.set(normalizeName(tool.name), tool);\n    if (!enabled)\n        return { immediate: [...uniqueTools.values()], deferred: new Map() };\n    const deferredNames = new Set();\n    const usedNames = new Set();\n    for (const message of context.messages) {\n        if (message.role === \"assistant\") {\n            for (const block of message.content) {\n                if (block.type === \"toolCall\")\n                    usedNames.add(normalizeName(block.name));\n            }\n        }\n        else if (message.role === \"toolResult\") {\n            for (const name of message.addedToolNames ?? []) {\n                const normalizedName = normalizeName(name);\n                if (!usedNames.has(normalizedName))\n                    deferredNames.add(normalizedName);\n            }\n        }\n    }\n    const immediate = [];\n    const deferred = new Map();\n    for (const [name, tool] of uniqueTools) {\n        if (deferredNames.has(name))\n            deferred.set(name, tool);\n        else\n            immediate.push(tool);\n    }\n    return { immediate, deferred };\n}\n//# sourceMappingURL=deferred-tools.js.map"],"x_google_ignoreList":[0],"mappings":";;AAAA,MAAM,oBAAoB,SAAS;;AAEnC,SAAgB,mBAAmB,SAAS,SAAS,gBAAgB,kBAAkB;CACnF,MAAM,8BAAc,IAAI,IAAI;CAC5B,KAAK,MAAM,QAAQ,QAAQ,SAAS,CAAC,GACjC,YAAY,IAAI,cAAc,KAAK,IAAI,GAAG,IAAI;CAClD,IAAI,CAAC,SACD,OAAO;EAAE,WAAW,CAAC,GAAG,YAAY,OAAO,CAAC;EAAG,0BAAU,IAAI,IAAI;CAAE;CACvE,MAAM,gCAAgB,IAAI,IAAI;CAC9B,MAAM,4BAAY,IAAI,IAAI;CAC1B,KAAK,MAAM,WAAW,QAAQ,UAC1B,IAAI,QAAQ,SAAS,aACZ;OAAA,MAAM,SAAS,QAAQ,SACxB,IAAI,MAAM,SAAS,YACf,UAAU,IAAI,cAAc,MAAM,IAAI,CAAC;CAAA,OAG9C,IAAI,QAAQ,SAAS,cACtB,KAAK,MAAM,QAAQ,QAAQ,kBAAkB,CAAC,GAAG;EAC7C,MAAM,iBAAiB,cAAc,IAAI;EACzC,IAAI,CAAC,UAAU,IAAI,cAAc,GAC7B,cAAc,IAAI,cAAc;CACxC;CAGR,MAAM,YAAY,CAAC;CACnB,MAAM,2BAAW,IAAI,IAAI;CACzB,KAAK,MAAM,CAAC,MAAM,SAAS,aACvB,IAAI,cAAc,IAAI,IAAI,GACtB,SAAS,IAAI,MAAM,IAAI;MAEvB,UAAU,KAAK,IAAI;CAE3B,OAAO;EAAE;EAAW;CAAS;AACjC"}