withruntime 0.7.0 → 0.7.1

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.
package/E2B.md CHANGED
@@ -58,7 +58,7 @@ machine. An E2B key (`e2b_...`) is never sent anywhere. If one is passed as
58
58
  | `envs` | Given to every command and code run through this object. |
59
59
  | `allowInternetAccess: false` | `network: { internet: false }`. |
60
60
  | `lifecycle.onTimeout` | `onLeaseEnd`: `kill` is `stop`, `pause` is `pause`. |
61
- | `commands.run(cmd, { cwd, envs, timeoutMs, onStdout, onStderr })` | `exec`, streamed, so the whole output comes back however large. Default timeout 60 s. `0` means no limit (Runtime's longest, 24 hours). |
61
+ | `commands.run(cmd, { cwd, envs, timeoutMs, onStdout, onStderr })` | `exec`, streamed, so the whole output comes back however large; output lost before it was read sets `truncated` and warns. Default timeout 60 s. `0` means no limit (Runtime's longest, 24 hours). |
62
62
  | Non-zero exit | Throws `CommandExitError` with `exitCode`, `stdout`, `stderr` and `error` (`exit status N`). A command killed by a signal has `exitCode` -1. |
63
63
  | Command past its timeout | Throws `TimeoutError`. |
64
64
  | `commands.run(cmd, { background: true })` | `spawn`. Returns a `CommandHandle` with `pid`, `wait()`, `kill()` (SIGKILL), `sendStdin`, `closeStdin`, `disconnect`, `stdout`, `stderr`, `exitCode`. |
package/dist/cli.js CHANGED
@@ -598,11 +598,17 @@ export async function run(argv, env = process.env, out = defaultOut(argv)) {
598
598
  if (command === "login" || command === "logout") {
599
599
  const { authenticationCommand } = await import("./login.js");
600
600
  const result = await authenticationCommand([command, ...rest], env);
601
+ // Which account it connected to, so a person with several can tell. The
602
+ // connection stands whether or not this read answers.
603
+ const who = command === "login" && "connected" in result && result.connected
604
+ ? await (await client(env)).me().catch(() => undefined)
605
+ : undefined;
606
+ const account = who ? (who.orgName ? `${who.orgName} (${who.orgId})` : who.orgId) : undefined;
601
607
  print(result.pending
602
608
  ? `Not connected yet. When it is approved, run any command, or \`${me} login --wait\`; it uses this link.`
603
609
  : command === "login"
604
- ? `Connected${"agentName" in result && result.agentName ? ` as ${String(result.agentName)}` : ""}.`
605
- : "Disconnected.", result);
610
+ ? `Connected${"agentName" in result && result.agentName ? ` as ${String(result.agentName)}` : ""}${account ? ` to ${account}` : ""}.`
611
+ : "Disconnected.", who ? { ...result, orgId: who.orgId, orgName: who.orgName ?? null } : result);
606
612
  return 0;
607
613
  }
608
614
  if (command === "whoami") {
@@ -28,7 +28,8 @@ function timedOut(timeoutMs) {
28
28
  "Pass a larger 'timeoutMs', or 0 for no limit.");
29
29
  }
30
30
  /** A Runtime result as E2B's: a command killed by a signal has no exit code on
31
- * Runtime; E2B reports -1. */
31
+ * Runtime; E2B reports -1. E2B never loses output, so a result that did says
32
+ * so in `truncated` rather than passing as whole. */
32
33
  function toResult(result) {
33
34
  const exitCode = result.exitCode ?? -1;
34
35
  return {
@@ -40,12 +41,15 @@ function toResult(result) {
40
41
  : {
41
42
  error: result.exitCode === null ? "terminated by a signal" : `exit status ${exitCode}`,
42
43
  }),
44
+ ...(result.truncated ? { truncated: true } : {}),
43
45
  };
44
46
  }
45
47
  function settle(result, timeoutMs) {
46
48
  if (result.timedOut)
47
49
  throw timedOut(timeoutMs);
48
50
  const out = toResult(result);
51
+ if (out.truncated && typeof process !== "undefined" && process.emitWarning)
52
+ process.emitWarning("Part of the command's output was dropped before it was read, so stdout and stderr are incomplete (result.truncated). Write large output to a file and read it with sandbox.files.read.", { code: "RUNTIME_E2B_OUTPUT_TRUNCATED" });
49
53
  if (out.exitCode !== 0)
50
54
  throw new CommandExitError(out);
51
55
  return out;
@@ -80,7 +84,7 @@ export class Commands {
80
84
  ...(onStderr ? { onStderr: (text) => void onStderr(text) } : {}),
81
85
  ...(opts.signal ? { signal: opts.signal } : {}),
82
86
  }));
83
- return settle(result, timeoutMs);
87
+ return settle({ ...result, truncated: result.stdoutTruncated === true || result.stderrTruncated === true }, timeoutMs);
84
88
  }
85
89
  async #start(cmd, opts, timeoutMs) {
86
90
  const process = await guard("sandbox", () => this.#ctx.runtime.spawn(cmd, {
@@ -166,6 +170,7 @@ export class CommandHandle {
166
170
  #stdout = "";
167
171
  #stderr = "";
168
172
  #exit;
173
+ #truncated = false;
169
174
  #failure;
170
175
  #disconnected = false;
171
176
  constructor(process, options) {
@@ -189,6 +194,9 @@ export class CommandHandle {
189
194
  this.#stderr += event.data;
190
195
  await options.onStderr?.(event.data);
191
196
  }
197
+ else if (event.type === "truncated") {
198
+ this.#truncated = true;
199
+ }
192
200
  else if (event.type === "exit") {
193
201
  this.#exit = { exitCode: event.exitCode, timedOut: event.timedOut };
194
202
  }
@@ -237,6 +245,7 @@ export class CommandHandle {
237
245
  stdout: this.#stdout,
238
246
  stderr: this.#stderr,
239
247
  timedOut: this.#exit.timedOut,
248
+ truncated: this.#truncated,
240
249
  }, this.#timeoutMs);
241
250
  }
242
251
  /** Stops receiving output; the command keeps running. */
@@ -52,6 +52,10 @@ export interface CommandResult {
52
52
  error?: string;
53
53
  stdout: string;
54
54
  stderr: string;
55
+ /** Runtime's addition, present only when true: some of the command's
56
+ * output was dropped before it was read, so `stdout` and `stderr` are
57
+ * missing part of it. A warning says so too. */
58
+ truncated?: true;
55
59
  }
56
60
  /** Thrown by `commands.run` and `CommandHandle.wait` when the command exits
57
61
  * with a code other than 0. It carries the result, as in E2B. */
@@ -62,6 +66,7 @@ export declare class CommandExitError extends SandboxError implements CommandRes
62
66
  get error(): string | undefined;
63
67
  get stdout(): string;
64
68
  get stderr(): string;
69
+ get truncated(): true | undefined;
65
70
  }
66
71
  /** Which object a call was about, to name a 404 the way E2B would. */
67
72
  export type Subject = "sandbox" | "file" | "other";
@@ -92,6 +92,9 @@ export class CommandExitError extends SandboxError {
92
92
  get stderr() {
93
93
  return this.#result.stderr;
94
94
  }
95
+ get truncated() {
96
+ return this.#result.truncated;
97
+ }
95
98
  }
96
99
  /** Turns a Runtime SDK error into the E2B error a caller written for E2B
97
100
  * expects. Anything that is not a Runtime error passes through unchanged. */
package/dist/sandbox.js CHANGED
@@ -408,10 +408,6 @@ export class Sandbox {
408
408
  return this.#info;
409
409
  }
410
410
  }
411
- /** A streamed command keeps all its output unless the reader fell more than the
412
- * process's output buffer behind, which the server marks with a "truncated"
413
- * event. That event does not say which stream lost bytes, so both flags carry
414
- * it; without one, both are false, as a synchronous result's are. */
415
411
  /** Where a reader of a process's output is, in bytes of stdout and stderr
416
412
  * together. Output it did not receive, named by the server or not, becomes a
417
413
  * `truncated` event: the next chunk starting past the cursor means the bytes
@@ -448,6 +444,10 @@ class OutputCursor {
448
444
  function cutOff(error) {
449
445
  return !(error instanceof RuntimeError) || error instanceof ConnectionError;
450
446
  }
447
+ /** A streamed command keeps all its output unless the reader fell more than the
448
+ * process's output buffer behind, which the server marks with a "truncated"
449
+ * event. That event does not say which stream lost bytes, so both flags carry
450
+ * it; without one, both are false, as a synchronous result's are. */
451
451
  function truncation(dropped) {
452
452
  return { stdoutTruncated: dropped, stderrTruncated: dropped };
453
453
  }
@@ -1,5 +1,5 @@
1
1
  import { RuntimeError } from "./errors.js";
2
- export declare const VERSION = "0.7.0";
2
+ export declare const VERSION = "0.7.1";
3
3
  export declare const DEFAULT_BASE_URL = "https://api.withruntime.com";
4
4
  export type RequestOptions = {
5
5
  /** Sent as Idempotency-Key. Omit it: the SDK makes one per call and keeps
package/dist/transport.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ConnectionError, errorFor, RuntimeError, WAITS_FOR_ROOM } from "./errors.js";
2
2
  import { describeRoute, envFetch, openWebSocket } from "./proxy.js";
3
- export const VERSION = "0.7.0";
3
+ export const VERSION = "0.7.1";
4
4
  export const DEFAULT_BASE_URL = "https://api.withruntime.com";
5
5
  export function apiOrigin(value) {
6
6
  const url = new URL(value);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "withruntime",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "license": "Apache-2.0",
5
5
  "mcpName": "com.withruntime/runtime",
6
6
  "type": "module",
@@ -110,14 +110,25 @@
110
110
  "registry": "https://registry.npmjs.org/"
111
111
  },
112
112
  "description": "Runtime Cloud: one client, CLI and MCP bridge for every Runtime product. Sandboxes first.",
113
+ "homepage": "https://withruntime.com",
114
+ "repository": {
115
+ "type": "git",
116
+ "url": "git+https://github.com/withruntime/runtime.git",
117
+ "directory": "packages/cloud-sdk"
118
+ },
119
+ "bugs": "https://github.com/withruntime/runtime/issues",
113
120
  "sideEffects": false,
114
121
  "keywords": [
115
122
  "sandbox",
116
123
  "cloud",
117
124
  "agents",
125
+ "ai-agents",
118
126
  "mcp",
119
127
  "microvm",
120
- "code-execution"
128
+ "firecracker",
129
+ "code-execution",
130
+ "code-interpreter",
131
+ "llm"
121
132
  ],
122
133
  "dependencies": {
123
134
  "undici": "^7.29.1"