broods 0.2.0 → 0.3.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 +74 -0
- package/dist/account.d.ts +799 -0
- package/dist/account.js +271 -0
- package/dist/cli/index.js +54 -1
- package/dist/index.d.ts +363 -4
- package/dist/index.js +269 -1
- package/package.json +6 -1
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
|
-
|
|
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;
|
|
@@ -930,6 +950,319 @@ declare class BroodsClient {
|
|
|
930
950
|
}
|
|
931
951
|
declare function normalizeHttpServiceUrl(value: string): string;
|
|
932
952
|
|
|
953
|
+
/**
|
|
954
|
+
* Account config-plane client for the broods public account REST API.
|
|
955
|
+
*
|
|
956
|
+
* This is the DYNAMIC counterpart to the config-first `broods dev` / `broods
|
|
957
|
+
* deploy` flow: `broods dev` syncs the predefined resources declared in your
|
|
958
|
+
* `broods/` folder, while `BroodsAccountClient` creates and mutates the full
|
|
959
|
+
* account config plane at runtime — agents, sandboxes (config + lifecycle),
|
|
960
|
+
* workspaces (config + files), tools, policies, skills, crons, and the account
|
|
961
|
+
* itself — e.g. a multi-tenant app provisioning one agent per customer from its
|
|
962
|
+
* own backend.
|
|
963
|
+
*
|
|
964
|
+
* Kept intentionally standalone (import from `broods/account`): pure fetch,
|
|
965
|
+
* no Node built-ins, no `.env` file loading — so it runs in edge/worker
|
|
966
|
+
* runtimes such as Convex actions, Cloudflare Workers, and the browser-less
|
|
967
|
+
* server runtimes, as well as Node and Bun.
|
|
968
|
+
*
|
|
969
|
+
* Auth: every call sends `Authorization: Bearer {accountSecret}` to
|
|
970
|
+
* `{baseUrl}/v1/...`. Secrets inside agent configs are encrypted at rest by
|
|
971
|
+
* the platform and come back redacted (`********`) on reads.
|
|
972
|
+
*/
|
|
973
|
+
|
|
974
|
+
interface BroodsAccountClientOptions {
|
|
975
|
+
/** Base URL of the broods gateway. Falls back to `BROODS_BASE_URL`, then `https://gateway.broods.app`. */
|
|
976
|
+
baseUrl?: string;
|
|
977
|
+
/** Account secret used as the Bearer token. Falls back to `BROODS_ACCOUNT_SECRET`. */
|
|
978
|
+
accountSecret?: string;
|
|
979
|
+
fetch?: typeof fetch;
|
|
980
|
+
}
|
|
981
|
+
/** Public account record returned by `GET /v1/account`. */
|
|
982
|
+
interface BroodsAccount {
|
|
983
|
+
accountId: string;
|
|
984
|
+
username: string;
|
|
985
|
+
status: string;
|
|
986
|
+
[key: string]: unknown;
|
|
987
|
+
}
|
|
988
|
+
/** Public agent record; `config` comes back with secret values redacted. */
|
|
989
|
+
interface AccountAgent {
|
|
990
|
+
accountId: string;
|
|
991
|
+
agentId: string;
|
|
992
|
+
name: string;
|
|
993
|
+
description?: string;
|
|
994
|
+
status: string;
|
|
995
|
+
config: AgentConfig;
|
|
996
|
+
createdAt: string;
|
|
997
|
+
updatedAt: string;
|
|
998
|
+
}
|
|
999
|
+
interface CreateAgentResult {
|
|
1000
|
+
accountId: string;
|
|
1001
|
+
agentId: string;
|
|
1002
|
+
name: string;
|
|
1003
|
+
description?: string;
|
|
1004
|
+
}
|
|
1005
|
+
/** Fields accepted by `PATCH /v1/agents/{id}`. `config` is deep-merged; `null` values delete keys. */
|
|
1006
|
+
interface UpdateAgentInput {
|
|
1007
|
+
name?: string;
|
|
1008
|
+
description?: string | null;
|
|
1009
|
+
config?: unknown;
|
|
1010
|
+
}
|
|
1011
|
+
/** Public workspace record returned by the workspaces routes. */
|
|
1012
|
+
interface AccountWorkspace {
|
|
1013
|
+
accountId: string;
|
|
1014
|
+
workspaceId: string;
|
|
1015
|
+
name: string;
|
|
1016
|
+
description?: string;
|
|
1017
|
+
config: WorkspaceConfig;
|
|
1018
|
+
createdAt: string;
|
|
1019
|
+
updatedAt: string;
|
|
1020
|
+
}
|
|
1021
|
+
/** One entry of a workspace file listing (`GET /v1/workspaces/{id}/files`). */
|
|
1022
|
+
interface WorkspaceFileEntry {
|
|
1023
|
+
path: string;
|
|
1024
|
+
name: string;
|
|
1025
|
+
isFolder: boolean;
|
|
1026
|
+
sizeBytes?: number;
|
|
1027
|
+
updatedAt?: string;
|
|
1028
|
+
}
|
|
1029
|
+
/** Public sandbox config record; `config` comes back with secret values (e.g. `envVars`) redacted. */
|
|
1030
|
+
interface AccountSandbox {
|
|
1031
|
+
accountId: string;
|
|
1032
|
+
sandboxId: string;
|
|
1033
|
+
name: string;
|
|
1034
|
+
description?: string;
|
|
1035
|
+
config: SandboxConfig;
|
|
1036
|
+
createdAt: string;
|
|
1037
|
+
updatedAt: string;
|
|
1038
|
+
[key: string]: unknown;
|
|
1039
|
+
}
|
|
1040
|
+
/** Public agent-policy record returned by the policies routes. */
|
|
1041
|
+
interface AccountPolicy {
|
|
1042
|
+
accountId: string;
|
|
1043
|
+
policyId: string;
|
|
1044
|
+
name: string;
|
|
1045
|
+
description?: string;
|
|
1046
|
+
document: AgentPolicyDocument;
|
|
1047
|
+
status: string;
|
|
1048
|
+
createdAt: string;
|
|
1049
|
+
updatedAt: string;
|
|
1050
|
+
}
|
|
1051
|
+
/** Public uploaded-tool record returned by the tools routes. */
|
|
1052
|
+
interface AccountTool {
|
|
1053
|
+
accountId: string;
|
|
1054
|
+
toolId: string;
|
|
1055
|
+
name: string;
|
|
1056
|
+
description: string;
|
|
1057
|
+
inputSchema: unknown;
|
|
1058
|
+
sha256: string;
|
|
1059
|
+
runtime: "isolate" | "sandbox";
|
|
1060
|
+
defaultConfig?: unknown;
|
|
1061
|
+
status: string;
|
|
1062
|
+
createdAt: string;
|
|
1063
|
+
updatedAt: string;
|
|
1064
|
+
deletedAt?: string;
|
|
1065
|
+
}
|
|
1066
|
+
/** Fields accepted by `POST /v1/tools`. `bundle` is already-bundled JavaScript module source. */
|
|
1067
|
+
interface CreateToolInput {
|
|
1068
|
+
name: string;
|
|
1069
|
+
description: string;
|
|
1070
|
+
inputSchema: unknown;
|
|
1071
|
+
bundle: string;
|
|
1072
|
+
runtime?: "isolate" | "sandbox";
|
|
1073
|
+
defaultConfig?: unknown;
|
|
1074
|
+
}
|
|
1075
|
+
/** Fields accepted by `PATCH /v1/tools/{toolId}`; every field is optional. Omitting `bundle` keeps the stored one. */
|
|
1076
|
+
interface UpdateToolInput {
|
|
1077
|
+
name?: string;
|
|
1078
|
+
description?: string;
|
|
1079
|
+
inputSchema?: unknown;
|
|
1080
|
+
bundle?: string;
|
|
1081
|
+
runtime?: "isolate" | "sandbox";
|
|
1082
|
+
defaultConfig?: unknown;
|
|
1083
|
+
}
|
|
1084
|
+
/**
|
|
1085
|
+
* Body of a skill upload (`POST /v1/skills`, `PUT /v1/skills/{skillName}`).
|
|
1086
|
+
* `json` needs `name`/`description`/`content`; `files` needs base64 `files`
|
|
1087
|
+
* including a root `SKILL.md`; `github` needs a tree `url`.
|
|
1088
|
+
*/
|
|
1089
|
+
interface SkillUploadInput {
|
|
1090
|
+
source: "json" | "files" | "github";
|
|
1091
|
+
name?: string;
|
|
1092
|
+
description?: string;
|
|
1093
|
+
content?: string;
|
|
1094
|
+
files?: Array<{
|
|
1095
|
+
path: string;
|
|
1096
|
+
contentBase64: string;
|
|
1097
|
+
contentType?: string;
|
|
1098
|
+
}>;
|
|
1099
|
+
url?: string;
|
|
1100
|
+
}
|
|
1101
|
+
/** Result of `POST /v1/account/rotate-secret`. The returned `secret` is shown once; the old secret stops working immediately. */
|
|
1102
|
+
interface RotateSecretResult {
|
|
1103
|
+
account: BroodsAccount;
|
|
1104
|
+
secret: string;
|
|
1105
|
+
}
|
|
1106
|
+
/** Result of `DELETE /v1/account`: the account and all account-scoped data are removed; `cleanup` reports per-resource deletion counts. */
|
|
1107
|
+
interface DeleteAccountResult {
|
|
1108
|
+
deleted: boolean;
|
|
1109
|
+
cleanup?: Record<string, number>;
|
|
1110
|
+
}
|
|
1111
|
+
/** Result of a suspend/resume/terminate sandbox lifecycle action. */
|
|
1112
|
+
interface SandboxLifecycleResult {
|
|
1113
|
+
status: string;
|
|
1114
|
+
}
|
|
1115
|
+
/** Result of `POST /v1/sandboxes/{id}/snapshot`. */
|
|
1116
|
+
interface SandboxSnapshotResult {
|
|
1117
|
+
status: string;
|
|
1118
|
+
snapshotId?: string;
|
|
1119
|
+
externalImageId?: string;
|
|
1120
|
+
}
|
|
1121
|
+
/** Sealed ticket from `POST /v1/sandboxes/{id}/terminal`; hand `token` to the gateway terminal WebSocket at `websocketPath`. */
|
|
1122
|
+
interface SandboxTerminalTicket {
|
|
1123
|
+
token: string;
|
|
1124
|
+
expiresAt: number;
|
|
1125
|
+
websocketPath: string;
|
|
1126
|
+
}
|
|
1127
|
+
/** Non-2xx response from the account API (404s on id routes return null instead). */
|
|
1128
|
+
declare class BroodsAccountApiError extends Error {
|
|
1129
|
+
readonly status: number;
|
|
1130
|
+
readonly body: string;
|
|
1131
|
+
constructor(method: string, path: string, status: number, body: string);
|
|
1132
|
+
}
|
|
1133
|
+
/**
|
|
1134
|
+
* Typed client for the broods account config API. All `get`/`update`/`delete`
|
|
1135
|
+
* methods return `null`/`false` when the resource does not exist (HTTP 404) so
|
|
1136
|
+
* callers can implement upsert flows without try/catch; every other non-2xx
|
|
1137
|
+
* status throws {@link BroodsAccountApiError}.
|
|
1138
|
+
*/
|
|
1139
|
+
declare class BroodsAccountClient {
|
|
1140
|
+
private readonly baseUrl;
|
|
1141
|
+
private readonly accountSecret;
|
|
1142
|
+
private readonly fetchImpl;
|
|
1143
|
+
constructor(options?: BroodsAccountClientOptions);
|
|
1144
|
+
/** The account this secret belongs to. Its `accountId` is the first segment of channel webhook URLs. */
|
|
1145
|
+
getAccount(): Promise<BroodsAccount>;
|
|
1146
|
+
/** Update account metadata (username/description). Returns null when the account is gone. Runtime config is managed through the agent endpoints. */
|
|
1147
|
+
updateAccount(patch: {
|
|
1148
|
+
username?: string;
|
|
1149
|
+
description?: string | null;
|
|
1150
|
+
}): Promise<BroodsAccount | null>;
|
|
1151
|
+
/** Rotate the account secret. The returned `secret` is shown once and the current secret stops working immediately, so persist it before the process exits. */
|
|
1152
|
+
rotateSecret(): Promise<RotateSecretResult>;
|
|
1153
|
+
/** Delete this account and cascade-clean every account-scoped resource. `cleanup` reports per-resource deletion counts. */
|
|
1154
|
+
deleteAccount(): Promise<DeleteAccountResult>;
|
|
1155
|
+
/**
|
|
1156
|
+
* Provider webhook URL for one of an agent's channels. Paste this into the
|
|
1157
|
+
* provider's webhook settings (Slack Event Subscriptions, Zalo OA webhook,
|
|
1158
|
+
* Pancake page webhook). Routing is per account + agent, so each agent's
|
|
1159
|
+
* channels are isolated from every other agent's.
|
|
1160
|
+
*/
|
|
1161
|
+
webhookUrl(accountId: string, agentId: string, channelType: string): string;
|
|
1162
|
+
listAgents(): Promise<AccountAgent[]>;
|
|
1163
|
+
createAgent(input: {
|
|
1164
|
+
name: string;
|
|
1165
|
+
description?: string;
|
|
1166
|
+
config: unknown;
|
|
1167
|
+
}): Promise<CreateAgentResult>;
|
|
1168
|
+
getAgent(agentId: string): Promise<AccountAgent | null>;
|
|
1169
|
+
/** PATCH an agent. `config` deep-merges into the stored config; `null` leaves delete keys. Returns null when the agent is gone. */
|
|
1170
|
+
updateAgent(agentId: string, patch: UpdateAgentInput): Promise<AccountAgent | null>;
|
|
1171
|
+
deleteAgent(agentId: string): Promise<boolean>;
|
|
1172
|
+
listCrons(): Promise<Cron[]>;
|
|
1173
|
+
createCron(input: CreateCronInput): Promise<Cron>;
|
|
1174
|
+
getCron(cronId: string): Promise<Cron | null>;
|
|
1175
|
+
updateCron(cronId: string, patch: UpdateCronInput): Promise<Cron | null>;
|
|
1176
|
+
deleteCron(cronId: string): Promise<boolean>;
|
|
1177
|
+
/** Run history for a cron, newest first. Returns [] when the cron is gone. */
|
|
1178
|
+
listCronRuns(cronId: string, options?: {
|
|
1179
|
+
limit?: number;
|
|
1180
|
+
}): Promise<CronRun[]>;
|
|
1181
|
+
listWorkspaces(): Promise<AccountWorkspace[]>;
|
|
1182
|
+
createWorkspace(input: {
|
|
1183
|
+
name: string;
|
|
1184
|
+
description?: string;
|
|
1185
|
+
config?: unknown;
|
|
1186
|
+
}): Promise<AccountWorkspace>;
|
|
1187
|
+
getWorkspace(workspaceId: string): Promise<AccountWorkspace | null>;
|
|
1188
|
+
updateWorkspace(workspaceId: string, patch: {
|
|
1189
|
+
name?: string;
|
|
1190
|
+
description?: string | null;
|
|
1191
|
+
config?: unknown;
|
|
1192
|
+
}): Promise<AccountWorkspace | null>;
|
|
1193
|
+
deleteWorkspace(workspaceId: string): Promise<boolean>;
|
|
1194
|
+
/** Flat listing of every file in the workspace's S3-backed filesystem. Returns [] when the workspace is gone. */
|
|
1195
|
+
listWorkspaceFiles(workspaceId: string): Promise<WorkspaceFileEntry[]>;
|
|
1196
|
+
/** Short-lived download URL for one workspace file. Returns null when the workspace or file is gone. */
|
|
1197
|
+
getWorkspaceFileUrl(workspaceId: string, path: string): Promise<string | null>;
|
|
1198
|
+
/** Upload or replace one workspace file from base64 content. Throws when the workspace is gone (404). */
|
|
1199
|
+
uploadWorkspaceFile(workspaceId: string, input: {
|
|
1200
|
+
path: string;
|
|
1201
|
+
contentBase64: string;
|
|
1202
|
+
contentType?: string;
|
|
1203
|
+
}): Promise<WorkspaceFileEntry>;
|
|
1204
|
+
/** Rename a workspace file or folder. Returns false when the workspace or source path is gone. */
|
|
1205
|
+
renameWorkspaceFile(workspaceId: string, path: string, newPath: string): Promise<boolean>;
|
|
1206
|
+
/** Delete a workspace file or folder. Returns false when the workspace or path is gone. */
|
|
1207
|
+
deleteWorkspaceFile(workspaceId: string, path: string): Promise<boolean>;
|
|
1208
|
+
listSandboxes(): Promise<AccountSandbox[]>;
|
|
1209
|
+
createSandbox(input: {
|
|
1210
|
+
name: string;
|
|
1211
|
+
description?: string;
|
|
1212
|
+
config?: unknown;
|
|
1213
|
+
}): Promise<AccountSandbox>;
|
|
1214
|
+
getSandbox(sandboxId: string): Promise<AccountSandbox | null>;
|
|
1215
|
+
/** PATCH a sandbox config. `config` fully replaces the stored config. Returns null when the sandbox is gone. */
|
|
1216
|
+
updateSandbox(sandboxId: string, patch: {
|
|
1217
|
+
name?: string;
|
|
1218
|
+
description?: string | null;
|
|
1219
|
+
config?: unknown;
|
|
1220
|
+
}): Promise<AccountSandbox | null>;
|
|
1221
|
+
deleteSandbox(sandboxId: string): Promise<boolean>;
|
|
1222
|
+
/** Suspend a persistent sandbox reservation. Throws on 404/403/409 (missing sandbox, foreign reservation, or unsupported provider). */
|
|
1223
|
+
suspendSandbox(sandboxId: string, reservationKey: string): Promise<SandboxLifecycleResult>;
|
|
1224
|
+
/** Resume a persistent sandbox reservation. Throws on 404/403/409. */
|
|
1225
|
+
resumeSandbox(sandboxId: string, reservationKey: string): Promise<SandboxLifecycleResult>;
|
|
1226
|
+
/** Terminate a persistent sandbox reservation and drop its live-instance row. Throws on 404/403/409. */
|
|
1227
|
+
terminateSandbox(sandboxId: string, reservationKey: string): Promise<SandboxLifecycleResult>;
|
|
1228
|
+
/** Snapshot a persistent sandbox reservation into a reusable image (self-hosted `sandbox` provider). Throws on 404/403/409. */
|
|
1229
|
+
snapshotSandbox(sandboxId: string, reservationKey: string, name: string): Promise<SandboxSnapshotResult>;
|
|
1230
|
+
/** Mint a short-lived sealed ticket for an interactive PTY session on a persistent sandbox (`sandbox`/`lambda` providers). Throws on 404/403/409. */
|
|
1231
|
+
openSandboxTerminal(sandboxId: string, reservationKey: string): Promise<SandboxTerminalTicket>;
|
|
1232
|
+
listTools(): Promise<AccountTool[]>;
|
|
1233
|
+
createTool(input: CreateToolInput): Promise<AccountTool>;
|
|
1234
|
+
getTool(toolId: string): Promise<AccountTool | null>;
|
|
1235
|
+
/** PATCH an uploaded tool. Omitting `bundle` keeps the stored bundle and runtime. Returns null when the tool is gone. */
|
|
1236
|
+
updateTool(toolId: string, patch: UpdateToolInput): Promise<AccountTool | null>;
|
|
1237
|
+
deleteTool(toolId: string): Promise<boolean>;
|
|
1238
|
+
listPolicies(): Promise<AccountPolicy[]>;
|
|
1239
|
+
createPolicy(input: {
|
|
1240
|
+
name: string;
|
|
1241
|
+
description?: string;
|
|
1242
|
+
document: AgentPolicyDocument;
|
|
1243
|
+
}): Promise<AccountPolicy>;
|
|
1244
|
+
getPolicy(policyId: string): Promise<AccountPolicy | null>;
|
|
1245
|
+
/** PATCH a policy. `description: null` clears it. Returns null when the policy is gone. */
|
|
1246
|
+
updatePolicy(policyId: string, patch: {
|
|
1247
|
+
name?: string;
|
|
1248
|
+
description?: string | null;
|
|
1249
|
+
document?: AgentPolicyDocument;
|
|
1250
|
+
status?: string;
|
|
1251
|
+
}): Promise<AccountPolicy | null>;
|
|
1252
|
+
deletePolicy(policyId: string): Promise<boolean>;
|
|
1253
|
+
/** All skills for the account, each with its `<accountId>/<name>` path. */
|
|
1254
|
+
listSkills(): Promise<Skill[]>;
|
|
1255
|
+
/** Upload a new skill from JSON content, a base64 file bundle, or a GitHub tree URL. Every bundle must include a root `SKILL.md`. */
|
|
1256
|
+
createSkill(input: SkillUploadInput): Promise<Skill>;
|
|
1257
|
+
getSkill(skillName: string): Promise<Skill | null>;
|
|
1258
|
+
/** Replace a skill's bundle in place (`PUT`). Throws when the skill is gone (404). */
|
|
1259
|
+
uploadSkill(skillName: string, input: SkillUploadInput): Promise<Skill>;
|
|
1260
|
+
deleteSkill(skillName: string): Promise<boolean>;
|
|
1261
|
+
/** POST a sandbox lifecycle action, throwing on any non-2xx (including 404, since these are not upsert flows). */
|
|
1262
|
+
private sandboxAction;
|
|
1263
|
+
private request;
|
|
1264
|
+
}
|
|
1265
|
+
|
|
933
1266
|
/**
|
|
934
1267
|
* WebSocket client for deployed-agent endpoints.
|
|
935
1268
|
* Uses the gateway URL when configured, or derives one from the core service URL.
|
|
@@ -1272,7 +1605,33 @@ type AgentPolicyDefinitionConfig = Omit<AgentPolicyConfig, "policyIds"> & {
|
|
|
1272
1605
|
* `workspace:` instead of `workspaces:`. Add a key here when core's `AgentConfig`
|
|
1273
1606
|
* gains a new top-level field that should be code-definable.
|
|
1274
1607
|
*/
|
|
1275
|
-
|
|
1608
|
+
/**
|
|
1609
|
+
* SDK-facing model-provider constructor settings. Written as an explicit
|
|
1610
|
+
* interface — NOT `EnvRefString<AgentProviderSettings>` — because TypeScript
|
|
1611
|
+
* suppresses excess-property checks through mapped types, which would let a
|
|
1612
|
+
* typo like the camel `baseUrl` (instead of `base_url`/`baseURL`) slip past
|
|
1613
|
+
* `tsc`. Keep the keys in lockstep with core's `AgentProviderSettings`; the
|
|
1614
|
+
* `_ProviderKeyParity` assertion below fails `broods check` if they drift.
|
|
1615
|
+
* Every string field also accepts an `env(...)` reference.
|
|
1616
|
+
*/
|
|
1617
|
+
interface ProviderSettingsInput {
|
|
1618
|
+
apiKey?: string | EnvRef;
|
|
1619
|
+
base_url?: string | EnvRef;
|
|
1620
|
+
baseURL?: string | EnvRef;
|
|
1621
|
+
headers?: Record<string, string | EnvRef>;
|
|
1622
|
+
organization?: string | EnvRef;
|
|
1623
|
+
project?: string | EnvRef;
|
|
1624
|
+
name?: string | EnvRef;
|
|
1625
|
+
region?: string | EnvRef;
|
|
1626
|
+
accessKeyId?: string | EnvRef;
|
|
1627
|
+
secretAccessKey?: string | EnvRef;
|
|
1628
|
+
sessionToken?: string | EnvRef;
|
|
1629
|
+
}
|
|
1630
|
+
/** Per-provider settings; provider names stay synced with core's `AgentConfig`. */
|
|
1631
|
+
type ProviderConfigInput = Partial<Record<keyof NonNullable<AgentConfig["provider"]>, ProviderSettingsInput>>;
|
|
1632
|
+
type AgentDefinitionConfig = EnvRefString<Pick<AgentConfig, "agent" | "model" | "session" | "tools">> & {
|
|
1633
|
+
provider?: ProviderConfigInput;
|
|
1634
|
+
} & {
|
|
1276
1635
|
hooks?: AgentHooks & {
|
|
1277
1636
|
webhooks?: readonly EnvRefString<AgentWebhookHookConfig>[];
|
|
1278
1637
|
};
|
|
@@ -1333,5 +1692,5 @@ declare function isResource(value: unknown): value is AnyResource;
|
|
|
1333
1692
|
declare function isChannelDefinition(value: unknown): value is AnyChannelDefinition;
|
|
1334
1693
|
declare function isBroodsConfig(value: unknown): value is BroodsConfigDefinition;
|
|
1335
1694
|
|
|
1336
|
-
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 };
|
|
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, ResourceDefinitionInput, ResourceKind, RotateSecretResult, Sandbox, SandboxConfig, SandboxConfigDoc, SandboxDefinitionConfig, SandboxLifecycleResult, SandboxResource, SandboxSnapshotResult, SandboxTerminalTicket, Skill, SkillDefinitionConfig, SkillResource, SkillUploadInput, SlackChannelDefinition, SlackChannelInput, SlackMessageSource, SlackSource, TelegramChannelDefinition, TelegramChannelInput, TelegramMessageSource, TelegramSource, ToolApprovalSummary, ToolDefinitionConfig, ToolResource, UpdateAgentInput, UpdateCronInput, UpdateToolInput, WebSocketClientCancelMessage, WebSocketClientExecuteMessage, WebSocketClientMessage, WebSocketConstructorLike, WebSocketHandlers, WebSocketLike, WebSocketRunInput, WebSocketServerMessage, WebSocketStreamMessage, WebSocketSubscription, Workspace, WorkspaceConfig, WorkspaceConfigDoc, WorkspaceFileEntry, WorkspaceResource, ZaloChannelDefinition, ZaloChannelInput, ZaloMessageSource, ZaloSource };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,270 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
// src/account.ts
|
|
3
|
+
var DEFAULT_ACCOUNT_BASE_URL = "https://gateway.broods.app";
|
|
4
|
+
|
|
5
|
+
class BroodsAccountApiError extends Error {
|
|
6
|
+
status;
|
|
7
|
+
body;
|
|
8
|
+
constructor(method, path, status, body) {
|
|
9
|
+
super(`${method} ${path} failed with ${status}: ${body}`);
|
|
10
|
+
this.name = "BroodsAccountApiError";
|
|
11
|
+
this.status = status;
|
|
12
|
+
this.body = body;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function envVar(name) {
|
|
16
|
+
return typeof process !== "undefined" ? process?.env?.[name] : undefined;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
class BroodsAccountClient {
|
|
20
|
+
baseUrl;
|
|
21
|
+
accountSecret;
|
|
22
|
+
fetchImpl;
|
|
23
|
+
constructor(options = {}) {
|
|
24
|
+
const baseUrl = options.baseUrl ?? envVar("BROODS_BASE_URL") ?? DEFAULT_ACCOUNT_BASE_URL;
|
|
25
|
+
const accountSecret = options.accountSecret ?? envVar("BROODS_ACCOUNT_SECRET");
|
|
26
|
+
if (!accountSecret)
|
|
27
|
+
throw new Error("BroodsAccountClient requires an accountSecret (or BROODS_ACCOUNT_SECRET).");
|
|
28
|
+
this.baseUrl = baseUrl.replace(/\/+$/, "");
|
|
29
|
+
this.accountSecret = accountSecret;
|
|
30
|
+
this.fetchImpl = options.fetch ?? fetch;
|
|
31
|
+
}
|
|
32
|
+
async getAccount() {
|
|
33
|
+
const result = await this.request("GET", "/v1/account");
|
|
34
|
+
if (!result)
|
|
35
|
+
throw new BroodsAccountApiError("GET", "/v1/account", 404, "Account not found");
|
|
36
|
+
return result.account;
|
|
37
|
+
}
|
|
38
|
+
async updateAccount(patch) {
|
|
39
|
+
const result = await this.request("PATCH", "/v1/account", patch);
|
|
40
|
+
return result?.account ?? null;
|
|
41
|
+
}
|
|
42
|
+
async rotateSecret() {
|
|
43
|
+
const result = await this.request("POST", "/v1/account/rotate-secret");
|
|
44
|
+
if (!result)
|
|
45
|
+
throw new BroodsAccountApiError("POST", "/v1/account/rotate-secret", 404, "Account not found");
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
async deleteAccount() {
|
|
49
|
+
const result = await this.request("DELETE", "/v1/account");
|
|
50
|
+
return result ?? { deleted: false };
|
|
51
|
+
}
|
|
52
|
+
webhookUrl(accountId, agentId, channelType) {
|
|
53
|
+
const segments = [accountId, agentId, channelType].map(encodeURIComponent);
|
|
54
|
+
return `${this.baseUrl}/webhooks/${segments.join("/")}`;
|
|
55
|
+
}
|
|
56
|
+
async listAgents() {
|
|
57
|
+
const result = await this.request("GET", "/v1/agents");
|
|
58
|
+
return result?.agents ?? [];
|
|
59
|
+
}
|
|
60
|
+
async createAgent(input) {
|
|
61
|
+
const result = await this.request("POST", "/v1/agents", input);
|
|
62
|
+
if (!result)
|
|
63
|
+
throw new BroodsAccountApiError("POST", "/v1/agents", 404, "Not found");
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
async getAgent(agentId) {
|
|
67
|
+
return await this.request("GET", `/v1/agents/${encodeURIComponent(agentId)}`);
|
|
68
|
+
}
|
|
69
|
+
async updateAgent(agentId, patch) {
|
|
70
|
+
return await this.request("PATCH", `/v1/agents/${encodeURIComponent(agentId)}`, patch);
|
|
71
|
+
}
|
|
72
|
+
async deleteAgent(agentId) {
|
|
73
|
+
const result = await this.request("DELETE", `/v1/agents/${encodeURIComponent(agentId)}`);
|
|
74
|
+
return result?.deleted ?? false;
|
|
75
|
+
}
|
|
76
|
+
async listCrons() {
|
|
77
|
+
const result = await this.request("GET", "/v1/crons");
|
|
78
|
+
return result?.crons ?? [];
|
|
79
|
+
}
|
|
80
|
+
async createCron(input) {
|
|
81
|
+
const result = await this.request("POST", "/v1/crons", input);
|
|
82
|
+
if (!result)
|
|
83
|
+
throw new BroodsAccountApiError("POST", "/v1/crons", 404, "Not found");
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
async getCron(cronId) {
|
|
87
|
+
return await this.request("GET", `/v1/crons/${encodeURIComponent(cronId)}`);
|
|
88
|
+
}
|
|
89
|
+
async updateCron(cronId, patch) {
|
|
90
|
+
return await this.request("PATCH", `/v1/crons/${encodeURIComponent(cronId)}`, patch);
|
|
91
|
+
}
|
|
92
|
+
async deleteCron(cronId) {
|
|
93
|
+
const result = await this.request("DELETE", `/v1/crons/${encodeURIComponent(cronId)}`);
|
|
94
|
+
return result?.deleted ?? false;
|
|
95
|
+
}
|
|
96
|
+
async listCronRuns(cronId, options = {}) {
|
|
97
|
+
const query = options.limit !== undefined ? `?limit=${options.limit}` : "";
|
|
98
|
+
const result = await this.request("GET", `/v1/crons/${encodeURIComponent(cronId)}/runs${query}`);
|
|
99
|
+
return result?.runs ?? [];
|
|
100
|
+
}
|
|
101
|
+
async listWorkspaces() {
|
|
102
|
+
const result = await this.request("GET", "/v1/workspaces");
|
|
103
|
+
return result?.workspaces ?? [];
|
|
104
|
+
}
|
|
105
|
+
async createWorkspace(input) {
|
|
106
|
+
const result = await this.request("POST", "/v1/workspaces", input);
|
|
107
|
+
if (!result)
|
|
108
|
+
throw new BroodsAccountApiError("POST", "/v1/workspaces", 404, "Not found");
|
|
109
|
+
return result;
|
|
110
|
+
}
|
|
111
|
+
async getWorkspace(workspaceId) {
|
|
112
|
+
return await this.request("GET", `/v1/workspaces/${encodeURIComponent(workspaceId)}`);
|
|
113
|
+
}
|
|
114
|
+
async updateWorkspace(workspaceId, patch) {
|
|
115
|
+
return await this.request("PATCH", `/v1/workspaces/${encodeURIComponent(workspaceId)}`, patch);
|
|
116
|
+
}
|
|
117
|
+
async deleteWorkspace(workspaceId) {
|
|
118
|
+
const result = await this.request("DELETE", `/v1/workspaces/${encodeURIComponent(workspaceId)}`);
|
|
119
|
+
return result?.deleted ?? false;
|
|
120
|
+
}
|
|
121
|
+
async listWorkspaceFiles(workspaceId) {
|
|
122
|
+
const result = await this.request("GET", `/v1/workspaces/${encodeURIComponent(workspaceId)}/files`);
|
|
123
|
+
return result?.files ?? [];
|
|
124
|
+
}
|
|
125
|
+
async getWorkspaceFileUrl(workspaceId, path) {
|
|
126
|
+
const query = `?path=${encodeURIComponent(path)}`;
|
|
127
|
+
const result = await this.request("GET", `/v1/workspaces/${encodeURIComponent(workspaceId)}/files${query}`);
|
|
128
|
+
return result?.url ?? null;
|
|
129
|
+
}
|
|
130
|
+
async uploadWorkspaceFile(workspaceId, input) {
|
|
131
|
+
const path = `/v1/workspaces/${encodeURIComponent(workspaceId)}/files`;
|
|
132
|
+
const result = await this.request("POST", path, input);
|
|
133
|
+
if (!result)
|
|
134
|
+
throw new BroodsAccountApiError("POST", path, 404, "Workspace not found");
|
|
135
|
+
return result.file;
|
|
136
|
+
}
|
|
137
|
+
async renameWorkspaceFile(workspaceId, path, newPath) {
|
|
138
|
+
const result = await this.request("PATCH", `/v1/workspaces/${encodeURIComponent(workspaceId)}/files`, { path, newPath });
|
|
139
|
+
return result?.renamed ?? false;
|
|
140
|
+
}
|
|
141
|
+
async deleteWorkspaceFile(workspaceId, path) {
|
|
142
|
+
const result = await this.request("DELETE", `/v1/workspaces/${encodeURIComponent(workspaceId)}/files`, { path });
|
|
143
|
+
return result?.deleted ?? false;
|
|
144
|
+
}
|
|
145
|
+
async listSandboxes() {
|
|
146
|
+
const result = await this.request("GET", "/v1/sandboxes");
|
|
147
|
+
return result?.sandboxes ?? [];
|
|
148
|
+
}
|
|
149
|
+
async createSandbox(input) {
|
|
150
|
+
const result = await this.request("POST", "/v1/sandboxes", input);
|
|
151
|
+
if (!result)
|
|
152
|
+
throw new BroodsAccountApiError("POST", "/v1/sandboxes", 404, "Not found");
|
|
153
|
+
return result;
|
|
154
|
+
}
|
|
155
|
+
async getSandbox(sandboxId) {
|
|
156
|
+
return await this.request("GET", `/v1/sandboxes/${encodeURIComponent(sandboxId)}`);
|
|
157
|
+
}
|
|
158
|
+
async updateSandbox(sandboxId, patch) {
|
|
159
|
+
return await this.request("PATCH", `/v1/sandboxes/${encodeURIComponent(sandboxId)}`, patch);
|
|
160
|
+
}
|
|
161
|
+
async deleteSandbox(sandboxId) {
|
|
162
|
+
const result = await this.request("DELETE", `/v1/sandboxes/${encodeURIComponent(sandboxId)}`);
|
|
163
|
+
return result?.deleted ?? false;
|
|
164
|
+
}
|
|
165
|
+
async suspendSandbox(sandboxId, reservationKey) {
|
|
166
|
+
return await this.sandboxAction(sandboxId, "suspend", { reservationKey });
|
|
167
|
+
}
|
|
168
|
+
async resumeSandbox(sandboxId, reservationKey) {
|
|
169
|
+
return await this.sandboxAction(sandboxId, "resume", { reservationKey });
|
|
170
|
+
}
|
|
171
|
+
async terminateSandbox(sandboxId, reservationKey) {
|
|
172
|
+
return await this.sandboxAction(sandboxId, "terminate", { reservationKey });
|
|
173
|
+
}
|
|
174
|
+
async snapshotSandbox(sandboxId, reservationKey, name) {
|
|
175
|
+
return await this.sandboxAction(sandboxId, "snapshot", { reservationKey, name });
|
|
176
|
+
}
|
|
177
|
+
async openSandboxTerminal(sandboxId, reservationKey) {
|
|
178
|
+
return await this.sandboxAction(sandboxId, "terminal", { reservationKey });
|
|
179
|
+
}
|
|
180
|
+
async listTools() {
|
|
181
|
+
const result = await this.request("GET", "/v1/tools");
|
|
182
|
+
return result?.tools ?? [];
|
|
183
|
+
}
|
|
184
|
+
async createTool(input) {
|
|
185
|
+
const result = await this.request("POST", "/v1/tools", input);
|
|
186
|
+
if (!result)
|
|
187
|
+
throw new BroodsAccountApiError("POST", "/v1/tools", 404, "Not found");
|
|
188
|
+
return result;
|
|
189
|
+
}
|
|
190
|
+
async getTool(toolId) {
|
|
191
|
+
return await this.request("GET", `/v1/tools/${encodeURIComponent(toolId)}`);
|
|
192
|
+
}
|
|
193
|
+
async updateTool(toolId, patch) {
|
|
194
|
+
return await this.request("PATCH", `/v1/tools/${encodeURIComponent(toolId)}`, patch);
|
|
195
|
+
}
|
|
196
|
+
async deleteTool(toolId) {
|
|
197
|
+
const result = await this.request("DELETE", `/v1/tools/${encodeURIComponent(toolId)}`);
|
|
198
|
+
return result?.deleted ?? false;
|
|
199
|
+
}
|
|
200
|
+
async listPolicies() {
|
|
201
|
+
const result = await this.request("GET", "/v1/policies");
|
|
202
|
+
return result?.policies ?? [];
|
|
203
|
+
}
|
|
204
|
+
async createPolicy(input) {
|
|
205
|
+
const result = await this.request("POST", "/v1/policies", input);
|
|
206
|
+
if (!result)
|
|
207
|
+
throw new BroodsAccountApiError("POST", "/v1/policies", 404, "Not found");
|
|
208
|
+
return result;
|
|
209
|
+
}
|
|
210
|
+
async getPolicy(policyId) {
|
|
211
|
+
return await this.request("GET", `/v1/policies/${encodeURIComponent(policyId)}`);
|
|
212
|
+
}
|
|
213
|
+
async updatePolicy(policyId, patch) {
|
|
214
|
+
return await this.request("PATCH", `/v1/policies/${encodeURIComponent(policyId)}`, patch);
|
|
215
|
+
}
|
|
216
|
+
async deletePolicy(policyId) {
|
|
217
|
+
const result = await this.request("DELETE", `/v1/policies/${encodeURIComponent(policyId)}`);
|
|
218
|
+
return result?.deleted ?? false;
|
|
219
|
+
}
|
|
220
|
+
async listSkills() {
|
|
221
|
+
const result = await this.request("GET", "/v1/skills");
|
|
222
|
+
return result?.skills ?? [];
|
|
223
|
+
}
|
|
224
|
+
async createSkill(input) {
|
|
225
|
+
const result = await this.request("POST", "/v1/skills", input);
|
|
226
|
+
if (!result)
|
|
227
|
+
throw new BroodsAccountApiError("POST", "/v1/skills", 404, "Not found");
|
|
228
|
+
return result;
|
|
229
|
+
}
|
|
230
|
+
async getSkill(skillName) {
|
|
231
|
+
return await this.request("GET", `/v1/skills/${encodeURIComponent(skillName)}`);
|
|
232
|
+
}
|
|
233
|
+
async uploadSkill(skillName, input) {
|
|
234
|
+
const path = `/v1/skills/${encodeURIComponent(skillName)}`;
|
|
235
|
+
const result = await this.request("PUT", path, input);
|
|
236
|
+
if (!result)
|
|
237
|
+
throw new BroodsAccountApiError("PUT", path, 404, "Skill not found");
|
|
238
|
+
return result;
|
|
239
|
+
}
|
|
240
|
+
async deleteSkill(skillName) {
|
|
241
|
+
const result = await this.request("DELETE", `/v1/skills/${encodeURIComponent(skillName)}`);
|
|
242
|
+
return result?.deleted ?? false;
|
|
243
|
+
}
|
|
244
|
+
async sandboxAction(sandboxId, action, body) {
|
|
245
|
+
const path = `/v1/sandboxes/${encodeURIComponent(sandboxId)}/${action}`;
|
|
246
|
+
const result = await this.request("POST", path, body);
|
|
247
|
+
if (!result)
|
|
248
|
+
throw new BroodsAccountApiError("POST", path, 404, "Sandbox not found");
|
|
249
|
+
return result;
|
|
250
|
+
}
|
|
251
|
+
async request(method, path, body) {
|
|
252
|
+
const response = await this.fetchImpl(`${this.baseUrl}${path}`, {
|
|
253
|
+
method,
|
|
254
|
+
headers: {
|
|
255
|
+
Authorization: `Bearer ${this.accountSecret}`,
|
|
256
|
+
...body !== undefined ? { "Content-Type": "application/json" } : {}
|
|
257
|
+
},
|
|
258
|
+
...body !== undefined ? { body: JSON.stringify(body) } : {}
|
|
259
|
+
});
|
|
260
|
+
if (response.status === 404)
|
|
261
|
+
return null;
|
|
262
|
+
if (!response.ok) {
|
|
263
|
+
throw new BroodsAccountApiError(method, path, response.status, await response.text());
|
|
264
|
+
}
|
|
265
|
+
return await response.json();
|
|
266
|
+
}
|
|
267
|
+
}
|
|
2
268
|
// src/run-input.ts
|
|
3
269
|
function resolveRunEvents(input) {
|
|
4
270
|
if (input.events && input.input !== undefined) {
|
|
@@ -857,5 +1123,7 @@ export {
|
|
|
857
1123
|
MAX_OBSERVABILITY_BACKFILL,
|
|
858
1124
|
DEFAULT_CORE_BASE_URL,
|
|
859
1125
|
BroodsWebSocketClient,
|
|
860
|
-
BroodsClient
|
|
1126
|
+
BroodsClient,
|
|
1127
|
+
BroodsAccountClient,
|
|
1128
|
+
BroodsAccountApiError
|
|
861
1129
|
};
|