@shareai-lab/kode-sdk 2.7.1 → 2.7.2
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/dist/core/agent/breakpoint-manager.js +36 -0
- package/dist/core/agent/message-queue.js +57 -0
- package/dist/core/agent/permission-manager.js +32 -0
- package/dist/core/agent/todo-manager.js +91 -0
- package/dist/core/agent/tool-runner.js +45 -0
- package/dist/core/agent.js +2035 -0
- package/dist/core/config.js +2 -0
- package/dist/core/context-manager.js +241 -0
- package/dist/core/errors.js +49 -0
- package/dist/core/events.js +329 -0
- package/dist/core/file-pool.d.ts +2 -0
- package/dist/core/file-pool.js +125 -0
- package/dist/core/hooks.js +71 -0
- package/dist/core/permission-modes.js +61 -0
- package/dist/core/pool.js +301 -0
- package/dist/core/room.js +57 -0
- package/dist/core/scheduler.js +58 -0
- package/dist/core/skills/index.js +20 -0
- package/dist/core/skills/management-manager.js +557 -0
- package/dist/core/skills/manager.js +243 -0
- package/dist/core/skills/operation-queue.js +113 -0
- package/dist/core/skills/sandbox-file-manager.js +183 -0
- package/dist/core/skills/types.js +9 -0
- package/dist/core/skills/xml-generator.js +70 -0
- package/dist/core/template.js +35 -0
- package/dist/core/time-bridge.js +100 -0
- package/dist/core/todo.js +89 -0
- package/dist/core/types.js +3 -0
- package/dist/index.js +148 -60461
- package/dist/infra/db/postgres/postgres-store.js +1073 -0
- package/dist/infra/db/sqlite/sqlite-store.js +800 -0
- package/dist/infra/e2b/e2b-fs.js +128 -0
- package/dist/infra/e2b/e2b-sandbox.js +156 -0
- package/dist/infra/e2b/e2b-template.js +105 -0
- package/dist/infra/e2b/index.js +9 -0
- package/dist/infra/e2b/types.js +2 -0
- package/dist/infra/provider.js +67 -0
- package/dist/infra/providers/anthropic.js +308 -0
- package/dist/infra/providers/core/errors.js +353 -0
- package/dist/infra/providers/core/fork.js +418 -0
- package/dist/infra/providers/core/index.js +76 -0
- package/dist/infra/providers/core/logger.js +191 -0
- package/dist/infra/providers/core/retry.js +189 -0
- package/dist/infra/providers/core/usage.js +376 -0
- package/dist/infra/providers/gemini.js +493 -0
- package/dist/infra/providers/index.js +83 -0
- package/dist/infra/providers/openai.js +662 -0
- package/dist/infra/providers/types.js +20 -0
- package/dist/infra/providers/utils.js +400 -0
- package/dist/infra/sandbox-factory.js +30 -0
- package/dist/infra/sandbox.js +243 -0
- package/dist/infra/store/factory.js +80 -0
- package/dist/infra/store/index.js +26 -0
- package/dist/infra/store/json-store.js +606 -0
- package/dist/infra/store/types.js +2 -0
- package/dist/infra/store.js +29 -0
- package/dist/tools/bash_kill/index.js +35 -0
- package/dist/tools/bash_kill/prompt.js +14 -0
- package/dist/tools/bash_logs/index.js +40 -0
- package/dist/tools/bash_logs/prompt.js +14 -0
- package/dist/tools/bash_run/index.js +61 -0
- package/dist/tools/bash_run/prompt.js +18 -0
- package/dist/tools/builtin.js +26 -0
- package/dist/tools/define.js +214 -0
- package/dist/tools/fs_edit/index.js +62 -0
- package/dist/tools/fs_edit/prompt.js +15 -0
- package/dist/tools/fs_glob/index.js +40 -0
- package/dist/tools/fs_glob/prompt.js +15 -0
- package/dist/tools/fs_grep/index.js +66 -0
- package/dist/tools/fs_grep/prompt.js +16 -0
- package/dist/tools/fs_multi_edit/index.js +106 -0
- package/dist/tools/fs_multi_edit/prompt.js +16 -0
- package/dist/tools/fs_read/index.js +40 -0
- package/dist/tools/fs_read/prompt.js +16 -0
- package/dist/tools/fs_write/index.js +40 -0
- package/dist/tools/fs_write/prompt.js +15 -0
- package/dist/tools/index.js +61 -0
- package/dist/tools/mcp.js +185 -0
- package/dist/tools/registry.js +26 -0
- package/dist/tools/scripts.js +205 -0
- package/dist/tools/skills.js +115 -0
- package/dist/tools/task_run/index.js +58 -0
- package/dist/tools/task_run/prompt.js +25 -0
- package/dist/tools/todo_read/index.js +29 -0
- package/dist/tools/todo_read/prompt.js +18 -0
- package/dist/tools/todo_write/index.js +42 -0
- package/dist/tools/todo_write/prompt.js +23 -0
- package/dist/tools/tool.js +211 -0
- package/dist/tools/toolkit.js +98 -0
- package/dist/tools/type-inference.js +207 -0
- package/dist/utils/agent-id.js +28 -0
- package/dist/utils/logger.js +44 -0
- package/dist/utils/session-id.js +64 -0
- package/package.json +7 -38
- package/dist/index.js.map +0 -7
- package/dist/index.mjs +0 -60385
- package/dist/index.mjs.map +0 -7
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.E2BFS = void 0;
|
|
4
|
+
class E2BFS {
|
|
5
|
+
constructor(host) {
|
|
6
|
+
this.host = host;
|
|
7
|
+
}
|
|
8
|
+
resolve(p) {
|
|
9
|
+
if (p.startsWith('/'))
|
|
10
|
+
return p;
|
|
11
|
+
return `${this.host.workDir}/${p}`.replace(/\/+/g, '/');
|
|
12
|
+
}
|
|
13
|
+
isInside(_p) {
|
|
14
|
+
// E2B sandbox is fully isolated, all paths are safe
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
async read(p) {
|
|
18
|
+
const e2b = this.host.getE2BInstance();
|
|
19
|
+
const resolved = this.resolve(p);
|
|
20
|
+
return await e2b.files.read(resolved, { format: 'text' });
|
|
21
|
+
}
|
|
22
|
+
async write(p, content) {
|
|
23
|
+
const e2b = this.host.getE2BInstance();
|
|
24
|
+
const resolved = this.resolve(p);
|
|
25
|
+
// Ensure parent directory exists
|
|
26
|
+
const dir = resolved.replace(/\/[^/]+$/, '');
|
|
27
|
+
if (dir && dir !== '/') {
|
|
28
|
+
await e2b.commands.run(`mkdir -p "${dir}"`, { timeoutMs: 5000 }).catch(() => { });
|
|
29
|
+
}
|
|
30
|
+
await e2b.files.write(resolved, content);
|
|
31
|
+
}
|
|
32
|
+
temp(name) {
|
|
33
|
+
const tempName = name || `temp-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
34
|
+
return `/tmp/${tempName}`;
|
|
35
|
+
}
|
|
36
|
+
async stat(p) {
|
|
37
|
+
const e2b = this.host.getE2BInstance();
|
|
38
|
+
const resolved = this.resolve(p);
|
|
39
|
+
const info = await e2b.files.getInfo(resolved);
|
|
40
|
+
return { mtimeMs: info.modifiedTime?.getTime() || Date.now() };
|
|
41
|
+
}
|
|
42
|
+
async glob(pattern, opts) {
|
|
43
|
+
const cwd = opts?.cwd ? this.resolve(opts.cwd) : this.host.workDir;
|
|
44
|
+
// Strategy 1: prefer find command (better performance)
|
|
45
|
+
try {
|
|
46
|
+
return await this.globViaFind(pattern, cwd, opts);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
// Strategy 2: fallback to files.list recursion
|
|
50
|
+
return await this.globViaList(pattern, cwd, opts);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async globViaFind(pattern, cwd, opts) {
|
|
54
|
+
const e2b = this.host.getE2BInstance();
|
|
55
|
+
const findPattern = this.globToFindPattern(pattern);
|
|
56
|
+
let cmd = `find "${cwd}" ${findPattern} -type f`;
|
|
57
|
+
if (!opts?.dot) {
|
|
58
|
+
cmd += ' -not -path "*/.*"';
|
|
59
|
+
}
|
|
60
|
+
if (opts?.ignore?.length) {
|
|
61
|
+
for (const ig of opts.ignore) {
|
|
62
|
+
cmd += ` -not -path "${ig}"`;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const result = await e2b.commands.run(cmd, { timeoutMs: 30000 });
|
|
66
|
+
if (result.exitCode !== 0)
|
|
67
|
+
throw new Error(result.stderr);
|
|
68
|
+
const paths = result.stdout.split('\n').filter(Boolean);
|
|
69
|
+
if (opts?.absolute)
|
|
70
|
+
return paths;
|
|
71
|
+
return paths.map((p) => {
|
|
72
|
+
const rel = p.startsWith(cwd) ? p.slice(cwd.length).replace(/^\//, '') : p;
|
|
73
|
+
return rel;
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
async globViaList(pattern, cwd, opts) {
|
|
77
|
+
const e2b = this.host.getE2BInstance();
|
|
78
|
+
const results = [];
|
|
79
|
+
const walk = async (dir) => {
|
|
80
|
+
let entries;
|
|
81
|
+
try {
|
|
82
|
+
entries = await e2b.files.list(dir);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
for (const entry of entries) {
|
|
88
|
+
const fullPath = `${dir}/${entry.name}`.replace(/\/+/g, '/');
|
|
89
|
+
if (!opts?.dot && entry.name.startsWith('.'))
|
|
90
|
+
continue;
|
|
91
|
+
const rel = fullPath.startsWith(cwd)
|
|
92
|
+
? fullPath.slice(cwd.length).replace(/^\//, '')
|
|
93
|
+
: fullPath;
|
|
94
|
+
if (this.matchGlob(pattern, rel)) {
|
|
95
|
+
const ignored = opts?.ignore?.some((ig) => this.matchGlob(ig, rel));
|
|
96
|
+
if (!ignored) {
|
|
97
|
+
results.push(opts?.absolute ? fullPath : rel);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (entry.type === 'dir') {
|
|
101
|
+
await walk(fullPath);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
await walk(cwd);
|
|
106
|
+
return results;
|
|
107
|
+
}
|
|
108
|
+
/** @internal */
|
|
109
|
+
globToFindPattern(pattern) {
|
|
110
|
+
if (pattern.includes('/')) {
|
|
111
|
+
const findPat = pattern.replace(/\*\*/g, '*');
|
|
112
|
+
return `-path "*/${findPat}"`;
|
|
113
|
+
}
|
|
114
|
+
return `-name "${pattern}"`;
|
|
115
|
+
}
|
|
116
|
+
/** @internal */
|
|
117
|
+
matchGlob(pattern, target) {
|
|
118
|
+
const regex = pattern
|
|
119
|
+
.replace(/[.+^${}()|[\]\\]/g, '\\$&')
|
|
120
|
+
.replace(/\?/g, '.')
|
|
121
|
+
.replace(/\*\*\//g, '<<<GLOBSTAR_SLASH>>>')
|
|
122
|
+
.replace(/\*\*/g, '.*')
|
|
123
|
+
.replace(/\*/g, '[^/]*')
|
|
124
|
+
.replace(/<<<GLOBSTAR_SLASH>>>/g, '(.*/)?');
|
|
125
|
+
return new RegExp(`^${regex}$`).test(target);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
exports.E2BFS = E2BFS;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.E2BSandbox = void 0;
|
|
4
|
+
const e2b_1 = require("e2b");
|
|
5
|
+
const e2b_fs_1 = require("./e2b-fs");
|
|
6
|
+
class E2BSandbox {
|
|
7
|
+
constructor(options = {}) {
|
|
8
|
+
this.kind = 'e2b';
|
|
9
|
+
this.e2b = null;
|
|
10
|
+
this.watchers = new Map();
|
|
11
|
+
this.options = options;
|
|
12
|
+
this.workDir = options.workDir || '/home/user';
|
|
13
|
+
this.fs = new e2b_fs_1.E2BFS(this);
|
|
14
|
+
}
|
|
15
|
+
/** Initialize sandbox connection (create or resume) */
|
|
16
|
+
async init() {
|
|
17
|
+
if (this.options.sandboxId) {
|
|
18
|
+
this.e2b = await e2b_1.Sandbox.connect(this.options.sandboxId, {
|
|
19
|
+
apiKey: this.options.apiKey,
|
|
20
|
+
domain: this.options.domain,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
this.e2b = await e2b_1.Sandbox.create(this.options.template || 'base', {
|
|
25
|
+
apiKey: this.options.apiKey,
|
|
26
|
+
timeoutMs: this.options.timeoutMs || 300000,
|
|
27
|
+
envs: this.options.envs,
|
|
28
|
+
metadata: this.options.metadata,
|
|
29
|
+
domain: this.options.domain,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** Get underlying E2B SDK instance */
|
|
34
|
+
getE2BInstance() {
|
|
35
|
+
if (!this.e2b)
|
|
36
|
+
throw new Error('E2BSandbox not initialized. Call init() first.');
|
|
37
|
+
return this.e2b;
|
|
38
|
+
}
|
|
39
|
+
/** Get sandbox ID (for persistence and resume) */
|
|
40
|
+
getSandboxId() {
|
|
41
|
+
return this.getE2BInstance().sandboxId;
|
|
42
|
+
}
|
|
43
|
+
/** Get accessible URL for a given port */
|
|
44
|
+
getHostUrl(port) {
|
|
45
|
+
return `https://${this.getE2BInstance().getHost(port)}`;
|
|
46
|
+
}
|
|
47
|
+
async exec(cmd, opts) {
|
|
48
|
+
const e2b = this.getE2BInstance();
|
|
49
|
+
const timeout = opts?.timeoutMs || this.options.execTimeoutMs || 120000;
|
|
50
|
+
try {
|
|
51
|
+
const result = await this.withRetry(() => e2b.commands.run(cmd, {
|
|
52
|
+
cwd: this.workDir,
|
|
53
|
+
timeoutMs: timeout,
|
|
54
|
+
}));
|
|
55
|
+
return {
|
|
56
|
+
code: result.exitCode,
|
|
57
|
+
stdout: result.stdout || '',
|
|
58
|
+
stderr: result.stderr || '',
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
if (error.exitCode !== undefined) {
|
|
63
|
+
return {
|
|
64
|
+
code: error.exitCode,
|
|
65
|
+
stdout: error.stdout || '',
|
|
66
|
+
stderr: error.stderr || error.message || '',
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
code: 1,
|
|
71
|
+
stdout: '',
|
|
72
|
+
stderr: error.message || 'E2B command execution failed',
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
async watchFiles(paths, listener) {
|
|
77
|
+
const e2b = this.getE2BInstance();
|
|
78
|
+
const id = `e2b-watch-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
79
|
+
// E2B watchDir is directory-based, group paths by parent directory
|
|
80
|
+
const dirs = [...new Set(paths.map((p) => {
|
|
81
|
+
const resolved = this.fs.resolve(p);
|
|
82
|
+
return resolved.replace(/\/[^/]+$/, '') || '/';
|
|
83
|
+
}))];
|
|
84
|
+
const handles = [];
|
|
85
|
+
for (const dir of dirs) {
|
|
86
|
+
const handle = await e2b.files.watchDir(dir, (event) => {
|
|
87
|
+
const fullPath = `${dir}/${event.name}`.replace(/\/+/g, '/');
|
|
88
|
+
listener({ path: fullPath, mtimeMs: Date.now() });
|
|
89
|
+
}, { recursive: true });
|
|
90
|
+
handles.push(handle);
|
|
91
|
+
}
|
|
92
|
+
this.watchers.set(id, {
|
|
93
|
+
stop: async () => {
|
|
94
|
+
for (const h of handles)
|
|
95
|
+
await h.stop();
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
return id;
|
|
99
|
+
}
|
|
100
|
+
unwatchFiles(id) {
|
|
101
|
+
const entry = this.watchers.get(id);
|
|
102
|
+
if (entry) {
|
|
103
|
+
entry.stop().catch(() => { });
|
|
104
|
+
this.watchers.delete(id);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
async dispose() {
|
|
108
|
+
for (const entry of this.watchers.values()) {
|
|
109
|
+
await entry.stop().catch(() => { });
|
|
110
|
+
}
|
|
111
|
+
this.watchers.clear();
|
|
112
|
+
if (this.e2b) {
|
|
113
|
+
await this.e2b.kill();
|
|
114
|
+
this.e2b = null;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/** Extend sandbox lifetime */
|
|
118
|
+
async setTimeout(timeoutMs) {
|
|
119
|
+
await this.getE2BInstance().setTimeout(timeoutMs);
|
|
120
|
+
}
|
|
121
|
+
/** Check if sandbox is running */
|
|
122
|
+
async isRunning() {
|
|
123
|
+
try {
|
|
124
|
+
return await this.getE2BInstance().isRunning();
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/** Custom JSON serialization to avoid circular reference */
|
|
131
|
+
toJSON() {
|
|
132
|
+
return {
|
|
133
|
+
kind: this.kind,
|
|
134
|
+
workDir: this.workDir,
|
|
135
|
+
sandboxId: this.e2b?.sandboxId ?? null,
|
|
136
|
+
template: this.options.template,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
async withRetry(fn, maxRetries = 3) {
|
|
140
|
+
for (let i = 0; i < maxRetries; i++) {
|
|
141
|
+
try {
|
|
142
|
+
return await fn();
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
const isRateLimit = error.name === 'RateLimitError' || error.status === 429;
|
|
146
|
+
if (isRateLimit && i < maxRetries - 1) {
|
|
147
|
+
await new Promise((r) => setTimeout(r, Math.pow(2, i) * 1000));
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
throw error;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
throw new Error('Max retries exceeded');
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
exports.E2BSandbox = E2BSandbox;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.E2BTemplateBuilder = void 0;
|
|
37
|
+
/**
|
|
38
|
+
* Build E2B custom templates.
|
|
39
|
+
* Uses E2B Template API to create pre-configured sandbox environments.
|
|
40
|
+
*/
|
|
41
|
+
class E2BTemplateBuilder {
|
|
42
|
+
/**
|
|
43
|
+
* Build a template from config.
|
|
44
|
+
* @returns Build result containing templateId
|
|
45
|
+
*/
|
|
46
|
+
static async build(config, opts) {
|
|
47
|
+
const { Template } = await Promise.resolve().then(() => __importStar(require('e2b')));
|
|
48
|
+
let template;
|
|
49
|
+
switch (config.base) {
|
|
50
|
+
case 'python':
|
|
51
|
+
template = Template().fromPythonImage(config.baseVersion || '3');
|
|
52
|
+
break;
|
|
53
|
+
case 'node':
|
|
54
|
+
template = Template().fromNodeImage(config.baseVersion || '20');
|
|
55
|
+
break;
|
|
56
|
+
case 'debian':
|
|
57
|
+
template = Template().fromDebianImage(config.baseVersion);
|
|
58
|
+
break;
|
|
59
|
+
case 'ubuntu':
|
|
60
|
+
template = Template().fromUbuntuImage(config.baseVersion);
|
|
61
|
+
break;
|
|
62
|
+
case 'custom':
|
|
63
|
+
if (!config.dockerfile)
|
|
64
|
+
throw new Error('Custom base requires dockerfile content');
|
|
65
|
+
template = Template().fromDockerfile(config.dockerfile);
|
|
66
|
+
break;
|
|
67
|
+
default:
|
|
68
|
+
template = Template().fromBaseImage();
|
|
69
|
+
}
|
|
70
|
+
if (config.aptPackages?.length) {
|
|
71
|
+
template = template.aptInstall(config.aptPackages);
|
|
72
|
+
}
|
|
73
|
+
if (config.pipPackages?.length) {
|
|
74
|
+
template = template.pipInstall(config.pipPackages);
|
|
75
|
+
}
|
|
76
|
+
if (config.npmPackages?.length) {
|
|
77
|
+
template = template.npmInstall(config.npmPackages, { g: true });
|
|
78
|
+
}
|
|
79
|
+
if (config.buildCommands?.length) {
|
|
80
|
+
template = template.runCmd(config.buildCommands);
|
|
81
|
+
}
|
|
82
|
+
if (config.workDir) {
|
|
83
|
+
template = template.setWorkdir(config.workDir);
|
|
84
|
+
}
|
|
85
|
+
const buildInfo = await Template.build(template, {
|
|
86
|
+
alias: config.alias,
|
|
87
|
+
cpuCount: config.cpuCount || 2,
|
|
88
|
+
memoryMB: config.memoryMB || 512,
|
|
89
|
+
apiKey: opts?.apiKey,
|
|
90
|
+
onBuildLogs: opts?.onLog ? (log) => opts.onLog(String(log)) : undefined,
|
|
91
|
+
});
|
|
92
|
+
return {
|
|
93
|
+
templateId: buildInfo.templateId || config.alias,
|
|
94
|
+
alias: config.alias,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Check if a template alias already exists.
|
|
99
|
+
*/
|
|
100
|
+
static async exists(alias, opts) {
|
|
101
|
+
const { Template } = await Promise.resolve().then(() => __importStar(require('e2b')));
|
|
102
|
+
return await Template.aliasExists(alias, { apiKey: opts?.apiKey });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.E2BTemplateBuilder = E2BTemplateBuilder;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.E2BTemplateBuilder = exports.E2BFS = exports.E2BSandbox = void 0;
|
|
4
|
+
var e2b_sandbox_1 = require("./e2b-sandbox");
|
|
5
|
+
Object.defineProperty(exports, "E2BSandbox", { enumerable: true, get: function () { return e2b_sandbox_1.E2BSandbox; } });
|
|
6
|
+
var e2b_fs_1 = require("./e2b-fs");
|
|
7
|
+
Object.defineProperty(exports, "E2BFS", { enumerable: true, get: function () { return e2b_fs_1.E2BFS; } });
|
|
8
|
+
var e2b_template_1 = require("./e2b-template");
|
|
9
|
+
Object.defineProperty(exports, "E2BTemplateBuilder", { enumerable: true, get: function () { return e2b_template_1.E2BTemplateBuilder; } });
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Provider Module
|
|
4
|
+
*
|
|
5
|
+
* Re-exports from the providers module for backward compatibility.
|
|
6
|
+
* The actual implementations are in src/infra/providers/.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { AnthropicProvider, OpenAIProvider, GeminiProvider } from './infra/provider';
|
|
11
|
+
* // or
|
|
12
|
+
* import { AnthropicProvider } from './infra/providers';
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
18
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
19
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
20
|
+
}
|
|
21
|
+
Object.defineProperty(o, k2, desc);
|
|
22
|
+
}) : (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
o[k2] = m[k];
|
|
25
|
+
}));
|
|
26
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
27
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.normalizeAnthropicDelta = exports.normalizeAnthropicContentBlock = exports.normalizeAnthropicContent = exports.mergeAnthropicBetaHeader = exports.hasAnthropicFileBlocks = exports.sanitizeGeminiSchema = exports.buildGeminiFilePart = exports.buildGeminiImagePart = exports.extractReasoningDetails = exports.splitThinkText = exports.normalizeThinkBlocks = exports.joinReasoningBlocks = exports.concatTextWithReasoning = exports.AUDIO_UNSUPPORTED_TEXT = exports.IMAGE_UNSUPPORTED_TEXT = exports.FILE_UNSUPPORTED_TEXT = exports.safeJsonStringify = exports.formatToolResult = exports.joinTextBlocks = exports.markTransportIfDegraded = exports.getMessageBlocks = exports.normalizeGeminiBaseUrl = exports.normalizeAnthropicBaseUrl = exports.normalizeOpenAIBaseUrl = exports.normalizeBaseUrl = exports.withProxy = exports.getProxyDispatcher = exports.resolveProxyUrl = exports.GeminiProvider = exports.OpenAIProvider = exports.AnthropicProvider = void 0;
|
|
31
|
+
// Re-export provider implementations
|
|
32
|
+
var providers_1 = require("./providers");
|
|
33
|
+
Object.defineProperty(exports, "AnthropicProvider", { enumerable: true, get: function () { return providers_1.AnthropicProvider; } });
|
|
34
|
+
Object.defineProperty(exports, "OpenAIProvider", { enumerable: true, get: function () { return providers_1.OpenAIProvider; } });
|
|
35
|
+
Object.defineProperty(exports, "GeminiProvider", { enumerable: true, get: function () { return providers_1.GeminiProvider; } });
|
|
36
|
+
// Re-export utilities for backward compatibility
|
|
37
|
+
var providers_2 = require("./providers");
|
|
38
|
+
Object.defineProperty(exports, "resolveProxyUrl", { enumerable: true, get: function () { return providers_2.resolveProxyUrl; } });
|
|
39
|
+
Object.defineProperty(exports, "getProxyDispatcher", { enumerable: true, get: function () { return providers_2.getProxyDispatcher; } });
|
|
40
|
+
Object.defineProperty(exports, "withProxy", { enumerable: true, get: function () { return providers_2.withProxy; } });
|
|
41
|
+
Object.defineProperty(exports, "normalizeBaseUrl", { enumerable: true, get: function () { return providers_2.normalizeBaseUrl; } });
|
|
42
|
+
Object.defineProperty(exports, "normalizeOpenAIBaseUrl", { enumerable: true, get: function () { return providers_2.normalizeOpenAIBaseUrl; } });
|
|
43
|
+
Object.defineProperty(exports, "normalizeAnthropicBaseUrl", { enumerable: true, get: function () { return providers_2.normalizeAnthropicBaseUrl; } });
|
|
44
|
+
Object.defineProperty(exports, "normalizeGeminiBaseUrl", { enumerable: true, get: function () { return providers_2.normalizeGeminiBaseUrl; } });
|
|
45
|
+
Object.defineProperty(exports, "getMessageBlocks", { enumerable: true, get: function () { return providers_2.getMessageBlocks; } });
|
|
46
|
+
Object.defineProperty(exports, "markTransportIfDegraded", { enumerable: true, get: function () { return providers_2.markTransportIfDegraded; } });
|
|
47
|
+
Object.defineProperty(exports, "joinTextBlocks", { enumerable: true, get: function () { return providers_2.joinTextBlocks; } });
|
|
48
|
+
Object.defineProperty(exports, "formatToolResult", { enumerable: true, get: function () { return providers_2.formatToolResult; } });
|
|
49
|
+
Object.defineProperty(exports, "safeJsonStringify", { enumerable: true, get: function () { return providers_2.safeJsonStringify; } });
|
|
50
|
+
Object.defineProperty(exports, "FILE_UNSUPPORTED_TEXT", { enumerable: true, get: function () { return providers_2.FILE_UNSUPPORTED_TEXT; } });
|
|
51
|
+
Object.defineProperty(exports, "IMAGE_UNSUPPORTED_TEXT", { enumerable: true, get: function () { return providers_2.IMAGE_UNSUPPORTED_TEXT; } });
|
|
52
|
+
Object.defineProperty(exports, "AUDIO_UNSUPPORTED_TEXT", { enumerable: true, get: function () { return providers_2.AUDIO_UNSUPPORTED_TEXT; } });
|
|
53
|
+
Object.defineProperty(exports, "concatTextWithReasoning", { enumerable: true, get: function () { return providers_2.concatTextWithReasoning; } });
|
|
54
|
+
Object.defineProperty(exports, "joinReasoningBlocks", { enumerable: true, get: function () { return providers_2.joinReasoningBlocks; } });
|
|
55
|
+
Object.defineProperty(exports, "normalizeThinkBlocks", { enumerable: true, get: function () { return providers_2.normalizeThinkBlocks; } });
|
|
56
|
+
Object.defineProperty(exports, "splitThinkText", { enumerable: true, get: function () { return providers_2.splitThinkText; } });
|
|
57
|
+
Object.defineProperty(exports, "extractReasoningDetails", { enumerable: true, get: function () { return providers_2.extractReasoningDetails; } });
|
|
58
|
+
Object.defineProperty(exports, "buildGeminiImagePart", { enumerable: true, get: function () { return providers_2.buildGeminiImagePart; } });
|
|
59
|
+
Object.defineProperty(exports, "buildGeminiFilePart", { enumerable: true, get: function () { return providers_2.buildGeminiFilePart; } });
|
|
60
|
+
Object.defineProperty(exports, "sanitizeGeminiSchema", { enumerable: true, get: function () { return providers_2.sanitizeGeminiSchema; } });
|
|
61
|
+
Object.defineProperty(exports, "hasAnthropicFileBlocks", { enumerable: true, get: function () { return providers_2.hasAnthropicFileBlocks; } });
|
|
62
|
+
Object.defineProperty(exports, "mergeAnthropicBetaHeader", { enumerable: true, get: function () { return providers_2.mergeAnthropicBetaHeader; } });
|
|
63
|
+
Object.defineProperty(exports, "normalizeAnthropicContent", { enumerable: true, get: function () { return providers_2.normalizeAnthropicContent; } });
|
|
64
|
+
Object.defineProperty(exports, "normalizeAnthropicContentBlock", { enumerable: true, get: function () { return providers_2.normalizeAnthropicContentBlock; } });
|
|
65
|
+
Object.defineProperty(exports, "normalizeAnthropicDelta", { enumerable: true, get: function () { return providers_2.normalizeAnthropicDelta; } });
|
|
66
|
+
// Re-export core module (errors, usage, retry, logging, fork)
|
|
67
|
+
__exportStar(require("./providers/core"), exports);
|