{"version":3,"file":"index.mjs","names":[],"sources":["../../src/agent-openai/openai-client.ts","../../src/agent-openai/openai.ts"],"sourcesContent":["/* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD */\n/* SPDX-License-Identifier: Apache-2.0 */\n\nimport {\n  callServiceFunction,\n  closeService,\n  isServiceAvailable,\n  openService,\n  resolveHost,\n  type ServiceClientOptions,\n  type ServiceHandle,\n} from '../common/service-rpc.ts';\n\nexport const OPENAI_SERVICE_NAME = 'OpenAI';\n\nexport const OPENAI_FUNCTIONS = {} as const;\n\nexport type OpenaiClientOptions = ServiceClientOptions;\nexport { type ServiceHandle as OpenaiHandle };\n\nexport function isOpenaiAvailable(options?: OpenaiClientOptions): boolean {\n  return isServiceAvailable(OPENAI_SERVICE_NAME, options);\n}\n\nexport function openOpenai(options?: OpenaiClientOptions): ServiceHandle {\n  return openService(OPENAI_SERVICE_NAME, options);\n}\n\nexport function closeOpenai(handle: ServiceHandle, options?: OpenaiClientOptions): void {\n  closeService(handle, options);\n}\n\nexport function callOpenaiFunction<T>(\n  handle: ServiceHandle,\n  functionName: string,\n  params: Record<string, unknown> = {},\n  options?: OpenaiClientOptions,\n): T {\n  return callServiceFunction<T>(resolveHost(options), handle, functionName, params);\n}\n","/* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD */\n/* SPDX-License-Identifier: Apache-2.0 */\n\nimport {\n  callOpenaiFunction,\n  closeOpenai,\n  isOpenaiAvailable,\n  openOpenai,\n  type OpenaiClientOptions,\n  type OpenaiHandle,\n} from './openai-client.ts';\n\nexport type OpenaiModuleOptions = OpenaiClientOptions;\n\ntype State = { handle: OpenaiHandle | null; options: OpenaiModuleOptions };\nconst state: State = { handle: null, options: {} };\n\nfunction handle(): OpenaiHandle {\n  if (state.handle !== null) return state.handle;\n  if (!isOpenaiAvailable(state.options)) throw new Error('OpenAI service is not available');\n  state.handle = openOpenai(state.options);\n  return state.handle;\n}\n\nexport function configure(options: OpenaiModuleOptions): void {\n  if (state.handle !== null) closeOpenai(state.handle, state.options);\n  state.handle = null;\n  state.options = options;\n}\n\nconst openai = {\n  available(): boolean {\n    return isOpenaiAvailable(state.options);\n  },\n  close(): void {\n    if (state.handle === null) return;\n    closeOpenai(state.handle, state.options);\n    state.handle = null;\n  },\n  call<T = unknown>(functionName: string, params: Record<string, unknown> = {}): T {\n    return callOpenaiFunction<T>(handle(), functionName, params, state.options);\n  },\n};\n\nexport default openai;\n"],"mappings":";;AAaA,MAAa,sBAAsB;AAEnC,MAAa,mBAAmB,CAAC;AAKjC,SAAgB,kBAAkB,SAAwC;CACxE,OAAO,mBAAmB,qBAAqB,OAAO;AACxD;AAEA,SAAgB,WAAW,SAA8C;CACvE,OAAO,YAAY,qBAAqB,OAAO;AACjD;AAEA,SAAgB,YAAY,QAAuB,SAAqC;CACtF,aAAa,QAAQ,OAAO;AAC9B;AAEA,SAAgB,mBACd,QACA,cACA,SAAkC,CAAC,GACnC,SACG;CACH,OAAO,oBAAuB,YAAY,OAAO,GAAG,QAAQ,cAAc,MAAM;AAClF;;;ACxBA,MAAM,QAAe;CAAE,QAAQ;CAAM,SAAS,CAAC;AAAE;AAEjD,SAAS,SAAuB;CAC9B,IAAI,MAAM,WAAW,MAAM,OAAO,MAAM;CACxC,IAAI,CAAC,kBAAkB,MAAM,OAAO,GAAG,MAAM,IAAI,MAAM,iCAAiC;CACxF,MAAM,SAAS,WAAW,MAAM,OAAO;CACvC,OAAO,MAAM;AACf;AAEA,SAAgB,UAAU,SAAoC;CAC5D,IAAI,MAAM,WAAW,MAAM,YAAY,MAAM,QAAQ,MAAM,OAAO;CAClE,MAAM,SAAS;CACf,MAAM,UAAU;AAClB;AAEA,MAAM,SAAS;CACb,YAAqB;EACnB,OAAO,kBAAkB,MAAM,OAAO;CACxC;CACA,QAAc;EACZ,IAAI,MAAM,WAAW,MAAM;EAC3B,YAAY,MAAM,QAAQ,MAAM,OAAO;EACvC,MAAM,SAAS;CACjB;CACA,KAAkB,cAAsB,SAAkC,CAAC,GAAM;EAC/E,OAAO,mBAAsB,OAAO,GAAG,cAAc,QAAQ,MAAM,OAAO;CAC5E;AACF"}