@tangle-network/agent-app 0.60.30 → 0.60.32

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.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  agentSurfaceFiles
4
- } from "../chunk-XGPINAHY.js";
4
+ } from "../chunk-AVR6CAPX.js";
5
5
 
6
6
  // src/agent-surfaces/generate.ts
7
7
  import { mkdirSync, readFileSync, writeFileSync } from "fs";
@@ -10,7 +10,7 @@ import {
10
10
  renderHomeMarkdown,
11
11
  renderLlmsTxt,
12
12
  withVaryAccept
13
- } from "../chunk-XGPINAHY.js";
13
+ } from "../chunk-AVR6CAPX.js";
14
14
  export {
15
15
  AGENT_MANIFEST_SCHEMA_VERSION,
16
16
  TANGLE_PLATFORM_ORIGIN,
@@ -37,7 +37,15 @@ if (command === 'start') {
37
37
  if (flag('products')) request.products = flag('products').split(',').map((id) => id.trim()).filter(Boolean)
38
38
  if (flag('owner-email')) request.owner_email = flag('owner-email')
39
39
  if (flag('budget-usd')) request.budget_usd = Number(flag('budget-usd'))
40
- const started = await post('/cross-site/device/start', request)
40
+ let started = await post('/cross-site/device/start', request)
41
+ // Tangle caps the approval emails one owner receives. Past the cap the
42
+ // owner approves from the link the agent hands them instead.
43
+ let emailCapped = false
44
+ if (started.status === 429 && started.body.error === 'owner_notification_throttled' && request.owner_email) {
45
+ emailCapped = true
46
+ delete request.owner_email
47
+ started = await post('/cross-site/device/start', request)
48
+ }
41
49
  if (started.status !== 200) {
42
50
  console.error(\`Signup refused (HTTP \${started.status}): \${JSON.stringify(started.body)}\`)
43
51
  process.exit(1)
@@ -49,6 +57,9 @@ if (command === 'start') {
49
57
  expires_at: Date.now() + grant.expires_in * 1000,
50
58
  }
51
59
  writeFileSync(statePath, JSON.stringify(saved), { mode: 0o600 })
60
+ if (emailCapped) {
61
+ console.log('Tangle has already sent this owner the most approval emails it allows for now, so none was sent.')
62
+ }
52
63
  console.log(grant.agent?.owner_notified
53
64
  ? \`Approval email sent to \${request.owner_email}.\`
54
65
  : 'Send your owner this approval link.')
@@ -129,7 +140,7 @@ function signupSection(config) {
129
140
  code: `node tangle-signup.mjs start --agent-name "<your agent name>" --owner-email "<owner email>" --budget-usd ${budget}${config.signup.products ? ` --products ${config.signup.products.join(",")}` : ""}`
130
141
  }),
131
142
  "",
132
- "It prints the approval link and a confirmation code. Tangle emails the owner the same link; if you cannot give an email, omit `--owner-email` and send the owner the printed link yourself. Tell the owner the code if you can reach them.",
143
+ "It prints the approval link and a confirmation code. Tangle emails the owner the same link; if you cannot give an email, omit `--owner-email` and send the owner the printed link yourself. When Tangle has already sent that owner the most approval emails it allows, `start` says so and prints the link without emailing it: send it to the owner yourself. Tell the owner the code if you can reach them.",
133
144
  "",
134
145
  "Then wait for the approval. Each run returns within about 8 seconds: exit code 3 and `Still waiting` mean run it again; exit code 0 and `Approved` mean the key is saved. Keep each run short rather than wrapping it in one long blocking loop, since many agent tools stop long commands.",
135
146
  "",
@@ -411,4 +422,4 @@ export {
411
422
  withVaryAccept,
412
423
  createAgentSurfaceHandler
413
424
  };
414
- //# sourceMappingURL=chunk-XGPINAHY.js.map
425
+ //# sourceMappingURL=chunk-AVR6CAPX.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/agent-surfaces/index.ts"],"sourcesContent":["/**\n * Machine-readable surfaces for a Tangle product, generated from one config.\n *\n * Every product publishes the same four things an AI agent needs to become a\n * customer without a human doing the setup:\n *\n * - `/agent-setup.md`: a SKILL.md (Claude Code and Codex skill format) that\n * doubles as a copy-paste prompt. It takes a fresh agent from nothing to a\n * verified first call: one owner approval, a scoped key, install, call.\n * - `/llms.txt`: the llms.txt index, pointing at the setup skill first.\n * - `/.well-known/tangle-agent.json`: the Tangle agent manifest.\n * - Markdown for `Accept: text/markdown` on the product's pages, with\n * `Vary: Accept` on both representations so caches keep them apart.\n *\n * The signup section is rendered here, not in product config, so every\n * product describes Platform's agent signup identically and cannot drift.\n *\n * Web-standard `Request`/`Response` only: safe in Workers, Node and browsers.\n */\n\n/** Manifest schema this module emits. Additive over the 2026-06-16 shape. */\nexport const AGENT_MANIFEST_SCHEMA_VERSION = '2026-10-09'\n\nexport const TANGLE_PLATFORM_ORIGIN = 'https://id.tangle.tools'\n\nexport interface AgentSurfaceStep {\n title: string\n /** Fence language for the code block. */\n language: 'bash' | 'js' | 'ts' | 'python' | 'json'\n code: string\n /** What a successful run prints or returns. */\n expect: string\n}\n\nexport interface AgentSurfaceError {\n symptom: string\n cause: string\n fix: string\n}\n\nexport interface AgentSurfaceLink {\n label: string\n url: string\n}\n\n/**\n * How an agent obtains a key. `device` uses Platform's agent signup: the owner\n * approves once and the agent receives its own capped, revocable key.\n */\nexport type AgentSignup =\n | {\n kind: 'device'\n /**\n * Products to ask for. Omitted, the one signup asks for every\n * agent-ready product, so the same key works across Tangle.\n */\n products?: string[]\n /** Default lifetime spend cap the skill asks for, in USD. */\n budgetUsd?: number\n }\n | {\n kind: 'manual'\n /** Numbered steps the owner performs; each one is a human input. */\n steps: string[]\n }\n\nexport interface AgentSurfaceConfig {\n /** Short id used in the skill name: `tangle-<id>-setup`. */\n id: string\n name: string\n /** Public HTTPS origin, no trailing slash. */\n origin: string\n /** What the product is for, in one to three plain sentences. */\n summary: string\n useWhen: string[]\n signup: AgentSignup\n /** Environment variable the key is exported as. */\n apiKeyEnv: string\n /** Runtime prerequisites a fresh machine needs, e.g. `Node.js 20 or newer`. */\n prerequisites: string[]\n install: AgentSurfaceStep[]\n firstCall: AgentSurfaceStep[]\n verify: AgentSurfaceStep[]\n errors: AgentSurfaceError[]\n pricing: {\n /** Plain statement of how usage is charged. */\n summary: string\n /** Public, credential-free price data an agent can quote from. */\n quoteUrl?: string\n url?: string\n }\n next: AgentSurfaceLink[]\n docs?: string\n openapi?: string\n mcp?: { url: string; auth: string }\n related?: Array<{ name: string; manifest?: string; url?: string }>\n /** Extra manifest fields a product already publishes (kept verbatim). */\n manifest?: Record<string, unknown>\n}\n\nexport interface AgentSurfaceFile {\n path: string\n contentType: string\n body: string\n}\n\nconst MARKDOWN = 'text/markdown; charset=utf-8'\n\nfunction trimOrigin(origin: string): string {\n return origin.replace(/\\/+$/, '')\n}\n\nfunction fence(step: Pick<AgentSurfaceStep, 'language' | 'code'>): string {\n return ['```' + step.language, step.code.trimEnd(), '```'].join('\\n')\n}\n\n/**\n * The signup script the skill tells an agent to save and run. Node 18+ only,\n * no dependencies, in two short commands so a tool that kills long-running\n * commands cannot cut the wait: `start` returns at once with the link and the\n * confirmation code; `wait` polls for a few seconds and exits 0 once approved\n * or 3 while the owner has not approved yet. It never prints the key; it\n * writes `.tangle/api-key` with mode 0600.\n */\nexport function agentSignupScript(platformOrigin = TANGLE_PLATFORM_ORIGIN): string {\n // The specifier is interpolated so this module's own import scan (the\n // browser-safe subpath gate) does not read script text as an import.\n return `// Requests a scoped Tangle key for this agent. The owner approves once.\n// node tangle-signup.mjs start --agent-name <name> [--owner-email <email>] [--budget-usd <n>] [--products a,b]\n// node tangle-signup.mjs wait (run again while it exits 3; exits 0 once approved)\nimport { mkdirSync, readFileSync, writeFileSync } from ${JSON.stringify('node:fs')}\n\nconst command = process.argv[2]\nconst flag = (name) => {\n const index = process.argv.indexOf(\\`--\\${name}\\`)\n return index > 0 ? process.argv[index + 1] : undefined\n}\nconst platform = '${trimOrigin(platformOrigin)}'\nconst statePath = '.tangle/signup.json'\nmkdirSync('.tangle', { recursive: true, mode: 0o700 })\n\nasync function post(path, body) {\n const response = await fetch(platform + path, {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify(body),\n })\n return { status: response.status, body: await response.json().catch(() => ({})) }\n}\n\nif (command === 'start') {\n const request = { agent_name: flag('agent-name') ?? 'coding-agent' }\n if (flag('products')) request.products = flag('products').split(',').map((id) => id.trim()).filter(Boolean)\n if (flag('owner-email')) request.owner_email = flag('owner-email')\n if (flag('budget-usd')) request.budget_usd = Number(flag('budget-usd'))\n let started = await post('/cross-site/device/start', request)\n // Tangle caps the approval emails one owner receives. Past the cap the\n // owner approves from the link the agent hands them instead.\n let emailCapped = false\n if (started.status === 429 && started.body.error === 'owner_notification_throttled' && request.owner_email) {\n emailCapped = true\n delete request.owner_email\n started = await post('/cross-site/device/start', request)\n }\n if (started.status !== 200) {\n console.error(\\`Signup refused (HTTP \\${started.status}): \\${JSON.stringify(started.body)}\\`)\n process.exit(1)\n }\n const grant = started.body.data\n const saved = {\n device_code: grant.device_code,\n interval: grant.interval,\n expires_at: Date.now() + grant.expires_in * 1000,\n }\n writeFileSync(statePath, JSON.stringify(saved), { mode: 0o600 })\n if (emailCapped) {\n console.log('Tangle has already sent this owner the most approval emails it allows for now, so none was sent.')\n }\n console.log(grant.agent?.owner_notified\n ? \\`Approval email sent to \\${request.owner_email}.\\`\n : 'Send your owner this approval link.')\n console.log(\\`Approval link: \\${grant.verification_uri_complete}\\`)\n console.log(\\`Confirmation code: \\${grant.user_code} (expires in \\${Math.round(grant.expires_in / 60)} minutes)\\`)\n console.log('Next: run \\`node tangle-signup.mjs wait\\` until it prints Approved.')\n process.exit(0)\n}\n\nif (command === 'wait') {\n let saved\n try {\n saved = JSON.parse(readFileSync(statePath, 'utf8'))\n } catch {\n console.error('No pending signup. Run \\`node tangle-signup.mjs start\\` first.')\n process.exit(1)\n }\n const stopAt = Math.min(saved.expires_at, Date.now() + Number(flag('seconds') ?? 8) * 1000)\n for (;;) {\n const polled = await post('/cross-site/device/poll', { device_code: saved.device_code })\n if (polled.status === 200) {\n const { api_key: apiKey, key, account } = polled.body.data\n writeFileSync('.tangle/api-key', \\`\\${apiKey}\\\\n\\`, { mode: 0o600 })\n console.log(\\`Approved. Key \"\\${key?.name ?? 'agent'}\" saved to .tangle/api-key for \\${(key?.products ?? []).join(', ') || 'the approved products'} (spend cap $\\${key?.budget_usd ?? 'none'}).\\`)\n if (account && !account.funded) {\n console.log(\\`The owner's account has no credit yet. Ask the owner to add credits: \\${account.add_credits_url}\\`)\n }\n process.exit(0)\n }\n if (polled.status !== 428) {\n console.error(\\`Approval failed (HTTP \\${polled.status}): \\${JSON.stringify(polled.body)}\\`)\n process.exit(1)\n }\n if (Date.now() >= saved.expires_at) {\n console.error('The approval link expired. Run \\`node tangle-signup.mjs start\\` again.')\n process.exit(1)\n }\n if (Date.now() + saved.interval * 1000 > stopAt) {\n console.log('Still waiting for the owner to approve. Run \\`node tangle-signup.mjs wait\\` again.')\n process.exit(3)\n }\n await new Promise((resolve) => setTimeout(resolve, saved.interval * 1000))\n }\n}\n\nconsole.error('Usage: node tangle-signup.mjs start --agent-name <name> [--owner-email <email>] [--budget-usd <n>] [--products a,b] | wait')\nprocess.exit(2)\n`\n}\n\nfunction signupSection(config: AgentSurfaceConfig): string[] {\n const env = config.apiKeyEnv\n if (config.signup.kind === 'manual') {\n return [\n '## 1. Get a key',\n '',\n 'This product does not yet support agent signup. Ask your owner to do the following, then continue:',\n '',\n ...config.signup.steps.map((step, index) => `${index + 1}. ${step}`),\n '',\n `Store the key outside version control and export it as \\`${env}\\`. Never print, log, or commit it.`,\n ]\n }\n const budget = config.signup.budgetUsd ?? 25\n return [\n '## 1. Get a scoped key (one owner approval)',\n '',\n 'Tangle issues each agent one key, owned by a person who approves it once. The same key works for every Tangle product the owner approves: Tangle Sandbox, Tangle Router and the agent apps such as Tangle GTM Agent. If you already hold one from another Tangle product\\'s setup, reuse it and skip to step 2.',\n `Ask your owner which email address their Tangle account uses (or should use). Nothing is charged by signing up, and there is no free credit: ${config.name} work is paid from the owner's prepaid balance.`,\n '',\n 'Save this script as `tangle-signup.mjs` (Node.js 18 or newer, no dependencies):',\n '',\n fence({ language: 'js', code: agentSignupScript() }),\n '',\n 'Start the request with your own name and the owner\\'s email. It returns at once:',\n '',\n fence({\n language: 'bash',\n code: `node tangle-signup.mjs start --agent-name \"<your agent name>\" --owner-email \"<owner email>\" --budget-usd ${budget}${config.signup.products ? ` --products ${config.signup.products.join(',')}` : ''}`,\n }),\n '',\n 'It prints the approval link and a confirmation code. Tangle emails the owner the same link; if you cannot give an email, omit `--owner-email` and send the owner the printed link yourself. When Tangle has already sent that owner the most approval emails it allows, `start` says so and prints the link without emailing it: send it to the owner yourself. Tell the owner the code if you can reach them.',\n '',\n 'Then wait for the approval. Each run returns within about 8 seconds: exit code 3 and `Still waiting` mean run it again; exit code 0 and `Approved` mean the key is saved. Keep each run short rather than wrapping it in one long blocking loop, since many agent tools stop long commands.',\n '',\n fence({ language: 'bash', code: 'node tangle-signup.mjs wait' }),\n '',\n 'What the owner does, once: sign in (or create an account and verify the email), check the confirmation code, and approve. That is the only human step.',\n '',\n `The key in \\`.tangle/api-key\\` (mode 600) works only for the products the owner approved, can spend at most the cap you requested across all of them, and the owner can revoke it once under Keys to stop it everywhere. If \\`wait\\` says the account has no credit, ask the owner to add credits at the printed link before your first paid call.`,\n '',\n 'Then load the key without printing it, and keep it out of version control:',\n '',\n fence({\n language: 'bash',\n code: `export ${env}=\"$(cat .tangle/api-key)\"\\ngrep -qxF '.tangle/' .gitignore 2>/dev/null || echo '.tangle/' >> .gitignore`,\n }),\n '',\n 'Never print, log, paste, or commit the key.',\n ]\n}\n\nfunction stepsSection(heading: string, steps: AgentSurfaceStep[]): string[] {\n if (steps.length === 0) return []\n const lines = [heading, '']\n for (const step of steps) {\n lines.push(`${step.title}:`, '', fence(step), '', `Expected: ${step.expect}`, '')\n }\n return lines\n}\n\n/** The agent setup skill: valid SKILL.md and a plain copy-paste prompt. */\nexport function renderAgentSetupSkill(config: AgentSurfaceConfig): string {\n const origin = trimOrigin(config.origin)\n const install = config.install.length > 0 ? ', install the client' : ''\n const description = `Set up ${config.name} for this agent end to end: get a scoped API key with one owner approval${install}, make the first successful call, and verify it.`\n // Signup is step 1; the sections a product has are numbered on from there,\n // so a product with nothing to install reads 1, 2, 3.\n const sections = ([\n ['Install', config.install],\n ['Make the first call', config.firstCall],\n ['Verify it worked', config.verify],\n ] as const).filter(([, steps]) => steps.length > 0)\n const lines: string[] = [\n '---',\n `name: tangle-${config.id}-setup`,\n `description: ${description}`,\n '---',\n '',\n `# Set up ${config.name}`,\n '',\n config.summary,\n '',\n 'Use it when:',\n '',\n ...config.useWhen.map((item) => `- ${item}`),\n '',\n 'Complete every step below in order and stop at the first failure; the error table at the end names the fix.',\n 'Prerequisites: ' + config.prerequisites.join('; ') + '.',\n '',\n ...signupSection(config),\n '',\n ...sections.flatMap(([title, steps], index) => stepsSection(`## ${index + 2}. ${title}`, steps)),\n '## Common errors',\n '',\n '| Symptom | Cause | Fix |',\n '| --- | --- | --- |',\n ...config.errors.map(\n (error) => `| ${error.symptom.replace(/\\|/g, '\\\\|')} | ${error.cause.replace(/\\|/g, '\\\\|')} | ${error.fix.replace(/\\|/g, '\\\\|')} |`,\n ),\n '',\n '## Pricing',\n '',\n config.pricing.summary,\n ...(config.pricing.quoteUrl ? ['', `Current prices, no key needed: ${config.pricing.quoteUrl}`] : []),\n ...(config.pricing.url ? [`Pricing page: ${config.pricing.url}`] : []),\n '',\n '## Next',\n '',\n ...config.next.map((link) => `- [${link.label}](${link.url})`),\n '',\n '## Machine-readable surfaces',\n '',\n `- Agent manifest: ${origin}/.well-known/tangle-agent.json`,\n `- llms.txt: ${origin}/llms.txt`,\n `- This setup skill: ${origin}/agent-setup.md`,\n ...(config.openapi ? [`- OpenAPI: ${config.openapi}`] : []),\n ...(config.mcp ? [`- MCP server: ${config.mcp.url} (${config.mcp.auth})`] : []),\n '',\n ]\n return lines.join('\\n')\n}\n\n/** llms.txt index for the product. The setup skill is the first link. */\nexport function renderLlmsTxt(config: AgentSurfaceConfig): string {\n const origin = trimOrigin(config.origin)\n return [\n `# ${config.name}`,\n '',\n `> ${config.summary}`,\n '',\n `To set this product up from scratch, fetch ${origin}/agent-setup.md and follow it. It is a complete prompt and a SKILL.md: one owner approval, a scoped key, install, first call, verification.`,\n '',\n '## Start here',\n '',\n `- [Agent setup skill](${origin}/agent-setup.md): from nothing to a verified first call`,\n `- [Agent manifest](${origin}/.well-known/tangle-agent.json): machine-readable contract`,\n ...(config.openapi ? [`- [OpenAPI](${config.openapi}): HTTP API schema`] : []),\n ...(config.mcp ? [`- [MCP server](${config.mcp.url}): ${config.mcp.auth}`] : []),\n ...(config.docs ? [`- [Documentation](${config.docs})`] : []),\n '',\n '## Pricing',\n '',\n `- ${config.pricing.summary}`,\n ...(config.pricing.quoteUrl ? [`- [Machine-readable prices](${config.pricing.quoteUrl}): no key needed`] : []),\n '',\n '## Optional',\n '',\n ...config.next.map((link) => `- [${link.label}](${link.url})`),\n ...(config.related ?? []).map(\n (surface) => `- [${surface.name}](${surface.manifest ?? surface.url ?? ''})`,\n ),\n '',\n ].join('\\n')\n}\n\n/** Markdown for the product's home page, served for `Accept: text/markdown`. */\nexport function renderHomeMarkdown(config: AgentSurfaceConfig): string {\n const origin = trimOrigin(config.origin)\n return [\n `# ${config.name}`,\n '',\n config.summary,\n '',\n '## Use it when',\n '',\n ...config.useWhen.map((item) => `- ${item}`),\n '',\n '## Hand this to your agent',\n '',\n `An AI agent can set ${config.name} up by itself: fetch ${origin}/agent-setup.md and follow it. The owner approves once; nothing else needs a human.`,\n '',\n '## Pricing',\n '',\n config.pricing.summary,\n ...(config.pricing.quoteUrl ? ['', `Machine-readable prices: ${config.pricing.quoteUrl}`] : []),\n '',\n '## Machine-readable surfaces',\n '',\n `- ${origin}/llms.txt`,\n `- ${origin}/.well-known/tangle-agent.json`,\n `- ${origin}/agent-setup.md`,\n ...(config.openapi ? [`- ${config.openapi}`] : []),\n ...(config.mcp ? [`- ${config.mcp.url}`] : []),\n '',\n ].join('\\n')\n}\n\n/** The `/.well-known/tangle-agent.json` document. */\nexport function renderAgentManifest(config: AgentSurfaceConfig): Record<string, unknown> {\n const origin = trimOrigin(config.origin)\n const signup =\n config.signup.kind === 'device'\n ? {\n kind: 'device_authorization',\n start: `POST ${TANGLE_PLATFORM_ORIGIN}/cross-site/device/start`,\n poll: `POST ${TANGLE_PLATFORM_ORIGIN}/cross-site/device/poll`,\n contract: `${TANGLE_PLATFORM_ORIGIN}/.well-known/tangle-agent.json`,\n request: {\n agent_name: 'string, 1-64 characters',\n owner_email: 'optional; Tangle emails this owner the approval link',\n budget_usd: `optional lifetime spend cap shared by every granted product, 1-1000, default ${config.signup.budgetUsd ?? 25}`,\n products: config.signup.products ?? 'optional; default every agent-ready product, or [\"*\"]',\n },\n human_inputs: ['The owner approves the request once.'],\n key: {\n scope: 'One key for every product the owner approved; use it as Bearer at each product.',\n revocable_at: `${TANGLE_PLATFORM_ORIGIN}/app/keys`,\n },\n payment: 'Prepaid credit on the owner account. No free credit; paid calls are refused until the owner adds credits.',\n add_credits: `${TANGLE_PLATFORM_ORIGIN}/app/billing`,\n }\n : { kind: 'manual', steps: config.signup.steps }\n return {\n ...config.manifest,\n schema_version: AGENT_MANIFEST_SCHEMA_VERSION,\n name: config.name,\n description: config.summary,\n homepage: `${origin}/`,\n llms: `${origin}/llms.txt`,\n agent_setup: `${origin}/agent-setup.md`,\n ...(config.docs ? { docs: config.docs } : {}),\n ...(config.openapi ? { openapi: config.openapi } : {}),\n ...(config.mcp ? { mcp: config.mcp } : {}),\n environment: { api_key: config.apiKeyEnv },\n signup,\n pricing: {\n summary: config.pricing.summary,\n ...(config.pricing.quoteUrl ? { quote: config.pricing.quoteUrl } : {}),\n ...(config.pricing.url ? { page: config.pricing.url } : {}),\n },\n ...(config.related?.length ? { related_surfaces: config.related } : {}),\n }\n}\n\n/** Every static surface as files, for products that ship them as assets. */\nexport function agentSurfaceFiles(config: AgentSurfaceConfig): AgentSurfaceFile[] {\n return [\n { path: 'agent-setup.md', contentType: MARKDOWN, body: renderAgentSetupSkill(config) },\n { path: 'llms.txt', contentType: 'text/plain; charset=utf-8', body: renderLlmsTxt(config) },\n { path: 'index.md', contentType: MARKDOWN, body: renderHomeMarkdown(config) },\n {\n path: '.well-known/tangle-agent.json',\n contentType: 'application/json; charset=utf-8',\n body: `${JSON.stringify(renderAgentManifest(config), null, 2)}\\n`,\n },\n ]\n}\n\n/**\n * True when `Accept` ranks `text/markdown` strictly above `text/html` and\n * gives it a nonzero weight. A browser's default header never does.\n */\nexport function prefersMarkdown(accept: string | null | undefined): boolean {\n if (!accept) return false\n let markdown = -1\n let html = -1\n for (const part of accept.split(',')) {\n const [rawType, ...params] = part.trim().split(';')\n const type = rawType?.trim().toLowerCase()\n let quality = 1\n for (const param of params) {\n const [key, value] = param.trim().split('=')\n if (key?.trim().toLowerCase() === 'q') {\n const parsed = Number(value)\n quality = Number.isFinite(parsed) ? parsed : 0\n }\n }\n if (type === 'text/markdown') markdown = Math.max(markdown, quality)\n if (type === 'text/html') html = Math.max(html, quality)\n }\n return markdown > 0 && markdown > html\n}\n\n/** A copy of `response` whose `Vary` includes `Accept`. */\nexport function withVaryAccept(response: Response): Response {\n const vary = response.headers.get('vary')\n if (vary && vary.split(',').some((value) => value.trim().toLowerCase() === 'accept')) {\n return response\n }\n const headers = new Headers(response.headers)\n headers.set('vary', vary ? `${vary}, Accept` : 'Accept')\n return new Response(response.body, {\n status: response.status,\n statusText: response.statusText,\n headers,\n })\n}\n\nexport interface AgentSurfaceHandler {\n /**\n * Answers a surface request (`/agent-setup.md`, `/llms.txt`, the manifest,\n * or a negotiated markdown page), or `null` to let the app answer it.\n */\n handle(request: Request): Response | null\n /** Adds `Vary: Accept` when the path has a markdown representation. */\n finalize(request: Request, response: Response): Response\n}\n\n/**\n * Request handler over {@link agentSurfaceFiles}. `markdownPages` maps extra\n * HTML paths to markdown served on negotiation; `/` always maps to the home\n * markdown.\n */\nexport function createAgentSurfaceHandler(\n config: AgentSurfaceConfig,\n options: { markdownPages?: Record<string, string> } = {},\n): AgentSurfaceHandler {\n const files = new Map(agentSurfaceFiles(config).map((file) => [`/${file.path}`, file]))\n const negotiated = new Map<string, string>([\n ['/', renderHomeMarkdown(config)],\n ...Object.entries(options.markdownPages ?? {}),\n ])\n\n function respond(body: string, contentType: string, method: string, vary: boolean): Response {\n const headers = new Headers({\n 'content-type': contentType,\n 'cache-control': 'public, max-age=300',\n 'x-content-type-options': 'nosniff',\n })\n if (vary) headers.set('vary', 'Accept')\n return new Response(method === 'HEAD' ? null : body, { status: 200, headers })\n }\n\n return {\n handle(request) {\n if (request.method !== 'GET' && request.method !== 'HEAD') return null\n const path = new URL(request.url).pathname\n const file = files.get(path)\n if (file) return respond(file.body, file.contentType, request.method, false)\n const markdown = negotiated.get(path)\n if (markdown !== undefined && prefersMarkdown(request.headers.get('accept'))) {\n return respond(markdown, MARKDOWN, request.method, true)\n }\n return null\n },\n finalize(request, response) {\n return negotiated.has(new URL(request.url).pathname) ? withVaryAccept(response) : response\n },\n }\n}\n"],"mappings":";AAqBO,IAAM,gCAAgC;AAEtC,IAAM,yBAAyB;AAmFtC,IAAM,WAAW;AAEjB,SAAS,WAAW,QAAwB;AAC1C,SAAO,OAAO,QAAQ,QAAQ,EAAE;AAClC;AAEA,SAAS,MAAM,MAA2D;AACxE,SAAO,CAAC,QAAQ,KAAK,UAAU,KAAK,KAAK,QAAQ,GAAG,KAAK,EAAE,KAAK,IAAI;AACtE;AAUO,SAAS,kBAAkB,iBAAiB,wBAAgC;AAGjF,SAAO;AAAA;AAAA;AAAA,yDAGgD,KAAK,UAAU,SAAS,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAO9D,WAAW,cAAc,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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MAAM,IAAI,IAAI;AAC3B,UAAI,KAAM,QAAO,QAAQ,KAAK,MAAM,KAAK,aAAa,QAAQ,QAAQ,KAAK;AAC3E,YAAM,WAAW,WAAW,IAAI,IAAI;AACpC,UAAI,aAAa,UAAa,gBAAgB,QAAQ,QAAQ,IAAI,QAAQ,CAAC,GAAG;AAC5E,eAAO,QAAQ,UAAU,UAAU,QAAQ,QAAQ,IAAI;AAAA,MACzD;AACA,aAAO;AAAA,IACT;AAAA,IACA,SAAS,SAAS,UAAU;AAC1B,aAAO,WAAW,IAAI,IAAI,IAAI,QAAQ,GAAG,EAAE,QAAQ,IAAI,eAAe,QAAQ,IAAI;AAAA,IACpF;AAAA,EACF;AACF;","names":[]}
@@ -45,7 +45,7 @@ function HubProviderMark({ providerId, name, size = 28 }) {
45
45
  }
46
46
  );
47
47
  }
48
- function HubRawDetails({ sections }) {
48
+ function HubRawDetails({ sections, label = "Details" }) {
49
49
  const [open, setOpen] = useState(false);
50
50
  const shown = sections.filter((section) => section.value !== void 0 && section.value !== null && section.value !== "");
51
51
  if (shown.length === 0) return null;
@@ -59,7 +59,7 @@ function HubRawDetails({ sections }) {
59
59
  className: "inline-flex min-h-8 items-center gap-1 rounded-md text-sm font-medium text-muted-foreground hover:text-foreground",
60
60
  children: [
61
61
  /* @__PURE__ */ jsx(ChevronRight, { "aria-hidden": true, className: `size-4 transition-transform ${open ? "rotate-90" : ""}` }),
62
- "Details"
62
+ label
63
63
  ]
64
64
  }
65
65
  ),
@@ -437,34 +437,33 @@ function HubApprovalDock({ items, onDecide, permissions, onOpen, focusId, classN
437
437
  "data-hub-approval-dock": active.id,
438
438
  className: `overflow-hidden rounded-2xl border border-[var(--surface-warning-border)] bg-card shadow-md ${className}`,
439
439
  children: [
440
- /* @__PURE__ */ jsxs3("div", { className: "flex items-start gap-3 px-4 pt-3", children: [
440
+ /* @__PURE__ */ jsxs3("div", { className: "flex flex-wrap items-start gap-x-3 gap-y-1 px-4 pt-3", children: [
441
441
  /* @__PURE__ */ jsx3(HubProviderMark, { providerId: presentation.provider.id, name: presentation.provider.name, size: 32 }),
442
442
  /* @__PURE__ */ jsxs3("div", { className: "min-w-0 flex-1", children: [
443
443
  /* @__PURE__ */ jsx3("h3", { className: "line-clamp-2 break-words text-base font-semibold leading-6 text-foreground", title: presentation.title, children: presentation.title }),
444
444
  /* @__PURE__ */ jsx3("p", { className: "truncate text-sm text-muted-foreground", children: subtitle })
445
445
  ] }),
446
- /* @__PURE__ */ jsxs3("div", { className: "flex shrink-0 items-center gap-1", children: [
447
- queue.length > 1 && /* @__PURE__ */ jsxs3(Fragment, { children: [
448
- /* @__PURE__ */ jsx3(Button2, { variant: "ghost", size: "icon-sm", "aria-label": "Previous request", onClick: () => step(-1), children: /* @__PURE__ */ jsx3(ChevronLeft, {}) }),
449
- /* @__PURE__ */ jsxs3("span", { className: "min-w-14 text-center text-sm tabular-nums text-muted-foreground", "aria-live": "polite", children: [
450
- activeIndex + 1,
451
- " of ",
452
- queue.length
453
- ] }),
454
- /* @__PURE__ */ jsx3(Button2, { variant: "ghost", size: "icon-sm", "aria-label": "Next request", onClick: () => step(1), children: /* @__PURE__ */ jsx3(ChevronRight2, {}) })
446
+ /* @__PURE__ */ jsx3(
447
+ Button2,
448
+ {
449
+ variant: "ghost",
450
+ size: "icon-sm",
451
+ className: "sm:order-last",
452
+ "aria-label": collapsed ? "Show the request" : "Hide the preview",
453
+ "aria-expanded": !collapsed,
454
+ onClick: () => setCollapsed((value) => !value),
455
+ children: /* @__PURE__ */ jsx3(ChevronDown, { className: `transition-transform ${collapsed ? "-rotate-90" : ""}` })
456
+ }
457
+ ),
458
+ queue.length > 1 && /* @__PURE__ */ jsx3("div", { className: "flex w-full items-center justify-end gap-1 sm:w-auto", children: /* @__PURE__ */ jsxs3(Fragment, { children: [
459
+ /* @__PURE__ */ jsx3(Button2, { variant: "ghost", size: "icon-sm", "aria-label": "Previous request", onClick: () => step(-1), children: /* @__PURE__ */ jsx3(ChevronLeft, {}) }),
460
+ /* @__PURE__ */ jsxs3("span", { className: "min-w-14 text-center text-sm tabular-nums text-muted-foreground", "aria-live": "polite", children: [
461
+ activeIndex + 1,
462
+ " of ",
463
+ queue.length
455
464
  ] }),
456
- /* @__PURE__ */ jsx3(
457
- Button2,
458
- {
459
- variant: "ghost",
460
- size: "icon-sm",
461
- "aria-label": collapsed ? "Show the request" : "Hide the preview",
462
- "aria-expanded": !collapsed,
463
- onClick: () => setCollapsed((value) => !value),
464
- children: /* @__PURE__ */ jsx3(ChevronDown, { className: `transition-transform ${collapsed ? "-rotate-90" : ""}` })
465
- }
466
- )
467
- ] })
465
+ /* @__PURE__ */ jsx3(Button2, { variant: "ghost", size: "icon-sm", "aria-label": "Next request", onClick: () => step(1), children: /* @__PURE__ */ jsx3(ChevronRight2, {}) })
466
+ ] }) })
468
467
  ] }),
469
468
  !collapsed && /* @__PURE__ */ jsxs3("div", { className: "max-h-64 space-y-3 overflow-y-auto px-4 pt-3 sm:max-h-96", children: [
470
469
  active.bundle?.steps && active.bundle.steps.length > 0 && /* @__PURE__ */ jsx3("ol", { className: "space-y-1 text-sm", "aria-label": "Steps this approval covers", children: active.bundle.steps.map((stepItem, index) => /* @__PURE__ */ jsxs3("li", { className: `flex items-center gap-2 ${stepItem.state === "current" ? "font-medium text-foreground" : "text-muted-foreground"}`, children: [
@@ -662,7 +661,7 @@ function HubApprovalReceipts({ items, message, at }) {
662
661
  ] })
663
662
  ] }),
664
663
  decided.map((item) => /* @__PURE__ */ jsx5(HubActionReceiptCard, { item }, item.id)),
665
- message && /* @__PURE__ */ jsx5(HubRawDetails, { sections: [{ label: "Message sent to the agent", value: message }] })
664
+ message && /* @__PURE__ */ jsx5(HubRawDetails, { label: "Message sent to the agent", sections: [{ label: "The agent received", value: message }] })
666
665
  ] });
667
666
  }
668
667
 
@@ -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 { HUB_APPROVAL_UNKNOWN_WARNING } from '../hub-approvals/unknown'\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; open, running and uncertain calls stay visible until resolved or dismissed. */\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 === 'unknown') {\n return (\n <p role=\"alert\" className=\"break-words text-sm text-[var(--surface-warning-text)]\">\n <span className=\"font-medium\">May have run.</span> {HUB_APPROVAL_UNKNOWN_WARNING}\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. Uncertain outcomes also stay\n // visible after remount or status reload, until dismissed in this session.\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' || item.phase === 'unknown')) 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.phase === 'unknown'\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={active.phase === 'unknown' ? 'Action may have run' : '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 && active.phase === 'waiting' && <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' || active.phase === 'unknown') && (\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 unknown: 'warning',\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(/&nbsp;/g, ' ')\n .replace(/&amp;/g, '&')\n .replace(/&lt;/g, '<')\n .replace(/&gt;/g, '>')\n .replace(/&quot;/g, '\"')\n .replace(/&#39;/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 { HUB_APPROVAL_UNKNOWN_WARNING } from '../hub-approvals/unknown'\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 // Uncertain effects need provider verification, separate from confirmed failures.\n { id: 'unknown', label: 'May have run', phases: ['unknown'] },\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 {item.phase === 'unknown' && <span className=\"mt-1 block text-sm text-[var(--surface-warning-text)]\">{HUB_APPROVAL_UNKNOWN_WARNING}</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 { HUB_APPROVAL_UNKNOWN_WARNING } from '../hub-approvals/unknown'\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 settled calls; suppressed for unknown outcomes to prevent unsafe retries. */\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 && item.phase === 'unknown' && (\n <p className=\"px-3 pb-3 text-sm text-[var(--surface-warning-text)]\">{HUB_APPROVAL_UNKNOWN_WARNING}</p>\n )}\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' || item.phase === 'unknown'\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 {item.phase !== 'unknown' && 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 || receipt.warning) && (\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.warning && (\n <p className=\"break-words rounded-lg border border-[var(--surface-warning-border)] bg-[var(--surface-warning-bg)] px-3 py-2 text-sm text-[var(--surface-warning-text)]\">\n {receipt.warning}\n </p>\n )}\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', 'unknown'])\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;AAmBhD,cA0BE,YA1BF;AAfJ,IAAM,cAAoD;AAAA,EACxD,SAAS;AAAA,EACT,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,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;AAE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AA,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 { HUB_APPROVAL_UNKNOWN_WARNING } from '../hub-approvals/unknown'\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; open, running and uncertain calls stay visible until resolved or dismissed. */\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 === 'unknown') {\n return (\n <p role=\"alert\" className=\"break-words text-sm text-[var(--surface-warning-text)]\">\n <span className=\"font-medium\">May have run.</span> {HUB_APPROVAL_UNKNOWN_WARNING}\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. Uncertain outcomes also stay\n // visible after remount or status reload, until dismissed in this session.\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' || item.phase === 'unknown')) 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.phase === 'unknown'\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={active.phase === 'unknown' ? 'Action may have run' : '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 flex-wrap items-start gap-x-3 gap-y-1 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 <Button\n variant=\"ghost\"\n size=\"icon-sm\"\n className=\"sm:order-last\"\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 {/* On a phone the pager takes its own row, so the title keeps the width. */}\n {queue.length > 1 && (\n <div className=\"flex w-full items-center justify-end gap-1 sm:w-auto\">\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 </div>\n )}\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 && active.phase === 'waiting' && <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' || active.phase === 'unknown') && (\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 unknown: 'warning',\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, label = 'Details' }: { sections: ReadonlyArray<{ label: string; value: unknown }>; label?: string }) {\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 {label}\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(/&nbsp;/g, ' ')\n .replace(/&amp;/g, '&')\n .replace(/&lt;/g, '<')\n .replace(/&gt;/g, '>')\n .replace(/&quot;/g, '\"')\n .replace(/&#39;/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 { HUB_APPROVAL_UNKNOWN_WARNING } from '../hub-approvals/unknown'\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 // Uncertain effects need provider verification, separate from confirmed failures.\n { id: 'unknown', label: 'May have run', phases: ['unknown'] },\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 {item.phase === 'unknown' && <span className=\"mt-1 block text-sm text-[var(--surface-warning-text)]\">{HUB_APPROVAL_UNKNOWN_WARNING}</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 { HUB_APPROVAL_UNKNOWN_WARNING } from '../hub-approvals/unknown'\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 settled calls; suppressed for unknown outcomes to prevent unsafe retries. */\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 && item.phase === 'unknown' && (\n <p className=\"px-3 pb-3 text-sm text-[var(--surface-warning-text)]\">{HUB_APPROVAL_UNKNOWN_WARNING}</p>\n )}\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' || item.phase === 'unknown'\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 {item.phase !== 'unknown' && 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 || receipt.warning) && (\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.warning && (\n <p className=\"break-words rounded-lg border border-[var(--surface-warning-border)] bg-[var(--surface-warning-bg)] px-3 py-2 text-sm text-[var(--surface-warning-text)]\">\n {receipt.warning}\n </p>\n )}\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', 'unknown'])\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 label=\"Message sent to the agent\" sections={[{ label: 'The agent received', value: message }]} />}\n </section>\n )\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,WAAW,SAAS,QAAQ,YAAAA,iBAAgB;AACrD,SAAS,OAAO,aAAa,aAAa,gBAAAC,eAAc,cAAc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AU,wDAAwD,wCAA6B;AAAA,IAEnG,YACC,gBAAAC,MAAC,SAAI,WAAU,mDACZ;AAAA,WAAK,UAAU,UAAU,KAAK,UAAU,YAAY,KAAK,UAAU,YAChE,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,KAAK,UAAU,aAAa;AAAA,OAC/B;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"]}
@@ -12,11 +12,12 @@ export declare function HubProviderMark({ providerId, name, size }: {
12
12
  size?: number;
13
13
  }): import("react").JSX.Element;
14
14
  /** Raw JSON behind a disclosure, for the person who wants the exact call. */
15
- export declare function HubRawDetails({ sections }: {
15
+ export declare function HubRawDetails({ sections, label }: {
16
16
  sections: ReadonlyArray<{
17
17
  label: string;
18
18
  value: unknown;
19
19
  }>;
20
+ label?: string;
20
21
  }): import("react").JSX.Element | null;
21
22
  /** A `label value` list that wraps on a phone. */
22
23
  export declare function HubFieldList({ fields }: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-app",
3
- "version": "0.60.30",
3
+ "version": "0.60.32",
4
4
  "packageManager": "pnpm@11.24.0",
5
5
  "description": "Build agent applications with typed chat, tools, sandboxes, integrations, billing, and evaluation.",
6
6
  "keywords": [
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/agent-surfaces/index.ts"],"sourcesContent":["/**\n * Machine-readable surfaces for a Tangle product, generated from one config.\n *\n * Every product publishes the same four things an AI agent needs to become a\n * customer without a human doing the setup:\n *\n * - `/agent-setup.md`: a SKILL.md (Claude Code and Codex skill format) that\n * doubles as a copy-paste prompt. It takes a fresh agent from nothing to a\n * verified first call: one owner approval, a scoped key, install, call.\n * - `/llms.txt`: the llms.txt index, pointing at the setup skill first.\n * - `/.well-known/tangle-agent.json`: the Tangle agent manifest.\n * - Markdown for `Accept: text/markdown` on the product's pages, with\n * `Vary: Accept` on both representations so caches keep them apart.\n *\n * The signup section is rendered here, not in product config, so every\n * product describes Platform's agent signup identically and cannot drift.\n *\n * Web-standard `Request`/`Response` only: safe in Workers, Node and browsers.\n */\n\n/** Manifest schema this module emits. Additive over the 2026-06-16 shape. */\nexport const AGENT_MANIFEST_SCHEMA_VERSION = '2026-10-09'\n\nexport const TANGLE_PLATFORM_ORIGIN = 'https://id.tangle.tools'\n\nexport interface AgentSurfaceStep {\n title: string\n /** Fence language for the code block. */\n language: 'bash' | 'js' | 'ts' | 'python' | 'json'\n code: string\n /** What a successful run prints or returns. */\n expect: string\n}\n\nexport interface AgentSurfaceError {\n symptom: string\n cause: string\n fix: string\n}\n\nexport interface AgentSurfaceLink {\n label: string\n url: string\n}\n\n/**\n * How an agent obtains a key. `device` uses Platform's agent signup: the owner\n * approves once and the agent receives its own capped, revocable key.\n */\nexport type AgentSignup =\n | {\n kind: 'device'\n /**\n * Products to ask for. Omitted, the one signup asks for every\n * agent-ready product, so the same key works across Tangle.\n */\n products?: string[]\n /** Default lifetime spend cap the skill asks for, in USD. */\n budgetUsd?: number\n }\n | {\n kind: 'manual'\n /** Numbered steps the owner performs; each one is a human input. */\n steps: string[]\n }\n\nexport interface AgentSurfaceConfig {\n /** Short id used in the skill name: `tangle-<id>-setup`. */\n id: string\n name: string\n /** Public HTTPS origin, no trailing slash. */\n origin: string\n /** What the product is for, in one to three plain sentences. */\n summary: string\n useWhen: string[]\n signup: AgentSignup\n /** Environment variable the key is exported as. */\n apiKeyEnv: string\n /** Runtime prerequisites a fresh machine needs, e.g. `Node.js 20 or newer`. */\n prerequisites: string[]\n install: AgentSurfaceStep[]\n firstCall: AgentSurfaceStep[]\n verify: AgentSurfaceStep[]\n errors: AgentSurfaceError[]\n pricing: {\n /** Plain statement of how usage is charged. */\n summary: string\n /** Public, credential-free price data an agent can quote from. */\n quoteUrl?: string\n url?: string\n }\n next: AgentSurfaceLink[]\n docs?: string\n openapi?: string\n mcp?: { url: string; auth: string }\n related?: Array<{ name: string; manifest?: string; url?: string }>\n /** Extra manifest fields a product already publishes (kept verbatim). */\n manifest?: Record<string, unknown>\n}\n\nexport interface AgentSurfaceFile {\n path: string\n contentType: string\n body: string\n}\n\nconst MARKDOWN = 'text/markdown; charset=utf-8'\n\nfunction trimOrigin(origin: string): string {\n return origin.replace(/\\/+$/, '')\n}\n\nfunction fence(step: Pick<AgentSurfaceStep, 'language' | 'code'>): string {\n return ['```' + step.language, step.code.trimEnd(), '```'].join('\\n')\n}\n\n/**\n * The signup script the skill tells an agent to save and run. Node 18+ only,\n * no dependencies, in two short commands so a tool that kills long-running\n * commands cannot cut the wait: `start` returns at once with the link and the\n * confirmation code; `wait` polls for a few seconds and exits 0 once approved\n * or 3 while the owner has not approved yet. It never prints the key; it\n * writes `.tangle/api-key` with mode 0600.\n */\nexport function agentSignupScript(platformOrigin = TANGLE_PLATFORM_ORIGIN): string {\n // The specifier is interpolated so this module's own import scan (the\n // browser-safe subpath gate) does not read script text as an import.\n return `// Requests a scoped Tangle key for this agent. The owner approves once.\n// node tangle-signup.mjs start --agent-name <name> [--owner-email <email>] [--budget-usd <n>] [--products a,b]\n// node tangle-signup.mjs wait (run again while it exits 3; exits 0 once approved)\nimport { mkdirSync, readFileSync, writeFileSync } from ${JSON.stringify('node:fs')}\n\nconst command = process.argv[2]\nconst flag = (name) => {\n const index = process.argv.indexOf(\\`--\\${name}\\`)\n return index > 0 ? process.argv[index + 1] : undefined\n}\nconst platform = '${trimOrigin(platformOrigin)}'\nconst statePath = '.tangle/signup.json'\nmkdirSync('.tangle', { recursive: true, mode: 0o700 })\n\nasync function post(path, body) {\n const response = await fetch(platform + path, {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify(body),\n })\n return { status: response.status, body: await response.json().catch(() => ({})) }\n}\n\nif (command === 'start') {\n const request = { agent_name: flag('agent-name') ?? 'coding-agent' }\n if (flag('products')) request.products = flag('products').split(',').map((id) => id.trim()).filter(Boolean)\n if (flag('owner-email')) request.owner_email = flag('owner-email')\n if (flag('budget-usd')) request.budget_usd = Number(flag('budget-usd'))\n const started = await post('/cross-site/device/start', request)\n if (started.status !== 200) {\n console.error(\\`Signup refused (HTTP \\${started.status}): \\${JSON.stringify(started.body)}\\`)\n process.exit(1)\n }\n const grant = started.body.data\n const saved = {\n device_code: grant.device_code,\n interval: grant.interval,\n expires_at: Date.now() + grant.expires_in * 1000,\n }\n writeFileSync(statePath, JSON.stringify(saved), { mode: 0o600 })\n console.log(grant.agent?.owner_notified\n ? \\`Approval email sent to \\${request.owner_email}.\\`\n : 'Send your owner this approval link.')\n console.log(\\`Approval link: \\${grant.verification_uri_complete}\\`)\n console.log(\\`Confirmation code: \\${grant.user_code} (expires in \\${Math.round(grant.expires_in / 60)} minutes)\\`)\n console.log('Next: run \\`node tangle-signup.mjs wait\\` until it prints Approved.')\n process.exit(0)\n}\n\nif (command === 'wait') {\n let saved\n try {\n saved = JSON.parse(readFileSync(statePath, 'utf8'))\n } catch {\n console.error('No pending signup. Run \\`node tangle-signup.mjs start\\` first.')\n process.exit(1)\n }\n const stopAt = Math.min(saved.expires_at, Date.now() + Number(flag('seconds') ?? 8) * 1000)\n for (;;) {\n const polled = await post('/cross-site/device/poll', { device_code: saved.device_code })\n if (polled.status === 200) {\n const { api_key: apiKey, key, account } = polled.body.data\n writeFileSync('.tangle/api-key', \\`\\${apiKey}\\\\n\\`, { mode: 0o600 })\n console.log(\\`Approved. Key \"\\${key?.name ?? 'agent'}\" saved to .tangle/api-key for \\${(key?.products ?? []).join(', ') || 'the approved products'} (spend cap $\\${key?.budget_usd ?? 'none'}).\\`)\n if (account && !account.funded) {\n console.log(\\`The owner's account has no credit yet. Ask the owner to add credits: \\${account.add_credits_url}\\`)\n }\n process.exit(0)\n }\n if (polled.status !== 428) {\n console.error(\\`Approval failed (HTTP \\${polled.status}): \\${JSON.stringify(polled.body)}\\`)\n process.exit(1)\n }\n if (Date.now() >= saved.expires_at) {\n console.error('The approval link expired. Run \\`node tangle-signup.mjs start\\` again.')\n process.exit(1)\n }\n if (Date.now() + saved.interval * 1000 > stopAt) {\n console.log('Still waiting for the owner to approve. Run \\`node tangle-signup.mjs wait\\` again.')\n process.exit(3)\n }\n await new Promise((resolve) => setTimeout(resolve, saved.interval * 1000))\n }\n}\n\nconsole.error('Usage: node tangle-signup.mjs start --agent-name <name> [--owner-email <email>] [--budget-usd <n>] [--products a,b] | wait')\nprocess.exit(2)\n`\n}\n\nfunction signupSection(config: AgentSurfaceConfig): string[] {\n const env = config.apiKeyEnv\n if (config.signup.kind === 'manual') {\n return [\n '## 1. Get a key',\n '',\n 'This product does not yet support agent signup. Ask your owner to do the following, then continue:',\n '',\n ...config.signup.steps.map((step, index) => `${index + 1}. ${step}`),\n '',\n `Store the key outside version control and export it as \\`${env}\\`. Never print, log, or commit it.`,\n ]\n }\n const budget = config.signup.budgetUsd ?? 25\n return [\n '## 1. Get a scoped key (one owner approval)',\n '',\n 'Tangle issues each agent one key, owned by a person who approves it once. The same key works for every Tangle product the owner approves: Tangle Sandbox, Tangle Router and the agent apps such as Tangle GTM Agent. If you already hold one from another Tangle product\\'s setup, reuse it and skip to step 2.',\n `Ask your owner which email address their Tangle account uses (or should use). Nothing is charged by signing up, and there is no free credit: ${config.name} work is paid from the owner's prepaid balance.`,\n '',\n 'Save this script as `tangle-signup.mjs` (Node.js 18 or newer, no dependencies):',\n '',\n fence({ language: 'js', code: agentSignupScript() }),\n '',\n 'Start the request with your own name and the owner\\'s email. It returns at once:',\n '',\n fence({\n language: 'bash',\n code: `node tangle-signup.mjs start --agent-name \"<your agent name>\" --owner-email \"<owner email>\" --budget-usd ${budget}${config.signup.products ? ` --products ${config.signup.products.join(',')}` : ''}`,\n }),\n '',\n 'It prints the approval link and a confirmation code. Tangle emails the owner the same link; if you cannot give an email, omit `--owner-email` and send the owner the printed link yourself. Tell the owner the code if you can reach them.',\n '',\n 'Then wait for the approval. Each run returns within about 8 seconds: exit code 3 and `Still waiting` mean run it again; exit code 0 and `Approved` mean the key is saved. Keep each run short rather than wrapping it in one long blocking loop, since many agent tools stop long commands.',\n '',\n fence({ language: 'bash', code: 'node tangle-signup.mjs wait' }),\n '',\n 'What the owner does, once: sign in (or create an account and verify the email), check the confirmation code, and approve. That is the only human step.',\n '',\n `The key in \\`.tangle/api-key\\` (mode 600) works only for the products the owner approved, can spend at most the cap you requested across all of them, and the owner can revoke it once under Keys to stop it everywhere. If \\`wait\\` says the account has no credit, ask the owner to add credits at the printed link before your first paid call.`,\n '',\n 'Then load the key without printing it, and keep it out of version control:',\n '',\n fence({\n language: 'bash',\n code: `export ${env}=\"$(cat .tangle/api-key)\"\\ngrep -qxF '.tangle/' .gitignore 2>/dev/null || echo '.tangle/' >> .gitignore`,\n }),\n '',\n 'Never print, log, paste, or commit the key.',\n ]\n}\n\nfunction stepsSection(heading: string, steps: AgentSurfaceStep[]): string[] {\n if (steps.length === 0) return []\n const lines = [heading, '']\n for (const step of steps) {\n lines.push(`${step.title}:`, '', fence(step), '', `Expected: ${step.expect}`, '')\n }\n return lines\n}\n\n/** The agent setup skill: valid SKILL.md and a plain copy-paste prompt. */\nexport function renderAgentSetupSkill(config: AgentSurfaceConfig): string {\n const origin = trimOrigin(config.origin)\n const install = config.install.length > 0 ? ', install the client' : ''\n const description = `Set up ${config.name} for this agent end to end: get a scoped API key with one owner approval${install}, make the first successful call, and verify it.`\n // Signup is step 1; the sections a product has are numbered on from there,\n // so a product with nothing to install reads 1, 2, 3.\n const sections = ([\n ['Install', config.install],\n ['Make the first call', config.firstCall],\n ['Verify it worked', config.verify],\n ] as const).filter(([, steps]) => steps.length > 0)\n const lines: string[] = [\n '---',\n `name: tangle-${config.id}-setup`,\n `description: ${description}`,\n '---',\n '',\n `# Set up ${config.name}`,\n '',\n config.summary,\n '',\n 'Use it when:',\n '',\n ...config.useWhen.map((item) => `- ${item}`),\n '',\n 'Complete every step below in order and stop at the first failure; the error table at the end names the fix.',\n 'Prerequisites: ' + config.prerequisites.join('; ') + '.',\n '',\n ...signupSection(config),\n '',\n ...sections.flatMap(([title, steps], index) => stepsSection(`## ${index + 2}. ${title}`, steps)),\n '## Common errors',\n '',\n '| Symptom | Cause | Fix |',\n '| --- | --- | --- |',\n ...config.errors.map(\n (error) => `| ${error.symptom.replace(/\\|/g, '\\\\|')} | ${error.cause.replace(/\\|/g, '\\\\|')} | ${error.fix.replace(/\\|/g, '\\\\|')} |`,\n ),\n '',\n '## Pricing',\n '',\n config.pricing.summary,\n ...(config.pricing.quoteUrl ? ['', `Current prices, no key needed: ${config.pricing.quoteUrl}`] : []),\n ...(config.pricing.url ? [`Pricing page: ${config.pricing.url}`] : []),\n '',\n '## Next',\n '',\n ...config.next.map((link) => `- [${link.label}](${link.url})`),\n '',\n '## Machine-readable surfaces',\n '',\n `- Agent manifest: ${origin}/.well-known/tangle-agent.json`,\n `- llms.txt: ${origin}/llms.txt`,\n `- This setup skill: ${origin}/agent-setup.md`,\n ...(config.openapi ? [`- OpenAPI: ${config.openapi}`] : []),\n ...(config.mcp ? [`- MCP server: ${config.mcp.url} (${config.mcp.auth})`] : []),\n '',\n ]\n return lines.join('\\n')\n}\n\n/** llms.txt index for the product. The setup skill is the first link. */\nexport function renderLlmsTxt(config: AgentSurfaceConfig): string {\n const origin = trimOrigin(config.origin)\n return [\n `# ${config.name}`,\n '',\n `> ${config.summary}`,\n '',\n `To set this product up from scratch, fetch ${origin}/agent-setup.md and follow it. It is a complete prompt and a SKILL.md: one owner approval, a scoped key, install, first call, verification.`,\n '',\n '## Start here',\n '',\n `- [Agent setup skill](${origin}/agent-setup.md): from nothing to a verified first call`,\n `- [Agent manifest](${origin}/.well-known/tangle-agent.json): machine-readable contract`,\n ...(config.openapi ? [`- [OpenAPI](${config.openapi}): HTTP API schema`] : []),\n ...(config.mcp ? [`- [MCP server](${config.mcp.url}): ${config.mcp.auth}`] : []),\n ...(config.docs ? [`- [Documentation](${config.docs})`] : []),\n '',\n '## Pricing',\n '',\n `- ${config.pricing.summary}`,\n ...(config.pricing.quoteUrl ? [`- [Machine-readable prices](${config.pricing.quoteUrl}): no key needed`] : []),\n '',\n '## Optional',\n '',\n ...config.next.map((link) => `- [${link.label}](${link.url})`),\n ...(config.related ?? []).map(\n (surface) => `- [${surface.name}](${surface.manifest ?? surface.url ?? ''})`,\n ),\n '',\n ].join('\\n')\n}\n\n/** Markdown for the product's home page, served for `Accept: text/markdown`. */\nexport function renderHomeMarkdown(config: AgentSurfaceConfig): string {\n const origin = trimOrigin(config.origin)\n return [\n `# ${config.name}`,\n '',\n config.summary,\n '',\n '## Use it when',\n '',\n ...config.useWhen.map((item) => `- ${item}`),\n '',\n '## Hand this to your agent',\n '',\n `An AI agent can set ${config.name} up by itself: fetch ${origin}/agent-setup.md and follow it. The owner approves once; nothing else needs a human.`,\n '',\n '## Pricing',\n '',\n config.pricing.summary,\n ...(config.pricing.quoteUrl ? ['', `Machine-readable prices: ${config.pricing.quoteUrl}`] : []),\n '',\n '## Machine-readable surfaces',\n '',\n `- ${origin}/llms.txt`,\n `- ${origin}/.well-known/tangle-agent.json`,\n `- ${origin}/agent-setup.md`,\n ...(config.openapi ? [`- ${config.openapi}`] : []),\n ...(config.mcp ? [`- ${config.mcp.url}`] : []),\n '',\n ].join('\\n')\n}\n\n/** The `/.well-known/tangle-agent.json` document. */\nexport function renderAgentManifest(config: AgentSurfaceConfig): Record<string, unknown> {\n const origin = trimOrigin(config.origin)\n const signup =\n config.signup.kind === 'device'\n ? {\n kind: 'device_authorization',\n start: `POST ${TANGLE_PLATFORM_ORIGIN}/cross-site/device/start`,\n poll: `POST ${TANGLE_PLATFORM_ORIGIN}/cross-site/device/poll`,\n contract: `${TANGLE_PLATFORM_ORIGIN}/.well-known/tangle-agent.json`,\n request: {\n agent_name: 'string, 1-64 characters',\n owner_email: 'optional; Tangle emails this owner the approval link',\n budget_usd: `optional lifetime spend cap shared by every granted product, 1-1000, default ${config.signup.budgetUsd ?? 25}`,\n products: config.signup.products ?? 'optional; default every agent-ready product, or [\"*\"]',\n },\n human_inputs: ['The owner approves the request once.'],\n key: {\n scope: 'One key for every product the owner approved; use it as Bearer at each product.',\n revocable_at: `${TANGLE_PLATFORM_ORIGIN}/app/keys`,\n },\n payment: 'Prepaid credit on the owner account. No free credit; paid calls are refused until the owner adds credits.',\n add_credits: `${TANGLE_PLATFORM_ORIGIN}/app/billing`,\n }\n : { kind: 'manual', steps: config.signup.steps }\n return {\n ...config.manifest,\n schema_version: AGENT_MANIFEST_SCHEMA_VERSION,\n name: config.name,\n description: config.summary,\n homepage: `${origin}/`,\n llms: `${origin}/llms.txt`,\n agent_setup: `${origin}/agent-setup.md`,\n ...(config.docs ? { docs: config.docs } : {}),\n ...(config.openapi ? { openapi: config.openapi } : {}),\n ...(config.mcp ? { mcp: config.mcp } : {}),\n environment: { api_key: config.apiKeyEnv },\n signup,\n pricing: {\n summary: config.pricing.summary,\n ...(config.pricing.quoteUrl ? { quote: config.pricing.quoteUrl } : {}),\n ...(config.pricing.url ? { page: config.pricing.url } : {}),\n },\n ...(config.related?.length ? { related_surfaces: config.related } : {}),\n }\n}\n\n/** Every static surface as files, for products that ship them as assets. */\nexport function agentSurfaceFiles(config: AgentSurfaceConfig): AgentSurfaceFile[] {\n return [\n { path: 'agent-setup.md', contentType: MARKDOWN, body: renderAgentSetupSkill(config) },\n { path: 'llms.txt', contentType: 'text/plain; charset=utf-8', body: renderLlmsTxt(config) },\n { path: 'index.md', contentType: MARKDOWN, body: renderHomeMarkdown(config) },\n {\n path: '.well-known/tangle-agent.json',\n contentType: 'application/json; charset=utf-8',\n body: `${JSON.stringify(renderAgentManifest(config), null, 2)}\\n`,\n },\n ]\n}\n\n/**\n * True when `Accept` ranks `text/markdown` strictly above `text/html` and\n * gives it a nonzero weight. A browser's default header never does.\n */\nexport function prefersMarkdown(accept: string | null | undefined): boolean {\n if (!accept) return false\n let markdown = -1\n let html = -1\n for (const part of accept.split(',')) {\n const [rawType, ...params] = part.trim().split(';')\n const type = rawType?.trim().toLowerCase()\n let quality = 1\n for (const param of params) {\n const [key, value] = param.trim().split('=')\n if (key?.trim().toLowerCase() === 'q') {\n const parsed = Number(value)\n quality = Number.isFinite(parsed) ? parsed : 0\n }\n }\n if (type === 'text/markdown') markdown = Math.max(markdown, quality)\n if (type === 'text/html') html = Math.max(html, quality)\n }\n return markdown > 0 && markdown > html\n}\n\n/** A copy of `response` whose `Vary` includes `Accept`. */\nexport function withVaryAccept(response: Response): Response {\n const vary = response.headers.get('vary')\n if (vary && vary.split(',').some((value) => value.trim().toLowerCase() === 'accept')) {\n return response\n }\n const headers = new Headers(response.headers)\n headers.set('vary', vary ? `${vary}, Accept` : 'Accept')\n return new Response(response.body, {\n status: response.status,\n statusText: response.statusText,\n headers,\n })\n}\n\nexport interface AgentSurfaceHandler {\n /**\n * Answers a surface request (`/agent-setup.md`, `/llms.txt`, the manifest,\n * or a negotiated markdown page), or `null` to let the app answer it.\n */\n handle(request: Request): Response | null\n /** Adds `Vary: Accept` when the path has a markdown representation. */\n finalize(request: Request, response: Response): Response\n}\n\n/**\n * Request handler over {@link agentSurfaceFiles}. `markdownPages` maps extra\n * HTML paths to markdown served on negotiation; `/` always maps to the home\n * markdown.\n */\nexport function createAgentSurfaceHandler(\n config: AgentSurfaceConfig,\n options: { markdownPages?: Record<string, string> } = {},\n): AgentSurfaceHandler {\n const files = new Map(agentSurfaceFiles(config).map((file) => [`/${file.path}`, file]))\n const negotiated = new Map<string, string>([\n ['/', renderHomeMarkdown(config)],\n ...Object.entries(options.markdownPages ?? {}),\n ])\n\n function respond(body: string, contentType: string, method: string, vary: boolean): Response {\n const headers = new Headers({\n 'content-type': contentType,\n 'cache-control': 'public, max-age=300',\n 'x-content-type-options': 'nosniff',\n })\n if (vary) headers.set('vary', 'Accept')\n return new Response(method === 'HEAD' ? null : body, { status: 200, headers })\n }\n\n return {\n handle(request) {\n if (request.method !== 'GET' && request.method !== 'HEAD') return null\n const path = new URL(request.url).pathname\n const file = files.get(path)\n if (file) return respond(file.body, file.contentType, request.method, false)\n const markdown = negotiated.get(path)\n if (markdown !== undefined && prefersMarkdown(request.headers.get('accept'))) {\n return respond(markdown, MARKDOWN, request.method, true)\n }\n return null\n },\n finalize(request, response) {\n return negotiated.has(new URL(request.url).pathname) ? withVaryAccept(response) : response\n },\n }\n}\n"],"mappings":";AAqBO,IAAM,gCAAgC;AAEtC,IAAM,yBAAyB;AAmFtC,IAAM,WAAW;AAEjB,SAAS,WAAW,QAAwB;AAC1C,SAAO,OAAO,QAAQ,QAAQ,EAAE;AAClC;AAEA,SAAS,MAAM,MAA2D;AACxE,SAAO,CAAC,QAAQ,KAAK,UAAU,KAAK,KAAK,QAAQ,GAAG,KAAK,EAAE,KAAK,IAAI;AACtE;AAUO,SAAS,kBAAkB,iBAAiB,wBAAgC;AAGjF,SAAO;AAAA;AAAA;AAAA,yDAGgD,KAAK,UAAU,SAAS,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAO9D,WAAW,cAAc,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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