import "../register-secrets.js"; import { getOrgContext } from "@agent-native/core/org"; import { createAgentChatPlugin, loadActionsFromStaticRegistry, } from "@agent-native/core/server"; // Static-import registry generated by @agent-native/core's Vite plugin at // build time. Using a static import ensures bundlers (Nitro on Netlify, // Vercel, AWS-Lambda) include every action module in the server bundle — // a runtime filesystem scan finds nothing in a bundled function, which is // why `autoDiscoverActions` on its own produces 404s for action routes in // production. import actionsRegistry from "../../.generated/actions-registry.js"; const INITIAL_TOOL_NAMES = [ "view-screen", "list-recordings", "search-recordings", "get-recording-player-data", "prepare-crm-call-evidence", "request-transcript", "create-recording", "import-loom-recording", "update-recording", "finalize-recording", "cleanup-transcript", "regenerate-summary", "regenerate-title", "regenerate-chapters", "trim-recording", "remove-silences", "update-ai-request-status", "remove-filler-words", "export-to-brain", "navigate", "refresh-list", ]; export default createAgentChatPlugin({ appId: "clips", actions: loadActionsFromStaticRegistry(actionsRegistry), initialToolNames: INITIAL_TOOL_NAMES, // Declared in source rather than left to AGENT_CHAT_DURABLE_BACKGROUND alone: // a site-level env var silently overrides netlify.toml, which is how plan and // brain each spent their whole lifetime pinned to the ~58s synchronous wall. durableBackgroundRuns: true, extraContext: async () => ` The transcript in view-screen and get-recording-player-data are bounded previews when called by the agent. When previewTruncated is true, the text is expected to end mid-sentence and is never evidence that transcription stopped early. Use the bounded payload for a concise summary and do not request or reconstruct the omitted transcript by searching other recordings. For a failed or pending transcript, use request-transcript with force=true. For an explicit fresh retry of an existing ready transcript, also pass regenerate=true. Agent-triggered retries are queued for the durable worker and return pending while processing. Clips public recordings are unlisted-by-link, not a searchable public catalog. Treat a recording as known only when it is owned by the current user, already appears in the current screen, or the current user has already viewed it. Do not use list-recordings or search-recordings to discover someone else's clips, recover from a failed direct lookup, answer a date/time question, or search by a title that was not supplied by the user. A question such as when this clip was created refers to the clip already in context; answer it from current-screen or get-recording-player-data. If a direct recording lookup fails, report the failure and stop instead of broadening the search. Only inspect another clip when the user provides its share URL or recording id in the request. `, resolveOrgId: async (event) => (await getOrgContext(event)).orgId, });