@tangle-network/agent-app 0.60.23 → 0.60.25
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/{chunk-NV7TNF7V.js → chunk-BGJQFDRL.js} +22 -1
- package/dist/chunk-BGJQFDRL.js.map +1 -0
- package/dist/hub-approvals/index.js +1 -1
- package/dist/hub-approvals-react/index.js +13 -6
- package/dist/hub-approvals-react/index.js.map +1 -1
- package/dist/hub-approvals-react/parts.d.ts +2 -0
- package/package.json +1 -1
- package/dist/chunk-NV7TNF7V.js.map +0 -1
|
@@ -485,6 +485,27 @@ var PRESENTERS = {
|
|
|
485
485
|
}
|
|
486
486
|
};
|
|
487
487
|
},
|
|
488
|
+
"phony.create_agent": (input) => {
|
|
489
|
+
const name = text(input.name);
|
|
490
|
+
return {
|
|
491
|
+
action: "Create voice agent",
|
|
492
|
+
title: `Create voice agent${name ? ` \u201C${clipped(name, 60)}\u201D` : ""}`,
|
|
493
|
+
preview: { kind: "fields", fields: scalarFields(input) }
|
|
494
|
+
};
|
|
495
|
+
},
|
|
496
|
+
"phony.update_agent": (input) => ({
|
|
497
|
+
action: "Update voice agent",
|
|
498
|
+
title: "Update a voice agent",
|
|
499
|
+
preview: { kind: "fields", fields: scalarFields(input) }
|
|
500
|
+
}),
|
|
501
|
+
"phony.clone_voice": (input) => {
|
|
502
|
+
const name = text(input.name);
|
|
503
|
+
return {
|
|
504
|
+
action: "Clone voice",
|
|
505
|
+
title: `Clone your voice${name ? ` as \u201C${clipped(name, 60)}\u201D` : ""}`,
|
|
506
|
+
preview: { kind: "fields", fields: scalarFields(input) }
|
|
507
|
+
};
|
|
508
|
+
},
|
|
488
509
|
"google-calendar.create_event": calendarEvent,
|
|
489
510
|
"google-calendar.book_slot": calendarEvent,
|
|
490
511
|
"google-calendar.update_event": (input, item) => {
|
|
@@ -736,4 +757,4 @@ export {
|
|
|
736
757
|
HUB_APPROVAL_RESUME_PART,
|
|
737
758
|
hubApprovalResumePart
|
|
738
759
|
};
|
|
739
|
-
//# sourceMappingURL=chunk-
|
|
760
|
+
//# sourceMappingURL=chunk-BGJQFDRL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hub-approvals/types.ts","../src/hub-approvals/result.ts","../src/hub-approvals/present.ts","../src/hub-approvals/index.ts"],"sourcesContent":["/**\n * The vocabulary of a Hub action that waits on a person: where it stands, what\n * it will do in the owner's words, and what it did once it ran.\n */\n\n/** Where one held action stands, as the dock, the list and the transcript show it. */\nexport type HubApprovalPhase =\n /** Held by Hub; the viewer can decide it. */\n | 'waiting'\n /** Held by Hub; someone else (the workspace owner) decides it. */\n | 'blocked'\n /** Approved here; the run has not started. */\n | 'queued'\n /** Approved; Hub is running the call. */\n | 'running'\n | 'done'\n /** Approved, but Hub could not run it. */\n | 'failed'\n | 'denied'\n | 'expired'\n\n/** Phases that still need someone's decision. */\nexport const HUB_APPROVAL_OPEN_PHASES: ReadonlySet<HubApprovalPhase> = new Set(['waiting', 'blocked'])\n/** Phases between a decision and its result. */\nexport const HUB_APPROVAL_ACTIVE_PHASES: ReadonlySet<HubApprovalPhase> = new Set(['queued', 'running'])\n\n/** A file a held write changes. Counts stay undefined until someone has read them. */\nexport interface HubActionFile {\n path: string\n /** A rename reads as a modification of its new path. */\n change: 'added' | 'modified' | 'deleted'\n additions?: number\n deletions?: number\n}\n\n/**\n * The change a held call serves, when it is one step of a larger change such\n * as a pull request. The dock then names the change rather than the step.\n */\nexport interface HubActionBundle {\n /** What the whole change does, e.g. `Open PR: Fix the hero on acme/site`. */\n title: string\n steps?: ReadonlyArray<{ label: string; state: 'done' | 'current' | 'upcoming' }>\n}\n\n/** One held Hub action and its decision, in the form every surface renders. */\nexport interface HubApprovalItem {\n /** Stable within a conversation, such as `<messageId>:<partId>`. */\n id: string\n /** `provider.action`, e.g. `github.pulls.propose`. */\n actionPath: string\n providerId: string\n /** The call's input as Hub received it. */\n input: unknown\n phase: HubApprovalPhase\n /** The connected account the action runs as, e.g. `octocat` or `ops@acme.com`. */\n account?: string | null\n requestedAt?: string | null\n /** When the decision window closes. */\n expiresAt?: string | null\n /** Hub's result, or a bounded projection of it from {@link summarizeHubResult}. */\n result?: unknown\n error?: string | null\n /** The standing permission granted with the approval. */\n grant?: { scope: string; expiresAt: string | null } | null\n /** Set when a permissions mode, not a person, approved it. */\n autoApproved?: string | null\n /** Files with line counts read by the host, replacing those the input declares. */\n files?: readonly HubActionFile[]\n bundle?: HubActionBundle | null\n}\n\n/** A labelled value on a preview or a receipt. */\nexport interface HubActionField {\n label: string\n value: string\n href?: string\n /** Render in the monospace face: shas, ids, paths. */\n mono?: boolean\n}\n\n/** What a held call will do, shaped for its integration's renderer. */\nexport type HubActionPreview =\n | {\n kind: 'pull-request'\n repository?: string\n title?: string\n body?: string\n head?: string\n base?: string\n draft?: boolean\n files: readonly HubActionFile[]\n }\n | { kind: 'commit'; repository?: string; message?: string; tree?: string; parents: readonly string[] }\n | { kind: 'branch'; repository?: string; branch?: string; sha?: string }\n | { kind: 'files'; repository?: string; files: readonly HubActionFile[] }\n | { kind: 'issue'; repository?: string; number?: number; title?: string; body?: string; verdict?: string }\n | {\n kind: 'email'\n to: readonly string[]\n cc: readonly string[]\n bcc: readonly string[]\n subject?: string\n body?: string\n html: boolean\n reply: boolean\n }\n | {\n kind: 'post'\n channel: 'x' | 'linkedin' | 'slack'\n text: string\n /** The post's place, such as a Slack channel. */\n where?: string\n link?: { url: string; title?: string; description?: string }\n }\n | { kind: 'payment'; label: string; amount?: number; currency?: string; customer?: string; description?: string }\n | { kind: 'speech'; text: string; voice?: string; seconds?: number }\n | { kind: 'call'; to?: string; from?: string; purpose?: string }\n | {\n kind: 'event'\n title?: string\n start?: string\n end?: string\n location?: string\n attendees: readonly string[]\n description?: string\n }\n | { kind: 'fields'; fields: readonly HubActionField[] }\n\n/** A held call in the owner's words. */\nexport interface HubActionPresentation {\n provider: { id: string; name: string }\n /** The imperative, e.g. `Open pull request`. */\n action: string\n /** One line naming the action and its object, e.g. `Open PR: Fix the hero on acme/site`. */\n title: string\n /** Where it acts: a repository, recipients, a channel or a customer. */\n target?: string\n preview: HubActionPreview\n}\n\n/** What a decided call did, as its receipt shows it. */\nexport interface HubActionReceipt {\n provider: { id: string; name: string }\n /** The result in past tense, e.g. `Opened PR #123` or `Sent email to ada@acme.com`. */\n title: string\n /** The result's own page, when it has one: the pull request, the post, the event. */\n href?: string\n status: 'done' | 'failed' | 'denied' | 'expired' | 'running' | 'waiting'\n fields: readonly HubActionField[]\n files?: readonly HubActionFile[]\n media?: { kind: 'audio'; src: string; seconds?: number }\n error?: string\n}\n","/**\n * Hub results, read the same way by every receipt: unwrapped from Hub's\n * envelope and bounded before a host persists them.\n */\n\nconst MAX_DEPTH = 4\nconst MAX_KEYS = 24\nconst MAX_ITEMS = 50\nconst MAX_STRING = 600\n\nexport function asRecord(value: unknown): Record<string, unknown> {\n return value && typeof value === 'object' && !Array.isArray(value) ? value as Record<string, unknown> : {}\n}\n\n/**\n * The provider's own result inside Hub's envelopes. `tools.invoke` answers\n * `{ result: … }` and a connector may wrap its body in `data`; a JSON string,\n * as an older host stored it, is parsed first.\n */\nexport function unwrapHubResult(value: unknown): unknown {\n let current: unknown = value\n if (typeof current === 'string') {\n const text = current\n try {\n current = JSON.parse(text)\n } catch {\n // An older host stored `Hub result: {…}`-style text with a JSON tail.\n const start = text.indexOf('{')\n if (start < 0) return value\n try {\n current = JSON.parse(text.slice(start))\n } catch {\n return value\n }\n }\n }\n for (let depth = 0; depth < 3; depth++) {\n const record = asRecord(current)\n const keys = Object.keys(record)\n const inner = keys.find((key) => key === 'result' || key === 'data')\n // Only a thin envelope is unwrapped; a body that happens to carry a `data`\n // field among its own fields is the result itself.\n if (!inner || keys.length > 3 || record[inner] === null || typeof record[inner] !== 'object') break\n current = record[inner]\n }\n return current\n}\n\nfunction bounded(value: unknown, depth: number): unknown {\n if (value === null || typeof value === 'boolean') return value\n if (typeof value === 'number') return Number.isFinite(value) ? value : null\n if (typeof value === 'string') return value.length > MAX_STRING ? `${value.slice(0, MAX_STRING - 1)}…` : value\n if (depth >= MAX_DEPTH) return undefined\n if (Array.isArray(value)) {\n return value.slice(0, MAX_ITEMS).map((item) => bounded(item, depth + 1)).filter((item) => item !== undefined)\n }\n if (typeof value === 'object') {\n const out: Record<string, unknown> = {}\n for (const [key, entry] of Object.entries(value as Record<string, unknown>).slice(0, MAX_KEYS)) {\n const kept = bounded(entry, depth + 1)\n if (kept !== undefined) out[key] = kept\n }\n return out\n }\n return undefined\n}\n\n/**\n * A bounded copy of a Hub result for a host to store with the decision: the\n * envelope removed, strings, arrays and nesting capped. Receipts read it in\n * place of the full result.\n */\nexport function summarizeHubResult(result: unknown): unknown {\n return bounded(unwrapHubResult(result), 0)\n}\n\n/** The first non-empty string among `keys`, searched one level into nested records. */\nexport function readText(value: unknown, ...keys: string[]): string | undefined {\n const record = asRecord(value)\n for (const key of keys) {\n const found = record[key]\n if (typeof found === 'string' && found.trim()) return found.trim()\n if (typeof found === 'number' && Number.isFinite(found)) return String(found)\n }\n return undefined\n}\n\nexport function readNumber(value: unknown, ...keys: string[]): number | undefined {\n const record = asRecord(value)\n for (const key of keys) {\n const found = record[key]\n if (typeof found === 'number' && Number.isFinite(found)) return found\n }\n return undefined\n}\n\n/** A link a result names for itself, in the order providers use them. */\nexport function resultLink(value: unknown): string | undefined {\n const url = readText(value, 'html_url', 'htmlLink', 'webLink', 'web_url', 'permalink', 'hosted_invoice_url', 'url', 'link')\n return url && /^https:\\/\\//.test(url) ? url : undefined\n}\n","/**\n * Hub actions in an owner's words. Known integrations read as what they do —\n * `github.pulls.propose` is \"Open PR: Fix the hero on acme/site\", `gmail.send`\n * is \"Send email to ada@acme.com\" — and any other Hub action falls back to its\n * own name and its input's scalar fields.\n */\n\nimport { asRecord, readNumber, readText, resultLink, unwrapHubResult } from './result'\nimport type {\n HubActionField,\n HubActionFile,\n HubActionPresentation,\n HubActionPreview,\n HubActionReceipt,\n HubApprovalItem,\n} from './types'\n\nconst PROVIDER_NAMES: Record<string, string> = {\n github: 'GitHub',\n gitlab: 'GitLab',\n gmail: 'Gmail',\n google: 'Google',\n 'google-calendar': 'Google Calendar',\n 'microsoft-calendar': 'Outlook Calendar',\n 'outlook-mail': 'Outlook',\n outlook: 'Outlook',\n twitter: 'X',\n x: 'X',\n linkedin: 'LinkedIn',\n stripe: 'Stripe',\n phony: 'ph0ny',\n slack: 'Slack',\n notion: 'Notion',\n hubspot: 'HubSpot',\n linear: 'Linear',\n inkbox: 'Inkbox',\n resend: 'Resend',\n}\n\n/** A provider's display name: `github` is GitHub, `outlook-mail` is Outlook. */\nexport function hubProviderName(id: string): string {\n if (PROVIDER_NAMES[id]) return PROVIDER_NAMES[id]\n const words = id.split(/[-_\\s]+/).filter(Boolean)\n return words.map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(' ') || id\n}\n\n/** `provider.action` split at the first dot. */\nexport function splitHubActionPath(actionPath: string): { provider: string; action: string } {\n const separator = actionPath.indexOf('.')\n return separator < 0 ? { provider: '', action: actionPath } : { provider: actionPath.slice(0, separator), action: actionPath.slice(separator + 1) }\n}\n\nfunction text(value: unknown): string | undefined {\n return typeof value === 'string' && value.trim() ? value.trim() : undefined\n}\n\nfunction clipped(value: string, max = 80): string {\n const single = value.replace(/\\s+/g, ' ').trim()\n return single.length > max ? `${single.slice(0, max - 1).trimEnd()}…` : single\n}\n\nfunction list(value: unknown): string[] {\n if (typeof value === 'string') return value.split(/[,;]/).map((entry) => entry.trim()).filter(Boolean)\n if (!Array.isArray(value)) return []\n return value.flatMap((entry) => {\n if (typeof entry === 'string' && entry.trim()) return [entry.trim()]\n const record = asRecord(entry)\n const address = text(record.email) ?? text(record.address) ?? text(asRecord(record.emailAddress).address)\n return address ? [address] : []\n })\n}\n\nfunction people(addresses: readonly string[]): string {\n if (addresses.length === 0) return ''\n if (addresses.length === 1) return addresses[0]!\n return `${addresses[0]} and ${addresses.length - 1} more`\n}\n\nfunction shortSha(sha: string | undefined): string | undefined {\n return sha && /^[0-9a-f]{7,}$/i.test(sha) ? sha.slice(0, 7) : sha\n}\n\n// ---------- verbs ----------\n\nconst PAST: Record<string, string> = {\n add: 'added', approve: 'approved', archive: 'archived', assign: 'assigned', book: 'booked', cancel: 'canceled',\n capture: 'captured', charge: 'charged', clone: 'cloned', close: 'closed', comment: 'commented', create: 'created',\n deactivate: 'deactivated', delete: 'deleted', enroll: 'enrolled', export: 'exported', finalize: 'finalized',\n forward: 'forwarded', import: 'imported', ingest: 'ingested', invite: 'invited', like: 'liked', make: 'made',\n merge: 'merged', move: 'moved', open: 'opened', pay: 'paid', place: 'placed', post: 'posted', provision: 'provisioned',\n publish: 'published', put: 'put', react: 'reacted', refund: 'refunded', remove: 'removed', reply: 'replied',\n retweet: 'reposted', review: 'reviewed', run: 'ran', save: 'saved', schedule: 'scheduled', send: 'sent', set: 'set',\n share: 'shared', start: 'started', stop: 'stopped', submit: 'submitted', subscribe: 'subscribed',\n synthesize: 'synthesized', transfer: 'transferred', translate: 'translated', update: 'updated', upload: 'uploaded',\n upsert: 'saved', void: 'voided', watch: 'watched', write: 'wrote',\n}\n\n/** The past tense of an English verb this vocabulary uses. */\nexport function pastTense(verb: string): string {\n const lower = verb.toLowerCase()\n const past = PAST[lower] ?? (lower.endsWith('e') ? `${lower}d` : `${lower}ed`)\n return verb.charAt(0) === verb.charAt(0).toUpperCase() ? past.charAt(0).toUpperCase() + past.slice(1) : past\n}\n\nfunction words(action: string): string[] {\n return action\n .replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n .split(/[._\\-\\s]+/)\n .map((word) => word.toLowerCase())\n .filter(Boolean)\n}\n\nfunction singular(word: string): string {\n if (word.endsWith('ies')) return `${word.slice(0, -3)}y`\n if (word.endsWith('sses') || word.endsWith('ss')) return word\n return word.endsWith('s') && word.length > 3 ? word.slice(0, -1) : word\n}\n\n/** A Hub action's own name as a sentence: `payment-intents.create` is \"Create payment intent\". */\nfunction genericVerb(action: string): { verb: string; noun: string } {\n const parts = words(action)\n const index = parts.findIndex((word) => word in PAST)\n if (index < 0) return { verb: '', noun: parts.join(' ') }\n const noun = [...parts.slice(0, index), ...parts.slice(index + 1)].map(singular).join(' ')\n return { verb: parts[index]!, noun }\n}\n\nfunction sentence(verb: string, noun: string): string {\n const phrase = [verb, noun].filter(Boolean).join(' ')\n return phrase.charAt(0).toUpperCase() + phrase.slice(1)\n}\n\n// ---------- inputs ----------\n\nfunction repository(input: Record<string, unknown>): string | undefined {\n const owner = text(input.owner)\n const repo = text(input.repo)\n if (owner && repo) return `${owner}/${repo}`\n return repo ?? text(input.repository)\n}\n\nfunction branchOf(ref: unknown): string | undefined {\n return text(ref)?.replace(/^refs\\/heads\\//, '')\n}\n\n/** The files a call writes, as its input declares them. */\nexport function hubActionFiles(actionPath: string, input: unknown): HubActionFile[] {\n const fields = asRecord(input)\n const { action } = splitHubActionPath(actionPath)\n const entries = action === 'git.createTree' ? fields.tree : fields.files\n if (!Array.isArray(entries)) return []\n return entries.flatMap((entry): HubActionFile[] => {\n const item = asRecord(entry)\n const path = text(item.path)\n if (!path) return []\n const deleted = item.delete === true || (item.sha === null && item.content === undefined)\n return [{ path, change: deleted ? 'deleted' : 'modified' }]\n })\n}\n\n/** Counted files replace declared ones by path; the declared order stays. */\nfunction mergedFiles(declared: readonly HubActionFile[], counted: readonly HubActionFile[] | undefined): HubActionFile[] {\n if (!counted || counted.length === 0) return [...declared]\n if (declared.length === 0) return [...counted]\n const byPath = new Map(counted.map((file) => [file.path, file]))\n return declared.map((file) => byPath.get(file.path) ?? file)\n}\n\nfunction emailPreview(input: Record<string, unknown>, reply: boolean): HubActionPreview {\n return {\n kind: 'email',\n to: list(input.to ?? input.recipients),\n cc: list(input.cc),\n bcc: list(input.bcc),\n subject: text(input.subject),\n body: text(input.body) ?? text(input.text) ?? text(input.html) ?? text(input.comment),\n html: input.html === true || text(input.bodyType)?.toLowerCase() === 'html' || typeof input.html === 'string',\n reply,\n }\n}\n\nfunction speechSeconds(input: Record<string, unknown>): number | undefined {\n const spoken = text(input.text)\n if (!spoken) return undefined\n const speed = typeof input.speed === 'number' && input.speed > 0 ? input.speed : 1\n // About 2.5 spoken words a second at normal speed.\n return Math.max(1, Math.round(spoken.split(/\\s+/).length / 2.5 / speed))\n}\n\nfunction voiceName(input: Record<string, unknown>): string | undefined {\n const voice = text(input.voiceId)\n // An opaque provider id says nothing to an owner; a named voice does.\n if (voice && !/^[0-9a-f-]{16,}$/i.test(voice) && voice.length <= 32) return voice.charAt(0).toUpperCase() + voice.slice(1)\n return text(input.provider)\n}\n\nconst CURRENCY_DIGITS: Record<string, number> = { jpy: 0, krw: 0, vnd: 0, clp: 0, bhd: 3, kwd: 3, omr: 3 }\n\n/** A Stripe minor-unit amount in its currency: `4900` USD is `$49.00`. */\nexport function formatMinorAmount(amount: number, currency = 'usd'): string {\n const code = currency.toLowerCase()\n const digits = CURRENCY_DIGITS[code] ?? 2\n try {\n return new Intl.NumberFormat('en-US', { style: 'currency', currency: code.toUpperCase(), minimumFractionDigits: digits })\n .format(amount / 10 ** digits)\n } catch {\n return `${(amount / 10 ** digits).toFixed(digits)} ${code.toUpperCase()}`\n }\n}\n\n/** Scalar input fields, for an action no renderer knows. */\nfunction scalarFields(input: Record<string, unknown>, max = 6): HubActionField[] {\n return Object.entries(input).flatMap(([key, value]): HubActionField[] => {\n if (key.startsWith('__')) return []\n if (typeof value === 'string' && value.trim()) return [{ label: labelOf(key), value: clipped(value, 160) }]\n if (typeof value === 'number' || typeof value === 'boolean') return [{ label: labelOf(key), value: String(value) }]\n const strings = Array.isArray(value) ? value.filter((entry): entry is string => typeof entry === 'string') : []\n return strings.length > 0 ? [{ label: labelOf(key), value: clipped(strings.join(', '), 160) }] : []\n }).slice(0, max)\n}\n\nfunction labelOf(key: string): string {\n const spaced = key.replace(/([a-z0-9])([A-Z])/g, '$1 $2').replace(/[_-]+/g, ' ').trim().toLowerCase()\n return spaced.charAt(0).toUpperCase() + spaced.slice(1)\n}\n\n// ---------- presentation ----------\n\ntype Presenter = (input: Record<string, unknown>, item: Pick<HubApprovalItem, 'actionPath' | 'files'>) => Omit<HubActionPresentation, 'provider'>\n\nfunction pullRequest(input: Record<string, unknown>, item: Pick<HubApprovalItem, 'actionPath' | 'files'>): Omit<HubActionPresentation, 'provider'> {\n const repo = repository(input)\n const title = text(input.title) ?? 'Untitled change'\n return {\n action: 'Open pull request',\n title: `Open PR: ${clipped(title)}${repo ? ` on ${repo}` : ''}`,\n ...(repo ? { target: repo } : {}),\n preview: {\n kind: 'pull-request',\n repository: repo,\n title,\n body: text(input.body),\n head: branchOf(input.branch ?? input.head),\n base: text(input.base),\n draft: item.actionPath.endsWith('.propose') ? true : input.draft === true,\n files: mergedFiles(hubActionFiles(item.actionPath, input), item.files),\n },\n }\n}\n\nfunction issueLike(verb: string, noun: string): Presenter {\n return (input) => {\n const repo = repository(input)\n const number = readNumber(input, 'issue_number', 'pull_number', 'number')\n const title = text(input.title)\n const object = number !== undefined ? `${noun} #${number}` : title ? `${noun}: ${clipped(title)}` : noun\n return {\n action: sentence(verb, noun.toLowerCase()),\n title: `${sentence(verb, object)}${repo ? ` on ${repo}` : ''}`,\n ...(repo ? { target: repo } : {}),\n preview: {\n kind: 'issue',\n repository: repo,\n number,\n title,\n body: text(input.body),\n verdict: text(input.event)?.toLowerCase().replace(/_/g, ' '),\n },\n }\n }\n}\n\nfunction sendEmail(verb: 'Send' | 'Save draft', reply = false): Presenter {\n return (input) => {\n const preview = emailPreview(input, reply)\n const recipients = preview.kind === 'email' ? people(preview.to) : ''\n const action = reply ? 'Send reply' : verb === 'Send' ? 'Send email' : 'Save draft'\n return {\n action,\n title: reply ? 'Send reply' : `${action}${recipients ? ` to ${recipients}` : ''}`,\n ...(recipients ? { target: recipients } : {}),\n preview,\n }\n }\n}\n\nfunction post(channel: 'x' | 'linkedin', reply = false): Presenter {\n return (input) => {\n const body = text(input.text) ?? text(input.commentary) ?? ''\n const url = text(input.url)\n const where = channel === 'x' ? 'X' : 'LinkedIn'\n return {\n action: reply ? `Reply on ${where}` : `Post on ${where}`,\n title: `${reply ? 'Reply' : 'Post'} on ${where}${body ? `: “${clipped(body, 60)}”` : ''}`,\n target: where,\n preview: {\n kind: 'post',\n channel,\n text: body,\n ...(url ? { link: { url, title: text(input.title), description: text(input.description) } } : {}),\n },\n }\n }\n}\n\nfunction payment(label: string): Presenter {\n return (input) => {\n const amount = readNumber(input, 'amount')\n const currency = text(input.currency)\n const customer = text(input.customerId) ?? text(input.customer) ?? text(input.email)\n const formatted = amount !== undefined ? formatMinorAmount(amount, currency) : undefined\n const object = formatted ? `${label} of ${formatted}` : label\n return {\n action: sentence('create', label),\n title: `${sentence('create', object)}${customer ? ` for ${customer}` : ''}`,\n ...(customer ? { target: customer } : {}),\n preview: { kind: 'payment', label, amount, currency, customer, description: text(input.description) },\n }\n }\n}\n\nfunction calendarEvent(input: Record<string, unknown>, _item?: Pick<HubApprovalItem, 'actionPath' | 'files'>): Omit<HubActionPresentation, 'provider'> {\n const title = text(input.summary) ?? text(input.title) ?? text(input.subject)\n return {\n action: 'Book event',\n title: title ? `Book “${clipped(title, 60)}”` : 'Book an event',\n preview: {\n kind: 'event',\n title,\n start: text(input.start) ?? text(asRecord(input.start).dateTime),\n end: text(input.end) ?? text(asRecord(input.end).dateTime),\n location: text(input.location) ?? text(asRecord(input.location).displayName),\n attendees: list(input.attendees),\n description: text(input.description),\n },\n }\n}\n\nconst PRESENTERS: Record<string, Presenter> = {\n 'github.pulls.propose': pullRequest,\n 'github.pulls.create': pullRequest,\n 'github.git.createTree': (input, item) => {\n const repo = repository(input)\n const files = mergedFiles(hubActionFiles(item.actionPath, input), item.files)\n return {\n action: 'Write files',\n title: `Write ${files.length === 1 ? files[0]!.path : `${files.length} files`}${repo ? ` to ${repo}` : ''}`,\n ...(repo ? { target: repo } : {}),\n preview: { kind: 'files', repository: repo, files },\n }\n },\n 'github.git.createCommit': (input) => {\n const repo = repository(input)\n const message = text(input.message)\n return {\n action: 'Create commit',\n title: `Commit${message ? ` “${clipped(message, 60)}”` : ''}${repo ? ` to ${repo}` : ''}`,\n ...(repo ? { target: repo } : {}),\n preview: { kind: 'commit', repository: repo, message, tree: text(input.tree), parents: list(input.parents) },\n }\n },\n 'github.git.createRef': (input) => {\n const repo = repository(input)\n const branch = branchOf(input.ref)\n return {\n action: 'Create branch',\n title: `Create branch ${branch ?? ''}${repo ? ` in ${repo}` : ''}`.replace(/\\s+/g, ' ').trim(),\n ...(repo ? { target: repo } : {}),\n preview: { kind: 'branch', repository: repo, branch, sha: text(input.sha) },\n }\n },\n 'github.pulls.merge': issueLike('merge', 'PR'),\n 'github.pulls.reviews.create': issueLike('review', 'PR'),\n 'github.issues.create': issueLike('open', 'Issue'),\n 'github.issues.update': issueLike('update', 'Issue'),\n 'github.issues.createComment': issueLike('comment on', 'Issue'),\n 'gmail.send': sendEmail('Send'),\n 'gmail.send_reply': sendEmail('Send', true),\n 'outlook-mail.send_message': sendEmail('Send'),\n 'outlook-mail.send_draft': sendEmail('Send'),\n 'outlook-mail.create_draft': sendEmail('Save draft'),\n 'outlook-mail.send_reply': sendEmail('Send', true),\n 'inkbox.email.send': sendEmail('Send'),\n 'resend.emails.send': sendEmail('Send'),\n 'resend.emails.reply': sendEmail('Send', true),\n 'twitter.tweets.create': post('x'),\n 'twitter.tweets.reply': post('x', true),\n 'x.tweets.create': post('x'),\n 'linkedin.posts.create': post('linkedin'),\n 'linkedin.shares.create': post('linkedin'),\n 'slack.post_message': (input) => {\n const channel = text(input.channel) ?? text(input.channelId)\n const where = channel ? (channel.startsWith('#') || /^[CDG][A-Z0-9]{6,}$/.test(channel) ? channel : `#${channel}`) : undefined\n return {\n action: 'Post in Slack',\n title: `Post in ${where ?? 'Slack'}`,\n ...(where ? { target: where } : {}),\n preview: { kind: 'post', channel: 'slack', text: text(input.text) ?? '', where },\n }\n },\n 'stripe.payment-intents.create': payment('payment'),\n 'stripe.payment-links.create': payment('payment link'),\n 'stripe.invoices.create': payment('invoice'),\n 'stripe.refunds.create': payment('refund'),\n 'stripe.subscriptions.create': payment('subscription'),\n 'phony.synthesize_speech': (input) => {\n const seconds = speechSeconds(input)\n const voice = voiceName(input)\n const detail = [voice, seconds ? `${seconds} s` : undefined].filter(Boolean)\n return {\n action: 'Create voice memo',\n title: `Create voice memo${detail.length ? ` (${detail.join(', ')})` : ''}`,\n preview: { kind: 'speech', text: text(input.text) ?? '', voice, seconds },\n }\n },\n 'phony.start_outbound_call': (input) => {\n const to = text(input.toNumber) ?? text(input.to)\n const mission = asRecord(input.mission)\n return {\n action: 'Start call',\n title: to ? `Call ${to}` : 'Start an outbound call',\n ...(to ? { target: to } : {}),\n preview: {\n kind: 'call',\n to,\n from: text(input.fromNumber),\n purpose: text(mission.goal) ?? text(mission.objective) ?? text(mission.summary) ?? text(input.missionId),\n },\n }\n },\n 'phony.create_agent': (input) => {\n const name = text(input.name)\n return {\n action: 'Create voice agent',\n title: `Create voice agent${name ? ` “${clipped(name, 60)}”` : ''}`,\n preview: { kind: 'fields', fields: scalarFields(input) },\n }\n },\n 'phony.update_agent': (input) => ({\n action: 'Update voice agent',\n title: 'Update a voice agent',\n preview: { kind: 'fields', fields: scalarFields(input) },\n }),\n 'phony.clone_voice': (input) => {\n const name = text(input.name)\n return {\n action: 'Clone voice',\n title: `Clone your voice${name ? ` as “${clipped(name, 60)}”` : ''}`,\n preview: { kind: 'fields', fields: scalarFields(input) },\n }\n },\n 'google-calendar.create_event': calendarEvent,\n 'google-calendar.book_slot': calendarEvent,\n 'google-calendar.update_event': (input, item) => {\n const event = calendarEvent(input, item)\n const title = event.preview.kind === 'event' ? event.preview.title : undefined\n return { ...event, action: 'Update event', title: title ? `Update “${clipped(title, 60)}”` : 'Update an event' }\n },\n 'microsoft-calendar.book_slot': calendarEvent,\n}\n\n/** A held call in the owner's words, with the preview its integration renders. */\nexport function presentHubAction(item: Pick<HubApprovalItem, 'actionPath' | 'providerId' | 'input' | 'files' | 'bundle'>): HubActionPresentation {\n const { provider: pathProvider, action } = splitHubActionPath(item.actionPath)\n const providerId = item.providerId || pathProvider\n const provider = { id: providerId, name: hubProviderName(providerId) }\n const input = asRecord(item.input)\n const known = PRESENTERS[item.actionPath]\n const presented = known\n ? known(input, item)\n : (() => {\n const { verb, noun } = genericVerb(action)\n const phrase = sentence(verb, noun) || action\n const object = text(input.name) ?? text(input.title) ?? text(input.subject) ?? text(input.label)\n return {\n action: phrase,\n title: object ? `${phrase} “${clipped(object, 60)}”` : phrase,\n preview: { kind: 'fields', fields: scalarFields(input) } as HubActionPreview,\n }\n })()\n return { provider, ...presented, ...(item.bundle ? { title: item.bundle.title } : {}) }\n}\n\n// ---------- receipts ----------\n\nfunction prField(result: Record<string, unknown>): HubActionField | undefined {\n const pull = asRecord(result.pullRequest)\n const number = readNumber(pull, 'number') ?? readNumber(result, 'number')\n if (number === undefined) return undefined\n return { label: 'Pull request', value: `#${number}`, href: resultLink(pull) ?? resultLink(result) }\n}\n\nfunction receiptTitle(item: HubApprovalItem, presentation: HubActionPresentation, result: Record<string, unknown>): string {\n const { action } = splitHubActionPath(item.actionPath)\n const input = asRecord(item.input)\n const pull = asRecord(result.pullRequest)\n const number = readNumber(pull, 'number') ?? readNumber(result, 'number')\n switch (item.actionPath) {\n case 'github.pulls.propose':\n case 'github.pulls.create':\n return number !== undefined ? `Opened PR #${number}` : 'Opened pull request'\n case 'github.git.createCommit': {\n const sha = shortSha(readText(result, 'sha'))\n return sha ? `Created commit ${sha}` : 'Created commit'\n }\n case 'github.git.createTree': {\n const files = hubActionFiles(item.actionPath, input).length\n return `Wrote ${files === 1 ? '1 file' : `${files} files`}`\n }\n case 'github.git.createRef':\n return `Created branch ${branchOf(readText(result, 'ref') ?? input.ref) ?? ''}`.trim()\n case 'github.issues.create':\n return number !== undefined ? `Opened issue #${number}` : 'Opened issue'\n case 'github.issues.createComment': {\n const on = readNumber(input, 'issue_number')\n return on !== undefined ? `Commented on #${on}` : 'Commented'\n }\n case 'github.pulls.reviews.create': {\n const on = readNumber(input, 'pull_number')\n return on !== undefined ? `Reviewed PR #${on}` : 'Reviewed pull request'\n }\n case 'github.pulls.merge': {\n const on = readNumber(input, 'pull_number')\n return on !== undefined ? `Merged PR #${on}` : 'Merged pull request'\n }\n case 'phony.synthesize_speech':\n return 'Created voice memo'\n }\n if (presentation.preview.kind === 'email') {\n const to = people(presentation.preview.to)\n if (presentation.preview.reply) return 'Sent reply'\n return action.includes('draft') && !action.startsWith('send') ? `Saved draft${to ? ` to ${to}` : ''}` : `Sent email${to ? ` to ${to}` : ''}`\n }\n if (presentation.preview.kind === 'post') {\n return presentation.preview.channel === 'slack' ? `Posted in ${presentation.preview.where ?? 'Slack'}` : `Posted on ${presentation.target ?? presentation.provider.name}`\n }\n if (presentation.preview.kind === 'event') {\n const verb = presentation.action === 'Update event' ? 'Updated' : 'Booked'\n return presentation.preview.title ? `${verb} “${clipped(presentation.preview.title, 60)}”` : `${verb} event`\n }\n if (presentation.preview.kind === 'call') return presentation.preview.to ? `Started call to ${presentation.preview.to}` : 'Started call'\n const [first = '', ...rest] = presentation.action.split(' ')\n return [pastTense(first), ...rest].join(' ')\n}\n\nfunction postLink(item: HubApprovalItem, result: Record<string, unknown>): string | undefined {\n const id = readText(result, 'id', 'urn', 'postUrn')\n if (!id) return resultLink(result)\n if (item.providerId === 'twitter' || item.providerId === 'x') return /^\\d+$/.test(id) ? `https://x.com/i/web/status/${id}` : resultLink(result)\n if (item.providerId === 'linkedin') return id.startsWith('urn:li:') ? `https://www.linkedin.com/feed/update/${id}/` : resultLink(result)\n return resultLink(result)\n}\n\nfunction receiptFields(item: HubApprovalItem, presentation: HubActionPresentation, result: Record<string, unknown>): HubActionField[] {\n const fields: HubActionField[] = []\n const preview = presentation.preview\n switch (preview.kind) {\n case 'pull-request': {\n const pr = prField(result)\n if (pr) fields.push(pr)\n const head = readText(result, 'branch') ?? preview.head\n const base = readText(result, 'base') ?? preview.base\n if (head && base) fields.push({ label: 'Branch', value: `${head} → ${base}`, mono: true })\n const commit = asRecord(result.commit)\n const sha = readText(commit, 'sha')\n if (sha) fields.push({ label: 'Commit', value: shortSha(sha)!, href: resultLink(commit), mono: true })\n const repo = readText(result, 'repository') ?? preview.repository\n if (repo) fields.push({ label: 'Repository', value: repo, href: `https://github.com/${repo}` })\n return fields\n }\n case 'commit': {\n const sha = readText(result, 'sha')\n if (sha) fields.push({ label: 'Commit', value: shortSha(sha)!, href: resultLink(result)?.includes('api.github.com') ? undefined : resultLink(result), mono: true })\n if (preview.message) fields.push({ label: 'Message', value: clipped(preview.message, 120) })\n return fields\n }\n case 'branch': {\n const branch = branchOf(readText(result, 'ref')) ?? preview.branch\n if (branch && preview.repository) fields.push({ label: 'Branch', value: branch, href: `https://github.com/${preview.repository}/tree/${branch}`, mono: true })\n return fields\n }\n case 'files': {\n const sha = readText(result, 'sha')\n if (sha) fields.push({ label: 'Tree', value: shortSha(sha)!, mono: true })\n return fields\n }\n case 'email': {\n if (preview.subject) fields.push({ label: 'Subject', value: clipped(preview.subject, 120) })\n if (preview.cc.length) fields.push({ label: 'Cc', value: preview.cc.join(', ') })\n return fields\n }\n case 'payment': {\n const amount = readNumber(result, 'amount', 'amount_total', 'total') ?? preview.amount\n const currency = readText(result, 'currency') ?? preview.currency\n if (amount !== undefined) fields.push({ label: 'Amount', value: formatMinorAmount(amount, currency) })\n const customer = readText(result, 'customer_email', 'customer') ?? preview.customer\n if (customer) fields.push({ label: 'Customer', value: customer, mono: customer.startsWith('cus_') })\n const status = readText(result, 'status')\n if (status) fields.push({ label: 'Status', value: status })\n return fields\n }\n case 'speech': {\n const seconds = readNumber(result, 'durationSeconds', 'duration')\n if (seconds !== undefined) fields.push({ label: 'Length', value: `${Math.round(seconds * 10) / 10} s` })\n if (preview.voice) fields.push({ label: 'Voice', value: preview.voice })\n return fields\n }\n case 'event': {\n if (preview.start) fields.push({ label: 'When', value: formatWhen(preview.start, preview.end) })\n if (preview.attendees.length) fields.push({ label: 'Guests', value: people(preview.attendees) })\n return fields\n }\n case 'call': {\n const status = readText(asRecord(result.call), 'status') ?? readText(result, 'status')\n if (status) fields.push({ label: 'Status', value: status })\n return fields\n }\n default: {\n const id = readText(result, 'id', 'number', 'key')\n if (id) fields.push({ label: 'ID', value: id, mono: true })\n const status = readText(result, 'status', 'state')\n if (status) fields.push({ label: 'Status', value: status })\n const name = readText(result, 'name', 'title')\n if (name) fields.push({ label: 'Name', value: clipped(name, 80) })\n return fields\n }\n }\n}\n\n/** A start and optional end in the viewer's locale: `Tue, Oct 14, 3:00 – 3:30 PM`. */\nexport function formatWhen(start: string, end?: string): string {\n const from = new Date(start)\n if (Number.isNaN(from.getTime())) return end ? `${start} – ${end}` : start\n const day = from.toLocaleDateString(undefined, { weekday: 'short', month: 'short', day: 'numeric' })\n const time = (date: Date) => date.toLocaleTimeString(undefined, { hour: 'numeric', minute: '2-digit' })\n const to = end ? new Date(end) : null\n if (!to || Number.isNaN(to.getTime())) return `${day}, ${time(from)}`\n return to.toDateString() === from.toDateString() ? `${day}, ${time(from)} – ${time(to)}` : `${day}, ${time(from)} – ${to.toLocaleDateString(undefined, { month: 'short', day: 'numeric' })}, ${time(to)}`\n}\n\nfunction receiptFiles(result: Record<string, unknown>): HubActionFile[] | undefined {\n if (!Array.isArray(result.files)) return undefined\n return result.files.flatMap((entry): HubActionFile[] => {\n const file = asRecord(entry)\n const path = text(file.path) ?? text(file.filename)\n if (!path) return []\n const status = text(file.status)\n const change = status === 'added' ? 'added' : status === 'removed' || status === 'deleted' ? 'deleted' : 'modified'\n return [{ path, change, additions: readNumber(file, 'additions'), deletions: readNumber(file, 'deletions') }]\n })\n}\n\n/** What a decided call did: its past-tense title, key fields, link, media and files. */\nexport function hubActionReceipt(item: HubApprovalItem): HubActionReceipt {\n const presentation = presentHubAction(item)\n const result = asRecord(unwrapHubResult(item.result))\n const status: HubActionReceipt['status'] = item.phase === 'done' || item.phase === 'failed' || item.phase === 'denied' || item.phase === 'expired'\n ? item.phase\n : item.phase === 'queued' || item.phase === 'running' ? 'running' : 'waiting'\n const base = { provider: presentation.provider, status }\n if (status === 'denied') return { ...base, title: `Denied: ${presentation.title}`, fields: [] }\n if (status === 'expired') return { ...base, title: `Expired: ${presentation.title}`, fields: [] }\n if (status === 'failed') return { ...base, title: `Could not ${presentation.action.charAt(0).toLowerCase()}${presentation.action.slice(1)}`, fields: [], ...(item.error ? { error: item.error } : {}) }\n if (status !== 'done') return { ...base, title: presentation.title, fields: [] }\n const title = receiptTitle(item, presentation, result)\n const fields = receiptFields(item, presentation, result)\n const pull = asRecord(result.pullRequest)\n const href = presentation.preview.kind === 'post'\n ? postLink(item, result)\n : resultLink(pull) ?? (item.actionPath.startsWith('github.git.') ? undefined : resultLink(result))\n const audio = readText(result, 'audioUrl')\n const seconds = readNumber(result, 'durationSeconds', 'duration')\n const files = receiptFiles(result)\n return {\n ...base,\n title,\n ...(href ? { href } : {}),\n fields,\n ...(files && files.length ? { files } : {}),\n ...(audio && /^https:\\/\\//.test(audio) ? { media: { kind: 'audio' as const, src: audio, ...(seconds !== undefined ? { seconds } : {}) } } : {}),\n }\n}\n","/**\n * `./hub-approvals` — Hub actions that wait on a person, in the owner's words.\n *\n * Pure and browser-safe: a host maps its held calls into {@link HubApprovalItem}s\n * and every surface — the approval dock above the composer, the Approvals list\n * beside the conversation, and the receipts in the transcript — renders the\n * same presentation from them. Servers use {@link summarizeHubResult} to store\n * a bounded result with the decision.\n */\n\nimport type { HubApprovalPhase } from './types'\n\nexport * from './types'\nexport {\n formatMinorAmount,\n formatWhen,\n hubActionFiles,\n hubActionReceipt,\n hubProviderName,\n pastTense,\n presentHubAction,\n splitHubActionPath,\n} from './present'\nexport { summarizeHubResult, unwrapHubResult } from './result'\n\n/** A phase as a status label. */\nexport const HUB_APPROVAL_PHASE_LABELS: Record<HubApprovalPhase, string> = {\n waiting: 'Waiting for you',\n blocked: 'Waiting for the owner',\n queued: 'Queued',\n running: 'Running',\n done: 'Done',\n failed: 'Failed',\n denied: 'Denied',\n expired: 'Expired',\n}\n\n/**\n * The part type marking a user message that resumes the agent after a\n * decision. The message's text goes to the agent unchanged; a transcript\n * renders the decided actions' receipts in its place, never a chat bubble.\n */\nexport const HUB_APPROVAL_RESUME_PART = 'hub-approval-resume'\n\nexport interface HubApprovalResumePart {\n type: typeof HUB_APPROVAL_RESUME_PART\n /** The assistant message whose held calls this resume reports. */\n messageId: string\n}\n\n/** The resume marker among a message's parts, if it carries one. */\nexport function hubApprovalResumePart(parts: ReadonlyArray<Record<string, unknown>> | null | undefined): HubApprovalResumePart | null {\n for (const part of parts ?? []) {\n if (part?.type === HUB_APPROVAL_RESUME_PART && typeof part.messageId === 'string' && part.messageId) {\n return { type: HUB_APPROVAL_RESUME_PART, messageId: part.messageId }\n }\n }\n return null\n}\n"],"mappings":";AAsBO,IAAM,2BAA0D,oBAAI,IAAI,CAAC,WAAW,SAAS,CAAC;AAE9F,IAAM,6BAA4D,oBAAI,IAAI,CAAC,UAAU,SAAS,CAAC;;;ACnBtG,IAAM,YAAY;AAClB,IAAM,WAAW;AACjB,IAAM,YAAY;AAClB,IAAM,aAAa;AAEZ,SAAS,SAAS,OAAyC;AAChE,SAAO,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,IAAI,QAAmC,CAAC;AAC3G;AAOO,SAAS,gBAAgB,OAAyB;AACvD,MAAI,UAAmB;AACvB,MAAI,OAAO,YAAY,UAAU;AAC/B,UAAMA,QAAO;AACb,QAAI;AACF,gBAAU,KAAK,MAAMA,KAAI;AAAA,IAC3B,QAAQ;AAEN,YAAM,QAAQA,MAAK,QAAQ,GAAG;AAC9B,UAAI,QAAQ,EAAG,QAAO;AACtB,UAAI;AACF,kBAAU,KAAK,MAAMA,MAAK,MAAM,KAAK,CAAC;AAAA,MACxC,QAAQ;AACN,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACA,WAAS,QAAQ,GAAG,QAAQ,GAAG,SAAS;AACtC,UAAM,SAAS,S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IAAI,EAAE,OAAO,EAAE,MAAM,SAAkB,KAAK,OAAO,GAAI,YAAY,SAAY,EAAE,QAAQ,IAAI,CAAC,EAAG,EAAE,IAAI,CAAC;AAAA,EAC/I;AACF;;;AC/oBO,IAAM,4BAA8D;AAAA,EACzE,SAAS;AAAA,EACT,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AACX;AAOO,IAAM,2BAA2B;AASjC,SAAS,sBAAsB,OAAgG;AACpI,aAAW,QAAQ,SAAS,CAAC,GAAG;AAC9B,QAAI,MAAM,SAAS,4BAA4B,OAAO,KAAK,cAAc,YAAY,KAAK,WAAW;AACnG,aAAO,EAAE,MAAM,0BAA0B,WAAW,KAAK,UAAU;AAAA,IACrE;AAAA,EACF;AACA,SAAO;AACT;","names":["text","words"]}
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
formatWhen,
|
|
7
7
|
hubActionReceipt,
|
|
8
8
|
presentHubAction
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-BGJQFDRL.js";
|
|
10
10
|
|
|
11
11
|
// src/hub-approvals-react/dock.tsx
|
|
12
12
|
import { useEffect, useMemo, useRef, useState as useState2 } from "react";
|
|
@@ -77,6 +77,10 @@ function HubFieldList({ fields }) {
|
|
|
77
77
|
function Chip({ children, mono }) {
|
|
78
78
|
return /* @__PURE__ */ jsx("span", { className: `inline-flex max-w-full items-center truncate rounded-md border border-border bg-muted/50 px-1.5 py-0.5 text-sm text-foreground ${mono ? "font-mono" : ""}`, children });
|
|
79
79
|
}
|
|
80
|
+
function distinctAccount(account, providerName) {
|
|
81
|
+
const value = account?.trim();
|
|
82
|
+
return value && value.toLowerCase() !== providerName.toLowerCase() ? value : null;
|
|
83
|
+
}
|
|
80
84
|
function closesIn(expiresAt, now = Date.now()) {
|
|
81
85
|
if (!expiresAt) return null;
|
|
82
86
|
const minutes = Math.ceil((Date.parse(expiresAt) - now) / 6e4);
|
|
@@ -399,7 +403,8 @@ function HubApprovalDock({ items, onDecide, permissions, onOpen, focusId, classN
|
|
|
399
403
|
const busy = submitting?.id === active.id;
|
|
400
404
|
const decidable = active.phase === "waiting" && !busy;
|
|
401
405
|
const closing = active.phase === "waiting" ? closesIn(active.expiresAt, now) : null;
|
|
402
|
-
const
|
|
406
|
+
const account = distinctAccount(active.account, presentation.provider.name);
|
|
407
|
+
const subtitle = [presentation.provider.name, account ? `as ${account}` : null, closing].filter(Boolean).join(" \xB7 ");
|
|
403
408
|
async function decide(decision, label) {
|
|
404
409
|
if (!active || submitting) return;
|
|
405
410
|
setSubmitting({ id: active.id, label });
|
|
@@ -552,7 +557,7 @@ function HubApprovalsList({ items, onSelect, selectedId, className = "" }) {
|
|
|
552
557
|
const presentation = presentHubAction(item);
|
|
553
558
|
const title = item.phase === "done" ? hubActionReceipt(item).title : presentation.title;
|
|
554
559
|
const when = item.phase === "waiting" ? closesIn(item.expiresAt, now) ?? relativeTime(item.requestedAt, now) : relativeTime(item.requestedAt, now);
|
|
555
|
-
const detail = [presentation.provider.name, item.account, when].filter(Boolean).join(" \xB7 ");
|
|
560
|
+
const detail = [presentation.provider.name, distinctAccount(item.account, presentation.provider.name), when].filter(Boolean).join(" \xB7 ");
|
|
556
561
|
const selected = selectedId === item.id;
|
|
557
562
|
return /* @__PURE__ */ jsx4("li", { children: /* @__PURE__ */ jsxs4(
|
|
558
563
|
Button3,
|
|
@@ -597,7 +602,8 @@ function AudioPlayer({ src }) {
|
|
|
597
602
|
function HubActionReceiptCard({ item, className = "" }) {
|
|
598
603
|
const receipt = hubActionReceipt(item);
|
|
599
604
|
const presentation = presentHubAction(item);
|
|
600
|
-
const
|
|
605
|
+
const account = distinctAccount(item.account, receipt.provider.name);
|
|
606
|
+
const subtitle = [receipt.provider.name, account ? `as ${account}` : null, presentation.target && !receipt.title.includes(presentation.target) ? presentation.target : null].filter(Boolean).join(" \xB7 ");
|
|
601
607
|
const phase = item.phase;
|
|
602
608
|
return /* @__PURE__ */ jsxs5("article", { "aria-label": receipt.title, className: `rounded-xl border border-border bg-card px-4 py-3 shadow-sm ${className}`, children: [
|
|
603
609
|
/* @__PURE__ */ jsxs5("div", { className: "flex items-start gap-3", children: [
|
|
@@ -674,12 +680,13 @@ function HubApprovalRow({ item, expanded: controlled, onExpandedChange, onReview
|
|
|
674
680
|
children: [
|
|
675
681
|
/* @__PURE__ */ jsx6(HubProviderMark, { providerId: presentation.provider.id, name: presentation.provider.name, size: 24 }),
|
|
676
682
|
/* @__PURE__ */ jsx6("span", { className: "min-w-0 flex-1 truncate text-sm font-medium text-foreground", children: title }),
|
|
677
|
-
/* @__PURE__ */ jsx6(HubApprovalPhasePill, { phase: item.phase }),
|
|
683
|
+
/* @__PURE__ */ jsx6(HubApprovalPhasePill, { phase: item.phase, label: item.phase === "waiting" ? "Waiting" : item.phase === "blocked" ? "Owner decides" : void 0 }),
|
|
678
684
|
/* @__PURE__ */ jsx6(ChevronDown2, { "aria-hidden": true, className: `size-4 shrink-0 text-muted-foreground transition-transform ${expanded ? "rotate-180" : ""}` })
|
|
679
685
|
]
|
|
680
686
|
}
|
|
681
687
|
),
|
|
682
|
-
item.phase === "waiting" && onReview &&
|
|
688
|
+
item.phase === "waiting" && onReview && // On a phone the dock sits just below; the row keeps its width for the title.
|
|
689
|
+
/* @__PURE__ */ jsx6(Button4, { variant: "outline", className: "hidden sm:inline-flex", onClick: () => onReview(item), children: "Review" })
|
|
683
690
|
] }),
|
|
684
691
|
expanded && /* @__PURE__ */ jsxs6("div", { className: "space-y-3 border-t border-border px-3 pb-3 pt-3", children: [
|
|
685
692
|
item.phase === "done" || item.phase === "failed" ? /* @__PURE__ */ jsx6(HubActionReceiptCard, { item, className: "border-0 px-0 py-0 shadow-none" }) : /* @__PURE__ */ jsxs6(Fragment2, { children: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hub-approvals-react/dock.tsx","../../src/hub-approvals-react/parts.tsx","../../src/hub-approvals-react/preview.tsx","../../src/hub-approvals-react/list.tsx","../../src/hub-approvals-react/row.tsx","../../src/hub-approvals-react/receipt.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from 'react'\nimport { Check, ChevronDown, ChevronLeft, ChevronRight, ExternalLink, Loader2, X } from 'lucide-react'\nimport { Button, Label, RadioGroup, RadioGroupItem } from '@tangle-network/ui/primitives'\n\nimport {\n HUB_APPROVAL_ACTIVE_PHASES,\n HUB_APPROVAL_OPEN_PHASES,\n hubActionReceipt,\n presentHubAction,\n type HubApprovalItem,\n type HubApprovalPhase,\n} from '../hub-approvals'\nimport { closesIn, HubProviderMark, HubRawDetails } from './parts'\nimport { HubActionPreviewView } from './preview'\n\n/** The owner's answer to one held call. `allow` also grants a standing permission. */\nexport type HubApprovalDecision =\n | { kind: 'approve' }\n | { kind: 'deny' }\n | { kind: 'allow'; duration: '24h' | 'always'; scope: string }\n\n/** What a standing permission for one call may cover, or why none can. */\nexport type HubApprovalPermissions =\n | { scopes: ReadonlyArray<{ id: string; label: string }> }\n | { never: string }\n\nexport interface HubApprovalDockProps {\n /** Every held call in the conversation; the dock shows the open and running ones. */\n items: readonly HubApprovalItem[]\n onDecide: (item: HubApprovalItem, decision: HubApprovalDecision) => Promise<void>\n /** Standing-permission choices for a call; omit when the host offers none. */\n permissions?: (item: HubApprovalItem) => HubApprovalPermissions | null\n /** Show the call where the agent made it. */\n onOpen?: (item: HubApprovalItem) => void\n /** Bring one call to the front, e.g. after it was picked in the Approvals list. */\n focusId?: string | null\n className?: string\n}\n\n/** How long a finished call stays in the dock, so its result is seen where it was approved. */\nconst DONE_VISIBLE_MS = 6_000\n\nfunction useNow(intervalMs: number) {\n const [now, setNow] = useState(() => Date.now())\n useEffect(() => {\n const timer = setInterval(() => setNow(Date.now()), intervalMs)\n return () => clearInterval(timer)\n }, [intervalMs])\n return now\n}\n\nfunction Progress({ item }: { item: HubApprovalItem }) {\n const provider = presentHubAction(item).provider.name\n if (item.phase === 'queued' || item.phase === 'running') {\n return (\n <p role=\"status\" className=\"flex items-center gap-2 text-sm font-medium text-foreground\">\n <Loader2 aria-hidden className=\"size-4 animate-spin text-[var(--surface-info-text)]\" />\n {item.phase === 'queued' ? 'Approved. It runs when the agent’s turn finishes…' : `Running on ${provider}…`}\n </p>\n )\n }\n if (item.phase === 'done') {\n const receipt = hubActionReceipt(item)\n return (\n <p role=\"status\" className=\"flex min-w-0 items-center gap-2 text-sm font-medium text-foreground\">\n <Check aria-hidden className=\"size-4 shrink-0 text-[var(--surface-success-text)]\" />\n {receipt.href\n ? <a href={receipt.href} target=\"_blank\" rel=\"noreferrer\" className=\"inline-flex min-w-0 items-center gap-1 hover:underline\"><span className=\"truncate\">{receipt.title}</span><ExternalLink aria-hidden className=\"size-4 shrink-0 text-muted-foreground\" /></a>\n : <span className=\"truncate\">{receipt.title}</span>}\n </p>\n )\n }\n if (item.phase === 'failed') {\n return (\n <p role=\"alert\" className=\"break-words text-sm text-[var(--surface-danger-text)]\">\n {hubActionReceipt(item).title}{item.error ? `: ${item.error}` : '.'}\n </p>\n )\n }\n return null\n}\n\n/**\n * The calls waiting on the owner, pinned above the composer so a held action\n * never scrolls away. Each shows what it does, where, as which account, and a\n * preview drawn like its integration; Approve, Deny and the standing\n * permissions a host offers sit beside it. Approving shows the run in place —\n * starting, running, then the result — without leaving the conversation.\n */\nexport function HubApprovalDock({ items, onDecide, permissions, onOpen, focusId, className = '' }: HubApprovalDockProps) {\n const now = useNow(30_000)\n // Calls that finished while this dock watched them stay with their result: a\n // success briefly, a failure until dismissed. One that failed before the dock\n // mounted shows in the transcript row, the Approvals list and its receipt.\n const watched = useRef(new Map<string, HubApprovalPhase>())\n const [settled, setSettled] = useState<Record<string, number>>({})\n const [dismissed, setDismissed] = useState<ReadonlySet<string>>(new Set())\n const [submitting, setSubmitting] = useState<{ id: string; label: string } | null>(null)\n const [error, setError] = useState<{ id: string; message: string } | null>(null)\n const [activeId, setActiveId] = useState<string | null>(null)\n const [collapsed, setCollapsed] = useState(false)\n const [permissionsOpen, setPermissionsOpen] = useState(false)\n const [scope, setScope] = useState<string | null>(null)\n\n useEffect(() => {\n const finishedNow: Record<string, number> = {}\n for (const item of items) {\n const before = watched.current.get(item.id)\n const wasLive = before !== undefined && (HUB_APPROVAL_OPEN_PHASES.has(before) || HUB_APPROVAL_ACTIVE_PHASES.has(before))\n if (wasLive && (item.phase === 'done' || item.phase === 'failed')) finishedNow[item.id] = Date.now()\n watched.current.set(item.id, item.phase)\n }\n if (Object.keys(finishedNow).length > 0) setSettled((current) => ({ ...current, ...finishedNow }))\n }, [items])\n\n useEffect(() => {\n const doneIds = Object.entries(settled).filter(([id]) => items.find((item) => item.id === id)?.phase === 'done')\n if (doneIds.length === 0) return\n const oldest = Math.min(...doneIds.map(([, at]) => at))\n const timer = setTimeout(() => {\n const cutoff = Date.now() - DONE_VISIBLE_MS\n setSettled((current) => Object.fromEntries(Object.entries(current).filter(([id, at]) => at > cutoff || items.find((item) => item.id === id)?.phase !== 'done')))\n }, Math.max(0, oldest + DONE_VISIBLE_MS - Date.now()))\n return () => clearTimeout(timer)\n }, [settled, items])\n\n const queue = useMemo(() => items.filter((item) => !dismissed.has(item.id) && (\n HUB_APPROVAL_OPEN_PHASES.has(item.phase)\n || HUB_APPROVAL_ACTIVE_PHASES.has(item.phase)\n || item.id in settled\n || submitting?.id === item.id\n )), [items, dismissed, settled, submitting])\n\n useEffect(() => {\n if (focusId && queue.some((item) => item.id === focusId)) {\n setActiveId(focusId)\n setCollapsed(false)\n }\n }, [focusId, queue])\n\n const activeIndex = Math.max(0, queue.findIndex((item) => item.id === activeId))\n const active = queue[activeIndex]\n\n // When the shown call finishes and its result has been seen, move to the next one waiting.\n useEffect(() => {\n if (!active || activeId === active.id) return\n setActiveId(active.id)\n }, [active, activeId])\n useEffect(() => {\n setPermissionsOpen(false)\n setScope(null)\n }, [active?.id])\n\n if (!active) return null\n const presentation = presentHubAction(active)\n const waitingCount = queue.filter((item) => HUB_APPROVAL_OPEN_PHASES.has(item.phase)).length\n const choices = permissions?.(active) ?? null\n const scopes = choices && 'scopes' in choices ? choices.scopes : []\n const chosenScope = scope ?? scopes[0]?.id ?? null\n const busy = submitting?.id === active.id\n const decidable = active.phase === 'waiting' && !busy\n const closing = active.phase === 'waiting' ? closesIn(active.expiresAt, now) : null\n const subtitle = [presentation.provider.name, active.account ? `as ${active.account}` : null, closing].filter(Boolean).join(' · ')\n\n async function decide(decision: HubApprovalDecision, label: string) {\n if (!active || submitting) return\n setSubmitting({ id: active.id, label })\n setError(null)\n try {\n await onDecide(active, decision)\n } catch (cause) {\n setError({ id: active.id, message: cause instanceof Error ? cause.message : 'The decision did not go through. Try again.' })\n } finally {\n setSubmitting(null)\n }\n }\n\n const step = (delta: number) => {\n const next = queue[(activeIndex + delta + queue.length) % queue.length]\n if (next) setActiveId(next.id)\n }\n\n return (\n <section\n aria-label=\"Waiting for your approval\"\n data-hub-approval-dock={active.id}\n className={`overflow-hidden rounded-2xl border border-[var(--surface-warning-border)] bg-card shadow-md ${className}`}\n >\n <div className=\"flex items-start gap-3 px-4 pt-3\">\n <HubProviderMark providerId={presentation.provider.id} name={presentation.provider.name} size={32} />\n <div className=\"min-w-0 flex-1\">\n <h3 className=\"line-clamp-2 break-words text-base font-semibold leading-6 text-foreground\" title={presentation.title}>{presentation.title}</h3>\n <p className=\"truncate text-sm text-muted-foreground\">{subtitle}</p>\n </div>\n <div className=\"flex shrink-0 items-center gap-1\">\n {queue.length > 1 && (\n <>\n <Button variant=\"ghost\" size=\"icon-sm\" aria-label=\"Previous request\" onClick={() => step(-1)}><ChevronLeft /></Button>\n <span className=\"min-w-14 text-center text-sm tabular-nums text-muted-foreground\" aria-live=\"polite\">\n {activeIndex + 1} of {queue.length}\n </span>\n <Button variant=\"ghost\" size=\"icon-sm\" aria-label=\"Next request\" onClick={() => step(1)}><ChevronRight /></Button>\n </>\n )}\n <Button\n variant=\"ghost\"\n size=\"icon-sm\"\n aria-label={collapsed ? 'Show the request' : 'Hide the preview'}\n aria-expanded={!collapsed}\n onClick={() => setCollapsed((value) => !value)}\n >\n <ChevronDown className={`transition-transform ${collapsed ? '-rotate-90' : ''}`} />\n </Button>\n </div>\n </div>\n\n {!collapsed && (\n <div className=\"max-h-64 space-y-3 overflow-y-auto px-4 pt-3 sm:max-h-96\">\n {active.bundle?.steps && active.bundle.steps.length > 0 && (\n <ol className=\"space-y-1 text-sm\" aria-label=\"Steps this approval covers\">\n {active.bundle.steps.map((stepItem, index) => (\n <li key={index} className={`flex items-center gap-2 ${stepItem.state === 'current' ? 'font-medium text-foreground' : 'text-muted-foreground'}`}>\n <span className={`flex size-5 shrink-0 items-center justify-center rounded-full border text-sm tabular-nums ${stepItem.state === 'done' ? 'border-transparent bg-[var(--surface-success-bg)] text-[var(--surface-success-text)]' : 'border-border'}`}>\n {stepItem.state === 'done' ? <Check aria-hidden className=\"size-3.5\" /> : index + 1}\n </span>\n {stepItem.label}\n </li>\n ))}\n </ol>\n )}\n <HubActionPreviewView preview={presentation.preview} account={active.account} />\n <HubRawDetails sections={[{ label: 'Call', value: { action: active.actionPath, input: active.input } }]} />\n </div>\n )}\n\n <div className=\"space-y-3 px-4 pb-4 pt-3\">\n {busy && submitting && !HUB_APPROVAL_ACTIVE_PHASES.has(active.phase) && active.phase === 'waiting' && (\n <p role=\"status\" className=\"flex items-center gap-2 text-sm font-medium text-foreground\">\n <Loader2 aria-hidden className=\"size-4 animate-spin text-[var(--surface-info-text)]\" />\n {submitting.label}\n </p>\n )}\n <Progress item={active} />\n {error?.id === active.id && <p role=\"alert\" className=\"text-sm text-[var(--surface-danger-text)]\">{error.message}</p>}\n {active.phase === 'blocked' && <p className=\"text-sm text-muted-foreground\">The workspace owner approves this request.</p>}\n\n {decidable && permissionsOpen && scopes.length > 0 && (\n <fieldset className=\"space-y-2 rounded-xl border border-border bg-muted/30 px-3 py-3\">\n <legend className=\"sr-only\">Standing permission</legend>\n {scopes.length > 1 && (\n <RadioGroup\n aria-label=\"What the permission covers\"\n value={chosenScope ?? undefined}\n onValueChange={setScope}\n className=\"gap-1.5\"\n >\n {scopes.map((option) => (\n <div key={option.id} className=\"flex min-h-8 items-center gap-2\">\n <RadioGroupItem id={`hub-scope-${active.id}-${option.id}`} value={option.id} />\n <Label htmlFor={`hub-scope-${active.id}-${option.id}`} className=\"cursor-pointer text-sm font-normal text-foreground\">{option.label}</Label>\n </div>\n ))}\n </RadioGroup>\n )}\n {scopes.length === 1 && <p className=\"text-sm text-foreground\">{scopes[0]?.label}</p>}\n <div className=\"flex flex-wrap gap-2\">\n <Button variant=\"outline\" onClick={() => chosenScope && void decide({ kind: 'allow', duration: '24h', scope: chosenScope }, 'Approving and allowing for 24 hours…')}>\n Approve and allow for 24 hours\n </Button>\n <Button variant=\"outline\" onClick={() => chosenScope && void decide({ kind: 'allow', duration: 'always', scope: chosenScope }, 'Approving and allowing from now on…')}>\n Approve and always allow\n </Button>\n </div>\n </fieldset>\n )}\n\n <div className=\"flex flex-wrap items-center gap-2\">\n {decidable && (\n <>\n <Button onClick={() => void decide({ kind: 'approve' }, 'Approving…')}>Approve</Button>\n <Button variant=\"outline\" onClick={() => void decide({ kind: 'deny' }, 'Denying…')}>Deny</Button>\n {scopes.length > 0 && (\n <Button variant=\"ghost\" aria-expanded={permissionsOpen} onClick={() => setPermissionsOpen((value) => !value)}>\n {permissionsOpen ? 'Fewer options' : 'Allow future calls…'}\n </Button>\n )}\n </>\n )}\n {active.phase === 'failed' && (\n <Button variant=\"outline\" onClick={() => setDismissed((current) => new Set([...current, active.id]))}>\n <X aria-hidden /> Dismiss\n </Button>\n )}\n <span className=\"flex-1\" />\n {decidable && choices && 'never' in choices && (\n <span className=\"text-sm text-muted-foreground\">{choices.never}</span>\n )}\n {onOpen && (\n <Button variant=\"ghost\" onClick={() => onOpen(active)}>View in chat</Button>\n )}\n </div>\n {waitingCount > 0 && queue.length > 1 && active.phase !== 'waiting' && (\n <p className=\"text-sm text-muted-foreground\">{waitingCount === 1 ? '1 more request is waiting.' : `${waitingCount} more requests are waiting.`}</p>\n )}\n </div>\n </section>\n )\n}\n","import { useState, type ReactNode } from 'react'\nimport { ChevronRight } from 'lucide-react'\nimport { ProviderIcon } from '@tangle-network/sandbox-ui/integrations'\nimport { Button, StatusPill, type StatusTone } from '@tangle-network/ui/primitives'\n\nimport { HUB_APPROVAL_PHASE_LABELS, type HubApprovalPhase } from '../hub-approvals'\n\nconst PHASE_TONES: Record<HubApprovalPhase, StatusTone> = {\n waiting: 'warning',\n blocked: 'warning',\n queued: 'running',\n running: 'running',\n done: 'success',\n failed: 'danger',\n denied: 'neutral',\n expired: 'neutral',\n}\n\n/** A phase as a toned pill: glyph, colour and label. */\nexport function HubApprovalPhasePill({ phase, label }: { phase: HubApprovalPhase; label?: string }) {\n return (\n <StatusPill tone={PHASE_TONES[phase]} size=\"md\" className=\"shrink-0 whitespace-nowrap\">\n {label ?? HUB_APPROVAL_PHASE_LABELS[phase]}\n </StatusPill>\n )\n}\n\n/** The integration's own logo on a neutral tile, so dark marks stay legible. */\nexport function HubProviderMark({ providerId, name, size = 28 }: { providerId: string; name: string; size?: number }) {\n const inner = Math.round(size * 0.64)\n return (\n <span\n className=\"flex shrink-0 items-center justify-center rounded-lg border border-border bg-background\"\n style={{ width: size, height: size }}\n >\n <ProviderIcon id={providerId} displayName={name} size={inner} className=\"rounded-sm\" />\n </span>\n )\n}\n\n/** Raw JSON behind a disclosure, for the person who wants the exact call. */\nexport function HubRawDetails({ sections }: { sections: ReadonlyArray<{ label: string; value: unknown }> }) {\n const [open, setOpen] = useState(false)\n const shown = sections.filter((section) => section.value !== undefined && section.value !== null && section.value !== '')\n if (shown.length === 0) return null\n return (\n <div>\n <Button\n variant=\"bare\"\n aria-expanded={open}\n onClick={() => setOpen((value) => !value)}\n className=\"inline-flex min-h-8 items-center gap-1 rounded-md text-sm font-medium text-muted-foreground hover:text-foreground\"\n >\n <ChevronRight aria-hidden className={`size-4 transition-transform ${open ? 'rotate-90' : ''}`} />\n Details\n </Button>\n {open && (\n <div className=\"mt-2 space-y-3\">\n {shown.map((section) => (\n <div key={section.label} className=\"space-y-1\">\n <p className=\"text-sm font-medium text-muted-foreground\">{section.label}</p>\n <pre className=\"max-h-64 overflow-auto whitespace-pre-wrap break-all rounded-lg border border-border bg-muted/40 p-3 font-mono text-sm leading-5 text-foreground\">\n {typeof section.value === 'string' ? section.value : JSON.stringify(section.value, null, 2)}\n </pre>\n </div>\n ))}\n </div>\n )}\n </div>\n )\n}\n\n/** A `label value` list that wraps on a phone. */\nexport function HubFieldList({ fields }: { fields: ReadonlyArray<{ label: string; value: string; href?: string; mono?: boolean }> }) {\n if (fields.length === 0) return null\n return (\n <dl className=\"flex flex-wrap gap-x-6 gap-y-2 text-sm\">\n {fields.map((field) => (\n <div key={`${field.label}:${field.value}`} className=\"flex min-w-0 max-w-full items-baseline gap-2\">\n <dt className=\"shrink-0 text-muted-foreground\">{field.label}</dt>\n <dd className={`min-w-0 truncate text-foreground ${field.mono ? 'font-mono' : ''}`} title={field.value}>\n {field.href\n ? <a href={field.href} target=\"_blank\" rel=\"noreferrer\" className=\"text-[var(--accent-text)] underline-offset-2 hover:underline\">{field.value}</a>\n : field.value}\n </dd>\n </div>\n ))}\n </dl>\n )\n}\n\nexport function Chip({ children, mono }: { children: ReactNode; mono?: boolean }) {\n return (\n <span className={`inline-flex max-w-full items-center truncate rounded-md border border-border bg-muted/50 px-1.5 py-0.5 text-sm text-foreground ${mono ? 'font-mono' : ''}`}>\n {children}\n </span>\n )\n}\n\n/** When a decision window closes, relative to now: `in 23 h`, `in 5 min`. */\nexport function closesIn(expiresAt: string | null | undefined, now = Date.now()): string | null {\n if (!expiresAt) return null\n const minutes = Math.ceil((Date.parse(expiresAt) - now) / 60_000)\n if (!Number.isFinite(minutes) || minutes <= 0) return null\n return minutes >= 120 ? `closes in ${Math.round(minutes / 60)} h` : `closes in ${minutes} min`\n}\n\n/** A short relative time: `just now`, `4 min ago`, `3 h ago`, then the date. */\nexport function relativeTime(at: string | null | undefined, now = Date.now()): string | null {\n if (!at) return null\n const then = Date.parse(at)\n if (!Number.isFinite(then)) return null\n const minutes = Math.round((now - then) / 60_000)\n if (minutes < 1) return 'just now'\n if (minutes < 60) return `${minutes} min ago`\n if (minutes < 24 * 60) return `${Math.round(minutes / 60)} h ago`\n return new Date(then).toLocaleDateString(undefined, { month: 'short', day: 'numeric' })\n}\n","import { ArrowRight, CalendarDays, GitBranch, GitCommitHorizontal, GitPullRequest, MapPin, Phone, Users } from 'lucide-react'\nimport { ApprovalDiffSummary } from '@tangle-network/ui/run'\n\nimport { formatMinorAmount, formatWhen, type HubActionPreview } from '../hub-approvals'\nimport { Chip, HubFieldList } from './parts'\n\n/** Readable text of an HTML email body, for a preview that never renders markup. */\nfunction plainText(body: string, html: boolean): string {\n if (!html) return body\n return body\n .replace(/<(script|style)[\\s\\S]*?<\\/\\1>/gi, '')\n .replace(/<br\\s*\\/?>/gi, '\\n')\n .replace(/<\\/(p|div|li|h[1-6]|tr)>/gi, '\\n')\n .replace(/<[^>]+>/g, '')\n .replace(/ /g, ' ')\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/"/g, '\"')\n .replace(/'/g, \"'\")\n .replace(/\\n{3,}/g, '\\n\\n')\n .trim()\n}\n\nfunction initial(name: string | null | undefined): string {\n return (name?.trim().replace(/^@/, '').charAt(0) || '?').toUpperCase()\n}\n\nfunction Panel({ children, className = '' }: { children: React.ReactNode; className?: string }) {\n return <div className={`rounded-lg border border-border bg-background ${className}`}>{children}</div>\n}\n\nfunction PullRequestPreview({ preview }: { preview: Extract<HubActionPreview, { kind: 'pull-request' }> }) {\n return (\n <div className=\"space-y-3\">\n <Panel className=\"px-3 py-3\">\n <div className=\"flex flex-wrap items-center gap-2 text-sm text-muted-foreground\">\n <GitPullRequest aria-hidden className=\"size-4 shrink-0\" />\n {preview.repository && <span className=\"font-medium text-foreground\">{preview.repository}</span>}\n {preview.head && preview.base && (\n <span className=\"flex min-w-0 flex-wrap items-center gap-1.5\">\n <Chip mono>{preview.head}</Chip>\n <ArrowRight aria-label=\"into\" className=\"size-4 shrink-0\" />\n <Chip mono>{preview.base}</Chip>\n </span>\n )}\n {preview.draft && <span className=\"rounded-md border border-border px-1.5 py-0.5 text-sm text-muted-foreground\">Draft</span>}\n </div>\n {preview.title && <p className=\"mt-2 text-base font-semibold leading-6 text-foreground\">{preview.title}</p>}\n {preview.body && <p className=\"mt-1 line-clamp-3 whitespace-pre-line text-sm leading-6 text-muted-foreground sm:line-clamp-4\">{preview.body}</p>}\n </Panel>\n {preview.files.length > 0 && <ApprovalDiffSummary files={preview.files} />}\n </div>\n )\n}\n\nfunction EmailPreview({ preview, account }: { preview: Extract<HubActionPreview, { kind: 'email' }>; account?: string | null }) {\n const rows: Array<[string, string]> = [\n ...(account ? [['From', account] as [string, string]] : []),\n ...(preview.to.length ? [['To', preview.to.join(', ')] as [string, string]] : []),\n ...(preview.cc.length ? [['Cc', preview.cc.join(', ')] as [string, string]] : []),\n ...(preview.bcc.length ? [['Bcc', preview.bcc.join(', ')] as [string, string]] : []),\n ]\n const body = preview.body ? plainText(preview.body, preview.html) : ''\n return (\n <Panel className=\"overflow-hidden\">\n <dl className=\"grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 border-b border-border px-3 py-2.5 text-sm\">\n {rows.map(([label, value]) => (\n <div key={label} className=\"contents\">\n <dt className=\"text-muted-foreground\">{label}</dt>\n <dd className=\"break-words text-foreground\">{value}</dd>\n </div>\n ))}\n {preview.subject && (\n <div className=\"contents\">\n <dt className=\"text-muted-foreground\">Subject</dt>\n <dd className=\"break-words font-semibold text-foreground\">{preview.subject}</dd>\n </div>\n )}\n {preview.reply && !preview.subject && (\n <div className=\"contents\">\n <dt className=\"text-muted-foreground\">Reply</dt>\n <dd className=\"text-foreground\">In the existing conversation</dd>\n </div>\n )}\n </dl>\n {body && <div className=\"max-h-60 overflow-y-auto whitespace-pre-wrap break-words px-3 py-3 text-sm leading-6 text-foreground\">{body}</div>}\n </Panel>\n )\n}\n\nfunction PostPreview({ preview, account }: { preview: Extract<HubActionPreview, { kind: 'post' }>; account?: string | null }) {\n if (preview.channel === 'slack') {\n return (\n <Panel className=\"px-3 py-3\">\n <p className=\"text-sm font-semibold text-foreground\">{preview.where ?? 'Slack'}</p>\n <div className=\"mt-2 flex gap-3\">\n <span className=\"flex size-9 shrink-0 items-center justify-center rounded-md bg-muted text-sm font-semibold text-foreground\">{initial(account)}</span>\n <div className=\"min-w-0\">\n <p className=\"text-sm font-semibold text-foreground\">{account ?? 'Your account'}</p>\n <p className=\"whitespace-pre-wrap break-words text-sm leading-6 text-foreground\">{preview.text}</p>\n </div>\n </div>\n </Panel>\n )\n }\n const x = preview.channel === 'x'\n const length = [...preview.text].length\n return (\n <Panel className=\"px-4 py-3\">\n <div className=\"flex gap-3\">\n <span className={`flex size-10 shrink-0 items-center justify-center rounded-full text-base font-semibold ${x ? 'bg-foreground text-background' : 'bg-[#0a66c2] text-white'}`}>\n {initial(account)}\n </span>\n <div className=\"min-w-0 flex-1\">\n <p className=\"flex flex-wrap items-baseline gap-x-1.5 text-sm\">\n <span className=\"font-semibold text-foreground\">{account ?? 'Your account'}</span>\n <span className=\"text-muted-foreground\">{x ? '· now' : '· Post · Anyone'}</span>\n </p>\n <p className={`mt-1 whitespace-pre-wrap break-words text-foreground ${x ? 'text-base leading-6' : 'text-sm leading-6'}`}>{preview.text}</p>\n {preview.link && (\n <div className=\"mt-3 overflow-hidden rounded-lg border border-border\">\n <div className=\"px-3 py-2\">\n <p className=\"truncate text-sm text-muted-foreground\">{preview.link.url.replace(/^https?:\\/\\//, '')}</p>\n {preview.link.title && <p className=\"truncate text-sm font-semibold text-foreground\">{preview.link.title}</p>}\n {preview.link.description && <p className=\"line-clamp-2 text-sm text-muted-foreground\">{preview.link.description}</p>}\n </div>\n </div>\n )}\n </div>\n </div>\n {x && (\n <p className={`mt-2 text-right text-sm tabular-nums ${length > 280 ? 'text-[var(--surface-danger-text)]' : 'text-muted-foreground'}`}>\n {length} / 280\n </p>\n )}\n </Panel>\n )\n}\n\nfunction PaymentPreview({ preview }: { preview: Extract<HubActionPreview, { kind: 'payment' }> }) {\n return (\n <Panel className=\"px-4 py-3\">\n <p className=\"text-sm text-muted-foreground\">{preview.label.charAt(0).toUpperCase() + preview.label.slice(1)}</p>\n {preview.amount !== undefined && (\n <p className=\"mt-0.5 text-2xl font-semibold tabular-nums text-foreground\">{formatMinorAmount(preview.amount, preview.currency)}</p>\n )}\n <div className=\"mt-2 space-y-1 text-sm\">\n {preview.customer && (\n <p className=\"text-muted-foreground\">Customer <span className={`text-foreground ${preview.customer.startsWith('cus_') ? 'font-mono' : ''}`}>{preview.customer}</span></p>\n )}\n {preview.description && <p className=\"text-foreground\">{preview.description}</p>}\n </div>\n </Panel>\n )\n}\n\nfunction SpeechPreview({ preview }: { preview: Extract<HubActionPreview, { kind: 'speech' }> }) {\n return (\n <Panel className=\"px-4 py-3\">\n <blockquote className=\"border-l-2 border-[var(--accent-text)] pl-3 text-base leading-7 text-foreground\">{preview.text}</blockquote>\n {(preview.voice || preview.seconds) && (\n <div className=\"mt-3 flex flex-wrap gap-2\">\n {preview.voice && <Chip>Voice: {preview.voice}</Chip>}\n {preview.seconds && <Chip>About {preview.seconds} s</Chip>}\n </div>\n )}\n </Panel>\n )\n}\n\nfunction CallPreview({ preview }: { preview: Extract<HubActionPreview, { kind: 'call' }> }) {\n return (\n <Panel className=\"flex gap-3 px-4 py-3\">\n <span className=\"flex size-10 shrink-0 items-center justify-center rounded-full bg-muted\"><Phone aria-hidden className=\"size-5 text-foreground\" /></span>\n <div className=\"min-w-0 space-y-1 text-sm\">\n <p className=\"text-base font-semibold tabular-nums text-foreground\">{preview.to ?? 'Unknown number'}</p>\n {preview.from && <p className=\"text-muted-foreground\">From <span className=\"tabular-nums text-foreground\">{preview.from}</span></p>}\n {preview.purpose && <p className=\"leading-6 text-foreground\">{preview.purpose}</p>}\n </div>\n </Panel>\n )\n}\n\nfunction EventPreview({ preview }: { preview: Extract<HubActionPreview, { kind: 'event' }> }) {\n const start = preview.start ? new Date(preview.start) : null\n const valid = start && !Number.isNaN(start.getTime())\n return (\n <Panel className=\"flex gap-4 px-4 py-3\">\n <div className=\"flex w-14 shrink-0 flex-col items-center overflow-hidden rounded-lg border border-border text-center\">\n <span className=\"w-full bg-[var(--surface-danger-bg)] py-0.5 text-sm font-semibold uppercase text-[var(--surface-danger-text)]\">\n {valid ? start!.toLocaleDateString(undefined, { month: 'short' }) : <CalendarDays aria-hidden className=\"mx-auto size-4\" />}\n </span>\n <span className=\"py-1 text-xl font-semibold tabular-nums text-foreground\">{valid ? start!.getDate() : '–'}</span>\n </div>\n <div className=\"min-w-0 space-y-1 text-sm\">\n <p className=\"text-base font-semibold text-foreground\">{preview.title ?? 'Untitled event'}</p>\n {preview.start && <p className=\"text-foreground\">{formatWhen(preview.start, preview.end)}</p>}\n {preview.location && <p className=\"flex items-center gap-1.5 text-muted-foreground\"><MapPin aria-hidden className=\"size-4 shrink-0\" />{preview.location}</p>}\n {preview.attendees.length > 0 && (\n <p className=\"flex items-start gap-1.5 text-muted-foreground\"><Users aria-hidden className=\"mt-0.5 size-4 shrink-0\" /><span className=\"break-words\">{preview.attendees.join(', ')}</span></p>\n )}\n {preview.description && <p className=\"line-clamp-3 leading-6 text-foreground\">{preview.description}</p>}\n </div>\n </Panel>\n )\n}\n\n/**\n * What a held call will do, drawn the way its integration shows it: a pull\n * request with its branch and file changes, an email, a post in the channel's\n * style, a payment, a voice memo, a call or a calendar event. Any other action\n * lists its input fields.\n */\nexport function HubActionPreviewView({ preview, account }: { preview: HubActionPreview; account?: string | null }) {\n switch (preview.kind) {\n case 'pull-request':\n return <PullRequestPreview preview={preview} />\n case 'files':\n return preview.files.length > 0 ? <ApprovalDiffSummary files={preview.files} /> : null\n case 'commit':\n return (\n <Panel className=\"px-3 py-3\">\n <p className=\"flex items-center gap-2 text-sm text-muted-foreground\">\n <GitCommitHorizontal aria-hidden className=\"size-4 shrink-0\" />\n {preview.repository ?? 'Commit'}\n </p>\n {preview.message && <p className=\"mt-2 whitespace-pre-line text-sm leading-6 text-foreground\">{preview.message}</p>}\n <div className=\"mt-2\"><HubFieldList fields={[\n ...(preview.tree ? [{ label: 'Tree', value: preview.tree.slice(0, 7), mono: true }] : []),\n ...preview.parents.map((parent) => ({ label: 'Parent', value: parent.slice(0, 7), mono: true })),\n ]} /></div>\n </Panel>\n )\n case 'branch':\n return (\n <Panel className=\"flex flex-wrap items-center gap-2 px-3 py-3 text-sm\">\n <GitBranch aria-hidden className=\"size-4 shrink-0 text-muted-foreground\" />\n {preview.branch && <Chip mono>{preview.branch}</Chip>}\n {preview.sha && <span className=\"text-muted-foreground\">at <span className=\"font-mono text-foreground\">{preview.sha.slice(0, 7)}</span></span>}\n </Panel>\n )\n case 'issue':\n return (\n <Panel className=\"px-3 py-3\">\n {preview.verdict && <p className=\"text-sm font-medium capitalize text-foreground\">{preview.verdict}</p>}\n {preview.title && <p className=\"text-base font-semibold leading-6 text-foreground\">{preview.title}</p>}\n {preview.body && <p className=\"mt-1 line-clamp-6 whitespace-pre-line text-sm leading-6 text-foreground\">{preview.body}</p>}\n </Panel>\n )\n case 'email':\n return <EmailPreview preview={preview} account={account} />\n case 'post':\n return <PostPreview preview={preview} account={account} />\n case 'payment':\n return <PaymentPreview preview={preview} />\n case 'speech':\n return <SpeechPreview preview={preview} />\n case 'call':\n return <CallPreview preview={preview} />\n case 'event':\n return <EventPreview preview={preview} />\n case 'fields':\n return preview.fields.length > 0 ? <Panel className=\"px-3 py-3\"><HubFieldList fields={preview.fields} /></Panel> : null\n }\n}\n","import { useEffect, useState } from 'react'\nimport { ChevronRight, ShieldCheck } from 'lucide-react'\nimport { Button } from '@tangle-network/ui/primitives'\n\nimport { hubActionReceipt, presentHubAction, type HubApprovalItem, type HubApprovalPhase } from '../hub-approvals'\nimport { closesIn, HubApprovalPhasePill, HubProviderMark, relativeTime } from './parts'\n\nconst GROUPS: ReadonlyArray<{ id: string; label: string; phases: readonly HubApprovalPhase[] }> = [\n { id: 'waiting', label: 'Waiting', phases: ['waiting', 'blocked'] },\n { id: 'running', label: 'Running', phases: ['queued', 'running'] },\n { id: 'failed', label: 'Failed', phases: ['failed'] },\n { id: 'done', label: 'Done', phases: ['done'] },\n { id: 'closed', label: 'Denied or expired', phases: ['denied', 'expired'] },\n]\n\nexport interface HubApprovalsListProps {\n items: readonly HubApprovalItem[]\n /** Show one call: scroll to it in the conversation and open its detail. */\n onSelect?: (item: HubApprovalItem) => void\n selectedId?: string | null\n className?: string\n}\n\n/**\n * Every held call in the conversation, grouped by where it stands — waiting,\n * running, failed, done, then denied or expired — and updated as the host's\n * items change. Picking one hands it to `onSelect`.\n */\nexport function HubApprovalsList({ items, onSelect, selectedId, className = '' }: HubApprovalsListProps) {\n const [now, setNow] = useState(() => Date.now())\n useEffect(() => {\n const timer = setInterval(() => setNow(Date.now()), 30_000)\n return () => clearInterval(timer)\n }, [])\n const waiting = items.filter((item) => item.phase === 'waiting' || item.phase === 'blocked').length\n const groups = GROUPS\n .map((group) => ({ ...group, items: items.filter((item) => group.phases.includes(item.phase)).slice().reverse() }))\n .filter((group) => group.items.length > 0)\n\n return (\n <div className={`flex h-full min-h-0 flex-col ${className}`}>\n <div className=\"shrink-0 border-b border-border px-4 py-3\">\n <h2 className=\"text-base font-semibold text-foreground\">Approvals</h2>\n <p className=\"text-sm text-muted-foreground\" aria-live=\"polite\">\n {waiting === 0 ? 'Nothing is waiting for you' : waiting === 1 ? '1 request is waiting' : `${waiting} requests are waiting`}\n </p>\n </div>\n {groups.length === 0 ? (\n <div className=\"flex flex-1 flex-col items-center justify-center gap-2 px-6 py-10 text-center\">\n <span className=\"flex size-10 items-center justify-center rounded-xl bg-muted\"><ShieldCheck aria-hidden className=\"size-5 text-muted-foreground\" /></span>\n <p className=\"text-sm font-medium text-foreground\">No approvals in this conversation</p>\n <p className=\"text-sm text-muted-foreground\">Requests to act on your connected accounts appear here.</p>\n </div>\n ) : (\n <div className=\"min-h-0 flex-1 space-y-5 overflow-y-auto px-2 py-3\">\n {groups.map((group) => (\n <section key={group.id} aria-label={group.label}>\n <h3 className=\"px-2 pb-1 text-sm font-medium text-muted-foreground\">\n {group.label} <span className=\"tabular-nums\">· {group.items.length}</span>\n </h3>\n <ul className=\"space-y-1\">\n {group.items.map((item) => {\n const presentation = presentHubAction(item)\n const title = item.phase === 'done' ? hubActionReceipt(item).title : presentation.title\n const when = item.phase === 'waiting' ? closesIn(item.expiresAt, now) ?? relativeTime(item.requestedAt, now) : relativeTime(item.requestedAt, now)\n const detail = [presentation.provider.name, item.account, when].filter(Boolean).join(' · ')\n const selected = selectedId === item.id\n return (\n <li key={item.id}>\n <Button\n variant=\"bare\"\n onClick={() => onSelect?.(item)}\n aria-current={selected ? 'true' : undefined}\n className={`flex w-full items-start gap-3 rounded-lg px-2 py-2.5 text-left transition-colors hover:bg-muted ${selected ? 'bg-muted' : ''}`}\n >\n <HubProviderMark providerId={presentation.provider.id} name={presentation.provider.name} size={28} />\n <span className=\"min-w-0 flex-1\">\n <span className=\"line-clamp-2 text-sm font-medium leading-5 text-foreground\">{title}</span>\n <span className=\"mt-0.5 block truncate text-sm text-muted-foreground\">{detail}</span>\n </span>\n <span className=\"flex shrink-0 items-center gap-1\">\n <HubApprovalPhasePill phase={item.phase} label={item.phase === 'waiting' ? 'Waiting' : item.phase === 'blocked' ? 'Owner' : undefined} />\n <ChevronRight aria-hidden className=\"size-4 text-muted-foreground\" />\n </span>\n </Button>\n </li>\n )\n })}\n </ul>\n </section>\n ))}\n </div>\n )}\n </div>\n )\n}\n","import { useEffect, useRef, useState, type ReactNode } from 'react'\nimport { ChevronDown } from 'lucide-react'\nimport { Button } from '@tangle-network/ui/primitives'\n\nimport { hubActionReceipt, presentHubAction, type HubApprovalItem } from '../hub-approvals'\nimport { HubApprovalPhasePill, HubProviderMark, HubRawDetails } from './parts'\nimport { HubActionPreviewView } from './preview'\nimport { HubActionReceiptCard } from './receipt'\n\nexport interface HubApprovalRowProps {\n item: HubApprovalItem\n /** Open the detail, e.g. when the call was picked in the Approvals list. */\n expanded?: boolean\n onExpandedChange?: (expanded: boolean) => void\n /** Bring a waiting call to the front of the dock. */\n onReview?: (item: HubApprovalItem) => void\n /** Extra controls for a call no one can decide any more, e.g. asking the agent again. */\n actions?: ReactNode\n}\n\n/**\n * A held call where the agent made it: one line with the integration, what\n * the call does and where it stands, opening to its preview, result and the\n * exact call. The decision itself lives in the dock, so the transcript stays\n * readable while a request waits.\n */\nexport function HubApprovalRow({ item, expanded: controlled, onExpandedChange, onReview, actions }: HubApprovalRowProps) {\n const [own, setOwn] = useState(false)\n const expanded = controlled ?? own\n const ref = useRef<HTMLDivElement>(null)\n const presentation = presentHubAction(item)\n const title = item.phase === 'done' ? hubActionReceipt(item).title : presentation.title\n\n useEffect(() => {\n if (controlled) ref.current?.scrollIntoView({ block: 'center', behavior: 'smooth' })\n }, [controlled])\n\n const toggle = () => {\n setOwn(!expanded)\n onExpandedChange?.(!expanded)\n }\n\n return (\n <div ref={ref} data-hub-approval-row={item.id} className={`rounded-xl border bg-card ${expanded ? 'border-border shadow-sm' : 'border-border/80'}`}>\n <div className=\"flex items-center gap-3 px-3 py-2\">\n <Button\n variant=\"bare\"\n aria-expanded={expanded}\n onClick={toggle}\n className=\"flex min-h-9 min-w-0 flex-1 items-center gap-3 rounded-md text-left\"\n >\n <HubProviderMark providerId={presentation.provider.id} name={presentation.provider.name} size={24} />\n <span className=\"min-w-0 flex-1 truncate text-sm font-medium text-foreground\">{title}</span>\n <HubApprovalPhasePill phase={item.phase} />\n <ChevronDown aria-hidden className={`size-4 shrink-0 text-muted-foreground transition-transform ${expanded ? 'rotate-180' : ''}`} />\n </Button>\n {item.phase === 'waiting' && onReview && (\n <Button variant=\"outline\" onClick={() => onReview(item)}>Review</Button>\n )}\n </div>\n {expanded && (\n <div className=\"space-y-3 border-t border-border px-3 pb-3 pt-3\">\n {item.phase === 'done' || item.phase === 'failed'\n ? <HubActionReceiptCard item={item} className=\"border-0 px-0 py-0 shadow-none\" />\n : (\n <>\n <HubActionPreviewView preview={presentation.preview} account={item.account} />\n <HubRawDetails sections={[{ label: 'Call', value: { action: item.actionPath, input: item.input } }]} />\n </>\n )}\n {actions}\n </div>\n )}\n {!expanded && actions && (item.phase === 'expired' || item.phase === 'failed') && (\n <div className=\"border-t border-border px-3 py-2\">{actions}</div>\n )}\n </div>\n )\n}\n","import { useState } from 'react'\nimport { ExternalLink } from 'lucide-react'\nimport { ApprovalDiffSummary } from '@tangle-network/ui/run'\n\nimport { hubActionReceipt, presentHubAction, type HubApprovalItem, type HubApprovalPhase } from '../hub-approvals'\nimport { HubApprovalPhasePill, HubFieldList, HubProviderMark, HubRawDetails } from './parts'\n\nfunction AudioPlayer({ src }: { src: string }) {\n const [failed, setFailed] = useState(false)\n if (failed) return <p className=\"text-sm text-muted-foreground\">The audio link has expired. Ask the agent for a new one.</p>\n // The memo is generated speech with its text shown beside it, so it carries no caption track.\n // eslint-disable-next-line jsx-a11y/media-has-caption\n return <audio controls preload=\"metadata\" src={src} onError={() => setFailed(true)} className=\"h-10 w-full\" />\n}\n\nexport interface HubActionReceiptCardProps {\n item: HubApprovalItem\n className?: string\n}\n\n/**\n * What one decided Hub action did: the integration's logo, the result in plain\n * words with its link, the key fields, a player or file changes when the\n * result has them, and the exact call and result behind Details.\n */\nexport function HubActionReceiptCard({ item, className = '' }: HubActionReceiptCardProps) {\n const receipt = hubActionReceipt(item)\n const presentation = presentHubAction(item)\n const subtitle = [receipt.provider.name, item.account ? `as ${item.account}` : null, presentation.target && !receipt.title.includes(presentation.target) ? presentation.target : null]\n .filter(Boolean).join(' · ')\n const phase: HubApprovalPhase = item.phase\n return (\n <article aria-label={receipt.title} className={`rounded-xl border border-border bg-card px-4 py-3 shadow-sm ${className}`}>\n <div className=\"flex items-start gap-3\">\n <HubProviderMark providerId={receipt.provider.id} name={receipt.provider.name} />\n <div className=\"min-w-0 flex-1\">\n <p className=\"text-base font-semibold leading-6 text-foreground\">\n {receipt.href\n ? (\n <a href={receipt.href} target=\"_blank\" rel=\"noreferrer\" className=\"inline-flex max-w-full items-center gap-1.5 hover:underline\">\n <span className=\"truncate\">{receipt.title}</span>\n <ExternalLink aria-hidden className=\"size-4 shrink-0 text-muted-foreground\" />\n </a>\n )\n : <span className=\"break-words\">{receipt.title}</span>}\n </p>\n {subtitle && <p className=\"truncate text-sm text-muted-foreground\">{subtitle}</p>}\n </div>\n <HubApprovalPhasePill phase={phase} />\n </div>\n {(receipt.fields.length > 0 || receipt.media || receipt.files || receipt.error) && (\n <div className=\"mt-3 space-y-3\">\n <HubFieldList fields={receipt.fields} />\n {receipt.media && <AudioPlayer src={receipt.media.src} />}\n {receipt.files && <ApprovalDiffSummary files={receipt.files} />}\n {receipt.error && (\n <p className=\"break-words rounded-lg border border-[var(--surface-danger-border)] bg-[var(--surface-danger-bg)] px-3 py-2 text-sm text-[var(--surface-danger-text)]\">\n {receipt.error}\n </p>\n )}\n </div>\n )}\n {(item.grant || item.autoApproved) && (\n <p className=\"mt-3 text-sm text-muted-foreground\">\n {item.autoApproved ?? `Allowed ${item.grant?.expiresAt ? 'for 24 hours' : 'from now on'}: ${item.grant?.scope}`}\n </p>\n )}\n <div className=\"mt-2\">\n <HubRawDetails sections={[\n { label: 'Call', value: { action: item.actionPath, input: item.input } },\n { label: 'Result', value: item.result },\n ]} />\n </div>\n </article>\n )\n}\n\nexport interface HubApprovalReceiptsProps {\n items: readonly HubApprovalItem[]\n /** The message the agent received, shown behind Details so nothing it read is hidden. */\n message?: string\n /** When the decisions were sent. */\n at?: string | Date | null\n}\n\n/**\n * The receipts that stand in for the message resuming the agent after a\n * decision. The agent gets that message unchanged; the transcript shows what\n * happened instead of the machine prompt.\n */\nexport function HubApprovalReceipts({ items, message, at }: HubApprovalReceiptsProps) {\n const decided = items.filter((item) => item.phase !== 'waiting' && item.phase !== 'blocked')\n const count = (phases: readonly HubApprovalPhase[]) => decided.filter((item) => phases.includes(item.phase)).length\n const actions = (n: number) => (n === 1 ? '1 action' : `${n} actions`)\n const approved = count(['queued', 'running', 'done', 'failed'])\n const denied = count(['denied'])\n const expired = count(['expired'])\n const verbs = [approved ? `approved ${actions(approved)}` : null, denied ? `denied ${actions(denied)}` : null].filter(Boolean)\n const summary = verbs.length\n ? `You ${verbs.join(' and ')}${expired ? `; ${actions(expired)} expired` : ''}`\n : expired ? `${actions(expired)} expired` : 'Your decisions'\n const when = at ? new Date(at) : null\n return (\n <section aria-label=\"Approval results\" className=\"space-y-2\">\n <p className=\"flex items-center gap-2 text-sm text-muted-foreground\">\n <span>{summary}</span>\n {when && !Number.isNaN(when.getTime()) && (\n <time dateTime={when.toISOString()}>· {when.toLocaleTimeString(undefined, { hour: 'numeric', minute: '2-digit' })}</time>\n )}\n </p>\n {decided.map((item) => <HubActionReceiptCard key={item.id} item={item} />)}\n {message && <HubRawDetails sections={[{ label: 'Message sent to the agent', value: message }]} />}\n </section>\n )\n}\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,WAAW,SAAS,QAAQ,YAAAA,iBAAgB;AACrD,SAAS,OAAO,aAAa,aAAa,gBAAAC,eAAc,cAAc,SAAS,SAAS;AACxF,SAAS,UAAAC,SAAQ,OAAO,YAAY,sBAAsB;;;ACF1D,SAAS,gBAAgC;AACzC,SAAS,oBAAoB;AAC7B,SAAS,oBAAoB;AAC7B,SAAS,QAAQ,kBAAmC;AAkBhD,cA0BE,YA1BF;AAdJ,IAAM,cAAoD;AAAA,EACxD,SAAS;AAAA,EACT,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AACX;AAGO,SAAS,qBAAqB,EAAE,OAAO,MAAM,GAAgD;AAClG,SACE,oBAAC,cAAW,MAAM,YAAY,KAAK,GAAG,MAAK,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AC,KAAC,wBAAqB,SAAS,aAAa,SAAS,SAAS,KAAK,SAAS;AAAA,QAC5E,gBAAAA,KAAC,iBAAc,UAAU,CAAC,EAAE,OAAO,QAAQ,OAAO,EAAE,QAAQ,KAAK,YAAY,OAAO,KAAK,MAAM,EAAE,CAAC,GAAG;AAAA,SACvG;AAAA,MAEL;AAAA,OACH;AAAA,IAED,CAAC,YAAY,YAAY,KAAK,UAAU,aAAa,KAAK,UAAU,aACnE,gBAAAA,KAAC,SAAI,WAAU,oCAAoC,mBAAQ;AAAA,KAE/D;AAEJ;","names":["useState","ChevronRight","Button","jsx","jsxs","jsx","jsxs","useState","Button","ChevronRight","useEffect","useState","ChevronRight","Button","jsx","jsxs","useState","useEffect","Button","ChevronRight","useEffect","useRef","useState","ChevronDown","Button","useState","ExternalLink","ApprovalDiffSummary","jsx","jsxs","useState","ExternalLink","ApprovalDiffSummary","Fragment","jsx","jsxs","useState","useRef","useEffect","Button","ChevronDown"]}
|
|
1
|
+
{"version":3,"sources":["../../src/hub-approvals-react/dock.tsx","../../src/hub-approvals-react/parts.tsx","../../src/hub-approvals-react/preview.tsx","../../src/hub-approvals-react/list.tsx","../../src/hub-approvals-react/row.tsx","../../src/hub-approvals-react/receipt.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from 'react'\nimport { Check, ChevronDown, ChevronLeft, ChevronRight, ExternalLink, Loader2, X } from 'lucide-react'\nimport { Button, Label, RadioGroup, RadioGroupItem } from '@tangle-network/ui/primitives'\n\nimport {\n HUB_APPROVAL_ACTIVE_PHASES,\n HUB_APPROVAL_OPEN_PHASES,\n hubActionReceipt,\n presentHubAction,\n type HubApprovalItem,\n type HubApprovalPhase,\n} from '../hub-approvals'\nimport { closesIn, distinctAccount, HubProviderMark, HubRawDetails } from './parts'\nimport { HubActionPreviewView } from './preview'\n\n/** The owner's answer to one held call. `allow` also grants a standing permission. */\nexport type HubApprovalDecision =\n | { kind: 'approve' }\n | { kind: 'deny' }\n | { kind: 'allow'; duration: '24h' | 'always'; scope: string }\n\n/** What a standing permission for one call may cover, or why none can. */\nexport type HubApprovalPermissions =\n | { scopes: ReadonlyArray<{ id: string; label: string }> }\n | { never: string }\n\nexport interface HubApprovalDockProps {\n /** Every held call in the conversation; the dock shows the open and running ones. */\n items: readonly HubApprovalItem[]\n onDecide: (item: HubApprovalItem, decision: HubApprovalDecision) => Promise<void>\n /** Standing-permission choices for a call; omit when the host offers none. */\n permissions?: (item: HubApprovalItem) => HubApprovalPermissions | null\n /** Show the call where the agent made it. */\n onOpen?: (item: HubApprovalItem) => void\n /** Bring one call to the front, e.g. after it was picked in the Approvals list. */\n focusId?: string | null\n className?: string\n}\n\n/** How long a finished call stays in the dock, so its result is seen where it was approved. */\nconst DONE_VISIBLE_MS = 6_000\n\nfunction useNow(intervalMs: number) {\n const [now, setNow] = useState(() => Date.now())\n useEffect(() => {\n const timer = setInterval(() => setNow(Date.now()), intervalMs)\n return () => clearInterval(timer)\n }, [intervalMs])\n return now\n}\n\nfunction Progress({ item }: { item: HubApprovalItem }) {\n const provider = presentHubAction(item).provider.name\n if (item.phase === 'queued' || item.phase === 'running') {\n return (\n <p role=\"status\" className=\"flex items-center gap-2 text-sm font-medium text-foreground\">\n <Loader2 aria-hidden className=\"size-4 animate-spin text-[var(--surface-info-text)]\" />\n {item.phase === 'queued' ? 'Approved. It runs when the agent’s turn finishes…' : `Running on ${provider}…`}\n </p>\n )\n }\n if (item.phase === 'done') {\n const receipt = hubActionReceipt(item)\n return (\n <p role=\"status\" className=\"flex min-w-0 items-center gap-2 text-sm font-medium text-foreground\">\n <Check aria-hidden className=\"size-4 shrink-0 text-[var(--surface-success-text)]\" />\n {receipt.href\n ? <a href={receipt.href} target=\"_blank\" rel=\"noreferrer\" className=\"inline-flex min-w-0 items-center gap-1 hover:underline\"><span className=\"truncate\">{receipt.title}</span><ExternalLink aria-hidden className=\"size-4 shrink-0 text-muted-foreground\" /></a>\n : <span className=\"truncate\">{receipt.title}</span>}\n </p>\n )\n }\n if (item.phase === 'failed') {\n return (\n <p role=\"alert\" className=\"break-words text-sm text-[var(--surface-danger-text)]\">\n {hubActionReceipt(item).title}{item.error ? `: ${item.error}` : '.'}\n </p>\n )\n }\n return null\n}\n\n/**\n * The calls waiting on the owner, pinned above the composer so a held action\n * never scrolls away. Each shows what it does, where, as which account, and a\n * preview drawn like its integration; Approve, Deny and the standing\n * permissions a host offers sit beside it. Approving shows the run in place —\n * starting, running, then the result — without leaving the conversation.\n */\nexport function HubApprovalDock({ items, onDecide, permissions, onOpen, focusId, className = '' }: HubApprovalDockProps) {\n const now = useNow(30_000)\n // Calls that finished while this dock watched them stay with their result: a\n // success briefly, a failure until dismissed. One that failed before the dock\n // mounted shows in the transcript row, the Approvals list and its receipt.\n const watched = useRef(new Map<string, HubApprovalPhase>())\n const [settled, setSettled] = useState<Record<string, number>>({})\n const [dismissed, setDismissed] = useState<ReadonlySet<string>>(new Set())\n const [submitting, setSubmitting] = useState<{ id: string; label: string } | null>(null)\n const [error, setError] = useState<{ id: string; message: string } | null>(null)\n const [activeId, setActiveId] = useState<string | null>(null)\n const [collapsed, setCollapsed] = useState(false)\n const [permissionsOpen, setPermissionsOpen] = useState(false)\n const [scope, setScope] = useState<string | null>(null)\n\n useEffect(() => {\n const finishedNow: Record<string, number> = {}\n for (const item of items) {\n const before = watched.current.get(item.id)\n const wasLive = before !== undefined && (HUB_APPROVAL_OPEN_PHASES.has(before) || HUB_APPROVAL_ACTIVE_PHASES.has(before))\n if (wasLive && (item.phase === 'done' || item.phase === 'failed')) finishedNow[item.id] = Date.now()\n watched.current.set(item.id, item.phase)\n }\n if (Object.keys(finishedNow).length > 0) setSettled((current) => ({ ...current, ...finishedNow }))\n }, [items])\n\n useEffect(() => {\n const doneIds = Object.entries(settled).filter(([id]) => items.find((item) => item.id === id)?.phase === 'done')\n if (doneIds.length === 0) return\n const oldest = Math.min(...doneIds.map(([, at]) => at))\n const timer = setTimeout(() => {\n const cutoff = Date.now() - DONE_VISIBLE_MS\n setSettled((current) => Object.fromEntries(Object.entries(current).filter(([id, at]) => at > cutoff || items.find((item) => item.id === id)?.phase !== 'done')))\n }, Math.max(0, oldest + DONE_VISIBLE_MS - Date.now()))\n return () => clearTimeout(timer)\n }, [settled, items])\n\n const queue = useMemo(() => items.filter((item) => !dismissed.has(item.id) && (\n HUB_APPROVAL_OPEN_PHASES.has(item.phase)\n || HUB_APPROVAL_ACTIVE_PHASES.has(item.phase)\n || item.id in settled\n || submitting?.id === item.id\n )), [items, dismissed, settled, submitting])\n\n useEffect(() => {\n if (focusId && queue.some((item) => item.id === focusId)) {\n setActiveId(focusId)\n setCollapsed(false)\n }\n }, [focusId, queue])\n\n const activeIndex = Math.max(0, queue.findIndex((item) => item.id === activeId))\n const active = queue[activeIndex]\n\n // When the shown call finishes and its result has been seen, move to the next one waiting.\n useEffect(() => {\n if (!active || activeId === active.id) return\n setActiveId(active.id)\n }, [active, activeId])\n useEffect(() => {\n setPermissionsOpen(false)\n setScope(null)\n }, [active?.id])\n\n if (!active) return null\n const presentation = presentHubAction(active)\n const waitingCount = queue.filter((item) => HUB_APPROVAL_OPEN_PHASES.has(item.phase)).length\n const choices = permissions?.(active) ?? null\n const scopes = choices && 'scopes' in choices ? choices.scopes : []\n const chosenScope = scope ?? scopes[0]?.id ?? null\n const busy = submitting?.id === active.id\n const decidable = active.phase === 'waiting' && !busy\n const closing = active.phase === 'waiting' ? closesIn(active.expiresAt, now) : null\n const account = distinctAccount(active.account, presentation.provider.name)\n const subtitle = [presentation.provider.name, account ? `as ${account}` : null, closing].filter(Boolean).join(' · ')\n\n async function decide(decision: HubApprovalDecision, label: string) {\n if (!active || submitting) return\n setSubmitting({ id: active.id, label })\n setError(null)\n try {\n await onDecide(active, decision)\n } catch (cause) {\n setError({ id: active.id, message: cause instanceof Error ? cause.message : 'The decision did not go through. Try again.' })\n } finally {\n setSubmitting(null)\n }\n }\n\n const step = (delta: number) => {\n const next = queue[(activeIndex + delta + queue.length) % queue.length]\n if (next) setActiveId(next.id)\n }\n\n return (\n <section\n aria-label=\"Waiting for your approval\"\n data-hub-approval-dock={active.id}\n className={`overflow-hidden rounded-2xl border border-[var(--surface-warning-border)] bg-card shadow-md ${className}`}\n >\n <div className=\"flex items-start gap-3 px-4 pt-3\">\n <HubProviderMark providerId={presentation.provider.id} name={presentation.provider.name} size={32} />\n <div className=\"min-w-0 flex-1\">\n <h3 className=\"line-clamp-2 break-words text-base font-semibold leading-6 text-foreground\" title={presentation.title}>{presentation.title}</h3>\n <p className=\"truncate text-sm text-muted-foreground\">{subtitle}</p>\n </div>\n <div className=\"flex shrink-0 items-center gap-1\">\n {queue.length > 1 && (\n <>\n <Button variant=\"ghost\" size=\"icon-sm\" aria-label=\"Previous request\" onClick={() => step(-1)}><ChevronLeft /></Button>\n <span className=\"min-w-14 text-center text-sm tabular-nums text-muted-foreground\" aria-live=\"polite\">\n {activeIndex + 1} of {queue.length}\n </span>\n <Button variant=\"ghost\" size=\"icon-sm\" aria-label=\"Next request\" onClick={() => step(1)}><ChevronRight /></Button>\n </>\n )}\n <Button\n variant=\"ghost\"\n size=\"icon-sm\"\n aria-label={collapsed ? 'Show the request' : 'Hide the preview'}\n aria-expanded={!collapsed}\n onClick={() => setCollapsed((value) => !value)}\n >\n <ChevronDown className={`transition-transform ${collapsed ? '-rotate-90' : ''}`} />\n </Button>\n </div>\n </div>\n\n {!collapsed && (\n <div className=\"max-h-64 space-y-3 overflow-y-auto px-4 pt-3 sm:max-h-96\">\n {active.bundle?.steps && active.bundle.steps.length > 0 && (\n <ol className=\"space-y-1 text-sm\" aria-label=\"Steps this approval covers\">\n {active.bundle.steps.map((stepItem, index) => (\n <li key={index} className={`flex items-center gap-2 ${stepItem.state === 'current' ? 'font-medium text-foreground' : 'text-muted-foreground'}`}>\n <span className={`flex size-5 shrink-0 items-center justify-center rounded-full border text-sm tabular-nums ${stepItem.state === 'done' ? 'border-transparent bg-[var(--surface-success-bg)] text-[var(--surface-success-text)]' : 'border-border'}`}>\n {stepItem.state === 'done' ? <Check aria-hidden className=\"size-3.5\" /> : index + 1}\n </span>\n {stepItem.label}\n </li>\n ))}\n </ol>\n )}\n <HubActionPreviewView preview={presentation.preview} account={active.account} />\n <HubRawDetails sections={[{ label: 'Call', value: { action: active.actionPath, input: active.input } }]} />\n </div>\n )}\n\n <div className=\"space-y-3 px-4 pb-4 pt-3\">\n {busy && submitting && !HUB_APPROVAL_ACTIVE_PHASES.has(active.phase) && active.phase === 'waiting' && (\n <p role=\"status\" className=\"flex items-center gap-2 text-sm font-medium text-foreground\">\n <Loader2 aria-hidden className=\"size-4 animate-spin text-[var(--surface-info-text)]\" />\n {submitting.label}\n </p>\n )}\n <Progress item={active} />\n {error?.id === active.id && <p role=\"alert\" className=\"text-sm text-[var(--surface-danger-text)]\">{error.message}</p>}\n {active.phase === 'blocked' && <p className=\"text-sm text-muted-foreground\">The workspace owner approves this request.</p>}\n\n {decidable && permissionsOpen && scopes.length > 0 && (\n <fieldset className=\"space-y-2 rounded-xl border border-border bg-muted/30 px-3 py-3\">\n <legend className=\"sr-only\">Standing permission</legend>\n {scopes.length > 1 && (\n <RadioGroup\n aria-label=\"What the permission covers\"\n value={chosenScope ?? undefined}\n onValueChange={setScope}\n className=\"gap-1.5\"\n >\n {scopes.map((option) => (\n <div key={option.id} className=\"flex min-h-8 items-center gap-2\">\n <RadioGroupItem id={`hub-scope-${active.id}-${option.id}`} value={option.id} />\n <Label htmlFor={`hub-scope-${active.id}-${option.id}`} className=\"cursor-pointer text-sm font-normal text-foreground\">{option.label}</Label>\n </div>\n ))}\n </RadioGroup>\n )}\n {scopes.length === 1 && <p className=\"text-sm text-foreground\">{scopes[0]?.label}</p>}\n <div className=\"flex flex-wrap gap-2\">\n <Button variant=\"outline\" onClick={() => chosenScope && void decide({ kind: 'allow', duration: '24h', scope: chosenScope }, 'Approving and allowing for 24 hours…')}>\n Approve and allow for 24 hours\n </Button>\n <Button variant=\"outline\" onClick={() => chosenScope && void decide({ kind: 'allow', duration: 'always', scope: chosenScope }, 'Approving and allowing from now on…')}>\n Approve and always allow\n </Button>\n </div>\n </fieldset>\n )}\n\n <div className=\"flex flex-wrap items-center gap-2\">\n {decidable && (\n <>\n <Button onClick={() => void decide({ kind: 'approve' }, 'Approving…')}>Approve</Button>\n <Button variant=\"outline\" onClick={() => void decide({ kind: 'deny' }, 'Denying…')}>Deny</Button>\n {scopes.length > 0 && (\n <Button variant=\"ghost\" aria-expanded={permissionsOpen} onClick={() => setPermissionsOpen((value) => !value)}>\n {permissionsOpen ? 'Fewer options' : 'Allow future calls…'}\n </Button>\n )}\n </>\n )}\n {active.phase === 'failed' && (\n <Button variant=\"outline\" onClick={() => setDismissed((current) => new Set([...current, active.id]))}>\n <X aria-hidden /> Dismiss\n </Button>\n )}\n <span className=\"flex-1\" />\n {decidable && choices && 'never' in choices && (\n <span className=\"text-sm text-muted-foreground\">{choices.never}</span>\n )}\n {onOpen && (\n <Button variant=\"ghost\" onClick={() => onOpen(active)}>View in chat</Button>\n )}\n </div>\n {waitingCount > 0 && queue.length > 1 && active.phase !== 'waiting' && (\n <p className=\"text-sm text-muted-foreground\">{waitingCount === 1 ? '1 more request is waiting.' : `${waitingCount} more requests are waiting.`}</p>\n )}\n </div>\n </section>\n )\n}\n","import { useState, type ReactNode } from 'react'\nimport { ChevronRight } from 'lucide-react'\nimport { ProviderIcon } from '@tangle-network/sandbox-ui/integrations'\nimport { Button, StatusPill, type StatusTone } from '@tangle-network/ui/primitives'\n\nimport { HUB_APPROVAL_PHASE_LABELS, type HubApprovalPhase } from '../hub-approvals'\n\nconst PHASE_TONES: Record<HubApprovalPhase, StatusTone> = {\n waiting: 'warning',\n blocked: 'warning',\n queued: 'running',\n running: 'running',\n done: 'success',\n failed: 'danger',\n denied: 'neutral',\n expired: 'neutral',\n}\n\n/** A phase as a toned pill: glyph, colour and label. */\nexport function HubApprovalPhasePill({ phase, label }: { phase: HubApprovalPhase; label?: string }) {\n return (\n <StatusPill tone={PHASE_TONES[phase]} size=\"md\" className=\"shrink-0 whitespace-nowrap\">\n {label ?? HUB_APPROVAL_PHASE_LABELS[phase]}\n </StatusPill>\n )\n}\n\n/** The integration's own logo on a neutral tile, so dark marks stay legible. */\nexport function HubProviderMark({ providerId, name, size = 28 }: { providerId: string; name: string; size?: number }) {\n const inner = Math.round(size * 0.64)\n return (\n <span\n className=\"flex shrink-0 items-center justify-center rounded-lg border border-border bg-background\"\n style={{ width: size, height: size }}\n >\n <ProviderIcon id={providerId} displayName={name} size={inner} className=\"rounded-sm\" />\n </span>\n )\n}\n\n/** Raw JSON behind a disclosure, for the person who wants the exact call. */\nexport function HubRawDetails({ sections }: { sections: ReadonlyArray<{ label: string; value: unknown }> }) {\n const [open, setOpen] = useState(false)\n const shown = sections.filter((section) => section.value !== undefined && section.value !== null && section.value !== '')\n if (shown.length === 0) return null\n return (\n <div>\n <Button\n variant=\"bare\"\n aria-expanded={open}\n onClick={() => setOpen((value) => !value)}\n className=\"inline-flex min-h-8 items-center gap-1 rounded-md text-sm font-medium text-muted-foreground hover:text-foreground\"\n >\n <ChevronRight aria-hidden className={`size-4 transition-transform ${open ? 'rotate-90' : ''}`} />\n Details\n </Button>\n {open && (\n <div className=\"mt-2 space-y-3\">\n {shown.map((section) => (\n <div key={section.label} className=\"space-y-1\">\n <p className=\"text-sm font-medium text-muted-foreground\">{section.label}</p>\n <pre className=\"max-h-64 overflow-auto whitespace-pre-wrap break-all rounded-lg border border-border bg-muted/40 p-3 font-mono text-sm leading-5 text-foreground\">\n {typeof section.value === 'string' ? section.value : JSON.stringify(section.value, null, 2)}\n </pre>\n </div>\n ))}\n </div>\n )}\n </div>\n )\n}\n\n/** A `label value` list that wraps on a phone. */\nexport function HubFieldList({ fields }: { fields: ReadonlyArray<{ label: string; value: string; href?: string; mono?: boolean }> }) {\n if (fields.length === 0) return null\n return (\n <dl className=\"flex flex-wrap gap-x-6 gap-y-2 text-sm\">\n {fields.map((field) => (\n <div key={`${field.label}:${field.value}`} className=\"flex min-w-0 max-w-full items-baseline gap-2\">\n <dt className=\"shrink-0 text-muted-foreground\">{field.label}</dt>\n <dd className={`min-w-0 truncate text-foreground ${field.mono ? 'font-mono' : ''}`} title={field.value}>\n {field.href\n ? <a href={field.href} target=\"_blank\" rel=\"noreferrer\" className=\"text-[var(--accent-text)] underline-offset-2 hover:underline\">{field.value}</a>\n : field.value}\n </dd>\n </div>\n ))}\n </dl>\n )\n}\n\nexport function Chip({ children, mono }: { children: ReactNode; mono?: boolean }) {\n return (\n <span className={`inline-flex max-w-full items-center truncate rounded-md border border-border bg-muted/50 px-1.5 py-0.5 text-sm text-foreground ${mono ? 'font-mono' : ''}`}>\n {children}\n </span>\n )\n}\n\n/** The account worth naming: none when it only repeats the provider's name. */\nexport function distinctAccount(account: string | null | undefined, providerName: string): string | null {\n const value = account?.trim()\n return value && value.toLowerCase() !== providerName.toLowerCase() ? value : null\n}\n\n/** When a decision window closes, relative to now: `in 23 h`, `in 5 min`. */\nexport function closesIn(expiresAt: string | null | undefined, now = Date.now()): string | null {\n if (!expiresAt) return null\n const minutes = Math.ceil((Date.parse(expiresAt) - now) / 60_000)\n if (!Number.isFinite(minutes) || minutes <= 0) return null\n return minutes >= 120 ? `closes in ${Math.round(minutes / 60)} h` : `closes in ${minutes} min`\n}\n\n/** A short relative time: `just now`, `4 min ago`, `3 h ago`, then the date. */\nexport function relativeTime(at: string | null | undefined, now = Date.now()): string | null {\n if (!at) return null\n const then = Date.parse(at)\n if (!Number.isFinite(then)) return null\n const minutes = Math.round((now - then) / 60_000)\n if (minutes < 1) return 'just now'\n if (minutes < 60) return `${minutes} min ago`\n if (minutes < 24 * 60) return `${Math.round(minutes / 60)} h ago`\n return new Date(then).toLocaleDateString(undefined, { month: 'short', day: 'numeric' })\n}\n","import { ArrowRight, CalendarDays, GitBranch, GitCommitHorizontal, GitPullRequest, MapPin, Phone, Users } from 'lucide-react'\nimport { ApprovalDiffSummary } from '@tangle-network/ui/run'\n\nimport { formatMinorAmount, formatWhen, type HubActionPreview } from '../hub-approvals'\nimport { Chip, HubFieldList } from './parts'\n\n/** Readable text of an HTML email body, for a preview that never renders markup. */\nfunction plainText(body: string, html: boolean): string {\n if (!html) return body\n return body\n .replace(/<(script|style)[\\s\\S]*?<\\/\\1>/gi, '')\n .replace(/<br\\s*\\/?>/gi, '\\n')\n .replace(/<\\/(p|div|li|h[1-6]|tr)>/gi, '\\n')\n .replace(/<[^>]+>/g, '')\n .replace(/ /g, ' ')\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/"/g, '\"')\n .replace(/'/g, \"'\")\n .replace(/\\n{3,}/g, '\\n\\n')\n .trim()\n}\n\nfunction initial(name: string | null | undefined): string {\n return (name?.trim().replace(/^@/, '').charAt(0) || '?').toUpperCase()\n}\n\nfunction Panel({ children, className = '' }: { children: React.ReactNode; className?: string }) {\n return <div className={`rounded-lg border border-border bg-background ${className}`}>{children}</div>\n}\n\nfunction PullRequestPreview({ preview }: { preview: Extract<HubActionPreview, { kind: 'pull-request' }> }) {\n return (\n <div className=\"space-y-3\">\n <Panel className=\"px-3 py-3\">\n <div className=\"flex flex-wrap items-center gap-2 text-sm text-muted-foreground\">\n <GitPullRequest aria-hidden className=\"size-4 shrink-0\" />\n {preview.repository && <span className=\"font-medium text-foreground\">{preview.repository}</span>}\n {preview.head && preview.base && (\n <span className=\"flex min-w-0 flex-wrap items-center gap-1.5\">\n <Chip mono>{preview.head}</Chip>\n <ArrowRight aria-label=\"into\" className=\"size-4 shrink-0\" />\n <Chip mono>{preview.base}</Chip>\n </span>\n )}\n {preview.draft && <span className=\"rounded-md border border-border px-1.5 py-0.5 text-sm text-muted-foreground\">Draft</span>}\n </div>\n {preview.title && <p className=\"mt-2 text-base font-semibold leading-6 text-foreground\">{preview.title}</p>}\n {preview.body && <p className=\"mt-1 line-clamp-3 whitespace-pre-line text-sm leading-6 text-muted-foreground sm:line-clamp-4\">{preview.body}</p>}\n </Panel>\n {preview.files.length > 0 && <ApprovalDiffSummary files={preview.files} />}\n </div>\n )\n}\n\nfunction EmailPreview({ preview, account }: { preview: Extract<HubActionPreview, { kind: 'email' }>; account?: string | null }) {\n const rows: Array<[string, string]> = [\n ...(account ? [['From', account] as [string, string]] : []),\n ...(preview.to.length ? [['To', preview.to.join(', ')] as [string, string]] : []),\n ...(preview.cc.length ? [['Cc', preview.cc.join(', ')] as [string, string]] : []),\n ...(preview.bcc.length ? [['Bcc', preview.bcc.join(', ')] as [string, string]] : []),\n ]\n const body = preview.body ? plainText(preview.body, preview.html) : ''\n return (\n <Panel className=\"overflow-hidden\">\n <dl className=\"grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 border-b border-border px-3 py-2.5 text-sm\">\n {rows.map(([label, value]) => (\n <div key={label} className=\"contents\">\n <dt className=\"text-muted-foreground\">{label}</dt>\n <dd className=\"break-words text-foreground\">{value}</dd>\n </div>\n ))}\n {preview.subject && (\n <div className=\"contents\">\n <dt className=\"text-muted-foreground\">Subject</dt>\n <dd className=\"break-words font-semibold text-foreground\">{preview.subject}</dd>\n </div>\n )}\n {preview.reply && !preview.subject && (\n <div className=\"contents\">\n <dt className=\"text-muted-foreground\">Reply</dt>\n <dd className=\"text-foreground\">In the existing conversation</dd>\n </div>\n )}\n </dl>\n {body && <div className=\"max-h-60 overflow-y-auto whitespace-pre-wrap break-words px-3 py-3 text-sm leading-6 text-foreground\">{body}</div>}\n </Panel>\n )\n}\n\nfunction PostPreview({ preview, account }: { preview: Extract<HubActionPreview, { kind: 'post' }>; account?: string | null }) {\n if (preview.channel === 'slack') {\n return (\n <Panel className=\"px-3 py-3\">\n <p className=\"text-sm font-semibold text-foreground\">{preview.where ?? 'Slack'}</p>\n <div className=\"mt-2 flex gap-3\">\n <span className=\"flex size-9 shrink-0 items-center justify-center rounded-md bg-muted text-sm font-semibold text-foreground\">{initial(account)}</span>\n <div className=\"min-w-0\">\n <p className=\"text-sm font-semibold text-foreground\">{account ?? 'Your account'}</p>\n <p className=\"whitespace-pre-wrap break-words text-sm leading-6 text-foreground\">{preview.text}</p>\n </div>\n </div>\n </Panel>\n )\n }\n const x = preview.channel === 'x'\n const length = [...preview.text].length\n return (\n <Panel className=\"px-4 py-3\">\n <div className=\"flex gap-3\">\n <span className={`flex size-10 shrink-0 items-center justify-center rounded-full text-base font-semibold ${x ? 'bg-foreground text-background' : 'bg-[#0a66c2] text-white'}`}>\n {initial(account)}\n </span>\n <div className=\"min-w-0 flex-1\">\n <p className=\"flex flex-wrap items-baseline gap-x-1.5 text-sm\">\n <span className=\"font-semibold text-foreground\">{account ?? 'Your account'}</span>\n <span className=\"text-muted-foreground\">{x ? '· now' : '· Post · Anyone'}</span>\n </p>\n <p className={`mt-1 whitespace-pre-wrap break-words text-foreground ${x ? 'text-base leading-6' : 'text-sm leading-6'}`}>{preview.text}</p>\n {preview.link && (\n <div className=\"mt-3 overflow-hidden rounded-lg border border-border\">\n <div className=\"px-3 py-2\">\n <p className=\"truncate text-sm text-muted-foreground\">{preview.link.url.replace(/^https?:\\/\\//, '')}</p>\n {preview.link.title && <p className=\"truncate text-sm font-semibold text-foreground\">{preview.link.title}</p>}\n {preview.link.description && <p className=\"line-clamp-2 text-sm text-muted-foreground\">{preview.link.description}</p>}\n </div>\n </div>\n )}\n </div>\n </div>\n {x && (\n <p className={`mt-2 text-right text-sm tabular-nums ${length > 280 ? 'text-[var(--surface-danger-text)]' : 'text-muted-foreground'}`}>\n {length} / 280\n </p>\n )}\n </Panel>\n )\n}\n\nfunction PaymentPreview({ preview }: { preview: Extract<HubActionPreview, { kind: 'payment' }> }) {\n return (\n <Panel className=\"px-4 py-3\">\n <p className=\"text-sm text-muted-foreground\">{preview.label.charAt(0).toUpperCase() + preview.label.slice(1)}</p>\n {preview.amount !== undefined && (\n <p className=\"mt-0.5 text-2xl font-semibold tabular-nums text-foreground\">{formatMinorAmount(preview.amount, preview.currency)}</p>\n )}\n <div className=\"mt-2 space-y-1 text-sm\">\n {preview.customer && (\n <p className=\"text-muted-foreground\">Customer <span className={`text-foreground ${preview.customer.startsWith('cus_') ? 'font-mono' : ''}`}>{preview.customer}</span></p>\n )}\n {preview.description && <p className=\"text-foreground\">{preview.description}</p>}\n </div>\n </Panel>\n )\n}\n\nfunction SpeechPreview({ preview }: { preview: Extract<HubActionPreview, { kind: 'speech' }> }) {\n return (\n <Panel className=\"px-4 py-3\">\n <blockquote className=\"border-l-2 border-[var(--accent-text)] pl-3 text-base leading-7 text-foreground\">{preview.text}</blockquote>\n {(preview.voice || preview.seconds) && (\n <div className=\"mt-3 flex flex-wrap gap-2\">\n {preview.voice && <Chip>Voice: {preview.voice}</Chip>}\n {preview.seconds && <Chip>About {preview.seconds} s</Chip>}\n </div>\n )}\n </Panel>\n )\n}\n\nfunction CallPreview({ preview }: { preview: Extract<HubActionPreview, { kind: 'call' }> }) {\n return (\n <Panel className=\"flex gap-3 px-4 py-3\">\n <span className=\"flex size-10 shrink-0 items-center justify-center rounded-full bg-muted\"><Phone aria-hidden className=\"size-5 text-foreground\" /></span>\n <div className=\"min-w-0 space-y-1 text-sm\">\n <p className=\"text-base font-semibold tabular-nums text-foreground\">{preview.to ?? 'Unknown number'}</p>\n {preview.from && <p className=\"text-muted-foreground\">From <span className=\"tabular-nums text-foreground\">{preview.from}</span></p>}\n {preview.purpose && <p className=\"leading-6 text-foreground\">{preview.purpose}</p>}\n </div>\n </Panel>\n )\n}\n\nfunction EventPreview({ preview }: { preview: Extract<HubActionPreview, { kind: 'event' }> }) {\n const start = preview.start ? new Date(preview.start) : null\n const valid = start && !Number.isNaN(start.getTime())\n return (\n <Panel className=\"flex gap-4 px-4 py-3\">\n <div className=\"flex w-14 shrink-0 flex-col items-center overflow-hidden rounded-lg border border-border text-center\">\n <span className=\"w-full bg-[var(--surface-danger-bg)] py-0.5 text-sm font-semibold uppercase text-[var(--surface-danger-text)]\">\n {valid ? start!.toLocaleDateString(undefined, { month: 'short' }) : <CalendarDays aria-hidden className=\"mx-auto size-4\" />}\n </span>\n <span className=\"py-1 text-xl font-semibold tabular-nums text-foreground\">{valid ? start!.getDate() : '–'}</span>\n </div>\n <div className=\"min-w-0 space-y-1 text-sm\">\n <p className=\"text-base font-semibold text-foreground\">{preview.title ?? 'Untitled event'}</p>\n {preview.start && <p className=\"text-foreground\">{formatWhen(preview.start, preview.end)}</p>}\n {preview.location && <p className=\"flex items-center gap-1.5 text-muted-foreground\"><MapPin aria-hidden className=\"size-4 shrink-0\" />{preview.location}</p>}\n {preview.attendees.length > 0 && (\n <p className=\"flex items-start gap-1.5 text-muted-foreground\"><Users aria-hidden className=\"mt-0.5 size-4 shrink-0\" /><span className=\"break-words\">{preview.attendees.join(', ')}</span></p>\n )}\n {preview.description && <p className=\"line-clamp-3 leading-6 text-foreground\">{preview.description}</p>}\n </div>\n </Panel>\n )\n}\n\n/**\n * What a held call will do, drawn the way its integration shows it: a pull\n * request with its branch and file changes, an email, a post in the channel's\n * style, a payment, a voice memo, a call or a calendar event. Any other action\n * lists its input fields.\n */\nexport function HubActionPreviewView({ preview, account }: { preview: HubActionPreview; account?: string | null }) {\n switch (preview.kind) {\n case 'pull-request':\n return <PullRequestPreview preview={preview} />\n case 'files':\n return preview.files.length > 0 ? <ApprovalDiffSummary files={preview.files} /> : null\n case 'commit':\n return (\n <Panel className=\"px-3 py-3\">\n <p className=\"flex items-center gap-2 text-sm text-muted-foreground\">\n <GitCommitHorizontal aria-hidden className=\"size-4 shrink-0\" />\n {preview.repository ?? 'Commit'}\n </p>\n {preview.message && <p className=\"mt-2 whitespace-pre-line text-sm leading-6 text-foreground\">{preview.message}</p>}\n <div className=\"mt-2\"><HubFieldList fields={[\n ...(preview.tree ? [{ label: 'Tree', value: preview.tree.slice(0, 7), mono: true }] : []),\n ...preview.parents.map((parent) => ({ label: 'Parent', value: parent.slice(0, 7), mono: true })),\n ]} /></div>\n </Panel>\n )\n case 'branch':\n return (\n <Panel className=\"flex flex-wrap items-center gap-2 px-3 py-3 text-sm\">\n <GitBranch aria-hidden className=\"size-4 shrink-0 text-muted-foreground\" />\n {preview.branch && <Chip mono>{preview.branch}</Chip>}\n {preview.sha && <span className=\"text-muted-foreground\">at <span className=\"font-mono text-foreground\">{preview.sha.slice(0, 7)}</span></span>}\n </Panel>\n )\n case 'issue':\n return (\n <Panel className=\"px-3 py-3\">\n {preview.verdict && <p className=\"text-sm font-medium capitalize text-foreground\">{preview.verdict}</p>}\n {preview.title && <p className=\"text-base font-semibold leading-6 text-foreground\">{preview.title}</p>}\n {preview.body && <p className=\"mt-1 line-clamp-6 whitespace-pre-line text-sm leading-6 text-foreground\">{preview.body}</p>}\n </Panel>\n )\n case 'email':\n return <EmailPreview preview={preview} account={account} />\n case 'post':\n return <PostPreview preview={preview} account={account} />\n case 'payment':\n return <PaymentPreview preview={preview} />\n case 'speech':\n return <SpeechPreview preview={preview} />\n case 'call':\n return <CallPreview preview={preview} />\n case 'event':\n return <EventPreview preview={preview} />\n case 'fields':\n return preview.fields.length > 0 ? <Panel className=\"px-3 py-3\"><HubFieldList fields={preview.fields} /></Panel> : null\n }\n}\n","import { useEffect, useState } from 'react'\nimport { ChevronRight, ShieldCheck } from 'lucide-react'\nimport { Button } from '@tangle-network/ui/primitives'\n\nimport { hubActionReceipt, presentHubAction, type HubApprovalItem, type HubApprovalPhase } from '../hub-approvals'\nimport { closesIn, distinctAccount, HubApprovalPhasePill, HubProviderMark, relativeTime } from './parts'\n\nconst GROUPS: ReadonlyArray<{ id: string; label: string; phases: readonly HubApprovalPhase[] }> = [\n { id: 'waiting', label: 'Waiting', phases: ['waiting', 'blocked'] },\n { id: 'running', label: 'Running', phases: ['queued', 'running'] },\n { id: 'failed', label: 'Failed', phases: ['failed'] },\n { id: 'done', label: 'Done', phases: ['done'] },\n { id: 'closed', label: 'Denied or expired', phases: ['denied', 'expired'] },\n]\n\nexport interface HubApprovalsListProps {\n items: readonly HubApprovalItem[]\n /** Show one call: scroll to it in the conversation and open its detail. */\n onSelect?: (item: HubApprovalItem) => void\n selectedId?: string | null\n className?: string\n}\n\n/**\n * Every held call in the conversation, grouped by where it stands — waiting,\n * running, failed, done, then denied or expired — and updated as the host's\n * items change. Picking one hands it to `onSelect`.\n */\nexport function HubApprovalsList({ items, onSelect, selectedId, className = '' }: HubApprovalsListProps) {\n const [now, setNow] = useState(() => Date.now())\n useEffect(() => {\n const timer = setInterval(() => setNow(Date.now()), 30_000)\n return () => clearInterval(timer)\n }, [])\n const waiting = items.filter((item) => item.phase === 'waiting' || item.phase === 'blocked').length\n const groups = GROUPS\n .map((group) => ({ ...group, items: items.filter((item) => group.phases.includes(item.phase)).slice().reverse() }))\n .filter((group) => group.items.length > 0)\n\n return (\n <div className={`flex h-full min-h-0 flex-col ${className}`}>\n <div className=\"shrink-0 border-b border-border px-4 py-3\">\n <h2 className=\"text-base font-semibold text-foreground\">Approvals</h2>\n <p className=\"text-sm text-muted-foreground\" aria-live=\"polite\">\n {waiting === 0 ? 'Nothing is waiting for you' : waiting === 1 ? '1 request is waiting' : `${waiting} requests are waiting`}\n </p>\n </div>\n {groups.length === 0 ? (\n <div className=\"flex flex-1 flex-col items-center justify-center gap-2 px-6 py-10 text-center\">\n <span className=\"flex size-10 items-center justify-center rounded-xl bg-muted\"><ShieldCheck aria-hidden className=\"size-5 text-muted-foreground\" /></span>\n <p className=\"text-sm font-medium text-foreground\">No approvals in this conversation</p>\n <p className=\"text-sm text-muted-foreground\">Requests to act on your connected accounts appear here.</p>\n </div>\n ) : (\n <div className=\"min-h-0 flex-1 space-y-5 overflow-y-auto px-2 py-3\">\n {groups.map((group) => (\n <section key={group.id} aria-label={group.label}>\n <h3 className=\"px-2 pb-1 text-sm font-medium text-muted-foreground\">\n {group.label} <span className=\"tabular-nums\">· {group.items.length}</span>\n </h3>\n <ul className=\"space-y-1\">\n {group.items.map((item) => {\n const presentation = presentHubAction(item)\n const title = item.phase === 'done' ? hubActionReceipt(item).title : presentation.title\n const when = item.phase === 'waiting' ? closesIn(item.expiresAt, now) ?? relativeTime(item.requestedAt, now) : relativeTime(item.requestedAt, now)\n const detail = [presentation.provider.name, distinctAccount(item.account, presentation.provider.name), when].filter(Boolean).join(' · ')\n const selected = selectedId === item.id\n return (\n <li key={item.id}>\n <Button\n variant=\"bare\"\n onClick={() => onSelect?.(item)}\n aria-current={selected ? 'true' : undefined}\n className={`flex w-full items-start gap-3 rounded-lg px-2 py-2.5 text-left transition-colors hover:bg-muted ${selected ? 'bg-muted' : ''}`}\n >\n <HubProviderMark providerId={presentation.provider.id} name={presentation.provider.name} size={28} />\n <span className=\"min-w-0 flex-1\">\n <span className=\"line-clamp-2 text-sm font-medium leading-5 text-foreground\">{title}</span>\n <span className=\"mt-0.5 block truncate text-sm text-muted-foreground\">{detail}</span>\n </span>\n <span className=\"flex shrink-0 items-center gap-1\">\n <HubApprovalPhasePill phase={item.phase} label={item.phase === 'waiting' ? 'Waiting' : item.phase === 'blocked' ? 'Owner' : undefined} />\n <ChevronRight aria-hidden className=\"size-4 text-muted-foreground\" />\n </span>\n </Button>\n </li>\n )\n })}\n </ul>\n </section>\n ))}\n </div>\n )}\n </div>\n )\n}\n","import { useEffect, useRef, useState, type ReactNode } from 'react'\nimport { ChevronDown } from 'lucide-react'\nimport { Button } from '@tangle-network/ui/primitives'\n\nimport { hubActionReceipt, presentHubAction, type HubApprovalItem } from '../hub-approvals'\nimport { HubApprovalPhasePill, HubProviderMark, HubRawDetails } from './parts'\nimport { HubActionPreviewView } from './preview'\nimport { HubActionReceiptCard } from './receipt'\n\nexport interface HubApprovalRowProps {\n item: HubApprovalItem\n /** Open the detail, e.g. when the call was picked in the Approvals list. */\n expanded?: boolean\n onExpandedChange?: (expanded: boolean) => void\n /** Bring a waiting call to the front of the dock. */\n onReview?: (item: HubApprovalItem) => void\n /** Extra controls for a call no one can decide any more, e.g. asking the agent again. */\n actions?: ReactNode\n}\n\n/**\n * A held call where the agent made it: one line with the integration, what\n * the call does and where it stands, opening to its preview, result and the\n * exact call. The decision itself lives in the dock, so the transcript stays\n * readable while a request waits.\n */\nexport function HubApprovalRow({ item, expanded: controlled, onExpandedChange, onReview, actions }: HubApprovalRowProps) {\n const [own, setOwn] = useState(false)\n const expanded = controlled ?? own\n const ref = useRef<HTMLDivElement>(null)\n const presentation = presentHubAction(item)\n const title = item.phase === 'done' ? hubActionReceipt(item).title : presentation.title\n\n useEffect(() => {\n if (controlled) ref.current?.scrollIntoView({ block: 'center', behavior: 'smooth' })\n }, [controlled])\n\n const toggle = () => {\n setOwn(!expanded)\n onExpandedChange?.(!expanded)\n }\n\n return (\n <div ref={ref} data-hub-approval-row={item.id} className={`rounded-xl border bg-card ${expanded ? 'border-border shadow-sm' : 'border-border/80'}`}>\n <div className=\"flex items-center gap-3 px-3 py-2\">\n <Button\n variant=\"bare\"\n aria-expanded={expanded}\n onClick={toggle}\n className=\"flex min-h-9 min-w-0 flex-1 items-center gap-3 rounded-md text-left\"\n >\n <HubProviderMark providerId={presentation.provider.id} name={presentation.provider.name} size={24} />\n <span className=\"min-w-0 flex-1 truncate text-sm font-medium text-foreground\">{title}</span>\n <HubApprovalPhasePill phase={item.phase} label={item.phase === 'waiting' ? 'Waiting' : item.phase === 'blocked' ? 'Owner decides' : undefined} />\n <ChevronDown aria-hidden className={`size-4 shrink-0 text-muted-foreground transition-transform ${expanded ? 'rotate-180' : ''}`} />\n </Button>\n {item.phase === 'waiting' && onReview && (\n // On a phone the dock sits just below; the row keeps its width for the title.\n <Button variant=\"outline\" className=\"hidden sm:inline-flex\" onClick={() => onReview(item)}>Review</Button>\n )}\n </div>\n {expanded && (\n <div className=\"space-y-3 border-t border-border px-3 pb-3 pt-3\">\n {item.phase === 'done' || item.phase === 'failed'\n ? <HubActionReceiptCard item={item} className=\"border-0 px-0 py-0 shadow-none\" />\n : (\n <>\n <HubActionPreviewView preview={presentation.preview} account={item.account} />\n <HubRawDetails sections={[{ label: 'Call', value: { action: item.actionPath, input: item.input } }]} />\n </>\n )}\n {actions}\n </div>\n )}\n {!expanded && actions && (item.phase === 'expired' || item.phase === 'failed') && (\n <div className=\"border-t border-border px-3 py-2\">{actions}</div>\n )}\n </div>\n )\n}\n","import { useState } from 'react'\nimport { ExternalLink } from 'lucide-react'\nimport { ApprovalDiffSummary } from '@tangle-network/ui/run'\n\nimport { hubActionReceipt, presentHubAction, type HubApprovalItem, type HubApprovalPhase } from '../hub-approvals'\nimport { distinctAccount, HubApprovalPhasePill, HubFieldList, HubProviderMark, HubRawDetails } from './parts'\n\nfunction AudioPlayer({ src }: { src: string }) {\n const [failed, setFailed] = useState(false)\n if (failed) return <p className=\"text-sm text-muted-foreground\">The audio link has expired. Ask the agent for a new one.</p>\n // The memo is generated speech with its text shown beside it, so it carries no caption track.\n // eslint-disable-next-line jsx-a11y/media-has-caption\n return <audio controls preload=\"metadata\" src={src} onError={() => setFailed(true)} className=\"h-10 w-full\" />\n}\n\nexport interface HubActionReceiptCardProps {\n item: HubApprovalItem\n className?: string\n}\n\n/**\n * What one decided Hub action did: the integration's logo, the result in plain\n * words with its link, the key fields, a player or file changes when the\n * result has them, and the exact call and result behind Details.\n */\nexport function HubActionReceiptCard({ item, className = '' }: HubActionReceiptCardProps) {\n const receipt = hubActionReceipt(item)\n const presentation = presentHubAction(item)\n const account = distinctAccount(item.account, receipt.provider.name)\n const subtitle = [receipt.provider.name, account ? `as ${account}` : null, presentation.target && !receipt.title.includes(presentation.target) ? presentation.target : null]\n .filter(Boolean).join(' · ')\n const phase: HubApprovalPhase = item.phase\n return (\n <article aria-label={receipt.title} className={`rounded-xl border border-border bg-card px-4 py-3 shadow-sm ${className}`}>\n <div className=\"flex items-start gap-3\">\n <HubProviderMark providerId={receipt.provider.id} name={receipt.provider.name} />\n <div className=\"min-w-0 flex-1\">\n <p className=\"text-base font-semibold leading-6 text-foreground\">\n {receipt.href\n ? (\n <a href={receipt.href} target=\"_blank\" rel=\"noreferrer\" className=\"inline-flex max-w-full items-center gap-1.5 hover:underline\">\n <span className=\"truncate\">{receipt.title}</span>\n <ExternalLink aria-hidden className=\"size-4 shrink-0 text-muted-foreground\" />\n </a>\n )\n : <span className=\"break-words\">{receipt.title}</span>}\n </p>\n {subtitle && <p className=\"truncate text-sm text-muted-foreground\">{subtitle}</p>}\n </div>\n <HubApprovalPhasePill phase={phase} />\n </div>\n {(receipt.fields.length > 0 || receipt.media || receipt.files || receipt.error) && (\n <div className=\"mt-3 space-y-3\">\n <HubFieldList fields={receipt.fields} />\n {receipt.media && <AudioPlayer src={receipt.media.src} />}\n {receipt.files && <ApprovalDiffSummary files={receipt.files} />}\n {receipt.error && (\n <p className=\"break-words rounded-lg border border-[var(--surface-danger-border)] bg-[var(--surface-danger-bg)] px-3 py-2 text-sm text-[var(--surface-danger-text)]\">\n {receipt.error}\n </p>\n )}\n </div>\n )}\n {(item.grant || item.autoApproved) && (\n <p className=\"mt-3 text-sm text-muted-foreground\">\n {item.autoApproved ?? `Allowed ${item.grant?.expiresAt ? 'for 24 hours' : 'from now on'}: ${item.grant?.scope}`}\n </p>\n )}\n <div className=\"mt-2\">\n <HubRawDetails sections={[\n { label: 'Call', value: { action: item.actionPath, input: item.input } },\n { label: 'Result', value: item.result },\n ]} />\n </div>\n </article>\n )\n}\n\nexport interface HubApprovalReceiptsProps {\n items: readonly HubApprovalItem[]\n /** The message the agent received, shown behind Details so nothing it read is hidden. */\n message?: string\n /** When the decisions were sent. */\n at?: string | Date | null\n}\n\n/**\n * The receipts that stand in for the message resuming the agent after a\n * decision. The agent gets that message unchanged; the transcript shows what\n * happened instead of the machine prompt.\n */\nexport function HubApprovalReceipts({ items, message, at }: HubApprovalReceiptsProps) {\n const decided = items.filter((item) => item.phase !== 'waiting' && item.phase !== 'blocked')\n const count = (phases: readonly HubApprovalPhase[]) => decided.filter((item) => phases.includes(item.phase)).length\n const actions = (n: number) => (n === 1 ? '1 action' : `${n} actions`)\n const approved = count(['queued', 'running', 'done', 'failed'])\n const denied = count(['denied'])\n const expired = count(['expired'])\n const verbs = [approved ? `approved ${actions(approved)}` : null, denied ? `denied ${actions(denied)}` : null].filter(Boolean)\n const summary = verbs.length\n ? `You ${verbs.join(' and ')}${expired ? `; ${actions(expired)} expired` : ''}`\n : expired ? `${actions(expired)} expired` : 'Your decisions'\n const when = at ? new Date(at) : null\n return (\n <section aria-label=\"Approval results\" className=\"space-y-2\">\n <p className=\"flex items-center gap-2 text-sm text-muted-foreground\">\n <span>{summary}</span>\n {when && !Number.isNaN(when.getTime()) && (\n <time dateTime={when.toISOString()}>· {when.toLocaleTimeString(undefined, { hour: 'numeric', minute: '2-digit' })}</time>\n )}\n </p>\n {decided.map((item) => <HubActionReceiptCard key={item.id} item={item} />)}\n {message && <HubRawDetails sections={[{ label: 'Message sent to the agent', value: message }]} />}\n </section>\n )\n}\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,WAAW,SAAS,QAAQ,YAAAA,iBAAgB;AACrD,SAAS,OAAO,aAAa,aAAa,gBAAAC,eAAc,cAAc,SAAS,SAAS;AACxF,SAAS,UAAAC,SAAQ,OAAO,YAAY,sBAAsB;;;ACF1D,SAAS,gBAAgC;AACzC,SAAS,oBAAoB;AAC7B,SAAS,oBAAoB;AAC7B,SAAS,QAAQ,kBAAmC;AAkBhD,cA0BE,YA1BF;AAdJ,IAAM,cAAoD;AAAA,EACxD,SAAS;AAAA,EACT,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AACX;AAGO,SAAS,qBAAqB,EAAE,OAAO,MAAM,GAAgD;AAClG,SACE,oBAAC,cAAW,MAAM,YAAY,KAAK,GAAG,MAAK,MAAK,WAAU,8BACvD,mBAAS,0BAA0B,KAAK,GAC3C;AAEJ;AAGO,SAAS,gBAAgB,EAAE,YAAY,MAAM,OAAO,GAAG,GAAwD;AACpH,QAAM,QAAQ,KAAK,MAAM,OAAO,IAAI;AACpC,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MACV,OAAO,EAAE,OAAO,MAAM,QAAQ,KAAK;AA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,gBAAAD,KAAC,wBAAqB,MAAY,WAAU,kCAAiC,IAE3E,gBAAAC,MAAAF,WAAA,EACE;AAAA,wBAAAC,KAAC,wBAAqB,SAAS,aAAa,SAAS,SAAS,KAAK,SAAS;AAAA,QAC5E,gBAAAA,KAAC,iBAAc,UAAU,CAAC,EAAE,OAAO,QAAQ,OAAO,EAAE,QAAQ,KAAK,YAAY,OAAO,KAAK,MAAM,EAAE,CAAC,GAAG;AAAA,SACvG;AAAA,MAEL;AAAA,OACH;AAAA,IAED,CAAC,YAAY,YAAY,KAAK,UAAU,aAAa,KAAK,UAAU,aACnE,gBAAAA,KAAC,SAAI,WAAU,oCAAoC,mBAAQ;AAAA,KAE/D;AAEJ;","names":["useState","ChevronRight","Button","jsx","jsxs","jsx","jsxs","useState","Button","ChevronRight","useEffect","useState","ChevronRight","Button","jsx","jsxs","useState","useEffect","Button","ChevronRight","useEffect","useRef","useState","ChevronDown","Button","useState","ExternalLink","ApprovalDiffSummary","jsx","jsxs","useState","ExternalLink","ApprovalDiffSummary","Fragment","jsx","jsxs","useState","useRef","useEffect","Button","ChevronDown"]}
|
|
@@ -31,6 +31,8 @@ export declare function Chip({ children, mono }: {
|
|
|
31
31
|
children: ReactNode;
|
|
32
32
|
mono?: boolean;
|
|
33
33
|
}): import("react").JSX.Element;
|
|
34
|
+
/** The account worth naming: none when it only repeats the provider's name. */
|
|
35
|
+
export declare function distinctAccount(account: string | null | undefined, providerName: string): string | null;
|
|
34
36
|
/** When a decision window closes, relative to now: `in 23 h`, `in 5 min`. */
|
|
35
37
|
export declare function closesIn(expiresAt: string | null | undefined, now?: number): string | null;
|
|
36
38
|
/** A short relative time: `just now`, `4 min ago`, `3 h ago`, then the date. */
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hub-approvals/types.ts","../src/hub-approvals/result.ts","../src/hub-approvals/present.ts","../src/hub-approvals/index.ts"],"sourcesContent":["/**\n * The vocabulary of a Hub action that waits on a person: where it stands, what\n * it will do in the owner's words, and what it did once it ran.\n */\n\n/** Where one held action stands, as the dock, the list and the transcript show it. */\nexport type HubApprovalPhase =\n /** Held by Hub; the viewer can decide it. */\n | 'waiting'\n /** Held by Hub; someone else (the workspace owner) decides it. */\n | 'blocked'\n /** Approved here; the run has not started. */\n | 'queued'\n /** Approved; Hub is running the call. */\n | 'running'\n | 'done'\n /** Approved, but Hub could not run it. */\n | 'failed'\n | 'denied'\n | 'expired'\n\n/** Phases that still need someone's decision. */\nexport const HUB_APPROVAL_OPEN_PHASES: ReadonlySet<HubApprovalPhase> = new Set(['waiting', 'blocked'])\n/** Phases between a decision and its result. */\nexport const HUB_APPROVAL_ACTIVE_PHASES: ReadonlySet<HubApprovalPhase> = new Set(['queued', 'running'])\n\n/** A file a held write changes. Counts stay undefined until someone has read them. */\nexport interface HubActionFile {\n path: string\n /** A rename reads as a modification of its new path. */\n change: 'added' | 'modified' | 'deleted'\n additions?: number\n deletions?: number\n}\n\n/**\n * The change a held call serves, when it is one step of a larger change such\n * as a pull request. The dock then names the change rather than the step.\n */\nexport interface HubActionBundle {\n /** What the whole change does, e.g. `Open PR: Fix the hero on acme/site`. */\n title: string\n steps?: ReadonlyArray<{ label: string; state: 'done' | 'current' | 'upcoming' }>\n}\n\n/** One held Hub action and its decision, in the form every surface renders. */\nexport interface HubApprovalItem {\n /** Stable within a conversation, such as `<messageId>:<partId>`. */\n id: string\n /** `provider.action`, e.g. `github.pulls.propose`. */\n actionPath: string\n providerId: string\n /** The call's input as Hub received it. */\n input: unknown\n phase: HubApprovalPhase\n /** The connected account the action runs as, e.g. `octocat` or `ops@acme.com`. */\n account?: string | null\n requestedAt?: string | null\n /** When the decision window closes. */\n expiresAt?: string | null\n /** Hub's result, or a bounded projection of it from {@link summarizeHubResult}. */\n result?: unknown\n error?: string | null\n /** The standing permission granted with the approval. */\n grant?: { scope: string; expiresAt: string | null } | null\n /** Set when a permissions mode, not a person, approved it. */\n autoApproved?: string | null\n /** Files with line counts read by the host, replacing those the input declares. */\n files?: readonly HubActionFile[]\n bundle?: HubActionBundle | null\n}\n\n/** A labelled value on a preview or a receipt. */\nexport interface HubActionField {\n label: string\n value: string\n href?: string\n /** Render in the monospace face: shas, ids, paths. */\n mono?: boolean\n}\n\n/** What a held call will do, shaped for its integration's renderer. */\nexport type HubActionPreview =\n | {\n kind: 'pull-request'\n repository?: string\n title?: string\n body?: string\n head?: string\n base?: string\n draft?: boolean\n files: readonly HubActionFile[]\n }\n | { kind: 'commit'; repository?: string; message?: string; tree?: string; parents: readonly string[] }\n | { kind: 'branch'; repository?: string; branch?: string; sha?: string }\n | { kind: 'files'; repository?: string; files: readonly HubActionFile[] }\n | { kind: 'issue'; repository?: string; number?: number; title?: string; body?: string; verdict?: string }\n | {\n kind: 'email'\n to: readonly string[]\n cc: readonly string[]\n bcc: readonly string[]\n subject?: string\n body?: string\n html: boolean\n reply: boolean\n }\n | {\n kind: 'post'\n channel: 'x' | 'linkedin' | 'slack'\n text: string\n /** The post's place, such as a Slack channel. */\n where?: string\n link?: { url: string; title?: string; description?: string }\n }\n | { kind: 'payment'; label: string; amount?: number; currency?: string; customer?: string; description?: string }\n | { kind: 'speech'; text: string; voice?: string; seconds?: number }\n | { kind: 'call'; to?: string; from?: string; purpose?: string }\n | {\n kind: 'event'\n title?: string\n start?: string\n end?: string\n location?: string\n attendees: readonly string[]\n description?: string\n }\n | { kind: 'fields'; fields: readonly HubActionField[] }\n\n/** A held call in the owner's words. */\nexport interface HubActionPresentation {\n provider: { id: string; name: string }\n /** The imperative, e.g. `Open pull request`. */\n action: string\n /** One line naming the action and its object, e.g. `Open PR: Fix the hero on acme/site`. */\n title: string\n /** Where it acts: a repository, recipients, a channel or a customer. */\n target?: string\n preview: HubActionPreview\n}\n\n/** What a decided call did, as its receipt shows it. */\nexport interface HubActionReceipt {\n provider: { id: string; name: string }\n /** The result in past tense, e.g. `Opened PR #123` or `Sent email to ada@acme.com`. */\n title: string\n /** The result's own page, when it has one: the pull request, the post, the event. */\n href?: string\n status: 'done' | 'failed' | 'denied' | 'expired' | 'running' | 'waiting'\n fields: readonly HubActionField[]\n files?: readonly HubActionFile[]\n media?: { kind: 'audio'; src: string; seconds?: number }\n error?: string\n}\n","/**\n * Hub results, read the same way by every receipt: unwrapped from Hub's\n * envelope and bounded before a host persists them.\n */\n\nconst MAX_DEPTH = 4\nconst MAX_KEYS = 24\nconst MAX_ITEMS = 50\nconst MAX_STRING = 600\n\nexport function asRecord(value: unknown): Record<string, unknown> {\n return value && typeof value === 'object' && !Array.isArray(value) ? value as Record<string, unknown> : {}\n}\n\n/**\n * The provider's own result inside Hub's envelopes. `tools.invoke` answers\n * `{ result: … }` and a connector may wrap its body in `data`; a JSON string,\n * as an older host stored it, is parsed first.\n */\nexport function unwrapHubResult(value: unknown): unknown {\n let current: unknown = value\n if (typeof current === 'string') {\n const text = current\n try {\n current = JSON.parse(text)\n } catch {\n // An older host stored `Hub result: {…}`-style text with a JSON tail.\n const start = text.indexOf('{')\n if (start < 0) return value\n try {\n current = JSON.parse(text.slice(start))\n } catch {\n return value\n }\n }\n }\n for (let depth = 0; depth < 3; depth++) {\n const record = asRecord(current)\n const keys = Object.keys(record)\n const inner = keys.find((key) => key === 'result' || key === 'data')\n // Only a thin envelope is unwrapped; a body that happens to carry a `data`\n // field among its own fields is the result itself.\n if (!inner || keys.length > 3 || record[inner] === null || typeof record[inner] !== 'object') break\n current = record[inner]\n }\n return current\n}\n\nfunction bounded(value: unknown, depth: number): unknown {\n if (value === null || typeof value === 'boolean') return value\n if (typeof value === 'number') return Number.isFinite(value) ? value : null\n if (typeof value === 'string') return value.length > MAX_STRING ? `${value.slice(0, MAX_STRING - 1)}…` : value\n if (depth >= MAX_DEPTH) return undefined\n if (Array.isArray(value)) {\n return value.slice(0, MAX_ITEMS).map((item) => bounded(item, depth + 1)).filter((item) => item !== undefined)\n }\n if (typeof value === 'object') {\n const out: Record<string, unknown> = {}\n for (const [key, entry] of Object.entries(value as Record<string, unknown>).slice(0, MAX_KEYS)) {\n const kept = bounded(entry, depth + 1)\n if (kept !== undefined) out[key] = kept\n }\n return out\n }\n return undefined\n}\n\n/**\n * A bounded copy of a Hub result for a host to store with the decision: the\n * envelope removed, strings, arrays and nesting capped. Receipts read it in\n * place of the full result.\n */\nexport function summarizeHubResult(result: unknown): unknown {\n return bounded(unwrapHubResult(result), 0)\n}\n\n/** The first non-empty string among `keys`, searched one level into nested records. */\nexport function readText(value: unknown, ...keys: string[]): string | undefined {\n const record = asRecord(value)\n for (const key of keys) {\n const found = record[key]\n if (typeof found === 'string' && found.trim()) return found.trim()\n if (typeof found === 'number' && Number.isFinite(found)) return String(found)\n }\n return undefined\n}\n\nexport function readNumber(value: unknown, ...keys: string[]): number | undefined {\n const record = asRecord(value)\n for (const key of keys) {\n const found = record[key]\n if (typeof found === 'number' && Number.isFinite(found)) return found\n }\n return undefined\n}\n\n/** A link a result names for itself, in the order providers use them. */\nexport function resultLink(value: unknown): string | undefined {\n const url = readText(value, 'html_url', 'htmlLink', 'webLink', 'web_url', 'permalink', 'hosted_invoice_url', 'url', 'link')\n return url && /^https:\\/\\//.test(url) ? url : undefined\n}\n","/**\n * Hub actions in an owner's words. Known integrations read as what they do —\n * `github.pulls.propose` is \"Open PR: Fix the hero on acme/site\", `gmail.send`\n * is \"Send email to ada@acme.com\" — and any other Hub action falls back to its\n * own name and its input's scalar fields.\n */\n\nimport { asRecord, readNumber, readText, resultLink, unwrapHubResult } from './result'\nimport type {\n HubActionField,\n HubActionFile,\n HubActionPresentation,\n HubActionPreview,\n HubActionReceipt,\n HubApprovalItem,\n} from './types'\n\nconst PROVIDER_NAMES: Record<string, string> = {\n github: 'GitHub',\n gitlab: 'GitLab',\n gmail: 'Gmail',\n google: 'Google',\n 'google-calendar': 'Google Calendar',\n 'microsoft-calendar': 'Outlook Calendar',\n 'outlook-mail': 'Outlook',\n outlook: 'Outlook',\n twitter: 'X',\n x: 'X',\n linkedin: 'LinkedIn',\n stripe: 'Stripe',\n phony: 'ph0ny',\n slack: 'Slack',\n notion: 'Notion',\n hubspot: 'HubSpot',\n linear: 'Linear',\n inkbox: 'Inkbox',\n resend: 'Resend',\n}\n\n/** A provider's display name: `github` is GitHub, `outlook-mail` is Outlook. */\nexport function hubProviderName(id: string): string {\n if (PROVIDER_NAMES[id]) return PROVIDER_NAMES[id]\n const words = id.split(/[-_\\s]+/).filter(Boolean)\n return words.map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(' ') || id\n}\n\n/** `provider.action` split at the first dot. */\nexport function splitHubActionPath(actionPath: string): { provider: string; action: string } {\n const separator = actionPath.indexOf('.')\n return separator < 0 ? { provider: '', action: actionPath } : { provider: actionPath.slice(0, separator), action: actionPath.slice(separator + 1) }\n}\n\nfunction text(value: unknown): string | undefined {\n return typeof value === 'string' && value.trim() ? value.trim() : undefined\n}\n\nfunction clipped(value: string, max = 80): string {\n const single = value.replace(/\\s+/g, ' ').trim()\n return single.length > max ? `${single.slice(0, max - 1).trimEnd()}…` : single\n}\n\nfunction list(value: unknown): string[] {\n if (typeof value === 'string') return value.split(/[,;]/).map((entry) => entry.trim()).filter(Boolean)\n if (!Array.isArray(value)) return []\n return value.flatMap((entry) => {\n if (typeof entry === 'string' && entry.trim()) return [entry.trim()]\n const record = asRecord(entry)\n const address = text(record.email) ?? text(record.address) ?? text(asRecord(record.emailAddress).address)\n return address ? [address] : []\n })\n}\n\nfunction people(addresses: readonly string[]): string {\n if (addresses.length === 0) return ''\n if (addresses.length === 1) return addresses[0]!\n return `${addresses[0]} and ${addresses.length - 1} more`\n}\n\nfunction shortSha(sha: string | undefined): string | undefined {\n return sha && /^[0-9a-f]{7,}$/i.test(sha) ? sha.slice(0, 7) : sha\n}\n\n// ---------- verbs ----------\n\nconst PAST: Record<string, string> = {\n add: 'added', approve: 'approved', archive: 'archived', assign: 'assigned', book: 'booked', cancel: 'canceled',\n capture: 'captured', charge: 'charged', clone: 'cloned', close: 'closed', comment: 'commented', create: 'created',\n deactivate: 'deactivated', delete: 'deleted', enroll: 'enrolled', export: 'exported', finalize: 'finalized',\n forward: 'forwarded', import: 'imported', ingest: 'ingested', invite: 'invited', like: 'liked', make: 'made',\n merge: 'merged', move: 'moved', open: 'opened', pay: 'paid', place: 'placed', post: 'posted', provision: 'provisioned',\n publish: 'published', put: 'put', react: 'reacted', refund: 'refunded', remove: 'removed', reply: 'replied',\n retweet: 'reposted', review: 'reviewed', run: 'ran', save: 'saved', schedule: 'scheduled', send: 'sent', set: 'set',\n share: 'shared', start: 'started', stop: 'stopped', submit: 'submitted', subscribe: 'subscribed',\n synthesize: 'synthesized', transfer: 'transferred', translate: 'translated', update: 'updated', upload: 'uploaded',\n upsert: 'saved', void: 'voided', watch: 'watched', write: 'wrote',\n}\n\n/** The past tense of an English verb this vocabulary uses. */\nexport function pastTense(verb: string): string {\n const lower = verb.toLowerCase()\n const past = PAST[lower] ?? (lower.endsWith('e') ? `${lower}d` : `${lower}ed`)\n return verb.charAt(0) === verb.charAt(0).toUpperCase() ? past.charAt(0).toUpperCase() + past.slice(1) : past\n}\n\nfunction words(action: string): string[] {\n return action\n .replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n .split(/[._\\-\\s]+/)\n .map((word) => word.toLowerCase())\n .filter(Boolean)\n}\n\nfunction singular(word: string): string {\n if (word.endsWith('ies')) return `${word.slice(0, -3)}y`\n if (word.endsWith('sses') || word.endsWith('ss')) return word\n return word.endsWith('s') && word.length > 3 ? word.slice(0, -1) : word\n}\n\n/** A Hub action's own name as a sentence: `payment-intents.create` is \"Create payment intent\". */\nfunction genericVerb(action: string): { verb: string; noun: string } {\n const parts = words(action)\n const index = parts.findIndex((word) => word in PAST)\n if (index < 0) return { verb: '', noun: parts.join(' ') }\n const noun = [...parts.slice(0, index), ...parts.slice(index + 1)].map(singular).join(' ')\n return { verb: parts[index]!, noun }\n}\n\nfunction sentence(verb: string, noun: string): string {\n const phrase = [verb, noun].filter(Boolean).join(' ')\n return phrase.charAt(0).toUpperCase() + phrase.slice(1)\n}\n\n// ---------- inputs ----------\n\nfunction repository(input: Record<string, unknown>): string | undefined {\n const owner = text(input.owner)\n const repo = text(input.repo)\n if (owner && repo) return `${owner}/${repo}`\n return repo ?? text(input.repository)\n}\n\nfunction branchOf(ref: unknown): string | undefined {\n return text(ref)?.replace(/^refs\\/heads\\//, '')\n}\n\n/** The files a call writes, as its input declares them. */\nexport function hubActionFiles(actionPath: string, input: unknown): HubActionFile[] {\n const fields = asRecord(input)\n const { action } = splitHubActionPath(actionPath)\n const entries = action === 'git.createTree' ? fields.tree : fields.files\n if (!Array.isArray(entries)) return []\n return entries.flatMap((entry): HubActionFile[] => {\n const item = asRecord(entry)\n const path = text(item.path)\n if (!path) return []\n const deleted = item.delete === true || (item.sha === null && item.content === undefined)\n return [{ path, change: deleted ? 'deleted' : 'modified' }]\n })\n}\n\n/** Counted files replace declared ones by path; the declared order stays. */\nfunction mergedFiles(declared: readonly HubActionFile[], counted: readonly HubActionFile[] | undefined): HubActionFile[] {\n if (!counted || counted.length === 0) return [...declared]\n if (declared.length === 0) return [...counted]\n const byPath = new Map(counted.map((file) => [file.path, file]))\n return declared.map((file) => byPath.get(file.path) ?? file)\n}\n\nfunction emailPreview(input: Record<string, unknown>, reply: boolean): HubActionPreview {\n return {\n kind: 'email',\n to: list(input.to ?? input.recipients),\n cc: list(input.cc),\n bcc: list(input.bcc),\n subject: text(input.subject),\n body: text(input.body) ?? text(input.text) ?? text(input.html) ?? text(input.comment),\n html: input.html === true || text(input.bodyType)?.toLowerCase() === 'html' || typeof input.html === 'string',\n reply,\n }\n}\n\nfunction speechSeconds(input: Record<string, unknown>): number | undefined {\n const spoken = text(input.text)\n if (!spoken) return undefined\n const speed = typeof input.speed === 'number' && input.speed > 0 ? input.speed : 1\n // About 2.5 spoken words a second at normal speed.\n return Math.max(1, Math.round(spoken.split(/\\s+/).length / 2.5 / speed))\n}\n\nfunction voiceName(input: Record<string, unknown>): string | undefined {\n const voice = text(input.voiceId)\n // An opaque provider id says nothing to an owner; a named voice does.\n if (voice && !/^[0-9a-f-]{16,}$/i.test(voice) && voice.length <= 32) return voice.charAt(0).toUpperCase() + voice.slice(1)\n return text(input.provider)\n}\n\nconst CURRENCY_DIGITS: Record<string, number> = { jpy: 0, krw: 0, vnd: 0, clp: 0, bhd: 3, kwd: 3, omr: 3 }\n\n/** A Stripe minor-unit amount in its currency: `4900` USD is `$49.00`. */\nexport function formatMinorAmount(amount: number, currency = 'usd'): string {\n const code = currency.toLowerCase()\n const digits = CURRENCY_DIGITS[code] ?? 2\n try {\n return new Intl.NumberFormat('en-US', { style: 'currency', currency: code.toUpperCase(), minimumFractionDigits: digits })\n .format(amount / 10 ** digits)\n } catch {\n return `${(amount / 10 ** digits).toFixed(digits)} ${code.toUpperCase()}`\n }\n}\n\n/** Scalar input fields, for an action no renderer knows. */\nfunction scalarFields(input: Record<string, unknown>, max = 6): HubActionField[] {\n return Object.entries(input).flatMap(([key, value]): HubActionField[] => {\n if (key.startsWith('__')) return []\n if (typeof value === 'string' && value.trim()) return [{ label: labelOf(key), value: clipped(value, 160) }]\n if (typeof value === 'number' || typeof value === 'boolean') return [{ label: labelOf(key), value: String(value) }]\n const strings = Array.isArray(value) ? value.filter((entry): entry is string => typeof entry === 'string') : []\n return strings.length > 0 ? [{ label: labelOf(key), value: clipped(strings.join(', '), 160) }] : []\n }).slice(0, max)\n}\n\nfunction labelOf(key: string): string {\n const spaced = key.replace(/([a-z0-9])([A-Z])/g, '$1 $2').replace(/[_-]+/g, ' ').trim().toLowerCase()\n return spaced.charAt(0).toUpperCase() + spaced.slice(1)\n}\n\n// ---------- presentation ----------\n\ntype Presenter = (input: Record<string, unknown>, item: Pick<HubApprovalItem, 'actionPath' | 'files'>) => Omit<HubActionPresentation, 'provider'>\n\nfunction pullRequest(input: Record<string, unknown>, item: Pick<HubApprovalItem, 'actionPath' | 'files'>): Omit<HubActionPresentation, 'provider'> {\n const repo = repository(input)\n const title = text(input.title) ?? 'Untitled change'\n return {\n action: 'Open pull request',\n title: `Open PR: ${clipped(title)}${repo ? ` on ${repo}` : ''}`,\n ...(repo ? { target: repo } : {}),\n preview: {\n kind: 'pull-request',\n repository: repo,\n title,\n body: text(input.body),\n head: branchOf(input.branch ?? input.head),\n base: text(input.base),\n draft: item.actionPath.endsWith('.propose') ? true : input.draft === true,\n files: mergedFiles(hubActionFiles(item.actionPath, input), item.files),\n },\n }\n}\n\nfunction issueLike(verb: string, noun: string): Presenter {\n return (input) => {\n const repo = repository(input)\n const number = readNumber(input, 'issue_number', 'pull_number', 'number')\n const title = text(input.title)\n const object = number !== undefined ? `${noun} #${number}` : title ? `${noun}: ${clipped(title)}` : noun\n return {\n action: sentence(verb, noun.toLowerCase()),\n title: `${sentence(verb, object)}${repo ? ` on ${repo}` : ''}`,\n ...(repo ? { target: repo } : {}),\n preview: {\n kind: 'issue',\n repository: repo,\n number,\n title,\n body: text(input.body),\n verdict: text(input.event)?.toLowerCase().replace(/_/g, ' '),\n },\n }\n }\n}\n\nfunction sendEmail(verb: 'Send' | 'Save draft', reply = false): Presenter {\n return (input) => {\n const preview = emailPreview(input, reply)\n const recipients = preview.kind === 'email' ? people(preview.to) : ''\n const action = reply ? 'Send reply' : verb === 'Send' ? 'Send email' : 'Save draft'\n return {\n action,\n title: reply ? 'Send reply' : `${action}${recipients ? ` to ${recipients}` : ''}`,\n ...(recipients ? { target: recipients } : {}),\n preview,\n }\n }\n}\n\nfunction post(channel: 'x' | 'linkedin', reply = false): Presenter {\n return (input) => {\n const body = text(input.text) ?? text(input.commentary) ?? ''\n const url = text(input.url)\n const where = channel === 'x' ? 'X' : 'LinkedIn'\n return {\n action: reply ? `Reply on ${where}` : `Post on ${where}`,\n title: `${reply ? 'Reply' : 'Post'} on ${where}${body ? `: “${clipped(body, 60)}”` : ''}`,\n target: where,\n preview: {\n kind: 'post',\n channel,\n text: body,\n ...(url ? { link: { url, title: text(input.title), description: text(input.description) } } : {}),\n },\n }\n }\n}\n\nfunction payment(label: string): Presenter {\n return (input) => {\n const amount = readNumber(input, 'amount')\n const currency = text(input.currency)\n const customer = text(input.customerId) ?? text(input.customer) ?? text(input.email)\n const formatted = amount !== undefined ? formatMinorAmount(amount, currency) : undefined\n const object = formatted ? `${label} of ${formatted}` : label\n return {\n action: sentence('create', label),\n title: `${sentence('create', object)}${customer ? ` for ${customer}` : ''}`,\n ...(customer ? { target: customer } : {}),\n preview: { kind: 'payment', label, amount, currency, customer, description: text(input.description) },\n }\n }\n}\n\nfunction calendarEvent(input: Record<string, unknown>, _item?: Pick<HubApprovalItem, 'actionPath' | 'files'>): Omit<HubActionPresentation, 'provider'> {\n const title = text(input.summary) ?? text(input.title) ?? text(input.subject)\n return {\n action: 'Book event',\n title: title ? `Book “${clipped(title, 60)}”` : 'Book an event',\n preview: {\n kind: 'event',\n title,\n start: text(input.start) ?? text(asRecord(input.start).dateTime),\n end: text(input.end) ?? text(asRecord(input.end).dateTime),\n location: text(input.location) ?? text(asRecord(input.location).displayName),\n attendees: list(input.attendees),\n description: text(input.description),\n },\n }\n}\n\nconst PRESENTERS: Record<string, Presenter> = {\n 'github.pulls.propose': pullRequest,\n 'github.pulls.create': pullRequest,\n 'github.git.createTree': (input, item) => {\n const repo = repository(input)\n const files = mergedFiles(hubActionFiles(item.actionPath, input), item.files)\n return {\n action: 'Write files',\n title: `Write ${files.length === 1 ? files[0]!.path : `${files.length} files`}${repo ? ` to ${repo}` : ''}`,\n ...(repo ? { target: repo } : {}),\n preview: { kind: 'files', repository: repo, files },\n }\n },\n 'github.git.createCommit': (input) => {\n const repo = repository(input)\n const message = text(input.message)\n return {\n action: 'Create commit',\n title: `Commit${message ? ` “${clipped(message, 60)}”` : ''}${repo ? ` to ${repo}` : ''}`,\n ...(repo ? { target: repo } : {}),\n preview: { kind: 'commit', repository: repo, message, tree: text(input.tree), parents: list(input.parents) },\n }\n },\n 'github.git.createRef': (input) => {\n const repo = repository(input)\n const branch = branchOf(input.ref)\n return {\n action: 'Create branch',\n title: `Create branch ${branch ?? ''}${repo ? ` in ${repo}` : ''}`.replace(/\\s+/g, ' ').trim(),\n ...(repo ? { target: repo } : {}),\n preview: { kind: 'branch', repository: repo, branch, sha: text(input.sha) },\n }\n },\n 'github.pulls.merge': issueLike('merge', 'PR'),\n 'github.pulls.reviews.create': issueLike('review', 'PR'),\n 'github.issues.create': issueLike('open', 'Issue'),\n 'github.issues.update': issueLike('update', 'Issue'),\n 'github.issues.createComment': issueLike('comment on', 'Issue'),\n 'gmail.send': sendEmail('Send'),\n 'gmail.send_reply': sendEmail('Send', true),\n 'outlook-mail.send_message': sendEmail('Send'),\n 'outlook-mail.send_draft': sendEmail('Send'),\n 'outlook-mail.create_draft': sendEmail('Save draft'),\n 'outlook-mail.send_reply': sendEmail('Send', true),\n 'inkbox.email.send': sendEmail('Send'),\n 'resend.emails.send': sendEmail('Send'),\n 'resend.emails.reply': sendEmail('Send', true),\n 'twitter.tweets.create': post('x'),\n 'twitter.tweets.reply': post('x', true),\n 'x.tweets.create': post('x'),\n 'linkedin.posts.create': post('linkedin'),\n 'linkedin.shares.create': post('linkedin'),\n 'slack.post_message': (input) => {\n const channel = text(input.channel) ?? text(input.channelId)\n const where = channel ? (channel.startsWith('#') || /^[CDG][A-Z0-9]{6,}$/.test(channel) ? channel : `#${channel}`) : undefined\n return {\n action: 'Post in Slack',\n title: `Post in ${where ?? 'Slack'}`,\n ...(where ? { target: where } : {}),\n preview: { kind: 'post', channel: 'slack', text: text(input.text) ?? '', where },\n }\n },\n 'stripe.payment-intents.create': payment('payment'),\n 'stripe.payment-links.create': payment('payment link'),\n 'stripe.invoices.create': payment('invoice'),\n 'stripe.refunds.create': payment('refund'),\n 'stripe.subscriptions.create': payment('subscription'),\n 'phony.synthesize_speech': (input) => {\n const seconds = speechSeconds(input)\n const voice = voiceName(input)\n const detail = [voice, seconds ? `${seconds} s` : undefined].filter(Boolean)\n return {\n action: 'Create voice memo',\n title: `Create voice memo${detail.length ? ` (${detail.join(', ')})` : ''}`,\n preview: { kind: 'speech', text: text(input.text) ?? '', voice, seconds },\n }\n },\n 'phony.start_outbound_call': (input) => {\n const to = text(input.toNumber) ?? text(input.to)\n const mission = asRecord(input.mission)\n return {\n action: 'Start call',\n title: to ? `Call ${to}` : 'Start an outbound call',\n ...(to ? { target: to } : {}),\n preview: {\n kind: 'call',\n to,\n from: text(input.fromNumber),\n purpose: text(mission.goal) ?? text(mission.objective) ?? text(mission.summary) ?? text(input.missionId),\n },\n }\n },\n 'google-calendar.create_event': calendarEvent,\n 'google-calendar.book_slot': calendarEvent,\n 'google-calendar.update_event': (input, item) => {\n const event = calendarEvent(input, item)\n const title = event.preview.kind === 'event' ? event.preview.title : undefined\n return { ...event, action: 'Update event', title: title ? `Update “${clipped(title, 60)}”` : 'Update an event' }\n },\n 'microsoft-calendar.book_slot': calendarEvent,\n}\n\n/** A held call in the owner's words, with the preview its integration renders. */\nexport function presentHubAction(item: Pick<HubApprovalItem, 'actionPath' | 'providerId' | 'input' | 'files' | 'bundle'>): HubActionPresentation {\n const { provider: pathProvider, action } = splitHubActionPath(item.actionPath)\n const providerId = item.providerId || pathProvider\n const provider = { id: providerId, name: hubProviderName(providerId) }\n const input = asRecord(item.input)\n const known = PRESENTERS[item.actionPath]\n const presented = known\n ? known(input, item)\n : (() => {\n const { verb, noun } = genericVerb(action)\n const phrase = sentence(verb, noun) || action\n const object = text(input.name) ?? text(input.title) ?? text(input.subject) ?? text(input.label)\n return {\n action: phrase,\n title: object ? `${phrase} “${clipped(object, 60)}”` : phrase,\n preview: { kind: 'fields', fields: scalarFields(input) } as HubActionPreview,\n }\n })()\n return { provider, ...presented, ...(item.bundle ? { title: item.bundle.title } : {}) }\n}\n\n// ---------- receipts ----------\n\nfunction prField(result: Record<string, unknown>): HubActionField | undefined {\n const pull = asRecord(result.pullRequest)\n const number = readNumber(pull, 'number') ?? readNumber(result, 'number')\n if (number === undefined) return undefined\n return { label: 'Pull request', value: `#${number}`, href: resultLink(pull) ?? resultLink(result) }\n}\n\nfunction receiptTitle(item: HubApprovalItem, presentation: HubActionPresentation, result: Record<string, unknown>): string {\n const { action } = splitHubActionPath(item.actionPath)\n const input = asRecord(item.input)\n const pull = asRecord(result.pullRequest)\n const number = readNumber(pull, 'number') ?? readNumber(result, 'number')\n switch (item.actionPath) {\n case 'github.pulls.propose':\n case 'github.pulls.create':\n return number !== undefined ? `Opened PR #${number}` : 'Opened pull request'\n case 'github.git.createCommit': {\n const sha = shortSha(readText(result, 'sha'))\n return sha ? `Created commit ${sha}` : 'Created commit'\n }\n case 'github.git.createTree': {\n const files = hubActionFiles(item.actionPath, input).length\n return `Wrote ${files === 1 ? '1 file' : `${files} files`}`\n }\n case 'github.git.createRef':\n return `Created branch ${branchOf(readText(result, 'ref') ?? input.ref) ?? ''}`.trim()\n case 'github.issues.create':\n return number !== undefined ? `Opened issue #${number}` : 'Opened issue'\n case 'github.issues.createComment': {\n const on = readNumber(input, 'issue_number')\n return on !== undefined ? `Commented on #${on}` : 'Commented'\n }\n case 'github.pulls.reviews.create': {\n const on = readNumber(input, 'pull_number')\n return on !== undefined ? `Reviewed PR #${on}` : 'Reviewed pull request'\n }\n case 'github.pulls.merge': {\n const on = readNumber(input, 'pull_number')\n return on !== undefined ? `Merged PR #${on}` : 'Merged pull request'\n }\n case 'phony.synthesize_speech':\n return 'Created voice memo'\n }\n if (presentation.preview.kind === 'email') {\n const to = people(presentation.preview.to)\n if (presentation.preview.reply) return 'Sent reply'\n return action.includes('draft') && !action.startsWith('send') ? `Saved draft${to ? ` to ${to}` : ''}` : `Sent email${to ? ` to ${to}` : ''}`\n }\n if (presentation.preview.kind === 'post') {\n return presentation.preview.channel === 'slack' ? `Posted in ${presentation.preview.where ?? 'Slack'}` : `Posted on ${presentation.target ?? presentation.provider.name}`\n }\n if (presentation.preview.kind === 'event') {\n const verb = presentation.action === 'Update event' ? 'Updated' : 'Booked'\n return presentation.preview.title ? `${verb} “${clipped(presentation.preview.title, 60)}”` : `${verb} event`\n }\n if (presentation.preview.kind === 'call') return presentation.preview.to ? `Started call to ${presentation.preview.to}` : 'Started call'\n const [first = '', ...rest] = presentation.action.split(' ')\n return [pastTense(first), ...rest].join(' ')\n}\n\nfunction postLink(item: HubApprovalItem, result: Record<string, unknown>): string | undefined {\n const id = readText(result, 'id', 'urn', 'postUrn')\n if (!id) return resultLink(result)\n if (item.providerId === 'twitter' || item.providerId === 'x') return /^\\d+$/.test(id) ? `https://x.com/i/web/status/${id}` : resultLink(result)\n if (item.providerId === 'linkedin') return id.startsWith('urn:li:') ? `https://www.linkedin.com/feed/update/${id}/` : resultLink(result)\n return resultLink(result)\n}\n\nfunction receiptFields(item: HubApprovalItem, presentation: HubActionPresentation, result: Record<string, unknown>): HubActionField[] {\n const fields: HubActionField[] = []\n const preview = presentation.preview\n switch (preview.kind) {\n case 'pull-request': {\n const pr = prField(result)\n if (pr) fields.push(pr)\n const head = readText(result, 'branch') ?? preview.head\n const base = readText(result, 'base') ?? preview.base\n if (head && base) fields.push({ label: 'Branch', value: `${head} → ${base}`, mono: true })\n const commit = asRecord(result.commit)\n const sha = readText(commit, 'sha')\n if (sha) fields.push({ label: 'Commit', value: shortSha(sha)!, href: resultLink(commit), mono: true })\n const repo = readText(result, 'repository') ?? preview.repository\n if (repo) fields.push({ label: 'Repository', value: repo, href: `https://github.com/${repo}` })\n return fields\n }\n case 'commit': {\n const sha = readText(result, 'sha')\n if (sha) fields.push({ label: 'Commit', value: shortSha(sha)!, href: resultLink(result)?.includes('api.github.com') ? undefined : resultLink(result), mono: true })\n if (preview.message) fields.push({ label: 'Message', value: clipped(preview.message, 120) })\n return fields\n }\n case 'branch': {\n const branch = branchOf(readText(result, 'ref')) ?? preview.branch\n if (branch && preview.repository) fields.push({ label: 'Branch', value: branch, href: `https://github.com/${preview.repository}/tree/${branch}`, mono: true })\n return fields\n }\n case 'files': {\n const sha = readText(result, 'sha')\n if (sha) fields.push({ label: 'Tree', value: shortSha(sha)!, mono: true })\n return fields\n }\n case 'email': {\n if (preview.subject) fields.push({ label: 'Subject', value: clipped(preview.subject, 120) })\n if (preview.cc.length) fields.push({ label: 'Cc', value: preview.cc.join(', ') })\n return fields\n }\n case 'payment': {\n const amount = readNumber(result, 'amount', 'amount_total', 'total') ?? preview.amount\n const currency = readText(result, 'currency') ?? preview.currency\n if (amount !== undefined) fields.push({ label: 'Amount', value: formatMinorAmount(amount, currency) })\n const customer = readText(result, 'customer_email', 'customer') ?? preview.customer\n if (customer) fields.push({ label: 'Customer', value: customer, mono: customer.startsWith('cus_') })\n const status = readText(result, 'status')\n if (status) fields.push({ label: 'Status', value: status })\n return fields\n }\n case 'speech': {\n const seconds = readNumber(result, 'durationSeconds', 'duration')\n if (seconds !== undefined) fields.push({ label: 'Length', value: `${Math.round(seconds * 10) / 10} s` })\n if (preview.voice) fields.push({ label: 'Voice', value: preview.voice })\n return fields\n }\n case 'event': {\n if (preview.start) fields.push({ label: 'When', value: formatWhen(preview.start, preview.end) })\n if (preview.attendees.length) fields.push({ label: 'Guests', value: people(preview.attendees) })\n return fields\n }\n case 'call': {\n const status = readText(asRecord(result.call), 'status') ?? readText(result, 'status')\n if (status) fields.push({ label: 'Status', value: status })\n return fields\n }\n default: {\n const id = readText(result, 'id', 'number', 'key')\n if (id) fields.push({ label: 'ID', value: id, mono: true })\n const status = readText(result, 'status', 'state')\n if (status) fields.push({ label: 'Status', value: status })\n const name = readText(result, 'name', 'title')\n if (name) fields.push({ label: 'Name', value: clipped(name, 80) })\n return fields\n }\n }\n}\n\n/** A start and optional end in the viewer's locale: `Tue, Oct 14, 3:00 – 3:30 PM`. */\nexport function formatWhen(start: string, end?: string): string {\n const from = new Date(start)\n if (Number.isNaN(from.getTime())) return end ? `${start} – ${end}` : start\n const day = from.toLocaleDateString(undefined, { weekday: 'short', month: 'short', day: 'numeric' })\n const time = (date: Date) => date.toLocaleTimeString(undefined, { hour: 'numeric', minute: '2-digit' })\n const to = end ? new Date(end) : null\n if (!to || Number.isNaN(to.getTime())) return `${day}, ${time(from)}`\n return to.toDateString() === from.toDateString() ? `${day}, ${time(from)} – ${time(to)}` : `${day}, ${time(from)} – ${to.toLocaleDateString(undefined, { month: 'short', day: 'numeric' })}, ${time(to)}`\n}\n\nfunction receiptFiles(result: Record<string, unknown>): HubActionFile[] | undefined {\n if (!Array.isArray(result.files)) return undefined\n return result.files.flatMap((entry): HubActionFile[] => {\n const file = asRecord(entry)\n const path = text(file.path) ?? text(file.filename)\n if (!path) return []\n const status = text(file.status)\n const change = status === 'added' ? 'added' : status === 'removed' || status === 'deleted' ? 'deleted' : 'modified'\n return [{ path, change, additions: readNumber(file, 'additions'), deletions: readNumber(file, 'deletions') }]\n })\n}\n\n/** What a decided call did: its past-tense title, key fields, link, media and files. */\nexport function hubActionReceipt(item: HubApprovalItem): HubActionReceipt {\n const presentation = presentHubAction(item)\n const result = asRecord(unwrapHubResult(item.result))\n const status: HubActionReceipt['status'] = item.phase === 'done' || item.phase === 'failed' || item.phase === 'denied' || item.phase === 'expired'\n ? item.phase\n : item.phase === 'queued' || item.phase === 'running' ? 'running' : 'waiting'\n const base = { provider: presentation.provider, status }\n if (status === 'denied') return { ...base, title: `Denied: ${presentation.title}`, fields: [] }\n if (status === 'expired') return { ...base, title: `Expired: ${presentation.title}`, fields: [] }\n if (status === 'failed') return { ...base, title: `Could not ${presentation.action.charAt(0).toLowerCase()}${presentation.action.slice(1)}`, fields: [], ...(item.error ? { error: item.error } : {}) }\n if (status !== 'done') return { ...base, title: presentation.title, fields: [] }\n const title = receiptTitle(item, presentation, result)\n const fields = receiptFields(item, presentation, result)\n const pull = asRecord(result.pullRequest)\n const href = presentation.preview.kind === 'post'\n ? postLink(item, result)\n : resultLink(pull) ?? (item.actionPath.startsWith('github.git.') ? undefined : resultLink(result))\n const audio = readText(result, 'audioUrl')\n const seconds = readNumber(result, 'durationSeconds', 'duration')\n const files = receiptFiles(result)\n return {\n ...base,\n title,\n ...(href ? { href } : {}),\n fields,\n ...(files && files.length ? { files } : {}),\n ...(audio && /^https:\\/\\//.test(audio) ? { media: { kind: 'audio' as const, src: audio, ...(seconds !== undefined ? { seconds } : {}) } } : {}),\n }\n}\n","/**\n * `./hub-approvals` — Hub actions that wait on a person, in the owner's words.\n *\n * Pure and browser-safe: a host maps its held calls into {@link HubApprovalItem}s\n * and every surface — the approval dock above the composer, the Approvals list\n * beside the conversation, and the receipts in the transcript — renders the\n * same presentation from them. Servers use {@link summarizeHubResult} to store\n * a bounded result with the decision.\n */\n\nimport type { HubApprovalPhase } from './types'\n\nexport * from './types'\nexport {\n formatMinorAmount,\n formatWhen,\n hubActionFiles,\n hubActionReceipt,\n hubProviderName,\n pastTense,\n presentHubAction,\n splitHubActionPath,\n} from './present'\nexport { summarizeHubResult, unwrapHubResult } from './result'\n\n/** A phase as a status label. */\nexport const HUB_APPROVAL_PHASE_LABELS: Record<HubApprovalPhase, string> = {\n waiting: 'Waiting for you',\n blocked: 'Waiting for the owner',\n queued: 'Queued',\n running: 'Running',\n done: 'Done',\n failed: 'Failed',\n denied: 'Denied',\n expired: 'Expired',\n}\n\n/**\n * The part type marking a user message that resumes the agent after a\n * decision. The message's text goes to the agent unchanged; a transcript\n * renders the decided actions' receipts in its place, never a chat bubble.\n */\nexport const HUB_APPROVAL_RESUME_PART = 'hub-approval-resume'\n\nexport interface HubApprovalResumePart {\n type: typeof HUB_APPROVAL_RESUME_PART\n /** The assistant message whose held calls this resume reports. */\n messageId: string\n}\n\n/** The resume marker among a message's parts, if it carries one. */\nexport function hubApprovalResumePart(parts: ReadonlyArray<Record<string, unknown>> | null | undefined): HubApprovalResumePart | null {\n for (const part of parts ?? []) {\n if (part?.type === HUB_APPROVAL_RESUME_PART && typeof part.messageId === 'string' && part.messageId) {\n return { type: HUB_APPROVAL_RESUME_PART, messageId: part.messageId }\n }\n }\n return null\n}\n"],"mappings":";AAsBO,IAAM,2BAA0D,oBAAI,IAAI,CAAC,WAAW,SAAS,CAAC;AAE9F,IAAM,6BAA4D,oBAAI,IAAI,CAAC,UAAU,SAAS,CAAC;;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