{"version":3,"file":"agent-model.cjs","names":["DOOM_AGENT_MODEL_ENTRY_TYPE"],"sources":["../../src/extensions/agentModel.ts"],"sourcesContent":["import { type AgentModelProjection, DOOM_AGENT_MODEL_ENTRY_TYPE } from '@agimon-ai/doompi-core/agent-model';\nimport type { ExtensionAPI } from '@earendil-works/pi-coding-agent';\n\n/**\n * Journals the model the agent is on whenever something inside the agent\n * changes it.\n *\n * Pi announces a thinking-level switch on the wire, so a cockpit can follow\n * that field from the frame alone. It announces a model switch only in-process,\n * through `model_select`. Without this entry a client that did not itself ask\n * for the switch keeps whatever model its last `get_state` reported, which is\n * what plan mode applying its configured planning model looks like from a\n * browser: the footer names the model the session left behind.\n *\n * The entry rides Pi's `entry_appended` frames, the same road the minor-mode\n * projection takes, so it reaches live and replaying clients alike.\n */\nexport function publishAgentModel(\n  pi: Pick<ExtensionAPI, 'appendEntry'>,\n  projection: AgentModelProjection,\n  published: string | undefined,\n): string {\n  const serialized = JSON.stringify(projection);\n  // A model_select that resolves to the model already on the record is noise:\n  // plan mode restoring the model it never actually changed still fires one.\n  if (serialized === published) return serialized;\n  pi.appendEntry(DOOM_AGENT_MODEL_ENTRY_TYPE, projection);\n  return serialized;\n}\n\nexport function agentModelExtension(pi: ExtensionAPI): void {\n  let published: string | undefined;\n  pi.on('model_select', (event) => {\n    published = publishAgentModel(pi, { provider: event.model.provider, id: event.model.id }, published);\n  });\n}\n\nexport default agentModelExtension;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAiBA,SAAgB,kBACd,IACA,YACA,WACQ;CACR,MAAM,aAAa,KAAK,UAAU,UAAU;CAG5C,IAAI,eAAe,WAAW,OAAO;CACrC,GAAG,YAAYA,mCAAAA,6BAA6B,UAAU;CACtD,OAAO;AACT;AAEA,SAAgB,oBAAoB,IAAwB;CAC1D,IAAI;CACJ,GAAG,GAAG,iBAAiB,UAAU;EAC/B,YAAY,kBAAkB,IAAI;GAAE,UAAU,MAAM,MAAM;GAAU,IAAI,MAAM,MAAM;EAAG,GAAG,SAAS;CACrG,CAAC;AACH"}