@lenserfight/sdk 0.2.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # @lenserfight/sdk
2
+
3
+ > The public client SDK for LenserFight. Browse battles, render templates,
4
+ > call public RPCs. Alpha — surface may shift before `1.0.0`.
5
+
6
+ ```bash
7
+ npm install @lenserfight/sdk@alpha
8
+ # or
9
+ pnpm add @lenserfight/sdk@alpha
10
+ ```
11
+
12
+ ## Quickstart
13
+
14
+ ```ts
15
+ import { createClient } from '@lenserfight/sdk'
16
+
17
+ const lf = createClient({
18
+ url: process.env.SUPABASE_URL!, // e.g. https://abc.supabase.co
19
+ anonKey: process.env.SUPABASE_ANON_KEY!, // publishable / anon key only
20
+ })
21
+
22
+ const battles = await lf.battles.browse(
23
+ { status: 'open' },
24
+ undefined,
25
+ 10,
26
+ )
27
+ console.log(battles)
28
+ ```
29
+
30
+ ## What's on the surface
31
+
32
+ | Method | Description |
33
+ |--------|-------------|
34
+ | `lf.battles.browse(filters?, cursor?, limit?)` | List public battles via `fn_browse_battles` (anon-readable). Keyset paginated. `limit` clamped to [1, 100]. |
35
+ | `lf.templates.renderPrompt(templateId, variables)` | Render a template's `task_prompt` with `{{variable}}` substitution via `fn_battles_render_prompt`. |
36
+ | `lf.rpcCall(fn, params)` | Escape hatch — call any RPC the anon key has EXECUTE on. |
37
+
38
+ ## Bring your own RPC client
39
+
40
+ If your app already has a `@supabase/supabase-js` client, you can hand it to the SDK:
41
+
42
+ ```ts
43
+ import { createClient as createSupabase } from '@supabase/supabase-js'
44
+ import { createClientFromRpc } from '@lenserfight/sdk'
45
+
46
+ const supabase = createSupabase(url, anonKey)
47
+ const lf = createClientFromRpc(supabase)
48
+ ```
49
+
50
+ Any client conforming to the `SupabaseLikeRpcClient` shape works.
51
+
52
+ ## Stability
53
+
54
+ This release is `0.1.0-alpha.1`. Surface changes are documented in the
55
+ [CHANGELOG](https://github.com/conectlens/lenserfight/blob/main/CHANGELOG.md).
56
+ The `1.0.0` line will follow once early-adopter feedback settles the public
57
+ surface.
58
+
59
+ For the deeper walkthrough see the [SDK quickstart](https://docs.lenserfight.com/how-to/integrations/sdk-quickstart) and the [reference docs](https://docs.lenserfight.com/reference/sdk).
60
+
61
+ Apache-2.0.
package/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=100;class l{constructor(t){this.rpcClient=t}rpcClient;async browse(t={},r,e=20){const n=Math.max(1,Math.min(e,h)),s={p_search:t.search??null,p_cursor_created_at:r?.created_at??null,p_cursor_id:r?.id??null,p_limit:n},{data:i,error:c}=await this.rpcClient.rpc("fn_sdk_browse_agents",s);if(c)throw new Error(`@lenserfight/sdk: fn_sdk_browse_agents failed — ${JSON.stringify(c)}`);return Array.isArray(i)?i:[]}async getById(t){const{data:r,error:e}=await this.rpcClient.rpc("fn_sdk_get_agent_detail",{p_agent_id:t});if(e)throw new Error(`@lenserfight/sdk: fn_sdk_get_agent_detail failed — ${JSON.stringify(e)}`);return r??null}async getLensBindings(t){const{data:r,error:e}=await this.rpcClient.rpc("fn_sdk_get_agent_lens_bindings",{p_agent_id:t});if(e)throw new Error(`@lenserfight/sdk: fn_sdk_get_agent_lens_bindings failed — ${JSON.stringify(e)}`);return Array.isArray(r)?r:[]}async getModelBindings(t){const{data:r,error:e}=await this.rpcClient.rpc("fn_sdk_get_agent_model_bindings",{p_agent_id:t});if(e)throw new Error(`@lenserfight/sdk: fn_sdk_get_agent_model_bindings failed — ${JSON.stringify(e)}`);return Array.isArray(r)?r:[]}}const u=100;class _{constructor(t){this.rpcClient=t}rpcClient;async browse(t={},r,e=20){const n=Math.max(1,Math.min(e,u)),s={p_search:t.search??null,p_category:t.category??null,p_status:t.status??null,p_cursor_created_at:r?.created_at??null,p_cursor_id:r?.id??null,p_limit:n},{data:i,error:c}=await this.rpcClient.rpc("fn_browse_battles",s);if(c)throw new Error(`@lenserfight/sdk: browse failed — ${JSON.stringify(c)}`);return Array.isArray(i)?i:[]}}function d(a){if(!a.url)throw new Error("@lenserfight/sdk: createClient requires `url`");if(!a.anonKey)throw new Error("@lenserfight/sdk: createClient requires `anonKey`");const t=a.fetch??globalThis.fetch;if(typeof t!="function")throw new Error("@lenserfight/sdk: global fetch unavailable — pass `fetch` in options");const r=a.url.replace(/\/+$/,"");return{async rpc(e,n){const s=await t(`${r}/rest/v1/rpc/${e}`,{method:"POST",headers:{apikey:a.anonKey,authorization:`Bearer ${a.anonKey}`,"content-type":"application/json"},body:JSON.stringify(n??{})});if(!s.ok){const c=await s.text().catch(()=>"");return{data:null,error:{status:s.status,message:c||s.statusText}}}return{data:await s.json().catch(()=>null),error:null}}}}const w=100;class p{constructor(t){this.rpcClient=t}rpcClient;async browse(t={},r,e=20){const n=Math.max(1,Math.min(e,w)),{data:s,error:i}=await this.rpcClient.rpc("fn_sdk_browse_lenses",{p_search:t.search??null,p_tag:t.tag??null,p_kind:t.kind??null,p_cursor_created_at:r?.created_at??null,p_cursor_id:r?.id??null,p_limit:n});if(i)throw new Error(`@lenserfight/sdk: fn_sdk_browse_lenses failed — ${JSON.stringify(i)}`);return Array.isArray(s)?s:[]}async search(t,r={},e,n=20){return this.browse({...r,search:t},e,n)}async getById(t){const{data:r,error:e}=await this.rpcClient.rpc("fn_get_lens_detail_bootstrap",{p_lens_id:t});if(e)throw new Error(`@lenserfight/sdk: fn_get_lens_detail_bootstrap failed — ${JSON.stringify(e)}`);return!r||r.error?null:r}async getVersion(t){const[r,e]=await Promise.all([this.rpcClient.rpc("fn_get_lens_version_detail",{p_version_id:t}),this.rpcClient.rpc("fn_get_lens_version_parameters",{p_version_id:t})]);if(r.error)throw new Error(`@lenserfight/sdk: fn_get_lens_version_detail failed — ${JSON.stringify(r.error)}`);if(!r.data)return null;const n=Array.isArray(r.data)?r.data[0]:r.data;return n?{...n,parameters:Array.isArray(e.data)?e.data:e.data??[]}:null}async getParameterContracts(t){const{data:r,error:e}=await this.rpcClient.rpc("fn_get_version_contracts",{p_version_id:t});if(e)throw new Error(`@lenserfight/sdk: fn_get_version_contracts failed — ${JSON.stringify(e)}`);if(!r)return[];const n=Array.isArray(r)?r[0]:r;if(!n)return[];const s=n.input_contract;if(!s)return[];const i=s.parameters??s.inputs;return Array.isArray(i)?i:[]}}class f{constructor(t){this.rpcClient=t}rpcClient;async getContractByVersion(t){const{data:r,error:e}=await this.rpcClient.rpc("fn_sdk_get_contract",{p_version_id:t,p_content_hash:null});if(e)throw new Error(`@lenserfight/sdk: fn_sdk_get_contract failed — ${JSON.stringify(e)}`);return r??null}async getContractByHash(t){const{data:r,error:e}=await this.rpcClient.rpc("fn_sdk_get_contract",{p_version_id:null,p_content_hash:t});if(e)throw new Error(`@lenserfight/sdk: fn_sdk_get_contract failed — ${JSON.stringify(e)}`);return r??null}async getManifest(t){const{data:r,error:e}=await this.rpcClient.rpc("fn_sdk_get_manifest",{p_version_id:t});if(e)throw new Error(`@lenserfight/sdk: fn_sdk_get_manifest failed — ${JSON.stringify(e)}`);return r??null}async getDependencies(t){const{data:r,error:e}=await this.rpcClient.rpc("fn_sdk_get_dependencies",{p_content_hash:t});if(e)throw new Error(`@lenserfight/sdk: fn_sdk_get_dependencies failed — ${JSON.stringify(e)}`);return Array.isArray(r)?r:[]}async checkCompatibility(t,r){const e=await this.getContractByHash(t);if(!e)return{compatible:!1,missingScopes:[],warnings:["Contract not found"]};const n=e.body.requiredScopes??[],s=r.filter(i=>!n.includes(i));return{compatible:s.length===0,missingScopes:s,warnings:[]}}}class g{constructor(t){this.rpcClient=t}rpcClient;async renderPrompt(t,r={}){const{data:e,error:n}=await this.rpcClient.rpc("fn_battles_render_prompt",{p_template_id:t,p_variables:r});if(n)throw new Error(`@lenserfight/sdk: renderPrompt failed — ${JSON.stringify(n)}`);return typeof e=="string"?e:""}}class o{battles;templates;lenses;agents;protocols;rpc;constructor(t){this.rpc=t,this.battles=new _(t),this.templates=new g(t),this.lenses=new p(t),this.agents=new l(t),this.protocols=new f(t)}async rpcCall(t,r){const{data:e,error:n}=await this.rpc.rpc(t,r);if(n)throw new Error(`@lenserfight/sdk: ${t} failed — ${JSON.stringify(n)}`);return e}}function y(a){const t=d(a);return new o(t)}function C(a){return new o(a)}const m="0.2.0-alpha.1";exports.AgentClient=l;exports.BattleClient=_;exports.LensClient=p;exports.LenserFightClient=o;exports.ProtocolClient=f;exports.SDK_VERSION=m;exports.TemplateClient=g;exports.createClient=y;exports.createClientFromRpc=C;exports.createFetchRpcClient=d;
package/index.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ export { createClient, createClientFromRpc, LenserFightClient } from './lib/lenserfight-client';
2
+ export { BattleClient } from './lib/battle-client';
3
+ export { TemplateClient } from './lib/template-client';
4
+ export { LensClient } from './lib/lens-client';
5
+ export { AgentClient } from './lib/agent-client';
6
+ export { ProtocolClient } from './lib/protocol-client';
7
+ export { createFetchRpcClient } from './lib/client';
8
+ export type { SupabaseLikeRpcClient } from './lib/client';
9
+ export type { BattleLifecycleStatus, BrowseFilters, BrowseCursor, BrowseBattle, BattleTemplate, CreateClientOptions, } from './lib/types';
10
+ export type { SdkLensKind, SdkVisibility, SdkContentStatus, SdkLensAuthor, SdkLensTag, SdkLensSummary, SdkLensDetail, SdkLensVersionSummary, SdkLensVersion, SdkLensParameter, SdkParameterTool, LensBrowseFilters, } from './lib/types/lenses';
11
+ export type { SdkAgentRuntimePref, SdkAgentModelBindingMode, SdkAgentSummary, SdkAgentDetail, SdkAgentCapabilities, SdkAgentStats, SdkAgentOwner, SdkAgentLensBinding, SdkAgentModelBinding, AgentBrowseFilters, } from './lib/types/agents';
12
+ export type { SdkContractKind, SdkChannel, SdkSignatureAlgorithm, SdkParameterClassification, SdkParameterKind, SdkParameterScope, SdkDependencyBinding, SdkParameterDefault, SdkParameterValidation, SdkParameterContract, SdkOutputDefinition, SdkDependencyReference, SdkLensContractBody, SdkLensContract, SdkContractSignature, SdkLensManifest, SdkDependencyEdge, SdkCompatibilityResult, } from './lib/types/protocols';
13
+ export declare const SDK_VERSION = "0.2.0-alpha.1";
package/index.mjs ADDED
@@ -0,0 +1,326 @@
1
+ class l {
2
+ constructor(r) {
3
+ this.rpcClient = r;
4
+ }
5
+ rpcClient;
6
+ /**
7
+ * Browse public AI agents. Only agents with `is_public_policy = true` are visible.
8
+ * Keyset pagination on (created_at DESC, id DESC).
9
+ */
10
+ async browse(r = {}, t, e = 20) {
11
+ const n = Math.max(1, Math.min(e, 100)), s = {
12
+ p_search: r.search ?? null,
13
+ p_cursor_created_at: t?.created_at ?? null,
14
+ p_cursor_id: t?.id ?? null,
15
+ p_limit: n
16
+ }, { data: i, error: c } = await this.rpcClient.rpc("fn_sdk_browse_agents", s);
17
+ if (c)
18
+ throw new Error(`@lenserfight/sdk: fn_sdk_browse_agents failed — ${JSON.stringify(c)}`);
19
+ return Array.isArray(i) ? i : [];
20
+ }
21
+ /**
22
+ * Get public agent profile detail. Returns null for non-public or non-existent agents.
23
+ */
24
+ async getById(r) {
25
+ const { data: t, error: e } = await this.rpcClient.rpc("fn_sdk_get_agent_detail", {
26
+ p_agent_id: r
27
+ });
28
+ if (e)
29
+ throw new Error(
30
+ `@lenserfight/sdk: fn_sdk_get_agent_detail failed — ${JSON.stringify(e)}`
31
+ );
32
+ return t ?? null;
33
+ }
34
+ /**
35
+ * Get lens bindings for a public agent.
36
+ */
37
+ async getLensBindings(r) {
38
+ const { data: t, error: e } = await this.rpcClient.rpc("fn_sdk_get_agent_lens_bindings", {
39
+ p_agent_id: r
40
+ });
41
+ if (e)
42
+ throw new Error(
43
+ `@lenserfight/sdk: fn_sdk_get_agent_lens_bindings failed — ${JSON.stringify(e)}`
44
+ );
45
+ return Array.isArray(t) ? t : [];
46
+ }
47
+ /**
48
+ * Get model bindings for a public agent.
49
+ */
50
+ async getModelBindings(r) {
51
+ const { data: t, error: e } = await this.rpcClient.rpc("fn_sdk_get_agent_model_bindings", {
52
+ p_agent_id: r
53
+ });
54
+ if (e)
55
+ throw new Error(
56
+ `@lenserfight/sdk: fn_sdk_get_agent_model_bindings failed — ${JSON.stringify(e)}`
57
+ );
58
+ return Array.isArray(t) ? t : [];
59
+ }
60
+ }
61
+ const _ = 100;
62
+ class d {
63
+ constructor(r) {
64
+ this.rpcClient = r;
65
+ }
66
+ rpcClient;
67
+ /**
68
+ * Browse public battles. Calls `public.fn_browse_battles` (SECURITY DEFINER,
69
+ * grants EXECUTE to anon + authenticated). Returns at most 100 rows per call
70
+ * regardless of `limit` — the server clamps too.
71
+ *
72
+ * For deeper paging, pass the last row's `{created_at, id}` as `cursor`.
73
+ */
74
+ async browse(r = {}, t, e = 20) {
75
+ const n = Math.max(1, Math.min(e, _)), s = {
76
+ p_search: r.search ?? null,
77
+ p_category: r.category ?? null,
78
+ p_status: r.status ?? null,
79
+ p_cursor_created_at: t?.created_at ?? null,
80
+ p_cursor_id: t?.id ?? null,
81
+ p_limit: n
82
+ }, { data: i, error: c } = await this.rpcClient.rpc("fn_browse_battles", s);
83
+ if (c)
84
+ throw new Error(
85
+ `@lenserfight/sdk: browse failed — ${JSON.stringify(c)}`
86
+ );
87
+ return Array.isArray(i) ? i : [];
88
+ }
89
+ }
90
+ function p(a) {
91
+ if (!a.url)
92
+ throw new Error("@lenserfight/sdk: createClient requires `url`");
93
+ if (!a.anonKey)
94
+ throw new Error("@lenserfight/sdk: createClient requires `anonKey`");
95
+ const r = a.fetch ?? globalThis.fetch;
96
+ if (typeof r != "function")
97
+ throw new Error("@lenserfight/sdk: global fetch unavailable — pass `fetch` in options");
98
+ const t = a.url.replace(/\/+$/, "");
99
+ return {
100
+ async rpc(e, n) {
101
+ const s = await r(`${t}/rest/v1/rpc/${e}`, {
102
+ method: "POST",
103
+ headers: {
104
+ apikey: a.anonKey,
105
+ authorization: `Bearer ${a.anonKey}`,
106
+ "content-type": "application/json"
107
+ },
108
+ body: JSON.stringify(n ?? {})
109
+ });
110
+ if (!s.ok) {
111
+ const c = await s.text().catch(() => "");
112
+ return {
113
+ data: null,
114
+ error: { status: s.status, message: c || s.statusText }
115
+ };
116
+ }
117
+ return { data: await s.json().catch(() => null), error: null };
118
+ }
119
+ };
120
+ }
121
+ const f = 100;
122
+ class h {
123
+ constructor(r) {
124
+ this.rpcClient = r;
125
+ }
126
+ rpcClient;
127
+ /**
128
+ * Browse public lenses. Keyset pagination on (created_at DESC, id DESC).
129
+ */
130
+ async browse(r = {}, t, e = 20) {
131
+ const n = Math.max(1, Math.min(e, f)), { data: s, error: i } = await this.rpcClient.rpc("fn_sdk_browse_lenses", {
132
+ p_search: r.search ?? null,
133
+ p_tag: r.tag ?? null,
134
+ p_kind: r.kind ?? null,
135
+ p_cursor_created_at: t?.created_at ?? null,
136
+ p_cursor_id: t?.id ?? null,
137
+ p_limit: n
138
+ });
139
+ if (i)
140
+ throw new Error(`@lenserfight/sdk: fn_sdk_browse_lenses failed — ${JSON.stringify(i)}`);
141
+ return Array.isArray(s) ? s : [];
142
+ }
143
+ /**
144
+ * Full-text search across public lenses.
145
+ */
146
+ async search(r, t = {}, e, n = 20) {
147
+ return this.browse({ ...t, search: r }, e, n);
148
+ }
149
+ /**
150
+ * Get full lens detail. Reuses existing `fn_get_lens_detail_bootstrap`.
151
+ */
152
+ async getById(r) {
153
+ const { data: t, error: e } = await this.rpcClient.rpc("fn_get_lens_detail_bootstrap", {
154
+ p_lens_id: r
155
+ });
156
+ if (e)
157
+ throw new Error(`@lenserfight/sdk: fn_get_lens_detail_bootstrap failed — ${JSON.stringify(e)}`);
158
+ return !t || t.error ? null : t;
159
+ }
160
+ /**
161
+ * Get a specific version with parameters. Combines existing RPCs:
162
+ * `fn_get_lens_version_detail` + `fn_get_lens_version_parameters`.
163
+ */
164
+ async getVersion(r) {
165
+ const [t, e] = await Promise.all([
166
+ this.rpcClient.rpc("fn_get_lens_version_detail", { p_version_id: r }),
167
+ this.rpcClient.rpc("fn_get_lens_version_parameters", { p_version_id: r })
168
+ ]);
169
+ if (t.error)
170
+ throw new Error(`@lenserfight/sdk: fn_get_lens_version_detail failed — ${JSON.stringify(t.error)}`);
171
+ if (!t.data) return null;
172
+ const n = Array.isArray(t.data) ? t.data[0] : t.data;
173
+ return n ? {
174
+ ...n,
175
+ parameters: Array.isArray(e.data) ? e.data : e.data ?? []
176
+ } : null;
177
+ }
178
+ /**
179
+ * Get parameter contracts for a version via `fn_get_version_contracts`.
180
+ * Returns the input_contract's parameter array if present.
181
+ */
182
+ async getParameterContracts(r) {
183
+ const { data: t, error: e } = await this.rpcClient.rpc("fn_get_version_contracts", {
184
+ p_version_id: r
185
+ });
186
+ if (e)
187
+ throw new Error(`@lenserfight/sdk: fn_get_version_contracts failed — ${JSON.stringify(e)}`);
188
+ if (!t) return [];
189
+ const n = Array.isArray(t) ? t[0] : t;
190
+ if (!n) return [];
191
+ const s = n.input_contract;
192
+ if (!s) return [];
193
+ const i = s.parameters ?? s.inputs;
194
+ return Array.isArray(i) ? i : [];
195
+ }
196
+ }
197
+ class g {
198
+ constructor(r) {
199
+ this.rpcClient = r;
200
+ }
201
+ rpcClient;
202
+ /**
203
+ * Get the contract for a lens version (by version_id).
204
+ * Uses `fn_sdk_get_contract(p_version_id)`.
205
+ */
206
+ async getContractByVersion(r) {
207
+ const { data: t, error: e } = await this.rpcClient.rpc("fn_sdk_get_contract", {
208
+ p_version_id: r,
209
+ p_content_hash: null
210
+ });
211
+ if (e)
212
+ throw new Error(`@lenserfight/sdk: fn_sdk_get_contract failed — ${JSON.stringify(e)}`);
213
+ return t ?? null;
214
+ }
215
+ /**
216
+ * Get a contract by its content hash (hex-encoded SHA-256).
217
+ * Uses `fn_sdk_get_contract(p_content_hash)`.
218
+ */
219
+ async getContractByHash(r) {
220
+ const { data: t, error: e } = await this.rpcClient.rpc("fn_sdk_get_contract", {
221
+ p_version_id: null,
222
+ p_content_hash: r
223
+ });
224
+ if (e)
225
+ throw new Error(`@lenserfight/sdk: fn_sdk_get_contract failed — ${JSON.stringify(e)}`);
226
+ return t ?? null;
227
+ }
228
+ /**
229
+ * Get the full manifest (contract + channel + signatures) for a version.
230
+ */
231
+ async getManifest(r) {
232
+ const { data: t, error: e } = await this.rpcClient.rpc("fn_sdk_get_manifest", {
233
+ p_version_id: r
234
+ });
235
+ if (e)
236
+ throw new Error(`@lenserfight/sdk: fn_sdk_get_manifest failed — ${JSON.stringify(e)}`);
237
+ return t ?? null;
238
+ }
239
+ /**
240
+ * Get dependency edges for a contract (its children in the DAG).
241
+ */
242
+ async getDependencies(r) {
243
+ const { data: t, error: e } = await this.rpcClient.rpc("fn_sdk_get_dependencies", {
244
+ p_content_hash: r
245
+ });
246
+ if (e)
247
+ throw new Error(`@lenserfight/sdk: fn_sdk_get_dependencies failed — ${JSON.stringify(e)}`);
248
+ return Array.isArray(t) ? t : [];
249
+ }
250
+ /**
251
+ * Check if a contract satisfies required scopes. Pure client-side logic —
252
+ * fetches the contract and compares scopes locally.
253
+ */
254
+ async checkCompatibility(r, t) {
255
+ const e = await this.getContractByHash(r);
256
+ if (!e)
257
+ return { compatible: !1, missingScopes: [], warnings: ["Contract not found"] };
258
+ const n = e.body.requiredScopes ?? [], s = t.filter((i) => !n.includes(i));
259
+ return { compatible: s.length === 0, missingScopes: s, warnings: [] };
260
+ }
261
+ }
262
+ class u {
263
+ constructor(r) {
264
+ this.rpcClient = r;
265
+ }
266
+ rpcClient;
267
+ /**
268
+ * Render a template's task_prompt with the supplied variable values.
269
+ * Calls `public.fn_battles_render_prompt` (SECURITY DEFINER, EXEC granted
270
+ * to anon + authenticated). Required variables that are missing raise
271
+ * 22023 — the SDK surfaces the server error verbatim.
272
+ */
273
+ async renderPrompt(r, t = {}) {
274
+ const { data: e, error: n } = await this.rpcClient.rpc("fn_battles_render_prompt", {
275
+ p_template_id: r,
276
+ p_variables: t
277
+ });
278
+ if (n)
279
+ throw new Error(
280
+ `@lenserfight/sdk: renderPrompt failed — ${JSON.stringify(n)}`
281
+ );
282
+ return typeof e == "string" ? e : "";
283
+ }
284
+ }
285
+ class o {
286
+ battles;
287
+ templates;
288
+ lenses;
289
+ agents;
290
+ protocols;
291
+ rpc;
292
+ constructor(r) {
293
+ this.rpc = r, this.battles = new d(r), this.templates = new u(r), this.lenses = new h(r), this.agents = new l(r), this.protocols = new g(r);
294
+ }
295
+ /**
296
+ * Direct RPC escape hatch. Use sparingly — anything that's part of the
297
+ * stable surface should live on `battles` / `templates` (or get added there
298
+ * in a follow-up PR).
299
+ */
300
+ async rpcCall(r, t) {
301
+ const { data: e, error: n } = await this.rpc.rpc(r, t);
302
+ if (n)
303
+ throw new Error(`@lenserfight/sdk: ${r} failed — ${JSON.stringify(n)}`);
304
+ return e;
305
+ }
306
+ }
307
+ function w(a) {
308
+ const r = p(a);
309
+ return new o(r);
310
+ }
311
+ function y(a) {
312
+ return new o(a);
313
+ }
314
+ const m = "0.2.0-alpha.1";
315
+ export {
316
+ l as AgentClient,
317
+ d as BattleClient,
318
+ h as LensClient,
319
+ o as LenserFightClient,
320
+ g as ProtocolClient,
321
+ m as SDK_VERSION,
322
+ u as TemplateClient,
323
+ w as createClient,
324
+ y as createClientFromRpc,
325
+ p as createFetchRpcClient
326
+ };
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@lenserfight/sdk",
3
+ "version": "0.2.0-alpha.10",
4
+ "description": "LenserFight public client SDK — read battles, lenses, agents, protocols, and templates from any Supabase-backed deployment",
5
+ "license": "Apache-2.0",
6
+ "main": "./index.cjs",
7
+ "module": "./index.mjs",
8
+ "types": "./index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./index.d.ts",
12
+ "import": "./index.mjs",
13
+ "require": "./index.cjs"
14
+ }
15
+ },
16
+ "files": [
17
+ "index.mjs",
18
+ "index.cjs",
19
+ "index.d.ts",
20
+ "README.md"
21
+ ],
22
+ "keywords": [
23
+ "lenserfight",
24
+ "ai-agents",
25
+ "supabase",
26
+ "evaluation",
27
+ "battles",
28
+ "lenses",
29
+ "protocols"
30
+ ],
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "https://github.com/conectlens/lenserfight.git",
34
+ "directory": "libs/sdk"
35
+ },
36
+ "publishConfig": {
37
+ "access": "public",
38
+ "registry": "https://registry.npmjs.org/",
39
+ "tag": "alpha"
40
+ },
41
+ "peerDependencies": {
42
+ "@supabase/supabase-js": "^2.0.0"
43
+ }
44
+ }