@hybridaione/hybridclaw 0.25.8 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. package/AGENTS.md +1 -0
  2. package/CHANGELOG.md +89 -0
  3. package/README.md +19 -13
  4. package/config.example.json +25 -1
  5. package/console/dist/assets/apps-BCUhkPkB.js +1 -0
  6. package/console/dist/assets/apps-fd_S5yFK.css +1 -0
  7. package/console/dist/assets/chat-B4ykLwkT.js +4 -0
  8. package/console/dist/assets/chat-sidebar-bGb6YbfM.js +5 -0
  9. package/console/dist/assets/{index-D_dyldhe.js → index-Btzl6jZZ.js} +38 -38
  10. package/console/dist/assets/index-DuxG8IST.css +1 -0
  11. package/console/dist/assets/{terminal-y2BUUQIR.js → terminal-BOibs0Ai.js} +1 -1
  12. package/console/dist/icons/github.svg +3 -0
  13. package/console/dist/index.html +2 -2
  14. package/console/package.json +2 -2
  15. package/container/dist/providers/openai-codex.js +2 -1
  16. package/container/dist/providers/openai-codex.js.map +1 -1
  17. package/container/dist/tools.js +86 -7
  18. package/container/dist/tools.js.map +1 -1
  19. package/container/npm-shrinkwrap.json +27 -2723
  20. package/container/package-lock.json +27 -2723
  21. package/container/package.json +5 -5
  22. package/container/src/providers/openai-codex.ts +5 -1
  23. package/container/src/tools.ts +86 -9
  24. package/dist/a2a/a2a-inbound.d.ts.map +1 -1
  25. package/dist/a2a/a2a-inbound.js +7 -7
  26. package/dist/a2a/a2a-inbound.js.map +1 -1
  27. package/dist/a2a/pairing.d.ts +9 -1
  28. package/dist/a2a/pairing.d.ts.map +1 -1
  29. package/dist/a2a/pairing.js +132 -4
  30. package/dist/a2a/pairing.js.map +1 -1
  31. package/dist/a2a/trust-ledger.d.ts +74 -0
  32. package/dist/a2a/trust-ledger.d.ts.map +1 -1
  33. package/dist/a2a/trust-ledger.js +638 -74
  34. package/dist/a2a/trust-ledger.js.map +1 -1
  35. package/dist/a2a/webhook-inbound.d.ts +3 -2
  36. package/dist/a2a/webhook-inbound.d.ts.map +1 -1
  37. package/dist/a2a/webhook-inbound.js +22 -9
  38. package/dist/a2a/webhook-inbound.js.map +1 -1
  39. package/dist/apps/app-generator.d.ts +21 -0
  40. package/dist/apps/app-generator.d.ts.map +1 -0
  41. package/dist/apps/app-generator.js +105 -0
  42. package/dist/apps/app-generator.js.map +1 -0
  43. package/dist/auth/google-auth.d.ts +14 -0
  44. package/dist/auth/google-auth.d.ts.map +1 -1
  45. package/dist/auth/google-auth.js +4 -4
  46. package/dist/auth/google-auth.js.map +1 -1
  47. package/dist/auth/hybridai-auth.d.ts.map +1 -1
  48. package/dist/auth/hybridai-auth.js +23 -14
  49. package/dist/auth/hybridai-auth.js.map +1 -1
  50. package/dist/auth/microsoft-auth.d.ts +77 -0
  51. package/dist/auth/microsoft-auth.d.ts.map +1 -0
  52. package/dist/auth/microsoft-auth.js +348 -0
  53. package/dist/auth/microsoft-auth.js.map +1 -0
  54. package/dist/channels/discord/tool-actions.d.ts +8 -0
  55. package/dist/channels/discord/tool-actions.d.ts.map +1 -1
  56. package/dist/channels/discord/tool-actions.js.map +1 -1
  57. package/dist/channels/email/admin-mailbox.d.ts +24 -4
  58. package/dist/channels/email/admin-mailbox.d.ts.map +1 -1
  59. package/dist/channels/email/admin-mailbox.js +102 -0
  60. package/dist/channels/email/admin-mailbox.js.map +1 -1
  61. package/dist/channels/email/prompt-adapter.d.ts.map +1 -1
  62. package/dist/channels/email/prompt-adapter.js +2 -3
  63. package/dist/channels/email/prompt-adapter.js.map +1 -1
  64. package/dist/channels/email/runtime.d.ts +20 -0
  65. package/dist/channels/email/runtime.d.ts.map +1 -1
  66. package/dist/channels/email/runtime.js +27 -0
  67. package/dist/channels/email/runtime.js.map +1 -1
  68. package/dist/channels/message/tool-actions.d.ts.map +1 -1
  69. package/dist/channels/message/tool-actions.js +152 -1
  70. package/dist/channels/message/tool-actions.js.map +1 -1
  71. package/dist/channels/message-tool-advertising.js +1 -1
  72. package/dist/channels/message-tool-advertising.js.map +1 -1
  73. package/dist/cli/auth-command.d.ts.map +1 -1
  74. package/dist/cli/auth-command.js +209 -5
  75. package/dist/cli/auth-command.js.map +1 -1
  76. package/dist/cli/help.d.ts +1 -0
  77. package/dist/cli/help.d.ts.map +1 -1
  78. package/dist/cli/help.js +42 -5
  79. package/dist/cli/help.js.map +1 -1
  80. package/dist/cli/secret-command.d.ts.map +1 -1
  81. package/dist/cli/secret-command.js +17 -6
  82. package/dist/cli/secret-command.js.map +1 -1
  83. package/dist/cli.d.ts.map +1 -1
  84. package/dist/cli.js +8 -3
  85. package/dist/cli.js.map +1 -1
  86. package/dist/command-registry.d.ts.map +1 -1
  87. package/dist/command-registry.js +22 -2
  88. package/dist/command-registry.js.map +1 -1
  89. package/dist/config/runtime-config.d.ts +20 -2
  90. package/dist/config/runtime-config.d.ts.map +1 -1
  91. package/dist/config/runtime-config.js +124 -2
  92. package/dist/config/runtime-config.js.map +1 -1
  93. package/dist/gateway/gateway-admin-connectors.d.ts +67 -0
  94. package/dist/gateway/gateway-admin-connectors.d.ts.map +1 -0
  95. package/dist/gateway/gateway-admin-connectors.js +589 -0
  96. package/dist/gateway/gateway-admin-connectors.js.map +1 -0
  97. package/dist/gateway/gateway-chat-service.d.ts.map +1 -1
  98. package/dist/gateway/gateway-chat-service.js +6 -2
  99. package/dist/gateway/gateway-chat-service.js.map +1 -1
  100. package/dist/gateway/gateway-http-proxy.d.ts.map +1 -1
  101. package/dist/gateway/gateway-http-proxy.js +272 -76
  102. package/dist/gateway/gateway-http-proxy.js.map +1 -1
  103. package/dist/gateway/gateway-http-server.d.ts.map +1 -1
  104. package/dist/gateway/gateway-http-server.js +775 -10
  105. package/dist/gateway/gateway-http-server.js.map +1 -1
  106. package/dist/gateway/gateway-http-utils.d.ts.map +1 -1
  107. package/dist/gateway/gateway-http-utils.js +105 -1
  108. package/dist/gateway/gateway-http-utils.js.map +1 -1
  109. package/dist/gateway/gateway-secret-injection.d.ts +2 -2
  110. package/dist/gateway/gateway-secret-injection.d.ts.map +1 -1
  111. package/dist/gateway/gateway-service.d.ts.map +1 -1
  112. package/dist/gateway/gateway-service.js +18 -10
  113. package/dist/gateway/gateway-service.js.map +1 -1
  114. package/dist/gateway/gateway-types.d.ts +17 -0
  115. package/dist/gateway/gateway-types.d.ts.map +1 -1
  116. package/dist/gateway/gateway-types.js.map +1 -1
  117. package/dist/identity/resolver.js +1 -1
  118. package/dist/identity/resolver.js.map +1 -1
  119. package/dist/infra/container-runner.d.ts.map +1 -1
  120. package/dist/infra/container-runner.js +4 -1
  121. package/dist/infra/container-runner.js.map +1 -1
  122. package/dist/infra/host-runner.d.ts.map +1 -1
  123. package/dist/infra/host-runner.js +2 -1
  124. package/dist/infra/host-runner.js.map +1 -1
  125. package/dist/mcp/hybridai-connectors.d.ts +11 -0
  126. package/dist/mcp/hybridai-connectors.d.ts.map +1 -0
  127. package/dist/mcp/hybridai-connectors.js +43 -0
  128. package/dist/mcp/hybridai-connectors.js.map +1 -0
  129. package/dist/memory/apps.d.ts +70 -0
  130. package/dist/memory/apps.d.ts.map +1 -0
  131. package/dist/memory/apps.js +206 -0
  132. package/dist/memory/apps.js.map +1 -0
  133. package/dist/memory/db.d.ts +8 -1
  134. package/dist/memory/db.d.ts.map +1 -1
  135. package/dist/memory/db.js +80 -3
  136. package/dist/memory/db.js.map +1 -1
  137. package/dist/policy/secret-route-policy.d.ts.map +1 -1
  138. package/dist/policy/secret-route-policy.js +14 -7
  139. package/dist/policy/secret-route-policy.js.map +1 -1
  140. package/dist/security/admin-rbac.d.ts +13 -13
  141. package/dist/security/admin-rbac.d.ts.map +1 -1
  142. package/dist/security/admin-rbac.js +17 -0
  143. package/dist/security/admin-rbac.js.map +1 -1
  144. package/dist/types/activity-trace.d.ts +45 -0
  145. package/dist/types/activity-trace.d.ts.map +1 -0
  146. package/dist/types/activity-trace.js +138 -0
  147. package/dist/types/activity-trace.js.map +1 -0
  148. package/dist/types/session.d.ts +3 -0
  149. package/dist/types/session.d.ts.map +1 -1
  150. package/docs/content/README.md +20 -3
  151. package/docs/content/agents.md +1 -0
  152. package/docs/content/channels/admin-console.md +8 -1
  153. package/docs/content/channels/email.md +19 -0
  154. package/docs/content/developer-guide/desktop-release.md +1 -1
  155. package/docs/content/developer-guide/runtime.md +5 -4
  156. package/docs/content/extensibility/skills.md +10 -3
  157. package/docs/content/getting-started/README.md +1 -1
  158. package/docs/content/getting-started/authentication.md +60 -2
  159. package/docs/content/getting-started/local-vs-cloud.md +4 -3
  160. package/docs/content/getting-started/quickstart.md +3 -1
  161. package/docs/content/guides/README.md +3 -1
  162. package/docs/content/guides/apps.md +107 -0
  163. package/docs/content/guides/bundled-skills.md +3 -3
  164. package/docs/content/guides/remote-access.md +5 -4
  165. package/docs/content/guides/skills/README.md +3 -3
  166. package/docs/content/guides/skills/integrations.md +128 -6
  167. package/docs/content/guides/skills/productivity.md +59 -1
  168. package/docs/content/navigation.json +4 -0
  169. package/docs/content/reference/commands.md +8 -2
  170. package/docs/content/reference/configuration.md +10 -4
  171. package/docs/content/reference/faq.md +8 -5
  172. package/npm-shrinkwrap.json +1071 -2630
  173. package/package.json +8 -5
  174. package/skills/airtable/SKILL.md +12 -4
  175. package/skills/alexa/SKILL.md +30 -9
  176. package/skills/blink/SKILL.md +8 -4
  177. package/skills/byd-battery/SKILL.md +12 -5
  178. package/skills/download-platform-invoices/SKILL.md +3 -0
  179. package/skills/fastbill/SKILL.md +1 -1
  180. package/skills/fastbill/references/operator-setup.md +9 -2
  181. package/skills/fax-send/SKILL.md +26 -7
  182. package/skills/firecrawl/SKILL.md +16 -4
  183. package/skills/fronius/SKILL.md +11 -3
  184. package/skills/ga4/SKILL.md +11 -1
  185. package/skills/gh-issues/SKILL.md +4 -1
  186. package/skills/google-ads/SKILL.md +11 -2
  187. package/skills/google-ads/references/setup-and-operations.md +11 -2
  188. package/skills/hermes3000-writing/SKILL.md +7 -3
  189. package/skills/hermes3000-writing/references/api-workflow.md +4 -2
  190. package/skills/hetzner-cloud/SKILL.md +1 -1
  191. package/skills/hetzner-cloud/references/operator-setup.md +6 -1
  192. package/skills/hetzner-dns/SKILL.md +1 -1
  193. package/skills/hetzner-dns/references/operator-setup.md +6 -1
  194. package/skills/hetzner-storage-box/SKILL.md +14 -4
  195. package/skills/hetzner-storage-box/references/operator-setup.md +12 -2
  196. package/skills/heygen/SKILL.md +7 -2
  197. package/skills/homematic/SKILL.md +11 -3
  198. package/skills/hubspot/SKILL.md +8 -2
  199. package/skills/hue/SKILL.md +8 -4
  200. package/skills/langfuse/SKILL.md +13 -4
  201. package/skills/langfuse/references/operator-setup.md +6 -2
  202. package/skills/lexware-office/SKILL.md +46 -9
  203. package/skills/lexware-office/evals/scenarios.json +31 -0
  204. package/skills/lexware-office/lexware_office.cjs +81 -4
  205. package/skills/lexware-office/references/operator-setup.md +13 -1
  206. package/skills/mailchimp/SKILL.md +16 -11
  207. package/skills/microsoft-365/SKILL.md +162 -0
  208. package/skills/microsoft-365/m365.cjs +495 -0
  209. package/skills/miro/SKILL.md +345 -0
  210. package/skills/miro/index.cjs +1 -0
  211. package/skills/miro/miro.cjs +1569 -0
  212. package/skills/mittwald/SKILL.md +8 -2
  213. package/skills/posthog/SKILL.md +8 -4
  214. package/skills/salesforce/SKILL.md +6 -2
  215. package/skills/salesforce/references/metadata-and-queries.md +5 -1
  216. package/skills/shelly/SKILL.md +2 -2
  217. package/skills/speech.detect-language/SKILL.md +3 -3
  218. package/skills/speech.transcribe/SKILL.md +3 -3
  219. package/skills/t-cloud-public/SKILL.md +4 -4
  220. package/skills/t-cloud-public/references/operator-setup.md +17 -3
  221. package/skills/video.from-script/SKILL.md +1 -1
  222. package/skills/zabbix/SKILL.md +12 -2
  223. package/skills/zoho/SKILL.md +114 -0
  224. package/console/dist/assets/chat-jou7NqjM.js +0 -4
  225. package/console/dist/assets/index-DqS0t_64.css +0 -1
package/AGENTS.md CHANGED
@@ -276,6 +276,7 @@ hybridclaw gateway status # gateway liveness, PID, build/version dia
276
276
 
277
277
  - Treat existing uncommitted changes as user work unless you created them.
278
278
  - Run `npm run format` before creating commits that will be pushed to GitHub.
279
+ - Always run `npm run lint` before creating any commit.
279
280
  - Conventional Commits preferred: `feat:`, `fix:`, `test:`, `refactor:`,
280
281
  `chore:`, `docs:`.
281
282
  - Group related changes; avoid bundling unrelated refactors.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,95 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## [0.27.0](https://github.com/HybridAIOne/hybridclaw/tree/v0.27.0) - 2026-07-05
6
+
7
+ ### Added
8
+
9
+ - **Chat activity traces**: The web `/chat` view now renders the agent's
10
+ thinking and tool calls as a light-grey, collapsible trace above each answer.
11
+ The trace streams live while the run is in flight (one row per thinking
12
+ segment or tool call, with args/result previews and durations) and
13
+ auto-collapses to a one-line summary once the final answer, an approval, or
14
+ an error arrives. It consumes the `thinking` and `tool` NDJSON events the
15
+ gateway already emits on `/api/chat`, gated by the session `/show` mode.
16
+ The ordered trace is persisted per assistant message (schema v46), so a page
17
+ reload replays the same activity instead of dropping it.
18
+
19
+ `Manifesto: Principle IV - A coworker is a colleague, not a chatbot.`
20
+
21
+ - **Apps gallery**: Web chat includes an `/apps` gallery and `/app <description>`
22
+ flow for building self-contained HTML apps, documents, games, dashboards, and
23
+ tools, then saving captured HTML artifacts with search, category filtering,
24
+ previews, new-tab links, and deletion controls.
25
+ - **Live apps**: Apps can be marked as connector-aware live apps that embed a
26
+ snapshot fallback and refresh inside the Apps viewer through a sandbox bridge
27
+ for read-only MCP connector tool calls.
28
+
29
+ ### Fixed
30
+
31
+ - **OpenAI Codex stream stalls**: Codex SSE reads now use an idle timeout so a
32
+ stalled upstream stream is cancelled and surfaced as a retryable error instead
33
+ of hanging indefinitely.
34
+
35
+ ## [0.26.0](https://github.com/HybridAIOne/hybridclaw/tree/v0.26.0) - 2026-07-03
36
+
37
+ ### Added
38
+
39
+ - **Admin connector setup**: `/admin/connectors` can connect HybridAI with an
40
+ API key, run Google Workspace OAuth from the browser, show connector
41
+ connection state, test connector health, and launch HybridAI-managed GitHub
42
+ and Microsoft 365 authorization flows.
43
+ - **HybridAI connector MCP**: Gateways with HybridAI credentials now
44
+ auto-register the HybridAI connector MCP server unless an operator disables
45
+ or overrides the `hybridai` MCP server entry.
46
+ - **Live email mailbox reads**: The `message` tool can search and read
47
+ configured email mailboxes directly, with folder, unread, sender, subject,
48
+ date, query, and UID filters plus thread snapshots for individual messages.
49
+ - **Microsoft 365 Graph skill**: Added a read-only `microsoft-365` skill for
50
+ Outlook mail, calendars, OneDrive/SharePoint files, Teams, chats, and profile
51
+ reads through Microsoft Graph, plus `hybridclaw auth login microsoft365` and
52
+ `microsoft-oauth` secret routes for gateway-injected Graph access tokens.
53
+ - **Miro skill**: Added the `miro` skill for board discovery, metadata and item
54
+ reads, guarded sticky/text/shape/connector/frame writes, OAuth token
55
+ exchange helpers, and Enterprise board export workflows.
56
+ - **Zoho MCP skill**: Added the `zoho` skill for Zoho CRM, Desk, Mail,
57
+ Calendar, Books, Projects, WorkDrive, Cliq, Campaigns, and related workflows
58
+ through a configured Zoho MCP server.
59
+ - **A2A trust ledger**: A2A JSON-RPC and webhook trust now share a durable
60
+ trusted-peer ledger with legacy migration, TOFU audit lineage, revocation
61
+ state, and sender/public-key lookup paths.
62
+ - **A2A delegation trust pairing**: Agent Cards can advertise delegation
63
+ signing keys and canonical sender ids, and pairing approval records the
64
+ advertised A2A senders for trusted outbound delegation.
65
+ - **Console navigation config**: The top navigation strip can be customized
66
+ from runtime config with local console paths or HTTP(S) URLs and link text.
67
+ - **Lexware quotations**: The `lexware-office` skill now covers quotation
68
+ listing, retrieval, creation, and PDF downloads with explicit draft vs.
69
+ finalized document guidance.
70
+
71
+ ### Changed
72
+
73
+ - **Skill credential guidance**: Bundled API-backed skills now point operators
74
+ to browser admin secrets first, then `/secret set` from chat or TUI, with
75
+ local `hybridclaw secret set` commands as the fallback path.
76
+ - **Admin console docs**: Public docs and examples cover the connector setup
77
+ surface, Microsoft Graph OAuth routes, the updated bundled-skill count, and
78
+ the new Microsoft 365, Miro, Zoho, and live email mailbox-read surfaces.
79
+
80
+ ### Fixed
81
+
82
+ - **Dependency security updates**: Resolved high npm audit findings, refreshed
83
+ lockfiles and shrinkwrap files, and updated dependency policy baselines.
84
+ - **Connector auth hardening**: Connector flows isolate signed-payload secrets,
85
+ keep return URLs result-neutral, restrict TLS pin secret resolution, and avoid
86
+ connector taint paths flagged by CodeQL.
87
+ - **Vision artifact URLs**: `vision_analyze` accepts local
88
+ `/api/artifact?path=...` URLs copied from chat history and resolves them to
89
+ the underlying workspace or media-cache file.
90
+ - **Instruction restore prompt**: The TUI config restore prompt more clearly
91
+ distinguishes restoring the last known-good config from manually repairing an
92
+ invalid config file.
93
+
5
94
  ## [0.25.8](https://github.com/HybridAIOne/hybridclaw/tree/v0.25.8) - 2026-06-27
6
95
 
7
96
  ### Changed
package/README.md CHANGED
@@ -21,9 +21,9 @@ approval tiers, and are validated against `Qwen/Qwen3.6-27B-FP8` as the
21
21
  small-model baseline.
22
22
 
23
23
  That is the useful difference: a compact model can operate Salesforce,
24
- HubSpot, GA4, Google Ads, Lexware, Airtable, warehouse SQL, invoices, cloud
25
- ops, and office documents through structured rails instead of fragile
26
- free-form prompting.
24
+ HubSpot, GA4, Google Ads, Lexware, Airtable, Miro, Zoho, Microsoft 365,
25
+ warehouse SQL, invoices, cloud ops, and office documents through structured
26
+ rails instead of fragile free-form prompting.
27
27
 
28
28
  HybridClaw also treats agents as networked coworkers. Local agents, hosted
29
29
  HybridAI proxy agents, and trusted peer HybridClaw instances can address one
@@ -57,9 +57,10 @@ HybridClaw on HybridAI Cloud in a few minutes at
57
57
  | --- | --- |
58
58
  | A first run that becomes useful quickly | Guided hatching with setup links, tailored first-job suggestions, optional onboarding-specific model routing, and welcome-email handoff |
59
59
  | Business workflows that survive real use | Production skill helpers with fixtures, eval scenarios, targeted tests, approval tiers, and a `Qwen/Qwen3.6-27B-FP8` validation baseline |
60
+ | Generated work artifacts you can reuse | An Apps gallery for self-contained HTML apps, dashboards, documents, games, tools, and live connector-backed views |
60
61
  | Multi-agent workflows across installations | Local agents, hosted proxy agents, A2A trust, explicit addressing, inbound envelopes, and admin-visible peer pairing |
61
62
  | Credentials the model cannot read | Encrypted runtime secrets and SecretRef-backed execution paths that keep raw keys and passwords out of prompts and tool results |
62
- | Assistants that can act, not just chat | A gateway, web chat, TUI, admin console, scheduler, tools, and OpenAI-compatible API behind one local service |
63
+ | Assistants that can act, not just chat | A gateway, web chat, Apps gallery, TUI, admin console, scheduler, tools, and OpenAI-compatible API behind one local service |
63
64
  | Control over sensitive work | Approval policy, sandbox boundaries, output guardrails, and hash-chained audit trails |
64
65
  | Agents that fit existing teams | Discord, Slack, Teams, Telegram, WhatsApp, email, voice, web, and more through the same runtime |
65
66
  | Operational memory | Local files, SQLite state, semantic recall, session compaction, and optional HybridAI cloud memory |
@@ -101,7 +102,8 @@ After the gateway starts, open:
101
102
  | Surface | URL / command | Use it for |
102
103
  | --- | --- | --- |
103
104
  | Web Chat | `http://127.0.0.1:9090/chat` | Chat, slash commands, model and agent switching |
104
- | Admin Console | `http://127.0.0.1:9090/admin` | Channels, agents, approvals, audit, config, secrets, skills, distillation |
105
+ | Apps Gallery | `http://127.0.0.1:9090/apps` | Generated web apps, documents, games, tools, and live connector-backed views |
106
+ | Admin Console | `http://127.0.0.1:9090/admin` | Channels, connectors, agents, approvals, audit, config, secrets, skills, distillation |
105
107
  | Agents UI | `http://127.0.0.1:9090/agents` | Agent fleet overview and prompt-file editing |
106
108
  | TUI | `hybridclaw tui` | Terminal chat, approvals, status, resume |
107
109
  | OpenAI-compatible API | `http://127.0.0.1:9090/v1/chat/completions` | Local evals and compatible clients |
@@ -121,13 +123,13 @@ npm run desktop
121
123
 
122
124
  | Area | Built in |
123
125
  | --- | --- |
124
- | Skills | 76 bundled skills, production business helpers, eval fixtures, packaged skill lifecycle, and human-distillation workflows |
126
+ | Skills | 79 bundled skills, production business helpers, eval fixtures, packaged skill lifecycle, and human-distillation workflows |
125
127
  | Channels | Discord, Slack, Signal, WhatsApp, Telegram, Microsoft Teams, email, iMessage, fax, Twilio voice, web, and incoming webhooks |
126
- | Runtime | Gateway service, TUI client, web chat, admin console, loopback OpenAI-compatible API, Docker or host execution |
128
+ | Runtime | Gateway service, TUI client, web chat, Apps gallery, admin console, loopback OpenAI-compatible API, Docker or host execution |
127
129
  | Governance | Encrypted runtime secrets, SecretRef credential isolation, approval policies, sandbox controls, audit trails with hash-chain integrity |
128
130
  | Memory | Local memory files, SQLite persistence, semantic recall, session compaction, optional HybridAI cloud memory sync |
129
131
  | Agents | Guided hatching, per-agent workspaces, models, budgets, prompt files, explicit addressing, proxy agents, A2A trust, peer-instance communication |
130
- | Extensibility | Packaged business skills, plugins, MCP servers, SecretRef-backed HTTP tools |
132
+ | Extensibility | Packaged business skills, plugins, MCP servers, admin connector flows, SecretRef-backed HTTP tools |
131
133
 
132
134
  ## Product Strengths
133
135
 
@@ -147,15 +149,18 @@ npm run desktop
147
149
  - **One runtime for many surfaces**: web, terminal, Discord, Slack, Teams,
148
150
  email, voice, webhooks, and local API clients all use the same gateway,
149
151
  memory, policy, and audit model.
152
+ - **Generated apps from chat**: describe an app, dashboard, document, game, or
153
+ tool in web chat; HybridClaw saves the generated HTML artifact into the Apps
154
+ gallery and can refresh live apps through read-only connector calls.
150
155
  - **Secure by default**: LLM output is treated as untrusted, risky actions
151
156
  route through approval policy, and every sensitive boundary is visible in
152
157
  audit.
153
158
  - **Model freedom**: use HybridAI, major hosted providers, local engines, or
154
159
  named OpenAI-compatible endpoints from the same model picker and config
155
160
  surface.
156
- - **Operator visibility**: `/admin` covers channels, approvals, audit,
157
- statistics, output guard, secrets, fleet topology, A2A inbox/trust, and
158
- distillation without requiring shell access.
161
+ - **Operator visibility**: `/admin` covers channels, connectors, approvals,
162
+ audit, statistics, output guard, secrets, fleet topology, A2A inbox/trust,
163
+ and distillation without requiring shell access.
159
164
  - **Business-ready extension model**: packaged skills, plugins, MCP servers,
160
165
  and SecretRef-backed HTTP tools share the same approval and credential
161
166
  boundaries.
@@ -211,7 +216,7 @@ Core pieces:
211
216
  - **Container runtime**: sandboxed tool execution, provider adapters, browser
212
217
  automation, media/search tooling, file-based IPC.
213
218
  - **TUI client**: thin HTTP client for terminal-first operation.
214
- - **Console**: web chat and admin UI served by the gateway.
219
+ - **Console**: web chat, Apps gallery, and admin UI served by the gateway.
215
220
 
216
221
  ## Docs By Goal
217
222
 
@@ -219,6 +224,7 @@ Core pieces:
219
224
  | --- | --- |
220
225
  | Install and launch | [Quick Start](https://hybridaione.github.io/hybridclaw/docs/getting-started/quickstart), [Installation](https://hybridaione.github.io/hybridclaw/docs/getting-started/installation) |
221
226
  | Configure providers and models | [Authentication](https://hybridaione.github.io/hybridclaw/docs/getting-started/authentication), [Model Selection](https://hybridaione.github.io/hybridclaw/docs/reference/model-selection) |
227
+ | Build generated apps | [Apps Gallery](https://hybridaione.github.io/hybridclaw/docs/guides/apps) |
222
228
  | Connect channels | [Connect Your First Channel](https://hybridaione.github.io/hybridclaw/docs/getting-started/first-channel), [Channels](https://hybridaione.github.io/hybridclaw/docs/channels/overview) |
223
229
  | Use bundled skills | [Bundled Skills](https://hybridaione.github.io/hybridclaw/docs/guides/bundled-skills), [Skills Catalog](https://hybridaione.github.io/hybridclaw/docs/guides/skills/) |
224
230
  | Distill a coworker | [Human Distillation](https://hybridaione.github.io/hybridclaw/docs/guides/human-distillation) |
@@ -228,7 +234,7 @@ Core pieces:
228
234
  | Build desktop releases | [Desktop Release Builds](https://hybridaione.github.io/hybridclaw/docs/developer-guide/desktop-release) |
229
235
  | Contribute | [CONTRIBUTING.md](./CONTRIBUTING.md), [docs/content/README.md](./docs/content/README.md) |
230
236
 
231
- Latest release: [v0.25.8](https://github.com/HybridAIOne/hybridclaw/releases/tag/v0.25.8).
237
+ Latest release: [v0.27.0](https://github.com/HybridAIOne/hybridclaw/releases/tag/v0.27.0).
232
238
  Release notes: [CHANGELOG.md](./CHANGELOG.md)
233
239
 
234
240
  ## Development
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": 31,
2
+ "version": 32,
3
3
  "security": {
4
4
  "trustModelAccepted": false,
5
5
  "trustModelAcceptedAt": "",
@@ -15,6 +15,30 @@
15
15
  "health_check_interval_ms": 30000
16
16
  }
17
17
  },
18
+ "ui": {
19
+ "navigation": [
20
+ {
21
+ "href": "/chat",
22
+ "label": "Chat"
23
+ },
24
+ {
25
+ "href": "/agents",
26
+ "label": "Agents"
27
+ },
28
+ {
29
+ "href": "/admin",
30
+ "label": "Admin"
31
+ },
32
+ {
33
+ "href": "https://github.com/HybridAIOne/hybridclaw",
34
+ "label": "GitHub"
35
+ },
36
+ {
37
+ "href": "/docs",
38
+ "label": "Docs"
39
+ }
40
+ ]
41
+ },
18
42
  "browser": {
19
43
  "provider": "local",
20
44
  "local": {
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-Bh1tDfsg.js";import{C as t,a as n,n as r,o as i,r as a}from"./query-o_Dd9s85.js";import{l as o}from"./router-DoNPHesn.js";import{D as s,H as c,J as l,L as u,O as d,T as f,X as p,Y as m,at as h,ct as g,et as _,ft as v,ht as y,it as b,j as x,k as S,mt as C,nt as w,ot as T,pt as E,q as D,r as O,rt as k,tt as A,vt as j}from"./index-Btzl6jZZ.js";import{C as M,S as ee,_ as N,b as P,i as F,m as I,n as L,r as R,t as z,v as te,w as ne,x as B}from"./chat-sidebar-bGb6YbfM.js";var V=e(t(),1),H={scroll:`_scroll_in2v6_1`,page:`_page_in2v6_7`,topbar:`_topbar_in2v6_18`,topbarLeft:`_topbarLeft_in2v6_25`,mobileTrigger:`_mobileTrigger_in2v6_31`,title:`_title_in2v6_35`,toolbar:`_toolbar_in2v6_43`,searchWrap:`_searchWrap_in2v6_49`,searchIcon:`_searchIcon_in2v6_56`,searchInput:`_searchInput_in2v6_65`,filterTrigger:`_filterTrigger_in2v6_82`,newAppTrigger:`_newAppTrigger_in2v6_101`,newAppItem:`_newAppItem_in2v6_120`,newAppItemTitle:`_newAppItemTitle_in2v6_127`,newAppItemHint:`_newAppItemHint_in2v6_133`,grid:`_grid_in2v6_138`,card:`_card_in2v6_147`,cardMain:`_cardMain_in2v6_162`,cardTop:`_cardTop_in2v6_176`,cardGlyph:`_cardGlyph_in2v6_183`,kindBadge:`_kindBadge_in2v6_194`,kindBadgeLive:`_kindBadgeLive_in2v6_195`,cardActions:`_cardActions_in2v6_213`,cardAction:`_cardAction_in2v6_213`,cardActionIcon:`_cardActionIcon_in2v6_246`,inlineIcon:`_inlineIcon_in2v6_251`,cardBody:`_cardBody_in2v6_262`,cardTitle:`_cardTitle_in2v6_269`,cardDesc:`_cardDesc_in2v6_276`,cardMeta:`_cardMeta_in2v6_287`,cardCategory:`_cardCategory_in2v6_296`,cardDot:`_cardDot_in2v6_301`,cardDelete:`_cardDelete_in2v6_305`,cardDeleteIcon:`_cardDeleteIcon_in2v6_333`,buildingBanner:`_buildingBanner_in2v6_338`,buildingSpinner:`_buildingSpinner_in2v6_350`,appsSpin:`_appsSpin_in2v6_1`,empty:`_empty_in2v6_367`,emptyGlyph:`_emptyGlyph_in2v6_379`,emptyTitle:`_emptyTitle_in2v6_395`,emptyText:`_emptyText_in2v6_402`,newDialog:`_newDialog_in2v6_410`,categoryGrid:`_categoryGrid_in2v6_415`,categoryTile:`_categoryTile_in2v6_422`,categoryGlyph:`_categoryGlyph_in2v6_443`,dialogTitleIcon:`_dialogTitleIcon_in2v6_459`,examples:`_examples_in2v6_475`,examplesLabel:`_examplesLabel_in2v6_482`,exampleChips:`_exampleChips_in2v6_490`,exampleChip:`_exampleChip_in2v6_490`,categoryLabel:`_categoryLabel_in2v6_519`,categoryHint:`_categoryHint_in2v6_525`,promptInput:`_promptInput_in2v6_531`,secondaryButton:`_secondaryButton_in2v6_552`,viewerDialog:`_viewerDialog_in2v6_578`,viewerHeader:`_viewerHeader_in2v6_588`,viewerTitle:`_viewerTitle_in2v6_600`,viewerActions:`_viewerActions_in2v6_609`,viewerFrame:`_viewerFrame_in2v6_618`},U=i();function re(){let e=y(),t=s(),i=o(),c=n(),l=(0,V.useRef)(f()).current,[u,p]=(0,V.useState)(``),[m,g]=(0,V.useState)(`user`),[v,S]=(0,V.useState)(null),E=u.trim(),D=a({queryKey:[`apps-chat-recent`,e.token,l,E,m],queryFn:()=>I(e.token,l,`web`,E?F.maxSearchResults:F.maxRecentSessions,E||void 0,m),staleTime:1e4,enabled:C(e)}),O=r({mutationFn:t=>j(e.token,t),onSuccess:async()=>{S(null),await c.invalidateQueries({queryKey:[`apps-chat-recent`]}),t.success(`Conversation deleted.`)},onError:e=>{t.error(`Delete failed: ${x(e)}`)}});return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(z,{sessions:D.data?.sessions??[],activeSessionId:``,onNewChat:()=>i({to:`/chat`}),onOpenSession:e=>i({to:`/chat/$sessionId`,params:{sessionId:e}}),onRequestDeleteSession:e=>S(e),deleteDisabled:O.isPending,searchQuery:u,onSearchQueryChange:p,recentScope:m,onRecentScopeChange:g,isLoading:D.isFetching,onRefreshRecent:()=>{D.refetch()}}),(0,U.jsx)(_,{open:v!==null,onOpenChange:e=>{e||S(null)},children:(0,U.jsxs)(w,{size:`sm`,role:`alertdialog`,children:[(0,U.jsxs)(h,{children:[(0,U.jsx)(T,{children:`Delete conversation?`}),(0,U.jsxs)(k,{children:[`“`,v?.title||`Untitled`,`” will be permanently removed.`]})]}),(0,U.jsxs)(b,{children:[(0,U.jsx)(A,{children:`Cancel`}),(0,U.jsx)(d,{variant:`danger`,disabled:O.isPending,onClick:()=>v&&O.mutate(v.sessionId),children:O.isPending?`Deleting…`:`Delete`})]})]})})]})}var W=[{slug:`apps`,label:`Apps & websites`,hint:`Internal tools, portals, landing pages`,seedNoun:`web app or website`,examples:[`A client onboarding portal with step-by-step progress`,`A SaaS pricing page with a monthly/annual toggle`,`An internal team directory with search`]},{slug:`documents`,label:`Documents & templates`,hint:`Proposals, reports, printable templates`,seedNoun:`document or template`,examples:[`A consulting invoice with line items and totals`,`A quarterly business review one-pager`,`A statement-of-work proposal template`]},{slug:`games`,label:`Games`,hint:`Playable browser games`,seedNoun:`browser game`,examples:[`A product-knowledge quiz game for new hires`,`A typing-speed trainer`,`A memory match game`]},{slug:`productivity`,label:`Productivity tools`,hint:`Calculators, trackers, dashboards`,seedNoun:`productivity tool`,examples:[`A SaaS MRR and churn dashboard`,`A meeting-cost calculator`,`A project ROI calculator`]},{slug:`creative`,label:`Creative projects`,hint:`Brand assets, mockups, visuals`,seedNoun:`creative project`,examples:[`A branded social media post mockup`,`A pitch-deck cover slide`,`A simple drawing canvas`]},{slug:`quiz`,label:`Quiz or survey`,hint:`Lead capture, feedback, assessments`,seedNoun:`quiz or survey`,examples:[`A lead-qualification survey with scoring`,`An employee eNPS survey`,`A customer CSAT form`]},{slug:`scratch`,label:`Start from scratch`,hint:`Describe anything you can imagine`,seedNoun:null,examples:[]}],G=new Map(W.map(e=>[e.slug,e]));function K(e){return G.get(e)?.label??`App`}function q(){let{token:e}=y(),t=s(),i=o(),f=n(),[g,S]=(0,V.useState)(``),[C,j]=(0,V.useState)(`all`),[P,F]=(0,V.useState)(null),[I,L]=(0,V.useState)(null),[R,z]=(0,V.useState)(0),[B,q]=(0,V.useState)(null),J=(0,V.useRef)(null),Y=a({queryKey:[`apps`,e],queryFn:()=>ne(e),retry:!1});function ce(e,t){let n=G.get(e)?.seedNoun??null;F(null),i({to:`/chat`,search:{prompt:N(n,t),send:`1`,app:`1`,kind:`web`,...e===`scratch`?{}:{category:e}}})}function le(e){F(null),i({to:`/chat`,search:{prompt:te(e),send:`1`,app:`1`,kind:`live`}})}async function X(n){if(n.kind!==`live`){t.error(`Only live apps can refresh connector data.`);return}if(!(I?.id===n.id&&J.current?.refreshData()))try{L((await M(e,n.id)).app),z(e=>e+1)}catch(e){t.error(`Could not refresh app: ${x(e)}`)}}let Z=r({mutationFn:t=>ee(e,t),onSuccess:async(e,n)=>{await f.invalidateQueries({queryKey:[`apps`]}),I?.id===n&&L(null),q(null),t.success(`App deleted.`)},onError:e=>{t.error(`Delete failed: ${x(e)}`)}}),Q=Y.data?.apps??[],$=(0,V.useMemo)(()=>{let e=g.trim().toLowerCase();return Q.filter(t=>C!==`all`&&t.category!==C?!1:e?t.title.toLowerCase().includes(e)||(t.description??``).toLowerCase().includes(e):!0)},[Q,g,C]);async function ue(n){try{L((await M(e,n.id)).app)}catch(e){t.error(`Could not open app: ${x(e)}`)}}let de=C===`all`?`All`:K(C);return(0,U.jsxs)(c,{children:[(0,U.jsxs)(`div`,{className:O.chatPage,children:[(0,U.jsx)(re,{}),(0,U.jsx)(`div`,{className:O.chatMain,children:(0,U.jsx)(`div`,{className:H.scroll,children:(0,U.jsxs)(`div`,{className:H.page,children:[(0,U.jsxs)(`header`,{className:H.topbar,children:[(0,U.jsxs)(`div`,{className:H.topbarLeft,children:[(0,U.jsx)(u,{className:H.mobileTrigger}),(0,U.jsx)(`h1`,{className:H.title,children:`Apps`})]}),(0,U.jsxs)(D,{children:[(0,U.jsxs)(p,{className:H.newAppTrigger,children:[`+ New app`,(0,U.jsx)(E,{"aria-hidden":`true`})]}),(0,U.jsxs)(l,{align:`end`,children:[(0,U.jsx)(m,{onSelect:()=>F(`web`),children:(0,U.jsxs)(`span`,{className:H.newAppItem,children:[(0,U.jsx)(`span`,{className:H.newAppItemTitle,children:`Web app`}),(0,U.jsx)(`span`,{className:H.newAppItemHint,children:`Self-contained app, document, game, or tool`})]})}),(0,U.jsx)(m,{onSelect:()=>F(`live`),children:(0,U.jsxs)(`span`,{className:H.newAppItem,children:[(0,U.jsx)(`span`,{className:H.newAppItemTitle,children:`Live app`}),(0,U.jsx)(`span`,{className:H.newAppItemHint,children:`Uses your connectors and can be refreshed`})]})})]})]})]}),(0,U.jsxs)(`div`,{className:H.toolbar,children:[(0,U.jsxs)(`div`,{className:H.searchWrap,children:[(0,U.jsx)(v,{className:H.searchIcon,"aria-hidden":`true`}),(0,U.jsx)(`input`,{type:`search`,className:H.searchInput,placeholder:`Search apps…`,value:g,onChange:e=>S(e.target.value),"aria-label":`Search apps`})]}),(0,U.jsxs)(D,{children:[(0,U.jsxs)(p,{className:H.filterTrigger,children:[(0,U.jsxs)(`span`,{children:[`Filter: `,(0,U.jsx)(`strong`,{children:de})]}),(0,U.jsx)(E,{"aria-hidden":`true`})]}),(0,U.jsxs)(l,{align:`end`,children:[(0,U.jsx)(m,{active:C===`all`,onSelect:()=>j(`all`),children:`All`}),W.map(e=>(0,U.jsx)(m,{active:C===e.slug,onSelect:()=>j(e.slug),children:e.label},e.slug))]})]})]}),Y.isPending?(0,U.jsx)(`div`,{className:`empty-state`,children:`Loading apps…`}):Y.isError?(0,U.jsxs)(`div`,{className:`empty-state`,children:[`Failed to load apps: `,x(Y.error)]}):$.length===0?(0,U.jsx)(ie,{hasApps:Q.length>0,onCreate:()=>F(`web`)}):(0,U.jsx)(`ul`,{className:H.grid,children:$.map(e=>(0,U.jsx)(`li`,{children:(0,U.jsx)(ae,{app:e,onOpen:()=>ue(e),onDelete:()=>q(e),onRefresh:()=>X(e)})},e.id))})]})})})]}),(0,U.jsx)(oe,{kind:P,onClose:()=>F(null),onStartWeb:ce,onStartLive:le}),(0,U.jsx)(se,{app:I,token:e,onClose:()=>L(null),frameRef:J,refreshNonce:R,onRefresh:I?()=>X(I):void 0}),(0,U.jsx)(_,{open:B!==null,onOpenChange:e=>{e||q(null)},children:(0,U.jsxs)(w,{size:`sm`,role:`alertdialog`,children:[(0,U.jsxs)(h,{children:[(0,U.jsx)(T,{children:`Delete app?`}),(0,U.jsxs)(k,{children:[`“`,B?.title,`” will be permanently removed from the gallery.`]})]}),(0,U.jsxs)(b,{children:[(0,U.jsx)(A,{className:H.secondaryButton,children:`Cancel`}),(0,U.jsx)(d,{variant:`danger`,disabled:Z.isPending,onClick:()=>B&&Z.mutate(B.id),children:Z.isPending?`Deleting…`:`Delete`})]})]})})]})}function ie(e){return(0,U.jsxs)(`div`,{className:H.empty,children:[(0,U.jsx)(`div`,{className:H.emptyGlyph,"aria-hidden":`true`,children:(0,U.jsx)(L,{category:`scratch`})}),(0,U.jsx)(`h2`,{className:H.emptyTitle,children:e.hasApps?`No matching apps`:`No apps yet`}),(0,U.jsx)(`p`,{className:H.emptyText,children:e.hasApps?`Try a different search or filter.`:`Describe an app, document, tool, or report and HybridClaw builds it for you.`}),e.hasApps?null:(0,U.jsx)(d,{onClick:e.onCreate,children:`+ New app`})]})}function ae(e){let{app:t}=e,n=t.kind===`live`;return(0,U.jsxs)(`div`,{className:H.card,children:[(0,U.jsxs)(`button`,{type:`button`,className:H.cardMain,onClick:e.onOpen,children:[(0,U.jsxs)(`div`,{className:H.cardTop,children:[(0,U.jsx)(`div`,{className:H.cardGlyph,"aria-hidden":`true`,children:(0,U.jsx)(L,{category:t.category})}),(0,U.jsx)(`span`,{className:n?H.kindBadgeLive:H.kindBadge,title:n?`Connector-aware, refreshable`:void 0,children:n?`Live`:`Web`})]}),(0,U.jsxs)(`div`,{className:H.cardBody,children:[(0,U.jsx)(`span`,{className:H.cardTitle,children:t.title}),t.description?(0,U.jsx)(`span`,{className:H.cardDesc,children:t.description}):null]}),(0,U.jsxs)(`div`,{className:H.cardMeta,children:[(0,U.jsx)(`span`,{className:H.cardCategory,children:K(t.category)}),(0,U.jsx)(`span`,{className:H.cardDot,children:`·`}),(0,U.jsx)(`span`,{children:S(t.createdAt)}),(0,U.jsx)(`span`,{className:H.cardDot,children:`·`}),(0,U.jsx)(`span`,{children:t.visibility===`public`?`Public`:`Private`})]})]}),(0,U.jsxs)(`div`,{className:H.cardActions,children:[n?(0,U.jsx)(`button`,{type:`button`,className:H.cardAction,"aria-label":`Refresh ${t.title}`,title:`Refresh with latest data`,onClick:e.onRefresh,children:(0,U.jsx)(R,{className:H.cardActionIcon})}):null,(0,U.jsx)(`button`,{type:`button`,className:H.cardAction,"aria-label":`Delete ${t.title}`,title:`Delete`,onClick:e.onDelete,children:(0,U.jsx)(g,{className:H.cardActionIcon})})]})]})}function oe(e){let[t,n]=(0,V.useState)(null),[r,i]=(0,V.useState)(``),a=e.kind!==null;(0,V.useEffect)(()=>{a&&(n(null),i(``))},[a,e.kind]);let o=t?G.get(t):void 0,s=e.kind===`web`&&t===null;return(0,U.jsx)(_,{open:a,onOpenChange:t=>{t||e.onClose()},children:(0,U.jsx)(w,{className:H.newDialog,children:s?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(h,{children:[(0,U.jsx)(T,{children:`Create a web app`}),(0,U.jsx)(k,{children:`Pick a category to get started, or start from scratch with your own idea.`})]}),(0,U.jsx)(`div`,{className:H.categoryGrid,children:W.map(e=>(0,U.jsxs)(`button`,{type:`button`,className:H.categoryTile,onClick:()=>n(e.slug),children:[(0,U.jsx)(`span`,{className:H.categoryGlyph,"aria-hidden":`true`,children:(0,U.jsx)(L,{category:e.slug})}),(0,U.jsx)(`span`,{className:H.categoryLabel,children:e.label}),(0,U.jsx)(`span`,{className:H.categoryHint,children:e.hint})]},e.slug))})]}):e.kind===`live`?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(h,{children:[(0,U.jsx)(T,{children:`Create a live app`}),(0,U.jsx)(k,{children:`HybridClaw checks your connected tools (MCP), suggests apps that use them, then builds one you can refresh. Add a starting idea (optional).`})]}),(0,U.jsx)(`textarea`,{className:H.promptInput,value:r,autoFocus:!0,placeholder:`e.g. A dashboard of my upcoming meetings and unread priority emails`,onChange:e=>i(e.target.value),rows:4}),(0,U.jsxs)(b,{children:[(0,U.jsx)(`button`,{type:`button`,className:H.secondaryButton,onClick:e.onClose,children:`Cancel`}),(0,U.jsx)(d,{onClick:()=>e.onStartLive(r.trim()),children:`Start building →`})]})]}):t?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(h,{children:[(0,U.jsxs)(T,{children:[(0,U.jsx)(`span`,{className:H.dialogTitleIcon,"aria-hidden":`true`,children:(0,U.jsx)(L,{category:t})}),o?.label]}),(0,U.jsx)(k,{children:`Add a starting idea (optional). HybridClaw opens a chat, asks a few questions, then builds it for you.`})]}),(0,U.jsx)(`textarea`,{className:H.promptInput,value:r,autoFocus:!0,placeholder:`e.g. A client onboarding portal that tracks setup steps and shows progress`,onChange:e=>i(e.target.value),rows:4}),o&&o.examples.length>0?(0,U.jsxs)(`div`,{className:H.examples,children:[(0,U.jsx)(`span`,{className:H.examplesLabel,children:`Examples`}),(0,U.jsx)(`div`,{className:H.exampleChips,children:o.examples.map(e=>(0,U.jsx)(`button`,{type:`button`,className:H.exampleChip,onClick:()=>i(e),children:e},e))})]}):null,(0,U.jsxs)(b,{children:[(0,U.jsx)(`button`,{type:`button`,className:H.secondaryButton,onClick:()=>n(null),children:`← Back`}),(0,U.jsx)(d,{onClick:()=>e.onStartWeb(t,r.trim()),children:`Start building →`})]})]}):null})})}function se(e){let{app:t}=e;return(0,U.jsx)(_,{open:t!==null,onOpenChange:t=>{t||e.onClose()},children:(0,U.jsxs)(w,{className:H.viewerDialog,"aria-label":`App preview`,children:[(0,U.jsxs)(`div`,{className:H.viewerHeader,children:[(0,U.jsx)(T,{className:H.viewerTitle,children:t?.title}),(0,U.jsxs)(`div`,{className:H.viewerActions,children:[t&&t.kind===`live`&&e.onRefresh?(0,U.jsxs)(`button`,{type:`button`,className:H.secondaryButton,onClick:t=>{t.stopPropagation(),e.onRefresh?.()},children:[(0,U.jsx)(R,{className:H.inlineIcon}),` Refresh`]}):null,t?(0,U.jsx)(`a`,{className:H.secondaryButton,href:B(t.id,e.token),target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),children:`Open in new tab ↗`}):null,(0,U.jsx)(A,{className:H.secondaryButton,onClick:e=>e.stopPropagation(),children:`Close`})]})]}),t?(0,U.jsx)(P,{ref:e.frameRef,appId:t.id,className:H.viewerFrame,refreshNonce:e.refreshNonce,title:t.title,token:e.token}):null]})})}export{q as AppsPage};
@@ -0,0 +1 @@
1
+ ._scroll_in2v6_1{flex:auto;min-height:0;overflow-y:auto}._page_in2v6_7{box-sizing:border-box;flex-direction:column;gap:20px;width:100%;max-width:1100px;margin:0 auto;padding:28px 24px 48px;display:flex}._topbar_in2v6_18{justify-content:space-between;align-items:center;gap:16px;display:flex}._topbarLeft_in2v6_25{align-items:center;gap:10px;display:flex}._mobileTrigger_in2v6_31{flex-shrink:0}._title_in2v6_35{letter-spacing:-.01em;color:var(--foreground);margin:0;font-size:1.75rem;font-weight:700}._toolbar_in2v6_43{align-items:center;gap:12px;display:flex}._searchWrap_in2v6_49{flex:1;align-items:center;display:flex;position:relative}._searchIcon_in2v6_56{width:18px;height:18px;color:var(--muted-foreground);pointer-events:none;position:absolute;left:14px}._searchInput_in2v6_65{box-sizing:border-box;border:1px solid var(--border);background:var(--card);width:100%;color:var(--foreground);border-radius:12px;padding:12px 14px 12px 42px;font-size:.9375rem}._searchInput_in2v6_65:focus{border-color:var(--ring);box-shadow:var(--shadow-focus);outline:none}._filterTrigger_in2v6_82{border:1px solid var(--border);background:var(--card);color:var(--foreground);white-space:nowrap;border-radius:12px;align-items:center;gap:8px;padding:10px 14px;font-size:.875rem;display:inline-flex}._filterTrigger_in2v6_82 svg{width:16px;height:16px;color:var(--muted-foreground)}._newAppTrigger_in2v6_101{border-radius:var(--radius-sm,10px);background:var(--foreground);color:var(--background);white-space:nowrap;border:none;align-items:center;gap:6px;padding:9px 14px;font-size:.875rem;font-weight:500;display:inline-flex}._newAppTrigger_in2v6_101 svg{width:15px;height:15px}._newAppItem_in2v6_120{text-align:left;flex-direction:column;gap:2px;display:flex}._newAppItemTitle_in2v6_127{color:var(--foreground);font-size:.875rem;font-weight:600}._newAppItemHint_in2v6_133{color:var(--muted-foreground);font-size:.75rem}._grid_in2v6_138{grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:16px;margin:0;padding:0;list-style:none;display:grid}._card_in2v6_147{border:1px solid var(--border);background:var(--card);height:100%;box-shadow:var(--shadow-card);border-radius:14px;transition:border-color .12s;display:flex;position:relative}._card_in2v6_147:hover{border-color:var(--border-strong)}._cardMain_in2v6_162{text-align:left;cursor:pointer;color:inherit;background:0 0;border:none;border-radius:14px;flex-direction:column;flex:1;gap:12px;padding:18px;display:flex}._cardTop_in2v6_176{justify-content:space-between;align-items:center;gap:8px;display:flex}._cardGlyph_in2v6_183{background:var(--muted);width:38px;height:38px;color:var(--foreground);border-radius:10px;justify-content:center;align-items:center;display:inline-flex}._kindBadge_in2v6_194,._kindBadgeLive_in2v6_195{border:1px solid var(--border);color:var(--muted-foreground);background:var(--muted);text-transform:uppercase;letter-spacing:.03em;border-radius:999px;padding:2px 8px;font-size:.6875rem;font-weight:600}._kindBadgeLive_in2v6_195{color:var(--accent-foreground,var(--foreground));background:var(--accent-soft,var(--accent));border-color:var(--accent,var(--border-strong))}._cardActions_in2v6_213{opacity:0;gap:4px;transition:opacity .12s;display:flex;position:absolute;top:10px;right:10px}._card_in2v6_147:hover ._cardActions_in2v6_213,._cardActions_in2v6_213:focus-within{opacity:1}._cardAction_in2v6_213{background:var(--card);width:30px;height:30px;color:var(--muted-foreground);cursor:pointer;border:none;border-radius:8px;justify-content:center;align-items:center;display:inline-flex}._cardAction_in2v6_213:hover{background:var(--nav-hover);color:var(--foreground)}._cardActionIcon_in2v6_246{width:16px;height:16px}._inlineIcon_in2v6_251{vertical-align:-2px;width:15px;height:15px}._cardGlyph_in2v6_183 svg{width:22px;height:22px}._cardBody_in2v6_262{flex-direction:column;flex:1;gap:6px;display:flex}._cardTitle_in2v6_269{color:var(--foreground);font-size:1rem;font-weight:650;line-height:1.3}._cardDesc_in2v6_276{color:var(--muted-foreground);-webkit-line-clamp:3;line-clamp:3;-webkit-box-orient:vertical;font-size:.8125rem;line-height:1.45;display:-webkit-box;overflow:hidden}._cardMeta_in2v6_287{color:var(--muted-foreground);flex-wrap:wrap;align-items:center;gap:6px;font-size:.75rem;display:flex}._cardCategory_in2v6_296{color:var(--foreground);font-weight:600}._cardDot_in2v6_301{opacity:.5}._cardDelete_in2v6_305{width:30px;height:30px;color:var(--muted-foreground);cursor:pointer;opacity:0;background:0 0;border:none;border-radius:8px;justify-content:center;align-items:center;transition:opacity .12s;display:inline-flex;position:absolute;top:10px;right:10px}._card_in2v6_147:hover ._cardDelete_in2v6_305,._cardDelete_in2v6_305:focus-visible{opacity:1}._cardDelete_in2v6_305:hover{background:var(--danger-soft);color:var(--danger)}._cardDeleteIcon_in2v6_333{width:16px;height:16px}._buildingBanner_in2v6_338{border:1px solid var(--border);background:var(--accent-soft,var(--card));color:var(--foreground);border-radius:12px;align-items:center;gap:10px;padding:12px 16px;font-size:.875rem;display:flex}._buildingSpinner_in2v6_350{border:2px solid var(--border-strong);border-top-color:var(--primary);border-radius:50%;flex-shrink:0;width:16px;height:16px;animation:.7s linear infinite _appsSpin_in2v6_1}@keyframes _appsSpin_in2v6_1{to{transform:rotate(360deg)}}._empty_in2v6_367{text-align:center;border:1px dashed var(--border);background:var(--card);border-radius:16px;flex-direction:column;align-items:center;gap:12px;padding:64px 24px;display:flex}._emptyGlyph_in2v6_379{background:var(--muted);width:48px;height:48px;color:var(--muted-foreground);border-radius:12px;justify-content:center;align-items:center;display:inline-flex}._emptyGlyph_in2v6_379 svg{width:26px;height:26px}._emptyTitle_in2v6_395{color:var(--foreground);margin:0;font-size:1.125rem;font-weight:650}._emptyText_in2v6_402{max-width:420px;color:var(--muted-foreground);margin:0 0 8px;font-size:.9375rem}._newDialog_in2v6_410{width:min(720px,94vw);max-width:min(720px,94vw)}._categoryGrid_in2v6_415{grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:12px;margin-top:8px;display:grid}._categoryTile_in2v6_422{border:1px solid var(--border);background:var(--card);cursor:pointer;text-align:left;border-radius:12px;flex-direction:column;gap:8px;min-height:110px;padding:16px;transition:border-color .12s,background .12s;display:flex}._categoryTile_in2v6_422:hover{border-color:var(--border-strong);background:var(--nav-hover)}._categoryGlyph_in2v6_443{background:var(--muted);width:40px;height:40px;color:var(--foreground);border-radius:10px;justify-content:center;align-items:center;display:inline-flex}._categoryGlyph_in2v6_443 svg{width:23px;height:23px}._dialogTitleIcon_in2v6_459{vertical-align:-5px;width:22px;height:22px;color:var(--foreground);justify-content:center;align-items:center;margin-right:8px;display:inline-flex}._dialogTitleIcon_in2v6_459 svg{width:20px;height:20px}._examples_in2v6_475{flex-direction:column;gap:8px;margin-top:12px;display:flex}._examplesLabel_in2v6_482{text-transform:uppercase;letter-spacing:.04em;color:var(--muted-foreground);font-size:.75rem;font-weight:600}._exampleChips_in2v6_490{flex-wrap:wrap;gap:8px;display:flex}._exampleChip_in2v6_490{border:1px solid var(--border);background:var(--card);color:var(--foreground);cursor:pointer;border-radius:999px;padding:6px 12px;font-size:.8125rem;transition:border-color .12s,background .12s}._exampleChip_in2v6_490:hover{border-color:var(--border-strong);background:var(--nav-hover)}._exampleChip_in2v6_490:disabled{opacity:.5;cursor:not-allowed}._categoryLabel_in2v6_519{color:var(--foreground);font-size:.9375rem;font-weight:650}._categoryHint_in2v6_525{color:var(--muted-foreground);font-size:.75rem;line-height:1.4}._promptInput_in2v6_531{box-sizing:border-box;border:1px solid var(--border);background:var(--input,var(--card));width:100%;color:var(--foreground);resize:vertical;border-radius:12px;min-height:120px;margin-top:8px;padding:12px 14px;font-family:inherit;font-size:.9375rem}._promptInput_in2v6_531:focus{border-color:var(--ring);box-shadow:var(--shadow-focus);outline:none}._secondaryButton_in2v6_552{border:1px solid var(--border);background:var(--card);color:var(--foreground);cursor:pointer;border-radius:10px;justify-content:center;align-items:center;gap:6px;padding:8px 14px;font-size:.875rem;text-decoration:none;display:inline-flex}._secondaryButton_in2v6_552:hover{border-color:var(--border-strong);background:var(--nav-hover)}._secondaryButton_in2v6_552:disabled{opacity:.5;cursor:not-allowed}._viewerDialog_in2v6_578{flex-direction:column;width:min(1100px,95vw);max-width:min(1100px,95vw);height:86vh;padding:0;display:flex;overflow:hidden}._viewerHeader_in2v6_588{z-index:2;border-bottom:1px solid var(--border);background:var(--panel-bg);justify-content:space-between;align-items:center;gap:16px;padding:14px 16px;display:flex;position:relative}._viewerTitle_in2v6_600{text-overflow:ellipsis;white-space:nowrap;margin:0;font-size:1rem;font-weight:650;overflow:hidden}._viewerActions_in2v6_609{z-index:3;flex-shrink:0;align-items:center;gap:8px;display:flex;position:relative}._viewerFrame_in2v6_618{z-index:1;background:#fff;border:none;flex:1;width:100%;min-height:0;position:relative}@media (width<=640px){._toolbar_in2v6_43{flex-direction:column;align-items:stretch}}
@@ -0,0 +1,4 @@
1
+ import{n as e}from"./rolldown-runtime-Bh1tDfsg.js";import{C as t,a as n,n as r,o as i,r as a}from"./query-o_Dd9s85.js";import{d as o,l as s,u as c}from"./router-DoNPHesn.js";import{$ as l,A as u,C as d,Ct as f,Dt as p,E as m,H as h,L as g,N as _,O as v,Ot as y,P as b,Q as ee,S as x,St as S,T as C,Z as w,_ as te,a as T,at as E,b as D,bt as ne,c as O,d as re,dt as ie,et as ae,f as k,g as A,h as oe,ht as se,i as j,it as ce,j as M,l as le,lt as ue,m as de,mt as fe,n as pe,nt as me,o as he,ot as ge,p as _e,r as N,rt as ve,s as P,st as F,t as ye,tt as be,u as xe,ut as Se,vt as Ce,w as I,x as we,xt as Te,y as Ee}from"./index-Btzl6jZZ.js";import{_ as De,a as Oe,b as ke,c as Ae,d as je,f as Me,g as Ne,h as Pe,i as Fe,l as Ie,m as Le,o as Re,p as ze,s as Be,t as Ve,u as He,x as Ue,y as L}from"./chat-sidebar-bGb6YbfM.js";var R=e(t(),1);function We(e,t){let[n,r]=(0,R.useState)(e);return(0,R.useEffect)(()=>{let n=window.setTimeout(()=>{r(e)},t);return()=>{window.clearTimeout(n)}},[e,t]),n}var Ge=`[A-Za-z0-9._-]+(?:@[A-Za-z0-9._-]+@[A-Za-z0-9._-]+)?`,Ke=String.raw`(?=$|[\s:.,!?;)\]}])`;RegExp(`^@(${Ge})${Ke}`,`u`);var qe=RegExp(`@(${Ge})${Ke}`,`gu`);function Je(e){let t=[];for(let n of e.matchAll(qe)){let r=n[0],i=n[1]??``,a=n.index??0;if(!i)continue;let o=a===0?``:e[a-1];o&&!/[\s([{]/u.test(o)||t.push({mention:r,agentId:i,index:a})}return t}var Ye=new Map;function z(e){return String(e??``).trim().toLowerCase()}function B(e,t){if(!e||!Array.isArray(e.steps)||e.steps.length===0)return null;let n=e.steps.map(e=>e.kind===`thinking`?{kind:`thinking`,text:e.text}:{kind:`tool`,toolName:e.toolName,status:`done`,...e.argsPreview?{argsPreview:e.argsPreview}:{},...e.resultPreview?{resultPreview:e.resultPreview}:{},...typeof e.durationMs==`number`?{durationMs:e.durationMs}:{}});return{id:I(),role:`trace`,content:``,sessionId:t,steps:n,done:!0,startedAt:0,...typeof e.elapsedMs==`number`?{finishedAt:e.elapsedMs}:{}}}function Xe(e,t){let n=e.sessionId??t,r=new Map((e.branchFamilies??[]).map(e=>[`${e.anchorSessionId}:${e.anchorMessageId}`,e.variants])),i=new Map;for(let[e,t]of r.entries()){let r=t.find(e=>e.sessionId===n);r&&i.set(r.messageId,e)}let a=e.history??[],o=z(e.agentId),s=null,c=[];return a.forEach((e,t)=>{let r=a.slice(t+1).find(e=>e.role!==`system`),l=z(r?.agent_id??r?.assistantPresentation?.agentId),u=e.role===`user`&&r?.role===`assistant`&&l&&l!==o?r?.assistantPresentation??null:null;e.role===`user`&&(s=e.content);let d=e.role===`user`?e.content:e.role===`assistant`?s:null,f={id:I(),role:e.role,content:e.content,rawContent:e.content,sessionId:n,messageId:e.id??null,media:[],artifacts:e.artifacts??[],replayRequest:d===null?null:{content:d,media:[]},assistantPresentation:e.assistantPresentation??null,addressedAgentPresentation:u,responseRating:e.response_rating??null,branchKey:e.id!==void 0&&e.id!==null?i.get(e.id)??null:null};if(e.role===`assistant`){let t=B(e.activityTrace,n);t&&c.push(t)}c.push(f)}),{messages:c,branchFamilies:r,requestedSessionId:t,resolvedSessionId:n,agentId:e.agentId?.trim()||null,bootstrapAutostart:e.bootstrapAutostart??null}}function V(e,t){return[`chat-history`,e,t]}async function Ze(e,t,n,r){return Xe(await ze(e,t,80,n,r),t)}var Qe=new Map;function $e(e,t){return`${e}\u0000${t}`}function H(e,t){let n=$e(e,t),r=Qe.get(n);return r||(r={objectUrl:null,loading:!1,promise:null,listeners:new Set},Qe.set(n,r)),r}function et(e){for(let t of e.listeners)t()}function tt(e,t){let n=t?.trim(),r=e.trim();if(!n)return null;let i=H(r,n);return i.objectUrl?Promise.resolve(i.objectUrl):i.promise?i.promise:(i.loading=!0,i.promise=Ie(r,n).then(e=>{let t=URL.createObjectURL(e);return i.objectUrl=t,i.loading=!1,i.promise=null,et(i),t}).catch(()=>(i.objectUrl=null,i.loading=!1,i.promise=null,et(i),null)),et(i),i.promise)}function U(e){let t=e.token.trim(),n=e.imageUrl?.trim()??``,[r,i]=(0,R.useState)(()=>{if(!n)return{objectUrl:null,loading:!1};let e=H(t,n);return{objectUrl:e.objectUrl,loading:e.loading}});return(0,R.useEffect)(()=>{if(!n){i({objectUrl:null,loading:!1});return}let e=H(t,n),r=()=>{i({objectUrl:e.objectUrl,loading:e.loading})};return e.listeners.add(r),r(),tt(t,n),()=>{e.listeners.delete(r)}},[t,n]),r}var W=i();function G(){return(0,W.jsx)(`svg`,{"aria-hidden":`true`,focusable:`false`,viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,W.jsx)(`path`,{d:`m6 9 6 6 6-6`})})}function nt(e){let t=e.agents.find(t=>t.id===e.selectedAgentId),n=t?.name?.trim()||t?.id||`Agent`,{localAgents:r,remoteGroups:i}=(0,R.useMemo)(()=>{let t=e.agents.filter(e=>e.source?.type!==`remote`),n=new Map;for(let t of e.agents){if(t.source?.type!==`remote`)continue;let e=t.source.instanceId;n.set(e,[...n.get(e)??[],t])}return{localAgents:t,remoteGroups:[...n.entries()]}},[e.agents]),a=i.length>0;return e.agents.length===0?null:(0,W.jsxs)(j,{value:e.selectedAgentId,disabled:e.disabled,onValueChange:t=>{if(!t||t===e.selectedAgentId)return;let n=e.agents.find(e=>e.id===t);n&&e.onSwitch(n)},children:[(0,W.jsxs)(k,{className:N.composerPill,"aria-label":`Switch agent`,disabled:e.disabled,children:[(0,W.jsx)(_e,{children:n}),(0,W.jsx)(O,{className:N.composerPillChevron,children:(0,W.jsx)(G,{})})]}),(0,W.jsxs)(T,{className:N.agentSelectPopup,children:[a?(0,W.jsxs)(he,{children:[(0,W.jsx)(P,{children:`Local`}),r.map(t=>(0,W.jsx)(K,{agent:t,token:e.token},t.id))]}):r.map(t=>(0,W.jsx)(K,{agent:t,token:e.token},t.id)),i.map(([t,n])=>(0,W.jsxs)(he,{children:[(0,W.jsxs)(P,{className:N.remoteAgentGroupLabel,children:[(0,W.jsx)(ie,{"aria-hidden":`true`,className:N.remoteAgentGroupIcon,width:13,height:13}),(0,W.jsx)(`span`,{children:t})]}),n.map(t=>(0,W.jsx)(K,{agent:t,token:e.token},t.id))]},t))]})]})}function K(e){let t=e.agent.name?.trim()||e.agent.id,n=e.agent.source?.type===`remote`;return(0,W.jsxs)(le,{value:e.agent.id,textValue:t,className:N.agentSelectItem,children:[(0,W.jsx)(rt,{agent:e.agent,token:e.token}),n?(0,W.jsxs)(xe,{children:[(0,W.jsx)(`span`,{className:N.agentSelectItemText,children:t}),(0,W.jsx)(re,{children:e.agent.id})]}):(0,W.jsx)(`span`,{className:N.agentSelectItemText,children:t})]})}function rt(e){let t=e.agent.imageUrl?.trim(),n=U({token:e.token??``,imageUrl:t});return n.objectUrl?(0,W.jsx)(`img`,{className:N.agentSelectAvatar,src:n.objectUrl,alt:``}):t?(0,W.jsx)(`span`,{className:N.agentSelectAvatarLoading,"aria-hidden":`true`}):null}function it(e,t){let n=e.lastIndexOf(`
2
+ `,t-1)+1,r=-1;for(let i=n;i<t;i++)e[i]===`/`&&(i===n||/\s/.test(e[i-1]))&&(r=i);return r===-1?null:{query:e.slice(r+1,t),tokenStart:r}}function at(e,t){return`${e}-opt-${t}`}function ot({mode:e,kind:t=`slash`,suggestions:n,activeIdx:r,query:i,listboxId:a,token:o,onSelect:s,onActiveChange:c}){(0,R.useEffect)(()=>{e!==`list`||n.length===0||document.getElementById(at(a,r))?.scrollIntoView({block:`nearest`})},[r,e,n.length,a]);let u=i.trim().toLowerCase(),d=t===`agent`?`@`:`/`,f=t===`agent`?`Agents`:`Slash commands`,p=t===`agent`?`No agents match ${d}${i}`:`No commands match ${d}${i}`;return(0,W.jsx)(l,{side:`top`,focusOnOpen:`none`,closeOnEscape:!1,closeOnOutsideClick:!0,sideOffset:4,className:N.slashSuggestions,children:(0,W.jsxs)(de,{className:N.slashSuggestionsScroll,children:[(0,W.jsx)(te,{id:a,role:`listbox`,"aria-label":f,className:N.slashSuggestionsList,children:e===`list`?n.map((e,n)=>(0,W.jsxs)(`div`,{id:at(a,n),className:F(N.suggestionItem,t===`agent`&&N.suggestionItemAgent,n===r&&N.suggestionItemActive,(e.depth??1)>=2&&N.suggestionItemSub),role:`option`,tabIndex:-1,"aria-selected":n===r,onMouseDown:t=>{t.preventDefault(),s(e)},onMouseEnter:()=>c(n),title:e.description||void 0,children:[t===`agent`?(0,W.jsx)(st,{item:e,token:o}):null,(0,W.jsxs)(`span`,{className:N.suggestionText,children:[(0,W.jsx)(`span`,{className:N.suggestionLabel,children:lt(e.label,u)}),e.description?(0,W.jsx)(`span`,{className:N.suggestionDesc,children:e.description}):null]})]},e.id)):(0,W.jsx)(`div`,{className:N.suggestionEmpty,role:`status`,children:p})}),(0,W.jsx)(oe,{children:(0,W.jsx)(A,{})})]})})}function st(e){let t=e.item.imageUrl?.trim(),n=U({token:e.token??``,imageUrl:t});return n.objectUrl?(0,W.jsx)(`img`,{className:N.suggestionAvatar,src:n.objectUrl,alt:``}):t?(0,W.jsx)(`span`,{className:N.suggestionAvatarLoading,"aria-hidden":`true`}):null}var ct=/<[^>]+>|\[[^\]]+\]/g;function lt(e,t){let n=[],r=0,i=0,a=(e,r)=>{if(!e)return;let a=r?N.suggestionLabelMono:void 0,o=t?e.toLowerCase().indexOf(t):-1;n.push(o===-1?(0,W.jsx)(`span`,{className:a,children:e},i++):(0,W.jsxs)(`span`,{className:a,children:[e.slice(0,o),(0,W.jsx)(`mark`,{className:N.suggestionMatch,children:e.slice(o,o+t.length)}),e.slice(o+t.length)]},i++))};for(let t of e.matchAll(ct)){let n=t.index??0;a(e.slice(r,n),!1),a(t[0],!0),r=n+t[0].length}return a(e.slice(r),!1),n}var ut=RegExp(`(?:^|[\\s([{])@([A-Za-z0-9._-]*(?:@[A-Za-z0-9._-]*){0,2})$`,`u`),dt=RegExp(`@(${Ge})(?=$|[\\s:])`,`gu`),q=RegExp(`^@${Ge}(?=$|[\\s:])\\s*`,`u`);function ft(e,t){let n=e.slice(0,t),r=ut.exec(n);if(!r)return null;let i=r[1]??``;return{tokenStart:n.length-i.length-1,query:i}}function pt(e){let t=(0,R.useRef)(null),n=(0,R.useRef)(null),r=(0,R.useRef)(null),[i,a]=(0,R.useState)([]),[o,s]=(0,R.useState)(0),[c,l]=(0,R.useState)([]),[d,f]=(0,R.useState)(`slash`),[p,m]=(0,R.useState)(0),[h,g]=(0,R.useState)(`closed`),[_,v]=(0,R.useState)(``),[y,b]=(0,R.useState)(``),[S,C]=(0,R.useState)(0),te=(0,R.useRef)(null),T=(0,R.useRef)(null),E=(0,R.useRef)(null),D=(0,R.useRef)(0),ne=(0,R.useRef)(null),O=(0,R.useId)(),re=h!==`closed`,ie=h===`closed`?``:d===`agent`?h===`list`?`${u(c.length,`agent`)} available`:`No agents match @${_}`:h===`list`?`${u(c.length,`command`)} available`:`No commands match /${_}`;(0,R.useEffect)(()=>()=>{T.current&&clearTimeout(T.current),E.current&&clearTimeout(E.current),D.current+=1},[]),(0,R.useEffect)(()=>{let e=r.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect().height;!Number.isFinite(t)||t<=0||document.documentElement.style.setProperty(`--chat-composer-height`,`${Math.ceil(t)}px`)};t();let n=typeof ResizeObserver>`u`?null:new ResizeObserver(t);return n?.observe(e),window.addEventListener(`resize`,t),()=>{n?.disconnect(),window.removeEventListener(`resize`,t),document.documentElement.style.removeProperty(`--chat-composer-height`)}},[]);let ae=(0,R.useRef)(e.isStreaming);(0,R.useEffect)(()=>{ae.current&&!e.isStreaming&&t.current?.focus(),ae.current=e.isStreaming},[e.isStreaming]);let k=(0,R.useCallback)(()=>{let e=t.current;e&&(e.style.height=`36px`,e.style.height=`${Math.max(36,Math.min(e.scrollHeight,180))}px`)},[]),A=(0,R.useCallback)(()=>{let e=t.current;e&&C(e.selectionStart??e.value.length)},[]),oe=(0,R.useCallback)(e=>{let n=()=>{let n=t.current;if(!n)return;let r=Math.max(0,Math.min(e,n.value.length));n.focus(),n.setSelectionRange(r,r),C(r)};n(),E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{E.current=null,n()},0)},[]);(0,R.useEffect)(()=>{let n=e.initialValue?.trim()||``;if(te.current===n||(te.current=n,!n))return;let r=t.current;r&&(r.value=n,r.setSelectionRange(n.length,n.length),b(n),C(n.length),g(`closed`),D.current+=1,k(),r.focus())},[e.initialValue,k]);let se=(0,R.useCallback)(()=>{T.current&&=(clearTimeout(T.current),null),D.current+=1},[]),j=(0,R.useCallback)(()=>{se(),g(`closed`)},[se]),ce=(0,R.useCallback)(async t=>{let n=D.current;try{let r=await je(e.token,t||void 0);if(n!==D.current)return;let i=r.commands??[];l(i),m(0),v(t),i.length>0?g(`list`):g(t===``?`closed`:`empty`)}catch{if(n!==D.current)return;l([]),g(`closed`)}},[e.token]),M=(0,R.useCallback)(t=>{let n=t.trim().toLowerCase();return(e.agents??[]).filter(e=>n?e.id.toLowerCase().includes(n)||(e.name??``).toLowerCase().includes(n):!0).map(e=>{let t=e.name?.trim();return{id:`agent:${e.id}`,label:`@${e.id}`,insertText:`@${e.id}`,description:t&&t!==e.id?t:``,imageUrl:e.imageUrl??null}})},[e.agents]);(0,R.useEffect)(()=>{for(let t of e.agents??[])tt(e.token,t.imageUrl)},[e.agents,e.token]);let le=()=>{k();let n=t.current;if(!n)return;b(n.value);let r=n.selectionStart??n.value.length;C(r);let i=it(n.value,r);if(i){let e=i.query.trim();f(`slash`),se(),T.current=setTimeout(()=>{ce(e)},150);return}let a=ft(n.value,r);if(a&&(e.agents?.length??0)>0){se();let e=M(a.query);l(e),f(`agent`),m(0),v(a.query),g(e.length>0?`list`:a.query===``?`closed`:`empty`)}else j()},ue=e=>{let n=t.current;if(!n)return;let r=n.value,i=n.selectionStart??r.length,a=e.insertText.replace(/\s+$/,``),o=n.value.length;if(d===`agent`){let e=ft(r,i);if(e){let t=r.slice(0,e.tokenStart),s=r.slice(i),c=s.startsWith(` `)?a:`${a} `;n.value=t+c+s,o=t.length+c.length,n.setSelectionRange(o,o)}else n.value=`${a} `,o=n.value.length,n.setSelectionRange(o,o);b(n.value),C(o),j(),k(),n.focus();return}let s=it(r,i);if(s){let e=r.slice(0,s.tokenStart),t=r.slice(i),c=t.startsWith(` `)?a:`${a} `;n.value=e+c+t,o=e.length+c.length,n.setSelectionRange(o,o)}else n.value=`${a} `,o=n.value.length,n.setSelectionRange(o,o);b(n.value),C(o),j(),k(),n.focus()},de=(0,R.useCallback)(e=>{let n=t.current;if(!n)return;let r=`${`@${e}`} `,i=n.value,a=q.exec(i),o;o=i.trim()?a?`${r}${i.slice(a[0].length).trimStart()}`:`${r}${i.trimStart()}`:r,n.value=o,b(n.value),C(r.length),j(),k(),oe(r.length)},[j,k,oe]),fe=()=>{if(e.isStreaming){e.onStop();return}let n=(t.current?.value??``).trim();!n&&i.length===0||o>0||(e.onSend(n,i),t.current&&(t.current.value=``),b(``),C(0),a([]),j(),k())},me=()=>{let e=t.current,n=ne.current;!e||!n||(n.scrollTop=e.scrollTop,n.scrollLeft=e.scrollLeft)},he=e=>{if(!(e.nativeEvent.isComposing||e.nativeEvent.keyCode===229)){if(h===`list`&&c.length>0){if(e.key===`ArrowDown`){e.preventDefault(),m(e=>(e+1)%c.length);return}if(e.key===`ArrowUp`){e.preventDefault(),m(e=>(e-1+c.length)%c.length);return}if(e.key===`Home`){e.preventDefault(),m(0);return}if(e.key===`End`){e.preventDefault(),m(c.length-1);return}if(e.key===`Tab`){e.preventDefault(),ue(c[p]);return}}if(e.key===`Escape`){let t=re;if(j(),t){e.preventDefault();return}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),fe())}},ge=e=>{let t=x(e.clipboardData);t.length>0&&(e.preventDefault(),_e(t))},_e=async t=>{s(e=>e+t.length);try{let n=await e.onUploadFiles(t);n.length>0&&a(e=>[...e,...n])}finally{s(e=>Math.max(0,e-t.length))}},ve=e=>{let t=Array.from(e.target.files??[]);t.length>0&&_e(t),e.target.value=``},P=e=>{a(t=>t.filter((t,n)=>n!==e))},ye=e.agents??[],be=(0,R.useMemo)(()=>new Map(ye.map(e=>[e.id,e])),[ye]),xe=e.selectedAgentId??``,Se=e.models??[],Ce=e.selectedModelId??``;return(0,W.jsxs)(`div`,{className:N.composerWrapper,ref:r,children:[(0,W.jsxs)(w,{open:re,onOpenChange:e=>{e||j()},children:[(0,W.jsxs)(`div`,{className:N.composer,children:[i.length>0||o>0?(0,W.jsxs)(`div`,{className:N.pendingMediaRow,children:[i.map((e,t)=>(0,W.jsxs)(`span`,{className:N.mediaChip,children:[(0,W.jsx)(`span`,{className:N.mediaChipName,children:e.filename}),(0,W.jsx)(`button`,{type:`button`,className:N.mediaChipRemove,onClick:()=>P(t),children:`×`})]},e.path)),o>0?(0,W.jsx)(`span`,{className:N.mediaChip,children:`Uploading…`}):null]}):null,(0,W.jsxs)(ee,{className:N.composerInputWrap,children:[y?(0,W.jsx)(`div`,{ref:ne,className:N.composerInputOverlay,"aria-hidden":`true`,children:(0,W.jsx)(J,{value:y,caretIndex:S,agents:be,token:e.token})}):null,(0,W.jsx)(`textarea`,{ref:t,className:F(N.composerInput,y&&N.composerInputHasOverlay),rows:1,placeholder:`Message HybridClaw`,disabled:e.isStreaming,onInput:le,onSelect:A,onClick:A,onKeyUp:A,onFocus:A,onKeyDown:he,onPaste:ge,onScroll:me,"aria-label":`Message input`,role:`combobox`,"aria-autocomplete":`list`,"aria-haspopup":`listbox`,"aria-controls":O,"aria-expanded":re,"aria-activedescendant":h===`list`&&c.length>0?at(O,p):void 0})]}),(0,W.jsxs)(`div`,{className:N.composerActions,children:[(0,W.jsxs)(`div`,{className:N.composerLeftActions,children:[(0,W.jsx)(`button`,{type:`button`,className:N.attachButton,onClick:()=>n.current?.click(),"aria-label":`Attach files`,children:`+`}),(0,W.jsx)(nt,{agents:ye,selectedAgentId:xe,token:e.token,disabled:e.isStreaming,onSwitch:t=>{if(t.source?.type===`remote`){de(t.id);return}e.onAgentSwitch?.(t.id)}}),(0,W.jsx)(pe,{models:Se,selectedModelId:Ce,disabled:e.isStreaming,onSwitch:t=>e.onModelSwitch?.(t)})]}),(0,W.jsx)(`button`,{type:`button`,className:F(N.sendButton,e.isStreaming&&N.stopping),onClick:fe,"aria-label":e.isStreaming?`Stop`:`Send message`,children:e.isStreaming?(0,W.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`currentColor`,"aria-hidden":`true`,children:(0,W.jsx)(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`})}):(0,W.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,W.jsx)(`path`,{d:`M12 19V5`}),(0,W.jsx)(`path`,{d:`m5 12 7-7 7 7`})]})}),(0,W.jsx)(`input`,{ref:n,type:`file`,hidden:!0,multiple:!0,onChange:ve})]})]}),h===`closed`?null:(0,W.jsx)(ot,{mode:h,kind:d,suggestions:c,activeIdx:p,query:_,listboxId:O,token:e.token,onSelect:ue,onActiveChange:m})]}),(0,W.jsx)(`div`,{className:N.slashLiveRegion,"aria-live":`polite`,"aria-atomic":`true`,children:ie})]})}function J(e){let t=[],n=0,r=0,i=!1,a=Math.max(0,Math.min(e.caretIndex,e.value.length)),o=()=>{i||=(t.push((0,W.jsx)(`span`,{className:N.composerOverlayCaret,"aria-hidden":`true`},`caret-${r++}`)),!0)},s=(e,n)=>{let r=n+e.length;if(a<n||a>r){t.push(e);return}let i=a-n;i>0&&t.push(e.slice(0,i)),o(),i<e.length&&t.push(e.slice(i))};for(let i of e.value.matchAll(dt)){let c=i[0],l=i[1]??``,u=i.index??0,d=u+c.length,f=e.agents.get(l);f&&(u>n&&s(e.value.slice(n,u),n),a>u&&a<d?s(c,u):(a===u&&o(),t.push((0,W.jsx)(Y,{mention:c,imageUrl:f.imageUrl??null,token:e.token},`mention-${r++}`)),a===d&&o()),n=d)}return n<e.value.length&&s(e.value.slice(n),n),!i&&a===e.value.length&&o(),t.length>0?t:e.value}function Y(e){let t=U({token:e.token,imageUrl:e.imageUrl});return(0,W.jsxs)(`span`,{className:N.composerMentionPill,children:[t.objectUrl?(0,W.jsx)(`img`,{className:N.composerMentionAvatar,src:t.objectUrl,alt:``}):null,(0,W.jsx)(`span`,{children:e.mention})]})}var X={wrap:`_wrap_jrif0_1`,trigger:`_trigger_jrif0_11`,ring:`_ring_jrif0_33`,ringTrack:`_ringTrack_jrif0_37`,ringFill:`_ringFill_jrif0_43`,ringFillNominal:`_ringFillNominal_jrif0_52`,ringFillWarn:`_ringFillWarn_jrif0_56`,ringFillDanger:`_ringFillDanger_jrif0_60`,ringLabel:`_ringLabel_jrif0_64`,ringLabelUnknown:`_ringLabelUnknown_jrif0_77`,popover:`_popover_jrif0_81`,popoverTitle:`_popoverTitle_jrif0_112`,popoverTitleValue:`_popoverTitleValue_jrif0_121`,popoverRow:`_popoverRow_jrif0_126`,popoverRowValue:`_popoverRowValue_jrif0_133`,popoverProgress:`_popoverProgress_jrif0_138`,popoverProgressFill:`_popoverProgressFill_jrif0_148`,popoverProgressFillWarn:`_popoverProgressFillWarn_jrif0_157`,popoverProgressFillDanger:`_popoverProgressFillDanger_jrif0_161`,popoverFoot:`_popoverFoot_jrif0_165`},Z=14,mt=2*Math.PI*Z;function Q(e){if(e==null)return`n/a`;let t=Math.abs(e);return t>=1e6?`${(t>=1e7?(e/1e6).toFixed(0):(e/1e6).toFixed(1)).replace(/\.0$/,``)}M`:t>=1e3?`${(t>=1e4?(e/1e3).toFixed(0):(e/1e3).toFixed(1)).replace(/\.0$/,``)}k`:String(Math.round(e))}function ht(e){return e==null||!Number.isFinite(e)?0:Math.max(0,Math.min(100,e))}function gt(e){return e==null?`nominal`:e>=90?`danger`:e>=70?`warn`:`nominal`}function _t(e){let t=e.sessionId,n=e.enabled&&!!t,r=a({queryKey:[`chat-context`,e.token,t],queryFn:()=>Me(e.token,t),enabled:n,staleTime:15e3,refetchOnWindowFocus:!1}).data?.snapshot??null,i=r?.contextUsagePercent??null,o=ht(i),s=gt(i),c=r?.contextBudgetTokens!=null&&r.contextUsedTokens!=null,l=c?mt*(1-o/100):mt,u=i!=null&&Number.isFinite(i)?Math.max(0,Math.round(i)):null,d=u==null?`–`:`${u}%`,f=r&&c&&u!=null?`Context usage ${u} percent (${Q(r.contextUsedTokens)} of ${Q(r.contextBudgetTokens)} tokens)`:`Context usage unavailable`;return(0,W.jsxs)(`div`,{className:X.wrap,children:[(0,W.jsxs)(`button`,{type:`button`,className:X.trigger,"aria-label":f,children:[(0,W.jsxs)(`svg`,{width:34,height:34,viewBox:`0 0 34 34`,className:X.ring,"aria-hidden":`true`,children:[(0,W.jsx)(`circle`,{cx:17,cy:17,r:Z,className:X.ringTrack}),(0,W.jsx)(`circle`,{cx:17,cy:17,r:Z,className:F(X.ringFill,s===`warn`&&X.ringFillWarn,s===`danger`&&X.ringFillDanger,s===`nominal`&&X.ringFillNominal),strokeDasharray:mt,strokeDashoffset:l})]}),(0,W.jsx)(`span`,{className:F(X.ringLabel,u==null&&X.ringLabelUnknown),children:d})]}),(0,W.jsxs)(`div`,{role:`tooltip`,className:X.popover,children:[(0,W.jsxs)(`div`,{className:X.popoverTitle,children:[(0,W.jsx)(`span`,{children:`Context`}),(0,W.jsx)(`span`,{className:X.popoverTitleValue,children:r?.model||`unknown model`})]}),r&&c?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:X.popoverProgress,children:(0,W.jsx)(`div`,{className:F(X.popoverProgressFill,s===`warn`&&X.popoverProgressFillWarn,s===`danger`&&X.popoverProgressFillDanger),style:{width:`${o}%`}})}),(0,W.jsxs)(`div`,{className:X.popoverRow,children:[(0,W.jsx)(`span`,{children:`Used`}),(0,W.jsxs)(`span`,{className:X.popoverRowValue,children:[Q(r.contextUsedTokens),` /`,` `,Q(r.contextBudgetTokens),` tokens`]})]}),(0,W.jsxs)(`div`,{className:X.popoverRow,children:[(0,W.jsx)(`span`,{children:`Headroom`}),(0,W.jsxs)(`span`,{className:X.popoverRowValue,children:[Q(r.contextRemainingTokens),` tokens`]})]})]}):(0,W.jsxs)(`div`,{className:X.popoverRow,children:[(0,W.jsx)(`span`,{children:`Used`}),(0,W.jsx)(`span`,{className:X.popoverRowValue,children:r?.contextUsedTokens==null?`no usage recorded yet`:`${Q(r.contextUsedTokens)} tokens`})]}),(0,W.jsxs)(`div`,{className:X.popoverRow,children:[(0,W.jsx)(`span`,{children:`Compactions`}),(0,W.jsx)(`span`,{className:X.popoverRowValue,children:r?`${r.compactionCount} · ${Q(r.compactionMessageThreshold)} msgs / ${Q(r.compactionTokenBudget)} tokens`:`n/a`})]}),(0,W.jsxs)(`div`,{className:X.popoverFoot,children:[`Run `,(0,W.jsx)(`code`,{children:`/context`}),` for full details · `,(0,W.jsx)(`code`,{children:`/compact`}),` to archive older history.`]})]})]})}var vt=[{label:`Trust session`,action:`session`,isAvailable:e=>e.allowSession===!0},{label:`Trust agent`,action:`agent`,isAvailable:e=>e.allowAgent===!0},{label:`Always allow`,action:`all`,isAvailable:e=>e.allowAll===!0}],$=/^([^:\n]{2,44}):\s+(.+)$/,yt=/^(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS)\s+/i;function bt(e){return e===`yellow`?`Amber`:e===`red`?`Red`:null}function xt(e){return/^reply\b/i.test(e)||/^approval expires\b/i.test(e)||/^approval id\b/i.test(e)}function St(e){let t=e.trim();return/^proposed action$/i.test(t)?`Request`:/^why$/i.test(t)?`Reason`:t}function Ct(e){let t=[],n,r=e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean);for(let e of r){if(xt(e)||/^classifier reasoning$/i.test(e)||/^if you skip this/i.test(e))continue;let r=e.match($);if(r){let e=St(r[1]??``);/^classifier reasoning$/i.test(e)||t.push({label:e,value:r[2]??``});continue}n??=e}return{introLine:n,rows:t}}function wt(e){let t=[],n=new Set,r=(e,r)=>{let i=e.trim(),a=String(r??``).trim();if(!i||!a)return;let o=`${i.toLowerCase()}:${a}`;n.has(o)||(n.add(o),t.push({label:i,value:a}))};e.intent&&r(`Action`,e.intent),e.commandPreview&&r(yt.test(e.commandPreview)?`Request`:`Preview`,e.commandPreview),e.toolName&&r(`Tool`,e.toolName);for(let t of Ct(e.prompt).rows)r(t.label,t.value);if(r(`Approval ID`,e.approvalId),e.expiresAt&&Number.isFinite(e.expiresAt)){let t=new Date(e.expiresAt);Number.isNaN(t.getTime())||r(`Expires`,t.toLocaleTimeString())}return t}function Tt(e){let{introLine:t}=Ct(e.prompt);return t||(e.summary?e.summary.split(/\r?\n/)[0]??``:e.intent?`Confirmation required for ${e.intent}.`:`Confirmation required before this action can continue.`)}function Et(e){let{approval:t}=e,n=(0,R.useMemo)(()=>wt(t),[t]),r=(0,R.useMemo)(()=>Tt(t),[t]),i=vt.filter(e=>e.isAvailable(t)),a=bt(t.approvalTier),o=n=>{e.onAction(n,t.approvalId)};return(0,W.jsxs)(`div`,{className:N.approvalCard,children:[(0,W.jsxs)(`div`,{className:N.approvalHeader,children:[a?(0,W.jsx)(`span`,{className:N.approvalTier,children:a}):null,(0,W.jsx)(`span`,{className:N.approvalTitle,children:`Confirmation required`})]}),(0,W.jsx)(`p`,{className:N.approvalIntro,children:r}),n.length>0?(0,W.jsx)(`dl`,{className:N.approvalDetails,children:n.map(e=>(0,W.jsxs)(`div`,{className:N.approvalDetailRow,children:[(0,W.jsx)(`dt`,{children:e.label}),(0,W.jsx)(`dd`,{children:e.value})]},`${e.label}:${e.value}`))}):null,(0,W.jsxs)(`div`,{className:N.approvalPrimaryActions,children:[(0,W.jsx)(v,{size:`sm`,disabled:e.busy,onClick:()=>o(`once`),children:`Allow once`}),(0,W.jsx)(v,{variant:`danger`,size:`sm`,disabled:e.busy,onClick:()=>o(`deny`),children:`Cancel`})]}),i.length>0?(0,W.jsx)(`div`,{className:N.approvalTrustActions,children:i.map(t=>(0,W.jsx)(v,{variant:`outline`,size:`sm`,className:N.approvalAllow,disabled:e.busy,onClick:()=>o(t.action),children:t.label},t.action))}):null]})}function Dt(e){if(e<1e3)return`${Math.max(0,Math.round(e))}ms`;let t=e/1e3;if(t<10)return`${t.toFixed(1)}s`;if(t<60)return`${Math.round(t)}s`;let n=Math.floor(t/60),r=Math.round(t%60);return r>0?`${n}m ${r}s`:`${n}m`}function Ot(e){let t=e.steps;if(!e.done){let e=t[t.length-1];return e?.kind===`tool`&&e.status===`running`?`${e.toolName}…`:e?.kind===`thinking`?`Thinking…`:`Working…`}let n=t.filter(e=>e.kind===`tool`).length,r=t.some(e=>e.kind===`thinking`),i=[];n>0?(i.push(`${n} tool call${n===1?``:`s`}`),r&&i.push(`thinking`)):r&&i.push(`Thought`);let a=e.finishedAt?e.finishedAt-e.startedAt:0;return a>=1e3&&i.push(Dt(a)),i.join(` · `)||`Agent activity`}function kt(e){let{step:t,live:n}=e;if(t.kind===`thinking`)return(0,W.jsxs)(`div`,{className:N.traceStep,children:[(0,W.jsx)(`span`,{className:N.traceStepMarker,"aria-hidden":`true`,children:(0,W.jsx)(`span`,{className:N.traceDot})}),(0,W.jsx)(`div`,{className:N.traceThinkingText,children:t.text})]});let r=n&&t.status===`running`;return(0,W.jsxs)(`div`,{className:N.traceStep,children:[(0,W.jsx)(`span`,{className:N.traceStepMarker,"aria-hidden":`true`,children:(0,W.jsx)(`span`,{className:F(N.traceDot,r&&N.traceDotRunning)})}),(0,W.jsxs)(`div`,{className:N.traceStepBody,children:[(0,W.jsxs)(`div`,{className:N.traceToolLine,children:[(0,W.jsx)(`span`,{className:N.traceToolName,children:t.toolName}),t.argsPreview?(0,W.jsx)(`span`,{className:N.traceToolPreview,title:t.argsPreview,children:t.argsPreview}):null,typeof t.durationMs==`number`?(0,W.jsx)(`span`,{className:N.traceToolDuration,children:Dt(t.durationMs)}):null]}),t.resultPreview?(0,W.jsx)(`div`,{className:N.traceToolResult,title:t.resultPreview,children:t.resultPreview}):null]})]})}var At=(0,R.memo)(function(e){let{message:t}=e,[n,r]=(0,R.useState)(null);if((0,R.useEffect)(()=>{t.done&&r(null)},[t.done]),t.steps.length===0)return null;let i=n??!t.done;return(0,W.jsxs)(`div`,{className:N.traceBlock,children:[(0,W.jsxs)(`button`,{type:`button`,className:N.traceHeader,"aria-expanded":i,"aria-label":i?`Collapse agent activity`:`Expand agent activity`,onClick:()=>r(!i),children:[(0,W.jsx)(`span`,{className:F(N.traceChevron,i&&N.traceChevronOpen),"aria-hidden":`true`,children:`›`}),(0,W.jsx)(`span`,{className:F(N.traceSummary,!t.done&&N.traceSummaryLive),children:Ot(t)})]}),i?(0,W.jsx)(`div`,{className:N.traceSteps,children:t.steps.map((e,n)=>(0,W.jsx)(kt,{step:e,live:!t.done},n))}):null]})}),jt=120;function Mt(e,t,n){let[r,i]=(0,R.useState)(e),a=(0,R.useRef)(e),o=(0,R.useRef)(null);a.current=e,(0,R.useEffect)(()=>{if(!t){o.current!==null&&(window.clearTimeout(o.current),o.current=null),i(``);return}if(!n){o.current!==null&&(window.clearTimeout(o.current),o.current=null),i(e);return}o.current!==null||e===r||(o.current=window.setTimeout(()=>{o.current=null,(0,R.startTransition)(()=>{i(a.current)})},jt))},[e,t,n,r]),(0,R.useEffect)(()=>()=>{o.current!==null&&window.clearTimeout(o.current)},[]);let s=t?n?r:e:``;return(0,R.useMemo)(()=>t?ye(s,{highlight:!n}):``,[t,s,n])}var Nt=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="9" y="9" width="11" height="11" rx="2"/><path d="M5 15V5a2 2 0 0 1 2-2h10"/></svg>`,Pt=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 6 9 17l-5-5"/></svg>`,Ft=`<svg viewBox="0 0 24 24" width="11" height="11" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m9 7-5 5 5 5"/><path d="m15 7 5 5-5 5"/><path d="m13.5 5-3 14"/></svg>`,It=/^\/([A-Za-z0-9][A-Za-z0-9._-]*)(?=$|[\s:.,!?;)\]}])/u,Lt=new Set([`text`,`plaintext`,`plain`,`txt`]);function Rt(e){let t=e.querySelector(`code`)?.className.match(/language-([\w#.+-]+)/)?.[1]??``;return Lt.has(t)?``:t}function zt(e){if(e.querySelector(`button[data-copy-btn]`))return;let t=Rt(e);if(t){e.classList.add(N.codeBlockLabeled);let n=document.createElement(`span`);n.className=N.codeLangLabel,n.setAttribute(`aria-hidden`,`true`),n.innerHTML=Ft;let r=document.createElement(`span`);r.textContent=t,n.appendChild(r),e.appendChild(n)}let n=document.createElement(`button`);n.type=`button`,n.dataset.copyBtn=``,n.className=N.codeCopyButton,n.innerHTML=Nt;let r=e=>{n.setAttribute(`aria-label`,e),n.title=e};r(`Copy code`);let i=null;n.addEventListener(`click`,()=>{we((e.querySelector(`code`)??e).textContent??``).then(e=>{e&&(n.innerHTML=Pt,n.classList.add(N.codeCopyButtonDone),r(`Copied`),i!==null&&window.clearTimeout(i),i=window.setTimeout(()=>{n.innerHTML=Nt,n.classList.remove(N.codeCopyButtonDone),r(`Copy code`)},1500))})}),e.appendChild(n)}function Bt(){let e=(0,R.useRef)(null);return(0,R.useCallback)(t=>{if(e.current?.disconnect(),e.current=null,!t)return;let n=()=>{for(let e of t.querySelectorAll(`pre`))zt(e)};n();let r=new MutationObserver(n);r.observe(t,{childList:!0,subtree:!0}),e.current=r},[])}function Vt(e,t){let n=t.split(`;`)[0]?.trim().toLowerCase()||``;return!n||n!==`application/pdf`&&!n.startsWith(`image/`)&&!n.startsWith(`video/`)||e.type.toLowerCase()===n?e:new Blob([e],{type:n})}function Ht(e){let{artifact:t,token:n}=e,r=(0,R.useRef)(null),[i,a]=(0,R.useState)(null),[o,s]=(0,R.useState)(!1),c=(t.mimeType??``).toLowerCase(),l=t.filename??`artifact`,u=c.startsWith(`image/`),d=c.startsWith(`video/`)||/\.(mp4|m4v|mov|webm)$/i.test(t.filename??``)||/\.(mp4|m4v|mov|webm)$/i.test(t.path??``),f=c===`application/pdf`||/\.pdf$/i.test(t.filename??``)||/\.pdf$/i.test(t.path??``),p=u||d||f;(0,R.useEffect)(()=>{let e=r.current;if(r.current=null,e&&URL.revokeObjectURL(e),a(null),!p||!t.path)return;let i=!1;return He(n,t.path).then(e=>{if(i)return;let t=URL.createObjectURL(Vt(e,c));r.current=t,a(t)}).catch(()=>{i||a(null)}),()=>{i=!0;let e=r.current;r.current=null,e&&URL.revokeObjectURL(e)}},[t.path,p,c,n]);let m=o?`Downloading…`:`Download`,h=async()=>{if(!(!t.path||o)){s(!0);try{let e=i??URL.createObjectURL(await He(n,t.path)),r=document.createElement(`a`);r.href=e,r.download=t.filename??`artifact`,r.rel=`noopener noreferrer`,document.body.appendChild(r),r.click(),r.remove(),i||window.setTimeout(()=>URL.revokeObjectURL(e),0)}catch{}finally{s(!1)}}};return(0,W.jsxs)(`div`,{className:F(N.artifactCard,i&&N.artifactCardWithPreview),children:[(0,W.jsxs)(`div`,{className:N.artifactHeader,children:[(0,W.jsx)(`span`,{className:N.artifactFilename,children:l}),t.type?(0,W.jsx)(`span`,{className:N.artifactBadge,children:t.type}):null,t.path?(0,W.jsx)(`button`,{type:`button`,className:N.artifactDownload,disabled:o,onClick:()=>{h()},children:m}):null]}),u&&i?(0,W.jsx)(`div`,{className:N.artifactPreview,children:(0,W.jsx)(`img`,{src:i,alt:l})}):null,f&&i?(0,W.jsx)(`div`,{className:F(N.artifactPreview,N.artifactPdfPreview),children:(0,W.jsx)(`iframe`,{src:i,title:`${l} preview`,sandbox:``})}):null,d&&i?(0,W.jsx)(`div`,{className:F(N.artifactPreview,N.artifactVideoPreview),children:(0,W.jsx)(`video`,{controls:!0,preload:`metadata`,src:i,children:(0,W.jsxs)(`a`,{href:i,download:l,children:[`Download `,l]})})}):null]})}function Ut(e){let t=(0,R.useRef)(null),[n,r]=(0,R.useState)(null);return(0,R.useEffect)(()=>{let n=t.current;if(t.current=null,n&&URL.revokeObjectURL(n),r(null),!e.imageUrl)return;let i=!1;return Ie(e.token,e.imageUrl).then(e=>{if(i)return;let n=URL.createObjectURL(e);t.current=n,r(n)}).catch(()=>{i||r(null)}),()=>{i=!0;let e=t.current;t.current=null,e&&URL.revokeObjectURL(e)}},[e.imageUrl,e.token]),n}var Wt=(0,R.memo)(function(e){let{message:t,token:n}=e,[r,i]=(0,R.useState)(!1),a=()=>{e.onCopy(t.rawContent??t.content),i(!0),setTimeout(()=>i(!1),900)},o=(0,R.useMemo)(()=>{let e=new Map;return(t.artifacts??[]).map(t=>{let n=[t.path,t.filename,t.mimeType,t.type].filter(Boolean),r=n.length>0?n.join(`|`):`artifact`,i=e.get(r)??0;return e.set(r,i+1),{artifact:t,key:`${r}:${i}`}})},[t.artifacts]),s=t.role===`approval`,c=s&&!!t.pendingApproval,l=t.role===`assistant`||t.role===`command`||s&&!c,u=Mt(t.content,l,e.isStreaming),d=Bt(),f=t.assistantPresentation,p=f?.displayName??`Assistant`,m=Ut({token:n,imageUrl:f?.imageUrl});if(t.role===`trace`)return(0,W.jsx)(At,{message:t});if(t.role===`thinking`)return(0,W.jsxs)(`div`,{className:N.thinking,role:`status`,"aria-label":`Assistant is thinking`,children:[(0,W.jsx)(`span`,{className:N.thinkingDot}),(0,W.jsx)(`span`,{className:N.thinkingDot}),(0,W.jsx)(`span`,{className:N.thinkingDot})]});let h=t.role===`user`,g=t.role===`assistant`,_=h||t.content.trim().length>0||o.length===0||s,y=F(N.messageBlock,h&&N.messageBlockUser,(g||t.role===`system`||t.role===`command`||s)&&N.messageBlockAssistant),b=F(N.bubble,h&&N.bubbleUser,(g||s)&&N.bubbleAssistant,s&&N.bubbleApproval,t.role===`system`&&N.bubbleSystem,t.role===`command`&&N.bubbleCommand);return(0,W.jsxs)(`div`,{className:y,children:[g?(0,W.jsxs)(`div`,{className:N.agentLabel,children:[m?(0,W.jsx)(`img`,{className:N.agentAvatar,src:m,alt:``}):(0,W.jsx)(`span`,{className:N.agentInitial,children:p.charAt(0).toUpperCase()}),(0,W.jsx)(`span`,{children:p})]}):null,_?(0,W.jsx)(`div`,{className:b,children:c&&t.pendingApproval?(0,W.jsx)(Et,{approval:t.pendingApproval,busy:e.approvalBusy,onAction:e.onApprovalAction}):l?(0,W.jsx)(`div`,{ref:d,className:N.markdownContent,dangerouslySetInnerHTML:{__html:u}}):h?(0,W.jsx)(Gt,{content:L(t.content),presentation:t.addressedAgentPresentation,skillInvocationTargets:e.skillInvocationTargets,token:n}):t.content}):null,o.map(({artifact:e,key:t})=>(0,W.jsx)(Ht,{artifact:e,token:n},t)),e.isStreaming?null:(0,W.jsxs)(`div`,{className:N.messageActions,children:[g&&t.replayRequest?(0,W.jsx)(v,{variant:`ghost`,size:`icon`,className:N.actionButton,title:`Regenerate`,"aria-label":`Regenerate response`,onClick:()=>e.onRegenerate(t),children:`↻`}):null,g?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(v,{variant:`ghost`,size:`icon`,className:F(N.actionButton,t.responseRating===`up`&&N.actionButtonSelected),title:t.responseRating===`up`?`Clear thumbs up`:`Thumbs up`,"aria-label":t.responseRating===`up`?`Clear thumbs up rating`:`Rate response thumbs up`,"aria-pressed":t.responseRating===`up`,"data-rating-locked":t.responseRating?`true`:void 0,disabled:e.ratingBusy===!0||!t.messageId||t.responseRating===`down`,onClick:()=>e.onRate?.(t,t.responseRating===`up`?null:`up`),children:(0,W.jsx)(ue,{width:`13`,height:`13`,filled:t.responseRating===`up`})}),(0,W.jsx)(v,{variant:`ghost`,size:`icon`,className:F(N.actionButton,t.responseRating===`down`&&N.actionButtonSelected),title:t.responseRating===`down`?`Clear thumbs down`:`Thumbs down`,"aria-label":t.responseRating===`down`?`Clear thumbs down rating`:`Rate response thumbs down`,"aria-pressed":t.responseRating===`down`,"data-rating-locked":t.responseRating?`true`:void 0,disabled:e.ratingBusy===!0||!t.messageId||t.responseRating===`up`,onClick:()=>e.onRate?.(t,t.responseRating===`down`?null:`down`),children:(0,W.jsx)(Se,{width:`13`,height:`13`,filled:t.responseRating===`down`})})]}):null,(0,W.jsx)(v,{variant:`ghost`,size:`icon`,className:F(N.actionButton,r&&N.actionButtonSuccess),title:`Copy`,"aria-label":r?`Copied`:`Copy message`,onClick:a,children:r?`✓`:`⧉`}),h?(0,W.jsx)(v,{variant:`ghost`,size:`icon`,className:N.actionButton,title:`Edit`,"aria-label":`Edit message`,onClick:()=>e.onEdit(t),children:`✎`}):null,e.branchInfo&&e.branchInfo.total>1?(0,W.jsxs)(`div`,{className:N.branchSwitcher,children:[(0,W.jsx)(v,{variant:`ghost`,size:`icon`,className:N.branchButton,"aria-label":`Previous branch`,disabled:e.branchInfo.current<=1,onClick:()=>e.onBranchNav(t,-1),children:`‹`}),(0,W.jsxs)(`span`,{children:[e.branchInfo.current,`/`,e.branchInfo.total]}),(0,W.jsx)(v,{variant:`ghost`,size:`icon`,className:N.branchButton,"aria-label":`Next branch`,disabled:e.branchInfo.current>=e.branchInfo.total,onClick:()=>e.onBranchNav(t,1),children:`›`})]}):null]})]})});function Gt(e){let t=Je(e.content),n=[],r=0;for(let[i,a]of t.entries()){a.index>r&&Kt(n,e.content.slice(r,a.index),`text-${i}`,r===0,e.skillInvocationTargets);let t=e.presentation?.agentId?.toLowerCase()===a.agentId.toLowerCase()?e.presentation:null;n.push((0,W.jsx)(qt,{mention:a.mention,imageUrl:t?.imageUrl??null,token:e.token},`${a.index}-${i}`)),r=a.index+a.mention.length}return r<e.content.length&&Kt(n,e.content.slice(r),`text-tail`,r===0,e.skillInvocationTargets),(0,W.jsx)(W.Fragment,{children:n})}function Kt(e,t,n,r,i){if(!t)return;if(!r||!i){e.push(t);return}let a=It.exec(t),o=a?.[1]??``,s=i.get(o.toLowerCase());if(!a||!o||!s){e.push(t);return}let c=a[0];e.push((0,W.jsx)(`a`,{className:N.userSkillCommandLink,href:`/admin/skills/${encodeURIComponent(s)}`,children:c},`${n}-skill-command`));let l=t.slice(c.length);l&&e.push(l)}function qt(e){let t=Ut({token:e.token,imageUrl:e.imageUrl});return(0,W.jsxs)(`span`,{className:N.userAgentMentionPill,children:[t?(0,W.jsx)(`img`,{className:N.userAgentMentionAvatar,src:t,alt:``}):null,(0,W.jsx)(`span`,{children:e.mention})]})}function Jt(e){let[t,n]=(0,R.useState)(e.initial);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`textarea`,{className:N.editArea,value:t,onChange:e=>n(e.target.value),"aria-label":`Edit message`,autoFocus:!0}),(0,W.jsxs)(`div`,{className:N.editButtons,children:[(0,W.jsx)(v,{onClick:()=>e.onSave(t.trim()),disabled:!t.trim(),children:`Save`}),(0,W.jsx)(v,{variant:`ghost`,onClick:e.onCancel,children:`Cancel`})]})]})}function Yt(){let e=o({strict:!1}),t=s(),n=e.sessionId,r=(0,R.useRef)(null),i=(0,R.useRef)(new Set);if(!n&&!r.current){let e=d();r.current=e,i.current.add(e)}let a=n??r.current??``,c=(0,R.useRef)(a);c.current=a,(0,R.useEffect)(()=>{n&&(r.current=null)},[n]),(0,R.useEffect)(()=>{a&&m(a)},[a]);let l=(0,R.useCallback)(()=>c.current,[]),u=(0,R.useCallback)((e,n)=>t({to:`/chat/$sessionId`,params:{sessionId:e},...n}),[t]);return(0,R.useEffect)(()=>{n||!a||u(a,{replace:!0})},[u,a,n]),{sessionId:a,getSessionId:l,navigateToSession:u,switchToSession:(0,R.useCallback)((e,t)=>(r.current=e,c.current=e,u(e,t)),[u]),startFreshChat:(0,R.useCallback)(e=>{let t=d();return r.current=t,c.current=t,i.current.add(t),u(t,e),t},[u]),ensureSessionForSend:(0,R.useCallback)(()=>{if(c.current)return c.current;let e=d();return r.current=e,c.current=e,i.current.add(e),u(e,{replace:!0}),e},[u]),isLocallyCreatedSession:(0,R.useCallback)(e=>i.current.has(e),[]),handleSessionIdCorrection:(0,R.useCallback)(e=>{e!==c.current&&u(e,{replace:!0})},[u])}}async function Xt(e,t){let n=await fetch(e,{method:`POST`,headers:{...f(t.token,t.body),Accept:`application/x-ndjson`},body:JSON.stringify(t.body),signal:t.signal});n.ok||await p(n);let{callbacks:r}=t,i=e=>{let t=String(e||``).trim();if(!t)return null;let n;try{n=JSON.parse(t)}catch{return console.warn(`Ignoring malformed chat stream line`,t),null}return!n||typeof n!=`object`?null:n.type===`text`&&typeof n.delta==`string`?(r.onTextDelta(n.delta),null):n.type===`thinking`&&typeof n.delta==`string`?(r.onThinkingDelta?.(n.delta),null):n.type===`tool`&&typeof n.toolName==`string`&&(n.phase===`start`||n.phase===`finish`)?(r.onToolEvent?.(n),null):n.type===`approval`&&typeof n.approvalId==`string`&&typeof n.prompt==`string`?(r.onApproval(n),null):n.type===`result`&&n.result&&typeof n.result==`object`?n.result:typeof n.status==`string`&&Array.isArray(n.toolsUsed)?n:null};if(!n.body){let e=await n.text().catch(()=>``),t=null;for(let n of e.split(`
3
+ `)){let e=i(n);e&&(t=e)}if(!t)throw Error(`Chat stream ended without a result payload.`);return t}let a=n.body.getReader(),o=new TextDecoder,s=``,c=null,l=(e=!1)=>{let t=s.split(`
4
+ `),n=e?t.pop()??``:null;s=e?``:t.pop()??``;for(let e of t){let t=i(e);t&&(c=t)}if(e&&n?.trim()){let e=i(n);e&&(c=e)}};try{for(;;){let{done:e,value:t}=await a.read();if(e)break;s+=o.decode(t,{stream:!0}),l()}s+=o.decode(),l(!0)}finally{a.releaseLock()}if(!c)throw Error(`Chat stream ended without a result payload.`);return c}function Zt(e){let t=e.trim().split(/\s+/),n=t[0]?.replace(/^\/+/,``).toLowerCase(),r=t[1]?.toLowerCase();return(n===`agent`||n===`agents`)&&(r===`create`||r===`install`)}function Qt(e){let t=e.trim().split(/\s+/),n=t[0]?.replace(/^\/+/,``).toLowerCase();if(n!==`agent`&&n!==`agents`||t[1]?.toLowerCase()!==`switch`)return null;let r=t[2]?.trim();return r&&!/\s/.test(r)?r:null}function $t(e){return/^Session agent set to\b/i.test(e.trim())}function en(e){return/\bBOOTSTRAP\.md\b/i.test(e)}function tn(e){let{token:t,userId:r,getSessionId:i,setError:a,refreshRecent:o,onSessionIdCorrection:s,onModelResolved:c,onAppsCaptured:l,resolveAddressedAgentPresentation:u}=e,d=n(),f=(0,R.useRef)(null),[p,m]=(0,R.useState)(!1),[h,g]=(0,R.useState)(null),[_,v]=(0,R.useState)(null),y=(0,R.useCallback)((e,n)=>{let r=V(t,e);d.setQueryData(r,t=>{let r=t?.messages??[],i=typeof n==`function`?n(r):n;return i===r?t:{messages:i,branchFamilies:t?.branchFamilies??new Map,requestedSessionId:t?.requestedSessionId??e,resolvedSessionId:t?.resolvedSessionId??e,agentId:t?.agentId??null,bootstrapAutostart:t?.bootstrapAutostart??null}})},[d,t]);return{sendMessage:(0,R.useCallback)(async(e,n,p)=>{if(f.current)return a(`Wait for the current run to finish before sending another message.`),!1;let h=i(),_=e=>y(h,e),b=p?.hideUser?null:I();if(a(``),b){let t=u?.(e)??null,r={id:b,role:`user`,content:e,rawContent:e,sessionId:h,media:n,artifacts:[],replayRequest:{content:e,media:n},addressedAgentPresentation:t};_(e=>[...e,r])}let ee=I(),x=I();_(e=>[...e,{id:x,role:`trace`,content:``,sessionId:h,steps:[],done:!1,startedAt:Date.now()},{id:ee,role:`thinking`,content:``,sessionId:h}]);let S=I();g(S);let C={controller:new AbortController,sessionId:h,messageRole:`assistant`,assistantText:``,lastRenderedText:``,pendingApproval:null,trace:[],traceVersion:0,lastRenderedTraceVersion:0,renderFrame:0,stopping:!1};f.current=C,v(h),m(!0);let w=()=>{C.renderFrame=0;let e=C.traceVersion!==C.lastRenderedTraceVersion;if(C.assistantText===C.lastRenderedText&&!C.pendingApproval&&!e)return;C.lastRenderedText=C.assistantText,C.lastRenderedTraceVersion=C.traceVersion;let t=C.assistantText,n=C.pendingApproval,r=e?C.trace.map(e=>({...e})):null;_(e=>{let i=r?e.map(e=>e.id===x&&e.role===`trace`?{...e,steps:r}:e):e;if(!t&&!n)return i;let a=i.filter(e=>e.id!==ee),o=a.find(e=>e.id===S);return o?a.map(e=>e===o?{...e,role:C.messageRole,content:t,pendingApproval:n}:e):[...a,{id:S,role:C.messageRole,content:t,sessionId:C.sessionId,artifacts:[],pendingApproval:n}]})},te=()=>{C.renderFrame&&=(cancelAnimationFrame(C.renderFrame),0),w()},T=()=>{C.renderFrame||=requestAnimationFrame(w)},E=e=>{if(!e)return;let t=C.trace.at(-1);t?.kind===`thinking`?t.text+=e:C.trace.push({kind:`thinking`,text:e}),C.traceVersion+=1,T()},ne=e=>{if(e.phase===`start`)C.trace.push({kind:`tool`,toolName:e.toolName,status:`running`,argsPreview:e.preview||void 0});else{let t;for(let n=C.trace.length-1;n>=0;n--){let r=C.trace[n];if(r?.kind===`tool`&&r.status===`running`&&r.toolName===e.toolName){t=r;break}}t?(t.status=`done`,t.durationMs=e.durationMs,t.resultPreview=e.preview||void 0):C.trace.push({kind:`tool`,toolName:e.toolName,status:`done`,durationMs:e.durationMs,resultPreview:e.preview||void 0})}C.traceVersion+=1,T()},O=e=>{if(C.trace.length===0)return e.filter(e=>e.id!==x);let t=C.trace.map(e=>({...e}));return e.map(e=>e.id===x&&e.role===`trace`?{...e,steps:t,done:!0,finishedAt:Date.now()}:e)};try{let i=await Xt(`/api/chat`,{token:t,body:{sessionId:h,channelId:`web`,userId:r,username:`web`,content:e,stream:!0,...n.length>0?{media:n}:{},...p?.appBuild?{appBuild:!0}:{},...p?.appCategory?{appCategory:p.appCategory}:{},...p?.appKind?{appKind:p.appKind}:{}},signal:C.controller.signal,callbacks:{onTextDelta:e=>{C.assistantText+=e,T()},onApproval:e=>{C.pendingApproval=e,C.messageRole=`approval`,C.assistantText.trim()||(C.assistantText=D(e)),T()},onThinkingDelta:E,onToolEvent:ne}});if(i.status===`error`)throw Error(i.error??`Unknown error`);i.sessionId&&i.sessionId!==h&&s(i.sessionId);let a=i.model?.trim();a&&c?.(a),p?.appBuild&&i.apps&&i.apps.length>0&&l?.(i.apps),te();let u=i.result??C.assistantText??``,f=C.pendingApproval,m=i.artifacts??[],g=typeof i.addressEnvelope?.to==`string`?i.addressEnvelope.to:null;if(!i.messageRole)throw Error(`Gateway chat result is missing messageRole.`);let v=i.messageRole,y=v===`command`&&u.trim().length===0&&m.length===0,x=(t,r,a)=>({...a,id:t,role:v,content:u,sessionId:r,messageId:i.assistantMessageId??null,artifacts:m,assistantPresentation:i.assistantPresentation??null,pendingApproval:f,responseRating:null,replayRequest:{content:e,media:n}});_(e=>{let t=O(e).filter(e=>e.id!==ee),n=t.some(e=>e.id===S),r=e=>e.id===S?x(S,i.sessionId??e.sessionId,e):b&&e.id===b&&e.role===`user`?{...e,addressedAgentPresentation:g?i.assistantPresentation??null:null,messageId:e.messageId??i.userMessageId??null,sessionId:i.sessionId??e.sessionId}:e;if(y)return t.filter(e=>e.id!==S).map(r);let a=t.map(r);return n?a:[...a,x(S,i.sessionId??C.sessionId)]}),o();let w=v===`command`&&$t(u)?Qt(e):null;if(w){let e=i.sessionId??h,n=V(t,e);d.setQueryData(n,e=>e&&{...e,agentId:w,bootstrapAutostart:en(u)?{status:`starting`,fileName:`BOOTSTRAP.md`}:e.bootstrapAutostart}),d.invalidateQueries({queryKey:n,refetchType:`none`}),d.invalidateQueries({queryKey:[`chat-context`,t,e]})}v===`command`&&Zt(e)&&d.invalidateQueries({queryKey:[`agents-list`,t]})}catch(e){C.renderFrame&&cancelAnimationFrame(C.renderFrame);let t=M(e);_(e=>{let n=O(e).filter(e=>e.id!==ee);return C.stopping?n:[...n,{id:I(),role:`system`,content:`Error: ${t}`,sessionId:h}]})}finally{f.current=null,v(null),m(!1),g(null)}return!0},[t,r,i,y,s,c,l,u,d,a,o]),stopRequest:(0,R.useCallback)(async()=>{let e=f.current;if(!(!e||e.stopping)){e.stopping=!0;try{await Ae(t,e.sessionId,r,[`stop`])}catch(e){a(`Failed to stop: ${M(e)}`)}finally{e.controller.abort()}}},[t,r,a]),isStreaming:p,streamingMsgId:h,activeSessionId:_,isActive:(0,R.useCallback)(()=>f.current!==null,[])}}var nn=120,rn=220;function an(){let e=(0,R.useRef)(null),t=(0,R.useRef)(null),n=(0,R.useRef)(null),r=(0,R.useRef)(0),[i,a]=(0,R.useState)(!0),o=(0,R.useRef)(!0),s=(0,R.useRef)(!1),c=(0,R.useCallback)(e=>{o.current!==e&&(o.current=e,a(e))},[]),l=(0,R.useCallback)((e,t)=>{let n=Math.max(0,e.scrollHeight-e.clientHeight),r=Math.max(0,Math.min(t,n));r!==e.scrollTop&&(s.current=!0,e.scrollTop=r)},[]),u=(0,R.useCallback)(()=>{let t=e.current;!t||!o.current||t.scrollHeight<=t.clientHeight||l(t,t.scrollHeight)},[l]),d=(0,R.useCallback)(n=>{if(t.current?.abort(),t.current=null,e.current=n,!n)return;let r=new AbortController;t.current=r,n.addEventListener(`scroll`,()=>{if(s.current){s.current=!1;return}c(n.scrollHeight-n.scrollTop-n.clientHeight<=nn)},{passive:!0,signal:r.signal}),u()},[c,u]),f=(0,R.useCallback)(e=>{if(n.current?.disconnect(),n.current=null,!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>u());t.observe(e),n.current=t},[u]),p=(0,R.useCallback)(()=>{let t=e.current;if(!t)return;if(r.current&&=(cancelAnimationFrame(r.current),0),c(!0),typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches){l(t,t.scrollHeight);return}let n=t.scrollTop;if(t.scrollHeight-t.clientHeight-n<=0)return;let i=performance.now(),a=()=>{let t=e.current;if(!t){r.current=0;return}let o=Math.min(1,(performance.now()-i)/rn),s=1-(1-o)**3;l(t,n+(t.scrollHeight-t.clientHeight-n)*s),r.current=o<1?requestAnimationFrame(a):0};r.current=requestAnimationFrame(a)},[c,l]),m=(0,R.useCallback)(()=>{c(!0);let t=e.current;t&&l(t,t.scrollHeight)},[c,l]);return(0,R.useEffect)(()=>()=>{t.current?.abort(),n.current?.disconnect(),r.current&&cancelAnimationFrame(r.current)},[]),{scrollRef:d,contentRef:f,isPinned:i,jumpToBottom:p,resetToBottom:m}}var on=[],sn=[],cn=5e3,ln=`bootstrap-autostart-thinking`,un=1500,dn=`Ready to claw through your to-do list?`,fn=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;function pn(){let e=new URLSearchParams(window.location.search).get(`agent`)?.trim();return e&&fn.test(e)?e:``}function mn(e,t){let n=new Map;if(t.size===0)return n;for(let r of e){let e=r.branchKey;if(!e)continue;let i=t.get(e);if(!i||i.length<2)continue;let a=i.findIndex(e=>e.sessionId===r.sessionId);a<0||n.set(r.id,{current:a+1,total:i.length})}return n}function hn(e,t,n=``,r=`user`){return[`chat-recent`,e,t,n,r]}function gn(e,t){return[`chat-recent`,e,t]}function _n(e,t){return[`chat-context`,e,t]}var vn=`hybridclaw.appBuildSessions`;function yn(){try{let e=localStorage.getItem(vn);return e?new Map(Object.entries(JSON.parse(e))):new Map}catch{return new Map}}function bn(e){try{localStorage.setItem(vn,JSON.stringify(Object.fromEntries(e)))}catch{}}function xn(){let e=se(),t=s(),i=n(),o=(0,R.useRef)(C()).current,l=c({strict:!1}),[u]=(0,R.useState)(()=>{let e=l.kind,t=e===`live`?`live`:e===`web`?`web`:void 0;return{prompt:l.prompt??``,autoSend:l.send===`1`,appBuild:l.app===`1`,appCategory:l.category,appKind:t}}),d=(0,R.useRef)(yn()),f=(0,R.useCallback)((e,t)=>{d.current.set(e,t),bn(d.current)},[]),p=u.autoSend?``:u.prompt,m=(0,R.useMemo)(pn,[]),[v,ee]=(0,R.useState)({message:``,version:0}),x=v.message,w=(0,R.useCallback)(e=>{ee(t=>({message:typeof e==`function`?e(t.message):e,version:t.version+1}))},[]),[te,T]=(0,R.useState)(!1),[D,O]=(0,R.useState)(null),[re,ie]=(0,R.useState)(!1),[k,A]=(0,R.useState)(null),[oe,j]=(0,R.useState)(!1),[le,ue]=(0,R.useState)(m||null),[de,pe]=(0,R.useState)(``),[he,_e]=(0,R.useState)(`user`),[P,F]=(0,R.useState)(null),[ye,xe]=(0,R.useState)(``),Se=(0,R.useRef)(null),je=We(ye,160).trim(),{scrollRef:Ie,contentRef:ze,isPinned:He,jumpToBottom:L,resetToBottom:Ge}=an(),Ke=(0,R.useRef)(null),qe=(0,R.useRef)(null);(0,R.useEffect)(()=>{let e=()=>{let e=window.visualViewport?.height??window.innerHeight;!Number.isFinite(e)||e<=0||(document.documentElement.style.setProperty(`--chat-visual-viewport-height`,`${Math.round(e)}px`),document.scrollingElement?.scrollTo({left:0}),document.body.scrollLeft=0,document.documentElement.scrollLeft=0)};return e(),window.addEventListener(`resize`,e),window.addEventListener(`orientationchange`,e),window.visualViewport?.addEventListener(`resize`,e),window.visualViewport?.addEventListener(`scroll`,e),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`orientationchange`,e),window.visualViewport?.removeEventListener(`resize`,e),window.visualViewport?.removeEventListener(`scroll`,e),document.documentElement.style.removeProperty(`--chat-visual-viewport-height`)}},[]);let{sessionId:z,getSessionId:B,navigateToSession:Xe,switchToSession:Qe,startFreshChat:$e,ensureSessionForSend:H,handleSessionIdCorrection:et}=Yt();m&&z&&!Se.current&&(Se.current=z);let tt=z&&Se.current===z?m:``,U=(0,R.useCallback)(()=>{i.invalidateQueries({queryKey:gn(e.token,o)}),i.invalidateQueries({queryKey:V(e.token,B()),refetchType:`none`})},[i,e.token,o,B]),G=fe(e),nt=b(e.token),K=a({queryKey:[`app-status`,e.token],queryFn:()=>y(e.token),staleTime:1/0,enabled:G,initialData:e.status===`ready`&&e.gatewayStatus?e.gatewayStatus:void 0}),rt=a({queryKey:[`agents-list`,e.token],queryFn:()=>ne(e.token),staleTime:3e4,enabled:G}),it=a({queryKey:[`models`,e.token],queryFn:()=>Te(e.token),staleTime:3e4,enabled:G}),at=a({queryKey:[`skills`,e.token],queryFn:()=>S(e.token),staleTime:6e4,retry:!1,enabled:G});(0,R.useEffect)(()=>{pe(K.data?.defaultModel?.trim()??``)},[z,K.data?.defaultModel]),(0,R.useEffect)(()=>{K.error&&(console.error(`Failed to load gateway status for chat page`,K.error),w(`Failed to load the default agent. New chats will use main until gateway status loads.`))},[K.error,w]),(0,R.useEffect)(()=>{it.error&&(console.error(`Failed to load models list for chat page`,it.error),w(`Failed to load the model list. Model switching is unavailable.`))},[it.error,w]);let ot=a({queryKey:hn(e.token,o,je,he),queryFn:()=>Le(e.token,o,`web`,je?Fe.maxSearchResults:Fe.maxRecentSessions,je||void 0,he),staleTime:1e4,enabled:G}),st=ot.data?.sessions??[],ct=(0,R.useMemo)(()=>(rt.data??[]).map(e=>({id:e.id,name:e.name,imageUrl:e.imageUrl??null,emptyChatHeader:e.emptyChatHeader??null,source:e.source})),[rt.data]),lt=(0,R.useMemo)(()=>new Map((at.data?.skills??[]).filter(e=>e.userInvocable).map(e=>[e.name.toLowerCase(),e.name])),[at.data?.skills]),ut=(0,R.useCallback)(e=>{let t=Je(e);for(let e of t){let t=ct.find(t=>t.id.toLowerCase()===e.agentId.toLowerCase());if(t)return{agentId:t.id,displayName:t.name??t.id,imageUrl:t.imageUrl??null}}return null},[ct]),dt=it.data?.models??sn,[q,ft]=(0,R.useState)(null),J=tn({token:e.token,userId:o,getSessionId:B,setError:w,refreshRecent:U,onSessionIdCorrection:et,onModelResolved:pe,onAppsCaptured:e=>ft(e[e.length-1]??null),resolveAddressedAgentPresentation:ut});(0,R.useEffect)(()=>{let e=v.message;if(T(!1),!e)return;let t=window.setTimeout(()=>{T(!0)},cn),n=window.setTimeout(()=>{w(``),T(!1)},5200);return()=>{window.clearTimeout(t),window.clearTimeout(n)}},[v,w]);let Y=a({queryKey:V(e.token,z),queryFn:()=>Ze(e.token,z,o,tt||void 0),enabled:G&&!!z,staleTime:1/0}),X=a({queryKey:_n(e.token,z),queryFn:()=>Me(e.token,z),enabled:G&&!!z,staleTime:15e3,refetchOnWindowFocus:!1}),Z=Y.data?.messages??on,mt=Y.data?.bootstrapAutostart?.status===`starting`,Q=(0,R.useMemo)(()=>mt?[...Z,{id:ln,role:`thinking`,content:``,sessionId:z}]:Z,[mt,Z,z]),ht=Y.data?.branchFamilies??Ye,gt=le?.trim().toLowerCase()||Y.data?.agentId?.trim().toLowerCase()||K.data?.defaultAgentId?.trim().toLowerCase()||`main`,vt=ct.find(e=>e.id.toLowerCase()===gt)?.emptyChatHeader?.trim()||dn,$=r({mutationFn:t=>Ce(e.token,t),onSuccess:t=>{if(!t.deleted){w(`Delete failed: session was not found.`);return}let n=t.sessionId;i.removeQueries({queryKey:V(e.token,n)}),i.removeQueries({queryKey:_n(e.token,n)}),i.invalidateQueries({queryKey:gn(e.token,o)}),i.invalidateQueries({queryKey:[`overview`],refetchType:`none`}),F(null),n===B()&&$e({replace:!0})},onError:e=>{w(`Delete failed: ${M(e)}`)}}),yt=r({mutationFn:t=>{if(!t.message.messageId)throw Error(`This response cannot be rated right now.`);return Pe(e.token,{sessionId:t.message.sessionId,messageId:t.message.messageId,userId:o,rating:t.rating})},onSuccess:(t,n)=>{let r=n.message.sessionId;i.setQueryData(V(e.token,r),e=>e&&{...e,messages:e.messages.map(e=>e.messageId===t.messageId?{...e,responseRating:t.rating}:e)})},onError:e=>{w(`Rating failed: ${M(e)}`)}});(0,R.useEffect)(()=>{let e=X.data?.snapshot?.model?.trim()??``;e&&pe(e)},[X.data?.snapshot?.model]),(0,R.useEffect)(()=>{if(m&&Se.current===z){ue(m);return}ue(null)},[m,z]),(0,R.useEffect)(()=>{Y.error&&w(M(Y.error))},[Y.error,w]),(0,R.useEffect)(()=>{if(Y.data?.bootstrapAutostart?.status!==`starting`||Y.isFetching)return;let e=window.setTimeout(()=>{Y.refetch()},un);return()=>window.clearTimeout(e)},[Y.data?.bootstrapAutostart?.status,Y.isFetching,Y.refetch]),(0,R.useEffect)(()=>{if(!k)return;let e=document.body.style.overflow,t=document.activeElement;document.body.style.overflow=`hidden`,qe.current?.focus();let n=e=>{if(e.key===`Escape`){e.preventDefault(),A(null);return}if(e.key!==`Tab`)return;let t=Array.from(Ke.current?.querySelectorAll(`a[href], button:not(:disabled)`)??[]);if(t.length===0)return;let n=t[0],r=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),r?.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n?.focus())};return document.addEventListener(`keydown`,n),()=>{document.removeEventListener(`keydown`,n),document.body.style.overflow=e,t instanceof HTMLElement&&t.focus()}},[k]),(0,R.useEffect)(()=>{if(Y.isPending||Y.fetchStatus!==`idle`||Y.data?.requestedSessionId!==z)return;let e=Y.data?.resolvedSessionId;!e||e===z||Xe(e,{replace:!0})},[Y.data?.requestedSessionId,Y.data?.resolvedSessionId,Y.fetchStatus,Y.isPending,z,Xe]);let bt=(0,R.useMemo)(()=>mn(Z,ht),[Z,ht]),xt=(0,R.useRef)(!1);(0,R.useEffect)(()=>{xt.current&&!J.isStreaming&&z&&i.invalidateQueries({queryKey:_n(e.token,z)}),xt.current=J.isStreaming},[J.isStreaming,i,e.token,z]),(0,R.useEffect)(()=>{z&&Ge()},[z,Ge]);let St=(0,R.useCallback)(async(t,n)=>{if(!t.messageId||!t.sessionId){w(`This message cannot be edited right now.`);return}O(null);try{let r=await Re(e.token,t.sessionId,t.messageId);i.invalidateQueries({queryKey:V(e.token,t.sessionId),refetchType:`none`}),await i.ensureQueryData({queryKey:V(e.token,r.sessionId),queryFn:()=>Ze(e.token,r.sessionId,o)}),await Qe(r.sessionId),J.sendMessage(n,t.media??[])}catch(e){w(M(e))}},[e.token,i,w,Qe,J.sendMessage,o]),Ct=(0,R.useCallback)(e=>{e.replayRequest&&(L(),J.sendMessage(e.replayRequest.content,e.replayRequest.media,{hideUser:!0}))},[L,J.sendMessage]),wt=(0,R.useCallback)(async(e,t)=>{let n=Ee(e,t);if(n){ie(!0);try{L(),await J.sendMessage(n,[],{hideUser:!0})}finally{ie(!1)}}},[L,J.sendMessage]),Tt=(0,R.useCallback)((e,t)=>{yt.mutate({message:e,rating:t})},[yt]),Et=(0,R.useCallback)(async t=>{let n=await Promise.allSettled(t.map(t=>Ne(e.token,t))),r=[];for(let e of n)e.status===`fulfilled`&&e.value.media?r.push(e.value.media):e.status===`rejected`&&w(M(e.reason));return r},[e.token,w]),Dt=(0,R.useCallback)(t=>{Oe(e.token,{channelId:`web`,keepSessionId:t}).then(t=>{if(t.deletedCount!==0){for(let n of t.deletedSessionIds)i.removeQueries({queryKey:V(e.token,n)}),i.removeQueries({queryKey:_n(e.token,n)});i.invalidateQueries({queryKey:gn(e.token,o)}),i.invalidateQueries({queryKey:[`overview`],refetchType:`none`})}}).catch(e=>{console.warn(`Failed to clean up no-user chat session`,e)})},[e.token,i,o]),Ot=(0,R.useCallback)(()=>{if(J.isActive()){w(`Stop the current run before starting a new chat.`);return}Dt($e()),U()},[J.isActive,$e,Dt,U,w]),kt=(0,R.useCallback)((e,n)=>{let r=/^\/apps?\b[ \t]*([\s\S]*)$/i.exec(e.trim());if(r&&n.length===0){let e=r[1].trim();if(!e){t({to:`/apps`});return}f(H(),{kind:`web`}),L(),J.sendMessage(De(null,e),[],{appBuild:!0,appKind:`web`});return}let i=H();L();let a=d.current.get(i);if(a){J.sendMessage(e,n,{appBuild:!0,...a.category?{appCategory:a.category}:{},...a.kind?{appKind:a.kind}:{}});return}J.sendMessage(e,n)},[H,L,t,f,J.sendMessage]),At=(0,R.useRef)(!1);(0,R.useEffect)(()=>{if(At.current||!u.autoSend)return;let e=u.prompt.trim();e&&G&&Y.isFetched&&(At.current=!0,window.history.replaceState(null,``,window.location.pathname),u.appBuild&&f(H(),{category:u.appCategory,kind:u.appKind}),kt(e,[]))},[u,G,Y.isFetched,H,f,kt]);let jt=(0,R.useCallback)((t,n)=>{let r=n.trim();r&&i.setQueryData(V(e.token,t),e=>{let n=e?.messages??[];return n.some(e=>e.role===`command`&&(e.rawContent||e.content).trim()===r)?e:{messages:[...n,{id:I(),role:`command`,content:r,rawContent:r,sessionId:t,artifacts:[],replayRequest:null}],branchFamilies:e?.branchFamilies??new Map,requestedSessionId:e?.requestedSessionId??t,resolvedSessionId:t,agentId:e?.agentId??null,bootstrapAutostart:e?.bootstrapAutostart??null}})},[e.token,i]),Mt=(0,R.useCallback)(async t=>{let n=V(e.token,t);return i.fetchQuery({queryKey:n,queryFn:()=>Ze(e.token,t,o),staleTime:0}).catch(e=>(console.warn(`Failed to prefetch chat history before appending switch result`,e),null))},[e.token,i,o]),Nt=(0,R.useCallback)(async(t,n,r,a)=>{if(!n||/\s/.test(n))return;if(J.isActive()){w(a);return}H();let s=B();try{let a=await Ae(e.token,s,o,[...t,n]),c=a.sessionId?.trim()||s,l=await Mt(c);jt(c,a.text),c!==s&&await Qe(c,{replace:!0}),i.invalidateQueries({queryKey:_n(e.token,c)}),t[0]===`agent`&&t[1]===`switch`&&l?.bootstrapAutostart?.fileName===`BOOTSTRAP.md`&&(l.bootstrapAutostart.status===`idle`||l.bootstrapAutostart.status===`starting`)&&(i.setQueryData(V(e.token,c),e=>e&&{...e,bootstrapAutostart:{status:`starting`,fileName:`BOOTSTRAP.md`}}),L()),U(),r(n)}catch(e){w(M(e))}},[jt,e.token,H,Mt,B,L,i,U,w,J.isActive,Qe,o]),Pt=(0,R.useCallback)(e=>Nt([`agent`,`switch`],e,ue,`Could not switch agent — stop the current run and try again.`),[Nt]),Ft=(0,R.useCallback)(e=>Nt([`model`,`set`],e,pe,`Could not switch model — stop the current run and try again.`),[Nt]),It=(0,R.useCallback)(e=>{if(J.isActive()){w(`Stop the current run before switching chats.`);return}Xe(e)},[J.isActive,Xe,w]),Lt=(0,R.useCallback)(e=>J.activeSessionId===e?(w(`Stop the current run before deleting this chat.`),!1):!$.isPending,[$.isPending,J.activeSessionId,w]),Rt=(0,R.useCallback)(e=>{Lt(e.sessionId)&&F(e)},[Lt]),zt=(0,R.useCallback)(()=>{if(!P)throw Error(`Delete confirmation is missing a session.`);Lt(P.sessionId)&&$.mutate(P.sessionId)},[Lt,$,P]),Bt=(0,R.useCallback)(t=>{t!==B()&&i.prefetchQuery({queryKey:V(e.token,t),queryFn:()=>Ze(e.token,t,o),staleTime:3e4})},[i,e.token,B,o]),Vt=(0,R.useCallback)(()=>{i.invalidateQueries({queryKey:hn(e.token,o,je,he)})},[i,e.token,o,je,he]),Ht=(0,R.useCallback)(async()=>{let t=B();if(!t){w(`Open or send a chat before creating a mobile QR code.`);return}j(!0);try{A(await Be(e.token,{userId:o,sessionId:t,baseUrl:window.location.origin}))}catch(e){w(M(e))}finally{j(!1)}},[e.token,B,o,w]),Ut=(0,R.useCallback)(e=>{O(e.id)},[]),Gt=(0,R.useCallback)((e,t)=>{let n=e.branchKey;if(!n)return;let r=ht.get(n);if(!r||r.length<2)return;let i=r.findIndex(t=>t.sessionId===e.sessionId);if(i<0)return;let a=i+t;if(a<0||a>=r.length)return;let o=r[a];o&&It(o.sessionId)},[ht,It]),Kt=Q.length===0,qt=Y.isFetching,Xt={sessions:st,activeSessionId:z,onNewChat:Ot,onOpenSession:It,onHoverSession:Bt,onRequestDeleteSession:Rt,deleteDisabled:$.isPending,isPending:qt,searchQuery:ye,onSearchQueryChange:xe,recentScope:he,onRecentScopeChange:_e,isLoading:ot.isFetching,onRefreshRecent:Vt};return(0,W.jsx)(h,{children:(0,W.jsxs)(`div`,{className:N.chatPage,"aria-busy":qt,children:[(0,W.jsx)(Ve,{...Xt}),(0,W.jsxs)(`div`,{className:N.chatMain,children:[(0,W.jsxs)(`div`,{className:N.chatTopbar,children:[(0,W.jsx)(g,{className:N.chatMobileTrigger}),(0,W.jsx)(_t,{sessionId:z,token:e.token,enabled:G}),(0,W.jsx)(`button`,{type:`button`,className:N.mobileQrButton,onClick:()=>void Ht(),disabled:oe,"aria-label":`Show mobile QR code`,title:`Show mobile QR code`,children:(0,W.jsxs)(`span`,{"aria-hidden":`true`,className:N.mobileQrIcon,children:[(0,W.jsx)(`span`,{}),(0,W.jsx)(`span`,{}),(0,W.jsx)(`span`,{}),(0,W.jsx)(`span`,{})]})}),(0,W.jsx)(_,{items:nt})]}),k?(0,W.jsx)(`div`,{className:N.mobileQrOverlay,children:(0,W.jsxs)(`div`,{ref:Ke,className:N.mobileQrDialog,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`mobile-qr-title`,children:[(0,W.jsxs)(`div`,{className:N.mobileQrHeader,children:[(0,W.jsx)(`h2`,{id:`mobile-qr-title`,children:`Open on mobile`}),(0,W.jsx)(`button`,{ref:qe,type:`button`,className:N.mobileQrClose,onClick:()=>A(null),"aria-label":`Close mobile QR code`,children:`x`})]}),(0,W.jsx)(`div`,{className:N.mobileQrImage,children:(0,W.jsx)(`img`,{src:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(k.qrSvg)}`,alt:`Mobile session QR code`})}),(0,W.jsx)(`a`,{className:N.mobileQrLink,href:k.launchUrl,children:`Open link`})]})}):null,Kt?(0,W.jsx)(`div`,{className:N.emptyState,children:(0,W.jsx)(`h1`,{className:N.greeting,children:vt})}):(0,W.jsx)(`div`,{className:N.messageArea,ref:Ie,children:(0,W.jsx)(`div`,{className:N.messageList,ref:ze,children:Q.map(t=>D===t.id&&t.role!==`thinking`&&t.role!==`trace`?(0,W.jsx)(`div`,{className:N.messageBlock,children:(0,W.jsx)(Jt,{initial:t.rawContent??t.content,onSave:e=>void St(t,e),onCancel:()=>O(null)})},t.id):(0,W.jsx)(Wt,{message:t,token:e.token,isStreaming:t.id===J.streamingMsgId,onCopy:we,onEdit:Ut,onRegenerate:Ct,onRate:Tt,ratingBusy:yt.isPending&&yt.variables?.message.id===t.id,skillInvocationTargets:lt,onApprovalAction:wt,approvalBusy:re,branchInfo:bt.get(t.id)??null,onBranchNav:Gt},t.id))})}),!Kt&&!He?(0,W.jsxs)(`button`,{type:`button`,className:N.jumpToLatest,onClick:L,"aria-label":`Jump to latest message`,children:[(0,W.jsx)(`span`,{"aria-hidden":`true`,children:`↓`}),(0,W.jsx)(`span`,{children:`Latest`})]}):null,x?(0,W.jsx)(`div`,{className:`${N.errorBanner} ${te?N.errorBannerExiting:``}`,children:x}):null,(0,W.jsx)(pt,{isStreaming:J.isStreaming,onSend:kt,onStop:()=>void J.stopRequest(),onUploadFiles:Et,token:e.token,agents:ct,selectedAgentId:gt,onAgentSwitch:e=>void Pt(e),models:dt,selectedModelId:de,onModelSwitch:e=>void Ft(e),initialValue:p})]}),(0,W.jsx)(ae,{open:P!==null,onOpenChange:e=>{!e&&!$.isPending&&F(null)},children:(0,W.jsxs)(me,{size:`sm`,role:`alertdialog`,preventCloseOnOutsideClick:$.isPending,children:[(0,W.jsxs)(E,{children:[(0,W.jsx)(ge,{children:`Delete session?`}),(0,W.jsx)(ve,{children:`This permanently removes the conversation and associated session records.`})]}),(0,W.jsxs)(ce,{children:[(0,W.jsx)(be,{className:`ghost-button`,disabled:$.isPending,children:`Cancel`}),(0,W.jsx)(`button`,{type:`button`,className:`danger-button`,disabled:$.isPending,onClick:zt,children:$.isPending?`Deleting...`:`Delete`})]})]})}),(0,W.jsx)(ae,{open:q!==null,onOpenChange:e=>{e||ft(null)},children:(0,W.jsxs)(me,{className:N.appPreviewDialog,"aria-label":`App preview`,children:[(0,W.jsxs)(`div`,{className:N.appPreviewHeader,children:[(0,W.jsx)(ge,{className:N.appPreviewTitle,children:q?.title}),(0,W.jsxs)(`div`,{className:N.appPreviewActions,children:[(0,W.jsx)(`button`,{type:`button`,className:N.appPreviewLink,onClick:()=>{ft(null),t({to:`/apps`})},children:`View in Apps`}),q?(0,W.jsx)(`a`,{className:N.appPreviewLink,href:Ue(q.id,e.token),target:`_blank`,rel:`noreferrer`,children:`Open in new tab ↗`}):null,(0,W.jsx)(be,{className:N.appPreviewLink,children:`Close`})]})]}),q?(0,W.jsx)(ke,{appId:q.id,className:N.appPreviewFrame,title:q.title,token:e.token}):null]})})]})})}export{xn as ChatPage};
@@ -0,0 +1,5 @@
1
+ import{n as e}from"./rolldown-runtime-Bh1tDfsg.js";import{C as t,o as n}from"./query-o_Dd9s85.js";import{l as r}from"./router-DoNPHesn.js";import{B as i,Ct as a,F as o,G as s,I as c,K as l,R as u,U as ee,V as d,W as f,_t as p,ct as m,ht as h,k as g,r as _,st as v,wt as y,yt as te,z as ne}from"./index-Btzl6jZZ.js";var b=e(t(),1);function x(e,t={}){let n=new URLSearchParams;t.category&&t.category!==`all`&&n.set(`category`,t.category),t.search?.trim()&&n.set(`q`,t.search.trim());let r=n.toString();return y(`/api/apps${r?`?${r}`:``}`,{token:e})}function S(e,t){return y(`/api/apps/${encodeURIComponent(t)}`,{token:e})}function C(e,t){return y(`/api/apps/${encodeURIComponent(t)}`,{token:e,method:`DELETE`})}function w(e,t,n){return y(`/api/apps/${encodeURIComponent(t)}/bridge/tool`,{token:e,method:`POST`,body:n})}function T(e,t){let n=new URLSearchParams({token:t});return`/api/apps/${encodeURIComponent(e)}/view?${n.toString()}`}var E=n();function D(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function O(e){if(!D(e)||e.type!==`hybridclaw:live-app-tool-call`||typeof e.appId!=`string`||typeof e.requestId!=`string`||typeof e.toolName!=`string`)return null;let t=e.arguments;return t!==void 0&&!D(t)?null:{type:`hybridclaw:live-app-tool-call`,appId:e.appId,requestId:e.requestId,toolName:e.toolName,...t===void 0?{}:{arguments:t}}}var k=(0,b.forwardRef)(function(e,t){let n=(0,b.useRef)(null),r=(0,b.useRef)(!1),i=(0,b.useRef)(e.appId);i.current!==e.appId&&(i.current=e.appId,r.current=!1);let a=(0,b.useCallback)(()=>{let t=n.current?.contentWindow;return!t||!r.current?!1:(t.postMessage({type:`hybridclaw:live-app-refresh`,appId:e.appId},`*`),!0)},[e.appId]);return(0,b.useImperativeHandle)(t,()=>({refreshData:a}),[a]),(0,b.useEffect)(()=>{let t=!0,r=(t,r)=>{let i=n.current?.contentWindow;i&&i.postMessage({type:`hybridclaw:live-app-tool-result`,appId:e.appId,requestId:t,...r},`*`)},i=i=>{if(i.source!==n.current?.contentWindow)return;let a=O(i.data);!a||a.appId!==e.appId||w(e.token,e.appId,{toolName:a.toolName,arguments:a.arguments??{}}).then(e=>{t&&r(a.requestId,{ok:!0,payload:e})}).catch(e=>{t&&r(a.requestId,{ok:!1,error:e instanceof Error?e.message:String(e)})})};return window.addEventListener(`message`,i),()=>{t=!1,window.removeEventListener(`message`,i)}},[e.appId,e.token]),(0,b.useEffect)(()=>{!e.refreshNonce||!r.current||a()},[a,e.refreshNonce]),(0,E.jsx)(`iframe`,{ref:n,className:e.className,title:e.title,src:T(e.appId,e.token),sandbox:`allow-scripts allow-forms allow-popups allow-modals allow-downloads allow-popups-to-escape-sandbox`,onLoad:()=>{r.current=!0,e.refreshNonce&&a()}},e.appId)}),A=`
2
+
3
+ <<<APP_BUILD_DIRECTIVE>>>
4
+ `;function j(e){let t=e.indexOf(A);return t===-1?e:e.slice(0,t).trimEnd()}var M='Build one self-contained, fully client-side HTML file (no backend), and save it into the workspace `apps/` folder (e.g. apps/<short-name>.html). Default to React via CDN — load React, ReactDOM, and Babel standalone from a CDN and put your JSX in an inline <script type="text/babel"> so it stays a single HTML file. Use a different stack only if I ask. Design it with care — if you have a frontend-design skill, use it; otherwise apply strong fundamentals (clear layout, sensible typography, responsive, accessible, modern). When you finish, the app is automatically published to my Apps gallery and opened as a preview with its own link — no external hosting needed, so just build it.',N='For live refresh inside the Apps viewer, never call `/api/mcp/...` or other gateway URLs directly. Generated HTML runs in a sandbox and must use `window.hybridclaw.callMcpTool("<namespaced_mcp_tool>", { ... })` (or `window.hybridclaw.callTool`) from its refresh action. Register the same refresh function with `window.hybridclaw.setRefreshHandler(refresh)` when that API exists, so the Apps viewer Refresh button updates data in place instead of rebuilding the app. Keep an embedded snapshot fallback so the app still works outside the Apps viewer or when the bridge is unavailable.';function P(e,t){return`${e}${A}${t.join(`
5
+ `)}`}function F(e,t){let n=t.trim();return n?P(e?`Let's build a ${e} web app. Here's my idea: ${n}`:`Let's build a web app. Here's my idea: ${n}`,[`Don't ask me a list of questions — use best-practice defaults for anything I didn't specify, and don't suggest a different app (I already know what I want).`,`First propose a short plan (your key decisions, a few bullets), then wait for my OK and build it. ${M}`]):P(e?`Let's build a ${e} web app.`:`Let's build a web app.`,[`Ask me one quick question about what I want, then propose a short plan, wait for my OK, and build it.`,M])}function I(e){let t=e.trim(),n=`build it as a live app that embeds the latest data pulled from those connectors, with a refresh action. ${N} ${M}`,r=`Assume my connected MCP servers / tools are the data source: if a relevant connector is available, use it directly to fetch the data — do not ask me which data source or connector to use.`;return t?P(`I want to create a live app that uses my connected tools. Here's my idea: ${t}`,[r,`Don't ask me a list of questions — use best-practice defaults for anything I didn't specify (scope, fields, sorting, refresh), and don't suggest a different app (I already know what I want). Tell me only if something essential is missing.`,`First propose a short plan (your key decisions, a few bullets), then wait for my OK and ${n}`]):P(`I want to create a live app that uses my connected tools.`,[r,`Suggest the most useful live app or dashboard you can build with my connectors (briefly list a couple of options and recommend one).`,`Once I pick, propose a short plan, wait for my OK, and ${n}`])}function L(e,t,n=`web`,r=10,i,a){let o=new URLSearchParams({userId:t,channelId:n,limit:String(r)});return i&&o.set(`q`,i),a&&o.set(`scope`,a),y(`/api/chat/recent?${o.toString()}`,{token:e})}function R(e,t){let n=new URLSearchParams({channelId:t.channelId||`web`});return t.keepSessionId&&n.set(`keepSessionId`,t.keepSessionId),y(`/api/chat/cleanup?${n.toString()}`,{token:e,method:`POST`})}function z(e,t,n=80,r,i){let a=new URLSearchParams({sessionId:t,limit:String(n)});return r&&a.set(`userId`,r),i?.trim()&&a.set(`agentId`,i.trim()),y(`/api/history?${a.toString()}`,{token:e})}function re(e,t){return y(`/api/chat/context?${new URLSearchParams({sessionId:t}).toString()}`,{token:e})}function B(e,t){return y(t?`/api/chat/commands?q=${encodeURIComponent(t)}`:`/api/chat/commands`,{token:e})}function V(e,t){return y(`/api/chat/mobile-qr`,{token:e,method:`POST`,body:t})}function H(e,t,n){return y(`/api/chat/branch`,{token:e,method:`POST`,body:{sessionId:t,beforeMessageId:n}})}function U(e,t){return y(`/api/chat/rating`,{token:e,method:`POST`,body:t})}function W(e,t,n,r){return y(`/api/command`,{token:e,method:`POST`,body:p({sessionId:t,args:r,userId:n,username:`web`})})}function G(e,t){return y(`/api/media/upload`,{token:e,method:`POST`,rawBody:t,extraHeaders:{"Content-Type":t.type||`application/octet-stream`,"X-Hybridclaw-Filename":encodeURIComponent(t.name||`upload`)}})}function K(e){return`/api/artifact?${new URLSearchParams({path:e}).toString()}`}function q(e){return e}async function J(e,t){let n=await fetch(t,{headers:a(e),cache:`no-store`});if(!n.ok){let e=(n.headers.get(`content-type`)||``).toLowerCase().trim(),t=`${n.status} ${n.statusText}`;if(e.includes(`application/json`)){let e=await n.json().catch(()=>null);t=e?.error||e?.text||t}else{let e=(await n.text().catch(()=>``)).trim();e&&(t=e)}throw n.status===401&&te(t),Error(t)}return n.blob()}async function Y(e,t){return J(e,K(t))}function X(e,t){return J(e,q(t))}var ie={maxRecentSessions:10,maxSearchResults:50};function Z(e){let{children:t,...n}=e;return(0,E.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.6,strokeLinecap:`round`,strokeLinejoin:`round`,width:`100%`,height:`100%`,"aria-hidden":`true`,...n,children:t})}function ae(e){return(0,E.jsxs)(Z,{...e,children:[(0,E.jsx)(`rect`,{x:`4`,y:`4`,width:`7`,height:`7`,rx:`1.5`}),(0,E.jsx)(`rect`,{x:`13`,y:`4`,width:`7`,height:`7`,rx:`1.5`}),(0,E.jsx)(`rect`,{x:`4`,y:`13`,width:`7`,height:`7`,rx:`1.5`}),(0,E.jsx)(`rect`,{x:`13`,y:`13`,width:`7`,height:`7`,rx:`1.5`})]})}function oe(e){return(0,E.jsxs)(Z,{...e,children:[(0,E.jsx)(`path`,{d:`M20 11a8 8 0 1 0-2.3 5.7`}),(0,E.jsx)(`path`,{d:`M20 5v6h-6`})]})}function Q(e){return(0,E.jsxs)(Z,{...e,children:[(0,E.jsx)(`rect`,{x:`3.5`,y:`5`,width:`17`,height:`14`,rx:`2`}),(0,E.jsx)(`path`,{d:`M3.5 9h17`}),(0,E.jsx)(`path`,{d:`M6.5 7h.01M8.5 7h.01`})]})}function se(e){return(0,E.jsxs)(Z,{...e,children:[(0,E.jsx)(`path`,{d:`M7 3h7l4 4v14H7z`}),(0,E.jsx)(`path`,{d:`M14 3v4h4`}),(0,E.jsx)(`path`,{d:`M9.5 12h5M9.5 15h5M9.5 9h2`})]})}function ce(e){return(0,E.jsxs)(Z,{...e,children:[(0,E.jsx)(`rect`,{x:`3`,y:`8`,width:`18`,height:`9`,rx:`4.5`}),(0,E.jsx)(`path`,{d:`M7 11.5v3M5.5 13h3`}),(0,E.jsx)(`path`,{d:`M15.5 12h.01M17.5 14h.01`})]})}function le(e){return(0,E.jsx)(Z,{...e,children:(0,E.jsx)(`path`,{d:`M13 3 5 13h6l-1 8 8-10h-6z`})})}function $(e){return(0,E.jsxs)(Z,{...e,children:[(0,E.jsx)(`path`,{d:`M3 21c0-3 2-4 4-4 1.5 0 2.5 1 2.5 2.5S8 21 6 21z`}),(0,E.jsx)(`path`,{d:`M9 17 19.5 6.5a2.1 2.1 0 0 0-3-3L6 14`})]})}function ue(e){return(0,E.jsxs)(Z,{...e,children:[(0,E.jsx)(`rect`,{x:`5`,y:`4`,width:`14`,height:`17`,rx:`2`}),(0,E.jsx)(`path`,{d:`M9 4.5h6V7H9z`}),(0,E.jsx)(`path`,{d:`m8.5 12 1.5 1.5 2.5-3`}),(0,E.jsx)(`path`,{d:`M14.5 12.5h2`})]})}function de(e){return(0,E.jsxs)(Z,{...e,children:[(0,E.jsx)(`path`,{d:`M12 4v6M9 7h6`}),(0,E.jsx)(`path`,{d:`M6 16.5 7 19l2.5 1L7 21l-1 2.5L5 21l-2.5-1L5 19z`,transform:`translate(0 -3)`}),(0,E.jsx)(`path`,{d:`M17 13l.7 1.8 1.8.7-1.8.7L17 18l-.7-1.8-1.8-.7 1.8-.7z`})]})}var fe={apps:Q,documents:se,games:ce,productivity:le,creative:$,quiz:ue,scratch:de};function pe(e){let{category:t,...n}=e;return(0,E.jsx)(fe[t]??Q,{...n})}function me(e){let t=h(),n=f(),a=r(),p=e.searchQuery.trim().length>0;return(0,b.useEffect)(()=>{n.openMobile&&e.onRefreshRecent?.()},[e.onRefreshRecent,n.openMobile]),(0,E.jsxs)(u,{side:`left`,collapsible:`icon`,children:[(0,E.jsxs)(d,{children:[(0,E.jsxs)(`div`,{className:s.headerRow,children:[(0,E.jsx)(o,{}),(0,E.jsx)(ee,{className:s.sidebarToggle})]}),(0,E.jsxs)(`button`,{type:`button`,className:_.newChatButton,onClick:e.onNewChat,children:[(0,E.jsx)(`span`,{"aria-hidden":`true`,children:`+`}),(0,E.jsx)(`span`,{children:`New Conversation`})]}),(0,E.jsxs)(`button`,{type:`button`,className:_.newChatButton,onClick:()=>a({to:`/apps`}),children:[(0,E.jsx)(`span`,{"aria-hidden":`true`,className:_.navLinkIcon,children:(0,E.jsx)(ae,{})}),(0,E.jsx)(`span`,{children:`Apps`})]}),(0,E.jsx)(`div`,{className:_.sidebarSearchWrap,children:(0,E.jsx)(`input`,{type:`search`,className:_.sidebarSearch,value:e.searchQuery,onChange:t=>e.onSearchQueryChange(t.target.value),placeholder:`Search`,"aria-label":`Search conversations`})})]}),(0,E.jsx)(ne,{children:(0,E.jsx)(he,{...e,isSearching:p})}),(0,E.jsx)(i,{children:(0,E.jsxs)(`div`,{className:s.footerBlock,children:[(0,E.jsx)(c,{version:t.gatewayStatus?.version}),(0,E.jsx)(l,{labelClassName:s.themeToggleLabel})]})})]})}function he(e){return(0,E.jsxs)(`div`,{className:_.chatSidebarContent,children:[(0,E.jsxs)(`div`,{className:_.sidebarListHeader,children:[(0,E.jsx)(`div`,{className:_.sidebarLabel,children:e.isSearching?`Search Results`:`Recent Chats`}),(0,E.jsx)(`div`,{className:_.sidebarScopeToggle,children:[`user`,`all`].map(t=>(0,E.jsx)(`button`,{type:`button`,className:v(_.sidebarScopeButton,e.recentScope===t&&_.sidebarScopeButtonActive),"aria-pressed":e.recentScope===t,onClick:()=>e.onRecentScopeChange(t),children:t===`user`?`User`:`All`},t))})]}),e.isLoading&&e.isSearching?(0,E.jsx)(`div`,{className:_.sidebarStatus,children:`Searching...`}):e.sessions.length===0?(0,E.jsx)(`div`,{className:_.sidebarStatus,children:e.isSearching?`No matching conversations.`:`No recent chats yet.`}):(0,E.jsx)(`ul`,{className:_.sessionList,"aria-live":`polite`,children:e.sessions.map(t=>(0,E.jsx)(`li`,{children:(0,E.jsxs)(`div`,{className:_.sessionItemRow,children:[(0,E.jsxs)(`button`,{type:`button`,className:v(_.sessionItem,t.sessionId===e.activeSessionId&&_.sessionItemActive,t.sessionId===e.activeSessionId&&e.isPending&&_.sessionItemPending),"aria-current":t.sessionId===e.activeSessionId?`page`:void 0,onMouseEnter:()=>e.onHoverSession?.(t.sessionId),onClick:()=>e.onOpenSession(t.sessionId),children:[(0,E.jsx)(`span`,{className:_.sessionTitle,children:t.title||`Untitled`}),t.searchSnippet?(0,E.jsx)(`span`,{className:_.sessionSnippet,children:t.searchSnippet}):null,(0,E.jsx)(`span`,{className:_.sessionTime,children:g(t.lastActive)})]}),(0,E.jsx)(`button`,{type:`button`,className:_.sessionDeleteButton,"aria-label":`Delete ${t.title||`Untitled`} session`,title:`Delete session`,disabled:e.deleteDisabled,onClick:()=>e.onRequestDeleteSession(t),children:(0,E.jsx)(m,{className:_.sessionDeleteIcon})})]})},t.sessionId))})]})}export{S as C,C as S,F as _,R as a,k as b,W as c,B as d,re as f,G as g,U as h,ie as i,X as l,L as m,pe as n,H as o,z as p,oe as r,V as s,me as t,Y as u,I as v,x as w,T as x,j as y};