@theokit/sdk 5.15.2 → 5.16.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.
- package/CHANGELOG.md +22 -0
- package/dist/{agent-QRIFX2SY.js → agent-FB56RAXD.js} +11 -10
- package/dist/{agent-QRIFX2SY.js.map → agent-FB56RAXD.js.map} +1 -1
- package/dist/{agent-D6WBBNGR.cjs → agent-TM634NHQ.cjs} +12 -11
- package/dist/{agent-D6WBBNGR.cjs.map → agent-TM634NHQ.cjs.map} +1 -1
- package/dist/chunk-22HVMMXX.cjs +13 -0
- package/dist/chunk-22HVMMXX.cjs.map +1 -0
- package/dist/{chunk-PDFSLD5P.cjs → chunk-3JGRKXA7.cjs} +4 -4
- package/dist/{chunk-PDFSLD5P.cjs.map → chunk-3JGRKXA7.cjs.map} +1 -1
- package/dist/{chunk-CMDM4VF6.js → chunk-4XYCF5PA.js} +3 -3
- package/dist/{chunk-CMDM4VF6.js.map → chunk-4XYCF5PA.js.map} +1 -1
- package/dist/{chunk-PSMWZYW6.js → chunk-6WPNFZH3.js} +4 -4
- package/dist/{chunk-PSMWZYW6.js.map → chunk-6WPNFZH3.js.map} +1 -1
- package/dist/{chunk-5L7S2VOL.js → chunk-A3T2A2WU.js} +3 -69
- package/dist/chunk-A3T2A2WU.js.map +1 -0
- package/dist/{chunk-BTGYRM4J.cjs → chunk-BJB6RDEA.cjs} +59 -59
- package/dist/{chunk-BTGYRM4J.cjs.map → chunk-BJB6RDEA.cjs.map} +1 -1
- package/dist/{chunk-6XT5LAZG.cjs → chunk-BXEHUUDJ.cjs} +69 -30
- package/dist/chunk-BXEHUUDJ.cjs.map +1 -0
- package/dist/{chunk-ATGSV4GS.js → chunk-DLCYS5RI.js} +3 -3
- package/dist/{chunk-ATGSV4GS.js.map → chunk-DLCYS5RI.js.map} +1 -1
- package/dist/chunk-GA4ZRKYF.cjs +75 -0
- package/dist/chunk-GA4ZRKYF.cjs.map +1 -0
- package/dist/chunk-ICBNSAO4.js +11 -0
- package/dist/chunk-ICBNSAO4.js.map +1 -0
- package/dist/{chunk-JRQJMZKY.js → chunk-MNE4633K.js} +45 -6
- package/dist/chunk-MNE4633K.js.map +1 -0
- package/dist/{chunk-CG64VPPU.js → chunk-NHD5IN3E.js} +10 -10
- package/dist/{chunk-CG64VPPU.js.map → chunk-NHD5IN3E.js.map} +1 -1
- package/dist/{chunk-Q4UOCMAO.cjs → chunk-S5WTJ6LL.cjs} +5 -5
- package/dist/{chunk-Q4UOCMAO.cjs.map → chunk-S5WTJ6LL.cjs.map} +1 -1
- package/dist/chunk-SGKMTBCO.cjs +18 -0
- package/dist/{chunk-EDIYR4VR.cjs.map → chunk-SGKMTBCO.cjs.map} +1 -1
- package/dist/{chunk-VT3NWHFH.cjs → chunk-TDKLSWHU.cjs} +4 -4
- package/dist/{chunk-VT3NWHFH.cjs.map → chunk-TDKLSWHU.cjs.map} +1 -1
- package/dist/{chunk-AQ23NII7.js → chunk-UNUGF36D.js} +3 -3
- package/dist/{chunk-AQ23NII7.js.map → chunk-UNUGF36D.js.map} +1 -1
- package/dist/{chunk-Z5MB2HAN.cjs → chunk-WVQRE7CO.cjs} +4 -70
- package/dist/chunk-WVQRE7CO.cjs.map +1 -0
- package/dist/chunk-Z2UVCAYS.js +72 -0
- package/dist/chunk-Z2UVCAYS.js.map +1 -0
- package/dist/{compact-session-5DWFHMW4.cjs → compact-session-OHA543HN.cjs} +14 -13
- package/dist/{compact-session-5DWFHMW4.cjs.map → compact-session-OHA543HN.cjs.map} +1 -1
- package/dist/{compact-session-AL65PEMX.js → compact-session-XPJS27JD.js} +5 -4
- package/dist/{compact-session-AL65PEMX.js.map → compact-session-XPJS27JD.js.map} +1 -1
- package/dist/cron.cjs +11 -10
- package/dist/cron.js +10 -9
- package/dist/eval.cjs +10 -9
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +9 -8
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +219 -45
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +106 -1
- package/dist/index.d.ts +106 -1
- package/dist/index.js +185 -14
- package/dist/index.js.map +1 -1
- package/dist/{inject-session-QZULG65O.cjs → inject-session-NTL2UAE6.cjs} +5 -5
- package/dist/{inject-session-QZULG65O.cjs.map → inject-session-NTL2UAE6.cjs.map} +1 -1
- package/dist/{inject-session-E2SZ4A35.js → inject-session-SCJ6MTUT.js} +4 -4
- package/dist/{inject-session-E2SZ4A35.js.map → inject-session-SCJ6MTUT.js.map} +1 -1
- package/dist/internal/llm/openai.d.ts +2 -0
- package/dist/internal/llm/responses.d.ts +2 -0
- package/dist/internal/llm/sse.d.ts +6 -0
- package/dist/internal/providers/builtin/openai-chatgpt.d.ts +8 -0
- package/dist/internal/trim-trailing-slashes.d.ts +6 -0
- package/dist/models.cjs +12 -16
- package/dist/models.cjs.map +1 -1
- package/dist/models.js +4 -8
- package/dist/models.js.map +1 -1
- package/dist/openai-chatgpt-IVAL4MW6.cjs +22 -0
- package/dist/openai-chatgpt-IVAL4MW6.cjs.map +1 -0
- package/dist/openai-chatgpt-ZFNZWT2L.js +9 -0
- package/dist/openai-chatgpt-ZFNZWT2L.js.map +1 -0
- package/dist/providers.cjs +5 -4
- package/dist/providers.js +3 -2
- package/dist/sandbox/e2b-sandbox.d.cts +61 -0
- package/dist/sandbox/e2b-sandbox.d.ts +61 -0
- package/dist/sandbox/index.cjs +55 -0
- package/dist/sandbox/index.cjs.map +1 -1
- package/dist/sandbox/index.d.cts +1 -0
- package/dist/sandbox/index.d.ts +1 -0
- package/dist/sandbox/index.js +54 -1
- package/dist/sandbox/index.js.map +1 -1
- package/docs/error-codes.md +6 -4
- package/docs/harness-capability-map.md +21 -1
- package/package.json +5 -1
- package/dist/chunk-5L7S2VOL.js.map +0 -1
- package/dist/chunk-6XT5LAZG.cjs.map +0 -1
- package/dist/chunk-EDIYR4VR.cjs +0 -18
- package/dist/chunk-JRQJMZKY.js.map +0 -1
- package/dist/chunk-Z5MB2HAN.cjs.map +0 -1
package/dist/providers.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { getProviderProfile, listProviders } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { getProviderProfile, listProviders } from './chunk-UNUGF36D.js';
|
|
2
|
+
import './chunk-A3T2A2WU.js';
|
|
3
3
|
import './chunk-AGACYRJ2.js';
|
|
4
|
+
import './chunk-Z2UVCAYS.js';
|
|
4
5
|
import './chunk-UNP4NCMZ.js';
|
|
5
6
|
import './chunk-L2KC2G7H.js';
|
|
6
7
|
import './chunk-5IUDICRK.js';
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* E2BSandbox — a {@link SandboxBackend} over an E2B cloud sandbox you already created.
|
|
3
|
+
*
|
|
4
|
+
* It takes the `Sandbox` instance from the `e2b` package rather than importing it, so `e2b` is not a
|
|
5
|
+
* dependency of this package: the handle only has to match {@link E2BSandboxHandle}. What it solves:
|
|
6
|
+
*
|
|
7
|
+
* - `commands.run` throws `CommandExitError` for a non-zero exit; that becomes the real `exitCode`.
|
|
8
|
+
* - `TimeoutError` becomes `exitCode` 124 with `timedOut: true`. `SandboxNotRunningError` and
|
|
9
|
+
* `SandboxUnreachableError` extend `TimeoutError` in e2b but mean the sandbox is gone, so they throw
|
|
10
|
+
* `SandboxNotAvailableError` instead of reporting a slow command.
|
|
11
|
+
* - Every command gets `envs` (a Dockerfile `ENV` is not applied by E2B templates) and
|
|
12
|
+
* `NODE_EXTRA_CA_CERTS`, because Node does not trust E2B's egress proxy.
|
|
13
|
+
*
|
|
14
|
+
* Errors are recognised by `name`, so a different copy of `e2b` still matches.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
import { type ExecuteResult, SandboxBackend, type SandboxConfig, type SandboxNetworkPolicy } from "./types.js";
|
|
19
|
+
/** System CA bundle that includes the certificate of E2B's egress proxy. */
|
|
20
|
+
export declare const E2B_CA_BUNDLE = "/etc/ssl/certs/ca-certificates.crt";
|
|
21
|
+
/** The slice of an `e2b` `Sandbox` that {@link E2BSandbox} uses. */
|
|
22
|
+
export interface E2BSandboxHandle {
|
|
23
|
+
commands: {
|
|
24
|
+
run(cmd: string, opts?: {
|
|
25
|
+
cwd?: string;
|
|
26
|
+
envs?: Record<string, string>;
|
|
27
|
+
timeoutMs?: number;
|
|
28
|
+
}): Promise<{
|
|
29
|
+
stdout: string;
|
|
30
|
+
stderr: string;
|
|
31
|
+
exitCode: number;
|
|
32
|
+
}>;
|
|
33
|
+
};
|
|
34
|
+
files: {
|
|
35
|
+
write(path: string, data: string | ArrayBuffer | Blob): Promise<unknown>;
|
|
36
|
+
};
|
|
37
|
+
kill(): Promise<unknown>;
|
|
38
|
+
}
|
|
39
|
+
/** Configuration for {@link E2BSandbox}. */
|
|
40
|
+
export interface E2BSandboxConfig extends SandboxConfig {
|
|
41
|
+
/** The created e2b sandbox. */
|
|
42
|
+
sandbox: E2BSandboxHandle;
|
|
43
|
+
/** Environment for every command (e.g. the template's Dockerfile `ENV` lines). */
|
|
44
|
+
envs?: Record<string, string>;
|
|
45
|
+
/** The egress policy the sandbox was created with; exposed as `networkPolicy`. */
|
|
46
|
+
networkPolicy?: SandboxNetworkPolicy;
|
|
47
|
+
}
|
|
48
|
+
/** Sandbox backend that runs commands in an E2B sandbox. */
|
|
49
|
+
export declare class E2BSandbox extends SandboxBackend {
|
|
50
|
+
readonly networkPolicy?: SandboxNetworkPolicy;
|
|
51
|
+
private readonly sandbox;
|
|
52
|
+
private readonly envs;
|
|
53
|
+
constructor(config: E2BSandboxConfig);
|
|
54
|
+
execute(command: string, opts?: {
|
|
55
|
+
timeoutMs?: number;
|
|
56
|
+
}): Promise<ExecuteResult>;
|
|
57
|
+
private fromError;
|
|
58
|
+
uploadFile(path: string, content: string | Buffer): Promise<void>;
|
|
59
|
+
dispose(): Promise<void>;
|
|
60
|
+
private result;
|
|
61
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* E2BSandbox — a {@link SandboxBackend} over an E2B cloud sandbox you already created.
|
|
3
|
+
*
|
|
4
|
+
* It takes the `Sandbox` instance from the `e2b` package rather than importing it, so `e2b` is not a
|
|
5
|
+
* dependency of this package: the handle only has to match {@link E2BSandboxHandle}. What it solves:
|
|
6
|
+
*
|
|
7
|
+
* - `commands.run` throws `CommandExitError` for a non-zero exit; that becomes the real `exitCode`.
|
|
8
|
+
* - `TimeoutError` becomes `exitCode` 124 with `timedOut: true`. `SandboxNotRunningError` and
|
|
9
|
+
* `SandboxUnreachableError` extend `TimeoutError` in e2b but mean the sandbox is gone, so they throw
|
|
10
|
+
* `SandboxNotAvailableError` instead of reporting a slow command.
|
|
11
|
+
* - Every command gets `envs` (a Dockerfile `ENV` is not applied by E2B templates) and
|
|
12
|
+
* `NODE_EXTRA_CA_CERTS`, because Node does not trust E2B's egress proxy.
|
|
13
|
+
*
|
|
14
|
+
* Errors are recognised by `name`, so a different copy of `e2b` still matches.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
import { type ExecuteResult, SandboxBackend, type SandboxConfig, type SandboxNetworkPolicy } from "./types.js";
|
|
19
|
+
/** System CA bundle that includes the certificate of E2B's egress proxy. */
|
|
20
|
+
export declare const E2B_CA_BUNDLE = "/etc/ssl/certs/ca-certificates.crt";
|
|
21
|
+
/** The slice of an `e2b` `Sandbox` that {@link E2BSandbox} uses. */
|
|
22
|
+
export interface E2BSandboxHandle {
|
|
23
|
+
commands: {
|
|
24
|
+
run(cmd: string, opts?: {
|
|
25
|
+
cwd?: string;
|
|
26
|
+
envs?: Record<string, string>;
|
|
27
|
+
timeoutMs?: number;
|
|
28
|
+
}): Promise<{
|
|
29
|
+
stdout: string;
|
|
30
|
+
stderr: string;
|
|
31
|
+
exitCode: number;
|
|
32
|
+
}>;
|
|
33
|
+
};
|
|
34
|
+
files: {
|
|
35
|
+
write(path: string, data: string | ArrayBuffer | Blob): Promise<unknown>;
|
|
36
|
+
};
|
|
37
|
+
kill(): Promise<unknown>;
|
|
38
|
+
}
|
|
39
|
+
/** Configuration for {@link E2BSandbox}. */
|
|
40
|
+
export interface E2BSandboxConfig extends SandboxConfig {
|
|
41
|
+
/** The created e2b sandbox. */
|
|
42
|
+
sandbox: E2BSandboxHandle;
|
|
43
|
+
/** Environment for every command (e.g. the template's Dockerfile `ENV` lines). */
|
|
44
|
+
envs?: Record<string, string>;
|
|
45
|
+
/** The egress policy the sandbox was created with; exposed as `networkPolicy`. */
|
|
46
|
+
networkPolicy?: SandboxNetworkPolicy;
|
|
47
|
+
}
|
|
48
|
+
/** Sandbox backend that runs commands in an E2B sandbox. */
|
|
49
|
+
export declare class E2BSandbox extends SandboxBackend {
|
|
50
|
+
readonly networkPolicy?: SandboxNetworkPolicy;
|
|
51
|
+
private readonly sandbox;
|
|
52
|
+
private readonly envs;
|
|
53
|
+
constructor(config: E2BSandboxConfig);
|
|
54
|
+
execute(command: string, opts?: {
|
|
55
|
+
timeoutMs?: number;
|
|
56
|
+
}): Promise<ExecuteResult>;
|
|
57
|
+
private fromError;
|
|
58
|
+
uploadFile(path: string, content: string | Buffer): Promise<void>;
|
|
59
|
+
dispose(): Promise<void>;
|
|
60
|
+
private result;
|
|
61
|
+
}
|
package/dist/sandbox/index.cjs
CHANGED
|
@@ -314,6 +314,59 @@ var DockerSandbox = class extends chunkX2XLSE2N_cjs.SandboxBackend {
|
|
|
314
314
|
if (r.code !== 0) throw new Error(`uploadFile failed: ${r.stderr.trim() || "docker error"}`);
|
|
315
315
|
}
|
|
316
316
|
};
|
|
317
|
+
var E2B_CA_BUNDLE = "/etc/ssl/certs/ca-certificates.crt";
|
|
318
|
+
var E2BSandbox = class extends chunkX2XLSE2N_cjs.SandboxBackend {
|
|
319
|
+
sandbox;
|
|
320
|
+
envs;
|
|
321
|
+
constructor(config) {
|
|
322
|
+
super({ ...config, workDir: config.workDir ?? "/home/user" });
|
|
323
|
+
this.sandbox = config.sandbox;
|
|
324
|
+
this.envs = { NODE_EXTRA_CA_CERTS: E2B_CA_BUNDLE, ...config.envs };
|
|
325
|
+
if (config.networkPolicy) this.networkPolicy = config.networkPolicy;
|
|
326
|
+
}
|
|
327
|
+
async execute(command, opts) {
|
|
328
|
+
const timeoutMs = opts?.timeoutMs ?? this.config.timeoutMs ?? 3e4;
|
|
329
|
+
try {
|
|
330
|
+
const r = await this.sandbox.commands.run(command, {
|
|
331
|
+
cwd: this.config.workDir,
|
|
332
|
+
envs: this.envs,
|
|
333
|
+
timeoutMs
|
|
334
|
+
});
|
|
335
|
+
return this.result(r, r.exitCode, false);
|
|
336
|
+
} catch (e) {
|
|
337
|
+
return this.fromError(e);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
fromError(e) {
|
|
341
|
+
const err = e ?? {};
|
|
342
|
+
if (err.name === "CommandExitError") {
|
|
343
|
+
return this.result(err, typeof err.exitCode === "number" ? err.exitCode : 1, false);
|
|
344
|
+
}
|
|
345
|
+
if (err.name === "TimeoutError") return this.result(err, 124, true);
|
|
346
|
+
if (err.name === "SandboxNotRunningError" || err.name === "SandboxUnreachableError") {
|
|
347
|
+
throw new chunkX2XLSE2N_cjs.SandboxNotAvailableError(
|
|
348
|
+
`e2b sandbox is not available: ${err.message ?? err.name}`
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
throw e;
|
|
352
|
+
}
|
|
353
|
+
async uploadFile(path3, content) {
|
|
354
|
+
const target = path3.startsWith("/") ? path.posix.normalize(path3) : path.posix.normalize(`${this.config.workDir ?? "/home/user"}/${path3}`);
|
|
355
|
+
const data = typeof content === "string" ? content : new Uint8Array(content).buffer;
|
|
356
|
+
await this.sandbox.files.write(target, data);
|
|
357
|
+
}
|
|
358
|
+
async dispose() {
|
|
359
|
+
await this.sandbox.kill().catch(() => void 0);
|
|
360
|
+
}
|
|
361
|
+
result(r, exitCode, timedOut) {
|
|
362
|
+
return {
|
|
363
|
+
stdout: this.truncateOutput(r.stdout ?? ""),
|
|
364
|
+
stderr: this.truncateOutput(r.stderr ?? ""),
|
|
365
|
+
exitCode,
|
|
366
|
+
timedOut
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
};
|
|
317
370
|
|
|
318
371
|
// src/sandbox/seccomp.ts
|
|
319
372
|
var BPF_LD = 0;
|
|
@@ -751,6 +804,8 @@ Object.defineProperty(exports, "shellEscapePosix", {
|
|
|
751
804
|
get: function () { return chunkX2XLSE2N_cjs.shellEscapePosix; }
|
|
752
805
|
});
|
|
753
806
|
exports.DockerSandbox = DockerSandbox;
|
|
807
|
+
exports.E2BSandbox = E2BSandbox;
|
|
808
|
+
exports.E2B_CA_BUNDLE = E2B_CA_BUNDLE;
|
|
754
809
|
exports.LinuxSandbox = LinuxSandbox;
|
|
755
810
|
exports.RepoProvisionError = RepoProvisionError;
|
|
756
811
|
exports.allowlistedEnv = allowlistedEnv;
|