@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.
Files changed (82) hide show
  1. package/README.md +15 -19
  2. package/dist/WebContainerManager-4LIOGRVM.js +22 -0
  3. package/dist/browser-http-client-ZQLDWZMU.js +317 -0
  4. package/dist/cache-VKYSQRXX.js +45 -0
  5. package/dist/capabilities-MIPUMBLL.js +96 -0
  6. package/dist/chunk-2ESYSVXG.js +48 -0
  7. package/dist/chunk-2WTYE4SW.js +190 -0
  8. package/dist/chunk-3LFMIVJM.js +40 -0
  9. package/dist/chunk-ABCK4FWN.js +136 -0
  10. package/dist/chunk-AFDUOYHD.js +2060 -0
  11. package/dist/chunk-BCOQMFKT.js +265 -0
  12. package/dist/chunk-BYXBJQAS.js +0 -0
  13. package/dist/chunk-DKFJIILR.js +9798 -0
  14. package/dist/chunk-EXI3LJVJ.js +51 -0
  15. package/dist/chunk-FOXUEYWK.js +42 -0
  16. package/dist/chunk-GJWAJAX3.js +173 -0
  17. package/dist/chunk-H3POJCFA.js +333 -0
  18. package/dist/chunk-KASHT6C5.js +784 -0
  19. package/dist/chunk-KHR7ZYCX.js +4034 -0
  20. package/dist/chunk-L45BSQDJ.js +296 -0
  21. package/dist/chunk-LLGZTP3G.js +5521 -0
  22. package/dist/chunk-NTMBOESX.js +152 -0
  23. package/dist/chunk-OCLSAUCD.js +474 -0
  24. package/dist/chunk-OSSRZOGC.js +190 -0
  25. package/dist/chunk-PPFTKJDB.js +497 -0
  26. package/dist/chunk-PWAHFID5.js +381 -0
  27. package/dist/chunk-Q2VI6ICE.js +188 -0
  28. package/dist/chunk-QJFKEQHF.js +6460 -0
  29. package/dist/chunk-QWXPVB2L.js +320 -0
  30. package/dist/chunk-QWZRZKLZ.js +896 -0
  31. package/dist/chunk-STMI72WH.js +1005 -0
  32. package/dist/chunk-TSQ3BGLA.js +11945 -0
  33. package/dist/chunk-UJDUQNE2.js +79 -0
  34. package/dist/chunk-VZA2NUH3.js +118 -0
  35. package/dist/chunk-WGBCRNMB.js +1817 -0
  36. package/dist/chunk-WU4OTGJE.js +752 -0
  37. package/dist/chunk-XPJ63Y6T.js +70 -0
  38. package/dist/chunk-Y2EULKA2.js +172 -0
  39. package/dist/chunk-YJEZWCYV.js +94 -0
  40. package/dist/chunk-ZVO47SQV.js +150 -0
  41. package/dist/container-lite-QD3CRLS4.js +327 -0
  42. package/dist/core-H2UUDATO.js +146 -0
  43. package/dist/crypto-D4LMI2RN.js +45 -0
  44. package/dist/db-BWC2GGBN.js +50 -0
  45. package/dist/demo-T655Z5S4.js +87 -0
  46. package/dist/diagnostics-6RQTBR6I.js +113 -0
  47. package/dist/dist-OPDCWARF.js +727 -0
  48. package/dist/dist-VXJEKX3T.js +2441 -0
  49. package/dist/dist-VYGJXGUS.js +1008 -0
  50. package/dist/embeddings-7QXTXUMC.js +15 -0
  51. package/dist/embeddings-MAEWWUHW.js +9 -0
  52. package/dist/graph-RKMNE2X5.js +36 -0
  53. package/dist/hvm-CBEP3M4F.js +126 -0
  54. package/dist/index.cjs +49874 -8001
  55. package/dist/index.d.cts +1629 -1363
  56. package/dist/index.d.ts +1629 -1363
  57. package/dist/index.js +2462 -8130
  58. package/dist/mcp-NK34ZNM5.js +101 -0
  59. package/dist/mcp-client-service-browser-SGB2K3VZ.js +14 -0
  60. package/dist/neuro-state-XHRGIRVO.js +498 -0
  61. package/dist/nodes-K6GKI2FM.js +364 -0
  62. package/dist/package-EXUIU2RL.js +93 -0
  63. package/dist/package-VGL7HYTO.js +106 -0
  64. package/dist/package-XHMLOAQ4.js +98 -0
  65. package/dist/pg-events-QJAM2HIP.js +15 -0
  66. package/dist/pglite-adapter-43IOUBMV.js +50 -0
  67. package/dist/pgliteService-IUGNNOVU.js +258 -0
  68. package/dist/policy-IRJCM6FS.js +13 -0
  69. package/dist/registry-5WTDYQVQ.js +26 -0
  70. package/dist/registry-FW63E7FE.js +16 -0
  71. package/dist/registry-ZQ2IBLF6.js +9 -0
  72. package/dist/resolver-ALOJSOK5.js +24 -0
  73. package/dist/scheduler-B5CEYKWT.js +127 -0
  74. package/dist/secret-store-H7273UIT.js +18 -0
  75. package/dist/server-VW6DYDLH.js +18 -0
  76. package/dist/skills-VN7IN7SJ.js +6375 -0
  77. package/dist/stack-4KWCQQP7.js +103 -0
  78. package/dist/storage-L7MWNSPG.js +13 -0
  79. package/dist/supabaseService-6AYP2VY3.js +476 -0
  80. package/dist/topology-CIWWNVAN.js +13 -0
  81. package/dist/webcontainer-XWCE56F3.js +281 -0
  82. package/package.json +9 -3
@@ -0,0 +1,327 @@
1
+ import {
2
+ DEFAULT_CONTAINER_LITE_IMAGE,
3
+ DEFAULT_CONTAINER_LITE_TIMEOUT_MS,
4
+ asStringArray,
5
+ buildContainerLiteCommand,
6
+ extractUrls,
7
+ flattenFilesystemTree,
8
+ isRecord,
9
+ resolveContainerLiteCwd,
10
+ shellQuote,
11
+ validateContainerLiteNetworkPolicy
12
+ } from "./chunk-YJEZWCYV.js";
13
+ import "./chunk-UJDUQNE2.js";
14
+ import {
15
+ runners
16
+ } from "./chunk-PPFTKJDB.js";
17
+ import "./chunk-KASHT6C5.js";
18
+ import "./chunk-H3POJCFA.js";
19
+ import "./chunk-KHR7ZYCX.js";
20
+ import "./chunk-PWAHFID5.js";
21
+ import "./chunk-Y2EULKA2.js";
22
+ import "./chunk-WU4OTGJE.js";
23
+ import "./chunk-OCLSAUCD.js";
24
+ import "./chunk-BYXBJQAS.js";
25
+ import "./chunk-BCOQMFKT.js";
26
+ import "./chunk-2WTYE4SW.js";
27
+ import "./chunk-FOXUEYWK.js";
28
+ import "./chunk-EXI3LJVJ.js";
29
+ import "./chunk-QJFKEQHF.js";
30
+ import "./chunk-ZVO47SQV.js";
31
+ import "./chunk-XPJ63Y6T.js";
32
+ import "./chunk-WGBCRNMB.js";
33
+ import "./chunk-3LFMIVJM.js";
34
+ import "./chunk-AFDUOYHD.js";
35
+ import "./chunk-NTMBOESX.js";
36
+ import "./chunk-2ESYSVXG.js";
37
+
38
+ // ../../lib/terminals-tech/machines/core/runners/container-lite-session.ts
39
+ import path2 from "path";
40
+
41
+ // ../../lib/terminals-tech/machines/core/runners/container-lite-adapter.ts
42
+ import { spawnSync } from "child_process";
43
+ import { mkdtempSync, rmSync, writeFileSync } from "fs";
44
+ import os from "os";
45
+ import path from "path";
46
+ var DEFAULT_COMMAND_TIMEOUT_MS = 12e4;
47
+ function shellQuote2(value) {
48
+ return `'${value.replace(/'/g, `'"'"'`)}'`;
49
+ }
50
+ function tailText(value, maxChars = 2e3) {
51
+ if (value.length <= maxChars) {
52
+ return value;
53
+ }
54
+ return value.slice(value.length - maxChars);
55
+ }
56
+ function sanitizeName(value) {
57
+ return value.replace(/[^a-zA-Z0-9._-]+/g, "-").slice(0, 80) || "artifact";
58
+ }
59
+ var ContainerLiteAdapter = class {
60
+ containerName;
61
+ workdir;
62
+ image;
63
+ scratchDir;
64
+ defaultTimeoutMs;
65
+ maxBufferBytes;
66
+ constructor(options) {
67
+ this.containerName = `terminals-swe-${sanitizeName(options.name)}`;
68
+ this.workdir = options.workdir ?? "/workspace";
69
+ this.image = options.image;
70
+ this.defaultTimeoutMs = options.defaultTimeoutMs ?? DEFAULT_COMMAND_TIMEOUT_MS;
71
+ this.maxBufferBytes = options.maxBufferBytes ?? 16 * 1024 * 1024;
72
+ this.scratchDir = mkdtempSync(path.join(os.tmpdir(), "terminals-swe-"));
73
+ }
74
+ ensureDockerAvailable() {
75
+ const result = this.runDocker(["version"], this.defaultTimeoutMs);
76
+ if (result.exitCode !== 0) {
77
+ throw new Error(this.formatFailure("docker version", result));
78
+ }
79
+ }
80
+ start(command = ["tail", "-f", "/dev/null"]) {
81
+ this.ensureDockerAvailable();
82
+ this.removeContainer();
83
+ const runResult = this.runDocker([
84
+ "run",
85
+ "-d",
86
+ "--name",
87
+ this.containerName,
88
+ this.image,
89
+ ...command
90
+ ]);
91
+ if (runResult.exitCode !== 0) {
92
+ throw new Error(this.formatFailure(runResult.command, runResult));
93
+ }
94
+ }
95
+ exec(command, options = {}) {
96
+ const result = this.runDocker(
97
+ ["exec", this.containerName, "bash", "-lc", command],
98
+ options.timeoutMs ?? this.defaultTimeoutMs
99
+ );
100
+ if (!options.allowFailure && result.exitCode !== 0) {
101
+ throw new Error(this.formatFailure(command, result));
102
+ }
103
+ return result;
104
+ }
105
+ writeText(targetPath, content) {
106
+ const localPath = path.join(
107
+ this.scratchDir,
108
+ `${sanitizeName(path.basename(targetPath))}-${Date.now()}`
109
+ );
110
+ writeFileSync(localPath, content, "utf8");
111
+ const result = this.runDocker(["cp", localPath, `${this.containerName}:${targetPath}`]);
112
+ if (result.exitCode !== 0) {
113
+ throw new Error(this.formatFailure(`docker cp ${localPath} ${targetPath}`, result));
114
+ }
115
+ }
116
+ readText(relativePath) {
117
+ const result = this.exec(
118
+ `cd ${shellQuote2(this.workdir)} && python -c ${shellQuote2(
119
+ "from pathlib import Path; import sys; print(Path(sys.argv[1]).read_text(encoding='utf-8', errors='ignore'))"
120
+ )} ${shellQuote2(relativePath)}`
121
+ );
122
+ return result.stdout;
123
+ }
124
+ listChangedFiles(glob) {
125
+ const result = this.exec(
126
+ `cd ${shellQuote2(this.workdir)} && git diff --name-only --diff-filter=ACM -- ${shellQuote2(glob)}`,
127
+ { allowFailure: true }
128
+ );
129
+ return result.stdout.split(/\r?\n/).map((entry) => entry.trim()).filter(Boolean);
130
+ }
131
+ reset() {
132
+ this.exec(`cd ${shellQuote2(this.workdir)} && git reset --hard HEAD && git clean -fd`);
133
+ }
134
+ destroy() {
135
+ this.removeContainer();
136
+ this.releaseScratch();
137
+ }
138
+ releaseScratch() {
139
+ rmSync(this.scratchDir, { recursive: true, force: true });
140
+ }
141
+ formatFailure(command, result) {
142
+ return [
143
+ `Command failed: ${command}`,
144
+ `Exit code: ${result.exitCode}`,
145
+ result.stdout ? `STDOUT:
146
+ ${tailText(result.stdout)}` : "",
147
+ result.stderr ? `STDERR:
148
+ ${tailText(result.stderr)}` : ""
149
+ ].filter(Boolean).join("\n\n");
150
+ }
151
+ removeContainer() {
152
+ this.runDocker(["rm", "-f", this.containerName], this.defaultTimeoutMs);
153
+ }
154
+ runDocker(args, timeoutMs = this.defaultTimeoutMs) {
155
+ const result = spawnSync("docker", args, {
156
+ encoding: "utf8",
157
+ timeout: timeoutMs,
158
+ maxBuffer: this.maxBufferBytes
159
+ });
160
+ const timedOut = result.error?.message?.toLowerCase().includes("timed out") ?? false;
161
+ const exitCode = typeof result.status === "number" ? result.status : timedOut ? 124 : 1;
162
+ const stderr = timedOut ? `${result.stderr ?? ""}
163
+ Command timed out after ${timeoutMs}ms.` : `${result.stderr ?? ""}${result.error && !timedOut ? `
164
+ ${String(result.error.message ?? result.error)}` : ""}`;
165
+ return {
166
+ command: ["docker", ...args].join(" "),
167
+ stdout: result.stdout ?? "",
168
+ stderr,
169
+ exitCode
170
+ };
171
+ }
172
+ };
173
+
174
+ // ../../lib/terminals-tech/machines/core/runners/container-lite-session.ts
175
+ var ContainerLiteSession = class {
176
+ adapter;
177
+ constructor(options) {
178
+ this.adapter = new ContainerLiteAdapter({
179
+ name: options.name,
180
+ image: options.image,
181
+ workdir: options.workdir
182
+ });
183
+ }
184
+ get containerName() {
185
+ return this.adapter.containerName;
186
+ }
187
+ get workdir() {
188
+ return this.adapter.workdir;
189
+ }
190
+ start() {
191
+ this.adapter.start();
192
+ }
193
+ ensureWorkspace() {
194
+ this.adapter.exec(`mkdir -p ${shellQuote(this.workdir)}`);
195
+ }
196
+ cloneRepository(repositoryUrl, checkout, timeoutMs = DEFAULT_CONTAINER_LITE_TIMEOUT_MS) {
197
+ this.adapter.exec(`git clone ${shellQuote(repositoryUrl)} ${shellQuote(this.workdir)}`, {
198
+ timeoutMs: timeoutMs * 3
199
+ });
200
+ if (checkout) {
201
+ this.adapter.exec(`cd ${shellQuote(this.workdir)} && git checkout ${shellQuote(checkout)}`, {
202
+ timeoutMs
203
+ });
204
+ }
205
+ }
206
+ materializeFilesystem(tree) {
207
+ const files = flattenFilesystemTree(tree);
208
+ this.writeFiles(files);
209
+ }
210
+ writeFiles(files) {
211
+ for (const file of files) {
212
+ const targetPath = path2.posix.join(this.workdir, file.path);
213
+ const targetDir = path2.posix.dirname(targetPath);
214
+ this.adapter.exec(`mkdir -p ${shellQuote(targetDir)}`);
215
+ this.adapter.writeText(targetPath, file.content);
216
+ }
217
+ }
218
+ writeWorkspaceFile(relativePath, content) {
219
+ const targetPath = path2.posix.join(this.workdir, relativePath);
220
+ const targetDir = path2.posix.dirname(targetPath);
221
+ this.adapter.exec(`mkdir -p ${shellQuote(targetDir)}`);
222
+ this.adapter.writeText(targetPath, content);
223
+ }
224
+ writeTempFile(label, content) {
225
+ const targetPath = `/tmp/${label}-${Date.now()}`;
226
+ this.adapter.writeText(targetPath, content);
227
+ return targetPath;
228
+ }
229
+ runBootstrap(commands, timeoutMs = DEFAULT_CONTAINER_LITE_TIMEOUT_MS) {
230
+ for (const command of commands) {
231
+ this.execInWorkspace(command, { timeoutMs: timeoutMs * 3 });
232
+ }
233
+ }
234
+ exec(command, options = {}) {
235
+ return this.adapter.exec(command, options);
236
+ }
237
+ execInWorkspace(command, options = {}) {
238
+ const cwd = resolveContainerLiteCwd(this.workdir, options.cwd);
239
+ return this.adapter.exec(`cd ${shellQuote(cwd)} && ${command}`, options);
240
+ }
241
+ readWorkspaceFile(relativePath) {
242
+ return this.adapter.readText(relativePath);
243
+ }
244
+ listChangedFiles(glob) {
245
+ return this.adapter.listChangedFiles(glob);
246
+ }
247
+ resetWorkspace() {
248
+ this.adapter.reset();
249
+ }
250
+ releaseScratch() {
251
+ this.adapter.releaseScratch();
252
+ }
253
+ destroy() {
254
+ this.adapter.destroy();
255
+ }
256
+ };
257
+
258
+ // ../../lib/terminals-tech/machines/core/runners/container-lite.ts
259
+ async function runInContainerLite(manifest, input, ctx) {
260
+ const urls = extractUrls(input);
261
+ if (urls.length > 0) {
262
+ const validation = await validateContainerLiteNetworkPolicy(urls, ctx);
263
+ if (!validation.allowed) {
264
+ return {
265
+ input,
266
+ runtime: "container-lite:policy-denied",
267
+ error: `Network egress denied for URL: ${validation.deniedUrl}`
268
+ };
269
+ }
270
+ }
271
+ const entry = manifest.entrypoints["container-lite"];
272
+ if (!entry) {
273
+ throw new Error(`Manifest ${manifest.id} is missing a container-lite entrypoint.`);
274
+ }
275
+ const metadata = isRecord(manifest.metadata) ? manifest.metadata.containerLite ?? {} : {};
276
+ const image = typeof input.containerImage === "string" && input.containerImage || metadata.image || DEFAULT_CONTAINER_LITE_IMAGE;
277
+ const session = new ContainerLiteSession({
278
+ name: `${ctx.stackId}-${ctx.nodeId}`,
279
+ image
280
+ });
281
+ try {
282
+ session.start();
283
+ const repositoryUrl = typeof input.repositoryUrl === "string" && input.repositoryUrl || metadata.repositoryUrl;
284
+ const checkout = typeof input.checkout === "string" && input.checkout || metadata.checkout;
285
+ if (repositoryUrl) {
286
+ session.cloneRepository(repositoryUrl, checkout, DEFAULT_CONTAINER_LITE_TIMEOUT_MS);
287
+ } else {
288
+ session.ensureWorkspace();
289
+ }
290
+ session.materializeFilesystem(
291
+ manifest.filesystem
292
+ );
293
+ session.materializeFilesystem(input.filesystem);
294
+ session.runBootstrap(
295
+ [...asStringArray(metadata.bootstrapCommands), ...asStringArray(input.bootstrapCommands)],
296
+ DEFAULT_CONTAINER_LITE_TIMEOUT_MS
297
+ );
298
+ const command = typeof input.command === "string" && input.command || entry.command;
299
+ const args = Array.isArray(input.args) ? input.args.filter((value) => typeof value === "string") : entry.args || [];
300
+ const env = isRecord(input.env) ? Object.fromEntries(
301
+ Object.entries(input.env).filter((entry2) => typeof entry2[1] === "string").map(([key, value]) => [key, value])
302
+ ) : {};
303
+ const requestedCwd = typeof input.cwd === "string" ? input.cwd : entry.cwd;
304
+ const cwd = resolveContainerLiteCwd(session.workdir, requestedCwd);
305
+ const timeoutMs = typeof input.timeoutMs === "number" ? input.timeoutMs : DEFAULT_CONTAINER_LITE_TIMEOUT_MS;
306
+ const result = session.execInWorkspace(buildContainerLiteCommand(command, args, env), {
307
+ allowFailure: true,
308
+ timeoutMs,
309
+ cwd
310
+ });
311
+ return {
312
+ input,
313
+ runtime: "container-lite",
314
+ image,
315
+ exitCode: result.exitCode,
316
+ stdout: result.stdout,
317
+ stderr: result.stderr,
318
+ cwd
319
+ };
320
+ } finally {
321
+ session.destroy();
322
+ }
323
+ }
324
+ runners.registerRunner("container-lite", runInContainerLite);
325
+ export {
326
+ runInContainerLite
327
+ };
@@ -0,0 +1,146 @@
1
+ import "./chunk-2ESYSVXG.js";
2
+
3
+ // ../../lib/terminals-tech/core/base/adapters.ts
4
+ async function core() {
5
+ return await import("./dist-VXJEKX3T.js");
6
+ }
7
+ function makeTimeline(windowISO) {
8
+ const windowMs = (() => {
9
+ try {
10
+ if (!windowISO) return 6e4;
11
+ return /PT(\d+)M/.test(windowISO) ? Number(RegExp.$1) * 6e4 : 6e4;
12
+ } catch {
13
+ return 6e4;
14
+ }
15
+ })();
16
+ return {
17
+ process(events) {
18
+ const now = Date.now();
19
+ const start = now - windowMs;
20
+ const windowEvents = (Array.isArray(events) ? events : []).filter((e) => {
21
+ const t = typeof e?.t === "number" ? e.t : Date.parse(e?.time || e?.timestamp || "");
22
+ return Number.isFinite(t) && t >= start && t <= now;
23
+ });
24
+ const ticks = [now];
25
+ return { windowEvents, ticks };
26
+ }
27
+ };
28
+ }
29
+ function temporalKV() {
30
+ const store = /* @__PURE__ */ new Map();
31
+ return {
32
+ handle(input) {
33
+ if (input?.put) {
34
+ const { key, value, ttlMs } = input.put;
35
+ store.set(String(key), {
36
+ t: Date.now(),
37
+ v: value,
38
+ ttl: typeof ttlMs === "number" ? ttlMs : void 0
39
+ });
40
+ }
41
+ if (input?.get) {
42
+ const { key } = input.get;
43
+ const rec = store.get(String(key));
44
+ if (!rec) return { value: null };
45
+ if (rec.ttl && Date.now() - rec.t > rec.ttl) {
46
+ store.delete(String(key));
47
+ return { value: null };
48
+ }
49
+ return { value: rec.v };
50
+ }
51
+ if (input?.query?.sinceMs) {
52
+ const since = Date.now() - Number(input.query.sinceMs);
53
+ const items = Array.from(store.entries()).filter(([, rec]) => rec.t >= since).map(([k, rec]) => ({ key: k, value: rec.v, at: rec.t }));
54
+ return { items };
55
+ }
56
+ return {};
57
+ }
58
+ };
59
+ }
60
+ function fieldStore3d() {
61
+ const points = [];
62
+ return {
63
+ handle(input) {
64
+ if (Array.isArray(input?.upsert)) {
65
+ for (const p of input.upsert) {
66
+ const { x, y, z, t, ...a } = p || {};
67
+ points.push({
68
+ x: Number(x) || 0,
69
+ y: Number(y) || 0,
70
+ z: Number(z) || 0,
71
+ t: typeof t === "number" ? t : void 0,
72
+ a
73
+ });
74
+ }
75
+ }
76
+ if (input?.query) {
77
+ const { box, sinceMs, limit = 256 } = input.query;
78
+ let res = points;
79
+ if (box) {
80
+ const { min, max } = box;
81
+ res = res.filter(
82
+ (p) => p.x >= min[0] && p.y >= min[1] && p.z >= min[2] && p.x <= max[0] && p.y <= max[1] && p.z <= max[2]
83
+ );
84
+ }
85
+ if (sinceMs) {
86
+ const since = Date.now() - Number(sinceMs);
87
+ res = res.filter((p) => (p.t || 0) >= since);
88
+ }
89
+ return { points: res.slice(0, limit) };
90
+ }
91
+ return { count: points.length };
92
+ }
93
+ };
94
+ }
95
+ function zeroAgent() {
96
+ return {
97
+ async handle(input) {
98
+ const { prompt, memory } = input || {};
99
+ const c = await core();
100
+ try {
101
+ const llm = c?.llm;
102
+ if (llm?.chat) {
103
+ const out = await llm.chat({
104
+ messages: [{ role: "user", content: String(prompt || "") }],
105
+ memory
106
+ });
107
+ return {
108
+ messages: out?.messages || [],
109
+ artifacts: out?.artifacts || []
110
+ };
111
+ }
112
+ } catch {
113
+ }
114
+ return {
115
+ messages: [{ role: "assistant", content: String(prompt || "") }]
116
+ };
117
+ }
118
+ };
119
+ }
120
+ function httpOracle(policies) {
121
+ return {
122
+ async handle(input) {
123
+ const req = input?.request || input;
124
+ const url = req?.url || req?.href;
125
+ const method = (req?.method || "GET").toUpperCase();
126
+ const allow = policies?.network?.allowList;
127
+ if (allow && !allow.some((a) => String(url || "").startsWith(a))) {
128
+ throw new Error("network egress blocked by policy");
129
+ }
130
+ const res = await fetch(String(url), {
131
+ method,
132
+ headers: req?.headers || {},
133
+ body: req?.body ? JSON.stringify(req.body) : void 0
134
+ });
135
+ const text = await res.text();
136
+ return { response: { status: res.status, ok: res.ok, body: text } };
137
+ }
138
+ };
139
+ }
140
+ export {
141
+ fieldStore3d,
142
+ httpOracle,
143
+ makeTimeline,
144
+ temporalKV,
145
+ zeroAgent
146
+ };
@@ -0,0 +1,45 @@
1
+ import "./chunk-2ESYSVXG.js";
2
+
3
+ // ../../lib/terminals-tech/machines/core/crypto.ts
4
+ import crypto from "crypto";
5
+ function getKey() {
6
+ const raw = process.env.TERMINALS_VAULT_KEY || "";
7
+ if (!raw) throw new Error("TERMINALS_VAULT_KEY is not set");
8
+ try {
9
+ return Buffer.from(raw, "base64");
10
+ } catch {
11
+ }
12
+ try {
13
+ return Buffer.from(raw, "hex");
14
+ } catch {
15
+ }
16
+ const buf = Buffer.alloc(32);
17
+ buf.write(raw.slice(0, 32), "utf8");
18
+ return buf;
19
+ }
20
+ function encrypt(value) {
21
+ const key = getKey();
22
+ const iv = crypto.randomBytes(12);
23
+ const cipher = crypto.createCipheriv("aes-256-gcm", key.slice(0, 32), iv);
24
+ const ct = Buffer.concat([cipher.update(value, "utf8"), cipher.final()]);
25
+ const tag = cipher.getAuthTag();
26
+ return {
27
+ iv: iv.toString("base64"),
28
+ ct: Buffer.concat([ct, tag]).toString("base64")
29
+ };
30
+ }
31
+ function decrypt(payload) {
32
+ const key = getKey();
33
+ const iv = Buffer.from(payload.iv, "base64");
34
+ const data = Buffer.from(payload.ct, "base64");
35
+ const tag = data.slice(data.length - 16);
36
+ const body = data.slice(0, data.length - 16);
37
+ const decipher = crypto.createDecipheriv("aes-256-gcm", key.slice(0, 32), iv);
38
+ decipher.setAuthTag(tag);
39
+ const pt = Buffer.concat([decipher.update(body), decipher.final()]);
40
+ return pt.toString("utf8");
41
+ }
42
+ export {
43
+ decrypt,
44
+ encrypt
45
+ };
@@ -0,0 +1,50 @@
1
+ import {
2
+ PGLiteConnectionPool,
3
+ checkConnectionPoolHealth,
4
+ forceHardReset,
5
+ forceRecycleStale,
6
+ getConnectionPoolStats,
7
+ getCurrentDataDir,
8
+ getCurrentScope,
9
+ getDB,
10
+ getDataDirForScope,
11
+ getDatabase,
12
+ getDbHealth,
13
+ getDbInitStatus,
14
+ getPoolStatus,
15
+ getSchemaVersion,
16
+ isDatabaseReady,
17
+ onDbInitStatusChange,
18
+ restartDbInit,
19
+ retryDbInit,
20
+ setDbScope,
21
+ shutdownPool,
22
+ withDB,
23
+ withTransaction
24
+ } from "./chunk-AFDUOYHD.js";
25
+ import "./chunk-NTMBOESX.js";
26
+ import "./chunk-2ESYSVXG.js";
27
+ export {
28
+ PGLiteConnectionPool,
29
+ checkConnectionPoolHealth,
30
+ forceHardReset,
31
+ forceRecycleStale,
32
+ getConnectionPoolStats,
33
+ getCurrentDataDir,
34
+ getCurrentScope,
35
+ getDB,
36
+ getDataDirForScope,
37
+ getDatabase,
38
+ getDbHealth,
39
+ getDbInitStatus,
40
+ getPoolStatus,
41
+ getSchemaVersion,
42
+ isDatabaseReady,
43
+ onDbInitStatusChange,
44
+ restartDbInit,
45
+ retryDbInit,
46
+ setDbScope,
47
+ shutdownPool,
48
+ withDB,
49
+ withTransaction
50
+ };
@@ -0,0 +1,87 @@
1
+ import {
2
+ runners
3
+ } from "./chunk-PPFTKJDB.js";
4
+ import "./chunk-KASHT6C5.js";
5
+ import "./chunk-H3POJCFA.js";
6
+ import "./chunk-KHR7ZYCX.js";
7
+ import "./chunk-PWAHFID5.js";
8
+ import "./chunk-Y2EULKA2.js";
9
+ import "./chunk-WU4OTGJE.js";
10
+ import {
11
+ registerNode
12
+ } from "./chunk-OCLSAUCD.js";
13
+ import "./chunk-BYXBJQAS.js";
14
+ import "./chunk-BCOQMFKT.js";
15
+ import "./chunk-2WTYE4SW.js";
16
+ import "./chunk-FOXUEYWK.js";
17
+ import "./chunk-EXI3LJVJ.js";
18
+ import "./chunk-QJFKEQHF.js";
19
+ import "./chunk-ZVO47SQV.js";
20
+ import "./chunk-XPJ63Y6T.js";
21
+ import "./chunk-WGBCRNMB.js";
22
+ import "./chunk-3LFMIVJM.js";
23
+ import "./chunk-AFDUOYHD.js";
24
+ import "./chunk-NTMBOESX.js";
25
+ import "./chunk-2ESYSVXG.js";
26
+
27
+ // ../../lib/terminals-tech/machines/core/runners/demo.ts
28
+ registerNode({
29
+ id: "system.input.v1",
30
+ version: "0.1.0",
31
+ kind: "task",
32
+ label: "Stack Input",
33
+ description: "Defines the inputs for a stack.",
34
+ runtimes: ["worker"],
35
+ entrypoints: { worker: { module: "local" } },
36
+ inputsSchema: { type: "object" },
37
+ // Freeform input
38
+ outputsSchema: { type: "object" }
39
+ // Outputs whatever it receives
40
+ });
41
+ registerNode({
42
+ id: "system.output.v1",
43
+ version: "0.1.0",
44
+ kind: "task",
45
+ label: "Stack Output",
46
+ description: "Defines the outputs of a stack.",
47
+ runtimes: ["worker"],
48
+ entrypoints: { worker: { module: "local" } },
49
+ inputsSchema: { type: "object" },
50
+ // Freeform input
51
+ outputsSchema: { type: "object" }
52
+ // Outputs whatever it receives
53
+ });
54
+ runners.registerWorker("system.input.v1", async (manifest, input) => {
55
+ return input;
56
+ });
57
+ runners.registerWorker("system.output.v1", async (manifest, input) => {
58
+ return input;
59
+ });
60
+ runners.registerWorker("demo.echo.v1", async (manifest, input) => {
61
+ return { echoed: input };
62
+ });
63
+ runners.registerWorker("demo.webhook.post.v1", async (manifest, input, ctx) => {
64
+ const webhookInput = input;
65
+ const url = webhookInput.url;
66
+ const body = webhookInput.body;
67
+ const token = webhookInput.__secrets?.AUTH_TOKEN;
68
+ const res = await fetch(url, {
69
+ method: "POST",
70
+ headers: {
71
+ "Content-Type": "application/json",
72
+ ...token ? { Authorization: `Bearer ${token}` } : {}
73
+ },
74
+ body: JSON.stringify(body)
75
+ });
76
+ return { status: res.status, ok: res.ok, body: await res.text() };
77
+ });
78
+ runners.registerWorker("astro.transform.extractObsIds.v1", async (_manifest, input) => {
79
+ const obsInput = input;
80
+ const rows = Array.isArray(obsInput?.rows) ? obsInput.rows : [];
81
+ const ids = Array.from(
82
+ new Set(
83
+ rows.map((r) => r?.obsid ?? r?.parentID ?? r?.observationId).filter((v) => v !== void 0)
84
+ )
85
+ );
86
+ return { obsids: ids };
87
+ });