{"version":3,"sources":["../../src/configuration/configuration.ts"],"sourcesContent":["/**\n * ConfigurationRegistry SDK\n * On-chain key-value config store for AI Agents\n */\nimport { type PublicClient, type WalletClient, type Address, type Hash } from 'viem'\n\nexport interface ConfigEntry {\n  agentId: bigint\n  key: string\n  value: string\n  dataType: string\n  updatedAt: bigint\n  updatedBy: Address\n}\n\nexport interface ConfigurationConfig {\n  address: Address\n}\n\nconst ABI = [\n  {\n    name: 'getConfig',\n    type: 'function',\n    stateMutability: 'view',\n    inputs: [\n      { name: 'agentId', type: 'uint256' },\n      { name: 'configKey', type: 'string' },\n    ],\n    outputs: [{\n      type: 'tuple',\n      components: [\n        { name: 'agentId', type: 'uint256' },\n        { name: 'key', type: 'string' },\n        { name: 'value', type: 'string' },\n        { name: 'dataType', type: 'string' },\n        { name: 'updatedAt', type: 'uint256' },\n        { name: 'updatedBy', type: 'address' },\n      ],\n    }],\n  },\n  {\n    name: 'getAgentConfigs',\n    type: 'function',\n    stateMutability: 'view',\n    inputs: [{ name: 'agentId', type: 'uint256' }],\n    outputs: [{\n      type: 'tuple[]',\n      components: [\n        { name: 'agentId', type: 'uint256' },\n        { name: 'key', type: 'string' },\n        { name: 'value', type: 'string' },\n        { name: 'dataType', type: 'string' },\n        { name: 'updatedAt', type: 'uint256' },\n        { name: 'updatedBy', type: 'address' },\n      ],\n    }],\n  },\n  {\n    name: 'getConfigKeys',\n    type: 'function',\n    stateMutability: 'view',\n    inputs: [{ name: 'agentId', type: 'uint256' }],\n    outputs: [{ type: 'string[]' }],\n  },\n  {\n    name: 'getConfigCount',\n    type: 'function',\n    stateMutability: 'view',\n    inputs: [{ name: 'agentId', type: 'uint256' }],\n    outputs: [{ type: 'uint256' }],\n  },\n  {\n    name: 'configExists',\n    type: 'function',\n    stateMutability: 'view',\n    inputs: [\n      { name: 'agentId', type: 'uint256' },\n      { name: 'configKey', type: 'string' },\n    ],\n    outputs: [{ type: 'bool' }],\n  },\n] as const\n\nexport class ConfigurationClient {\n  private address: Address\n  private publicClient: PublicClient | null\n\n  constructor(config: ConfigurationConfig, publicClient?: PublicClient) {\n    this.address = config.address\n    this.publicClient = publicClient ?? null\n  }\n\n  setPublicClient(client: PublicClient) {\n    this.publicClient = client\n  }\n\n  async get(agentId: bigint, key: string): Promise<ConfigEntry | null> {\n    if (!this.publicClient) throw new Error('publicClient not set')\n    try {\n      return (await this.publicClient.readContract({\n        address: this.address,\n        abi: ABI,\n        functionName: 'getConfig',\n        args: [agentId, key],\n      })) as ConfigEntry\n    } catch {\n      return null\n    }\n  }\n\n  async getAll(agentId: bigint): Promise<ConfigEntry[]> {\n    if (!this.publicClient) throw new Error('publicClient not set')\n    return (await this.publicClient.readContract({\n      address: this.address,\n      abi: ABI,\n      functionName: 'getAgentConfigs',\n      args: [agentId],\n    })) as ConfigEntry[]\n  }\n\n  async getKeys(agentId: bigint): Promise<string[]> {\n    if (!this.publicClient) throw new Error('publicClient not set')\n    return (await this.publicClient.readContract({\n      address: this.address,\n      abi: ABI,\n      functionName: 'getConfigKeys',\n      args: [agentId],\n    })) as string[]\n  }\n\n  async getCount(agentId: bigint): Promise<bigint> {\n    if (!this.publicClient) throw new Error('publicClient not set')\n    return (await this.publicClient.readContract({\n      address: this.address,\n      abi: ABI,\n      functionName: 'getConfigCount',\n      args: [agentId],\n    })) as bigint\n  }\n\n  async exists(agentId: bigint, key: string): Promise<boolean> {\n    if (!this.publicClient) throw new Error('publicClient not set')\n    return (await this.publicClient.readContract({\n      address: this.address,\n      abi: ABI,\n      functionName: 'configExists',\n      args: [agentId, key],\n    })) as boolean\n  }\n}\n"],"mappings":";AAmBA,IAAM,MAAM;AAAA,EACV;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,iBAAiB;AAAA,IACjB,QAAQ;AAAA,MACN,EAAE,MAAM,WAAW,MAAM,UAAU;AAAA,MACnC,EAAE,MAAM,aAAa,MAAM,SAAS;AAAA,IACtC;AAAA,IACA,SAAS,CAAC;AAAA,MACR,MAAM;AAA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