@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,51 @@
|
|
|
1
|
+
// ../../lib/terminals-tech/core/primitives/types.ts
|
|
2
|
+
var Combinators = {
|
|
3
|
+
/** γ - Decompose task into subtasks */
|
|
4
|
+
CONSTRUCT: "\u03B3",
|
|
5
|
+
/** δ - Spawn parallel execution paths */
|
|
6
|
+
DUPLICATE: "\u03B4",
|
|
7
|
+
/** ε - Fold/aggregate results */
|
|
8
|
+
ERASE: "\u03B5"
|
|
9
|
+
};
|
|
10
|
+
function createPAdicAddress(base, coefficients = []) {
|
|
11
|
+
if (base < 2) {
|
|
12
|
+
throw new Error(`P-adic base must be >= 2, got ${base}`);
|
|
13
|
+
}
|
|
14
|
+
for (const c of coefficients) {
|
|
15
|
+
if (c < 0 || c >= base) {
|
|
16
|
+
throw new Error(`Coefficient ${c} must be in [0, ${base - 1}] for base ${base}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return { base, coefficients: Object.freeze([...coefficients]) };
|
|
20
|
+
}
|
|
21
|
+
function validated(value) {
|
|
22
|
+
return Object.assign(value, { _validated: true });
|
|
23
|
+
}
|
|
24
|
+
function unbrand(value) {
|
|
25
|
+
const obj = value;
|
|
26
|
+
delete obj._validated;
|
|
27
|
+
return obj;
|
|
28
|
+
}
|
|
29
|
+
function untrusted(value) {
|
|
30
|
+
if (value === null || value === void 0 || typeof value !== "object") {
|
|
31
|
+
return { value, _untrusted: true };
|
|
32
|
+
}
|
|
33
|
+
return Object.assign(value, { _untrusted: true });
|
|
34
|
+
}
|
|
35
|
+
function validate(value, validator) {
|
|
36
|
+
const raw = { ...value };
|
|
37
|
+
delete raw._untrusted;
|
|
38
|
+
if (validator(raw)) {
|
|
39
|
+
return validated(raw);
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export {
|
|
45
|
+
Combinators,
|
|
46
|
+
createPAdicAddress,
|
|
47
|
+
validated,
|
|
48
|
+
unbrand,
|
|
49
|
+
untrusted,
|
|
50
|
+
validate
|
|
51
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {
|
|
2
|
+
untrusted,
|
|
3
|
+
validate
|
|
4
|
+
} from "./chunk-EXI3LJVJ.js";
|
|
5
|
+
import {
|
|
6
|
+
require_ajv
|
|
7
|
+
} from "./chunk-QJFKEQHF.js";
|
|
8
|
+
import {
|
|
9
|
+
__toESM
|
|
10
|
+
} from "./chunk-2ESYSVXG.js";
|
|
11
|
+
|
|
12
|
+
// ../../lib/terminals-tech/core/primitives/validation.ts
|
|
13
|
+
var import_ajv = __toESM(require_ajv());
|
|
14
|
+
var ajv = new import_ajv.default({ allErrors: true });
|
|
15
|
+
var validatorCache = /* @__PURE__ */ new Map();
|
|
16
|
+
function getValidator(schema) {
|
|
17
|
+
const schemaStr = JSON.stringify(schema);
|
|
18
|
+
if (validatorCache.has(schemaStr)) {
|
|
19
|
+
return validatorCache.get(schemaStr);
|
|
20
|
+
}
|
|
21
|
+
const validateFn = ajv.compile(schema);
|
|
22
|
+
validatorCache.set(schemaStr, validateFn);
|
|
23
|
+
return validateFn;
|
|
24
|
+
}
|
|
25
|
+
function validateWithSchema(data, schema) {
|
|
26
|
+
const validator = getValidator(schema);
|
|
27
|
+
return validate(data, (raw) => {
|
|
28
|
+
const isValid = validator(raw);
|
|
29
|
+
if (!isValid) {
|
|
30
|
+
console.warn("[Validation] Schema validation failed:", validator.errors);
|
|
31
|
+
}
|
|
32
|
+
return !!isValid;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function secureValidate(data, schema) {
|
|
36
|
+
return validateWithSchema(untrusted(data), schema);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export {
|
|
40
|
+
validateWithSchema,
|
|
41
|
+
secureValidate
|
|
42
|
+
};
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__require
|
|
3
|
+
} from "./chunk-2ESYSVXG.js";
|
|
4
|
+
|
|
5
|
+
// ../../lib/terminals-tech/machines/core/topology.ts
|
|
6
|
+
function clone(value) {
|
|
7
|
+
return JSON.parse(JSON.stringify(value));
|
|
8
|
+
}
|
|
9
|
+
function normalizeRuntimes(r) {
|
|
10
|
+
if (!r) return void 0;
|
|
11
|
+
const normalized = {};
|
|
12
|
+
if (r.default && Array.isArray(r.default)) normalized.default = [...r.default].slice().sort();
|
|
13
|
+
if (r.overrides) {
|
|
14
|
+
const entries = Object.entries(r.overrides).map(
|
|
15
|
+
([nodeId, tiers]) => [nodeId, [...tiers].slice().sort()]
|
|
16
|
+
);
|
|
17
|
+
entries.sort((a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0);
|
|
18
|
+
normalized.overrides = Object.fromEntries(entries);
|
|
19
|
+
}
|
|
20
|
+
return normalized;
|
|
21
|
+
}
|
|
22
|
+
function normalizePolicies(p) {
|
|
23
|
+
if (!p) return void 0;
|
|
24
|
+
const normalized = {};
|
|
25
|
+
if (p.fs) {
|
|
26
|
+
normalized.fs = { mode: p.fs.mode };
|
|
27
|
+
if (p.fs.allowedPaths) normalized.fs.allowedPaths = [...p.fs.allowedPaths].slice().sort();
|
|
28
|
+
}
|
|
29
|
+
if (p.network) {
|
|
30
|
+
normalized.network = { egress: p.network.egress };
|
|
31
|
+
if (p.network.allowList) normalized.network.allowList = [...p.network.allowList].slice().sort();
|
|
32
|
+
}
|
|
33
|
+
return normalized;
|
|
34
|
+
}
|
|
35
|
+
function normalizeNode(n) {
|
|
36
|
+
const out = {
|
|
37
|
+
id: n.id,
|
|
38
|
+
nodeRef: n.nodeRef
|
|
39
|
+
};
|
|
40
|
+
if (n.runtimes && n.runtimes.length > 0) out.runtimes = [...n.runtimes].slice().sort();
|
|
41
|
+
if (n.policies) out.policies = normalizePolicies(n.policies);
|
|
42
|
+
if (n.secrets && n.secrets.length > 0) out.secrets = [...n.secrets].slice().sort();
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
function normalizeEdge(e) {
|
|
46
|
+
const ce = { from: e.from, to: e.to };
|
|
47
|
+
if (e.map) {
|
|
48
|
+
const pairs = Object.entries(e.map).map(([outKey, inKey]) => ({
|
|
49
|
+
outKey,
|
|
50
|
+
inKey
|
|
51
|
+
}));
|
|
52
|
+
pairs.sort(
|
|
53
|
+
(a, b) => a.outKey < b.outKey ? -1 : a.outKey > b.outKey ? 1 : a.inKey < b.inKey ? -1 : a.inKey > b.inKey ? 1 : 0
|
|
54
|
+
);
|
|
55
|
+
ce.map = pairs;
|
|
56
|
+
}
|
|
57
|
+
return ce;
|
|
58
|
+
}
|
|
59
|
+
function normalizeSecrets(s) {
|
|
60
|
+
if (!s) return void 0;
|
|
61
|
+
const entries = Object.entries(s).map(
|
|
62
|
+
([name, rec]) => [name, { scope: [...rec.scope].slice().sort(), required: rec.required }]
|
|
63
|
+
);
|
|
64
|
+
entries.sort((a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0);
|
|
65
|
+
return Object.fromEntries(entries);
|
|
66
|
+
}
|
|
67
|
+
function canonicalizeStack(manifest) {
|
|
68
|
+
const m = clone(manifest);
|
|
69
|
+
const nodes = (m.nodes || []).map(normalizeNode).sort((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0);
|
|
70
|
+
const edges = (m.edges || []).map(normalizeEdge).sort((a, b) => {
|
|
71
|
+
if (a.from !== b.from) return a.from < b.from ? -1 : 1;
|
|
72
|
+
return a.to < b.to ? -1 : a.to > b.to ? 1 : 0;
|
|
73
|
+
});
|
|
74
|
+
return {
|
|
75
|
+
version: m.version,
|
|
76
|
+
name: m.name || void 0,
|
|
77
|
+
nodes,
|
|
78
|
+
edges,
|
|
79
|
+
policies: normalizePolicies(m.policies),
|
|
80
|
+
runtimes: normalizeRuntimes(m.runtimes),
|
|
81
|
+
secrets: normalizeSecrets(m.secrets),
|
|
82
|
+
layer: m.layer
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function stableStringify(value) {
|
|
86
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
87
|
+
function walk(v) {
|
|
88
|
+
if (v === null || typeof v !== "object") return v;
|
|
89
|
+
if (seen.has(v)) return v;
|
|
90
|
+
seen.add(v);
|
|
91
|
+
if (Array.isArray(v)) return v.map(walk);
|
|
92
|
+
const out = {};
|
|
93
|
+
for (const key of Object.keys(v).sort()) {
|
|
94
|
+
out[key] = walk(v[key]);
|
|
95
|
+
}
|
|
96
|
+
return out;
|
|
97
|
+
}
|
|
98
|
+
return JSON.stringify(walk(value));
|
|
99
|
+
}
|
|
100
|
+
async function sha256Hex(input) {
|
|
101
|
+
try {
|
|
102
|
+
if (typeof crypto !== "undefined" && crypto.subtle) {
|
|
103
|
+
const enc = new TextEncoder().encode(input);
|
|
104
|
+
const buf = await crypto.subtle.digest("SHA-256", enc);
|
|
105
|
+
const bytes = Array.from(new Uint8Array(buf));
|
|
106
|
+
return bytes.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
107
|
+
}
|
|
108
|
+
} catch {
|
|
109
|
+
}
|
|
110
|
+
try {
|
|
111
|
+
const nodeCrypto = __require("crypto");
|
|
112
|
+
return nodeCrypto.createHash("sha256").update(input).digest("hex");
|
|
113
|
+
} catch {
|
|
114
|
+
}
|
|
115
|
+
let hashHigh = 3421674724;
|
|
116
|
+
let hashLow = 2216829733;
|
|
117
|
+
for (let i = 0; i < input.length; i++) {
|
|
118
|
+
const code = input.charCodeAt(i);
|
|
119
|
+
hashLow ^= code;
|
|
120
|
+
const low = hashLow * 435 >>> 0;
|
|
121
|
+
const carry = Math.floor(hashLow * 435 / 4294967296);
|
|
122
|
+
const high = hashHigh * 435 + carry >>> 0;
|
|
123
|
+
hashLow = low;
|
|
124
|
+
hashHigh = high;
|
|
125
|
+
}
|
|
126
|
+
return (hashHigh >>> 0).toString(16).padStart(8, "0") + (hashLow >>> 0).toString(16).padStart(8, "0");
|
|
127
|
+
}
|
|
128
|
+
async function computeShapeHash(manifest, fsTreeHash) {
|
|
129
|
+
const canonical = canonicalizeStack(manifest);
|
|
130
|
+
const payload = {
|
|
131
|
+
canonical,
|
|
132
|
+
fsTreeHash: fsTreeHash || "fs:none",
|
|
133
|
+
domain: canonical.layer || "L1"
|
|
134
|
+
// layer-aware domain separation
|
|
135
|
+
};
|
|
136
|
+
const text = stableStringify(payload);
|
|
137
|
+
return await sha256Hex(text);
|
|
138
|
+
}
|
|
139
|
+
function adjacencyMatrix(nodes, edges) {
|
|
140
|
+
const index = {};
|
|
141
|
+
nodes.forEach((n, i) => {
|
|
142
|
+
index[n.id] = i;
|
|
143
|
+
});
|
|
144
|
+
const N = nodes.length;
|
|
145
|
+
const A = Array.from({ length: N }, () => Array(N).fill(0));
|
|
146
|
+
for (const e of edges) {
|
|
147
|
+
const i = index[e.from], j = index[e.to];
|
|
148
|
+
if (i !== void 0 && j !== void 0) A[i][j] = 1;
|
|
149
|
+
}
|
|
150
|
+
return A;
|
|
151
|
+
}
|
|
152
|
+
function incidenceMatrix(nodes, edges) {
|
|
153
|
+
const index = {};
|
|
154
|
+
nodes.forEach((n, i) => {
|
|
155
|
+
index[n.id] = i;
|
|
156
|
+
});
|
|
157
|
+
const E = edges.length;
|
|
158
|
+
const N = nodes.length;
|
|
159
|
+
const B = Array.from({ length: N }, () => Array(E).fill(0));
|
|
160
|
+
edges.forEach((e, k) => {
|
|
161
|
+
const i = index[e.from], j = index[e.to];
|
|
162
|
+
if (i !== void 0) B[i][k] = -1;
|
|
163
|
+
if (j !== void 0) B[j][k] = 1;
|
|
164
|
+
});
|
|
165
|
+
return B;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export {
|
|
169
|
+
canonicalizeStack,
|
|
170
|
+
computeShapeHash,
|
|
171
|
+
adjacencyMatrix,
|
|
172
|
+
incidenceMatrix
|
|
173
|
+
};
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BRAND,
|
|
3
|
+
DIRTY,
|
|
4
|
+
EMPTY_PATH,
|
|
5
|
+
INVALID,
|
|
6
|
+
NEVER,
|
|
7
|
+
OK,
|
|
8
|
+
ParseStatus,
|
|
9
|
+
ZodAny,
|
|
10
|
+
ZodArray,
|
|
11
|
+
ZodBigInt,
|
|
12
|
+
ZodBoolean,
|
|
13
|
+
ZodBranded,
|
|
14
|
+
ZodCatch,
|
|
15
|
+
ZodDate,
|
|
16
|
+
ZodDefault,
|
|
17
|
+
ZodDiscriminatedUnion,
|
|
18
|
+
ZodEffects,
|
|
19
|
+
ZodEnum,
|
|
20
|
+
ZodError,
|
|
21
|
+
ZodFirstPartyTypeKind,
|
|
22
|
+
ZodFunction,
|
|
23
|
+
ZodIntersection,
|
|
24
|
+
ZodIssueCode,
|
|
25
|
+
ZodLazy,
|
|
26
|
+
ZodLiteral,
|
|
27
|
+
ZodMap,
|
|
28
|
+
ZodNaN,
|
|
29
|
+
ZodNativeEnum,
|
|
30
|
+
ZodNever,
|
|
31
|
+
ZodNull,
|
|
32
|
+
ZodNullable,
|
|
33
|
+
ZodNumber,
|
|
34
|
+
ZodObject,
|
|
35
|
+
ZodOptional,
|
|
36
|
+
ZodParsedType,
|
|
37
|
+
ZodPipeline,
|
|
38
|
+
ZodPromise,
|
|
39
|
+
ZodReadonly,
|
|
40
|
+
ZodRecord,
|
|
41
|
+
ZodSet,
|
|
42
|
+
ZodString,
|
|
43
|
+
ZodSymbol,
|
|
44
|
+
ZodTuple,
|
|
45
|
+
ZodType,
|
|
46
|
+
ZodUndefined,
|
|
47
|
+
ZodUnion,
|
|
48
|
+
ZodUnknown,
|
|
49
|
+
ZodVoid,
|
|
50
|
+
addIssueToContext,
|
|
51
|
+
anyType,
|
|
52
|
+
arrayType,
|
|
53
|
+
bigIntType,
|
|
54
|
+
booleanType,
|
|
55
|
+
coerce,
|
|
56
|
+
custom,
|
|
57
|
+
dateType,
|
|
58
|
+
datetimeRegex,
|
|
59
|
+
discriminatedUnionType,
|
|
60
|
+
effectsType,
|
|
61
|
+
en_default,
|
|
62
|
+
enumType,
|
|
63
|
+
functionType,
|
|
64
|
+
getErrorMap,
|
|
65
|
+
getParsedType,
|
|
66
|
+
instanceOfType,
|
|
67
|
+
intersectionType,
|
|
68
|
+
isAborted,
|
|
69
|
+
isAsync,
|
|
70
|
+
isDirty,
|
|
71
|
+
isValid,
|
|
72
|
+
late,
|
|
73
|
+
lazyType,
|
|
74
|
+
literalType,
|
|
75
|
+
makeIssue,
|
|
76
|
+
mapType,
|
|
77
|
+
nanType,
|
|
78
|
+
nativeEnumType,
|
|
79
|
+
neverType,
|
|
80
|
+
nullType,
|
|
81
|
+
nullableType,
|
|
82
|
+
numberType,
|
|
83
|
+
objectType,
|
|
84
|
+
objectUtil,
|
|
85
|
+
oboolean,
|
|
86
|
+
onumber,
|
|
87
|
+
optionalType,
|
|
88
|
+
ostring,
|
|
89
|
+
pipelineType,
|
|
90
|
+
preprocessType,
|
|
91
|
+
promiseType,
|
|
92
|
+
quotelessJson,
|
|
93
|
+
recordType,
|
|
94
|
+
setErrorMap,
|
|
95
|
+
setType,
|
|
96
|
+
strictObjectType,
|
|
97
|
+
stringType,
|
|
98
|
+
symbolType,
|
|
99
|
+
tupleType,
|
|
100
|
+
undefinedType,
|
|
101
|
+
unionType,
|
|
102
|
+
unknownType,
|
|
103
|
+
util,
|
|
104
|
+
voidType
|
|
105
|
+
} from "./chunk-KHR7ZYCX.js";
|
|
106
|
+
import {
|
|
107
|
+
__export
|
|
108
|
+
} from "./chunk-2ESYSVXG.js";
|
|
109
|
+
|
|
110
|
+
// ../../node_modules/zod/v3/external.js
|
|
111
|
+
var external_exports = {};
|
|
112
|
+
__export(external_exports, {
|
|
113
|
+
BRAND: () => BRAND,
|
|
114
|
+
DIRTY: () => DIRTY,
|
|
115
|
+
EMPTY_PATH: () => EMPTY_PATH,
|
|
116
|
+
INVALID: () => INVALID,
|
|
117
|
+
NEVER: () => NEVER,
|
|
118
|
+
OK: () => OK,
|
|
119
|
+
ParseStatus: () => ParseStatus,
|
|
120
|
+
Schema: () => ZodType,
|
|
121
|
+
ZodAny: () => ZodAny,
|
|
122
|
+
ZodArray: () => ZodArray,
|
|
123
|
+
ZodBigInt: () => ZodBigInt,
|
|
124
|
+
ZodBoolean: () => ZodBoolean,
|
|
125
|
+
ZodBranded: () => ZodBranded,
|
|
126
|
+
ZodCatch: () => ZodCatch,
|
|
127
|
+
ZodDate: () => ZodDate,
|
|
128
|
+
ZodDefault: () => ZodDefault,
|
|
129
|
+
ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
|
|
130
|
+
ZodEffects: () => ZodEffects,
|
|
131
|
+
ZodEnum: () => ZodEnum,
|
|
132
|
+
ZodError: () => ZodError,
|
|
133
|
+
ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
|
|
134
|
+
ZodFunction: () => ZodFunction,
|
|
135
|
+
ZodIntersection: () => ZodIntersection,
|
|
136
|
+
ZodIssueCode: () => ZodIssueCode,
|
|
137
|
+
ZodLazy: () => ZodLazy,
|
|
138
|
+
ZodLiteral: () => ZodLiteral,
|
|
139
|
+
ZodMap: () => ZodMap,
|
|
140
|
+
ZodNaN: () => ZodNaN,
|
|
141
|
+
ZodNativeEnum: () => ZodNativeEnum,
|
|
142
|
+
ZodNever: () => ZodNever,
|
|
143
|
+
ZodNull: () => ZodNull,
|
|
144
|
+
ZodNullable: () => ZodNullable,
|
|
145
|
+
ZodNumber: () => ZodNumber,
|
|
146
|
+
ZodObject: () => ZodObject,
|
|
147
|
+
ZodOptional: () => ZodOptional,
|
|
148
|
+
ZodParsedType: () => ZodParsedType,
|
|
149
|
+
ZodPipeline: () => ZodPipeline,
|
|
150
|
+
ZodPromise: () => ZodPromise,
|
|
151
|
+
ZodReadonly: () => ZodReadonly,
|
|
152
|
+
ZodRecord: () => ZodRecord,
|
|
153
|
+
ZodSchema: () => ZodType,
|
|
154
|
+
ZodSet: () => ZodSet,
|
|
155
|
+
ZodString: () => ZodString,
|
|
156
|
+
ZodSymbol: () => ZodSymbol,
|
|
157
|
+
ZodTransformer: () => ZodEffects,
|
|
158
|
+
ZodTuple: () => ZodTuple,
|
|
159
|
+
ZodType: () => ZodType,
|
|
160
|
+
ZodUndefined: () => ZodUndefined,
|
|
161
|
+
ZodUnion: () => ZodUnion,
|
|
162
|
+
ZodUnknown: () => ZodUnknown,
|
|
163
|
+
ZodVoid: () => ZodVoid,
|
|
164
|
+
addIssueToContext: () => addIssueToContext,
|
|
165
|
+
any: () => anyType,
|
|
166
|
+
array: () => arrayType,
|
|
167
|
+
bigint: () => bigIntType,
|
|
168
|
+
boolean: () => booleanType,
|
|
169
|
+
coerce: () => coerce,
|
|
170
|
+
custom: () => custom,
|
|
171
|
+
date: () => dateType,
|
|
172
|
+
datetimeRegex: () => datetimeRegex,
|
|
173
|
+
defaultErrorMap: () => en_default,
|
|
174
|
+
discriminatedUnion: () => discriminatedUnionType,
|
|
175
|
+
effect: () => effectsType,
|
|
176
|
+
enum: () => enumType,
|
|
177
|
+
function: () => functionType,
|
|
178
|
+
getErrorMap: () => getErrorMap,
|
|
179
|
+
getParsedType: () => getParsedType,
|
|
180
|
+
instanceof: () => instanceOfType,
|
|
181
|
+
intersection: () => intersectionType,
|
|
182
|
+
isAborted: () => isAborted,
|
|
183
|
+
isAsync: () => isAsync,
|
|
184
|
+
isDirty: () => isDirty,
|
|
185
|
+
isValid: () => isValid,
|
|
186
|
+
late: () => late,
|
|
187
|
+
lazy: () => lazyType,
|
|
188
|
+
literal: () => literalType,
|
|
189
|
+
makeIssue: () => makeIssue,
|
|
190
|
+
map: () => mapType,
|
|
191
|
+
nan: () => nanType,
|
|
192
|
+
nativeEnum: () => nativeEnumType,
|
|
193
|
+
never: () => neverType,
|
|
194
|
+
null: () => nullType,
|
|
195
|
+
nullable: () => nullableType,
|
|
196
|
+
number: () => numberType,
|
|
197
|
+
object: () => objectType,
|
|
198
|
+
objectUtil: () => objectUtil,
|
|
199
|
+
oboolean: () => oboolean,
|
|
200
|
+
onumber: () => onumber,
|
|
201
|
+
optional: () => optionalType,
|
|
202
|
+
ostring: () => ostring,
|
|
203
|
+
pipeline: () => pipelineType,
|
|
204
|
+
preprocess: () => preprocessType,
|
|
205
|
+
promise: () => promiseType,
|
|
206
|
+
quotelessJson: () => quotelessJson,
|
|
207
|
+
record: () => recordType,
|
|
208
|
+
set: () => setType,
|
|
209
|
+
setErrorMap: () => setErrorMap,
|
|
210
|
+
strictObject: () => strictObjectType,
|
|
211
|
+
string: () => stringType,
|
|
212
|
+
symbol: () => symbolType,
|
|
213
|
+
transformer: () => effectsType,
|
|
214
|
+
tuple: () => tupleType,
|
|
215
|
+
undefined: () => undefinedType,
|
|
216
|
+
union: () => unionType,
|
|
217
|
+
unknown: () => unknownType,
|
|
218
|
+
util: () => util,
|
|
219
|
+
void: () => voidType
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
// ../../lib/terminals-tech/machines/core/providers/registry.ts
|
|
223
|
+
var ChatMessage = external_exports.object({
|
|
224
|
+
role: external_exports.enum(["system", "user", "assistant"]),
|
|
225
|
+
content: external_exports.string()
|
|
226
|
+
});
|
|
227
|
+
var ChatGenerateInput = external_exports.object({
|
|
228
|
+
model: external_exports.string(),
|
|
229
|
+
messages: external_exports.array(ChatMessage),
|
|
230
|
+
temperature: external_exports.number().optional()
|
|
231
|
+
});
|
|
232
|
+
var TokenUsage = external_exports.object({
|
|
233
|
+
prompt_tokens: external_exports.number().optional(),
|
|
234
|
+
completion_tokens: external_exports.number().optional(),
|
|
235
|
+
total_tokens: external_exports.number().optional()
|
|
236
|
+
}).passthrough();
|
|
237
|
+
var ChatGenerateOutput = external_exports.object({
|
|
238
|
+
message: external_exports.string(),
|
|
239
|
+
usage: TokenUsage.optional(),
|
|
240
|
+
raw: external_exports.record(external_exports.unknown()).optional()
|
|
241
|
+
});
|
|
242
|
+
var registry = /* @__PURE__ */ new Map();
|
|
243
|
+
function registerProvider(p) {
|
|
244
|
+
registry.set(p.id, p);
|
|
245
|
+
}
|
|
246
|
+
function getProvider(id) {
|
|
247
|
+
return registry.get(id);
|
|
248
|
+
}
|
|
249
|
+
registerProvider({
|
|
250
|
+
id: "openai",
|
|
251
|
+
chat: {
|
|
252
|
+
async generate(input, secrets) {
|
|
253
|
+
ChatGenerateInput.parse(input);
|
|
254
|
+
const apiKey = secrets["apiKey"] || secrets["OPENAI_API_KEY"];
|
|
255
|
+
const baseUrl = secrets["baseUrl"] || "https://api.openai.com/v1";
|
|
256
|
+
const res = await fetch(`${baseUrl}/chat/completions`, {
|
|
257
|
+
method: "POST",
|
|
258
|
+
headers: {
|
|
259
|
+
"Content-Type": "application/json",
|
|
260
|
+
...apiKey ? { Authorization: `Bearer ${apiKey}` } : {}
|
|
261
|
+
},
|
|
262
|
+
body: JSON.stringify({
|
|
263
|
+
model: input.model,
|
|
264
|
+
messages: input.messages,
|
|
265
|
+
temperature: input.temperature ?? 0.2
|
|
266
|
+
})
|
|
267
|
+
});
|
|
268
|
+
if (!res.ok) throw new Error(`chat.generate failed: ${res.status}`);
|
|
269
|
+
const j = await res.json();
|
|
270
|
+
const message = j?.choices?.[0]?.message?.content || "";
|
|
271
|
+
return { message, usage: j?.usage, raw: j };
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
var allowExperimentalProviders = process.env.NODE_ENV !== "production" || process.env.ENABLE_EXPERIMENTAL_PROVIDERS === "true";
|
|
276
|
+
if (allowExperimentalProviders) {
|
|
277
|
+
registerProvider({
|
|
278
|
+
id: "nous",
|
|
279
|
+
chat: {
|
|
280
|
+
async generate(input, secrets) {
|
|
281
|
+
const baseUrl = secrets["baseUrl"] || "https://api.nous.example/v1";
|
|
282
|
+
const apiKey = secrets["apiKey"] || "";
|
|
283
|
+
const res = await fetch(`${baseUrl}/chat/completions`, {
|
|
284
|
+
method: "POST",
|
|
285
|
+
headers: {
|
|
286
|
+
"Content-Type": "application/json",
|
|
287
|
+
...apiKey ? { Authorization: `Bearer ${apiKey}` } : {}
|
|
288
|
+
},
|
|
289
|
+
body: JSON.stringify({
|
|
290
|
+
model: input.model,
|
|
291
|
+
messages: input.messages
|
|
292
|
+
})
|
|
293
|
+
});
|
|
294
|
+
if (!res.ok) throw new Error(`nous chat ${res.status}`);
|
|
295
|
+
const j = await res.json();
|
|
296
|
+
const message = j?.choices?.[0]?.message?.content || "";
|
|
297
|
+
return { message, usage: j?.usage, raw: j };
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
registerProvider({
|
|
302
|
+
id: "prime",
|
|
303
|
+
chat: {
|
|
304
|
+
async generate(input, secrets) {
|
|
305
|
+
const baseUrl = secrets["baseUrl"] || "https://api.prime.example/v1";
|
|
306
|
+
const apiKey = secrets["apiKey"] || "";
|
|
307
|
+
const res = await fetch(`${baseUrl}/chat`, {
|
|
308
|
+
method: "POST",
|
|
309
|
+
headers: {
|
|
310
|
+
"Content-Type": "application/json",
|
|
311
|
+
...apiKey ? { "X-API-Key": apiKey } : {}
|
|
312
|
+
},
|
|
313
|
+
body: JSON.stringify({
|
|
314
|
+
model: input.model,
|
|
315
|
+
messages: input.messages
|
|
316
|
+
})
|
|
317
|
+
});
|
|
318
|
+
if (!res.ok) throw new Error(`prime chat ${res.status}`);
|
|
319
|
+
const j = await res.json();
|
|
320
|
+
const message = j?.output || j?.choices?.[0]?.message?.content || "";
|
|
321
|
+
return { message, usage: j?.usage, raw: j };
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
export {
|
|
328
|
+
ChatMessage,
|
|
329
|
+
ChatGenerateInput,
|
|
330
|
+
ChatGenerateOutput,
|
|
331
|
+
registerProvider,
|
|
332
|
+
getProvider
|
|
333
|
+
};
|