import { getOrgContext } from "@agent-native/core/org"; import "../register-secrets.js"; 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"; import { searchRecordingReferences, validateRecordingReferences, } from "../lib/composer-references.js"; import { INITIAL_TOOL_NAMES } from "../lib/initial-tool-names.js"; export default createAgentChatPlugin({ appId: "clips", mentionProviders: { recordings: { label: "composerSources.group", search: searchRecordingReferences, }, }, prepareRequest: async ({ references }) => { await validateRecordingReferences(references); }, mcp: { appApprovalPage: true }, actions: loadActionsFromStaticRegistry(actionsRegistry), initialToolNames: INITIAL_TOOL_NAMES, durableBackgroundRuns: true, extraContext: async () => ` The transcript in view-screen and get-recording-player-data is bounded 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. Continue the same recording with get-recording-player-data and transcriptOffset set to each nextFullTextOffset until that value is null, then interpret the chunks together. Do not search other recordings to reconstruct omitted content. 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. For summaries, action-item lists, follow-up lists, and todo lists based on the recording in view, use Clips' recording/transcript actions and answer directly in this chat. Do not call Plan or another app for a generic written list. Only delegate to Plan when the user explicitly asks for a visual or structured Agent-Native Plan, a Plan artifact, or the Plans app. 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, });