@rankcli/agent-runtime 0.0.36 → 0.0.38

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  analyzeUrl
3
- } from "./chunk-O7B2LBKG.mjs";
3
+ } from "./chunk-ZLQQXIZ3.mjs";
4
4
  import "./chunk-6BWS3CLP.mjs";
5
5
  export {
6
6
  analyzeUrl
@@ -25,7 +25,8 @@ async function httpGet(url, config = {}) {
25
25
  timeout = DEFAULT_TIMEOUT,
26
26
  validateStatus = (status) => status >= 200 && status < 300,
27
27
  maxRedirects = 5,
28
- params
28
+ params,
29
+ maxBytes
29
30
  } = config;
30
31
  let finalUrl = url;
31
32
  if (params) {
@@ -52,7 +53,7 @@ async function httpGet(url, config = {}) {
52
53
  if (contentType.includes("application/json")) {
53
54
  data = await response.json();
54
55
  } else {
55
- data = await response.text();
56
+ data = await readText(response, maxBytes);
56
57
  }
57
58
  clearTimeout(timeoutId);
58
59
  if (!validateStatus(response.status)) {
@@ -79,6 +80,23 @@ async function httpGet(url, config = {}) {
79
80
  throw error;
80
81
  }
81
82
  }
83
+ async function readText(response, maxBytes) {
84
+ if (!maxBytes || !response.body) return response.text();
85
+ const reader = response.body.getReader();
86
+ const chunks = [];
87
+ let received = 0;
88
+ while (received < maxBytes) {
89
+ const { done, value } = await reader.read();
90
+ if (done) break;
91
+ chunks.push(value);
92
+ received += value.byteLength;
93
+ }
94
+ if (received >= maxBytes) await reader.cancel().catch(() => void 0);
95
+ const decoder = new TextDecoder();
96
+ let text = "";
97
+ for (const chunk of chunks) text += decoder.decode(chunk, { stream: true });
98
+ return text + decoder.decode();
99
+ }
82
100
  async function httpHead(url, config = {}) {
83
101
  const {
84
102
  headers = {},
package/dist/index.d.mts CHANGED
@@ -3106,14 +3106,9 @@ declare function servedDir(framework: Framework | undefined, files: string[], ap
3106
3106
 
3107
3107
  interface ReplacementConcern {
3108
3108
  /** Machine-readable, for logs and the PR body. */
3109
- code: 'shrunk' | 'lost_closing_tag' | 'lost_script' | 'lost_stylesheet' | 'lost_verification' | 'lost_import' | 'invalid_json' | 'invalid_xml' | 'invalid_json_ld' | 'fewer_sitemap_urls' | 'lastmod_moved_backwards';
3109
+ code: 'shrunk' | 'lost_closing_tag' | 'lost_script' | 'lost_stylesheet' | 'lost_verification' | 'lost_import' | 'invalid_json' | 'invalid_xml' | 'invalid_json_ld' | 'fewer_sitemap_urls' | 'lastmod_moved_backwards' | 'placeholder_content' | 'canonical_in_shared_shell';
3110
3110
  detail: string;
3111
3111
  }
3112
- /**
3113
- * Everything wrong with replacing `original` with `replacement` at `path`. Empty means safe
3114
- * to commit. `original` is null for a file being created, where there is nothing to lose and
3115
- * only the content's own validity matters.
3116
- */
3117
3112
  declare function assessReplacement(path: string, original: string | null, replacement: string): ReplacementConcern[];
3118
3113
  /** One line naming why a file was dropped, for a log line or a PR body. */
3119
3114
  declare function describeConcerns(concerns: ReplacementConcern[]): string;
package/dist/index.d.ts CHANGED
@@ -3106,14 +3106,9 @@ declare function servedDir(framework: Framework | undefined, files: string[], ap
3106
3106
 
3107
3107
  interface ReplacementConcern {
3108
3108
  /** Machine-readable, for logs and the PR body. */
3109
- code: 'shrunk' | 'lost_closing_tag' | 'lost_script' | 'lost_stylesheet' | 'lost_verification' | 'lost_import' | 'invalid_json' | 'invalid_xml' | 'invalid_json_ld' | 'fewer_sitemap_urls' | 'lastmod_moved_backwards';
3109
+ code: 'shrunk' | 'lost_closing_tag' | 'lost_script' | 'lost_stylesheet' | 'lost_verification' | 'lost_import' | 'invalid_json' | 'invalid_xml' | 'invalid_json_ld' | 'fewer_sitemap_urls' | 'lastmod_moved_backwards' | 'placeholder_content' | 'canonical_in_shared_shell';
3110
3110
  detail: string;
3111
3111
  }
3112
- /**
3113
- * Everything wrong with replacing `original` with `replacement` at `path`. Empty means safe
3114
- * to commit. `original` is null for a file being created, where there is nothing to lose and
3115
- * only the content's own validity matters.
3116
- */
3117
3112
  declare function assessReplacement(path: string, original: string | null, replacement: string): ReplacementConcern[];
3118
3113
  /** One line naming why a file was dropped, for a log line or a PR body. */
3119
3114
  declare function describeConcerns(concerns: ReplacementConcern[]): string;