@agimon-ai/doompi-notification 0.0.1-alpha.4 → 0.0.1-alpha.41

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.
Files changed (41) hide show
  1. package/README.md +56 -13
  2. package/dist/adapters/notificationRouter.cjs +2 -0
  3. package/dist/adapters/notificationRouter.cjs.map +1 -0
  4. package/dist/adapters/notificationRouter.mjs +2 -0
  5. package/dist/adapters/notificationRouter.mjs.map +1 -0
  6. package/dist/adapters/pi/extension.cjs +1 -1
  7. package/dist/adapters/pi/extension.cjs.map +1 -1
  8. package/dist/adapters/pi/extension.d.cts +3 -3
  9. package/dist/adapters/pi/extension.d.cts.map +1 -1
  10. package/dist/adapters/pi/extension.d.mts +3 -3
  11. package/dist/adapters/pi/extension.d.mts.map +1 -1
  12. package/dist/adapters/pi/extension.mjs +1 -1
  13. package/dist/adapters/pi/extension.mjs.map +1 -1
  14. package/dist/adapters/shellTitleController.cjs +1 -1
  15. package/dist/adapters/shellTitleController.cjs.map +1 -1
  16. package/dist/adapters/shellTitleController.d.cts +2 -3
  17. package/dist/adapters/shellTitleController.d.cts.map +1 -1
  18. package/dist/adapters/shellTitleController.d.mts +2 -3
  19. package/dist/adapters/shellTitleController.d.mts.map +1 -1
  20. package/dist/adapters/shellTitleController.mjs +1 -1
  21. package/dist/adapters/shellTitleController.mjs.map +1 -1
  22. package/dist/adapters/systemNotification.d.cts +1 -2
  23. package/dist/adapters/systemNotification.d.cts.map +1 -1
  24. package/dist/adapters/systemNotification.d.mts +1 -2
  25. package/dist/adapters/systemNotification.d.mts.map +1 -1
  26. package/dist/index.cjs +1 -1
  27. package/dist/index.mjs +1 -1
  28. package/dist/services/notificationPolicy.d.cts +6 -7
  29. package/dist/services/notificationPolicy.d.cts.map +1 -1
  30. package/dist/services/notificationPolicy.d.mts +6 -7
  31. package/dist/services/notificationPolicy.d.mts.map +1 -1
  32. package/dist/services/notificationText.d.cts +6 -7
  33. package/dist/services/notificationText.d.cts.map +1 -1
  34. package/dist/services/notificationText.d.mts +6 -7
  35. package/dist/services/notificationText.d.mts.map +1 -1
  36. package/dist/types/notifications.d.cts +5 -6
  37. package/dist/types/notifications.d.cts.map +1 -1
  38. package/dist/types/notifications.d.mts +5 -6
  39. package/dist/types/notifications.d.mts.map +1 -1
  40. package/llms.txt +2 -2
  41. package/package.json +19 -11
package/README.md CHANGED
@@ -1,22 +1,65 @@
1
1
  # @agimon-ai/doompi-notification
2
2
 
3
- Desktop notifications and an animated shell-tab title for
3
+ System and browser notifications, plus an animated shell-tab title, for
4
4
  [DoomPi](https://www.npmjs.com/package/@agimon-ai/doompi) sessions.
5
5
 
6
- Long agent runs are worth walking away from. This package makes that safe: the terminal tab says
7
- what the session is doing at a glance, and the desktop says when the agent has stopped and why.
6
+ Long agent runs are worth walking away from. This package owns the shared `doom/notification` service,
7
+ routes each request for the active session, and announces when the agent needs attention.
8
8
 
9
9
  ## What it does
10
10
 
11
- | Surface | Behaviour |
12
- | ---------------- | ----------------------------------------------------------------------------------------------------- |
13
- | Shell tab title | `π - <session or first prompt> - <repository>`, with a braille spinner while the agent works |
14
- | Desktop, mid-run | one notification per dialog the agent opens on its own initiative, and per `ask_user_question` prompt |
15
- | Desktop, at rest | one notification when a run settles with nothing queued behind it |
11
+ | Surface | Behavior |
12
+ | ---------------- | -------------------------------------------------------------------------------------------- |
13
+ | Shell tab title | `π - <session or first prompt> - <repository>`, with a braille spinner while the agent works |
14
+ | Notification API | caller-authored notices through the shared `doom/notification` Cordis service |
15
+ | Mid-run | one notification for each agent-initiated dialog and each `ask_user_question` prompt |
16
+ | At rest | one notification when a run settles with nothing queued behind it |
16
17
 
17
- Notifications go to `cmux notify` first, because it routes them back to the window the session
18
- lives in. On macOS a missing `cmux` falls back to `osascript`. Any other host stays silent rather
19
- than failing the turn.
18
+ In an interactive terminal session, requests use `cmux notify` first because it routes them back to
19
+ the session window. On macOS, a missing `cmux` falls back to `osascript`. In RPC mode, requests become
20
+ versioned `doom-notification` session entries for a live client such as `doompi-web`. An RPC append
21
+ failure stays silent and never falls back to a host notifier. Hosts without a supported notifier also
22
+ stay silent.
23
+
24
+ ## Service usage
25
+
26
+ Callers should discover the optional service through Cordis and request delivery without depending on
27
+ a particular host:
28
+
29
+ ```ts
30
+ import {
31
+ DOOM_NOTIFICATION_SERVICE,
32
+ readDoomNotificationService,
33
+ } from '@agimon-ai/doompi-extension-contracts/notification';
34
+
35
+ ctx.inject([DOOM_NOTIFICATION_SERVICE], (notificationContext) => {
36
+ void readDoomNotificationService(notificationContext)?.request({
37
+ body: 'Deployment needs approval',
38
+ level: 'warning',
39
+ });
40
+ });
41
+ ```
42
+
43
+ `body` is required. `title`, `subtitle`, and `level` are optional, and `level` accepts `info`,
44
+ `warning`, or `error`. The router defaults the title to `Pi`, the subtitle to the session name or
45
+ working-directory basename, and the level to `info`. Invalid requests, missing active sessions,
46
+ unavailable providers, and delivery failures are silent so notifications cannot fail an agent turn.
47
+
48
+ The package also wraps Pi's broad `ui.notify(message, level)` API while active, so existing extensions
49
+ use the same route without changing their calls. If this package is muted or the process is a detached
50
+ subagent child, it does not install that wrapper and Pi's original `ui.notify` behavior remains.
51
+
52
+ ## Browser delivery
53
+
54
+ `doompi-web` shows full notification text only for entries received by a currently open page. Every connected
55
+ page receives live notification entries for every attached session, not only the focused session. Permission
56
+ is requested only from an explicit settings action.
57
+
58
+ A paired installed PWA may also opt into live Web Push while closed. That payload is fixed generic copy with
59
+ `TTL: 0`; it contains no session, prompt, response, or file data. The host keeps subscriptions only in memory,
60
+ so there is no durable database, outbox, replay, or delivery of historical entries. The open app re-registers
61
+ a browser-held subscription after a host restart. Device revocation or expiry, remote shutdown, browser
62
+ disable, and expired provider endpoints remove the live subscription.
20
63
 
21
64
  ## The shell title
22
65
 
@@ -29,8 +72,8 @@ escape sequences never end up in machine-read output.
29
72
 
30
73
  ## Quiet by design
31
74
 
32
- - A detached subagent (`PI_SUBAGENT_CHILD`) registers nothing. It shares its parent's terminal and
33
- desktop, and a second voice reporting the same run is noise.
75
+ - A detached subagent (`PI_SUBAGENT_CHILD`) does not register this package's service or wrappers. It
76
+ shares its parent's terminal and desktop, and a second voice reporting the same run is noise.
34
77
  - Dialogs only notify while the agent holds the turn. A dialog the user opened is already in front
35
78
  of them.
36
79
  - An `ask_user_question` prompt notifies from its own event, and the dialog it then opens stays
@@ -0,0 +1,2 @@
1
+ const e=require("../_virtual/_rolldown/runtime.cjs"),t=require("./systemNotification.cjs");let n=require("@agimon-ai/doompi-extension-contracts/notification"),r=require("node:path");r=e.__toESM(r,1);function i({generation:e,pi:i,context:a}){return Object.freeze({generation:e,async request(e){let o=a();if(o)try{let a=(0,n.normalizeDoomNotificationRequest)(e);if(!a)return;let s=(0,n.createDoomNotificationEntryData)({title:a.title??`Pi`,subtitle:a.subtitle??i.getSessionName()??r.default.basename(o.cwd),body:a.body,level:a.level??`info`});if(!s)return;if(o.mode===`rpc`){i.appendEntry(n.DOOM_NOTIFICATION_ENTRY_TYPE,s);return}await t.sendSystemNotification(i,s)}catch{}}})}exports.createDoomNotificationRouter=i;
2
+ //# sourceMappingURL=notificationRouter.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notificationRouter.cjs","names":["normalizeDoomNotificationRequest","createDoomNotificationEntryData","path","DOOM_NOTIFICATION_ENTRY_TYPE","sendSystemNotification"],"sources":["../../src/adapters/notificationRouter.ts"],"sourcesContent":["import path from 'node:path';\nimport {\n createDoomNotificationEntryData,\n DOOM_NOTIFICATION_ENTRY_TYPE,\n type DoomNotificationRequest,\n type DoomNotificationService,\n normalizeDoomNotificationRequest,\n} from '@agimon-ai/doompi-extension-contracts/notification';\nimport type { ExtensionAPI, ExtensionContext } from '@earendil-works/pi-coding-agent';\nimport { sendSystemNotification } from './systemNotification.ts';\n\nconst DEFAULT_TITLE = 'Pi';\n\nexport interface DoomNotificationRouterOptions {\n readonly generation: string;\n readonly pi: ExtensionAPI;\n readonly context: () => ExtensionContext | undefined;\n}\n\n/**\n * Creates the shared notification router for one extension runtime.\n *\n * A missing session, invalid request, or delivery failure is an intentional\n * silent outcome because notification delivery must never fail the active turn.\n * RPC delivery never falls back to a host notifier after an append failure.\n */\nexport function createDoomNotificationRouter({\n generation,\n pi,\n context: readContext,\n}: DoomNotificationRouterOptions): DoomNotificationService {\n return Object.freeze({\n generation,\n async request(request: DoomNotificationRequest): Promise<void> {\n const context = readContext();\n if (!context) return;\n\n try {\n const normalized = normalizeDoomNotificationRequest(request);\n if (!normalized) return;\n const data = createDoomNotificationEntryData({\n title: normalized.title ?? DEFAULT_TITLE,\n subtitle: normalized.subtitle ?? pi.getSessionName() ?? path.basename(context.cwd),\n body: normalized.body,\n level: normalized.level ?? 'info',\n });\n if (!data) return;\n\n if (context.mode === 'rpc') {\n pi.appendEntry(DOOM_NOTIFICATION_ENTRY_TYPE, data);\n return;\n }\n await sendSystemNotification(pi, data);\n } catch (error) {\n // Best-effort delivery deliberately ends here. In particular, an RPC\n // append failure must not leak the notification through the host OS.\n void error;\n }\n },\n });\n}\n"],"mappings":"uMA0BA,SAAgB,EAA6B,CAC3C,aACA,KACA,QAAS,GACgD,CACzD,OAAO,OAAO,OAAO,CACnB,aACA,MAAM,QAAQ,EAAiD,CAC7D,IAAM,EAAU,EAAY,EACvB,KAEL,GAAI,CACF,IAAM,GAAA,EAAaA,EAAAA,iCAAAA,CAAiC,CAAO,EAC3D,GAAI,CAAC,EAAY,OACjB,IAAM,GAAA,EAAOC,EAAAA,gCAAAA,CAAgC,CAC3C,MAAO,EAAW,OAAS,KAC3B,SAAU,EAAW,UAAY,EAAG,eAAe,GAAKC,EAAAA,QAAK,SAAS,EAAQ,GAAG,EACjF,KAAM,EAAW,KACjB,MAAO,EAAW,OAAS,MAC7B,CAAC,EACD,GAAI,CAAC,EAAM,OAEX,GAAI,EAAQ,OAAS,MAAO,CAC1B,EAAG,YAAYC,EAAAA,6BAA8B,CAAI,EACjD,MACF,CACA,MAAMC,EAAAA,uBAAuB,EAAI,CAAI,CACvC,MAAgB,CAIhB,CACF,CACF,CAAC,CACH"}
@@ -0,0 +1,2 @@
1
+ import{sendSystemNotification as e}from"./systemNotification.mjs";import{DOOM_NOTIFICATION_ENTRY_TYPE as t,createDoomNotificationEntryData as n,normalizeDoomNotificationRequest as r}from"@agimon-ai/doompi-extension-contracts/notification";import i from"node:path";function a({generation:a,pi:o,context:s}){return Object.freeze({generation:a,async request(a){let c=s();if(c)try{let s=r(a);if(!s)return;let l=n({title:s.title??`Pi`,subtitle:s.subtitle??o.getSessionName()??i.basename(c.cwd),body:s.body,level:s.level??`info`});if(!l)return;if(c.mode===`rpc`){o.appendEntry(t,l);return}await e(o,l)}catch{}}})}export{a as createDoomNotificationRouter};
2
+ //# sourceMappingURL=notificationRouter.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notificationRouter.mjs","names":[],"sources":["../../src/adapters/notificationRouter.ts"],"sourcesContent":["import path from 'node:path';\nimport {\n createDoomNotificationEntryData,\n DOOM_NOTIFICATION_ENTRY_TYPE,\n type DoomNotificationRequest,\n type DoomNotificationService,\n normalizeDoomNotificationRequest,\n} from '@agimon-ai/doompi-extension-contracts/notification';\nimport type { ExtensionAPI, ExtensionContext } from '@earendil-works/pi-coding-agent';\nimport { sendSystemNotification } from './systemNotification.ts';\n\nconst DEFAULT_TITLE = 'Pi';\n\nexport interface DoomNotificationRouterOptions {\n readonly generation: string;\n readonly pi: ExtensionAPI;\n readonly context: () => ExtensionContext | undefined;\n}\n\n/**\n * Creates the shared notification router for one extension runtime.\n *\n * A missing session, invalid request, or delivery failure is an intentional\n * silent outcome because notification delivery must never fail the active turn.\n * RPC delivery never falls back to a host notifier after an append failure.\n */\nexport function createDoomNotificationRouter({\n generation,\n pi,\n context: readContext,\n}: DoomNotificationRouterOptions): DoomNotificationService {\n return Object.freeze({\n generation,\n async request(request: DoomNotificationRequest): Promise<void> {\n const context = readContext();\n if (!context) return;\n\n try {\n const normalized = normalizeDoomNotificationRequest(request);\n if (!normalized) return;\n const data = createDoomNotificationEntryData({\n title: normalized.title ?? DEFAULT_TITLE,\n subtitle: normalized.subtitle ?? pi.getSessionName() ?? path.basename(context.cwd),\n body: normalized.body,\n level: normalized.level ?? 'info',\n });\n if (!data) return;\n\n if (context.mode === 'rpc') {\n pi.appendEntry(DOOM_NOTIFICATION_ENTRY_TYPE, data);\n return;\n }\n await sendSystemNotification(pi, data);\n } catch (error) {\n // Best-effort delivery deliberately ends here. In particular, an RPC\n // append failure must not leak the notification through the host OS.\n void error;\n }\n },\n });\n}\n"],"mappings":"wQA0BA,SAAgB,EAA6B,CAC3C,aACA,KACA,QAAS,GACgD,CACzD,OAAO,OAAO,OAAO,CACnB,aACA,MAAM,QAAQ,EAAiD,CAC7D,IAAM,EAAU,EAAY,EACvB,KAEL,GAAI,CACF,IAAM,EAAa,EAAiC,CAAO,EAC3D,GAAI,CAAC,EAAY,OACjB,IAAM,EAAO,EAAgC,CAC3C,MAAO,EAAW,OAAS,KAC3B,SAAU,EAAW,UAAY,EAAG,eAAe,GAAK,EAAK,SAAS,EAAQ,GAAG,EACjF,KAAM,EAAW,KACjB,MAAO,EAAW,OAAS,MAC7B,CAAC,EACD,GAAI,CAAC,EAAM,OAEX,GAAI,EAAQ,OAAS,MAAO,CAC1B,EAAG,YAAY,EAA8B,CAAI,EACjD,MACF,CACA,MAAM,EAAuB,EAAI,CAAI,CACvC,MAAgB,CAIhB,CACF,CACF,CAAC,CACH"}
@@ -1,2 +1,2 @@
1
- const e=require("../../services/notificationPolicy.cjs"),t=require("../../services/notificationText.cjs"),n=require("../shellTitleController.cjs"),r=require("../systemNotification.cjs");let i=require("@agimon-ai/doompi-extension-contracts/ask-user"),a=require("@agimon-ai/doompi-extension-contracts/child-process"),o=require("@agimon-ai/doompi-extension-contracts/cordis-host");const s=`@agimon-ai/doompi-notification`;function c(e,t){return e[t]}function l(e,t,n){let r=c(e,`confirm`),i=(i,a,o)=>(t()&&n(`${i}: ${a}`),r.call(e,i,a,o));e.confirm=i;let a=c(e,`select`),o=(r,i,o)=>(t()&&n(r),a.call(e,r,i,o));e.select=o;let s=c(e,`input`),l=(r,i,a)=>(t()&&n(r),s.call(e,r,i,a));e.input=l;let u=c(e,`editor`),d=(r,i)=>(t()&&n(r),u.call(e,r,i));return e.editor=d,()=>{e.confirm===i&&(e.confirm=r),e.select===o&&(e.select=a),e.input===l&&(e.input=s),e.editor===d&&(e.editor=u)}}function u(a,{pi:o,options:c}){a.effect(function*(){let s=c.titleController??n.createWorkerTitleController(),u=new Map,d=!0,f=!1,p=!1,m,h,g=e=>t.shellTabTitle({cwd:e,sessionName:o.getSessionName(),prompt:m}),_=t=>{if(!(!d||!e.supportsShellTitle(t)))return h={cwd:t.cwd,write:e=>t.ui.setTitle(e)},h},v=e=>{d&&r.sendSystemNotification(o,t.attentionNotification(e))};yield a.on(i.DOOM_ASK_USER_PROMPT_EVENT,t=>{v(e.askUserPromptBody(t.questions))}),yield a.on(i.DOOM_ASK_USER_BLOCKED_EVENT,e=>{p=e.active}),yield()=>{h&&s.dispose(g(h.cwd),h.write),h=void 0},yield()=>{for(let e of u.values())e();u.clear()},yield()=>{d=!1,f=!1,p=!1},o.on(`input`,(e,n)=>{if(!d||m||e.source===`extension`)return;m=t.promptTitle(e.text);let r=m?_(n):void 0;r&&s.set(g(r.cwd),r.write)}),o.on(`session_start`,(t,n)=>{!d||u.has(n.ui)||u.set(n.ui,l(n.ui,()=>d&&e.warrantsAttentionNotification({agentRunning:f,askUserBlocked:p}),v))}),o.on(`agent_start`,(e,t)=>{if(!d)return;f=!0;let n=_(t);n&&s.start(g(n.cwd),n.write)}),o.on(`agent_settled`,async(n,i)=>{if(!d)return;f=!1,p=!1;let a=_(i);a&&s.stop(g(a.cwd),a.write),e.warrantsSettledNotification(i.hasPendingMessages())&&await r.sendSystemNotification(o,t.settledNotification({cwd:i.cwd,sessionName:o.getSessionName()}))})},s)}async function d(e,t={}){if((t.environment??process.env)[a.SUBAGENT_CHILD_ENV])return;let n=await(0,o.connectDoomCordisHost)(e,s,{environment:t.environment??process.env}),r=n.root.plugin(u,{pi:e,options:t});try{await r}catch(e){try{await r.dispose()}finally{await n.dispose()}throw e}let i;e.on(`session_shutdown`,()=>i??=(async()=>{try{await r.dispose()}finally{await n.dispose()}})())}exports.default=d,exports.notificationExtension=d;
1
+ const e=require("../../services/notificationPolicy.cjs"),t=require("../../services/notificationText.cjs"),n=require("../notificationRouter.cjs"),r=require("../shellTitleController.cjs");let i=require("@agimon-ai/doompi-extension-contracts/ask-user"),a=require("@agimon-ai/doompi-extension-contracts/child-process"),o=require("@agimon-ai/doompi-extension-contracts/cordis-host"),s=require("@agimon-ai/doompi-extension-contracts/notification");const c=`@agimon-ai/doompi-notification`,l=Symbol.for(`@agimon-ai/doompi-notification/original-ui-method`);function u(e,t){let n=e[t],r=new Set;for(;typeof n==`function`&&!r.has(n);){r.add(n);let e=Reflect.get(n,l);if(typeof e!=`function`)break;n=e}return n}function d(e,t){Reflect.defineProperty(e,l,{configurable:!1,enumerable:!1,value:t,writable:!1})}function f(e,t,n,r,i){let a=u(e,`confirm`),o=(t,i,o)=>(n()&&r(`${t}: ${i}`),a.call(e,t,i,o));d(o,a),e.confirm=o;let s=u(e,`select`),c=(t,i,a)=>(n()&&r(t),s.call(e,t,i,a));d(c,s),e.select=c;let l=u(e,`input`),f=(t,i,a)=>(n()&&r(t),l.call(e,t,i,a));d(f,l),e.input=f;let p=u(e,`editor`),m=(t,i)=>(n()&&r(t),p.call(e,t,i));d(m,p),e.editor=m;let h=u(e,`notify`),g=(n,r)=>{t()?i(n,r):h.call(e,n,r)};return d(g,h),e.notify=g,()=>{e.confirm===o&&(e.confirm=a),e.select===c&&(e.select=s),e.input===f&&(e.input=l),e.editor===m&&(e.editor=p),e.notify===g&&(e.notify=h)}}function p(a,{generation:l,pi:u,options:d}){let p,m=n.createDoomNotificationRouter({generation:l,pi:u,context:()=>p});a.provide(s.DOOM_NOTIFICATION_SERVICE,m),a.inject([o.DOOM_CORDIS_SESSION_SERVICE],e=>{let t=e.get(o.DOOM_CORDIS_SESSION_SERVICE).context;return p=t,()=>{p===t&&(p=void 0)}}),a.effect(function*(){let n=d.titleController??r.createWorkerTitleController(),o=new Map,s=!0,c=!1,l=!1,h,g,_=e=>t.shellTabTitle({cwd:e,sessionName:u.getSessionName(),prompt:h}),v=t=>{if(s&&e.supportsShellTitle(t))return g={cwd:t.cwd,write:e=>t.ui.setTitle(e)},g},y=e=>{s&&m.request(t.attentionNotification(e))};yield a.on(i.DOOM_ASK_USER_PROMPT_EVENT,t=>{y(e.askUserPromptBody(t.questions))}),yield a.on(i.DOOM_ASK_USER_BLOCKED_EVENT,e=>{l=e.active}),yield()=>{g&&n.dispose(_(g.cwd),g.write),g=void 0},yield()=>{for(let e of o.values())e();o.clear()},yield()=>{s=!1,c=!1,l=!1},u.on(`input`,(e,r)=>{if(!s||h||e.source===`extension`)return;p=r,h=t.promptTitle(e.text);let i=h?v(r):void 0;i&&n.set(_(i.cwd),i.write)}),u.on(`session_start`,(t,n)=>{s&&!o.has(n.ui)&&(p=n,o.set(n.ui,f(n.ui,()=>s,()=>s&&e.warrantsAttentionNotification({agentRunning:c,askUserBlocked:l}),y,(e,t)=>void m.request({body:e,...t?{level:t}:{}}))))}),u.on(`agent_start`,(e,t)=>{if(!s)return;p=t,c=!0;let r=v(t);r&&n.start(_(r.cwd),r.write)}),u.on(`agent_settled`,async(r,i)=>{if(!s)return;p=i,c=!1,l=!1;let a=v(i);a&&n.stop(_(a.cwd),a.write),e.warrantsSettledNotification(i.hasPendingMessages())&&await m.request(t.settledNotification({cwd:i.cwd,sessionName:u.getSessionName()}))})},c)}async function m(e,t={}){if((t.environment??process.env)[a.SUBAGENT_CHILD_ENV])return;let n=await(0,o.connectDoomCordisHost)(e,c,{environment:t.environment??process.env}),r=n.root.plugin(p,{generation:`${n.runtime.generation}:notification`,pi:e,options:t});try{await r}catch(e){try{await r.dispose()}finally{await n.dispose()}throw e}let i;e.on(`session_shutdown`,()=>i??=(async()=>{try{await r.dispose()}finally{await n.dispose()}})())}exports.default=m,exports.notificationExtension=m;
2
2
  //# sourceMappingURL=extension.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"extension.cjs","names":["createWorkerTitleController","shellTabTitle","supportsShellTitle","sendSystemNotification","attentionNotification","DOOM_ASK_USER_PROMPT_EVENT","askUserPromptBody","DOOM_ASK_USER_BLOCKED_EVENT","promptTitle","warrantsAttentionNotification","warrantsSettledNotification","settledNotification","SUBAGENT_CHILD_ENV","connectDoomCordisHost"],"sources":["../../../src/adapters/pi/extension.ts"],"sourcesContent":["import {\n DOOM_ASK_USER_BLOCKED_EVENT,\n DOOM_ASK_USER_PROMPT_EVENT,\n} from '@agimon-ai/doompi-extension-contracts/ask-user';\nimport { SUBAGENT_CHILD_ENV } from '@agimon-ai/doompi-extension-contracts/child-process';\nimport { connectDoomCordisHost } from '@agimon-ai/doompi-extension-contracts/cordis-host';\nimport type { Context } from '@deepseek-ai/cordis';\nimport type { ExtensionAPI, ExtensionContext, ExtensionUIContext } from '@earendil-works/pi-coding-agent';\nimport {\n askUserPromptBody,\n supportsShellTitle,\n warrantsAttentionNotification,\n warrantsSettledNotification,\n} from '../../services/notificationPolicy.ts';\nimport {\n attentionNotification,\n promptTitle,\n settledNotification,\n shellTabTitle,\n} from '../../services/notificationText.ts';\nimport type { ShellTitleController, WriteTitle } from '../../types/notifications.ts';\nimport { createWorkerTitleController } from '../shellTitleController.ts';\nimport { sendSystemNotification } from '../systemNotification.ts';\n\nconst AGENT_SETTLED_EVENT = 'agent_settled';\nconst AGENT_START_EVENT = 'agent_start';\nconst EXTENSION_INPUT_SOURCE = 'extension';\nconst INPUT_EVENT = 'input';\nconst PACKAGE_SOURCE = '@agimon-ai/doompi-notification';\nconst SESSION_START_EVENT = 'session_start';\n\nexport interface NotificationExtensionOptions {\n /** Replaces the worker-thread animator, which a host without worker threads cannot start. */\n titleController?: ShellTitleController;\n environment?: NodeJS.ProcessEnv;\n}\n\n/** Where the tab title is written, remembered so shutdown can restore it without an event. */\ninterface TitleSurface {\n cwd: string;\n write: WriteTitle;\n}\n\ntype AttentionDialogMethod = 'confirm' | 'editor' | 'input' | 'select';\n\n/** Capture a host method whose original identity must be restored after reload. */\nfunction captureUiMethod<Method extends AttentionDialogMethod>(\n ui: ExtensionUIContext,\n method: Method,\n): ExtensionUIContext[Method] {\n return ui[method];\n}\n\n/**\n * Announces every dialog the agent opens on its own initiative.\n *\n * Pi has no event for \"a dialog is showing\", so the only way to catch one is to\n * wrap the UI context the session hands out. Each wrapper delegates to the\n * original, so nothing about the dialog itself changes.\n */\nfunction wrapAttentionDialogs(\n ui: ExtensionUIContext,\n shouldNotify: () => boolean,\n notify: (body: string) => void,\n): () => void {\n const originalConfirm = captureUiMethod(ui, 'confirm');\n const wrappedConfirm: ExtensionUIContext['confirm'] = (title, message, options) => {\n if (shouldNotify()) notify(`${title}: ${message}`);\n return originalConfirm.call(ui, title, message, options);\n };\n ui.confirm = wrappedConfirm;\n\n const originalSelect = captureUiMethod(ui, 'select');\n const wrappedSelect: ExtensionUIContext['select'] = (title, options, dialogOptions) => {\n if (shouldNotify()) notify(title);\n return originalSelect.call(ui, title, options, dialogOptions);\n };\n ui.select = wrappedSelect;\n\n const originalInput = captureUiMethod(ui, 'input');\n const wrappedInput: ExtensionUIContext['input'] = (title, placeholder, options) => {\n if (shouldNotify()) notify(title);\n return originalInput.call(ui, title, placeholder, options);\n };\n ui.input = wrappedInput;\n\n const originalEditor = captureUiMethod(ui, 'editor');\n const wrappedEditor: ExtensionUIContext['editor'] = (title, prefill) => {\n if (shouldNotify()) notify(title);\n return originalEditor.call(ui, title, prefill);\n };\n ui.editor = wrappedEditor;\n\n return () => {\n if (ui.confirm === wrappedConfirm) ui.confirm = originalConfirm;\n if (ui.select === wrappedSelect) ui.select = originalSelect;\n if (ui.input === wrappedInput) ui.input = originalInput;\n if (ui.editor === wrappedEditor) ui.editor = originalEditor;\n };\n}\n\ninterface NotificationPluginConfig {\n readonly pi: ExtensionAPI;\n readonly options: NotificationExtensionOptions;\n}\n\nfunction notificationPlugin(cordis: Context, { pi, options }: NotificationPluginConfig): void {\n cordis.effect(function* () {\n const titles = options.titleController ?? createWorkerTitleController();\n const wrappedUis = new Map<ExtensionUIContext, () => void>();\n let active = true;\n let agentRunning = false;\n let askUserBlocked = false;\n let firstPrompt: string | undefined;\n let surface: TitleSurface | undefined;\n\n const idleTitle = (cwd: string): string =>\n shellTabTitle({ cwd, sessionName: pi.getSessionName(), prompt: firstPrompt });\n const titleSurface = (context: ExtensionContext): TitleSurface | undefined => {\n if (!active || !supportsShellTitle(context)) return undefined;\n surface = { cwd: context.cwd, write: (title) => context.ui.setTitle(title) };\n return surface;\n };\n const notifyAttention = (body: string): void => {\n if (active) void sendSystemNotification(pi, attentionNotification(body));\n };\n\n yield cordis.on(DOOM_ASK_USER_PROMPT_EVENT, (prompt) => {\n notifyAttention(askUserPromptBody(prompt.questions));\n });\n yield cordis.on(DOOM_ASK_USER_BLOCKED_EVENT, (payload) => {\n askUserBlocked = payload.active;\n });\n\n yield () => {\n if (surface) titles.dispose(idleTitle(surface.cwd), surface.write);\n surface = undefined;\n };\n yield () => {\n for (const restore of wrappedUis.values()) restore();\n wrappedUis.clear();\n };\n yield () => {\n active = false;\n agentRunning = false;\n askUserBlocked = false;\n };\n\n pi.on(INPUT_EVENT, (event, context) => {\n if (!active || firstPrompt || event.source === EXTENSION_INPUT_SOURCE) return;\n firstPrompt = promptTitle(event.text);\n const target = firstPrompt ? titleSurface(context) : undefined;\n if (target) titles.set(idleTitle(target.cwd), target.write);\n });\n\n pi.on(SESSION_START_EVENT, (_event, context) => {\n if (!active || wrappedUis.has(context.ui)) return;\n wrappedUis.set(\n context.ui,\n wrapAttentionDialogs(\n context.ui,\n () => active && warrantsAttentionNotification({ agentRunning, askUserBlocked }),\n notifyAttention,\n ),\n );\n });\n\n pi.on(AGENT_START_EVENT, (_event, context) => {\n if (!active) return;\n agentRunning = true;\n const target = titleSurface(context);\n if (target) titles.start(idleTitle(target.cwd), target.write);\n });\n\n pi.on(AGENT_SETTLED_EVENT, async (_event, context) => {\n if (!active) return;\n agentRunning = false;\n askUserBlocked = false;\n const target = titleSurface(context);\n if (target) titles.stop(idleTitle(target.cwd), target.write);\n if (!warrantsSettledNotification(context.hasPendingMessages())) return;\n await sendSystemNotification(pi, settledNotification({ cwd: context.cwd, sessionName: pi.getSessionName() }));\n });\n }, PACKAGE_SOURCE);\n}\n\n/** The package's single standard Pi factory. */\nexport async function notificationExtension(\n pi: ExtensionAPI,\n options: NotificationExtensionOptions = {},\n): Promise<void> {\n if ((options.environment ?? process.env)[SUBAGENT_CHILD_ENV]) return;\n\n const connection = await connectDoomCordisHost(pi, PACKAGE_SOURCE, {\n environment: options.environment ?? process.env,\n });\n const fiber = connection.root.plugin(notificationPlugin, { pi, options });\n try {\n await fiber;\n } catch (error) {\n try {\n await fiber.dispose();\n } finally {\n await connection.dispose();\n }\n throw error;\n }\n let disposal: Promise<void> | undefined;\n pi.on(\n 'session_shutdown',\n () =>\n (disposal ??= (async () => {\n try {\n await fiber.dispose();\n } finally {\n await connection.dispose();\n }\n })()),\n );\n}\n\nexport default notificationExtension;\n"],"mappings":"0XAwBA,MAIM,EAAiB,iCAkBvB,SAAS,EACP,EACA,EAC4B,CAC5B,OAAO,EAAG,EACZ,CASA,SAAS,EACP,EACA,EACA,EACY,CACZ,IAAM,EAAkB,EAAgB,EAAI,SAAS,EAC/C,GAAiD,EAAO,EAAS,KACjE,EAAa,GAAG,EAAO,GAAG,EAAM,IAAI,GAAS,EAC1C,EAAgB,KAAK,EAAI,EAAO,EAAS,CAAO,GAEzD,EAAG,QAAU,EAEb,IAAM,EAAiB,EAAgB,EAAI,QAAQ,EAC7C,GAA+C,EAAO,EAAS,KAC/D,EAAa,GAAG,EAAO,CAAK,EACzB,EAAe,KAAK,EAAI,EAAO,EAAS,CAAa,GAE9D,EAAG,OAAS,EAEZ,IAAM,EAAgB,EAAgB,EAAI,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Ae,QAAQ,IAAA,CAAKC,EAAAA,oBAAqB,OAE9D,IAAM,EAAa,MAAA,EAAMC,EAAAA,sBAAAA,CAAsB,EAAI,EAAgB,CACjE,YAAa,EAAQ,aAAe,QAAQ,GAC9C,CAAC,EACK,EAAQ,EAAW,KAAK,OAAO,EAAoB,CAAE,KAAI,SAAQ,CAAC,EACxE,GAAI,CACF,MAAM,CACR,OAAS,EAAO,CACd,GAAI,CACF,MAAM,EAAM,QAAQ,CACtB,QAAU,CACR,MAAM,EAAW,QAAQ,CAC3B,CACA,MAAM,CACR,CACA,IAAI,EACJ,EAAG,GACD,uBAEG,KAAc,SAAY,CACzB,GAAI,CACF,MAAM,EAAM,QAAQ,CACtB,QAAU,CACR,MAAM,EAAW,QAAQ,CAC3B,CACF,EAAA,CAAG,CACP,CACF"}
1
+ {"version":3,"file":"extension.cjs","names":["createDoomNotificationRouter","DOOM_NOTIFICATION_SERVICE","DOOM_CORDIS_SESSION_SERVICE","createWorkerTitleController","shellTabTitle","supportsShellTitle","attentionNotification","DOOM_ASK_USER_PROMPT_EVENT","askUserPromptBody","DOOM_ASK_USER_BLOCKED_EVENT","promptTitle","warrantsAttentionNotification","warrantsSettledNotification","settledNotification","SUBAGENT_CHILD_ENV","connectDoomCordisHost"],"sources":["../../../src/adapters/pi/extension.ts"],"sourcesContent":["import {\n DOOM_ASK_USER_BLOCKED_EVENT,\n DOOM_ASK_USER_PROMPT_EVENT,\n} from '@agimon-ai/doompi-extension-contracts/ask-user';\nimport { SUBAGENT_CHILD_ENV } from '@agimon-ai/doompi-extension-contracts/child-process';\nimport {\n connectDoomCordisHost,\n DOOM_CORDIS_SESSION_SERVICE,\n type DoomCordisSessionService,\n} from '@agimon-ai/doompi-extension-contracts/cordis-host';\nimport {\n DOOM_NOTIFICATION_SERVICE,\n type DoomNotificationLevel,\n} from '@agimon-ai/doompi-extension-contracts/notification';\nimport type { Context } from '@deepseek-ai/cordis';\nimport type { ExtensionAPI, ExtensionContext, ExtensionUIContext } from '@earendil-works/pi-coding-agent';\nimport {\n askUserPromptBody,\n supportsShellTitle,\n warrantsAttentionNotification,\n warrantsSettledNotification,\n} from '../../services/notificationPolicy.ts';\nimport {\n attentionNotification,\n promptTitle,\n settledNotification,\n shellTabTitle,\n} from '../../services/notificationText.ts';\nimport type { ShellTitleController, WriteTitle } from '../../types/notifications.ts';\nimport { createDoomNotificationRouter } from '../notificationRouter.ts';\nimport { createWorkerTitleController } from '../shellTitleController.ts';\n\nconst AGENT_SETTLED_EVENT = 'agent_settled';\nconst AGENT_START_EVENT = 'agent_start';\nconst EXTENSION_INPUT_SOURCE = 'extension';\nconst INPUT_EVENT = 'input';\nconst PACKAGE_SOURCE = '@agimon-ai/doompi-notification';\nconst SESSION_START_EVENT = 'session_start';\n\nexport interface NotificationExtensionOptions {\n /** Replaces the worker-thread animator, which a host without worker threads cannot start. */\n titleController?: ShellTitleController;\n environment?: NodeJS.ProcessEnv;\n}\n\n/** Where the tab title is written, remembered so shutdown can restore it without an event. */\ninterface TitleSurface {\n cwd: string;\n write: WriteTitle;\n}\n\ntype WrappedUiMethod = 'confirm' | 'editor' | 'input' | 'notify' | 'select';\n\nconst ORIGINAL_UI_METHOD = Symbol.for('@agimon-ai/doompi-notification/original-ui-method');\n\n/** Capture the true host method even when another bundle copy currently owns the UI. */\nfunction captureUiMethod<Method extends WrappedUiMethod>(\n ui: ExtensionUIContext,\n method: Method,\n): ExtensionUIContext[Method] {\n let captured: unknown = ui[method];\n const seen = new Set<unknown>();\n while (typeof captured === 'function' && !seen.has(captured)) {\n seen.add(captured);\n const original = Reflect.get(captured, ORIGINAL_UI_METHOD) as unknown;\n if (typeof original !== 'function') break;\n captured = original;\n }\n return captured as ExtensionUIContext[Method];\n}\n\nfunction tagUiWrapper(wrapper: object, original: object): void {\n Reflect.defineProperty(wrapper, ORIGINAL_UI_METHOD, {\n configurable: false,\n enumerable: false,\n value: original,\n writable: false,\n });\n}\n\n/**\n * Routes UI notices and announces dialogs the agent opens on its own initiative.\n * Dialog wrappers preserve the original behavior. The notice wrapper replaces\n * host delivery while this plugin owns the UI and restores its exact identity.\n */\nfunction wrapUiNotifications(\n ui: ExtensionUIContext,\n isActive: () => boolean,\n shouldNotifyAttention: () => boolean,\n notifyAttention: (body: string) => void,\n notify: (body: string, level?: DoomNotificationLevel) => void,\n): () => void {\n const originalConfirm = captureUiMethod(ui, 'confirm');\n const wrappedConfirm: ExtensionUIContext['confirm'] = (title, message, options) => {\n if (shouldNotifyAttention()) notifyAttention(`${title}: ${message}`);\n return originalConfirm.call(ui, title, message, options);\n };\n tagUiWrapper(wrappedConfirm, originalConfirm);\n ui.confirm = wrappedConfirm;\n\n const originalSelect = captureUiMethod(ui, 'select');\n const wrappedSelect: ExtensionUIContext['select'] = (title, options, dialogOptions) => {\n if (shouldNotifyAttention()) notifyAttention(title);\n return originalSelect.call(ui, title, options, dialogOptions);\n };\n tagUiWrapper(wrappedSelect, originalSelect);\n ui.select = wrappedSelect;\n\n const originalInput = captureUiMethod(ui, 'input');\n const wrappedInput: ExtensionUIContext['input'] = (title, placeholder, options) => {\n if (shouldNotifyAttention()) notifyAttention(title);\n return originalInput.call(ui, title, placeholder, options);\n };\n tagUiWrapper(wrappedInput, originalInput);\n ui.input = wrappedInput;\n\n const originalEditor = captureUiMethod(ui, 'editor');\n const wrappedEditor: ExtensionUIContext['editor'] = (title, prefill) => {\n if (shouldNotifyAttention()) notifyAttention(title);\n return originalEditor.call(ui, title, prefill);\n };\n tagUiWrapper(wrappedEditor, originalEditor);\n ui.editor = wrappedEditor;\n\n const originalNotify = captureUiMethod(ui, 'notify');\n const wrappedNotify: ExtensionUIContext['notify'] = (message, level) => {\n if (isActive()) notify(message, level);\n else originalNotify.call(ui, message, level);\n };\n tagUiWrapper(wrappedNotify, originalNotify);\n ui.notify = wrappedNotify;\n\n return () => {\n if (ui.confirm === wrappedConfirm) ui.confirm = originalConfirm;\n if (ui.select === wrappedSelect) ui.select = originalSelect;\n if (ui.input === wrappedInput) ui.input = originalInput;\n if (ui.editor === wrappedEditor) ui.editor = originalEditor;\n if (ui.notify === wrappedNotify) ui.notify = originalNotify;\n };\n}\n\ninterface NotificationPluginConfig {\n readonly generation: string;\n readonly pi: ExtensionAPI;\n readonly options: NotificationExtensionOptions;\n}\n\nfunction notificationPlugin(cordis: Context, { generation, pi, options }: NotificationPluginConfig): void {\n let activeContext: ExtensionContext | undefined;\n const router = createDoomNotificationRouter({ generation, pi, context: () => activeContext });\n cordis.provide(DOOM_NOTIFICATION_SERVICE, router);\n cordis.inject([DOOM_CORDIS_SESSION_SERVICE], (sessionContext) => {\n const session = sessionContext.get(DOOM_CORDIS_SESSION_SERVICE) as DoomCordisSessionService;\n const context = session.context;\n activeContext = context;\n return () => {\n if (activeContext === context) activeContext = undefined;\n };\n });\n\n cordis.effect(function* () {\n const titles = options.titleController ?? createWorkerTitleController();\n const wrappedUis = new Map<ExtensionUIContext, () => void>();\n let active = true;\n let agentRunning = false;\n let askUserBlocked = false;\n let firstPrompt: string | undefined;\n let surface: TitleSurface | undefined;\n\n const idleTitle = (cwd: string): string =>\n shellTabTitle({ cwd, sessionName: pi.getSessionName(), prompt: firstPrompt });\n const titleSurface = (context: ExtensionContext): TitleSurface | undefined => {\n if (!active || !supportsShellTitle(context)) return undefined;\n surface = { cwd: context.cwd, write: (title) => context.ui.setTitle(title) };\n return surface;\n };\n const notifyAttention = (body: string): void => {\n if (active) void router.request(attentionNotification(body));\n };\n\n yield cordis.on(DOOM_ASK_USER_PROMPT_EVENT, (prompt) => {\n notifyAttention(askUserPromptBody(prompt.questions));\n });\n yield cordis.on(DOOM_ASK_USER_BLOCKED_EVENT, (payload) => {\n askUserBlocked = payload.active;\n });\n\n yield () => {\n if (surface) titles.dispose(idleTitle(surface.cwd), surface.write);\n surface = undefined;\n };\n yield () => {\n for (const restore of wrappedUis.values()) restore();\n wrappedUis.clear();\n };\n yield () => {\n active = false;\n agentRunning = false;\n askUserBlocked = false;\n };\n\n pi.on(INPUT_EVENT, (event, context) => {\n if (!active || firstPrompt || event.source === EXTENSION_INPUT_SOURCE) return;\n activeContext = context;\n firstPrompt = promptTitle(event.text);\n const target = firstPrompt ? titleSurface(context) : undefined;\n if (target) titles.set(idleTitle(target.cwd), target.write);\n });\n\n pi.on(SESSION_START_EVENT, (_event, context) => {\n if (!active || wrappedUis.has(context.ui)) return;\n activeContext = context;\n wrappedUis.set(\n context.ui,\n wrapUiNotifications(\n context.ui,\n () => active,\n () => active && warrantsAttentionNotification({ agentRunning, askUserBlocked }),\n notifyAttention,\n (body, level) => void router.request({ body, ...(level ? { level } : {}) }),\n ),\n );\n });\n\n pi.on(AGENT_START_EVENT, (_event, context) => {\n if (!active) return;\n activeContext = context;\n agentRunning = true;\n const target = titleSurface(context);\n if (target) titles.start(idleTitle(target.cwd), target.write);\n });\n\n pi.on(AGENT_SETTLED_EVENT, async (_event, context) => {\n if (!active) return;\n activeContext = context;\n agentRunning = false;\n askUserBlocked = false;\n const target = titleSurface(context);\n if (target) titles.stop(idleTitle(target.cwd), target.write);\n if (!warrantsSettledNotification(context.hasPendingMessages())) return;\n await router.request(settledNotification({ cwd: context.cwd, sessionName: pi.getSessionName() }));\n });\n }, PACKAGE_SOURCE);\n}\n\n/** The package's single standard Pi factory. */\nexport async function notificationExtension(\n pi: ExtensionAPI,\n options: NotificationExtensionOptions = {},\n): Promise<void> {\n if ((options.environment ?? process.env)[SUBAGENT_CHILD_ENV]) return;\n\n const connection = await connectDoomCordisHost(pi, PACKAGE_SOURCE, {\n environment: options.environment ?? process.env,\n });\n const fiber = connection.root.plugin(notificationPlugin, {\n generation: `${connection.runtime.generation}:notification`,\n pi,\n options,\n });\n try {\n await fiber;\n } catch (error) {\n try {\n await fiber.dispose();\n } finally {\n await connection.dispose();\n }\n throw error;\n }\n let disposal: Promise<void> | undefined;\n pi.on(\n 'session_shutdown',\n () =>\n (disposal ??= (async () => {\n try {\n await fiber.dispose();\n } finally {\n await connection.dispose();\n }\n })()),\n );\n}\n\nexport default notific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AO,EAAQ,IAAY,CACpD,GAAI,CAAC,EAAQ,OACb,EAAgB,EAChB,EAAe,GACf,EAAiB,GACjB,IAAM,EAAS,EAAa,CAAO,EAC/B,GAAQ,EAAO,KAAK,EAAU,EAAO,GAAG,EAAG,EAAO,KAAK,EACtDC,EAAAA,4BAA4B,EAAQ,mBAAmB,CAAC,GAC7D,MAAM,EAAO,QAAQC,EAAAA,oBAAoB,CAAE,IAAK,EAAQ,IAAK,YAAa,EAAG,eAAe,CAAE,CAAC,CAAC,CAClG,CAAC,CACH,EAAG,CAAc,CACnB,CAGA,eAAsB,EACpB,EACA,EAAwC,CAAC,EAC1B,CACf,IAAK,EAAQ,aAAe,QAAQ,IAAA,CAAKC,EAAAA,oBAAqB,OAE9D,IAAM,EAAa,MAAA,EAAMC,EAAAA,sBAAAA,CAAsB,EAAI,EAAgB,CACjE,YAAa,EAAQ,aAAe,QAAQ,GAC9C,CAAC,EACK,EAAQ,EAAW,KAAK,OAAO,EAAoB,CACvD,WAAY,GAAG,EAAW,QAAQ,WAAW,eAC7C,KACA,SACF,CAAC,EACD,GAAI,CACF,MAAM,CACR,OAAS,EAAO,CACd,GAAI,CACF,MAAM,EAAM,QAAQ,CACtB,QAAU,CACR,MAAM,EAAW,QAAQ,CAC3B,CACA,MAAM,CACR,CACA,IAAI,EACJ,EAAG,GACD,uBAEG,KAAc,SAAY,CACzB,GAAI,CACF,MAAM,EAAM,QAAQ,CACtB,QAAU,CACR,MAAM,EAAW,QAAQ,CAC3B,CACF,EAAA,CAAG,CACP,CACF"}
@@ -1,13 +1,13 @@
1
1
  import { ShellTitleController } from "../../types/notifications.cjs";
2
2
  import { ExtensionAPI } from "@earendil-works/pi-coding-agent";
3
3
  //#region src/adapters/pi/extension.d.ts
4
- interface NotificationExtensionOptions {
4
+ export interface NotificationExtensionOptions {
5
5
  /** Replaces the worker-thread animator, which a host without worker threads cannot start. */
6
6
  titleController?: ShellTitleController;
7
7
  environment?: NodeJS.ProcessEnv;
8
8
  }
9
9
  /** The package's single standard Pi factory. */
10
- declare function notificationExtension(pi: ExtensionAPI, options?: NotificationExtensionOptions): Promise<void>;
10
+ export declare function notificationExtension(pi: ExtensionAPI, options?: NotificationExtensionOptions): Promise<void>;
11
11
  //#endregion
12
- export { NotificationExtensionOptions, notificationExtension as default, notificationExtension };
12
+ export { notificationExtension as default };
13
13
  //# sourceMappingURL=extension.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"extension.d.cts","names":[],"sources":["../../../src/adapters/pi/extension.ts"],"mappings":";;;UA+BiB;;EAEf,kBAAkB;EAClB,cAAc,OAAO;;;iBAyJD,sBACpB,IAAI,cACJ,UAAS,+BACR"}
1
+ {"version":3,"file":"extension.d.cts","names":[],"sources":["../../../src/adapters/pi/extension.ts"],"mappings":";;;iBAuCiB;;EAEf,kBAAkB;EAClB,cAAc,OAAO;;;wBA4MD,sBACpB,IAAI,cACJ,UAAS,+BACR"}
@@ -1,13 +1,13 @@
1
1
  import { ShellTitleController } from "../../types/notifications.mjs";
2
2
  import { ExtensionAPI } from "@earendil-works/pi-coding-agent";
3
3
  //#region src/adapters/pi/extension.d.ts
4
- interface NotificationExtensionOptions {
4
+ export interface NotificationExtensionOptions {
5
5
  /** Replaces the worker-thread animator, which a host without worker threads cannot start. */
6
6
  titleController?: ShellTitleController;
7
7
  environment?: NodeJS.ProcessEnv;
8
8
  }
9
9
  /** The package's single standard Pi factory. */
10
- declare function notificationExtension(pi: ExtensionAPI, options?: NotificationExtensionOptions): Promise<void>;
10
+ export declare function notificationExtension(pi: ExtensionAPI, options?: NotificationExtensionOptions): Promise<void>;
11
11
  //#endregion
12
- export { NotificationExtensionOptions, notificationExtension as default, notificationExtension };
12
+ export { notificationExtension as default };
13
13
  //# sourceMappingURL=extension.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"extension.d.mts","names":[],"sources":["../../../src/adapters/pi/extension.ts"],"mappings":";;;UA+BiB;;EAEf,kBAAkB;EAClB,cAAc,OAAO;;;iBAyJD,sBACpB,IAAI,cACJ,UAAS,+BACR"}
1
+ {"version":3,"file":"extension.d.mts","names":[],"sources":["../../../src/adapters/pi/extension.ts"],"mappings":";;;iBAuCiB;;EAEf,kBAAkB;EAClB,cAAc,OAAO;;;wBA4MD,sBACpB,IAAI,cACJ,UAAS,+BACR"}
@@ -1,2 +1,2 @@
1
- import{askUserPromptBody as e,supportsShellTitle as t,warrantsAttentionNotification as n,warrantsSettledNotification as r}from"../../services/notificationPolicy.mjs";import{attentionNotification as i,promptTitle as a,settledNotification as o,shellTabTitle as s}from"../../services/notificationText.mjs";import{createWorkerTitleController as c}from"../shellTitleController.mjs";import{sendSystemNotification as l}from"../systemNotification.mjs";import{DOOM_ASK_USER_BLOCKED_EVENT as u,DOOM_ASK_USER_PROMPT_EVENT as d}from"@agimon-ai/doompi-extension-contracts/ask-user";import{SUBAGENT_CHILD_ENV as f}from"@agimon-ai/doompi-extension-contracts/child-process";import{connectDoomCordisHost as p}from"@agimon-ai/doompi-extension-contracts/cordis-host";const m=`@agimon-ai/doompi-notification`;function h(e,t){return e[t]}function g(e,t,n){let r=h(e,`confirm`),i=(i,a,o)=>(t()&&n(`${i}: ${a}`),r.call(e,i,a,o));e.confirm=i;let a=h(e,`select`),o=(r,i,o)=>(t()&&n(r),a.call(e,r,i,o));e.select=o;let s=h(e,`input`),c=(r,i,a)=>(t()&&n(r),s.call(e,r,i,a));e.input=c;let l=h(e,`editor`),u=(r,i)=>(t()&&n(r),l.call(e,r,i));return e.editor=u,()=>{e.confirm===i&&(e.confirm=r),e.select===o&&(e.select=a),e.input===c&&(e.input=s),e.editor===u&&(e.editor=l)}}function _(f,{pi:p,options:h}){f.effect(function*(){let m=h.titleController??c(),_=new Map,v=!0,y=!1,b=!1,x,S,C=e=>s({cwd:e,sessionName:p.getSessionName(),prompt:x}),w=e=>{if(!(!v||!t(e)))return S={cwd:e.cwd,write:t=>e.ui.setTitle(t)},S},T=e=>{v&&l(p,i(e))};yield f.on(d,t=>{T(e(t.questions))}),yield f.on(u,e=>{b=e.active}),yield()=>{S&&m.dispose(C(S.cwd),S.write),S=void 0},yield()=>{for(let e of _.values())e();_.clear()},yield()=>{v=!1,y=!1,b=!1},p.on(`input`,(e,t)=>{if(!v||x||e.source===`extension`)return;x=a(e.text);let n=x?w(t):void 0;n&&m.set(C(n.cwd),n.write)}),p.on(`session_start`,(e,t)=>{!v||_.has(t.ui)||_.set(t.ui,g(t.ui,()=>v&&n({agentRunning:y,askUserBlocked:b}),T))}),p.on(`agent_start`,(e,t)=>{if(!v)return;y=!0;let n=w(t);n&&m.start(C(n.cwd),n.write)}),p.on(`agent_settled`,async(e,t)=>{if(!v)return;y=!1,b=!1;let n=w(t);n&&m.stop(C(n.cwd),n.write),r(t.hasPendingMessages())&&await l(p,o({cwd:t.cwd,sessionName:p.getSessionName()}))})},m)}async function v(e,t={}){if((t.environment??process.env)[f])return;let n=await p(e,m,{environment:t.environment??process.env}),r=n.root.plugin(_,{pi:e,options:t});try{await r}catch(e){try{await r.dispose()}finally{await n.dispose()}throw e}let i;e.on(`session_shutdown`,()=>i??=(async()=>{try{await r.dispose()}finally{await n.dispose()}})())}export{v as default,v as notificationExtension};
1
+ import{askUserPromptBody as e,supportsShellTitle as t,warrantsAttentionNotification as n,warrantsSettledNotification as r}from"../../services/notificationPolicy.mjs";import{attentionNotification as i,promptTitle as a,settledNotification as o,shellTabTitle as s}from"../../services/notificationText.mjs";import{createDoomNotificationRouter as c}from"../notificationRouter.mjs";import{createWorkerTitleController as l}from"../shellTitleController.mjs";import{DOOM_ASK_USER_BLOCKED_EVENT as u,DOOM_ASK_USER_PROMPT_EVENT as d}from"@agimon-ai/doompi-extension-contracts/ask-user";import{SUBAGENT_CHILD_ENV as f}from"@agimon-ai/doompi-extension-contracts/child-process";import{DOOM_CORDIS_SESSION_SERVICE as p,connectDoomCordisHost as m}from"@agimon-ai/doompi-extension-contracts/cordis-host";import{DOOM_NOTIFICATION_SERVICE as h}from"@agimon-ai/doompi-extension-contracts/notification";const g=`@agimon-ai/doompi-notification`,_=Symbol.for(`@agimon-ai/doompi-notification/original-ui-method`);function v(e,t){let n=e[t],r=new Set;for(;typeof n==`function`&&!r.has(n);){r.add(n);let e=Reflect.get(n,_);if(typeof e!=`function`)break;n=e}return n}function y(e,t){Reflect.defineProperty(e,_,{configurable:!1,enumerable:!1,value:t,writable:!1})}function b(e,t,n,r,i){let a=v(e,`confirm`),o=(t,i,o)=>(n()&&r(`${t}: ${i}`),a.call(e,t,i,o));y(o,a),e.confirm=o;let s=v(e,`select`),c=(t,i,a)=>(n()&&r(t),s.call(e,t,i,a));y(c,s),e.select=c;let l=v(e,`input`),u=(t,i,a)=>(n()&&r(t),l.call(e,t,i,a));y(u,l),e.input=u;let d=v(e,`editor`),f=(t,i)=>(n()&&r(t),d.call(e,t,i));y(f,d),e.editor=f;let p=v(e,`notify`),m=(n,r)=>{t()?i(n,r):p.call(e,n,r)};return y(m,p),e.notify=m,()=>{e.confirm===o&&(e.confirm=a),e.select===c&&(e.select=s),e.input===u&&(e.input=l),e.editor===f&&(e.editor=d),e.notify===m&&(e.notify=p)}}function x(f,{generation:m,pi:_,options:v}){let y,x=c({generation:m,pi:_,context:()=>y});f.provide(h,x),f.inject([p],e=>{let t=e.get(p).context;return y=t,()=>{y===t&&(y=void 0)}}),f.effect(function*(){let c=v.titleController??l(),p=new Map,m=!0,h=!1,g=!1,S,C,w=e=>s({cwd:e,sessionName:_.getSessionName(),prompt:S}),T=e=>{if(m&&t(e))return C={cwd:e.cwd,write:t=>e.ui.setTitle(t)},C},E=e=>{m&&x.request(i(e))};yield f.on(d,t=>{E(e(t.questions))}),yield f.on(u,e=>{g=e.active}),yield()=>{C&&c.dispose(w(C.cwd),C.write),C=void 0},yield()=>{for(let e of p.values())e();p.clear()},yield()=>{m=!1,h=!1,g=!1},_.on(`input`,(e,t)=>{if(!m||S||e.source===`extension`)return;y=t,S=a(e.text);let n=S?T(t):void 0;n&&c.set(w(n.cwd),n.write)}),_.on(`session_start`,(e,t)=>{m&&!p.has(t.ui)&&(y=t,p.set(t.ui,b(t.ui,()=>m,()=>m&&n({agentRunning:h,askUserBlocked:g}),E,(e,t)=>void x.request({body:e,...t?{level:t}:{}}))))}),_.on(`agent_start`,(e,t)=>{if(!m)return;y=t,h=!0;let n=T(t);n&&c.start(w(n.cwd),n.write)}),_.on(`agent_settled`,async(e,t)=>{if(!m)return;y=t,h=!1,g=!1;let n=T(t);n&&c.stop(w(n.cwd),n.write),r(t.hasPendingMessages())&&await x.request(o({cwd:t.cwd,sessionName:_.getSessionName()}))})},g)}async function S(e,t={}){if((t.environment??process.env)[f])return;let n=await m(e,g,{environment:t.environment??process.env}),r=n.root.plugin(x,{generation:`${n.runtime.generation}:notification`,pi:e,options:t});try{await r}catch(e){try{await r.dispose()}finally{await n.dispose()}throw e}let i;e.on(`session_shutdown`,()=>i??=(async()=>{try{await r.dispose()}finally{await n.dispose()}})())}export{S as default,S as notificationExtension};
2
2
  //# sourceMappingURL=extension.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"extension.mjs","names":[],"sources":["../../../src/adapters/pi/extension.ts"],"sourcesContent":["import {\n DOOM_ASK_USER_BLOCKED_EVENT,\n DOOM_ASK_USER_PROMPT_EVENT,\n} from '@agimon-ai/doompi-extension-contracts/ask-user';\nimport { SUBAGENT_CHILD_ENV } from '@agimon-ai/doompi-extension-contracts/child-process';\nimport { connectDoomCordisHost } from '@agimon-ai/doompi-extension-contracts/cordis-host';\nimport type { Context } from '@deepseek-ai/cordis';\nimport type { ExtensionAPI, ExtensionContext, ExtensionUIContext } from '@earendil-works/pi-coding-agent';\nimport {\n askUserPromptBody,\n supportsShellTitle,\n warrantsAttentionNotification,\n warrantsSettledNotification,\n} from '../../services/notificationPolicy.ts';\nimport {\n attentionNotification,\n promptTitle,\n settledNotification,\n shellTabTitle,\n} from '../../services/notificationText.ts';\nimport type { ShellTitleController, WriteTitle } from '../../types/notifications.ts';\nimport { createWorkerTitleController } from '../shellTitleController.ts';\nimport { sendSystemNotification } from '../systemNotification.ts';\n\nconst AGENT_SETTLED_EVENT = 'agent_settled';\nconst AGENT_START_EVENT = 'agent_start';\nconst EXTENSION_INPUT_SOURCE = 'extension';\nconst INPUT_EVENT = 'input';\nconst PACKAGE_SOURCE = '@agimon-ai/doompi-notification';\nconst SESSION_START_EVENT = 'session_start';\n\nexport interface NotificationExtensionOptions {\n /** Replaces the worker-thread animator, which a host without worker threads cannot start. */\n titleController?: ShellTitleController;\n environment?: NodeJS.ProcessEnv;\n}\n\n/** Where the tab title is written, remembered so shutdown can restore it without an event. */\ninterface TitleSurface {\n cwd: string;\n write: WriteTitle;\n}\n\ntype AttentionDialogMethod = 'confirm' | 'editor' | 'input' | 'select';\n\n/** Capture a host method whose original identity must be restored after reload. */\nfunction captureUiMethod<Method extends AttentionDialogMethod>(\n ui: ExtensionUIContext,\n method: Method,\n): ExtensionUIContext[Method] {\n return ui[method];\n}\n\n/**\n * Announces every dialog the agent opens on its own initiative.\n *\n * Pi has no event for \"a dialog is showing\", so the only way to catch one is to\n * wrap the UI context the session hands out. Each wrapper delegates to the\n * original, so nothing about the dialog itself changes.\n */\nfunction wrapAttentionDialogs(\n ui: ExtensionUIContext,\n shouldNotify: () => boolean,\n notify: (body: string) => void,\n): () => void {\n const originalConfirm = captureUiMethod(ui, 'confirm');\n const wrappedConfirm: ExtensionUIContext['confirm'] = (title, message, options) => {\n if (shouldNotify()) notify(`${title}: ${message}`);\n return originalConfirm.call(ui, title, message, options);\n };\n ui.confirm = wrappedConfirm;\n\n const originalSelect = captureUiMethod(ui, 'select');\n const wrappedSelect: ExtensionUIContext['select'] = (title, options, dialogOptions) => {\n if (shouldNotify()) notify(title);\n return originalSelect.call(ui, title, options, dialogOptions);\n };\n ui.select = wrappedSelect;\n\n const originalInput = captureUiMethod(ui, 'input');\n const wrappedInput: ExtensionUIContext['input'] = (title, placeholder, options) => {\n if (shouldNotify()) notify(title);\n return originalInput.call(ui, title, placeholder, options);\n };\n ui.input = wrappedInput;\n\n const originalEditor = captureUiMethod(ui, 'editor');\n const wrappedEditor: ExtensionUIContext['editor'] = (title, prefill) => {\n if (shouldNotify()) notify(title);\n return originalEditor.call(ui, title, prefill);\n };\n ui.editor = wrappedEditor;\n\n return () => {\n if (ui.confirm === wrappedConfirm) ui.confirm = originalConfirm;\n if (ui.select === wrappedSelect) ui.select = originalSelect;\n if (ui.input === wrappedInput) ui.input = originalInput;\n if (ui.editor === wrappedEditor) ui.editor = originalEditor;\n };\n}\n\ninterface NotificationPluginConfig {\n readonly pi: ExtensionAPI;\n readonly options: NotificationExtensionOptions;\n}\n\nfunction notificationPlugin(cordis: Context, { pi, options }: NotificationPluginConfig): void {\n cordis.effect(function* () {\n const titles = options.titleController ?? createWorkerTitleController();\n const wrappedUis = new Map<ExtensionUIContext, () => void>();\n let active = true;\n let agentRunning = false;\n let askUserBlocked = false;\n let firstPrompt: string | undefined;\n let surface: TitleSurface | undefined;\n\n const idleTitle = (cwd: string): string =>\n shellTabTitle({ cwd, sessionName: pi.getSessionName(), prompt: firstPrompt });\n const titleSurface = (context: ExtensionContext): TitleSurface | undefined => {\n if (!active || !supportsShellTitle(context)) return undefined;\n surface = { cwd: context.cwd, write: (title) => context.ui.setTitle(title) };\n return surface;\n };\n const notifyAttention = (body: string): void => {\n if (active) void sendSystemNotification(pi, attentionNotification(body));\n };\n\n yield cordis.on(DOOM_ASK_USER_PROMPT_EVENT, (prompt) => {\n notifyAttention(askUserPromptBody(prompt.questions));\n });\n yield cordis.on(DOOM_ASK_USER_BLOCKED_EVENT, (payload) => {\n askUserBlocked = payload.active;\n });\n\n yield () => {\n if (surface) titles.dispose(idleTitle(surface.cwd), surface.write);\n surface = undefined;\n };\n yield () => {\n for (const restore of wrappedUis.values()) restore();\n wrappedUis.clear();\n };\n yield () => {\n active = false;\n agentRunning = false;\n askUserBlocked = false;\n };\n\n pi.on(INPUT_EVENT, (event, context) => {\n if (!active || firstPrompt || event.source === EXTENSION_INPUT_SOURCE) return;\n firstPrompt = promptTitle(event.text);\n const target = firstPrompt ? titleSurface(context) : undefined;\n if (target) titles.set(idleTitle(target.cwd), target.write);\n });\n\n pi.on(SESSION_START_EVENT, (_event, context) => {\n if (!active || wrappedUis.has(context.ui)) return;\n wrappedUis.set(\n context.ui,\n wrapAttentionDialogs(\n context.ui,\n () => active && warrantsAttentionNotification({ agentRunning, askUserBlocked }),\n notifyAttention,\n ),\n );\n });\n\n pi.on(AGENT_START_EVENT, (_event, context) => {\n if (!active) return;\n agentRunning = true;\n const target = titleSurface(context);\n if (target) titles.start(idleTitle(target.cwd), target.write);\n });\n\n pi.on(AGENT_SETTLED_EVENT, async (_event, context) => {\n if (!active) return;\n agentRunning = false;\n askUserBlocked = false;\n const target = titleSurface(context);\n if (target) titles.stop(idleTitle(target.cwd), target.write);\n if (!warrantsSettledNotification(context.hasPendingMessages())) return;\n await sendSystemNotification(pi, settledNotification({ cwd: context.cwd, sessionName: pi.getSessionName() }));\n });\n }, PACKAGE_SOURCE);\n}\n\n/** The package's single standard Pi factory. */\nexport async function notificationExtension(\n pi: ExtensionAPI,\n options: NotificationExtensionOptions = {},\n): Promise<void> {\n if ((options.environment ?? process.env)[SUBAGENT_CHILD_ENV]) return;\n\n const connection = await connectDoomCordisHost(pi, PACKAGE_SOURCE, {\n environment: options.environment ?? process.env,\n });\n const fiber = connection.root.plugin(notificationPlugin, { pi, options });\n try {\n await fiber;\n } catch (error) {\n try {\n await fiber.dispose();\n } finally {\n await connection.dispose();\n }\n throw error;\n }\n let disposal: Promise<void> | undefined;\n pi.on(\n 'session_shutdown',\n () =>\n (disposal ??= (async () => {\n try {\n await fiber.dispose();\n } finally {\n await connection.dispose();\n }\n })()),\n );\n}\n\nexport default notificationExtension;\n"],"mappings":"4uBAwBA,MAIM,EAAiB,iCAkBvB,SAAS,EACP,EACA,EAC4B,CAC5B,OAAO,EAAG,EACZ,CASA,SAAS,EACP,EACA,EACA,EACY,CACZ,IAAM,EAAkB,EAAgB,EAAI,SA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,mBAAmB,CAAC,GAC7D,MAAM,EAAuB,EAAI,EAAoB,CAAE,IAAK,EAAQ,IAAK,YAAa,EAAG,eAAe,CAAE,CAAC,CAAC,CAC9G,CAAC,CACH,EAAG,CAAc,CACnB,CAGA,eAAsB,EACpB,EACA,EAAwC,CAAC,EAC1B,CACf,IAAK,EAAQ,aAAe,QAAQ,IAAA,CAAK,GAAqB,OAE9D,IAAM,EAAa,MAAM,EAAsB,EAAI,EAAgB,CACjE,YAAa,EAAQ,aAAe,QAAQ,GAC9C,CAAC,EACK,EAAQ,EAAW,KAAK,OAAO,EAAoB,CAAE,KAAI,SAAQ,CAAC,EACxE,GAAI,CACF,MAAM,CACR,OAAS,EAAO,CACd,GAAI,CACF,MAAM,EAAM,QAAQ,CACtB,QAAU,CACR,MAAM,EAAW,QAAQ,CAC3B,CACA,MAAM,CACR,CACA,IAAI,EACJ,EAAG,GACD,uBAEG,KAAc,SAAY,CACzB,GAAI,CACF,MAAM,EAAM,QAAQ,CACtB,QAAU,CACR,MAAM,EAAW,QAAQ,CAC3B,CACF,EAAA,CAAG,CACP,CACF"}
1
+ {"version":3,"file":"extension.mjs","names":[],"sources":["../../../src/adapters/pi/extension.ts"],"sourcesContent":["import {\n DOOM_ASK_USER_BLOCKED_EVENT,\n DOOM_ASK_USER_PROMPT_EVENT,\n} from '@agimon-ai/doompi-extension-contracts/ask-user';\nimport { SUBAGENT_CHILD_ENV } from '@agimon-ai/doompi-extension-contracts/child-process';\nimport {\n connectDoomCordisHost,\n DOOM_CORDIS_SESSION_SERVICE,\n type DoomCordisSessionService,\n} from '@agimon-ai/doompi-extension-contracts/cordis-host';\nimport {\n DOOM_NOTIFICATION_SERVICE,\n type DoomNotificationLevel,\n} from '@agimon-ai/doompi-extension-contracts/notification';\nimport type { Context } from '@deepseek-ai/cordis';\nimport type { ExtensionAPI, ExtensionContext, ExtensionUIContext } from '@earendil-works/pi-coding-agent';\nimport {\n askUserPromptBody,\n supportsShellTitle,\n warrantsAttentionNotification,\n warrantsSettledNotification,\n} from '../../services/notificationPolicy.ts';\nimport {\n attentionNotification,\n promptTitle,\n settledNotification,\n shellTabTitle,\n} from '../../services/notificationText.ts';\nimport type { ShellTitleController, WriteTitle } from '../../types/notifications.ts';\nimport { createDoomNotificationRouter } from '../notificationRouter.ts';\nimport { createWorkerTitleController } from '../shellTitleController.ts';\n\nconst AGENT_SETTLED_EVENT = 'agent_settled';\nconst AGENT_START_EVENT = 'agent_start';\nconst EXTENSION_INPUT_SOURCE = 'extension';\nconst INPUT_EVENT = 'input';\nconst PACKAGE_SOURCE = '@agimon-ai/doompi-notification';\nconst SESSION_START_EVENT = 'session_start';\n\nexport interface NotificationExtensionOptions {\n /** Replaces the worker-thread animator, which a host without worker threads cannot start. */\n titleController?: ShellTitleController;\n environment?: NodeJS.ProcessEnv;\n}\n\n/** Where the tab title is written, remembered so shutdown can restore it without an event. */\ninterface TitleSurface {\n cwd: string;\n write: WriteTitle;\n}\n\ntype WrappedUiMethod = 'confirm' | 'editor' | 'input' | 'notify' | 'select';\n\nconst ORIGINAL_UI_METHOD = Symbol.for('@agimon-ai/doompi-notification/original-ui-method');\n\n/** Capture the true host method even when another bundle copy currently owns the UI. */\nfunction captureUiMethod<Method extends WrappedUiMethod>(\n ui: ExtensionUIContext,\n method: Method,\n): ExtensionUIContext[Method] {\n let captured: unknown = ui[method];\n const seen = new Set<unknown>();\n while (typeof captured === 'function' && !seen.has(captured)) {\n seen.add(captured);\n const original = Reflect.get(captured, ORIGINAL_UI_METHOD) as unknown;\n if (typeof original !== 'function') break;\n captured = original;\n }\n return captured as ExtensionUIContext[Method];\n}\n\nfunction tagUiWrapper(wrapper: object, original: object): void {\n Reflect.defineProperty(wrapper, ORIGINAL_UI_METHOD, {\n configurable: false,\n enumerable: false,\n value: original,\n writable: false,\n });\n}\n\n/**\n * Routes UI notices and announces dialogs the agent opens on its own initiative.\n * Dialog wrappers preserve the original behavior. The notice wrapper replaces\n * host delivery while this plugin owns the UI and restores its exact identity.\n */\nfunction wrapUiNotifications(\n ui: ExtensionUIContext,\n isActive: () => boolean,\n shouldNotifyAttention: () => boolean,\n notifyAttention: (body: string) => void,\n notify: (body: string, level?: DoomNotificationLevel) => void,\n): () => void {\n const originalConfirm = captureUiMethod(ui, 'confirm');\n const wrappedConfirm: ExtensionUIContext['confirm'] = (title, message, options) => {\n if (shouldNotifyAttention()) notifyAttention(`${title}: ${message}`);\n return originalConfirm.call(ui, title, message, options);\n };\n tagUiWrapper(wrappedConfirm, originalConfirm);\n ui.confirm = wrappedConfirm;\n\n const originalSelect = captureUiMethod(ui, 'select');\n const wrappedSelect: ExtensionUIContext['select'] = (title, options, dialogOptions) => {\n if (shouldNotifyAttention()) notifyAttention(title);\n return originalSelect.call(ui, title, options, dialogOptions);\n };\n tagUiWrapper(wrappedSelect, originalSelect);\n ui.select = wrappedSelect;\n\n const originalInput = captureUiMethod(ui, 'input');\n const wrappedInput: ExtensionUIContext['input'] = (title, placeholder, options) => {\n if (shouldNotifyAttention()) notifyAttention(title);\n return originalInput.call(ui, title, placeholder, options);\n };\n tagUiWrapper(wrappedInput, originalInput);\n ui.input = wrappedInput;\n\n const originalEditor = captureUiMethod(ui, 'editor');\n const wrappedEditor: ExtensionUIContext['editor'] = (title, prefill) => {\n if (shouldNotifyAttention()) notifyAttention(title);\n return originalEditor.call(ui, title, prefill);\n };\n tagUiWrapper(wrappedEditor, originalEditor);\n ui.editor = wrappedEditor;\n\n const originalNotify = captureUiMethod(ui, 'notify');\n const wrappedNotify: ExtensionUIContext['notify'] = (message, level) => {\n if (isActive()) notify(message, level);\n else originalNotify.call(ui, message, level);\n };\n tagUiWrapper(wrappedNotify, originalNotify);\n ui.notify = wrappedNotify;\n\n return () => {\n if (ui.confirm === wrappedConfirm) ui.confirm = originalConfirm;\n if (ui.select === wrappedSelect) ui.select = originalSelect;\n if (ui.input === wrappedInput) ui.input = originalInput;\n if (ui.editor === wrappedEditor) ui.editor = originalEditor;\n if (ui.notify === wrappedNotify) ui.notify = originalNotify;\n };\n}\n\ninterface NotificationPluginConfig {\n readonly generation: string;\n readonly pi: ExtensionAPI;\n readonly options: NotificationExtensionOptions;\n}\n\nfunction notificationPlugin(cordis: Context, { generation, pi, options }: NotificationPluginConfig): void {\n let activeContext: ExtensionContext | undefined;\n const router = createDoomNotificationRouter({ generation, pi, context: () => activeContext });\n cordis.provide(DOOM_NOTIFICATION_SERVICE, router);\n cordis.inject([DOOM_CORDIS_SESSION_SERVICE], (sessionContext) => {\n const session = sessionContext.get(DOOM_CORDIS_SESSION_SERVICE) as DoomCordisSessionService;\n const context = session.context;\n activeContext = context;\n return () => {\n if (activeContext === context) activeContext = undefined;\n };\n });\n\n cordis.effect(function* () {\n const titles = options.titleController ?? createWorkerTitleController();\n const wrappedUis = new Map<ExtensionUIContext, () => void>();\n let active = true;\n let agentRunning = false;\n let askUserBlocked = false;\n let firstPrompt: string | undefined;\n let surface: TitleSurface | undefined;\n\n const idleTitle = (cwd: string): string =>\n shellTabTitle({ cwd, sessionName: pi.getSessionName(), prompt: firstPrompt });\n const titleSurface = (context: ExtensionContext): TitleSurface | undefined => {\n if (!active || !supportsShellTitle(context)) return undefined;\n surface = { cwd: context.cwd, write: (title) => context.ui.setTitle(title) };\n return surface;\n };\n const notifyAttention = (body: string): void => {\n if (active) void router.request(attentionNotification(body));\n };\n\n yield cordis.on(DOOM_ASK_USER_PROMPT_EVENT, (prompt) => {\n notifyAttention(askUserPromptBody(prompt.questions));\n });\n yield cordis.on(DOOM_ASK_USER_BLOCKED_EVENT, (payload) => {\n askUserBlocked = payload.active;\n });\n\n yield () => {\n if (surface) titles.dispose(idleTitle(surface.cwd), surface.write);\n surface = undefined;\n };\n yield () => {\n for (const restore of wrappedUis.values()) restore();\n wrappedUis.clear();\n };\n yield () => {\n active = false;\n agentRunning = false;\n askUserBlocked = false;\n };\n\n pi.on(INPUT_EVENT, (event, context) => {\n if (!active || firstPrompt || event.source === EXTENSION_INPUT_SOURCE) return;\n activeContext = context;\n firstPrompt = promptTitle(event.text);\n const target = firstPrompt ? titleSurface(context) : undefined;\n if (target) titles.set(idleTitle(target.cwd), target.write);\n });\n\n pi.on(SESSION_START_EVENT, (_event, context) => {\n if (!active || wrappedUis.has(context.ui)) return;\n activeContext = context;\n wrappedUis.set(\n context.ui,\n wrapUiNotifications(\n context.ui,\n () => active,\n () => active && warrantsAttentionNotification({ agentRunning, askUserBlocked }),\n notifyAttention,\n (body, level) => void router.request({ body, ...(level ? { level } : {}) }),\n ),\n );\n });\n\n pi.on(AGENT_START_EVENT, (_event, context) => {\n if (!active) return;\n activeContext = context;\n agentRunning = true;\n const target = titleSurface(context);\n if (target) titles.start(idleTitle(target.cwd), target.write);\n });\n\n pi.on(AGENT_SETTLED_EVENT, async (_event, context) => {\n if (!active) return;\n activeContext = context;\n agentRunning = false;\n askUserBlocked = false;\n const target = titleSurface(context);\n if (target) titles.stop(idleTitle(target.cwd), target.write);\n if (!warrantsSettledNotification(context.hasPendingMessages())) return;\n await router.request(settledNotification({ cwd: context.cwd, sessionName: pi.getSessionName() }));\n });\n }, PACKAGE_SOURCE);\n}\n\n/** The package's single standard Pi factory. */\nexport async function notificationExtension(\n pi: ExtensionAPI,\n options: NotificationExtensionOptions = {},\n): Promise<void> {\n if ((options.environment ?? process.env)[SUBAGENT_CHILD_ENV]) return;\n\n const connection = await connectDoomCordisHost(pi, PACKAGE_SOURCE, {\n environment: options.environment ?? process.env,\n });\n const fiber = connection.root.plugin(notificationPlugin, {\n generation: `${connection.runtime.generation}:notification`,\n pi,\n options,\n });\n try {\n await fiber;\n } catch (error) {\n try {\n await fiber.dispose();\n } finally {\n await connection.dispose();\n }\n throw error;\n }\n let disposal: Promise<void> | undefined;\n pi.on(\n 'session_shutdown',\n () =>\n (disposal ??= (async () => {\n try {\n await fiber.dispose();\n } finally {\n await connection.dispose();\n }\n })()),\n );\n}\n\nexport default notificationExtension;\n"],"mappings":"k3BAgCA,MAIM,EAAiB,iCAiBjB,EAAqB,OAAO,IAAI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AAQ,mBAAmB,CAAC,GAC7D,MAAM,EAAO,QAAQ,EAAoB,CAAE,IAAK,EAAQ,IAAK,YAAa,EAAG,eAAe,CAAE,CAAC,CAAC,CAClG,CAAC,CACH,EAAG,CAAc,CACnB,CAGA,eAAsB,EACpB,EACA,EAAwC,CAAC,EAC1B,CACf,IAAK,EAAQ,aAAe,QAAQ,IAAA,CAAK,GAAqB,OAE9D,IAAM,EAAa,MAAM,EAAsB,EAAI,EAAgB,CACjE,YAAa,EAAQ,aAAe,QAAQ,GAC9C,CAAC,EACK,EAAQ,EAAW,KAAK,OAAO,EAAoB,CACvD,WAAY,GAAG,EAAW,QAAQ,WAAW,eAC7C,KACA,SACF,CAAC,EACD,GAAI,CACF,MAAM,CACR,OAAS,EAAO,CACd,GAAI,CACF,MAAM,EAAM,QAAQ,CACtB,QAAU,CACR,MAAM,EAAW,QAAQ,CAC3B,CACA,MAAM,CACR,CACA,IAAI,EACJ,EAAG,GACD,uBAEG,KAAc,SAAY,CACzB,GAAI,CACF,MAAM,EAAM,QAAQ,CACtB,QAAU,CACR,MAAM,EAAW,QAAQ,CAC3B,CACF,EAAA,CAAG,CACP,CACF"}
@@ -1,4 +1,4 @@
1
- let e=require("node:worker_threads");const t=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`];function n(){let e=0,n,r=()=>{n&&clearInterval(n),n=void 0,e=0};return{set(e,t){r(),t(e)},start(i,a){r();let o=()=>{a(`${t[e%t.length]} ${i}`),e+=1};o(),n=setInterval(o,80)},stop(e,t){r(),t(e)},dispose(e,t){r(),t(e)}}}function r(){let r=n(),i,a,o,s=()=>{o=void 0,!(!i||!a)&&r[i.action](i.title,a)};try{let n=new e.Worker(`
1
+ let e=require("node:worker_threads");const t=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`];function n(){let e=0,n,r=()=>{n&&clearInterval(n),n=void 0,e=0};return{set(e,t){r(),t(e)},start(i,a){r();let o=()=>{a(`${t[e%t.length]} ${i}`),e+=1};o(),n=setInterval(o,80)},stop(e,t){r(),t(e)},dispose(e,t){r(),t(e)}}}function r(){let r=n(),i,a,o,s=()=>{o=void 0,i&&a&&r[i.action](i.title,a)};try{let n=new e.Worker(`
2
2
  const { writeSync } = require('node:fs');
3
3
  const { parentPort, workerData } = require('node:worker_threads');
4
4
  let frameIndex = 0;
@@ -1 +1 @@
1
- {"version":3,"file":"shellTitleController.cjs","names":["Worker"],"sources":["../../src/adapters/shellTitleController.ts"],"sourcesContent":["import { Worker } from 'node:worker_threads';\nimport type { ShellTitleCommand, ShellTitleController, WriteTitle } from '../types/notifications.ts';\n\nconst BRAILLE_FRAMES = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];\nconst TITLE_FRAME_INTERVAL_MS = 80;\n/**\n * The animator runs off the main thread so a busy agent turn cannot stall the\n * spinner. It is an inline eval source rather than a shipped file because the\n * package is bundled per entry, and a separate worker module would have to be\n * located on disk at runtime.\n */\nconst TITLE_WORKER_SOURCE = `\nconst { writeSync } = require('node:fs');\nconst { parentPort, workerData } = require('node:worker_threads');\nlet frameIndex = 0;\nlet timer;\nconst writeTitle = (title) => writeSync(1, '\\\\u001b]0;' + title + '\\\\u0007');\nconst stop = () => {\n if (timer) clearInterval(timer);\n timer = undefined;\n frameIndex = 0;\n};\nparentPort.on('message', (command) => {\n stop();\n if (command.action === 'start') {\n const render = () => {\n writeTitle(workerData.frames[frameIndex % workerData.frames.length] + ' ' + command.title);\n frameIndex += 1;\n };\n render();\n timer = setInterval(render, workerData.intervalMs);\n return;\n }\n writeTitle(command.title);\n if (command.action === 'dispose') parentPort.close();\n});\n`;\n\n/** Animates on the main thread, for hosts where a worker could not be started. */\nexport function createMainThreadTitleController(): ShellTitleController {\n let frameIndex = 0;\n let timer: ReturnType<typeof setInterval> | undefined;\n const stopAnimation = () => {\n if (timer) clearInterval(timer);\n timer = undefined;\n frameIndex = 0;\n };\n\n return {\n set(title, write) {\n stopAnimation();\n write(title);\n },\n start(title, write) {\n stopAnimation();\n const render = () => {\n write(`${BRAILLE_FRAMES[frameIndex % BRAILLE_FRAMES.length]} ${title}`);\n frameIndex += 1;\n };\n render();\n timer = setInterval(render, TITLE_FRAME_INTERVAL_MS);\n },\n stop(title, write) {\n stopAnimation();\n write(title);\n },\n dispose(title, write) {\n stopAnimation();\n write(title);\n },\n };\n}\n\n/**\n * Animates from a worker thread, replaying the last command on the main thread\n * if the worker never started, failed, or exited under us. The worker is\n * unreferenced so a pending frame never holds the process open.\n */\nexport function createWorkerTitleController(): ShellTitleController {\n const fallback = createMainThreadTitleController();\n let lastCommand: ShellTitleCommand | undefined;\n let lastWrite: WriteTitle | undefined;\n let worker: Worker | undefined;\n\n const fallBack = () => {\n worker = undefined;\n if (!lastCommand || !lastWrite) return;\n fallback[lastCommand.action](lastCommand.title, lastWrite);\n };\n\n try {\n const titleWorker = new Worker(TITLE_WORKER_SOURCE, {\n eval: true,\n workerData: { frames: BRAILLE_FRAMES, intervalMs: TITLE_FRAME_INTERVAL_MS },\n });\n titleWorker.unref();\n titleWorker.once('error', fallBack);\n titleWorker.once('exit', (code) => {\n if (code !== 0 && worker === titleWorker) fallBack();\n });\n worker = titleWorker;\n } catch {\n // Workers are unavailable on this host, which the main-thread animator covers.\n worker = undefined;\n }\n\n const dispatch = (command: ShellTitleCommand, write: WriteTitle) => {\n lastCommand = command;\n lastWrite = write;\n if (!worker) {\n fallback[command.action](command.title, write);\n return;\n }\n try {\n worker.postMessage(command);\n } catch {\n // The worker closed between the last frame and this command.\n fallBack();\n }\n };\n\n return {\n set: (title, write) => dispatch({ action: 'set', title }, write),\n start: (title, write) => dispatch({ action: 'start', title }, write),\n stop: (title, write) => dispatch({ action: 'stop', title }, write),\n dispose: (title, write) => dispatch({ action: 'dispose', title }, write),\n };\n}\n"],"mappings":"qCAGA,MAAM,EAAiB,CAAC,IAAK,IAAK,I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S,CACX,CACF,EAEA,MAAO,CACL,KAAM,EAAO,IAAU,EAAS,CAAE,OAAQ,MAAO,OAAM,EAAG,CAAK,EAC/D,OAAQ,EAAO,IAAU,EAAS,CAAE,OAAQ,QAAS,OAAM,EAAG,CAAK,EACnE,MAAO,EAAO,IAAU,EAAS,CAAE,OAAQ,OAAQ,OAAM,EAAG,CAAK,EACjE,SAAU,EAAO,IAAU,EAAS,CAAE,OAAQ,UAAW,OAAM,EAAG,CAAK,CACzE,CACF"}
1
+ {"version":3,"file":"shellTitleController.cjs","names":["Worker"],"sources":["../../src/adapters/shellTitleController.ts"],"sourcesContent":["import { Worker } from 'node:worker_threads';\nimport type { ShellTitleCommand, ShellTitleController, WriteTitle } from '../types/notifications.ts';\n\nconst BRAILLE_FRAMES = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];\nconst TITLE_FRAME_INTERVAL_MS = 80;\n/**\n * The animator runs off the main thread so a busy agent turn cannot stall the\n * spinner. It is an inline eval source rather than a shipped file because the\n * package is bundled per entry, and a separate worker module would have to be\n * located on disk at runtime.\n */\nconst TITLE_WORKER_SOURCE = `\nconst { writeSync } = require('node:fs');\nconst { parentPort, workerData } = require('node:worker_threads');\nlet frameIndex = 0;\nlet timer;\nconst writeTitle = (title) => writeSync(1, '\\\\u001b]0;' + title + '\\\\u0007');\nconst stop = () => {\n if (timer) clearInterval(timer);\n timer = undefined;\n frameIndex = 0;\n};\nparentPort.on('message', (command) => {\n stop();\n if (command.action === 'start') {\n const render = () => {\n writeTitle(workerData.frames[frameIndex % workerData.frames.length] + ' ' + command.title);\n frameIndex += 1;\n };\n render();\n timer = setInterval(render, workerData.intervalMs);\n return;\n }\n writeTitle(command.title);\n if (command.action === 'dispose') parentPort.close();\n});\n`;\n\n/** Animates on the main thread, for hosts where a worker could not be started. */\nexport function createMainThreadTitleController(): ShellTitleController {\n let frameIndex = 0;\n let timer: ReturnType<typeof setInterval> | undefined;\n const stopAnimation = () => {\n if (timer) clearInterval(timer);\n timer = undefined;\n frameIndex = 0;\n };\n\n return {\n set(title, write) {\n stopAnimation();\n write(title);\n },\n start(title, write) {\n stopAnimation();\n const render = () => {\n write(`${BRAILLE_FRAMES[frameIndex % BRAILLE_FRAMES.length]} ${title}`);\n frameIndex += 1;\n };\n render();\n timer = setInterval(render, TITLE_FRAME_INTERVAL_MS);\n },\n stop(title, write) {\n stopAnimation();\n write(title);\n },\n dispose(title, write) {\n stopAnimation();\n write(title);\n },\n };\n}\n\n/**\n * Animates from a worker thread, replaying the last command on the main thread\n * if the worker never started, failed, or exited under us. The worker is\n * unreferenced so a pending frame never holds the process open.\n */\nexport function createWorkerTitleController(): ShellTitleController {\n const fallback = createMainThreadTitleController();\n let lastCommand: ShellTitleCommand | undefined;\n let lastWrite: WriteTitle | undefined;\n let worker: Worker | undefined;\n\n const fallBack = () => {\n worker = undefined;\n if (!lastCommand || !lastWrite) return;\n fallback[lastCommand.action](lastCommand.title, lastWrite);\n };\n\n try {\n const titleWorker = new Worker(TITLE_WORKER_SOURCE, {\n eval: true,\n workerData: { frames: BRAILLE_FRAMES, intervalMs: TITLE_FRAME_INTERVAL_MS },\n });\n titleWorker.unref();\n titleWorker.once('error', fallBack);\n titleWorker.once('exit', (code) => {\n if (code !== 0 && worker === titleWorker) fallBack();\n });\n worker = titleWorker;\n } catch {\n // Workers are unavailable on this host, which the main-thread animator covers.\n worker = undefined;\n }\n\n const dispatch = (command: ShellTitleCommand, write: WriteTitle) => {\n lastCommand = command;\n lastWrite = write;\n if (!worker) {\n fallback[command.action](command.title, write);\n return;\n }\n try {\n worker.postMessage(command);\n } catch {\n // The worker closed between the last frame and this command.\n fallBack();\n }\n };\n\n return {\n set: (title, write) => dispatch({ action: 'set', title }, write),\n start: (title, write) => dispatch({ action: 'start', title }, write),\n stop: (title, write) => dispatch({ action: 'stop', title }, write),\n dispose: (title, write) => dispatch({ action: 'dispose', title }, write),\n };\n}\n"],"mappings":"qCAGA,MAAM,EA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AQ,CAEN,EAAS,CACX,CACF,EAEA,MAAO,CACL,KAAM,EAAO,IAAU,EAAS,CAAE,OAAQ,MAAO,OAAM,EAAG,CAAK,EAC/D,OAAQ,EAAO,IAAU,EAAS,CAAE,OAAQ,QAAS,OAAM,EAAG,CAAK,EACnE,MAAO,EAAO,IAAU,EAAS,CAAE,OAAQ,OAAQ,OAAM,EAAG,CAAK,EACjE,SAAU,EAAO,IAAU,EAAS,CAAE,OAAQ,UAAW,OAAM,EAAG,CAAK,CACzE,CACF"}
@@ -1,13 +1,12 @@
1
1
  import { ShellTitleController } from "../types/notifications.cjs";
2
2
  //#region src/adapters/shellTitleController.d.ts
3
3
  /** Animates on the main thread, for hosts where a worker could not be started. */
4
- declare function createMainThreadTitleController(): ShellTitleController;
4
+ export declare function createMainThreadTitleController(): ShellTitleController;
5
5
  /**
6
6
  * Animates from a worker thread, replaying the last command on the main thread
7
7
  * if the worker never started, failed, or exited under us. The worker is
8
8
  * unreferenced so a pending frame never holds the process open.
9
9
  */
10
- declare function createWorkerTitleController(): ShellTitleController;
10
+ export declare function createWorkerTitleController(): ShellTitleController;
11
11
  //#endregion
12
- export { createMainThreadTitleController, createWorkerTitleController };
13
12
  //# sourceMappingURL=shellTitleController.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shellTitleController.d.cts","names":[],"sources":["../../src/adapters/shellTitleController.ts"],"mappings":";;;iBAuCgB,mCAAmC;;;;;;iBAuCnC,+BAA+B"}
1
+ {"version":3,"file":"shellTitleController.d.cts","names":[],"sources":["../../src/adapters/shellTitleController.ts"],"mappings":";;;wBAuCgB,mCAAmC;;;;;;wBAuCnC,+BAA+B"}
@@ -1,13 +1,12 @@
1
1
  import { ShellTitleController } from "../types/notifications.mjs";
2
2
  //#region src/adapters/shellTitleController.d.ts
3
3
  /** Animates on the main thread, for hosts where a worker could not be started. */
4
- declare function createMainThreadTitleController(): ShellTitleController;
4
+ export declare function createMainThreadTitleController(): ShellTitleController;
5
5
  /**
6
6
  * Animates from a worker thread, replaying the last command on the main thread
7
7
  * if the worker never started, failed, or exited under us. The worker is
8
8
  * unreferenced so a pending frame never holds the process open.
9
9
  */
10
- declare function createWorkerTitleController(): ShellTitleController;
10
+ export declare function createWorkerTitleController(): ShellTitleController;
11
11
  //#endregion
12
- export { createMainThreadTitleController, createWorkerTitleController };
13
12
  //# sourceMappingURL=shellTitleController.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shellTitleController.d.mts","names":[],"sources":["../../src/adapters/shellTitleController.ts"],"mappings":";;;iBAuCgB,mCAAmC;;;;;;iBAuCnC,+BAA+B"}
1
+ {"version":3,"file":"shellTitleController.d.mts","names":[],"sources":["../../src/adapters/shellTitleController.ts"],"mappings":";;;wBAuCgB,mCAAmC;;;;;;wBAuCnC,+BAA+B"}
@@ -1,4 +1,4 @@
1
- import{Worker as e}from"node:worker_threads";const t=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`];function n(){let e=0,n,r=()=>{n&&clearInterval(n),n=void 0,e=0};return{set(e,t){r(),t(e)},start(i,a){r();let o=()=>{a(`${t[e%t.length]} ${i}`),e+=1};o(),n=setInterval(o,80)},stop(e,t){r(),t(e)},dispose(e,t){r(),t(e)}}}function r(){let r=n(),i,a,o,s=()=>{o=void 0,!(!i||!a)&&r[i.action](i.title,a)};try{let n=new e(`
1
+ import{Worker as e}from"node:worker_threads";const t=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`];function n(){let e=0,n,r=()=>{n&&clearInterval(n),n=void 0,e=0};return{set(e,t){r(),t(e)},start(i,a){r();let o=()=>{a(`${t[e%t.length]} ${i}`),e+=1};o(),n=setInterval(o,80)},stop(e,t){r(),t(e)},dispose(e,t){r(),t(e)}}}function r(){let r=n(),i,a,o,s=()=>{o=void 0,i&&a&&r[i.action](i.title,a)};try{let n=new e(`
2
2
  const { writeSync } = require('node:fs');
3
3
  const { parentPort, workerData } = require('node:worker_threads');
4
4
  let frameIndex = 0;
@@ -1 +1 @@
1
- {"version":3,"file":"shellTitleController.mjs","names":[],"sources":["../../src/adapters/shellTitleController.ts"],"sourcesContent":["import { Worker } from 'node:worker_threads';\nimport type { ShellTitleCommand, ShellTitleController, WriteTitle } from '../types/notifications.ts';\n\nconst BRAILLE_FRAMES = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];\nconst TITLE_FRAME_INTERVAL_MS = 80;\n/**\n * The animator runs off the main thread so a busy agent turn cannot stall the\n * spinner. It is an inline eval source rather than a shipped file because the\n * package is bundled per entry, and a separate worker module would have to be\n * located on disk at runtime.\n */\nconst TITLE_WORKER_SOURCE = `\nconst { writeSync } = require('node:fs');\nconst { parentPort, workerData } = require('node:worker_threads');\nlet frameIndex = 0;\nlet timer;\nconst writeTitle = (title) => writeSync(1, '\\\\u001b]0;' + title + '\\\\u0007');\nconst stop = () => {\n if (timer) clearInterval(timer);\n timer = undefined;\n frameIndex = 0;\n};\nparentPort.on('message', (command) => {\n stop();\n if (command.action === 'start') {\n const render = () => {\n writeTitle(workerData.frames[frameIndex % workerData.frames.length] + ' ' + command.title);\n frameIndex += 1;\n };\n render();\n timer = setInterval(render, workerData.intervalMs);\n return;\n }\n writeTitle(command.title);\n if (command.action === 'dispose') parentPort.close();\n});\n`;\n\n/** Animates on the main thread, for hosts where a worker could not be started. */\nexport function createMainThreadTitleController(): ShellTitleController {\n let frameIndex = 0;\n let timer: ReturnType<typeof setInterval> | undefined;\n const stopAnimation = () => {\n if (timer) clearInterval(timer);\n timer = undefined;\n frameIndex = 0;\n };\n\n return {\n set(title, write) {\n stopAnimation();\n write(title);\n },\n start(title, write) {\n stopAnimation();\n const render = () => {\n write(`${BRAILLE_FRAMES[frameIndex % BRAILLE_FRAMES.length]} ${title}`);\n frameIndex += 1;\n };\n render();\n timer = setInterval(render, TITLE_FRAME_INTERVAL_MS);\n },\n stop(title, write) {\n stopAnimation();\n write(title);\n },\n dispose(title, write) {\n stopAnimation();\n write(title);\n },\n };\n}\n\n/**\n * Animates from a worker thread, replaying the last command on the main thread\n * if the worker never started, failed, or exited under us. The worker is\n * unreferenced so a pending frame never holds the process open.\n */\nexport function createWorkerTitleController(): ShellTitleController {\n const fallback = createMainThreadTitleController();\n let lastCommand: ShellTitleCommand | undefined;\n let lastWrite: WriteTitle | undefined;\n let worker: Worker | undefined;\n\n const fallBack = () => {\n worker = undefined;\n if (!lastCommand || !lastWrite) return;\n fallback[lastCommand.action](lastCommand.title, lastWrite);\n };\n\n try {\n const titleWorker = new Worker(TITLE_WORKER_SOURCE, {\n eval: true,\n workerData: { frames: BRAILLE_FRAMES, intervalMs: TITLE_FRAME_INTERVAL_MS },\n });\n titleWorker.unref();\n titleWorker.once('error', fallBack);\n titleWorker.once('exit', (code) => {\n if (code !== 0 && worker === titleWorker) fallBack();\n });\n worker = titleWorker;\n } catch {\n // Workers are unavailable on this host, which the main-thread animator covers.\n worker = undefined;\n }\n\n const dispatch = (command: ShellTitleCommand, write: WriteTitle) => {\n lastCommand = command;\n lastWrite = write;\n if (!worker) {\n fallback[command.action](command.title, write);\n return;\n }\n try {\n worker.postMessage(command);\n } catch {\n // The worker closed between the last frame and this command.\n fallBack();\n }\n };\n\n return {\n set: (title, write) => dispatch({ action: 'set', title }, write),\n start: (title, write) => dispatch({ action: 'start', title }, write),\n stop: (title, write) => dispatch({ action: 'stop', title }, write),\n dispose: (title, write) => dispatch({ action: 'dispose', title }, write),\n };\n}\n"],"mappings":"6CAGA,MAAM,EAAiB,CAAC,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,GAAG,EAoCxE,SAAgB,GAAwD,CACtE,IAAI,EAAa,EACb,EACE,MAAsB,CACtB,GAAO,cAAc,CAAK,EAC9B,EAAQ,IAAA,GACR,EAAa,CACf,EAEA,MAAO,CACL,IAAI,EAAO,EAAO,CAChB,EAAc,EACd,EAAM,CAAK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AAU,EAAO,IAAU,EAAS,CAAE,OAAQ,UAAW,OAAM,EAAG,CAAK,CACzE,CACF"}
1
+ {"version":3,"file":"shellTitleController.mjs","names":[],"sources":["../../src/adapters/shellTitleController.ts"],"sourcesContent":["import { Worker } from 'node:worker_threads';\nimport type { ShellTitleCommand, ShellTitleController, WriteTitle } from '../types/notifications.ts';\n\nconst BRAILLE_FRAMES = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];\nconst TITLE_FRAME_INTERVAL_MS = 80;\n/**\n * The animator runs off the main thread so a busy agent turn cannot stall the\n * spinner. It is an inline eval source rather than a shipped file because the\n * package is bundled per entry, and a separate worker module would have to be\n * located on disk at runtime.\n */\nconst TITLE_WORKER_SOURCE = `\nconst { writeSync } = require('node:fs');\nconst { parentPort, workerData } = require('node:worker_threads');\nlet frameIndex = 0;\nlet timer;\nconst writeTitle = (title) => writeSync(1, '\\\\u001b]0;' + title + '\\\\u0007');\nconst stop = () => {\n if (timer) clearInterval(timer);\n timer = undefined;\n frameIndex = 0;\n};\nparentPort.on('message', (command) => {\n stop();\n if (command.action === 'start') {\n const render = () => {\n writeTitle(workerData.frames[frameIndex % workerData.frames.length] + ' ' + command.title);\n frameIndex += 1;\n };\n render();\n timer = setInterval(render, workerData.intervalMs);\n return;\n }\n writeTitle(command.title);\n if (command.action === 'dispose') parentPort.close();\n});\n`;\n\n/** Animates on the main thread, for hosts where a worker could not be started. */\nexport function createMainThreadTitleController(): ShellTitleController {\n let frameIndex = 0;\n let timer: ReturnType<typeof setInterval> | undefined;\n const stopAnimation = () => {\n if (timer) clearInterval(timer);\n timer = undefined;\n frameIndex = 0;\n };\n\n return {\n set(title, write) {\n stopAnimation();\n write(title);\n },\n start(title, write) {\n stopAnimation();\n const render = () => {\n write(`${BRAILLE_FRAMES[frameIndex % BRAILLE_FRAMES.length]} ${title}`);\n frameIndex += 1;\n };\n render();\n timer = setInterval(render, TITLE_FRAME_INTERVAL_MS);\n },\n stop(title, write) {\n stopAnimation();\n write(title);\n },\n dispose(title, write) {\n stopAnimation();\n write(title);\n },\n };\n}\n\n/**\n * Animates from a worker thread, replaying the last command on the main thread\n * if the worker never started, failed, or exited under us. The worker is\n * unreferenced so a pending frame never holds the process open.\n */\nexport function createWorkerTitleController(): ShellTitleController {\n const fallback = createMainThreadTitleController();\n let lastCommand: ShellTitleCommand | undefined;\n let lastWrite: WriteTitle | undefined;\n let worker: Worker | undefined;\n\n const fallBack = () => {\n worker = undefined;\n if (!lastCommand || !lastWrite) return;\n fallback[lastCommand.action](lastCommand.title, lastWrite);\n };\n\n try {\n const titleWorker = new Worker(TITLE_WORKER_SOURCE, {\n eval: true,\n workerData: { frames: BRAILLE_FRAMES, intervalMs: TITLE_FRAME_INTERVAL_MS },\n });\n titleWorker.unref();\n titleWorker.once('error', fallBack);\n titleWorker.once('exit', (code) => {\n if (code !== 0 && worker === titleWorker) fallBack();\n });\n worker = titleWorker;\n } catch {\n // Workers are unavailable on this host, which the main-thread animator covers.\n worker = undefined;\n }\n\n const dispatch = (command: ShellTitleCommand, write: WriteTitle) => {\n lastCommand = command;\n lastWrite = write;\n if (!worker) {\n fallback[command.action](command.title, write);\n return;\n }\n try {\n worker.postMessage(command);\n } catch {\n // The worker closed between the last frame and this command.\n fallBack();\n }\n };\n\n return {\n set: (title, write) => dispatch({ action: 'set', title }, write),\n start: (title, write) => dispatch({ action: 'start', title }, write),\n stop: (title, write) => dispatch({ action: 'stop', title }, write),\n dispose: (title, write) => dispatch({ action: 'dispose', title }, write),\n };\n}\n"],"mappings":"6CAGA,MAAM,EAAiB,CAAC,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,GAAG,EAoCxE,SAAgB,GAAwD,CACtE,IAAI,EAAa,EACb,EACE,MAAsB,CACtB,GAAO,cAAc,CAAK,EAC9B,EAAQ,IAAA,GACR,EAAa,CACf,EAEA,MAAO,CACL,IAAI,EAAO,EAAO,CAChB,EAAc,EACd,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SAAU,EAAO,IAAU,EAAS,CAAE,OAAQ,UAAW,OAAM,EAAG,CAAK,CACzE,CACF"}
@@ -8,7 +8,6 @@ import { ExtensionAPI } from "@earendil-works/pi-coding-agent";
8
8
  * session actually lives in. Only macOS has a second option worth attempting,
9
9
  * and a host with neither stays silent rather than failing the turn.
10
10
  */
11
- declare function sendSystemNotification(pi: ExtensionAPI, notification: DesktopNotification, platform?: string): Promise<void>;
11
+ export declare function sendSystemNotification(pi: ExtensionAPI, notification: DesktopNotification, platform?: string): Promise<void>;
12
12
  //#endregion
13
- export { sendSystemNotification };
14
13
  //# sourceMappingURL=systemNotification.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"systemNotification.d.cts","names":[],"sources":["../../src/adapters/systemNotification.ts"],"mappings":";;;;;;;;;;iBA4BsB,uBACpB,IAAI,cACJ,cAAc,qBACd,oBACC"}
1
+ {"version":3,"file":"systemNotification.d.cts","names":[],"sources":["../../src/adapters/systemNotification.ts"],"mappings":";;;;;;;;;;wBA4BsB,uBACpB,IAAI,cACJ,cAAc,qBACd,oBACC"}
@@ -8,7 +8,6 @@ import { ExtensionAPI } from "@earendil-works/pi-coding-agent";
8
8
  * session actually lives in. Only macOS has a second option worth attempting,
9
9
  * and a host with neither stays silent rather than failing the turn.
10
10
  */
11
- declare function sendSystemNotification(pi: ExtensionAPI, notification: DesktopNotification, platform?: string): Promise<void>;
11
+ export declare function sendSystemNotification(pi: ExtensionAPI, notification: DesktopNotification, platform?: string): Promise<void>;
12
12
  //#endregion
13
- export { sendSystemNotification };
14
13
  //# sourceMappingURL=systemNotification.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"systemNotification.d.mts","names":[],"sources":["../../src/adapters/systemNotification.ts"],"mappings":";;;;;;;;;;iBA4BsB,uBACpB,IAAI,cACJ,cAAc,qBACd,oBACC"}
1
+ {"version":3,"file":"systemNotification.d.mts","names":[],"sources":["../../src/adapters/systemNotification.ts"],"mappings":";;;;;;;;;;wBA4BsB,uBACpB,IAAI,cACJ,cAAc,qBACd,oBACC"}
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./services/notificationPolicy.cjs"),t=require("./services/notificationText.cjs"),n=require("./adapters/shellTitleController.cjs"),r=require("./adapters/systemNotification.cjs"),i=require("./adapters/pi/extension.cjs");exports.askUserPromptBody=e.askUserPromptBody,exports.attentionNotification=t.attentionNotification,exports.createMainThreadTitleController=n.createMainThreadTitleController,exports.createWorkerTitleController=n.createWorkerTitleController,exports.notificationBody=t.notificationBody,exports.notificationExtension=i.default,exports.promptTitle=t.promptTitle,exports.sendSystemNotification=r.sendSystemNotification,exports.settledNotification=t.settledNotification,exports.shellTabTitle=t.shellTabTitle,exports.supportsShellTitle=e.supportsShellTitle,exports.warrantsAttentionNotification=e.warrantsAttentionNotification,exports.warrantsSettledNotification=e.warrantsSettledNotification;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./services/notificationPolicy.cjs"),t=require("./services/notificationText.cjs"),n=require("./adapters/systemNotification.cjs"),r=require("./adapters/shellTitleController.cjs"),i=require("./adapters/pi/extension.cjs");exports.askUserPromptBody=e.askUserPromptBody,exports.attentionNotification=t.attentionNotification,exports.createMainThreadTitleController=r.createMainThreadTitleController,exports.createWorkerTitleController=r.createWorkerTitleController,exports.notificationBody=t.notificationBody,exports.notificationExtension=i.default,exports.promptTitle=t.promptTitle,exports.sendSystemNotification=n.sendSystemNotification,exports.settledNotification=t.settledNotification,exports.shellTabTitle=t.shellTabTitle,exports.supportsShellTitle=e.supportsShellTitle,exports.warrantsAttentionNotification=e.warrantsAttentionNotification,exports.warrantsSettledNotification=e.warrantsSettledNotification;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{askUserPromptBody as e,supportsShellTitle as t,warrantsAttentionNotification as n,warrantsSettledNotification as r}from"./services/notificationPolicy.mjs";import{attentionNotification as i,notificationBody as a,promptTitle as o,settledNotification as s,shellTabTitle as c}from"./services/notificationText.mjs";import{createMainThreadTitleController as l,createWorkerTitleController as u}from"./adapters/shellTitleController.mjs";import{sendSystemNotification as d}from"./adapters/systemNotification.mjs";import f from"./adapters/pi/extension.mjs";export{e as askUserPromptBody,i as attentionNotification,l as createMainThreadTitleController,u as createWorkerTitleController,a as notificationBody,f as notificationExtension,o as promptTitle,d as sendSystemNotification,s as settledNotification,c as shellTabTitle,t as supportsShellTitle,n as warrantsAttentionNotification,r as warrantsSettledNotification};
1
+ import{askUserPromptBody as e,supportsShellTitle as t,warrantsAttentionNotification as n,warrantsSettledNotification as r}from"./services/notificationPolicy.mjs";import{attentionNotification as i,notificationBody as a,promptTitle as o,settledNotification as s,shellTabTitle as c}from"./services/notificationText.mjs";import{sendSystemNotification as l}from"./adapters/systemNotification.mjs";import{createMainThreadTitleController as u,createWorkerTitleController as d}from"./adapters/shellTitleController.mjs";import f from"./adapters/pi/extension.mjs";export{e as askUserPromptBody,i as attentionNotification,u as createMainThreadTitleController,d as createWorkerTitleController,a as notificationBody,f as notificationExtension,o as promptTitle,l as sendSystemNotification,s as settledNotification,c as shellTabTitle,t as supportsShellTitle,n as warrantsAttentionNotification,r as warrantsSettledNotification};
@@ -1,9 +1,9 @@
1
1
  //#region src/services/notificationPolicy.d.ts
2
- interface AttentionState {
2
+ export interface AttentionState {
3
3
  agentRunning: boolean;
4
4
  askUserBlocked: boolean;
5
5
  }
6
- interface ShellSurface {
6
+ export interface ShellSurface {
7
7
  hasUI: boolean;
8
8
  mode?: string;
9
9
  }
@@ -14,15 +14,14 @@ interface ShellSurface {
14
14
  * it. An ask-user prompt is announced by its own event, so the dialog it then
15
15
  * opens must stay silent or the same question notifies twice.
16
16
  */
17
- declare function warrantsAttentionNotification({ agentRunning, askUserBlocked }: AttentionState): boolean;
17
+ export declare function warrantsAttentionNotification({ agentRunning, askUserBlocked }: AttentionState): boolean;
18
18
  /** A queued follow-up means the agent keeps working, so the run has not stopped for the user. */
19
- declare function warrantsSettledNotification(hasPendingMessages: boolean): boolean;
19
+ export declare function warrantsSettledNotification(hasPendingMessages: boolean): boolean;
20
20
  /** Terminal title escapes only mean something on an attached terminal; RPC output stays clean. */
21
- declare function supportsShellTitle({ hasUI, mode }: ShellSurface): boolean;
21
+ export declare function supportsShellTitle({ hasUI, mode }: ShellSurface): boolean;
22
22
  /** The question an ask-user prompt is blocking on, or a stand-in when it asked none. */
23
- declare function askUserPromptBody(questions: readonly {
23
+ export declare function askUserPromptBody(questions: readonly {
24
24
  question: string;
25
25
  }[]): string;
26
26
  //#endregion
27
- export { AttentionState, ShellSurface, askUserPromptBody, supportsShellTitle, warrantsAttentionNotification, warrantsSettledNotification };
28
27
  //# sourceMappingURL=notificationPolicy.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"notificationPolicy.d.cts","names":[],"sources":["../../src/services/notificationPolicy.ts"],"mappings":";UAGiB;EACf;EACA;;UAGe;EACf;EACA;;;;;;;;;iBAUc,gCAAgC,cAAc,kBAAkB;;iBAKhE,4BAA4B;;iBAK5B,qBAAqB,OAAO,QAAQ;;iBAKpC,kBAAkB;EAAsB"}
1
+ {"version":3,"file":"notificationPolicy.d.cts","names":[],"sources":["../../src/services/notificationPolicy.ts"],"mappings":";iBAGiB;EACf;EACA;;iBAGe;EACf;EACA;;;;;;;;;wBAUc,gCAAgC,cAAc,kBAAkB;;wBAKhE,4BAA4B;;wBAK5B,qBAAqB,OAAO,QAAQ;;wBAKpC,kBAAkB;EAAsB"}
@@ -1,9 +1,9 @@
1
1
  //#region src/services/notificationPolicy.d.ts
2
- interface AttentionState {
2
+ export interface AttentionState {
3
3
  agentRunning: boolean;
4
4
  askUserBlocked: boolean;
5
5
  }
6
- interface ShellSurface {
6
+ export interface ShellSurface {
7
7
  hasUI: boolean;
8
8
  mode?: string;
9
9
  }
@@ -14,15 +14,14 @@ interface ShellSurface {
14
14
  * it. An ask-user prompt is announced by its own event, so the dialog it then
15
15
  * opens must stay silent or the same question notifies twice.
16
16
  */
17
- declare function warrantsAttentionNotification({ agentRunning, askUserBlocked }: AttentionState): boolean;
17
+ export declare function warrantsAttentionNotification({ agentRunning, askUserBlocked }: AttentionState): boolean;
18
18
  /** A queued follow-up means the agent keeps working, so the run has not stopped for the user. */
19
- declare function warrantsSettledNotification(hasPendingMessages: boolean): boolean;
19
+ export declare function warrantsSettledNotification(hasPendingMessages: boolean): boolean;
20
20
  /** Terminal title escapes only mean something on an attached terminal; RPC output stays clean. */
21
- declare function supportsShellTitle({ hasUI, mode }: ShellSurface): boolean;
21
+ export declare function supportsShellTitle({ hasUI, mode }: ShellSurface): boolean;
22
22
  /** The question an ask-user prompt is blocking on, or a stand-in when it asked none. */
23
- declare function askUserPromptBody(questions: readonly {
23
+ export declare function askUserPromptBody(questions: readonly {
24
24
  question: string;
25
25
  }[]): string;
26
26
  //#endregion
27
- export { AttentionState, ShellSurface, askUserPromptBody, supportsShellTitle, warrantsAttentionNotification, warrantsSettledNotification };
28
27
  //# sourceMappingURL=notificationPolicy.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"notificationPolicy.d.mts","names":[],"sources":["../../src/services/notificationPolicy.ts"],"mappings":";UAGiB;EACf;EACA;;UAGe;EACf;EACA;;;;;;;;;iBAUc,gCAAgC,cAAc,kBAAkB;;iBAKhE,4BAA4B;;iBAK5B,qBAAqB,OAAO,QAAQ;;iBAKpC,kBAAkB;EAAsB"}
1
+ {"version":3,"file":"notificationPolicy.d.mts","names":[],"sources":["../../src/services/notificationPolicy.ts"],"mappings":";iBAGiB;EACf;EACA;;iBAGe;EACf;EACA;;;;;;;;;wBAUc,gCAAgC,cAAc,kBAAkB;;wBAKhE,4BAA4B;;wBAK5B,qBAAqB,OAAO,QAAQ;;wBAKpC,kBAAkB;EAAsB"}
@@ -1,8 +1,8 @@
1
1
  import { DesktopNotification } from "../types/notifications.cjs";
2
2
  //#region src/services/notificationText.d.ts
3
3
  /** The first user prompt, shortened to fit a shell tab. A blank prompt names nothing. */
4
- declare function promptTitle(prompt: string): string | undefined;
5
- interface ShellTabTitleInput {
4
+ export declare function promptTitle(prompt: string): string | undefined;
5
+ export interface ShellTabTitleInput {
6
6
  cwd: string;
7
7
  sessionName?: string;
8
8
  prompt?: string;
@@ -13,16 +13,15 @@ interface ShellTabTitleInput {
13
13
  * The session name wins over the first prompt because the user chose it. With
14
14
  * neither, the repository alone still tells two tabs apart.
15
15
  */
16
- declare function shellTabTitle({ cwd, sessionName, prompt }: ShellTabTitleInput): string;
16
+ export declare function shellTabTitle({ cwd, sessionName, prompt }: ShellTabTitleInput): string;
17
17
  /** Notification bodies are one line in a system panel, so they collapse and truncate. */
18
- declare function notificationBody(body: string): string;
18
+ export declare function notificationBody(body: string): string;
19
19
  /** Sent while the agent holds the turn and something is blocking on the user. */
20
- declare function attentionNotification(body: string): DesktopNotification;
20
+ export declare function attentionNotification(body: string): DesktopNotification;
21
21
  /** Sent once a run has stopped, subtitled with whichever name the user recognises. */
22
- declare function settledNotification({ cwd, sessionName }: {
22
+ export declare function settledNotification({ cwd, sessionName }: {
23
23
  cwd: string;
24
24
  sessionName?: string;
25
25
  }): DesktopNotification;
26
26
  //#endregion
27
- export { ShellTabTitleInput, attentionNotification, notificationBody, promptTitle, settledNotification, shellTabTitle };
28
27
  //# sourceMappingURL=notificationText.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"notificationText.d.cts","names":[],"sources":["../../src/services/notificationText.ts"],"mappings":";;;iBAsBgB,YAAY;UAKX;EACf;EACA;EACA;;;;;;;;iBASc,gBAAgB,KAAK,aAAa,UAAU;;iBAS5C,iBAAiB;;iBAKjB,sBAAsB,eAAe;;iBAKrC,sBAAsB,KAAK;EAAiB;EAAa;IAAyB"}
1
+ {"version":3,"file":"notificationText.d.cts","names":[],"sources":["../../src/services/notificationText.ts"],"mappings":";;;wBAsBgB,YAAY;iBAKX;EACf;EACA;EACA;;;;;;;;wBASc,gBAAgB,KAAK,aAAa,UAAU;;wBAS5C,iBAAiB;;wBAKjB,sBAAsB,eAAe;;wBAKrC,sBAAsB,KAAK;EAAiB;EAAa;IAAyB"}
@@ -1,8 +1,8 @@
1
1
  import { DesktopNotification } from "../types/notifications.mjs";
2
2
  //#region src/services/notificationText.d.ts
3
3
  /** The first user prompt, shortened to fit a shell tab. A blank prompt names nothing. */
4
- declare function promptTitle(prompt: string): string | undefined;
5
- interface ShellTabTitleInput {
4
+ export declare function promptTitle(prompt: string): string | undefined;
5
+ export interface ShellTabTitleInput {
6
6
  cwd: string;
7
7
  sessionName?: string;
8
8
  prompt?: string;
@@ -13,16 +13,15 @@ interface ShellTabTitleInput {
13
13
  * The session name wins over the first prompt because the user chose it. With
14
14
  * neither, the repository alone still tells two tabs apart.
15
15
  */
16
- declare function shellTabTitle({ cwd, sessionName, prompt }: ShellTabTitleInput): string;
16
+ export declare function shellTabTitle({ cwd, sessionName, prompt }: ShellTabTitleInput): string;
17
17
  /** Notification bodies are one line in a system panel, so they collapse and truncate. */
18
- declare function notificationBody(body: string): string;
18
+ export declare function notificationBody(body: string): string;
19
19
  /** Sent while the agent holds the turn and something is blocking on the user. */
20
- declare function attentionNotification(body: string): DesktopNotification;
20
+ export declare function attentionNotification(body: string): DesktopNotification;
21
21
  /** Sent once a run has stopped, subtitled with whichever name the user recognises. */
22
- declare function settledNotification({ cwd, sessionName }: {
22
+ export declare function settledNotification({ cwd, sessionName }: {
23
23
  cwd: string;
24
24
  sessionName?: string;
25
25
  }): DesktopNotification;
26
26
  //#endregion
27
- export { ShellTabTitleInput, attentionNotification, notificationBody, promptTitle, settledNotification, shellTabTitle };
28
27
  //# sourceMappingURL=notificationText.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"notificationText.d.mts","names":[],"sources":["../../src/services/notificationText.ts"],"mappings":";;;iBAsBgB,YAAY;UAKX;EACf;EACA;EACA;;;;;;;;iBASc,gBAAgB,KAAK,aAAa,UAAU;;iBAS5C,iBAAiB;;iBAKjB,sBAAsB,eAAe;;iBAKrC,sBAAsB,KAAK;EAAiB;EAAa;IAAyB"}
1
+ {"version":3,"file":"notificationText.d.mts","names":[],"sources":["../../src/services/notificationText.ts"],"mappings":";;;wBAsBgB,YAAY;iBAKX;EACf;EACA;EACA;;;;;;;;wBASc,gBAAgB,KAAK,aAAa,UAAU;;wBAS5C,iBAAiB;;wBAKjB,sBAAsB,eAAe;;wBAKrC,sBAAsB,KAAK;EAAiB;EAAa;IAAyB"}
@@ -1,10 +1,10 @@
1
1
  //#region src/types/notifications.d.ts
2
2
  /** Writes a shell-tab title to whatever terminal surface the host owns. */
3
- type WriteTitle = (title: string) => void;
3
+ export type WriteTitle = (title: string) => void;
4
4
  /** The four things a title controller can be asked to do, and its method names. */
5
- type ShellTitleAction = 'dispose' | 'set' | 'start' | 'stop';
5
+ export type ShellTitleAction = 'dispose' | 'set' | 'start' | 'stop';
6
6
  /** One instruction for a title controller, and the message shape its worker consumes. */
7
- interface ShellTitleCommand {
7
+ export interface ShellTitleCommand {
8
8
  action: ShellTitleAction;
9
9
  title: string;
10
10
  }
@@ -16,18 +16,17 @@ interface ShellTitleCommand {
16
16
  * title and releases whatever machinery the implementation owns. Every method
17
17
  * takes the writer so the controller never has to hold a session reference.
18
18
  */
19
- interface ShellTitleController {
19
+ export interface ShellTitleController {
20
20
  set(title: string, write: WriteTitle): void;
21
21
  start(title: string, write: WriteTitle): void;
22
22
  stop(title: string, write: WriteTitle): void;
23
23
  dispose(title: string, write: WriteTitle): void;
24
24
  }
25
25
  /** One OS-level desktop notification. */
26
- interface DesktopNotification {
26
+ export interface DesktopNotification {
27
27
  title: string;
28
28
  subtitle: string;
29
29
  body: string;
30
30
  }
31
31
  //#endregion
32
- export { DesktopNotification, ShellTitleAction, ShellTitleCommand, ShellTitleController, WriteTitle };
33
32
  //# sourceMappingURL=notifications.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"notifications.d.cts","names":[],"sources":["../../src/types/notifications.ts"],"mappings":";;KACY,cAAc;;KAGd;;UAGK;EACf,QAAQ;EACR;;;;;;;;;;UAWe;EACf,IAAI,eAAe,OAAO;EAC1B,MAAM,eAAe,OAAO;EAC5B,KAAK,eAAe,OAAO;EAC3B,QAAQ,eAAe,OAAO;;;UAIf;EACf;EACA;EACA"}
1
+ {"version":3,"file":"notifications.d.cts","names":[],"sources":["../../src/types/notifications.ts"],"mappings":";;YACY,cAAc;;YAGd;;iBAGK;EACf,QAAQ;EACR;;;;;;;;;;iBAWe;EACf,IAAI,eAAe,OAAO;EAC1B,MAAM,eAAe,OAAO;EAC5B,KAAK,eAAe,OAAO;EAC3B,QAAQ,eAAe,OAAO;;;iBAIf;EACf;EACA;EACA"}
@@ -1,10 +1,10 @@
1
1
  //#region src/types/notifications.d.ts
2
2
  /** Writes a shell-tab title to whatever terminal surface the host owns. */
3
- type WriteTitle = (title: string) => void;
3
+ export type WriteTitle = (title: string) => void;
4
4
  /** The four things a title controller can be asked to do, and its method names. */
5
- type ShellTitleAction = 'dispose' | 'set' | 'start' | 'stop';
5
+ export type ShellTitleAction = 'dispose' | 'set' | 'start' | 'stop';
6
6
  /** One instruction for a title controller, and the message shape its worker consumes. */
7
- interface ShellTitleCommand {
7
+ export interface ShellTitleCommand {
8
8
  action: ShellTitleAction;
9
9
  title: string;
10
10
  }
@@ -16,18 +16,17 @@ interface ShellTitleCommand {
16
16
  * title and releases whatever machinery the implementation owns. Every method
17
17
  * takes the writer so the controller never has to hold a session reference.
18
18
  */
19
- interface ShellTitleController {
19
+ export interface ShellTitleController {
20
20
  set(title: string, write: WriteTitle): void;
21
21
  start(title: string, write: WriteTitle): void;
22
22
  stop(title: string, write: WriteTitle): void;
23
23
  dispose(title: string, write: WriteTitle): void;
24
24
  }
25
25
  /** One OS-level desktop notification. */
26
- interface DesktopNotification {
26
+ export interface DesktopNotification {
27
27
  title: string;
28
28
  subtitle: string;
29
29
  body: string;
30
30
  }
31
31
  //#endregion
32
- export { DesktopNotification, ShellTitleAction, ShellTitleCommand, ShellTitleController, WriteTitle };
33
32
  //# sourceMappingURL=notifications.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"notifications.d.mts","names":[],"sources":["../../src/types/notifications.ts"],"mappings":";;KACY,cAAc;;KAGd;;UAGK;EACf,QAAQ;EACR;;;;;;;;;;UAWe;EACf,IAAI,eAAe,OAAO;EAC1B,MAAM,eAAe,OAAO;EAC5B,KAAK,eAAe,OAAO;EAC3B,QAAQ,eAAe,OAAO;;;UAIf;EACf;EACA;EACA"}
1
+ {"version":3,"file":"notifications.d.mts","names":[],"sources":["../../src/types/notifications.ts"],"mappings":";;YACY,cAAc;;YAGd;;iBAGK;EACf,QAAQ;EACR;;;;;;;;;;iBAWe;EACf,IAAI,eAAe,OAAO;EAC1B,MAAM,eAAe,OAAO;EAC5B,KAAK,eAAe,OAAO;EAC3B,QAAQ,eAAe,OAAO;;;iBAIf;EACf;EACA;EACA"}
package/llms.txt CHANGED
@@ -1,7 +1,7 @@
1
1
  # Doom Pi Notification
2
2
 
3
- Desktop notifications and an animated shell-tab title for Doom Pi sessions.
3
+ Shared notification routing, browser and system delivery, and an animated shell-tab title for Doom Pi sessions.
4
4
 
5
5
  ## Resources
6
6
 
7
- - [Package README](./README.md): what is announced and when, the worker-thread shell-title animator, and the rules that keep a session quiet.
7
+ - [Package README](./README.md): public `doom/notification` service usage, request defaults, RPC and interactive delivery, live-page browser permission behavior, shell-title animation, and silent fallback rules.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agimon-ai/doompi-notification",
3
- "version": "0.0.1-alpha.4",
3
+ "version": "0.0.1-alpha.41",
4
4
  "description": "Desktop notifications and an animated shell-tab title for DoomPi sessions.",
5
5
  "keywords": [
6
6
  "ai",
@@ -16,8 +16,16 @@
16
16
  "terminal-title"
17
17
  ],
18
18
  "homepage": "https://agimon.ai",
19
+ "bugs": {
20
+ "url": "https://github.com/AgiFlow/doompi/issues"
21
+ },
19
22
  "license": "MIT",
20
23
  "author": "Vuong Ngo",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/AgiFlow/doompi.git",
27
+ "directory": "packages/core/doompi-notification"
28
+ },
21
29
  "files": [
22
30
  "dist",
23
31
  "llms.txt",
@@ -46,20 +54,20 @@
46
54
  "access": "public"
47
55
  },
48
56
  "dependencies": {
49
- "@deepseek-ai/cordis": "4.0.1",
50
- "@agimon-ai/doompi-extension-contracts": "0.0.1-alpha.26"
57
+ "@deepseek-ai/cordis": "4.0.2",
58
+ "@agimon-ai/doompi-extension-contracts": "0.0.1-alpha.63"
51
59
  },
52
60
  "devDependencies": {
53
- "@earendil-works/pi-coding-agent": "0.84.2",
54
- "@types/node": "26.1.1",
55
- "@vitest/coverage-v8": "4.1.10",
56
- "tsdown": "0.22.14",
57
- "typescript": "6.0.3",
58
- "vitest": "4.1.10",
59
- "@agimon-ai/vibe-lint-plugin-doom-extension": "0.0.1-alpha.26"
61
+ "@earendil-works/pi-coding-agent": "0.85.1",
62
+ "@types/node": "26.4.1",
63
+ "@vitest/coverage-v8": "5.0.0",
64
+ "tsdown": "0.23.0",
65
+ "typescript": "7.0.2",
66
+ "vitest": "5.0.0",
67
+ "@agimon-ai/vibe-lint-plugin-doom-extension": "0.0.1-alpha.60"
60
68
  },
61
69
  "peerDependencies": {
62
- "@earendil-works/pi-coding-agent": "0.84.2"
70
+ "@earendil-works/pi-coding-agent": "0.85.1"
63
71
  },
64
72
  "peerDependenciesMeta": {
65
73
  "@earendil-works/pi-coding-agent": {