@agimon-ai/po-notification 0.0.0-alpha.44 → 0.0.0-alpha.46

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.
package/dist/index.cjs CHANGED
@@ -82,11 +82,12 @@ function createMainThreadTitleController() {
82
82
  * located on disk at runtime.
83
83
  */
84
84
  const TITLE_WORKER_SOURCE = `
85
- const { writeSync } = require('node:fs');
85
+ const { createWriteStream } = require('node:fs');
86
+ const output = createWriteStream('', { fd: 1, autoClose: false });
86
87
  const { parentPort, workerData } = require('node:worker_threads');
87
88
  let frameIndex = 0;
88
89
  let timer;
89
- const writeTitle = (title) => writeSync(1, '\\u001b]0;' + title + '\\u0007');
90
+ const writeTitle = (title) => output.write('\\u001b]0;' + title + '\\u0007');
90
91
  const stop = () => {
91
92
  if (timer) clearInterval(timer);
92
93
  timer = undefined;
@@ -104,7 +105,7 @@ parentPort.on('message', (command) => {
104
105
  return;
105
106
  }
106
107
  writeTitle(command.title);
107
- if (command.action === 'dispose') parentPort.close();
108
+ if (command.action === 'dispose') output.end(() => parentPort.close());
108
109
  });
109
110
  `;
110
111
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["Worker","path","sign","connect","request"],"sources":["../src/services/shellTitleController/mainThread.ts","../src/services/shellTitleController/index.ts","../src/services/notificationText/index.ts","../src/services/systemNotification/index.ts","../src/services/nativePushSender/sync.ts","../src/services/nativePushSender/index.ts","../src/services/notificationPolicy/index.ts"],"sourcesContent":["import type { ShellTitleController } from '../../types/notifications';\n\nexport const BRAILLE_FRAMES = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];\nexport const TITLE_FRAME_INTERVAL_MS = 80;\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","import { Worker } from 'node:worker_threads';\n\nimport type { ShellTitleCommand, ShellTitleController, WriteTitle } from '../../types/notifications';\nimport { BRAILLE_FRAMES, TITLE_FRAME_INTERVAL_MS, createMainThreadTitleController } from './mainThread';\n\nexport { createMainThreadTitleController } from './mainThread';\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/**\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","import path from 'node:path';\n\nimport type { DesktopNotification } from '../../types/notifications';\n\nconst ATTENTION_SUBTITLE = 'Approval or feedback required';\nconst ATTENTION_TITLE = 'Po needs your input';\nconst ELLIPSIS = '…';\nconst MAX_BODY_LENGTH = 240;\nconst MAX_PROMPT_TITLE_LENGTH = 36;\nconst SETTLED_BODY = 'The agent finished its work and is waiting for you.';\nconst SETTLED_TITLE = 'Po finished';\nconst SHELL_TITLE_SEPARATOR = ' - ';\nconst SHELL_TITLE_PREFIX = 'π';\n\nfunction collapseWhitespace(value: string): string {\n return value.replace(/\\s+/g, ' ').trim();\n}\n\nfunction truncate(value: string, maxLength: number): string {\n return value.length > maxLength ? `${value.slice(0, maxLength - 1)}${ELLIPSIS}` : value;\n}\n\n/** The first user prompt, shortened to fit a shell tab. A blank prompt names nothing. */\nexport function promptTitle(prompt: string): string | undefined {\n const normalized = collapseWhitespace(prompt);\n return normalized ? truncate(normalized, MAX_PROMPT_TITLE_LENGTH) : undefined;\n}\n\nexport interface ShellTabTitleInput {\n cwd: string;\n sessionName?: string;\n prompt?: string;\n}\n\n/**\n * The idle shell-tab title: `π - <label> - <repository>`.\n *\n * The session name wins over the first prompt because the user chose it. With\n * neither, the repository alone still tells two tabs apart.\n */\nexport function shellTabTitle({ cwd, sessionName, prompt }: ShellTabTitleInput): string {\n const repository = path.basename(cwd);\n const label = sessionName ?? prompt;\n return label\n ? `${SHELL_TITLE_PREFIX}${SHELL_TITLE_SEPARATOR}${label}${SHELL_TITLE_SEPARATOR}${repository}`\n : `${SHELL_TITLE_PREFIX}${SHELL_TITLE_SEPARATOR}${repository}`;\n}\n\n/** Notification bodies are one line in a system panel, so they collapse and truncate. */\nexport function notificationBody(body: string): string {\n return truncate(collapseWhitespace(body), MAX_BODY_LENGTH);\n}\n\n/** Sent while the agent holds the turn and something is blocking on the user. */\nexport function attentionNotification(body: string): DesktopNotification {\n return { title: ATTENTION_TITLE, subtitle: ATTENTION_SUBTITLE, body };\n}\n\n/** Sent once a run has stopped, subtitled with whichever name the user recognises. */\nexport function settledNotification({ cwd, sessionName }: { cwd: string; sessionName?: string }): DesktopNotification {\n return { title: SETTLED_TITLE, subtitle: sessionName ?? path.basename(cwd), body: SETTLED_BODY };\n}\n","import type { DesktopNotification, NotificationExecutor } from '../../types/notifications';\nimport { notificationBody } from '../notificationText';\n\nconst CMUX_COMMAND = 'cmux';\nconst COMMAND_TIMEOUT_MS = 3_000;\nconst DARWIN_PLATFORM = 'darwin';\nconst OSASCRIPT_COMMAND = 'osascript';\nconst OSASCRIPT_EXPRESSION_FLAG = '-e';\n\nasync function execute(pi: NotificationExecutor, command: string, args: string[]): Promise<boolean> {\n try {\n const result = await pi.exec(command, args, { timeout: COMMAND_TIMEOUT_MS });\n return result.code === 0;\n } catch {\n // A notifier that is not installed is the ordinary case, not a fault: report\n // \"not delivered\" and let the caller decide whether another one exists.\n return false;\n }\n}\n\n/**\n * Delivers one desktop notification on a best-effort basis.\n *\n * cmux is tried first because it routes the notification to the window the\n * session actually lives in. Only macOS has a second option worth attempting,\n * and a host with neither stays silent rather than failing the turn.\n */\nexport async function sendSystemNotification(\n pi: NotificationExecutor,\n notification: DesktopNotification,\n platform: string = process.platform,\n): Promise<void> {\n const body = notificationBody(notification.body);\n const sentToCmux = await execute(pi, CMUX_COMMAND, [\n 'notify',\n '--title',\n notification.title,\n '--subtitle',\n notification.subtitle,\n '--body',\n body,\n ]);\n if (sentToCmux || platform !== DARWIN_PLATFORM) return;\n\n await execute(pi, OSASCRIPT_COMMAND, [\n OSASCRIPT_EXPRESSION_FLAG,\n 'on run argv',\n OSASCRIPT_EXPRESSION_FLAG,\n 'display notification (item 3 of argv) with title (item 1 of argv) subtitle (item 2 of argv)',\n OSASCRIPT_EXPRESSION_FLAG,\n 'end run',\n notification.title,\n notification.subtitle,\n body,\n ]);\n}\n","import { sign } from 'node:crypto';\nimport { connect } from 'node:http2';\nimport { request } from 'node:https';\n\nimport type { NativePushRequest, NativePushResponse } from './type';\n\nconst MAX_RESPONSE_BYTES = 65_536;\n\nexport function signPushJwt(header: object, claims: object, key: string, algorithm: 'ES256' | 'RS256'): string {\n const input = [header, claims].map((part) => Buffer.from(JSON.stringify(part)).toString('base64url')).join('.');\n const signature = sign('sha256', Buffer.from(input), { key, dsaEncoding: 'ieee-p1363' });\n // APNs requires the raw P1363 ECDSA signature, not ASN.1 DER.\n if (algorithm === 'ES256' && signature.length !== 64) throw new Error('Invalid signing key');\n return `${input}.${signature.toString('base64url')}`;\n}\n\nexport function createPushTransport() {\n const pending = new Set<() => void>();\n return {\n request(this: void, input: NativePushRequest): Promise<NativePushResponse> {\n return new Promise((resolve, reject) => {\n const url = new URL(input.url);\n let size = 0;\n const chunks: Buffer[] = [];\n let done = false;\n let dispose = () => {};\n const finish = (error?: Error, status = 0) => {\n if (done) return;\n done = true;\n clearTimeout(timer);\n pending.delete(cancel);\n dispose();\n if (error) reject(error);\n else resolve({ status, body: Buffer.concat(chunks).toString('utf8') });\n };\n const cancel = () => finish(new Error('Push request cancelled'));\n const timer = setTimeout(() => finish(new Error('Push request timed out')), input.timeoutMs);\n pending.add(cancel);\n const data = (chunk: Buffer) => {\n size += chunk.length;\n if (size > MAX_RESPONSE_BYTES) finish(new Error('Push response too large'));\n else chunks.push(Buffer.from(chunk));\n };\n if (input.http2) {\n const session = connect(url.origin);\n dispose = () => session.destroy();\n session.on('error', (error) => finish(error));\n const stream = session.request({ ':method': 'POST', ':path': url.pathname, ...input.headers });\n let status = 0;\n stream.on('response', (headers) => {\n status = Number(headers[':status']);\n });\n stream.on('data', data);\n stream.on('error', (error) => finish(error));\n stream.on('end', () => finish(undefined, status));\n stream.end(input.body);\n } else {\n const req = request(url, { method: 'POST', headers: input.headers }, (response) => {\n response.on('data', data);\n response.on('error', (error) => finish(error));\n response.on('end', () => finish(undefined, response.statusCode));\n });\n dispose = () => req.destroy();\n req.on('error', (error) => finish(error));\n req.end(input.body);\n }\n });\n },\n close() {\n for (const cancel of pending) cancel();\n },\n };\n}\n","import type { PoNotificationEntryData } from '@agimon-ai/po-core';\n\nimport { createPushTransport, signPushJwt } from './sync';\nimport type { NativePushSender, NativePushSenderOptions } from './type';\n\nconst MAX_PAYLOAD_BYTES = 4096;\nconst APNS_TOPIC = 'ai.po.app';\n// Only documented provider codes may enter diagnostics, never arbitrary response text.\nconst APNS_REASONS = new Set([\n 'BadCollapseId',\n 'BadDeviceToken',\n 'BadExpirationDate',\n 'BadMessageId',\n 'BadPriority',\n 'BadTopic',\n 'DeviceTokenNotForTopic',\n 'DuplicateHeaders',\n 'IdleTimeout',\n 'InvalidPushType',\n 'MissingDeviceToken',\n 'MissingTopic',\n 'PayloadEmpty',\n 'TopicDisallowed',\n 'BadCertificate',\n 'BadCertificateEnvironment',\n 'ExpiredProviderToken',\n 'Forbidden',\n 'InvalidProviderToken',\n 'MissingProviderToken',\n 'BadPath',\n 'MethodNotAllowed',\n 'Unregistered',\n 'PayloadTooLarge',\n 'TooManyProviderTokenUpdates',\n 'TooManyRequests',\n 'InternalServerError',\n 'ServiceUnavailable',\n 'Shutdown',\n]);\nconst OAUTH_URL = 'https://oauth2.googleapis.com/token';\nconst FCM_ERROR_TYPE = 'type.googleapis.com/google.firebase.fcm.v1.FcmError';\nconst encoder = new TextEncoder();\n\nfunction parse(body: string): Record<string, unknown> {\n try {\n const value: unknown = JSON.parse(body);\n return value && typeof value === 'object' ? (value as Record<string, unknown>) : {};\n } catch {\n return {};\n } // Malformed provider responses never invalidate registrations.\n}\n\nfunction payload(\n notification: PoNotificationEntryData,\n build: (text: { title: string; subtitle: string; body: string }) => object,\n): string {\n const text = { title: notification.title, subtitle: notification.subtitle, body: notification.body };\n let result = JSON.stringify(build(text));\n // Measure the full serialized envelope, including escaped text and the FCM token.\n for (const field of ['body', 'subtitle', 'title'] as const) {\n if (encoder.encode(result).length <= MAX_PAYLOAD_BYTES) break;\n const points = Array.from(text[field]);\n let low = 0;\n let high = points.length;\n while (low < high) {\n const middle = Math.ceil((low + high) / 2);\n text[field] = points.slice(0, middle).join('');\n if (encoder.encode(JSON.stringify(build(text))).length <= MAX_PAYLOAD_BYTES) low = middle;\n else high = middle - 1;\n }\n text[field] = points.slice(0, low).join('');\n result = JSON.stringify(build(text));\n }\n if (encoder.encode(result).length > MAX_PAYLOAD_BYTES) throw new Error('Push payload too large');\n return result;\n}\n\nexport function createNativePushSender(options: NativePushSenderOptions): NativePushSender {\n const transport = createPushTransport();\n const request = options.request ?? transport.request;\n const now = options.now ?? Date.now;\n const timeoutMs = Number.isFinite(options.timeoutMs) ? Math.max(1, Math.min(options.timeoutMs!, 30_000)) : 10_000;\n let closed = false;\n let apnsJwt: { value: string; expires: number } | undefined;\n let oauth: { value: string; expires: number } | undefined;\n let oauthPending: Promise<string> | undefined;\n\n async function accessToken(): Promise<string> {\n if (oauth && now() < oauth.expires) return oauth.value;\n if (oauthPending) return oauthPending;\n oauthPending = (async () => {\n const credentials = options.fcm!;\n const issued = Math.floor(now() / 1000);\n const assertion = signPushJwt(\n { alg: 'RS256', typ: 'JWT' },\n {\n iss: credentials.clientEmail,\n scope: 'https://www.googleapis.com/auth/firebase.messaging',\n aud: OAUTH_URL,\n iat: issued,\n exp: issued + 3600,\n },\n credentials.privateKey,\n 'RS256',\n );\n const response = await request({\n url: OAUTH_URL,\n headers: { 'content-type': 'application/x-www-form-urlencoded' },\n body: new URLSearchParams({ grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer', assertion }).toString(),\n timeoutMs,\n });\n const data = parse(response.body);\n if (\n response.status !== 200 ||\n typeof data.access_token !== 'string' ||\n !data.access_token ||\n typeof data.expires_in !== 'number' ||\n !Number.isFinite(data.expires_in) ||\n data.expires_in <= 0\n )\n throw new Error('OAuth failed');\n oauth = { value: data.access_token, expires: now() + Math.max(0, Math.min(data.expires_in, 3600) - 60) * 1000 };\n return oauth.value;\n })();\n try {\n return await oauthPending;\n } finally {\n oauthPending = undefined;\n }\n }\n\n return {\n async send(registration, notification, sessionId) {\n const provider = registration.platform === 'ios' ? 'apns' : 'fcm';\n if (closed || !options[provider]) {\n options.diagnostic?.({ provider, outcome: 'unavailable' });\n return { invalid: false };\n }\n try {\n const data = {\n ...(registration.hostRef ? { hostRef: registration.hostRef } : {}),\n ...(sessionId ? { sessionId } : {}),\n };\n let response;\n let reason: string | undefined;\n if (registration.platform === 'ios') {\n const credentials = options.apns!;\n if (!apnsJwt || now() >= apnsJwt.expires) {\n apnsJwt = {\n value: signPushJwt(\n { alg: 'ES256', kid: credentials.keyId },\n {\n iss: credentials.teamId,\n iat: Math.floor(now() / 1000),\n },\n credentials.key,\n 'ES256',\n ),\n expires: now() + 50 * 60_000,\n };\n }\n response = await request({\n url: `https://${registration.environment === 'development' ? 'api.sandbox.push.apple.com' : 'api.push.apple.com'}/3/device/${encodeURIComponent(registration.token)}`,\n http2: true,\n timeoutMs,\n headers: {\n authorization: `bearer ${apnsJwt.value}`,\n 'apns-topic': APNS_TOPIC,\n 'apns-push-type': 'alert',\n 'apns-priority': '10',\n 'apns-expiration': '0',\n 'content-type': 'application/json',\n },\n // ponytail: live alerts only; add a durable outbox if delayed delivery becomes a requirement.\n // Expo iOS reads custom remote data from userInfo.body. Keep data as the provider-neutral payload.\n body: payload(notification, (text) => ({ aps: { alert: text, sound: 'default' }, data, body: data })),\n });\n const value = parse(response.body).reason;\n if (typeof value === 'string' && APNS_REASONS.has(value)) reason = value;\n if (\n (response.status === 410 && reason === 'Unregistered') ||\n (response.status === 400 && reason === 'BadDeviceToken')\n ) {\n options.diagnostic?.({\n provider,\n outcome: 'invalid',\n status: response.status,\n ...(reason ? { reason } : {}),\n });\n return { invalid: true };\n }\n } else {\n const body = payload(notification, (text) => ({\n message: {\n token: registration.token,\n data,\n notification: { title: text.title, body: [text.subtitle, text.body].filter(Boolean).join('\\n') },\n // ponytail: zero TTL, no offline delivery; an outbox would own delayed sends.\n android: { ttl: '0s', priority: 'HIGH', notification: { channel_id: 'po-notifications' } },\n },\n }));\n const token = await accessToken();\n if (closed) return { invalid: false };\n response = await request({\n url: `https://fcm.googleapis.com/v1/projects/${encodeURIComponent(options.fcm!.projectId)}/messages:send`,\n headers: { authorization: `Bearer ${token}`, 'content-type': 'application/json' },\n body,\n timeoutMs,\n });\n const error = parse(response.body).error;\n if (\n response.status === 404 &&\n error &&\n typeof error === 'object' &&\n 'details' in error &&\n Array.isArray(error.details) &&\n error.details.some(\n (detail: unknown) =>\n detail &&\n typeof detail === 'object' &&\n '@type' in detail &&\n detail['@type'] === FCM_ERROR_TYPE &&\n 'errorCode' in detail &&\n detail.errorCode === 'UNREGISTERED',\n )\n ) {\n options.diagnostic?.({\n provider,\n outcome: 'invalid',\n status: response.status,\n ...(reason ? { reason } : {}),\n });\n return { invalid: true };\n }\n }\n if (response.status < 200 || response.status >= 300)\n options.diagnostic?.({ provider, outcome: 'failed', status: response.status, ...(reason ? { reason } : {}) });\n } catch {\n // Never expose provider bodies, credentials, device tokens, or network errors.\n options.diagnostic?.({ provider, outcome: 'failed' });\n }\n return { invalid: false };\n },\n close() {\n closed = true;\n apnsJwt = undefined;\n oauth = undefined;\n transport.close();\n },\n };\n}\n","const DEFAULT_ASK_USER_BODY = 'The agent is waiting for your feedback.';\nconst RPC_MODE = 'rpc';\n\nexport interface AttentionState {\n agentRunning: boolean;\n askUserBlocked: boolean;\n}\n\nexport interface ShellSurface {\n hasUI: boolean;\n mode?: string;\n}\n\n/**\n * A dialog is worth interrupting the user for only while the agent holds the turn.\n *\n * Outside a run the user opened the dialog themselves and is already looking at\n * it. An ask-user prompt is announced by its own event, so the dialog it then\n * opens must stay silent or the same question notifies twice.\n */\nexport function warrantsAttentionNotification({ agentRunning, askUserBlocked }: AttentionState): boolean {\n return agentRunning && !askUserBlocked;\n}\n\n/** A queued follow-up means the agent keeps working, so the run has not stopped for the user. */\nexport function warrantsSettledNotification(hasPendingMessages: boolean): boolean {\n return !hasPendingMessages;\n}\n\n/** Terminal title escapes only mean something on an attached terminal; RPC output stays clean. */\nexport function supportsShellTitle({ hasUI, mode }: ShellSurface): boolean {\n return hasUI && mode !== RPC_MODE;\n}\n\n/** The question an ask-user prompt is blocking on, or a stand-in when it asked none. */\nexport function askUserPromptBody(questions: readonly { question: string }[]): string {\n return questions[0]?.question ?? DEFAULT_ASK_USER_BODY;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAa,iBAAiB;CAAC;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;AAAG;;AAI/E,SAAgB,kCAAwD;CACtE,IAAI,aAAa;CACjB,IAAI;CACJ,MAAM,sBAAsB;EAC1B,IAAI,OAAO,cAAc,KAAK;EAC9B,QAAQ,KAAA;EACR,aAAa;CACf;CAEA,OAAO;EACL,IAAI,OAAO,OAAO;GAChB,cAAc;GACd,MAAM,KAAK;EACb;EACA,MAAM,OAAO,OAAO;GAClB,cAAc;GACd,MAAM,eAAe;IACnB,MAAM,GAAG,eAAe,aAAa,eAA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Aa;OACnB;OACA,SAAS;OACT,QAAQ,SAAS;OACjB,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;MAC7B,CAAC;MACD,OAAO,EAAE,SAAS,KAAK;KACzB;IACF;IACA,IAAI,SAAS,SAAS,OAAO,SAAS,UAAU,KAC9C,QAAQ,aAAa;KAAE;KAAU,SAAS;KAAU,QAAQ,SAAS;KAAQ,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;IAAG,CAAC;GAChH,QAAQ;IAEN,QAAQ,aAAa;KAAE;KAAU,SAAS;IAAS,CAAC;GACtD;GACA,OAAO,EAAE,SAAS,MAAM;EAC1B;EACA,QAAQ;GACN,SAAS;GACT,UAAU,KAAA;GACV,QAAQ,KAAA;GACR,UAAU,MAAM;EAClB;CACF;AACF;;;AC1PA,MAAM,wBAAwB;AAC9B,MAAM,WAAW;;;;;;;;AAmBjB,SAAgB,8BAA8B,EAAE,cAAc,kBAA2C;CACvG,OAAO,gBAAgB,CAAC;AAC1B;;AAGA,SAAgB,4BAA4B,oBAAsC;CAChF,OAAO,CAAC;AACV;;AAGA,SAAgB,mBAAmB,EAAE,OAAO,QAA+B;CACzE,OAAO,SAAS,SAAS;AAC3B;;AAGA,SAAgB,kBAAkB,WAAoD;CACpF,OAAO,UAAU,EAAE,EAAE,YAAY;AACnC"}
1
+ {"version":3,"file":"index.cjs","names":["Worker","path","sign","connect","request"],"sources":["../src/services/shellTitleController/mainThread.ts","../src/services/shellTitleController/index.ts","../src/services/notificationText/index.ts","../src/services/systemNotification/index.ts","../src/services/nativePushSender/sync.ts","../src/services/nativePushSender/index.ts","../src/services/notificationPolicy/index.ts"],"sourcesContent":["import type { ShellTitleController } from '../../types/notifications';\n\nexport const BRAILLE_FRAMES = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];\nexport const TITLE_FRAME_INTERVAL_MS = 80;\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","import { Worker } from 'node:worker_threads';\n\nimport type { ShellTitleCommand, ShellTitleController, WriteTitle } from '../../types/notifications';\nimport { BRAILLE_FRAMES, TITLE_FRAME_INTERVAL_MS, createMainThreadTitleController } from './mainThread';\n\nexport { createMainThreadTitleController } from './mainThread';\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 { createWriteStream } = require('node:fs');\nconst output = createWriteStream('', { fd: 1, autoClose: false });\nconst { parentPort, workerData } = require('node:worker_threads');\nlet frameIndex = 0;\nlet timer;\nconst writeTitle = (title) => output.write('\\\\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') output.end(() => parentPort.close());\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","import path from 'node:path';\n\nimport type { DesktopNotification } from '../../types/notifications';\n\nconst ATTENTION_SUBTITLE = 'Approval or feedback required';\nconst ATTENTION_TITLE = 'Po needs your input';\nconst ELLIPSIS = '…';\nconst MAX_BODY_LENGTH = 240;\nconst MAX_PROMPT_TITLE_LENGTH = 36;\nconst SETTLED_BODY = 'The agent finished its work and is waiting for you.';\nconst SETTLED_TITLE = 'Po finished';\nconst SHELL_TITLE_SEPARATOR = ' - ';\nconst SHELL_TITLE_PREFIX = 'π';\n\nfunction collapseWhitespace(value: string): string {\n return value.replace(/\\s+/g, ' ').trim();\n}\n\nfunction truncate(value: string, maxLength: number): string {\n return value.length > maxLength ? `${value.slice(0, maxLength - 1)}${ELLIPSIS}` : value;\n}\n\n/** The first user prompt, shortened to fit a shell tab. A blank prompt names nothing. */\nexport function promptTitle(prompt: string): string | undefined {\n const normalized = collapseWhitespace(prompt);\n return normalized ? truncate(normalized, MAX_PROMPT_TITLE_LENGTH) : undefined;\n}\n\nexport interface ShellTabTitleInput {\n cwd: string;\n sessionName?: string;\n prompt?: string;\n}\n\n/**\n * The idle shell-tab title: `π - <label> - <repository>`.\n *\n * The session name wins over the first prompt because the user chose it. With\n * neither, the repository alone still tells two tabs apart.\n */\nexport function shellTabTitle({ cwd, sessionName, prompt }: ShellTabTitleInput): string {\n const repository = path.basename(cwd);\n const label = sessionName ?? prompt;\n return label\n ? `${SHELL_TITLE_PREFIX}${SHELL_TITLE_SEPARATOR}${label}${SHELL_TITLE_SEPARATOR}${repository}`\n : `${SHELL_TITLE_PREFIX}${SHELL_TITLE_SEPARATOR}${repository}`;\n}\n\n/** Notification bodies are one line in a system panel, so they collapse and truncate. */\nexport function notificationBody(body: string): string {\n return truncate(collapseWhitespace(body), MAX_BODY_LENGTH);\n}\n\n/** Sent while the agent holds the turn and something is blocking on the user. */\nexport function attentionNotification(body: string): DesktopNotification {\n return { title: ATTENTION_TITLE, subtitle: ATTENTION_SUBTITLE, body };\n}\n\n/** Sent once a run has stopped, subtitled with whichever name the user recognises. */\nexport function settledNotification({ cwd, sessionName }: { cwd: string; sessionName?: string }): DesktopNotification {\n return { title: SETTLED_TITLE, subtitle: sessionName ?? path.basename(cwd), body: SETTLED_BODY };\n}\n","import type { DesktopNotification, NotificationExecutor } from '../../types/notifications';\nimport { notificationBody } from '../notificationText';\n\nconst CMUX_COMMAND = 'cmux';\nconst COMMAND_TIMEOUT_MS = 3_000;\nconst DARWIN_PLATFORM = 'darwin';\nconst OSASCRIPT_COMMAND = 'osascript';\nconst OSASCRIPT_EXPRESSION_FLAG = '-e';\n\nasync function execute(pi: NotificationExecutor, command: string, args: string[]): Promise<boolean> {\n try {\n const result = await pi.exec(command, args, { timeout: COMMAND_TIMEOUT_MS });\n return result.code === 0;\n } catch {\n // A notifier that is not installed is the ordinary case, not a fault: report\n // \"not delivered\" and let the caller decide whether another one exists.\n return false;\n }\n}\n\n/**\n * Delivers one desktop notification on a best-effort basis.\n *\n * cmux is tried first because it routes the notification to the window the\n * session actually lives in. Only macOS has a second option worth attempting,\n * and a host with neither stays silent rather than failing the turn.\n */\nexport async function sendSystemNotification(\n pi: NotificationExecutor,\n notification: DesktopNotification,\n platform: string = process.platform,\n): Promise<void> {\n const body = notificationBody(notification.body);\n const sentToCmux = await execute(pi, CMUX_COMMAND, [\n 'notify',\n '--title',\n notification.title,\n '--subtitle',\n notification.subtitle,\n '--body',\n body,\n ]);\n if (sentToCmux || platform !== DARWIN_PLATFORM) return;\n\n await execute(pi, OSASCRIPT_COMMAND, [\n OSASCRIPT_EXPRESSION_FLAG,\n 'on run argv',\n OSASCRIPT_EXPRESSION_FLAG,\n 'display notification (item 3 of argv) with title (item 1 of argv) subtitle (item 2 of argv)',\n OSASCRIPT_EXPRESSION_FLAG,\n 'end run',\n notification.title,\n notification.subtitle,\n body,\n ]);\n}\n","import { sign } from 'node:crypto';\nimport { connect } from 'node:http2';\nimport { request } from 'node:https';\n\nimport type { NativePushRequest, NativePushResponse } from './type';\n\nconst MAX_RESPONSE_BYTES = 65_536;\n\nexport function signPushJwt(header: object, claims: object, key: string, algorithm: 'ES256' | 'RS256'): string {\n const input = [header, claims].map((part) => Buffer.from(JSON.stringify(part)).toString('base64url')).join('.');\n const signature = sign('sha256', Buffer.from(input), { key, dsaEncoding: 'ieee-p1363' });\n // APNs requires the raw P1363 ECDSA signature, not ASN.1 DER.\n if (algorithm === 'ES256' && signature.length !== 64) throw new Error('Invalid signing key');\n return `${input}.${signature.toString('base64url')}`;\n}\n\nexport function createPushTransport() {\n const pending = new Set<() => void>();\n return {\n request(this: void, input: NativePushRequest): Promise<NativePushResponse> {\n return new Promise((resolve, reject) => {\n const url = new URL(input.url);\n let size = 0;\n const chunks: Buffer[] = [];\n let done = false;\n let dispose = () => {};\n const finish = (error?: Error, status = 0) => {\n if (done) return;\n done = true;\n clearTimeout(timer);\n pending.delete(cancel);\n dispose();\n if (error) reject(error);\n else resolve({ status, body: Buffer.concat(chunks).toString('utf8') });\n };\n const cancel = () => finish(new Error('Push request cancelled'));\n const timer = setTimeout(() => finish(new Error('Push request timed out')), input.timeoutMs);\n pending.add(cancel);\n const data = (chunk: Buffer) => {\n size += chunk.length;\n if (size > MAX_RESPONSE_BYTES) finish(new Error('Push response too large'));\n else chunks.push(Buffer.from(chunk));\n };\n if (input.http2) {\n const session = connect(url.origin);\n dispose = () => session.destroy();\n session.on('error', (error) => finish(error));\n const stream = session.request({ ':method': 'POST', ':path': url.pathname, ...input.headers });\n let status = 0;\n stream.on('response', (headers) => {\n status = Number(headers[':status']);\n });\n stream.on('data', data);\n stream.on('error', (error) => finish(error));\n stream.on('end', () => finish(undefined, status));\n stream.end(input.body);\n } else {\n const req = request(url, { method: 'POST', headers: input.headers }, (response) => {\n response.on('data', data);\n response.on('error', (error) => finish(error));\n response.on('end', () => finish(undefined, response.statusCode));\n });\n dispose = () => req.destroy();\n req.on('error', (error) => finish(error));\n req.end(input.body);\n }\n });\n },\n close() {\n for (const cancel of pending) cancel();\n },\n };\n}\n","import type { PoNotificationEntryData } from '@agimon-ai/po-core';\n\nimport { createPushTransport, signPushJwt } from './sync';\nimport type { NativePushSender, NativePushSenderOptions } from './type';\n\nconst MAX_PAYLOAD_BYTES = 4096;\nconst APNS_TOPIC = 'ai.po.app';\n// Only documented provider codes may enter diagnostics, never arbitrary response text.\nconst APNS_REASONS = new Set([\n 'BadCollapseId',\n 'BadDeviceToken',\n 'BadExpirationDate',\n 'BadMessageId',\n 'BadPriority',\n 'BadTopic',\n 'DeviceTokenNotForTopic',\n 'DuplicateHeaders',\n 'IdleTimeout',\n 'InvalidPushType',\n 'MissingDeviceToken',\n 'MissingTopic',\n 'PayloadEmpty',\n 'TopicDisallowed',\n 'BadCertificate',\n 'BadCertificateEnvironment',\n 'ExpiredProviderToken',\n 'Forbidden',\n 'InvalidProviderToken',\n 'MissingProviderToken',\n 'BadPath',\n 'MethodNotAllowed',\n 'Unregistered',\n 'PayloadTooLarge',\n 'TooManyProviderTokenUpdates',\n 'TooManyRequests',\n 'InternalServerError',\n 'ServiceUnavailable',\n 'Shutdown',\n]);\nconst OAUTH_URL = 'https://oauth2.googleapis.com/token';\nconst FCM_ERROR_TYPE = 'type.googleapis.com/google.firebase.fcm.v1.FcmError';\nconst encoder = new TextEncoder();\n\nfunction parse(body: string): Record<string, unknown> {\n try {\n const value: unknown = JSON.parse(body);\n return value && typeof value === 'object' ? (value as Record<string, unknown>) : {};\n } catch {\n return {};\n } // Malformed provider responses never invalidate registrations.\n}\n\nfunction payload(\n notification: PoNotificationEntryData,\n build: (text: { title: string; subtitle: string; body: string }) => object,\n): string {\n const text = { title: notification.title, subtitle: notification.subtitle, body: notification.body };\n let result = JSON.stringify(build(text));\n // Measure the full serialized envelope, including escaped text and the FCM token.\n for (const field of ['body', 'subtitle', 'title'] as const) {\n if (encoder.encode(result).length <= MAX_PAYLOAD_BYTES) break;\n const points = Array.from(text[field]);\n let low = 0;\n let high = points.length;\n while (low < high) {\n const middle = Math.ceil((low + high) / 2);\n text[field] = points.slice(0, middle).join('');\n if (encoder.encode(JSON.stringify(build(text))).length <= MAX_PAYLOAD_BYTES) low = middle;\n else high = middle - 1;\n }\n text[field] = points.slice(0, low).join('');\n result = JSON.stringify(build(text));\n }\n if (encoder.encode(result).length > MAX_PAYLOAD_BYTES) throw new Error('Push payload too large');\n return result;\n}\n\nexport function createNativePushSender(options: NativePushSenderOptions): NativePushSender {\n const transport = createPushTransport();\n const request = options.request ?? transport.request;\n const now = options.now ?? Date.now;\n const timeoutMs = Number.isFinite(options.timeoutMs) ? Math.max(1, Math.min(options.timeoutMs!, 30_000)) : 10_000;\n let closed = false;\n let apnsJwt: { value: string; expires: number } | undefined;\n let oauth: { value: string; expires: number } | undefined;\n let oauthPending: Promise<string> | undefined;\n\n async function accessToken(): Promise<string> {\n if (oauth && now() < oauth.expires) return oauth.value;\n if (oauthPending) return oauthPending;\n oauthPending = (async () => {\n const credentials = options.fcm!;\n const issued = Math.floor(now() / 1000);\n const assertion = signPushJwt(\n { alg: 'RS256', typ: 'JWT' },\n {\n iss: credentials.clientEmail,\n scope: 'https://www.googleapis.com/auth/firebase.messaging',\n aud: OAUTH_URL,\n iat: issued,\n exp: issued + 3600,\n },\n credentials.privateKey,\n 'RS256',\n );\n const response = await request({\n url: OAUTH_URL,\n headers: { 'content-type': 'application/x-www-form-urlencoded' },\n body: new URLSearchParams({ grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer', assertion }).toString(),\n timeoutMs,\n });\n const data = parse(response.body);\n if (\n response.status !== 200 ||\n typeof data.access_token !== 'string' ||\n !data.access_token ||\n typeof data.expires_in !== 'number' ||\n !Number.isFinite(data.expires_in) ||\n data.expires_in <= 0\n )\n throw new Error('OAuth failed');\n oauth = { value: data.access_token, expires: now() + Math.max(0, Math.min(data.expires_in, 3600) - 60) * 1000 };\n return oauth.value;\n })();\n try {\n return await oauthPending;\n } finally {\n oauthPending = undefined;\n }\n }\n\n return {\n async send(registration, notification, sessionId) {\n const provider = registration.platform === 'ios' ? 'apns' : 'fcm';\n if (closed || !options[provider]) {\n options.diagnostic?.({ provider, outcome: 'unavailable' });\n return { invalid: false };\n }\n try {\n const data = {\n ...(registration.hostRef ? { hostRef: registration.hostRef } : {}),\n ...(sessionId ? { sessionId } : {}),\n };\n let response;\n let reason: string | undefined;\n if (registration.platform === 'ios') {\n const credentials = options.apns!;\n if (!apnsJwt || now() >= apnsJwt.expires) {\n apnsJwt = {\n value: signPushJwt(\n { alg: 'ES256', kid: credentials.keyId },\n {\n iss: credentials.teamId,\n iat: Math.floor(now() / 1000),\n },\n credentials.key,\n 'ES256',\n ),\n expires: now() + 50 * 60_000,\n };\n }\n response = await request({\n url: `https://${registration.environment === 'development' ? 'api.sandbox.push.apple.com' : 'api.push.apple.com'}/3/device/${encodeURIComponent(registration.token)}`,\n http2: true,\n timeoutMs,\n headers: {\n authorization: `bearer ${apnsJwt.value}`,\n 'apns-topic': APNS_TOPIC,\n 'apns-push-type': 'alert',\n 'apns-priority': '10',\n 'apns-expiration': '0',\n 'content-type': 'application/json',\n },\n // ponytail: live alerts only; add a durable outbox if delayed delivery becomes a requirement.\n // Expo iOS reads custom remote data from userInfo.body. Keep data as the provider-neutral payload.\n body: payload(notification, (text) => ({ aps: { alert: text, sound: 'default' }, data, body: data })),\n });\n const value = parse(response.body).reason;\n if (typeof value === 'string' && APNS_REASONS.has(value)) reason = value;\n if (\n (response.status === 410 && reason === 'Unregistered') ||\n (response.status === 400 && reason === 'BadDeviceToken')\n ) {\n options.diagnostic?.({\n provider,\n outcome: 'invalid',\n status: response.status,\n ...(reason ? { reason } : {}),\n });\n return { invalid: true };\n }\n } else {\n const body = payload(notification, (text) => ({\n message: {\n token: registration.token,\n data,\n notification: { title: text.title, body: [text.subtitle, text.body].filter(Boolean).join('\\n') },\n // ponytail: zero TTL, no offline delivery; an outbox would own delayed sends.\n android: { ttl: '0s', priority: 'HIGH', notification: { channel_id: 'po-notifications' } },\n },\n }));\n const token = await accessToken();\n if (closed) return { invalid: false };\n response = await request({\n url: `https://fcm.googleapis.com/v1/projects/${encodeURIComponent(options.fcm!.projectId)}/messages:send`,\n headers: { authorization: `Bearer ${token}`, 'content-type': 'application/json' },\n body,\n timeoutMs,\n });\n const error = parse(response.body).error;\n if (\n response.status === 404 &&\n error &&\n typeof error === 'object' &&\n 'details' in error &&\n Array.isArray(error.details) &&\n error.details.some(\n (detail: unknown) =>\n detail &&\n typeof detail === 'object' &&\n '@type' in detail &&\n detail['@type'] === FCM_ERROR_TYPE &&\n 'errorCode' in detail &&\n detail.errorCode === 'UNREGISTERED',\n )\n ) {\n options.diagnostic?.({\n provider,\n outcome: 'invalid',\n status: response.status,\n ...(reason ? { reason } : {}),\n });\n return { invalid: true };\n }\n }\n if (response.status < 200 || response.status >= 300)\n options.diagnostic?.({ provider, outcome: 'failed', status: response.status, ...(reason ? { reason } : {}) });\n } catch {\n // Never expose provider bodies, credentials, device tokens, or network errors.\n options.diagnostic?.({ provider, outcome: 'failed' });\n }\n return { invalid: false };\n },\n close() {\n closed = true;\n apnsJwt = undefined;\n oauth = undefined;\n transport.close();\n },\n };\n}\n","const DEFAULT_ASK_USER_BODY = 'The agent is waiting for your feedback.';\nconst RPC_MODE = 'rpc';\n\nexport interface AttentionState {\n agentRunning: boolean;\n askUserBlocked: boolean;\n}\n\nexport interface ShellSurface {\n hasUI: boolean;\n mode?: string;\n}\n\n/**\n * A dialog is worth interrupting the user for only while the agent holds the turn.\n *\n * Outside a run the user opened the dialog themselves and is already looking at\n * it. An ask-user prompt is announced by its own event, so the dialog it then\n * opens must stay silent or the same question notifies twice.\n */\nexport function warrantsAttentionNotification({ agentRunning, askUserBlocked }: AttentionState): boolean {\n return agentRunning && !askUserBlocked;\n}\n\n/** A queued follow-up means the agent keeps working, so the run has not stopped for the user. */\nexport function warrantsSettledNotification(hasPendingMessages: boolean): boolean {\n return !hasPendingMessages;\n}\n\n/** Terminal title escapes only mean something on an attached terminal; RPC output stays clean. */\nexport function supportsShellTitle({ hasUI, mode }: ShellSurface): boolean {\n return hasUI && mode !== RPC_MODE;\n}\n\n/** The question an ask-user prompt is blocking on, or a stand-in when it asked none. */\nexport function askUserPromptBody(questions: readonly { question: string }[]): string {\n return questions[0]?.question ?? DEFAULT_ASK_USER_BODY;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAa,iBAAiB;CAAC;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;AAAG;;AAI/E,SAAgB,kCAAwD;CACtE,IAAI,aAAa;CACjB,IAAI;CACJ,MAAM,sBAAsB;EAC1B,IAAI,OAAO,cAAc,KAAK;EAC9B,QAAQ,KAAA;EACR,aAAa;CACf;CAEA,OAAO;EACL,IAAI,OA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AC3B,MAAM,QAAQ,MACX,WACC,UACA,OAAO,WAAW,YAClB,WAAW,UACX,OAAO,aAAa,kBACpB,eAAe,UACf,OAAO,cAAc,cACzB,GACA;MACA,QAAQ,aAAa;OACnB;OACA,SAAS;OACT,QAAQ,SAAS;OACjB,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;MAC7B,CAAC;MACD,OAAO,EAAE,SAAS,KAAK;KACzB;IACF;IACA,IAAI,SAAS,SAAS,OAAO,SAAS,UAAU,KAC9C,QAAQ,aAAa;KAAE;KAAU,SAAS;KAAU,QAAQ,SAAS;KAAQ,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;IAAG,CAAC;GAChH,QAAQ;IAEN,QAAQ,aAAa;KAAE;KAAU,SAAS;IAAS,CAAC;GACtD;GACA,OAAO,EAAE,SAAS,MAAM;EAC1B;EACA,QAAQ;GACN,SAAS;GACT,UAAU,KAAA;GACV,QAAQ,KAAA;GACR,UAAU,MAAM;EAClB;CACF;AACF;;;AC1PA,MAAM,wBAAwB;AAC9B,MAAM,WAAW;;;;;;;;AAmBjB,SAAgB,8BAA8B,EAAE,cAAc,kBAA2C;CACvG,OAAO,gBAAgB,CAAC;AAC1B;;AAGA,SAAgB,4BAA4B,oBAAsC;CAChF,OAAO,CAAC;AACV;;AAGA,SAAgB,mBAAmB,EAAE,OAAO,QAA+B;CACzE,OAAO,SAAS,SAAS;AAC3B;;AAGA,SAAgB,kBAAkB,WAAoD;CACpF,OAAO,UAAU,EAAE,EAAE,YAAY;AACnC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/types/notifications.ts","../src/services/shellTitleController/mainThread.ts","../src/services/shellTitleController/index.ts","../src/services/systemNotification/index.ts","../src/services/nativePushSender/type.ts","../src/services/nativePushSender/index.ts","../src/services/notificationPolicy/index.ts","../src/services/notificationText/index.ts"],"mappings":";;UAAiB;;EAEf,kBAAkB;EAClB,cAAc,OAAO;;UAGN;EACf,KAAK,iBAAiB,gBAAgB;IAAW;MAAoB;IAAU;;;;KAIrE,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;;;;;wBCnCc,mCAAmC;;;;;;;;wBCsCnC,+BAA+B;;;;;;;;;;wBCjBzB,uBACpB,IAAI,sBACJ,cAAc,qBACd,oBACC;;;KC7BS;EACN;EAAiB;EAAe;EAAkB;;EAClD;EAAqB;EAAe;;UAEzB;EACf;EACA,SAAS;EACT;EACA;EACA;;UAEe;EACf;EACA;;UAEe;EACf;IAAS;IAAa;IAAe;;EACrC;IAAQ;IAAqB;IAAoB;;EACjD;EACA,WAAW,SAAS,sBAAsB,QAAQ;EAClD;EACA,cAAc;IACZ;IACA;IACA;IACA;;;UAGa;EACf,KACE,cAAc,wBACd,cAAc,yBACd,qBACC;IAAU;;EACb;;;;wBCyCc,uBAAuB,SAAS,0BAA0B;;;UC1EzD;EACf;EACA;;UAGe;EACf;EACA;;;;;;;;;wBAUc,gCAAgC,cAAc,kBAAkB;;wBAKhE,4BAA4B;;wBAK5B,qBAAqB,OAAO,QAAQ;;wBAKpC,kBAAkB;EAAsB;;;;;wBCZxC,YAAY;UAKX;EACf;EACA;EACA;;;;;;;;wBASc,gBAAgB,KAAK,aAAa,UAAU;;wBAS5C,iBAAiB;;wBAKjB,sBAAsB,eAAe;;wBAKrC,sBAAsB,KAAK;EAAiB;EAAa;IAAyB"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/types/notifications.ts","../src/services/shellTitleController/mainThread.ts","../src/services/shellTitleController/index.ts","../src/services/systemNotification/index.ts","../src/services/nativePushSender/type.ts","../src/services/nativePushSender/index.ts","../src/services/notificationPolicy/index.ts","../src/services/notificationText/index.ts"],"mappings":";;UAAiB;;EAEf,kBAAkB;EAClB,cAAc,OAAO;;UAGN;EACf,KAAK,iBAAiB,gBAAgB;IAAW;MAAoB;IAAU;;;;KAIrE,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;;;;;wBCnCc,mCAAmC;;;;;;;;wBCuCnC,+BAA+B;;;;;;;;;;wBClBzB,uBACpB,IAAI,sBACJ,cAAc,qBACd,oBACC;;;KC7BS;EACN;EAAiB;EAAe;EAAkB;;EAClD;EAAqB;EAAe;;UAEzB;EACf;EACA,SAAS;EACT;EACA;EACA;;UAEe;EACf;EACA;;UAEe;EACf;IAAS;IAAa;IAAe;;EACrC;IAAQ;IAAqB;IAAoB;;EACjD;EACA,WAAW,SAAS,sBAAsB,QAAQ;EAClD;EACA,cAAc;IACZ;IACA;IACA;IACA;;;UAGa;EACf,KACE,cAAc,wBACd,cAAc,yBACd,qBACC;IAAU;;EACb;;;;wBCyCc,uBAAuB,SAAS,0BAA0B;;;UC1EzD;EACf;EACA;;UAGe;EACf;EACA;;;;;;;;;wBAUc,gCAAgC,cAAc,kBAAkB;;wBAKhE,4BAA4B;;wBAK5B,qBAAqB,OAAO,QAAQ;;wBAKpC,kBAAkB;EAAsB;;;;;wBCZxC,YAAY;UAKX;EACf;EACA;EACA;;;;;;;;wBASc,gBAAgB,KAAK,aAAa,UAAU;;wBAS5C,iBAAiB;;wBAKjB,sBAAsB,eAAe;;wBAKrC,sBAAsB,KAAK;EAAiB;EAAa;IAAyB"}
package/dist/index.mjs CHANGED
@@ -58,11 +58,12 @@ function createMainThreadTitleController() {
58
58
  * located on disk at runtime.
59
59
  */
60
60
  const TITLE_WORKER_SOURCE = `
61
- const { writeSync } = require('node:fs');
61
+ const { createWriteStream } = require('node:fs');
62
+ const output = createWriteStream('', { fd: 1, autoClose: false });
62
63
  const { parentPort, workerData } = require('node:worker_threads');
63
64
  let frameIndex = 0;
64
65
  let timer;
65
- const writeTitle = (title) => writeSync(1, '\\u001b]0;' + title + '\\u0007');
66
+ const writeTitle = (title) => output.write('\\u001b]0;' + title + '\\u0007');
66
67
  const stop = () => {
67
68
  if (timer) clearInterval(timer);
68
69
  timer = undefined;
@@ -80,7 +81,7 @@ parentPort.on('message', (command) => {
80
81
  return;
81
82
  }
82
83
  writeTitle(command.title);
83
- if (command.action === 'dispose') parentPort.close();
84
+ if (command.action === 'dispose') output.end(() => parentPort.close());
84
85
  });
85
86
  `;
86
87
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/services/shellTitleController/mainThread.ts","../src/services/shellTitleController/index.ts","../src/services/notificationText/index.ts","../src/services/systemNotification/index.ts","../src/services/nativePushSender/sync.ts","../src/services/nativePushSender/index.ts","../src/services/notificationPolicy/index.ts"],"sourcesContent":["import type { ShellTitleController } from '../../types/notifications';\n\nexport const BRAILLE_FRAMES = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];\nexport const TITLE_FRAME_INTERVAL_MS = 80;\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","import { Worker } from 'node:worker_threads';\n\nimport type { ShellTitleCommand, ShellTitleController, WriteTitle } from '../../types/notifications';\nimport { BRAILLE_FRAMES, TITLE_FRAME_INTERVAL_MS, createMainThreadTitleController } from './mainThread';\n\nexport { createMainThreadTitleController } from './mainThread';\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/**\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","import path from 'node:path';\n\nimport type { DesktopNotification } from '../../types/notifications';\n\nconst ATTENTION_SUBTITLE = 'Approval or feedback required';\nconst ATTENTION_TITLE = 'Po needs your input';\nconst ELLIPSIS = '…';\nconst MAX_BODY_LENGTH = 240;\nconst MAX_PROMPT_TITLE_LENGTH = 36;\nconst SETTLED_BODY = 'The agent finished its work and is waiting for you.';\nconst SETTLED_TITLE = 'Po finished';\nconst SHELL_TITLE_SEPARATOR = ' - ';\nconst SHELL_TITLE_PREFIX = 'π';\n\nfunction collapseWhitespace(value: string): string {\n return value.replace(/\\s+/g, ' ').trim();\n}\n\nfunction truncate(value: string, maxLength: number): string {\n return value.length > maxLength ? `${value.slice(0, maxLength - 1)}${ELLIPSIS}` : value;\n}\n\n/** The first user prompt, shortened to fit a shell tab. A blank prompt names nothing. */\nexport function promptTitle(prompt: string): string | undefined {\n const normalized = collapseWhitespace(prompt);\n return normalized ? truncate(normalized, MAX_PROMPT_TITLE_LENGTH) : undefined;\n}\n\nexport interface ShellTabTitleInput {\n cwd: string;\n sessionName?: string;\n prompt?: string;\n}\n\n/**\n * The idle shell-tab title: `π - <label> - <repository>`.\n *\n * The session name wins over the first prompt because the user chose it. With\n * neither, the repository alone still tells two tabs apart.\n */\nexport function shellTabTitle({ cwd, sessionName, prompt }: ShellTabTitleInput): string {\n const repository = path.basename(cwd);\n const label = sessionName ?? prompt;\n return label\n ? `${SHELL_TITLE_PREFIX}${SHELL_TITLE_SEPARATOR}${label}${SHELL_TITLE_SEPARATOR}${repository}`\n : `${SHELL_TITLE_PREFIX}${SHELL_TITLE_SEPARATOR}${repository}`;\n}\n\n/** Notification bodies are one line in a system panel, so they collapse and truncate. */\nexport function notificationBody(body: string): string {\n return truncate(collapseWhitespace(body), MAX_BODY_LENGTH);\n}\n\n/** Sent while the agent holds the turn and something is blocking on the user. */\nexport function attentionNotification(body: string): DesktopNotification {\n return { title: ATTENTION_TITLE, subtitle: ATTENTION_SUBTITLE, body };\n}\n\n/** Sent once a run has stopped, subtitled with whichever name the user recognises. */\nexport function settledNotification({ cwd, sessionName }: { cwd: string; sessionName?: string }): DesktopNotification {\n return { title: SETTLED_TITLE, subtitle: sessionName ?? path.basename(cwd), body: SETTLED_BODY };\n}\n","import type { DesktopNotification, NotificationExecutor } from '../../types/notifications';\nimport { notificationBody } from '../notificationText';\n\nconst CMUX_COMMAND = 'cmux';\nconst COMMAND_TIMEOUT_MS = 3_000;\nconst DARWIN_PLATFORM = 'darwin';\nconst OSASCRIPT_COMMAND = 'osascript';\nconst OSASCRIPT_EXPRESSION_FLAG = '-e';\n\nasync function execute(pi: NotificationExecutor, command: string, args: string[]): Promise<boolean> {\n try {\n const result = await pi.exec(command, args, { timeout: COMMAND_TIMEOUT_MS });\n return result.code === 0;\n } catch {\n // A notifier that is not installed is the ordinary case, not a fault: report\n // \"not delivered\" and let the caller decide whether another one exists.\n return false;\n }\n}\n\n/**\n * Delivers one desktop notification on a best-effort basis.\n *\n * cmux is tried first because it routes the notification to the window the\n * session actually lives in. Only macOS has a second option worth attempting,\n * and a host with neither stays silent rather than failing the turn.\n */\nexport async function sendSystemNotification(\n pi: NotificationExecutor,\n notification: DesktopNotification,\n platform: string = process.platform,\n): Promise<void> {\n const body = notificationBody(notification.body);\n const sentToCmux = await execute(pi, CMUX_COMMAND, [\n 'notify',\n '--title',\n notification.title,\n '--subtitle',\n notification.subtitle,\n '--body',\n body,\n ]);\n if (sentToCmux || platform !== DARWIN_PLATFORM) return;\n\n await execute(pi, OSASCRIPT_COMMAND, [\n OSASCRIPT_EXPRESSION_FLAG,\n 'on run argv',\n OSASCRIPT_EXPRESSION_FLAG,\n 'display notification (item 3 of argv) with title (item 1 of argv) subtitle (item 2 of argv)',\n OSASCRIPT_EXPRESSION_FLAG,\n 'end run',\n notification.title,\n notification.subtitle,\n body,\n ]);\n}\n","import { sign } from 'node:crypto';\nimport { connect } from 'node:http2';\nimport { request } from 'node:https';\n\nimport type { NativePushRequest, NativePushResponse } from './type';\n\nconst MAX_RESPONSE_BYTES = 65_536;\n\nexport function signPushJwt(header: object, claims: object, key: string, algorithm: 'ES256' | 'RS256'): string {\n const input = [header, claims].map((part) => Buffer.from(JSON.stringify(part)).toString('base64url')).join('.');\n const signature = sign('sha256', Buffer.from(input), { key, dsaEncoding: 'ieee-p1363' });\n // APNs requires the raw P1363 ECDSA signature, not ASN.1 DER.\n if (algorithm === 'ES256' && signature.length !== 64) throw new Error('Invalid signing key');\n return `${input}.${signature.toString('base64url')}`;\n}\n\nexport function createPushTransport() {\n const pending = new Set<() => void>();\n return {\n request(this: void, input: NativePushRequest): Promise<NativePushResponse> {\n return new Promise((resolve, reject) => {\n const url = new URL(input.url);\n let size = 0;\n const chunks: Buffer[] = [];\n let done = false;\n let dispose = () => {};\n const finish = (error?: Error, status = 0) => {\n if (done) return;\n done = true;\n clearTimeout(timer);\n pending.delete(cancel);\n dispose();\n if (error) reject(error);\n else resolve({ status, body: Buffer.concat(chunks).toString('utf8') });\n };\n const cancel = () => finish(new Error('Push request cancelled'));\n const timer = setTimeout(() => finish(new Error('Push request timed out')), input.timeoutMs);\n pending.add(cancel);\n const data = (chunk: Buffer) => {\n size += chunk.length;\n if (size > MAX_RESPONSE_BYTES) finish(new Error('Push response too large'));\n else chunks.push(Buffer.from(chunk));\n };\n if (input.http2) {\n const session = connect(url.origin);\n dispose = () => session.destroy();\n session.on('error', (error) => finish(error));\n const stream = session.request({ ':method': 'POST', ':path': url.pathname, ...input.headers });\n let status = 0;\n stream.on('response', (headers) => {\n status = Number(headers[':status']);\n });\n stream.on('data', data);\n stream.on('error', (error) => finish(error));\n stream.on('end', () => finish(undefined, status));\n stream.end(input.body);\n } else {\n const req = request(url, { method: 'POST', headers: input.headers }, (response) => {\n response.on('data', data);\n response.on('error', (error) => finish(error));\n response.on('end', () => finish(undefined, response.statusCode));\n });\n dispose = () => req.destroy();\n req.on('error', (error) => finish(error));\n req.end(input.body);\n }\n });\n },\n close() {\n for (const cancel of pending) cancel();\n },\n };\n}\n","import type { PoNotificationEntryData } from '@agimon-ai/po-core';\n\nimport { createPushTransport, signPushJwt } from './sync';\nimport type { NativePushSender, NativePushSenderOptions } from './type';\n\nconst MAX_PAYLOAD_BYTES = 4096;\nconst APNS_TOPIC = 'ai.po.app';\n// Only documented provider codes may enter diagnostics, never arbitrary response text.\nconst APNS_REASONS = new Set([\n 'BadCollapseId',\n 'BadDeviceToken',\n 'BadExpirationDate',\n 'BadMessageId',\n 'BadPriority',\n 'BadTopic',\n 'DeviceTokenNotForTopic',\n 'DuplicateHeaders',\n 'IdleTimeout',\n 'InvalidPushType',\n 'MissingDeviceToken',\n 'MissingTopic',\n 'PayloadEmpty',\n 'TopicDisallowed',\n 'BadCertificate',\n 'BadCertificateEnvironment',\n 'ExpiredProviderToken',\n 'Forbidden',\n 'InvalidProviderToken',\n 'MissingProviderToken',\n 'BadPath',\n 'MethodNotAllowed',\n 'Unregistered',\n 'PayloadTooLarge',\n 'TooManyProviderTokenUpdates',\n 'TooManyRequests',\n 'InternalServerError',\n 'ServiceUnavailable',\n 'Shutdown',\n]);\nconst OAUTH_URL = 'https://oauth2.googleapis.com/token';\nconst FCM_ERROR_TYPE = 'type.googleapis.com/google.firebase.fcm.v1.FcmError';\nconst encoder = new TextEncoder();\n\nfunction parse(body: string): Record<string, unknown> {\n try {\n const value: unknown = JSON.parse(body);\n return value && typeof value === 'object' ? (value as Record<string, unknown>) : {};\n } catch {\n return {};\n } // Malformed provider responses never invalidate registrations.\n}\n\nfunction payload(\n notification: PoNotificationEntryData,\n build: (text: { title: string; subtitle: string; body: string }) => object,\n): string {\n const text = { title: notification.title, subtitle: notification.subtitle, body: notification.body };\n let result = JSON.stringify(build(text));\n // Measure the full serialized envelope, including escaped text and the FCM token.\n for (const field of ['body', 'subtitle', 'title'] as const) {\n if (encoder.encode(result).length <= MAX_PAYLOAD_BYTES) break;\n const points = Array.from(text[field]);\n let low = 0;\n let high = points.length;\n while (low < high) {\n const middle = Math.ceil((low + high) / 2);\n text[field] = points.slice(0, middle).join('');\n if (encoder.encode(JSON.stringify(build(text))).length <= MAX_PAYLOAD_BYTES) low = middle;\n else high = middle - 1;\n }\n text[field] = points.slice(0, low).join('');\n result = JSON.stringify(build(text));\n }\n if (encoder.encode(result).length > MAX_PAYLOAD_BYTES) throw new Error('Push payload too large');\n return result;\n}\n\nexport function createNativePushSender(options: NativePushSenderOptions): NativePushSender {\n const transport = createPushTransport();\n const request = options.request ?? transport.request;\n const now = options.now ?? Date.now;\n const timeoutMs = Number.isFinite(options.timeoutMs) ? Math.max(1, Math.min(options.timeoutMs!, 30_000)) : 10_000;\n let closed = false;\n let apnsJwt: { value: string; expires: number } | undefined;\n let oauth: { value: string; expires: number } | undefined;\n let oauthPending: Promise<string> | undefined;\n\n async function accessToken(): Promise<string> {\n if (oauth && now() < oauth.expires) return oauth.value;\n if (oauthPending) return oauthPending;\n oauthPending = (async () => {\n const credentials = options.fcm!;\n const issued = Math.floor(now() / 1000);\n const assertion = signPushJwt(\n { alg: 'RS256', typ: 'JWT' },\n {\n iss: credentials.clientEmail,\n scope: 'https://www.googleapis.com/auth/firebase.messaging',\n aud: OAUTH_URL,\n iat: issued,\n exp: issued + 3600,\n },\n credentials.privateKey,\n 'RS256',\n );\n const response = await request({\n url: OAUTH_URL,\n headers: { 'content-type': 'application/x-www-form-urlencoded' },\n body: new URLSearchParams({ grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer', assertion }).toString(),\n timeoutMs,\n });\n const data = parse(response.body);\n if (\n response.status !== 200 ||\n typeof data.access_token !== 'string' ||\n !data.access_token ||\n typeof data.expires_in !== 'number' ||\n !Number.isFinite(data.expires_in) ||\n data.expires_in <= 0\n )\n throw new Error('OAuth failed');\n oauth = { value: data.access_token, expires: now() + Math.max(0, Math.min(data.expires_in, 3600) - 60) * 1000 };\n return oauth.value;\n })();\n try {\n return await oauthPending;\n } finally {\n oauthPending = undefined;\n }\n }\n\n return {\n async send(registration, notification, sessionId) {\n const provider = registration.platform === 'ios' ? 'apns' : 'fcm';\n if (closed || !options[provider]) {\n options.diagnostic?.({ provider, outcome: 'unavailable' });\n return { invalid: false };\n }\n try {\n const data = {\n ...(registration.hostRef ? { hostRef: registration.hostRef } : {}),\n ...(sessionId ? { sessionId } : {}),\n };\n let response;\n let reason: string | undefined;\n if (registration.platform === 'ios') {\n const credentials = options.apns!;\n if (!apnsJwt || now() >= apnsJwt.expires) {\n apnsJwt = {\n value: signPushJwt(\n { alg: 'ES256', kid: credentials.keyId },\n {\n iss: credentials.teamId,\n iat: Math.floor(now() / 1000),\n },\n credentials.key,\n 'ES256',\n ),\n expires: now() + 50 * 60_000,\n };\n }\n response = await request({\n url: `https://${registration.environment === 'development' ? 'api.sandbox.push.apple.com' : 'api.push.apple.com'}/3/device/${encodeURIComponent(registration.token)}`,\n http2: true,\n timeoutMs,\n headers: {\n authorization: `bearer ${apnsJwt.value}`,\n 'apns-topic': APNS_TOPIC,\n 'apns-push-type': 'alert',\n 'apns-priority': '10',\n 'apns-expiration': '0',\n 'content-type': 'application/json',\n },\n // ponytail: live alerts only; add a durable outbox if delayed delivery becomes a requirement.\n // Expo iOS reads custom remote data from userInfo.body. Keep data as the provider-neutral payload.\n body: payload(notification, (text) => ({ aps: { alert: text, sound: 'default' }, data, body: data })),\n });\n const value = parse(response.body).reason;\n if (typeof value === 'string' && APNS_REASONS.has(value)) reason = value;\n if (\n (response.status === 410 && reason === 'Unregistered') ||\n (response.status === 400 && reason === 'BadDeviceToken')\n ) {\n options.diagnostic?.({\n provider,\n outcome: 'invalid',\n status: response.status,\n ...(reason ? { reason } : {}),\n });\n return { invalid: true };\n }\n } else {\n const body = payload(notification, (text) => ({\n message: {\n token: registration.token,\n data,\n notification: { title: text.title, body: [text.subtitle, text.body].filter(Boolean).join('\\n') },\n // ponytail: zero TTL, no offline delivery; an outbox would own delayed sends.\n android: { ttl: '0s', priority: 'HIGH', notification: { channel_id: 'po-notifications' } },\n },\n }));\n const token = await accessToken();\n if (closed) return { invalid: false };\n response = await request({\n url: `https://fcm.googleapis.com/v1/projects/${encodeURIComponent(options.fcm!.projectId)}/messages:send`,\n headers: { authorization: `Bearer ${token}`, 'content-type': 'application/json' },\n body,\n timeoutMs,\n });\n const error = parse(response.body).error;\n if (\n response.status === 404 &&\n error &&\n typeof error === 'object' &&\n 'details' in error &&\n Array.isArray(error.details) &&\n error.details.some(\n (detail: unknown) =>\n detail &&\n typeof detail === 'object' &&\n '@type' in detail &&\n detail['@type'] === FCM_ERROR_TYPE &&\n 'errorCode' in detail &&\n detail.errorCode === 'UNREGISTERED',\n )\n ) {\n options.diagnostic?.({\n provider,\n outcome: 'invalid',\n status: response.status,\n ...(reason ? { reason } : {}),\n });\n return { invalid: true };\n }\n }\n if (response.status < 200 || response.status >= 300)\n options.diagnostic?.({ provider, outcome: 'failed', status: response.status, ...(reason ? { reason } : {}) });\n } catch {\n // Never expose provider bodies, credentials, device tokens, or network errors.\n options.diagnostic?.({ provider, outcome: 'failed' });\n }\n return { invalid: false };\n },\n close() {\n closed = true;\n apnsJwt = undefined;\n oauth = undefined;\n transport.close();\n },\n };\n}\n","const DEFAULT_ASK_USER_BODY = 'The agent is waiting for your feedback.';\nconst RPC_MODE = 'rpc';\n\nexport interface AttentionState {\n agentRunning: boolean;\n askUserBlocked: boolean;\n}\n\nexport interface ShellSurface {\n hasUI: boolean;\n mode?: string;\n}\n\n/**\n * A dialog is worth interrupting the user for only while the agent holds the turn.\n *\n * Outside a run the user opened the dialog themselves and is already looking at\n * it. An ask-user prompt is announced by its own event, so the dialog it then\n * opens must stay silent or the same question notifies twice.\n */\nexport function warrantsAttentionNotification({ agentRunning, askUserBlocked }: AttentionState): boolean {\n return agentRunning && !askUserBlocked;\n}\n\n/** A queued follow-up means the agent keeps working, so the run has not stopped for the user. */\nexport function warrantsSettledNotification(hasPendingMessages: boolean): boolean {\n return !hasPendingMessages;\n}\n\n/** Terminal title escapes only mean something on an attached terminal; RPC output stays clean. */\nexport function supportsShellTitle({ hasUI, mode }: ShellSurface): boolean {\n return hasUI && mode !== RPC_MODE;\n}\n\n/** The question an ask-user prompt is blocking on, or a stand-in when it asked none. */\nexport function askUserPromptBody(questions: readonly { question: string }[]): string {\n return questions[0]?.question ?? DEFAULT_ASK_USER_BODY;\n}\n"],"mappings":";;;;;;AAEA,MAAa,iBAAiB;CAAC;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;AAAG;;AAI/E,SAAgB,kCAAwD;CACtE,IAAI,aAAa;CACjB,IAAI;CACJ,MAAM,sBAAsB;EAC1B,IAAI,OAAO,cAAc,KAAK;EAC9B,QAAQ,KAAA;EACR,aAAa;CACf;CAEA,OAAO;EACL,IAAI,OAAO,OAAO;GAChB,cAAc;GACd,MAAM,KAAK;EACb;EACA,MAAM,OAAO,OAAO;GAClB,cAAc;GACd,MAAM,eAAe;IACnB,MAAM,GAAG,eAAe,aAAa,eAAe,QAAQ,GAAG,OAAO;IACtE,cAAc;GAChB;GACA,OAAO;GACP,QAAQ,YAAY,QAAA,EAA+B;EACrD;EACA,KAAK,OAAO,OAAO;GACjB,cAAc;GACd,MAAM,KAAK;EACb;EACA,QAAQ,OAAO,OAAO;GACpB,cAAc;GACd,MAAM,KAAK;EACb;CACF;AACF;;;;;;;;;AC1BA,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgC5B,SAAgB,8BAAoD;CAClE,MAAM,WAAW,gCAAgC;CACjD,IAAI;CACJ,IAAI;CACJ,IAAI;CAEJ,MAAM,iBAAiB;EACrB,SAAS,K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MAAM,wBAAwB;AAC9B,MAAM,WAAW;;;;;;;;AAmBjB,SAAgB,8BAA8B,EAAE,cAAc,kBAA2C;CACvG,OAAO,gBAAgB,CAAC;AAC1B;;AAGA,SAAgB,4BAA4B,oBAAsC;CAChF,OAAO,CAAC;AACV;;AAGA,SAAgB,mBAAmB,EAAE,OAAO,QAA+B;CACzE,OAAO,SAAS,SAAS;AAC3B;;AAGA,SAAgB,kBAAkB,WAAoD;CACpF,OAAO,UAAU,EAAE,EAAE,YAAY;AACnC"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/services/shellTitleController/mainThread.ts","../src/services/shellTitleController/index.ts","../src/services/notificationText/index.ts","../src/services/systemNotification/index.ts","../src/services/nativePushSender/sync.ts","../src/services/nativePushSender/index.ts","../src/services/notificationPolicy/index.ts"],"sourcesContent":["import type { ShellTitleController } from '../../types/notifications';\n\nexport const BRAILLE_FRAMES = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];\nexport const TITLE_FRAME_INTERVAL_MS = 80;\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","import { Worker } from 'node:worker_threads';\n\nimport type { ShellTitleCommand, ShellTitleController, WriteTitle } from '../../types/notifications';\nimport { BRAILLE_FRAMES, TITLE_FRAME_INTERVAL_MS, createMainThreadTitleController } from './mainThread';\n\nexport { createMainThreadTitleController } from './mainThread';\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 { createWriteStream } = require('node:fs');\nconst output = createWriteStream('', { fd: 1, autoClose: false });\nconst { parentPort, workerData } = require('node:worker_threads');\nlet frameIndex = 0;\nlet timer;\nconst writeTitle = (title) => output.write('\\\\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') output.end(() => parentPort.close());\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","import path from 'node:path';\n\nimport type { DesktopNotification } from '../../types/notifications';\n\nconst ATTENTION_SUBTITLE = 'Approval or feedback required';\nconst ATTENTION_TITLE = 'Po needs your input';\nconst ELLIPSIS = '…';\nconst MAX_BODY_LENGTH = 240;\nconst MAX_PROMPT_TITLE_LENGTH = 36;\nconst SETTLED_BODY = 'The agent finished its work and is waiting for you.';\nconst SETTLED_TITLE = 'Po finished';\nconst SHELL_TITLE_SEPARATOR = ' - ';\nconst SHELL_TITLE_PREFIX = 'π';\n\nfunction collapseWhitespace(value: string): string {\n return value.replace(/\\s+/g, ' ').trim();\n}\n\nfunction truncate(value: string, maxLength: number): string {\n return value.length > maxLength ? `${value.slice(0, maxLength - 1)}${ELLIPSIS}` : value;\n}\n\n/** The first user prompt, shortened to fit a shell tab. A blank prompt names nothing. */\nexport function promptTitle(prompt: string): string | undefined {\n const normalized = collapseWhitespace(prompt);\n return normalized ? truncate(normalized, MAX_PROMPT_TITLE_LENGTH) : undefined;\n}\n\nexport interface ShellTabTitleInput {\n cwd: string;\n sessionName?: string;\n prompt?: string;\n}\n\n/**\n * The idle shell-tab title: `π - <label> - <repository>`.\n *\n * The session name wins over the first prompt because the user chose it. With\n * neither, the repository alone still tells two tabs apart.\n */\nexport function shellTabTitle({ cwd, sessionName, prompt }: ShellTabTitleInput): string {\n const repository = path.basename(cwd);\n const label = sessionName ?? prompt;\n return label\n ? `${SHELL_TITLE_PREFIX}${SHELL_TITLE_SEPARATOR}${label}${SHELL_TITLE_SEPARATOR}${repository}`\n : `${SHELL_TITLE_PREFIX}${SHELL_TITLE_SEPARATOR}${repository}`;\n}\n\n/** Notification bodies are one line in a system panel, so they collapse and truncate. */\nexport function notificationBody(body: string): string {\n return truncate(collapseWhitespace(body), MAX_BODY_LENGTH);\n}\n\n/** Sent while the agent holds the turn and something is blocking on the user. */\nexport function attentionNotification(body: string): DesktopNotification {\n return { title: ATTENTION_TITLE, subtitle: ATTENTION_SUBTITLE, body };\n}\n\n/** Sent once a run has stopped, subtitled with whichever name the user recognises. */\nexport function settledNotification({ cwd, sessionName }: { cwd: string; sessionName?: string }): DesktopNotification {\n return { title: SETTLED_TITLE, subtitle: sessionName ?? path.basename(cwd), body: SETTLED_BODY };\n}\n","import type { DesktopNotification, NotificationExecutor } from '../../types/notifications';\nimport { notificationBody } from '../notificationText';\n\nconst CMUX_COMMAND = 'cmux';\nconst COMMAND_TIMEOUT_MS = 3_000;\nconst DARWIN_PLATFORM = 'darwin';\nconst OSASCRIPT_COMMAND = 'osascript';\nconst OSASCRIPT_EXPRESSION_FLAG = '-e';\n\nasync function execute(pi: NotificationExecutor, command: string, args: string[]): Promise<boolean> {\n try {\n const result = await pi.exec(command, args, { timeout: COMMAND_TIMEOUT_MS });\n return result.code === 0;\n } catch {\n // A notifier that is not installed is the ordinary case, not a fault: report\n // \"not delivered\" and let the caller decide whether another one exists.\n return false;\n }\n}\n\n/**\n * Delivers one desktop notification on a best-effort basis.\n *\n * cmux is tried first because it routes the notification to the window the\n * session actually lives in. Only macOS has a second option worth attempting,\n * and a host with neither stays silent rather than failing the turn.\n */\nexport async function sendSystemNotification(\n pi: NotificationExecutor,\n notification: DesktopNotification,\n platform: string = process.platform,\n): Promise<void> {\n const body = notificationBody(notification.body);\n const sentToCmux = await execute(pi, CMUX_COMMAND, [\n 'notify',\n '--title',\n notification.title,\n '--subtitle',\n notification.subtitle,\n '--body',\n body,\n ]);\n if (sentToCmux || platform !== DARWIN_PLATFORM) return;\n\n await execute(pi, OSASCRIPT_COMMAND, [\n OSASCRIPT_EXPRESSION_FLAG,\n 'on run argv',\n OSASCRIPT_EXPRESSION_FLAG,\n 'display notification (item 3 of argv) with title (item 1 of argv) subtitle (item 2 of argv)',\n OSASCRIPT_EXPRESSION_FLAG,\n 'end run',\n notification.title,\n notification.subtitle,\n body,\n ]);\n}\n","import { sign } from 'node:crypto';\nimport { connect } from 'node:http2';\nimport { request } from 'node:https';\n\nimport type { NativePushRequest, NativePushResponse } from './type';\n\nconst MAX_RESPONSE_BYTES = 65_536;\n\nexport function signPushJwt(header: object, claims: object, key: string, algorithm: 'ES256' | 'RS256'): string {\n const input = [header, claims].map((part) => Buffer.from(JSON.stringify(part)).toString('base64url')).join('.');\n const signature = sign('sha256', Buffer.from(input), { key, dsaEncoding: 'ieee-p1363' });\n // APNs requires the raw P1363 ECDSA signature, not ASN.1 DER.\n if (algorithm === 'ES256' && signature.length !== 64) throw new Error('Invalid signing key');\n return `${input}.${signature.toString('base64url')}`;\n}\n\nexport function createPushTransport() {\n const pending = new Set<() => void>();\n return {\n request(this: void, input: NativePushRequest): Promise<NativePushResponse> {\n return new Promise((resolve, reject) => {\n const url = new URL(input.url);\n let size = 0;\n const chunks: Buffer[] = [];\n let done = false;\n let dispose = () => {};\n const finish = (error?: Error, status = 0) => {\n if (done) return;\n done = true;\n clearTimeout(timer);\n pending.delete(cancel);\n dispose();\n if (error) reject(error);\n else resolve({ status, body: Buffer.concat(chunks).toString('utf8') });\n };\n const cancel = () => finish(new Error('Push request cancelled'));\n const timer = setTimeout(() => finish(new Error('Push request timed out')), input.timeoutMs);\n pending.add(cancel);\n const data = (chunk: Buffer) => {\n size += chunk.length;\n if (size > MAX_RESPONSE_BYTES) finish(new Error('Push response too large'));\n else chunks.push(Buffer.from(chunk));\n };\n if (input.http2) {\n const session = connect(url.origin);\n dispose = () => session.destroy();\n session.on('error', (error) => finish(error));\n const stream = session.request({ ':method': 'POST', ':path': url.pathname, ...input.headers });\n let status = 0;\n stream.on('response', (headers) => {\n status = Number(headers[':status']);\n });\n stream.on('data', data);\n stream.on('error', (error) => finish(error));\n stream.on('end', () => finish(undefined, status));\n stream.end(input.body);\n } else {\n const req = request(url, { method: 'POST', headers: input.headers }, (response) => {\n response.on('data', data);\n response.on('error', (error) => finish(error));\n response.on('end', () => finish(undefined, response.statusCode));\n });\n dispose = () => req.destroy();\n req.on('error', (error) => finish(error));\n req.end(input.body);\n }\n });\n },\n close() {\n for (const cancel of pending) cancel();\n },\n };\n}\n","import type { PoNotificationEntryData } from '@agimon-ai/po-core';\n\nimport { createPushTransport, signPushJwt } from './sync';\nimport type { NativePushSender, NativePushSenderOptions } from './type';\n\nconst MAX_PAYLOAD_BYTES = 4096;\nconst APNS_TOPIC = 'ai.po.app';\n// Only documented provider codes may enter diagnostics, never arbitrary response text.\nconst APNS_REASONS = new Set([\n 'BadCollapseId',\n 'BadDeviceToken',\n 'BadExpirationDate',\n 'BadMessageId',\n 'BadPriority',\n 'BadTopic',\n 'DeviceTokenNotForTopic',\n 'DuplicateHeaders',\n 'IdleTimeout',\n 'InvalidPushType',\n 'MissingDeviceToken',\n 'MissingTopic',\n 'PayloadEmpty',\n 'TopicDisallowed',\n 'BadCertificate',\n 'BadCertificateEnvironment',\n 'ExpiredProviderToken',\n 'Forbidden',\n 'InvalidProviderToken',\n 'MissingProviderToken',\n 'BadPath',\n 'MethodNotAllowed',\n 'Unregistered',\n 'PayloadTooLarge',\n 'TooManyProviderTokenUpdates',\n 'TooManyRequests',\n 'InternalServerError',\n 'ServiceUnavailable',\n 'Shutdown',\n]);\nconst OAUTH_URL = 'https://oauth2.googleapis.com/token';\nconst FCM_ERROR_TYPE = 'type.googleapis.com/google.firebase.fcm.v1.FcmError';\nconst encoder = new TextEncoder();\n\nfunction parse(body: string): Record<string, unknown> {\n try {\n const value: unknown = JSON.parse(body);\n return value && typeof value === 'object' ? (value as Record<string, unknown>) : {};\n } catch {\n return {};\n } // Malformed provider responses never invalidate registrations.\n}\n\nfunction payload(\n notification: PoNotificationEntryData,\n build: (text: { title: string; subtitle: string; body: string }) => object,\n): string {\n const text = { title: notification.title, subtitle: notification.subtitle, body: notification.body };\n let result = JSON.stringify(build(text));\n // Measure the full serialized envelope, including escaped text and the FCM token.\n for (const field of ['body', 'subtitle', 'title'] as const) {\n if (encoder.encode(result).length <= MAX_PAYLOAD_BYTES) break;\n const points = Array.from(text[field]);\n let low = 0;\n let high = points.length;\n while (low < high) {\n const middle = Math.ceil((low + high) / 2);\n text[field] = points.slice(0, middle).join('');\n if (encoder.encode(JSON.stringify(build(text))).length <= MAX_PAYLOAD_BYTES) low = middle;\n else high = middle - 1;\n }\n text[field] = points.slice(0, low).join('');\n result = JSON.stringify(build(text));\n }\n if (encoder.encode(result).length > MAX_PAYLOAD_BYTES) throw new Error('Push payload too large');\n return result;\n}\n\nexport function createNativePushSender(options: NativePushSenderOptions): NativePushSender {\n const transport = createPushTransport();\n const request = options.request ?? transport.request;\n const now = options.now ?? Date.now;\n const timeoutMs = Number.isFinite(options.timeoutMs) ? Math.max(1, Math.min(options.timeoutMs!, 30_000)) : 10_000;\n let closed = false;\n let apnsJwt: { value: string; expires: number } | undefined;\n let oauth: { value: string; expires: number } | undefined;\n let oauthPending: Promise<string> | undefined;\n\n async function accessToken(): Promise<string> {\n if (oauth && now() < oauth.expires) return oauth.value;\n if (oauthPending) return oauthPending;\n oauthPending = (async () => {\n const credentials = options.fcm!;\n const issued = Math.floor(now() / 1000);\n const assertion = signPushJwt(\n { alg: 'RS256', typ: 'JWT' },\n {\n iss: credentials.clientEmail,\n scope: 'https://www.googleapis.com/auth/firebase.messaging',\n aud: OAUTH_URL,\n iat: issued,\n exp: issued + 3600,\n },\n credentials.privateKey,\n 'RS256',\n );\n const response = await request({\n url: OAUTH_URL,\n headers: { 'content-type': 'application/x-www-form-urlencoded' },\n body: new URLSearchParams({ grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer', assertion }).toString(),\n timeoutMs,\n });\n const data = parse(response.body);\n if (\n response.status !== 200 ||\n typeof data.access_token !== 'string' ||\n !data.access_token ||\n typeof data.expires_in !== 'number' ||\n !Number.isFinite(data.expires_in) ||\n data.expires_in <= 0\n )\n throw new Error('OAuth failed');\n oauth = { value: data.access_token, expires: now() + Math.max(0, Math.min(data.expires_in, 3600) - 60) * 1000 };\n return oauth.value;\n })();\n try {\n return await oauthPending;\n } finally {\n oauthPending = undefined;\n }\n }\n\n return {\n async send(registration, notification, sessionId) {\n const provider = registration.platform === 'ios' ? 'apns' : 'fcm';\n if (closed || !options[provider]) {\n options.diagnostic?.({ provider, outcome: 'unavailable' });\n return { invalid: false };\n }\n try {\n const data = {\n ...(registration.hostRef ? { hostRef: registration.hostRef } : {}),\n ...(sessionId ? { sessionId } : {}),\n };\n let response;\n let reason: string | undefined;\n if (registration.platform === 'ios') {\n const credentials = options.apns!;\n if (!apnsJwt || now() >= apnsJwt.expires) {\n apnsJwt = {\n value: signPushJwt(\n { alg: 'ES256', kid: credentials.keyId },\n {\n iss: credentials.teamId,\n iat: Math.floor(now() / 1000),\n },\n credentials.key,\n 'ES256',\n ),\n expires: now() + 50 * 60_000,\n };\n }\n response = await request({\n url: `https://${registration.environment === 'development' ? 'api.sandbox.push.apple.com' : 'api.push.apple.com'}/3/device/${encodeURIComponent(registration.token)}`,\n http2: true,\n timeoutMs,\n headers: {\n authorization: `bearer ${apnsJwt.value}`,\n 'apns-topic': APNS_TOPIC,\n 'apns-push-type': 'alert',\n 'apns-priority': '10',\n 'apns-expiration': '0',\n 'content-type': 'application/json',\n },\n // ponytail: live alerts only; add a durable outbox if delayed delivery becomes a requirement.\n // Expo iOS reads custom remote data from userInfo.body. Keep data as the provider-neutral payload.\n body: payload(notification, (text) => ({ aps: { alert: text, sound: 'default' }, data, body: data })),\n });\n const value = parse(response.body).reason;\n if (typeof value === 'string' && APNS_REASONS.has(value)) reason = value;\n if (\n (response.status === 410 && reason === 'Unregistered') ||\n (response.status === 400 && reason === 'BadDeviceToken')\n ) {\n options.diagnostic?.({\n provider,\n outcome: 'invalid',\n status: response.status,\n ...(reason ? { reason } : {}),\n });\n return { invalid: true };\n }\n } else {\n const body = payload(notification, (text) => ({\n message: {\n token: registration.token,\n data,\n notification: { title: text.title, body: [text.subtitle, text.body].filter(Boolean).join('\\n') },\n // ponytail: zero TTL, no offline delivery; an outbox would own delayed sends.\n android: { ttl: '0s', priority: 'HIGH', notification: { channel_id: 'po-notifications' } },\n },\n }));\n const token = await accessToken();\n if (closed) return { invalid: false };\n response = await request({\n url: `https://fcm.googleapis.com/v1/projects/${encodeURIComponent(options.fcm!.projectId)}/messages:send`,\n headers: { authorization: `Bearer ${token}`, 'content-type': 'application/json' },\n body,\n timeoutMs,\n });\n const error = parse(response.body).error;\n if (\n response.status === 404 &&\n error &&\n typeof error === 'object' &&\n 'details' in error &&\n Array.isArray(error.details) &&\n error.details.some(\n (detail: unknown) =>\n detail &&\n typeof detail === 'object' &&\n '@type' in detail &&\n detail['@type'] === FCM_ERROR_TYPE &&\n 'errorCode' in detail &&\n detail.errorCode === 'UNREGISTERED',\n )\n ) {\n options.diagnostic?.({\n provider,\n outcome: 'invalid',\n status: response.status,\n ...(reason ? { reason } : {}),\n });\n return { invalid: true };\n }\n }\n if (response.status < 200 || response.status >= 300)\n options.diagnostic?.({ provider, outcome: 'failed', status: response.status, ...(reason ? { reason } : {}) });\n } catch {\n // Never expose provider bodies, credentials, device tokens, or network errors.\n options.diagnostic?.({ provider, outcome: 'failed' });\n }\n return { invalid: false };\n },\n close() {\n closed = true;\n apnsJwt = undefined;\n oauth = undefined;\n transport.close();\n },\n };\n}\n","const DEFAULT_ASK_USER_BODY = 'The agent is waiting for your feedback.';\nconst RPC_MODE = 'rpc';\n\nexport interface AttentionState {\n agentRunning: boolean;\n askUserBlocked: boolean;\n}\n\nexport interface ShellSurface {\n hasUI: boolean;\n mode?: string;\n}\n\n/**\n * A dialog is worth interrupting the user for only while the agent holds the turn.\n *\n * Outside a run the user opened the dialog themselves and is already looking at\n * it. An ask-user prompt is announced by its own event, so the dialog it then\n * opens must stay silent or the same question notifies twice.\n */\nexport function warrantsAttentionNotification({ agentRunning, askUserBlocked }: AttentionState): boolean {\n return agentRunning && !askUserBlocked;\n}\n\n/** A queued follow-up means the agent keeps working, so the run has not stopped for the user. */\nexport function warrantsSettledNotification(hasPendingMessages: boolean): boolean {\n return !hasPendingMessages;\n}\n\n/** Terminal title escapes only mean something on an attached terminal; RPC output stays clean. */\nexport function supportsShellTitle({ hasUI, mode }: ShellSurface): boolean {\n return hasUI && mode !== RPC_MODE;\n}\n\n/** The question an ask-user prompt is blocking on, or a stand-in when it asked none. */\nexport function askUserPromptBody(questions: readonly { question: string }[]): string {\n return questions[0]?.question ?? DEFAULT_ASK_USER_BODY;\n}\n"],"mappings":";;;;;;AAEA,MAAa,iBAAiB;CAAC;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;AAAG;;AAI/E,SAAgB,kCAAwD;CACtE,IAAI,aAAa;CACjB,IAAI;CACJ,MAAM,sBAAsB;EAC1B,IAAI,OAAO,cAAc,KAAK;EAC9B,QAAQ,KAAA;EACR,aAAa;CACf;CAEA,OAAO;EACL,IAAI,OAAO,OAAO;GAChB,cAAc;GACd,MAAM,KAAK;EACb;EACA,MAAM,OAAO,OAAO;GAClB,cAAc;GACd,MAAM,eAAe;IACnB,MAAM,GAAG,eAAe,aAAa,eAAe,QAAQ,GAAG,OAAO;IACtE,cAAc;GAChB;GACA,OAAO;GACP,QAAQ,YAAY,QAAA,EAA+B;EACrD;EACA,KAAK,OAAO,OAAO;GACjB,cAAc;GACd,MAAM,KAAK;EACb;EACA,QAAQ,OAAO,OAAO;GACpB,cAAc;GACd,MAAM,KAAK;EACb;CACF;AACF;;;;;;;;;AC1BA,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiC5B,SAAgB,8BAAoD;CAClE,MAAM,WAAW,gCAAgC;CACjD,IAAI;CACJ,IAAI;CACJ,IAAI;CAEJ,MAAM,iBAAiB;EACrB,SAAS,KAAA;EAC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BAAwB;AAC9B,MAAM,WAAW;;;;;;;;AAmBjB,SAAgB,8BAA8B,EAAE,cAAc,kBAA2C;CACvG,OAAO,gBAAgB,CAAC;AAC1B;;AAGA,SAAgB,4BAA4B,oBAAsC;CAChF,OAAO,CAAC;AACV;;AAGA,SAAgB,mBAAmB,EAAE,OAAO,QAA+B;CACzE,OAAO,SAAS,SAAS;AAC3B;;AAGA,SAAgB,kBAAkB,WAAoD;CACpF,OAAO,UAAU,EAAE,EAAE,YAAY;AACnC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agimon-ai/po-notification",
3
- "version": "0.0.0-alpha.44",
3
+ "version": "0.0.0-alpha.46",
4
4
  "description": "Desktop notifications and an animated shell-tab title for Po sessions.",
5
5
  "keywords": [
6
6
  "ai",
@@ -60,12 +60,12 @@
60
60
  "access": "public"
61
61
  },
62
62
  "dependencies": {
63
- "@agimon-ai/po-core": "0.0.0-alpha.44",
63
+ "@agimon-ai/po-core": "0.0.0-alpha.46",
64
64
  "@deepseek-ai/cordis": "4.0.5"
65
65
  },
66
66
  "devDependencies": {
67
- "@agimon-ai/po-build": "0.0.0-alpha.44",
68
- "@agimon-ai/vibe-lint-plugin-po-extension": "0.0.0-alpha.44",
67
+ "@agimon-ai/po-build": "0.0.0-alpha.46",
68
+ "@agimon-ai/vibe-lint-plugin-po-extension": "0.0.0-alpha.46",
69
69
  "@earendil-works/pi-coding-agent": "1.4.0",
70
70
  "@types/node": "26.6.5",
71
71
  "@vitest/coverage-v8": "5.0.4",