{"version":3,"file":"wait-tool.d.ts","sourceRoot":"","sources":["../../../../src/runs/background/wait-tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAkB,MAAM,2BAA2B,CAAC;AAE9E,OAAO,KAAK,EAAW,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAEvE,wBAAgB,gBAAgB,CAC/B,EAAE,EAAE,YAAY,EAChB,KAAK,EAAE,aAAa,EACpB,OAAO,UAAkC,EACzC,aAAa,CAAC,EAAE,IAAI,CAAC,uBAAuB,EAAE,KAAK,CAAC,GAClD,IAAI,CA2BN","sourcesContent":["import type { ExtensionAPI, ToolDefinition } from \"@lpb-work/pi-coding-agent\";\nimport { SubagentWaitParams } from \"../../extension/schemas.ts\";\nimport type { Details, SubagentState } from \"../../shared/types.ts\";\nimport { resolveWaitToolConfig, waitForSubagents } from \"./subagent-wait.ts\";\nimport type { WaitSubscriptionManager } from \"./wait-subscriptions.ts\";\n\nexport function registerWaitTool(\n\tpi: ExtensionAPI,\n\tstate: SubagentState,\n\tenabled = resolveWaitToolConfig().enabled,\n\tsubscriptions?: Pick<WaitSubscriptionManager, \"arm\">,\n): void {\n\tconst tool: ToolDefinition<typeof SubagentWaitParams, Details> = {\n\t\tname: \"subagent_wait\",\n\t\tlabel: \"Subagent Wait\",\n\t\tdescription: `Block until background work owned by this session changes, then return.\n\nIn an interactive chat, do not call this merely to wait: return control to the user and let Pi wake the session on completion. Override that default and call it when the current request is run-to-completion — for example, the user asked you to report results back before continuing or a skill cannot return before its work finishes. Headless runs auto-drain current-session work at agent_end; call this when the current turn must receive results before it ends.\n\n• { } — return when the first initially active async run or registered provider item finishes, or when a subagent needs attention.\n• { all: true } — wait for every async run and provider item that was active when the call began.\n• { id: \"...\" } — wait for one async or remembered detached foreground subagent run (id or prefix).\n• { id: \"...\", nonBlocking: true } — resolve the prefix once, persist an exact-run wake subscription, and return immediately. The originating interactive session wakes on completion, failure, attention, reconciliation failure, or timeout.\n• { timeoutMs: 600000 } — stop waiting after N ms; active work keeps running.\n\nNon-blocking subscriptions are visible in subagent status and differ from disabling waitTool: waitTool.enabled=false returns immediately without registering any future wake. Provider jobs are session-scoped and identified exactly, so replacing one job with another cannot hide a completion. Provider extensions must be explicitly loaded in this process. In a child agent, keep \\`subagent_wait\\` in the child tool allowlist and load each provider through the agent's extensions or subagentOnlyExtensions; this tool never loads providers or grants tools itself.${enabled ? \"\" : \"\\n\\nConfigured behavior: subagent_wait is disabled by config.waitTool or PI_SUBAGENT_WAIT_TOOL_ENABLED and returns immediately without blocking.\"}`,\n\t\tparameters: SubagentWaitParams,\n\t\texecute(_id, params, signal, onUpdate, ctx) {\n\t\t\treturn waitForSubagents(params, signal, {\n\t\t\t\tstate,\n\t\t\t\tevents: pi.events,\n\t\t\t\tenabled,\n\t\t\t\tonUpdate,\n\t\t\t\t...(subscriptions && ctx?.hasUI ? { subscribe: (input) => subscriptions.arm(input) } : {}),\n\t\t\t});\n\t\t},\n\t};\n\tpi.registerTool(tool);\n}\n"]}