@yadsh/dsh-qa-integrations 0.8.3 → 0.10.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.
Files changed (188) hide show
  1. package/README.md +44 -27
  2. package/compatibility.json +7 -3
  3. package/lib/broker.js +225 -18
  4. package/lib/broker.js.map +1 -1
  5. package/lib/client/bitrix24.js +8 -6
  6. package/lib/client/bitrix24.js.map +1 -1
  7. package/lib/client/card.js +14 -13
  8. package/lib/client/card.js.map +1 -1
  9. package/lib/client/confluence.js +11 -7
  10. package/lib/client/confluence.js.map +1 -1
  11. package/lib/client/credential-help-note.js +51 -0
  12. package/lib/client/credential-help-note.js.map +1 -0
  13. package/lib/client/gitlab.js +8 -6
  14. package/lib/client/gitlab.js.map +1 -1
  15. package/lib/client/index.js +38 -32
  16. package/lib/client/index.js.map +1 -1
  17. package/lib/client/integrations.js +31 -18
  18. package/lib/client/integrations.js.map +1 -1
  19. package/lib/client/jira.js +10 -8
  20. package/lib/client/jira.js.map +1 -1
  21. package/lib/client/operator-card.js +93 -534
  22. package/lib/client/operator-card.js.map +1 -1
  23. package/lib/client/operator-controls.js +72 -23
  24. package/lib/client/operator-controls.js.map +1 -1
  25. package/lib/client/operator-sections/bitrix24.js +22 -0
  26. package/lib/client/operator-sections/bitrix24.js.map +1 -0
  27. package/lib/client/operator-sections/confluence.js +27 -0
  28. package/lib/client/operator-sections/confluence.js.map +1 -0
  29. package/lib/client/operator-sections/credential-help.js +15 -0
  30. package/lib/client/operator-sections/credential-help.js.map +1 -0
  31. package/lib/client/operator-sections/general.js +8 -0
  32. package/lib/client/operator-sections/general.js.map +1 -0
  33. package/lib/client/operator-sections/gitlab.js +41 -0
  34. package/lib/client/operator-sections/gitlab.js.map +1 -0
  35. package/lib/client/operator-sections/jira.js +25 -0
  36. package/lib/client/operator-sections/jira.js.map +1 -0
  37. package/lib/client/operator-sections/provider-section.js +21 -0
  38. package/lib/client/operator-sections/provider-section.js.map +1 -0
  39. package/lib/client/operator-sections/service-profiles.js +178 -0
  40. package/lib/client/operator-sections/service-profiles.js.map +1 -0
  41. package/lib/client/operator-sections/shared.js +192 -0
  42. package/lib/client/operator-sections/shared.js.map +1 -0
  43. package/lib/client/operator-sections/teamcity.js +42 -0
  44. package/lib/client/operator-sections/teamcity.js.map +1 -0
  45. package/lib/client/operator-sections/testit.js +35 -0
  46. package/lib/client/operator-sections/testit.js.map +1 -0
  47. package/lib/client/operator-sections/weblate.js +32 -0
  48. package/lib/client/operator-sections/weblate.js.map +1 -0
  49. package/lib/client/operator-service-reach.js +98 -0
  50. package/lib/client/operator-service-reach.js.map +1 -0
  51. package/lib/client/provider-card.js +32 -19
  52. package/lib/client/provider-card.js.map +1 -1
  53. package/lib/client/styles.js +52 -15
  54. package/lib/client/styles.js.map +1 -1
  55. package/lib/client/teamcity.js +7 -5
  56. package/lib/client/teamcity.js.map +1 -1
  57. package/lib/client/testit.js +8 -6
  58. package/lib/client/testit.js.map +1 -1
  59. package/lib/client/weblate.js +8 -6
  60. package/lib/client/weblate.js.map +1 -1
  61. package/lib/client.js +2838 -1923
  62. package/lib/client.js.map +1 -1
  63. package/lib/config.js +64 -17
  64. package/lib/config.js.map +1 -1
  65. package/lib/index.js +177 -223
  66. package/lib/index.js.map +1 -1
  67. package/lib/providers/bitrix24/tools.js +7 -2
  68. package/lib/providers/bitrix24/tools.js.map +1 -1
  69. package/lib/providers/bitrix24/transport.js +16 -6
  70. package/lib/providers/bitrix24/transport.js.map +1 -1
  71. package/lib/providers/confluence/config.js +14 -55
  72. package/lib/providers/confluence/config.js.map +1 -1
  73. package/lib/providers/confluence/tools.js +7 -2
  74. package/lib/providers/confluence/tools.js.map +1 -1
  75. package/lib/providers/confluence/transport.js +42 -78
  76. package/lib/providers/confluence/transport.js.map +1 -1
  77. package/lib/providers/gitlab/config.js +11 -55
  78. package/lib/providers/gitlab/config.js.map +1 -1
  79. package/lib/providers/gitlab/operations.js +3 -3
  80. package/lib/providers/gitlab/operations.js.map +1 -1
  81. package/lib/providers/gitlab/tools.js +7 -2
  82. package/lib/providers/gitlab/tools.js.map +1 -1
  83. package/lib/providers/gitlab/transport.js +33 -65
  84. package/lib/providers/gitlab/transport.js.map +1 -1
  85. package/lib/providers/jira/config.js +18 -58
  86. package/lib/providers/jira/config.js.map +1 -1
  87. package/lib/providers/jira/jql.js +105 -1
  88. package/lib/providers/jira/jql.js.map +1 -1
  89. package/lib/providers/jira/tools.js +68 -2
  90. package/lib/providers/jira/tools.js.map +1 -1
  91. package/lib/providers/jira/transport.js +44 -110
  92. package/lib/providers/jira/transport.js.map +1 -1
  93. package/lib/providers/kernel/address.js +90 -0
  94. package/lib/providers/kernel/address.js.map +1 -0
  95. package/lib/providers/kernel/errors.js +42 -0
  96. package/lib/providers/kernel/errors.js.map +1 -0
  97. package/lib/providers/kernel/read-policy.js +250 -0
  98. package/lib/providers/kernel/read-policy.js.map +1 -0
  99. package/lib/providers/kernel/token.js +45 -0
  100. package/lib/providers/kernel/token.js.map +1 -0
  101. package/lib/providers/shared/service-boundary.js +31 -3
  102. package/lib/providers/shared/service-boundary.js.map +1 -1
  103. package/lib/providers/teamcity/tools.js +8 -3
  104. package/lib/providers/teamcity/tools.js.map +1 -1
  105. package/lib/providers/teamcity/transport.js +6 -8
  106. package/lib/providers/teamcity/transport.js.map +1 -1
  107. package/lib/providers/testit/config.js +12 -57
  108. package/lib/providers/testit/config.js.map +1 -1
  109. package/lib/providers/testit/tools.js +7 -2
  110. package/lib/providers/testit/tools.js.map +1 -1
  111. package/lib/providers/testit/transport.js +12 -12
  112. package/lib/providers/testit/transport.js.map +1 -1
  113. package/lib/providers/weblate/config.js +12 -55
  114. package/lib/providers/weblate/config.js.map +1 -1
  115. package/lib/providers/weblate/tools.js +7 -2
  116. package/lib/providers/weblate/tools.js.map +1 -1
  117. package/lib/providers/weblate/transport.js +21 -20
  118. package/lib/providers/weblate/transport.js.map +1 -1
  119. package/lib/public-api.js +79 -0
  120. package/lib/public-api.js.map +1 -0
  121. package/lib/repository.js +96 -16
  122. package/lib/repository.js.map +1 -1
  123. package/lib/service-credentials/config.js +61 -0
  124. package/lib/service-credentials/config.js.map +1 -1
  125. package/lib/service-credentials/policy.js +14 -1
  126. package/lib/service-credentials/policy.js.map +1 -1
  127. package/lib/service-credentials/rate-limit.js +136 -0
  128. package/lib/service-credentials/rate-limit.js.map +1 -0
  129. package/lib/tool-kit.js +15 -7
  130. package/lib/tool-kit.js.map +1 -1
  131. package/lib/tools.js +49 -24
  132. package/lib/tools.js.map +1 -1
  133. package/lib/typert.host.js +460 -352
  134. package/lib/typert.remote-client.js +450 -336
  135. package/lib/types/broker.d.ts +77 -3
  136. package/lib/types/client/card.d.ts +13 -4
  137. package/lib/types/client/credential-help-note.d.ts +26 -0
  138. package/lib/types/client/index.d.ts +15 -7
  139. package/lib/types/client/integrations.d.ts +5 -4
  140. package/lib/types/client/operator-card.d.ts +56 -4
  141. package/lib/types/client/operator-controls.d.ts +31 -0
  142. package/lib/types/client/operator-sections/bitrix24.d.ts +12 -0
  143. package/lib/types/client/operator-sections/confluence.d.ts +10 -0
  144. package/lib/types/client/operator-sections/credential-help.d.ts +17 -0
  145. package/lib/types/client/operator-sections/general.d.ts +11 -0
  146. package/lib/types/client/operator-sections/gitlab.d.ts +13 -0
  147. package/lib/types/client/operator-sections/jira.d.ts +11 -0
  148. package/lib/types/client/operator-sections/provider-section.d.ts +58 -0
  149. package/lib/types/client/operator-sections/service-profiles.d.ts +13 -0
  150. package/lib/types/client/operator-sections/shared.d.ts +123 -0
  151. package/lib/types/client/operator-sections/teamcity.d.ts +11 -0
  152. package/lib/types/client/operator-sections/testit.d.ts +10 -0
  153. package/lib/types/client/operator-sections/weblate.d.ts +10 -0
  154. package/lib/types/client/operator-service-reach.d.ts +76 -0
  155. package/lib/types/client/provider-card.d.ts +14 -3
  156. package/lib/types/client/styles.d.ts +28 -4
  157. package/lib/types/config.d.ts +49 -2
  158. package/lib/types/index.d.ts +54 -117
  159. package/lib/types/providers/bitrix24/tools.d.ts +2 -5
  160. package/lib/types/providers/confluence/tools.d.ts +2 -6
  161. package/lib/types/providers/confluence/transport.d.ts +0 -6
  162. package/lib/types/providers/gitlab/config.d.ts +1 -1
  163. package/lib/types/providers/gitlab/tools.d.ts +2 -6
  164. package/lib/types/providers/gitlab/transport.d.ts +3 -5
  165. package/lib/types/providers/jira/tools.d.ts +2 -6
  166. package/lib/types/providers/jira/transport.d.ts +2 -11
  167. package/lib/types/providers/kernel/address.d.ts +57 -0
  168. package/lib/types/providers/kernel/errors.d.ts +34 -0
  169. package/lib/types/providers/kernel/read-policy.d.ts +107 -0
  170. package/lib/types/providers/kernel/token.d.ts +25 -0
  171. package/lib/types/providers/shared/service-boundary.d.ts +15 -0
  172. package/lib/types/providers/teamcity/tools.d.ts +2 -6
  173. package/lib/types/providers/teamcity/transport.d.ts +1 -1
  174. package/lib/types/providers/testit/tools.d.ts +2 -6
  175. package/lib/types/providers/testit/transport.d.ts +1 -1
  176. package/lib/types/providers/weblate/tools.d.ts +2 -6
  177. package/lib/types/public-api.d.ts +80 -0
  178. package/lib/types/repository.d.ts +64 -2
  179. package/lib/types/service-credentials/config.d.ts +22 -0
  180. package/lib/types/service-credentials/rate-limit.d.ts +66 -0
  181. package/lib/types/service-credentials/types.d.ts +18 -0
  182. package/lib/types/tool-kit.d.ts +27 -1
  183. package/lib/types/tools.d.ts +26 -9
  184. package/lib/types/types.d.ts +17 -3
  185. package/package.json +23 -21
  186. package/lib/providers/shared/http.js +0 -168
  187. package/lib/providers/shared/http.js.map +0 -1
  188. package/lib/types/providers/shared/http.d.ts +0 -60
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yadsh/dsh-qa-integrations",
3
- "version": "0.8.3",
3
+ "version": "0.10.0",
4
4
  "description": "Principal-scoped, encrypted user integrations for DSH QA Surface",
5
5
  "repository": {
6
6
  "type": "git",
@@ -58,8 +58,8 @@
58
58
  ],
59
59
  "inject": [
60
60
  "@deepseek-ai/dsh-api-gateway",
61
+ "@deepseek-ai/dsh-client-ui-plugin-manager",
61
62
  "@deepseek-ai/dsh-client-ui-settings",
62
- "@deepseek-ai/dsh-client-ui-settings-plugins",
63
63
  "@yadsh/dsh-qa-surface"
64
64
  ],
65
65
  "platform": "web"
@@ -87,34 +87,35 @@
87
87
  },
88
88
  "dependencies": {
89
89
  "zod": "^4.4.3",
90
- "@yadsh/dsh-plugin-kit": "^0.3.0",
91
- "@yadsh/dsh-plugin-log": "^0.4.0",
92
- "@yadsh/dsh-qa-surface": "^0.12.0"
90
+ "@yadsh/dsh-plugin-log": "^0.4.1",
91
+ "@yadsh/dsh-plugin-kit": "^0.5.0",
92
+ "@yadsh/dsh-qa-surface": "^0.14.0"
93
93
  },
94
94
  "peerDependencies": {
95
- "@deepseek-ai/cordis": "^4.0.2",
96
- "@deepseek-ai/dsh-client-ui-settings": ">=0.1.5-rc.2 <0.2.0",
97
- "@deepseek-ai/dsh-client-ui-settings-plugins": ">=0.1.5-rc.2 <0.2.0",
98
- "@deepseek-ai/dsh-tools": ">=0.1.5-rc.2 <0.2.0",
99
- "@deepseek-ai/dsh-typert-protocol": ">=0.1.5-rc.2 <0.2.0",
100
- "@deepseek-ai/schemastery": "^3.18.2",
95
+ "@deepseek-ai/cordis": "^4.0.4",
96
+ "@deepseek-ai/dsh-client-ui-plugin-manager": ">=0.1.7-rc.2 <0.2.0",
97
+ "@deepseek-ai/dsh-client-ui-settings": ">=0.1.7-rc.2 <0.2.0",
98
+ "@deepseek-ai/dsh-tools": ">=0.1.7-rc.2 <0.2.0",
99
+ "@deepseek-ai/dsh-typert-protocol": ">=0.1.7-rc.2 <0.2.0",
100
+ "@deepseek-ai/schemastery": "^3.18.4",
101
101
  "react": "^18.2.0"
102
102
  },
103
103
  "devDependencies": {
104
- "@deepseek-ai/cordis": "4.0.2",
105
- "@deepseek-ai/dsh-api-gateway": "0.1.5-rc.2",
106
- "@deepseek-ai/dsh-client-ui-renderer": "0.1.5-rc.2",
107
- "@deepseek-ai/dsh-client-ui-settings": "0.1.5-rc.2",
108
- "@deepseek-ai/dsh-client-ui-settings-plugins": "0.1.5-rc.2",
109
- "@deepseek-ai/dsh-client-ui-slots": "0.1.5-rc.2",
110
- "@deepseek-ai/dsh-tools": "0.1.5-rc.2",
111
- "@deepseek-ai/dsh-typert-generator": "0.1.5-rc.2",
112
- "@deepseek-ai/dsh-typert-protocol": "0.1.5-rc.2",
113
- "@deepseek-ai/schemastery": "3.18.2",
104
+ "@deepseek-ai/cordis": "4.0.4",
105
+ "@deepseek-ai/dsh-api-gateway": "0.1.7-rc.2",
106
+ "@deepseek-ai/dsh-client-ui-plugin-manager": "0.1.7-rc.2",
107
+ "@deepseek-ai/dsh-client-ui-renderer": "0.1.7-rc.2",
108
+ "@deepseek-ai/dsh-client-ui-settings": "0.1.7-rc.2",
109
+ "@deepseek-ai/dsh-client-ui-slots": "0.1.7-rc.2",
110
+ "@deepseek-ai/dsh-tools": "0.1.7-rc.2",
111
+ "@deepseek-ai/dsh-typert-generator": "0.1.7-rc.2",
112
+ "@deepseek-ai/dsh-typert-protocol": "0.1.7-rc.2",
113
+ "@deepseek-ai/schemastery": "3.18.4",
114
114
  "@testing-library/react": "^16.3.0",
115
115
  "@types/node": "^26.4.0",
116
116
  "@types/react": "18.3.28",
117
117
  "@types/react-dom": "18.3.7",
118
+ "@vitest/coverage-v8": "^4.1.8",
118
119
  "eslint": "10.9.1",
119
120
  "jsdom": "^26.1.0",
120
121
  "react": "18.3.1",
@@ -136,6 +137,7 @@
136
137
  "lint": "eslint src tests scripts tsdown.config.ts",
137
138
  "typecheck": "tsc -p tsconfig.json --noEmit",
138
139
  "test": "vitest run",
140
+ "test:coverage": "vitest run --coverage",
139
141
  "verify:package": "node scripts/verify-package.mjs",
140
142
  "verify": "pnpm run verify:package",
141
143
  "check": "pnpm run lint && pnpm run typecheck && pnpm run test && pnpm run build && pnpm run verify"
@@ -1,168 +0,0 @@
1
- import { IntegrationError } from "../../errors.js";
2
- export const RETRY_CAP_MS = 2_000;
3
- export const BACKOFF_BASE_MS = 250;
4
- /** Upstream codes that mean "the TLS handshake did not succeed". */
5
- export const TLS_FAILURE = /CERT|TLS|SSL|UNABLE_TO_VERIFY|SELF_SIGNED|DEPTH_ZERO|ERR_TLS/u;
6
- /** Content types that must never be handed to the model as text. */
7
- export const BINARY_TYPE = /^(?:image|audio|video)\/|application\/(?:octet-stream|zip|gzip|pdf|x-tar|x-7z-compressed|wasm)/u;
8
- export function numberFrom(value) {
9
- if (value === null || value.trim() === "")
10
- return undefined;
11
- const parsed = Number(value);
12
- return Number.isFinite(parsed) ? parsed : undefined;
13
- }
14
- export function looksBinary(contentType, bytes) {
15
- if (contentType !== null && BINARY_TYPE.test(contentType))
16
- return true;
17
- if (contentType !== null && /charset=/u.test(contentType))
18
- return false;
19
- if (contentType !== null &&
20
- /^(?:text\/|application\/(?:json|xml))/u.test(contentType)) {
21
- return false;
22
- }
23
- // No usable content type: a NUL byte in the head is the classic text/binary
24
- // split, and it costs nothing to be conservative about the rest.
25
- for (const byte of bytes.subarray(0, 8_192)) {
26
- if (byte === 0)
27
- return true;
28
- }
29
- return false;
30
- }
31
- export function sleep(ms) {
32
- return new Promise((resolve) => setTimeout(resolve, ms));
33
- }
34
- /** The first upstream error code in a fetch failure chain, if any. */
35
- export function causeCode(error) {
36
- let current = error;
37
- for (let depth = 0; depth < 4; depth += 1) {
38
- if (typeof current !== "object" || current === null)
39
- break;
40
- const code = current.code;
41
- if (typeof code === "string")
42
- return code;
43
- current = current.cause;
44
- }
45
- return "";
46
- }
47
- export function backoff(response, attempt) {
48
- const header = response.headers.get("retry-after");
49
- const seconds = header === null ? Number.NaN : Number(header.trim());
50
- if (Number.isFinite(seconds) && seconds >= 0) {
51
- return Math.min(seconds * 1_000, RETRY_CAP_MS);
52
- }
53
- return retryDelay(attempt);
54
- }
55
- export function retryDelay(attempt) {
56
- const backoff = BACKOFF_BASE_MS * 2 ** attempt;
57
- return Math.min(backoff + Math.floor(Math.random() * 100), RETRY_CAP_MS);
58
- }
59
- /**
60
- * Read a body without letting upstream decide how much memory the broker
61
- * spends. A body over the cap is reported as truncated instead of surfacing a
62
- * raw `content-length` nobody can verify.
63
- */
64
- export async function readBoundedText(response, maxBytes) {
65
- const contentType = response.headers.get("content-type");
66
- if (response.body === null) {
67
- return { text: "", bytes: 0, truncated: false, binary: false };
68
- }
69
- const declared = numberFrom(response.headers.get("content-length"));
70
- const reader = response.body.getReader();
71
- const chunks = [];
72
- let bytes = 0;
73
- let truncated = declared !== undefined && declared > maxBytes;
74
- for (;;) {
75
- const next = await reader.read();
76
- if (next.done)
77
- break;
78
- bytes += next.value.byteLength;
79
- if (bytes > maxBytes) {
80
- // Keep the prefix that still fits: a bounded preview is what makes a
81
- // truncated answer useful, an empty one is not.
82
- const room = maxBytes - (bytes - next.value.byteLength);
83
- if (room > 0)
84
- chunks.push(next.value.subarray(0, room));
85
- await reader.cancel();
86
- truncated = true;
87
- break;
88
- }
89
- chunks.push(next.value);
90
- }
91
- const body = Buffer.concat(chunks.map((chunk) => Buffer.from(chunk)));
92
- const binary = looksBinary(contentType, body);
93
- return {
94
- text: binary ? "" : body.toString("utf8"),
95
- bytes: Math.max(bytes, body.byteLength),
96
- truncated,
97
- binary,
98
- };
99
- }
100
- /**
101
- * Read one JSON body under the deployment cap, folding what a capped or
102
- * unreadable body means into a domain error. The cap, the prefix-keeping
103
- * truncation and the binary classification are the shared policy; a transport
104
- * only supplies the label it answers with, so the same limit cannot mean
105
- * "narrow the request" in one provider and "try again later" in another, and
106
- * no transport can quietly skip the cap.
107
- */
108
- export async function readBoundedJson(response, maxBytes, label) {
109
- const body = await readBoundedText(response, maxBytes);
110
- if (body.truncated) {
111
- throw new IntegrationError("ResultTooLarge", `${label} response is too large`);
112
- }
113
- try {
114
- return JSON.parse(body.text);
115
- }
116
- catch {
117
- throw new IntegrationError("ProviderUnavailable", `${label} returned invalid JSON`);
118
- }
119
- }
120
- /**
121
- * The shared transport loop: one bounded GET per attempt, transient answers
122
- * retried with backoff, upstream failures folded into safe domain errors. The
123
- * deadline is per attempt, and a fetch that answered is never retried by this
124
- * loop unless its status says the upstream fault may be gone on a later try.
125
- */
126
- export async function fetchWithRetries(fetcher, target, policy) {
127
- let lastError;
128
- for (let attempt = 0;; attempt += 1) {
129
- let response;
130
- let timedOut = false;
131
- const controller = new AbortController();
132
- const timer = setTimeout(() => {
133
- timedOut = true;
134
- controller.abort();
135
- }, policy.timeoutMs);
136
- try {
137
- response = await fetcher(target, {
138
- method: "GET",
139
- // An upstream that answers with a redirect is never followed: the
140
- // credential must not travel to another origin.
141
- redirect: "error",
142
- headers: policy.headers,
143
- signal: controller.signal,
144
- });
145
- }
146
- catch (error) {
147
- lastError = policy.transportFailure(error, timedOut);
148
- if (attempt >= policy.retries || !policy.retriable(lastError)) {
149
- throw lastError;
150
- }
151
- await sleep(retryDelay(attempt));
152
- continue;
153
- }
154
- finally {
155
- clearTimeout(timer);
156
- }
157
- if (response.ok)
158
- return response;
159
- lastError = policy.statusFailure(response);
160
- // Only throttling and upstream faults are retried; an authorization or
161
- // not-found answer will not change by asking again.
162
- const transient = response.status === 429 || response.status >= 500;
163
- if (!transient || attempt >= policy.retries)
164
- throw lastError;
165
- await sleep(backoff(response, attempt));
166
- }
167
- }
168
- //# sourceMappingURL=http.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"http.js","sourceRoot":"","sources":["../../../src/providers/shared/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,CAAC;AAClC,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAC;AAEnC,oEAAoE;AACpE,MAAM,CAAC,MAAM,WAAW,GACtB,+DAA+D,CAAC;AAElE,oEAAoE;AACpE,MAAM,CAAC,MAAM,WAAW,GACtB,iGAAiG,CAAC;AAWpG,MAAM,UAAU,UAAU,CA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
4
- /** Upstream codes that mean "the TLS handshake did not succeed". */
5
- export declare const TLS_FAILURE: RegExp;
6
- /** Content types that must never be handed to the model as text. */
7
- export declare const BINARY_TYPE: RegExp;
8
- /** A body read up to a cap; the text is empty for a payload that looks binary. */
9
- export interface BoundedText {
10
- /** Body prefix; empty for a payload that looks binary. */
11
- readonly text: string;
12
- readonly bytes: number;
13
- readonly truncated: boolean;
14
- readonly binary: boolean;
15
- }
16
- export declare function numberFrom(value: string | null): number | undefined;
17
- export declare function looksBinary(contentType: string | null, bytes: Uint8Array): boolean;
18
- export declare function sleep(ms: number): Promise<void>;
19
- /** The first upstream error code in a fetch failure chain, if any. */
20
- export declare function causeCode(error: unknown): string;
21
- export declare function backoff(response: Response, attempt: number): number;
22
- export declare function retryDelay(attempt: number): number;
23
- /**
24
- * Read a body without letting upstream decide how much memory the broker
25
- * spends. A body over the cap is reported as truncated instead of surfacing a
26
- * raw `content-length` nobody can verify.
27
- */
28
- export declare function readBoundedText(response: Response, maxBytes: number): Promise<BoundedText>;
29
- /**
30
- * Read one JSON body under the deployment cap, folding what a capped or
31
- * unreadable body means into a domain error. The cap, the prefix-keeping
32
- * truncation and the binary classification are the shared policy; a transport
33
- * only supplies the label it answers with, so the same limit cannot mean
34
- * "narrow the request" in one provider and "try again later" in another, and
35
- * no transport can quietly skip the cap.
36
- */
37
- export declare function readBoundedJson<T>(response: Response, maxBytes: number, label: string): Promise<T>;
38
- /**
39
- * How a provider folds transport outcomes into its own safe domain errors:
40
- * each transport keeps the wording, the shared loop keeps the mechanics.
41
- */
42
- export interface FetchRetryPolicy {
43
- readonly timeoutMs: number;
44
- readonly retries: number;
45
- readonly headers: Record<string, string>;
46
- /** Fold a thrown fetch (abort, DNS, refused connection) into a safe error. */
47
- readonly transportFailure: (error: unknown, timedOut: boolean) => IntegrationError;
48
- /** Whether a folded transport failure earns another attempt. */
49
- readonly retriable: (error: IntegrationError) => boolean;
50
- /** Fold a non-2xx answer into the provider's safe domain error. */
51
- readonly statusFailure: (response: Response) => IntegrationError;
52
- }
53
- /**
54
- * The shared transport loop: one bounded GET per attempt, transient answers
55
- * retried with backoff, upstream failures folded into safe domain errors. The
56
- * deadline is per attempt, and a fetch that answered is never retried by this
57
- * loop unless its status says the upstream fault may be gone on a later try.
58
- */
59
- export declare function fetchWithRetries(fetcher: typeof fetch, target: string, policy: FetchRetryPolicy): Promise<Response>;
60
- //# sourceMappingURL=http.d.ts.map