agentbox-sdk 0.1.0 → 0.1.3

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.
@@ -0,0 +1,18 @@
1
+ // src/enums.ts
2
+ var AgentProvider = {
3
+ ClaudeCode: "claude-code",
4
+ OpenCode: "open-code",
5
+ Codex: "codex"
6
+ };
7
+ var SandboxProvider = {
8
+ LocalDocker: "local-docker",
9
+ Modal: "modal",
10
+ Daytona: "daytona",
11
+ Vercel: "vercel",
12
+ E2B: "e2b"
13
+ };
14
+
15
+ export {
16
+ AgentProvider,
17
+ SandboxProvider
18
+ };
@@ -1,3 +1,23 @@
1
+ import {
2
+ AgentProvider
3
+ } from "./chunk-GOFJNFAD.js";
4
+
5
+ // src/agents/ports.ts
6
+ var AGENT_RESERVED_PORTS = {
7
+ [AgentProvider.ClaudeCode]: [43180],
8
+ [AgentProvider.Codex]: [43181],
9
+ [AgentProvider.OpenCode]: [4096]
10
+ };
11
+ function collectAllAgentReservedPorts() {
12
+ const seen = /* @__PURE__ */ new Set();
13
+ for (const ports of Object.values(AGENT_RESERVED_PORTS)) {
14
+ for (const port of ports) {
15
+ seen.add(port);
16
+ }
17
+ }
18
+ return Array.from(seen);
19
+ }
20
+
1
21
  // src/shared/errors.ts
2
22
  var AgentBoxError = class extends Error {
3
23
  code;
@@ -24,6 +44,10 @@ function asError(error) {
24
44
  }
25
45
  return new Error(typeof error === "string" ? error : JSON.stringify(error));
26
46
  }
47
+ function suppressUnhandledRejection(promise) {
48
+ promise.catch(() => void 0);
49
+ return promise;
50
+ }
27
51
 
28
52
  // src/shared/async-queue.ts
29
53
  var AsyncQueue = class {
@@ -80,33 +104,58 @@ var AsyncQueue = class {
80
104
  }
81
105
  };
82
106
 
107
+ // src/shared/debug.ts
108
+ import createDebug from "debug";
109
+ var ROOT = "agentbox";
110
+ var namespaces = {};
111
+ function debug(namespace) {
112
+ let d = namespaces[namespace];
113
+ if (!d) {
114
+ d = createDebug(`${ROOT}:${namespace}`);
115
+ namespaces[namespace] = d;
116
+ }
117
+ return d;
118
+ }
119
+ var debugAgent = debug("agent");
120
+ var debugClaude = debug("claude");
121
+ var debugCodex = debug("codex");
122
+ var debugOpencode = debug("opencode");
123
+ var debugSetup = debug("setup");
124
+ var debugRuntime = debug("runtime");
125
+ var debugSandbox = debug("sandbox");
126
+ var debugRelay = debug("relay");
127
+ async function time(log, label, fn, extra) {
128
+ if (!log.enabled) {
129
+ return fn();
130
+ }
131
+ const start = Date.now();
132
+ log("\u2192 %s", label);
133
+ try {
134
+ const result = await fn();
135
+ const meta = extra?.(result);
136
+ if (meta) {
137
+ log("\u2190 %s (%dms) %o", label, Date.now() - start, meta);
138
+ } else {
139
+ log("\u2190 %s (%dms)", label, Date.now() - start);
140
+ }
141
+ return result;
142
+ } catch (error) {
143
+ log(
144
+ "\u2717 %s (%dms): %s",
145
+ label,
146
+ Date.now() - start,
147
+ error instanceof Error ? error.message : String(error)
148
+ );
149
+ throw error;
150
+ }
151
+ }
152
+
83
153
  // src/shared/network.ts
84
154
  import net from "net";
85
155
  import { setTimeout as sleepTimeout } from "timers/promises";
86
156
  async function sleep(ms) {
87
157
  await sleepTimeout(ms);
88
158
  }
89
- async function getAvailablePort(host = "127.0.0.1") {
90
- return new Promise((resolve, reject) => {
91
- const server = net.createServer();
92
- server.once("error", reject);
93
- server.listen(0, host, () => {
94
- const address = server.address();
95
- if (!address || typeof address === "string") {
96
- reject(new Error("Could not determine an available port."));
97
- return;
98
- }
99
- const { port } = address;
100
- server.close((error) => {
101
- if (error) {
102
- reject(error);
103
- return;
104
- }
105
- resolve(port);
106
- });
107
- });
108
- });
109
- }
110
159
  async function waitFor(predicate, options) {
111
160
  const timeoutMs = options?.timeoutMs ?? 15e3;
112
161
  const intervalMs = options?.intervalMs ?? 250;
@@ -193,12 +242,23 @@ export {
193
242
  AgentBoxError,
194
243
  UnsupportedProviderError,
195
244
  asError,
245
+ suppressUnhandledRejection,
196
246
  AsyncQueue,
247
+ debugAgent,
248
+ debugClaude,
249
+ debugCodex,
250
+ debugOpencode,
251
+ debugSetup,
252
+ debugRuntime,
253
+ debugSandbox,
254
+ debugRelay,
255
+ time,
197
256
  sleep,
198
- getAvailablePort,
199
257
  waitFor,
200
258
  readStreamAsText,
201
259
  pipeReadableStream,
202
260
  readNodeStream,
203
- linesFromTextChunks
261
+ linesFromTextChunks,
262
+ AGENT_RESERVED_PORTS,
263
+ collectAllAgentReservedPorts
204
264
  };