{
  "version": 3,
  "sources": ["../../src/document/components/utils/isWaitingForMeasuredRect.ts", "../../../../plugin-api/src/internal.ts", "../../src/plugins/methodPayloadPolicy.ts", "../../src/plugins/isTrustedOrigin.ts", "../../src/plugins/transport.ts", "../../src/app/ai/agents/getPendingClarificationQuestions.ts", "../../../../plugin-api/src/marshal.ts"],
  "sourcesContent": ["import { delay } from \"@framerjs/shared\"\nimport type { VekterEngine } from \"document/VekterEngine.ts\"\nimport type { CanvasNode } from \"document/models/CanvasTree/nodes/CanvasNode.ts\"\nimport { withDOMLayout } from \"document/models/CanvasTree/traits/WithDOMLayout.ts\"\n\n/**\n * Used when you need to determine if a DOM Layout-enabled node is still waiting\n * for its first measurements. Useful in situations like displaying selection\n * outlines where trying to display an outline before node measurements have\n * arrived could show the wrong outline rect.\n *\n * Non-DOM Layout nodes are assumed to have measured rects already.\n *\n * @see waitForMeasuredRect\n * @see waitForMeasuredRectWithTimeout\n *\n * @param node\n * @returns\n */\nexport function isWaitingForMeasuredRect(node: CanvasNode) {\n\tif (!withDOMLayout(node)) return false\n\tif (Boolean(node.usesLayoutTemplateRectForModuleIdentifierCached()) && !node.cache.layoutTemplateRects) return true\n\treturn node.usesDOMRectCached() && node.getDOMRect() === null\n}\n\n/**\n * Waits for a node's measured rect.\n *\n * @see isWaitingForMeasuredRect\n */\n/**\n * Waits for a node's measured rect.\n *\n * @see isWaitingForMeasuredRect\n */\nexport async function waitForMeasuredRect(engine: VekterEngine, node: CanvasNode, abortSignal?: AbortSignal) {\n\tlet waiting = isWaitingForMeasuredRect(node)\n\twhile (waiting) {\n\t\tif (abortSignal?.aborted) return\n\t\tawait new Promise(resolve => engine.scheduler.runBeforeNextFrame(resolve))\n\t\twaiting = isWaitingForMeasuredRect(node)\n\t}\n}\n\n/**\n * Waits for a node's measured rect, but only up to a timeout.\n *\n * @see isWaitingForMeasuredRect\n * @see waitForMeasuredRect\n */\nexport async function waitForMeasuredRectWithTimeout(\n\tengine: VekterEngine,\n\tnodeOrNodes: CanvasNode | readonly CanvasNode[],\n\ttimeoutMs: number = 2000,\n) {\n\tconst nodes = Array.isArray(nodeOrNodes) ? nodeOrNodes : [nodeOrNodes]\n\tconst abortController = new AbortController()\n\n\tconst allWaits = Promise.all(nodes.map(n => waitForMeasuredRect(engine, n, abortController.signal)))\n\n\tconst timeout = (async () => {\n\t\tawait delay(timeoutMs)\n\t\tabortController.abort()\n\t})()\n\n\tawait Promise.race([allWaits, timeout])\n}\n", "// These symbols must be defined as top-level constants first, otherwise they won't be treated as\n// \"unique symbol\" and the resulting type of, for example, FramerPluginAPI will be \"{ [x: symbol]:\n// ... }\" rather than \"{ [yourSymbol]: ... }\", ruining the typing.\n\n// See permissions.ts for why some of these need to be exported. Always use $framerInternal, unless\n// something doesn't work.\n\nexport const getAiServiceInfo = Symbol()\nexport const sendTrackingEvent = Symbol()\nexport const getCurrentUser = Symbol()\nexport const getProjectInfo = Symbol()\nconst environmentInfo = Symbol()\nconst initialState = Symbol()\nconst showUncheckedPermissionToasts = Symbol()\nconst marshal = Symbol()\nconst unmarshal = Symbol()\nexport const getHTMLForNode = Symbol()\nexport const setHTMLForNode = Symbol()\n\nexport const $framerInternal = {\n\tgetAiServiceInfo,\n\tsendTrackingEvent,\n\tgetCurrentUser,\n\tgetProjectInfo,\n\tenvironmentInfo,\n\tinitialState,\n\tshowUncheckedPermissionToasts,\n\tmarshal,\n\tunmarshal,\n\tgetHTMLForNode,\n\tsetHTMLForNode,\n} as const\n\n// Done this way as to make typos like \"ITERNAL_foo\" next to impossible, and make checking whether a\n// message type is internal or not trivial.\nexport const internalMessageTypePrefix = \"INTERNAL_\"\nexport const getAiServiceInfoMessageType = `${internalMessageTypePrefix}getAiServiceInfo`\nexport const sendTrackingEventMessageType = `${internalMessageTypePrefix}sendTrackingEvent`\nexport const getCurrentUserMessageType = `${internalMessageTypePrefix}getCurrentUser`\nexport const getProjectInfoMessageType = `${internalMessageTypePrefix}getProjectInfo`\nexport const getHTMLForNodeMessageType = `${internalMessageTypePrefix}getHTMLForNode`\nexport const setHTMLForNodeMessageType = `${internalMessageTypePrefix}setHTMLForNode`\n", "// Per-(method, clientFamily) sampling for the `payload` field on\n// plugin_method_error / plugin_method_timeout.\n//\n// Most method args are opaque IDs; only a few (DSL apply, CMS writes, publish,\n// agent conversation inputs) are worth keeping. Throws are noisy \u2192 sample\n// down. Hangs are rare \u2192 capture everything.\n\nimport type { PluginMessageAPI } from \"#framer-plugin/framerAPI.ts\"\n\ntype APIMethodName = keyof PluginMessageAPI\n\n// clientId looks like \"framer-api/0.1.10\". Family is the prefix.\n// `unknown` is the legacy framer-api-alpha SDK (no clientId sent).\n// `other` is the long-tail of custom client IDs.\ntype ClientFamily = \"dalton\" | \"framer-api\" | \"unknown\" | \"other\"\n\nfunction isKnownFamily(value: string): value is \"dalton\" | \"framer-api\" {\n\treturn value === \"dalton\" || value === \"framer-api\"\n}\n\nexport function clientFamilyFromId(clientId: string | undefined): ClientFamily {\n\tif (!clientId) return \"unknown\"\n\tconst family = clientId.split(\"/\", 1)[0]\n\tif (family === undefined) return \"other\"\n\treturn isKnownFamily(family) ? family : \"other\"\n}\n\ninterface PayloadDecision {\n\trecord: boolean\n\tsampleRate: number\n\tmaxBytes: number\n}\n\n// `true` = 1.0, `false` = 0.0, else 0..1 sample rate.\ntype SampleMap = Partial<Record<APIMethodName, number | boolean>> & { default: number | boolean }\ntype FamilyMap = Partial<Record<ClientFamily, SampleMap>> & { default: SampleMap }\n\ninterface PathConfig {\n\tmaxBytes: number\n\tfamilies: FamilyMap\n}\n\nexport interface PayloadPolicyConfig {\n\tthrowPath: PathConfig\n\ttimeoutPath: PathConfig\n}\n\n// Sentry headless_timeout tag, last 7d (229 events):\n//   addCollectionItems2          65   addManagedCollectionItems2   56\n//   getChangeContributors        40   applyAgentChanges            27\n//   setCodeFileContent           12   publish                       7\n//   uploadImage                   5   startAgentConversation        4\n//   readProjectForAgent           3   setCollectionItemAttributes2  2\n// Agent-conversation peers added by shape, even without recent hangs.\nconst HIGH_SIGNAL_METHODS: readonly APIMethodName[] = [\n\t\"addCollectionItems2\",\n\t\"addManagedCollectionItems2\",\n\t\"getChangeContributors\",\n\t\"applyAgentChanges\",\n\t\"setCodeFileContent\",\n\t\"publish\",\n\t\"uploadImage\",\n\t\"setCollectionItemAttributes2\",\n\t\"readProjectForAgent\",\n\t\"startAgentConversation\",\n\t\"continueAgentConversation\",\n\t\"runSupervisorAgentCommand\",\n\t\"setLocalizationData\",\n]\n\nfunction highSignalSampleMap(rate: number, defaultRate: number): SampleMap {\n\tconst m: SampleMap = { default: defaultRate }\n\tfor (const name of HIGH_SIGNAL_METHODS) {\n\t\tm[name] = rate\n\t}\n\treturn m\n}\n\n// Sentry 7d: dalton ~37% of throw volume, framer-api+unknown ~62%, other <1%.\n// Dalton is agent traffic \u2014 keep everything. framer-api/unknown sample high-\n// signal methods only. Other: off.\n//\n// Timeouts are ~229/7d total \u2014 record payload for every family \u00D7 method.\nexport const DEFAULT_POLICY: PayloadPolicyConfig = {\n\tthrowPath: {\n\t\tmaxBytes: 16_384,\n\t\tfamilies: {\n\t\t\tdalton: { default: 1.0 },\n\t\t\t\"framer-api\": highSignalSampleMap(0.25, 0.0),\n\t\t\tunknown: highSignalSampleMap(0.25, 0.0),\n\t\t\tdefault: { default: 0.0 },\n\t\t},\n\t},\n\ttimeoutPath: {\n\t\tmaxBytes: 16_384,\n\t\tfamilies: {\n\t\t\tdefault: { default: 1.0 },\n\t\t},\n\t},\n}\n\nfunction resolveSampleRate(config: PathConfig, family: ClientFamily, methodName: APIMethodName): number {\n\tconst familyMap = config.families[family] ?? config.families.default\n\tconst raw = familyMap[methodName] ?? familyMap.default\n\tif (raw === true) return 1.0\n\tif (raw === false) return 0.0\n\treturn raw\n}\n\nexport function shouldRecordThrowPayload(\n\tmethodName: APIMethodName,\n\tclientId: string | undefined,\n\tpolicy: PayloadPolicyConfig = DEFAULT_POLICY,\n): PayloadDecision {\n\treturn decide(policy.throwPath, clientFamilyFromId(clientId), methodName)\n}\n\nexport function shouldRecordTimeoutPayload(\n\tmethodName: APIMethodName,\n\tclientId: string | undefined,\n\tpolicy: PayloadPolicyConfig = DEFAULT_POLICY,\n): PayloadDecision {\n\treturn decide(policy.timeoutPath, clientFamilyFromId(clientId), methodName)\n}\n\nfunction decide(config: PathConfig, family: ClientFamily, methodName: APIMethodName): PayloadDecision {\n\tconst sampleRate = resolveSampleRate(config, family, methodName)\n\tconst maxBytes = config.maxBytes\n\tif (sampleRate <= 0) return { record: false, sampleRate, maxBytes }\n\tif (sampleRate >= 1) return { record: true, sampleRate, maxBytes }\n\treturn { record: Math.random() < sampleRate, sampleRate, maxBytes }\n}\n", "import type { PluginManifestId } from \"./plugins.ts\"\n\n// For Workspace Plugins we want to support configuring `trustedOrigins` in the framer.json manifest.\n// In order to unblock Bunq, we are hardcoding an allowlisted of trusted origins for their Owner ID\n// TODO: Remove this allowlist once https://github.com/framer/company/issues/34024 is implemented\nconst bunqTrustedOrigins = new Set([\"https://framer-plugins.bunq.net\", \"https://framer-plugins.bunq.com\"])\nconst bunqOwnerId = \"185fe6b1-0a2d-44da-93f5-b81332748d4a\"\nconst supportedOriginsByOwnerId: Record<PluginManifestId, Set<string>> = {\n\t[bunqOwnerId]: bunqTrustedOrigins,\n}\n\ninterface IsTrustedOriginOptions {\n\tentrypointOrigin: string\n\tmessageOrigin: string\n\townerId: string | undefined\n}\n\nexport function isTrustedOrigin({ entrypointOrigin, messageOrigin, ownerId }: IsTrustedOriginOptions) {\n\tif (entrypointOrigin === messageOrigin) return true\n\n\tif (!ownerId) return false\n\n\tconst trustedOrigins = supportedOriginsByOwnerId[ownerId]\n\tif (!trustedOrigins) return false\n\n\treturn trustedOrigins.has(messageOrigin)\n}\n\nexport const testing = { bunqOwnerId }\n", "import { ResolvablePromise } from \"@framerjs/shared\"\nimport * as Sentry from \"@sentry/browser\"\nimport { record } from \"web/lib/tracker.ts\"\nimport type { PluginMessageAPI } from \"#framer-plugin/framerAPI.ts\"\nimport type { PluginToVekterMessage, VekterToPluginMessage } from \"#framer-plugin/messages.ts\"\nimport { isPluginToVekterMessage } from \"#framer-plugin/messages.ts\"\nimport { isTrustedOrigin } from \"./isTrustedOrigin.ts\"\nimport { shouldRecordTimeoutPayload } from \"./methodPayloadPolicy.ts\"\nimport { apiPluginManifest } from \"./plugins.ts\"\n\nexport interface PluginTransport {\n\tstart(): void\n\tstop(): void\n\tsend(message: VekterToPluginMessage): void\n\tonMessage(handler: (message: PluginToVekterMessage) => void): void\n}\n\nexport class IframeTransport implements PluginTransport {\n\tprivate messageHandler?: (message: PluginToVekterMessage) => void\n\tprivate postMessageHandler?: (message: VekterToPluginMessage) => void\n\n\tconstructor(\n\t\tprivate readonly entrypointOrigin: string,\n\t\tprivate readonly ownerId: string | undefined,\n\t) {}\n\n\tstart(): void {\n\t\tif (typeof window !== \"undefined\") {\n\t\t\twindow.addEventListener(\"message\", this.handleWindowMessage)\n\t\t}\n\t}\n\n\tstop(): void {\n\t\tif (typeof window !== \"undefined\") {\n\t\t\twindow.removeEventListener(\"message\", this.handleWindowMessage)\n\t\t}\n\t}\n\n\tsend(message: VekterToPluginMessage): void {\n\t\tif (this.postMessageHandler) {\n\t\t\tthis.postMessageHandler(message)\n\t\t}\n\t}\n\n\tonMessage(handler: (message: PluginToVekterMessage) => void): void {\n\t\tthis.messageHandler = handler\n\t}\n\n\tprivate handleWindowMessage = (event: MessageEvent) => {\n\t\tif (!event.source) return\n\n\t\tif (\n\t\t\t!isTrustedOrigin({\n\t\t\t\tentrypointOrigin: this.entrypointOrigin,\n\t\t\t\tmessageOrigin: event.origin,\n\t\t\t\townerId: this.ownerId,\n\t\t\t})\n\t\t) {\n\t\t\treturn\n\t\t}\n\n\t\tif (!this.postMessageHandler) {\n\t\t\tconst options = { targetOrigin: event.origin }\n\t\t\tconst source = event.source\n\t\t\tthis.postMessageHandler = data => source.postMessage(data, options)\n\t\t}\n\n\t\tconst message = event.data\n\t\tif (this.messageHandler && isPluginToVekterMessage(message)) {\n\t\t\tthis.messageHandler(message)\n\t\t}\n\t}\n}\n\ntype MethodTimeouts = Partial<Record<keyof PluginMessageAPI, number>> & { $default: number }\n\nconst longTimeout = 10 * 60 * 1000\n\nconst DEFAULT_TIMEOUTS: MethodTimeouts = {\n\t$default: 120_000,\n\tstartAgentConversation: longTimeout,\n\tcontinueAgentConversation: longTimeout,\n\trunSupervisorAgentCommand: longTimeout,\n\tgetActiveLocale: longTimeout,\n\tsetLocalizationData: longTimeout,\n\tpublish: longTimeout,\n}\n\n/** Tagged-payload format for the `sendToNodePlugin` bridge \u2014 mirrors\n *  FramerHeadlessApi/src/utils/messages.ts. Older backends that don't\n *  recognize the tag drop the payload silently. */\nconst TAG_OPEN = \"\\x01\"\nconst TAG_CLOSE = \"\\x02\"\nconst PLUGIN_META_TAG = \"META\"\nconst buildTaggedPrefix = (tag: string) => `${TAG_OPEN}${tag}${TAG_CLOSE}`\nexport const PLUGIN_META_PREFIX = buildTaggedPrefix(PLUGIN_META_TAG)\n\ninterface PluginBridgeHost {\n\tsendToNodePlugin?: (payload: string) => void\n}\n\ninterface PluginMethodStartMeta {\n\tv: 1\n\ttype: \"method_start\"\n\tid: number\n\tmethodName: string\n}\n\ninterface PluginMethodEndMeta {\n\tv: 1\n\ttype: \"method_end\"\n\tid: number\n\treason?: \"completed\" | \"timeout\" | \"reset\"\n}\n\nfunction emitPluginMeta(meta: PluginMethodStartMeta | PluginMethodEndMeta): void {\n\tconst send = (globalThis as PluginBridgeHost).sendToNodePlugin\n\tif (!send) return\n\ttry {\n\t\tsend(PLUGIN_META_PREFIX + JSON.stringify(meta))\n\t} catch {\n\t\t// Best-effort signal \u2014 never let a meta-emit failure break the dispatch path.\n\t}\n}\n\n// Worst-case width of `\u2026[truncated:<n>]` for n up to a few GB. 32 covers it.\nconst TRUNCATED_SUFFIX_RESERVE = 32\nconst utf8Encoder = new TextEncoder()\nconst utf8Decoder = new TextDecoder(\"utf-8\", { fatal: false })\n\n// JSON-stringify with a hard UTF-8 byte cap; appends `\u2026[truncated:<orig>]`\n// when cut. `maxBytes` is the budget for the *emitted* string in UTF-8 bytes\n// (not UTF-16 code units, not characters) \u2014 Cyrillic / CJK / emoji payloads\n// stay under the cap instead of overshooting 2-3\u00D7.\nexport function serializeMethodArgsForError(args: unknown[], maxBytes = 16_384): string {\n\tlet serialized: string\n\ttry {\n\t\tserialized = JSON.stringify(args)\n\t} catch {\n\t\treturn \"[unserializable]\"\n\t}\n\tconst bytes = utf8Encoder.encode(serialized)\n\tif (bytes.length <= maxBytes) return serialized\n\tconst budget = Math.max(0, maxBytes - TRUNCATED_SUFFIX_RESERVE)\n\treturn `${truncateToUtf8Bytes(bytes, budget)}\u2026[truncated:${bytes.length}]`\n}\n\n// Clamp a pre-encoded UTF-8 byte array to at most `maxBytes`, walking back\n// to a code-point boundary so we never emit a half-decoded character.\nfunction truncateToUtf8Bytes(bytes: Uint8Array, maxBytes: number): string {\n\tif (bytes.length <= maxBytes) return utf8Decoder.decode(bytes)\n\tlet end = maxBytes\n\t// UTF-8 continuation bytes are 10xxxxxx \u2014 back up until we're on a lead byte.\n\twhile (end > 0 && ((bytes[end] ?? 0) & 0xc0) === 0x80) end--\n\treturn utf8Decoder.decode(bytes.subarray(0, end))\n}\n\nexport class HeadlessTransport implements PluginTransport {\n\tprivate messageHandler?: (message: PluginToVekterMessage) => void | Promise<void>\n\tprivate sendHandler?: (message: VekterToPluginMessage) => void\n\t// timerId + a settled-signal so HeadlessAPI can release the heavy-method gate when transport\n\t// times the call out, even if the underlying handler promise never settles.\n\tprivate pendingTimers = new Map<\n\t\tnumber,\n\t\t{ timerId: ReturnType<typeof setTimeout>; settled: ResolvablePromise<void> }\n\t>()\n\tprivate timedOutIds = new Set<number>()\n\tprivate stopped = false\n\t// Bumped on setSendHandler (new session). updateSendHandler keeps it stable so\n\t// same-session wrapper upgrades don't drop in-flight replies.\n\tprivate sessionEpoch = 0\n\tprivate readonly timeouts: MethodTimeouts\n\tprivate sessionId?: string\n\tprivate clientId?: string\n\tprivate overrideTimeoutMs?: number\n\n\tconstructor(timeouts?: MethodTimeouts) {\n\t\tthis.timeouts = timeouts ?? DEFAULT_TIMEOUTS\n\t}\n\n\t/** HeadlessAPI calls this when a session attaches so the transport can\n\t *  tag timeout-path telemetry with the right session/client identifiers. */\n\tsetSessionContext(sessionId: string | undefined, clientId: string | undefined): void {\n\t\tthis.sessionId = sessionId\n\t\tthis.clientId = clientId\n\t}\n\n\t/** Debug-bar only. Overrides the default timeout so test buttons can fire\n\t *  `plugin_method_timeout` in a second instead of two minutes. Pass\n\t *  `undefined` to clear. */\n\tsetOverrideTimeoutMs(ms: number | undefined): void {\n\t\tthis.overrideTimeoutMs = ms\n\t}\n\n\t/** Debug-bar only. Drives the timeout machinery without invoking a real\n\t *  method handler \u2014 the timer fires after `getTimeoutMs(methodName)` and\n\t *  records `plugin_method_timeout`. Avoids the pitfall where a real\n\t *  method (e.g. applyAgentChanges) throws on parse before the timer\n\t *  could fire. */\n\tscheduleTimeoutForTest(methodName: keyof PluginMessageAPI, args: unknown[]): number {\n\t\tconst id = -Math.floor(Math.random() * 1_000_000) - 1\n\t\tvoid this.startTimeout({ type: \"methodInvocation\", id, methodName, args })\n\t\treturn id\n\t}\n\n\tprivate getTimeoutMs(methodName: keyof PluginMessageAPI): number {\n\t\tif (this.overrideTimeoutMs !== undefined) return this.overrideTimeoutMs\n\t\treturn this.timeouts[methodName] ?? this.timeouts.$default\n\t}\n\n\t/** Number of plugin-method invocations awaiting a response from Vekter.\n\t *  Used by HeadlessAPI to delay standby release until in-flight work drains. */\n\tget pendingMethodCount(): number {\n\t\treturn this.pendingTimers.size\n\t}\n\n\tstart(): void {}\n\n\tprivate reset(): void {\n\t\tfor (const [id, entry] of this.pendingTimers) {\n\t\t\tclearTimeout(entry.timerId)\n\t\t\tentry.settled.resolve()\n\t\t\t// Signal end for everything we're about to forget, otherwise the\n\t\t\t// backend's inflight registry holds ghost entries for this session.\n\t\t\temitPluginMeta({ v: 1, type: \"method_end\", id, reason: \"reset\" })\n\t\t}\n\t\tthis.pendingTimers.clear()\n\t\tthis.timedOutIds.clear()\n\t}\n\n\t/** Mirrors the timeout handler: marks ids in `timedOutIds` so late real\n\t *  responses from the original handler are suppressed by `send()`. */\n\tfailPendingMethods(reason: string): void {\n\t\tconst send = this.sendHandler\n\t\tif (!send) return\n\t\tconst inflight = Array.from(this.pendingTimers.entries())\n\t\tfor (const [id, entry] of inflight) {\n\t\t\tclearTimeout(entry.timerId)\n\t\t\tentry.settled.resolve()\n\t\t\tthis.pendingTimers.delete(id)\n\t\t\tthis.timedOutIds.add(id)\n\t\t\temitPluginMeta({ v: 1, type: \"method_end\", id, reason: \"reset\" })\n\t\t\tPromise.resolve(send({ type: \"methodResponse\", id, result: null, error: reason })).catch(() => {})\n\t\t}\n\t}\n\n\tstop(): void {\n\t\tthis.stopped = true\n\t\tthis.reset()\n\t}\n\n\tsend(message: VekterToPluginMessage): void {\n\t\tif (!this.sendHandler) return\n\n\t\tif (message.type === \"methodResponse\") {\n\t\t\tconst id = message.id\n\n\t\t\tconst entry = this.pendingTimers.get(id)\n\t\t\tif (entry) {\n\t\t\t\tclearTimeout(entry.timerId)\n\t\t\t\tentry.settled.resolve()\n\t\t\t\tthis.pendingTimers.delete(id)\n\t\t\t\tSentry.addBreadcrumb({\n\t\t\t\t\tmessage: \"Method response\",\n\t\t\t\t\tlevel: \"info\",\n\t\t\t\t\tdata: { id, hasError: message.error !== null },\n\t\t\t\t})\n\t\t\t\t// Only signal end when this `send` is the first completion event.\n\t\t\t\t// On the late-response-after-timeout path the timeout handler\n\t\t\t\t// already emitted `method_end`; emitting again would double-count\n\t\t\t\t// in the backend inflight registry.\n\t\t\t\temitPluginMeta({ v: 1, type: \"method_end\", id, reason: \"completed\" })\n\t\t\t}\n\n\t\t\tif (this.timedOutIds.has(id)) {\n\t\t\t\tthis.timedOutIds.delete(id)\n\t\t\t\tSentry.addBreadcrumb({\n\t\t\t\t\tmessage: \"Suppressed late response for timed-out method\",\n\t\t\t\t\tlevel: \"info\",\n\t\t\t\t\tdata: { id },\n\t\t\t\t})\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tthis.sendHandler(message)\n\t}\n\n\tonMessage(handler: (message: PluginToVekterMessage) => void): void {\n\t\tthis.messageHandler = handler\n\t}\n\n\t/** Replace handler and reset all state. Used for session transitions (standby reuse). */\n\tsetSendHandler(handler: (message: VekterToPluginMessage) => void): void {\n\t\tthis.sendHandler = handler\n\t\tthis.stopped = false\n\t\tthis.sessionEpoch++\n\t\tthis.reset()\n\t}\n\n\t/** Replace handler without resetting timers. Used for handler upgrades within a session. */\n\tupdateSendHandler(handler: (message: VekterToPluginMessage) => void): void {\n\t\tthis.sendHandler = handler\n\t}\n\n\tcaptureSessionOrigin(): number {\n\t\treturn this.sessionEpoch\n\t}\n\n\t/** Drops the reply if setSendHandler ran since `origin` was captured.\n\t *  updateSendHandler (same-session wrapper upgrade) keeps the epoch stable. */\n\treplyToSessionOrigin(origin: number, message: VekterToPluginMessage): void {\n\t\tif (origin !== this.sessionEpoch) return\n\t\tthis.send(message)\n\t}\n\n\t/** Returns a promise that settles when the call completes, times out, or is reset.\n\t *  Callers can race this to free per-call resources (e.g. the heavy-method gate slot)\n\t *  the moment transport declares the call done \u2014 even if the underlying handler hangs. */\n\tprivate startTimeout(message: PluginToVekterMessage): ResolvablePromise<void> | undefined {\n\t\tif (message.type !== \"methodInvocation\") return undefined\n\n\t\tconst { id, methodName, args } = message\n\t\temitPluginMeta({ v: 1, type: \"method_start\", id, methodName })\n\n\t\tconst settled = new ResolvablePromise<void>()\n\t\tvoid settled.pending()\n\t\tvoid settled.catch(() => {})\n\n\t\tconst sessionId = this.sessionId\n\t\tconst clientId = this.clientId\n\t\tconst timeoutMs = this.getTimeoutMs(methodName)\n\t\tconst timerId = setTimeout(() => {\n\t\t\tthis.pendingTimers.delete(id)\n\t\t\tthis.timedOutIds.add(id)\n\t\t\tsettled.resolve()\n\t\t\temitPluginMeta({ v: 1, type: \"method_end\", id, reason: \"timeout\" })\n\t\t\tconst timeoutMessage = `Method \"${methodName}\" timed out after ${timeoutMs}ms`\n\t\t\tSentry.captureException(new Error(timeoutMessage), {\n\t\t\t\ttags: { headless_timeout: methodName },\n\t\t\t\textra: { id, methodName, timeoutMs },\n\t\t\t})\n\t\t\t// Separate event from plugin_method_error: the late throw still\n\t\t\t// fires sendMethodResultError, so unioning would double-count.\n\t\t\ttry {\n\t\t\t\tconst decision = shouldRecordTimeoutPayload(methodName, clientId)\n\t\t\t\trecord(\"plugin_method_timeout\", {\n\t\t\t\t\turl: \"headless-api\",\n\t\t\t\t\tid: apiPluginManifest.id,\n\t\t\t\t\tmode: \"api\",\n\t\t\t\t\tmethodName,\n\t\t\t\t\ttimeoutMs,\n\t\t\t\t\tpluginName: apiPluginManifest.name,\n\t\t\t\t\tsessionId,\n\t\t\t\t\tclientId,\n\t\t\t\t\t...(decision.record ? { payload: serializeMethodArgsForError(args, decision.maxBytes) } : {}),\n\t\t\t\t})\n\t\t\t} catch (recordError) {\n\t\t\t\tSentry.captureException(recordError, {\n\t\t\t\t\textra: { source: \"HeadlessTransport.record\", id, methodName },\n\t\t\t\t})\n\t\t\t}\n\t\t\tPromise.resolve(\n\t\t\t\tthis.sendHandler?.({\n\t\t\t\t\ttype: \"methodResponse\",\n\t\t\t\t\tid,\n\t\t\t\t\tresult: null,\n\t\t\t\t\terror: timeoutMessage,\n\t\t\t\t}),\n\t\t\t).catch(error => {\n\t\t\t\tSentry.captureException(error, { extra: { source: \"HeadlessTransport.timeout\", id, methodName } })\n\t\t\t})\n\t\t}, timeoutMs)\n\t\tthis.pendingTimers.set(id, { timerId, settled })\n\t\treturn settled\n\t}\n\n\treceiveMessage(message: PluginToVekterMessage): Promise<void> {\n\t\tif (!this.messageHandler || this.stopped) {\n\t\t\tif (message.type === \"methodInvocation\") {\n\t\t\t\tthis.send({\n\t\t\t\t\ttype: \"methodResponse\",\n\t\t\t\t\tid: message.id,\n\t\t\t\t\tresult: null,\n\t\t\t\t\terror: \"HeadlessSessionClosed: plugin transport not connected\",\n\t\t\t\t})\n\t\t\t}\n\t\t\treturn Promise.resolve()\n\t\t}\n\t\tconst settled = this.startTimeout(message)\n\n\t\t// Invoke the handler synchronously (callers depend on the side effect landing before\n\t\t// the next line) but normalize any synchronous throw into a rejected promise so\n\t\t// HeavyMethodGate's `.finally(release)` still fires.\n\t\tlet handlerResult: void | Promise<void>\n\t\ttry {\n\t\t\thandlerResult = this.messageHandler(message)\n\t\t} catch (error) {\n\t\t\thandlerResult = Promise.reject(error)\n\t\t}\n\t\tconst handler = Promise.resolve(handlerResult).catch(error => {\n\t\t\tSentry.captureException(error, { extra: { source: \"HeadlessTransport.receiveMessage\" } })\n\t\t})\n\t\t// Resolve on whichever fires first: handler completing or transport's timer firing.\n\t\t// Without the race, a hung handler holds the heavy-method gate slot indefinitely\n\t\t// even though transport has already failed the call back to the client.\n\t\treturn settled ? Promise.race([handler, settled]) : handler\n\t}\n}\n", "import type { ClarificationQuestion } from \"./tools/askClarification.ts\"\nimport type { AgentRequest } from \"./types.ts\"\n\n/**\n * Returns the pending clarification questions (questions without **any** answers) for the given\n * agent requests.\n */\nexport function getPendingClarificationQuestions(\n\trequests: readonly AgentRequest[] | undefined,\n): readonly ClarificationQuestion[] | undefined {\n\tif (!requests) return\n\n\tfor (let r = requests.length - 1; r >= 0; r--) {\n\t\tconst messages = requests[r]?.state.messages\n\t\tif (!messages) continue\n\n\t\tfor (let m = messages.length - 1; m >= 0; m--) {\n\t\t\tconst message = messages[m]\n\t\t\tif (message?.type !== \"clarification\") continue\n\t\t\treturn message.answers ? undefined : message.questions\n\t\t}\n\t}\n\n\treturn\n}\n", "import { $framerInternal } from \"./internal.ts\"\nimport { isArray, isObject, isPlainObject } from \"./utils.ts\"\n\nexport const pluginMarshalTag = \"plugin-marshal\"\n\nexport type Marshaled<T> = T extends { [$framerInternal.marshal]: () => unknown }\n\t? ReturnType<T[typeof $framerInternal.marshal]>\n\t: T extends string & {} // Because of csstype, which uses this as a code hint hack\n\t\t? T\n\t\t: T extends number & {}\n\t\t\t? T\n\t\t\t: T extends object // Covers arrays too\n\t\t\t\t? { [K in keyof T]: Marshaled<T[K]> }\n\t\t\t\t: T\n\nexport function isSelfMarshalable<T>(value: T): value is T & { [$framerInternal.marshal]: () => Marshaled<T> } {\n\treturn isObject(value) && $framerInternal.marshal in value\n}\n\n// No attempt to reject any values, that's JSON.stringify's and Typia's job\nexport function marshal<T>(value: T): Marshaled<T> {\n\ttype R = ReturnType<typeof marshal<T>>\n\n\tif (isSelfMarshalable(value)) return value[$framerInternal.marshal]()\n\tif (isArray(value)) return value.map(marshal) as R\n\n\t// Rules out any class instances, including that of Uint8Array\n\tif (isPlainObject(value)) {\n\t\tconst result: Record<string, unknown> = {}\n\t\tfor (const key of Object.keys(value)) {\n\t\t\tresult[key] = marshal(value[key])\n\t\t}\n\n\t\treturn result as R\n\t}\n\n\treturn value as R\n}\n"],
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAmBO,SAAS,yBAAyB,MAAkB;AAC1D,MAAI,CAAC,cAAc,IAAI,EAAG,QAAO;AACjC,MAAI,QAAQ,KAAK,gDAAgD,CAAC,KAAK,CAAC,KAAK,MAAM,oBAAqB,QAAO;AAC/G,SAAO,KAAK,kBAAkB,KAAK,KAAK,WAAW,MAAM;AAC1D;AAYA,eAAsB,oBAAoB,QAAsB,MAAkB,aAA2B;AAC5G,MAAI,UAAU,yBAAyB,IAAI;AAC3C,SAAO,SAAS;AACf,QAAI,aAAa,QAAS;AAC1B,UAAM,IAAI,QAAQ,aAAW,OAAO,UAAU,mBAAmB,OAAO,CAAC;AACzE,cAAU,yBAAyB,IAAI;AAAA,EACxC;AACD;AAQA,eAAsB,+BACrB,QACA,aACA,YAAoB,KACnB;AACD,QAAM,QAAQ,MAAM,QAAQ,WAAW,IAAI,cAAc,CAAC,WAAW;AACrE,QAAM,kBAAkB,IAAI,gBAAgB;AAE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