@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,79 @@
|
|
|
1
|
+
import {
|
|
2
|
+
safeDbOperation
|
|
3
|
+
} from "./chunk-WGBCRNMB.js";
|
|
4
|
+
import {
|
|
5
|
+
getDB
|
|
6
|
+
} from "./chunk-AFDUOYHD.js";
|
|
7
|
+
|
|
8
|
+
// ../../lib/terminals-tech/machines/core/approvalsStore.ts
|
|
9
|
+
async function createAsk(stackId, nodeId, url) {
|
|
10
|
+
return await safeDbOperation(
|
|
11
|
+
async () => {
|
|
12
|
+
const db = await getDB();
|
|
13
|
+
const r = await db.query(
|
|
14
|
+
`INSERT INTO policy_asks (stack_id, node_id, url) VALUES ($1,$2,$3) RETURNING *`,
|
|
15
|
+
[stackId, nodeId, url]
|
|
16
|
+
);
|
|
17
|
+
return r.rows[0];
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
id: crypto.randomUUID(),
|
|
21
|
+
stack_id: stackId,
|
|
22
|
+
node_id: nodeId,
|
|
23
|
+
url,
|
|
24
|
+
status: "pending",
|
|
25
|
+
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
26
|
+
decided_at: null
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
async function getLatestDecision(stackId, nodeId, url) {
|
|
31
|
+
return await safeDbOperation(async () => {
|
|
32
|
+
const db = await getDB();
|
|
33
|
+
const r = await db.query(
|
|
34
|
+
`SELECT * FROM policy_asks WHERE stack_id = $1 AND node_id = $2 AND url = $3 ORDER BY created_at DESC LIMIT 1`,
|
|
35
|
+
[stackId, nodeId, url]
|
|
36
|
+
);
|
|
37
|
+
return r.rows[0]?.status || null;
|
|
38
|
+
}, null);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// ../../lib/terminals-tech/machines/core/policy.ts
|
|
42
|
+
function isNetworkAllowed(policies, url) {
|
|
43
|
+
const p = policies?.network;
|
|
44
|
+
if (!p) return false;
|
|
45
|
+
if (p.egress === "deny") return false;
|
|
46
|
+
if (p.egress === "ask") return false;
|
|
47
|
+
if (p.egress === "allow:list") {
|
|
48
|
+
if (!url) return false;
|
|
49
|
+
const byNode = !!p.allowList?.some((prefix) => url.startsWith(prefix));
|
|
50
|
+
try {
|
|
51
|
+
const globalObj = globalThis;
|
|
52
|
+
const globalList = globalObj.__tn_allowlist__ || [];
|
|
53
|
+
const byGlobal = !!globalList.find((prefix) => url.startsWith(prefix));
|
|
54
|
+
return byNode || byGlobal;
|
|
55
|
+
} catch {
|
|
56
|
+
return byNode;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
async function requireNetworkApproval(stackId, nodeId, policies, url) {
|
|
62
|
+
const p = policies?.network;
|
|
63
|
+
if (!p || !url) return false;
|
|
64
|
+
if (p.egress === "deny") return false;
|
|
65
|
+
if (p.egress === "allow:list") return isNetworkAllowed(policies, url);
|
|
66
|
+
if (p.egress === "ask") {
|
|
67
|
+
const decision = await getLatestDecision(stackId, nodeId, url);
|
|
68
|
+
if (decision === "approved") return true;
|
|
69
|
+
if (decision === "denied") return false;
|
|
70
|
+
await createAsk(stackId, nodeId, url);
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export {
|
|
77
|
+
isNetworkAllowed,
|
|
78
|
+
requireNetworkApproval
|
|
79
|
+
};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// ../../lib/terminals-tech/core/stores/global-store.ts
|
|
2
|
+
var NAMESPACE_PREFIX = "__terminals_store_";
|
|
3
|
+
var GlobalStore = class {
|
|
4
|
+
key;
|
|
5
|
+
store;
|
|
6
|
+
constructor(namespace) {
|
|
7
|
+
this.key = `${NAMESPACE_PREFIX}${namespace}__`;
|
|
8
|
+
if (!globalThis[this.key]) {
|
|
9
|
+
globalThis[this.key] = /* @__PURE__ */ new Map();
|
|
10
|
+
}
|
|
11
|
+
this.store = globalThis[this.key];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Get value by key
|
|
15
|
+
*/
|
|
16
|
+
get(key) {
|
|
17
|
+
return this.store.get(key);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Set value for key
|
|
21
|
+
*/
|
|
22
|
+
set(key, value) {
|
|
23
|
+
this.store.set(key, value);
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Check if key exists
|
|
28
|
+
*/
|
|
29
|
+
has(key) {
|
|
30
|
+
return this.store.has(key);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Delete key
|
|
34
|
+
*/
|
|
35
|
+
delete(key) {
|
|
36
|
+
return this.store.delete(key);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Clear all entries
|
|
40
|
+
*/
|
|
41
|
+
clear() {
|
|
42
|
+
this.store.clear();
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Get store size
|
|
46
|
+
*/
|
|
47
|
+
get size() {
|
|
48
|
+
return this.store.size;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Get all keys
|
|
52
|
+
*/
|
|
53
|
+
keys() {
|
|
54
|
+
return this.store.keys();
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Get all values
|
|
58
|
+
*/
|
|
59
|
+
values() {
|
|
60
|
+
return this.store.values();
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get all entries
|
|
64
|
+
*/
|
|
65
|
+
entries() {
|
|
66
|
+
return this.store.entries();
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Iterate over entries
|
|
70
|
+
*/
|
|
71
|
+
forEach(callback) {
|
|
72
|
+
this.store.forEach(callback);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Get or create value with factory function
|
|
76
|
+
*/
|
|
77
|
+
getOrCreate(key, factory) {
|
|
78
|
+
const existing = this.store.get(key);
|
|
79
|
+
if (existing !== void 0) {
|
|
80
|
+
return existing;
|
|
81
|
+
}
|
|
82
|
+
const value = factory();
|
|
83
|
+
this.store.set(key, value);
|
|
84
|
+
return value;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Update value if exists, returning whether update occurred
|
|
88
|
+
*/
|
|
89
|
+
update(key, updater) {
|
|
90
|
+
const current = this.store.get(key);
|
|
91
|
+
if (current === void 0) return false;
|
|
92
|
+
this.store.set(key, updater(current));
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Get underlying Map for advanced operations
|
|
97
|
+
*/
|
|
98
|
+
raw() {
|
|
99
|
+
return this.store;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Make iterable
|
|
103
|
+
*/
|
|
104
|
+
[Symbol.iterator]() {
|
|
105
|
+
return this.store.entries();
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
var storeRegistry = /* @__PURE__ */ new Map();
|
|
109
|
+
function getGlobalStore(namespace) {
|
|
110
|
+
if (!storeRegistry.has(namespace)) {
|
|
111
|
+
storeRegistry.set(namespace, new GlobalStore(namespace));
|
|
112
|
+
}
|
|
113
|
+
return storeRegistry.get(namespace);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export {
|
|
117
|
+
getGlobalStore
|
|
118
|
+
};
|