{"version":3,"file":"index.mjs","names":[],"sources":["../../src/agent-coze/coze-client.ts","../../src/agent-coze/coze.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';\nimport type { CozeRobotInfo } from './coze-types.ts';\n\nexport const COZE_SERVICE_NAME = 'Coze';\n\nexport const COZE_FUNCTIONS = {\n  SetActiveRobotIndex: 'SetActiveRobotIndex',\n  GetActiveRobotIndex: 'GetActiveRobotIndex',\n  GetRobotInfos: 'GetRobotInfos',\n} as const;\n\nexport type CozeClientOptions = ServiceClientOptions;\nexport { type ServiceHandle as CozeHandle };\n\nexport function isCozeAvailable(options?: CozeClientOptions): boolean {\n  return isServiceAvailable(COZE_SERVICE_NAME, options);\n}\n\nexport function openCoze(options?: CozeClientOptions): ServiceHandle {\n  return openService(COZE_SERVICE_NAME, options);\n}\n\nexport function closeCoze(handle: ServiceHandle, options?: CozeClientOptions): void {\n  closeService(handle, options);\n}\n\nexport function setActiveRobotIndex(\n  handle: ServiceHandle,\n  index: number,\n  options?: CozeClientOptions,\n): void {\n  callServiceFunction<void>(resolveHost(options), handle, COZE_FUNCTIONS.SetActiveRobotIndex, {\n    Index: index,\n  });\n}\n\nexport function getActiveRobotIndex(handle: ServiceHandle, options?: CozeClientOptions): number {\n  return callServiceFunction<number>(\n    resolveHost(options),\n    handle,\n    COZE_FUNCTIONS.GetActiveRobotIndex,\n    {},\n  );\n}\n\nexport function getRobotInfos(handle: ServiceHandle, options?: CozeClientOptions): CozeRobotInfo[] {\n  return callServiceFunction<CozeRobotInfo[]>(\n    resolveHost(options),\n    handle,\n    COZE_FUNCTIONS.GetRobotInfos,\n    {},\n  );\n}\n","/* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD */\n/* SPDX-License-Identifier: Apache-2.0 */\n\nimport {\n  closeCoze,\n  getActiveRobotIndex,\n  getRobotInfos,\n  isCozeAvailable,\n  openCoze,\n  setActiveRobotIndex,\n  type CozeClientOptions,\n  type CozeHandle,\n} from './coze-client.ts';\nimport type { CozeRobotInfo } from './coze-types.ts';\n\nexport type CozeModuleOptions = CozeClientOptions;\n\ntype State = { handle: CozeHandle | null; options: CozeModuleOptions };\nconst state: State = { handle: null, options: {} };\n\nfunction handle(): CozeHandle {\n  if (state.handle !== null) return state.handle;\n  if (!isCozeAvailable(state.options)) throw new Error('Coze service is not available');\n  state.handle = openCoze(state.options);\n  return state.handle;\n}\n\nexport function configure(options: CozeModuleOptions): void {\n  if (state.handle !== null) closeCoze(state.handle, state.options);\n  state.handle = null;\n  state.options = options;\n}\n\nconst coze = {\n  available(): boolean {\n    return isCozeAvailable(state.options);\n  },\n  close(): void {\n    if (state.handle === null) return;\n    closeCoze(state.handle, state.options);\n    state.handle = null;\n  },\n  setActiveRobotIndex(index: number): void {\n    setActiveRobotIndex(handle(), index, state.options);\n  },\n  getActiveRobotIndex(): number {\n    return getActiveRobotIndex(handle(), state.options);\n  },\n  getRobotInfos(): CozeRobotInfo[] {\n    return getRobotInfos(handle(), state.options);\n  },\n};\n\nexport default coze;\n"],"mappings":";;AAcA,MAAa,oBAAoB;AAEjC,MAAa,iBAAiB;CAC5B,qBAAqB;CACrB,qBAAqB;CACrB,eAAe;AACjB;AAKA,SAAgB,gBAAgB,SAAsC;CACpE,OAAO,mBAAmB,mBAAmB,OAAO;AACtD;AAEA,SAAgB,SAAS,SAA4C;CACnE,OAAO,YAAY,mBAAmB,OAAO;AAC/C;AAEA,SAAgB,UAAU,QAAuB,SAAmC;CAClF,aAAa,QAAQ,OAAO;AAC9B;AAEA,SAAgB,oBACd,QACA,OACA,SACM;CACN,oBAA0B,YAAY,OAAO,GAAG,QAAQ,eAAe,qBAAqB,EAC1F,OAAO,MACT,CAAC;AACH;AAEA,SAAgB,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