@trama-dev/runtime 0.3.1 → 0.5.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 (47) hide show
  1. package/README.md +4 -3
  2. package/dist/abort.d.ts +12 -0
  3. package/dist/abort.js +31 -0
  4. package/dist/agent-backend.d.ts +0 -6
  5. package/dist/agent-backend.js +1 -21
  6. package/dist/agent.d.ts +16 -1
  7. package/dist/agent.js +108 -35
  8. package/dist/bridge-client.js +44 -14
  9. package/dist/child-process.d.ts +1 -20
  10. package/dist/child-process.js +11 -86
  11. package/dist/client.d.ts +2 -1
  12. package/dist/client.js +5 -15
  13. package/dist/context.d.ts +36 -7
  14. package/dist/context.js +83 -92
  15. package/dist/errors.d.ts +2 -0
  16. package/dist/errors.js +2 -0
  17. package/dist/index.d.ts +12 -1
  18. package/dist/index.js +93 -53
  19. package/dist/ipc-server.d.ts +12 -6
  20. package/dist/ipc-server.js +124 -136
  21. package/dist/journal-view.d.ts +9 -0
  22. package/dist/journal-view.js +139 -0
  23. package/dist/journal.d.ts +70 -0
  24. package/dist/journal.js +454 -0
  25. package/dist/meta.d.ts +18 -0
  26. package/dist/meta.js +29 -0
  27. package/dist/path-guard.d.ts +128 -19
  28. package/dist/path-guard.js +384 -68
  29. package/dist/pi-adapter.d.ts +7 -6
  30. package/dist/pi-adapter.js +15 -26
  31. package/dist/replace-file.d.ts +31 -0
  32. package/dist/replace-file.js +75 -0
  33. package/dist/runner-types.d.ts +2 -0
  34. package/dist/runner.d.ts +37 -37
  35. package/dist/runner.js +565 -239
  36. package/dist/serializable.d.ts +10 -4
  37. package/dist/serializable.js +56 -31
  38. package/dist/{watchdog.d.ts → stopping.d.ts} +15 -0
  39. package/dist/stopping.js +268 -0
  40. package/dist/tools.js +44 -13
  41. package/dist/tree.d.ts +234 -0
  42. package/dist/tree.js +1409 -0
  43. package/dist/types.d.ts +6 -3
  44. package/dist/workspace.d.ts +7 -0
  45. package/dist/workspace.js +93 -104
  46. package/package.json +2 -2
  47. package/dist/watchdog.js +0 -167
@@ -1,8 +1,14 @@
1
1
  /**
2
2
  * Recursively check that a value is strictly JSON-serializable.
3
3
  * Throws TypeError with the path to the offending value.
4
- *
5
- * Uses a stack (ancestor chain) instead of a flat set so that shared-but-
6
- * non-circular structures like { a: shared, b: shared } pass validation.
7
4
  */
8
- export declare function assertSerializable(value: unknown, path: string, ancestors?: Set<unknown>): void;
5
+ export declare function assertSerializable(value: unknown, path: string): void;
6
+ /** What a parsed JSON value is, for saying what was found where an object was expected. */
7
+ export declare const describeJson: (value: unknown) => string;
8
+ export declare const isJsonObject: (value: unknown) => value is Record<string, unknown>;
9
+ /**
10
+ * Log data as a log line will hold it: what JSON makes of it — or, where JSON
11
+ * can make nothing of it (a circular reference, a BigInt), a note that says
12
+ * so. A log call does not fail over what it was handed.
13
+ */
14
+ export declare function toLogData(data: unknown): unknown;
@@ -1,41 +1,66 @@
1
1
  /**
2
2
  * Recursively check that a value is strictly JSON-serializable.
3
3
  * Throws TypeError with the path to the offending value.
4
- *
5
- * Uses a stack (ancestor chain) instead of a flat set so that shared-but-
6
- * non-circular structures like { a: shared, b: shared } pass validation.
7
4
  */
8
- export function assertSerializable(value, path, ancestors = new Set()) {
9
- if (value === null || typeof value === "string" || typeof value === "boolean") {
10
- return;
11
- }
12
- if (typeof value === "number") {
13
- if (!Number.isFinite(value)) {
14
- throw new TypeError(`${path} is not JSON-serializable (${value})`);
5
+ export function assertSerializable(value, path) {
6
+ // The objects on the way down to the value being checked. An ancestor chain
7
+ // rather than a set of everything seen, so that a structure that is shared
8
+ // but not circular — { a: shared, b: shared } — passes.
9
+ const ancestors = new Set();
10
+ const check = (value, path) => {
11
+ if (value === null || typeof value === "string" || typeof value === "boolean")
12
+ return;
13
+ if (typeof value === "number") {
14
+ if (!Number.isFinite(value))
15
+ throw new TypeError(`${path} is not JSON-serializable (${value})`);
16
+ return;
15
17
  }
16
- return;
17
- }
18
- if (typeof value === "undefined" || typeof value === "function" || typeof value === "symbol" || typeof value === "bigint") {
19
- throw new TypeError(`${path} is not JSON-serializable (${typeof value})`);
20
- }
21
- if (ancestors.has(value)) {
22
- throw new TypeError(`${path} contains a circular reference`);
23
- }
24
- ancestors.add(value);
25
- if (Array.isArray(value)) {
26
- for (let i = 0; i < value.length; i++) {
27
- assertSerializable(value[i], `${path}[${i}]`, ancestors);
18
+ if (typeof value !== "object") {
19
+ throw new TypeError(`${path} is not JSON-serializable (${typeof value})`);
20
+ }
21
+ if (ancestors.has(value)) {
22
+ throw new TypeError(`${path} contains a circular reference`);
23
+ }
24
+ ancestors.add(value);
25
+ if (Array.isArray(value)) {
26
+ for (let i = 0; i < value.length; i++)
27
+ check(value[i], `${path}[${i}]`);
28
+ }
29
+ else {
30
+ const proto = Object.getPrototypeOf(value);
31
+ if (proto !== Object.prototype && proto !== null) {
32
+ const name = value.constructor?.name ?? "unknown";
33
+ throw new TypeError(`${path} is not a plain object (${name})`);
34
+ }
35
+ for (const [k, v] of Object.entries(value))
36
+ check(v, `${path}.${k}`);
28
37
  }
29
38
  ancestors.delete(value);
30
- return;
31
- }
32
- const proto = Object.getPrototypeOf(value);
33
- if (proto !== Object.prototype && proto !== null) {
34
- const name = value.constructor?.name ?? "unknown";
35
- throw new TypeError(`${path} is not a plain object (${name})`);
39
+ };
40
+ check(value, path);
41
+ }
42
+ /** What a parsed JSON value is, for saying what was found where an object was expected. */
43
+ export const describeJson = (value) => Array.isArray(value) ? "an array" : value === null ? "null" : typeof value;
44
+ export const isJsonObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
45
+ /**
46
+ * Log data as a log line will hold it: what JSON makes of it — or, where JSON
47
+ * can make nothing of it (a circular reference, a BigInt), a note that says
48
+ * so. A log call does not fail over what it was handed.
49
+ */
50
+ export function toLogData(data) {
51
+ try {
52
+ const text = JSON.stringify(data);
53
+ return text === undefined ? undefined : JSON.parse(text);
36
54
  }
37
- for (const [k, v] of Object.entries(value)) {
38
- assertSerializable(v, `${path}.${k}`, ancestors);
55
+ catch {
56
+ let described;
57
+ // An object with no prototype cannot even be turned into text.
58
+ try {
59
+ described = String(data);
60
+ }
61
+ catch {
62
+ described = Object.prototype.toString.call(data);
63
+ }
64
+ return { __trama_unserializable: described };
39
65
  }
40
- ancestors.delete(value);
41
66
  }
@@ -1,3 +1,12 @@
1
+ /**
2
+ * Send a signal to a whole process group. Children spawned with `detached: true`
3
+ * lead their own group, so this also reaches whatever they started in the background.
4
+ * Signal 0 only probes. Returns false if the group no longer exists — or
5
+ * holds nothing that can be signalled, which is the same to one who means to
6
+ * stop it. (macOS says so of a group whose last members have exited and are
7
+ * yet to be reaped; to wait for such a group is to wait for nothing.)
8
+ */
9
+ export declare function signalGroup(pgid: number, signal: NodeJS.Signals | 0): boolean;
1
10
  /**
2
11
  * Make sure there is a watchdog before anything is started that would need
3
12
  * one. Throws if one cannot be started: running without it would mean leaving
@@ -17,3 +26,9 @@ export declare function stopWithThisProcess(pgid: number): () => void;
17
26
  export declare function removeWithThisProcess(dir: string): () => void;
18
27
  /** Remove a temp directory. Best-effort: failing to clean up must never change a run's outcome. */
19
28
  export declare function removeTempDir(dir: string): void;
29
+ /**
30
+ * Stop process groups for good: SIGTERM now, SIGKILL after the grace period to
31
+ * whichever are still there. Resolves when none is left — so that what follows
32
+ * (merging a directory they were writing to, deleting it) finds them gone.
33
+ */
34
+ export declare function stopGroups(pgids: number[]): Promise<void>;
@@ -0,0 +1,268 @@
1
+ // Stopping what a runner started, and removing what it made.
2
+ //
3
+ // A program, and every shell command it runs, leads its own process group — so
4
+ // that a timeout can take down everything it started. The cost is that none of
5
+ // them die with the runner: something has to stop them, and delete the temp
6
+ // directories they worked in.
7
+ //
8
+ // Never SIGKILL first. A group gets the chance to end properly — a program to
9
+ // close what it opened, a `trama` command to stop its own run and report it.
10
+ // Killed outright, nothing in it gets to finish anything. So a group is asked
11
+ // to stop, and killed only if it is still there when the grace period is over.
12
+ //
13
+ // That policy is carried out in two places. While the runner is there, it does
14
+ // it itself and waits for the result (stopGroups). When the runner is gone, it
15
+ // cannot: a process that is killed outright, or runs out of memory, or
16
+ // crashes, runs no code on its way out. So there is a process of its own, the
17
+ // watchdog. The runner keeps a pipe to it open, and tells it what it has
18
+ // started and what has ended. When the pipe closes — the runner is gone,
19
+ // however it went — the watchdog stops whatever is still on its list and
20
+ // deletes what is left of the directories. One runner carries every run of a
21
+ // session, so one list covers the whole tree.
22
+ //
23
+ // Nothing here listens for a signal or for the process exiting: the process
24
+ // that hosts a runner keeps its own way of handling both.
25
+ import { spawn } from "child_process";
26
+ import * as fs from "fs";
27
+ /** How long a process group gets to exit after SIGTERM before it is sent SIGKILL. */
28
+ const KILL_GRACE_MS = 5000;
29
+ const STOP_POLL_MS = 25;
30
+ /** How long a group is waited for after SIGKILL before it is given up on. */
31
+ const KILL_SETTLE_MS = 1000;
32
+ /**
33
+ * Send a signal to a whole process group. Children spawned with `detached: true`
34
+ * lead their own group, so this also reaches whatever they started in the background.
35
+ * Signal 0 only probes. Returns false if the group no longer exists — or
36
+ * holds nothing that can be signalled, which is the same to one who means to
37
+ * stop it. (macOS says so of a group whose last members have exited and are
38
+ * yet to be reaped; to wait for such a group is to wait for nothing.)
39
+ */
40
+ export function signalGroup(pgid, signal) {
41
+ try {
42
+ process.kill(-pgid, signal);
43
+ return true;
44
+ }
45
+ catch {
46
+ return false;
47
+ }
48
+ }
49
+ // --- Removing what was made ---
50
+ /**
51
+ * Remove a directory tree, whatever has been done to it since it was made. A
52
+ * tree with a directory in it that may not be written to — a copy of a project
53
+ * that has one, or one a program made so — cannot be emptied as it stands; so
54
+ * where removing it fails, its directories are opened first.
55
+ *
56
+ * It runs in two processes, here and in the watchdog, which is handed its
57
+ * text: it may use nothing but its arguments.
58
+ */
59
+ function removeTree(fs, dir) {
60
+ const remove = () => fs.rmSync(dir, { recursive: true, force: true });
61
+ try {
62
+ return remove();
63
+ }
64
+ catch { /* opened below, and tried once more */ }
65
+ const open = (at) => {
66
+ try {
67
+ fs.chmodSync(at, 0o700);
68
+ for (const entry of fs.readdirSync(at, { withFileTypes: true })) {
69
+ if (entry.isDirectory())
70
+ open(at + "/" + entry.name); // not a link to one: only this tree is touched
71
+ }
72
+ }
73
+ catch { /* what cannot be opened stays as it is */ }
74
+ };
75
+ open(dir);
76
+ try {
77
+ remove();
78
+ }
79
+ catch { /* left for the OS to reap */ }
80
+ }
81
+ // --- The watchdog ---
82
+ // Run by the watchdog process: the same policy as stopGroups below. A group
83
+ // the runner had already asked to stop is not asked a second time.
84
+ const WATCHDOG = `
85
+ const fs = require("fs");
86
+ ${removeTree}
87
+ ${signalGroup}
88
+ const { grace, settle, poll } = JSON.parse(process.argv[1]);
89
+ const lists = { g: new Set(), d: new Set(), asked: new Set() };
90
+ const alive = (pgid) => signalGroup(pgid, 0);
91
+ const signal = signalGroup;
92
+
93
+ let unread = "";
94
+ process.stdin.setEncoding("utf8");
95
+ process.stdin.on("data", (chunk) => {
96
+ unread += chunk;
97
+ for (let end; (end = unread.indexOf("\\n")) !== -1; unread = unread.slice(end + 1)) {
98
+ const [op, list, item] = JSON.parse(unread.slice(0, end));
99
+ lists[list][op === "+" ? "add" : "delete"](item);
100
+ }
101
+ });
102
+
103
+ // The pipe has closed: the runner is gone.
104
+ let leaving = false;
105
+ const takeOver = () => {
106
+ if (leaving) return;
107
+ leaving = true;
108
+ const finish = () => {
109
+ for (const dir of lists.d) removeTree(fs, dir);
110
+ process.exit(0);
111
+ };
112
+ let left = [...lists.g].filter(alive);
113
+ for (const pgid of left) { if (!lists.asked.has(pgid)) signal(pgid, "SIGTERM"); }
114
+ let deadline = performance.now() + grace;
115
+ let killed = false;
116
+ const check = () => {
117
+ // A group seen gone is never signalled again: its id may belong to another by now.
118
+ left = left.filter(alive);
119
+ if (left.length === 0) return finish();
120
+ if (performance.now() < deadline) return;
121
+ if (killed) return finish();
122
+ for (const pgid of left) signal(pgid, "SIGKILL");
123
+ killed = true;
124
+ deadline = performance.now() + settle;
125
+ };
126
+ check();
127
+ setInterval(check, poll);
128
+ };
129
+ process.stdin.on("end", takeOver);
130
+ process.stdin.on("close", takeOver);
131
+ process.stdin.on("error", takeOver);
132
+ `;
133
+ /** What the watchdog has been told about and not yet told to forget. */
134
+ const listed = { g: new Set(), d: new Set(), asked: new Set() };
135
+ let watchdog = null;
136
+ const tell = (to, op, list, item) => {
137
+ to.stdin?.write(JSON.stringify([op, list, item]) + "\n");
138
+ };
139
+ /**
140
+ * Start the watchdog if there is none, and return it — or null if it cannot be
141
+ * started. A watchdog that has itself died is replaced, and told again what is
142
+ * still listed.
143
+ */
144
+ function startWatchdog() {
145
+ if (watchdog)
146
+ return watchdog;
147
+ let child;
148
+ try {
149
+ const timings = { grace: KILL_GRACE_MS, settle: KILL_SETTLE_MS, poll: STOP_POLL_MS };
150
+ // It is this file's own few lines, and is to start whatever this process was started with:
151
+ // not with what NODE_OPTIONS would have it load first, or wait for (a debugger, say).
152
+ const { NODE_OPTIONS: _options, ...env } = process.env;
153
+ child = spawn(process.execPath, ["-e", WATCHDOG, JSON.stringify(timings)], {
154
+ detached: true, // a signal sent to this process's group must not reach it
155
+ stdio: ["pipe", "ignore", "ignore"],
156
+ env,
157
+ });
158
+ }
159
+ catch {
160
+ return null;
161
+ }
162
+ const lost = () => { if (watchdog === child)
163
+ watchdog = null; };
164
+ child.on("error", lost);
165
+ child.on("exit", lost);
166
+ child.stdin?.on("error", lost);
167
+ if (child.pid === undefined)
168
+ return null; // a failed spawn has no pid from the start
169
+ // Neither the watchdog nor the pipe to it keeps this process alive.
170
+ child.unref();
171
+ child.stdin?.unref?.();
172
+ watchdog = child;
173
+ for (const name of ["g", "d", "asked"]) {
174
+ for (const item of listed[name])
175
+ tell(child, "+", name, item);
176
+ }
177
+ return child;
178
+ }
179
+ /**
180
+ * Make sure there is a watchdog before anything is started that would need
181
+ * one. Throws if one cannot be started: running without it would mean leaving
182
+ * processes behind with nobody to stop them.
183
+ */
184
+ export function requireWatchdog() {
185
+ if (!startWatchdog()) {
186
+ throw new Error("Could not start trama's watchdog process, which stops what a run started if the runner dies.");
187
+ }
188
+ }
189
+ /** Put an item on one of the watchdog's lists. */
190
+ function enlist(on, item) {
191
+ listed[on].add(item);
192
+ const to = startWatchdog();
193
+ if (to)
194
+ tell(to, "+", on, item);
195
+ }
196
+ /** Take it off again. */
197
+ function delist(from, item) {
198
+ if (listed[from].delete(item) && watchdog)
199
+ tell(watchdog, "-", from, item);
200
+ }
201
+ /**
202
+ * Register a process group this process started: if this process ends before
203
+ * the returned function is called, the group is stopped.
204
+ */
205
+ export function stopWithThisProcess(pgid) {
206
+ enlist("g", pgid);
207
+ return () => {
208
+ delist("g", pgid);
209
+ delist("asked", pgid);
210
+ };
211
+ }
212
+ /**
213
+ * Register a temp directory this process created: if this process ends before
214
+ * the returned function is called, the directory is removed — once the groups
215
+ * that may be writing to it are gone.
216
+ */
217
+ export function removeWithThisProcess(dir) {
218
+ enlist("d", dir);
219
+ return () => delist("d", dir);
220
+ }
221
+ /** Remove a temp directory. Best-effort: failing to clean up must never change a run's outcome. */
222
+ export function removeTempDir(dir) {
223
+ removeTree(fs, dir);
224
+ }
225
+ // --- Stopping, while this process is there to see it through ---
226
+ /** Groups this process has asked to stop and is still watching. */
227
+ const stopping = new Map();
228
+ function stopGroup(pgid) {
229
+ // Asked once is enough: to some programs a second SIGTERM means "now".
230
+ const watched = stopping.get(pgid);
231
+ if (watched)
232
+ return watched;
233
+ if (!signalGroup(pgid, "SIGTERM"))
234
+ return Promise.resolve();
235
+ // The watchdog, should it take over from here, must not ask again either.
236
+ if (listed.g.has(pgid))
237
+ enlist("asked", pgid);
238
+ const gone = new Promise((resolve) => {
239
+ let deadline = performance.now() + KILL_GRACE_MS;
240
+ let killed = false;
241
+ const poll = setInterval(() => {
242
+ const alive = signalGroup(pgid, 0);
243
+ if (alive && performance.now() < deadline)
244
+ return;
245
+ if (alive && !killed) {
246
+ // Out of patience. A killed group is gone in a moment; allow it that
247
+ // moment, but do not wait on one that for some reason never goes.
248
+ signalGroup(pgid, "SIGKILL");
249
+ killed = true;
250
+ deadline = performance.now() + KILL_SETTLE_MS;
251
+ return;
252
+ }
253
+ clearInterval(poll);
254
+ stopping.delete(pgid);
255
+ resolve();
256
+ }, STOP_POLL_MS);
257
+ });
258
+ stopping.set(pgid, gone);
259
+ return gone;
260
+ }
261
+ /**
262
+ * Stop process groups for good: SIGTERM now, SIGKILL after the grace period to
263
+ * whichever are still there. Resolves when none is left — so that what follows
264
+ * (merging a directory they were writing to, deleting it) finds them gone.
265
+ */
266
+ export async function stopGroups(pgids) {
267
+ await Promise.all(pgids.map(stopGroup));
268
+ }
package/dist/tools.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import { spawn } from "child_process";
2
- import { readFileSync, writeFileSync, mkdirSync } from "fs";
2
+ import { readFileSync, writeFileSync } from "fs";
3
3
  import { resolve, dirname } from "path";
4
- import { guardPath } from "./path-guard.js";
5
- import { signalGroup, stopGroups, superviseChild } from "./child-process.js";
6
- import { stopWithThisProcess } from "./watchdog.js";
4
+ import { guardPath, makeDirsIn, projectAt, realRootOf } from "./path-guard.js";
5
+ import { superviseChild } from "./child-process.js";
6
+ import { messageOf } from "./errors.js";
7
+ import { signalGroup, stopGroups, stopWithThisProcess } from "./stopping.js";
7
8
  const MAX_FETCH_BODY = 10 * 1024 * 1024; // 10 MB
8
9
  const DEFAULT_SHELL_TIMEOUT = 30_000;
9
10
  const GROUP_SWEEP_MS = 250;
@@ -78,7 +79,11 @@ export function createTools(projectDir, signal) {
78
79
  },
79
80
  async write(path, content) {
80
81
  const target = guardPath(normalizedProjectDir, path); // before mkdir — no side effects outside the project
81
- mkdirSync(dirname(target), { recursive: true });
82
+ // (Asked to write the project itself, the system refuses a directory. Where the project is gone it is refused
83
+ // either way, as any write is: this only says of the project what is otherwise said of "the directory".)
84
+ if (target === realRootOf(normalizedProjectDir))
85
+ projectAt(normalizedProjectDir);
86
+ makeDirsIn(normalizedProjectDir, dirname(target));
82
87
  writeFileSync(target, content);
83
88
  },
84
89
  async shell(command, options = {}) {
@@ -86,7 +91,8 @@ export function createTools(projectDir, signal) {
86
91
  const child = spawn("sh", ["-c", command], {
87
92
  cwd,
88
93
  env: shellEnv,
89
- stdio: ["pipe", "pipe", "pipe"],
94
+ // Nothing is ever sent to a command: one that reads its input finds it at an end, rather than waiting.
95
+ stdio: ["ignore", "pipe", "pipe"],
90
96
  detached: true,
91
97
  });
92
98
  const pgid = child.pid;
@@ -105,9 +111,7 @@ export function createTools(projectDir, signal) {
105
111
  }
106
112
  catch (spawnError) {
107
113
  // Failed to start (e.g. cwd does not exist) — a result, not an exception.
108
- if (pgid)
109
- untrack(pgid);
110
- return { exitCode: 1, stdout: "", stderr: spawnError.message };
114
+ return { exitCode: 1, stdout: "", stderr: messageOf(spawnError) };
111
115
  }
112
116
  },
113
117
  async fetch(url, options = {}) {
@@ -117,10 +121,37 @@ export function createTools(projectDir, signal) {
117
121
  body: options.body,
118
122
  signal,
119
123
  });
120
- const raw = await response.text();
121
- const body = raw.length > MAX_FETCH_BODY
122
- ? raw.slice(0, MAX_FETCH_BODY) + "\n[trama] response body truncated at 10MB"
123
- : raw;
124
+ let body;
125
+ if (response.body) {
126
+ const reader = response.body.getReader();
127
+ const decoder = new TextDecoder("utf-8");
128
+ let text = "";
129
+ let truncated = false;
130
+ try {
131
+ for (;;) {
132
+ const { done, value } = await reader.read();
133
+ if (done)
134
+ break;
135
+ text += decoder.decode(value, { stream: true });
136
+ if (text.length > MAX_FETCH_BODY) {
137
+ truncated = true;
138
+ await reader.cancel();
139
+ break;
140
+ }
141
+ }
142
+ if (!truncated)
143
+ text += decoder.decode();
144
+ }
145
+ finally {
146
+ reader.releaseLock();
147
+ }
148
+ body = truncated
149
+ ? text.slice(0, MAX_FETCH_BODY) + "\n[trama] response body truncated at 10MB"
150
+ : text;
151
+ }
152
+ else {
153
+ body = ""; // (an answer that has no body: to a HEAD, say)
154
+ }
124
155
  const headers = {};
125
156
  response.headers.forEach((v, k) => { headers[k] = v; });
126
157
  return { status: response.status, body, headers };