{
  "version": 3,
  "sources": ["../../src/model-api.ts", "../../src/terminal.ts"],
  "sourcesContent": ["import type { Api, Model } from \"@earendil-works/pi-ai\";\nimport type { CodexCompactSettings } from \"./settings.js\";\n\nexport const RESPONSES_COMPACTION_APIS = [\n  \"openai-codex-responses\",\n  \"openai-responses\",\n  \"azure-openai-responses\",\n] as const;\n\nexport type BuiltInResponsesCompactionApi = (typeof RESPONSES_COMPACTION_APIS)[number];\nexport type ResponsesCompactionApi = BuiltInResponsesCompactionApi;\nexport type ResponsesCompactionProfile = \"codex-responses-v1\" | \"openai-responses-v1\";\nexport type RemoteCompactionProtocol = \"remote-v2\" | \"responses-compact\";\nexport type RemoteCompactionProtocolSetting = \"auto\" | RemoteCompactionProtocol;\n\nexport type CompactionRoute =\n  | { kind: \"remote\"; protocol: RemoteCompactionProtocol; api: Api; profile: ResponsesCompactionProfile }\n  | { kind: \"native\"; reason: string };\n\nfunction resolveResponsesCompactionProfile(\n  api: Api | undefined,\n  apiProfiles: Readonly<Record<string, \"codex-responses-v1\">> = {},\n): ResponsesCompactionProfile | undefined {\n  if (api === \"openai-codex-responses\") return \"codex-responses-v1\";\n  if (api === \"openai-responses\" || api === \"azure-openai-responses\") return \"openai-responses-v1\";\n  return api && Object.hasOwn(apiProfiles, api) && apiProfiles[api] === \"codex-responses-v1\"\n    ? \"codex-responses-v1\"\n    : undefined;\n}\n\nexport function resolveCompactionRouteForApi(\n  api: Api | undefined,\n  options: Pick<CodexCompactSettings, \"enabled\" | \"protocol\"> & {\n    apiProfiles?: Readonly<Record<string, \"codex-responses-v1\">>;\n  },\n): CompactionRoute {\n  if (!options.enabled) return { kind: \"native\", reason: \"remote compaction is disabled\" };\n  if (!api) return { kind: \"native\", reason: \"no active model\" };\n  const profile = resolveResponsesCompactionProfile(api, options.apiProfiles);\n  if (!profile) {\n    return { kind: \"native\", reason: `API ${api} does not support Responses compaction` };\n  }\n  const protocol =\n    options.protocol === \"auto\"\n      ? profile === \"codex-responses-v1\"\n        ? \"remote-v2\"\n        : \"responses-compact\"\n      : options.protocol;\n  return { kind: \"remote\", protocol, api, profile };\n}\n\nexport function resolveCompactionRoute(\n  model: Model<Api> | undefined,\n  options: Pick<CodexCompactSettings, \"enabled\" | \"protocol\"> & {\n    apiProfiles?: Readonly<Record<string, \"codex-responses-v1\">>;\n  },\n): CompactionRoute {\n  return resolveCompactionRouteForApi(model?.api, options);\n}\n", "export function terminalText(value: string): string {\n  return Array.from(value, (character) => {\n    const codePoint = character.codePointAt(0) ?? 0;\n    return codePoint < 32 || (codePoint >= 127 && codePoint <= 159) ? \" \" : character;\n  }).join(\"\");\n}\n"],
  "mappings": ";;;;AAmBA,SAAS,kCACP,KACA,cAA8D,CAAC,GACvB;AACxC,MAAI,QAAQ,yBAA0B,QAAO;AAC7C,MAAI,QAAQ,sBAAsB,QAAQ,yBAA0B,QAAO;AAC3E,SAAO,OAAO,OAAO,OAAO,aAAa,GAAG,KAAK,YAAY,GAAG,MAAM,uBAClE,uBACA;AACN;AAEO,SAAS,6BACd,KACA,SAGiB;AACjB,MAAI,CAAC,QAAQ,QAAS,QAAO,EAAE,MAAM,UAAU,QAAQ,gCAAgC;AACvF,MAAI,CAAC,IAAK,QAAO,EAAE,MAAM,UAAU,QAAQ,kBAAkB;AAC7D,QAAM,UAAU,kCAAkC,KAAK,QAAQ,WAAW;AAC1E,MAAI,CAAC,SAAS;AACZ,WAAO,EAAE,MAAM,UAAU,QAAQ,OAAO,GAAG,yCAAyC;AAAA,EACtF;AACA,QAAM,WACJ,QAAQ,aAAa,SACjB,YAAY,uBACV,cACA,sBACF,QAAQ;AACd,SAAO,EAAE,MAAM,UAAU,UAAU,KAAK,QAAQ;AAClD;AAEO,SAAS,uBACd,OACA,SAGiB;AACjB,SAAO,6BAA6B,OAAO,KAAK,OAAO;AACzD;;;AC1DO,SAAS,aAAa,OAAuB;AAClD,SAAO,MAAM,KAAK,OAAO,CAAC,cAAc;AACtC,UAAM,YAAY,UAAU,YAAY,CAAC,KAAK;AAC9C,WAAO,YAAY,MAAO,aAAa,OAAO,aAAa,MAAO,MAAM;AAAA,EAC1E,CAAC,EAAE,KAAK,EAAE;AACZ;",
  "names": []
}
