@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,320 @@
1
+ import {
2
+ createClient,
3
+ init_dist
4
+ } from "./chunk-TSQ3BGLA.js";
5
+ import {
6
+ __esm,
7
+ __export,
8
+ __toCommonJS
9
+ } from "./chunk-2ESYSVXG.js";
10
+
11
+ // ../../lib/terminals-tech/machines/core/secretsSupabase.ts
12
+ var secretsSupabase_exports = {};
13
+ __export(secretsSupabase_exports, {
14
+ SupabaseVault: () => SupabaseVault
15
+ });
16
+ var SupabaseVault;
17
+ var init_secretsSupabase = __esm({
18
+ "../../lib/terminals-tech/machines/core/secretsSupabase.ts"() {
19
+ "use strict";
20
+ init_dist();
21
+ SupabaseVault = class {
22
+ client;
23
+ table;
24
+ encKey;
25
+ constructor(url, serviceRoleKey, table = "vault_secrets", encKey = process.env.TERMINALS_VAULT_KEY) {
26
+ this.client = createClient(url, serviceRoleKey, {
27
+ auth: { persistSession: false }
28
+ });
29
+ this.table = table;
30
+ this.encKey = String(encKey || "");
31
+ }
32
+ async put(s) {
33
+ const p_key = this.encKey;
34
+ if (!p_key) throw new Error("TERMINALS_VAULT_KEY is required for SupabaseVault");
35
+ const { error } = await this.client.rpc("vault_secret_upsert", {
36
+ p_name: s.name,
37
+ p_value: s.value,
38
+ p_key,
39
+ p_scopes: s.scopes
40
+ });
41
+ if (error) throw error;
42
+ }
43
+ async get(name) {
44
+ const p_key = this.encKey;
45
+ if (!p_key) {
46
+ console.warn("[SupabaseVault] TERMINALS_VAULT_KEY not set, skipping secret fetch for:", name);
47
+ return null;
48
+ }
49
+ const { data: val, error: e1 } = await this.client.rpc("vault_secret_get", {
50
+ p_name: name,
51
+ p_key
52
+ });
53
+ if (e1) throw e1;
54
+ const { data: meta, error: e2 } = await this.client.from(this.table).select("name, scopes, created_at, updated_at").eq("name", name).limit(1).maybeSingle();
55
+ if (e2) throw e2;
56
+ if (!meta) return null;
57
+ const scopes = Array.isArray(meta.scopes) ? { nodeIds: meta.scopes } : {};
58
+ return {
59
+ name,
60
+ value: String(val || ""),
61
+ scopes,
62
+ createdAt: new Date(meta.created_at).getTime(),
63
+ updatedAt: new Date(meta.updated_at).getTime()
64
+ };
65
+ }
66
+ async list() {
67
+ const { data, error } = await this.client.from(this.table).select("name, scopes, created_at, updated_at").order("created_at", { ascending: false });
68
+ if (error) throw error;
69
+ return (data || []).map(
70
+ (r) => ({
71
+ name: r.name,
72
+ value: "",
73
+ scopes: Array.isArray(r.scopes) ? { nodeIds: r.scopes } : {},
74
+ createdAt: new Date(r.created_at).getTime(),
75
+ updatedAt: new Date(r.updated_at).getTime()
76
+ })
77
+ );
78
+ }
79
+ async remove(name) {
80
+ const { error } = await this.client.rpc("vault_secret_delete", {
81
+ p_name: name
82
+ });
83
+ if (error) throw error;
84
+ }
85
+ };
86
+ }
87
+ });
88
+
89
+ // ../../lib/terminals-tech/machines/core/secrets.ts
90
+ var InMemoryVault = class {
91
+ store = /* @__PURE__ */ new Map();
92
+ async put(s) {
93
+ const now = Date.now();
94
+ try {
95
+ const { encrypt } = await import("./crypto-D4LMI2RN.js");
96
+ const enc = encrypt(s.value);
97
+ this.store.set(s.name, {
98
+ ...s,
99
+ value: JSON.stringify(enc),
100
+ createdAt: now,
101
+ updatedAt: now
102
+ });
103
+ } catch {
104
+ this.store.set(s.name, { ...s, createdAt: now, updatedAt: now });
105
+ }
106
+ }
107
+ async get(name) {
108
+ return this.store.get(name) || null;
109
+ }
110
+ async list() {
111
+ return Array.from(this.store.values());
112
+ }
113
+ async remove(name) {
114
+ this.store.delete(name);
115
+ }
116
+ };
117
+ var _vault = null;
118
+ function getVault() {
119
+ const url = process.env.NEXT_PUBLIC_SUPABASE_URL;
120
+ const key = process.env.SUPABASE_SERVICE_ROLE_KEY;
121
+ if (url && key) {
122
+ const { SupabaseVault: SupabaseVault2 } = (init_secretsSupabase(), __toCommonJS(secretsSupabase_exports));
123
+ return new SupabaseVault2(url, key);
124
+ }
125
+ if (!_vault) _vault = new InMemoryVault();
126
+ return _vault;
127
+ }
128
+
129
+ // ../../lib/terminals-tech/machines/core/secret-scope.ts
130
+ var SECRET_SCOPE_PRECEDENCE = [
131
+ "terminal",
132
+ "world",
133
+ "applet",
134
+ "stack",
135
+ "user"
136
+ ];
137
+ var SCOPE_PREFIX = {
138
+ user: "user",
139
+ stack: "stack",
140
+ applet: "applet",
141
+ world: "world",
142
+ terminal: "terminal"
143
+ };
144
+ function getScopeId(scope, level) {
145
+ switch (level) {
146
+ case "terminal":
147
+ return scope.terminalId || null;
148
+ case "world":
149
+ return scope.worldId || null;
150
+ case "applet":
151
+ return scope.appletId || null;
152
+ case "stack":
153
+ return scope.stackId || null;
154
+ case "user":
155
+ return null;
156
+ default:
157
+ return null;
158
+ }
159
+ }
160
+ function buildScopedSecretName(name, scope, level) {
161
+ const owner = scope.ownerId || "anonymous";
162
+ const scopeId = getScopeId(scope, level);
163
+ if (!scopeId || level === "user") {
164
+ return `${owner}::${name}`;
165
+ }
166
+ return `${owner}::${SCOPE_PREFIX[level]}:${scopeId}::${name}`;
167
+ }
168
+ function buildSecretCandidates(name, scope) {
169
+ const owner = scope.ownerId || "anonymous";
170
+ const candidates = [];
171
+ for (const level of SECRET_SCOPE_PRECEDENCE) {
172
+ const scopeId = getScopeId(scope, level);
173
+ if (level !== "user" && !scopeId) continue;
174
+ if (level === "user") {
175
+ candidates.push(`${owner}::${name}`);
176
+ continue;
177
+ }
178
+ candidates.push(`${owner}::${SCOPE_PREFIX[level]}:${scopeId}::${name}`);
179
+ }
180
+ return candidates;
181
+ }
182
+ function parseScopedSecretName(fullName, ownerId) {
183
+ const ownerPrefix = `${ownerId}::`;
184
+ if (!fullName.startsWith(ownerPrefix)) return null;
185
+ const remainder = fullName.slice(ownerPrefix.length);
186
+ const parts = remainder.split("::");
187
+ if (parts.length === 1) {
188
+ return { ownerId, level: "user", name: parts[0] };
189
+ }
190
+ const [scopePart, name] = parts;
191
+ if (!name) return null;
192
+ const scopeMatch = scopePart.match(/^(user|stack|applet|world|terminal):(.+)$/);
193
+ if (!scopeMatch) {
194
+ return { ownerId, level: "user", name: remainder };
195
+ }
196
+ const level = scopeMatch[1];
197
+ const scopeId = scopeMatch[2];
198
+ return { ownerId, level, scopeId, name };
199
+ }
200
+
201
+ // ../../lib/terminals-tech/machines/core/secret-store.ts
202
+ function scopeMatches(record, scope) {
203
+ const meta = record.scopes || {};
204
+ if (meta.ownerId && meta.ownerId !== scope.ownerId) return false;
205
+ if (meta.stackId && meta.stackId !== scope.stackId) return false;
206
+ if (meta.appletId && meta.appletId !== scope.appletId) return false;
207
+ if (meta.worldId && meta.worldId !== scope.worldId) return false;
208
+ if (meta.terminalId && meta.terminalId !== scope.terminalId) return false;
209
+ if (Array.isArray(meta.nodeIds) && meta.nodeIds.length > 0) {
210
+ if (!scope.nodeId) return false;
211
+ if (!meta.nodeIds.includes(scope.nodeId)) return false;
212
+ }
213
+ return true;
214
+ }
215
+ function redactSecretValue(value) {
216
+ if (!value) return "";
217
+ if (value.length <= 8) return "***";
218
+ return `${value.slice(0, 4)}...${value.slice(-4)}`;
219
+ }
220
+ async function putScopedSecret(input) {
221
+ const level = input.level || "user";
222
+ const key = buildScopedSecretName(input.name, input.scope, level);
223
+ const vault = getVault();
224
+ const scopes = {
225
+ level,
226
+ ownerId: input.scope.ownerId,
227
+ stackId: input.scope.stackId,
228
+ appletId: input.scope.appletId,
229
+ worldId: input.scope.worldId,
230
+ terminalId: input.scope.terminalId,
231
+ nodeIds: input.scope.nodeIds
232
+ };
233
+ await vault.put({
234
+ name: key,
235
+ value: input.value,
236
+ scopes
237
+ });
238
+ }
239
+ async function getScopedSecret(name, scope) {
240
+ const vault = getVault();
241
+ const candidates = buildSecretCandidates(name, scope);
242
+ for (const key of candidates) {
243
+ const rec = await vault.get(key);
244
+ if (!rec) continue;
245
+ if (!scopeMatches(rec, scope)) continue;
246
+ const parsed = parseScopedSecretName(rec.name, scope.ownerId);
247
+ const meta = rec.scopes || {};
248
+ const inferredLevel = meta.terminalId ? "terminal" : meta.worldId ? "world" : meta.appletId ? "applet" : meta.stackId ? "stack" : "user";
249
+ if (parsed && parsed.level === "user" && inferredLevel !== "user") {
250
+ const targetScope = {
251
+ ownerId: scope.ownerId,
252
+ stackId: meta.stackId,
253
+ appletId: meta.appletId,
254
+ worldId: meta.worldId,
255
+ terminalId: meta.terminalId,
256
+ nodeIds: meta.nodeIds
257
+ };
258
+ const targetKey = buildScopedSecretName(parsed.name, targetScope, inferredLevel);
259
+ await vault.put({
260
+ name: targetKey,
261
+ value: rec.value,
262
+ scopes: {
263
+ ...meta,
264
+ level: inferredLevel,
265
+ ownerId: scope.ownerId
266
+ }
267
+ });
268
+ await vault.remove(rec.name);
269
+ return {
270
+ ...rec,
271
+ name: targetKey,
272
+ scopes: {
273
+ ...meta,
274
+ level: inferredLevel,
275
+ ownerId: scope.ownerId
276
+ }
277
+ };
278
+ }
279
+ return rec;
280
+ }
281
+ const legacy = await vault.get(name);
282
+ if (legacy && scopeMatches(legacy, scope)) return legacy;
283
+ return null;
284
+ }
285
+ async function resolveSecretValue(name, scope) {
286
+ const rec = await getScopedSecret(name, scope);
287
+ return rec?.value || null;
288
+ }
289
+ async function listScopedSecrets(scope) {
290
+ const vault = getVault();
291
+ const list = await vault.list();
292
+ const results = [];
293
+ for (const item of list) {
294
+ const parsed = parseScopedSecretName(item.name, scope.ownerId);
295
+ if (!parsed) continue;
296
+ results.push({
297
+ name: parsed.name,
298
+ level: parsed.level,
299
+ scopeId: parsed.scopeId,
300
+ createdAt: item.createdAt,
301
+ updatedAt: item.updatedAt,
302
+ scopes: item.scopes
303
+ });
304
+ }
305
+ return results;
306
+ }
307
+ async function removeScopedSecret(name, scope, level = "user") {
308
+ const key = buildScopedSecretName(name, scope, level);
309
+ const vault = getVault();
310
+ await vault.remove(key);
311
+ }
312
+
313
+ export {
314
+ redactSecretValue,
315
+ putScopedSecret,
316
+ getScopedSecret,
317
+ resolveSecretValue,
318
+ listScopedSecrets,
319
+ removeScopedSecret
320
+ };