@lenserfight/sdk 0.3.0-alpha.9 → 2.1.0

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/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=100;class C{constructor(t){this.rpcClient=t}async browse(t={},r,e=20){const n=Math.max(1,Math.min(e,k)),i={p_search:t.search??null,p_cursor_created_at:r?.created_at??null,p_cursor_id:r?.id??null,p_limit:n},{data:s,error:o}=await this.rpcClient.rpc("fn_sdk_browse_agents",i);if(o)throw new Error(`@lenserfight/sdk: fn_sdk_browse_agents failed — ${JSON.stringify(o)}`);return Array.isArray(s)?s:[]}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 b=100;class u{constructor(t){this.rpcClient=t}async browse(t={},r,e=20){const n=Math.max(1,Math.min(e,b)),i={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:s,error:o}=await this.rpcClient.rpc("fn_browse_battles",i);if(o)throw new Error(`@lenserfight/sdk: browse failed — ${JSON.stringify(o)}`);return Array.isArray(s)?s:[]}}function w(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(/\/+$/,""),e=a.apiKey??a.anonKey;return{async rpc(n,i){const s=await t(`${r}/rest/v1/rpc/${n}`,{method:"POST",headers:{apikey:a.anonKey,authorization:`Bearer ${e}`,"content-type":"application/json"},body:JSON.stringify(i??{})});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 S=100;class h{constructor(t){this.rpcClient=t}async browse(t={},r,e=20){const n=Math.max(1,Math.min(e,S)),{data:i,error:s}=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(s)throw new Error(`@lenserfight/sdk: fn_sdk_browse_lenses failed — ${JSON.stringify(s)}`);return Array.isArray(i)?i:[]}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 resolveTemplate(t,r,e){const{data:n,error:i}=await this.rpcClient.rpc("fn_mcp_lens_resolve_template",{p_lens_id:t,p_version_id:e?.versionId??null});if(i)throw new Error(`@lenserfight/sdk: fn_mcp_lens_resolve_template failed — ${JSON.stringify(i)}`);if(!n)throw new Error(`@lenserfight/sdk: lens ${t} not found`);const s=n;let o=s.template_body;const c=[],d=[];for(const l of s.parameters??[]){const f=`[[:${l.id}]]`,p=r[l.label]??r[l.label.toLowerCase()]??Object.entries(r).find(([m])=>m.toLowerCase()===l.label.toLowerCase())?.[1];p!==void 0?(o=o.split(f).join(p),d.push(l.label)):l.optional?o=o.split(f).join(""):c.push(l.label)}return{resolvedPrompt:o,lensId:s.lens_id,versionId:s.version_id,lensTitle:s.title??t,lensDescription:s.description??null,paramsUsed:d,missing:c}}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 i=n.input_contract;if(!i)return[];const s=i.parameters??i.inputs;return Array.isArray(s)?s:[]}}class E{constructor(t){this.rpcClient=t}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??[],i=r.filter(s=>!n.includes(s));return{compatible:i.length===0,missingScopes:i,warnings:[]}}}class g{constructor(t){this.rpcClient=t}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:""}}const $=new Set(["completed","failed","cancelled"]),A=3e3,v=12e4;class y{constructor(t){this.rpcClient=t}async browse(t){const{data:r,error:e}=await this.rpcClient.rpc("fn_mcp_workflow_list",{p_limit:t?.limit??20,p_offset:t?.offset??0,p_visibility:t?.visibility??null,p_lenser_id:null});if(e)throw new Error(`@lenserfight/sdk: fn_mcp_workflow_list failed — ${JSON.stringify(e)}`);const n=r?.data;return Array.isArray(n)?n:[]}async getById(t){const{data:r,error:e}=await this.rpcClient.rpc("fn_mcp_workflow_get",{p_workflow_id:t});if(e)throw new Error(`@lenserfight/sdk: fn_mcp_workflow_get failed — ${JSON.stringify(e)}`);return r??null}async startRun(t,r,e){const{data:n,error:i}=await this.rpcClient.rpc("fn_mcp_workflow_run_start",{p_workflow_id:t,p_inputs:r??{},p_global_model_id:e?.modelId??null,p_idempotency_key:e?.idempotencyKey??null,p_metadata:{}});if(i)throw new Error(`@lenserfight/sdk: fn_mcp_workflow_run_start failed — ${JSON.stringify(i)}`);if(!n)throw new Error(`@lenserfight/sdk: workflow ${t} not found or inaccessible`);return n}async getRunStatus(t){const{data:r,error:e}=await this.rpcClient.rpc("fn_mcp_workflow_run_status",{p_run_id:t});if(e)throw new Error(`@lenserfight/sdk: fn_mcp_workflow_run_status failed — ${JSON.stringify(e)}`);if(!r)throw new Error(`@lenserfight/sdk: run ${t} not found`);const n=r;return{id:n.id,status:n.status,activeNodeId:n.active_node_id??null,creditsSpent:n.credits_spent??0}}async getRunLogs(t){const{data:r,error:e}=await this.rpcClient.rpc("fn_mcp_workflow_run_logs",{p_run_id:t});if(e)throw new Error(`@lenserfight/sdk: fn_mcp_workflow_run_logs failed — ${JSON.stringify(e)}`);const n=r?.node_results;return Array.isArray(n)?n.map(i=>{const s=i;return{nodeId:s.node_id,status:s.status,result:s.result??null,error:s.error??null,durationMs:s.duration_ms??0,tokenCount:s.token_count??0}}):[]}async awaitRun(t,r,e){const n=e?.timeoutMs??v,i=await this.startRun(t,r,e),s=Date.now()+n;for(;Date.now()<s;){await new Promise(c=>setTimeout(c,A));const o=await this.getRunStatus(i.id);if($.has(o.status)){if(o.status==="completed")return this.getRunLogs(i.id);throw new Error(`@lenserfight/sdk: workflow run ${i.id} ended with status "${o.status}"`)}}throw new Error(`@lenserfight/sdk: workflow run ${i.id} timed out after ${n}ms`)}}class _{agents;battles;lenses;protocols;templates;workflows;rpc;constructor(t){this.rpc=t,this.agents=new C(t),this.battles=new u(t),this.lenses=new h(t),this.protocols=new E(t),this.templates=new g(t),this.workflows=new y(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 O(a){const t=w(a);return new _(t)}function N(a){return new _(a)}const J="0.3.0-alpha.0";exports.BattleClient=u;exports.LensClient=h;exports.LenserFightClient=_;exports.SDK_VERSION=J;exports.TemplateClient=g;exports.WorkflowClient=y;exports.createClient=O;exports.createClientFromRpc=N;exports.createFetchRpcClient=w;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=100;class w{constructor(t){this.rpcClient=t}async browse(t,r=20){const e=Math.max(1,Math.min(r,A)),{data:n,error:a}=await this.rpcClient.rpc("fn_list_agents_by_owner",{p_owner_lenser_id:t.ownerId});if(a)throw new Error(`@lenserfight/sdk: fn_list_agents_by_owner failed — ${JSON.stringify(a)}`);return{items:(Array.isArray(n)?n:[]).slice(0,e),nextCursor:null}}async getById(t){const{data:r,error:e}=await this.rpcClient.rpc("fn_get_agent_profile",{p_ai_lenser_id:t});if(e)throw new Error(`@lenserfight/sdk: fn_get_agent_profile failed — ${JSON.stringify(e)}`);return r??null}async getLensBindings(t){const{data:r,error:e}=await this.rpcClient.rpc("fn_list_agent_lens_bindings",{p_ai_lenser_id:t,p_limit:50,p_offset:0});if(e)throw new Error(`@lenserfight/sdk: fn_list_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_list_agent_model_bindings",{p_ai_lenser_id:t,p_limit:50,p_offset:0});if(e)throw new Error(`@lenserfight/sdk: fn_list_agent_model_bindings failed — ${JSON.stringify(e)}`);return Array.isArray(r)?r:[]}}const v=100;class g{constructor(t){this.rpcClient=t}async browse(t={},r,e=20){const n=Math.max(1,Math.min(e,v)),a={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:s,error:l}=await this.rpcClient.rpc("fn_browse_battles",a);if(l)throw new Error(`@lenserfight/sdk: browse failed — ${JSON.stringify(l)}`);return Array.isArray(s)?s:[]}}function y(i){if(!i.url)throw new Error("@lenserfight/sdk: createClient requires `url`");if(!i.anonKey)throw new Error("@lenserfight/sdk: createClient requires `anonKey`");const t=i.fetch??globalThis.fetch;if(typeof t!="function")throw new Error("@lenserfight/sdk: global fetch unavailable — pass `fetch` in options");const r=i.url.replace(/\/+$/,""),e=i.apiKey??i.anonKey;return{async rpc(n,a){const s=await t(`${r}/rest/v1/rpc/${n}`,{method:"POST",headers:{apikey:i.anonKey,authorization:`Bearer ${e}`,"content-type":"application/json"},body:JSON.stringify(a??{})});if(!s.ok){const o=await s.text().catch(()=>"");return{data:null,error:{status:s.status,message:o||s.statusText}}}return{data:await s.json().catch(()=>null),error:null}}}}const E=100;function p(i){if(!i)return[];const t=i;return Array.isArray(t.data)?t.data:Array.isArray(i)?i:[]}function h(i){return{id:i.id,title:i.title??"",description:i.description??null,author:{id:i.lenser_id??"",handle:i.author_handle??"",displayName:i.author_handle??"",avatarUrl:null},tags:Array.isArray(i.tags)?i.tags:[],visibility:i.visibility??"public",status:i.status??"published",outputKind:null,latestVersionNumber:null,createdAt:i.created_at??""}}class m{constructor(t){this.rpcClient=t}async browse(t={},r=0,e=20){const n=Math.max(1,Math.min(e,E));if(t.search){const{data:l,error:o}=await this.rpcClient.rpc("fn_mcp_lens_search",{p_query:t.search,p_visibility:"public",p_limit:n,p_offset:Math.max(0,r)});if(o)throw new Error(`@lenserfight/sdk: fn_mcp_lens_search failed — ${JSON.stringify(o)}`);return p(l).map(h)}const{data:a,error:s}=await this.rpcClient.rpc("fn_mcp_lens_list",{p_limit:n,p_offset:Math.max(0,r),p_visibility:"public",p_status:t.status??null,p_lenser_id:null,p_include_archived:!1});if(s)throw new Error(`@lenserfight/sdk: fn_mcp_lens_list failed — ${JSON.stringify(s)}`);return p(a).map(h)}async search(t,r={},e=0,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 resolveTemplate(t,r,e){const{data:n,error:a}=await this.rpcClient.rpc("fn_mcp_lens_resolve_template",{p_lens_id:t,p_version_id:e?.versionId??null});if(a)throw new Error(`@lenserfight/sdk: fn_mcp_lens_resolve_template failed — ${JSON.stringify(a)}`);if(!n)throw new Error(`@lenserfight/sdk: lens ${t} not found`);const s=n;let l=s.template_body;const o=[],d=[];for(const c of s.parameters??[]){const f=`[[:${c.id}]]`,u=r[c.label]??r[c.label.toLowerCase()]??Object.entries(r).find(([S])=>S.toLowerCase()===c.label.toLowerCase())?.[1];u!==void 0?(l=l.split(f).join(u),d.push(c.label)):c.optional?l=l.split(f).join(""):o.push(c.label)}return{resolvedPrompt:l,lensId:s.lens_id,versionId:s.version_id,lensTitle:s.title??t,lensDescription:s.description??null,paramsUsed:d,missing:o}}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 a=n.input_contract;if(!a)return[];const s=a.parameters??a.inputs;return Array.isArray(s)?s:[]}async extractParams(t){const r=await this.getParameterContracts(t);return{params:r,labels:r.map(e=>e.label)}}async validateParams(t,r){const e=await this.getParameterContracts(t),n=new Set(Object.keys(r).map(o=>o.toLowerCase())),a=new Set(e.map(o=>o.label.toLowerCase())),s=e.filter(o=>o.required&&!n.has(o.label.toLowerCase())).map(o=>o.label),l=Object.keys(r).filter(o=>!a.has(o.toLowerCase()));return{valid:s.length===0&&l.length===0,missing:s,unknown:l,total:e.length,provided:Object.keys(r).length}}}class b{constructor(t){this.rpcClient=t}async getContractByVersion(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 null;const n=Array.isArray(r)?r[0]:r;if(!n)return null;const a=n.input_contract;return a?{contentHash:"",body:a,publishedBy:"",publishedAt:"",supersedesHash:null}:null}async getContractByHash(t){return null}async getManifest(t){const r=await this.getContractByVersion(t);return r?{specVersion:r.body?.specVersion??"1.0.0",contentHash:r.contentHash,body:r.body,channel:null,signatures:[]}:null}async getDependencies(t){return[]}async checkCompatibility(t,r){const e=await this.getContractByVersion(t);if(!e)return{compatible:!1,missingScopes:[],warnings:["Contract not found"]};const n=e.body?.requiredScopes??[],a=r.filter(s=>!n.includes(s));return{compatible:a.length===0,missingScopes:a,warnings:[]}}}class C{constructor(t){this.rpcClient=t}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:""}}const $=new Set(["completed","failed","cancelled"]),O=3e3,N=12e4;class k{constructor(t){this.rpcClient=t}async browse(t){const{data:r,error:e}=await this.rpcClient.rpc("fn_mcp_workflow_list",{p_limit:t?.limit??20,p_offset:t?.offset??0,p_visibility:t?.visibility??null,p_lenser_id:null});if(e)throw new Error(`@lenserfight/sdk: fn_mcp_workflow_list failed — ${JSON.stringify(e)}`);const n=r?.data;return Array.isArray(n)?n:[]}async getById(t){const{data:r,error:e}=await this.rpcClient.rpc("fn_mcp_workflow_get",{p_workflow_id:t});if(e)throw new Error(`@lenserfight/sdk: fn_mcp_workflow_get failed — ${JSON.stringify(e)}`);return r??null}async startRun(t,r,e){const{data:n,error:a}=await this.rpcClient.rpc("fn_mcp_workflow_run_start",{p_workflow_id:t,p_inputs:r??{},p_global_model_id:e?.modelId??null,p_idempotency_key:e?.idempotencyKey??null,p_metadata:{}});if(a)throw new Error(`@lenserfight/sdk: fn_mcp_workflow_run_start failed — ${JSON.stringify(a)}`);if(!n)throw new Error(`@lenserfight/sdk: workflow ${t} not found or inaccessible`);return n}async getRunStatus(t){const{data:r,error:e}=await this.rpcClient.rpc("fn_mcp_workflow_run_status",{p_run_id:t});if(e)throw new Error(`@lenserfight/sdk: fn_mcp_workflow_run_status failed — ${JSON.stringify(e)}`);if(!r)throw new Error(`@lenserfight/sdk: run ${t} not found`);const n=r;return{id:n.id,status:n.status,activeNodeId:n.active_node_id??null,creditsSpent:n.credits_spent??0}}async getRunLogs(t){const{data:r,error:e}=await this.rpcClient.rpc("fn_mcp_workflow_run_logs",{p_run_id:t});if(e)throw new Error(`@lenserfight/sdk: fn_mcp_workflow_run_logs failed — ${JSON.stringify(e)}`);const n=r?.node_results;return Array.isArray(n)?n.map(a=>{const s=a;return{nodeId:s.node_id,status:s.status,result:s.result??null,error:s.error??null,durationMs:s.duration_ms??0,tokenCount:s.token_count??0}}):[]}async awaitRun(t,r,e){const n=e?.timeoutMs??N,a=await this.startRun(t,r,e),s=Date.now()+n;for(;Date.now()<s;){await new Promise(o=>setTimeout(o,O));const l=await this.getRunStatus(a.id);if($.has(l.status)){if(l.status==="completed")return this.getRunLogs(a.id);throw new Error(`@lenserfight/sdk: workflow run ${a.id} ended with status "${l.status}"`)}}throw new Error(`@lenserfight/sdk: workflow run ${a.id} timed out after ${n}ms`)}}class _{agents;battles;lenses;protocols;templates;workflows;rpc;constructor(t){this.rpc=t,this.agents=new w(t),this.battles=new g(t),this.lenses=new m(t),this.protocols=new b(t),this.templates=new C(t),this.workflows=new k(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 L(i){const t=y(i);return new _(t)}function M(i){return new _(i)}const T="1.0.0";exports.AgentClient=w;exports.BattleClient=g;exports.LensClient=m;exports.LenserFightClient=_;exports.ProtocolClient=b;exports.SDK_VERSION=T;exports.TemplateClient=C;exports.WorkflowClient=k;exports.createClient=L;exports.createClientFromRpc=M;exports.createFetchRpcClient=y;
package/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  export { createClient, createClientFromRpc, LenserFightClient } from './lib/lenserfight-client';
2
+ export { AgentClient } from './lib/agent-client';
2
3
  export { BattleClient } from './lib/battle-client';
3
4
  export { LensClient } from './lib/lens-client';
5
+ export { ProtocolClient } from './lib/protocol-client';
4
6
  export { TemplateClient } from './lib/template-client';
5
7
  export { WorkflowClient } from './lib/workflow-client';
6
8
  export { createFetchRpcClient } from './lib/client';
@@ -8,4 +10,6 @@ export type { SupabaseLikeRpcClient } from './lib/client';
8
10
  export type { BattleLifecycleStatus, BrowseFilters, BrowseCursor, BrowseBattle, BattleTemplate, CreateClientOptions, } from './lib/types';
9
11
  export type { LensBrowseFilters, SdkLensDetail, SdkLensKind, SdkLensParameter, SdkLensSummary, SdkLensVersion, SdkLensVersionSummary, SdkParameterTool, SdkResolvedTemplate, SdkVisibility, SdkContentStatus, } from './lib/types/lenses';
10
12
  export type { SdkWorkflowDetail, SdkWorkflowRun, SdkWorkflowRunLog, SdkWorkflowRunState, SdkWorkflowRunStatus, SdkWorkflowSummary, } from './lib/types/workflows';
11
- export declare const SDK_VERSION = "0.3.0-alpha.0";
13
+ export type { AgentBrowseFilters, SdkAgentCapabilities, SdkAgentDetail, SdkAgentLensBinding, SdkAgentModelBinding, SdkAgentModelBindingMode, SdkAgentOwner, SdkAgentPage, SdkAgentRuntimePref, SdkAgentStats, SdkAgentSummary, } from './lib/types/agents';
14
+ export type { SdkCompatibilityResult, SdkDependencyEdge, SdkLensContract, SdkLensContractBody, SdkLensManifest, SdkParameterContract, } from './lib/types/protocols';
15
+ export declare const SDK_VERSION = "1.0.0";
package/index.mjs CHANGED
@@ -1,64 +1,65 @@
1
- class u {
1
+ class g {
2
2
  constructor(t) {
3
3
  this.rpcClient = t;
4
4
  }
5
5
  /**
6
- * Browse public AI agents. Only agents with `is_public_policy = true` are visible.
7
- * Keyset pagination on (created_at DESC, id DESC).
6
+ * List AI agents owned by `filters.ownerId`. Uses `fn_list_agents_by_owner`.
7
+ * Requires an authenticated client.
8
8
  */
9
- async browse(t = {}, r, e = 20) {
10
- const n = Math.max(1, Math.min(e, 100)), i = {
11
- p_search: t.search ?? null,
12
- p_cursor_created_at: r?.created_at ?? null,
13
- p_cursor_id: r?.id ?? null,
14
- p_limit: n
15
- }, { data: s, error: o } = await this.rpcClient.rpc("fn_sdk_browse_agents", i);
16
- if (o)
17
- throw new Error(`@lenserfight/sdk: fn_sdk_browse_agents failed — ${JSON.stringify(o)}`);
18
- return Array.isArray(s) ? s : [];
9
+ async browse(t, r = 20) {
10
+ const e = Math.max(1, Math.min(r, 100)), { data: n, error: a } = await this.rpcClient.rpc("fn_list_agents_by_owner", {
11
+ p_owner_lenser_id: t.ownerId
12
+ });
13
+ if (a)
14
+ throw new Error(`@lenserfight/sdk: fn_list_agents_by_owner failed — ${JSON.stringify(a)}`);
15
+ return { items: (Array.isArray(n) ? n : []).slice(0, e), nextCursor: null };
19
16
  }
20
17
  /**
21
- * Get public agent profile detail. Returns null for non-public or non-existent agents.
18
+ * Get agent profile detail by agent ID. Uses `fn_get_agent_profile`.
22
19
  */
23
20
  async getById(t) {
24
- const { data: r, error: e } = await this.rpcClient.rpc("fn_sdk_get_agent_detail", {
25
- p_agent_id: t
21
+ const { data: r, error: e } = await this.rpcClient.rpc("fn_get_agent_profile", {
22
+ p_ai_lenser_id: t
26
23
  });
27
24
  if (e)
28
25
  throw new Error(
29
- `@lenserfight/sdk: fn_sdk_get_agent_detail failed — ${JSON.stringify(e)}`
26
+ `@lenserfight/sdk: fn_get_agent_profile failed — ${JSON.stringify(e)}`
30
27
  );
31
28
  return r ?? null;
32
29
  }
33
30
  /**
34
- * Get lens bindings for a public agent.
31
+ * Get lens bindings for an agent. Uses `fn_list_agent_lens_bindings`.
35
32
  */
36
33
  async getLensBindings(t) {
37
- const { data: r, error: e } = await this.rpcClient.rpc("fn_sdk_get_agent_lens_bindings", {
38
- p_agent_id: t
34
+ const { data: r, error: e } = await this.rpcClient.rpc("fn_list_agent_lens_bindings", {
35
+ p_ai_lenser_id: t,
36
+ p_limit: 50,
37
+ p_offset: 0
39
38
  });
40
39
  if (e)
41
40
  throw new Error(
42
- `@lenserfight/sdk: fn_sdk_get_agent_lens_bindings failed — ${JSON.stringify(e)}`
41
+ `@lenserfight/sdk: fn_list_agent_lens_bindings failed — ${JSON.stringify(e)}`
43
42
  );
44
43
  return Array.isArray(r) ? r : [];
45
44
  }
46
45
  /**
47
- * Get model bindings for a public agent.
46
+ * Get model bindings for an agent. Uses `fn_list_agent_model_bindings`.
48
47
  */
49
48
  async getModelBindings(t) {
50
- const { data: r, error: e } = await this.rpcClient.rpc("fn_sdk_get_agent_model_bindings", {
51
- p_agent_id: t
49
+ const { data: r, error: e } = await this.rpcClient.rpc("fn_list_agent_model_bindings", {
50
+ p_ai_lenser_id: t,
51
+ p_limit: 50,
52
+ p_offset: 0
52
53
  });
53
54
  if (e)
54
55
  throw new Error(
55
- `@lenserfight/sdk: fn_sdk_get_agent_model_bindings failed — ${JSON.stringify(e)}`
56
+ `@lenserfight/sdk: fn_list_agent_model_bindings failed — ${JSON.stringify(e)}`
56
57
  );
57
58
  return Array.isArray(r) ? r : [];
58
59
  }
59
60
  }
60
- const h = 100;
61
- class g {
61
+ const y = 100;
62
+ class m {
62
63
  constructor(t) {
63
64
  this.rpcClient = t;
64
65
  }
@@ -70,77 +71,115 @@ class g {
70
71
  * For deeper paging, pass the last row's `{created_at, id}` as `cursor`.
71
72
  */
72
73
  async browse(t = {}, r, e = 20) {
73
- const n = Math.max(1, Math.min(e, h)), i = {
74
+ const n = Math.max(1, Math.min(e, y)), a = {
74
75
  p_search: t.search ?? null,
75
76
  p_category: t.category ?? null,
76
77
  p_status: t.status ?? null,
77
78
  p_cursor_created_at: r?.created_at ?? null,
78
79
  p_cursor_id: r?.id ?? null,
79
80
  p_limit: n
80
- }, { data: s, error: o } = await this.rpcClient.rpc("fn_browse_battles", i);
81
- if (o)
81
+ }, { data: s, error: l } = await this.rpcClient.rpc("fn_browse_battles", a);
82
+ if (l)
82
83
  throw new Error(
83
- `@lenserfight/sdk: browse failed — ${JSON.stringify(o)}`
84
+ `@lenserfight/sdk: browse failed — ${JSON.stringify(l)}`
84
85
  );
85
86
  return Array.isArray(s) ? s : [];
86
87
  }
87
88
  }
88
- function y(a) {
89
- if (!a.url)
89
+ function b(i) {
90
+ if (!i.url)
90
91
  throw new Error("@lenserfight/sdk: createClient requires `url`");
91
- if (!a.anonKey)
92
+ if (!i.anonKey)
92
93
  throw new Error("@lenserfight/sdk: createClient requires `anonKey`");
93
- const t = a.fetch ?? globalThis.fetch;
94
+ const t = i.fetch ?? globalThis.fetch;
94
95
  if (typeof t != "function")
95
96
  throw new Error("@lenserfight/sdk: global fetch unavailable — pass `fetch` in options");
96
- const r = a.url.replace(/\/+$/, ""), e = a.apiKey ?? a.anonKey;
97
+ const r = i.url.replace(/\/+$/, ""), e = i.apiKey ?? i.anonKey;
97
98
  return {
98
- async rpc(n, i) {
99
+ async rpc(n, a) {
99
100
  const s = await t(`${r}/rest/v1/rpc/${n}`, {
100
101
  method: "POST",
101
102
  headers: {
102
- apikey: a.anonKey,
103
+ apikey: i.anonKey,
103
104
  authorization: `Bearer ${e}`,
104
105
  "content-type": "application/json"
105
106
  },
106
- body: JSON.stringify(i ?? {})
107
+ body: JSON.stringify(a ?? {})
107
108
  });
108
109
  if (!s.ok) {
109
- const c = await s.text().catch(() => "");
110
+ const o = await s.text().catch(() => "");
110
111
  return {
111
112
  data: null,
112
- error: { status: s.status, message: c || s.statusText }
113
+ error: { status: s.status, message: o || s.statusText }
113
114
  };
114
115
  }
115
116
  return { data: await s.json().catch(() => null), error: null };
116
117
  }
117
118
  };
118
119
  }
119
- const m = 100;
120
- class k {
120
+ const k = 100;
121
+ function u(i) {
122
+ if (!i) return [];
123
+ const t = i;
124
+ return Array.isArray(t.data) ? t.data : Array.isArray(i) ? i : [];
125
+ }
126
+ function p(i) {
127
+ return {
128
+ id: i.id,
129
+ title: i.title ?? "",
130
+ description: i.description ?? null,
131
+ author: {
132
+ id: i.lenser_id ?? "",
133
+ handle: i.author_handle ?? "",
134
+ displayName: i.author_handle ?? "",
135
+ avatarUrl: null
136
+ },
137
+ tags: Array.isArray(i.tags) ? i.tags : [],
138
+ visibility: i.visibility ?? "public",
139
+ status: i.status ?? "published",
140
+ outputKind: null,
141
+ latestVersionNumber: null,
142
+ createdAt: i.created_at ?? ""
143
+ };
144
+ }
145
+ class C {
121
146
  constructor(t) {
122
147
  this.rpcClient = t;
123
148
  }
124
149
  /**
125
- * Browse public lenses. Keyset pagination on (created_at DESC, id DESC).
150
+ * Browse public lenses. Uses fn_mcp_lens_list (offset pagination).
151
+ * For text search, uses fn_mcp_lens_search instead.
152
+ * Requires an authenticated client.
126
153
  */
127
- async browse(t = {}, r, e = 20) {
128
- const n = Math.max(1, Math.min(e, m)), { data: i, error: s } = await this.rpcClient.rpc("fn_sdk_browse_lenses", {
129
- p_search: t.search ?? null,
130
- p_tag: t.tag ?? null,
131
- p_kind: t.kind ?? null,
132
- p_cursor_created_at: r?.created_at ?? null,
133
- p_cursor_id: r?.id ?? null,
134
- p_limit: n
154
+ async browse(t = {}, r = 0, e = 20) {
155
+ const n = Math.max(1, Math.min(e, k));
156
+ if (t.search) {
157
+ const { data: l, error: o } = await this.rpcClient.rpc("fn_mcp_lens_search", {
158
+ p_query: t.search,
159
+ p_visibility: "public",
160
+ p_limit: n,
161
+ p_offset: Math.max(0, r)
162
+ });
163
+ if (o)
164
+ throw new Error(`@lenserfight/sdk: fn_mcp_lens_search failed — ${JSON.stringify(o)}`);
165
+ return u(l).map(p);
166
+ }
167
+ const { data: a, error: s } = await this.rpcClient.rpc("fn_mcp_lens_list", {
168
+ p_limit: n,
169
+ p_offset: Math.max(0, r),
170
+ p_visibility: "public",
171
+ p_status: t.status ?? null,
172
+ p_lenser_id: null,
173
+ p_include_archived: !1
135
174
  });
136
175
  if (s)
137
- throw new Error(`@lenserfight/sdk: fn_sdk_browse_lenses failed — ${JSON.stringify(s)}`);
138
- return Array.isArray(i) ? i : [];
176
+ throw new Error(`@lenserfight/sdk: fn_mcp_lens_list failed — ${JSON.stringify(s)}`);
177
+ return u(a).map(p);
139
178
  }
140
179
  /**
141
180
  * Full-text search across public lenses.
142
181
  */
143
- async search(t, r = {}, e, n = 20) {
182
+ async search(t, r = {}, e = 0, n = 20) {
144
183
  return this.browse({ ...r, search: t }, e, n);
145
184
  }
146
185
  /**
@@ -178,37 +217,31 @@ class k {
178
217
  * filled prompt and lists which parameters were used or missing.
179
218
  *
180
219
  * Requires an authenticated client (`apiKey` in `createClient`).
181
- *
182
- * @example
183
- * const result = await lf.lenses.resolveTemplate(lensId, { Topic: 'TypeScript' });
184
- * if (result.missing.length === 0) {
185
- * // pass result.resolvedPrompt to your AI model
186
- * }
187
220
  */
188
221
  async resolveTemplate(t, r, e) {
189
- const { data: n, error: i } = await this.rpcClient.rpc("fn_mcp_lens_resolve_template", {
222
+ const { data: n, error: a } = await this.rpcClient.rpc("fn_mcp_lens_resolve_template", {
190
223
  p_lens_id: t,
191
224
  p_version_id: e?.versionId ?? null
192
225
  });
193
- if (i)
194
- throw new Error(`@lenserfight/sdk: fn_mcp_lens_resolve_template failed — ${JSON.stringify(i)}`);
226
+ if (a)
227
+ throw new Error(`@lenserfight/sdk: fn_mcp_lens_resolve_template failed — ${JSON.stringify(a)}`);
195
228
  if (!n)
196
229
  throw new Error(`@lenserfight/sdk: lens ${t} not found`);
197
230
  const s = n;
198
- let o = s.template_body;
199
- const c = [], _ = [];
200
- for (const l of s.parameters ?? []) {
201
- const d = `[[:${l.id}]]`, f = r[l.label] ?? r[l.label.toLowerCase()] ?? Object.entries(r).find(([w]) => w.toLowerCase() === l.label.toLowerCase())?.[1];
202
- f !== void 0 ? (o = o.split(d).join(f), _.push(l.label)) : l.optional ? o = o.split(d).join("") : c.push(l.label);
231
+ let l = s.template_body;
232
+ const o = [], _ = [];
233
+ for (const c of s.parameters ?? []) {
234
+ const d = `[[:${c.id}]]`, f = r[c.label] ?? r[c.label.toLowerCase()] ?? Object.entries(r).find(([w]) => w.toLowerCase() === c.label.toLowerCase())?.[1];
235
+ f !== void 0 ? (l = l.split(d).join(f), _.push(c.label)) : c.optional ? l = l.split(d).join("") : o.push(c.label);
203
236
  }
204
237
  return {
205
- resolvedPrompt: o,
238
+ resolvedPrompt: l,
206
239
  lensId: s.lens_id,
207
240
  versionId: s.version_id,
208
241
  lensTitle: s.title ?? t,
209
242
  lensDescription: s.description ?? null,
210
243
  paramsUsed: _,
211
- missing: c
244
+ missing: o
212
245
  };
213
246
  }
214
247
  /**
@@ -224,77 +257,95 @@ class k {
224
257
  if (!r) return [];
225
258
  const n = Array.isArray(r) ? r[0] : r;
226
259
  if (!n) return [];
227
- const i = n.input_contract;
228
- if (!i) return [];
229
- const s = i.parameters ?? i.inputs;
260
+ const a = n.input_contract;
261
+ if (!a) return [];
262
+ const s = a.parameters ?? a.inputs;
230
263
  return Array.isArray(s) ? s : [];
231
264
  }
265
+ /**
266
+ * Extract the parameters declared by a lens version — the contracts plus their labels.
267
+ */
268
+ async extractParams(t) {
269
+ const r = await this.getParameterContracts(t);
270
+ return { params: r, labels: r.map((e) => e.label) };
271
+ }
272
+ /**
273
+ * Validate supplied values against a lens version's parameter contracts.
274
+ */
275
+ async validateParams(t, r) {
276
+ const e = await this.getParameterContracts(t), n = new Set(Object.keys(r).map((o) => o.toLowerCase())), a = new Set(e.map((o) => o.label.toLowerCase())), s = e.filter((o) => o.required && !n.has(o.label.toLowerCase())).map((o) => o.label), l = Object.keys(r).filter(
277
+ (o) => !a.has(o.toLowerCase())
278
+ );
279
+ return {
280
+ valid: s.length === 0 && l.length === 0,
281
+ missing: s,
282
+ unknown: l,
283
+ total: e.length,
284
+ provided: Object.keys(r).length
285
+ };
286
+ }
232
287
  }
233
- class C {
288
+ class A {
234
289
  constructor(t) {
235
290
  this.rpcClient = t;
236
291
  }
237
292
  /**
238
- * Get the contract for a lens version (by version_id).
239
- * Uses `fn_sdk_get_contract(p_version_id)`.
293
+ * Get the input contract for a lens version. Uses `fn_get_version_contracts`.
294
+ * Note: contentHash, publishedBy, publishedAt are not available from this function.
240
295
  */
241
296
  async getContractByVersion(t) {
242
- const { data: r, error: e } = await this.rpcClient.rpc("fn_sdk_get_contract", {
243
- p_version_id: t,
244
- p_content_hash: null
297
+ const { data: r, error: e } = await this.rpcClient.rpc("fn_get_version_contracts", {
298
+ p_version_id: t
245
299
  });
246
300
  if (e)
247
- throw new Error(`@lenserfight/sdk: fn_sdk_get_contract failed — ${JSON.stringify(e)}`);
248
- return r ?? null;
301
+ throw new Error(`@lenserfight/sdk: fn_get_version_contracts failed — ${JSON.stringify(e)}`);
302
+ if (!r) return null;
303
+ const n = Array.isArray(r) ? r[0] : r;
304
+ if (!n) return null;
305
+ const a = n.input_contract;
306
+ return a ? { contentHash: "", body: a, publishedBy: "", publishedAt: "", supersedesHash: null } : null;
249
307
  }
250
308
  /**
251
- * Get a contract by its content hash (hex-encoded SHA-256).
252
- * Uses `fn_sdk_get_contract(p_content_hash)`.
309
+ * Hash-based contract lookup is not supported by the current DB schema.
310
+ * Always returns null.
253
311
  */
254
312
  async getContractByHash(t) {
255
- const { data: r, error: e } = await this.rpcClient.rpc("fn_sdk_get_contract", {
256
- p_version_id: null,
257
- p_content_hash: t
258
- });
259
- if (e)
260
- throw new Error(`@lenserfight/sdk: fn_sdk_get_contract failed — ${JSON.stringify(e)}`);
261
- return r ?? null;
313
+ return null;
262
314
  }
263
315
  /**
264
- * Get the full manifest (contract + channel + signatures) for a version.
316
+ * Get the manifest for a lens version. Built from `fn_get_version_contracts`.
317
+ * Channel and signatures are not available.
265
318
  */
266
319
  async getManifest(t) {
267
- const { data: r, error: e } = await this.rpcClient.rpc("fn_sdk_get_manifest", {
268
- p_version_id: t
269
- });
270
- if (e)
271
- throw new Error(`@lenserfight/sdk: fn_sdk_get_manifest failed — ${JSON.stringify(e)}`);
272
- return r ?? null;
320
+ const r = await this.getContractByVersion(t);
321
+ return r ? {
322
+ specVersion: r.body?.specVersion ?? "1.0.0",
323
+ contentHash: r.contentHash,
324
+ body: r.body,
325
+ channel: null,
326
+ signatures: []
327
+ } : null;
273
328
  }
274
329
  /**
275
- * Get dependency edges for a contract (its children in the DAG).
330
+ * Dependency graph lookup is not supported by the current DB schema.
331
+ * Always returns an empty array.
276
332
  */
277
333
  async getDependencies(t) {
278
- const { data: r, error: e } = await this.rpcClient.rpc("fn_sdk_get_dependencies", {
279
- p_content_hash: t
280
- });
281
- if (e)
282
- throw new Error(`@lenserfight/sdk: fn_sdk_get_dependencies failed — ${JSON.stringify(e)}`);
283
- return Array.isArray(r) ? r : [];
334
+ return [];
284
335
  }
285
336
  /**
286
- * Check if a contract satisfies required scopes. Pure client-side logic —
287
- * fetches the contract and compares scopes locally.
337
+ * Check if a lens version satisfies required scopes. Fetches the contract
338
+ * via `getContractByVersion` and compares scopes locally.
288
339
  */
289
340
  async checkCompatibility(t, r) {
290
- const e = await this.getContractByHash(t);
341
+ const e = await this.getContractByVersion(t);
291
342
  if (!e)
292
343
  return { compatible: !1, missingScopes: [], warnings: ["Contract not found"] };
293
- const n = e.body.requiredScopes ?? [], i = r.filter((s) => !n.includes(s));
294
- return { compatible: i.length === 0, missingScopes: i, warnings: [] };
344
+ const n = e.body?.requiredScopes ?? [], a = r.filter((s) => !n.includes(s));
345
+ return { compatible: a.length === 0, missingScopes: a, warnings: [] };
295
346
  }
296
347
  }
297
- class b {
348
+ class S {
298
349
  constructor(t) {
299
350
  this.rpcClient = t;
300
351
  }
@@ -316,8 +367,8 @@ class b {
316
367
  return typeof e == "string" ? e : "";
317
368
  }
318
369
  }
319
- const S = /* @__PURE__ */ new Set(["completed", "failed", "cancelled"]), $ = 3e3, E = 12e4;
320
- class A {
370
+ const v = /* @__PURE__ */ new Set(["completed", "failed", "cancelled"]), $ = 3e3, E = 12e4;
371
+ class O {
321
372
  constructor(t) {
322
373
  this.rpcClient = t;
323
374
  }
@@ -355,15 +406,15 @@ class A {
355
406
  * Requires an authenticated client (`apiKey` in `createClient`).
356
407
  */
357
408
  async startRun(t, r, e) {
358
- const { data: n, error: i } = await this.rpcClient.rpc("fn_mcp_workflow_run_start", {
409
+ const { data: n, error: a } = await this.rpcClient.rpc("fn_mcp_workflow_run_start", {
359
410
  p_workflow_id: t,
360
411
  p_inputs: r ?? {},
361
412
  p_global_model_id: e?.modelId ?? null,
362
413
  p_idempotency_key: e?.idempotencyKey ?? null,
363
414
  p_metadata: {}
364
415
  });
365
- if (i)
366
- throw new Error(`@lenserfight/sdk: fn_mcp_workflow_run_start failed — ${JSON.stringify(i)}`);
416
+ if (a)
417
+ throw new Error(`@lenserfight/sdk: fn_mcp_workflow_run_start failed — ${JSON.stringify(a)}`);
367
418
  if (!n)
368
419
  throw new Error(`@lenserfight/sdk: workflow ${t} not found or inaccessible`);
369
420
  return n;
@@ -397,8 +448,8 @@ class A {
397
448
  if (e)
398
449
  throw new Error(`@lenserfight/sdk: fn_mcp_workflow_run_logs failed — ${JSON.stringify(e)}`);
399
450
  const n = r?.node_results;
400
- return Array.isArray(n) ? n.map((i) => {
401
- const s = i;
451
+ return Array.isArray(n) ? n.map((a) => {
452
+ const s = a;
402
453
  return {
403
454
  nodeId: s.node_id,
404
455
  status: s.status,
@@ -417,20 +468,20 @@ class A {
417
468
  * @param timeoutMs Maximum wait time in milliseconds (default 120 s).
418
469
  */
419
470
  async awaitRun(t, r, e) {
420
- const n = e?.timeoutMs ?? E, i = await this.startRun(t, r, e), s = Date.now() + n;
471
+ const n = e?.timeoutMs ?? E, a = await this.startRun(t, r, e), s = Date.now() + n;
421
472
  for (; Date.now() < s; ) {
422
- await new Promise((c) => setTimeout(c, $));
423
- const o = await this.getRunStatus(i.id);
424
- if (S.has(o.status)) {
425
- if (o.status === "completed")
426
- return this.getRunLogs(i.id);
427
- throw new Error(`@lenserfight/sdk: workflow run ${i.id} ended with status "${o.status}"`);
473
+ await new Promise((o) => setTimeout(o, $));
474
+ const l = await this.getRunStatus(a.id);
475
+ if (v.has(l.status)) {
476
+ if (l.status === "completed")
477
+ return this.getRunLogs(a.id);
478
+ throw new Error(`@lenserfight/sdk: workflow run ${a.id} ended with status "${l.status}"`);
428
479
  }
429
480
  }
430
- throw new Error(`@lenserfight/sdk: workflow run ${i.id} timed out after ${n}ms`);
481
+ throw new Error(`@lenserfight/sdk: workflow run ${a.id} timed out after ${n}ms`);
431
482
  }
432
483
  }
433
- class p {
484
+ class h {
434
485
  agents;
435
486
  battles;
436
487
  lenses;
@@ -439,12 +490,11 @@ class p {
439
490
  workflows;
440
491
  rpc;
441
492
  constructor(t) {
442
- this.rpc = t, this.agents = new u(t), this.battles = new g(t), this.lenses = new k(t), this.protocols = new C(t), this.templates = new b(t), this.workflows = new A(t);
493
+ this.rpc = t, this.agents = new g(t), this.battles = new m(t), this.lenses = new C(t), this.protocols = new A(t), this.templates = new S(t), this.workflows = new O(t);
443
494
  }
444
495
  /**
445
496
  * Direct RPC escape hatch. Use sparingly — anything that's part of the
446
- * stable surface should live on `battles` / `templates` (or get added there
447
- * in a follow-up PR).
497
+ * stable surface should live on a named sub-client.
448
498
  */
449
499
  async rpcCall(t, r) {
450
500
  const { data: e, error: n } = await this.rpc.rpc(t, r);
@@ -453,22 +503,24 @@ class p {
453
503
  return e;
454
504
  }
455
505
  }
456
- function v(a) {
457
- const t = y(a);
458
- return new p(t);
506
+ function N(i) {
507
+ const t = b(i);
508
+ return new h(t);
459
509
  }
460
- function O(a) {
461
- return new p(a);
510
+ function M(i) {
511
+ return new h(i);
462
512
  }
463
- const N = "0.3.0-alpha.0";
513
+ const L = "1.0.0";
464
514
  export {
465
- g as BattleClient,
466
- k as LensClient,
467
- p as LenserFightClient,
468
- N as SDK_VERSION,
469
- b as TemplateClient,
470
- A as WorkflowClient,
471
- v as createClient,
472
- O as createClientFromRpc,
473
- y as createFetchRpcClient
515
+ g as AgentClient,
516
+ m as BattleClient,
517
+ C as LensClient,
518
+ h as LenserFightClient,
519
+ A as ProtocolClient,
520
+ L as SDK_VERSION,
521
+ S as TemplateClient,
522
+ O as WorkflowClient,
523
+ N as createClient,
524
+ M as createClientFromRpc,
525
+ b as createFetchRpcClient
474
526
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lenserfight/sdk",
3
- "version": "0.3.0-alpha.9",
3
+ "version": "2.1.0",
4
4
  "description": "LenserFight public client SDK — browse and execute lenses, workflows, battles, agents, and protocols from any Supabase-backed deployment",
5
5
  "license": "MIT",
6
6
  "main": "./index.cjs",