broods 0.38.1 → 0.39.1

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 CHANGED
@@ -117,7 +117,7 @@ declare const AGENT_LIFECYCLE_EVENT_NAMES: readonly ["agent.started", "agent.ste
117
117
  * Shared validation for MCP server registrations (#331). One normalizer
118
118
  * serves every write path (CLI sync, direct API, dashboard). A `url` makes an "http" row
119
119
  * core connects to over the stateless 2026-07-28 transport; a `bundle` makes
120
- * a "hosted" row served by the tool-runner Lambda, hashed here so sha256
120
+ * a "hosted" row served by the mcp-runner Lambda, hashed here so sha256
121
121
  * always travels with the bundle. Auth header values may carry ${NAME}
122
122
  * account env refs; they resolve into the encrypted agent config at sync
123
123
  * time, never on this row, and credential-bearing headers must use one
@@ -172,6 +172,7 @@ interface AgentConfig {
172
172
  /** Policies that gate this agent. Each one carries its own enforcement mode. */
173
173
  policies?: string[];
174
174
  publicAccess?: boolean;
175
+ allowRunOverrides?: boolean;
175
176
  [key: string]: unknown;
176
177
  }
177
178
  interface AgentBehaviorConfig {
package/dist/cli/index.js CHANGED
@@ -25,7 +25,7 @@ export const defineZaloChannel = passthrough;
25
25
  export const defineZaloConnection = passthrough;
26
26
  export const env = (name) => ({ __beeblastEnv: true, name });
27
27
  export default {};
28
- `,xe=1e7,An=50000000,Gn=1e7,xn=20000000,jn=200,Ht=new Set(["node_modules",".git"]),zt=[/^\.env(?:\.|$)/i,/^id_(?:rsa|dsa|ecdsa|ed25519)(?:\.pub)?$/i,/\.(?:pem|key|p12|pfx)$/i],ze={onStart:"agent.started",onStepFinish:"agent.step.finished",onToolCall:"tool.call.started",onToolResult:"tool.result",onFinish:"agent.finished",onApproval:"agent.approval.required",onError:"agent.failed",onSubagentFinish:"subagent.task.finished",onMessageReceived:"channel.message.received",onMessageSending:"channel.message.sending"};async function ee(e={}){let n=e.cwd??process.cwd();h(n);let t=Ae(n,S),o=await Vt(t),r=await Jt(o),s=await Zt(r,n,e.project),i=r.filter((m)=>g(m.value)).map((m)=>({exportName:m.exportName,file:m.file,resource:m.value})),a=i.map((m)=>m.resource);Dn(a),co(a);let c=uo(i,r),d=fo(a);for(let m of a)Qt(m);for(let m of a)eo(m);for(let m of a)no(m);to(a),ro(a),go(i,d);let l=lo(i),u=Yt(s,e.stage??(e.useRuntimeStage===!1?void 0:_()),e.command??"dev"),p=(await Promise.all(i.map((m)=>po(m,t,d)))).flat().sort((m,y)=>`${m.kind}:${m.name}`.localeCompare(`${y.kind}:${y.name}`));return Dn(p),{config:s,resources:a,resourceAliases:l,channels:c,manifest:{version:1,project:s.project,stage:u,resources:p}}}function Wn(e){let n=new Set;for(let t of e.resources)Ye(t.config,n);return[...n].sort()}function Ye(e,n){if(Array.isArray(e)){for(let t of e)Ye(t,n);return}if(e&&typeof e==="object"){let t=e;if(t.__beeblastEnv===!0&&typeof t.name==="string"){n.add(t.name);return}for(let o of Object.values(t))Ye(o,n)}}function Yt(e,n,t){if(n)return n;let o=e.stages?.[t];if(o)return o;return t==="deploy"?"production":"development"}async function Vt(e){let n=[];async function t(o){let r=await Nn(o,{withFileTypes:!0});for(let s of r){let i=Q(o,s.name);if(s.isDirectory()){if(s.name===v||s.name==="generated")continue;await t(i)}else if(s.isFile()&&s.name.endsWith(".ts"))n.push(i)}}return await t(e),n.sort((o,r)=>ge(e,o).localeCompare(ge(e,r)))}async function Jt(e){qt();let n=[];for(let t of e){let r=await import(`${Un(t).href}?t=${Date.now()}`);n.push(...Object.entries(r).map(([s,i])=>({exportName:s,file:t,value:i})))}return n}var Pn=!1;function qt(){if(Pn)return;if(Pn=!0,typeof Cn.registerHooks!=="function")return;Cn.registerHooks({load:(e,n,t)=>{let[o]=e.split("?");if(o===void 0||!o.startsWith("file:")||!o.endsWith(".ts"))return t(e,n);let r=Lt(o);return{format:"module",shortCircuit:!0,source:Kn(Bt(r,"utf8"),{loader:"ts",format:"esm",sourcefile:r,sourcemap:"inline"}).code}}})}async function Zt(e,n,t){let r=e.find((i)=>ne(i.value))?.value?.config??{},s=t??process.env.BROODS_PROJECT??r.project??Ko(Kt(Ae(n)));if(!s.trim())throw Error("Project name is required. Pass --project <name> or set BROODS_PROJECT.");return{...r,project:s}}var In=new Set(["agent","harness","model","provider","session","hooks","connections","tools","mcp","denyTools","sandboxes","workspaces","subagent","skills","scheduler","policies","publicAccess"]),Xt={workspace:"workspaces",skill:"skills",policy:"policies",tool:"tools",mcpServers:"mcp",channel:"connections",channels:"connections",hook:"hooks",subagents:"subagent",systemPrompt:"agent",system:"agent"};function Qt(e){if(e.kind!=="agent")return;let n=e.config;for(let t of Object.keys(n)){if(In.has(t))continue;if(t==="sandbox")throw Error(`Agent "${e.name}" config.sandbox was removed; use sandboxes, the first is the default`);let o=Xt[t],r=o?` Did you mean "${o}"?`:` Allowed keys: ${[...In].sort().join(", ")}.`;throw Error(`Agent "${e.name}" has an unknown config key "${t}".${r}`)}}function eo(e){if(e.kind!=="workspace")return;let t=e.config.storage;if(t===void 0)return;if(!t||typeof t!=="object"||Array.isArray(t))throw Error(`Workspace "${e.name}" config.storage must be an object`);let o=t.provider;if(o===void 0||o==="s3")return;if(o==="vercel")throw Error(`Workspace "${e.name}" uses storage.provider "vercel", but Vercel Drive workspace storage is not supported yet. Use storage.provider "s3" or omit storage until Vercel Drive is wired.`);throw Error(`Workspace "${e.name}" config.storage.provider must be one of: s3`)}function no(e){if(e.kind!=="workspace")return;let n=e.config;if(typeof n.partitioned==="string")throw Error(`Workspace "${e.name}" config.partitioned must be a boolean; string modes are not supported.`);if(n.isolation!==void 0)throw Error(`Workspace "${e.name}" config.isolation is no longer supported; use partitioned: true.`)}function to(e){let n=new Map(e.filter((t)=>t.kind==="workspace").map((t)=>[t.name,t]));for(let t of e){if(t.kind!=="agent")continue;let o=t.config,r=o.connections;if(r!==void 0&&!Array.isArray(r))throw Error(`Agent "${t.name}" config.connections must be an array of connection definitions`);let s=Array.isArray(r)?r.filter(w):[],i=new Set;for(let l of s){let u=l.config,p=typeof u.id==="string"?u.id:void 0;if(p){if(i.has(p))throw Error(`Duplicate channel id: ${p}`);i.add(p)}if(l.partition)Fn(l.partition,`Agent "${t.name}" connection "${l.type}"`);if(l.config&&typeof l.config==="object"&&(("workspaceIsolationScope"in l.config)||("workspaceScope"in l.config)))throw Error(`Agent "${t.name}" connection "${l.type}" uses workspaceScope, which is no longer supported; use partition.`)}let c=(Array.isArray(o.workspaces)?o.workspaces.map((l)=>oo(l,n)).filter((l)=>Boolean(l)):[]).filter((l)=>l.config.partitioned===!0),d=s.filter((l)=>l.partition);if(d.length>0&&c.length===0){let l=d[0];throw Error(`Agent "${t.name}" connection "${l.type}" defines partition, but no attached workspace has partitioned: true.`)}if(c.length>0){for(let l of s)if(!l.partition)throw Error(`Agent "${t.name}" attaches partitioned workspace "${c[0].name}", but connection "${l.type}" does not define partition.`)}}}function Fn(e,n){if(!e)return;if(e.by==="shared"){if("alias"in e&&e.alias!==void 0)throw Error(`${n} partition.alias is only supported when partition.by is conversation`);return}if(e.by!=="conversation")throw Error(`${n} partition.by must be one of: shared, conversation`);if(typeof e.alias!=="string"||e.alias.length===0)throw Error(`${n} partition.alias is required when partition.by is conversation`);if(!/^[A-Za-z0-9._-]+$/.test(e.alias))throw Error(`${n} partition.alias must use only letters, numbers, dots, underscores, or hyphens`);if(e.alias==="."||e.alias==="..")throw Error(`${n} partition.alias must not be "." or ".."`)}function oo(e,n){if(g(e)&&e.kind==="workspace")return e;if(typeof e==="string")return n.get(e);if(e&&typeof e==="object"&&"workspace"in e){let t=e.workspace;if(g(t)&&t.kind==="workspace")return t;if(typeof t==="string")return n.get(t)}return}function ro(e){let n=new Map(e.filter((t)=>t.kind==="sandbox").map((t)=>[t.name,t]));for(let t of e){if(t.kind!=="agent")continue;let o=t.config,r=Hn(Array.isArray(o.sandboxes)?o.sandboxes[0]:void 0,n),s=o.workspaces;if(!Array.isArray(s))continue;for(let i of s){let a=io(i),c=so(i,r,n);if(!c||ao(c))continue;throw Error(`Agent "${t.name}" workspace "${a}" uses sandbox "${c.name}" (${zn(c)}) which does not support S3 workspace mounts. Use lambda/sandbox, or daytona with options.mountAwsS3Buckets: true, or set this workspace ref to sandbox: null for read-only S3 access.`)}}}function Hn(e,n){if(g(e)&&e.kind==="sandbox")return e;if(typeof e==="string")return n.get(e);return}function so(e,n,t){if(e&&typeof e==="object"&&"sandbox"in e){let o=e.sandbox;if(o===null)return;return Hn(o,t)}return n}function io(e){if(g(e)&&e.kind==="workspace")return e.name;if(e&&typeof e==="object"&&"workspace"in e){let n=e.workspace;if(g(n))return n.name;if(typeof n==="string")return n}return"<unknown>"}function ao(e){let n=zn(e);if(n==="lambda"||n==="sandbox")return!0;if(n!=="daytona")return!1;let t=e.config.options;return Boolean(t&&typeof t==="object"&&!Array.isArray(t)&&t.mountAwsS3Buckets===!0)}function zn(e){return typeof e.config.provider==="string"?e.config.provider:"sandbox"}function co(e){let n=new Set(e.filter((t)=>t.kind==="sandbox").map((t)=>t.name));for(let t of e){if(t.kind!=="agent")continue;let o=t.config.sandboxes;if(o===void 0)continue;if(!Array.isArray(o))throw Error(`Agent "${t.name}" sandboxes must be an array of sandbox resources or names`);let r=o;for(let[s,i]of r.entries()){let a=typeof i==="string"&&i.trim().length>0,c=g(i)&&i.kind==="sandbox";if(!a&&!c)throw Error(`Agent "${t.name}" sandboxes[${s}] must be a sandbox resource or a non-empty name`);if(c&&!n.has(i.name))throw Error(`Agent "${t.name}" sandboxes references sandbox "${i.name}", but that sandbox is not exported from broods/`)}}}function Dn(e){let n=new Set;for(let t of e){let o=`${t.kind}:${t.name}`;if(n.has(o))throw Error(`Duplicate resource: ${o}`);n.add(o)}}function lo(e){let n={},t=new Set;for(let{exportName:o,resource:r}of e){if(o==="default"||!Ve(o))continue;let s=`${r.kind}:${o}`;if(t.has(s))throw Error(`Duplicate export alias for ${r.kind}: ${o}`);t.add(s),n[r.kind]??={},n[r.kind][r.name]=o}return n}function uo(e,n){let t=new Map;for(let i of n){if(!w(i.value)||i.exportName==="default"||!Ve(i.exportName))continue;let a=t.get(i.value);if(a&&a!==i.exportName)throw Error(`Channel is exported more than once: ${a}, ${i.exportName}`);t.set(i.value,i.exportName)}let o=new Map,r=new Set,s=[];for(let{exportName:i,resource:a}of e){if(a.kind!=="agent")continue;let c=a.config.connections;if(c===void 0)continue;if(!Array.isArray(c))throw Error(`Agent "${a.name}" config.connections must be an array of connection definitions`);let d=new Set;for(let l of c){if(!w(l))throw Error(`Agent "${a.name}" config.connections must contain connection definitions`);let u=o.get(l);if(u&&u!==a.name)throw Error(`Channel ${l.type} is already attached to agent "${u}" and cannot also attach to "${a.name}"`);if(d.has(l.type))throw Error(`Agent "${a.name}" cannot configure more than one ${l.type} channel`);o.set(l,a.name),d.add(l.type);let p=i!=="default"&&Ve(i)?i:a.name,m=t.get(l)??`${p}${Vn(l.type)}Channel`;if(r.has(m))throw Error(`Duplicate channel export alias: ${m}`);r.add(m),s.push({alias:m,type:l.type,id:m,agentName:a.name})}}for(let[i,a]of t)if(!o.has(i))throw Error(`Channel "${a}" must be attached to exactly one agent`);return s.sort((i,a)=>i.alias.localeCompare(a.alias))}function go(e,n){for(let{resource:t}of e){if(t.kind!=="agent")continue;let o=t.config.connections;if(!Array.isArray(o))continue;for(let r of o){if(!w(r))continue;if(Yn(r,n).length>0)continue;throw Error(`Agent "${t.name}" connection "${r.type}" reaches no rooms: declare a ${r.type} channel for it, or set allowedChannelIds: ["*"] to answer everywhere`)}}}function Yn(e,n){let t=e.config.allowedChannelIds??[];if(t.includes(we))return[we];return[...new Set([...n.get(e)??[],...t])]}function fo(e){let n=new Map;for(let t of e){if(t.kind!=="channelRecord")continue;let o=t.config;if(!w(o.connection))continue;let r=Jn(t.name,o.externalId);if(r.length===0)continue;let s=n.get(o.connection)??new Set;for(let i of r)s.add(i);n.set(o.connection,s)}return n}function Vn(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Ve(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)}async function po(e,n,t){let o=e.resource;if(o.kind==="agent"){let r=$o(o,n,t);return[...r.hookResource?[r.hookResource]:[],{kind:o.kind,name:o.name,...o.description?{description:o.description}:{},config:r.config}]}if(o.kind==="channelRecord"){let r=o.config,s=Jn(o.name,r.externalId);return s.map((i)=>({kind:o.kind,name:s.length===1?o.name:`${o.name}-${i}`,...o.description?{description:o.description}:{},config:Uo(o.name,{...r,externalId:i})}))}return[{kind:o.kind,name:o.name,...o.description?{description:o.description}:{},config:await mo(e,n)}]}function Jn(e,n){if(n===void 0)return[];if(typeof n==="string")return _n(e,n),[n];if(!Array.isArray(n))throw Error(`Channel "${e}" externalId must be a string or an array`);if(n.length===0)throw Error(`Channel "${e}" externalId must not be an empty array`);let t=new Set;for(let o of n){if(typeof o!=="string"||o.length===0)throw Error(`Channel "${e}" externalId must be an array of non-empty strings`);if(t.has(o))throw Error(`Channel "${e}" externalId lists ${o} twice`);_n(e,o),t.add(o)}return n}function _n(e,n){if(n!==we)return;throw Error(`Channel "${e}" cannot use "${we}" as its id: a record matches one exact room. To answer everywhere, set allowedChannelIds: ["${we}"] on the connection; undeclared rooms already fall back to its agent.`)}async function mo(e,n){let t=e.resource;if(t.kind==="skill")return await jo(t.config,n);if(t.kind==="workspace"){let o={...t.config};if(o.partitioned!==void 0){if(typeof o.partitioned!=="boolean")throw Error(`Workspace "${t.name}" config.partitioned must be a boolean`);let r=o.partitioned;if(delete o.partitioned,r)o.isolation=!0}return M(o)}if(t.kind==="mcp")return await Po(e,t.config,n);if(t.kind==="policy"){let o={...t.config};return o.version=o.version??1,M(o)}if(t.kind==="cron"){let o={...t.config},r=o.agent;if(o.agentId=g(r)?r.name:r,o.name=o.name??t.name,delete o.agent,typeof o.input==="string")o.events=[{role:"user",content:[{type:"text",text:o.input}]}],delete o.input;return M(o)}return M(t.config)}var ho=new Set(["apiKey","base_url","baseURL"]),bo=new Set(["activeTools","debug","inactiveTools","permissionMode","startupTimeoutMs","type","webSearch"]),wo=new Set(["enabled","level","subsystems"]);function yo(e){if(ho.has(e))return"";let n=e.replace(/[^a-z0-9]/gi,"").toLowerCase();if(n==="baseurl")return'"base_url" or "baseURL"';if(n==="apikey")return'"apiKey"';return""}function vo(e,n){if(n===void 0||n===null)return;if(typeof n!=="object"||Array.isArray(n))throw Error(`Agent "${e}" config.provider must be an object`);for(let[t,o]of Object.entries(n)){if(!Rn(t))throw Error(`Agent "${e}" config.provider.${t} is not a supported provider (expected one of: ${On.join(", ")})`);if(typeof o!=="object"||o===null||Array.isArray(o))throw Error(`Agent "${e}" config.provider.${t} must be an object`);let r=o;for(let s of Object.keys(r)){let i=yo(s);if(i)throw Error(`Agent "${e}" config.provider.${t} has unknown option "${s}". Did you mean ${i}?`)}if(t==="custom"&&r.base_url===void 0&&r.baseURL===void 0)throw Error(`Agent "${e}" config.provider.custom.base_url is required (use "base_url" or "baseURL")`)}}function ko(e,n){if(n===void 0||n===null)return;if(typeof n!=="object"||Array.isArray(n))throw Error(`Agent "${e}" config.harness must be an object`);let t=n;if("sandbox"in t)throw Error(`Agent "${e}" harness sandbox was removed; list it first in the agent's sandboxes`);for(let o of Object.keys(t))if(!bo.has(o))throw Error(`Agent "${e}" config.harness has unknown option "${o}"`);if(t.type!=="claude-code"&&t.type!=="codex"&&t.type!=="deepagents"&&t.type!=="opencode"&&t.type!=="pi")throw Error(`Agent "${e}" config.harness.type must be claude-code, codex, deepagents, opencode, or pi`);if(t.permissionMode!==void 0&&t.permissionMode!=="allow-reads"&&t.permissionMode!=="allow-edits"&&t.permissionMode!=="allow-all")throw Error(`Agent "${e}" config.harness.permissionMode must be allow-reads, allow-edits, or allow-all`);if(t.type==="codex"&&t.permissionMode!==void 0&&t.permissionMode!=="allow-all")throw Error(`Agent "${e}" config.harness.permissionMode must be allow-all for codex`);if(t.startupTimeoutMs!==void 0&&(typeof t.startupTimeoutMs!=="number"||!Number.isSafeInteger(t.startupTimeoutMs)||t.startupTimeoutMs<1||t.startupTimeoutMs>600000))throw Error(`Agent "${e}" config.harness.startupTimeoutMs must be an integer from 1 to 600000`);if(t.webSearch!==void 0&&typeof t.webSearch!=="boolean")throw Error(`Agent "${e}" config.harness.webSearch must be a boolean`);if(t.type!=="codex"&&t.webSearch!==void 0)throw Error(`Agent "${e}" config.harness.webSearch is only supported by codex`);if(t.type==="pi"&&t.startupTimeoutMs!==void 0)throw Error(`Agent "${e}" config.harness.startupTimeoutMs is not supported by pi`);if(Je(e,t.activeTools,"activeTools"),Je(e,t.inactiveTools,"inactiveTools"),t.activeTools!==void 0&&t.inactiveTools!==void 0)throw Error(`Agent "${e}" config.harness must use either activeTools or inactiveTools, not both`);So(e,t.debug)}function So(e,n){if(n===void 0)return;if(typeof n!=="object"||n===null||Array.isArray(n))throw Error(`Agent "${e}" config.harness.debug must be an object`);let t=n;for(let o of Object.keys(t))if(!wo.has(o))throw Error(`Agent "${e}" config.harness.debug has unknown option "${o}"`);if(t.enabled!==void 0&&typeof t.enabled!=="boolean")throw Error(`Agent "${e}" config.harness.debug.enabled must be a boolean`);if(t.level!==void 0&&t.level!=="error"&&t.level!=="warn"&&t.level!=="info"&&t.level!=="debug"&&t.level!=="trace")throw Error(`Agent "${e}" config.harness.debug.level must be error, warn, info, debug, or trace`);Je(e,t.subsystems,"debug.subsystems")}function Je(e,n,t){if(n!==void 0&&(!Array.isArray(n)||!n.every((o)=>typeof o==="string"&&o.trim().length>0)))throw Error(`Agent "${e}" config.harness.${t} must be an array of non-empty strings`)}function $o(e,n,t){let o={...e.config};vo(e.name,o.provider),ko(e.name,o.harness);let r=Array.isArray(o.sandboxes)?o.sandboxes.map((i)=>g(i)?i.name:i):void 0;if(r)o.sandboxes=r;r?.forEach((i,a)=>{if(r.indexOf(i)===a)return;throw Error(`Agent "${e.name}" sandboxes[${a}] "${String(i)}" is listed more than once`)});let s=Eo(e.name,o.hooks);if(s)o.hooks=s.agentHooksConfig;else if(o.hooks!==void 0)o.hooks=qn(o.hooks,e.name);if(o.connections!==void 0){if(!Array.isArray(o.connections))throw Error(`Agent "${e.name}" config.connections must be an array of connection definitions`);o.channels=Object.fromEntries(o.connections.map((i)=>{if(!w(i))throw Error(`Agent "${e.name}" config.connections must contain connection definitions`);let a=`${e.name}${Vn(i.type)}Channel`,c=Yn(i,t);return[i.type,{id:a,...i.config,...i.partition?{partition:i.partition}:{},allowedChannelIds:c}]})),delete o.connections}if(Array.isArray(o.workspaces)){let i=o.workspaces.map((a)=>_o(a,e.name));for(let a of i){let c=r?.indexOf(a.sandbox)??-1;if(c>=1)throw Error(`Agent "${e.name}" sandboxes[${c}] "${String(a.sandbox)}" also backs workspace "${String(a.name)}"; only the first sandbox can back a workspace`)}o.workspaces=i}if(o.harness&&!r?.length)throw Error(`Agent "${e.name}" runs a harness, so it needs sandboxes; the first runs the harness`);if(o.policies!==void 0){let i=Co(o.policies,e.name);if(i)o.policies=i;else delete o.policies}return{config:M(o),...s?.hookResource?{hookResource:s.hookResource}:{}}}function Eo(e,n){if(n===void 0)return;if(!n||typeof n!=="object"||Array.isArray(n))throw Error(`Agent "${e}" config.hooks must be an object`);let t=n,o=Object.keys(ze).flatMap((d)=>{let l=t[d];if(l===void 0)return[];if(typeof l!=="function")throw Error(`Agent "${e}" config.hooks.${d} must be a function`);return[{name:d,event:ze[d],source:Oo(l.toString())}]});if(o.length===0)return;let r=`${e}-hooks`,s=Ro(e,o),i=Buffer.byteLength(s);if(i>xe)throw Error(`Agent "${e}" hook bundle is too large (${i} bytes, max ${xe})`);let a=o.map((d)=>d.event),c=qn(t,e);return c.code=[{hookId:r}],{agentHooksConfig:c,hookResource:{kind:"hook",name:r,description:`Inline hooks for agent ${e}`,config:{events:a,bundle:s,sha256:je(s)}}}}function qn(e,n){if(!e||typeof e!=="object"||Array.isArray(e))throw Error(`Agent "${n}" config.hooks must be an object`);let t=Object.entries(e);for(let[r]of t){if(r==="webhooks"||r in ze)continue;throw Error(`Agent "${n}" config.hooks.${r} is not supported. Use inline hook callbacks or hooks.webhooks.`)}return Object.fromEntries(t.filter(([r])=>r==="webhooks"))}function Oo(e){let n=e.trim();if(/^(async\s+)?function\b/.test(n)||/^(async\s*)?\(/.test(n)||/^(async\s+)?[A-Za-z_$][\w$]*\s*=>/.test(n))return n;if(/^(async\s+)?[A-Za-z_$][\w$]*\s*\(/.test(n))return n.replace(/^(async\s+)?/,"$1function ");return n}function Ro(e,n){let t=`export default {
28
+ `,xe=1e7,An=50000000,Gn=1e7,xn=20000000,jn=200,Ht=new Set(["node_modules",".git"]),zt=[/^\.env(?:\.|$)/i,/^id_(?:rsa|dsa|ecdsa|ed25519)(?:\.pub)?$/i,/\.(?:pem|key|p12|pfx)$/i],ze={onStart:"agent.started",onStepFinish:"agent.step.finished",onToolCall:"tool.call.started",onToolResult:"tool.result",onFinish:"agent.finished",onApproval:"agent.approval.required",onError:"agent.failed",onSubagentFinish:"subagent.task.finished",onMessageReceived:"channel.message.received",onMessageSending:"channel.message.sending"};async function ee(e={}){let n=e.cwd??process.cwd();h(n);let t=Ae(n,S),o=await Vt(t),r=await Jt(o),s=await Zt(r,n,e.project),i=r.filter((m)=>g(m.value)).map((m)=>({exportName:m.exportName,file:m.file,resource:m.value})),a=i.map((m)=>m.resource);Dn(a),co(a);let c=uo(i,r),d=fo(a);for(let m of a)Qt(m);for(let m of a)eo(m);for(let m of a)no(m);to(a),ro(a),go(i,d);let l=lo(i),u=Yt(s,e.stage??(e.useRuntimeStage===!1?void 0:_()),e.command??"dev"),p=(await Promise.all(i.map((m)=>po(m,t,d)))).flat().sort((m,y)=>`${m.kind}:${m.name}`.localeCompare(`${y.kind}:${y.name}`));return Dn(p),{config:s,resources:a,resourceAliases:l,channels:c,manifest:{version:1,project:s.project,stage:u,resources:p}}}function Wn(e){let n=new Set;for(let t of e.resources)Ye(t.config,n);return[...n].sort()}function Ye(e,n){if(Array.isArray(e)){for(let t of e)Ye(t,n);return}if(e&&typeof e==="object"){let t=e;if(t.__beeblastEnv===!0&&typeof t.name==="string"){n.add(t.name);return}for(let o of Object.values(t))Ye(o,n)}}function Yt(e,n,t){if(n)return n;let o=e.stages?.[t];if(o)return o;return t==="deploy"?"production":"development"}async function Vt(e){let n=[];async function t(o){let r=await Nn(o,{withFileTypes:!0});for(let s of r){let i=Q(o,s.name);if(s.isDirectory()){if(s.name===v||s.name==="generated")continue;await t(i)}else if(s.isFile()&&s.name.endsWith(".ts"))n.push(i)}}return await t(e),n.sort((o,r)=>ge(e,o).localeCompare(ge(e,r)))}async function Jt(e){qt();let n=[];for(let t of e){let r=await import(`${Un(t).href}?t=${Date.now()}`);n.push(...Object.entries(r).map(([s,i])=>({exportName:s,file:t,value:i})))}return n}var Pn=!1;function qt(){if(Pn)return;if(Pn=!0,typeof Cn.registerHooks!=="function")return;Cn.registerHooks({load:(e,n,t)=>{let[o]=e.split("?");if(o===void 0||!o.startsWith("file:")||!o.endsWith(".ts"))return t(e,n);let r=Lt(o);return{format:"module",shortCircuit:!0,source:Kn(Bt(r,"utf8"),{loader:"ts",format:"esm",sourcefile:r,sourcemap:"inline"}).code}}})}async function Zt(e,n,t){let r=e.find((i)=>ne(i.value))?.value?.config??{},s=t??process.env.BROODS_PROJECT??r.project??Ko(Kt(Ae(n)));if(!s.trim())throw Error("Project name is required. Pass --project <name> or set BROODS_PROJECT.");return{...r,project:s}}var In=new Set(["agent","harness","model","provider","session","hooks","connections","tools","mcp","denyTools","sandboxes","workspaces","subagent","skills","scheduler","policies","publicAccess","allowRunOverrides"]),Xt={workspace:"workspaces",skill:"skills",policy:"policies",tool:"tools",mcpServers:"mcp",channel:"connections",channels:"connections",hook:"hooks",subagents:"subagent",systemPrompt:"agent",system:"agent"};function Qt(e){if(e.kind!=="agent")return;let n=e.config;for(let t of Object.keys(n)){if(In.has(t))continue;if(t==="sandbox")throw Error(`Agent "${e.name}" config.sandbox was removed; use sandboxes, the first is the default`);let o=Xt[t],r=o?` Did you mean "${o}"?`:` Allowed keys: ${[...In].sort().join(", ")}.`;throw Error(`Agent "${e.name}" has an unknown config key "${t}".${r}`)}}function eo(e){if(e.kind!=="workspace")return;let t=e.config.storage;if(t===void 0)return;if(!t||typeof t!=="object"||Array.isArray(t))throw Error(`Workspace "${e.name}" config.storage must be an object`);let o=t.provider;if(o===void 0||o==="s3")return;if(o==="vercel")throw Error(`Workspace "${e.name}" uses storage.provider "vercel", but Vercel Drive workspace storage is not supported yet. Use storage.provider "s3" or omit storage until Vercel Drive is wired.`);throw Error(`Workspace "${e.name}" config.storage.provider must be one of: s3`)}function no(e){if(e.kind!=="workspace")return;let n=e.config;if(typeof n.partitioned==="string")throw Error(`Workspace "${e.name}" config.partitioned must be a boolean; string modes are not supported.`);if(n.isolation!==void 0)throw Error(`Workspace "${e.name}" config.isolation is no longer supported; use partitioned: true.`)}function to(e){let n=new Map(e.filter((t)=>t.kind==="workspace").map((t)=>[t.name,t]));for(let t of e){if(t.kind!=="agent")continue;let o=t.config,r=o.connections;if(r!==void 0&&!Array.isArray(r))throw Error(`Agent "${t.name}" config.connections must be an array of connection definitions`);let s=Array.isArray(r)?r.filter(w):[],i=new Set;for(let l of s){let u=l.config,p=typeof u.id==="string"?u.id:void 0;if(p){if(i.has(p))throw Error(`Duplicate channel id: ${p}`);i.add(p)}if(l.partition)Fn(l.partition,`Agent "${t.name}" connection "${l.type}"`);if(l.config&&typeof l.config==="object"&&(("workspaceIsolationScope"in l.config)||("workspaceScope"in l.config)))throw Error(`Agent "${t.name}" connection "${l.type}" uses workspaceScope, which is no longer supported; use partition.`)}let c=(Array.isArray(o.workspaces)?o.workspaces.map((l)=>oo(l,n)).filter((l)=>Boolean(l)):[]).filter((l)=>l.config.partitioned===!0),d=s.filter((l)=>l.partition);if(d.length>0&&c.length===0){let l=d[0];throw Error(`Agent "${t.name}" connection "${l.type}" defines partition, but no attached workspace has partitioned: true.`)}if(c.length>0){for(let l of s)if(!l.partition)throw Error(`Agent "${t.name}" attaches partitioned workspace "${c[0].name}", but connection "${l.type}" does not define partition.`)}}}function Fn(e,n){if(!e)return;if(e.by==="shared"){if("alias"in e&&e.alias!==void 0)throw Error(`${n} partition.alias is only supported when partition.by is conversation`);return}if(e.by!=="conversation")throw Error(`${n} partition.by must be one of: shared, conversation`);if(typeof e.alias!=="string"||e.alias.length===0)throw Error(`${n} partition.alias is required when partition.by is conversation`);if(!/^[A-Za-z0-9._-]+$/.test(e.alias))throw Error(`${n} partition.alias must use only letters, numbers, dots, underscores, or hyphens`);if(e.alias==="."||e.alias==="..")throw Error(`${n} partition.alias must not be "." or ".."`)}function oo(e,n){if(g(e)&&e.kind==="workspace")return e;if(typeof e==="string")return n.get(e);if(e&&typeof e==="object"&&"workspace"in e){let t=e.workspace;if(g(t)&&t.kind==="workspace")return t;if(typeof t==="string")return n.get(t)}return}function ro(e){let n=new Map(e.filter((t)=>t.kind==="sandbox").map((t)=>[t.name,t]));for(let t of e){if(t.kind!=="agent")continue;let o=t.config,r=Hn(Array.isArray(o.sandboxes)?o.sandboxes[0]:void 0,n),s=o.workspaces;if(!Array.isArray(s))continue;for(let i of s){let a=io(i),c=so(i,r,n);if(!c||ao(c))continue;throw Error(`Agent "${t.name}" workspace "${a}" uses sandbox "${c.name}" (${zn(c)}) which does not support S3 workspace mounts. Use lambda/sandbox, or daytona with options.mountAwsS3Buckets: true, or set this workspace ref to sandbox: null for read-only S3 access.`)}}}function Hn(e,n){if(g(e)&&e.kind==="sandbox")return e;if(typeof e==="string")return n.get(e);return}function so(e,n,t){if(e&&typeof e==="object"&&"sandbox"in e){let o=e.sandbox;if(o===null)return;return Hn(o,t)}return n}function io(e){if(g(e)&&e.kind==="workspace")return e.name;if(e&&typeof e==="object"&&"workspace"in e){let n=e.workspace;if(g(n))return n.name;if(typeof n==="string")return n}return"<unknown>"}function ao(e){let n=zn(e);if(n==="lambda"||n==="sandbox")return!0;if(n!=="daytona")return!1;let t=e.config.options;return Boolean(t&&typeof t==="object"&&!Array.isArray(t)&&t.mountAwsS3Buckets===!0)}function zn(e){return typeof e.config.provider==="string"?e.config.provider:"sandbox"}function co(e){let n=new Set(e.filter((t)=>t.kind==="sandbox").map((t)=>t.name));for(let t of e){if(t.kind!=="agent")continue;let o=t.config.sandboxes;if(o===void 0)continue;if(!Array.isArray(o))throw Error(`Agent "${t.name}" sandboxes must be an array of sandbox resources or names`);let r=o;for(let[s,i]of r.entries()){let a=typeof i==="string"&&i.trim().length>0,c=g(i)&&i.kind==="sandbox";if(!a&&!c)throw Error(`Agent "${t.name}" sandboxes[${s}] must be a sandbox resource or a non-empty name`);if(c&&!n.has(i.name))throw Error(`Agent "${t.name}" sandboxes references sandbox "${i.name}", but that sandbox is not exported from broods/`)}}}function Dn(e){let n=new Set;for(let t of e){let o=`${t.kind}:${t.name}`;if(n.has(o))throw Error(`Duplicate resource: ${o}`);n.add(o)}}function lo(e){let n={},t=new Set;for(let{exportName:o,resource:r}of e){if(o==="default"||!Ve(o))continue;let s=`${r.kind}:${o}`;if(t.has(s))throw Error(`Duplicate export alias for ${r.kind}: ${o}`);t.add(s),n[r.kind]??={},n[r.kind][r.name]=o}return n}function uo(e,n){let t=new Map;for(let i of n){if(!w(i.value)||i.exportName==="default"||!Ve(i.exportName))continue;let a=t.get(i.value);if(a&&a!==i.exportName)throw Error(`Channel is exported more than once: ${a}, ${i.exportName}`);t.set(i.value,i.exportName)}let o=new Map,r=new Set,s=[];for(let{exportName:i,resource:a}of e){if(a.kind!=="agent")continue;let c=a.config.connections;if(c===void 0)continue;if(!Array.isArray(c))throw Error(`Agent "${a.name}" config.connections must be an array of connection definitions`);let d=new Set;for(let l of c){if(!w(l))throw Error(`Agent "${a.name}" config.connections must contain connection definitions`);let u=o.get(l);if(u&&u!==a.name)throw Error(`Channel ${l.type} is already attached to agent "${u}" and cannot also attach to "${a.name}"`);if(d.has(l.type))throw Error(`Agent "${a.name}" cannot configure more than one ${l.type} channel`);o.set(l,a.name),d.add(l.type);let p=i!=="default"&&Ve(i)?i:a.name,m=t.get(l)??`${p}${Vn(l.type)}Channel`;if(r.has(m))throw Error(`Duplicate channel export alias: ${m}`);r.add(m),s.push({alias:m,type:l.type,id:m,agentName:a.name})}}for(let[i,a]of t)if(!o.has(i))throw Error(`Channel "${a}" must be attached to exactly one agent`);return s.sort((i,a)=>i.alias.localeCompare(a.alias))}function go(e,n){for(let{resource:t}of e){if(t.kind!=="agent")continue;let o=t.config.connections;if(!Array.isArray(o))continue;for(let r of o){if(!w(r))continue;if(Yn(r,n).length>0)continue;throw Error(`Agent "${t.name}" connection "${r.type}" reaches no rooms: declare a ${r.type} channel for it, or set allowedChannelIds: ["*"] to answer everywhere`)}}}function Yn(e,n){let t=e.config.allowedChannelIds??[];if(t.includes(we))return[we];return[...new Set([...n.get(e)??[],...t])]}function fo(e){let n=new Map;for(let t of e){if(t.kind!=="channelRecord")continue;let o=t.config;if(!w(o.connection))continue;let r=Jn(t.name,o.externalId);if(r.length===0)continue;let s=n.get(o.connection)??new Set;for(let i of r)s.add(i);n.set(o.connection,s)}return n}function Vn(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Ve(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)}async function po(e,n,t){let o=e.resource;if(o.kind==="agent"){let r=$o(o,n,t);return[...r.hookResource?[r.hookResource]:[],{kind:o.kind,name:o.name,...o.description?{description:o.description}:{},config:r.config}]}if(o.kind==="channelRecord"){let r=o.config,s=Jn(o.name,r.externalId);return s.map((i)=>({kind:o.kind,name:s.length===1?o.name:`${o.name}-${i}`,...o.description?{description:o.description}:{},config:Uo(o.name,{...r,externalId:i})}))}return[{kind:o.kind,name:o.name,...o.description?{description:o.description}:{},config:await mo(e,n)}]}function Jn(e,n){if(n===void 0)return[];if(typeof n==="string")return _n(e,n),[n];if(!Array.isArray(n))throw Error(`Channel "${e}" externalId must be a string or an array`);if(n.length===0)throw Error(`Channel "${e}" externalId must not be an empty array`);let t=new Set;for(let o of n){if(typeof o!=="string"||o.length===0)throw Error(`Channel "${e}" externalId must be an array of non-empty strings`);if(t.has(o))throw Error(`Channel "${e}" externalId lists ${o} twice`);_n(e,o),t.add(o)}return n}function _n(e,n){if(n!==we)return;throw Error(`Channel "${e}" cannot use "${we}" as its id: a record matches one exact room. To answer everywhere, set allowedChannelIds: ["${we}"] on the connection; undeclared rooms already fall back to its agent.`)}async function mo(e,n){let t=e.resource;if(t.kind==="skill")return await jo(t.config,n);if(t.kind==="workspace"){let o={...t.config};if(o.partitioned!==void 0){if(typeof o.partitioned!=="boolean")throw Error(`Workspace "${t.name}" config.partitioned must be a boolean`);let r=o.partitioned;if(delete o.partitioned,r)o.isolation=!0}return M(o)}if(t.kind==="mcp")return await Po(e,t.config,n);if(t.kind==="policy"){let o={...t.config};return o.version=o.version??1,M(o)}if(t.kind==="cron"){let o={...t.config},r=o.agent;if(o.agentId=g(r)?r.name:r,o.name=o.name??t.name,delete o.agent,typeof o.input==="string")o.events=[{role:"user",content:[{type:"text",text:o.input}]}],delete o.input;return M(o)}return M(t.config)}var ho=new Set(["apiKey","base_url","baseURL"]),bo=new Set(["activeTools","debug","inactiveTools","permissionMode","startupTimeoutMs","type","webSearch"]),wo=new Set(["enabled","level","subsystems"]);function yo(e){if(ho.has(e))return"";let n=e.replace(/[^a-z0-9]/gi,"").toLowerCase();if(n==="baseurl")return'"base_url" or "baseURL"';if(n==="apikey")return'"apiKey"';return""}function vo(e,n){if(n===void 0||n===null)return;if(typeof n!=="object"||Array.isArray(n))throw Error(`Agent "${e}" config.provider must be an object`);for(let[t,o]of Object.entries(n)){if(!Rn(t))throw Error(`Agent "${e}" config.provider.${t} is not a supported provider (expected one of: ${On.join(", ")})`);if(typeof o!=="object"||o===null||Array.isArray(o))throw Error(`Agent "${e}" config.provider.${t} must be an object`);let r=o;for(let s of Object.keys(r)){let i=yo(s);if(i)throw Error(`Agent "${e}" config.provider.${t} has unknown option "${s}". Did you mean ${i}?`)}if(t==="custom"&&r.base_url===void 0&&r.baseURL===void 0)throw Error(`Agent "${e}" config.provider.custom.base_url is required (use "base_url" or "baseURL")`)}}function ko(e,n){if(n===void 0||n===null)return;if(typeof n!=="object"||Array.isArray(n))throw Error(`Agent "${e}" config.harness must be an object`);let t=n;if("sandbox"in t)throw Error(`Agent "${e}" harness sandbox was removed; list it first in the agent's sandboxes`);for(let o of Object.keys(t))if(!bo.has(o))throw Error(`Agent "${e}" config.harness has unknown option "${o}"`);if(t.type!=="claude-code"&&t.type!=="codex"&&t.type!=="deepagents"&&t.type!=="opencode"&&t.type!=="pi")throw Error(`Agent "${e}" config.harness.type must be claude-code, codex, deepagents, opencode, or pi`);if(t.permissionMode!==void 0&&t.permissionMode!=="allow-reads"&&t.permissionMode!=="allow-edits"&&t.permissionMode!=="allow-all")throw Error(`Agent "${e}" config.harness.permissionMode must be allow-reads, allow-edits, or allow-all`);if(t.type==="codex"&&t.permissionMode!==void 0&&t.permissionMode!=="allow-all")throw Error(`Agent "${e}" config.harness.permissionMode must be allow-all for codex`);if(t.startupTimeoutMs!==void 0&&(typeof t.startupTimeoutMs!=="number"||!Number.isSafeInteger(t.startupTimeoutMs)||t.startupTimeoutMs<1||t.startupTimeoutMs>600000))throw Error(`Agent "${e}" config.harness.startupTimeoutMs must be an integer from 1 to 600000`);if(t.webSearch!==void 0&&typeof t.webSearch!=="boolean")throw Error(`Agent "${e}" config.harness.webSearch must be a boolean`);if(t.type!=="codex"&&t.webSearch!==void 0)throw Error(`Agent "${e}" config.harness.webSearch is only supported by codex`);if(t.type==="pi"&&t.startupTimeoutMs!==void 0)throw Error(`Agent "${e}" config.harness.startupTimeoutMs is not supported by pi`);if(Je(e,t.activeTools,"activeTools"),Je(e,t.inactiveTools,"inactiveTools"),t.activeTools!==void 0&&t.inactiveTools!==void 0)throw Error(`Agent "${e}" config.harness must use either activeTools or inactiveTools, not both`);So(e,t.debug)}function So(e,n){if(n===void 0)return;if(typeof n!=="object"||n===null||Array.isArray(n))throw Error(`Agent "${e}" config.harness.debug must be an object`);let t=n;for(let o of Object.keys(t))if(!wo.has(o))throw Error(`Agent "${e}" config.harness.debug has unknown option "${o}"`);if(t.enabled!==void 0&&typeof t.enabled!=="boolean")throw Error(`Agent "${e}" config.harness.debug.enabled must be a boolean`);if(t.level!==void 0&&t.level!=="error"&&t.level!=="warn"&&t.level!=="info"&&t.level!=="debug"&&t.level!=="trace")throw Error(`Agent "${e}" config.harness.debug.level must be error, warn, info, debug, or trace`);Je(e,t.subsystems,"debug.subsystems")}function Je(e,n,t){if(n!==void 0&&(!Array.isArray(n)||!n.every((o)=>typeof o==="string"&&o.trim().length>0)))throw Error(`Agent "${e}" config.harness.${t} must be an array of non-empty strings`)}function $o(e,n,t){let o={...e.config};vo(e.name,o.provider),ko(e.name,o.harness);let r=Array.isArray(o.sandboxes)?o.sandboxes.map((i)=>g(i)?i.name:i):void 0;if(r)o.sandboxes=r;r?.forEach((i,a)=>{if(r.indexOf(i)===a)return;throw Error(`Agent "${e.name}" sandboxes[${a}] "${String(i)}" is listed more than once`)});let s=Eo(e.name,o.hooks);if(s)o.hooks=s.agentHooksConfig;else if(o.hooks!==void 0)o.hooks=qn(o.hooks,e.name);if(o.connections!==void 0){if(!Array.isArray(o.connections))throw Error(`Agent "${e.name}" config.connections must be an array of connection definitions`);o.channels=Object.fromEntries(o.connections.map((i)=>{if(!w(i))throw Error(`Agent "${e.name}" config.connections must contain connection definitions`);let a=`${e.name}${Vn(i.type)}Channel`,c=Yn(i,t);return[i.type,{id:a,...i.config,...i.partition?{partition:i.partition}:{},allowedChannelIds:c}]})),delete o.connections}if(Array.isArray(o.workspaces)){let i=o.workspaces.map((a)=>_o(a,e.name));for(let a of i){let c=r?.indexOf(a.sandbox)??-1;if(c>=1)throw Error(`Agent "${e.name}" sandboxes[${c}] "${String(a.sandbox)}" also backs workspace "${String(a.name)}"; only the first sandbox can back a workspace`)}o.workspaces=i}if(o.harness&&!r?.length)throw Error(`Agent "${e.name}" runs a harness, so it needs sandboxes; the first runs the harness`);if(o.policies!==void 0){let i=Co(o.policies,e.name);if(i)o.policies=i;else delete o.policies}return{config:M(o),...s?.hookResource?{hookResource:s.hookResource}:{}}}function Eo(e,n){if(n===void 0)return;if(!n||typeof n!=="object"||Array.isArray(n))throw Error(`Agent "${e}" config.hooks must be an object`);let t=n,o=Object.keys(ze).flatMap((d)=>{let l=t[d];if(l===void 0)return[];if(typeof l!=="function")throw Error(`Agent "${e}" config.hooks.${d} must be a function`);return[{name:d,event:ze[d],source:Oo(l.toString())}]});if(o.length===0)return;let r=`${e}-hooks`,s=Ro(e,o),i=Buffer.byteLength(s);if(i>xe)throw Error(`Agent "${e}" hook bundle is too large (${i} bytes, max ${xe})`);let a=o.map((d)=>d.event),c=qn(t,e);return c.code=[{hookId:r}],{agentHooksConfig:c,hookResource:{kind:"hook",name:r,description:`Inline hooks for agent ${e}`,config:{events:a,bundle:s,sha256:je(s)}}}}function qn(e,n){if(!e||typeof e!=="object"||Array.isArray(e))throw Error(`Agent "${n}" config.hooks must be an object`);let t=Object.entries(e);for(let[r]of t){if(r==="webhooks"||r in ze)continue;throw Error(`Agent "${n}" config.hooks.${r} is not supported. Use inline hook callbacks or hooks.webhooks.`)}return Object.fromEntries(t.filter(([r])=>r==="webhooks"))}function Oo(e){let n=e.trim();if(/^(async\s+)?function\b/.test(n)||/^(async\s*)?\(/.test(n)||/^(async\s+)?[A-Za-z_$][\w$]*\s*=>/.test(n))return n;if(/^(async\s+)?[A-Za-z_$][\w$]*\s*\(/.test(n))return n.replace(/^(async\s+)?/,"$1function ");return n}function Ro(e,n){let t=`export default {
29
29
  ${n.map((o)=>` ${JSON.stringify(o.event)}: ${o.source},`).join(`
30
30
  `)}
31
31
  };
@@ -73,7 +73,7 @@ Check the browser tab and the dashboard logs for an error. If the browser shows
73
73
  404 on /cli-auth/start, deploy the dashboard build that includes CLI auth or pass
74
74
  --dashboard-url for the environment you deployed. Other common causes are missing
75
75
  cliAuth Convex functions or no active API account (Settings -> API Access).`)),n)});try{return await Promise.race([e,o])}finally{if(t)clearTimeout(t)}}import{existsSync as it}from"node:fs";import{mkdir as vr,readFile as kr,writeFile as Sr}from"node:fs/promises";import{dirname as lt,join as rn,resolve as $r,sep as ie}from"node:path";import{fileURLToPath as Er}from"node:url";var sn=rn(lt(C),"update-check.json"),Or=86400000,Rr="https://registry.npmjs.org/broods/latest",Cr=2000;function an(e,n){let t=ct(e),o=ct(n);for(let r=0;r<3;r+=1){let s=t[r]??0,i=o[r]??0;if(s!==i)return s>i}return!at(e)&&at(n)}async function cn(e={}){let n=await jr(),t=e.maxAgeMs??Or;if(n&&Date.now()-n.checkedAt<t)return n.latest;let o=await Ar();if(o===null)return n?.latest??null;return await Pr({checkedAt:Date.now(),latest:o}),o}function dt(e=$r(process.cwd()),n=Er(import.meta.url)){let t=`${ie}node_modules${ie}`,o=n.lastIndexOf(t),r=o===-1?null:n.slice(0,o),s=r===null?n.startsWith(`${e}${ie}`):e===r||e.startsWith(`${r}${ie}`),a=n.includes(`${ie}.bun${ie}install${ie}global${ie}`)||s&&xr(r??e)?"bun":"npm",c=a==="bun"?"add":"install";return{manager:a,global:!s,command:a,args:s?[c,"broods@latest"]:[c,"-g","broods@latest"]}}async function Ar(){try{let e=await fetch(Rr,{signal:AbortSignal.timeout(Cr),headers:{accept:"application/json"}});if(!e.ok)return null;let n=await e.json();return typeof n.version==="string"?n.version:null}catch{return null}}function xr(e){return it(rn(e,"bun.lock"))||it(rn(e,"bun.lockb"))}function at(e){return e.includes("-")}async function jr(){try{let e=JSON.parse(await kr(sn,"utf8"));if(typeof e.latest!=="string")return null;if(typeof e.checkedAt!=="number")return null;return{checkedAt:e.checkedAt,latest:e.latest}}catch{return null}}function ct(e){let[n]=e.trim().replace(/^v/,"").split("-");return(n??"").split(".").slice(0,3).map((t)=>Number.parseInt(t,10)||0)}async function Pr(e){try{await vr(lt(sn),{recursive:!0}),await Sr(sn,`${JSON.stringify(e)}
76
- `,"utf8")}catch{}}var ut={name:"broods",version:"0.38.1",description:"CLI + TypeScript SDK for the broods agent platform.",keywords:["agents","ai","broods","cli","sdk"],homepage:"https://github.com/beeblastco/broods#readme",bugs:{url:"https://github.com/beeblastco/broods/issues"},license:"MIT",repository:{type:"git",url:"git+https://github.com/beeblastco/broods.git",directory:"packages/broods"},bin:{broods:"dist/cli/index.js"},files:["dist","README.md","LICENSE.md"],type:"module",main:"./dist/index.js",types:"./dist/index.d.ts",typesVersions:{"*":{account:["./dist/account.d.ts"]}},exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./account":{types:"./dist/account.d.ts",import:"./dist/account.js"}},scripts:{build:"bun scripts/build.ts && rollup -c rollup.dts.config.mjs && rm -rf .dts-temp",check:"tsc --noEmit","pack:check":"bun run build && publint && attw --pack .",test:"bun test"},dependencies:{"@modelcontextprotocol/client":"^2.0.0",esbuild:"^0.28.2"},devDependencies:{"@ai-sdk/tui":"1.0.108","@arethetypeswrong/cli":"^0.18.5","@chat-adapter/discord":"^4.38.1","@chat-adapter/github":"^4.38.1","@chat-adapter/slack":"^4.38.1","@chat-adapter/telegram":"^4.38.1","@modelcontextprotocol/server":"2.0.0","@types/bun":"^1.3.14","@typescript/typescript6":"6.0.2",ai:"^7.0.107",publint:"^0.3.23",rollup:"^4.62.4","rollup-plugin-dts":"^6.5.1",typescript:"^7.0.2",zod:"^4.4.3"},peerDependencies:{ai:"^7.0.107"},engines:{node:">=22.15"}};var gt=`---
76
+ `,"utf8")}catch{}}var ut={name:"broods",version:"0.39.1",description:"CLI + TypeScript SDK for the broods agent platform.",keywords:["agents","ai","broods","cli","sdk"],homepage:"https://github.com/beeblastco/broods#readme",bugs:{url:"https://github.com/beeblastco/broods/issues"},license:"MIT",repository:{type:"git",url:"git+https://github.com/beeblastco/broods.git",directory:"packages/broods"},bin:{broods:"dist/cli/index.js"},files:["dist","README.md","LICENSE.md"],type:"module",main:"./dist/index.js",types:"./dist/index.d.ts",typesVersions:{"*":{account:["./dist/account.d.ts"]}},exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./account":{types:"./dist/account.d.ts",import:"./dist/account.js"}},scripts:{build:"bun scripts/build.ts && rollup -c rollup.dts.config.mjs && rm -rf .dts-temp",check:"tsc --noEmit","pack:check":"bun run build && publint && attw --pack .",test:"bun test"},dependencies:{"@modelcontextprotocol/client":"^2.0.0",esbuild:"^0.28.2"},devDependencies:{"@ai-sdk/tui":"1.0.108","@arethetypeswrong/cli":"^0.18.5","@chat-adapter/discord":"^4.38.1","@chat-adapter/github":"^4.38.1","@chat-adapter/slack":"^4.38.1","@chat-adapter/telegram":"^4.38.1","@modelcontextprotocol/server":"2.0.0","@types/bun":"^1.3.14","@typescript/typescript6":"6.0.2",ai:"^7.0.107",publint:"^0.3.23",rollup:"^4.62.4","rollup-plugin-dts":"^6.5.1",typescript:"^7.0.2",zod:"^4.4.3"},peerDependencies:{ai:"^7.0.107"},engines:{node:">=22.15"}};var gt=`---
77
77
  name: broods
78
78
  description: Work on a broods account alongside a developer from Claude Code or a development agent. Covers onboarding and sign-in, creating a broods project, defining and deploying agents and their resources with the CLI, and integrating a deployed agent into existing code with the SDK. Use when asked to set up broods, create or work on a broods project, create or manage agents or any account resource, or call a deployed agent from application code.
79
79
  ---
@@ -379,7 +379,7 @@ Only orgs where you are owner or admin can be selected from the CLI.`);return}if
379
379
  ${L("project")}`);let s=h(),i=b(e,"--dashboard-url")??s.dashboardUrl??J,a=Ge(e),c=await Ke(i,b(e,"--base-url")),d=new D({baseUrl:c.baseUrl,token:c.token});if(o){let y=await d.listProjects();if(y.length===0){console.log("This org has no projects yet. `broods dev` creates one.");return}console.log("Projects:");for(let R of y)console.log(gs(R,a.project));let k=y.filter((R)=>R.empty);if(k.length>0)console.log(`
380
380
  ${k.length} empty project(s). Delete one with \`broods project delete <name>\`.`);return}let l=t??await le("Project to delete","");if(!l.trim())throw Error("Project name is required.");let u=await d.listProjects(),p=u.find((y)=>y.name===l||y.slug===l);if(!p)throw Error(`No project named "${l}". Existing: ${u.map((y)=>y.name).join(", ")}.`);if(!P(e,"--yes")){if(console.log(`Deleting ${p.name} removes ${gn(p)}.`),!await Le(`Permanently delete project ${p.name}?`)){console.log("Left it alone. Pass --yes to skip this prompt.");return}}let m=await d.deleteProject(p.id);if(!m)throw Error(`Project ${p.name} was not found.`);if(console.log(`Deleted project ${m.name} (${gn(m)})`),m.name===a.project||m.slug===a.project)console.log("That was the project this directory points at. Update BROODS_PROJECT in .env.local.")}async function es(e){let[n,t]=se(e);if(!n){console.log(L("stage"));return}let o=n==="list"||n==="ls",r=n==="use"||n==="select";if(!o&&!r&&!(n==="create"||n==="new"))throw Error(`Unknown stage subcommand: ${n}
381
381
 
382
- ${L("stage")}`);let i=h(),a=b(e,"--dashboard-url")??i.dashboardUrl??J,c=Ge(e),d=await Ke(a,b(e,"--base-url")),l=new D({baseUrl:d.baseUrl,token:d.token});if(o){let k=await l.listStages(c.project);if(k.length===0){console.log(`${c.project} has no stages yet. \`broods dev\` creates Development.`);return}console.log(`Stages for ${c.project}:`);for(let R of k)console.log(fs(R,c.stage));return}if(r){let k=await l.listStages(c.project),R=t?k.find((N)=>fn(N.name,t)):await Se("Select stage",k,Ct,k.findIndex((N)=>fn(N.name,c.stage)));if(!R)throw Error(`${c.project} has no stage "${t}". Existing: ${k.map((N)=>N.name).join(", ")}. Create it with \`broods stage create ${t} --from ${c.stage}\`.`);let q=O("BROODS_STAGE");await he("BROODS_STAGE",R.name),console.log(`Stage: ${R.name} (wrote BROODS_STAGE)`),un("BROODS_STAGE",q),await dn(l,{project:c.project,stage:R.name});return}let u=t??await le("Stage name","staging");if(!u.trim())throw Error("Stage name is required.");let p=b(e,"--from"),m=await l.createStage(c.project,u,p);if(console.log(`Created stage ${m.stage.name} in ${c.project}${m.clonedFrom?` from ${m.clonedFrom}`:""}`),m.clonedFrom)console.log(` ${m.stage.agentCount} agent(s), ${m.stage.variableCount} env var(s) copied`);if(!P(e,"--use")){console.log(`Switch to it with \`broods stage use ${m.stage.name}\`.`);return}let y=O("BROODS_STAGE");await he("BROODS_STAGE",m.stage.name),console.log(`Stage: ${m.stage.name} (wrote BROODS_STAGE)`),un("BROODS_STAGE",y),await dn(l,{project:c.project,stage:m.stage.name})}async function ns(e){let{manifest:n,config:t}=await ee({project:b(e,"--project"),stage:b(e,"--stage"),command:"dev"}),o=await G(b(e,"--base-url")??t.baseUrl),r=new D({baseUrl:o.baseUrl,token:o.token}),s=await r.getManifest(n.project,n.stage);Ue(nn(n,s?.manifest??null)),ys(await hn(r,n),`${n.project}/${n.stage}`)}async function ts(e){let{manifest:n,config:t,resourceAliases:o,channels:r}=await ee({project:b(e,"--project"),stage:b(e,"--stage"),command:"deploy",useRuntimeStage:!1}),s=await G(b(e,"--base-url")??t.baseUrl),a=await new D({baseUrl:s.baseUrl,token:s.token}).putManifest(n,P(e,"--prune"),P(e,"--rotate-key"));await Ie(n,a.ids,process.cwd(),o,a.deployment,r),await Dt(),await vn(),console.log(`Synced ${a.manifest.resources.length} resources to ${n.project}/${n.stage}`),await Et(a.deployment),At(r,a),Ot(a)}async function Et(e){if(!e)return;if(e.apiKey){await he("BROODS_API_KEY",e.apiKey),console.log(`Wrote BROODS_API_KEY (${e.keyHint}) to .env.local`);return}}function Ot(e){let n=e.warnings?.missingPolicies??[];if(n.length>0)x(`⚠ ${n.length} policy ref(s) in agent config match no policy resource in this deploy and will be ignored at runtime: ${n.join(", ")}`)}async function os(){let e=await cn({maxAgeMs:0});if(e===null)throw Error("Could not reach the npm registry to check for a newer broods.");if(!an(e,ae)){console.log(`broods v${ae} is already the newest release.`);return}let n=dt();console.log(`Updating broods ${ae} → ${e} ${n.global?"globally":"in this project"}`),console.log(`$ ${[n.command,...n.args].join(" ")}`),await new Promise((t,o)=>{let r=$t(n.command,n.args,{stdio:"inherit"});r.on("error",o),r.on("exit",(s)=>{if(s===0){t();return}o(Error(`${n.command} exited with code ${s??"unknown"}`))})}),console.log(`broods ${e} installed.`)}async function mt(){let e=await cn();if(e===null||!an(e,ae))return;x(`broods ${e} is out, you are on ${ae}. Run \`broods update\`.`)}async function rs(e){if(await is(e),P(e,"--once")){if(!process.env.BROODS_SUPPRESS_DEV_TARGET)await yt(e),await mt();let l=pt.now();await ws(e),ot(pt.now()-l);return}let n=Oe(Wr(),`broods-declined-${process.pid}.txt`),t={...process.env,BROODS_DECLINED_FILE:n,BROODS_SUPPRESS_DEV_TARGET:"1",BROODS_RELOAD_ENV:"1"};await yt(e),await mt(),await wt(e,t);let o,r=!1,s=!1,i=await vt(),a=()=>{if(r){s=!0;return}r=!0,vt().then(async(l)=>{if(l===i)return;i=l,await wt(e,t)}).catch((l)=>console.error(l instanceof Error?l.message:String(l))).finally(()=>{if(r=!1,s)s=!1,a()})},c=Gr(A(process.cwd(),S),{recursive:!0},(l,u)=>{if(!u||Us(u))return;clearTimeout(o),o=setTimeout(a,150)}),d=new AbortController;ss(e,d.signal),process.on("SIGINT",()=>{d.abort(),c.close(),process.exit(0)})}async function ss(e,n){let t;try{t=We()}catch{console.log("· live logs off. No runtime key for this stage yet. Run `broods dev --once` after login to create or reconnect it.");return}let o,r;try{({project:o,stage:r}=await wn(e,t))}catch{return}let s=bn(e);try{for await(let i of Te({baseUrl:t.baseUrl,apiKey:t.apiKey,project:o,stage:r},{backfill:0,minLevel:s,signal:n}))console.log(yn(i))}catch(i){if(!n.aborted)console.error(`live logs: ${i instanceof Error?i.message:String(i)}`)}}async function is(e){await cs(),await Rt(!1),await ls(e)}async function Rt(e){let n=process.cwd();if(!(await Promise.all([".agent",".agents",".claude","AGENTS.md","CLAUDE.md"].map((c)=>ht(A(n,c))))).includes(!0))return;let r=A(n,Ne);if(!e&&await ht(A(r,"SKILL.md")))return;let s=Oe(Ne,"SKILL.md"),i=Oe(Ne,"scripts","onboard.sh");for(let c of[s,i])if(await as(n,c)){x(`Skipped the agent skill: ${c} crosses a symlink.`);return}await pn(A(r,"scripts"),{recursive:!0}),await V(A(r,"SKILL.md"),gt);let a=A(r,"scripts","onboard.sh");await V(a,ft),await Tr(a,493),console.log(`Installed the broods agent skill at ${Ne}/`)}async function as(e,n){let t=e;for(let o of n.split(Kr)){t=A(t,o);try{if((await Ur(t)).isSymbolicLink())return!0}catch{return!1}}return!1}async function ht(e){try{return await Nr(e),!0}catch{return!1}}async function cs(){let e=A(process.cwd(),S);await pn(A(e,v),{recursive:!0});let n=[];if(await Sn(e,n),n.length>0)return;await Be(A(e,"index.ts"),Tt(),!1),await Be(A(e,".gitignore"),`_generated
382
+ ${L("stage")}`);let i=h(),a=b(e,"--dashboard-url")??i.dashboardUrl??J,c=Ge(e),d=await Ke(a,b(e,"--base-url")),l=new D({baseUrl:d.baseUrl,token:d.token});if(o){let k=await l.listStages(c.project);if(k.length===0){console.log(`${c.project} has no stages yet. \`broods dev\` creates Development.`);return}console.log(`Stages for ${c.project}:`);for(let R of k)console.log(fs(R,c.stage));return}if(r){let k=await l.listStages(c.project),R=t?k.find((N)=>fn(N.name,t)):await Se("Select stage",k,Ct,k.findIndex((N)=>fn(N.name,c.stage)));if(!R)throw Error(`${c.project} has no stage "${t}". Existing: ${k.map((N)=>N.name).join(", ")}. Create it with \`broods stage create ${t} --from ${c.stage}\`.`);let q=O("BROODS_STAGE");await he("BROODS_STAGE",R.name),console.log(`Stage: ${R.name} (wrote BROODS_STAGE)`),un("BROODS_STAGE",q),await dn(l,{project:c.project,stage:R.name});return}let u=t??await le("Stage name","staging");if(!u.trim())throw Error("Stage name is required.");let p=b(e,"--from"),m=await l.createStage(c.project,u,p);if(console.log(`Created stage ${m.stage.name} in ${c.project}${m.clonedFrom?` from ${m.clonedFrom}`:""}`),m.clonedFrom)console.log(` ${m.stage.agentCount} agent(s), ${m.stage.variableCount} env var(s) copied`);if(!P(e,"--use")){console.log(`Switch to it with \`broods stage use ${m.stage.name}\`.`);return}let y=O("BROODS_STAGE");await he("BROODS_STAGE",m.stage.name),console.log(`Stage: ${m.stage.name} (wrote BROODS_STAGE)`),un("BROODS_STAGE",y),await dn(l,{project:c.project,stage:m.stage.name})}async function ns(e){let{manifest:n,config:t}=await ee({project:b(e,"--project"),stage:b(e,"--stage"),command:"dev"}),o=await G(b(e,"--base-url")??t.baseUrl),r=new D({baseUrl:o.baseUrl,token:o.token}),s=await r.getManifest(n.project,n.stage);Ue(nn(n,s?.manifest??null)),ys(await hn(r,n),`${n.project}/${n.stage}`)}async function ts(e){let{manifest:n,config:t,resourceAliases:o,channels:r}=await ee({project:b(e,"--project"),stage:b(e,"--stage"),command:"deploy",useRuntimeStage:!1}),s=await G(b(e,"--base-url")??t.baseUrl),a=await new D({baseUrl:s.baseUrl,token:s.token}).putManifest(n,P(e,"--prune"),P(e,"--rotate-key"));await Ie(n,a.ids,process.cwd(),o,a.deployment,r),await Dt(),await vn(),console.log(`Synced ${a.manifest.resources.length} resources to ${n.project}/${n.stage}`),await Et(a.deployment),At(r,a),Ot(a)}async function Et(e){if(!e)return;if(e.apiKey){await he("BROODS_API_KEY",e.apiKey),console.log(`Wrote BROODS_API_KEY (${e.keyHint}) to .env.local`);return}}function Ot(e){let n=e.warnings?.missingPolicies??[];if(n.length>0)x(`⚠ ${n.length} policy ref(s) in agent config match no policy resource in this deploy. One that is not an existing policy id refuses every action at runtime: ${n.join(", ")}`)}async function os(){let e=await cn({maxAgeMs:0});if(e===null)throw Error("Could not reach the npm registry to check for a newer broods.");if(!an(e,ae)){console.log(`broods v${ae} is already the newest release.`);return}let n=dt();console.log(`Updating broods ${ae} → ${e} ${n.global?"globally":"in this project"}`),console.log(`$ ${[n.command,...n.args].join(" ")}`),await new Promise((t,o)=>{let r=$t(n.command,n.args,{stdio:"inherit"});r.on("error",o),r.on("exit",(s)=>{if(s===0){t();return}o(Error(`${n.command} exited with code ${s??"unknown"}`))})}),console.log(`broods ${e} installed.`)}async function mt(){let e=await cn();if(e===null||!an(e,ae))return;x(`broods ${e} is out, you are on ${ae}. Run \`broods update\`.`)}async function rs(e){if(await is(e),P(e,"--once")){if(!process.env.BROODS_SUPPRESS_DEV_TARGET)await yt(e),await mt();let l=pt.now();await ws(e),ot(pt.now()-l);return}let n=Oe(Wr(),`broods-declined-${process.pid}.txt`),t={...process.env,BROODS_DECLINED_FILE:n,BROODS_SUPPRESS_DEV_TARGET:"1",BROODS_RELOAD_ENV:"1"};await yt(e),await mt(),await wt(e,t);let o,r=!1,s=!1,i=await vt(),a=()=>{if(r){s=!0;return}r=!0,vt().then(async(l)=>{if(l===i)return;i=l,await wt(e,t)}).catch((l)=>console.error(l instanceof Error?l.message:String(l))).finally(()=>{if(r=!1,s)s=!1,a()})},c=Gr(A(process.cwd(),S),{recursive:!0},(l,u)=>{if(!u||Us(u))return;clearTimeout(o),o=setTimeout(a,150)}),d=new AbortController;ss(e,d.signal),process.on("SIGINT",()=>{d.abort(),c.close(),process.exit(0)})}async function ss(e,n){let t;try{t=We()}catch{console.log("· live logs off. No runtime key for this stage yet. Run `broods dev --once` after login to create or reconnect it.");return}let o,r;try{({project:o,stage:r}=await wn(e,t))}catch{return}let s=bn(e);try{for await(let i of Te({baseUrl:t.baseUrl,apiKey:t.apiKey,project:o,stage:r},{backfill:0,minLevel:s,signal:n}))console.log(yn(i))}catch(i){if(!n.aborted)console.error(`live logs: ${i instanceof Error?i.message:String(i)}`)}}async function is(e){await cs(),await Rt(!1),await ls(e)}async function Rt(e){let n=process.cwd();if(!(await Promise.all([".agent",".agents",".claude","AGENTS.md","CLAUDE.md"].map((c)=>ht(A(n,c))))).includes(!0))return;let r=A(n,Ne);if(!e&&await ht(A(r,"SKILL.md")))return;let s=Oe(Ne,"SKILL.md"),i=Oe(Ne,"scripts","onboard.sh");for(let c of[s,i])if(await as(n,c)){x(`Skipped the agent skill: ${c} crosses a symlink.`);return}await pn(A(r,"scripts"),{recursive:!0}),await V(A(r,"SKILL.md"),gt);let a=A(r,"scripts","onboard.sh");await V(a,ft),await Tr(a,493),console.log(`Installed the broods agent skill at ${Ne}/`)}async function as(e,n){let t=e;for(let o of n.split(Kr)){t=A(t,o);try{if((await Ur(t)).isSymbolicLink())return!0}catch{return!1}}return!1}async function ht(e){try{return await Nr(e),!0}catch{return!1}}async function cs(){let e=A(process.cwd(),S);await pn(A(e,v),{recursive:!0});let n=[];if(await Sn(e,n),n.length>0)return;await Be(A(e,"index.ts"),Tt(),!1),await Be(A(e,".gitignore"),`_generated
383
383
  .cache
384
384
  `,!1),console.log(`Created starter ${S}/`)}async function ls(e){let n=A(process.cwd(),".env.local"),t=await be(n),o=_t(t),r=o.BROODS_STAGE;if(["BROODS_DASHBOARD_URL","BROODS_BASE_URL","BROODS_PROJECT","BROODS_REGION"].filter((y)=>o[y]===void 0).length===0&&r!==void 0)return;let i=o.BROODS_PROJECT===void 0,a=r===void 0,c=o.BROODS_REGION===void 0,d=h(),l=b(e,"--dashboard-url")??d.dashboardUrl??J,u=b(e,"--project")??process.env.BROODS_PROJECT??Ce(process.cwd()),p=b(e,"--stage")??_()??"development",m=b(e,"--region")??process.env.BROODS_REGION??$e;if(process.stdin.isTTY&&i){let y=await Ke(l,b(e,"--base-url")),k=new D({baseUrl:y.baseUrl,token:y.token}),R=await ds(k,y),q=await ps(k,R);if(u=await bs(q,u),!u.trim())throw Error("Project name is required.")}if(process.stdin.isTTY&&a){if(p=await le("Stage",p),!p.trim())throw Error("Stage is required.")}if(process.stdin.isTTY&&c){let y=[...Hr];m=await Se("Select service region",y,(k)=>k.label,y.findIndex((k)=>k.region===m)).then((k)=>k.region)}await kn({dashboardUrl:l,baseUrl:d.baseUrl??te(l),project:u,stage:p,region:m,force:!1})}async function Ke(e,n){try{return await G(n)}catch(t){if(!process.stdin.isTTY)throw t;return x("No CLI login found. Starting browser login."),await on(e)}}async function ds(e,n){try{return await e.getOnboarding()}catch(t){if(!n.org)throw t;return x("CLI onboarding endpoint is not available yet; using the org from the current login."),{currentOrgId:n.org.id,orgs:[{id:n.org.id,name:n.org.name,slug:n.org.slug,role:"admin",accountStatus:"active"}],projects:[]}}}async function bt(e,n,t,o){let r=t.orgs.find((s)=>s.id===t.currentOrgId);if(!r)throw Error("Selected organization is not visible to this login");if(process.env.BROODS_TOKEN)x("BROODS_TOKEN is set, so the switch applies to this token only and was not stored.");else await H({...n,org:{id:r.id,name:r.name,slug:r.slug},...t.account?{account:{id:t.account.id,username:t.account.username}}:{}});console.log(`Org: ${Re(r)}`),console.log(`Projects: ${t.projects.length>0?t.projects.map((s)=>s.name).join(", "):"none yet"}`),await dn(e,Ge(o))}async function dn(e,n){let t;try{t=await e.getRuntimeKey(n.project,n.stage)}catch(r){x(`⚠ Could not read the runtime key for ${n.project}/${n.stage} (${r instanceof Error?r.message:String(r)}). BROODS_API_KEY still points at the previous scope. Run \`broods whoami\` to check it.`);return}if(!t?.apiKey){x(`⚠ ${n.project}/${n.stage} is not synced here yet, so BROODS_API_KEY still points at the previous scope. Run \`broods dev\`.`);return}let o=O("BROODS_API_KEY");if(!o&&process.env.BROODS_API_KEY===t.apiKey)return;await he("BROODS_API_KEY",t.apiKey),console.log(`Wrote BROODS_API_KEY (${t.keyHint}) to .env.local`),un("BROODS_API_KEY",o)}function un(e,n){if(!n)return;x(`⚠ ${e} is exported in your shell, which wins over .env.local. Run \`unset ${e}\` or the next broods command keeps the old value.`)}function Re(e){let n=e.role==="owner"||e.role==="admin"?e.role:"member",t=e.plan?`, ${e.plan} plan`:"";return`${e.name} (${e.slug}, ${n}${t})`}function us(e){return e.slug===e.name?e.name:`${e.name} (${e.slug})`}function gn(e){return e.empty?"nothing (it is already empty)":`${e.stageCount} stage(s), ${e.agentCount} agent(s), ${e.variableCount} env var(s), ${e.deploymentCount} deployment(s), ${e.fileCount} workspace file(s)`}function gs(e,n){let t=e.empty?"empty":gn(e);return fe(`${e.name}: ${t}`,e.name===n||e.slug===n)}function fs(e,n){return fe(Ct(e),fn(e.name,n))}function Ct(e){let n=e.deploymentRegion?`, ${e.deploymentRegion}`:"";return`${e.name} (${e.kind}${n}): ${e.agentCount} agent(s), ${e.variableCount} env var(s)`}function fn(e,n){return e.trim().toLowerCase()===n.trim().toLowerCase()}function Ge(e){return h(),{project:b(e,"--project")??process.env.BROODS_PROJECT??Ce(process.cwd()),stage:b(e,"--stage")??_()??"development"}}async function ps(e,n){let t=n.orgs.filter((s)=>s.accountStatus==="active"),o={kind:"create",name:"New organization"},r=await Se("Select organization",[...t,o],(s)=>("kind"in s)?"Create new organization":Re(s),t.findIndex((s)=>s.id===n.currentOrgId));if("kind"in r){let s=await le("Organization name",Ce(process.cwd()));if(!s.trim())throw Error("Organization name is required.");return await e.createOnboardingOrg(s)}return r.id===n.currentOrgId?n:await e.selectOnboardingOrg(r.id)}function ms(e,n){return e.projects.find((o)=>o.name===n||o.slug===n)?.name??n}function hs(e,n){return e.projects.find((t)=>t.name===n||t.slug===n)}async function bs(e,n){let t=ms(e,n);if(e.projects.length===0)return le("Project name",t);while(!0){let o=await st("Select project",e.projects,us,{hint:"type a new project name",defaultValue:t}),r=typeof o==="string"?o:o.name,s=hs(e,r);if(!s)return r;if(await Le(`Continue with the existing project ${s.name}?`))return s.name}}function wt(e,n){return new Promise((t,o)=>{let r=process.argv[1]??"",s=$t(process.execPath,[r,"dev","--once",...e],{stdio:"inherit",env:n});s.on("error",o),s.on("exit",(i,a)=>{if(i===0){t();return}o(Error(a?`Sync child exited from signal ${a}`:`Sync child exited with code ${i??"unknown"}`))})})}async function ws(e){let{manifest:n,config:t,resourceAliases:o,channels:r}=await ee({project:b(e,"--project"),stage:b(e,"--stage"),command:"dev"}),s=await G(b(e,"--base-url")??t.baseUrl),i=new D({baseUrl:s.baseUrl,token:s.token}),a=await i.getManifest(n.project,n.stage),c=nn(n,a?.manifest??null);Ue(c.filter((k)=>k.operation!=="delete"));let d=await xt(i,n,await hn(i,n));if(d.length>0)tn(d);let l=await i.putManifest(n,!1);await Ie(n,l.ids,process.cwd(),o,l.deployment,r),await Dt(),await vn();let u=await Ss(),p=c.filter((k)=>k.operation==="delete"),m=p.filter((k)=>!u.has(`${k.kind}:${k.name}`)),y=!1;if(m.length>0)if(x("⚠ These remote resources are no longer declared locally:"),Ue(m),await Le(`Delete ${m.length} resource(s) from ${n.project}/${n.stage}?`))l=await i.putManifest(n,!0),await Ie(n,l.ids,process.cwd(),o,l.deployment,r),await Es(),y=!0;else await $s(m.map((k)=>`${k.kind}:${k.name}`));if(!y&&p.length>0){let k=p.map((R)=>`${R.kind}:${R.name}`).join(", ");x(`⚠ ${p.length} undeclared resource(s) kept remotely: ${k}. Re-declare in code or run \`deploy --prune\` to remove.`)}return await Et(l.deployment),At(r,l),Ot(l),l}function At(e,n){let t=n.deployment;if(!t||e.length===0)return;let o=new j,r=new Map;for(let i of e){if(!n.ids.agents[i.agentName])continue;let a=r.get(i.type)??[];a.push(i.alias),r.set(i.type,a)}let s=t.stageKind===void 0||t.stageKind==="production";for(let[i,a]of r){let c=s?o.accountWebhookUrl(t.accountId,i):o.stageWebhookUrl(t.accountId,t.endpointId,i);console.log(`Channel ${a.join(", ")} (${i}): ${c}${i==="pancake"?"?secret=<PANCAKE_WEBHOOK_SECRET>":""}`)}}async function hn(e,n){let t=Wn(n).filter((r)=>!r.startsWith("BROODS_"));if(t.length===0)return[];let o=new Map((await e.listEnv(n.project,n.stage)).map((r)=>[r.name,r.valueDigest]));return t.map((r)=>({name:r,state:vs(r,o)}))}async function xt(e,n,t){let o=t.filter((r)=>r.state==="unset"||r.state==="drifted"||r.state==="unverified").map((r)=>r.name);if(o.length===0)return[];return await Promise.all(o.map((r)=>e.setEnv(n.project,n.stage,r,process.env[r]))),o}function ys(e,n){let t=Ee(e,"drifted"),o=Ee(e,"unverified");if(t.length>0)x(`⚠ .env.local and ${n} disagree on ${t.length} variable(s): ${t.join(", ")}. Run \`broods env sync\` to push the local values.`);if(o.length>0)x(`⚠ ${n} stored ${o.length} variable(s) before value digests, so nothing can compare them: ${o.join(", ")}. Run \`broods env sync\` to bring them in step.`)}function vs(e,n){let t=process.env[e],o=n.has(e);if(t===void 0||t==="")return o?"stage-only":"unresolved";if(!o)return"unset";let r=n.get(e);if(!r)return"unverified";return r===ks(t)?"synced":"drifted"}function ks(e){return St("sha256").update(e).digest("hex")}function Ee(e,n){return e.filter((t)=>t.state===n).map((t)=>t.name)}async function yt(e){let n=h(),{manifest:t,config:o}=await ee({project:b(e,"--project"),stage:b(e,"--stage"),command:"dev"}),r=await G(b(e,"--base-url")??o.baseUrl);tt({project:t.project,stage:t.stage,dashboardUrl:b(e,"--dashboard-url")??n.dashboardUrl??r.dashboardUrl??o.dashboardUrl??J})}async function Ss(){let e=process.env.BROODS_DECLINED_FILE;if(!e)return new Set;let n=await be(e);return new Set(n.split(/\r?\n/).map((t)=>t.trim()).filter(Boolean))}async function $s(e){let n=process.env.BROODS_DECLINED_FILE;if(!n||e.length===0)return;await V(n,`${e.join(`
385
385
  `)}
@@ -387,7 +387,7 @@ ${L("stage")}`);let i=h(),a=b(e,"--dashboard-url")??i.dashboardUrl??J,c=Ge(e),d=
387
387
 
388
388
  ${L("env")}`);if(a&&!t)throw Error(`broods env ${n} needs a variable name.
389
389
 
390
- ${L("env")}`);let{manifest:c,config:d}=await ee({project:b(e,"--project"),stage:b(e,"--stage"),command:"dev"}),l=await G(b(e,"--base-url")??d.baseUrl),u=new D({baseUrl:l.baseUrl,token:l.token}),p=`${c.project}/${c.stage}`;if(i){await Rs(u,c,p);return}if(o){let y=await u.listEnv(c.project,c.stage);if(y.length===0){console.log(`No environment variables set for ${p}.`);return}console.log(`Environment variables for ${p} (values hidden):`);for(let k of y)console.log(` ${k.name}`);return}if(s){let y=await u.getEnv(c.project,c.stage,t);if(y===null){console.error(`${t} is not set for ${p}`),process.exitCode=1;return}console.log(y);return}if(r){await u.removeEnv(c.project,c.stage,t),console.log(`Removed ${t} from ${p}`);return}let m=await rt(t);await u.setEnv(c.project,c.stage,t,m),console.log(`Stored ${t} for ${p}`)}async function Rs(e,n,t){let o=await hn(e,n);if(o.length===0){console.log('No env("NAME") references in this project.');return}let r=await xt(e,n,o);if(r.length>0)tn(r);let s=Ee(o,"synced").length;console.log(r.length>0?`${s} other referenced variable(s) already in step with ${t}.`:`${s} referenced variable(s) already in step with ${t}.`);let i=Ee(o,"stage-only");if(i.length>0)console.log(`${i.length} referenced variable(s) live only on ${t}: ${i.join(", ")}`);let a=Ee(o,"unresolved");if(a.length>0)x(`⚠ ${a.length} referenced variable(s) with no value here or on ${t}: ${a.join(", ")}. Put them in .env.local, or run \`broods env set <NAME>\`.`)}function We(){h();let e=process.env.BROODS_API_KEY??"";if(!e)throw Error("BROODS_API_KEY is not set. Run `broods deploy` first, or set the key in .env.local.");let n=process.env.BROODS_BASE_URL??process.env.BROODS_HOST??z;return{apiKey:e,baseUrl:n}}function bn(e){if(P(e,"--all"))return"DEBUG";let n=b(e,"--level");if(n===void 0&&P(e,"--level"))throw Error("Missing value for --level. Use DEBUG, INFO, WARN, or ERROR.");if(!n)return"WARN";let t=n.toUpperCase();if(t==="DEBUG")return"DEBUG";if(t==="INFO")return"INFO";if(t==="WARN"||t==="WARNING")return"WARN";if(t==="ERROR")return"ERROR";throw Error(`Unknown log level: ${n}. Use DEBUG, INFO, WARN, or ERROR.`)}async function Cs(e){h();let n=b(e,"--project")??process.env.BROODS_PROJECT,t=b(e,"--stage")??_();if(!n)throw Error("Project name is required. Pass --project <name> or set BROODS_PROJECT in .env.local.");if(!t)throw Error("Stage name is required. Pass --stage <name> or set BROODS_STAGE in .env.local.");return{project:n,stage:t}}async function wn(e,n){let t=await Cs(e),o=await nt(n.baseUrl,n.apiKey);if(!o)return t;if(o.projectSlug!==t.project||o.stageSlug!==t.stage)console.log(`· reading ${o.projectSlug}/${o.stageSlug}. The runtime key is scoped there, not to ${t.project}/${t.stage}.`);return{project:o.projectSlug,stage:o.stageSlug}}function jt(e){return e==="WARN"?" (--all for INFO too)":""}function yn(e){let n=new Date(e.ts).toISOString().slice(11,23),t=e.level.padEnd(5),o=Fr(e.message);return`${n} ${t} ${e.eventType} ${o}`}async function As(e){let{apiKey:n,baseUrl:t}=We(),{project:o,stage:r}=await wn(e,{baseUrl:t,apiKey:n}),s=bn(e),i=new AbortController,a=()=>i.abort();process.on("SIGINT",a),console.log(`Streaming live logs for ${o}/${r} [${s}+]`+jt(s)+", Ctrl+C to stop");try{for await(let c of Te({baseUrl:t,apiKey:n,project:o,stage:r},{backfill:0,minLevel:s,signal:i.signal}))console.log(yn(c))}catch(c){if(!i.signal.aborted)console.error(c instanceof Error?c.message:String(c)),process.exitCode=1}finally{process.off("SIGINT",a)}}async function xs(e){if(P(e,"--doctor")){await js(P(e,"--request"));return}let n=se(e)[0];if(!n){console.log(mn.machine),process.exitCode=1;return}let{runMachineDaemon:t}=await import("../chunk-rk1v0qm8.js"),{apiKey:o,baseUrl:r}=We(),s=A(b(e,"--cwd")??process.cwd()),i=P(e,"--computer"),a=b(e,"--mcp"),c=P(e,"--force"),d=new AbortController,l=()=>d.abort();process.on("SIGINT",l),console.log(`Connecting ${n} to ${r} (cwd ${s}${i?", computer use on":""}), Ctrl+C to stop`);try{await t({apiKey:o,baseUrl:r,computer:i,cwd:s,force:c,log:(u)=>console.log(u),mcpFile:a?A(a):void 0,sandbox:n,signal:d.signal})}catch(u){console.error(u instanceof Error?u.message:String(u)),process.exitCode=1}finally{process.off("SIGINT",l)}}async function js(e){try{let{startDesktop:n}=await import("../chunk-5tnnqapc.js"),{display:t,driver:o,permissions:r}=await n(e);o.stop();let s=(i)=>i?"granted":"missing";if(console.log(`screenshot frame ${t.width}x${t.height} (scale ${t.scale.toFixed(2)})`),console.log(`screen recording ${s(r.screenRecording)}`),console.log(`accessibility ${s(r.accessibility)}`),!r.screenRecording||!r.accessibility)console.log(e?"Approve the prompts, or add this terminal under System Settings > Privacy & Security, then run again.":"Run `broods machine --doctor --request` to show the macOS prompts."),process.exitCode=1}catch(n){console.error(n instanceof Error?n.message:String(n)),process.exitCode=1}}async function Ps(e){let{apiKey:n,baseUrl:t}=We(),{project:o,stage:r}=await wn(e,{baseUrl:t,apiKey:n}),s=b(e,"--sandbox");if(P(e,"--sandbox")&&!F(s))throw Error("--sandbox needs the instance log id, the UUID shown in the dashboard Instances sheet.");let i=s?"DEBUG":bn(e),a=Number(b(e,"--limit")??b(e,"-n")??100),c=P(e,"--json"),d=new AbortController,l=()=>d.abort();process.on("SIGINT",l),console.log(`Logs for ${o}/${r}`+(s?` sandbox ${s}`:"")+` [${i}+]`+jt(i)+` (backfill ${a}), Ctrl+C to stop`);try{for await(let u of Te({baseUrl:t,apiKey:n,project:o,stage:r},{backfill:a,minLevel:i,...s?{sandboxId:s}:{},signal:d.signal}))if(c)console.log(JSON.stringify(u));else console.log(yn(u))}catch(u){if(!d.signal.aborted)console.error(u instanceof Error?u.message:String(u)),process.exitCode=1}finally{process.off("SIGINT",l)}}async function Is(e){let[n,t]=se(e);if(!n){console.log(L("agent"));return}if(n==="list"||n==="ls"){await Ds(e);return}if(n==="get"){await _s(t,e);return}throw Error(`Unknown agent subcommand: ${n}
390
+ ${L("env")}`);let{manifest:c,config:d}=await ee({project:b(e,"--project"),stage:b(e,"--stage"),command:"dev"}),l=await G(b(e,"--base-url")??d.baseUrl),u=new D({baseUrl:l.baseUrl,token:l.token}),p=`${c.project}/${c.stage}`;if(i){await Rs(u,c,p);return}if(o){let y=await u.listEnv(c.project,c.stage);if(y.length===0){console.log(`No environment variables set for ${p}.`);return}console.log(`Environment variables for ${p} (values hidden):`);for(let k of y)console.log(` ${k.name}`);return}if(s){let y=await u.getEnv(c.project,c.stage,t);if(y===null){console.error(`${t} is not set for ${p}`),process.exitCode=1;return}console.log(y);return}if(r){await u.removeEnv(c.project,c.stage,t),console.log(`Removed ${t} from ${p}`);return}let m=await rt(t);await u.setEnv(c.project,c.stage,t,m),console.log(`Stored ${t} for ${p}`)}async function Rs(e,n,t){let o=await hn(e,n);if(o.length===0){console.log('No env("NAME") references in this project.');return}let r=await xt(e,n,o);if(r.length>0)tn(r);let s=Ee(o,"synced").length;console.log(r.length>0?`${s} other referenced variable(s) already in step with ${t}.`:`${s} referenced variable(s) already in step with ${t}.`);let i=Ee(o,"stage-only");if(i.length>0)console.log(`${i.length} referenced variable(s) live only on ${t}: ${i.join(", ")}`);let a=Ee(o,"unresolved");if(a.length>0)x(`⚠ ${a.length} referenced variable(s) with no value here or on ${t}: ${a.join(", ")}. Put them in .env.local, or run \`broods env set <NAME>\`.`)}function We(){h();let e=process.env.BROODS_API_KEY??"";if(!e)throw Error("BROODS_API_KEY is not set. Run `broods deploy` first, or set the key in .env.local.");let n=process.env.BROODS_BASE_URL??process.env.BROODS_HOST??z;return{apiKey:e,baseUrl:n}}function bn(e){if(P(e,"--all"))return"DEBUG";let n=b(e,"--level");if(n===void 0&&P(e,"--level"))throw Error("Missing value for --level. Use DEBUG, INFO, WARN, or ERROR.");if(!n)return"WARN";let t=n.toUpperCase();if(t==="DEBUG")return"DEBUG";if(t==="INFO")return"INFO";if(t==="WARN"||t==="WARNING")return"WARN";if(t==="ERROR")return"ERROR";throw Error(`Unknown log level: ${n}. Use DEBUG, INFO, WARN, or ERROR.`)}async function Cs(e){h();let n=b(e,"--project")??process.env.BROODS_PROJECT,t=b(e,"--stage")??_();if(!n)throw Error("Project name is required. Pass --project <name> or set BROODS_PROJECT in .env.local.");if(!t)throw Error("Stage name is required. Pass --stage <name> or set BROODS_STAGE in .env.local.");return{project:n,stage:t}}async function wn(e,n){let t=await Cs(e),o=await nt(n.baseUrl,n.apiKey);if(!o)return t;if(o.projectSlug!==t.project||o.stageSlug!==t.stage)console.log(`· reading ${o.projectSlug}/${o.stageSlug}. The runtime key is scoped there, not to ${t.project}/${t.stage}.`);return{project:o.projectSlug,stage:o.stageSlug}}function jt(e){return e==="WARN"?" (--all for INFO too)":""}function yn(e){let n=new Date(e.ts).toISOString().slice(11,23),t=e.level.padEnd(5),o=Fr(e.message);return`${n} ${t} ${e.eventType} ${o}`}async function As(e){let{apiKey:n,baseUrl:t}=We(),{project:o,stage:r}=await wn(e,{baseUrl:t,apiKey:n}),s=bn(e),i=new AbortController,a=()=>i.abort();process.on("SIGINT",a),console.log(`Streaming live logs for ${o}/${r} [${s}+]`+jt(s)+", Ctrl+C to stop");try{for await(let c of Te({baseUrl:t,apiKey:n,project:o,stage:r},{backfill:0,minLevel:s,signal:i.signal}))console.log(yn(c))}catch(c){if(!i.signal.aborted)console.error(c instanceof Error?c.message:String(c)),process.exitCode=1}finally{process.off("SIGINT",a)}}async function xs(e){if(P(e,"--doctor")){await js(P(e,"--request"));return}let n=se(e)[0];if(!n){console.log(mn.machine),process.exitCode=1;return}let{runMachineDaemon:t}=await import("../chunk-ccd2bc7s.js"),{apiKey:o,baseUrl:r}=We(),s=A(b(e,"--cwd")??process.cwd()),i=P(e,"--computer"),a=b(e,"--mcp"),c=P(e,"--force"),d=new AbortController,l=()=>d.abort();process.on("SIGINT",l),console.log(`Connecting ${n} to ${r} (cwd ${s}${i?", computer use on":""}), Ctrl+C to stop`);try{await t({apiKey:o,baseUrl:r,computer:i,cwd:s,force:c,log:(u)=>console.log(u),mcpFile:a?A(a):void 0,sandbox:n,signal:d.signal})}catch(u){console.error(u instanceof Error?u.message:String(u)),process.exitCode=1}finally{process.off("SIGINT",l)}}async function js(e){try{let{startDesktop:n}=await import("../chunk-5tnnqapc.js"),{display:t,driver:o,permissions:r}=await n(e);o.stop();let s=(i)=>i?"granted":"missing";if(console.log(`screenshot frame ${t.width}x${t.height} (scale ${t.scale.toFixed(2)})`),console.log(`screen recording ${s(r.screenRecording)}`),console.log(`accessibility ${s(r.accessibility)}`),!r.screenRecording||!r.accessibility)console.log(e?"Approve the prompts, or add this terminal under System Settings > Privacy & Security, then run again.":"Run `broods machine --doctor --request` to show the macOS prompts."),process.exitCode=1}catch(n){console.error(n instanceof Error?n.message:String(n)),process.exitCode=1}}async function Ps(e){let{apiKey:n,baseUrl:t}=We(),{project:o,stage:r}=await wn(e,{baseUrl:t,apiKey:n}),s=b(e,"--sandbox");if(P(e,"--sandbox")&&!F(s))throw Error("--sandbox needs the instance log id, the UUID shown in the dashboard Instances sheet.");let i=s?"DEBUG":bn(e),a=Number(b(e,"--limit")??b(e,"-n")??100),c=P(e,"--json"),d=new AbortController,l=()=>d.abort();process.on("SIGINT",l),console.log(`Logs for ${o}/${r}`+(s?` sandbox ${s}`:"")+` [${i}+]`+jt(i)+` (backfill ${a}), Ctrl+C to stop`);try{for await(let u of Te({baseUrl:t,apiKey:n,project:o,stage:r},{backfill:a,minLevel:i,...s?{sandboxId:s}:{},signal:d.signal}))if(c)console.log(JSON.stringify(u));else console.log(yn(u))}catch(u){if(!d.signal.aborted)console.error(u instanceof Error?u.message:String(u)),process.exitCode=1}finally{process.off("SIGINT",l)}}async function Is(e){let[n,t]=se(e);if(!n){console.log(L("agent"));return}if(n==="list"||n==="ls"){await Ds(e);return}if(n==="get"){await _s(t,e);return}throw Error(`Unknown agent subcommand: ${n}
391
391
 
392
392
  ${L("agent")}`)}async function Pt(e){let{manifest:n,config:t}=await ee({project:b(e,"--project"),stage:b(e,"--stage"),command:"dev"}),o=await G(b(e,"--base-url")??t.baseUrl),r=await new D({baseUrl:o.baseUrl,token:o.token}).getManifest(n.project,n.stage),s=n.resources.filter((i)=>i.kind==="agent").map((i)=>({name:i.name,config:i.config??{},agentId:r?.ids.agents[i.name]}));return{manifest:n,agents:s}}async function Ds(e){let{manifest:n,agents:t}=await Pt(e);if(t.length===0){console.log(`No agents declared in ${n.project}/${n.stage}.`);return}console.log(`Agents in ${n.project}/${n.stage}:`);for(let o of t){let r=It(o.config),s=o.config.publicAccess===!0?"public":"private",i=o.agentId?o.agentId:"not deployed";console.log(` ${o.name} [${s}] ${r} (${i})`)}}async function _s(e,n){if(!e)throw Error(`Missing agent name.
393
393
 
package/dist/index.d.ts CHANGED
@@ -117,7 +117,7 @@ declare const AGENT_LIFECYCLE_EVENT_NAMES: readonly ["agent.started", "agent.ste
117
117
  * Shared validation for MCP server registrations (#331). One normalizer
118
118
  * serves every write path (CLI sync, direct API, dashboard). A `url` makes an "http" row
119
119
  * core connects to over the stateless 2026-07-28 transport; a `bundle` makes
120
- * a "hosted" row served by the tool-runner Lambda, hashed here so sha256
120
+ * a "hosted" row served by the mcp-runner Lambda, hashed here so sha256
121
121
  * always travels with the bundle. Auth header values may carry ${NAME}
122
122
  * account env refs; they resolve into the encrypted agent config at sync
123
123
  * time, never on this row, and credential-bearing headers must use one
@@ -172,6 +172,7 @@ interface AgentConfig {
172
172
  /** Policies that gate this agent. Each one carries its own enforcement mode. */
173
173
  policies?: string[];
174
174
  publicAccess?: boolean;
175
+ allowRunOverrides?: boolean;
175
176
  [key: string]: unknown;
176
177
  }
177
178
  interface AgentBehaviorConfig {
@@ -2057,7 +2058,7 @@ interface McpDefinitionConfig {
2057
2058
  * Hosted alternative to `url`: declare the server inline as
2058
2059
  * `handler: createMcpHandler(...)` from @modelcontextprotocol/server,
2059
2060
  * right next to the `defineMcp` call. The CLI bundles the defining module
2060
- * and the tool-runner Lambda hosts it, one invoke per batch of requests.
2061
+ * and the mcp-runner Lambda hosts it, one invoke per batch of requests.
2061
2062
  */
2062
2063
  handler?: McpHandler;
2063
2064
  /**
@@ -2423,6 +2424,11 @@ type AgentDefinitionConfig = EnvRefString<Pick<AgentConfig, "agent" | "model" |
2423
2424
  * internal endpoint or a channel webhook. See issue #65.
2424
2425
  */
2425
2426
  publicAccess?: boolean;
2427
+ /**
2428
+ * Let a runtime-key caller send `system` and `model` overrides on a run. Off
2429
+ * by default: such a run is refused with `403 run_overrides_disabled`.
2430
+ */
2431
+ allowRunOverrides?: boolean;
2426
2432
  };
2427
2433
  type CronDefinitionConfig = Omit<CreateCronInput, "agentId" | "name"> & {
2428
2434
  agent: AgentResource | string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "broods",
3
- "version": "0.38.1",
3
+ "version": "0.39.1",
4
4
  "description": "CLI + TypeScript SDK for the broods agent platform.",
5
5
  "keywords": [
6
6
  "agents",
File without changes