@agent-native/core 0.7.10 → 0.7.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/action.js +30 -11
- package/dist/action.js.map +1 -1
- package/dist/agent/engine/ai-sdk-engine.d.ts +14 -2
- package/dist/agent/engine/ai-sdk-engine.d.ts.map +1 -1
- package/dist/agent/engine/ai-sdk-engine.js +70 -54
- package/dist/agent/engine/ai-sdk-engine.js.map +1 -1
- package/dist/agent/engine/anthropic-engine.d.ts +1 -6
- package/dist/agent/engine/anthropic-engine.d.ts.map +1 -1
- package/dist/agent/engine/anthropic-engine.js +3 -14
- package/dist/agent/engine/anthropic-engine.js.map +1 -1
- package/dist/agent/engine/builtin.d.ts.map +1 -1
- package/dist/agent/engine/builtin.js +3 -0
- package/dist/agent/engine/builtin.js.map +1 -1
- package/dist/agent/engine/index.d.ts +1 -1
- package/dist/agent/engine/index.d.ts.map +1 -1
- package/dist/agent/engine/index.js +1 -1
- package/dist/agent/engine/index.js.map +1 -1
- package/dist/agent/engine/provider-env-vars.d.ts +21 -0
- package/dist/agent/engine/provider-env-vars.d.ts.map +1 -0
- package/dist/agent/engine/provider-env-vars.js +50 -0
- package/dist/agent/engine/provider-env-vars.js.map +1 -0
- package/dist/agent/engine/registry.d.ts +18 -0
- package/dist/agent/engine/registry.d.ts.map +1 -1
- package/dist/agent/engine/registry.js +54 -4
- package/dist/agent/engine/registry.js.map +1 -1
- package/dist/agent/engine/translate-ai-sdk.d.ts +35 -10
- package/dist/agent/engine/translate-ai-sdk.d.ts.map +1 -1
- package/dist/agent/engine/translate-ai-sdk.js +190 -91
- package/dist/agent/engine/translate-ai-sdk.js.map +1 -1
- package/dist/agent/engine/types.d.ts +10 -1
- package/dist/agent/engine/types.d.ts.map +1 -1
- package/dist/agent/production-agent.d.ts +21 -1
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +72 -21
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/thread-data-builder.js +1 -1
- package/dist/agent/thread-data-builder.js.map +1 -1
- package/dist/agent/types.d.ts +4 -0
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/application-state/script-helpers.d.ts +12 -5
- package/dist/application-state/script-helpers.d.ts.map +1 -1
- package/dist/application-state/script-helpers.js +41 -20
- package/dist/application-state/script-helpers.js.map +1 -1
- package/dist/catalog.json +15 -0
- package/dist/checkpoints/index.d.ts +3 -0
- package/dist/checkpoints/index.d.ts.map +1 -0
- package/dist/checkpoints/index.js +3 -0
- package/dist/checkpoints/index.js.map +1 -0
- package/dist/checkpoints/service.d.ts +6 -0
- package/dist/checkpoints/service.d.ts.map +1 -0
- package/dist/checkpoints/service.js +107 -0
- package/dist/checkpoints/service.js.map +1 -0
- package/dist/checkpoints/store.d.ts +27 -0
- package/dist/checkpoints/store.d.ts.map +1 -0
- package/dist/checkpoints/store.js +92 -0
- package/dist/checkpoints/store.js.map +1 -0
- package/dist/cli/create.d.ts.map +1 -1
- package/dist/cli/create.js +191 -2
- package/dist/cli/create.js.map +1 -1
- package/dist/cli/index.js +63 -3
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/templates-meta.d.ts +2 -0
- package/dist/cli/templates-meta.d.ts.map +1 -1
- package/dist/cli/templates-meta.js +35 -0
- package/dist/cli/templates-meta.js.map +1 -1
- package/dist/cli/workspacify.d.ts.map +1 -1
- package/dist/cli/workspacify.js +7 -3
- package/dist/cli/workspacify.js.map +1 -1
- package/dist/client/AgentPanel.d.ts.map +1 -1
- package/dist/client/AgentPanel.js +3 -1
- package/dist/client/AgentPanel.js.map +1 -1
- package/dist/client/AssistantChat.d.ts +15 -0
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +162 -67
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/CommandMenu.d.ts.map +1 -1
- package/dist/client/CommandMenu.js +9 -5
- package/dist/client/CommandMenu.js.map +1 -1
- package/dist/client/ConnectBuilderCard.js +1 -1
- package/dist/client/ConnectBuilderCard.js.map +1 -1
- package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
- package/dist/client/MultiTabAssistantChat.js +89 -4
- package/dist/client/MultiTabAssistantChat.js.map +1 -1
- package/dist/client/agent-chat-adapter.d.ts +6 -0
- package/dist/client/agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/agent-chat-adapter.js +4 -0
- package/dist/client/agent-chat-adapter.js.map +1 -1
- package/dist/client/composer/TiptapComposer.d.ts +12 -1
- package/dist/client/composer/TiptapComposer.d.ts.map +1 -1
- package/dist/client/composer/TiptapComposer.js +87 -5
- package/dist/client/composer/TiptapComposer.js.map +1 -1
- package/dist/client/notifications/NotificationsBell.d.ts +23 -0
- package/dist/client/notifications/NotificationsBell.d.ts.map +1 -0
- package/dist/client/notifications/NotificationsBell.js +165 -0
- package/dist/client/notifications/NotificationsBell.js.map +1 -0
- package/dist/client/notifications/index.d.ts +2 -0
- package/dist/client/notifications/index.d.ts.map +1 -0
- package/dist/client/notifications/index.js +2 -0
- package/dist/client/notifications/index.js.map +1 -0
- package/dist/client/onboarding/OnboardingPanel.js +6 -3
- package/dist/client/onboarding/OnboardingPanel.js.map +1 -1
- package/dist/client/progress/RunsTray.d.ts +18 -0
- package/dist/client/progress/RunsTray.d.ts.map +1 -0
- package/dist/client/progress/RunsTray.js +70 -0
- package/dist/client/progress/RunsTray.js.map +1 -0
- package/dist/client/progress/index.d.ts +2 -0
- package/dist/client/progress/index.d.ts.map +1 -0
- package/dist/client/progress/index.js +2 -0
- package/dist/client/progress/index.js.map +1 -0
- package/dist/client/resources/ResourcesPanel.d.ts.map +1 -1
- package/dist/client/resources/ResourcesPanel.js +19 -4
- package/dist/client/resources/ResourcesPanel.js.map +1 -1
- package/dist/client/settings/AutomationsSection.d.ts +2 -0
- package/dist/client/settings/AutomationsSection.d.ts.map +1 -0
- package/dist/client/settings/AutomationsSection.js +214 -0
- package/dist/client/settings/AutomationsSection.js.map +1 -0
- package/dist/client/settings/ComingSoonSection.d.ts.map +1 -1
- package/dist/client/settings/ComingSoonSection.js +2 -1
- package/dist/client/settings/ComingSoonSection.js.map +1 -1
- package/dist/client/settings/SecretsSection.d.ts.map +1 -1
- package/dist/client/settings/SecretsSection.js +122 -3
- package/dist/client/settings/SecretsSection.js.map +1 -1
- package/dist/client/settings/SettingsPanel.d.ts.map +1 -1
- package/dist/client/settings/SettingsPanel.js +252 -14
- package/dist/client/settings/SettingsPanel.js.map +1 -1
- package/dist/client/settings/VoiceTranscriptionSection.d.ts.map +1 -1
- package/dist/client/settings/VoiceTranscriptionSection.js +2 -2
- package/dist/client/settings/VoiceTranscriptionSection.js.map +1 -1
- package/dist/client/use-pausing-interval.d.ts +11 -0
- package/dist/client/use-pausing-interval.d.ts.map +1 -0
- package/dist/client/use-pausing-interval.js +49 -0
- package/dist/client/use-pausing-interval.js.map +1 -0
- package/dist/db/client.d.ts +26 -0
- package/dist/db/client.d.ts.map +1 -1
- package/dist/db/client.js +84 -2
- package/dist/db/client.js.map +1 -1
- package/dist/db/drizzle-config.d.ts +33 -0
- package/dist/db/drizzle-config.d.ts.map +1 -0
- package/dist/db/drizzle-config.js +132 -0
- package/dist/db/drizzle-config.js.map +1 -0
- package/dist/db/migrations.d.ts.map +1 -1
- package/dist/db/migrations.js +11 -6
- package/dist/db/migrations.js.map +1 -1
- package/dist/deploy/build.js +2 -1
- package/dist/deploy/build.js.map +1 -1
- package/dist/event-bus/bus.d.ts +20 -0
- package/dist/event-bus/bus.d.ts.map +1 -0
- package/dist/event-bus/bus.js +108 -0
- package/dist/event-bus/bus.js.map +1 -0
- package/dist/event-bus/index.d.ts +4 -0
- package/dist/event-bus/index.d.ts.map +1 -0
- package/dist/event-bus/index.js +3 -0
- package/dist/event-bus/index.js.map +1 -0
- package/dist/event-bus/registry.d.ts +22 -0
- package/dist/event-bus/registry.d.ts.map +1 -0
- package/dist/event-bus/registry.js +63 -0
- package/dist/event-bus/registry.js.map +1 -0
- package/dist/event-bus/types.d.ts +27 -0
- package/dist/event-bus/types.d.ts.map +1 -0
- package/dist/event-bus/types.js +2 -0
- package/dist/event-bus/types.js.map +1 -0
- package/dist/integrations/config-store.d.ts.map +1 -1
- package/dist/integrations/config-store.js +16 -12
- package/dist/integrations/config-store.js.map +1 -1
- package/dist/integrations/google-docs-poller.d.ts.map +1 -1
- package/dist/integrations/google-docs-poller.js +5 -1
- package/dist/integrations/google-docs-poller.js.map +1 -1
- package/dist/jobs/scheduler.d.ts.map +1 -1
- package/dist/jobs/scheduler.js +7 -3
- package/dist/jobs/scheduler.js.map +1 -1
- package/dist/notifications/actions.d.ts +10 -0
- package/dist/notifications/actions.d.ts.map +1 -0
- package/dist/notifications/actions.js +114 -0
- package/dist/notifications/actions.js.map +1 -0
- package/dist/notifications/channels.d.ts +15 -0
- package/dist/notifications/channels.d.ts.map +1 -0
- package/dist/notifications/channels.js +97 -0
- package/dist/notifications/channels.js.map +1 -0
- package/dist/notifications/index.d.ts +4 -0
- package/dist/notifications/index.d.ts.map +1 -0
- package/dist/notifications/index.js +3 -0
- package/dist/notifications/index.js.map +1 -0
- package/dist/notifications/registry.d.ts +9 -0
- package/dist/notifications/registry.d.ts.map +1 -0
- package/dist/notifications/registry.js +146 -0
- package/dist/notifications/registry.js.map +1 -0
- package/dist/notifications/routes.d.ts +34 -0
- package/dist/notifications/routes.d.ts.map +1 -0
- package/dist/notifications/routes.js +69 -0
- package/dist/notifications/routes.js.map +1 -0
- package/dist/notifications/store.d.ts +25 -0
- package/dist/notifications/store.d.ts.map +1 -0
- package/dist/notifications/store.js +158 -0
- package/dist/notifications/store.js.map +1 -0
- package/dist/notifications/types.d.ts +43 -0
- package/dist/notifications/types.d.ts.map +1 -0
- package/dist/notifications/types.js +2 -0
- package/dist/notifications/types.js.map +1 -0
- package/dist/onboarding/default-steps.d.ts.map +1 -1
- package/dist/onboarding/default-steps.js +63 -20
- package/dist/onboarding/default-steps.js.map +1 -1
- package/dist/org/handlers.d.ts.map +1 -1
- package/dist/org/handlers.js +7 -26
- package/dist/org/handlers.js.map +1 -1
- package/dist/progress/actions.d.ts +8 -0
- package/dist/progress/actions.d.ts.map +1 -0
- package/dist/progress/actions.js +158 -0
- package/dist/progress/actions.js.map +1 -0
- package/dist/progress/index.d.ts +3 -0
- package/dist/progress/index.d.ts.map +1 -0
- package/dist/progress/index.js +2 -0
- package/dist/progress/index.js.map +1 -0
- package/dist/progress/registry.d.ts +22 -0
- package/dist/progress/registry.d.ts.map +1 -0
- package/dist/progress/registry.js +98 -0
- package/dist/progress/registry.js.map +1 -0
- package/dist/progress/routes.d.ts +21 -0
- package/dist/progress/routes.d.ts.map +1 -0
- package/dist/progress/routes.js +59 -0
- package/dist/progress/routes.js.map +1 -0
- package/dist/progress/store.d.ts +7 -0
- package/dist/progress/store.d.ts.map +1 -0
- package/dist/progress/store.js +195 -0
- package/dist/progress/store.js.map +1 -0
- package/dist/progress/types.d.ts +49 -0
- package/dist/progress/types.d.ts.map +1 -0
- package/dist/progress/types.js +7 -0
- package/dist/progress/types.js.map +1 -0
- package/dist/resources/store.d.ts.map +1 -1
- package/dist/resources/store.js +19 -15
- package/dist/resources/store.js.map +1 -1
- package/dist/scripts/agent-engines/list-agent-engines.d.ts.map +1 -1
- package/dist/scripts/agent-engines/list-agent-engines.js +19 -5
- package/dist/scripts/agent-engines/list-agent-engines.js.map +1 -1
- package/dist/scripts/agent-engines/set-agent-engine.d.ts.map +1 -1
- package/dist/scripts/agent-engines/set-agent-engine.js +8 -7
- package/dist/scripts/agent-engines/set-agent-engine.js.map +1 -1
- package/dist/secrets/index.d.ts +3 -2
- package/dist/secrets/index.d.ts.map +1 -1
- package/dist/secrets/index.js +3 -2
- package/dist/secrets/index.js.map +1 -1
- package/dist/secrets/routes.d.ts +41 -2
- package/dist/secrets/routes.d.ts.map +1 -1
- package/dist/secrets/routes.js +167 -1
- package/dist/secrets/routes.js.map +1 -1
- package/dist/secrets/schema.d.ts +39 -1
- package/dist/secrets/schema.d.ts.map +1 -1
- package/dist/secrets/schema.js +6 -0
- package/dist/secrets/schema.js.map +1 -1
- package/dist/secrets/storage.d.ts +26 -0
- package/dist/secrets/storage.d.ts.map +1 -1
- package/dist/secrets/storage.js +111 -5
- package/dist/secrets/storage.js.map +1 -1
- package/dist/secrets/substitution.d.ts +39 -0
- package/dist/secrets/substitution.d.ts.map +1 -0
- package/dist/secrets/substitution.js +93 -0
- package/dist/secrets/substitution.js.map +1 -0
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +1684 -1410
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/agent-teams.d.ts.map +1 -1
- package/dist/server/agent-teams.js +17 -6
- package/dist/server/agent-teams.js.map +1 -1
- package/dist/server/analytics.d.ts +8 -5
- package/dist/server/analytics.d.ts.map +1 -1
- package/dist/server/analytics.js +17 -8
- package/dist/server/analytics.js.map +1 -1
- package/dist/server/app-url.d.ts.map +1 -1
- package/dist/server/app-url.js +7 -4
- package/dist/server/app-url.js.map +1 -1
- package/dist/server/auth.d.ts +11 -0
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/auth.js +74 -21
- package/dist/server/auth.js.map +1 -1
- package/dist/server/better-auth-instance.d.ts.map +1 -1
- package/dist/server/better-auth-instance.js +34 -16
- package/dist/server/better-auth-instance.js.map +1 -1
- package/dist/server/core-routes-plugin.d.ts.map +1 -1
- package/dist/server/core-routes-plugin.js +179 -2
- package/dist/server/core-routes-plugin.js.map +1 -1
- package/dist/server/email-templates.d.ts +43 -0
- package/dist/server/email-templates.d.ts.map +1 -0
- package/dist/server/email-templates.js +86 -0
- package/dist/server/email-templates.js.map +1 -0
- package/dist/server/framework-request-handler.d.ts +15 -0
- package/dist/server/framework-request-handler.d.ts.map +1 -1
- package/dist/server/framework-request-handler.js +64 -1
- package/dist/server/framework-request-handler.js.map +1 -1
- package/dist/server/onboarding-html.d.ts +11 -0
- package/dist/server/onboarding-html.d.ts.map +1 -1
- package/dist/server/onboarding-html.js +275 -16
- package/dist/server/onboarding-html.js.map +1 -1
- package/dist/server/schema-prompt.d.ts.map +1 -1
- package/dist/server/schema-prompt.js +5 -0
- package/dist/server/schema-prompt.js.map +1 -1
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index.js +1 -0
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/truncate.d.ts +8 -0
- package/dist/shared/truncate.d.ts.map +1 -0
- package/dist/shared/truncate.js +12 -0
- package/dist/shared/truncate.js.map +1 -0
- package/dist/templates/default/.agents/skills/agent-engines/SKILL.md +60 -4
- package/dist/templates/default/.agents/skills/notifications/SKILL.md +95 -0
- package/dist/templates/default/.agents/skills/progress/SKILL.md +97 -0
- package/dist/templates/default/AGENTS.md +12 -10
- package/dist/templates/default/package.json +10 -10
- package/dist/templates/workspace-core/package.json +5 -5
- package/dist/templates/workspace-root/package.json +1 -1
- package/dist/templates/workspace-root/pnpm-workspace.yaml +6 -0
- package/dist/templates/workspace-root/tsconfig.base.json +1 -2
- package/dist/tools/fetch-tool.d.ts +22 -0
- package/dist/tools/fetch-tool.d.ts.map +1 -0
- package/dist/tools/fetch-tool.js +156 -0
- package/dist/tools/fetch-tool.js.map +1 -0
- package/dist/tracking/index.d.ts +4 -0
- package/dist/tracking/index.d.ts.map +1 -0
- package/dist/tracking/index.js +3 -0
- package/dist/tracking/index.js.map +1 -0
- package/dist/tracking/providers.d.ts +15 -0
- package/dist/tracking/providers.d.ts.map +1 -0
- package/dist/tracking/providers.js +195 -0
- package/dist/tracking/providers.js.map +1 -0
- package/dist/tracking/registry.d.ts +10 -0
- package/dist/tracking/registry.d.ts.map +1 -0
- package/dist/tracking/registry.js +75 -0
- package/dist/tracking/registry.js.map +1 -0
- package/dist/tracking/types.d.ts +13 -0
- package/dist/tracking/types.d.ts.map +1 -0
- package/dist/tracking/types.js +2 -0
- package/dist/tracking/types.js.map +1 -0
- package/dist/triggers/actions.d.ts +10 -0
- package/dist/triggers/actions.d.ts.map +1 -0
- package/dist/triggers/actions.js +277 -0
- package/dist/triggers/actions.js.map +1 -0
- package/dist/triggers/condition-evaluator.d.ts +15 -0
- package/dist/triggers/condition-evaluator.d.ts.map +1 -0
- package/dist/triggers/condition-evaluator.js +107 -0
- package/dist/triggers/condition-evaluator.js.map +1 -0
- package/dist/triggers/dispatcher.d.ts +32 -0
- package/dist/triggers/dispatcher.d.ts.map +1 -0
- package/dist/triggers/dispatcher.js +291 -0
- package/dist/triggers/dispatcher.js.map +1 -0
- package/dist/triggers/index.d.ts +5 -0
- package/dist/triggers/index.d.ts.map +1 -0
- package/dist/triggers/index.js +4 -0
- package/dist/triggers/index.js.map +1 -0
- package/dist/triggers/types.d.ts +35 -0
- package/dist/triggers/types.d.ts.map +1 -0
- package/dist/triggers/types.js +9 -0
- package/dist/triggers/types.js.map +1 -0
- package/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +66 -16
- package/dist/vite/client.js.map +1 -1
- package/docs/content/automations.md +239 -0
- package/docs/content/multi-tenancy.md +88 -0
- package/docs/content/notifications.md +199 -0
- package/docs/content/progress.md +176 -0
- package/docs/content/tracking.md +168 -0
- package/package.json +59 -35
- package/src/templates/default/.agents/skills/agent-engines/SKILL.md +60 -4
- package/src/templates/default/.agents/skills/notifications/SKILL.md +95 -0
- package/src/templates/default/.agents/skills/progress/SKILL.md +97 -0
- package/src/templates/default/AGENTS.md +12 -10
- package/src/templates/default/package.json +10 -10
- package/src/templates/workspace-core/package.json +5 -5
- package/src/templates/workspace-root/package.json +1 -1
- package/src/templates/workspace-root/pnpm-workspace.yaml +6 -0
- package/src/templates/workspace-root/tsconfig.base.json +1 -2
- package/tsconfig.base.json +1 -1
- package/dist/client/settings/LLMSection.d.ts +0 -2
- package/dist/client/settings/LLMSection.d.ts.map +0 -1
- package/dist/client/settings/LLMSection.js +0 -64
- package/dist/client/settings/LLMSection.js.map +0 -1
|
@@ -11,8 +11,9 @@ import { cn } from "./utils.js";
|
|
|
11
11
|
import { AgentTaskCard } from "./AgentTaskCard.js";
|
|
12
12
|
import { ConnectBuilderCard } from "./ConnectBuilderCard.js";
|
|
13
13
|
import { IframeEmbed, parseEmbedBody } from "./IframeEmbed.js";
|
|
14
|
+
import { useDevMode } from "./use-dev-mode.js";
|
|
14
15
|
import { TiptapComposer, } from "./composer/TiptapComposer.js";
|
|
15
|
-
import { IconMessage, IconX, IconPlayerStop, IconCheck, IconChevronDown, IconCopy, IconTerminal, IconLoader2, IconCircleX, IconSquareFilled, IconClock, IconFile, IconFolder, IconFileText, IconCheckbox, IconMail, IconUser, IconPresentation, IconStack2, IconMessageChatbot, IconLock, } from "@tabler/icons-react";
|
|
16
|
+
import { IconMessage, IconX, IconPlayerStop, IconCheck, IconChevronDown, IconCopy, IconTerminal, IconLoader2, IconCircleX, IconSquareFilled, IconClock, IconFile, IconFolder, IconFileText, IconCheckbox, IconMail, IconUser, IconPresentation, IconStack2, IconMessageChatbot, IconLock, IconArrowBackUp, IconExternalLink, } from "@tabler/icons-react";
|
|
16
17
|
// ─── Markdown Text ──────────────────────────────────────────────────────────
|
|
17
18
|
const markdownStyles = `
|
|
18
19
|
.agent-markdown > :first-child { margin-top: 0; }
|
|
@@ -101,6 +102,8 @@ function loadHighlighter() {
|
|
|
101
102
|
}
|
|
102
103
|
return highlighterLoader;
|
|
103
104
|
}
|
|
105
|
+
import { PROVIDER_ENV_VARS } from "../agent/engine/provider-env-vars.js";
|
|
106
|
+
const PROVIDER_ENV_VAR_SET = new Set(PROVIDER_ENV_VARS);
|
|
104
107
|
// Map a few common aliases to languages we bundled above.
|
|
105
108
|
const LANG_ALIASES = {
|
|
106
109
|
js: "javascript",
|
|
@@ -449,14 +452,17 @@ function UserMessage() {
|
|
|
449
452
|
Text: UserMessageText,
|
|
450
453
|
} }) }), !expanded && isExpandable && (_jsx("div", { className: "pointer-events-none absolute inset-x-0 bottom-0 h-14 rounded-b-lg bg-gradient-to-t from-accent via-accent/90 to-transparent" }))] }), isExpandable && (_jsxs("button", { type: "button", onClick: () => setExpanded((prev) => !prev), className: "mt-1 inline-flex items-center gap-1 rounded-md px-1.5 py-1 text-[11px] font-medium text-muted-foreground hover:text-foreground", children: [_jsx(IconChevronDown, { className: cn("h-3.5 w-3.5 transition-transform", expanded && "rotate-180") }), expanded ? "Collapse" : "Expand"] }))] }) }));
|
|
451
454
|
}
|
|
455
|
+
const CheckpointContext = React.createContext(null);
|
|
452
456
|
function AssistantMessage() {
|
|
453
457
|
const [copied, setCopied] = useState(false);
|
|
458
|
+
const [restoreState, setRestoreState] = useState("idle");
|
|
454
459
|
const messageRuntime = useMessageRuntime();
|
|
455
460
|
const thread = useThread();
|
|
456
461
|
const msg = messageRuntime.getState();
|
|
457
462
|
const isLast = thread.messages.length > 0 &&
|
|
458
463
|
thread.messages[thread.messages.length - 1].id === msg.id;
|
|
459
464
|
const isComplete = !isLast || !thread.isRunning;
|
|
465
|
+
const cpCtx = React.useContext(CheckpointContext);
|
|
460
466
|
const handleCopy = useCallback(() => {
|
|
461
467
|
const m = messageRuntime.getState();
|
|
462
468
|
const text = m.content
|
|
@@ -467,12 +473,56 @@ function AssistantMessage() {
|
|
|
467
473
|
setCopied(true);
|
|
468
474
|
setTimeout(() => setCopied(false), 2000);
|
|
469
475
|
}, [messageRuntime]);
|
|
476
|
+
const handleRestore = useCallback(async () => {
|
|
477
|
+
if (restoreState === "idle") {
|
|
478
|
+
setRestoreState("confirming");
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
if (restoreState !== "confirming" || !cpCtx)
|
|
482
|
+
return;
|
|
483
|
+
setRestoreState("restoring");
|
|
484
|
+
try {
|
|
485
|
+
const m = messageRuntime.getState();
|
|
486
|
+
const runId = m.metadata?.runId;
|
|
487
|
+
if (!runId) {
|
|
488
|
+
setRestoreState("idle");
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
// Look up checkpoint by runId
|
|
492
|
+
const tid = cpCtx.threadId || "";
|
|
493
|
+
const res = await fetch(`${cpCtx.apiUrl}/checkpoints?threadId=${encodeURIComponent(tid)}`);
|
|
494
|
+
const checkpoints = res.ok ? await res.json() : [];
|
|
495
|
+
const checkpoint = checkpoints.find((cp) => cp.runId === runId);
|
|
496
|
+
if (!checkpoint) {
|
|
497
|
+
setRestoreState("idle");
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
const restoreRes = await fetch(`${cpCtx.apiUrl}/checkpoints/restore`, {
|
|
501
|
+
method: "POST",
|
|
502
|
+
headers: { "Content-Type": "application/json" },
|
|
503
|
+
body: JSON.stringify({ checkpointId: checkpoint.id }),
|
|
504
|
+
});
|
|
505
|
+
if (restoreRes.ok) {
|
|
506
|
+
window.location.reload();
|
|
507
|
+
}
|
|
508
|
+
else {
|
|
509
|
+
setRestoreState("idle");
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
catch {
|
|
513
|
+
setRestoreState("idle");
|
|
514
|
+
}
|
|
515
|
+
}, [restoreState, cpCtx, messageRuntime]);
|
|
516
|
+
const cancelRestore = useCallback(() => {
|
|
517
|
+
setRestoreState("idle");
|
|
518
|
+
}, []);
|
|
519
|
+
const showRestore = cpCtx?.devMode && isComplete && !isLast;
|
|
470
520
|
return (_jsxs("div", { className: "group relative", style: { contentVisibility: isComplete ? "auto" : "visible" }, children: [_jsx("div", { className: "max-w-[95%] text-sm leading-relaxed text-foreground", children: _jsx(MessagePrimitive.Parts, { components: {
|
|
471
521
|
Text: MarkdownText,
|
|
472
522
|
tools: {
|
|
473
523
|
Fallback: ToolCallFallback,
|
|
474
524
|
},
|
|
475
|
-
} }) }), isComplete && (
|
|
525
|
+
} }) }), isComplete && (_jsxs("div", { className: "mt-1 flex items-center gap-0.5 opacity-0 group-hover:opacity-100", children: [_jsx("button", { onClick: handleCopy, className: "flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground", children: copied ? (_jsx(IconCheck, { className: "h-3 w-3" })) : (_jsx(IconCopy, { className: "h-3 w-3" })) }), showRestore && restoreState === "idle" && (_jsx("button", { onClick: handleRestore, title: "Restore project files to this point", className: "flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground", children: _jsx(IconArrowBackUp, { className: "h-3 w-3" }) })), showRestore && restoreState === "confirming" && (_jsxs("div", { className: "flex items-center gap-1 text-xs", children: [_jsx("button", { onClick: handleRestore, className: "rounded-md bg-destructive px-1.5 py-0.5 text-destructive-foreground hover:bg-destructive/90", children: "Restore to here?" }), _jsx("button", { onClick: cancelRestore, className: "rounded-md px-1.5 py-0.5 text-muted-foreground hover:bg-accent", children: "Cancel" })] })), showRestore && restoreState === "restoring" && (_jsxs("span", { className: "flex items-center gap-1 text-xs text-muted-foreground", children: [_jsx(IconLoader2, { className: "h-3 w-3 animate-spin" }), "Restoring..."] }))] }))] }));
|
|
476
526
|
}
|
|
477
527
|
// ─── Thinking Indicator ─────────────────────────────────────────────────────
|
|
478
528
|
function ThinkingIndicator({ label = "Thinking" } = {}) {
|
|
@@ -500,7 +550,7 @@ function ApiKeySetupCard({ apiUrl }) {
|
|
|
500
550
|
const res = await fetch(`${apiUrl}/save-key`, {
|
|
501
551
|
method: "POST",
|
|
502
552
|
headers: { "Content-Type": "application/json" },
|
|
503
|
-
body: JSON.stringify({ key: apiKey.trim() }),
|
|
553
|
+
body: JSON.stringify({ key: apiKey.trim(), provider: "anthropic" }),
|
|
504
554
|
});
|
|
505
555
|
if (!res.ok) {
|
|
506
556
|
const data = await res.json().catch(() => ({}));
|
|
@@ -519,13 +569,13 @@ function ApiKeySetupCard({ apiUrl }) {
|
|
|
519
569
|
if (saved) {
|
|
520
570
|
return (_jsx("div", { className: "mx-4 my-6 rounded-lg border border-emerald-500/30 bg-emerald-500/5 p-4", children: _jsxs("div", { className: "flex items-center gap-2 text-sm text-emerald-400", children: [_jsx(IconCheck, { className: "h-4 w-4" }), "API key saved. Reloading..."] }) }));
|
|
521
571
|
}
|
|
522
|
-
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(IconMessage, { className: "h-4.5 w-4.5 text-muted-foreground" }) }),
|
|
572
|
+
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(IconMessage, { className: "h-4.5 w-4.5 text-muted-foreground" }) }), _jsx("h3", { className: "text-sm font-medium text-foreground", children: "Connect your AI" })] }), _jsxs("div", { className: "space-y-3", children: [_jsxs("div", { className: "flex items-center gap-3 rounded-md border border-border px-3 py-3", children: [_jsxs("div", { className: "min-w-0", children: [_jsx("div", { className: "text-xs font-medium text-foreground", children: "Connect Builder.io" }), _jsx("p", { className: "text-[11px] text-muted-foreground mt-0.5 max-w-[200px]", children: "Managed LLM, hosting, and more \u2014 no API key needed" })] }), _jsxs("a", { href: "https://forms.agent-native.com/f/builder-waitlist/36GWqf", target: "_blank", rel: "noopener noreferrer", className: "ml-auto inline-flex items-center gap-1 shrink-0 rounded-md bg-muted/60 px-3 py-1.5 text-[11px] font-medium no-underline text-foreground hover:bg-muted", children: ["Join waitlist", _jsx(IconExternalLink, { size: 10 })] })] }), _jsxs("div", { className: "relative flex items-center", children: [_jsx("div", { className: "flex-grow border-t border-border" }), _jsx("span", { className: "mx-2 text-[10px] uppercase tracking-wider text-muted-foreground/60", children: "or" }), _jsx("div", { className: "flex-grow border-t border-border" })] }), _jsx("input", { type: "password", value: apiKey, onChange: (e) => {
|
|
523
573
|
setApiKey(e.target.value);
|
|
524
574
|
setError(null);
|
|
525
575
|
}, onKeyDown: (e) => {
|
|
526
576
|
if (e.key === "Enter")
|
|
527
577
|
handleSave();
|
|
528
|
-
}, 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
|
|
578
|
+
}, 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 }), apiKey.trim() && (_jsx("button", { onClick: handleSave, disabled: saving, 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" })), _jsx("p", { className: "text-[10px] text-muted-foreground/60 text-center", children: _jsx("a", { href: "https://console.anthropic.com/settings/keys", target: "_blank", rel: "noopener noreferrer", className: "underline hover:text-foreground/80", children: "Get an Anthropic key" }) })] })] }));
|
|
529
579
|
}
|
|
530
580
|
// ─── Builder.io CTA Card (usage limit / code changes / CLI) ─────────────────
|
|
531
581
|
export function BuilderCtaCard({ reason, usageCents, limitCents, apiUrl = "/_agent-native/agent-chat", }) {
|
|
@@ -546,7 +596,7 @@ export function BuilderCtaCard({ reason, usageCents, limitCents, apiUrl = "/_age
|
|
|
546
596
|
const res = await fetch(`${apiUrl}/save-key`, {
|
|
547
597
|
method: "POST",
|
|
548
598
|
headers: { "Content-Type": "application/json" },
|
|
549
|
-
body: JSON.stringify({ key: apiKey.trim() }),
|
|
599
|
+
body: JSON.stringify({ key: apiKey.trim(), provider: "anthropic" }),
|
|
550
600
|
});
|
|
551
601
|
if (!res.ok) {
|
|
552
602
|
const data = await res.json().catch(() => ({}));
|
|
@@ -581,7 +631,7 @@ export function BuilderCtaCard({ reason, usageCents, limitCents, apiUrl = "/_age
|
|
|
581
631
|
}, onKeyDown: (e) => {
|
|
582
632
|
if (e.key === "Enter")
|
|
583
633
|
handleSave();
|
|
584
|
-
}, 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" }), _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 })] }),
|
|
634
|
+
}, 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" }), _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 })] }), _jsxs("div", { className: "rounded-md border border-border px-3 py-2.5", children: [_jsxs("div", { className: "flex items-center justify-between gap-2", children: [_jsx("div", { className: "text-xs font-medium text-foreground", children: "Builder.io" }), _jsxs("a", { href: "https://forms.agent-native.com/f/builder-waitlist/36GWqf", target: "_blank", rel: "noopener noreferrer", className: "inline-flex items-center gap-1 shrink-0 rounded border border-border px-2 py-0.5 text-[10px] font-medium no-underline text-muted-foreground hover:text-foreground hover:bg-accent/40", children: ["Join waitlist", _jsx(IconExternalLink, { size: 10 })] })] }), _jsx("p", { className: "text-[11px] text-muted-foreground mt-0.5", children: "Managed hosting, LLM, and more" })] })] })] }));
|
|
585
635
|
}
|
|
586
636
|
export const CHAT_STORAGE_PREFIX = "agent-chat:";
|
|
587
637
|
/** Remove persisted chat for a given tabId (or "default"). */
|
|
@@ -611,7 +661,7 @@ function ensureMessageMetadata(repo) {
|
|
|
611
661
|
// Re-export for backwards compatibility
|
|
612
662
|
import { extractThreadMeta } from "../agent/thread-data-builder.js";
|
|
613
663
|
export { extractThreadMeta };
|
|
614
|
-
const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateText, suggestions, showHeader = true, onSwitchToCli, className, apiUrl, tabId, threadId, onMessageCountChange, onSaveThread, onGenerateTitle, composerSlot, isNewThread, onSlashCommand, execMode, onExecModeChange, }, ref) {
|
|
664
|
+
const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateText, suggestions, showHeader = true, onSwitchToCli, className, apiUrl, tabId, threadId, onMessageCountChange, onSaveThread, onGenerateTitle, composerSlot, isNewThread, onSlashCommand, execMode, onExecModeChange, selectedModel, defaultModel, selectedEngine, availableModels, onModelChange, }, ref) {
|
|
615
665
|
const scrollRef = useRef(null);
|
|
616
666
|
const thread = useThread();
|
|
617
667
|
const threadRuntime = useThreadRuntime();
|
|
@@ -1009,6 +1059,43 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
1009
1059
|
window.addEventListener("agent-chat:missing-api-key", handler);
|
|
1010
1060
|
return () => window.removeEventListener("agent-chat:missing-api-key", handler);
|
|
1011
1061
|
}, []);
|
|
1062
|
+
// Check on mount and whenever SettingsPanel dispatches
|
|
1063
|
+
// `agent-engine:configured-changed` so the gate flips live without reload.
|
|
1064
|
+
useEffect(() => {
|
|
1065
|
+
let cancelled = false;
|
|
1066
|
+
const check = async () => {
|
|
1067
|
+
const [envKeys, builderStatus, engineStatus] = await Promise.all([
|
|
1068
|
+
fetch("/_agent-native/env-status")
|
|
1069
|
+
.then((r) => (r.ok ? r.json() : null))
|
|
1070
|
+
.catch(() => null),
|
|
1071
|
+
fetch("/_agent-native/builder/status")
|
|
1072
|
+
.then((r) => (r.ok ? r.json() : null))
|
|
1073
|
+
.catch(() => null),
|
|
1074
|
+
fetch("/_agent-native/agent-engine/status")
|
|
1075
|
+
.then((r) => (r.ok ? r.json() : null))
|
|
1076
|
+
.catch(() => null),
|
|
1077
|
+
]);
|
|
1078
|
+
if (cancelled)
|
|
1079
|
+
return;
|
|
1080
|
+
// All three status endpoints failed — avoid flashing the gate on a
|
|
1081
|
+
// transient network error.
|
|
1082
|
+
if (envKeys == null && builderStatus == null && engineStatus == null) {
|
|
1083
|
+
return;
|
|
1084
|
+
}
|
|
1085
|
+
const keys = (envKeys ?? []);
|
|
1086
|
+
const llmKeys = keys.filter((k) => PROVIDER_ENV_VAR_SET.has(k.key));
|
|
1087
|
+
const anyConfigured = llmKeys.some((k) => k.configured) ||
|
|
1088
|
+
builderStatus?.configured === true ||
|
|
1089
|
+
engineStatus?.configured === true;
|
|
1090
|
+
setMissingApiKey(!anyConfigured);
|
|
1091
|
+
};
|
|
1092
|
+
check();
|
|
1093
|
+
window.addEventListener("agent-engine:configured-changed", check);
|
|
1094
|
+
return () => {
|
|
1095
|
+
cancelled = true;
|
|
1096
|
+
window.removeEventListener("agent-engine:configured-changed", check);
|
|
1097
|
+
};
|
|
1098
|
+
}, []);
|
|
1012
1099
|
// Listen for auth error events from the adapter
|
|
1013
1100
|
useEffect(() => {
|
|
1014
1101
|
const handler = (e) => {
|
|
@@ -1191,68 +1278,76 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
1191
1278
|
}, 100);
|
|
1192
1279
|
return () => clearInterval(interval);
|
|
1193
1280
|
}, [isRunning]);
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
.
|
|
1222
|
-
.
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1281
|
+
const { isDevMode: cpDevMode } = useDevMode(apiUrl);
|
|
1282
|
+
const checkpointCtx = useMemo(() => ({ apiUrl, devMode: cpDevMode, threadId }), [apiUrl, cpDevMode, threadId]);
|
|
1283
|
+
return (_jsx(CheckpointContext.Provider, { value: checkpointCtx, children: _jsx(ChatRunningContext.Provider, { value: isRunning, children: _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
|
|
1284
|
+
? "Session expired"
|
|
1285
|
+
: "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 () => {
|
|
1286
|
+
try {
|
|
1287
|
+
await fetch("/_agent-native/auth/logout", {
|
|
1288
|
+
method: "POST",
|
|
1289
|
+
});
|
|
1290
|
+
}
|
|
1291
|
+
catch { }
|
|
1292
|
+
window.location.reload();
|
|
1293
|
+
}, 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: () => {
|
|
1294
|
+
setAuthError(null);
|
|
1295
|
+
window.location.reload();
|
|
1296
|
+
}, 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, apiUrl: apiUrl }) })) : 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(IconMessage, { 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: () => {
|
|
1297
|
+
threadRuntime.append({
|
|
1298
|
+
role: "user",
|
|
1299
|
+
content: [{ type: "text", text: suggestion }],
|
|
1300
|
+
});
|
|
1301
|
+
}, 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: "agent-thread-content flex flex-col gap-4 px-4 py-4", children: [_jsx(ThreadPrimitive.Messages, { components: {
|
|
1302
|
+
UserMessage,
|
|
1303
|
+
AssistantMessage,
|
|
1304
|
+
} }), showContinue && !showRunningInUI && (_jsx("div", { className: "flex justify-center py-2", children: _jsx("button", { type: "button", onClick: () => {
|
|
1305
|
+
setShowContinue(false);
|
|
1306
|
+
addToQueue("Continue from where you left off.");
|
|
1307
|
+
}, 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) &&
|
|
1308
|
+
reconnectContent.length > 0 && (_jsx(ReconnectStreamMessage, { content: reconnectContent })), showRunningInUI && (_jsx(ThinkingIndicator, { label: isReconnecting ? "Reconnecting" : "Thinking" })), queuedMessages.map((msg) => {
|
|
1309
|
+
const displayText = msg.text
|
|
1310
|
+
.replace(/<context>[\s\S]*?<\/context>\n?/g, "")
|
|
1311
|
+
.trim();
|
|
1312
|
+
return (_jsx("div", { className: "flex justify-end group", children: _jsxs("div", { className: "relative 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"] }), displayText, 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))) })), _jsx("button", { type: "button", onClick: () => setQueuedMessages((prev) => prev.filter((m) => m.id !== msg.id)), "aria-label": "Remove from queue", className: "absolute -top-2 -right-2 flex h-5 w-5 items-center justify-center rounded-full border border-border bg-background text-muted-foreground opacity-0 group-hover:opacity-100 focus-visible:opacity-100 hover:text-foreground hover:bg-accent shadow-sm", children: _jsx(IconX, { className: "h-3 w-3" }) })] }) }, msg.id));
|
|
1313
|
+
})] })) }), 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: "agent-composer-area 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, disabled: missingApiKey, placeholder: missingApiKey
|
|
1314
|
+
? "Connect an AI engine above to start chatting…"
|
|
1315
|
+
: isRunning
|
|
1316
|
+
? queuedMessages.length > 0
|
|
1317
|
+
? `${queuedMessages.length} queued — type another...`
|
|
1318
|
+
: "Queue a message..."
|
|
1319
|
+
: undefined, onSubmit: isRunning
|
|
1320
|
+
? (text, references) => addToQueue(text, undefined, references.length > 0 ? references : undefined)
|
|
1321
|
+
: undefined, onSlashCommand: onSlashCommand, execMode: execMode, onExecModeChange: onExecModeChange, selectedModel: selectedModel ?? defaultModel, availableModels: availableModels, onModelChange: onModelChange, extraActionButton: showRunningInUI ? (_jsx("button", { type: "button", onClick: () => {
|
|
1322
|
+
// Nuclear stop: flip forceStopped so isRunning is false
|
|
1323
|
+
// immediately. This unblocks submission even if the
|
|
1324
|
+
// runtime or reconnect state is stuck.
|
|
1325
|
+
setForceStopped(true);
|
|
1326
|
+
if (isReconnecting) {
|
|
1327
|
+
if (reconnectRunIdRef.current) {
|
|
1328
|
+
fetch(`${apiUrl}/runs/${encodeURIComponent(reconnectRunIdRef.current)}/abort`, { method: "POST" });
|
|
1329
|
+
}
|
|
1330
|
+
reconnectAbortRef.current?.abort();
|
|
1331
|
+
reconnectAbortRef.current = null;
|
|
1332
|
+
reconnectRunIdRef.current = null;
|
|
1333
|
+
setIsReconnecting(false);
|
|
1334
|
+
setReconnectFrozen(reconnectContent.length > 0);
|
|
1238
1335
|
}
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
detail: {
|
|
1248
|
-
isRunning: false,
|
|
1249
|
-
tabId: tabId || threadId,
|
|
1250
|
-
},
|
|
1251
|
-
}));
|
|
1252
|
-
}, className: "shrink-0 flex h-7 w-7 items-center justify-center rounded-md bg-muted text-foreground hover:bg-muted/80", title: "Stop generating", children: _jsx(IconPlayerStop, { className: "h-3.5 w-3.5" }) })) : undefined })] }) })] }) }));
|
|
1336
|
+
threadRuntime.cancelRun();
|
|
1337
|
+
window.dispatchEvent(new CustomEvent("builder.chatRunning", {
|
|
1338
|
+
detail: {
|
|
1339
|
+
isRunning: false,
|
|
1340
|
+
tabId: tabId || threadId,
|
|
1341
|
+
},
|
|
1342
|
+
}));
|
|
1343
|
+
}, className: "shrink-0 flex h-7 w-7 items-center justify-center rounded-md bg-muted text-foreground hover:bg-muted/80", title: "Stop generating", children: _jsx(IconPlayerStop, { className: "h-3.5 w-3.5" }) })) : undefined })] }) })] }) }) }));
|
|
1253
1344
|
});
|
|
1254
1345
|
export const AssistantChat = forwardRef(function AssistantChat({ apiUrl = "/_agent-native/agent-chat", tabId, threadId, ...props }, ref) {
|
|
1255
|
-
const
|
|
1346
|
+
const modelRef = useRef(props.selectedModel);
|
|
1347
|
+
modelRef.current = props.selectedModel;
|
|
1348
|
+
const engineRef = useRef(props.selectedEngine);
|
|
1349
|
+
engineRef.current = props.selectedEngine;
|
|
1350
|
+
const adapter = useMemo(() => createAgentChatAdapter({ apiUrl, tabId, threadId, modelRef, engineRef }), [apiUrl, tabId, threadId]);
|
|
1256
1351
|
const attachmentAdapter = useMemo(() => new CompositeAttachmentAdapter([
|
|
1257
1352
|
new SimpleImageAttachmentAdapter(),
|
|
1258
1353
|
new SimpleTextAttachmentAdapter(),
|