broods 0.30.0 → 0.32.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 +41 -9
- package/dist/account.js +1 -1
- package/dist/chunk-0ng9002j.js +1 -0
- package/dist/{chunk-rx5qcgbh.js → chunk-7qxgm62s.js} +1 -1
- package/dist/{chunk-2tqw3gxy.js → chunk-bkv7avcd.js} +1 -1
- package/dist/{chunk-zk2w6bee.js → chunk-ejgnb5z6.js} +2 -2
- package/dist/chunk-h9meaxpn.js +5 -0
- package/dist/{chunk-e66afphr.js → chunk-ss48287m.js} +2 -2
- package/dist/{chunk-yy11cxjg.js → chunk-zk74tvhq.js} +1 -1
- package/dist/cli/index.js +152 -66
- package/dist/index.d.ts +72 -12
- package/dist/index.js +1 -1
- package/package.json +4 -4
- package/dist/chunk-3qpgf0c1.js +0 -5
- package/dist/chunk-736tg90p.js +0 -1
package/dist/account.d.ts
CHANGED
|
@@ -101,6 +101,20 @@ declare const MODEL_PROVIDERS: {
|
|
|
101
101
|
};
|
|
102
102
|
type AccountModelProviderName = keyof typeof MODEL_PROVIDERS;
|
|
103
103
|
|
|
104
|
+
/**
|
|
105
|
+
* OAuth 2.0 refresh-token grant for an external row. Core mints access tokens
|
|
106
|
+
* at connect time and sends `Authorization: Bearer <token>`, so a server
|
|
107
|
+
* whose tokens expire (Google's Workspace MCP endpoints) still works where a
|
|
108
|
+
* static header cannot. Secret fields hold ${NAME} refs on the row.
|
|
109
|
+
*/
|
|
110
|
+
interface McpOauth {
|
|
111
|
+
clientId: string;
|
|
112
|
+
clientSecret: string;
|
|
113
|
+
refreshToken: string;
|
|
114
|
+
/** Token endpoint, https only; core defaults to https://oauth2.googleapis.com/token. */
|
|
115
|
+
tokenUrl?: string;
|
|
116
|
+
}
|
|
117
|
+
|
|
104
118
|
/**
|
|
105
119
|
* Agent configuration: types for the per-agent settings object, input
|
|
106
120
|
* normalization, encryption helpers, patch-merge, and redaction.
|
|
@@ -193,6 +207,11 @@ interface AgentSubagentConfig {
|
|
|
193
207
|
interface AgentModelConfig extends LanguageModelCallOptions, Pick<RequestOptions, "maxRetries" | "timeout"> {
|
|
194
208
|
provider?: AccountModelProviderName;
|
|
195
209
|
modelId?: string;
|
|
210
|
+
/**
|
|
211
|
+
* Speech-to-text model for inbound audio, on the same provider and key as
|
|
212
|
+
* `modelId`. Defaults to the widest-container model the provider ships.
|
|
213
|
+
*/
|
|
214
|
+
transcriptionModelId?: string;
|
|
196
215
|
providerOptions?: AgentModelProviderOptions;
|
|
197
216
|
output?: AgentModelOutputConfig;
|
|
198
217
|
}
|
|
@@ -294,6 +313,12 @@ interface AgentMcpEntry {
|
|
|
294
313
|
needsApproval?: boolean;
|
|
295
314
|
/** Extra request headers; values resolved from account env vars at sync. */
|
|
296
315
|
headers?: Record<string, string>;
|
|
316
|
+
/**
|
|
317
|
+
* Overrides for the row's oauth credentials; values resolved from account
|
|
318
|
+
* env vars at sync, so the row's ${NAME} refs never reach the token
|
|
319
|
+
* endpoint. tokenUrl stays on the row, where registration checked it.
|
|
320
|
+
*/
|
|
321
|
+
oauth?: Partial<Omit<McpOauth, "tokenUrl">>;
|
|
297
322
|
[key: string]: unknown;
|
|
298
323
|
}
|
|
299
324
|
interface AgentChannelsConfig {
|
|
@@ -496,14 +521,6 @@ interface SandboxConfig {
|
|
|
496
521
|
options?: Record<string, unknown>;
|
|
497
522
|
}
|
|
498
523
|
|
|
499
|
-
/**
|
|
500
|
-
* Workspace-config validation for the Convex config plane. Ports core's
|
|
501
|
-
* former storage/workspace-config.ts normalizer so the public /v1/workspaces
|
|
502
|
-
* contract is unchanged. Workspace config holds no secrets (a roleArn is not
|
|
503
|
-
* a secret), so it is stored and returned in plaintext. Pure module — safe
|
|
504
|
-
* for the default Convex runtime. The public projection lives in
|
|
505
|
-
* ./responses.ts.
|
|
506
|
-
*/
|
|
507
524
|
declare const WORKSPACE_STORAGE_PROVIDERS: readonly ["s3"];
|
|
508
525
|
type WorkspaceStorageProvider = (typeof WORKSPACE_STORAGE_PROVIDERS)[number];
|
|
509
526
|
type WorkspaceStorageAuth = {
|
|
@@ -844,6 +861,18 @@ interface StageScope {
|
|
|
844
861
|
project: string;
|
|
845
862
|
stage: string;
|
|
846
863
|
}
|
|
864
|
+
/**
|
|
865
|
+
* OAuth 2.0 refresh-token grant on an external MCP row. The runtime mints and
|
|
866
|
+
* refreshes access tokens and sends `Authorization: Bearer <token>` itself.
|
|
867
|
+
* `clientSecret` and `refreshToken` must be `${NAME}` account env refs;
|
|
868
|
+
* `tokenUrl` defaults to https://oauth2.googleapis.com/token.
|
|
869
|
+
*/
|
|
870
|
+
interface McpOauthInput {
|
|
871
|
+
clientId: string;
|
|
872
|
+
clientSecret: string;
|
|
873
|
+
refreshToken: string;
|
|
874
|
+
tokenUrl?: string;
|
|
875
|
+
}
|
|
847
876
|
/** Public MCP server registration returned by the `/v1/mcp` routes (#331). */
|
|
848
877
|
interface AccountMcp {
|
|
849
878
|
accountId: string;
|
|
@@ -858,6 +887,7 @@ interface AccountMcp {
|
|
|
858
887
|
/** Hosted servers only: content hash of the uploaded bundle. */
|
|
859
888
|
sha256?: string;
|
|
860
889
|
headers?: Record<string, string>;
|
|
890
|
+
oauth?: McpOauthInput;
|
|
861
891
|
allowedTools?: string[];
|
|
862
892
|
disabled: boolean;
|
|
863
893
|
status: string;
|
|
@@ -877,6 +907,7 @@ interface CreateMcpInput {
|
|
|
877
907
|
bundleStorageId?: string;
|
|
878
908
|
sha256?: string;
|
|
879
909
|
headers?: Record<string, string>;
|
|
910
|
+
oauth?: McpOauthInput;
|
|
880
911
|
allowedTools?: string[];
|
|
881
912
|
}
|
|
882
913
|
/** Fields accepted by `PATCH /v1/mcp/{serverId}`; every field is optional. */
|
|
@@ -888,6 +919,7 @@ interface UpdateMcpInput {
|
|
|
888
919
|
bundleStorageId?: string;
|
|
889
920
|
sha256?: string;
|
|
890
921
|
headers?: Record<string, string>;
|
|
922
|
+
oauth?: McpOauthInput;
|
|
891
923
|
allowedTools?: string[];
|
|
892
924
|
disabled?: boolean;
|
|
893
925
|
}
|
|
@@ -1142,4 +1174,4 @@ declare class BroodsAccountClient {
|
|
|
1142
1174
|
}
|
|
1143
1175
|
|
|
1144
1176
|
export { BroodsAccountApiError, BroodsAccountClient, envPlaceholder, resolveEnvCredential };
|
|
1145
|
-
export type { AccountAgent, AccountChannel, AccountEnvVar, AccountMcp, AccountPolicy, AccountRole, AccountSandbox, AccountWorkspace, AssumeRoleResult, BroodsAccount, BroodsAccountClientOptions, ChannelRecordConfig, CreateAgentResult, CreateMcpInput, DeleteAccountResult, RotateSecretResult, SandboxLifecycleResult, SandboxSnapshotResult, SandboxTerminalTicket, SkillUploadInput, StageScope, UpdateAgentInput, UpdateMcpInput, WorkspaceFileEntry };
|
|
1177
|
+
export type { AccountAgent, AccountChannel, AccountEnvVar, AccountMcp, AccountPolicy, AccountRole, AccountSandbox, AccountWorkspace, AssumeRoleResult, BroodsAccount, BroodsAccountClientOptions, ChannelRecordConfig, CreateAgentResult, CreateMcpInput, DeleteAccountResult, McpOauthInput, RotateSecretResult, SandboxLifecycleResult, SandboxSnapshotResult, SandboxTerminalTicket, SkillUploadInput, StageScope, UpdateAgentInput, UpdateMcpInput, WorkspaceFileEntry };
|
package/dist/account.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{X as a,Y as b,Z as c,_ as d}from"./chunk-zk74tvhq.js";import"./chunk-7qxgm62s.js";export{b as BroodsAccountApiError,d as BroodsAccountClient,a as envPlaceholder,c as resolveEnvCredential};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{aa as _,ba as q,ca as C,da as P,ea as j,fa as k,ga as D,ha as p,ia as v,ja as z,ka as A,la as M,ma as J,na as L,oa as U,pa as x,qa as O,ra as g,sa as F,ta as X,ua as H,va as Q}from"./chunk-ejgnb5z6.js";import"./chunk-ss48287m.js";import"./chunk-7qxgm62s.js";var re=class{_readBuffer;_started=!1;_closed=!1;constructor(r=O.stdin,o=O.stdout,a){this._stdin=r,this._stdout=o,this._readBuffer=new U({maxBufferSize:a?.maxBufferSize})}onclose;onerror;onmessage;_ondata=(r)=>{try{this._readBuffer.append(r),this.processReadBuffer()}catch(o){this.onerror?.(o),this.close().catch(()=>{})}};_onerror=(r)=>{this.onerror?.(r)};_onstdouterror=(r)=>{this.onerror?.(r),this.close().catch(()=>{})};async start(){if(this._started)throw Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror),this._stdout.on("error",this._onstdouterror)}processReadBuffer(){while(!0)try{let r=this._readBuffer.readMessage();if(r===null)break;this.onmessage?.(r)}catch(r){this.onerror?.(r)}}async close(){if(this._closed)return;if(this._closed=!0,this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdout.off("error",this._onstdouterror),this._stdin.listenerCount("data")===0)this._stdin.pause();this._readBuffer.clear(),this.onclose?.()}send(r){if(this._closed)return Promise.reject(Error("StdioServerTransport is closed"));return new Promise((o,a)=>{let d=x(r),t=!1,u=(w)=>{if(t)return;t=!0,this._stdout.off("error",u),this._stdout.off("drain",h),a(w)},h=()=>{if(t)return;t=!0,this._stdout.off("error",u),this._stdout.off("drain",h),o()};if(this._stdout.once("error",u),this._stdout.write(d)){if(t)return;t=!0,this._stdout.off("error",u),o()}else if(!t)this._stdout.once("drain",h)})}},W=3000,te=class{onclose;onerror;onmessage;_closed=!1;_pendingRequests=new Set;_drainWaiters=[];constructor(r,o,a){this._wire=r,this._onInstanceClose=o,this._outboundIntercept=a}async start(){}async send(r,o){if(z(r)||A(r)){let{id:a}=r;if(a!==void 0)this._settle(a)}if(this._closed)return;if(this._outboundIntercept?.(r)==="handled")return;return this._wire.send(r,o)}setProtocolVersion=(r)=>{this._wire.setProtocolVersion?.(r)};deliver(r,o){if(this._closed)return;if(p(r))this._pendingRequests.add(r.id);else if(v(r)&&r.method==="notifications/cancelled"){let a=r.params?.requestId;if(a!==void 0)this._settle(a)}this.onmessage?.(r,o)}async whenRequestsAnswered(r){if(this._closed||this._pendingRequests.size===0)return!0;return await new Promise((o)=>{let a=()=>{clearTimeout(d),o(!0)},d=setTimeout(()=>{this._drainWaiters=this._drainWaiters.filter((t)=>t!==a),o(!1)},r);this._drainWaiters.push(a)})}async close(){if(this._closed)return;this._closed=!0,this._pendingRequests.clear(),this._releaseDrainWaiters();try{this._onInstanceClose()}finally{this.onclose?.()}}_settle(r){if(this._pendingRequests.delete(r),this._pendingRequests.size===0)this._releaseDrainWaiters()}_releaseDrainWaiters(){let r=this._drainWaiters;this._drainWaiters=[];for(let o of r)o()}};function ne(r){let o=r.params;if(r.method==="initialize"&&!M(o)){let u=o!==null&&typeof o==="object"&&typeof o.protocolVersion==="string"?o.protocolVersion:void 0;return{kind:"legacy",reason:"initialize",...u!==void 0&&{requestedVersion:u}}}if(!j(o))return{kind:"legacy",reason:"no-claim"};let a=P(o),d=(a===void 0?[]:D(a))[0];if(d!==void 0)return{kind:"invalid-envelope",issue:d};let t=k(o);if(t===void 0||!_.includes(t))return{kind:"unsupported-revision",requested:t??"unknown"};return{kind:"modern",revision:t,classification:{era:"modern",revision:t}}}function ae(r,o={}){let a=o.legacy??"serve",d=o.transport??new re,t={phase:"opening"},u,h=!1,w=()=>h||t.phase==="closed",c=(e)=>{try{o.onerror?.(e)}catch{}},R=(e,n,i,s)=>d.send({jsonrpc:"2.0",id:e,error:{code:n,message:i,...s!==void 0&&{data:s}}}).catch((l)=>c(f(l))),y=new F(o.maxSubscriptions??g),Y=(e)=>{if(!v(e))return;let n=y.routeOutbound(e);if(n==="passthrough")return;for(let i of n)d.send({jsonrpc:"2.0",...i}).catch((s)=>c(f(s)));return"handled"},V=async(e)=>{if(p(e)&&e.method==="subscriptions/listen"){let n=P(e.params),i=j(e.params)?(n===void 0?[]:D(n))[0]:{key:"_meta",problem:"the per-request envelope is required on protocol revision 2026-07-28"},s=k(e.params),l;if(i!==void 0)l={jsonrpc:"2.0",id:e.id,error:{code:-32602,message:`Invalid _meta envelope: ${i.key}: ${i.problem}`}};else if(s===void 0||!_.includes(s)){let m=new C({supported:[..._],requested:s??"unknown"});l={jsonrpc:"2.0",id:e.id,error:{code:m.code,message:m.message,data:m.data}}}else l=y.serve(e);return await d.send("error"in l?l:{jsonrpc:"2.0",method:l.method,params:l.params}).catch((m)=>c(f(m))),!0}if(v(e)&&e.method==="notifications/cancelled"){let n=e.params?.requestId;if(n!==void 0&&y.cancel(n))return!0}return!1},T=(e,n,i)=>{let s=J({kind:"legacy",reason:n,...i!==void 0&&{requestedVersion:i}},_);if(s===void 0)return Promise.resolve();return c(Error(`Rejected 2025-era request on a modern-only stdio connection (${s.cell}): ${s.message}`)),R(e.id,s.code,s.message,s.data)},G=(e)=>{if(h||e===u)return;B()},S=async(e,n)=>{let i=await r({era:e}),s=i instanceof Q?i.server:i;if(e==="modern")L(s,n),X(s,_),y.setServerCapabilities(s.getCapabilities(),H(s));let l=new te(d,()=>G(l),e==="modern"?Y:void 0);return await i.connect(l),{product:i,channel:l}},E=(e)=>e.product.close().catch((n)=>c(f(n))),K=async(e)=>{u=e.channel;try{if(!await e.channel.whenRequestsAnswered(W))c(Error(`Discarded the probe instance with requests still unanswered after ${W}ms; continuing with the fallback`));await e.product.close()}catch(n){c(f(n))}finally{u=void 0}},Z=async(e)=>{if(t.phase==="closed")return;if(t.phase==="pinned"){if(t.era==="modern"&&p(e)&&e.method==="initialize"&&!M(e.params)){await T(e,"initialize",e.params!==null&&typeof e.params==="object"&&typeof e.params.protocolVersion==="string"?e.params.protocolVersion:void 0);return}if(t.era==="modern"&&await V(e))return;t.instance.channel.deliver(e);return}if(!p(e)&&!v(e)){c(Error("Discarded a JSON-RPC response received before the connection negotiated an era"));return}let n=ne(e);switch(n.kind){case"invalid-envelope":{let i=`Invalid _meta envelope for protocol revision 2026-07-28: ${n.issue.key}: ${n.issue.problem}`;if(p(e))await R(e.id,q.InvalidParams,i,{envelope:n.issue});else c(Error(`Discarded a notification with a malformed envelope: ${i}`));return}case"unsupported-revision":if(p(e)){let i=new C({supported:[..._],requested:n.requested});c(i),await R(e.id,i.code,i.message,i.data)}else c(Error(`Discarded a notification claiming unsupported protocol revision ${n.requested}`));return;case"modern":if(p(e)&&e.method==="server/discover"){if(t.phase==="probe"){t.instance.channel.deliver(e,{classification:n.classification});return}let i=await S("modern",n.revision);if(w()){await E(i);return}t={phase:"probe",instance:i},i.channel.deliver(e,{classification:n.classification});return}if(t.phase==="probe"){if(v(e)){t.instance.channel.deliver(e,{classification:n.classification});return}t={phase:"pinned",era:"modern",instance:t.instance}}else{let i=await S("modern",n.revision);if(w()){await E(i);return}t={phase:"pinned",era:"modern",instance:i}}if(await V(e))return;t.instance.channel.deliver(e,{classification:n.classification});return;case"legacy":{if(a==="reject"){if(p(e))await T(e,n.reason,n.requestedVersion);return}if(t.phase==="probe"){if(await K(t.instance),w())return;t={phase:"opening"}}let i=await S("legacy");if(w()){await E(i);return}t={phase:"pinned",era:"legacy",instance:i},t.instance.channel.deliver(e);return}}},I=[],b=!1,ee=async()=>{if(b)return;b=!0;try{while(I.length>0){let e=I.shift();try{await Z(e)}catch(n){if(p(e))await R(e.id,q.InternalError,"Internal server error");c(f(n))}}}finally{b=!1}},B=async()=>{if(h||t.phase==="closed")return;h=!0;let e=t;t={phase:"closed"};for(let n of y.teardownAll())await d.send(n).catch((i)=>c(f(i)));if(e.phase==="probe"||e.phase==="pinned")await e.instance.product.close().catch((n)=>c(f(n)));await d.close().catch((n)=>c(f(n)))};d.onmessage=(e)=>{I.push(e),ee()},d.onerror=(e)=>{if(c(e),t.phase==="probe"||t.phase==="pinned")t.instance.channel.onerror?.(e)},d.onclose=()=>{if(h||t.phase==="closed")return;h=!0;let e=t;if(t={phase:"closed"},e.phase==="probe"||e.phase==="pinned")e.instance.product.close().catch((n)=>c(f(n)))};let N=d.start().catch((e)=>{throw c(f(e)),e});return N.catch(()=>{}),{close:async()=>{await N.catch(()=>{}),await B()}}}function f(r){return r instanceof Error?r:Error(String(r))}export{re as StdioServerTransport,ae as serveStdio};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{createRequire as g}from"node:module";var d=Object.defineProperty;var e=(a)=>a;function f(a,b){this[a]=e.bind(null,b)}var h=(a,b)=>{for(var c in b)d(a,c,{get:b[c],enumerable:!0,configurable:!0,set:f.bind(b,c)})};var j=g(import.meta.url);
|
|
2
|
-
export{h as
|
|
2
|
+
export{h as Te,j as Ue};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{T as R,U as E}from"./chunk-yy11cxjg.js";import{V as o,pa as g}from"./chunk-zk2w6bee.js";import"./chunk-e66afphr.js";import"./chunk-rx5qcgbh.js";var y={project:o.string().optional(),stage:o.string().optional()},I={sandboxId:o.string().min(1),reservationKey:o.string().min(1)},h=o.boolean().describe("Must be true, after the owner has agreed to this delete."),S="'********' keeps a stored secret and null deletes a field: never send a placeholder you did not read from a get.",C=[{singular:"agent",plural:"agents",key:"agentId",createHint:"Needs name and config; a 409 returns the existing agentId.",deleteHint:"Deleting an agent also drops its runtime rows.",updateHint:S,list:(e)=>e.listAgents(),get:(e,t)=>e.getAgent(t),create:(e,t)=>e.createAgent(t),update:(e,t,s)=>e.updateAgent(t,s),remove:(e,t)=>e.deleteAgent(t)},{singular:"cron",plural:"crons",key:"cronId",createHint:"Needs name, agentId, scheduleExpression (rate/cron/at) and input or events.",list:(e)=>e.listCrons(),get:(e,t)=>e.getCron(t),create:(e,t)=>e.createCron(t),update:(e,t,s)=>e.updateCron(t,s),remove:(e,t)=>e.deleteCron(t)},{singular:"sandbox",plural:"sandboxes",key:"sandboxId",updateHint:S,list:(e)=>e.listSandboxes(),get:(e,t)=>e.getSandbox(t),create:(e,t)=>e.createSandbox(t),update:(e,t,s)=>e.updateSandbox(t,s),remove:(e,t)=>e.deleteSandbox(t)},{singular:"workspace",plural:"workspaces",key:"workspaceId",list:(e)=>e.listWorkspaces(),get:(e,t)=>e.getWorkspace(t),create:(e,t)=>e.createWorkspace(t),update:(e,t,s)=>e.updateWorkspace(t,s),remove:(e,t)=>e.deleteWorkspace(t)},{singular:"policy",plural:"policies",key:"policyId",createHint:"Agent-runtime policy document (tool.call, skill.load), not API credential scoping.",list:(e)=>e.listPolicies(),get:(e,t)=>e.getPolicy(t),create:(e,t)=>e.createPolicy(t),update:(e,t,s)=>e.updatePolicy(t,s),remove:(e,t)=>e.deletePolicy(t)},{singular:"role",plural:"roles",key:"roleId",createHint:"Needs name and a version-1 policy over the API namespace, e.g. agents:read. Account secret only.",list:(e)=>e.listRoles(),get:(e,t)=>e.getRole(t),create:(e,t)=>e.createRole(t),update:(e,t,s)=>e.updateRole(t,s),remove:(e,t)=>e.deleteRole(t)},{singular:"channel",plural:"channels",key:"channelId",list:(e)=>e.listChannels(),get:(e,t)=>e.getChannel(t),create:(e,t)=>e.createChannel(t),update:(e,t,s)=>e.updateChannel(t,s),remove:(e,t)=>e.deleteChannel(t)},{singular:"skill",plural:"skills",key:"skillName",createHint:'source is "files" (base64), "json" or "github". The stored name comes from the SKILL.md frontmatter.',list:(e)=>e.listSkills(),get:(e,t)=>e.getSkill(t),create:(e,t)=>e.createSkill(t),remove:(e,t)=>e.deleteSkill(t)},{singular:"mcp",plural:"mcp",key:"serverId",scoped:!0,list:(e,t)=>e.listMcp(t),get:(e,t)=>e.getMcp(t),create:(e,t,s)=>e.createMcp(s,t),update:(e,t,s)=>e.updateMcp(t,s),remove:(e,t)=>e.deleteMcp(t)}];function Mt(e={}){let t=R()?new E({}):null;if(!t&&!e.cli)throw Error("broods mcp needs a credential: set BROODS_SESSION_TOKEN or BROODS_ACCOUNT_SECRET, or run `broods login`.");let s=new g({name:"broods",version:"1"},{capabilities:{tools:{}}});if(t){for(let r of C)k(s,t,r,e.scope??{});P(s,t)}if(e.cli)O(s,e.cli);if(e.allowDestructive)q(s,t,e.cli??null);return s}function M(e){return{content:[{type:"text",text:JSON.stringify(e??null,null,2)}]}}function A(e){return{content:[{type:"text",text:e instanceof Error?e.message:String(e)}],isError:!0}}function f(e,t){if(!e)throw Error(`Refusing without confirm:true. ${t}`)}async function a(e){try{return M(await e())}catch(t){return A(t)}}function _(e,t,s,r){if(!e.scoped)return;let n=s??t.project,c=r??t.stage;if(!n||!c)throw Error(`${e.plural} live in one stage, so this call needs both 'project' and 'stage'`);return{project:n,stage:c}}function k(e,t,s,r){let n=o.string().min(1).describe(`The ${s.key}.`),c=s.scoped?` ${s.plural} live in one stage, so this also takes 'project' and 'stage'.`:"",{list:d,get:p,create:m,update:v,remove:w}=s;if(d){let i=`List every ${s.singular} on the account.${c}`;if(s.scoped)e.registerTool(`list-${s.plural}`,{description:i,inputSchema:y},async({project:l,stage:u})=>await a(async()=>await d(t,_(s,r,l,u))));else e.registerTool(`list-${s.plural}`,{description:i,inputSchema:{}},async()=>await a(async()=>await d(t)))}if(p)e.registerTool(`get-${s.singular}`,{description:`Read one ${s.singular} by ${s.key}.`,inputSchema:{id:n}},async({id:i})=>await a(async()=>await p(t,i)));if(m){let i=`Create one ${s.singular}. 'body' is the request body the config plane documents.`+(s.createHint?` ${s.createHint}`:"")+c+" Prefer changing the broods/ manifest and deploying for anything the project already declares.",l=o.record(o.string(),o.unknown());if(s.scoped)e.registerTool(`create-${s.singular}`,{description:i,inputSchema:{body:l,...y}},async({body:u,project:b,stage:T})=>await a(async()=>await m(t,u,_(s,r,b,T))));else e.registerTool(`create-${s.singular}`,{description:i,inputSchema:{body:l}},async({body:u})=>await a(async()=>await m(t,u)))}if(v)e.registerTool(`update-${s.singular}`,{description:`Deep-merge a patch into one ${s.singular} and return the updated record, so there is no need to read it back.`+(s.updateHint?` ${s.updateHint}`:""),inputSchema:{id:n,body:o.record(o.string(),o.unknown())}},async({id:i,body:l})=>await a(async()=>await v(t,i,l)));if(w)e.registerTool(`delete-${s.singular}`,{description:`Delete one ${s.singular}. Requires confirm:true, and takes one ${s.key} per call: never loop this over a list.`+(s.deleteHint?` ${s.deleteHint}`:""),inputSchema:{id:n,confirm:h}},async({id:i,confirm:l})=>await a(async()=>(f(l,`Deleting ${s.singular} '${i}' goes away for good: name it, get the owner's agreement, then retry.`),{deleted:await w(t,i),id:i})))}function P(e,t){e.registerTool("list-cron-runs",{description:"Run history for one cron, newest first. Check this before telling anyone a cron fired.",inputSchema:{cronId:o.string().min(1),limit:o.number().int().positive().max(100).optional()}},async({cronId:r,limit:n})=>await a(async()=>await t.listCronRuns(r,n===void 0?{}:{limit:n})));let s=[["suspend-sandbox","Suspend a persistent sandbox reservation.",(r,n)=>t.suspendSandbox(r,n)],["resume-sandbox","Resume a suspended sandbox reservation.",(r,n)=>t.resumeSandbox(r,n)],["terminate-sandbox","Terminate a sandbox reservation and drop its live-instance row. Terminate only a sandbox you created, and never one holding state you did not put there.",(r,n)=>t.terminateSandbox(r,n)],["open-sandbox-terminal","Mint a short-lived sealed ticket for an interactive PTY session on a persistent sandbox.",(r,n)=>t.openSandboxTerminal(r,n)]];for(let[r,n,c]of s)e.registerTool(r,{description:n,inputSchema:I},async({sandboxId:d,reservationKey:p})=>await a(async()=>await c(d,p)));e.registerTool("snapshot-sandbox",{description:"Snapshot a sandbox reservation into a reusable image (self-hosted provider).",inputSchema:{sandboxId:o.string().min(1),reservationKey:o.string().min(1),name:o.string().min(1)}},async({sandboxId:r,reservationKey:n,name:c})=>await a(async()=>await t.snapshotSandbox(r,n,c))),e.registerTool("upload-skill",{description:"Replace one skill's bundle wholesale (PUT, not a merge) by skillName. 'body' is the same source shape create-skill takes.",inputSchema:{id:o.string().min(1).describe("The skillName."),body:o.record(o.string(),o.unknown())}},async({id:r,body:n})=>await a(async()=>await t.uploadSkill(r,n))),e.registerTool("list-env-vars",{description:"List environment variable names. Values are write-only: the plane never returns them, so there is no read.",inputSchema:{}},async()=>await a(async()=>await t.listEnvVars())),e.registerTool("set-env-var",{description:"Create or replace one write-only environment variable. Reference it from a config as ${NAME} rather than inlining the value.",inputSchema:{name:o.string().min(1),value:o.string()}},async({name:r,value:n})=>await a(async()=>(await t.setEnvVar(r,n),{name:r,stored:!0}))),e.registerTool("delete-env-var",{description:"Delete one environment variable.",inputSchema:{name:o.string().min(1),confirm:h}},async({name:r,confirm:n})=>await a(async()=>(f(n,`Anything referencing \${${r}} breaks the moment this env var goes.`),{deleted:await t.deleteEnvVar(r),name:r}))),e.registerTool("assume-role",{description:"Exchange a role for a short-lived session token (default 1h, max 12h). Hand the returned token to whatever tool needs narrow access, as BROODS_SESSION_TOKEN. It is shown once and is not stored here.",inputSchema:{roleId:o.string().min(1),ttlSeconds:o.number().int().positive().max(43200).optional()}},async({roleId:r,ttlSeconds:n})=>await a(async()=>await t.assumeRole(r,n===void 0?{}:{ttlSeconds:n}))),e.registerTool("update-account",{description:"Rename this account or change its description. Everything else about an account is derived, not settable.",inputSchema:{username:o.string().optional(),description:o.string().nullable().optional()}},async({username:r,description:n})=>await a(async()=>await t.updateAccount({...r===void 0?{}:{username:r},...n===void 0?{}:{description:n}}))),e.registerTool("get-account",{description:"The account this server's credential resolves to. Run it first to confirm which tenant you are about to change.",inputSchema:{}},async()=>await a(async()=>await t.getAccount()))}function O(e,t){e.registerTool("list-orgs",{description:"Every organization this login can reach, with the current one marked.",inputSchema:{}},async()=>await a(async()=>{let s=await t.getOnboarding();return{currentOrgId:s.currentOrgId,orgs:s.orgs}})),e.registerTool("create-org",{description:"Create an organization and switch this login to it. Later calls act in the new org.",inputSchema:{name:o.string().min(1)}},async({name:s})=>await a(async()=>await t.createOnboardingOrg(s))),e.registerTool("select-org",{description:"Switch this login to another organization, by an orgId from list-orgs.",inputSchema:{orgId:o.string().min(1)}},async({orgId:s})=>await a(async()=>await t.selectOnboardingOrg(s))),e.registerTool("list-projects",{description:"Every project in the current org, empty ones last. Project names are not unique, so take the id from here.",inputSchema:{}},async()=>await a(async()=>await t.listProjects())),e.registerTool("list-stages",{description:"Every stage of one project, by project name.",inputSchema:{project:o.string().min(1)}},async({project:s})=>await a(async()=>await t.listStages(s))),e.registerTool("create-stage",{description:"Create a stage in a project, optionally cloning another stage's architecture and env vars. A project name that does not exist yet is created with it, which is the only way to make a project without deploying a manifest.",inputSchema:{project:o.string().min(1),name:o.string().min(1),from:o.string().optional().describe("Stage to clone architecture and env vars from.")}},async({project:s,name:r,from:n})=>await a(async()=>await t.createStage(s,r,n)))}function q(e,t,s){if(t)e.registerTool("rotate-secret",{description:"Rotate the account secret. The current secret stops working immediately and the new one is shown once, so this breaks every deployment and CI job still holding the old one. Requires confirm:true.",inputSchema:{confirm:h}},async({confirm:r})=>await a(async()=>(f(r,"Everything holding the current secret breaks the moment this runs."),await t.rotateSecret())));if(s)e.registerTool("delete-project",{description:"Delete a project and everything under it: stages, agents, canvas, env vars, crons and workspace files. Takes a projectId from list-projects and requires confirm:true.",inputSchema:{projectId:o.string().min(1),confirm:h}},async({projectId:r,confirm:n})=>await a(async()=>(f(n,`Project '${r}' and everything under it goes away: name it, get the owner's agreement, then retry.`),await s.deleteProject(r))))}export{Mt as createBroodsMcpServer};
|
|
1
|
+
import{Z as R,_ as E}from"./chunk-zk74tvhq.js";import{$ as o,va as g}from"./chunk-ejgnb5z6.js";import"./chunk-ss48287m.js";import"./chunk-7qxgm62s.js";var y={project:o.string().optional(),stage:o.string().optional()},I={sandboxId:o.string().min(1),reservationKey:o.string().min(1)},h=o.boolean().describe("Must be true, after the owner has agreed to this delete."),S="'********' keeps a stored secret and null deletes a field: never send a placeholder you did not read from a get.",C=[{singular:"agent",plural:"agents",key:"agentId",createHint:"Needs name and config; a 409 returns the existing agentId.",deleteHint:"Deleting an agent also drops its runtime rows.",updateHint:S,list:(e)=>e.listAgents(),get:(e,t)=>e.getAgent(t),create:(e,t)=>e.createAgent(t),update:(e,t,s)=>e.updateAgent(t,s),remove:(e,t)=>e.deleteAgent(t)},{singular:"cron",plural:"crons",key:"cronId",createHint:"Needs name, agentId, scheduleExpression (rate/cron/at) and input or events.",list:(e)=>e.listCrons(),get:(e,t)=>e.getCron(t),create:(e,t)=>e.createCron(t),update:(e,t,s)=>e.updateCron(t,s),remove:(e,t)=>e.deleteCron(t)},{singular:"sandbox",plural:"sandboxes",key:"sandboxId",updateHint:S,list:(e)=>e.listSandboxes(),get:(e,t)=>e.getSandbox(t),create:(e,t)=>e.createSandbox(t),update:(e,t,s)=>e.updateSandbox(t,s),remove:(e,t)=>e.deleteSandbox(t)},{singular:"workspace",plural:"workspaces",key:"workspaceId",list:(e)=>e.listWorkspaces(),get:(e,t)=>e.getWorkspace(t),create:(e,t)=>e.createWorkspace(t),update:(e,t,s)=>e.updateWorkspace(t,s),remove:(e,t)=>e.deleteWorkspace(t)},{singular:"policy",plural:"policies",key:"policyId",createHint:"Agent-runtime policy document (tool.call, skill.load), not API credential scoping.",list:(e)=>e.listPolicies(),get:(e,t)=>e.getPolicy(t),create:(e,t)=>e.createPolicy(t),update:(e,t,s)=>e.updatePolicy(t,s),remove:(e,t)=>e.deletePolicy(t)},{singular:"role",plural:"roles",key:"roleId",createHint:"Needs name and a version-1 policy over the API namespace, e.g. agents:read. Account secret only.",list:(e)=>e.listRoles(),get:(e,t)=>e.getRole(t),create:(e,t)=>e.createRole(t),update:(e,t,s)=>e.updateRole(t,s),remove:(e,t)=>e.deleteRole(t)},{singular:"channel",plural:"channels",key:"channelId",list:(e)=>e.listChannels(),get:(e,t)=>e.getChannel(t),create:(e,t)=>e.createChannel(t),update:(e,t,s)=>e.updateChannel(t,s),remove:(e,t)=>e.deleteChannel(t)},{singular:"skill",plural:"skills",key:"skillName",createHint:'source is "files" (base64), "json" or "github". The stored name comes from the SKILL.md frontmatter.',list:(e)=>e.listSkills(),get:(e,t)=>e.getSkill(t),create:(e,t)=>e.createSkill(t),remove:(e,t)=>e.deleteSkill(t)},{singular:"mcp",plural:"mcp",key:"serverId",scoped:!0,list:(e,t)=>e.listMcp(t),get:(e,t)=>e.getMcp(t),create:(e,t,s)=>e.createMcp(s,t),update:(e,t,s)=>e.updateMcp(t,s),remove:(e,t)=>e.deleteMcp(t)}];function Mt(e={}){let t=R()?new E({}):null;if(!t&&!e.cli)throw Error("broods mcp needs a credential: set BROODS_SESSION_TOKEN or BROODS_ACCOUNT_SECRET, or run `broods login`.");let s=new g({name:"broods",version:"1"},{capabilities:{tools:{}}});if(t){for(let r of C)k(s,t,r,e.scope??{});P(s,t)}if(e.cli)O(s,e.cli);if(e.allowDestructive)q(s,t,e.cli??null);return s}function M(e){return{content:[{type:"text",text:JSON.stringify(e??null,null,2)}]}}function A(e){return{content:[{type:"text",text:e instanceof Error?e.message:String(e)}],isError:!0}}function f(e,t){if(!e)throw Error(`Refusing without confirm:true. ${t}`)}async function a(e){try{return M(await e())}catch(t){return A(t)}}function _(e,t,s,r){if(!e.scoped)return;let n=s??t.project,c=r??t.stage;if(!n||!c)throw Error(`${e.plural} live in one stage, so this call needs both 'project' and 'stage'`);return{project:n,stage:c}}function k(e,t,s,r){let n=o.string().min(1).describe(`The ${s.key}.`),c=s.scoped?` ${s.plural} live in one stage, so this also takes 'project' and 'stage'.`:"",{list:d,get:p,create:m,update:v,remove:w}=s;if(d){let i=`List every ${s.singular} on the account.${c}`;if(s.scoped)e.registerTool(`list-${s.plural}`,{description:i,inputSchema:y},async({project:l,stage:u})=>await a(async()=>await d(t,_(s,r,l,u))));else e.registerTool(`list-${s.plural}`,{description:i,inputSchema:{}},async()=>await a(async()=>await d(t)))}if(p)e.registerTool(`get-${s.singular}`,{description:`Read one ${s.singular} by ${s.key}.`,inputSchema:{id:n}},async({id:i})=>await a(async()=>await p(t,i)));if(m){let i=`Create one ${s.singular}. 'body' is the request body the config plane documents.`+(s.createHint?` ${s.createHint}`:"")+c+" Prefer changing the broods/ manifest and deploying for anything the project already declares.",l=o.record(o.string(),o.unknown());if(s.scoped)e.registerTool(`create-${s.singular}`,{description:i,inputSchema:{body:l,...y}},async({body:u,project:b,stage:T})=>await a(async()=>await m(t,u,_(s,r,b,T))));else e.registerTool(`create-${s.singular}`,{description:i,inputSchema:{body:l}},async({body:u})=>await a(async()=>await m(t,u)))}if(v)e.registerTool(`update-${s.singular}`,{description:`Deep-merge a patch into one ${s.singular} and return the updated record, so there is no need to read it back.`+(s.updateHint?` ${s.updateHint}`:""),inputSchema:{id:n,body:o.record(o.string(),o.unknown())}},async({id:i,body:l})=>await a(async()=>await v(t,i,l)));if(w)e.registerTool(`delete-${s.singular}`,{description:`Delete one ${s.singular}. Requires confirm:true, and takes one ${s.key} per call: never loop this over a list.`+(s.deleteHint?` ${s.deleteHint}`:""),inputSchema:{id:n,confirm:h}},async({id:i,confirm:l})=>await a(async()=>(f(l,`Deleting ${s.singular} '${i}' goes away for good: name it, get the owner's agreement, then retry.`),{deleted:await w(t,i),id:i})))}function P(e,t){e.registerTool("list-cron-runs",{description:"Run history for one cron, newest first. Check this before telling anyone a cron fired.",inputSchema:{cronId:o.string().min(1),limit:o.number().int().positive().max(100).optional()}},async({cronId:r,limit:n})=>await a(async()=>await t.listCronRuns(r,n===void 0?{}:{limit:n})));let s=[["suspend-sandbox","Suspend a persistent sandbox reservation.",(r,n)=>t.suspendSandbox(r,n)],["resume-sandbox","Resume a suspended sandbox reservation.",(r,n)=>t.resumeSandbox(r,n)],["terminate-sandbox","Terminate a sandbox reservation and drop its live-instance row. Terminate only a sandbox you created, and never one holding state you did not put there.",(r,n)=>t.terminateSandbox(r,n)],["open-sandbox-terminal","Mint a short-lived sealed ticket for an interactive PTY session on a persistent sandbox.",(r,n)=>t.openSandboxTerminal(r,n)]];for(let[r,n,c]of s)e.registerTool(r,{description:n,inputSchema:I},async({sandboxId:d,reservationKey:p})=>await a(async()=>await c(d,p)));e.registerTool("snapshot-sandbox",{description:"Snapshot a sandbox reservation into a reusable image (self-hosted provider).",inputSchema:{sandboxId:o.string().min(1),reservationKey:o.string().min(1),name:o.string().min(1)}},async({sandboxId:r,reservationKey:n,name:c})=>await a(async()=>await t.snapshotSandbox(r,n,c))),e.registerTool("upload-skill",{description:"Replace one skill's bundle wholesale (PUT, not a merge) by skillName. 'body' is the same source shape create-skill takes.",inputSchema:{id:o.string().min(1).describe("The skillName."),body:o.record(o.string(),o.unknown())}},async({id:r,body:n})=>await a(async()=>await t.uploadSkill(r,n))),e.registerTool("list-env-vars",{description:"List environment variable names. Values are write-only: the plane never returns them, so there is no read.",inputSchema:{}},async()=>await a(async()=>await t.listEnvVars())),e.registerTool("set-env-var",{description:"Create or replace one write-only environment variable. Reference it from a config as ${NAME} rather than inlining the value.",inputSchema:{name:o.string().min(1),value:o.string()}},async({name:r,value:n})=>await a(async()=>(await t.setEnvVar(r,n),{name:r,stored:!0}))),e.registerTool("delete-env-var",{description:"Delete one environment variable.",inputSchema:{name:o.string().min(1),confirm:h}},async({name:r,confirm:n})=>await a(async()=>(f(n,`Anything referencing \${${r}} breaks the moment this env var goes.`),{deleted:await t.deleteEnvVar(r),name:r}))),e.registerTool("assume-role",{description:"Exchange a role for a short-lived session token (default 1h, max 12h). Hand the returned token to whatever tool needs narrow access, as BROODS_SESSION_TOKEN. It is shown once and is not stored here.",inputSchema:{roleId:o.string().min(1),ttlSeconds:o.number().int().positive().max(43200).optional()}},async({roleId:r,ttlSeconds:n})=>await a(async()=>await t.assumeRole(r,n===void 0?{}:{ttlSeconds:n}))),e.registerTool("update-account",{description:"Rename this account or change its description. Everything else about an account is derived, not settable.",inputSchema:{username:o.string().optional(),description:o.string().nullable().optional()}},async({username:r,description:n})=>await a(async()=>await t.updateAccount({...r===void 0?{}:{username:r},...n===void 0?{}:{description:n}}))),e.registerTool("get-account",{description:"The account this server's credential resolves to. Run it first to confirm which tenant you are about to change.",inputSchema:{}},async()=>await a(async()=>await t.getAccount()))}function O(e,t){e.registerTool("list-orgs",{description:"Every organization this login can reach, with the current one marked.",inputSchema:{}},async()=>await a(async()=>{let s=await t.getOnboarding();return{currentOrgId:s.currentOrgId,orgs:s.orgs}})),e.registerTool("create-org",{description:"Create an organization and switch this login to it. Later calls act in the new org.",inputSchema:{name:o.string().min(1)}},async({name:s})=>await a(async()=>await t.createOnboardingOrg(s))),e.registerTool("select-org",{description:"Switch this login to another organization, by an orgId from list-orgs.",inputSchema:{orgId:o.string().min(1)}},async({orgId:s})=>await a(async()=>await t.selectOnboardingOrg(s))),e.registerTool("list-projects",{description:"Every project in the current org, empty ones last. Project names are not unique, so take the id from here.",inputSchema:{}},async()=>await a(async()=>await t.listProjects())),e.registerTool("list-stages",{description:"Every stage of one project, by project name.",inputSchema:{project:o.string().min(1)}},async({project:s})=>await a(async()=>await t.listStages(s))),e.registerTool("create-stage",{description:"Create a stage in a project, optionally cloning another stage's architecture and env vars. A project name that does not exist yet is created with it, which is the only way to make a project without deploying a manifest.",inputSchema:{project:o.string().min(1),name:o.string().min(1),from:o.string().optional().describe("Stage to clone architecture and env vars from.")}},async({project:s,name:r,from:n})=>await a(async()=>await t.createStage(s,r,n)))}function q(e,t,s){if(t)e.registerTool("rotate-secret",{description:"Rotate the account secret. The current secret stops working immediately and the new one is shown once, so this breaks every deployment and CI job still holding the old one. Requires confirm:true.",inputSchema:{confirm:h}},async({confirm:r})=>await a(async()=>(f(r,"Everything holding the current secret breaks the moment this runs."),await t.rotateSecret())));if(s)e.registerTool("delete-project",{description:"Delete a project and everything under it: stages, agents, canvas, env vars, crons and workspace files. Takes a projectId from list-projects and requires confirm:true.",inputSchema:{projectId:o.string().min(1),confirm:h}},async({projectId:r,confirm:n})=>await a(async()=>(f(n,`Project '${r}' and everything under it goes away: name it, get the owner's agreement, then retry.`),await s.deleteProject(r))))}export{Mt as createBroodsMcpServer};
|