deepline 0.3.1 → 0.3.2

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.
@@ -4656,6 +4656,12 @@ export class DeeplineClient {
4656
4656
  {
4657
4657
  method: 'POST',
4658
4658
  body: definition,
4659
+ // A provider can reject a create with a 429 after Deepline has begun
4660
+ // the lifecycle request. Do not replay a mutation or hide the server's
4661
+ // monitor-specific recovery guidance behind a generic transport retry.
4662
+ maxRetries: 0,
4663
+ exactUrlOnly: true,
4664
+ preserveRateLimitResponse: true,
4659
4665
  },
4660
4666
  );
4661
4667
  if (definition.tool !== 'deepline.analytics') return deployed;
@@ -70,6 +70,12 @@ interface RequestOptions {
70
70
  maxRetries?: number;
71
71
  /** Disable localhost/127.0.0.1 failover for non-idempotent requests. */
72
72
  exactUrlOnly?: boolean;
73
+ /**
74
+ * Return a server-owned 429 envelope as a DeeplineError instead of replacing
75
+ * it with the transport's generic RateLimitError. Lifecycle mutations use
76
+ * this when their response explains whether the upstream change applied.
77
+ */
78
+ preserveRateLimitResponse?: boolean;
73
79
  /** Enables endpoint-specific structured tool failure mapping. */
74
80
  toolId?: string;
75
81
  }
@@ -419,6 +425,17 @@ export class HttpClient {
419
425
  }
420
426
 
421
427
  if (response.status === 429) {
428
+ if (
429
+ options?.preserveRateLimitResponse &&
430
+ isMonitorRateLimitEnvelope(parsed)
431
+ ) {
432
+ throw new DeeplineError(
433
+ apiErrorMessage(parsed, response.status),
434
+ response.status,
435
+ apiErrorCodeFromResponse(parsed),
436
+ { response: parsed },
437
+ );
438
+ }
422
439
  const retryAfter = parseRetryAfter(response);
423
440
  lastError = new RateLimitError(retryAfter);
424
441
  if (attempt < maxRetries) {
@@ -779,6 +796,21 @@ function isProviderOriginatedHttpError(parsed: unknown): boolean {
779
796
  return failureOrigin === 'provider' || code === 'UPSTREAM_BLOCKED';
780
797
  }
781
798
 
799
+ /**
800
+ * A monitor deployment may receive a safe, actionable 429 from Deepline after
801
+ * an upstream lifecycle attempt. Do not treat a CDN/WAF 429 as that envelope:
802
+ * it can be arbitrary HTML or text and must retain normal RateLimitError
803
+ * behavior.
804
+ */
805
+ function isMonitorRateLimitEnvelope(parsed: unknown): boolean {
806
+ const response = asRecord(parsed);
807
+ const error = asRecord(response?.error);
808
+ return (
809
+ error?.code === 'monitor_upstream_rate_limited' &&
810
+ typeof error.message === 'string'
811
+ );
812
+ }
813
+
782
814
  function apiErrorCodeFromResponse(parsed: unknown): string {
783
815
  const response = asRecord(parsed);
784
816
  const error = asRecord(response?.error);
@@ -192,7 +192,7 @@ export const SDK_RELEASE = {
192
192
  // 0.3.0 introduces raw-v2: complete scrubbed provider responses are
193
193
  // available at toolResponse.rawV2 while toolResponse.raw and all declared
194
194
  // getters keep their established compatibility behavior.
195
- version: '0.3.1',
195
+ version: '0.3.2',
196
196
  updateSummary:
197
197
  'New raw-v2 tool responses preserve complete scrubbed provider envelopes at toolResponse.rawV2, including JSON:API included resources, links, cursors, and totals. Existing toolResponse.raw and declared getters keep working unchanged.',
198
198
  contracts: {
package/dist/cli/index.js CHANGED
@@ -1047,7 +1047,7 @@ var SDK_RELEASE = {
1047
1047
  // 0.3.0 introduces raw-v2: complete scrubbed provider responses are
1048
1048
  // available at toolResponse.rawV2 while toolResponse.raw and all declared
1049
1049
  // getters keep their established compatibility behavior.
1050
- version: "0.3.1",
1050
+ version: "0.3.2",
1051
1051
  updateSummary: "New raw-v2 tool responses preserve complete scrubbed provider envelopes at toolResponse.rawV2, including JSON:API included resources, links, cursors, and totals. Existing toolResponse.raw and declared getters keep working unchanged.",
1052
1052
  contracts: {
1053
1053
  api: {
@@ -1466,6 +1466,14 @@ var HttpClient = class {
1466
1466
  throw structuredToolError;
1467
1467
  }
1468
1468
  if (response.status === 429) {
1469
+ if (options?.preserveRateLimitResponse && isMonitorRateLimitEnvelope(parsed)) {
1470
+ throw new DeeplineError(
1471
+ apiErrorMessage(parsed, response.status),
1472
+ response.status,
1473
+ apiErrorCodeFromResponse(parsed),
1474
+ { response: parsed }
1475
+ );
1476
+ }
1469
1477
  const retryAfter = parseRetryAfter(response);
1470
1478
  lastError = new RateLimitError(retryAfter);
1471
1479
  if (attempt < maxRetries) {
@@ -1727,6 +1735,11 @@ function isProviderOriginatedHttpError(parsed) {
1727
1735
  const code = error?.code ?? response?.code;
1728
1736
  return failureOrigin === "provider" || code === "UPSTREAM_BLOCKED";
1729
1737
  }
1738
+ function isMonitorRateLimitEnvelope(parsed) {
1739
+ const response = asRecord(parsed);
1740
+ const error = asRecord(response?.error);
1741
+ return error?.code === "monitor_upstream_rate_limited" && typeof error.message === "string";
1742
+ }
1730
1743
  function apiErrorCodeFromResponse(parsed) {
1731
1744
  const response = asRecord(parsed);
1732
1745
  const error = asRecord(response?.error);
@@ -6503,7 +6516,13 @@ var DeeplineClient = class {
6503
6516
  "/api/v2/monitors/deploy",
6504
6517
  {
6505
6518
  method: "POST",
6506
- body: definition
6519
+ body: definition,
6520
+ // A provider can reject a create with a 429 after Deepline has begun
6521
+ // the lifecycle request. Do not replay a mutation or hide the server's
6522
+ // monitor-specific recovery guidance behind a generic transport retry.
6523
+ maxRetries: 0,
6524
+ exactUrlOnly: true,
6525
+ preserveRateLimitResponse: true
6507
6526
  }
6508
6527
  );
6509
6528
  if (definition.tool !== "deepline.analytics") return deployed;
@@ -1033,7 +1033,7 @@ var SDK_RELEASE = {
1033
1033
  // 0.3.0 introduces raw-v2: complete scrubbed provider responses are
1034
1034
  // available at toolResponse.rawV2 while toolResponse.raw and all declared
1035
1035
  // getters keep their established compatibility behavior.
1036
- version: "0.3.1",
1036
+ version: "0.3.2",
1037
1037
  updateSummary: "New raw-v2 tool responses preserve complete scrubbed provider envelopes at toolResponse.rawV2, including JSON:API included resources, links, cursors, and totals. Existing toolResponse.raw and declared getters keep working unchanged.",
1038
1038
  contracts: {
1039
1039
  api: {
@@ -1452,6 +1452,14 @@ var HttpClient = class {
1452
1452
  throw structuredToolError;
1453
1453
  }
1454
1454
  if (response.status === 429) {
1455
+ if (options?.preserveRateLimitResponse && isMonitorRateLimitEnvelope(parsed)) {
1456
+ throw new DeeplineError(
1457
+ apiErrorMessage(parsed, response.status),
1458
+ response.status,
1459
+ apiErrorCodeFromResponse(parsed),
1460
+ { response: parsed }
1461
+ );
1462
+ }
1455
1463
  const retryAfter = parseRetryAfter(response);
1456
1464
  lastError = new RateLimitError(retryAfter);
1457
1465
  if (attempt < maxRetries) {
@@ -1713,6 +1721,11 @@ function isProviderOriginatedHttpError(parsed) {
1713
1721
  const code = error?.code ?? response?.code;
1714
1722
  return failureOrigin === "provider" || code === "UPSTREAM_BLOCKED";
1715
1723
  }
1724
+ function isMonitorRateLimitEnvelope(parsed) {
1725
+ const response = asRecord(parsed);
1726
+ const error = asRecord(response?.error);
1727
+ return error?.code === "monitor_upstream_rate_limited" && typeof error.message === "string";
1728
+ }
1716
1729
  function apiErrorCodeFromResponse(parsed) {
1717
1730
  const response = asRecord(parsed);
1718
1731
  const error = asRecord(response?.error);
@@ -6489,7 +6502,13 @@ var DeeplineClient = class {
6489
6502
  "/api/v2/monitors/deploy",
6490
6503
  {
6491
6504
  method: "POST",
6492
- body: definition
6505
+ body: definition,
6506
+ // A provider can reject a create with a 429 after Deepline has begun
6507
+ // the lifecycle request. Do not replay a mutation or hide the server's
6508
+ // monitor-specific recovery guidance behind a generic transport retry.
6509
+ maxRetries: 0,
6510
+ exactUrlOnly: true,
6511
+ preserveRateLimitResponse: true
6493
6512
  }
6494
6513
  );
6495
6514
  if (definition.tool !== "deepline.analytics") return deployed;
package/dist/index.js CHANGED
@@ -783,7 +783,7 @@ var SDK_RELEASE = {
783
783
  // 0.3.0 introduces raw-v2: complete scrubbed provider responses are
784
784
  // available at toolResponse.rawV2 while toolResponse.raw and all declared
785
785
  // getters keep their established compatibility behavior.
786
- version: "0.3.1",
786
+ version: "0.3.2",
787
787
  updateSummary: "New raw-v2 tool responses preserve complete scrubbed provider envelopes at toolResponse.rawV2, including JSON:API included resources, links, cursors, and totals. Existing toolResponse.raw and declared getters keep working unchanged.",
788
788
  contracts: {
789
789
  api: {
@@ -1202,6 +1202,14 @@ var HttpClient = class {
1202
1202
  throw structuredToolError;
1203
1203
  }
1204
1204
  if (response.status === 429) {
1205
+ if (options?.preserveRateLimitResponse && isMonitorRateLimitEnvelope(parsed)) {
1206
+ throw new DeeplineError(
1207
+ apiErrorMessage(parsed, response.status),
1208
+ response.status,
1209
+ apiErrorCodeFromResponse(parsed),
1210
+ { response: parsed }
1211
+ );
1212
+ }
1205
1213
  const retryAfter = parseRetryAfter(response);
1206
1214
  lastError = new RateLimitError(retryAfter);
1207
1215
  if (attempt < maxRetries) {
@@ -1463,6 +1471,11 @@ function isProviderOriginatedHttpError(parsed) {
1463
1471
  const code = error?.code ?? response?.code;
1464
1472
  return failureOrigin === "provider" || code === "UPSTREAM_BLOCKED";
1465
1473
  }
1474
+ function isMonitorRateLimitEnvelope(parsed) {
1475
+ const response = asRecord(parsed);
1476
+ const error = asRecord(response?.error);
1477
+ return error?.code === "monitor_upstream_rate_limited" && typeof error.message === "string";
1478
+ }
1466
1479
  function apiErrorCodeFromResponse(parsed) {
1467
1480
  const response = asRecord(parsed);
1468
1481
  const error = asRecord(response?.error);
@@ -6239,7 +6252,13 @@ var DeeplineClient = class {
6239
6252
  "/api/v2/monitors/deploy",
6240
6253
  {
6241
6254
  method: "POST",
6242
- body: definition
6255
+ body: definition,
6256
+ // A provider can reject a create with a 429 after Deepline has begun
6257
+ // the lifecycle request. Do not replay a mutation or hide the server's
6258
+ // monitor-specific recovery guidance behind a generic transport retry.
6259
+ maxRetries: 0,
6260
+ exactUrlOnly: true,
6261
+ preserveRateLimitResponse: true
6243
6262
  }
6244
6263
  );
6245
6264
  if (definition.tool !== "deepline.analytics") return deployed;
package/dist/index.mjs CHANGED
@@ -706,7 +706,7 @@ var SDK_RELEASE = {
706
706
  // 0.3.0 introduces raw-v2: complete scrubbed provider responses are
707
707
  // available at toolResponse.rawV2 while toolResponse.raw and all declared
708
708
  // getters keep their established compatibility behavior.
709
- version: "0.3.1",
709
+ version: "0.3.2",
710
710
  updateSummary: "New raw-v2 tool responses preserve complete scrubbed provider envelopes at toolResponse.rawV2, including JSON:API included resources, links, cursors, and totals. Existing toolResponse.raw and declared getters keep working unchanged.",
711
711
  contracts: {
712
712
  api: {
@@ -1125,6 +1125,14 @@ var HttpClient = class {
1125
1125
  throw structuredToolError;
1126
1126
  }
1127
1127
  if (response.status === 429) {
1128
+ if (options?.preserveRateLimitResponse && isMonitorRateLimitEnvelope(parsed)) {
1129
+ throw new DeeplineError(
1130
+ apiErrorMessage(parsed, response.status),
1131
+ response.status,
1132
+ apiErrorCodeFromResponse(parsed),
1133
+ { response: parsed }
1134
+ );
1135
+ }
1128
1136
  const retryAfter = parseRetryAfter(response);
1129
1137
  lastError = new RateLimitError(retryAfter);
1130
1138
  if (attempt < maxRetries) {
@@ -1386,6 +1394,11 @@ function isProviderOriginatedHttpError(parsed) {
1386
1394
  const code = error?.code ?? response?.code;
1387
1395
  return failureOrigin === "provider" || code === "UPSTREAM_BLOCKED";
1388
1396
  }
1397
+ function isMonitorRateLimitEnvelope(parsed) {
1398
+ const response = asRecord(parsed);
1399
+ const error = asRecord(response?.error);
1400
+ return error?.code === "monitor_upstream_rate_limited" && typeof error.message === "string";
1401
+ }
1389
1402
  function apiErrorCodeFromResponse(parsed) {
1390
1403
  const response = asRecord(parsed);
1391
1404
  const error = asRecord(response?.error);
@@ -6162,7 +6175,13 @@ var DeeplineClient = class {
6162
6175
  "/api/v2/monitors/deploy",
6163
6176
  {
6164
6177
  method: "POST",
6165
- body: definition
6178
+ body: definition,
6179
+ // A provider can reject a create with a 429 after Deepline has begun
6180
+ // the lifecycle request. Do not replay a mutation or hide the server's
6181
+ // monitor-specific recovery guidance behind a generic transport retry.
6182
+ maxRetries: 0,
6183
+ exactUrlOnly: true,
6184
+ preserveRateLimitResponse: true
6166
6185
  }
6167
6186
  );
6168
6187
  if (definition.tool !== "deepline.analytics") return deployed;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepline",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "GTM data CLI and TypeScript SDK for coding agents",
5
5
  "license": "MIT",
6
6
  "homepage": "https://code.deepline.com",