broods 0.2.0 → 0.2.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/cli/index.js CHANGED
@@ -686,8 +686,56 @@ async function normalizeConfig(resource, projectRoot) {
686
686
  }
687
687
  return rewriteValues(resource.config);
688
688
  }
689
+ var KNOWN_PROVIDER_NAMES = ["google", "openai", "anthropic", "bedrock", "gateway", "minimax", "custom"];
690
+ var KNOWN_PROVIDER_SETTING_KEYS = new Set([
691
+ "apiKey",
692
+ "base_url",
693
+ "baseURL",
694
+ "headers",
695
+ "organization",
696
+ "project",
697
+ "name",
698
+ "region",
699
+ "accessKeyId",
700
+ "secretAccessKey",
701
+ "sessionToken"
702
+ ]);
703
+ function suggestProviderKey(key) {
704
+ const canonical = key.replace(/[^a-z0-9]/gi, "").toLowerCase();
705
+ if (canonical === "baseurl")
706
+ return `"base_url" or "baseURL"`;
707
+ if (canonical === "apikey")
708
+ return `"apiKey"`;
709
+ return "";
710
+ }
711
+ function validateProviderConfig(agentName, provider) {
712
+ if (provider === undefined || provider === null)
713
+ return;
714
+ if (typeof provider !== "object" || Array.isArray(provider)) {
715
+ throw new Error(`Agent "${agentName}" config.provider must be an object`);
716
+ }
717
+ for (const [providerName, settings] of Object.entries(provider)) {
718
+ if (!KNOWN_PROVIDER_NAMES.includes(providerName)) {
719
+ throw new Error(`Agent "${agentName}" config.provider.${providerName} is not a supported provider (expected one of: ${KNOWN_PROVIDER_NAMES.join(", ")})`);
720
+ }
721
+ if (typeof settings !== "object" || settings === null || Array.isArray(settings)) {
722
+ throw new Error(`Agent "${agentName}" config.provider.${providerName} must be an object`);
723
+ }
724
+ const record = settings;
725
+ for (const key of Object.keys(record)) {
726
+ if (KNOWN_PROVIDER_SETTING_KEYS.has(key))
727
+ continue;
728
+ const suggestion = suggestProviderKey(key);
729
+ throw new Error(`Agent "${agentName}" config.provider.${providerName} has unknown option "${key}"${suggestion ? ` \u2014 did you mean ${suggestion}?` : ""}`);
730
+ }
731
+ if (providerName === "custom" && record.base_url === undefined && record.baseURL === undefined) {
732
+ throw new Error(`Agent "${agentName}" config.provider.custom.base_url is required (use "base_url" or "baseURL")`);
733
+ }
734
+ }
735
+ }
689
736
  function normalizeAgentConfig(resource, _projectRoot) {
690
737
  const config = { ...resource.config };
738
+ validateProviderConfig(resource.name, config.provider);
691
739
  const inlineHooks = normalizeInlineAgentHooks(resource.name, config.hooks);
692
740
  if (inlineHooks) {
693
741
  config.hooks = inlineHooks.agentHooksConfig;
@@ -2547,7 +2595,7 @@ function renderStreamPart(part, state) {
2547
2595
  // package.json
2548
2596
  var package_default = {
2549
2597
  name: "broods",
2550
- version: "0.2.0",
2598
+ version: "0.2.1",
2551
2599
  description: "CLI + TypeScript SDK for the broods agent platform.",
2552
2600
  type: "module",
2553
2601
  license: "MIT",
@@ -2602,6 +2650,7 @@ var package_default = {
2602
2650
  devDependencies: {
2603
2651
  "@types/bun": "^1.3.14",
2604
2652
  rollup: "^4.53.3",
2653
+ typescript: "^6.0.3",
2605
2654
  "rollup-plugin-dts": "^6.3.0"
2606
2655
  }
2607
2656
  };
package/dist/index.d.ts CHANGED
@@ -132,8 +132,28 @@ type AgentModelOutputMetadata = {
132
132
  [key: string]: unknown;
133
133
  };
134
134
  type AgentProviderConfig = Partial<Record<AccountModelProviderName, AgentProviderSettings>>;
135
+ /**
136
+ * Constructor settings for a model provider. The keys are an explicit allow-list
137
+ * (no open index signature) so a misspelled option — most commonly the camel
138
+ * `baseUrl` instead of the canonical `base_url`/`baseURL` — is a compile-time
139
+ * error in the SDK and is caught by `normalizeProviderSettings` at runtime.
140
+ * Keep this list in sync with `normalizeProviderSettings` and the SDK's
141
+ * `KNOWN_PROVIDER_SETTING_KEYS`.
142
+ */
135
143
  interface AgentProviderSettings {
136
- [key: string]: unknown;
144
+ apiKey?: string;
145
+ /** OpenAI-compatible endpoint (`custom`). Snake form, as documented. */
146
+ base_url?: string;
147
+ /** OpenAI-compatible endpoint (`custom`). AI-SDK form; the dashboard writes both. */
148
+ baseURL?: string;
149
+ headers?: Record<string, string>;
150
+ organization?: string;
151
+ project?: string;
152
+ name?: string;
153
+ region?: string;
154
+ accessKeyId?: string;
155
+ secretAccessKey?: string;
156
+ sessionToken?: string;
137
157
  }
138
158
  interface AgentWorkspaceRef {
139
159
  name: string;
@@ -1272,7 +1292,33 @@ type AgentPolicyDefinitionConfig = Omit<AgentPolicyConfig, "policyIds"> & {
1272
1292
  * `workspace:` instead of `workspaces:`. Add a key here when core's `AgentConfig`
1273
1293
  * gains a new top-level field that should be code-definable.
1274
1294
  */
1275
- type AgentDefinitionConfig = EnvRefString<Pick<AgentConfig, "agent" | "model" | "provider" | "session" | "tools">> & {
1295
+ /**
1296
+ * SDK-facing model-provider constructor settings. Written as an explicit
1297
+ * interface — NOT `EnvRefString<AgentProviderSettings>` — because TypeScript
1298
+ * suppresses excess-property checks through mapped types, which would let a
1299
+ * typo like the camel `baseUrl` (instead of `base_url`/`baseURL`) slip past
1300
+ * `tsc`. Keep the keys in lockstep with core's `AgentProviderSettings`; the
1301
+ * `_ProviderKeyParity` assertion below fails `broods check` if they drift.
1302
+ * Every string field also accepts an `env(...)` reference.
1303
+ */
1304
+ interface ProviderSettingsInput {
1305
+ apiKey?: string | EnvRef;
1306
+ base_url?: string | EnvRef;
1307
+ baseURL?: string | EnvRef;
1308
+ headers?: Record<string, string | EnvRef>;
1309
+ organization?: string | EnvRef;
1310
+ project?: string | EnvRef;
1311
+ name?: string | EnvRef;
1312
+ region?: string | EnvRef;
1313
+ accessKeyId?: string | EnvRef;
1314
+ secretAccessKey?: string | EnvRef;
1315
+ sessionToken?: string | EnvRef;
1316
+ }
1317
+ /** Per-provider settings; provider names stay synced with core's `AgentConfig`. */
1318
+ type ProviderConfigInput = Partial<Record<keyof NonNullable<AgentConfig["provider"]>, ProviderSettingsInput>>;
1319
+ type AgentDefinitionConfig = EnvRefString<Pick<AgentConfig, "agent" | "model" | "session" | "tools">> & {
1320
+ provider?: ProviderConfigInput;
1321
+ } & {
1276
1322
  hooks?: AgentHooks & {
1277
1323
  webhooks?: readonly EnvRefString<AgentWebhookHookConfig>[];
1278
1324
  };
@@ -1334,4 +1380,4 @@ declare function isChannelDefinition(value: unknown): value is AnyChannelDefinit
1334
1380
  declare function isBroodsConfig(value: unknown): value is BroodsConfigDefinition;
1335
1381
 
1336
1382
  export { BroodsClient, BroodsWebSocketClient, DEFAULT_CORE_BASE_URL, MAX_OBSERVABILITY_BACKFILL, BroodsWebSocketClient as WebSocketClient, BroodsWebSocketClient as WebsocketClient, defineAgent, defineBroods, defineCron, defineDiscordChannel, defineGitHubChannel, definePancakeChannel, definePolicy, defineSandbox, defineSkill, defineSlackChannel, defineTelegramChannel, defineTool, defineWorkspace, defineZaloChannel, env, isBroodsConfig, isChannelDefinition, isObservabilityClientMessage, isResource, normalizeHttpServiceUrl, readSseStream, resolveRunEvents, toWebSocketBaseUrl };
1337
- export type { Account, Agent, AgentChannelWorkspaceScope, AgentChannelsConfig, AgentCodeHookConfig, AgentConfig, AgentConfigDoc, AgentDefinitionConfig, AgentDiscordChannelConfig, AgentGitHubChannelConfig, AgentHandle, AgentHookEventName, AgentHooks, AgentHooksConfig, AgentPancakeChannelConfig, AgentPolicyConfig, AgentPolicyDefinitionConfig, AgentPolicyDocument, AgentReference, AgentResource, AgentRunEventInput, AgentRunInput, AgentRunModelOverrides, AgentRunOverrides, AgentRunResult, AgentSkillsDefinitionConfig, AgentSlackChannelConfig, AgentStreamPart, AgentSubagentDefinitionConfig, AgentTelegramChannelConfig, AgentWebhookHookConfig, AgentWorkspaceInput, AgentWorkspaceRef, AgentWorkspaceRefInput, AgentZaloChannelConfig, AnyChannelDefinition, AnyResource, AsyncAgentRun, AsyncPollOptions, AsyncRequestAccepted, AsyncStatus, BroodsClientOptions, BroodsConfigDefinition, BroodsProjectConfig, BroodsWebSocketClientOptions, ChannelDefinition, ChannelMessageReceived, ChannelReference, ChannelType, CliManifest, CliManifestResource, CliResourceKind, CreateClientCronInput, CreateCronInput, Cron, CronDefinitionConfig, CronDoc, CronLastStatus, CronResource, CronRun, CronStatus, CustomTool, DiscordChannelDefinition, DiscordChannelInput, DiscordMessageSource, DiscordSource, Doc, EnvAccessor, EnvRef, EnvRefString, EnvironmentDoc, GeneratedIds, GitHubChannelDefinition, GitHubChannelInput, GitHubMessageSource, GitHubSource, HookContext, Id, LogLevel, ObservabilityBackfillMessage, ObservabilityClientMessage, ObservabilityErrorMessage, ObservabilityLogEntry, ObservabilityLogMessage, ObservabilityReadyMessage, ObservabilityServerMessage, ObservabilitySpanMessage, ObservabilitySpanRow, ObservabilitySubscribeMessage, ObservabilityUnsubscribeMessage, PancakeChannelDefinition, PancakeChannelInput, PancakeMessageSource, PancakeSource, PolicyDefinitionConfig, PolicyResource, ProjectDoc, ResourceApi, ResourceDefinition, ResourceDefinitionInput, ResourceKind, Sandbox, SandboxConfig, SandboxConfigDoc, SandboxDefinitionConfig, SandboxResource, Skill, SkillDefinitionConfig, SkillResource, SlackChannelDefinition, SlackChannelInput, SlackMessageSource, SlackSource, TelegramChannelDefinition, TelegramChannelInput, TelegramMessageSource, TelegramSource, ToolApprovalSummary, ToolDefinitionConfig, ToolResource, UpdateCronInput, WebSocketClientCancelMessage, WebSocketClientExecuteMessage, WebSocketClientMessage, WebSocketConstructorLike, WebSocketHandlers, WebSocketLike, WebSocketRunInput, WebSocketServerMessage, WebSocketStreamMessage, WebSocketSubscription, Workspace, WorkspaceConfig, WorkspaceConfigDoc, WorkspaceResource, ZaloChannelDefinition, ZaloChannelInput, ZaloMessageSource, ZaloSource };
1383
+ export type { Account, Agent, AgentChannelWorkspaceScope, AgentChannelsConfig, AgentCodeHookConfig, AgentConfig, AgentConfigDoc, AgentDefinitionConfig, AgentDiscordChannelConfig, AgentGitHubChannelConfig, AgentHandle, AgentHookEventName, AgentHooks, AgentHooksConfig, AgentPancakeChannelConfig, AgentPolicyConfig, AgentPolicyDefinitionConfig, AgentPolicyDocument, AgentProviderSettings, AgentReference, AgentResource, AgentRunEventInput, AgentRunInput, AgentRunModelOverrides, AgentRunOverrides, AgentRunResult, AgentSkillsDefinitionConfig, AgentSlackChannelConfig, AgentStreamPart, AgentSubagentDefinitionConfig, AgentTelegramChannelConfig, AgentWebhookHookConfig, AgentWorkspaceInput, AgentWorkspaceRef, AgentWorkspaceRefInput, AgentZaloChannelConfig, AnyChannelDefinition, AnyResource, AsyncAgentRun, AsyncPollOptions, AsyncRequestAccepted, AsyncStatus, BroodsClientOptions, BroodsConfigDefinition, BroodsProjectConfig, BroodsWebSocketClientOptions, ChannelDefinition, ChannelMessageReceived, ChannelReference, ChannelType, CliManifest, CliManifestResource, CliResourceKind, CreateClientCronInput, CreateCronInput, Cron, CronDefinitionConfig, CronDoc, CronLastStatus, CronResource, CronRun, CronStatus, CustomTool, DiscordChannelDefinition, DiscordChannelInput, DiscordMessageSource, DiscordSource, Doc, EnvAccessor, EnvRef, EnvRefString, EnvironmentDoc, GeneratedIds, GitHubChannelDefinition, GitHubChannelInput, GitHubMessageSource, GitHubSource, HookContext, Id, LogLevel, ObservabilityBackfillMessage, ObservabilityClientMessage, ObservabilityErrorMessage, ObservabilityLogEntry, ObservabilityLogMessage, ObservabilityReadyMessage, ObservabilityServerMessage, ObservabilitySpanMessage, ObservabilitySpanRow, ObservabilitySubscribeMessage, ObservabilityUnsubscribeMessage, PancakeChannelDefinition, PancakeChannelInput, PancakeMessageSource, PancakeSource, PolicyDefinitionConfig, PolicyResource, ProjectDoc, ProviderConfigInput, ProviderSettingsInput, ResourceApi, ResourceDefinition, ResourceDefinitionInput, ResourceKind, Sandbox, SandboxConfig, SandboxConfigDoc, SandboxDefinitionConfig, SandboxResource, Skill, SkillDefinitionConfig, SkillResource, SlackChannelDefinition, SlackChannelInput, SlackMessageSource, SlackSource, TelegramChannelDefinition, TelegramChannelInput, TelegramMessageSource, TelegramSource, ToolApprovalSummary, ToolDefinitionConfig, ToolResource, UpdateCronInput, WebSocketClientCancelMessage, WebSocketClientExecuteMessage, WebSocketClientMessage, WebSocketConstructorLike, WebSocketHandlers, WebSocketLike, WebSocketRunInput, WebSocketServerMessage, WebSocketStreamMessage, WebSocketSubscription, Workspace, WorkspaceConfig, WorkspaceConfigDoc, WorkspaceResource, ZaloChannelDefinition, ZaloChannelInput, ZaloMessageSource, ZaloSource };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "broods",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "CLI + TypeScript SDK for the broods agent platform.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -55,6 +55,7 @@
55
55
  "devDependencies": {
56
56
  "@types/bun": "^1.3.14",
57
57
  "rollup": "^4.53.3",
58
+ "typescript": "^6.0.3",
58
59
  "rollup-plugin-dts": "^6.3.0"
59
60
  }
60
61
  }