import type { ISdk } from 'iii-sdk' export class StateKV { constructor(private sdk: ISdk) {} async get(scope: string, key: string): Promise { return this.sdk.trigger<{ scope: string; key: string }, T | null>({ function_id: 'state::get', payload: { scope, key }, }) } async set(scope: string, key: string, value: T): Promise { return this.sdk.trigger<{ scope: string; key: string; value: T }, T>({ function_id: 'state::set', payload: { scope, key, value }, }) } async update( scope: string, key: string, ops: Array<{ type: string; path: string; value?: unknown }>, ): Promise { return this.sdk.trigger< { scope: string; key: string; ops: Array<{ type: string; path: string; value?: unknown }> }, T >({ function_id: 'state::update', payload: { scope, key, ops }, }) } async delete(scope: string, key: string): Promise { return this.sdk.trigger<{ scope: string; key: string }, void>({ function_id: 'state::delete', payload: { scope, key }, }) } async list(scope: string): Promise { return this.sdk.trigger<{ scope: string }, T[]>({ function_id: 'state::list', payload: { scope }, }) } }