broods 0.54.1 → 0.55.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/dist/account.d.ts +51 -490
- package/dist/{chunk-aqcx0cwa.js → chunk-2vxrctp1.js} +5 -5
- package/dist/{chunk-7nrh4nqb.js → chunk-6e95e9kc.js} +7 -7
- package/dist/{chunk-j55y24fb.js → chunk-dgm6742m.js} +1 -1
- package/dist/{chunk-wamkxgcg.js → chunk-fka39yjm.js} +2 -2
- package/dist/cli/index.js +90 -62
- package/dist/index.d.ts +124 -1048
- package/dist/index.js +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
function q(e){if(e.events&&e.input!==void 0)throw Error("Run input accepts either `input` or `events`, not both");if(e.events&&e.events.length>0)return e.events;if(typeof e.input==="string")return[{role:"user",content:[{type:"text",text:e.input}]}];throw Error("Run input requires `input` (string) or a non-empty `events` array")}async function*ae(e){let n=e.getReader(),t=new TextDecoder,o="";try{while(!0){let{done:r,value:
|
|
2
|
-
`);o=
|
|
3
|
-
`)}async function H(e,n){await
|
|
4
|
-
`).replace(/\\"/g,'"');if(e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1);let n=e.indexOf(" #");return n>=0?e.slice(0,n).trimEnd():e}var j=new TextEncoder,pe={name:"HMAC",hash:"SHA-256"};async function de(e,n,t,o){let r=le(j.encode(JSON.stringify(t))),i=await crypto.subtle.sign(pe,await Dn(n,o),j.encode(r));return`${e}${r}.${le(new Uint8Array(i))}`}function le(e){let n="";for(let t of e)n+=String.fromCharCode(t);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function Dn(e,n){let t=await crypto.subtle.digest("SHA-256",j.encode(`${e}${n}`));return crypto.subtle.importKey("raw",t,pe,!1,["sign","verify"])}var On="buat_",Z="bsig_",te="x-broods-user-token",he="broods.user.";var en=600000,V=3600000,Mn="broods-user-token:",nn=/^[A-Za-z0-9._@+=-]{1,128}$/,tn=100,_n=256,Un=60000;async function on(e,n,t=Date.now()){if(!n.startsWith(Z))throw Error(`The user token signing secret must start with ${Z}. It is not the bsk_ runtime key.`);let o=Pn(e,t);if(!o||e.expiresAt>t+V)throw Error(`Invalid user token: userId must match ${nn.source}, conversations must be at most ${tn} non-empty keys, and expiresAt must be in the next ${V/60000} minutes.`);return await de(On,Mn,o,n)}function Pn(e,n){if(!e||typeof e!=="object")return null;let{userId:t,conversations:o,expiresAt:r}=e;if(typeof t!=="string"||!nn.test(t)||typeof r!=="number"||!Number.isFinite(r)||r<=n||r>n+V+Un)return null;if(o===void 0)return{userId:t,expiresAt:r};if(!Array.isArray(o)||o.length>tn||!o.every((i)=>typeof i==="string"&&i.trim()===i&&i.length>0&&i.length<=_n))return null;return{userId:t,conversations:o,expiresAt:r}}var g="BROODS_USER_TOKEN_SECRET";async function be(e){let n=e.secret??process.env[g];if(!n)throw Error(`signUserToken needs the stage's signing secret: pass secret or set ${g}. \`broods dev\` and \`broods deploy\` write it to .env.local; the dashboard's Runtime key tab rotates it.`);return await on({userId:e.userId,...e.conversations?{conversations:e.conversations}:{},expiresAt:Date.now()+(e.ttlMs??en)},n)}var T="https://gateway.broods.app";class ce extends Error{accepted;constructor(e){super(`Ingress ${e.eventId} was accepted asynchronously with status ${e.status??"queued"}`);this.accepted=e;this.name="IngressAcceptedError"}}class N{baseUrl;apiKey;userToken;fetchImpl;constructor(e={}){m(),this.baseUrl=K(e.baseUrl||e.host||process.env.BROODS_BASE_URL||process.env.BROODS_HOST||T),this.apiKey=e.apiKey||process.env.BROODS_API_KEY||void 0,this.userToken=e.userToken,this.fetchImpl=e.fetch??fetch}channelWebhookUrl(e){return`${this.baseUrl}${e.webhookPath.startsWith("/")?"":"/"}${e.webhookPath}`}accountWebhookUrl(e,n){let t=[e,n].map(encodeURIComponent);return`${this.baseUrl}/v1/webhooks/${t.join("/")}`}stageWebhookUrl(e,n,t){let o=[e,"dev",n,t].map(encodeURIComponent);return`${this.baseUrl}/v1/webhooks/${o.join("/")}`}agent(e,n){if(typeof e==="string"){let o=e,r=n??"";if(!r)throw Error(`Agent ${o} is missing a generated id. Run broods dev --once or broods deploy to sync it first.`);return{id:r,run:(i)=>this.run({...i,agentName:o,agentId:r}),runAsync:(i)=>this.runAsync({...i,agentName:o,agentId:r}),continue:(i)=>this.continue({...i,agentId:r}),stream:(i)=>this.stream({...i,agentName:o,agentId:r})}}let t=e;if(!t.id)throw Error(`Agent ${t.name} is missing a generated id. Run broods dev --once or broods deploy to sync it first.`);return{id:t.id,run:(o)=>this.run(t,o),runAsync:(o)=>this.runAsync(t,o),continue:(o)=>this.continue(t,o),stream:(o)=>this.stream(t,o)}}async run(e,n){let t=[],o="",r=n?this.stream(e,n):this.stream(e);for await(let i of r)if(t.push(i),i.type==="text-delta")o+=i.text;return{text:o,events:t}}async*stream(e,n){let t=n?{...n,agentId:e.id,agentName:e.name}:e,o=rn(t,"cli"),r=n?this.scopedUrl(e):`${this.baseUrl}/v1/runs`,i=await this.openStream(o,r);if(!i.ok)throw Error(`Run failed: ${i.status} ${await i.text()}`);if(i.status===202)throw new ce(sn(await i.json(),o));if(!i.body)throw Error("Run response has no body");for await(let s of ae(i.body)){let a;try{a=JSON.parse(s)}catch{continue}if(a.type==="error")throw Error(`Agent run failed: ${Wn(a.error)}`);yield a}}async runAsync(e,n){let t=n?{...n,agentId:e.id,agentName:e.name}:e,o={...rn(t,"async"),background:!0},r=n?this.scopedUrl(e):`${this.baseUrl}/v1/runs`;return this.postAcceptedRun(r,o,"Async run")}async continue(e,n){let t=n?e:null,o=n??e,r={agentId:t?t.id:e.agentId,eventId:o.eventId??`continue-${crypto.randomUUID()}`,conversationKey:o.conversationKey,continue:!0},i=t?this.scopedUrl(t):`${this.baseUrl}/v1/runs`;return this.postAcceptedRun(i,r,"Continue")}async getAsyncStatus(e){let n=this.resolveStatusUrl(e),t=await this.fetchJson(n,{method:"GET",headers:await this.apiKeyHeaders()});if(t.status===404)return{status:"not_found"};if(!t.ok)throw Error(`Status check failed: ${t.status} ${await t.text()}`);return await t.json()}async waitForAsyncStatus(e,n={}){let t=Date.now()+(n.timeoutMs??180000),o=n.intervalMs??2000;while(Date.now()<t){if(n.signal?.aborted)throw Error("Async status polling aborted.");let r=await this.getAsyncStatus(e);if(r.status==="awaiting_approval"||r.status==="awaiting_input"||r.status==="completed"||r.status==="failed"||r.status==="expired"||r.status==="not_found")return r;await Ln(o,n.signal)}throw Error("Polling timeout")}scopedUrl(e){if(e.projectSlug&&e.stageSlug&&e.endpointId)return`${this.baseUrl}/v1/projects/${encodeURIComponent(e.projectSlug)}/stages/${encodeURIComponent(e.stageSlug)}/agents/${encodeURIComponent(e.endpointId)}`;return`${this.baseUrl}/v1/runs`}asyncAgentRun(e,n){return{...e,conversationKey:n,poll:()=>this.getAsyncStatus(e),wait:(t)=>this.waitForAsyncStatus(e,t)}}async postAcceptedRun(e,n,t){let o=await this.fetchJson(e,{method:"POST",headers:await this.apiKeyHeaders(),body:JSON.stringify(n)});if(o.status!==202)throw Error(`${t} failed: ${o.status} ${await Kn(o,"202 JSON")}`);return this.asyncAgentRun(sn(await o.json(),n),n.conversationKey)}async openStream(e,n){if(this.apiKey)return await this.fetchCore(e,n,{Authorization:`Bearer ${this.apiKey}`,...await this.userTokenHeaders()});throw Error(`BroodsClient streams directly from the core service at ${this.baseUrl}. Provide apiKey. For a self-hosted core service, set host/baseUrl or BROODS_HOST/BROODS_BASE_URL.`)}async fetchCore(e,n,t){try{return await this.fetchImpl(n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...t},body:JSON.stringify(e)})}catch(o){throw Error(`Cannot access the broods core service at ${n}. The SDK uses ${T} by default; set host/baseUrl or BROODS_HOST/BROODS_BASE_URL to your own core service URL if your account uses a custom deployment. Cause: ${o instanceof Error?o.message:String(o)}`)}}async apiKeyHeaders(){if(!this.apiKey)throw Error("BroodsClient requires apiKey or BROODS_API_KEY.");return{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`,...await this.userTokenHeaders()}}async userTokenHeaders(){let e=typeof this.userToken==="function"?await this.userToken():this.userToken;return e?{[te]:e}:{}}async fetchJson(e,n){try{return await this.fetchImpl(e,n)}catch(t){throw Error(`Cannot access the broods core service at ${e}. Cause: ${t instanceof Error?t.message:String(t)}`)}}resolveStatusUrl(e){if(typeof e!=="string")return e.statusUrl;if(/^https?:\/\//.test(e))return e;return $n(this.baseUrl,e)}}function K(e){let n=e.trim(),t=/^[A-Za-z][A-Za-z0-9+.-]*:\/\//.test(n)?n:`https://${n}`;return f(t)}function rn(e,n){let t=e.eventId??`${n}-${crypto.randomUUID()}`;return{agentId:e.agentId,eventId:t,conversationKey:e.conversationKey??t,events:q(e),...e.mode!==void 0?{mode:e.mode}:{},...e.idempotencyKey!==void 0?{idempotencyKey:e.idempotencyKey}:{},...e.system!==void 0?{system:e.system}:{},...e.model!==void 0?{model:e.model}:{}}}function Wn(e){if(typeof e==="string")return e;if(!e||typeof e!=="object")return String(e);let n=e,t=n.data?.error?.message??n.message??n.responseBody??JSON.stringify(e),o=n.name?`${n.name}: `:"",r=n.statusCode?` (HTTP ${n.statusCode})`:"";return`${o}${t}${r}`}function sn(e,n){if(!e||typeof e!=="object")throw Error("Async response must be an object");let t=e.statusUrl;if(typeof t!=="string"||t.length===0)throw Error("Async response missing statusUrl");let o=e.runId;if(typeof o!=="string"||o.length===0)throw Error("Async response missing runId");let r=typeof e.eventId==="string"?e.eventId:o,{status:i,requestedMode:s}=e;return{statusUrl:t,runId:o,eventId:r,agentId:n.agentId,...i==="accepted"||i==="queued"||i==="applied"||i==="processing"?{status:i}:{},...s==="reject"||s==="followup"||s==="collect"||s==="steer"?{requestedMode:s}:{}}}async function Kn(e,n){if((e.headers.get("content-type")??"").toLowerCase().includes("text/event-stream"))return await e.body?.cancel().catch(()=>{}),`expected ${n}, but the server returned an SSE stream. This usually means the core deployment ignored the background flag and ran the request on the direct streaming runner.`;let o=await e.text();if(o.length<=2000)return o;return`${o.slice(0,2000)}... [truncated ${o.length-2000} chars]`}function Ln(e,n){return new Promise((t,o)=>{if(n?.aborted){o(Error("Async status polling aborted."));return}let r=setTimeout(t,e);n?.addEventListener("abort",()=>{clearTimeout(r),o(Error("Async status polling aborted."))},{once:!0})})}function $n(e,n){return`${K(e)}/v1/runs/${encodeURIComponent(n)}`}var Bn=2000,an=0,w=1;class fe{baseUrl;apiKey;userToken;WebSocketImpl;connectTimeoutMs;constructor(e={}){if(m(),this.baseUrl=pn(e.baseUrl||e.host||process.env.BROODS_BASE_URL||process.env.BROODS_HOST||T),this.apiKey=e.apiKey||process.env.BROODS_API_KEY||"",!this.apiKey)throw Error("BroodsWebSocketClient requires apiKey or BROODS_API_KEY.");this.userToken=e.userToken,this.WebSocketImpl=e.WebSocket,this.connectTimeoutMs=e.connectTimeoutMs??Bn}subscribe(e,n={}){let t=this.resolveWebSocket(),o=this.buildUrl(e),r=Hn(e),i=ln(this.baseUrl),s=new t(o,E(this.apiKey,e.userToken??this.userToken)),a=!1,c=!1,d=setTimeout(()=>{if(!a)A(i)},this.connectTimeoutMs),R=(p=1000,_="client closed")=>{if(c)return;if(c=!0,clearTimeout(d),e.signal?.removeEventListener("abort",D),s.readyState===w||s.readyState===an)s.close(p,_)},A=(p)=>{n.onError?.(p),R(1000,"websocket error")},Cn=()=>{n.onDone?.(),R(1000,"done")},D=()=>{if(s.readyState===w)s.send(JSON.stringify({type:"cancel"}));A(Error("WebSocket run aborted."))};return e.signal?.addEventListener("abort",D,{once:!0}),s.onopen=()=>{if(a=!0,clearTimeout(d),e.signal?.aborted){D();return}s.send(JSON.stringify({type:"execute",agentId:r,...e.answers?{answers:e.answers}:{events:q(e)},sessionId:e.sessionId,...e.eventId!==void 0?{eventId:e.eventId}:{},...e.mode!==void 0?{mode:e.mode}:{},...e.idempotencyKey!==void 0?{idempotencyKey:e.idempotencyKey}:{},...e.system!==void 0?{system:e.system}:{},...e.model!==void 0?{model:e.model}:{}}))},s.onmessage=(p)=>{if(typeof p.data!=="string")return;let _=un(p.data);if(!_)return;let P=gn(_,n);switch(n.onMessage?.(P),P.type){case"meta":n.onMeta?.(P);break;case"done":Cn();break;case"error":A(Error(cn(P.error)));break}},s.onerror=()=>{A(i)},s.onclose=(p)=>{if(clearTimeout(d),e.signal?.removeEventListener("abort",D),c||p.code===1000)return;A(Error(p.reason||"WebSocket connection closed."))},{url:o,sendControl:function(p){if(s.readyState!==w)throw Error("WebSocket is not open");s.send(JSON.stringify({type:"control",...p}))},close:R}}attach(e,n={}){let t=this.resolveWebSocket(),o=this.buildUrl(e),r=new t(o,E(this.apiKey,e.userToken??this.userToken)),i=!1,s=(c=1000,d="client closed")=>{if(i)return;if(i=!0,e.signal?.removeEventListener("abort",a),r.readyState===w||r.readyState===an)r.close(c,d)},a=()=>{s(1000,"aborted"),n.onError?.(Error("WebSocket attach aborted."))};if(e.signal?.aborted)a();else e.signal?.addEventListener("abort",a,{once:!0});return r.onopen=()=>{if(i)return;r.send(JSON.stringify({type:"attach",...e,signal:void 0,agent:void 0,userToken:void 0}))},r.onmessage=(c)=>{if(i||typeof c.data!=="string")return;let d=un(c.data);if(!d)return;let R=gn(d,n);if(i)return;if(n.onMessage?.(R),i)return;if(R.type==="done")n.onDone?.();if(R.type==="error")n.onError?.(Error(cn(R.error)))},r.onerror=()=>{if(i)return;s(1000,"websocket error"),n.onError?.(ln(this.baseUrl))},r.onclose=(c)=>{if(e.signal?.removeEventListener("abort",a),!i&&c.code!==1000)n.onError?.(Error(c.reason||"WebSocket connection closed."))},{url:o,sendControl:function(c){if(r.readyState!==w)throw Error("WebSocket is not open");r.send(JSON.stringify({type:"control",...c}))},close:s}}async*stream(e){let n=[],t=!1,o=null,r=null,i=()=>{r?.(),r=null},s=this.subscribe(e,{onMessage:function(a){n.push(a),i()},onDone:function(){t=!0,i()},onError:function(a){o=a,i()}});try{while(!0){if(n.length>0){yield n.shift();continue}if(o)throw o;if(t)return;await new Promise((a)=>{r=a})}}finally{s.close()}}buildUrl(e){let n=Gn(e),t=e.projectSlug??e.agent?.projectSlug,o=e.stageSlug??e.agent?.stageSlug,r=t&&o?`/projects/${encodeURIComponent(t)}/stages/${encodeURIComponent(o)}`:"";return`${G(this.baseUrl)}/v1${r}/agents/${encodeURIComponent(n)}/ws`}resolveWebSocket(){let e=this.WebSocketImpl??globalThis.WebSocket;if(!e)throw Error("WebSocket is not available. Pass a WebSocket implementation in BroodsWebSocketClient options.");return e}}function G(e){let n=new URL(pn(e));if(n.protocol==="https:")n.protocol="wss:";if(n.protocol==="http:")n.protocol="ws:";return f(n.toString())}function E(e,n){return["broods.v1",`broods.token.${e}`,...n?[`${he}${n}`]:[]]}function cn(e){if(typeof e==="string")return e;if(e&&typeof e==="object"&&typeof e.message==="string")return e.message;return e===void 0?"WebSocket stream error.":JSON.stringify(e)}function pn(e){let n=e.trim();if(/^wss?:\/\//.test(n))return f(n);return K(n)}function un(e){try{let n=JSON.parse(e);return typeof n==="object"&&n!==null&&typeof n.type==="string"?n:null}catch{return null}}function Hn(e){let n=e.agentId??e.agent?.id??e.endpointId;if(!n)throw Error("WebSocket run requires agent, agentId, or endpointId.");return n}function Gn(e){let n=e.endpointId??e.agent?.endpointId??e.agent?.id;if(!n)throw Error("WebSocket run requires agent or endpointId.");return n}function gn(e,n){if(e.type!=="output")return e;let t=e;return n.onOutput?.(t),t.data}function ln(e){return Error(`Cannot access the WebSocket service at ${e}.`)}var fn=Symbol.for("broods.resource"),yn=Symbol.for("broods.config"),mn=Symbol.for("broods.connection"),dn=/^[A-Z][A-Z0-9_]{0,63}$/,ve=new Proxy((e)=>{if(!dn.test(e))throw Error("env name must match /^[A-Z][A-Z0-9_]*$/ and be at most 64 characters.");return{__beeblastEnv:!0,name:e}},{get:function(e,n,t){if(typeof n==="string"&&dn.test(n))throw Error(`env.${n} is not supported; use env("${n}")`);return Reflect.get(e,n,t)}});function _e(e){let{name:n,description:t,...o}=e;return I("agent",n,t,o)}function we(e){return{[yn]:!0,config:e}}function Re(e){let{name:n,description:t,...o}=e;return I("cron",n,t,o)}function $e(e){return e}function Ce(e){let{name:n,description:t,...o}=e;return I("mcp",n,t,o)}function Ee(e){let{name:n,description:t,...o}=e;return I("policy",n,t,o)}function ke(e){let{name:n,description:t,...o}=e;return I("sandbox",n,t,o)}function Te(e){let{name:n,description:t,...o}=e;return I("skill",n,t,o)}function Pe(e){let{name:n,description:t,...o}=e;return I("workspace",n,t,o)}function Ie(e){return l("discord",e)}function ze(e){return l("github",e)}function xe(e){return l("gchat",e)}function Ae(e){return l("instagram",e)}function Oe(e){return l("linear",e)}function Me(e){return l("matrix",e)}function Ne(e){return l("messenger",e)}function je(e){return l("pancake",e)}function De(e){return l("slack",e)}function qe(e){return l("teams",e)}function Le(e){return l("telegram",e)}function Ue(e){return l("twilio",e)}function Fe(e){return l("whatsapp",e)}function Be(e){return l("zalo",e)}function He(e){let{name:n,description:t,channelId:o,guildId:r,...i}=e;return u(n,t,o,r,i)}function Ze(e){let{name:n,description:t,repo:o,...r}=e,[i,...s]=o.split("/");if(!i||s.length!==1||!s[0])throw Error(`Channel "${n}" repo must be "owner/name", not "${o}"`);return u(n,t,o,i,r)}function Ve(e){let{name:n,description:t,spaceName:o,...r}=e;return u(n,t,o,void 0,r)}function Ke(e){let{name:n,description:t,igsid:o,...r}=e;return u(n,t,o,void 0,r)}function Ge(e){let{name:n,description:t,team:o,...r}=e;return u(n,t,o,void 0,r)}function We(e){let{name:n,description:t,channelId:o,...r}=e;return u(n,t,o,void 0,r)}function Je(e){let{name:n,description:t,psid:o,...r}=e;return u(n,t,o,void 0,r)}function Ye(e){let{name:n,description:t,conversationId:o,...r}=e;return u(n,t,o,void 0,r)}function Xe(e){let{name:n,description:t,channelId:o,teamId:r,...i}=e;return u(n,t,o,r,i)}function Qe(e){let{name:n,description:t,channelId:o,teamId:r,...i}=e;return u(n,t,o,r,i)}function et(e){let{name:n,description:t,chatId:o,...r}=e;return u(n,t,o,void 0,r)}function tt(e){let{name:n,description:t,from:o,...r}=e;return u(n,t,o,void 0,r)}function nt(e){let{name:n,description:t,waId:o,...r}=e;return u(n,t,o,void 0,r)}function rt(e){let{name:n,description:t,chatId:o,...r}=e;return u(n,t,o,void 0,r)}function ne(e){return Boolean(e&&typeof e==="object"&&e[yn])}function v(e){return Boolean(e&&typeof e==="object"&&e[mn])}function h(e){return Boolean(e&&typeof e==="object"&&e[fn])}function u(e,n,t,o,r){return I("channelRecord",e,n,{...r,externalId:t,...o?{workspaceRef:o}:{}})}function l(e,n){let{partition:t,...o}=n;return{[mn]:!0,kind:"connection",type:e,...t?{partition:t}:{},config:o}}function I(e,n,t,o){return{[fn]:!0,kind:e,name:n,...t?{description:t}:{},config:o}}
|
|
5
|
-
export{q,ae,L,me,ye,Se,U,
|
|
1
|
+
function q(e){if(e.events&&e.input!==void 0)throw Error("Run input accepts either `input` or `events`, not both");if(e.events&&e.events.length>0)return e.events;if(typeof e.input==="string")return[{role:"user",content:[{type:"text",text:e.input}]}];throw Error("Run input requires `input` (string) or a non-empty `events` array")}async function*ae(e){let n=e.getReader(),t=new TextDecoder,o="";try{while(!0){let{done:r,value:s}=await n.read();if(r)break;o+=t.decode(s,{stream:!0});let i=o.split(`
|
|
2
|
+
`);o=i.pop()??"";for(let a of i)if(a.startsWith("data: "))yield a.slice(6)}}finally{await n.cancel().catch(()=>{return}),n.releaseLock()}}var L=500,hn=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,Sn=/^(?!0{32}$)[0-9a-f]{32}$/;function me(e){return e==="DEBUG"||e==="INFO"||e==="WARN"||e==="ERROR"}function ye(e){if(typeof e!=="object"||e===null)return!1;let n=e;if(n.type==="subscribe")return Rn(n);if(n.type==="unsubscribe")return J(n.stream);if(n.type==="fetchTrace")return B(n.traceId);return!1}function Se(e){return e==="task"||e==="cron"||e==="subtask"}function U(e){return typeof e==="string"&&hn.test(e)}function B(e){return typeof e==="string"&&Sn.test(e)}function J(e){return e==="logs"||e==="traces"}function Rn(e){let n=e.stream;if(!J(n))return!1;let t=e.backfill;if(t!==void 0&&(typeof t!=="number"||!Number.isSafeInteger(t)||t<0||t>500))return!1;if(e.liveOnly!==void 0&&typeof e.liveOnly!=="boolean")return!1;let o=e.minLevel;if(o!==void 0&&!me(o))return!1;let r=e.sandboxId;return r===void 0||n==="logs"&&U(r)}import{readFileSync as bn}from"node:fs";import{chmod as ee,mkdir as In,writeFile as kn}from"node:fs/promises";import{homedir as An}from"node:os";import{dirname as X,join as xn}from"node:path";var y="broods",b="_generated",z=xn(An(),".broods","config.json"),Y="broods.app",Q="dashboard",vn="gateway";function k(e){let n=process.env.BROODS_TOKEN,t=e??process.env.BROODS_BASE_URL;if(n&&t)return{baseUrl:f(t),token:n,createdAt:new Date().toISOString()};let o=oe();if(!o)return null;if(t)return o.logins[f(t)]??null;let r=process.env.BROODS_DASHBOARD_URL;if(r){let s=f(r);return Object.values(o.logins).find((i)=>i.dashboardUrl===s)??null}return o.logins[o.current]??null}async function F(e){let n=oe()?.logins??{},t={current:e.baseUrl,logins:{...n,[e.baseUrl]:e}};await In(X(z),{recursive:!0,mode:448}),await ee(X(z),448),await H(z,`${JSON.stringify(t,null,2)}
|
|
3
|
+
`)}async function H(e,n){await kn(e,n,{encoding:"utf8",mode:384}),await ee(e,384)}function S(){return process.env.BROODS_STAGE}function f(e){let n=e.length;while(n>0&&e.charCodeAt(n-1)===47)n-=1;return e.slice(0,n)}function O(e){try{let n=new URL(e);if(!n.hostname.startsWith(`${Q}.`))return;let t=n.hostname.slice(Q.length+1);if(t!==Y&&!t.endsWith(`.${Y}`))return;return n.hostname=`${vn}.${t}`,f(n.origin)}catch{return}}function oe(){try{let e=JSON.parse(bn(z,"utf8"));if(typeof e.current!=="string"||!e.logins)return null;return{current:e.current,logins:e.logins}}catch{return null}}import{existsSync as se,readFileSync as ie,statSync as wn}from"node:fs";import{join as ue,resolve as ge}from"node:path";var W=new Map,Tn=new Set(Object.keys(process.env)),re=new Set;function m(e=process.cwd()){En(e);let n=k();return{dashboardUrl:process.env.BROODS_DASHBOARD_URL??n?.dashboardUrl,baseUrl:process.env.BROODS_BASE_URL??n?.baseUrl,token:n?.token,project:process.env.BROODS_PROJECT,stage:S()}}function M(){let e={};for(let[n,t]of Object.entries(process.env))if(typeof t==="string"&&!n.startsWith("BROODS_"))e[n]=t;return e}function C(e,n=process.cwd()){let t=process.env[e];if(t===void 0)return!1;let o=ge(n);for(let r of[".env.local",".env"]){let s=ue(o,r);if(!se(s))continue;let i=x(ie(s,"utf8"));if(i[e]!==void 0)return i[e]!==t}return!0}function En(e){let n=ge(e),t=process.env.BROODS_RELOAD_ENV==="1";for(let o of[".env",".env.local"]){let r=ue(n,o);if(!se(r)){W.delete(r);continue}let s=wn(r).mtimeMs,i=W.get(r);if(i&&i.mtimeMs===s)continue;W.set(r,{mtimeMs:s});for(let[a,c]of Object.entries(x(ie(r,"utf8"))))if(t||!Tn.has(a)||re.has(a))process.env[a]=c,re.add(a)}}function x(e){let n={};for(let t of e.split(/\r?\n/)){let o=t.trim();if(!o||o.startsWith("#"))continue;let r=o.startsWith("export ")?o.slice(7).trim():o,s=r.indexOf("=");if(s<=0)continue;let i=r.slice(0,s).trim();if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(i))continue;n[i]=Nn(r.slice(s+1).trim())}return n}function Nn(e){if(e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1).replace(/\\n/g,`
|
|
4
|
+
`).replace(/\\"/g,'"');if(e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1);let n=e.indexOf(" #");return n>=0?e.slice(0,n).trimEnd():e}var j=new TextEncoder,pe={name:"HMAC",hash:"SHA-256"};async function de(e,n,t,o){let r=le(j.encode(JSON.stringify(t))),s=await crypto.subtle.sign(pe,await On(n,o),j.encode(r));return`${e}${r}.${le(new Uint8Array(s))}`}function le(e){let n="";for(let t of e)n+=String.fromCharCode(t);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function On(e,n){let t=await crypto.subtle.digest("SHA-256",j.encode(`${e}${n}`));return crypto.subtle.importKey("raw",t,pe,!1,["sign","verify"])}var Dn="buat_",Z="bsig_",te="x-broods-user-token",he="broods.user.";var en=600000,V=3600000,Mn="broods-user-token:",nn=/^[A-Za-z0-9._@+=-]{1,128}$/,tn=100,_n=256,Un=60000;async function on(e,n,t=Date.now()){if(!n.startsWith(Z))throw Error(`The user token signing secret must start with ${Z}. It is not the bsk_ runtime key.`);let o=Pn(e,t);if(!o||e.expiresAt>t+V)throw Error(`Invalid user token: userId must match ${nn.source}, conversations must be at most ${tn} non-empty keys, and expiresAt must be in the next ${V/60000} minutes.`);return await de(Dn,Mn,o,n)}function Pn(e,n){if(!e||typeof e!=="object")return null;let{userId:t,conversations:o,expiresAt:r}=e;if(typeof t!=="string"||!nn.test(t)||typeof r!=="number"||!Number.isFinite(r)||r<=n||r>n+V+Un)return null;if(o===void 0)return{userId:t,expiresAt:r};if(!Array.isArray(o)||o.length>tn||!o.every((s)=>typeof s==="string"&&s.trim()===s&&s.length>0&&s.length<=_n))return null;return{userId:t,conversations:o,expiresAt:r}}var g="BROODS_USER_TOKEN_SECRET";async function be(e){let n=e.secret??process.env[g];if(!n)throw Error(`signUserToken needs the stage's signing secret: pass secret or set ${g}. \`broods dev\` and \`broods deploy\` write it to .env.local; the dashboard's Runtime key tab rotates it.`);return await on({userId:e.userId,...e.conversations?{conversations:e.conversations}:{},expiresAt:Date.now()+(e.ttlMs??en)},n)}var T="https://gateway.broods.app";class ce extends Error{accepted;constructor(e){super(`Ingress ${e.eventId} was accepted asynchronously with status ${e.status??"queued"}`);this.accepted=e;this.name="IngressAcceptedError"}}class N{baseUrl;apiKey;userToken;fetchImpl;constructor(e={}){m(),this.baseUrl=G(e.baseUrl||e.host||process.env.BROODS_BASE_URL||process.env.BROODS_HOST||T),this.apiKey=e.apiKey||process.env.BROODS_API_KEY||void 0,this.userToken=e.userToken,this.fetchImpl=e.fetch??fetch}channelWebhookUrl(e){return`${this.baseUrl}${e.webhookPath.startsWith("/")?"":"/"}${e.webhookPath}`}accountWebhookUrl(e,n){let t=[e,n].map(encodeURIComponent);return`${this.baseUrl}/v1/webhooks/${t.join("/")}`}stageWebhookUrl(e,n,t){let o=[e,"dev",n,t].map(encodeURIComponent);return`${this.baseUrl}/v1/webhooks/${o.join("/")}`}agent(e,n){if(typeof e==="string"){let o=e,r=n??"";if(!r)throw Error(`Agent ${o} is missing a generated id. Run broods dev --once or broods deploy to sync it first.`);return{id:r,run:(s)=>this.run({...s,agentName:o,agentId:r}),runAsync:(s)=>this.runAsync({...s,agentName:o,agentId:r}),continue:(s)=>this.continue({...s,agentId:r}),stream:(s)=>this.stream({...s,agentName:o,agentId:r})}}let t=e;if(!t.id)throw Error(`Agent ${t.name} is missing a generated id. Run broods dev --once or broods deploy to sync it first.`);return{id:t.id,run:(o)=>this.run(t,o),runAsync:(o)=>this.runAsync(t,o),continue:(o)=>this.continue(t,o),stream:(o)=>this.stream(t,o)}}async run(e,n){let t=[],o="",r=n?this.stream(e,n):this.stream(e);for await(let s of r)if(t.push(s),s.type==="text-delta")o+=s.text;return{text:o,events:t}}async*stream(e,n){let t=n?{...n,agentId:e.id,agentName:e.name}:e,o=rn(t,"cli"),r=n?this.scopedUrl(e):`${this.baseUrl}/v1/runs`,s=await this.openStream(o,r);if(!s.ok)throw Error(`Run failed: ${s.status} ${await s.text()}`);if(s.status===202)throw new ce(sn(await s.json(),o));if(!s.body)throw Error("Run response has no body");for await(let i of ae(s.body)){let a;try{a=JSON.parse(i)}catch{continue}if(a.type==="error")throw Error(`Agent run failed: ${Wn(a.error)}`);yield a}}async runAsync(e,n){let t=n?{...n,agentId:e.id,agentName:e.name}:e,o={...rn(t,"async"),background:!0},r=n?this.scopedUrl(e):`${this.baseUrl}/v1/runs`;return this.postAcceptedRun(r,o,"Async run")}async continue(e,n){let t=n?e:null,o=n??e,r={agentId:t?t.id:e.agentId,eventId:o.eventId??`continue-${crypto.randomUUID()}`,conversationKey:o.conversationKey,continue:!0},s=t?this.scopedUrl(t):`${this.baseUrl}/v1/runs`;return this.postAcceptedRun(s,r,"Continue")}async getAsyncStatus(e){let n=this.resolveStatusUrl(e),t=await this.fetchJson(n,{method:"GET",headers:await this.apiKeyHeaders()});if(t.status===404)return{status:"not_found"};if(!t.ok)throw Error(`Status check failed: ${t.status} ${await t.text()}`);return await t.json()}async waitForAsyncStatus(e,n={}){let t=Date.now()+(n.timeoutMs??180000),o=n.intervalMs??2000;while(Date.now()<t){if(n.signal?.aborted)throw Error("Async status polling aborted.");let r=await this.getAsyncStatus(e);if(r.status==="awaiting_approval"||r.status==="awaiting_input"||r.status==="completed"||r.status==="failed"||r.status==="expired"||r.status==="not_found")return r;await Ln(o,n.signal)}throw Error("Polling timeout")}scopedUrl(e){if(e.projectSlug&&e.stageSlug&&e.endpointId)return`${this.baseUrl}/v1/projects/${encodeURIComponent(e.projectSlug)}/stages/${encodeURIComponent(e.stageSlug)}/agents/${encodeURIComponent(e.endpointId)}`;return`${this.baseUrl}/v1/runs`}asyncAgentRun(e,n){return{...e,conversationKey:n,poll:()=>this.getAsyncStatus(e),wait:(t)=>this.waitForAsyncStatus(e,t)}}async postAcceptedRun(e,n,t){let o=await this.fetchJson(e,{method:"POST",headers:await this.apiKeyHeaders(),body:JSON.stringify(n)});if(o.status!==202)throw Error(`${t} failed: ${o.status} ${await Kn(o,"202 JSON")}`);return this.asyncAgentRun(sn(await o.json(),n),n.conversationKey)}async openStream(e,n){if(this.apiKey)return await this.fetchCore(e,n,{Authorization:`Bearer ${this.apiKey}`,...await this.userTokenHeaders()});throw Error(`BroodsClient streams directly from the core service at ${this.baseUrl}. Provide apiKey. For a self-hosted core service, set host/baseUrl or BROODS_HOST/BROODS_BASE_URL.`)}async fetchCore(e,n,t){try{return await this.fetchImpl(n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...t},body:JSON.stringify(e)})}catch(o){throw Error(`Cannot access the broods core service at ${n}. The SDK uses ${T} by default; set host/baseUrl or BROODS_HOST/BROODS_BASE_URL to your own core service URL if your account uses a custom deployment. Cause: ${o instanceof Error?o.message:String(o)}`)}}async apiKeyHeaders(){if(!this.apiKey)throw Error("BroodsClient requires apiKey or BROODS_API_KEY.");return{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`,...await this.userTokenHeaders()}}async userTokenHeaders(){let e=typeof this.userToken==="function"?await this.userToken():this.userToken;return e?{[te]:e}:{}}async fetchJson(e,n){try{return await this.fetchImpl(e,n)}catch(t){throw Error(`Cannot access the broods core service at ${e}. Cause: ${t instanceof Error?t.message:String(t)}`)}}resolveStatusUrl(e){if(typeof e!=="string")return e.statusUrl;if(/^https?:\/\//.test(e))return e;return $n(this.baseUrl,e)}}function G(e){let n=e.trim(),t=/^[A-Za-z][A-Za-z0-9+.-]*:\/\//.test(n)?n:`https://${n}`;return f(t)}function rn(e,n){let t=e.eventId??`${n}-${crypto.randomUUID()}`;return{agentId:e.agentId,eventId:t,conversationKey:e.conversationKey??t,events:q(e),...e.mode!==void 0?{mode:e.mode}:{},...e.idempotencyKey!==void 0?{idempotencyKey:e.idempotencyKey}:{},...e.system!==void 0?{system:e.system}:{},...e.model!==void 0?{model:e.model}:{}}}function Wn(e){if(typeof e==="string")return e;if(!e||typeof e!=="object")return String(e);let n=e,t=n.data?.error?.message??n.message??n.responseBody??JSON.stringify(e),o=n.name?`${n.name}: `:"",r=n.statusCode?` (HTTP ${n.statusCode})`:"";return`${o}${t}${r}`}function sn(e,n){if(!e||typeof e!=="object")throw Error("Async response must be an object");let t=e.statusUrl;if(typeof t!=="string"||t.length===0)throw Error("Async response missing statusUrl");let o=e.runId;if(typeof o!=="string"||o.length===0)throw Error("Async response missing runId");let r=typeof e.eventId==="string"?e.eventId:o,{status:s,requestedMode:i}=e;return{statusUrl:t,runId:o,eventId:r,agentId:n.agentId,...s==="accepted"||s==="queued"||s==="applied"||s==="processing"?{status:s}:{},...i==="reject"||i==="followup"||i==="collect"||i==="steer"?{requestedMode:i}:{}}}async function Kn(e,n){if((e.headers.get("content-type")??"").toLowerCase().includes("text/event-stream"))return await e.body?.cancel().catch(()=>{}),`expected ${n}, but the server returned an SSE stream. This usually means the core deployment ignored the background flag and ran the request on the direct streaming runner.`;let o=await e.text();if(o.length<=2000)return o;return`${o.slice(0,2000)}... [truncated ${o.length-2000} chars]`}function Ln(e,n){return new Promise((t,o)=>{if(n?.aborted){o(Error("Async status polling aborted."));return}let r=setTimeout(t,e);n?.addEventListener("abort",()=>{clearTimeout(r),o(Error("Async status polling aborted."))},{once:!0})})}function $n(e,n){return`${G(e)}/v1/runs/${encodeURIComponent(n)}`}var Bn=2000,an=0,w=1;class fe{baseUrl;apiKey;userToken;WebSocketImpl;connectTimeoutMs;constructor(e={}){if(m(),this.baseUrl=pn(e.baseUrl||e.host||process.env.BROODS_BASE_URL||process.env.BROODS_HOST||T),this.apiKey=e.apiKey||process.env.BROODS_API_KEY||"",!this.apiKey)throw Error("BroodsWebSocketClient requires apiKey or BROODS_API_KEY.");this.userToken=e.userToken,this.WebSocketImpl=e.WebSocket,this.connectTimeoutMs=e.connectTimeoutMs??Bn}subscribe(e,n={}){let t=this.resolveWebSocket(),o=this.buildUrl(e),r=Hn(e),s=ln(this.baseUrl),i=new t(o,E(this.apiKey,e.userToken??this.userToken)),a=!1,c=!1,d=setTimeout(()=>{if(!a)A(s)},this.connectTimeoutMs),R=(p=1000,_="client closed")=>{if(c)return;if(c=!0,clearTimeout(d),e.signal?.removeEventListener("abort",D),i.readyState===w||i.readyState===an)i.close(p,_)},A=(p)=>{n.onError?.(p),R(1000,"websocket error")},Cn=()=>{n.onDone?.(),R(1000,"done")},D=()=>{if(i.readyState===w)i.send(JSON.stringify({type:"cancel"}));A(Error("WebSocket run aborted."))};return e.signal?.addEventListener("abort",D,{once:!0}),i.onopen=()=>{if(a=!0,clearTimeout(d),e.signal?.aborted){D();return}i.send(JSON.stringify({type:"execute",agentId:r,...e.answers?{answers:e.answers}:{events:q(e)},sessionId:e.sessionId,...e.eventId!==void 0?{eventId:e.eventId}:{},...e.mode!==void 0?{mode:e.mode}:{},...e.idempotencyKey!==void 0?{idempotencyKey:e.idempotencyKey}:{},...e.system!==void 0?{system:e.system}:{},...e.model!==void 0?{model:e.model}:{}}))},i.onmessage=(p)=>{if(typeof p.data!=="string")return;let _=un(p.data);if(!_)return;let P=gn(_,n);switch(n.onMessage?.(P),P.type){case"meta":n.onMeta?.(P);break;case"done":Cn();break;case"error":A(Error(cn(P.error)));break}},i.onerror=()=>{A(s)},i.onclose=(p)=>{if(clearTimeout(d),e.signal?.removeEventListener("abort",D),c||p.code===1000)return;A(Error(p.reason||"WebSocket connection closed."))},{url:o,sendControl:function(p){if(i.readyState!==w)throw Error("WebSocket is not open");i.send(JSON.stringify({type:"control",...p}))},close:R}}attach(e,n={}){let t=this.resolveWebSocket(),o=this.buildUrl(e),r=new t(o,E(this.apiKey,e.userToken??this.userToken)),s=!1,i=(c=1000,d="client closed")=>{if(s)return;if(s=!0,e.signal?.removeEventListener("abort",a),r.readyState===w||r.readyState===an)r.close(c,d)},a=()=>{i(1000,"aborted"),n.onError?.(Error("WebSocket attach aborted."))};if(e.signal?.aborted)a();else e.signal?.addEventListener("abort",a,{once:!0});return r.onopen=()=>{if(s)return;r.send(JSON.stringify({type:"attach",...e,signal:void 0,agent:void 0,userToken:void 0}))},r.onmessage=(c)=>{if(s||typeof c.data!=="string")return;let d=un(c.data);if(!d)return;let R=gn(d,n);if(s)return;if(n.onMessage?.(R),s)return;if(R.type==="done")n.onDone?.();if(R.type==="error")n.onError?.(Error(cn(R.error)))},r.onerror=()=>{if(s)return;i(1000,"websocket error"),n.onError?.(ln(this.baseUrl))},r.onclose=(c)=>{if(e.signal?.removeEventListener("abort",a),!s&&c.code!==1000)n.onError?.(Error(c.reason||"WebSocket connection closed."))},{url:o,sendControl:function(c){if(r.readyState!==w)throw Error("WebSocket is not open");r.send(JSON.stringify({type:"control",...c}))},close:i}}async*stream(e){let n=[],t=!1,o=null,r=null,s=()=>{r?.(),r=null},i=this.subscribe(e,{onMessage:function(a){n.push(a),s()},onDone:function(){t=!0,s()},onError:function(a){o=a,s()}});try{while(!0){if(n.length>0){yield n.shift();continue}if(o)throw o;if(t)return;await new Promise((a)=>{r=a})}}finally{i.close()}}buildUrl(e){let n=Gn(e),t=e.projectSlug??e.agent?.projectSlug,o=e.stageSlug??e.agent?.stageSlug,r=t&&o?`/projects/${encodeURIComponent(t)}/stages/${encodeURIComponent(o)}`:"";return`${K(this.baseUrl)}/v1${r}/agents/${encodeURIComponent(n)}/ws`}resolveWebSocket(){let e=this.WebSocketImpl??globalThis.WebSocket;if(!e)throw Error("WebSocket is not available. Pass a WebSocket implementation in BroodsWebSocketClient options.");return e}}function K(e){let n=new URL(pn(e));if(n.protocol==="https:")n.protocol="wss:";if(n.protocol==="http:")n.protocol="ws:";return f(n.toString())}function E(e,n){return["broods.v1",`broods.token.${e}`,...n?[`${he}${n}`]:[]]}function cn(e){if(typeof e==="string")return e;if(e&&typeof e==="object"&&typeof e.message==="string")return e.message;return e===void 0?"WebSocket stream error.":JSON.stringify(e)}function pn(e){let n=e.trim();if(/^wss?:\/\//.test(n))return f(n);return G(n)}function un(e){try{let n=JSON.parse(e);return typeof n==="object"&&n!==null&&typeof n.type==="string"?n:null}catch{return null}}function Hn(e){let n=e.agentId??e.agent?.id??e.endpointId;if(!n)throw Error("WebSocket run requires agent, agentId, or endpointId.");return n}function Gn(e){let n=e.endpointId??e.agent?.endpointId??e.agent?.id;if(!n)throw Error("WebSocket run requires agent or endpointId.");return n}function gn(e,n){if(e.type!=="output")return e;let t=e;return n.onOutput?.(t),t.data}function ln(e){return Error(`Cannot access the WebSocket service at ${e}.`)}var fn=Symbol.for("broods.resource"),yn=Symbol.for("broods.config"),mn=Symbol.for("broods.connection"),dn=/^[A-Z][A-Z0-9_]{0,63}$/,ve=new Proxy((e)=>{if(!dn.test(e))throw Error("env name must match /^[A-Z][A-Z0-9_]*$/ and be at most 64 characters.");return{__beeblastEnv:!0,name:e}},{get:function(e,n,t){if(typeof n==="string"&&dn.test(n))throw Error(`env.${n} is not supported; use env("${n}")`);return Reflect.get(e,n,t)}});function _e(e){let{name:n,description:t,...o}=e;return I("agent",n,t,o)}function we(e){return{[yn]:!0,config:e}}function Re(e){let{name:n,description:t,...o}=e;return I("cron",n,t,o)}function $e(e){return e}function Ce(e){let{name:n,description:t,...o}=e;return I("mcp",n,t,o)}function Ee(e){let{name:n,description:t,...o}=e;return I("policy",n,t,o)}function ke(e){let{name:n,description:t,...o}=e;return I("sandbox",n,t,o)}function Te(e){let{name:n,description:t,...o}=e;return I("skill",n,t,o)}function Pe(e){let{name:n,description:t,...o}=e;return I("workspace",n,t,o)}function Ie(e){return l("discord",e)}function ze(e){return l("github",e)}function xe(e){return l("gchat",e)}function Ae(e){return l("instagram",e)}function Oe(e){return l("linear",e)}function Me(e){return l("messenger",e)}function Ne(e){return l("pancake",e)}function je(e){return l("slack",e)}function De(e){return l("teams",e)}function qe(e){return l("telegram",e)}function Le(e){return l("twilio",e)}function Ue(e){return l("whatsapp",e)}function Be(e){return l("zalo",e)}function Fe(e){let{name:n,description:t,channelId:o,guildId:r,...s}=e;return u(n,t,o,r,s)}function He(e){let{name:n,description:t,repo:o,...r}=e,[s,...i]=o.split("/");if(!s||i.length!==1||!i[0])throw Error(`Channel "${n}" repo must be "owner/name", not "${o}"`);return u(n,t,o,s,r)}function Ze(e){let{name:n,description:t,spaceName:o,...r}=e;return u(n,t,o,void 0,r)}function Ve(e){let{name:n,description:t,igsid:o,...r}=e;return u(n,t,o,void 0,r)}function Ge(e){let{name:n,description:t,team:o,...r}=e;return u(n,t,o,void 0,r)}function Ke(e){let{name:n,description:t,psid:o,...r}=e;return u(n,t,o,void 0,r)}function We(e){let{name:n,description:t,conversationId:o,...r}=e;return u(n,t,o,void 0,r)}function Je(e){let{name:n,description:t,channelId:o,teamId:r,...s}=e;return u(n,t,o,r,s)}function Ye(e){let{name:n,description:t,channelId:o,teamId:r,...s}=e;return u(n,t,o,r,s)}function Xe(e){let{name:n,description:t,chatId:o,...r}=e;return u(n,t,o,void 0,r)}function Qe(e){let{name:n,description:t,from:o,...r}=e;return u(n,t,o,void 0,r)}function et(e){let{name:n,description:t,waId:o,...r}=e;return u(n,t,o,void 0,r)}function tt(e){let{name:n,description:t,chatId:o,...r}=e;return u(n,t,o,void 0,r)}function ne(e){return Boolean(e&&typeof e==="object"&&e[yn])}function v(e){return Boolean(e&&typeof e==="object"&&e[mn])}function h(e){return Boolean(e&&typeof e==="object"&&e[fn])}function u(e,n,t,o,r){return I("channelRecord",e,n,{...r,externalId:t,...o?{workspaceRef:o}:{}})}function l(e,n){let{partition:t,...o}=n;return{[mn]:!0,kind:"connection",type:e,...t?{partition:t}:{},config:o}}function I(e,n,t,o){return{[fn]:!0,kind:e,name:n,...t?{description:t}:{},config:o}}
|
|
5
|
+
export{q,ae,L,me,ye,Se,U,B,y,b,z,k,F,H,S,f,O,m,M,C,x,Z,te,V,g,be,T,ce,N,G,fe,K,E,ve,_e,we,Re,$e,Ce,Ee,ke,Te,Pe,Ie,ze,xe,Ae,Oe,Me,Ne,je,De,qe,Le,Ue,Be,Fe,He,Ze,Ve,Ge,Ke,We,Je,Ye,Xe,Qe,et,tt,ne,v,h};
|