{
  "version": 3,
  "sources": ["../../src/document/components/chrome/debugbar/debugBarNavigationStore.ts", "../../src/document/components/chrome/debugbar/agents/examples/useExampleContextFromActiveChatHistory.ts", "../../src/document/components/chrome/debugbar/agents/examples/exampleContextFromHistory.ts"],
  "sourcesContent": ["import { useSyncExternalStore } from \"react\"\n\nexport const DEBUG_BAR_AGENTS_SECTION = \"Agents\"\nexport const DEBUG_BAR_CRDT_SECTION = \"CRDT\"\nexport const DEBUG_BAR_AGENTS_EXAMPLES_CATEGORY = \"Examples\"\n\nconst SECTION_KEY = \"debugBarSection\"\nconst CATEGORY_KEY = \"debugBarAgentsCategory\"\n\nfunction readStoredString(key: string): string | undefined {\n\tif (typeof window === \"undefined\") return undefined\n\ttry {\n\t\tconst json = localStorage.getItem(key)\n\t\tif (!json) return undefined\n\t\treturn JSON.parse(json) as string\n\t} catch {\n\t\treturn undefined\n\t}\n}\n\nlet currentSection = readStoredString(SECTION_KEY)\nlet currentAgentsCategory = readStoredString(CATEGORY_KEY)\n\nconst listeners = new Set<() => void>()\n\nfunction emit() {\n\tfor (const listener of listeners) listener()\n}\n\nfunction subscribe(listener: () => void) {\n\tlisteners.add(listener)\n\treturn () => {\n\t\tlisteners.delete(listener)\n\t}\n}\n\nexport function setDebugBarSection(section: string): void {\n\tif (typeof window === \"undefined\") return\n\tcurrentSection = section\n\tlocalStorage.setItem(SECTION_KEY, JSON.stringify(section))\n\temit()\n}\n\nexport function setDebugBarAgentsCategory(category: string): void {\n\tif (typeof window === \"undefined\") return\n\tcurrentAgentsCategory = category\n\tlocalStorage.setItem(CATEGORY_KEY, JSON.stringify(category))\n\temit()\n}\n\nexport function getDebugBarSection(): string | undefined {\n\treturn currentSection\n}\n\nexport function getDebugBarAgentsCategory(): string | undefined {\n\treturn currentAgentsCategory\n}\n\nexport function useDebugBarSection(): string | undefined {\n\treturn useSyncExternalStore(subscribe, getDebugBarSection)\n}\n\nexport function useDebugBarAgentsCategory(): string | undefined {\n\treturn useSyncExternalStore(subscribe, getDebugBarAgentsCategory)\n}\n", "import { emptyArray } from \"@framerjs/shared\"\nimport engine from \"document/engine.ts\"\nimport { useEffect, useState } from \"react\"\nimport { type ExampleContextFromHistory, getExampleContextFromHistory } from \"./exampleContextFromHistory.ts\"\n\nexport function useExampleContextFromActiveChatHistory() {\n\tconst activeChatAgentId = engine.stores.agentStore.useState(state => state.activeChatAgentId)\n\tconst activeAgent = activeChatAgentId ? engine.stores.agentStore.getAgent(activeChatAgentId) : undefined\n\n\tconst [requests, setRequests] = useState<ExampleContextFromHistory>(() =>\n\t\tgetExampleContextFromHistory(activeAgent?.chatMessages ?? emptyArray()),\n\t)\n\n\tuseEffect(() => {\n\t\treturn activeAgent?.subscribe(() => {\n\t\t\tconst result = getExampleContextFromHistory(activeAgent?.chatMessages ?? emptyArray())\n\t\t\tsetRequests(result)\n\t\t})\n\t}, [activeAgent])\n\n\treturn requests\n}\n", "import { extractEvictedGuidesFromSystemMessage } from \"app/ai/agents/context/guidesSystemState.ts\"\nimport { getRequestModelMessages } from \"app/ai/agents/messages.ts\"\nimport { REDACTED_EXAMPLE_MESSAGE } from \"app/ai/agents/prompt/tools.ts\"\nimport { isExampleErrorResult, isNodeExampleResult } from \"app/ai/agents/tools/readProject.ts\"\nimport {\n\tisReadProjectToolResultPart,\n\tisToolModelMessage,\n\tisToolResultModelPart,\n\tparseReadProjectToolResultOutput,\n} from \"app/ai/agents/tools/transformers/utils.ts\"\nimport type { AgentRequest } from \"app/ai/agents/types.ts\"\n\nexport type ExampleContextStatus = \"in-context\" | \"unloaded\"\n\nexport interface ExampleContextFromHistory {\n\tnodeExampleStatusByName: ReadonlyMap<string, ExampleContextStatus>\n}\n\nfunction isRedactedExample(example: unknown): boolean {\n\treturn example === REDACTED_EXAMPLE_MESSAGE\n}\n\nfunction getExampleContextStatus(example: unknown): ExampleContextStatus {\n\treturn isRedactedExample(example) ? \"unloaded\" : \"in-context\"\n}\n\nexport function getExampleContextFromHistory(requests: readonly AgentRequest[]): ExampleContextFromHistory {\n\tconst nodeExampleStatusByName = new Map<string, ExampleContextStatus>()\n\n\tfor (const request of requests) {\n\t\tfor (const message of getRequestModelMessages(request)) {\n\t\t\tif (!isToolModelMessage(message)) continue\n\n\t\t\tfor (const part of message.content) {\n\t\t\t\tif (!isToolResultModelPart(part) || !isReadProjectToolResultPart(part)) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tconst toolResponse = parseReadProjectToolResultOutput(part.output)\n\t\t\t\tif (!toolResponse) continue\n\n\t\t\t\tfor (const queryResult of toolResponse.queryResults) {\n\t\t\t\t\tif (isExampleErrorResult(queryResult)) continue\n\t\t\t\t\tif (!isNodeExampleResult(queryResult)) continue\n\n\t\t\t\t\tnodeExampleStatusByName.set(queryResult.name, getExampleContextStatus(queryResult.guide))\n\t\t\t\t}\n\n\t\t\t\tconst evictedNodeExamples = extractEvictedGuidesFromSystemMessage(toolResponse.systemState?.guides)\n\t\t\t\tfor (const evictedName of evictedNodeExamples) {\n\t\t\t\t\tnodeExampleStatusByName.set(evictedName, \"unloaded\")\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn { nodeExampleStatusByName }\n}\n"],
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mBAAqC;AAE9B,IAAM,2BAA2B;AACjC,IAAM,yBAAyB;AAC/B,IAAM,qCAAqC;AAElD,IAAM,cAAc;AACpB,IAAM,eAAe;AAErB,SAAS,iBAAiB,KAAiC;AAC1D,MAAI,OAAO,WAAW,YAAa,QAAO;AAC1C,MAAI;AACH,UAAM,OAAO,aAAa,QAAQ,GAAG;AACrC,QAAI,CAAC,KAAM,QAAO;AAClB,WAAO,KAAK,MAAM,IAAI;AAAA,EACvB,QAAQ;AACP,WAAO;AAAA,EACR;AACD;AAEA,IAAI,iBAAiB,iBAAiB,WAAW;AACjD,IAAI,wBAAwB,iBAAiB,YAAY;AAEzD,IAAM,YAAY,oBAAI,IAAgB;AAEtC,SAAS,OA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