@agent-native/core 0.5.0-dev.b51eaae → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -43
- package/dist/a2a/agent-card.d.ts.map +1 -1
- package/dist/a2a/agent-card.js +12 -1
- package/dist/a2a/agent-card.js.map +1 -1
- package/dist/a2a/client.d.ts +11 -0
- package/dist/a2a/client.d.ts.map +1 -1
- package/dist/a2a/client.js +38 -1
- package/dist/a2a/client.js.map +1 -1
- package/dist/a2a/index.d.ts +1 -1
- package/dist/a2a/index.d.ts.map +1 -1
- package/dist/a2a/index.js +1 -1
- package/dist/a2a/index.js.map +1 -1
- package/dist/a2a/server.d.ts +4 -0
- package/dist/a2a/server.d.ts.map +1 -1
- package/dist/a2a/server.js +53 -8
- package/dist/a2a/server.js.map +1 -1
- package/dist/a2a/types.d.ts +1 -0
- package/dist/a2a/types.d.ts.map +1 -1
- package/dist/action.d.ts +64 -30
- package/dist/action.d.ts.map +1 -1
- package/dist/action.js +224 -27
- package/dist/action.js.map +1 -1
- package/dist/agent/engine/ai-sdk-engine.d.ts +24 -0
- package/dist/agent/engine/ai-sdk-engine.d.ts.map +1 -0
- package/dist/agent/engine/ai-sdk-engine.js +302 -0
- package/dist/agent/engine/ai-sdk-engine.js.map +1 -0
- package/dist/agent/engine/anthropic-engine.d.ts +24 -0
- package/dist/agent/engine/anthropic-engine.d.ts.map +1 -0
- package/dist/agent/engine/anthropic-engine.js +169 -0
- package/dist/agent/engine/anthropic-engine.js.map +1 -0
- package/dist/agent/engine/builtin.d.ts +12 -0
- package/dist/agent/engine/builtin.d.ts.map +1 -0
- package/dist/agent/engine/builtin.js +72 -0
- package/dist/agent/engine/builtin.js.map +1 -0
- package/dist/agent/engine/index.d.ts +9 -0
- package/dist/agent/engine/index.d.ts.map +1 -0
- package/dist/agent/engine/index.js +8 -0
- package/dist/agent/engine/index.js.map +1 -0
- package/dist/agent/engine/registry.d.ts +61 -0
- package/dist/agent/engine/registry.d.ts.map +1 -0
- package/dist/agent/engine/registry.js +101 -0
- package/dist/agent/engine/registry.js.map +1 -0
- package/dist/agent/engine/translate-ai-sdk.d.ts +20 -0
- package/dist/agent/engine/translate-ai-sdk.d.ts.map +1 -0
- package/dist/agent/engine/translate-ai-sdk.js +174 -0
- package/dist/agent/engine/translate-ai-sdk.js.map +1 -0
- package/dist/agent/engine/translate-anthropic.d.ts +23 -0
- package/dist/agent/engine/translate-anthropic.d.ts.map +1 -0
- package/dist/agent/engine/translate-anthropic.js +140 -0
- package/dist/agent/engine/translate-anthropic.js.map +1 -0
- package/dist/agent/engine/types.d.ts +168 -0
- package/dist/agent/engine/types.d.ts.map +1 -0
- package/dist/agent/engine/types.js +13 -0
- package/dist/agent/engine/types.js.map +1 -0
- package/dist/agent/production-agent.d.ts +48 -2
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +216 -76
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/run-manager.d.ts +1 -1
- package/dist/agent/run-manager.d.ts.map +1 -1
- package/dist/agent/run-manager.js +15 -9
- package/dist/agent/run-manager.js.map +1 -1
- package/dist/agent/run-store.d.ts.map +1 -1
- package/dist/agent/run-store.js +5 -5
- package/dist/agent/run-store.js.map +1 -1
- package/dist/agent/thread-data-builder.d.ts +1 -0
- package/dist/agent/thread-data-builder.d.ts.map +1 -1
- package/dist/agent/thread-data-builder.js +4 -1
- package/dist/agent/thread-data-builder.js.map +1 -1
- package/dist/agent/types.d.ts +22 -1
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/application-state/handlers.d.ts +8 -8
- package/dist/application-state/handlers.d.ts.map +1 -1
- package/dist/application-state/handlers.js +3 -2
- package/dist/application-state/handlers.js.map +1 -1
- package/dist/application-state/script-helpers.d.ts.map +1 -1
- package/dist/application-state/script-helpers.js +47 -9
- package/dist/application-state/script-helpers.js.map +1 -1
- package/dist/chat-threads/store.d.ts +14 -0
- package/dist/chat-threads/store.d.ts.map +1 -1
- package/dist/chat-threads/store.js +32 -0
- package/dist/chat-threads/store.js.map +1 -1
- package/dist/cli/create.d.ts +8 -2
- package/dist/cli/create.d.ts.map +1 -1
- package/dist/cli/create.js +287 -32
- package/dist/cli/create.js.map +1 -1
- package/dist/cli/index.js +19 -6
- package/dist/cli/index.js.map +1 -1
- package/dist/client/AgentPanel.d.ts +5 -1
- package/dist/client/AgentPanel.d.ts.map +1 -1
- package/dist/client/AgentPanel.js +407 -111
- package/dist/client/AgentPanel.js.map +1 -1
- package/dist/client/AgentTaskCard.d.ts +12 -0
- package/dist/client/AgentTaskCard.d.ts.map +1 -0
- package/dist/client/AgentTaskCard.js +146 -0
- package/dist/client/AgentTaskCard.js.map +1 -0
- package/dist/client/AssistantChat.d.ts +13 -2
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +344 -122
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/MultiTabAssistantChat.d.ts +7 -1
- package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
- package/dist/client/MultiTabAssistantChat.js +345 -63
- package/dist/client/MultiTabAssistantChat.js.map +1 -1
- package/dist/client/PoweredByBadge.js +2 -2
- package/dist/client/PoweredByBadge.js.map +1 -1
- package/dist/client/Turnstile.d.ts.map +1 -1
- package/dist/client/Turnstile.js +2 -3
- package/dist/client/Turnstile.js.map +1 -1
- package/dist/client/agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/agent-chat-adapter.js +63 -2
- package/dist/client/agent-chat-adapter.js.map +1 -1
- package/dist/client/agent-chat.d.ts +14 -1
- package/dist/client/agent-chat.d.ts.map +1 -1
- package/dist/client/agent-chat.js +4 -2
- package/dist/client/agent-chat.js.map +1 -1
- package/dist/client/components/CodeAgentIndicator.d.ts +14 -0
- package/dist/client/components/CodeAgentIndicator.d.ts.map +1 -0
- package/dist/client/components/CodeAgentIndicator.js +29 -0
- package/dist/client/components/CodeAgentIndicator.js.map +1 -0
- package/dist/client/composer/MentionPopover.d.ts +4 -1
- package/dist/client/composer/MentionPopover.d.ts.map +1 -1
- package/dist/client/composer/MentionPopover.js +36 -6
- package/dist/client/composer/MentionPopover.js.map +1 -1
- package/dist/client/composer/TiptapComposer.d.ts +8 -1
- package/dist/client/composer/TiptapComposer.d.ts.map +1 -1
- package/dist/client/composer/TiptapComposer.js +146 -16
- package/dist/client/composer/TiptapComposer.js.map +1 -1
- package/dist/client/composer/index.d.ts +1 -1
- package/dist/client/composer/index.d.ts.map +1 -1
- package/dist/client/composer/types.d.ts +5 -0
- package/dist/client/composer/types.d.ts.map +1 -1
- package/dist/client/composer/use-mention-search.d.ts.map +1 -1
- package/dist/client/composer/use-mention-search.js +46 -13
- package/dist/client/composer/use-mention-search.js.map +1 -1
- package/dist/client/frame-protocol.d.ts +54 -0
- package/dist/client/frame-protocol.d.ts.map +1 -0
- package/dist/client/frame-protocol.js +9 -0
- package/dist/client/frame-protocol.js.map +1 -0
- package/dist/client/frame.d.ts +56 -0
- package/dist/client/frame.d.ts.map +1 -0
- package/dist/client/{harness.js → frame.js} +49 -26
- package/dist/client/frame.js.map +1 -0
- package/dist/client/index.d.ts +7 -3
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +6 -3
- package/dist/client/index.js.map +1 -1
- package/dist/client/integrations/IntegrationCard.d.ts +6 -0
- package/dist/client/integrations/IntegrationCard.d.ts.map +1 -0
- package/dist/client/integrations/IntegrationCard.js +45 -0
- package/dist/client/integrations/IntegrationCard.js.map +1 -0
- package/dist/client/integrations/IntegrationsPanel.d.ts +2 -0
- package/dist/client/integrations/IntegrationsPanel.d.ts.map +1 -0
- package/dist/client/integrations/IntegrationsPanel.js +149 -0
- package/dist/client/integrations/IntegrationsPanel.js.map +1 -0
- package/dist/client/integrations/index.d.ts +4 -0
- package/dist/client/integrations/index.d.ts.map +1 -0
- package/dist/client/integrations/index.js +3 -0
- package/dist/client/integrations/index.js.map +1 -0
- package/dist/client/integrations/useIntegrationStatus.d.ts +15 -0
- package/dist/client/integrations/useIntegrationStatus.d.ts.map +1 -0
- package/dist/client/integrations/useIntegrationStatus.js +37 -0
- package/dist/client/integrations/useIntegrationStatus.js.map +1 -0
- package/dist/client/org/InvitationBanner.d.ts +9 -0
- package/dist/client/org/InvitationBanner.d.ts.map +1 -0
- package/dist/client/org/InvitationBanner.js +17 -0
- package/dist/client/org/InvitationBanner.js.map +1 -0
- package/dist/client/org/OrgSwitcher.d.ts +14 -0
- package/dist/client/org/OrgSwitcher.d.ts.map +1 -0
- package/dist/client/org/OrgSwitcher.js +51 -0
- package/dist/client/org/OrgSwitcher.js.map +1 -0
- package/dist/client/org/TeamPage.d.ts +23 -0
- package/dist/client/org/TeamPage.d.ts.map +1 -0
- package/dist/client/org/TeamPage.js +145 -0
- package/dist/client/org/TeamPage.js.map +1 -0
- package/dist/client/org/hooks.d.ts +14 -0
- package/dist/client/org/hooks.d.ts.map +1 -0
- package/dist/client/org/hooks.js +101 -0
- package/dist/client/org/hooks.js.map +1 -0
- package/dist/client/org/index.d.ts +6 -0
- package/dist/client/org/index.d.ts.map +1 -0
- package/dist/client/org/index.js +6 -0
- package/dist/client/org/index.js.map +1 -0
- package/dist/client/resources/ResourceEditor.d.ts +8 -1
- package/dist/client/resources/ResourceEditor.d.ts.map +1 -1
- package/dist/client/resources/ResourceEditor.js +94 -13
- package/dist/client/resources/ResourceEditor.js.map +1 -1
- package/dist/client/resources/ResourceTree.d.ts +5 -1
- package/dist/client/resources/ResourceTree.d.ts.map +1 -1
- package/dist/client/resources/ResourceTree.js +18 -3
- package/dist/client/resources/ResourceTree.js.map +1 -1
- package/dist/client/resources/ResourcesPanel.d.ts.map +1 -1
- package/dist/client/resources/ResourcesPanel.js +135 -110
- package/dist/client/resources/ResourcesPanel.js.map +1 -1
- package/dist/client/resources/use-resources.d.ts +10 -0
- package/dist/client/resources/use-resources.d.ts.map +1 -1
- package/dist/client/resources/use-resources.js +2 -2
- package/dist/client/resources/use-resources.js.map +1 -1
- package/dist/client/sse-event-processor.d.ts +9 -1
- package/dist/client/sse-event-processor.d.ts.map +1 -1
- package/dist/client/sse-event-processor.js +36 -3
- package/dist/client/sse-event-processor.js.map +1 -1
- package/dist/client/terminal/AgentTerminal.d.ts +4 -4
- package/dist/client/terminal/AgentTerminal.d.ts.map +1 -1
- package/dist/client/terminal/AgentTerminal.js +14 -14
- package/dist/client/terminal/AgentTerminal.js.map +1 -1
- package/dist/client/use-action.d.ts +51 -0
- package/dist/client/use-action.d.ts.map +1 -0
- package/dist/client/use-action.js +102 -0
- package/dist/client/use-action.js.map +1 -0
- package/dist/client/use-avatar.d.ts +15 -0
- package/dist/client/use-avatar.d.ts.map +1 -0
- package/dist/client/use-avatar.js +116 -0
- package/dist/client/use-avatar.js.map +1 -0
- package/dist/client/use-chat-threads.d.ts +1 -1
- package/dist/client/use-chat-threads.d.ts.map +1 -1
- package/dist/client/use-chat-threads.js +34 -18
- package/dist/client/use-chat-threads.js.map +1 -1
- package/dist/client/use-dev-mode.d.ts.map +1 -1
- package/dist/client/use-dev-mode.js +2 -0
- package/dist/client/use-dev-mode.js.map +1 -1
- package/dist/client/use-send-to-agent-chat.d.ts +7 -4
- package/dist/client/use-send-to-agent-chat.d.ts.map +1 -1
- package/dist/client/use-send-to-agent-chat.js +31 -10
- package/dist/client/use-send-to-agent-chat.js.map +1 -1
- package/dist/collab/awareness.d.ts +41 -0
- package/dist/collab/awareness.d.ts.map +1 -0
- package/dist/collab/awareness.js +82 -0
- package/dist/collab/awareness.js.map +1 -0
- package/dist/collab/client.d.ts +49 -0
- package/dist/collab/client.d.ts.map +1 -0
- package/dist/collab/client.js +250 -0
- package/dist/collab/client.js.map +1 -0
- package/dist/collab/emitter.d.ts +12 -0
- package/dist/collab/emitter.d.ts.map +1 -0
- package/dist/collab/emitter.js +16 -0
- package/dist/collab/emitter.js.map +1 -0
- package/dist/collab/index.d.ts +7 -0
- package/dist/collab/index.d.ts.map +1 -0
- package/dist/collab/index.js +14 -0
- package/dist/collab/index.js.map +1 -0
- package/dist/collab/routes.d.ts +69 -0
- package/dist/collab/routes.d.ts.map +1 -0
- package/dist/collab/routes.js +98 -0
- package/dist/collab/routes.js.map +1 -0
- package/dist/collab/storage.d.ts +18 -0
- package/dist/collab/storage.d.ts.map +1 -0
- package/dist/collab/storage.js +94 -0
- package/dist/collab/storage.js.map +1 -0
- package/dist/collab/text-to-yjs.d.ts +23 -0
- package/dist/collab/text-to-yjs.d.ts.map +1 -0
- package/dist/collab/text-to-yjs.js +63 -0
- package/dist/collab/text-to-yjs.js.map +1 -0
- package/dist/collab/xml-ops.d.ts +20 -0
- package/dist/collab/xml-ops.d.ts.map +1 -0
- package/dist/collab/xml-ops.js +59 -0
- package/dist/collab/xml-ops.js.map +1 -0
- package/dist/collab/ydoc-manager.d.ts +52 -0
- package/dist/collab/ydoc-manager.d.ts.map +1 -0
- package/dist/collab/ydoc-manager.js +154 -0
- package/dist/collab/ydoc-manager.js.map +1 -0
- package/dist/db/client.d.ts +10 -0
- package/dist/db/client.d.ts.map +1 -1
- package/dist/db/client.js +43 -2
- package/dist/db/client.js.map +1 -1
- package/dist/db/create-get-db.js.map +1 -1
- package/dist/db/index.d.ts +1 -1
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +1 -1
- package/dist/db/index.js.map +1 -1
- package/dist/db/migrations.d.ts +9 -1
- package/dist/db/migrations.d.ts.map +1 -1
- package/dist/db/migrations.js +45 -20
- package/dist/db/migrations.js.map +1 -1
- package/dist/db/schema.d.ts +8 -1
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/db/schema.js +13 -2
- package/dist/db/schema.js.map +1 -1
- package/dist/deploy/build.js +607 -42
- package/dist/deploy/build.js.map +1 -1
- package/dist/deploy/route-discovery.d.ts +17 -4
- package/dist/deploy/route-discovery.d.ts.map +1 -1
- package/dist/deploy/route-discovery.js +117 -35
- package/dist/deploy/route-discovery.js.map +1 -1
- package/dist/index.browser.d.ts +2 -0
- package/dist/index.browser.d.ts.map +1 -1
- package/dist/index.browser.js +4 -0
- package/dist/index.browser.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/integrations/adapters/slack.d.ts +10 -0
- package/dist/integrations/adapters/slack.d.ts.map +1 -0
- package/dist/integrations/adapters/slack.js +215 -0
- package/dist/integrations/adapters/slack.js.map +1 -0
- package/dist/integrations/adapters/telegram.d.ts +12 -0
- package/dist/integrations/adapters/telegram.d.ts.map +1 -0
- package/dist/integrations/adapters/telegram.js +184 -0
- package/dist/integrations/adapters/telegram.js.map +1 -0
- package/dist/integrations/adapters/whatsapp.d.ts +14 -0
- package/dist/integrations/adapters/whatsapp.d.ts.map +1 -0
- package/dist/integrations/adapters/whatsapp.js +205 -0
- package/dist/integrations/adapters/whatsapp.js.map +1 -0
- package/dist/integrations/config-store.d.ts +24 -0
- package/dist/integrations/config-store.d.ts.map +1 -0
- package/dist/integrations/config-store.js +92 -0
- package/dist/integrations/config-store.js.map +1 -0
- package/dist/integrations/index.d.ts +8 -0
- package/dist/integrations/index.d.ts.map +1 -0
- package/dist/integrations/index.js +10 -0
- package/dist/integrations/index.js.map +1 -0
- package/dist/integrations/plugin.d.ts +20 -0
- package/dist/integrations/plugin.d.ts.map +1 -0
- package/dist/integrations/plugin.js +213 -0
- package/dist/integrations/plugin.js.map +1 -0
- package/dist/integrations/thread-mapping-store.d.ts +25 -0
- package/dist/integrations/thread-mapping-store.d.ts.map +1 -0
- package/dist/integrations/thread-mapping-store.js +95 -0
- package/dist/integrations/thread-mapping-store.js.map +1 -0
- package/dist/integrations/types.d.ts +111 -0
- package/dist/integrations/types.d.ts.map +1 -0
- package/dist/integrations/types.js +2 -0
- package/dist/integrations/types.js.map +1 -0
- package/dist/integrations/webhook-handler.d.ts +31 -0
- package/dist/integrations/webhook-handler.d.ts.map +1 -0
- package/dist/integrations/webhook-handler.js +210 -0
- package/dist/integrations/webhook-handler.js.map +1 -0
- package/dist/jobs/cron.d.ts +14 -0
- package/dist/jobs/cron.d.ts.map +1 -0
- package/dist/jobs/cron.js +100 -0
- package/dist/jobs/cron.js.map +1 -0
- package/dist/jobs/index.d.ts +4 -0
- package/dist/jobs/index.d.ts.map +1 -0
- package/dist/jobs/index.js +4 -0
- package/dist/jobs/index.js.map +1 -0
- package/dist/jobs/scheduler.d.ts +29 -0
- package/dist/jobs/scheduler.d.ts.map +1 -0
- package/dist/jobs/scheduler.js +205 -0
- package/dist/jobs/scheduler.js.map +1 -0
- package/dist/jobs/tools.d.ts +3 -0
- package/dist/jobs/tools.d.ts.map +1 -0
- package/dist/jobs/tools.js +192 -0
- package/dist/jobs/tools.js.map +1 -0
- package/dist/mcp/index.d.ts +3 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +2 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/server.d.ts +26 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +182 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/oauth-tokens/index.d.ts +1 -1
- package/dist/oauth-tokens/index.d.ts.map +1 -1
- package/dist/oauth-tokens/index.js +1 -1
- package/dist/oauth-tokens/index.js.map +1 -1
- package/dist/oauth-tokens/store.d.ts +5 -0
- package/dist/oauth-tokens/store.d.ts.map +1 -1
- package/dist/oauth-tokens/store.js +30 -7
- package/dist/oauth-tokens/store.js.map +1 -1
- package/dist/org/context.d.ts +11 -0
- package/dist/org/context.d.ts.map +1 -0
- package/dist/org/context.js +61 -0
- package/dist/org/context.js.map +1 -0
- package/dist/org/handlers.d.ts +66 -0
- package/dist/org/handlers.d.ts.map +1 -0
- package/dist/org/handlers.js +306 -0
- package/dist/org/handlers.js.map +1 -0
- package/dist/org/index.d.ts +7 -0
- package/dist/org/index.d.ts.map +1 -0
- package/dist/org/index.js +11 -0
- package/dist/org/index.js.map +1 -0
- package/dist/org/migrations.d.ts +10 -0
- package/dist/org/migrations.d.ts.map +1 -0
- package/dist/org/migrations.js +39 -0
- package/dist/org/migrations.js.map +1 -0
- package/dist/org/plugin.d.ts +26 -0
- package/dist/org/plugin.d.ts.map +1 -0
- package/dist/org/plugin.js +94 -0
- package/dist/org/plugin.js.map +1 -0
- package/dist/org/schema.d.ts +301 -0
- package/dist/org/schema.d.ts.map +1 -0
- package/dist/org/schema.js +23 -0
- package/dist/org/schema.js.map +1 -0
- package/dist/org/types.d.ts +42 -0
- package/dist/org/types.d.ts.map +1 -0
- package/dist/org/types.js +5 -0
- package/dist/org/types.js.map +1 -0
- package/dist/resources/handlers.d.ts +10 -1
- package/dist/resources/handlers.d.ts.map +1 -1
- package/dist/resources/handlers.js +82 -9
- package/dist/resources/handlers.js.map +1 -1
- package/dist/resources/store.d.ts +5 -0
- package/dist/resources/store.d.ts.map +1 -1
- package/dist/resources/store.js +44 -0
- package/dist/resources/store.js.map +1 -1
- package/dist/scripts/agent-engines/list-agent-engines.d.ts +7 -0
- package/dist/scripts/agent-engines/list-agent-engines.d.ts.map +1 -0
- package/dist/scripts/agent-engines/list-agent-engines.js +42 -0
- package/dist/scripts/agent-engines/list-agent-engines.js.map +1 -0
- package/dist/scripts/agent-engines/set-agent-engine.d.ts +7 -0
- package/dist/scripts/agent-engines/set-agent-engine.d.ts.map +1 -0
- package/dist/scripts/agent-engines/set-agent-engine.js +57 -0
- package/dist/scripts/agent-engines/set-agent-engine.js.map +1 -0
- package/dist/scripts/agent-engines/test-agent-engine.d.ts +7 -0
- package/dist/scripts/agent-engines/test-agent-engine.d.ts.map +1 -0
- package/dist/scripts/agent-engines/test-agent-engine.js +102 -0
- package/dist/scripts/agent-engines/test-agent-engine.js.map +1 -0
- package/dist/scripts/call-agent.d.ts +1 -1
- package/dist/scripts/call-agent.d.ts.map +1 -1
- package/dist/scripts/call-agent.js +10 -6
- package/dist/scripts/call-agent.js.map +1 -1
- package/dist/scripts/chat/index.d.ts +2 -0
- package/dist/scripts/chat/index.d.ts.map +1 -0
- package/dist/scripts/chat/index.js +5 -0
- package/dist/scripts/chat/index.js.map +1 -0
- package/dist/scripts/chat/open-chat.d.ts +11 -0
- package/dist/scripts/chat/open-chat.d.ts.map +1 -0
- package/dist/scripts/chat/open-chat.js +48 -0
- package/dist/scripts/chat/open-chat.js.map +1 -0
- package/dist/scripts/chat/search-chats.d.ts +10 -0
- package/dist/scripts/chat/search-chats.d.ts.map +1 -0
- package/dist/scripts/chat/search-chats.js +89 -0
- package/dist/scripts/chat/search-chats.js.map +1 -0
- package/dist/scripts/core-scripts.d.ts.map +1 -1
- package/dist/scripts/core-scripts.js +2 -0
- package/dist/scripts/core-scripts.js.map +1 -1
- package/dist/scripts/db/check-scoping.d.ts +14 -0
- package/dist/scripts/db/check-scoping.d.ts.map +1 -0
- package/dist/scripts/db/check-scoping.js +174 -0
- package/dist/scripts/db/check-scoping.js.map +1 -0
- package/dist/scripts/db/exec.d.ts +3 -2
- package/dist/scripts/db/exec.d.ts.map +1 -1
- package/dist/scripts/db/exec.js +35 -19
- package/dist/scripts/db/exec.js.map +1 -1
- package/dist/scripts/db/index.d.ts.map +1 -1
- package/dist/scripts/db/index.js +2 -0
- package/dist/scripts/db/index.js.map +1 -1
- package/dist/scripts/db/patch.d.ts +50 -0
- package/dist/scripts/db/patch.d.ts.map +1 -0
- package/dist/scripts/db/patch.js +392 -0
- package/dist/scripts/db/patch.js.map +1 -0
- package/dist/scripts/db/scoping.d.ts +8 -2
- package/dist/scripts/db/scoping.d.ts.map +1 -1
- package/dist/scripts/db/scoping.js +64 -46
- package/dist/scripts/db/scoping.js.map +1 -1
- package/dist/scripts/dev/index.d.ts.map +1 -1
- package/dist/scripts/dev/index.js +64 -1
- package/dist/scripts/dev/index.js.map +1 -1
- package/dist/scripts/parse-args.d.ts +14 -0
- package/dist/scripts/parse-args.d.ts.map +1 -0
- package/dist/scripts/parse-args.js +45 -0
- package/dist/scripts/parse-args.js.map +1 -0
- package/dist/scripts/runner.d.ts.map +1 -1
- package/dist/scripts/runner.js +10 -2
- package/dist/scripts/runner.js.map +1 -1
- package/dist/scripts/utils.d.ts +1 -9
- package/dist/scripts/utils.d.ts.map +1 -1
- package/dist/scripts/utils.js +2 -40
- package/dist/scripts/utils.js.map +1 -1
- package/dist/server/action-discovery.d.ts.map +1 -1
- package/dist/server/action-discovery.js +84 -16
- package/dist/server/action-discovery.js.map +1 -1
- package/dist/server/action-routes.d.ts +15 -0
- package/dist/server/action-routes.d.ts.map +1 -0
- package/dist/server/action-routes.js +105 -0
- package/dist/server/action-routes.js.map +1 -0
- package/dist/server/agent-chat-plugin.d.ts +20 -0
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +1149 -256
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/agent-discovery.d.ts +8 -3
- package/dist/server/agent-discovery.d.ts.map +1 -1
- package/dist/server/agent-discovery.js +69 -8
- package/dist/server/agent-discovery.js.map +1 -1
- package/dist/server/agent-teams.d.ts +70 -0
- package/dist/server/agent-teams.d.ts.map +1 -0
- package/dist/server/agent-teams.js +367 -0
- package/dist/server/agent-teams.js.map +1 -0
- package/dist/server/agents-bundle.d.ts +87 -0
- package/dist/server/agents-bundle.d.ts.map +1 -0
- package/dist/server/agents-bundle.js +231 -0
- package/dist/server/agents-bundle.js.map +1 -0
- package/dist/server/auth-plugin.d.ts +3 -3
- package/dist/server/auth-plugin.d.ts.map +1 -1
- package/dist/server/auth-plugin.js +9 -10
- package/dist/server/auth-plugin.js.map +1 -1
- package/dist/server/auth.d.ts +54 -33
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/auth.js +529 -611
- package/dist/server/auth.js.map +1 -1
- package/dist/server/better-auth-instance.d.ts +72 -0
- package/dist/server/better-auth-instance.d.ts.map +1 -0
- package/dist/server/better-auth-instance.js +144 -0
- package/dist/server/better-auth-instance.js.map +1 -0
- package/dist/server/collab-plugin.d.ts +29 -0
- package/dist/server/collab-plugin.d.ts.map +1 -0
- package/dist/server/collab-plugin.js +85 -0
- package/dist/server/collab-plugin.js.map +1 -0
- package/dist/server/core-routes-plugin.d.ts +0 -3
- package/dist/server/core-routes-plugin.d.ts.map +1 -1
- package/dist/server/core-routes-plugin.js +97 -27
- package/dist/server/core-routes-plugin.js.map +1 -1
- package/dist/server/create-server.d.ts +1 -1
- package/dist/server/create-server.d.ts.map +1 -1
- package/dist/server/create-server.js +39 -16
- package/dist/server/create-server.js.map +1 -1
- package/dist/server/framework-request-handler.d.ts +47 -0
- package/dist/server/framework-request-handler.d.ts.map +1 -0
- package/dist/server/framework-request-handler.js +168 -0
- package/dist/server/framework-request-handler.js.map +1 -0
- package/dist/server/google-auth-plugin.d.ts +4 -0
- package/dist/server/google-auth-plugin.d.ts.map +1 -1
- package/dist/server/google-auth-plugin.js +13 -12
- package/dist/server/google-auth-plugin.js.map +1 -1
- package/dist/server/google-oauth.d.ts +3 -3
- package/dist/server/google-oauth.d.ts.map +1 -1
- package/dist/server/google-oauth.js +40 -18
- package/dist/server/google-oauth.js.map +1 -1
- package/dist/server/h3-helpers.d.ts +23 -0
- package/dist/server/h3-helpers.d.ts.map +1 -0
- package/dist/server/h3-helpers.js +37 -0
- package/dist/server/h3-helpers.js.map +1 -0
- package/dist/server/index.d.ts +9 -4
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +12 -4
- package/dist/server/index.js.map +1 -1
- package/dist/server/local-migration.d.ts +32 -0
- package/dist/server/local-migration.d.ts.map +1 -0
- package/dist/server/local-migration.js +205 -0
- package/dist/server/local-migration.js.map +1 -0
- package/dist/server/oauth-helpers.d.ts +4 -6
- package/dist/server/oauth-helpers.d.ts.map +1 -1
- package/dist/server/oauth-helpers.js +6 -8
- package/dist/server/oauth-helpers.js.map +1 -1
- package/dist/server/onboarding-html.d.ts +24 -0
- package/dist/server/onboarding-html.d.ts.map +1 -0
- package/dist/server/onboarding-html.js +347 -0
- package/dist/server/onboarding-html.js.map +1 -0
- package/dist/server/poll.d.ts +7 -2
- package/dist/server/poll.d.ts.map +1 -1
- package/dist/server/poll.js +48 -1
- package/dist/server/poll.js.map +1 -1
- package/dist/server/resources-plugin.d.ts.map +1 -1
- package/dist/server/resources-plugin.js +4 -3
- package/dist/server/resources-plugin.js.map +1 -1
- package/dist/server/schema-prompt.d.ts +16 -0
- package/dist/server/schema-prompt.d.ts.map +1 -0
- package/dist/server/schema-prompt.js +275 -0
- package/dist/server/schema-prompt.js.map +1 -0
- package/dist/server/sse.d.ts +3 -20
- package/dist/server/sse.d.ts.map +1 -1
- package/dist/server/sse.js +1 -29
- package/dist/server/sse.js.map +1 -1
- package/dist/server/ssr-handler.d.ts +6 -0
- package/dist/server/ssr-handler.d.ts.map +1 -0
- package/dist/server/ssr-handler.js +55 -0
- package/dist/server/ssr-handler.js.map +1 -0
- package/dist/settings/handlers.d.ts +3 -3
- package/dist/settings/handlers.d.ts.map +1 -1
- package/dist/settings/handlers.js +2 -1
- package/dist/settings/handlers.js.map +1 -1
- package/dist/settings/index.d.ts +1 -0
- package/dist/settings/index.d.ts.map +1 -1
- package/dist/settings/index.js +2 -0
- package/dist/settings/index.js.map +1 -1
- package/dist/settings/org-settings.d.ts +22 -0
- package/dist/settings/org-settings.d.ts.map +1 -0
- package/dist/settings/org-settings.js +45 -0
- package/dist/settings/org-settings.js.map +1 -0
- package/dist/shared/agent-chat.d.ts +5 -5
- package/dist/shared/agent-chat.d.ts.map +1 -1
- package/dist/shared/agent-chat.js +8 -8
- package/dist/shared/agent-chat.js.map +1 -1
- package/dist/shared/agent-env.d.ts +1 -1
- package/dist/shared/agent-env.js +1 -1
- package/dist/shared/runtime.d.ts +14 -0
- package/dist/shared/runtime.d.ts.map +1 -0
- package/dist/shared/runtime.js +25 -0
- package/dist/shared/runtime.js.map +1 -0
- package/dist/templates/default/.agents/skills/actions/SKILL.md +142 -0
- package/dist/templates/default/.agents/skills/agent-engines/SKILL.md +127 -0
- package/dist/templates/default/.agents/skills/capture-learnings/SKILL.md +50 -0
- package/dist/templates/default/.agents/skills/create-skill/SKILL.md +167 -0
- package/dist/templates/default/.agents/skills/delegate-to-agent/SKILL.md +90 -0
- package/dist/templates/default/.agents/skills/frontend-design/SKILL.md +69 -0
- package/dist/templates/default/.agents/skills/real-time-collab/SKILL.md +183 -0
- package/dist/templates/default/.agents/skills/real-time-sync/SKILL.md +112 -0
- package/dist/templates/default/.agents/skills/security/SKILL.md +108 -0
- package/dist/templates/default/.agents/skills/self-modifying-code/SKILL.md +79 -0
- package/dist/templates/default/.claude/settings.json +100 -0
- package/dist/templates/default/.env.example +5 -0
- package/dist/templates/default/.prettierrc +5 -0
- package/dist/templates/default/AGENTS.md +110 -0
- package/dist/templates/default/DEVELOPING.md +117 -0
- package/dist/templates/default/_gitignore +37 -0
- package/dist/templates/default/actions/hello.ts +20 -0
- package/dist/templates/default/actions/navigate.ts +53 -0
- package/dist/templates/default/actions/run.ts +2 -0
- package/dist/templates/default/actions/view-screen.ts +39 -0
- package/dist/templates/default/app/entry.client.tsx +4 -0
- package/dist/templates/default/app/entry.server.tsx +56 -0
- package/dist/templates/default/app/global.css +95 -0
- package/dist/templates/default/app/lib/utils.ts +1 -0
- package/dist/templates/default/app/root.tsx +107 -0
- package/dist/templates/default/app/routes/_index.tsx +62 -0
- package/dist/templates/default/app/routes.ts +4 -0
- package/dist/templates/default/app/vite-env.d.ts +6 -0
- package/dist/templates/default/components.json +20 -0
- package/dist/templates/default/data/.gitkeep +0 -0
- package/dist/templates/default/data/sync-config.json +1 -0
- package/dist/templates/default/learnings.defaults.md +5 -0
- package/dist/templates/default/learnings.md +0 -0
- package/dist/templates/default/package.json +46 -0
- package/dist/templates/default/postcss.config.js +6 -0
- package/dist/templates/default/public/icon-180.svg +4 -0
- package/dist/templates/default/public/icon-192.svg +4 -0
- package/dist/templates/default/public/icon-512.svg +4 -0
- package/dist/templates/default/public/manifest.json +13 -0
- package/dist/templates/default/react-router.config.ts +6 -0
- package/dist/templates/default/server/middleware/auth.ts +15 -0
- package/dist/templates/default/server/plugins/.gitkeep +0 -0
- package/dist/templates/default/server/routes/[...page].get.ts +5 -0
- package/dist/templates/default/server/routes/api/hello.get.ts +5 -0
- package/dist/templates/default/shared/api.ts +6 -0
- package/dist/templates/default/ssr-entry.ts +20 -0
- package/dist/templates/default/tailwind.config.ts +7 -0
- package/dist/templates/default/tsconfig.json +11 -0
- package/dist/templates/default/vite.config.ts +6 -0
- package/dist/templates/templates/default/.agents/skills/actions/SKILL.md +142 -0
- package/dist/templates/templates/default/.agents/skills/agent-engines/SKILL.md +127 -0
- package/dist/templates/templates/default/.agents/skills/capture-learnings/SKILL.md +50 -0
- package/dist/templates/templates/default/.agents/skills/create-skill/SKILL.md +167 -0
- package/dist/templates/templates/default/.agents/skills/delegate-to-agent/SKILL.md +90 -0
- package/dist/templates/templates/default/.agents/skills/frontend-design/SKILL.md +69 -0
- package/dist/templates/templates/default/.agents/skills/real-time-collab/SKILL.md +183 -0
- package/dist/templates/templates/default/.agents/skills/real-time-sync/SKILL.md +112 -0
- package/dist/templates/templates/default/.agents/skills/security/SKILL.md +108 -0
- package/dist/templates/templates/default/.agents/skills/self-modifying-code/SKILL.md +79 -0
- package/dist/templates/templates/default/.agents/skills/storing-data/SKILL.md +110 -0
- package/dist/templates/templates/default/.claude/settings.json +100 -0
- package/dist/templates/templates/default/.env.example +5 -0
- package/dist/templates/templates/default/.ignore +0 -0
- package/dist/templates/templates/default/.prettierrc +5 -0
- package/dist/templates/templates/default/AGENTS.md +110 -0
- package/dist/templates/templates/default/DEVELOPING.md +117 -0
- package/dist/templates/templates/default/_gitignore +37 -0
- package/dist/templates/templates/default/actions/hello.ts +20 -0
- package/dist/templates/templates/default/actions/navigate.ts +53 -0
- package/dist/templates/templates/default/actions/run.ts +2 -0
- package/dist/templates/templates/default/actions/view-screen.ts +39 -0
- package/dist/templates/templates/default/app/entry.client.tsx +4 -0
- package/dist/templates/templates/default/app/entry.server.tsx +56 -0
- package/dist/templates/templates/default/app/global.css +95 -0
- package/dist/templates/templates/default/app/lib/utils.ts +1 -0
- package/dist/templates/templates/default/app/root.tsx +107 -0
- package/dist/templates/templates/default/app/routes/_index.tsx +62 -0
- package/dist/templates/templates/default/app/routes.ts +4 -0
- package/dist/templates/templates/default/app/vite-env.d.ts +6 -0
- package/dist/templates/templates/default/components.json +20 -0
- package/dist/templates/templates/default/data/.gitkeep +0 -0
- package/dist/templates/templates/default/data/sync-config.json +1 -0
- package/dist/templates/templates/default/learnings.defaults.md +5 -0
- package/dist/templates/templates/default/learnings.md +0 -0
- package/dist/templates/templates/default/package.json +46 -0
- package/dist/templates/templates/default/postcss.config.js +6 -0
- package/dist/templates/templates/default/public/icon-180.svg +4 -0
- package/dist/templates/templates/default/public/icon-192.svg +4 -0
- package/dist/templates/templates/default/public/icon-512.svg +4 -0
- package/dist/templates/templates/default/public/manifest.json +13 -0
- package/dist/templates/templates/default/react-router.config.ts +6 -0
- package/dist/templates/templates/default/server/middleware/auth.ts +15 -0
- package/dist/templates/templates/default/server/plugins/.gitkeep +0 -0
- package/dist/templates/templates/default/server/routes/[...page].get.ts +5 -0
- package/dist/templates/templates/default/server/routes/api/hello.get.ts +5 -0
- package/dist/templates/templates/default/shared/api.ts +6 -0
- package/dist/templates/templates/default/ssr-entry.ts +20 -0
- package/dist/templates/templates/default/tailwind.config.ts +7 -0
- package/dist/templates/templates/default/tsconfig.json +11 -0
- package/dist/templates/templates/default/vite.config.ts +6 -0
- package/dist/terminal/cli-registry.d.ts +1 -1
- package/dist/terminal/cli-registry.d.ts.map +1 -1
- package/dist/terminal/cli-registry.js +7 -7
- package/dist/terminal/cli-registry.js.map +1 -1
- package/dist/terminal/pty-server.d.ts +1 -1
- package/dist/terminal/pty-server.d.ts.map +1 -1
- package/dist/terminal/pty-server.js +34 -12
- package/dist/terminal/pty-server.js.map +1 -1
- package/dist/terminal/terminal-plugin.d.ts +0 -9
- package/dist/terminal/terminal-plugin.d.ts.map +1 -1
- package/dist/terminal/terminal-plugin.js +57 -14
- package/dist/terminal/terminal-plugin.js.map +1 -1
- package/dist/usage/store.d.ts +29 -0
- package/dist/usage/store.d.ts.map +1 -0
- package/dist/usage/store.js +102 -0
- package/dist/usage/store.js.map +1 -0
- package/dist/vite/action-types-plugin.d.ts +13 -0
- package/dist/vite/action-types-plugin.d.ts.map +1 -0
- package/dist/vite/action-types-plugin.js +132 -0
- package/dist/vite/action-types-plugin.js.map +1 -0
- package/dist/vite/agents-bundle-plugin.d.ts +3 -0
- package/dist/vite/agents-bundle-plugin.d.ts.map +1 -0
- package/dist/vite/agents-bundle-plugin.js +87 -0
- package/dist/vite/agents-bundle-plugin.js.map +1 -0
- package/dist/vite/client.d.ts +5 -0
- package/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +222 -37
- package/dist/vite/client.js.map +1 -1
- package/dist/vite/index.d.ts +2 -1
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +2 -1
- package/dist/vite/index.js.map +1 -1
- package/package.json +68 -20
- package/src/templates/default/.agents/skills/actions/SKILL.md +12 -6
- package/src/templates/default/.agents/skills/agent-engines/SKILL.md +127 -0
- package/src/templates/default/.agents/skills/real-time-collab/SKILL.md +183 -0
- package/src/templates/default/.agents/skills/security/SKILL.md +108 -0
- package/src/templates/default/.agents/skills/storing-data/SKILL.md +110 -0
- package/src/templates/default/.claude/settings.json +13 -0
- package/src/templates/default/AGENTS.md +25 -9
- package/src/templates/default/actions/view-screen.ts +1 -1
- package/src/templates/default/package.json +2 -2
- package/src/templates/default/server/middleware/auth.ts +15 -0
- package/src/templates/default/server/routes/[...page].get.ts +2 -9
- package/src/templates/default/ssr-entry.ts +20 -0
- package/dist/adapters/convex/adapter.d.ts +0 -24
- package/dist/adapters/convex/adapter.d.ts.map +0 -1
- package/dist/adapters/convex/adapter.js +0 -125
- package/dist/adapters/convex/adapter.js.map +0 -1
- package/dist/adapters/convex/index.d.ts +0 -4
- package/dist/adapters/convex/index.d.ts.map +0 -1
- package/dist/adapters/convex/index.js +0 -3
- package/dist/adapters/convex/index.js.map +0 -1
- package/dist/adapters/drizzle/adapter.d.ts +0 -36
- package/dist/adapters/drizzle/adapter.d.ts.map +0 -1
- package/dist/adapters/drizzle/adapter.js +0 -210
- package/dist/adapters/drizzle/adapter.js.map +0 -1
- package/dist/adapters/drizzle/index.d.ts +0 -3
- package/dist/adapters/drizzle/index.d.ts.map +0 -1
- package/dist/adapters/drizzle/index.js +0 -3
- package/dist/adapters/drizzle/index.js.map +0 -1
- package/dist/adapters/drizzle/schema.d.ts +0 -146
- package/dist/adapters/drizzle/schema.d.ts.map +0 -1
- package/dist/adapters/drizzle/schema.js +0 -20
- package/dist/adapters/drizzle/schema.js.map +0 -1
- package/dist/adapters/firestore/adapter.d.ts +0 -48
- package/dist/adapters/firestore/adapter.d.ts.map +0 -1
- package/dist/adapters/firestore/adapter.js +0 -62
- package/dist/adapters/firestore/adapter.js.map +0 -1
- package/dist/adapters/firestore/index.d.ts +0 -4
- package/dist/adapters/firestore/index.d.ts.map +0 -1
- package/dist/adapters/firestore/index.js +0 -3
- package/dist/adapters/firestore/index.js.map +0 -1
- package/dist/adapters/supabase/adapter.d.ts +0 -43
- package/dist/adapters/supabase/adapter.d.ts.map +0 -1
- package/dist/adapters/supabase/adapter.js +0 -137
- package/dist/adapters/supabase/adapter.js.map +0 -1
- package/dist/adapters/supabase/index.d.ts +0 -3
- package/dist/adapters/supabase/index.d.ts.map +0 -1
- package/dist/adapters/supabase/index.js +0 -3
- package/dist/adapters/supabase/index.js.map +0 -1
- package/dist/adapters/sync/config.d.ts +0 -40
- package/dist/adapters/sync/config.d.ts.map +0 -1
- package/dist/adapters/sync/config.js +0 -209
- package/dist/adapters/sync/config.js.map +0 -1
- package/dist/adapters/sync/create-file-sync.d.ts +0 -32
- package/dist/adapters/sync/create-file-sync.d.ts.map +0 -1
- package/dist/adapters/sync/create-file-sync.js +0 -218
- package/dist/adapters/sync/create-file-sync.js.map +0 -1
- package/dist/adapters/sync/file-sync.d.ts +0 -94
- package/dist/adapters/sync/file-sync.d.ts.map +0 -1
- package/dist/adapters/sync/file-sync.js +0 -671
- package/dist/adapters/sync/file-sync.js.map +0 -1
- package/dist/adapters/sync/index.d.ts +0 -6
- package/dist/adapters/sync/index.d.ts.map +0 -1
- package/dist/adapters/sync/index.js +0 -6
- package/dist/adapters/sync/index.js.map +0 -1
- package/dist/adapters/sync/merge.d.ts +0 -21
- package/dist/adapters/sync/merge.d.ts.map +0 -1
- package/dist/adapters/sync/merge.js +0 -132
- package/dist/adapters/sync/merge.js.map +0 -1
- package/dist/adapters/sync/types.d.ts +0 -62
- package/dist/adapters/sync/types.d.ts.map +0 -1
- package/dist/adapters/sync/types.js +0 -23
- package/dist/adapters/sync/types.js.map +0 -1
- package/dist/client/harness.d.ts +0 -48
- package/dist/client/harness.d.ts.map +0 -1
- package/dist/client/harness.js.map +0 -1
- package/dist/client/use-file-sync-status.d.ts +0 -21
- package/dist/client/use-file-sync-status.d.ts.map +0 -1
- package/dist/client/use-file-sync-status.js +0 -65
- package/dist/client/use-file-sync-status.js.map +0 -1
- package/dist/server/default-watcher.d.ts +0 -23
- package/dist/server/default-watcher.d.ts.map +0 -1
- package/dist/server/default-watcher.js +0 -57
- package/dist/server/default-watcher.js.map +0 -1
- package/dist/server/file-sync-plugin.d.ts +0 -7
- package/dist/server/file-sync-plugin.d.ts.map +0 -1
- package/dist/server/file-sync-plugin.js +0 -38
- package/dist/server/file-sync-plugin.js.map +0 -1
- package/dist/vite/dev-api-server.d.ts +0 -10
- package/dist/vite/dev-api-server.d.ts.map +0 -1
- package/dist/vite/dev-api-server.js +0 -243
- package/dist/vite/dev-api-server.js.map +0 -1
- /package/{src/templates/default/.agents/skills/files-as-database → dist/templates/default/.agents/skills/storing-data}/SKILL.md +0 -0
- /package/{src/templates/default/application-state/.gitkeep → dist/templates/default/.ignore} +0 -0
|
@@ -4,11 +4,13 @@ import { AssistantRuntimeProvider, useLocalRuntime, useThreadRuntime, useThread,
|
|
|
4
4
|
import { SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, CompositeAttachmentAdapter, } from "@assistant-ui/react";
|
|
5
5
|
import { MarkdownTextPrimitive } from "@assistant-ui/react-markdown";
|
|
6
6
|
import ReactMarkdown from "react-markdown";
|
|
7
|
+
import remarkGfm from "remark-gfm";
|
|
7
8
|
import { createAgentChatAdapter } from "./agent-chat-adapter.js";
|
|
8
9
|
import { readSSEStreamRaw } from "./sse-event-processor.js";
|
|
9
10
|
import { cn } from "./utils.js";
|
|
11
|
+
import { AgentTaskCard } from "./AgentTaskCard.js";
|
|
10
12
|
import { TiptapComposer, } from "./composer/TiptapComposer.js";
|
|
11
|
-
import { IconSparkles, IconX, IconPlayerStop, IconCheck, IconChevronDown, IconCopy, IconTerminal, IconLoader2, IconCircleX, IconSquareFilled, IconClock, IconFile, IconFolder, IconFileText, IconCheckbox, IconMail, IconUser, IconPresentation, IconStack2, IconMessageChatbot, } from "@tabler/icons-react";
|
|
13
|
+
import { IconSparkles, IconX, IconPlayerStop, IconCheck, IconChevronDown, IconCopy, IconTerminal, IconLoader2, IconCircleX, IconSquareFilled, IconClock, IconFile, IconFolder, IconFileText, IconCheckbox, IconMail, IconUser, IconPresentation, IconStack2, IconMessageChatbot, IconLock, } from "@tabler/icons-react";
|
|
12
14
|
// ─── Markdown Text ──────────────────────────────────────────────────────────
|
|
13
15
|
const markdownStyles = `
|
|
14
16
|
.agent-markdown > :first-child { margin-top: 0; }
|
|
@@ -45,7 +47,7 @@ function MarkdownText() {
|
|
|
45
47
|
useEffect(() => {
|
|
46
48
|
injectMarkdownStyles();
|
|
47
49
|
}, []);
|
|
48
|
-
return (_jsx(MarkdownTextPrimitive, { smooth: true, className: "agent-markdown break-words" }));
|
|
50
|
+
return (_jsx(MarkdownTextPrimitive, { smooth: true, className: "agent-markdown break-words", remarkPlugins: [remarkGfm] }));
|
|
49
51
|
}
|
|
50
52
|
// ─── Composer Attachment Preview ─────────────────────────────────────────────
|
|
51
53
|
function getImageAttachmentSrc(attachment) {
|
|
@@ -85,58 +87,49 @@ function ComposerAttachmentPreviewStrip() {
|
|
|
85
87
|
return null;
|
|
86
88
|
return (_jsx("div", { className: "flex flex-wrap gap-2 px-2 pt-2", children: attachments.map((attachment) => (_jsx(ComposerAttachmentPreviewCard, { attachment: attachment, onRemove: handleRemove }, attachment.id))) }));
|
|
87
89
|
}
|
|
88
|
-
// ─── Tool Call
|
|
89
|
-
|
|
90
|
+
// ─── Tool Call Display ──────────────────────────────────────────────────────
|
|
91
|
+
// Shared presentational component for rendering a tool call pill + result.
|
|
92
|
+
// Used by both the normal message path (ToolCallFallback) and the reconnect
|
|
93
|
+
// stream path (ReconnectStreamMessage). All state is passed as props — no
|
|
94
|
+
// assistant-ui hooks here.
|
|
95
|
+
function ToolCallDisplay({ toolName, argsText, args, result, isRunning, }) {
|
|
90
96
|
const streamRef = useRef(null);
|
|
91
|
-
const thread = useThread();
|
|
92
|
-
const isRunning = result === undefined && thread.isRunning;
|
|
93
97
|
const isAgentCall = toolName.startsWith("agent:");
|
|
94
|
-
// Agent calls default to expanded; regular tools default to collapsed
|
|
95
98
|
const [expanded, setExpanded] = useState(isAgentCall);
|
|
96
99
|
const agentName = isAgentCall ? toolName.slice(6) : null;
|
|
97
100
|
const isAgentError = isAgentCall && result === "Error calling agent";
|
|
98
|
-
// For agent calls, argsText holds the streaming response text
|
|
99
101
|
const agentStreamText = isAgentCall ? (argsText ?? "") : "";
|
|
100
102
|
const hasStreamText = agentStreamText.length > 0;
|
|
101
|
-
|
|
102
|
-
? ""
|
|
103
|
-
: Object.entries(args)
|
|
104
|
-
.map(([k, v]) => `${k}=${typeof v === "string" ? v : JSON.stringify(v)}`)
|
|
105
|
-
.join(", ");
|
|
106
|
-
const displayName = isAgentCall
|
|
107
|
-
? isRunning
|
|
108
|
-
? `Asking ${agentName}...`
|
|
109
|
-
: isAgentError
|
|
110
|
-
? `Error asking ${agentName}`
|
|
111
|
-
: `Asked ${agentName}`
|
|
112
|
-
: toolName;
|
|
113
|
-
// Agent calls expand only when there's text to show, toggleable when done
|
|
114
|
-
const canExpand = isAgentCall ? hasStreamText : result !== undefined;
|
|
115
|
-
const isExpanded = isAgentCall ? hasStreamText && expanded : expanded;
|
|
116
|
-
// Auto-scroll streaming text to bottom as new content arrives
|
|
103
|
+
// NOTE: All hooks must be above any conditional returns
|
|
117
104
|
useEffect(() => {
|
|
118
105
|
if (isAgentCall && isRunning && streamRef.current) {
|
|
119
106
|
streamRef.current.scrollTop = streamRef.current.scrollHeight;
|
|
120
107
|
}
|
|
121
108
|
}, [agentStreamText, isAgentCall, isRunning]);
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
109
|
+
// Render spawn-task as AgentTaskCard once the result is available
|
|
110
|
+
if (toolName === "spawn-task" && result) {
|
|
111
|
+
try {
|
|
112
|
+
const parsed = JSON.parse(result);
|
|
113
|
+
if (parsed.taskId && parsed.threadId) {
|
|
114
|
+
return (_jsx(AgentTaskCard, { taskId: parsed.taskId, threadId: parsed.threadId, description: parsed.description ||
|
|
115
|
+
args?.task ||
|
|
116
|
+
"Sub-agent task", onOpen: (tid) => {
|
|
117
|
+
window.dispatchEvent(new CustomEvent("agent-task-open", {
|
|
118
|
+
detail: {
|
|
119
|
+
threadId: tid,
|
|
120
|
+
description: parsed.description ||
|
|
121
|
+
args?.task ||
|
|
122
|
+
"",
|
|
123
|
+
name: parsed.name || "",
|
|
124
|
+
},
|
|
125
|
+
}));
|
|
126
|
+
} }));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
// Fall through to default pill rendering
|
|
131
|
+
}
|
|
132
|
+
}
|
|
140
133
|
const argsStr = isAgentCall
|
|
141
134
|
? ""
|
|
142
135
|
: Object.entries(args)
|
|
@@ -151,28 +144,35 @@ function ReconnectStreamToolCall({ toolName, argsText, args, result, }) {
|
|
|
151
144
|
: toolName;
|
|
152
145
|
const canExpand = isAgentCall ? hasStreamText : result !== undefined;
|
|
153
146
|
const isExpanded = isAgentCall ? hasStreamText && expanded : expanded;
|
|
154
|
-
useEffect(() => {
|
|
155
|
-
if (isAgentCall && isRunning && streamRef.current) {
|
|
156
|
-
streamRef.current.scrollTop = streamRef.current.scrollHeight;
|
|
157
|
-
}
|
|
158
|
-
}, [agentStreamText, isAgentCall, isRunning]);
|
|
159
147
|
return (_jsxs("div", { className: "my-1 overflow-hidden", children: [_jsxs("button", { onClick: () => canExpand && setExpanded(!isExpanded), className: cn("flex items-center gap-2 rounded-md px-2.5 py-1.5 text-xs font-mono w-full text-left overflow-hidden", isRunning
|
|
160
148
|
? "bg-muted text-muted-foreground"
|
|
161
|
-
: "bg-muted text-muted-foreground hover:bg-accent"), children: [_jsx("span", { className: "shrink-0", children: isRunning ? (_jsx(IconLoader2, { className: "h-3 w-3 animate-spin" })) : isAgentError ? (_jsx(IconCircleX, { className: "h-3 w-3 text-destructive" })) : (_jsx(IconCheck, { className: "h-3 w-3 text-emerald-500" })) }), _jsxs("span", { className: "truncate min-w-0", children: [_jsx("span", { className: "font-medium", children: displayName }), argsStr && _jsxs("span", { className: "opacity-60 ml-1", children: ["(", argsStr, ")"] })] }), canExpand && !isRunning && (_jsx(IconChevronDown, { className: cn("ml-auto h-3 w-3 shrink-0 opacity-40", isExpanded && "rotate-180") }))] }), isExpanded && isAgentCall && hasStreamText && (_jsx("div", { ref: streamRef, className: "mt-1 rounded-md bg-muted/50 px-3 py-2 text-xs text-muted-foreground break-words max-h-48 overflow-y-auto agent-markdown prose prose-sm prose-invert max-w-none", children: _jsx(ReactMarkdown, { children: agentStreamText }) })), isExpanded && !isAgentCall && result !== undefined && (_jsx("div", { className: "mt-1 rounded-md bg-muted/50 px-3 py-2 text-xs font-mono text-muted-foreground whitespace-pre-wrap break-all max-h-48 overflow-y-auto", children: typeof result === "string"
|
|
149
|
+
: "bg-muted text-muted-foreground hover:bg-accent"), children: [_jsx("span", { className: "shrink-0", children: isRunning ? (_jsx(IconLoader2, { className: "h-3 w-3 animate-spin" })) : isAgentError ? (_jsx(IconCircleX, { className: "h-3 w-3 text-destructive" })) : result !== undefined ? (_jsx(IconCheck, { className: "h-3 w-3 text-emerald-500" })) : (_jsx(IconSquareFilled, { className: "h-3 w-3 text-muted-foreground" })) }), _jsxs("span", { className: "truncate min-w-0", children: [_jsx("span", { className: "font-medium", children: displayName }), argsStr && _jsxs("span", { className: "opacity-60 ml-1", children: ["(", argsStr, ")"] })] }), canExpand && !isRunning && (_jsx(IconChevronDown, { className: cn("ml-auto h-3 w-3 shrink-0 opacity-40", isExpanded && "rotate-180") }))] }), isExpanded && isAgentCall && hasStreamText && (_jsx("div", { ref: streamRef, className: "mt-1 rounded-md bg-muted/50 px-3 py-2 text-xs text-muted-foreground break-words max-h-48 overflow-y-auto agent-markdown prose prose-sm prose-invert max-w-none", children: _jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], children: agentStreamText }) })), isExpanded && !isAgentCall && result !== undefined && (_jsx("div", { className: "mt-1 rounded-md bg-muted/50 px-3 py-2 text-xs font-mono text-muted-foreground whitespace-pre-wrap break-all max-h-48 overflow-y-auto", children: typeof result === "string"
|
|
162
150
|
? result
|
|
163
151
|
: JSON.stringify(result, null, 2) }))] }));
|
|
164
152
|
}
|
|
153
|
+
function ToolCallFallback({ toolName, args, argsText, result, }) {
|
|
154
|
+
const thread = useThread();
|
|
155
|
+
const isRunning = result === undefined && thread.isRunning;
|
|
156
|
+
return (_jsx(ToolCallDisplay, { toolName: toolName, args: args, argsText: argsText, result: typeof result === "string"
|
|
157
|
+
? result
|
|
158
|
+
: result !== undefined
|
|
159
|
+
? JSON.stringify(result)
|
|
160
|
+
: undefined, isRunning: isRunning }));
|
|
161
|
+
}
|
|
162
|
+
// ─── Reconnect Stream Message ───────────────────────────────────────────────
|
|
163
|
+
// Renders the agent's in-progress response during reconnection (outside
|
|
164
|
+
// assistant-ui's runtime). Uses the same visual styling as normal messages.
|
|
165
165
|
function ReconnectStreamMessage({ content }) {
|
|
166
166
|
const endRef = useRef(null);
|
|
167
167
|
useEffect(() => {
|
|
168
168
|
endRef.current?.scrollIntoView({ behavior: "smooth", block: "end" });
|
|
169
169
|
}, [content]);
|
|
170
|
-
return (_jsx("div", { className: "flex justify-start
|
|
170
|
+
return (_jsx("div", { className: "flex justify-start", children: _jsxs("div", { className: "max-w-[95%] text-sm leading-relaxed text-foreground space-y-1", children: [content.map((part, i) => {
|
|
171
171
|
if (part.type === "text") {
|
|
172
|
-
return (_jsx("div", { className: "
|
|
172
|
+
return (_jsx("div", { className: "agent-markdown break-words", children: _jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], children: part.text }) }, `reconnect-text-${i}`));
|
|
173
173
|
}
|
|
174
174
|
if (part.type === "tool-call") {
|
|
175
|
-
return (_jsx(
|
|
175
|
+
return (_jsx(ToolCallDisplay, { toolName: part.toolName, argsText: part.argsText, args: part.args, result: part.result, isRunning: part.result === undefined }, `reconnect-tool-${i}`));
|
|
176
176
|
}
|
|
177
177
|
return null;
|
|
178
178
|
}), _jsx("div", { ref: endRef })] }) }));
|
|
@@ -208,17 +208,21 @@ function MentionChipIcon({ icon }) {
|
|
|
208
208
|
const richMentionPattern = /@\[([^\]|]+)\|([^\]]+)\]/g;
|
|
209
209
|
const plainMentionPattern = /((?:^|(?<=\s))@(\w+))/g;
|
|
210
210
|
function UserMessageText({ text }) {
|
|
211
|
+
// Strip injected <context>...</context> blocks before display
|
|
212
|
+
const displayText = text
|
|
213
|
+
.replace(/<context>[\s\S]*?<\/context>\n?/g, "")
|
|
214
|
+
.trim();
|
|
211
215
|
const parts = [];
|
|
212
216
|
let lastIndex = 0;
|
|
213
217
|
let match;
|
|
214
218
|
let hasRichMentions = false;
|
|
215
219
|
// First try rich mentions (@[label|icon])
|
|
216
220
|
richMentionPattern.lastIndex = 0;
|
|
217
|
-
while ((match = richMentionPattern.exec(
|
|
221
|
+
while ((match = richMentionPattern.exec(displayText)) !== null) {
|
|
218
222
|
hasRichMentions = true;
|
|
219
223
|
const matchStart = match.index;
|
|
220
224
|
if (matchStart > lastIndex) {
|
|
221
|
-
parts.push(
|
|
225
|
+
parts.push(displayText.slice(lastIndex, matchStart));
|
|
222
226
|
}
|
|
223
227
|
const label = match[1];
|
|
224
228
|
const icon = match[2];
|
|
@@ -226,26 +230,37 @@ function UserMessageText({ text }) {
|
|
|
226
230
|
lastIndex = matchStart + match[0].length;
|
|
227
231
|
}
|
|
228
232
|
if (hasRichMentions) {
|
|
229
|
-
if (lastIndex <
|
|
230
|
-
parts.push(
|
|
233
|
+
if (lastIndex < displayText.length) {
|
|
234
|
+
parts.push(displayText.slice(lastIndex));
|
|
231
235
|
}
|
|
232
236
|
return _jsx(_Fragment, { children: parts });
|
|
233
237
|
}
|
|
234
238
|
// Fallback: plain @word mentions (for older messages)
|
|
235
239
|
plainMentionPattern.lastIndex = 0;
|
|
236
|
-
while ((match = plainMentionPattern.exec(
|
|
240
|
+
while ((match = plainMentionPattern.exec(displayText)) !== null) {
|
|
237
241
|
const matchStart = match.index;
|
|
238
242
|
if (matchStart > lastIndex) {
|
|
239
|
-
parts.push(
|
|
243
|
+
parts.push(displayText.slice(lastIndex, matchStart));
|
|
240
244
|
}
|
|
241
245
|
const mentionName = match[2];
|
|
242
246
|
parts.push(_jsxs("span", { className: "inline-flex items-center gap-1 rounded-md border border-input bg-muted/50 px-1.5 py-0.5 text-xs font-medium text-foreground align-middle mx-0.5 select-all", "data-mention-label": mentionName, children: ["@", mentionName] }, matchStart));
|
|
243
247
|
lastIndex = matchStart + match[0].length;
|
|
244
248
|
}
|
|
245
|
-
if (lastIndex <
|
|
246
|
-
parts.push(
|
|
249
|
+
if (lastIndex < displayText.length) {
|
|
250
|
+
parts.push(displayText.slice(lastIndex));
|
|
247
251
|
}
|
|
248
|
-
return _jsx(_Fragment, { children: parts.length > 0 ? parts :
|
|
252
|
+
return _jsx(_Fragment, { children: parts.length > 0 ? parts : displayText });
|
|
253
|
+
}
|
|
254
|
+
function UserMessageAttachments() {
|
|
255
|
+
const messageRuntime = useMessageRuntime();
|
|
256
|
+
const msg = messageRuntime.getState();
|
|
257
|
+
// Content parts may include image/file types from attachments
|
|
258
|
+
const parts = msg.content;
|
|
259
|
+
const images = parts.filter((p) => p.type === "image" && p.image);
|
|
260
|
+
const files = parts.filter((p) => p.type === "file");
|
|
261
|
+
if (images.length === 0 && files.length === 0)
|
|
262
|
+
return null;
|
|
263
|
+
return (_jsxs("div", { className: "flex flex-wrap justify-end gap-1.5 mb-1.5", children: [images.map((img, i) => (_jsx("div", { className: "h-16 w-16 overflow-hidden rounded-lg border border-border/70 bg-muted/50", children: _jsx("img", { src: img.image, alt: "attachment", className: "h-full w-full object-cover" }) }, i))), files.map((file, i) => (_jsxs("div", { className: "flex items-center gap-1.5 rounded-lg border border-border/70 bg-muted/50 px-2 py-1.5 text-xs text-muted-foreground", children: [_jsx(IconFile, { className: "h-3.5 w-3.5 shrink-0" }), _jsx("span", { className: "truncate max-w-[120px]", children: file.name || "file" })] }, `f-${i}`)))] }));
|
|
249
264
|
}
|
|
250
265
|
function UserMessage() {
|
|
251
266
|
const [expanded, setExpanded] = useState(false);
|
|
@@ -263,7 +278,7 @@ function UserMessage() {
|
|
|
263
278
|
observer.observe(el);
|
|
264
279
|
return () => observer.disconnect();
|
|
265
280
|
}, []);
|
|
266
|
-
return (_jsx("div", { className: "flex justify-end", style: { contentVisibility: "auto" }, children: _jsxs("div", { className: "max-w-[85%]", children: [_jsxs("div", { className: "relative rounded-lg bg-accent px-3 py-2 text-sm leading-relaxed text-foreground", onCopy: (e) => {
|
|
281
|
+
return (_jsx("div", { className: "flex justify-end", style: { contentVisibility: "auto" }, children: _jsxs("div", { className: "max-w-[85%]", children: [_jsx(UserMessageAttachments, {}), _jsxs("div", { className: "relative rounded-lg bg-accent px-3 py-2 text-sm leading-relaxed text-foreground", onCopy: (e) => {
|
|
267
282
|
const selection = window.getSelection();
|
|
268
283
|
if (!selection || selection.rangeCount === 0)
|
|
269
284
|
return;
|
|
@@ -309,10 +324,10 @@ function AssistantMessage() {
|
|
|
309
324
|
}
|
|
310
325
|
// ─── Thinking Indicator ─────────────────────────────────────────────────────
|
|
311
326
|
function ThinkingIndicator() {
|
|
312
|
-
const [dots, setDots] = useState(
|
|
327
|
+
const [dots, setDots] = useState(0);
|
|
313
328
|
useEffect(() => {
|
|
314
329
|
const interval = setInterval(() => {
|
|
315
|
-
setDots((d) => (d
|
|
330
|
+
setDots((d) => (d + 1) % 4);
|
|
316
331
|
}, 400);
|
|
317
332
|
return () => clearInterval(interval);
|
|
318
333
|
}, []);
|
|
@@ -360,6 +375,24 @@ function ApiKeySetupCard({ apiUrl }) {
|
|
|
360
375
|
handleSave();
|
|
361
376
|
}, placeholder: "sk-ant-...", className: "w-full rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring", autoComplete: "off" }), error && _jsx("p", { className: "text-xs text-destructive", children: error }), _jsx("button", { onClick: handleSave, disabled: saving || !apiKey.trim(), className: "w-full rounded-md bg-primary px-3 py-2 text-sm font-medium text-primary-foreground hover:opacity-90 disabled:opacity-40 disabled:cursor-not-allowed", children: saving ? "Saving..." : "Save API key" })] })] }));
|
|
362
377
|
}
|
|
378
|
+
// ─── Builder.io CTA Card (usage limit / code changes / CLI) ─────────────────
|
|
379
|
+
export function BuilderCtaCard({ reason, usageCents, limitCents, }) {
|
|
380
|
+
const appName = typeof window !== "undefined"
|
|
381
|
+
? window.location.hostname.split(".")[0]
|
|
382
|
+
: "app";
|
|
383
|
+
const cloneCommand = `npx agent-native create ${appName}`;
|
|
384
|
+
const title = reason === "usage_limit"
|
|
385
|
+
? "Free usage limit reached"
|
|
386
|
+
: reason === "code_changes"
|
|
387
|
+
? "Code changes require a local setup"
|
|
388
|
+
: "Get full access";
|
|
389
|
+
const description = reason === "usage_limit"
|
|
390
|
+
? `You've used $${((usageCents ?? 0) / 100).toFixed(2)} of your $${((limitCents ?? 100) / 100).toFixed(2)} free tier. Connect to Builder.io for unlimited usage, or clone this app to run it locally with your own API key.`
|
|
391
|
+
: reason === "code_changes"
|
|
392
|
+
? "This app is running in hosted mode. To make code changes, connect to Builder.io or clone and run locally."
|
|
393
|
+
: "This hosted app has limited AI features. Connect to Builder.io for the full experience, or clone and run locally with your own API key.";
|
|
394
|
+
return (_jsxs("div", { className: "mx-4 my-6 rounded-lg border border-border bg-card p-5", children: [_jsxs("div", { className: "flex items-center gap-3 mb-3", children: [_jsx("div", { className: "flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-muted", children: _jsx(IconSparkles, { className: "h-4.5 w-4.5 text-muted-foreground" }) }), _jsxs("div", { children: [_jsx("h3", { className: "text-sm font-medium text-foreground", children: title }), _jsx("p", { className: "text-xs text-muted-foreground mt-0.5", children: description })] })] }), _jsxs("div", { className: "space-y-2.5", children: [_jsx("a", { href: "https://www.builder.io/m/agent-native", target: "_blank", rel: "noopener noreferrer", className: "flex w-full items-center justify-center rounded-md bg-primary px-3 py-2 text-sm font-medium text-primary-foreground hover:opacity-90", children: "Connect to Builder.io" }), _jsxs("div", { className: "relative", children: [_jsx("div", { className: "absolute inset-0 flex items-center", children: _jsx("span", { className: "w-full border-t border-border" }) }), _jsx("div", { className: "relative flex justify-center text-xs", children: _jsx("span", { className: "bg-card px-2 text-muted-foreground", children: "or" }) })] }), _jsxs("div", { className: "rounded-md bg-muted/50 px-3 py-2.5", children: [_jsx("p", { className: "text-xs text-muted-foreground mb-1.5", children: "Clone and run locally:" }), _jsx("code", { className: "block text-xs text-foreground/80 font-mono break-all select-all", children: cloneCommand })] })] })] }));
|
|
395
|
+
}
|
|
363
396
|
export const CHAT_STORAGE_PREFIX = "agent-chat:";
|
|
364
397
|
/** Remove persisted chat for a given tabId (or "default"). */
|
|
365
398
|
export function clearChatStorage(tabId) {
|
|
@@ -368,20 +401,55 @@ export function clearChatStorage(tabId) {
|
|
|
368
401
|
}
|
|
369
402
|
catch { }
|
|
370
403
|
}
|
|
404
|
+
/**
|
|
405
|
+
* Ensure all messages in a thread repository have `metadata: {}`.
|
|
406
|
+
* assistant-ui's _getMessageRuntime accesses `message.metadata.submittedFeedback`
|
|
407
|
+
* without null-checking, so server-constructed messages without metadata crash.
|
|
408
|
+
*/
|
|
409
|
+
function ensureMessageMetadata(repo) {
|
|
410
|
+
if (!repo?.messages || !Array.isArray(repo.messages))
|
|
411
|
+
return repo;
|
|
412
|
+
for (const entry of repo.messages) {
|
|
413
|
+
// Handle both wrapped ({ message: { ... } }) and flat ({ role, ... }) formats
|
|
414
|
+
const msg = entry?.message ?? entry;
|
|
415
|
+
if (msg && !msg.metadata) {
|
|
416
|
+
msg.metadata = {};
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
return repo;
|
|
420
|
+
}
|
|
371
421
|
// Re-export for backwards compatibility
|
|
372
422
|
import { extractThreadMeta } from "../agent/thread-data-builder.js";
|
|
373
423
|
export { extractThreadMeta };
|
|
374
|
-
const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateText, suggestions, showHeader = true, onSwitchToCli, className, apiUrl, tabId, threadId, onMessageCountChange, onSaveThread, onGenerateTitle, composerSlot, isNewThread, }, ref) {
|
|
424
|
+
const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateText, suggestions, showHeader = true, onSwitchToCli, className, apiUrl, tabId, threadId, onMessageCountChange, onSaveThread, onGenerateTitle, composerSlot, isNewThread, onSlashCommand, execMode, onExecModeChange, }, ref) {
|
|
375
425
|
const scrollRef = useRef(null);
|
|
376
426
|
const thread = useThread();
|
|
377
427
|
const threadRuntime = useThreadRuntime();
|
|
378
|
-
const
|
|
428
|
+
const isRuntimeRunning = thread.isRunning;
|
|
379
429
|
const messages = thread.messages;
|
|
380
430
|
const [missingApiKey, setMissingApiKey] = useState(false);
|
|
431
|
+
const [authError, setAuthError] = useState(null);
|
|
432
|
+
const [usageLimitReached, setUsageLimitReached] = useState(null);
|
|
381
433
|
const [queuedMessages, setQueuedMessages] = useState([]);
|
|
382
434
|
const [showContinue, setShowContinue] = useState(false);
|
|
383
435
|
const [isReconnecting, setIsReconnecting] = useState(false);
|
|
384
436
|
const [reconnectContent, setReconnectContent] = useState([]);
|
|
437
|
+
// When stop is clicked during reconnect, keep content visible (don't wipe it)
|
|
438
|
+
const [reconnectFrozen, setReconnectFrozen] = useState(false);
|
|
439
|
+
const reconnectRunIdRef = useRef(null);
|
|
440
|
+
const reconnectAbortRef = useRef(null);
|
|
441
|
+
// Nuclear stop: user clicked stop but runtime hasn't cleared yet.
|
|
442
|
+
// This ONLY affects UI display (button + thinking indicator). Submission
|
|
443
|
+
// and queue gating still use the real `isRunning` so we never overlap a
|
|
444
|
+
// new run on top of one that's still cancelling on the server.
|
|
445
|
+
const [forceStopped, setForceStopped] = useState(false);
|
|
446
|
+
// Real running state — drives submission/queue gating. Treat reconnecting
|
|
447
|
+
// to an active run the same as running.
|
|
448
|
+
const isRunning = isRuntimeRunning || isReconnecting;
|
|
449
|
+
// UI-only running state — drives the stop button and thinking indicator.
|
|
450
|
+
// forceStopped lets us flip the indicator off immediately even if the
|
|
451
|
+
// underlying runtime or reconnect state hasn't caught up yet.
|
|
452
|
+
const showRunningInUI = !forceStopped && isRunning;
|
|
385
453
|
const wasRunningRef = useRef(false);
|
|
386
454
|
const tiptapRef = useRef(null);
|
|
387
455
|
// ─── Chat persistence ──────────────────────────────────────────────
|
|
@@ -411,7 +479,7 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
411
479
|
: data.threadData;
|
|
412
480
|
if (repo?.messages?.length > 0) {
|
|
413
481
|
titleGeneratedRef.current = true; // Don't re-generate for restored threads
|
|
414
|
-
threadRuntime.import(repo);
|
|
482
|
+
threadRuntime.import(ensureMessageMetadata(repo));
|
|
415
483
|
}
|
|
416
484
|
}
|
|
417
485
|
// Also skip title generation if thread already has a title
|
|
@@ -423,38 +491,9 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
423
491
|
const runRes = await fetch(`${apiUrl}/runs/active?threadId=${encodeURIComponent(threadId)}`);
|
|
424
492
|
if (runRes.ok) {
|
|
425
493
|
const runInfo = await runRes.json();
|
|
426
|
-
//
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
const streamReconnect = async () => {
|
|
430
|
-
try {
|
|
431
|
-
const sseRes = await fetch(`${apiUrl}/runs/${encodeURIComponent(runInfo.runId)}/events?after=0`);
|
|
432
|
-
if (sseRes.ok && sseRes.body) {
|
|
433
|
-
const content = [];
|
|
434
|
-
const toolCallCounter = { value: 0 };
|
|
435
|
-
// Throttle React state updates via requestAnimationFrame
|
|
436
|
-
let rafPending = false;
|
|
437
|
-
let latestSnapshot = [];
|
|
438
|
-
const scheduleUpdate = (snapshot) => {
|
|
439
|
-
latestSnapshot = snapshot;
|
|
440
|
-
if (!rafPending) {
|
|
441
|
-
rafPending = true;
|
|
442
|
-
requestAnimationFrame(() => {
|
|
443
|
-
rafPending = false;
|
|
444
|
-
setReconnectContent(latestSnapshot);
|
|
445
|
-
});
|
|
446
|
-
}
|
|
447
|
-
};
|
|
448
|
-
await readSSEStreamRaw(sseRes.body, content, toolCallCounter, tabId, scheduleUpdate);
|
|
449
|
-
// Final update with complete content
|
|
450
|
-
setReconnectContent([...content]);
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
catch {
|
|
454
|
-
// Stream error — fall through to re-fetch
|
|
455
|
-
}
|
|
456
|
-
// Run finished — re-fetch thread data from server
|
|
457
|
-
// (server now persists assistant response on completion)
|
|
494
|
+
// If the run already completed, just re-fetch thread data
|
|
495
|
+
// (don't enter "Thinking." reconnection mode)
|
|
496
|
+
if (runInfo.status !== "running") {
|
|
458
497
|
try {
|
|
459
498
|
const refreshRes = await fetch(`${apiUrl}/threads/${encodeURIComponent(threadId)}`);
|
|
460
499
|
if (refreshRes.ok) {
|
|
@@ -464,16 +503,99 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
464
503
|
? JSON.parse(refreshData.threadData)
|
|
465
504
|
: refreshData.threadData;
|
|
466
505
|
if (repo?.messages?.length > 0) {
|
|
467
|
-
threadRuntime.import(repo);
|
|
506
|
+
threadRuntime.import(ensureMessageMetadata(repo));
|
|
468
507
|
}
|
|
469
508
|
}
|
|
470
509
|
}
|
|
471
510
|
}
|
|
472
511
|
catch { }
|
|
512
|
+
// Skip reconnection entirely
|
|
513
|
+
}
|
|
514
|
+
else {
|
|
515
|
+
// Agent is still running — subscribe to live SSE stream
|
|
516
|
+
reconnectRunIdRef.current = runInfo.runId;
|
|
517
|
+
setIsReconnecting(true);
|
|
473
518
|
setReconnectContent([]);
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
519
|
+
// Signal tab running indicator
|
|
520
|
+
window.dispatchEvent(new CustomEvent("builder.chatRunning", {
|
|
521
|
+
detail: { isRunning: true, tabId: tabId || threadId },
|
|
522
|
+
}));
|
|
523
|
+
// Create AbortController before the async call so stop button
|
|
524
|
+
// can abort it even if clicked before the function body runs.
|
|
525
|
+
const abortCtrl = new AbortController();
|
|
526
|
+
reconnectAbortRef.current = abortCtrl;
|
|
527
|
+
const streamReconnect = async () => {
|
|
528
|
+
try {
|
|
529
|
+
const sseRes = await fetch(`${apiUrl}/runs/${encodeURIComponent(runInfo.runId)}/events?after=0`, { signal: abortCtrl.signal });
|
|
530
|
+
if (sseRes.ok && sseRes.body) {
|
|
531
|
+
const content = [];
|
|
532
|
+
const toolCallCounter = { value: 0 };
|
|
533
|
+
// Throttle React state updates via requestAnimationFrame
|
|
534
|
+
let rafPending = false;
|
|
535
|
+
let latestSnapshot = [];
|
|
536
|
+
const scheduleUpdate = (snapshot) => {
|
|
537
|
+
latestSnapshot = snapshot;
|
|
538
|
+
if (!rafPending) {
|
|
539
|
+
rafPending = true;
|
|
540
|
+
requestAnimationFrame(() => {
|
|
541
|
+
rafPending = false;
|
|
542
|
+
setReconnectContent(latestSnapshot);
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
await readSSEStreamRaw(sseRes.body, content, toolCallCounter, tabId, scheduleUpdate);
|
|
547
|
+
// Final update with complete content
|
|
548
|
+
setReconnectContent([...content]);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
catch {
|
|
552
|
+
// Stream error or abort — fall through to re-fetch
|
|
553
|
+
}
|
|
554
|
+
// Poll for thread data — server's updateThreadData may not have
|
|
555
|
+
// committed yet when the SSE `done` event fires, so retry until
|
|
556
|
+
// an assistant message appears (up to ~5 s) before clearing.
|
|
557
|
+
setReconnectFrozen(true);
|
|
558
|
+
let loaded = false;
|
|
559
|
+
for (let attempt = 0; attempt < 10; attempt++) {
|
|
560
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
561
|
+
// If the stop button fired mid-poll, bail out
|
|
562
|
+
if (!reconnectRunIdRef.current)
|
|
563
|
+
break;
|
|
564
|
+
try {
|
|
565
|
+
const refreshRes = await fetch(`${apiUrl}/threads/${encodeURIComponent(threadId)}`);
|
|
566
|
+
if (refreshRes.ok) {
|
|
567
|
+
const refreshData = await refreshRes.json();
|
|
568
|
+
if (refreshData.threadData) {
|
|
569
|
+
const repo = typeof refreshData.threadData === "string"
|
|
570
|
+
? JSON.parse(refreshData.threadData)
|
|
571
|
+
: refreshData.threadData;
|
|
572
|
+
const hasAssistant = repo?.messages?.some((m) => (m.message?.role ?? m.role) === "assistant");
|
|
573
|
+
if (hasAssistant) {
|
|
574
|
+
threadRuntime.import(ensureMessageMetadata(repo));
|
|
575
|
+
setReconnectContent([]);
|
|
576
|
+
setReconnectFrozen(false);
|
|
577
|
+
loaded = true;
|
|
578
|
+
break;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
catch { }
|
|
584
|
+
}
|
|
585
|
+
// Only clean up if the stop button hasn't already done it
|
|
586
|
+
if (reconnectRunIdRef.current) {
|
|
587
|
+
reconnectAbortRef.current = null;
|
|
588
|
+
// If loaded=true, reconnectContent already cleared above.
|
|
589
|
+
// If loaded=false (timeout), keep content frozen so user sees what happened.
|
|
590
|
+
setIsReconnecting(false);
|
|
591
|
+
reconnectRunIdRef.current = null;
|
|
592
|
+
window.dispatchEvent(new CustomEvent("builder.chatRunning", {
|
|
593
|
+
detail: { isRunning: false, tabId: tabId || threadId },
|
|
594
|
+
}));
|
|
595
|
+
}
|
|
596
|
+
};
|
|
597
|
+
streamReconnect();
|
|
598
|
+
} // end else (running)
|
|
477
599
|
}
|
|
478
600
|
}
|
|
479
601
|
catch {
|
|
@@ -496,7 +618,7 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
496
618
|
if (saved) {
|
|
497
619
|
const repo = JSON.parse(saved);
|
|
498
620
|
if (repo?.messages?.length > 0) {
|
|
499
|
-
threadRuntime.import(repo);
|
|
621
|
+
threadRuntime.import(ensureMessageMetadata(repo));
|
|
500
622
|
}
|
|
501
623
|
}
|
|
502
624
|
}
|
|
@@ -529,30 +651,39 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
529
651
|
if (!text.trim())
|
|
530
652
|
return;
|
|
531
653
|
titleGeneratedRef.current = true;
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
654
|
+
if (threadId) {
|
|
655
|
+
onGenerateTitleRef.current?.(threadId, text.trim());
|
|
656
|
+
}
|
|
657
|
+
}, [messages, threadId]);
|
|
658
|
+
// Periodically save thread data while the agent is running so refreshes
|
|
659
|
+
// don't lose messages. Saves every 5 seconds while running.
|
|
536
660
|
const savedTitleRef = useRef("");
|
|
661
|
+
const lastSaveTimeRef = useRef(0);
|
|
537
662
|
useEffect(() => {
|
|
538
663
|
if (!hasRestoredRef.current)
|
|
539
664
|
return;
|
|
665
|
+
if (!isRunning)
|
|
666
|
+
return;
|
|
540
667
|
if (messages.length === 0)
|
|
541
668
|
return;
|
|
542
669
|
if (!threadId || !onSaveThreadRef.current)
|
|
543
670
|
return;
|
|
671
|
+
const now = Date.now();
|
|
672
|
+
const timeSinceLastSave = now - lastSaveTimeRef.current;
|
|
673
|
+
if (timeSinceLastSave < 5000)
|
|
674
|
+
return;
|
|
544
675
|
const repo = threadRuntime.export();
|
|
545
676
|
const { title, preview } = extractThreadMeta(repo);
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
}
|
|
677
|
+
if (!title)
|
|
678
|
+
return;
|
|
679
|
+
lastSaveTimeRef.current = now;
|
|
680
|
+
savedTitleRef.current = title;
|
|
681
|
+
onSaveThreadRef.current(threadId, {
|
|
682
|
+
threadData: JSON.stringify(repo),
|
|
683
|
+
title,
|
|
684
|
+
preview,
|
|
685
|
+
messageCount: messages.length,
|
|
686
|
+
});
|
|
556
687
|
}, [messages, isRunning, threadId, threadRuntime]);
|
|
557
688
|
// Persist full thread data after each completed response
|
|
558
689
|
useEffect(() => {
|
|
@@ -567,7 +698,7 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
567
698
|
// Save to server via the hook callback
|
|
568
699
|
const { title, preview } = extractThreadMeta(repo);
|
|
569
700
|
savedTitleRef.current = title;
|
|
570
|
-
onSaveThreadRef.current({
|
|
701
|
+
onSaveThreadRef.current(threadId, {
|
|
571
702
|
threadData: JSON.stringify(repo),
|
|
572
703
|
title,
|
|
573
704
|
preview,
|
|
@@ -592,6 +723,27 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
592
723
|
window.addEventListener("agent-chat:missing-api-key", handler);
|
|
593
724
|
return () => window.removeEventListener("agent-chat:missing-api-key", handler);
|
|
594
725
|
}, []);
|
|
726
|
+
// Listen for auth error events from the adapter
|
|
727
|
+
useEffect(() => {
|
|
728
|
+
const handler = (e) => {
|
|
729
|
+
const detail = e.detail;
|
|
730
|
+
setAuthError({ sessionExpired: detail?.reason === "session-expired" });
|
|
731
|
+
};
|
|
732
|
+
window.addEventListener("agent-chat:auth-error", handler);
|
|
733
|
+
return () => window.removeEventListener("agent-chat:auth-error", handler);
|
|
734
|
+
}, []);
|
|
735
|
+
// Listen for usage limit reached events from the adapter
|
|
736
|
+
useEffect(() => {
|
|
737
|
+
const handler = (e) => {
|
|
738
|
+
const detail = e.detail;
|
|
739
|
+
setUsageLimitReached({
|
|
740
|
+
usageCents: detail?.usageCents ?? 0,
|
|
741
|
+
limitCents: detail?.limitCents ?? 100,
|
|
742
|
+
});
|
|
743
|
+
};
|
|
744
|
+
window.addEventListener("agent-chat:usage-limit-reached", handler);
|
|
745
|
+
return () => window.removeEventListener("agent-chat:usage-limit-reached", handler);
|
|
746
|
+
}, []);
|
|
595
747
|
// Listen for loop-limit events from the adapter
|
|
596
748
|
useEffect(() => {
|
|
597
749
|
const handler = (e) => {
|
|
@@ -627,6 +779,35 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
627
779
|
}
|
|
628
780
|
wasRunningRef.current = isRunning;
|
|
629
781
|
}, [isRunning, queuedMessages, threadRuntime]);
|
|
782
|
+
// Clear frozen reconnect content + forceStopped only on the false→true
|
|
783
|
+
// transition of isRuntimeRunning (i.e. a NEW run is actually starting).
|
|
784
|
+
// Reacting to "isRuntimeRunning is currently true" would clear the
|
|
785
|
+
// nuclear-stop flag immediately after the user clicks stop, since
|
|
786
|
+
// cancellation is async and isRuntimeRunning is still true at that moment.
|
|
787
|
+
const prevIsRuntimeRunningRef = useRef(isRuntimeRunning);
|
|
788
|
+
useEffect(() => {
|
|
789
|
+
const wasRunning = prevIsRuntimeRunningRef.current;
|
|
790
|
+
prevIsRuntimeRunningRef.current = isRuntimeRunning;
|
|
791
|
+
if (isRuntimeRunning && !wasRunning) {
|
|
792
|
+
if (reconnectFrozen) {
|
|
793
|
+
setReconnectFrozen(false);
|
|
794
|
+
setReconnectContent([]);
|
|
795
|
+
}
|
|
796
|
+
if (forceStopped) {
|
|
797
|
+
setForceStopped(false);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
}, [isRuntimeRunning, reconnectFrozen, forceStopped]);
|
|
801
|
+
// Same transition guard for isReconnecting: only clear forceStopped on
|
|
802
|
+
// the false→true edge (a new reconnect starting on page load).
|
|
803
|
+
const prevIsReconnectingRef = useRef(isReconnecting);
|
|
804
|
+
useEffect(() => {
|
|
805
|
+
const wasReconnecting = prevIsReconnectingRef.current;
|
|
806
|
+
prevIsReconnectingRef.current = isReconnecting;
|
|
807
|
+
if (isReconnecting && !wasReconnecting && forceStopped) {
|
|
808
|
+
setForceStopped(false);
|
|
809
|
+
}
|
|
810
|
+
}, [isReconnecting, forceStopped]);
|
|
630
811
|
const addToQueue = useCallback((text, images, references) => {
|
|
631
812
|
setShowContinue(false);
|
|
632
813
|
if (isRunning) {
|
|
@@ -714,7 +895,20 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
714
895
|
}, 100);
|
|
715
896
|
return () => clearInterval(interval);
|
|
716
897
|
}, [isRunning]);
|
|
717
|
-
return (_jsxs("div", { className: cn("flex flex-1 flex-col h-full min-h-0 text-foreground", className), children: [showHeader && (_jsxs("div", { className: "flex h-11 shrink-0 items-center justify-between border-b border-border px-4", children: [_jsx("span", { className: "text-[13px] font-medium text-muted-foreground", children: "Agent" }), _jsx("div", { className: "flex items-center gap-1", children: onSwitchToCli && (_jsxs("button", { onClick: onSwitchToCli, className: "flex items-center gap-1 text-[12px] text-muted-foreground hover:text-foreground px-2 py-1 rounded-md hover:bg-accent", title: "Switch to CLI", children: [_jsx(IconTerminal, { className: "h-3.5 w-3.5" }), "CLI"] })) })] })), _jsx("div", { ref: scrollRef, className: "flex-1 overflow-y-auto overflow-x-hidden min-h-0", children:
|
|
898
|
+
return (_jsxs("div", { className: cn("flex flex-1 flex-col h-full min-h-0 text-foreground", className), children: [showHeader && (_jsxs("div", { className: "flex h-11 shrink-0 items-center justify-between border-b border-border px-4", children: [_jsx("span", { className: "text-[13px] font-medium text-muted-foreground", children: "Agent" }), _jsx("div", { className: "flex items-center gap-1", children: onSwitchToCli && (_jsxs("button", { onClick: onSwitchToCli, className: "flex items-center gap-1 text-[12px] text-muted-foreground hover:text-foreground px-2 py-1 rounded-md hover:bg-accent", title: "Switch to CLI", children: [_jsx(IconTerminal, { className: "h-3.5 w-3.5" }), "CLI"] })) })] })), _jsx("div", { ref: scrollRef, className: "flex-1 overflow-y-auto overflow-x-hidden min-h-0", children: authError ? (_jsxs("div", { className: "flex flex-col items-center justify-center h-full px-4 gap-3", children: [_jsx("div", { className: "flex h-10 w-10 items-center justify-center rounded-full bg-destructive/10", children: _jsx(IconLock, { className: "h-5 w-5 text-destructive" }) }), _jsxs("div", { className: "text-center max-w-[280px]", children: [_jsx("p", { className: "text-sm font-medium text-foreground mb-1", children: authError.sessionExpired
|
|
899
|
+
? "Session expired"
|
|
900
|
+
: "Authentication required" }), _jsx("p", { className: "text-xs text-muted-foreground leading-relaxed", children: authError.sessionExpired ? ("Your session may have expired. Log out and log back in to reconnect.") : (_jsxs(_Fragment, { children: ["You need to log in to use the agent. If you're running locally, add", " ", _jsx("code", { className: "bg-muted px-1 py-0.5 rounded text-[10px]", children: "AUTH_MODE=local" }), " ", "to your", " ", _jsx("code", { className: "bg-muted px-1 py-0.5 rounded text-[10px]", children: ".env" }), " ", "file and restart the dev server."] })) })] }), _jsxs("div", { className: "flex gap-2", children: [authError.sessionExpired && (_jsx("button", { onClick: async () => {
|
|
901
|
+
try {
|
|
902
|
+
await fetch("/_agent-native/auth/logout", {
|
|
903
|
+
method: "POST",
|
|
904
|
+
});
|
|
905
|
+
}
|
|
906
|
+
catch { }
|
|
907
|
+
window.location.reload();
|
|
908
|
+
}, className: "text-xs text-destructive hover:text-destructive/80 px-3 py-1.5 rounded-md border border-destructive/30 hover:bg-destructive/10", children: "Log out" })), _jsx("button", { onClick: () => {
|
|
909
|
+
setAuthError(null);
|
|
910
|
+
window.location.reload();
|
|
911
|
+
}, className: "text-xs text-muted-foreground hover:text-foreground px-3 py-1.5 rounded-md border border-border hover:bg-accent", children: "Retry" })] })] })) : missingApiKey ? (_jsx("div", { className: "flex flex-col items-center justify-center h-full px-2", children: _jsx(ApiKeySetupCard, { apiUrl: apiUrl }) })) : usageLimitReached ? (_jsx("div", { className: "flex flex-col items-center justify-center h-full px-2", children: _jsx(BuilderCtaCard, { reason: "usage_limit", usageCents: usageLimitReached.usageCents, limitCents: usageLimitReached.limitCents }) })) : isRestoring ? (_jsxs("div", { className: "flex flex-col gap-3 p-4", children: [_jsx("div", { className: "flex justify-end", children: _jsx("div", { className: "h-8 w-32 rounded-lg bg-muted animate-pulse" }) }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("div", { className: "h-4 w-48 rounded bg-muted animate-pulse" }), _jsx("div", { className: "h-4 w-64 rounded bg-muted animate-pulse" }), _jsx("div", { className: "h-4 w-40 rounded bg-muted animate-pulse" })] })] })) : messages.length === 0 && !isReconnecting ? (_jsxs("div", { className: "flex flex-col items-center justify-center gap-4 py-16 px-4 h-full", children: [_jsx("div", { className: "flex h-10 w-10 items-center justify-center rounded-full bg-muted", children: _jsx(IconSparkles, { className: "h-5 w-5 text-muted-foreground" }) }), _jsx("p", { className: "text-sm text-muted-foreground text-center max-w-[240px]", children: emptyStateText ?? "How can I help you?" }), suggestions && suggestions.length > 0 && (_jsx("div", { className: "flex flex-col gap-1.5 w-full max-w-[280px]", children: suggestions.map((suggestion) => (_jsx("button", { onClick: () => {
|
|
718
912
|
threadRuntime.append({
|
|
719
913
|
role: "user",
|
|
720
914
|
content: [{ type: "text", text: suggestion }],
|
|
@@ -722,16 +916,44 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
722
916
|
}, className: "w-full rounded-lg border border-border px-3 py-2 text-left text-[13px] text-muted-foreground hover:bg-accent hover:text-foreground", children: suggestion }, suggestion))) }))] })) : (_jsxs("div", { className: "flex flex-col gap-4 px-4 py-4", children: [_jsx(ThreadPrimitive.Messages, { components: {
|
|
723
917
|
UserMessage,
|
|
724
918
|
AssistantMessage,
|
|
725
|
-
} }), showContinue && !
|
|
919
|
+
} }), showContinue && !showRunningInUI && (_jsx("div", { className: "flex justify-center py-2", children: _jsx("button", { type: "button", onClick: () => {
|
|
726
920
|
setShowContinue(false);
|
|
727
921
|
addToQueue("Continue from where you left off.");
|
|
728
|
-
}, className: "rounded-lg border border-border bg-background px-4 py-2 text-sm font-medium text-foreground hover:bg-accent", children: "Continue" }) })),
|
|
922
|
+
}, className: "rounded-lg border border-border bg-background px-4 py-2 text-sm font-medium text-foreground hover:bg-accent", children: "Continue" }) })), (isReconnecting || reconnectFrozen) &&
|
|
923
|
+
reconnectContent.length > 0 && (_jsx(ReconnectStreamMessage, { content: reconnectContent })), showRunningInUI && _jsx(ThinkingIndicator, {}), queuedMessages.map((msg, i) => (_jsx("div", { className: "flex justify-end", children: _jsxs("div", { className: "max-w-[85%] rounded-lg bg-accent/50 text-foreground/60 px-3 py-2 text-sm leading-relaxed whitespace-pre-wrap break-words", children: [_jsxs("div", { className: "flex items-center gap-1.5 text-[10px] text-muted-foreground mb-1 font-medium uppercase tracking-wide", children: [_jsx(IconClock, { className: "h-3 w-3" }), "Queued"] }), msg.text, msg.images && msg.images.length > 0 && (_jsx("div", { className: "flex flex-wrap gap-1.5 mt-1.5", children: msg.images.map((img, j) => (_jsx("img", { src: img, alt: "", className: "h-12 w-12 rounded object-cover border border-border/50" }, j))) }))] }) }, `queued-${i}`)))] })) }), showScrollToBottom && (_jsx("div", { className: "shrink-0 flex justify-center -mb-1", children: _jsx("button", { type: "button", onClick: scrollToBottom, className: "flex h-7 w-7 items-center justify-center rounded-full border border-border bg-background shadow-sm hover:bg-accent", "aria-label": "Scroll to bottom", children: _jsx(IconChevronDown, { className: "h-3.5 w-3.5 text-muted-foreground" }) }) })), composerSlot, _jsx("div", { className: "shrink-0 px-3 py-2", children: _jsxs(ComposerPrimitive.Root, { className: "flex flex-col rounded-lg border border-input bg-background focus-within:ring-1 focus-within:ring-ring", children: [_jsx(ComposerAttachmentPreviewStrip, {}), _jsx(TiptapComposer, { focusRef: tiptapRef, placeholder: isRunning
|
|
729
924
|
? queuedMessages.length > 0
|
|
730
925
|
? `${queuedMessages.length} queued — type another...`
|
|
731
926
|
: "Queue a message..."
|
|
732
927
|
: undefined, onSubmit: isRunning
|
|
733
928
|
? (text, references) => addToQueue(text, undefined, references.length > 0 ? references : undefined)
|
|
734
|
-
: undefined,
|
|
929
|
+
: undefined, onSlashCommand: onSlashCommand, execMode: execMode, onExecModeChange: onExecModeChange, actionButton: showRunningInUI ? (_jsx("button", { onClick: () => {
|
|
930
|
+
// Immediately force the indicator off — belt-and-suspenders
|
|
931
|
+
// so the UI is never stuck even if the runtime or reconnect
|
|
932
|
+
// state takes time (or fails) to clear on its own.
|
|
933
|
+
setForceStopped(true);
|
|
934
|
+
if (isReconnecting) {
|
|
935
|
+
// Abort the server-side run (fire-and-forget)
|
|
936
|
+
if (reconnectRunIdRef.current) {
|
|
937
|
+
fetch(`${apiUrl}/runs/${encodeURIComponent(reconnectRunIdRef.current)}/abort`, { method: "POST" });
|
|
938
|
+
}
|
|
939
|
+
// Abort the client-side SSE stream
|
|
940
|
+
reconnectAbortRef.current?.abort();
|
|
941
|
+
reconnectAbortRef.current = null;
|
|
942
|
+
reconnectRunIdRef.current = null;
|
|
943
|
+
setIsReconnecting(false);
|
|
944
|
+
// Keep reconnectContent visible (frozen) — don't wipe it
|
|
945
|
+
setReconnectFrozen(reconnectContent.length > 0);
|
|
946
|
+
}
|
|
947
|
+
// Always try to cancel the runtime run too (handles the
|
|
948
|
+
// normal non-reconnect path and is a no-op if not running)
|
|
949
|
+
threadRuntime.cancelRun();
|
|
950
|
+
window.dispatchEvent(new CustomEvent("builder.chatRunning", {
|
|
951
|
+
detail: {
|
|
952
|
+
isRunning: false,
|
|
953
|
+
tabId: tabId || threadId,
|
|
954
|
+
},
|
|
955
|
+
}));
|
|
956
|
+
}, className: "shrink-0 flex h-7 w-7 items-center justify-center rounded-md bg-primary text-primary-foreground hover:opacity-90", title: "Stop generating", children: _jsx(IconPlayerStop, { className: "h-3.5 w-3.5" }) })) : undefined })] }) })] }));
|
|
735
957
|
});
|
|
736
958
|
export const AssistantChat = forwardRef(function AssistantChat({ apiUrl = "/_agent-native/agent-chat", tabId, threadId, ...props }, ref) {
|
|
737
959
|
const adapter = useMemo(() => createAgentChatAdapter({ apiUrl, tabId, threadId }), [apiUrl, tabId, threadId]);
|