@blazingagents/sdk 0.1.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/LICENSE +21 -0
- package/README.md +366 -0
- package/dist/chat-transport.d.ts +17 -0
- package/dist/chat-transport.js +58 -0
- package/dist/client.d.ts +38 -0
- package/dist/client.js +86 -0
- package/dist/contracts/api.d.ts +256 -0
- package/dist/contracts/api.js +189 -0
- package/dist/contracts/entities/agent-tools.d.ts +26 -0
- package/dist/contracts/entities/agent-tools.js +52 -0
- package/dist/contracts/entities/agents.d.ts +183 -0
- package/dist/contracts/entities/agents.js +153 -0
- package/dist/contracts/entities/artifacts.d.ts +71 -0
- package/dist/contracts/entities/artifacts.js +71 -0
- package/dist/contracts/entities/attribution.d.ts +27 -0
- package/dist/contracts/entities/attribution.js +27 -0
- package/dist/contracts/entities/chat.d.ts +269 -0
- package/dist/contracts/entities/chat.js +198 -0
- package/dist/contracts/entities/mcp-connections.d.ts +421 -0
- package/dist/contracts/entities/mcp-connections.js +473 -0
- package/dist/contracts/entities/memories.d.ts +56 -0
- package/dist/contracts/entities/memories.js +62 -0
- package/dist/contracts/entities/prompts.d.ts +61 -0
- package/dist/contracts/entities/prompts.js +96 -0
- package/dist/contracts/entities/providers.d.ts +123 -0
- package/dist/contracts/entities/providers.js +111 -0
- package/dist/contracts/entities/sessions.d.ts +156 -0
- package/dist/contracts/entities/sessions.js +120 -0
- package/dist/contracts/entities/skills.d.ts +167 -0
- package/dist/contracts/entities/skills.js +153 -0
- package/dist/contracts/entities/tasks.d.ts +457 -0
- package/dist/contracts/entities/tasks.js +252 -0
- package/dist/contracts/entities/tenants.d.ts +69 -0
- package/dist/contracts/entities/tenants.js +54 -0
- package/dist/contracts/entities/usage.d.ts +95 -0
- package/dist/contracts/entities/usage.js +117 -0
- package/dist/contracts/entities/workspaces.d.ts +89 -0
- package/dist/contracts/entities/workspaces.js +71 -0
- package/dist/contracts/ids.d.ts +57 -0
- package/dist/contracts/ids.js +79 -0
- package/dist/contracts/index.d.ts +15 -0
- package/dist/contracts/index.js +16 -0
- package/dist/contracts/limitations.d.ts +138 -0
- package/dist/contracts/limitations.js +140 -0
- package/dist/contracts/utils.d.ts +3 -0
- package/dist/contracts/utils.js +7 -0
- package/dist/errors.d.ts +33 -0
- package/dist/errors.js +48 -0
- package/dist/generation.d.ts +5 -0
- package/dist/generation.js +422 -0
- package/dist/http.d.ts +21 -0
- package/dist/http.js +307 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +13 -0
- package/dist/relay.d.ts +20 -0
- package/dist/relay.js +113 -0
- package/dist/resources/agents.d.ts +8 -0
- package/dist/resources/agents.js +82 -0
- package/dist/resources/artifacts.d.ts +5 -0
- package/dist/resources/artifacts.js +29 -0
- package/dist/resources/mcp-connections.d.ts +2 -0
- package/dist/resources/mcp-connections.js +40 -0
- package/dist/resources/memories.d.ts +7 -0
- package/dist/resources/memories.js +33 -0
- package/dist/resources/prompts.d.ts +6 -0
- package/dist/resources/prompts.js +36 -0
- package/dist/resources/providers.d.ts +5 -0
- package/dist/resources/providers.js +38 -0
- package/dist/resources/sessions.d.ts +8 -0
- package/dist/resources/sessions.js +49 -0
- package/dist/resources/skills.d.ts +2 -0
- package/dist/resources/skills.js +49 -0
- package/dist/resources/tasks.d.ts +7 -0
- package/dist/resources/tasks.js +63 -0
- package/dist/resources/tenant.d.ts +6 -0
- package/dist/resources/tenant.js +19 -0
- package/dist/resources/usage.d.ts +7 -0
- package/dist/resources/usage.js +19 -0
- package/dist/resources/workspaces.d.ts +2 -0
- package/dist/resources/workspaces.js +31 -0
- package/dist/types.d.ts +381 -0
- package/dist/types.js +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { cursorSchema, paginatedResponseSchema } from "../api.js";
|
|
3
|
+
import { tenantIdSchema, workspaceIdSchema } from "../ids.js";
|
|
4
|
+
import { DEFAULT_WORKSPACES_LIST_LIMIT, MAX_WORKSPACE_NAME_LENGTH, MAX_WORKSPACES_LIST_LIMIT, } from "../limitations.js";
|
|
5
|
+
import { hasObjectKeys } from "../utils.js";
|
|
6
|
+
import { metadataSchema, userIdSchema } from "./attribution.js";
|
|
7
|
+
export const workspaceNameSchema = z
|
|
8
|
+
.string()
|
|
9
|
+
.trim()
|
|
10
|
+
.min(1)
|
|
11
|
+
.max(MAX_WORKSPACE_NAME_LENGTH);
|
|
12
|
+
export const workspaceBackupSchema = z
|
|
13
|
+
.object({
|
|
14
|
+
dir: z.literal("/workspace"),
|
|
15
|
+
id: z.uuid(),
|
|
16
|
+
localBucket: z.boolean().optional(),
|
|
17
|
+
})
|
|
18
|
+
.strict();
|
|
19
|
+
export const workspaceNetworkPolicySchema = z.discriminatedUnion("mode", [
|
|
20
|
+
z.object({ mode: z.literal("unrestricted") }).strict(),
|
|
21
|
+
z
|
|
22
|
+
.object({
|
|
23
|
+
allowedHosts: z.array(z.string().trim().min(1)).min(1),
|
|
24
|
+
mode: z.literal("allowlist"),
|
|
25
|
+
})
|
|
26
|
+
.strict(),
|
|
27
|
+
z.object({ mode: z.literal("offline") }).strict(),
|
|
28
|
+
]);
|
|
29
|
+
export const workspaceSchema = z
|
|
30
|
+
.object({
|
|
31
|
+
id: workspaceIdSchema,
|
|
32
|
+
tenantId: tenantIdSchema,
|
|
33
|
+
name: workspaceNameSchema.nullable(),
|
|
34
|
+
userId: userIdSchema,
|
|
35
|
+
metadata: metadataSchema,
|
|
36
|
+
networkPolicy: workspaceNetworkPolicySchema,
|
|
37
|
+
createdAt: z.iso.datetime({ offset: true }),
|
|
38
|
+
updatedAt: z.iso.datetime({ offset: true }),
|
|
39
|
+
})
|
|
40
|
+
.strict();
|
|
41
|
+
export const createWorkspaceBodySchema = z
|
|
42
|
+
.object({
|
|
43
|
+
name: workspaceNameSchema.optional(),
|
|
44
|
+
userId: userIdSchema.default(""),
|
|
45
|
+
metadata: metadataSchema.default({}),
|
|
46
|
+
networkPolicy: workspaceNetworkPolicySchema.default({
|
|
47
|
+
mode: "unrestricted",
|
|
48
|
+
}),
|
|
49
|
+
})
|
|
50
|
+
.strict();
|
|
51
|
+
export const updateWorkspaceBodySchema = z
|
|
52
|
+
.object({
|
|
53
|
+
name: workspaceNameSchema.nullable().optional(),
|
|
54
|
+
metadata: metadataSchema.optional(),
|
|
55
|
+
networkPolicy: workspaceNetworkPolicySchema.optional(),
|
|
56
|
+
})
|
|
57
|
+
.strict()
|
|
58
|
+
.refine(hasObjectKeys, { message: "At least one field is required." });
|
|
59
|
+
export const workspaceListQuerySchema = z
|
|
60
|
+
.object({
|
|
61
|
+
cursor: cursorSchema.optional(),
|
|
62
|
+
limit: z.coerce
|
|
63
|
+
.number()
|
|
64
|
+
.int()
|
|
65
|
+
.min(1)
|
|
66
|
+
.max(MAX_WORKSPACES_LIST_LIMIT)
|
|
67
|
+
.default(DEFAULT_WORKSPACES_LIST_LIMIT),
|
|
68
|
+
userId: userIdSchema.optional(),
|
|
69
|
+
})
|
|
70
|
+
.strict();
|
|
71
|
+
export const workspacesListResponseSchema = paginatedResponseSchema(workspaceSchema);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const ADMIN_AGENT_ID_PREFIX = "ag_adm";
|
|
3
|
+
export declare const createTenantId: () => string;
|
|
4
|
+
export declare const createAgentId: () => string;
|
|
5
|
+
export declare const mintAdminAgentId: () => string;
|
|
6
|
+
export declare const createSessionId: () => string;
|
|
7
|
+
export declare const createApiKeyId: () => string;
|
|
8
|
+
export declare const createProviderId: () => string;
|
|
9
|
+
export declare const createMcpConnectionId: () => string;
|
|
10
|
+
export declare const createWorkspaceId: () => string;
|
|
11
|
+
export declare const createArtifactId: () => string;
|
|
12
|
+
export declare const createTaskId: () => string;
|
|
13
|
+
export declare const createTaskRunId: () => string;
|
|
14
|
+
export declare const createMemoryId: () => string;
|
|
15
|
+
export declare const createPromptId: () => string;
|
|
16
|
+
export declare const createRequestId: () => string;
|
|
17
|
+
export declare const createCheckoutAttemptId: () => string;
|
|
18
|
+
export declare const createSkillId: () => string;
|
|
19
|
+
/**
|
|
20
|
+
* API keys — `ba_` + 40 base62 chars (~230 bits entropy). The full token is
|
|
21
|
+
* shown once at creation; only the sha256 hash and a 2-char display fragment
|
|
22
|
+
* are stored. (docs/adr/0004-unified-v1-dual-credential-auth.md)
|
|
23
|
+
*/
|
|
24
|
+
export declare const API_KEY_TOKEN_PREFIX = "ba_";
|
|
25
|
+
export declare function createApiKeyToken(): string;
|
|
26
|
+
/**
|
|
27
|
+
* The display fragment is `ba_` + the first 2 chars of the random body —
|
|
28
|
+
* safe to store (~12 of ~230 bits revealed).
|
|
29
|
+
*/
|
|
30
|
+
export declare function apiKeyFragmentFromToken(token: string): string;
|
|
31
|
+
export declare const tenantIdSchema: z.ZodString;
|
|
32
|
+
export declare const agentIdSchema: z.ZodString;
|
|
33
|
+
export declare const isAdminAgentId: (id: string) => boolean;
|
|
34
|
+
export declare const sessionIdSchema: z.ZodString;
|
|
35
|
+
export declare const apiKeyIdSchema: z.ZodString;
|
|
36
|
+
export declare const providerIdSchema: z.ZodString;
|
|
37
|
+
export declare const mcpConnectionIdSchema: z.ZodString;
|
|
38
|
+
export declare const workspaceIdSchema: z.ZodString;
|
|
39
|
+
export declare const artifactIdSchema: z.ZodString;
|
|
40
|
+
export declare const taskIdSchema: z.ZodString;
|
|
41
|
+
export declare const taskRunIdSchema: z.ZodString;
|
|
42
|
+
export declare const memoryIdSchema: z.ZodString;
|
|
43
|
+
export declare const promptIdSchema: z.ZodString;
|
|
44
|
+
export declare const requestIdSchema: z.ZodString;
|
|
45
|
+
export declare const checkoutAttemptIdSchema: z.ZodString;
|
|
46
|
+
export declare const turnIdSchema: z.ZodString;
|
|
47
|
+
export declare const skillIdSchema: z.ZodString;
|
|
48
|
+
/**
|
|
49
|
+
* API key token + digest helpers. The digest is sha256 hex (64 chars); the
|
|
50
|
+
* fragment is `ba_` + 2 base62 chars. Both stored columns are format-checked
|
|
51
|
+
* in the migration.
|
|
52
|
+
*/
|
|
53
|
+
export declare const apiKeyTokenSchema: z.ZodString;
|
|
54
|
+
export declare const apiKeyDigestSchema: z.ZodString;
|
|
55
|
+
export declare const apiKeyFragmentSchema: z.ZodString;
|
|
56
|
+
export declare const providerKeyFragmentSchema: z.ZodString;
|
|
57
|
+
export type TurnId = z.infer<typeof turnIdSchema>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { customAlphabet } from "nanoid";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
/**
|
|
4
|
+
* Base62 — the alphabet every platform id body uses (16 chars for ids,
|
|
5
|
+
* 40 chars for API key bodies). Matches the regex check constraints in every
|
|
6
|
+
* migration: `^<prefix>_[0-9A-Za-z]{16}$`.
|
|
7
|
+
*/
|
|
8
|
+
const BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
9
|
+
export const ADMIN_AGENT_ID_PREFIX = "ag_adm";
|
|
10
|
+
const createNanoId16 = customAlphabet(BASE62, 16);
|
|
11
|
+
const createNanoId13 = customAlphabet(BASE62, 13);
|
|
12
|
+
const createAgentIdFirstChar = customAlphabet(BASE62.replace("a", ""), 1);
|
|
13
|
+
const createNanoId15 = customAlphabet(BASE62, 15);
|
|
14
|
+
const createNanoId40 = customAlphabet(BASE62, 40);
|
|
15
|
+
const platformId = (prefix) => () => `${prefix}_${createNanoId16()}`;
|
|
16
|
+
export const createTenantId = platformId("ten");
|
|
17
|
+
export const createAgentId = () => `ag_${createAgentIdFirstChar()}${createNanoId15()}`;
|
|
18
|
+
export const mintAdminAgentId = () => `${ADMIN_AGENT_ID_PREFIX}${createNanoId13()}`;
|
|
19
|
+
export const createSessionId = platformId("ss");
|
|
20
|
+
export const createApiKeyId = platformId("ak");
|
|
21
|
+
export const createProviderId = platformId("prv");
|
|
22
|
+
export const createMcpConnectionId = platformId("mcp");
|
|
23
|
+
export const createWorkspaceId = platformId("ws");
|
|
24
|
+
export const createArtifactId = platformId("at");
|
|
25
|
+
export const createTaskId = platformId("tk");
|
|
26
|
+
export const createTaskRunId = platformId("tr");
|
|
27
|
+
export const createMemoryId = platformId("mem");
|
|
28
|
+
export const createPromptId = platformId("prompt");
|
|
29
|
+
export const createRequestId = platformId("req");
|
|
30
|
+
export const createCheckoutAttemptId = platformId("ca");
|
|
31
|
+
export const createSkillId = () => `skill_${createNanoId16()}`;
|
|
32
|
+
/**
|
|
33
|
+
* API keys — `ba_` + 40 base62 chars (~230 bits entropy). The full token is
|
|
34
|
+
* shown once at creation; only the sha256 hash and a 2-char display fragment
|
|
35
|
+
* are stored. (docs/adr/0004-unified-v1-dual-credential-auth.md)
|
|
36
|
+
*/
|
|
37
|
+
export const API_KEY_TOKEN_PREFIX = "ba_";
|
|
38
|
+
export function createApiKeyToken() {
|
|
39
|
+
return `${API_KEY_TOKEN_PREFIX}${createNanoId40()}`;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The display fragment is `ba_` + the first 2 chars of the random body —
|
|
43
|
+
* safe to store (~12 of ~230 bits revealed).
|
|
44
|
+
*/
|
|
45
|
+
export function apiKeyFragmentFromToken(token) {
|
|
46
|
+
if (!token.startsWith(API_KEY_TOKEN_PREFIX)) {
|
|
47
|
+
throw new Error(`API key token must start with ${API_KEY_TOKEN_PREFIX}.`);
|
|
48
|
+
}
|
|
49
|
+
const body = token.slice(API_KEY_TOKEN_PREFIX.length);
|
|
50
|
+
return `${API_KEY_TOKEN_PREFIX}${body.slice(0, 2)}`;
|
|
51
|
+
}
|
|
52
|
+
// Schemas — one per id prefix, mirroring the migration check constraints.
|
|
53
|
+
export const tenantIdSchema = z.string().regex(/^ten_[0-9A-Za-z]{16}$/);
|
|
54
|
+
export const agentIdSchema = z.string().regex(/^ag_[0-9A-Za-z]{16}$/);
|
|
55
|
+
export const isAdminAgentId = (id) => id.startsWith(ADMIN_AGENT_ID_PREFIX) && z.validate(agentIdSchema, id);
|
|
56
|
+
export const sessionIdSchema = z.string().regex(/^ss_[0-9A-Za-z]{16}$/);
|
|
57
|
+
export const apiKeyIdSchema = z.string().regex(/^ak_[0-9A-Za-z]{16}$/);
|
|
58
|
+
export const providerIdSchema = z.string().regex(/^prv_[0-9A-Za-z]{16}$/);
|
|
59
|
+
export const mcpConnectionIdSchema = z.string().regex(/^mcp_[0-9A-Za-z]{16}$/);
|
|
60
|
+
export const workspaceIdSchema = z.string().regex(/^ws_[0-9A-Za-z]{16}$/);
|
|
61
|
+
export const artifactIdSchema = z.string().regex(/^at_[0-9A-Za-z]{16}$/);
|
|
62
|
+
export const taskIdSchema = z.string().regex(/^tk_[0-9A-Za-z]{16}$/);
|
|
63
|
+
export const taskRunIdSchema = z.string().regex(/^tr_[0-9A-Za-z]{16}$/);
|
|
64
|
+
export const memoryIdSchema = z.string().regex(/^mem_[0-9A-Za-z]{16}$/);
|
|
65
|
+
export const promptIdSchema = z.string().regex(/^prompt_[0-9A-Za-z]{16}$/);
|
|
66
|
+
export const requestIdSchema = z.string().regex(/^req_[0-9A-Za-z]{16}$/);
|
|
67
|
+
export const checkoutAttemptIdSchema = z.string().regex(/^ca_[0-9A-Za-z]{16}$/);
|
|
68
|
+
export const turnIdSchema = z.string().regex(/^turn_[0-9A-Za-z]{16}$/);
|
|
69
|
+
export const skillIdSchema = z.string().regex(/^skill_[0-9A-Za-z]{16}$/);
|
|
70
|
+
/**
|
|
71
|
+
* API key token + digest helpers. The digest is sha256 hex (64 chars); the
|
|
72
|
+
* fragment is `ba_` + 2 base62 chars. Both stored columns are format-checked
|
|
73
|
+
* in the migration.
|
|
74
|
+
*/
|
|
75
|
+
export const apiKeyTokenSchema = z.string().regex(/^ba_[0-9A-Za-z]{40}$/);
|
|
76
|
+
export const apiKeyDigestSchema = z.string().regex(/^[0-9a-f]{64}$/);
|
|
77
|
+
export const apiKeyFragmentSchema = z.string().regex(/^ba_[0-9A-Za-z]{2}$/);
|
|
78
|
+
// Provider key fragment — last 4 chars of the secret, display-only.
|
|
79
|
+
export const providerKeyFragmentSchema = z.string().min(1).max(4);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Public runtime schemas for the Blazing Agents HTTP API. */
|
|
2
|
+
export { receivedApiErrorResponseSchema } from "./api.ts";
|
|
3
|
+
export { agentResponseSchema, agentsResponseSchema, agentVersionSchema, agentVersionsResponseSchema, } from "./entities/agents.ts";
|
|
4
|
+
export { artifactDownloadUrlResponseSchema, artifactListItemSchema, artifactsListResponseSchema, } from "./entities/artifacts.ts";
|
|
5
|
+
export { mcpAttachmentResponseSchema, mcpAttachmentsResponseSchema, mcpConnectionOauthConnectResponseSchema, mcpConnectionResponseSchema, mcpConnectionsResponseSchema, mcpConnectionTestResponseSchema, } from "./entities/mcp-connections.ts";
|
|
6
|
+
export { memoriesListResponseSchema, memoryResponseSchema, } from "./entities/memories.ts";
|
|
7
|
+
export { promptResponseSchema, promptsResponseSchema, } from "./entities/prompts.ts";
|
|
8
|
+
export { providerModelsResponseSchema, providerResponseSchema, providersResponseSchema, } from "./entities/providers.ts";
|
|
9
|
+
export { sessionMessagesResponseSchema, sessionsListResponseSchema, toolApprovalDecisionResponseSchema, toolApprovalsResponseSchema, } from "./entities/sessions.ts";
|
|
10
|
+
export { skillCopyResultsSchema, skillDetailSchema, skillsListResponseSchema, } from "./entities/skills.ts";
|
|
11
|
+
export { createTaskResponseSchema, createTaskRunResponseSchema, taskResponseSchema, taskRunMessagesResponseSchema, taskRunResponseSchema, taskRunsListResponseSchema, tasksListResponseSchema, } from "./entities/tasks.ts";
|
|
12
|
+
export { tenantSettingsResponseSchema } from "./entities/tenants.ts";
|
|
13
|
+
export { usageResponseSchema } from "./entities/usage.ts";
|
|
14
|
+
export { workspaceSchema, workspacesListResponseSchema, } from "./entities/workspaces.ts";
|
|
15
|
+
export { sessionIdSchema } from "./ids.ts";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Public runtime schemas for the Blazing Agents HTTP API. */
|
|
2
|
+
// biome-ignore lint/performance/noBarrelFile: public contract entry point
|
|
3
|
+
export { receivedApiErrorResponseSchema } from "./api.js";
|
|
4
|
+
export { agentResponseSchema, agentsResponseSchema, agentVersionSchema, agentVersionsResponseSchema, } from "./entities/agents.js";
|
|
5
|
+
export { artifactDownloadUrlResponseSchema, artifactListItemSchema, artifactsListResponseSchema, } from "./entities/artifacts.js";
|
|
6
|
+
export { mcpAttachmentResponseSchema, mcpAttachmentsResponseSchema, mcpConnectionOauthConnectResponseSchema, mcpConnectionResponseSchema, mcpConnectionsResponseSchema, mcpConnectionTestResponseSchema, } from "./entities/mcp-connections.js";
|
|
7
|
+
export { memoriesListResponseSchema, memoryResponseSchema, } from "./entities/memories.js";
|
|
8
|
+
export { promptResponseSchema, promptsResponseSchema, } from "./entities/prompts.js";
|
|
9
|
+
export { providerModelsResponseSchema, providerResponseSchema, providersResponseSchema, } from "./entities/providers.js";
|
|
10
|
+
export { sessionMessagesResponseSchema, sessionsListResponseSchema, toolApprovalDecisionResponseSchema, toolApprovalsResponseSchema, } from "./entities/sessions.js";
|
|
11
|
+
export { skillCopyResultsSchema, skillDetailSchema, skillsListResponseSchema, } from "./entities/skills.js";
|
|
12
|
+
export { createTaskResponseSchema, createTaskRunResponseSchema, taskResponseSchema, taskRunMessagesResponseSchema, taskRunResponseSchema, taskRunsListResponseSchema, tasksListResponseSchema, } from "./entities/tasks.js";
|
|
13
|
+
export { tenantSettingsResponseSchema } from "./entities/tenants.js";
|
|
14
|
+
export { usageResponseSchema } from "./entities/usage.js";
|
|
15
|
+
export { workspaceSchema, workspacesListResponseSchema, } from "./entities/workspaces.js";
|
|
16
|
+
export { sessionIdSchema } from "./ids.js";
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Effort-wide convention: every coded limit lives here as an UPPER_SNAKE_CASE
|
|
3
|
+
* constant. No scattered magic numbers.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* API keys — max 5 per tenant, name ≤ 80 (docs/adr/0004).
|
|
7
|
+
*/
|
|
8
|
+
export declare const MAX_API_KEYS_PER_TENANT = 5;
|
|
9
|
+
export declare const MAX_API_KEY_NAME_LENGTH = 80;
|
|
10
|
+
/**
|
|
11
|
+
* API key token shape — `ba_` + 40 base62 chars (~230 bits entropy).
|
|
12
|
+
* The prefix and body/fragment lengths live in `ids.ts` alongside the
|
|
13
|
+
* generators and schemas.
|
|
14
|
+
*/
|
|
15
|
+
export declare const API_KEY_BODY_LENGTH = 40;
|
|
16
|
+
export declare const API_KEY_FRAGMENT_BODY_LENGTH = 2;
|
|
17
|
+
/** Workspaces. */
|
|
18
|
+
export declare const MAX_WORKSPACE_NAME_LENGTH = 80;
|
|
19
|
+
export declare const MAX_WORKSPACE_ARCHIVE_ENTRIES = 16384;
|
|
20
|
+
export declare const DEFAULT_WORKSPACES_LIST_LIMIT = 50;
|
|
21
|
+
export declare const MAX_WORKSPACES_LIST_LIMIT = 200;
|
|
22
|
+
/**
|
|
23
|
+
* Agent Skills — at most 100 per Agent, 10 MiB per upload/archive and stored
|
|
24
|
+
* namespace, and 100 regular files. Frontmatter follows the Agent Skills
|
|
25
|
+
* specification accepted in ADR-0028.
|
|
26
|
+
*/
|
|
27
|
+
export declare const MAX_SKILLS_PER_AGENT = 100;
|
|
28
|
+
export declare const MAX_SKILL_UPLOAD_BYTES: number;
|
|
29
|
+
export declare const MAX_SKILL_UNCOMPRESSED_BYTES: number;
|
|
30
|
+
export declare const MAX_SKILL_FILES = 100;
|
|
31
|
+
export declare const MAX_SKILL_NAME_LENGTH = 64;
|
|
32
|
+
export declare const MAX_SKILL_DESCRIPTION_LENGTH = 1024;
|
|
33
|
+
export declare const MAX_SKILL_COMPATIBILITY_LENGTH = 500;
|
|
34
|
+
export declare const MAX_SKILL_COPY_DESTINATIONS = 30;
|
|
35
|
+
export declare const DEFAULT_SKILLS_LIST_LIMIT = 50;
|
|
36
|
+
export declare const MAX_SKILLS_LIST_LIMIT = 100;
|
|
37
|
+
/**
|
|
38
|
+
* Prompts — max 100 per tenant, ~10 KB template cap, name ≤ 80.
|
|
39
|
+
*/
|
|
40
|
+
export declare const MAX_PROMPTS_PER_TENANT = 100;
|
|
41
|
+
export declare const MAX_PROMPT_TEMPLATE_BYTES: number;
|
|
42
|
+
export declare const MAX_PROMPT_VARIABLES = 10;
|
|
43
|
+
export declare const MAX_PROMPT_NAME_LENGTH = 80;
|
|
44
|
+
/** Tasks — name ≤ 80, prompt ≤ 6000, interval ≥ 60s. */
|
|
45
|
+
export declare const MAX_TASK_NAME_LENGTH = 80;
|
|
46
|
+
export declare const MAX_TASK_PROMPT_LENGTH = 6000;
|
|
47
|
+
export declare const MIN_TASK_INTERVAL_MS = 60000;
|
|
48
|
+
/**
|
|
49
|
+
* Providers — max 20 per tenant, name ≤ 80.
|
|
50
|
+
*/
|
|
51
|
+
export declare const MAX_PROVIDERS_PER_TENANT = 20;
|
|
52
|
+
export declare const MAX_PROVIDER_NAME_LENGTH = 80;
|
|
53
|
+
export declare const PROVIDER_KEY_FRAGMENT_LENGTH = 4;
|
|
54
|
+
/**
|
|
55
|
+
* MCP Connections — max 50 per tenant, name ≤ 80, URL ≤ 2048.
|
|
56
|
+
*/
|
|
57
|
+
export declare const MAX_MCP_CONNECTIONS_PER_TENANT = 50;
|
|
58
|
+
export declare const MAX_MCP_CONNECTIONS_PER_AGENT = 10;
|
|
59
|
+
export declare const MAX_MCP_CONNECTION_NAME_LENGTH = 80;
|
|
60
|
+
export declare const MAX_MCP_CONNECTION_URL_LENGTH = 2048;
|
|
61
|
+
export declare const MAX_MCP_BEARER_TOKEN_LENGTH = 8192;
|
|
62
|
+
export declare const MAX_MCP_OAUTH_CLIENT_ID_LENGTH = 2048;
|
|
63
|
+
export declare const MAX_MCP_OAUTH_CLIENT_SECRET_LENGTH = 8192;
|
|
64
|
+
export declare const MAX_MCP_OAUTH_SCOPE_LENGTH = 2048;
|
|
65
|
+
export declare const MAX_MCP_CONNECTION_TEST_LATENCY_MS = 60000;
|
|
66
|
+
export declare const MAX_MCP_SERVER_NAME_LENGTH = 200;
|
|
67
|
+
export declare const MAX_MCP_SERVER_VERSION_LENGTH = 100;
|
|
68
|
+
export declare const MAX_MCP_TOOL_NAME_LENGTH = 256;
|
|
69
|
+
export declare const MAX_MCP_TOOLS_PER_CONNECTION = 128;
|
|
70
|
+
export declare const MAX_MCP_TOOLS_PER_TURN = 256;
|
|
71
|
+
export declare const MAX_MCP_CONNECTION_SETUP_CONCURRENCY = 4;
|
|
72
|
+
export declare const MAX_MCP_TOOL_KEY_LENGTH = 63;
|
|
73
|
+
export declare const MAX_MCP_TOOL_DEFINITION_BYTES: number;
|
|
74
|
+
export declare const MAX_MCP_CONNECTION_TOOL_DEFINITIONS_BYTES: number;
|
|
75
|
+
export declare const MAX_MCP_TOOL_RESULT_BYTES: number;
|
|
76
|
+
export declare const MAX_MCP_ATTACHMENT_METADATA_KEYS = 32;
|
|
77
|
+
export declare const MAX_MCP_ATTACHMENT_METADATA_KEY_LENGTH = 64;
|
|
78
|
+
export declare const MAX_MCP_REQUEST_CONTEXT_BYTES: number;
|
|
79
|
+
/** Agents — name ≤ 80, instructions ≤ 3000. */
|
|
80
|
+
export declare const MAX_AGENT_NAME_LENGTH = 80;
|
|
81
|
+
export declare const MAX_AGENT_INSTRUCTIONS_LENGTH = 3000;
|
|
82
|
+
export declare const DEFAULT_AGENT_VERSIONS_LIST_LIMIT = 50;
|
|
83
|
+
export declare const MAX_AGENT_VERSIONS_LIST_LIMIT = 200;
|
|
84
|
+
/**
|
|
85
|
+
* Artifacts — 10 MiB per file, 10 publications per Tool call, and 100
|
|
86
|
+
* Artifacts per Session.
|
|
87
|
+
*/
|
|
88
|
+
export declare const MAX_ARTIFACT_BYTES: number;
|
|
89
|
+
export declare const MAX_ARTIFACT_PUBLICATIONS_PER_CALL = 10;
|
|
90
|
+
export declare const MAX_ARTIFACTS_PER_SESSION = 100;
|
|
91
|
+
/**
|
|
92
|
+
* Sandbox operations — 30-second native Cloudflare commands under a bounded
|
|
93
|
+
* private HTTP caller budget that includes cold Container startup. File
|
|
94
|
+
* transfers are 10 MiB decoded under a 15 MiB authenticated internal JSON
|
|
95
|
+
* request.
|
|
96
|
+
*/
|
|
97
|
+
export declare const CLOUDFLARE_SANDBOX_EXEC_MS = 30000;
|
|
98
|
+
export declare const MAX_SANDBOX_OPERATION_HTTP_MS = 160000;
|
|
99
|
+
export declare const MAX_SANDBOX_FILE_TRANSFER_BYTES: number;
|
|
100
|
+
export declare const MAX_SANDBOX_FILE_CHUNK_BYTES: number;
|
|
101
|
+
export declare const MAX_SANDBOX_REQUEST_BODY_BYTES: number;
|
|
102
|
+
/**
|
|
103
|
+
* Memories — one pool per Agent spanning all `userId` partitions, capped
|
|
104
|
+
* globally at 500 rows (LRU eviction on create), 10 KiB of text per memory
|
|
105
|
+
* (zod byte refine + DB `octet_length` check).
|
|
106
|
+
*/
|
|
107
|
+
export declare const MAX_MEMORIES_PER_AGENT = 500;
|
|
108
|
+
export declare const MAX_MEMORY_TEXT_BYTES: number;
|
|
109
|
+
export declare const DEFAULT_MEMORIES_LIST_LIMIT = 50;
|
|
110
|
+
export declare const MAX_MEMORIES_LIST_LIMIT = 100;
|
|
111
|
+
export declare const DEFAULT_MEMORY_TOOL_SEARCH_LIMIT = 10;
|
|
112
|
+
export declare const MAX_MEMORY_TOOL_SEARCH_LIMIT = 20;
|
|
113
|
+
/**
|
|
114
|
+
* Sessions — messages endpoint default limit 50, max 200.
|
|
115
|
+
*/
|
|
116
|
+
export declare const DEFAULT_SESSION_MESSAGES_LIMIT = 50;
|
|
117
|
+
export declare const MAX_SESSION_MESSAGES_LIMIT = 200;
|
|
118
|
+
/**
|
|
119
|
+
* Usage — range cap 31 days, default 30 days; top-N sessions default 50, max 200.
|
|
120
|
+
*/
|
|
121
|
+
export declare const MAX_USAGE_RANGE_DAYS = 31;
|
|
122
|
+
export declare const DEFAULT_USAGE_RANGE_DAYS = 30;
|
|
123
|
+
export declare const DEFAULT_USAGE_SESSION_TOP_N = 50;
|
|
124
|
+
export declare const MAX_USAGE_SESSION_TOP_N = 200;
|
|
125
|
+
export declare const MIN_QUOTA_RESET_DAY = 1;
|
|
126
|
+
export declare const MAX_QUOTA_RESET_DAY = 28;
|
|
127
|
+
/**
|
|
128
|
+
* Tenant (workspace) — display name ≤ 80, set via `PATCH /v1/tenant`.
|
|
129
|
+
*/
|
|
130
|
+
export declare const MAX_TENANT_NAME_LENGTH = 80;
|
|
131
|
+
/**
|
|
132
|
+
* Tenant resource creation — provisional abuse-protection throughput, applied
|
|
133
|
+
* independently to Agent, Task, and Workspace creation.
|
|
134
|
+
*/
|
|
135
|
+
export declare const TENANT_CREATION_BURST_LIMIT = 60;
|
|
136
|
+
export declare const TENANT_CREATION_BURST_WINDOW_MS = 60000;
|
|
137
|
+
export declare const TENANT_CREATION_SUSTAINED_LIMIT = 1000;
|
|
138
|
+
export declare const TENANT_CREATION_SUSTAINED_WINDOW_MS = 86400000;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Effort-wide convention: every coded limit lives here as an UPPER_SNAKE_CASE
|
|
3
|
+
* constant. No scattered magic numbers.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* API keys — max 5 per tenant, name ≤ 80 (docs/adr/0004).
|
|
7
|
+
*/
|
|
8
|
+
export const MAX_API_KEYS_PER_TENANT = 5;
|
|
9
|
+
export const MAX_API_KEY_NAME_LENGTH = 80;
|
|
10
|
+
/**
|
|
11
|
+
* API key token shape — `ba_` + 40 base62 chars (~230 bits entropy).
|
|
12
|
+
* The prefix and body/fragment lengths live in `ids.ts` alongside the
|
|
13
|
+
* generators and schemas.
|
|
14
|
+
*/
|
|
15
|
+
export const API_KEY_BODY_LENGTH = 40;
|
|
16
|
+
// Display fragment — `ba_` + first 2 chars of the random body.
|
|
17
|
+
export const API_KEY_FRAGMENT_BODY_LENGTH = 2;
|
|
18
|
+
/** Workspaces. */
|
|
19
|
+
export const MAX_WORKSPACE_NAME_LENGTH = 80;
|
|
20
|
+
export const MAX_WORKSPACE_ARCHIVE_ENTRIES = 16_384;
|
|
21
|
+
export const DEFAULT_WORKSPACES_LIST_LIMIT = 50;
|
|
22
|
+
export const MAX_WORKSPACES_LIST_LIMIT = 200;
|
|
23
|
+
/**
|
|
24
|
+
* Agent Skills — at most 100 per Agent, 10 MiB per upload/archive and stored
|
|
25
|
+
* namespace, and 100 regular files. Frontmatter follows the Agent Skills
|
|
26
|
+
* specification accepted in ADR-0028.
|
|
27
|
+
*/
|
|
28
|
+
export const MAX_SKILLS_PER_AGENT = 100;
|
|
29
|
+
export const MAX_SKILL_UPLOAD_BYTES = 10 * 1024 * 1024;
|
|
30
|
+
export const MAX_SKILL_UNCOMPRESSED_BYTES = 10 * 1024 * 1024;
|
|
31
|
+
export const MAX_SKILL_FILES = 100;
|
|
32
|
+
export const MAX_SKILL_NAME_LENGTH = 64;
|
|
33
|
+
export const MAX_SKILL_DESCRIPTION_LENGTH = 1024;
|
|
34
|
+
export const MAX_SKILL_COMPATIBILITY_LENGTH = 500;
|
|
35
|
+
export const MAX_SKILL_COPY_DESTINATIONS = 30;
|
|
36
|
+
export const DEFAULT_SKILLS_LIST_LIMIT = 50;
|
|
37
|
+
export const MAX_SKILLS_LIST_LIMIT = 100;
|
|
38
|
+
/**
|
|
39
|
+
* Prompts — max 100 per tenant, ~10 KB template cap, name ≤ 80.
|
|
40
|
+
*/
|
|
41
|
+
export const MAX_PROMPTS_PER_TENANT = 100;
|
|
42
|
+
export const MAX_PROMPT_TEMPLATE_BYTES = 10 * 1024;
|
|
43
|
+
export const MAX_PROMPT_VARIABLES = 10;
|
|
44
|
+
export const MAX_PROMPT_NAME_LENGTH = 80;
|
|
45
|
+
/** Tasks — name ≤ 80, prompt ≤ 6000, interval ≥ 60s. */
|
|
46
|
+
export const MAX_TASK_NAME_LENGTH = 80;
|
|
47
|
+
export const MAX_TASK_PROMPT_LENGTH = 6000;
|
|
48
|
+
export const MIN_TASK_INTERVAL_MS = 60_000;
|
|
49
|
+
/**
|
|
50
|
+
* Providers — max 20 per tenant, name ≤ 80.
|
|
51
|
+
*/
|
|
52
|
+
export const MAX_PROVIDERS_PER_TENANT = 20;
|
|
53
|
+
export const MAX_PROVIDER_NAME_LENGTH = 80;
|
|
54
|
+
export const PROVIDER_KEY_FRAGMENT_LENGTH = 4;
|
|
55
|
+
/**
|
|
56
|
+
* MCP Connections — max 50 per tenant, name ≤ 80, URL ≤ 2048.
|
|
57
|
+
*/
|
|
58
|
+
export const MAX_MCP_CONNECTIONS_PER_TENANT = 50;
|
|
59
|
+
export const MAX_MCP_CONNECTIONS_PER_AGENT = 10;
|
|
60
|
+
export const MAX_MCP_CONNECTION_NAME_LENGTH = 80;
|
|
61
|
+
export const MAX_MCP_CONNECTION_URL_LENGTH = 2048;
|
|
62
|
+
export const MAX_MCP_BEARER_TOKEN_LENGTH = 8192;
|
|
63
|
+
export const MAX_MCP_OAUTH_CLIENT_ID_LENGTH = 2048;
|
|
64
|
+
export const MAX_MCP_OAUTH_CLIENT_SECRET_LENGTH = 8192;
|
|
65
|
+
export const MAX_MCP_OAUTH_SCOPE_LENGTH = 2048;
|
|
66
|
+
export const MAX_MCP_CONNECTION_TEST_LATENCY_MS = 60_000;
|
|
67
|
+
export const MAX_MCP_SERVER_NAME_LENGTH = 200;
|
|
68
|
+
export const MAX_MCP_SERVER_VERSION_LENGTH = 100;
|
|
69
|
+
export const MAX_MCP_TOOL_NAME_LENGTH = 256;
|
|
70
|
+
export const MAX_MCP_TOOLS_PER_CONNECTION = 128;
|
|
71
|
+
export const MAX_MCP_TOOLS_PER_TURN = 256;
|
|
72
|
+
export const MAX_MCP_CONNECTION_SETUP_CONCURRENCY = 4;
|
|
73
|
+
export const MAX_MCP_TOOL_KEY_LENGTH = 63;
|
|
74
|
+
export const MAX_MCP_TOOL_DEFINITION_BYTES = 256 * 1024;
|
|
75
|
+
export const MAX_MCP_CONNECTION_TOOL_DEFINITIONS_BYTES = 1024 * 1024;
|
|
76
|
+
export const MAX_MCP_TOOL_RESULT_BYTES = 1024 * 1024;
|
|
77
|
+
export const MAX_MCP_ATTACHMENT_METADATA_KEYS = 32;
|
|
78
|
+
export const MAX_MCP_ATTACHMENT_METADATA_KEY_LENGTH = 64;
|
|
79
|
+
export const MAX_MCP_REQUEST_CONTEXT_BYTES = 16 * 1024;
|
|
80
|
+
/** Agents — name ≤ 80, instructions ≤ 3000. */
|
|
81
|
+
export const MAX_AGENT_NAME_LENGTH = 80;
|
|
82
|
+
export const MAX_AGENT_INSTRUCTIONS_LENGTH = 3000;
|
|
83
|
+
export const DEFAULT_AGENT_VERSIONS_LIST_LIMIT = 50;
|
|
84
|
+
export const MAX_AGENT_VERSIONS_LIST_LIMIT = 200;
|
|
85
|
+
/**
|
|
86
|
+
* Artifacts — 10 MiB per file, 10 publications per Tool call, and 100
|
|
87
|
+
* Artifacts per Session.
|
|
88
|
+
*/
|
|
89
|
+
export const MAX_ARTIFACT_BYTES = 10 * 1024 * 1024;
|
|
90
|
+
export const MAX_ARTIFACT_PUBLICATIONS_PER_CALL = 10;
|
|
91
|
+
export const MAX_ARTIFACTS_PER_SESSION = 100;
|
|
92
|
+
/**
|
|
93
|
+
* Sandbox operations — 30-second native Cloudflare commands under a bounded
|
|
94
|
+
* private HTTP caller budget that includes cold Container startup. File
|
|
95
|
+
* transfers are 10 MiB decoded under a 15 MiB authenticated internal JSON
|
|
96
|
+
* request.
|
|
97
|
+
*/
|
|
98
|
+
export const CLOUDFLARE_SANDBOX_EXEC_MS = 30_000;
|
|
99
|
+
export const MAX_SANDBOX_OPERATION_HTTP_MS = 160_000;
|
|
100
|
+
export const MAX_SANDBOX_FILE_TRANSFER_BYTES = 10 * 1024 * 1024;
|
|
101
|
+
export const MAX_SANDBOX_FILE_CHUNK_BYTES = 1024 * 1024;
|
|
102
|
+
export const MAX_SANDBOX_REQUEST_BODY_BYTES = 15 * 1024 * 1024;
|
|
103
|
+
/**
|
|
104
|
+
* Memories — one pool per Agent spanning all `userId` partitions, capped
|
|
105
|
+
* globally at 500 rows (LRU eviction on create), 10 KiB of text per memory
|
|
106
|
+
* (zod byte refine + DB `octet_length` check).
|
|
107
|
+
*/
|
|
108
|
+
export const MAX_MEMORIES_PER_AGENT = 500;
|
|
109
|
+
export const MAX_MEMORY_TEXT_BYTES = 10 * 1024;
|
|
110
|
+
export const DEFAULT_MEMORIES_LIST_LIMIT = 50;
|
|
111
|
+
export const MAX_MEMORIES_LIST_LIMIT = 100;
|
|
112
|
+
export const DEFAULT_MEMORY_TOOL_SEARCH_LIMIT = 10;
|
|
113
|
+
export const MAX_MEMORY_TOOL_SEARCH_LIMIT = 20;
|
|
114
|
+
/**
|
|
115
|
+
* Sessions — messages endpoint default limit 50, max 200.
|
|
116
|
+
*/
|
|
117
|
+
export const DEFAULT_SESSION_MESSAGES_LIMIT = 50;
|
|
118
|
+
export const MAX_SESSION_MESSAGES_LIMIT = 200;
|
|
119
|
+
/**
|
|
120
|
+
* Usage — range cap 31 days, default 30 days; top-N sessions default 50, max 200.
|
|
121
|
+
*/
|
|
122
|
+
export const MAX_USAGE_RANGE_DAYS = 31;
|
|
123
|
+
export const DEFAULT_USAGE_RANGE_DAYS = 30;
|
|
124
|
+
export const DEFAULT_USAGE_SESSION_TOP_N = 50;
|
|
125
|
+
export const MAX_USAGE_SESSION_TOP_N = 200;
|
|
126
|
+
// Quota — reset day between 1 and 28.
|
|
127
|
+
export const MIN_QUOTA_RESET_DAY = 1;
|
|
128
|
+
export const MAX_QUOTA_RESET_DAY = 28;
|
|
129
|
+
/**
|
|
130
|
+
* Tenant (workspace) — display name ≤ 80, set via `PATCH /v1/tenant`.
|
|
131
|
+
*/
|
|
132
|
+
export const MAX_TENANT_NAME_LENGTH = 80;
|
|
133
|
+
/**
|
|
134
|
+
* Tenant resource creation — provisional abuse-protection throughput, applied
|
|
135
|
+
* independently to Agent, Task, and Workspace creation.
|
|
136
|
+
*/
|
|
137
|
+
export const TENANT_CREATION_BURST_LIMIT = 60;
|
|
138
|
+
export const TENANT_CREATION_BURST_WINDOW_MS = 60_000;
|
|
139
|
+
export const TENANT_CREATION_SUSTAINED_LIMIT = 1000;
|
|
140
|
+
export const TENANT_CREATION_SUSTAINED_WINDOW_MS = 86_400_000;
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { BlazingAgentsErrorCode } from "./types.ts";
|
|
2
|
+
declare const BLAZING_AGENTS_ERROR_SYMBOL: unique symbol;
|
|
3
|
+
export declare class BlazingAgentsError extends Error {
|
|
4
|
+
readonly cause?: unknown;
|
|
5
|
+
readonly code: BlazingAgentsErrorCode;
|
|
6
|
+
readonly details?: Record<string, unknown>;
|
|
7
|
+
readonly headers?: Headers;
|
|
8
|
+
readonly param?: string;
|
|
9
|
+
readonly requestId?: string;
|
|
10
|
+
readonly responseBody?: string;
|
|
11
|
+
readonly responseBodyTruncated?: boolean;
|
|
12
|
+
readonly status?: number;
|
|
13
|
+
/**
|
|
14
|
+
* Marker property used by `isInstance` for cross-realm `instanceof`
|
|
15
|
+
* checks — the symbol is checked via `in`, not direct property access,
|
|
16
|
+
* so the linter can't see the read.
|
|
17
|
+
* biome-ignore lint/correctness/noUnusedPrivateClassMembers: marker pattern
|
|
18
|
+
*/
|
|
19
|
+
private readonly [BLAZING_AGENTS_ERROR_SYMBOL];
|
|
20
|
+
constructor({ code, details, headers, message, param, requestId, responseBody, responseBodyTruncated, status, }: {
|
|
21
|
+
code: BlazingAgentsErrorCode;
|
|
22
|
+
details?: Record<string, unknown>;
|
|
23
|
+
headers?: Headers;
|
|
24
|
+
message: string;
|
|
25
|
+
param?: string;
|
|
26
|
+
requestId?: string;
|
|
27
|
+
responseBody?: string;
|
|
28
|
+
responseBodyTruncated?: boolean;
|
|
29
|
+
status?: number;
|
|
30
|
+
}, options?: ErrorOptions);
|
|
31
|
+
static isInstance(error: unknown): error is BlazingAgentsError;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The SDK's single error class. Server codes remain open for forward
|
|
3
|
+
* compatibility; SDK-local codes distinguish transport, response, abort, and
|
|
4
|
+
* streaming failures.
|
|
5
|
+
*
|
|
6
|
+
* `isInstance` uses the AI SDK's `Symbol.for` marker pattern so it
|
|
7
|
+
* survives duplicated package copies across realms/bundlers.
|
|
8
|
+
*/
|
|
9
|
+
const BLAZING_AGENTS_ERROR_NAME = "BlazingAgentsError";
|
|
10
|
+
const BLAZING_AGENTS_ERROR_MARKER = "blazing-agents.error.BlazingAgentsError";
|
|
11
|
+
const BLAZING_AGENTS_ERROR_SYMBOL = Symbol.for(BLAZING_AGENTS_ERROR_MARKER);
|
|
12
|
+
export class BlazingAgentsError extends Error {
|
|
13
|
+
code;
|
|
14
|
+
details;
|
|
15
|
+
headers;
|
|
16
|
+
param;
|
|
17
|
+
requestId;
|
|
18
|
+
responseBody;
|
|
19
|
+
responseBodyTruncated;
|
|
20
|
+
status;
|
|
21
|
+
// Stryker disable BooleanLiteral: cross-realm identity depends on marker presence, not its value.
|
|
22
|
+
/**
|
|
23
|
+
* Marker property used by `isInstance` for cross-realm `instanceof`
|
|
24
|
+
* checks — the symbol is checked via `in`, not direct property access,
|
|
25
|
+
* so the linter can't see the read.
|
|
26
|
+
* biome-ignore lint/correctness/noUnusedPrivateClassMembers: marker pattern
|
|
27
|
+
*/
|
|
28
|
+
[BLAZING_AGENTS_ERROR_SYMBOL] = true;
|
|
29
|
+
// Stryker restore BooleanLiteral
|
|
30
|
+
constructor({ code, details, headers, message, param, requestId, responseBody, responseBodyTruncated, status, }, options) {
|
|
31
|
+
super(message, options);
|
|
32
|
+
this.name = BLAZING_AGENTS_ERROR_NAME;
|
|
33
|
+
this.code = code;
|
|
34
|
+
this.details = details;
|
|
35
|
+
this.headers = headers;
|
|
36
|
+
this.param = param;
|
|
37
|
+
this.requestId = requestId;
|
|
38
|
+
this.responseBody = responseBody;
|
|
39
|
+
this.responseBodyTruncated = responseBodyTruncated;
|
|
40
|
+
this.status = status;
|
|
41
|
+
}
|
|
42
|
+
static isInstance(error) {
|
|
43
|
+
if (error === null || typeof error !== "object") {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
return BLAZING_AGENTS_ERROR_SYMBOL in error;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ChatInput, ChatResult, CompletionInput, CompletionResult, HttpConfig, ObjectInput, ObjectResult, TerminalStreamResult } from "./types.ts";
|
|
2
|
+
export declare function chat(config: HttpConfig, input: ChatInput): Promise<ChatResult>;
|
|
3
|
+
export declare function buildTerminalStreamResult(response: Response, resourceName: string): TerminalStreamResult;
|
|
4
|
+
export declare function completion(config: HttpConfig, input: CompletionInput): Promise<CompletionResult>;
|
|
5
|
+
export declare function objectGeneration(config: HttpConfig, input: ObjectInput): Promise<ObjectResult>;
|