@blazingagents/sdk 0.35.0 → 0.37.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.
@@ -379,6 +379,91 @@ export declare const taskRunResponseSchema: z.ZodObject<{
379
379
  succeeded: "succeeded";
380
380
  }>;
381
381
  error: z.ZodNullable<z.ZodString>;
382
+ errorCode: z.ZodNullable<z.ZodEnum<{
383
+ admin_agent_managed: "admin_agent_managed";
384
+ agent_disabled: "agent_disabled";
385
+ agent_mcp_connection_not_found: "agent_mcp_connection_not_found";
386
+ agent_mcp_connections_invalid: "agent_mcp_connections_invalid";
387
+ api_key_limit_reached: "api_key_limit_reached";
388
+ artifact_session_cap_reached: "artifact_session_cap_reached";
389
+ chat_webhook_conflict: "chat_webhook_conflict";
390
+ chat_webhook_registration_failed: "chat_webhook_registration_failed";
391
+ checkout_evidence_mismatch: "checkout_evidence_mismatch";
392
+ forbidden: "forbidden";
393
+ function_call_conflict: "function_call_conflict";
394
+ idempotency_conflict: "idempotency_conflict";
395
+ input_idempotency_conflict: "input_idempotency_conflict";
396
+ insufficient_scope: "insufficient_scope";
397
+ internal: "internal";
398
+ invalid_cursor: "invalid_cursor";
399
+ invalid_request: "invalid_request";
400
+ mcp_connection_authentication_failed: "mcp_connection_authentication_failed";
401
+ mcp_connection_discovery_failed: "mcp_connection_discovery_failed";
402
+ mcp_connection_in_use: "mcp_connection_in_use";
403
+ mcp_connection_invalid: "mcp_connection_invalid";
404
+ mcp_connection_limit_reached: "mcp_connection_limit_reached";
405
+ mcp_connection_name_conflict: "mcp_connection_name_conflict";
406
+ mcp_connection_stale_credential_version: "mcp_connection_stale_credential_version";
407
+ mcp_connection_unreachable: "mcp_connection_unreachable";
408
+ merchant_account_mismatch: "merchant_account_mismatch";
409
+ merchant_balance_required: "merchant_balance_required";
410
+ merchant_binding_not_found: "merchant_binding_not_found";
411
+ merchant_binding_required: "merchant_binding_required";
412
+ merchant_connection_not_found: "merchant_connection_not_found";
413
+ merchant_credential_invalid: "merchant_credential_invalid";
414
+ merchant_customer_not_found: "merchant_customer_not_found";
415
+ merchant_customer_unmapped: "merchant_customer_unmapped";
416
+ merchant_eligibility_unavailable: "merchant_eligibility_unavailable";
417
+ merchant_event_not_found: "merchant_event_not_found";
418
+ merchant_event_state_conflict: "merchant_event_state_conflict";
419
+ merchant_provider_unavailable: "merchant_provider_unavailable";
420
+ merchant_subscription_required: "merchant_subscription_required";
421
+ message_id_conflict: "message_id_conflict";
422
+ message_not_found: "message_not_found";
423
+ model_discovery_unsupported: "model_discovery_unsupported";
424
+ model_not_found: "model_not_found";
425
+ model_spending_limit_exceeded: "model_spending_limit_exceeded";
426
+ model_validation_unavailable: "model_validation_unavailable";
427
+ not_found: "not_found";
428
+ prompt_variable_missing: "prompt_variable_missing";
429
+ prompt_variable_unknown: "prompt_variable_unknown";
430
+ provider_historical_use: "provider_historical_use";
431
+ provider_in_use: "provider_in_use";
432
+ provider_limit_reached: "provider_limit_reached";
433
+ provider_name_conflict: "provider_name_conflict";
434
+ provider_not_found: "provider_not_found";
435
+ provider_required: "provider_required";
436
+ quota_exceeded: "quota_exceeded";
437
+ rate_limited: "rate_limited";
438
+ service_unavailable: "service_unavailable";
439
+ session_busy: "session_busy";
440
+ session_fork_deleted: "session_fork_deleted";
441
+ session_fork_unavailable: "session_fork_unavailable";
442
+ session_turn_unresponsive: "session_turn_unresponsive";
443
+ session_version_mismatch: "session_version_mismatch";
444
+ skill_invalid_archive: "skill_invalid_archive";
445
+ skill_invalid_markdown: "skill_invalid_markdown";
446
+ skill_limit_reached: "skill_limit_reached";
447
+ skill_name_conflict: "skill_name_conflict";
448
+ skill_not_found: "skill_not_found";
449
+ skill_too_many_files: "skill_too_many_files";
450
+ skill_uncompressed_too_large: "skill_uncompressed_too_large";
451
+ steer_not_available: "steer_not_available";
452
+ subscription_required: "subscription_required";
453
+ task_active_run_exists: "task_active_run_exists";
454
+ tenant_deleting: "tenant_deleting";
455
+ tenant_deletion_in_progress: "tenant_deletion_in_progress";
456
+ tenant_deletion_not_ready: "tenant_deletion_not_ready";
457
+ tenant_not_deleting: "tenant_not_deleting";
458
+ tool_approval_continuation_settled: "tool_approval_continuation_settled";
459
+ tool_approval_decision_conflict: "tool_approval_decision_conflict";
460
+ unauthorized: "unauthorized";
461
+ usage_credit_required: "usage_credit_required";
462
+ validation_failed: "validation_failed";
463
+ workspace_busy: "workspace_busy";
464
+ workspace_in_use: "workspace_in_use";
465
+ workspace_not_found: "workspace_not_found";
466
+ }>>;
382
467
  userId: z.ZodString;
383
468
  metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
384
469
  startedAt: z.ZodNullable<z.ZodISODateTime>;
@@ -513,6 +598,91 @@ export declare const taskRunsListResponseSchema: z.ZodObject<{
513
598
  succeeded: "succeeded";
514
599
  }>;
515
600
  error: z.ZodNullable<z.ZodString>;
601
+ errorCode: z.ZodNullable<z.ZodEnum<{
602
+ admin_agent_managed: "admin_agent_managed";
603
+ agent_disabled: "agent_disabled";
604
+ agent_mcp_connection_not_found: "agent_mcp_connection_not_found";
605
+ agent_mcp_connections_invalid: "agent_mcp_connections_invalid";
606
+ api_key_limit_reached: "api_key_limit_reached";
607
+ artifact_session_cap_reached: "artifact_session_cap_reached";
608
+ chat_webhook_conflict: "chat_webhook_conflict";
609
+ chat_webhook_registration_failed: "chat_webhook_registration_failed";
610
+ checkout_evidence_mismatch: "checkout_evidence_mismatch";
611
+ forbidden: "forbidden";
612
+ function_call_conflict: "function_call_conflict";
613
+ idempotency_conflict: "idempotency_conflict";
614
+ input_idempotency_conflict: "input_idempotency_conflict";
615
+ insufficient_scope: "insufficient_scope";
616
+ internal: "internal";
617
+ invalid_cursor: "invalid_cursor";
618
+ invalid_request: "invalid_request";
619
+ mcp_connection_authentication_failed: "mcp_connection_authentication_failed";
620
+ mcp_connection_discovery_failed: "mcp_connection_discovery_failed";
621
+ mcp_connection_in_use: "mcp_connection_in_use";
622
+ mcp_connection_invalid: "mcp_connection_invalid";
623
+ mcp_connection_limit_reached: "mcp_connection_limit_reached";
624
+ mcp_connection_name_conflict: "mcp_connection_name_conflict";
625
+ mcp_connection_stale_credential_version: "mcp_connection_stale_credential_version";
626
+ mcp_connection_unreachable: "mcp_connection_unreachable";
627
+ merchant_account_mismatch: "merchant_account_mismatch";
628
+ merchant_balance_required: "merchant_balance_required";
629
+ merchant_binding_not_found: "merchant_binding_not_found";
630
+ merchant_binding_required: "merchant_binding_required";
631
+ merchant_connection_not_found: "merchant_connection_not_found";
632
+ merchant_credential_invalid: "merchant_credential_invalid";
633
+ merchant_customer_not_found: "merchant_customer_not_found";
634
+ merchant_customer_unmapped: "merchant_customer_unmapped";
635
+ merchant_eligibility_unavailable: "merchant_eligibility_unavailable";
636
+ merchant_event_not_found: "merchant_event_not_found";
637
+ merchant_event_state_conflict: "merchant_event_state_conflict";
638
+ merchant_provider_unavailable: "merchant_provider_unavailable";
639
+ merchant_subscription_required: "merchant_subscription_required";
640
+ message_id_conflict: "message_id_conflict";
641
+ message_not_found: "message_not_found";
642
+ model_discovery_unsupported: "model_discovery_unsupported";
643
+ model_not_found: "model_not_found";
644
+ model_spending_limit_exceeded: "model_spending_limit_exceeded";
645
+ model_validation_unavailable: "model_validation_unavailable";
646
+ not_found: "not_found";
647
+ prompt_variable_missing: "prompt_variable_missing";
648
+ prompt_variable_unknown: "prompt_variable_unknown";
649
+ provider_historical_use: "provider_historical_use";
650
+ provider_in_use: "provider_in_use";
651
+ provider_limit_reached: "provider_limit_reached";
652
+ provider_name_conflict: "provider_name_conflict";
653
+ provider_not_found: "provider_not_found";
654
+ provider_required: "provider_required";
655
+ quota_exceeded: "quota_exceeded";
656
+ rate_limited: "rate_limited";
657
+ service_unavailable: "service_unavailable";
658
+ session_busy: "session_busy";
659
+ session_fork_deleted: "session_fork_deleted";
660
+ session_fork_unavailable: "session_fork_unavailable";
661
+ session_turn_unresponsive: "session_turn_unresponsive";
662
+ session_version_mismatch: "session_version_mismatch";
663
+ skill_invalid_archive: "skill_invalid_archive";
664
+ skill_invalid_markdown: "skill_invalid_markdown";
665
+ skill_limit_reached: "skill_limit_reached";
666
+ skill_name_conflict: "skill_name_conflict";
667
+ skill_not_found: "skill_not_found";
668
+ skill_too_many_files: "skill_too_many_files";
669
+ skill_uncompressed_too_large: "skill_uncompressed_too_large";
670
+ steer_not_available: "steer_not_available";
671
+ subscription_required: "subscription_required";
672
+ task_active_run_exists: "task_active_run_exists";
673
+ tenant_deleting: "tenant_deleting";
674
+ tenant_deletion_in_progress: "tenant_deletion_in_progress";
675
+ tenant_deletion_not_ready: "tenant_deletion_not_ready";
676
+ tenant_not_deleting: "tenant_not_deleting";
677
+ tool_approval_continuation_settled: "tool_approval_continuation_settled";
678
+ tool_approval_decision_conflict: "tool_approval_decision_conflict";
679
+ unauthorized: "unauthorized";
680
+ usage_credit_required: "usage_credit_required";
681
+ validation_failed: "validation_failed";
682
+ workspace_busy: "workspace_busy";
683
+ workspace_in_use: "workspace_in_use";
684
+ workspace_not_found: "workspace_not_found";
685
+ }>>;
516
686
  userId: z.ZodString;
517
687
  metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
518
688
  startedAt: z.ZodNullable<z.ZodISODateTime>;
@@ -1,6 +1,6 @@
1
1
  import { Cron } from "croner";
2
2
  import { z } from "zod";
3
- import { paginatedResponseSchema } from "../api.js";
3
+ import { apiErrorCodeSchema, paginatedResponseSchema } from "../api.js";
4
4
  import { agentIdSchema, sessionIdSchema, taskIdSchema, taskRunIdSchema, tenantIdSchema, turnIdSchema, } from "../ids.js";
5
5
  import { MAX_TASK_NAME_LENGTH, MAX_TASK_PROMPT_LENGTH, MIN_TASK_INTERVAL_MS, } from "../limitations.js";
6
6
  import { atLeastOneFieldMessage, hasObjectKeys } from "../utils.js";
@@ -242,6 +242,9 @@ export const taskRunResponseSchema = z
242
242
  turnId: turnIdSchema.nullable(),
243
243
  status: taskRunStatusSchema,
244
244
  error: z.string().nullable(),
245
+ errorCode: apiErrorCodeSchema
246
+ .nullable()
247
+ .describe("Machine-readable reason a run ended `blocked` or `failed`: one of the API error codes, such as `usage_credit_required`, `quota_exceeded` or `provider_required`. `null` for every other run, and for a failure without a code; `error` carries the message."),
245
248
  userId: userIdSchema,
246
249
  metadata: metadataSchema,
247
250
  startedAt: z.iso.datetime({ offset: true }).nullable(),
package/dist/http.js CHANGED
@@ -4,6 +4,22 @@ const DIAGNOSTIC_BODY_LIMIT_BYTES = 64 * 1024;
4
4
  const INVALID_RESPONSE_MESSAGE = "The server returned an invalid response.";
5
5
  const NETWORK_ERROR_MESSAGE = "Network request failed (fetch threw before any HTTP exchange).";
6
6
  const REQUEST_ABORTED_MESSAGE = "The request was aborted before any HTTP response.";
7
+ /** Fields no credential-bearing operation's response may contain. */
8
+ const CREDENTIAL_KEYS = new Set([
9
+ "apiKey",
10
+ "api_key",
11
+ "botToken",
12
+ "bot_token",
13
+ "signingSecret",
14
+ "signing_secret",
15
+ "webhookSecret",
16
+ "webhook_secret",
17
+ "bearerToken",
18
+ "bearer_token",
19
+ "clientSecret",
20
+ "client_secret",
21
+ "credential",
22
+ ]);
7
23
  const DOT_OR_EMPTY_SEGMENTS = new Set(["", ".", ".."]);
8
24
  /**
9
25
  * Builds an endpoint path, encoding each interpolated value so it stays inside
@@ -70,14 +86,59 @@ export async function requestJson(config, path, options = {}, schema) {
70
86
  }
71
87
  throw invalidResponseError(headers, response.status, read.diagnosticBody, true, read.cause);
72
88
  }
89
+ let json;
90
+ try {
91
+ json = JSON.parse(read.bodyText);
92
+ }
93
+ catch (cause) {
94
+ throw invalidResponseError(headers, response.status, read.diagnosticBody, read.diagnosticBodyTruncated, cause);
95
+ }
96
+ const echoed = options.credentialBearing
97
+ ? findCredentialKey(json)
98
+ : undefined;
99
+ if (echoed !== undefined) {
100
+ throw new BlazingAgentsError({
101
+ code: "credential_echo",
102
+ details: { field: echoed },
103
+ headers,
104
+ message: `The server echoed credential field ${JSON.stringify(echoed)}; the response body was discarded.`,
105
+ requestId: headers.get("x-request-id") ?? undefined,
106
+ status: response.status,
107
+ });
108
+ }
73
109
  try {
74
- const json = JSON.parse(read.bodyText);
75
110
  return schema === undefined ? json : schema.parse(json);
76
111
  }
77
112
  catch (cause) {
78
113
  throw invalidResponseError(headers, response.status, read.diagnosticBody, read.diagnosticBodyTruncated, cause);
79
114
  }
80
115
  }
116
+ /**
117
+ * Returns the first credential field found anywhere in a decoded JSON value.
118
+ */
119
+ function findCredentialKey(value) {
120
+ if (Array.isArray(value)) {
121
+ for (const item of value) {
122
+ const key = findCredentialKey(item);
123
+ if (key !== undefined) {
124
+ return key;
125
+ }
126
+ }
127
+ return;
128
+ }
129
+ if (value === null || typeof value !== "object") {
130
+ return;
131
+ }
132
+ for (const [key, item] of Object.entries(value)) {
133
+ if (CREDENTIAL_KEYS.has(key)) {
134
+ return key;
135
+ }
136
+ const nested = findCredentialKey(item);
137
+ if (nested !== undefined) {
138
+ return nested;
139
+ }
140
+ }
141
+ }
81
142
  /**
82
143
  * Performs a request and returns the raw `Response` for streaming paths.
83
144
  * Non-2xx bodies are decoded before a caller can observe a streaming body.
@@ -8,37 +8,57 @@ import { apiPath, requestJson } from "../http.js";
8
8
  export function createChatConnectionsResource(config) {
9
9
  return {
10
10
  async list({ abortSignal } = {}) {
11
- return await requestJson(config, "/v1/chat-connections", { signal: abortSignal }, chatConnectionsResponseSchema);
11
+ return await requestJson(config, "/v1/chat-connections", { credentialBearing: true, signal: abortSignal }, chatConnectionsResponseSchema);
12
12
  },
13
13
  async create({ abortSignal, ...body }) {
14
- return await requestJson(config, "/v1/chat-connections", { signal: abortSignal, method: "POST", json: body }, chatConnectionSchema);
14
+ return await requestJson(config, "/v1/chat-connections", {
15
+ credentialBearing: true,
16
+ signal: abortSignal,
17
+ method: "POST",
18
+ json: body,
19
+ }, chatConnectionSchema);
15
20
  },
16
21
  async get({ chatConnectionId, abortSignal }) {
17
- return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}`, { signal: abortSignal, method: "GET" }, chatConnectionSchema);
22
+ return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}`, { credentialBearing: true, signal: abortSignal, method: "GET" }, chatConnectionSchema);
18
23
  },
19
24
  async update({ chatConnectionId, abortSignal, ...body }) {
20
- return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}`, { signal: abortSignal, method: "PATCH", json: body }, chatConnectionSchema);
25
+ return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}`, {
26
+ credentialBearing: true,
27
+ signal: abortSignal,
28
+ method: "PATCH",
29
+ json: body,
30
+ }, chatConnectionSchema);
21
31
  },
22
32
  async rotateCredentials({ chatConnectionId, abortSignal, ...body }) {
23
- return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}/credentials`, { signal: abortSignal, method: "POST", json: body }, chatConnectionSchema);
33
+ return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}/credentials`, {
34
+ credentialBearing: true,
35
+ signal: abortSignal,
36
+ method: "POST",
37
+ json: body,
38
+ }, chatConnectionSchema);
24
39
  },
25
40
  async checkHealth({ chatConnectionId, abortSignal }) {
26
- return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}/health`, { signal: abortSignal, method: "POST" }, chatConnectionSchema);
41
+ return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}/health`, { credentialBearing: true, signal: abortSignal, method: "POST" }, chatConnectionSchema);
27
42
  },
28
43
  async listDeliveries({ chatConnectionId, abortSignal, ...query }) {
29
- return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}/deliveries`, { signal: abortSignal, query }, chatDeliveryListSchema);
44
+ return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}/deliveries`, { credentialBearing: true, signal: abortSignal, query }, chatDeliveryListSchema);
30
45
  },
31
46
  async repairDelivery({ chatConnectionId, deliveryId, abortSignal, ...body }) {
32
- return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}/deliveries/${deliveryId}/repair`, { signal: abortSignal, method: "POST", json: body }, chatDeliveryResultSchema);
47
+ return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}/deliveries/${deliveryId}/repair`, {
48
+ credentialBearing: true,
49
+ signal: abortSignal,
50
+ method: "POST",
51
+ json: body,
52
+ }, chatDeliveryResultSchema);
33
53
  },
34
54
  async enable({ chatConnectionId, abortSignal }) {
35
- return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}/enable`, { signal: abortSignal, method: "POST" }, chatConnectionSchema);
55
+ return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}/enable`, { credentialBearing: true, signal: abortSignal, method: "POST" }, chatConnectionSchema);
36
56
  },
37
57
  async disable({ chatConnectionId, abortSignal }) {
38
- return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}/disable`, { signal: abortSignal, method: "POST" }, chatConnectionSchema);
58
+ return await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}/disable`, { credentialBearing: true, signal: abortSignal, method: "POST" }, chatConnectionSchema);
39
59
  },
40
60
  async delete({ chatConnectionId, abortSignal }) {
41
- await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}`, { signal: abortSignal, method: "DELETE" });
61
+ await requestJson(config, apiPath `/v1/chat-connections/${chatConnectionId}`, { credentialBearing: true, signal: abortSignal, method: "DELETE" });
42
62
  },
43
63
  };
44
64
  }
@@ -15,6 +15,7 @@ export function createChatDeliveriesResource(config) {
15
15
  // Multi-value filters serialize as one comma-separated parameter.
16
16
  status: status?.length ? status.join(",") : undefined,
17
17
  },
18
+ credentialBearing: true,
18
19
  signal: abortSignal,
19
20
  }, chatDeliveriesResponseSchema);
20
21
  },
@@ -8,20 +8,22 @@ import { apiPath, requestJson } from "../http.js";
8
8
  export function createMcpConnectionsResource(config) {
9
9
  const create = (async ({ abortSignal, ...body }) => requestJson(config, "/v1/mcp-connections", {
10
10
  json: body,
11
+ credentialBearing: true,
11
12
  signal: abortSignal,
12
13
  method: "POST",
13
14
  }, mcpConnectionResponseSchema));
14
15
  return {
15
16
  create,
16
17
  async list({ abortSignal } = {}) {
17
- return await requestJson(config, "/v1/mcp-connections", { signal: abortSignal }, mcpConnectionsResponseSchema);
18
+ return await requestJson(config, "/v1/mcp-connections", { credentialBearing: true, signal: abortSignal }, mcpConnectionsResponseSchema);
18
19
  },
19
20
  async get({ mcpConnectionId, abortSignal }) {
20
- return await requestJson(config, apiPath `/v1/mcp-connections/${mcpConnectionId}`, { signal: abortSignal }, mcpConnectionResponseSchema);
21
+ return await requestJson(config, apiPath `/v1/mcp-connections/${mcpConnectionId}`, { credentialBearing: true, signal: abortSignal }, mcpConnectionResponseSchema);
21
22
  },
22
23
  async update({ mcpConnectionId, abortSignal, ...body }) {
23
24
  return await requestJson(config, apiPath `/v1/mcp-connections/${mcpConnectionId}`, {
24
25
  json: body,
26
+ credentialBearing: true,
25
27
  signal: abortSignal,
26
28
  method: "PATCH",
27
29
  }, mcpConnectionResponseSchema);
@@ -29,15 +31,17 @@ export function createMcpConnectionsResource(config) {
29
31
  async delete({ mcpConnectionId, abortSignal }) {
30
32
  await requestJson(config, apiPath `/v1/mcp-connections/${mcpConnectionId}`, {
31
33
  method: "DELETE",
34
+ credentialBearing: true,
32
35
  signal: abortSignal,
33
36
  });
34
37
  },
35
38
  async test({ mcpConnectionId, abortSignal }) {
36
- return await requestJson(config, apiPath `/v1/mcp-connections/${mcpConnectionId}/test`, { method: "POST", signal: abortSignal }, mcpConnectionTestResponseSchema);
39
+ return await requestJson(config, apiPath `/v1/mcp-connections/${mcpConnectionId}/test`, { method: "POST", credentialBearing: true, signal: abortSignal }, mcpConnectionTestResponseSchema);
37
40
  },
38
41
  async reconnect({ mcpConnectionId, abortSignal, ...body }) {
39
42
  return await requestJson(config, apiPath `/v1/mcp-connections/${mcpConnectionId}/reconnect`, {
40
43
  json: body,
44
+ credentialBearing: true,
41
45
  signal: abortSignal,
42
46
  method: "POST",
43
47
  }, mcpConnectionReconnectResultSchema);
@@ -10,17 +10,28 @@ import { requestJson } from "../http.js";
10
10
  export function createMerchantConnectionResource(config) {
11
11
  return {
12
12
  async get({ abortSignal } = {}) {
13
- return await requestJson(config, "/v1/merchant-connection", { signal: abortSignal }, merchantConnectionResponseSchema);
13
+ return await requestJson(config, "/v1/merchant-connection", { credentialBearing: true, signal: abortSignal }, merchantConnectionResponseSchema);
14
14
  },
15
15
  async create({ abortSignal, ...body }) {
16
- return await requestJson(config, "/v1/merchant-connection", { json: body, method: "POST", signal: abortSignal }, merchantConnectionResponseSchema);
16
+ return await requestJson(config, "/v1/merchant-connection", {
17
+ json: body,
18
+ method: "POST",
19
+ credentialBearing: true,
20
+ signal: abortSignal,
21
+ }, merchantConnectionResponseSchema);
17
22
  },
18
23
  async update({ abortSignal, ...body }) {
19
- return await requestJson(config, "/v1/merchant-connection", { json: body, method: "PATCH", signal: abortSignal }, merchantConnectionResponseSchema);
24
+ return await requestJson(config, "/v1/merchant-connection", {
25
+ json: body,
26
+ method: "PATCH",
27
+ credentialBearing: true,
28
+ signal: abortSignal,
29
+ }, merchantConnectionResponseSchema);
20
30
  },
21
31
  async retire({ abortSignal } = {}) {
22
32
  await requestJson(config, "/v1/merchant-connection", {
23
33
  method: "DELETE",
34
+ credentialBearing: true,
24
35
  signal: abortSignal,
25
36
  });
26
37
  },
@@ -10,25 +10,27 @@ export function createProvidersResource(config) {
10
10
  async create({ abortSignal, ...body }) {
11
11
  return await requestJson(config, "/v1/providers", {
12
12
  json: body,
13
+ credentialBearing: true,
13
14
  signal: abortSignal,
14
15
  method: "POST",
15
16
  }, providerResponseSchema);
16
17
  },
17
18
  async list({ abortSignal } = {}) {
18
- return await requestJson(config, "/v1/providers", { signal: abortSignal }, providersResponseSchema);
19
+ return await requestJson(config, "/v1/providers", { credentialBearing: true, signal: abortSignal }, providersResponseSchema);
19
20
  },
20
21
  async get({ providerId, abortSignal }) {
21
- return await requestJson(config, apiPath `/v1/providers/${providerId}`, { signal: abortSignal }, providerResponseSchema);
22
+ return await requestJson(config, apiPath `/v1/providers/${providerId}`, { credentialBearing: true, signal: abortSignal }, providerResponseSchema);
22
23
  },
23
24
  async listModels({ providerId, abortSignal }) {
24
- return await requestJson(config, apiPath `/v1/providers/${providerId}/models`, { signal: abortSignal }, providerModelsResponseSchema);
25
+ return await requestJson(config, apiPath `/v1/providers/${providerId}/models`, { credentialBearing: true, signal: abortSignal }, providerModelsResponseSchema);
25
26
  },
26
27
  async getThinkingLevels({ providerId, model, abortSignal }) {
27
- return await requestJson(config, apiPath `/v1/providers/${providerId}/thinking-levels`, { signal: abortSignal, query: { model } }, thinkingLevelsResponseSchema);
28
+ return await requestJson(config, apiPath `/v1/providers/${providerId}/thinking-levels`, { credentialBearing: true, signal: abortSignal, query: { model } }, thinkingLevelsResponseSchema);
28
29
  },
29
30
  async update({ providerId, abortSignal, ...body }) {
30
31
  return await requestJson(config, apiPath `/v1/providers/${providerId}`, {
31
32
  json: body,
33
+ credentialBearing: true,
32
34
  signal: abortSignal,
33
35
  method: "PATCH",
34
36
  }, providerResponseSchema);
@@ -36,6 +38,7 @@ export function createProvidersResource(config) {
36
38
  async delete({ providerId, abortSignal, ...options }) {
37
39
  await requestJson(config, apiPath `/v1/providers/${providerId}`, {
38
40
  method: "DELETE",
41
+ credentialBearing: true,
39
42
  signal: abortSignal,
40
43
  query: {
41
44
  confirmSnapshotInvalidation: options.confirmSnapshotInvalidation,
package/dist/types.d.ts CHANGED
@@ -13,7 +13,7 @@ import type { AgentSkillsResource } from "./resources/skills.ts";
13
13
  import type { TasksResource } from "./resources/tasks.ts";
14
14
  import type { UsageResource } from "./resources/usage.ts";
15
15
  import type { WorkspacesResource } from "./resources/workspaces.ts";
16
- export type KnownBlazingAgentsErrorCode = ApiErrorCode | "invalid_response" | "network_error" | "request_aborted" | "stream_error";
16
+ export type KnownBlazingAgentsErrorCode = ApiErrorCode | "credential_echo" | "invalid_response" | "network_error" | "request_aborted" | "stream_error";
17
17
  export type BlazingAgentsErrorCode = KnownBlazingAgentsErrorCode | (string & {});
18
18
  export type BlazingAgentsFetch = (input: string, init?: BlazingAgentsRequestInit) => Promise<Response>;
19
19
  export interface BlazingAgentsRequestInit extends RequestInit {
@@ -23,6 +23,11 @@ export interface BlazingAgentsRequestInit extends RequestInit {
23
23
  export interface RequestOptions {
24
24
  body?: BodyInit | FormData | null;
25
25
  clientRequestId?: string | undefined;
26
+ /**
27
+ * Set on operations the contract marks `x-credential-bearing`: a 2xx JSON
28
+ * body that contains a credential field is discarded and rejected.
29
+ */
30
+ credentialBearing?: true;
26
31
  /**
27
32
  * Extra headers (e.g. `Content-Type: multipart/form-data` is set
28
33
  * automatically by `fetch` when given a `FormData` body).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blazingagents/sdk",
3
- "version": "0.35.0",
3
+ "version": "0.37.0",
4
4
  "description": "TypeScript SDK for the Blazing Agents API",
5
5
  "homepage": "https://docs.blazingagents.com",
6
6
  "bugs": {
@@ -29,7 +29,6 @@
29
29
  "README.md"
30
30
  ],
31
31
  "scripts": {
32
- "agent-tools:json": "node scripts/write-agent-tools-json.ts",
33
32
  "build": "rm -rf dist && tsc -p tsconfig.build.json",
34
33
  "check": "npm run typecheck && npm run test && npm run lint && npm run unused",
35
34
  "fix": "ultracite fix",