broods 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -5
- package/dist/account.d.ts +61 -53
- package/dist/account.js +1 -271
- package/dist/chunk-18hxt2an.js +5 -0
- package/dist/chunk-1rk247mz.js +1 -0
- package/dist/chunk-3a8wdnav.js +1 -0
- package/dist/chunk-9qtppg6j.js +2 -0
- package/dist/chunk-m6935tq1.js +2 -0
- package/dist/chunk-xv4t40dh.js +2 -0
- package/dist/cli/index.js +186 -3636
- package/dist/index.d.ts +222 -80
- package/dist/index.js +1 -1129
- package/package.json +10 -8
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import { SystemModelMessage, LanguageModelCallOptions, RequestOptions, streamText, JSONSchema7, ModelMessage, TextStreamPart, ToolSet } from 'ai';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Supported account model provider names.
|
|
5
|
+
* Keep provider identifiers here so config validation and model resolution share one source.
|
|
6
|
+
*/
|
|
7
|
+
declare const ACCOUNT_MODEL_PROVIDERS: {
|
|
8
|
+
readonly google: true;
|
|
9
|
+
readonly openai: true;
|
|
10
|
+
readonly anthropic: true;
|
|
11
|
+
readonly bedrock: true;
|
|
12
|
+
readonly gateway: true;
|
|
13
|
+
readonly minimax: true;
|
|
14
|
+
readonly custom: true;
|
|
15
|
+
};
|
|
16
|
+
type AccountModelProviderName = keyof typeof ACCOUNT_MODEL_PROVIDERS;
|
|
6
17
|
|
|
7
18
|
/**
|
|
8
19
|
* Agent policy contracts and validation.
|
|
@@ -43,21 +54,6 @@ interface AgentPolicyConfig {
|
|
|
43
54
|
mode?: AgentPolicyMode;
|
|
44
55
|
}
|
|
45
56
|
|
|
46
|
-
/**
|
|
47
|
-
* Supported account model provider names.
|
|
48
|
-
* Keep provider identifiers here so config validation and model resolution share one source.
|
|
49
|
-
*/
|
|
50
|
-
declare const ACCOUNT_MODEL_PROVIDERS: {
|
|
51
|
-
readonly google: true;
|
|
52
|
-
readonly openai: true;
|
|
53
|
-
readonly anthropic: true;
|
|
54
|
-
readonly bedrock: true;
|
|
55
|
-
readonly gateway: true;
|
|
56
|
-
readonly minimax: true;
|
|
57
|
-
readonly custom: true;
|
|
58
|
-
};
|
|
59
|
-
type AccountModelProviderName = keyof typeof ACCOUNT_MODEL_PROVIDERS;
|
|
60
|
-
|
|
61
57
|
/**
|
|
62
58
|
* Agent configuration: types for the per-agent settings object, input
|
|
63
59
|
* normalization, encryption helpers, patch-merge, and redaction.
|
|
@@ -97,6 +93,11 @@ interface AgentSubagentConfig {
|
|
|
97
93
|
allowed?: string[];
|
|
98
94
|
context?: "new" | "inherited";
|
|
99
95
|
mode?: "ephemeral" | "persistent";
|
|
96
|
+
/**
|
|
97
|
+
* Publishes child reasoning, text, and tool stream parts to the existing
|
|
98
|
+
* WebSocket/JetStream response path. Off by default.
|
|
99
|
+
*/
|
|
100
|
+
stream?: boolean;
|
|
100
101
|
/**
|
|
101
102
|
* Controls what the parent agent sees from a finished subagent (AI SDK
|
|
102
103
|
* "controlling what the model sees"): `full` = the child's whole transcript,
|
|
@@ -232,9 +233,9 @@ type AgentChannelWorkspaceScope = {
|
|
|
232
233
|
};
|
|
233
234
|
interface AgentTelegramChannelConfig {
|
|
234
235
|
id?: string;
|
|
235
|
-
apiUrl?:
|
|
236
|
-
botToken?:
|
|
237
|
-
webhookSecret?:
|
|
236
|
+
apiUrl?: string;
|
|
237
|
+
botToken?: string;
|
|
238
|
+
webhookSecret?: string;
|
|
238
239
|
allowedChatIds?: number[];
|
|
239
240
|
reactionEmoji?: string;
|
|
240
241
|
workspaceScope?: AgentChannelWorkspaceScope;
|
|
@@ -242,18 +243,10 @@ interface AgentTelegramChannelConfig {
|
|
|
242
243
|
}
|
|
243
244
|
interface AgentGitHubChannelConfig {
|
|
244
245
|
id?: string;
|
|
245
|
-
apiUrl?:
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
appId: string;
|
|
250
|
-
}>["webhookSecret"];
|
|
251
|
-
appId?: Extract<GitHubAdapterConfig, {
|
|
252
|
-
appId: string;
|
|
253
|
-
}>["appId"];
|
|
254
|
-
privateKey?: Extract<GitHubAdapterConfig, {
|
|
255
|
-
appId: string;
|
|
256
|
-
}>["privateKey"];
|
|
246
|
+
apiUrl?: string;
|
|
247
|
+
webhookSecret?: string;
|
|
248
|
+
appId?: string;
|
|
249
|
+
privateKey?: string;
|
|
257
250
|
allowedRepos?: string[];
|
|
258
251
|
/** Bot username for @-mention detection (e.g. "my-bot" or "my-bot[bot]"). */
|
|
259
252
|
userName?: string;
|
|
@@ -268,9 +261,9 @@ interface AgentGitHubChannelConfig {
|
|
|
268
261
|
}
|
|
269
262
|
interface AgentSlackChannelConfig {
|
|
270
263
|
id?: string;
|
|
271
|
-
apiUrl?:
|
|
264
|
+
apiUrl?: string;
|
|
272
265
|
botToken?: string;
|
|
273
|
-
signingSecret?:
|
|
266
|
+
signingSecret?: string;
|
|
274
267
|
allowedChannelIds?: string[];
|
|
275
268
|
reactionEmoji?: string;
|
|
276
269
|
workspaceScope?: AgentChannelWorkspaceScope;
|
|
@@ -278,9 +271,9 @@ interface AgentSlackChannelConfig {
|
|
|
278
271
|
}
|
|
279
272
|
interface AgentDiscordChannelConfig {
|
|
280
273
|
id?: string;
|
|
281
|
-
apiUrl?:
|
|
282
|
-
botToken?:
|
|
283
|
-
publicKey?:
|
|
274
|
+
apiUrl?: string;
|
|
275
|
+
botToken?: string;
|
|
276
|
+
publicKey?: string;
|
|
284
277
|
allowedGuildIds?: string[];
|
|
285
278
|
workspaceScope?: AgentChannelWorkspaceScope;
|
|
286
279
|
[key: string]: unknown;
|
|
@@ -304,10 +297,7 @@ interface AgentZaloChannelConfig {
|
|
|
304
297
|
}
|
|
305
298
|
|
|
306
299
|
/**
|
|
307
|
-
* Cron-job
|
|
308
|
-
* Provider-agnostic — both the DynamoDB and Convex stores import the
|
|
309
|
-
* normalizer at their create/update entry points so behaviour is
|
|
310
|
-
* symmetric across modes.
|
|
300
|
+
* Cron-job records, input normalization, and patch-merge helpers.
|
|
311
301
|
*/
|
|
312
302
|
|
|
313
303
|
type CronStatus = "active" | "paused";
|
|
@@ -366,9 +356,8 @@ type SandboxSize = "tiny" | "xsmall" | "small" | "medium" | "large";
|
|
|
366
356
|
/**
|
|
367
357
|
* Sandbox config: account-scoped, reusable sandbox definitions referenced by
|
|
368
358
|
* agents via `config.sandbox`. A sandbox is a collection of Claude-Code-style
|
|
369
|
-
* tools (bash/read/write/edit/glob/grep) backed by a provider. Validation
|
|
370
|
-
* the public projection live here
|
|
371
|
-
* DynamoDB / Convex stores call these at their create/update entry points.
|
|
359
|
+
* tools (bash/read/write/edit/glob/grep) backed by a provider. Validation and
|
|
360
|
+
* the public projection live here.
|
|
372
361
|
* Stored encrypted at rest because `envVars`/`options` may hold secrets.
|
|
373
362
|
*/
|
|
374
363
|
|
|
@@ -408,8 +397,8 @@ interface SandboxConfig {
|
|
|
408
397
|
* agents via `config.workspaces[].workspaceId`. A workspace is the persistent
|
|
409
398
|
* S3-backed filesystem mounted into a sandbox; agents referencing the same
|
|
410
399
|
* workspaceId share the same files. Holds no secrets, so it is stored in
|
|
411
|
-
* plaintext (unlike sandbox config). Validation
|
|
412
|
-
* here
|
|
400
|
+
* plaintext (unlike sandbox config). Validation and the public projection live
|
|
401
|
+
* here.
|
|
413
402
|
*/
|
|
414
403
|
declare const WORKSPACE_STORAGE_PROVIDERS: readonly ["s3"];
|
|
415
404
|
type WorkspaceStorageProvider = (typeof WORKSPACE_STORAGE_PROVIDERS)[number];
|
|
@@ -428,12 +417,18 @@ interface WorkspaceStorageConfig {
|
|
|
428
417
|
prefix?: string;
|
|
429
418
|
auth?: WorkspaceStorageAuth;
|
|
430
419
|
}
|
|
420
|
+
interface WorkspaceHarnessConfig {
|
|
421
|
+
workspace?: {
|
|
422
|
+
enabled?: boolean;
|
|
423
|
+
};
|
|
424
|
+
memory?: {
|
|
425
|
+
enabled?: boolean;
|
|
426
|
+
};
|
|
427
|
+
}
|
|
431
428
|
interface WorkspaceConfig {
|
|
432
429
|
storage: WorkspaceStorageConfig;
|
|
433
430
|
isolation?: boolean;
|
|
434
|
-
harness?:
|
|
435
|
-
enabled?: boolean;
|
|
436
|
-
};
|
|
431
|
+
harness?: WorkspaceHarnessConfig;
|
|
437
432
|
}
|
|
438
433
|
|
|
439
434
|
/**
|
|
@@ -565,7 +560,7 @@ type CliManifest = {
|
|
|
565
560
|
};
|
|
566
561
|
|
|
567
562
|
/**
|
|
568
|
-
* Type contracts inherited from Convex and core
|
|
563
|
+
* Type contracts inherited from Convex and core domain/runtime modules.
|
|
569
564
|
* Keep this file type-only so the public SDK does not bundle backend code.
|
|
570
565
|
*/
|
|
571
566
|
|
|
@@ -619,9 +614,15 @@ interface ToolApprovalSummary {
|
|
|
619
614
|
input: unknown;
|
|
620
615
|
}
|
|
621
616
|
interface AsyncStatus {
|
|
622
|
-
status: "processing" | "awaiting_approval" | "completed" | "failed" | "not_found";
|
|
617
|
+
status: "accepted" | "queued" | "applied" | "processing" | "awaiting_approval" | "completed" | "failed" | "expired" | "not_found";
|
|
618
|
+
requestedMode?: "reject" | "followup" | "collect" | "steer";
|
|
619
|
+
appliedMode?: "reject" | "followup" | "collect" | "steer";
|
|
620
|
+
appliedToEventId?: string;
|
|
621
|
+
result?: unknown;
|
|
623
622
|
response?: unknown;
|
|
624
623
|
error?: string;
|
|
624
|
+
/** True when `failed` was a deliberate /stop, not a fault. */
|
|
625
|
+
stoppedByUser?: boolean;
|
|
625
626
|
approvals?: ToolApprovalSummary[];
|
|
626
627
|
}
|
|
627
628
|
interface AsyncRequestAccepted {
|
|
@@ -629,6 +630,8 @@ interface AsyncRequestAccepted {
|
|
|
629
630
|
statusId: string;
|
|
630
631
|
eventId: string;
|
|
631
632
|
agentId: string;
|
|
633
|
+
status?: "accepted" | "queued" | "applied" | "processing";
|
|
634
|
+
requestedMode?: "reject" | "followup" | "collect" | "steer";
|
|
632
635
|
}
|
|
633
636
|
interface Cron {
|
|
634
637
|
accountId: string;
|
|
@@ -714,6 +717,8 @@ declare function readSseStream(body: ReadableStream<Uint8Array>): AsyncGenerator
|
|
|
714
717
|
* Shared WebSocket wire message contracts used by the SDK client and gateway.
|
|
715
718
|
*/
|
|
716
719
|
|
|
720
|
+
type IngressMode = "reject" | "followup" | "collect" | "steer";
|
|
721
|
+
type IngressStatus = "accepted" | "queued" | "applied" | "processing" | "awaiting_approval" | "completed" | "failed" | "expired";
|
|
717
722
|
type WebSocketStreamMessage = AgentStreamPart | {
|
|
718
723
|
type: string;
|
|
719
724
|
[key: string]: unknown;
|
|
@@ -722,17 +727,78 @@ type WebSocketServerMessage = {
|
|
|
722
727
|
type: "meta";
|
|
723
728
|
sessionId: string;
|
|
724
729
|
taskId: string;
|
|
725
|
-
} |
|
|
730
|
+
} | {
|
|
731
|
+
type: "ack";
|
|
732
|
+
requestId: string;
|
|
733
|
+
eventId: string;
|
|
734
|
+
status: IngressStatus;
|
|
735
|
+
statusUrl?: string;
|
|
736
|
+
} | {
|
|
737
|
+
type: "status";
|
|
738
|
+
requestId: string;
|
|
739
|
+
eventId: string;
|
|
740
|
+
status: IngressStatus | "not_found";
|
|
741
|
+
requestedMode?: IngressMode;
|
|
742
|
+
appliedMode?: IngressMode;
|
|
743
|
+
appliedToEventId?: string;
|
|
744
|
+
statusUrl?: string;
|
|
745
|
+
error?: string;
|
|
746
|
+
} | {
|
|
747
|
+
type: "attached";
|
|
748
|
+
requestId: string;
|
|
749
|
+
eventId: string;
|
|
750
|
+
status: IngressStatus;
|
|
751
|
+
replayFromCursor?: string;
|
|
752
|
+
replayThroughCursor?: string;
|
|
753
|
+
statusUrl?: string;
|
|
754
|
+
} | {
|
|
755
|
+
type: "replay_unavailable";
|
|
756
|
+
requestId: string;
|
|
757
|
+
eventId: string;
|
|
758
|
+
status: IngressStatus | "not_found";
|
|
759
|
+
statusUrl?: string;
|
|
760
|
+
} | WebSocketOutputMessage | WebSocketStreamMessage;
|
|
761
|
+
/**
|
|
762
|
+
* Durable-stream envelope around one stream part. The SDK unwraps `data` for
|
|
763
|
+
* handlers and surfaces the envelope itself through `onOutput` so clients can
|
|
764
|
+
* persist `cursor` for attach-based resume.
|
|
765
|
+
*/
|
|
766
|
+
type WebSocketOutputMessage = {
|
|
767
|
+
type: "output";
|
|
768
|
+
eventId: string;
|
|
769
|
+
cursor: string;
|
|
770
|
+
replay: boolean;
|
|
771
|
+
data: WebSocketStreamMessage;
|
|
772
|
+
};
|
|
726
773
|
type WebSocketClientExecuteMessage = {
|
|
727
774
|
type: "execute";
|
|
728
775
|
agentId: string;
|
|
729
776
|
sessionId?: string;
|
|
730
777
|
eventId?: string;
|
|
778
|
+
/** Defaults to "steer": join the live run at its next step boundary. */
|
|
779
|
+
mode?: IngressMode;
|
|
780
|
+
idempotencyKey?: string;
|
|
731
781
|
} & AgentRunEventInput & AgentRunOverrides;
|
|
782
|
+
type WebSocketClientControlMessage = {
|
|
783
|
+
type: "control";
|
|
784
|
+
requestId: string;
|
|
785
|
+
eventId: string;
|
|
786
|
+
idempotencyKey?: string;
|
|
787
|
+
/** Defaults to "steer": join the live run at its next step boundary. */
|
|
788
|
+
mode?: IngressMode;
|
|
789
|
+
} & AgentRunEventInput;
|
|
790
|
+
type WebSocketClientAttachMessage = {
|
|
791
|
+
type: "attach";
|
|
792
|
+
requestId: string;
|
|
793
|
+
agentId: string;
|
|
794
|
+
conversationKey: string;
|
|
795
|
+
eventId: string;
|
|
796
|
+
afterCursor?: string;
|
|
797
|
+
};
|
|
732
798
|
type WebSocketClientCancelMessage = {
|
|
733
799
|
type: "cancel";
|
|
734
800
|
};
|
|
735
|
-
type WebSocketClientMessage = WebSocketClientExecuteMessage | WebSocketClientCancelMessage;
|
|
801
|
+
type WebSocketClientMessage = WebSocketClientExecuteMessage | WebSocketClientControlMessage | WebSocketClientAttachMessage | WebSocketClientCancelMessage;
|
|
736
802
|
|
|
737
803
|
/**
|
|
738
804
|
* Shared WebSocket wire-protocol types for the observability gateway, used by
|
|
@@ -821,12 +887,20 @@ declare const DEFAULT_CORE_BASE_URL = "https://gateway.broods.app";
|
|
|
821
887
|
type AgentRunInputBase = {
|
|
822
888
|
conversationKey?: string;
|
|
823
889
|
eventId?: string;
|
|
890
|
+
/** Busy-conversation behavior. Defaults to `steer`: join the live run at its next step boundary (falls back to a FIFO follow-up). */
|
|
891
|
+
mode?: "reject" | "followup" | "collect" | "steer";
|
|
892
|
+
/** Stable retry identity within the conversation; defaults to eventId. */
|
|
893
|
+
idempotencyKey?: string;
|
|
824
894
|
} & AgentRunOverrides;
|
|
825
895
|
type AgentRunInput = AgentRunInputBase & AgentRunEventInput;
|
|
826
896
|
interface AgentRunResult {
|
|
827
897
|
text: string;
|
|
828
898
|
events: TextStreamPart<ToolSet>[];
|
|
829
899
|
}
|
|
900
|
+
declare class IngressAcceptedError extends Error {
|
|
901
|
+
readonly accepted: AsyncRequestAccepted;
|
|
902
|
+
constructor(accepted: AsyncRequestAccepted);
|
|
903
|
+
}
|
|
830
904
|
interface AsyncPollOptions {
|
|
831
905
|
intervalMs?: number;
|
|
832
906
|
timeoutMs?: number;
|
|
@@ -1002,6 +1076,13 @@ interface CreateAgentResult {
|
|
|
1002
1076
|
name: string;
|
|
1003
1077
|
description?: string;
|
|
1004
1078
|
}
|
|
1079
|
+
/** Write-only account environment variable metadata. */
|
|
1080
|
+
interface AccountEnvVar {
|
|
1081
|
+
name: string;
|
|
1082
|
+
updatedAt: number;
|
|
1083
|
+
}
|
|
1084
|
+
/** Build a validated account env-var reference for use in an agent config. */
|
|
1085
|
+
declare function envPlaceholder(name: string): string;
|
|
1005
1086
|
/** Fields accepted by `PATCH /v1/agents/{id}`. `config` is deep-merged; `null` values delete keys. */
|
|
1006
1087
|
interface UpdateAgentInput {
|
|
1007
1088
|
name?: string;
|
|
@@ -1169,6 +1250,12 @@ declare class BroodsAccountClient {
|
|
|
1169
1250
|
/** PATCH an agent. `config` deep-merges into the stored config; `null` leaves delete keys. Returns null when the agent is gone. */
|
|
1170
1251
|
updateAgent(agentId: string, patch: UpdateAgentInput): Promise<AccountAgent | null>;
|
|
1171
1252
|
deleteAgent(agentId: string): Promise<boolean>;
|
|
1253
|
+
/** List account environment variable names and update timestamps; values are never returned. */
|
|
1254
|
+
listEnvVars(): Promise<AccountEnvVar[]>;
|
|
1255
|
+
/** Create or replace one write-only account environment variable. */
|
|
1256
|
+
setEnvVar(name: string, value: string): Promise<void>;
|
|
1257
|
+
/** Delete one account environment variable. Returns false when it is already absent. */
|
|
1258
|
+
deleteEnvVar(name: string): Promise<boolean>;
|
|
1172
1259
|
listCrons(): Promise<Cron[]>;
|
|
1173
1260
|
createCron(input: CreateCronInput): Promise<Cron>;
|
|
1174
1261
|
getCron(cronId: string): Promise<Cron | null>;
|
|
@@ -1277,9 +1364,26 @@ type WebSocketRunInput = {
|
|
|
1277
1364
|
projectSlug?: string;
|
|
1278
1365
|
environmentSlug?: string;
|
|
1279
1366
|
signal?: AbortSignal;
|
|
1367
|
+
/** Defaults to "steer": join the live run at its next step boundary. */
|
|
1368
|
+
mode?: "reject" | "followup" | "collect" | "steer";
|
|
1369
|
+
idempotencyKey?: string;
|
|
1280
1370
|
} & AgentRunEventInput & AgentRunOverrides;
|
|
1371
|
+
type WebSocketAttachInput = Omit<WebSocketClientAttachMessage, "type"> & {
|
|
1372
|
+
endpointId?: string;
|
|
1373
|
+
agent?: AgentReference;
|
|
1374
|
+
projectSlug?: string;
|
|
1375
|
+
environmentSlug?: string;
|
|
1376
|
+
signal?: AbortSignal;
|
|
1377
|
+
};
|
|
1281
1378
|
interface WebSocketHandlers {
|
|
1379
|
+
/**
|
|
1380
|
+
* Receives every server message with durable output envelopes unwrapped:
|
|
1381
|
+
* stream parts arrive as themselves (`message.type === "text-delta"`), never
|
|
1382
|
+
* nested under `data`. Use `onOutput` when the envelope cursor is needed.
|
|
1383
|
+
*/
|
|
1282
1384
|
onMessage?(message: WebSocketServerMessage): void;
|
|
1385
|
+
/** Receives the raw durable output envelope (cursor, replay flag, part). */
|
|
1386
|
+
onOutput?(output: WebSocketOutputMessage): void;
|
|
1283
1387
|
onMeta?(meta: Extract<WebSocketServerMessage, {
|
|
1284
1388
|
type: "meta";
|
|
1285
1389
|
}>): void;
|
|
@@ -1288,6 +1392,7 @@ interface WebSocketHandlers {
|
|
|
1288
1392
|
}
|
|
1289
1393
|
interface WebSocketSubscription {
|
|
1290
1394
|
readonly url: string;
|
|
1395
|
+
sendControl(message: Omit<WebSocketClientControlMessage, "type">): void;
|
|
1291
1396
|
close(code?: number, reason?: string): void;
|
|
1292
1397
|
}
|
|
1293
1398
|
interface BroodsWebSocketClientOptions {
|
|
@@ -1324,6 +1429,8 @@ declare class BroodsWebSocketClient {
|
|
|
1324
1429
|
private readonly connectTimeoutMs;
|
|
1325
1430
|
constructor(options?: BroodsWebSocketClientOptions);
|
|
1326
1431
|
subscribe(input: WebSocketRunInput, handlers?: WebSocketHandlers): WebSocketSubscription;
|
|
1432
|
+
/** Attach to a previously started event and replay from an exclusive cursor. */
|
|
1433
|
+
attach(input: WebSocketAttachInput, handlers?: WebSocketHandlers): WebSocketSubscription;
|
|
1327
1434
|
stream(input: WebSocketRunInput): AsyncGenerator<WebSocketServerMessage>;
|
|
1328
1435
|
buildUrl(input: Pick<WebSocketRunInput, "agent" | "endpointId" | "projectSlug" | "environmentSlug">): string;
|
|
1329
1436
|
private resolveWebSocket;
|
|
@@ -1347,10 +1454,9 @@ interface EnvRef<Name extends string = string> {
|
|
|
1347
1454
|
readonly __beeblastEnv: true;
|
|
1348
1455
|
readonly name: Name;
|
|
1349
1456
|
}
|
|
1350
|
-
/** Callable
|
|
1457
|
+
/** Callable accessor for {@link env}. */
|
|
1351
1458
|
interface EnvAccessor {
|
|
1352
1459
|
<const Name extends string>(name: Name): EnvRef<Name>;
|
|
1353
|
-
readonly [name: string]: EnvRef;
|
|
1354
1460
|
}
|
|
1355
1461
|
type EnvRefString<T> = T extends string ? T | EnvRef : T extends readonly (infer Item)[] ? readonly EnvRefString<Item>[] : T extends (infer Item)[] ? EnvRefString<Item>[] : T extends object ? {
|
|
1356
1462
|
[Key in keyof T]: EnvRefString<T[Key]>;
|
|
@@ -1378,14 +1484,17 @@ interface ResourceDefinition<Kind extends ResourceKind, Name extends string, Con
|
|
|
1378
1484
|
readonly description?: string;
|
|
1379
1485
|
readonly config: Config;
|
|
1380
1486
|
}
|
|
1381
|
-
|
|
1487
|
+
/**
|
|
1488
|
+
* Authoring shape for every resource helper: the resource's own `name` (plus an
|
|
1489
|
+
* optional human `description`) sits inline with that resource's config keys.
|
|
1490
|
+
*/
|
|
1491
|
+
type ResourceInput<Name extends string, Config> = {
|
|
1382
1492
|
name: Name;
|
|
1383
1493
|
description?: string;
|
|
1384
|
-
|
|
1385
|
-
}
|
|
1494
|
+
} & Config;
|
|
1386
1495
|
/**
|
|
1387
1496
|
* Code-first sandbox config surface. Mirrors core's `SandboxConfig` but lets
|
|
1388
|
-
* `envVars` values be `env
|
|
1497
|
+
* `envVars` values be `env("NAME")` references (compiled to `${NAME}` placeholders
|
|
1389
1498
|
* at sync time, exactly like provider `apiKey`). Add overrides here if more
|
|
1390
1499
|
* sandbox fields should accept env refs.
|
|
1391
1500
|
*/
|
|
@@ -1399,15 +1508,46 @@ interface SkillDefinitionConfig {
|
|
|
1399
1508
|
*/
|
|
1400
1509
|
path: string;
|
|
1401
1510
|
}
|
|
1402
|
-
|
|
1511
|
+
/** Broods-side context on `ToolExecuteOptions`, alongside the AI SDK's own fields. */
|
|
1512
|
+
interface ToolExecuteContext {
|
|
1513
|
+
/** Resolved tool config, `env("NAME")` already substituted. Where secrets arrive. */
|
|
1514
|
+
config: Record<string, unknown>;
|
|
1515
|
+
/** SSRF-guarded fetch. Also installed as the global `fetch`. */
|
|
1516
|
+
fetch: typeof fetch;
|
|
1517
|
+
/** Per-run scratchpad. Read back after hooks; empty and unused for tools. */
|
|
1518
|
+
state: Record<string, unknown>;
|
|
1519
|
+
}
|
|
1520
|
+
/** Call options an inline `execute` receives, mirroring the AI SDK's tool(). */
|
|
1521
|
+
interface ToolExecuteOptions {
|
|
1522
|
+
toolCallId?: string;
|
|
1523
|
+
context: ToolExecuteContext;
|
|
1524
|
+
abortSignal?: AbortSignal;
|
|
1525
|
+
/** Conversation so far. Truncated from the front to the newest 512 KB. */
|
|
1526
|
+
messages: ModelMessage[];
|
|
1527
|
+
experimental_context?: unknown;
|
|
1528
|
+
}
|
|
1529
|
+
interface ToolDefinitionConfig<Input = Record<string, unknown>> {
|
|
1403
1530
|
/**
|
|
1404
|
-
*
|
|
1405
|
-
*
|
|
1531
|
+
* Optional module file exporting the tool implementation, resolved from the
|
|
1532
|
+
* `broods/` project directory. Omit it and declare `execute` inline instead —
|
|
1533
|
+
* the CLI then bundles the module this tool is exported from.
|
|
1406
1534
|
*/
|
|
1407
|
-
path
|
|
1535
|
+
path?: string;
|
|
1536
|
+
/**
|
|
1537
|
+
* Runs in the isolate or the sandbox runner, not locally. Shaped like the AI
|
|
1538
|
+
* SDK's `tool({ execute })`: the input first, call options second. Annotate
|
|
1539
|
+
* the parameter to type it — `inputSchema` is JSON Schema, so it cannot be
|
|
1540
|
+
* inferred.
|
|
1541
|
+
*/
|
|
1542
|
+
execute?: (input: Input, options: ToolExecuteOptions) => unknown;
|
|
1408
1543
|
description: string;
|
|
1409
1544
|
inputSchema: Record<string, unknown>;
|
|
1410
1545
|
runtime?: "isolate" | "sandbox";
|
|
1546
|
+
/**
|
|
1547
|
+
* Account-wide, non-secret defaults. Environment references are rejected
|
|
1548
|
+
* here; put `env("NAME")` under the enabling agent's `tools.<tool>.config` so
|
|
1549
|
+
* the value is resolved per environment and stored with encrypted agent config.
|
|
1550
|
+
*/
|
|
1411
1551
|
defaultConfig?: Record<string, unknown>;
|
|
1412
1552
|
}
|
|
1413
1553
|
type PolicyDefinitionConfig = Omit<AgentPolicyDocument, "version"> & {
|
|
@@ -1439,7 +1579,7 @@ interface PancakeChannelInput extends ChannelIdentityInput {
|
|
|
1439
1579
|
interface ZaloChannelInput extends ChannelIdentityInput {
|
|
1440
1580
|
botToken: ChannelSecret;
|
|
1441
1581
|
webhookSecret: ChannelSecret;
|
|
1442
|
-
allowedUserIds
|
|
1582
|
+
allowedUserIds?: readonly (string | EnvRef)[];
|
|
1443
1583
|
}
|
|
1444
1584
|
type TelegramChannelDefinition = ChannelDefinition<"telegram", TelegramChannelInput>;
|
|
1445
1585
|
type GitHubChannelDefinition = ChannelDefinition<"github", GitHubChannelInput>;
|
|
@@ -1585,6 +1725,7 @@ interface AgentHooks {
|
|
|
1585
1725
|
onMessageReceived?: Handler<ChannelMessageReceived, {
|
|
1586
1726
|
drop?: boolean;
|
|
1587
1727
|
text?: string;
|
|
1728
|
+
metadata?: unknown;
|
|
1588
1729
|
}>;
|
|
1589
1730
|
onMessageSending?: Handler<{
|
|
1590
1731
|
channel: ChannelType;
|
|
@@ -1612,7 +1753,7 @@ type AgentPolicyDefinitionConfig = Omit<AgentPolicyConfig, "policyIds"> & {
|
|
|
1612
1753
|
* typo like the camel `baseUrl` (instead of `base_url`/`baseURL`) slip past
|
|
1613
1754
|
* `tsc`. Keep the keys in lockstep with core's `AgentProviderSettings`; the
|
|
1614
1755
|
* `_ProviderKeyParity` assertion below fails `broods check` if they drift.
|
|
1615
|
-
* Every string field also accepts an `env(
|
|
1756
|
+
* Every string field also accepts an `env("NAME")` reference.
|
|
1616
1757
|
*/
|
|
1617
1758
|
interface ProviderSettingsInput {
|
|
1618
1759
|
apiKey?: string | EnvRef;
|
|
@@ -1664,12 +1805,11 @@ type AnyResource = AgentResource | WorkspaceResource | SandboxResource | CronRes
|
|
|
1664
1805
|
* References an account/environment variable resolved on the SERVER at runtime —
|
|
1665
1806
|
* set it with `broods env set <NAME>` or in the dashboard (the Convex-style
|
|
1666
1807
|
* `convex env set` model). It is a deferred reference, never read from your local
|
|
1667
|
-
* environment and never baked into the deployed config
|
|
1808
|
+
* environment and never baked into the deployed config:
|
|
1668
1809
|
*
|
|
1669
|
-
* apiKey: env
|
|
1670
|
-
* apiKey: env("OPENAI_API_KEY") // call form (equivalent)
|
|
1810
|
+
* apiKey: env("OPENAI_API_KEY")
|
|
1671
1811
|
*
|
|
1672
|
-
*
|
|
1812
|
+
* It compiles to a `${NAME}` placeholder the harness fills in at run time. This is
|
|
1673
1813
|
* NOT `process.env`: agent configs are compiled locally, so `process.env.NAME` would
|
|
1674
1814
|
* bake the literal local value into the deployed config instead of deferring it.
|
|
1675
1815
|
*/
|
|
@@ -1681,16 +1821,18 @@ declare function defineDiscordChannel(config: DiscordChannelInput): DiscordChann
|
|
|
1681
1821
|
declare function definePancakeChannel(config: PancakeChannelInput): PancakeChannelDefinition;
|
|
1682
1822
|
declare function defineZaloChannel(config: ZaloChannelInput): ZaloChannelDefinition;
|
|
1683
1823
|
declare function defineBroods(config: BroodsProjectConfig): BroodsConfigDefinition;
|
|
1684
|
-
declare function defineAgent<const Name extends string>(input:
|
|
1685
|
-
declare function defineWorkspace<const Name extends string>(input:
|
|
1686
|
-
declare function defineSandbox<const Name extends string>(input:
|
|
1687
|
-
declare function defineSkill<const Name extends string>(input:
|
|
1688
|
-
declare function defineTool<const Name extends string
|
|
1689
|
-
|
|
1690
|
-
|
|
1824
|
+
declare function defineAgent<const Name extends string>(input: ResourceInput<Name, AgentDefinitionConfig>): AgentResource<Name>;
|
|
1825
|
+
declare function defineWorkspace<const Name extends string>(input: ResourceInput<Name, WorkspaceConfig>): WorkspaceResource<Name>;
|
|
1826
|
+
declare function defineSandbox<const Name extends string>(input: ResourceInput<Name, SandboxDefinitionConfig>): SandboxResource<Name>;
|
|
1827
|
+
declare function defineSkill<const Name extends string>(input: ResourceInput<Name, SkillDefinitionConfig>): SkillResource<Name>;
|
|
1828
|
+
declare function defineTool<const Name extends string, Input = Record<string, unknown>>(input: {
|
|
1829
|
+
name: Name;
|
|
1830
|
+
} & ToolDefinitionConfig<Input>): ToolResource<Name>;
|
|
1831
|
+
declare function definePolicy<const Name extends string>(input: ResourceInput<Name, PolicyDefinitionConfig>): PolicyResource<Name>;
|
|
1832
|
+
declare function defineCron<const Name extends string>(input: ResourceInput<Name, CronDefinitionConfig>): CronResource<Name>;
|
|
1691
1833
|
declare function isResource(value: unknown): value is AnyResource;
|
|
1692
1834
|
declare function isChannelDefinition(value: unknown): value is AnyChannelDefinition;
|
|
1693
1835
|
declare function isBroodsConfig(value: unknown): value is BroodsConfigDefinition;
|
|
1694
1836
|
|
|
1695
|
-
export { BroodsAccountApiError, BroodsAccountClient, 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 };
|
|
1696
|
-
export type { Account, AccountAgent, AccountPolicy, AccountSandbox, AccountTool, AccountWorkspace, 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, BroodsAccount, BroodsAccountClientOptions, BroodsClientOptions, BroodsConfigDefinition, BroodsProjectConfig, BroodsWebSocketClientOptions, ChannelDefinition, ChannelMessageReceived, ChannelReference, ChannelType, CliManifest, CliManifestResource, CliResourceKind, CreateAgentResult, CreateClientCronInput, CreateCronInput, CreateToolInput, Cron, CronDefinitionConfig, CronDoc, CronLastStatus, CronResource, CronRun, CronStatus, CustomTool, DeleteAccountResult, 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,
|
|
1837
|
+
export { BroodsAccountApiError, BroodsAccountClient, BroodsClient, BroodsWebSocketClient, DEFAULT_CORE_BASE_URL, IngressAcceptedError, MAX_OBSERVABILITY_BACKFILL, BroodsWebSocketClient as WebSocketClient, BroodsWebSocketClient as WebsocketClient, defineAgent, defineBroods, defineCron, defineDiscordChannel, defineGitHubChannel, definePancakeChannel, definePolicy, defineSandbox, defineSkill, defineSlackChannel, defineTelegramChannel, defineTool, defineWorkspace, defineZaloChannel, env, envPlaceholder, isBroodsConfig, isChannelDefinition, isObservabilityClientMessage, isResource, normalizeHttpServiceUrl, readSseStream, resolveRunEvents, toWebSocketBaseUrl };
|
|
1838
|
+
export type { Account, AccountAgent, AccountEnvVar, AccountPolicy, AccountSandbox, AccountTool, AccountWorkspace, 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, BroodsAccount, BroodsAccountClientOptions, BroodsClientOptions, BroodsConfigDefinition, BroodsProjectConfig, BroodsWebSocketClientOptions, ChannelDefinition, ChannelMessageReceived, ChannelReference, ChannelType, CliManifest, CliManifestResource, CliResourceKind, CreateAgentResult, CreateClientCronInput, CreateCronInput, CreateToolInput, Cron, CronDefinitionConfig, CronDoc, CronLastStatus, CronResource, CronRun, CronStatus, CustomTool, DeleteAccountResult, DiscordChannelDefinition, DiscordChannelInput, DiscordMessageSource, DiscordSource, Doc, EnvAccessor, EnvRef, EnvRefString, EnvironmentDoc, GeneratedIds, GitHubChannelDefinition, GitHubChannelInput, GitHubMessageSource, GitHubSource, HookContext, Id, IngressMode, IngressStatus, LogLevel, ObservabilityBackfillMessage, ObservabilityClientMessage, ObservabilityErrorMessage, ObservabilityLogEntry, ObservabilityLogMessage, ObservabilityReadyMessage, ObservabilityServerMessage, ObservabilitySpanMessage, ObservabilitySpanRow, ObservabilitySubscribeMessage, ObservabilityUnsubscribeMessage, PancakeChannelDefinition, PancakeChannelInput, PancakeMessageSource, PancakeSource, PolicyDefinitionConfig, PolicyResource, ProjectDoc, ProviderConfigInput, ProviderSettingsInput, ResourceApi, ResourceDefinition, ResourceInput, ResourceKind, RotateSecretResult, Sandbox, SandboxConfig, SandboxConfigDoc, SandboxDefinitionConfig, SandboxLifecycleResult, SandboxResource, SandboxSnapshotResult, SandboxTerminalTicket, Skill, SkillDefinitionConfig, SkillResource, SkillUploadInput, SlackChannelDefinition, SlackChannelInput, SlackMessageSource, SlackSource, TelegramChannelDefinition, TelegramChannelInput, TelegramMessageSource, TelegramSource, ToolApprovalSummary, ToolDefinitionConfig, ToolExecuteContext, ToolExecuteOptions, ToolResource, UpdateAgentInput, UpdateCronInput, UpdateToolInput, WebSocketAttachInput, WebSocketClientAttachMessage, WebSocketClientCancelMessage, WebSocketClientControlMessage, WebSocketClientExecuteMessage, WebSocketClientMessage, WebSocketConstructorLike, WebSocketHandlers, WebSocketLike, WebSocketOutputMessage, WebSocketRunInput, WebSocketServerMessage, WebSocketStreamMessage, WebSocketSubscription, Workspace, WorkspaceConfig, WorkspaceConfigDoc, WorkspaceFileEntry, WorkspaceResource, ZaloChannelDefinition, ZaloChannelInput, ZaloMessageSource, ZaloSource };
|