{"version":3,"file":"control-notices.d.ts","sourceRoot":"","sources":["../../../src/extension/control-notices.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEtE,eAAO,MAAM,6BAA6B,4BAA4B,CAAC;AAEvE,MAAM,WAAW,6BAA6B;IAC7C,KAAK,EAAE,YAAY,CAAC;IACpB,MAAM,CAAC,EAAE,YAAY,GAAG,OAAO,GAAG,MAAM,CAAC;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,6BAA6B,GAAG,MAAM,GAAG,SAAS,CAE9F;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,6BAA6B,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAE5G;AAuBD,wBAAgB,2BAA2B,CAAC,KAAK,EAAE;IAClD,EAAE,EAAE,IAAI,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;IACtC,KAAK,EAAE,aAAa,CAAC;IACrB,qBAAqB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACnC,OAAO,EAAE,6BAA6B,CAAC;CACvC,GAAG,IAAI,CASP","sourcesContent":["import type { ExtensionAPI } from \"@lpb-work/pi-coding-agent\";\nimport { controlNotificationKey, formatControlNoticeMessage } from \"../runs/shared/subagent-control.ts\";\nimport type { ControlEvent, SubagentState } from \"../shared/types.ts\";\n\nexport const SUBAGENT_CONTROL_MESSAGE_TYPE = \"subagent_control_notice\";\n\nexport interface SubagentControlMessageDetails {\n\tevent: ControlEvent;\n\tsource?: \"foreground\" | \"async\" | \"goal\";\n\tasyncDir?: string;\n\tchildIntercomTarget?: string;\n\tnoticeText?: string;\n}\n\nexport function controlNoticeTarget(details: SubagentControlMessageDetails): string | undefined {\n\treturn details.childIntercomTarget;\n}\n\nexport function formatSubagentControlNotice(details: SubagentControlMessageDetails, content?: string): string {\n\treturn details.noticeText ?? content ?? formatControlNoticeMessage(details.event, controlNoticeTarget(details));\n}\n\nfunction deliverControlNotice(input: {\n\tpi: Pick<ExtensionAPI, \"sendMessage\">;\n\tvisibleControlNotices: Set<string>;\n\tdetails: SubagentControlMessageDetails;\n}): void {\n\tconst childIntercomTarget = controlNoticeTarget(input.details);\n\tconst key = controlNotificationKey(input.details.event, childIntercomTarget);\n\tif (input.visibleControlNotices.has(key)) return;\n\tinput.visibleControlNotices.add(key);\n\tconst noticeText = input.details.noticeText ?? formatControlNoticeMessage(input.details.event, childIntercomTarget);\n\tinput.pi.sendMessage(\n\t\t{\n\t\t\tcustomType: SUBAGENT_CONTROL_MESSAGE_TYPE,\n\t\t\tcontent: noticeText,\n\t\t\tdisplay: true,\n\t\t\tdetails: { ...input.details, childIntercomTarget, noticeText },\n\t\t},\n\t\t{ triggerTurn: input.details.source === \"async\" },\n\t);\n}\n\nexport function handleSubagentControlNotice(input: {\n\tpi: Pick<ExtensionAPI, \"sendMessage\">;\n\tstate: SubagentState;\n\tvisibleControlNotices: Set<string>;\n\tdetails: SubagentControlMessageDetails;\n}): void {\n\tif (!input.details?.event || input.details.event.type === \"active_long_running\") return;\n\tif (input.details.source === \"foreground\") {\n\t\t// A foreground tool blocks Pi from displaying this message. The run can\n\t\t// finish before Pi flushes it, and queued messages cannot be withdrawn.\n\t\t// Foreground control remains available through the live tool and fleet state.\n\t\treturn;\n\t}\n\tdeliverControlNotice(input);\n}\n"]}