@terminals-tech/sdk 1.0.0-rc.1 → 1.0.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/README.md +15 -19
- package/dist/WebContainerManager-4LIOGRVM.js +22 -0
- package/dist/browser-http-client-ZQLDWZMU.js +317 -0
- package/dist/cache-VKYSQRXX.js +45 -0
- package/dist/capabilities-MIPUMBLL.js +96 -0
- package/dist/chunk-2ESYSVXG.js +48 -0
- package/dist/chunk-2WTYE4SW.js +190 -0
- package/dist/chunk-3LFMIVJM.js +40 -0
- package/dist/chunk-ABCK4FWN.js +136 -0
- package/dist/chunk-AFDUOYHD.js +2060 -0
- package/dist/chunk-BCOQMFKT.js +265 -0
- package/dist/chunk-BYXBJQAS.js +0 -0
- package/dist/chunk-DKFJIILR.js +9798 -0
- package/dist/chunk-EXI3LJVJ.js +51 -0
- package/dist/chunk-FOXUEYWK.js +42 -0
- package/dist/chunk-GJWAJAX3.js +173 -0
- package/dist/chunk-H3POJCFA.js +333 -0
- package/dist/chunk-KASHT6C5.js +784 -0
- package/dist/chunk-KHR7ZYCX.js +4034 -0
- package/dist/chunk-L45BSQDJ.js +296 -0
- package/dist/chunk-LLGZTP3G.js +5521 -0
- package/dist/chunk-NTMBOESX.js +152 -0
- package/dist/chunk-OCLSAUCD.js +474 -0
- package/dist/chunk-OSSRZOGC.js +190 -0
- package/dist/chunk-PPFTKJDB.js +497 -0
- package/dist/chunk-PWAHFID5.js +381 -0
- package/dist/chunk-Q2VI6ICE.js +188 -0
- package/dist/chunk-QJFKEQHF.js +6460 -0
- package/dist/chunk-QWXPVB2L.js +320 -0
- package/dist/chunk-QWZRZKLZ.js +896 -0
- package/dist/chunk-STMI72WH.js +1005 -0
- package/dist/chunk-TSQ3BGLA.js +11945 -0
- package/dist/chunk-UJDUQNE2.js +79 -0
- package/dist/chunk-VZA2NUH3.js +118 -0
- package/dist/chunk-WGBCRNMB.js +1817 -0
- package/dist/chunk-WU4OTGJE.js +752 -0
- package/dist/chunk-XPJ63Y6T.js +70 -0
- package/dist/chunk-Y2EULKA2.js +172 -0
- package/dist/chunk-YJEZWCYV.js +94 -0
- package/dist/chunk-ZVO47SQV.js +150 -0
- package/dist/container-lite-QD3CRLS4.js +327 -0
- package/dist/core-H2UUDATO.js +146 -0
- package/dist/crypto-D4LMI2RN.js +45 -0
- package/dist/db-BWC2GGBN.js +50 -0
- package/dist/demo-T655Z5S4.js +87 -0
- package/dist/diagnostics-6RQTBR6I.js +113 -0
- package/dist/dist-OPDCWARF.js +727 -0
- package/dist/dist-VXJEKX3T.js +2441 -0
- package/dist/dist-VYGJXGUS.js +1008 -0
- package/dist/embeddings-7QXTXUMC.js +15 -0
- package/dist/embeddings-MAEWWUHW.js +9 -0
- package/dist/graph-RKMNE2X5.js +36 -0
- package/dist/hvm-CBEP3M4F.js +126 -0
- package/dist/index.cjs +49874 -8001
- package/dist/index.d.cts +1629 -1363
- package/dist/index.d.ts +1629 -1363
- package/dist/index.js +2462 -8130
- package/dist/mcp-NK34ZNM5.js +101 -0
- package/dist/mcp-client-service-browser-SGB2K3VZ.js +14 -0
- package/dist/neuro-state-XHRGIRVO.js +498 -0
- package/dist/nodes-K6GKI2FM.js +364 -0
- package/dist/package-EXUIU2RL.js +93 -0
- package/dist/package-VGL7HYTO.js +106 -0
- package/dist/package-XHMLOAQ4.js +98 -0
- package/dist/pg-events-QJAM2HIP.js +15 -0
- package/dist/pglite-adapter-43IOUBMV.js +50 -0
- package/dist/pgliteService-IUGNNOVU.js +258 -0
- package/dist/policy-IRJCM6FS.js +13 -0
- package/dist/registry-5WTDYQVQ.js +26 -0
- package/dist/registry-FW63E7FE.js +16 -0
- package/dist/registry-ZQ2IBLF6.js +9 -0
- package/dist/resolver-ALOJSOK5.js +24 -0
- package/dist/scheduler-B5CEYKWT.js +127 -0
- package/dist/secret-store-H7273UIT.js +18 -0
- package/dist/server-VW6DYDLH.js +18 -0
- package/dist/skills-VN7IN7SJ.js +6375 -0
- package/dist/stack-4KWCQQP7.js +103 -0
- package/dist/storage-L7MWNSPG.js +13 -0
- package/dist/supabaseService-6AYP2VY3.js +476 -0
- package/dist/topology-CIWWNVAN.js +13 -0
- package/dist/webcontainer-XWCE56F3.js +281 -0
- package/package.json +9 -3
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import {
|
|
2
|
+
asStringArray,
|
|
3
|
+
buildContainerLiteCommand,
|
|
4
|
+
extractUrls,
|
|
5
|
+
isRecord,
|
|
6
|
+
validateContainerLiteNetworkPolicy
|
|
7
|
+
} from "./chunk-YJEZWCYV.js";
|
|
8
|
+
import "./chunk-UJDUQNE2.js";
|
|
9
|
+
import {
|
|
10
|
+
WebContainerManager,
|
|
11
|
+
WebContainerManager_default
|
|
12
|
+
} from "./chunk-LLGZTP3G.js";
|
|
13
|
+
import "./chunk-DKFJIILR.js";
|
|
14
|
+
import "./chunk-KHR7ZYCX.js";
|
|
15
|
+
import "./chunk-QWZRZKLZ.js";
|
|
16
|
+
import "./chunk-OSSRZOGC.js";
|
|
17
|
+
import "./chunk-TSQ3BGLA.js";
|
|
18
|
+
import "./chunk-2WTYE4SW.js";
|
|
19
|
+
import "./chunk-QJFKEQHF.js";
|
|
20
|
+
import "./chunk-WGBCRNMB.js";
|
|
21
|
+
import "./chunk-3LFMIVJM.js";
|
|
22
|
+
import "./chunk-AFDUOYHD.js";
|
|
23
|
+
import "./chunk-NTMBOESX.js";
|
|
24
|
+
import "./chunk-2ESYSVXG.js";
|
|
25
|
+
|
|
26
|
+
// ../../lib/terminals-tech/machines/core/webcontainer-adapter.ts
|
|
27
|
+
var WebContainerAdapter = class _WebContainerAdapter {
|
|
28
|
+
static instance = null;
|
|
29
|
+
constructor() {
|
|
30
|
+
}
|
|
31
|
+
static getInstance() {
|
|
32
|
+
if (!this.instance) {
|
|
33
|
+
this.instance = new _WebContainerAdapter();
|
|
34
|
+
}
|
|
35
|
+
return this.instance;
|
|
36
|
+
}
|
|
37
|
+
getManager() {
|
|
38
|
+
return WebContainerManager.getExistingInstance();
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Check if WebContainer is available
|
|
42
|
+
*/
|
|
43
|
+
isAvailable() {
|
|
44
|
+
return this.getManager() !== null;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Mount a filesystem tree
|
|
48
|
+
*/
|
|
49
|
+
async mountProject(files, options) {
|
|
50
|
+
const manager = this.getManager();
|
|
51
|
+
if (!manager) throw new Error("WebContainerManager not initialized");
|
|
52
|
+
await manager.mount(files, options);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Install npm dependencies
|
|
56
|
+
*/
|
|
57
|
+
async installDependencies(opts) {
|
|
58
|
+
const manager = this.getManager();
|
|
59
|
+
if (!manager) throw new Error("WebContainerManager not initialized");
|
|
60
|
+
const process = await manager.spawn("npm", ["install"], { cwd: opts?.cwd });
|
|
61
|
+
let output = "";
|
|
62
|
+
const outputPromise = new Promise((resolve) => {
|
|
63
|
+
process.output.pipeTo(
|
|
64
|
+
new WritableStream({
|
|
65
|
+
write(chunk) {
|
|
66
|
+
output += typeof chunk === "string" ? chunk : new TextDecoder().decode(chunk);
|
|
67
|
+
},
|
|
68
|
+
close() {
|
|
69
|
+
resolve();
|
|
70
|
+
},
|
|
71
|
+
abort() {
|
|
72
|
+
resolve();
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
).catch((err) => {
|
|
76
|
+
console.warn("[WebContainerAdapter] install output pipe failed", err);
|
|
77
|
+
resolve();
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
const exitCode = await process.exit;
|
|
81
|
+
await outputPromise.catch((err) => console.warn("[WebContainerAdapter] install output collection failed", err));
|
|
82
|
+
return { exitCode, output };
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Spawn a command with captured output
|
|
86
|
+
*/
|
|
87
|
+
async spawn(cmd, args, opts) {
|
|
88
|
+
const manager = this.getManager();
|
|
89
|
+
if (!manager) throw new Error("WebContainerManager not initialized");
|
|
90
|
+
const process = await manager.spawn(cmd, args, opts);
|
|
91
|
+
let stdout = "";
|
|
92
|
+
const outputPromise = new Promise((resolve) => {
|
|
93
|
+
process.output.pipeTo(
|
|
94
|
+
new WritableStream({
|
|
95
|
+
write(chunk) {
|
|
96
|
+
stdout += typeof chunk === "string" ? chunk : new TextDecoder().decode(chunk);
|
|
97
|
+
},
|
|
98
|
+
close() {
|
|
99
|
+
resolve();
|
|
100
|
+
},
|
|
101
|
+
abort() {
|
|
102
|
+
resolve();
|
|
103
|
+
}
|
|
104
|
+
})
|
|
105
|
+
).catch((err) => {
|
|
106
|
+
console.warn("[WebContainerAdapter] spawn output pipe failed", err);
|
|
107
|
+
resolve();
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
const exitCode = await process.exit;
|
|
111
|
+
await outputPromise.catch((err) => console.warn("[WebContainerAdapter] spawn output collection failed", err));
|
|
112
|
+
return { exitCode, stdout, stderr: "" };
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Write a file to the WebContainer filesystem
|
|
116
|
+
*/
|
|
117
|
+
async writeFile(path, contents) {
|
|
118
|
+
const manager = this.getManager();
|
|
119
|
+
if (!manager) throw new Error("WebContainerManager not initialized");
|
|
120
|
+
const container = manager.getContainer();
|
|
121
|
+
if (!container) throw new Error("WebContainer not booted");
|
|
122
|
+
await container.fs.writeFile(path, contents);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Read a file from the WebContainer filesystem
|
|
126
|
+
*/
|
|
127
|
+
async readFile(path) {
|
|
128
|
+
const manager = this.getManager();
|
|
129
|
+
if (!manager) throw new Error("WebContainerManager not initialized");
|
|
130
|
+
const container = manager.getContainer();
|
|
131
|
+
if (!container) throw new Error("WebContainer not booted");
|
|
132
|
+
return await container.fs.readFile(path, "utf-8");
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
var webContainerAdapter = WebContainerAdapter.getInstance();
|
|
136
|
+
|
|
137
|
+
// ../../lib/terminals-tech/machines/core/runners/webcontainer-session.ts
|
|
138
|
+
var WebContainerSession = class {
|
|
139
|
+
workdir;
|
|
140
|
+
manager;
|
|
141
|
+
adapter;
|
|
142
|
+
baseTree = null;
|
|
143
|
+
constructor(options = {}) {
|
|
144
|
+
const manager = WebContainerManager_default.getInstance({
|
|
145
|
+
autoInstallDependencies: false,
|
|
146
|
+
keepAlive: true,
|
|
147
|
+
suppressLifecycleLogs: true,
|
|
148
|
+
...options
|
|
149
|
+
});
|
|
150
|
+
if (!manager) {
|
|
151
|
+
throw new Error("WebContainerManager unavailable.");
|
|
152
|
+
}
|
|
153
|
+
this.manager = manager;
|
|
154
|
+
this.adapter = WebContainerAdapter.getInstance();
|
|
155
|
+
this.workdir = options.workdir || "/home/project";
|
|
156
|
+
}
|
|
157
|
+
isAvailable() {
|
|
158
|
+
return this.adapter.isAvailable();
|
|
159
|
+
}
|
|
160
|
+
async start() {
|
|
161
|
+
await this.manager.activate();
|
|
162
|
+
}
|
|
163
|
+
async mountBaseTree(files) {
|
|
164
|
+
this.baseTree = files;
|
|
165
|
+
await this.adapter.mountProject(files, { mountPoint: this.workdir });
|
|
166
|
+
}
|
|
167
|
+
async remountBaseTree() {
|
|
168
|
+
if (!this.baseTree) {
|
|
169
|
+
throw new Error("WebContainer base tree not initialized.");
|
|
170
|
+
}
|
|
171
|
+
await this.adapter.mountProject(this.baseTree, { mountPoint: this.workdir });
|
|
172
|
+
}
|
|
173
|
+
async installDependencies(cwd = this.workdir) {
|
|
174
|
+
return this.adapter.installDependencies({ cwd });
|
|
175
|
+
}
|
|
176
|
+
async exec(command, args = [], options = {}) {
|
|
177
|
+
return this.adapter.spawn(command, args, {
|
|
178
|
+
cwd: options.cwd || this.workdir,
|
|
179
|
+
env: options.env
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
async writeFile(path, contents) {
|
|
183
|
+
await this.adapter.writeFile(path, contents);
|
|
184
|
+
}
|
|
185
|
+
async readFile(path) {
|
|
186
|
+
return this.adapter.readFile(path);
|
|
187
|
+
}
|
|
188
|
+
async writeWorkspaceFile(relativePath, contents) {
|
|
189
|
+
const normalizedPath = relativePath.startsWith("/") ? relativePath : `${this.workdir}/${relativePath}`;
|
|
190
|
+
await this.adapter.writeFile(normalizedPath, contents);
|
|
191
|
+
}
|
|
192
|
+
async readWorkspaceFile(relativePath) {
|
|
193
|
+
const normalizedPath = relativePath.startsWith("/") ? relativePath : `${this.workdir}/${relativePath}`;
|
|
194
|
+
return this.adapter.readFile(normalizedPath);
|
|
195
|
+
}
|
|
196
|
+
async destroy() {
|
|
197
|
+
await this.manager.destroy();
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
// ../../lib/terminals-tech/machines/core/runners/webcontainer.ts
|
|
202
|
+
async function runInWebContainer(manifest, input, ctx) {
|
|
203
|
+
const urls = extractUrls(input);
|
|
204
|
+
if (urls.length > 0) {
|
|
205
|
+
const validation = await validateContainerLiteNetworkPolicy(urls, ctx);
|
|
206
|
+
if (!validation.allowed) {
|
|
207
|
+
return {
|
|
208
|
+
input,
|
|
209
|
+
runtime: "webcontainer:policy-denied",
|
|
210
|
+
error: `Network egress denied for URL: ${validation.deniedUrl}`
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
let session;
|
|
215
|
+
try {
|
|
216
|
+
session = new WebContainerSession();
|
|
217
|
+
} catch (error) {
|
|
218
|
+
return {
|
|
219
|
+
input,
|
|
220
|
+
runtime: "webcontainer:error",
|
|
221
|
+
error: error instanceof Error ? error.message : "WebContainerManager not initialized"
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
try {
|
|
225
|
+
await session.start();
|
|
226
|
+
const manifestWithFs = manifest;
|
|
227
|
+
const fsTree = manifestWithFs.filesystem || input.filesystem;
|
|
228
|
+
if (fsTree && typeof fsTree === "object") {
|
|
229
|
+
await session.mountBaseTree(fsTree);
|
|
230
|
+
} else {
|
|
231
|
+
await session.mountBaseTree({
|
|
232
|
+
"README.md": { file: { contents: "# Terminals WebContainer" } }
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
const packageJson = fsTree?.["package.json"];
|
|
236
|
+
if (packageJson) {
|
|
237
|
+
const { exitCode: exitCode2, output } = await session.installDependencies();
|
|
238
|
+
if (exitCode2 !== 0) {
|
|
239
|
+
return {
|
|
240
|
+
input,
|
|
241
|
+
runtime: "webcontainer",
|
|
242
|
+
exitCode: exitCode2,
|
|
243
|
+
error: "npm install failed",
|
|
244
|
+
npmOutput: output
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
const ep = manifest.entrypoints?.webcontainer;
|
|
249
|
+
const cmd = typeof input.command === "string" && input.command || ep?.command || "node";
|
|
250
|
+
const args = Array.isArray(input.args) ? input.args.filter((value) => typeof value === "string") : ep?.args || ["-e", 'console.log("webcontainer-ok")'];
|
|
251
|
+
const cwd = typeof input.cwd === "string" ? input.cwd : ep?.cwd ? `${session.workdir}/${ep.cwd}` : session.workdir;
|
|
252
|
+
const env = isRecord(input.env) ? Object.fromEntries(
|
|
253
|
+
Object.entries(input.env).filter((entry) => typeof entry[1] === "string").map(([key, value]) => [key, value])
|
|
254
|
+
) : {};
|
|
255
|
+
const bootstrapCommands = asStringArray(input.bootstrapCommands);
|
|
256
|
+
for (const command of bootstrapCommands) {
|
|
257
|
+
await session.exec("sh", ["-c", command], { cwd });
|
|
258
|
+
}
|
|
259
|
+
const { exitCode, stdout, stderr } = await session.exec(cmd, args, {
|
|
260
|
+
cwd,
|
|
261
|
+
env
|
|
262
|
+
});
|
|
263
|
+
return {
|
|
264
|
+
input,
|
|
265
|
+
runtime: "webcontainer",
|
|
266
|
+
exitCode,
|
|
267
|
+
stdout,
|
|
268
|
+
stderr,
|
|
269
|
+
commandPreview: buildContainerLiteCommand(cmd, args, env)
|
|
270
|
+
};
|
|
271
|
+
} catch (error) {
|
|
272
|
+
return {
|
|
273
|
+
input,
|
|
274
|
+
runtime: "webcontainer:error",
|
|
275
|
+
error: error.message
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
export {
|
|
280
|
+
runInWebContainer
|
|
281
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@terminals-tech/sdk",
|
|
3
|
-
"version": "1.0.0
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Terminals OS SDK — observable, coherence-aware primitives for building intelligent software. Patent Pending.",
|
|
5
5
|
"license": "BUSL-1.1",
|
|
6
6
|
"author": "Intuition Labs LLC",
|
|
7
7
|
"notice": "Terminals OS architecture is Patent Pending. © 2026 Intuition Labs LLC.",
|
|
@@ -34,13 +34,19 @@
|
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
|
-
"build": "tsup src/index.ts --format esm,cjs --dts --out-dir dist",
|
|
37
|
+
"build": "tsup src/index.ts --format esm,cjs --dts --out-dir dist --external @electric-sql/pglite --external onnxruntime-node --external @huggingface/transformers --external sharp --external rxjs --external @xenova/transformers",
|
|
38
38
|
"clean": "rm -rf dist",
|
|
39
39
|
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
40
40
|
"pack:dry-run": "npm run build && npm pack --json --dry-run --ignore-scripts",
|
|
41
41
|
"publish:check": "npm run clean && npm run build && node ../../scripts/verify-sdk-package.mjs",
|
|
42
42
|
"prepack": "npm run build"
|
|
43
43
|
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"rxjs": "^7.8.0"
|
|
46
|
+
},
|
|
47
|
+
"optionalDependencies": {
|
|
48
|
+
"@electric-sql/pglite": ">=0.2.0"
|
|
49
|
+
},
|
|
44
50
|
"peerDependencies": {
|
|
45
51
|
"typescript": ">=5.0.0"
|
|
46
52
|
}
|