@terminals-tech/sdk 1.0.0-rc.2 → 2.0.0-rc.1
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 +62 -20
- package/dist/{WebContainerManager-SHXC5VKI.js → WebContainerManager-NUGGUIWB.js} +2 -2
- package/dist/catalog-XA5VYWXG.js +16 -0
- package/dist/{chunk-PWAHFID5.js → chunk-D4MOOUDY.js} +3 -3
- package/dist/{chunk-FOXUEYWK.js → chunk-GOQHOLBG.js} +4 -3
- package/dist/{chunk-PUZ2S62E.js → chunk-ICFYWOI5.js} +61 -36
- package/dist/chunk-PKINKOW2.js +335 -0
- package/dist/chunk-PWEICJ47.js +30 -0
- package/dist/{chunk-BKB3MD5Y.js → chunk-Q4W3IUTD.js} +73 -12
- package/dist/{chunk-BCOQMFKT.js → chunk-TO7ETE5K.js} +2 -2
- package/dist/{chunk-Q2VI6ICE.js → chunk-UB5OINTA.js} +1 -1
- package/dist/{chunk-Q4B7YS7T.js → chunk-WJCIX7RO.js} +9 -69
- package/dist/{chunk-3CEM77QZ.js → chunk-WT6L6DK3.js} +30 -2
- package/dist/{chunk-UKVUPKZP.js → chunk-Y5WLSLLW.js} +1 -1
- package/dist/{container-lite-KQX3NMPY.js → container-lite-Q3O3EP6R.js} +9 -9
- package/dist/core.machine.orchestrator-NW73YDTL.js +24 -0
- package/dist/{demo-VXMGMJNK.js → demo-WARANXBT.js} +11 -11
- package/dist/{hvm-DRQK2MUT.js → hvm-A7DGZ3Q5.js} +1 -1
- package/dist/index.cjs +65114 -12973
- package/dist/index.d.cts +643 -146
- package/dist/index.d.ts +643 -146
- package/dist/index.js +2460 -454
- package/dist/{neuro-state-XHRGIRVO.js → neuro-state-KINIFV2D.js} +6 -6
- package/dist/{nodes-DXKYDTVO.js → nodes-TWQZUZRM.js} +153 -13
- package/dist/pglite-adapter-43IOUBMV.js +50 -0
- package/dist/{registry-BL3TDQDB.js → registry-UARRB6CF.js} +9 -9
- package/dist/resolver-ALOJSOK5.js +24 -0
- package/dist/{scheduler-H6Q53IMI.js → scheduler-SAQJLKXJ.js} +52 -45
- package/dist/sematon-2EUEZESN.js +19 -0
- package/dist/{server-7DM74VFW.js → server-JXM4Y2T6.js} +1 -1
- package/dist/{skills-KLTTT2RM.js → skills-XOFGMUP4.js} +2 -2
- package/dist/{stack-CHDAFU2S.js → stack-4QQCK7MG.js} +17 -15
- package/dist/{supabaseService-6AYP2VY3.js → supabaseService-O4ZFFLZP.js} +2 -2
- package/dist/{webcontainer-3LDJVIIL.js → webcontainer-PMWNRO4I.js} +2 -2
- package/package.json +10 -4
- package/dist/{chunk-SHPGIVDH.js → chunk-P4D4RNAV.js} +4 -4
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
// ../../lib/terminals-tech/core/L0/information.ts
|
|
2
|
+
function entropy(probabilities) {
|
|
3
|
+
if (probabilities.length === 0) return 0;
|
|
4
|
+
const sum = probabilities.reduce((a, b) => a + b, 0);
|
|
5
|
+
const normalized = sum === 0 ? probabilities : probabilities.map((p) => p / sum);
|
|
6
|
+
return normalized.reduce((h, p) => {
|
|
7
|
+
if (p <= 0) return h;
|
|
8
|
+
return h - p * Math.log2(p);
|
|
9
|
+
}, 0);
|
|
10
|
+
}
|
|
11
|
+
function jointEntropy(jointProbabilities) {
|
|
12
|
+
const flat = jointProbabilities.flat();
|
|
13
|
+
return entropy(flat);
|
|
14
|
+
}
|
|
15
|
+
function conditionalEntropy(jointProbabilities) {
|
|
16
|
+
const hXY = jointEntropy(jointProbabilities);
|
|
17
|
+
const pX = jointProbabilities.map((row) => row.reduce((a, b) => a + b, 0));
|
|
18
|
+
const hX = entropy(pX);
|
|
19
|
+
return hXY - hX;
|
|
20
|
+
}
|
|
21
|
+
function mutualInformation(pX, pY, pXY) {
|
|
22
|
+
const hX = entropy(pX);
|
|
23
|
+
const hY = entropy(pY);
|
|
24
|
+
const hXY = jointEntropy(pXY);
|
|
25
|
+
return Math.max(0, hX + hY - hXY);
|
|
26
|
+
}
|
|
27
|
+
function measurePreservation(source, transformed, roundTrip) {
|
|
28
|
+
if (source.length === 0) {
|
|
29
|
+
return {
|
|
30
|
+
retention: 1,
|
|
31
|
+
sourceEntropy: 0,
|
|
32
|
+
targetEntropy: 0,
|
|
33
|
+
mutualInfo: 0,
|
|
34
|
+
lossless: true
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const sourceFreq = countFrequencies(source.map(String));
|
|
38
|
+
const transformedFreq = countFrequencies(transformed.map(String));
|
|
39
|
+
const n = source.length;
|
|
40
|
+
const sourceProbabilities = Object.values(sourceFreq).map((c) => c / n);
|
|
41
|
+
const transformedProbabilities = Object.values(transformedFreq).map((c) => c / n);
|
|
42
|
+
const sourceEntropy = entropy(sourceProbabilities);
|
|
43
|
+
const targetEntropy = entropy(transformedProbabilities);
|
|
44
|
+
let retention = 1;
|
|
45
|
+
let lossless = true;
|
|
46
|
+
if (roundTrip) {
|
|
47
|
+
const matches = source.filter((s, i) => String(s) === String(roundTrip[i])).length;
|
|
48
|
+
retention = matches / source.length;
|
|
49
|
+
lossless = matches === source.length;
|
|
50
|
+
} else {
|
|
51
|
+
const sourceCardinality = Object.keys(sourceFreq).length;
|
|
52
|
+
const targetCardinality = Object.keys(transformedFreq).length;
|
|
53
|
+
retention = Math.min(1, targetCardinality / sourceCardinality);
|
|
54
|
+
lossless = targetCardinality >= sourceCardinality;
|
|
55
|
+
}
|
|
56
|
+
const minEntropy = Math.min(sourceEntropy, targetEntropy);
|
|
57
|
+
const mutualInfo = retention * minEntropy;
|
|
58
|
+
return {
|
|
59
|
+
retention,
|
|
60
|
+
sourceEntropy,
|
|
61
|
+
targetEntropy,
|
|
62
|
+
mutualInfo,
|
|
63
|
+
lossless
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function calculateSemanticDensity(tokens, baselineTokensPerBit = 2) {
|
|
67
|
+
if (tokens.length === 0) {
|
|
68
|
+
return {
|
|
69
|
+
tokenCount: 0,
|
|
70
|
+
informationBits: 0,
|
|
71
|
+
density: 0,
|
|
72
|
+
compressionRatio: 1
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
const freq = countFrequencies(tokens);
|
|
76
|
+
const probabilities = Object.values(freq).map((c) => c / tokens.length);
|
|
77
|
+
const informationBits = entropy(probabilities) * tokens.length;
|
|
78
|
+
const density = tokens.length > 0 ? informationBits / tokens.length : 0;
|
|
79
|
+
const baselineBits = tokens.length / baselineTokensPerBit;
|
|
80
|
+
const compressionRatio = baselineBits > 0 ? informationBits / baselineBits : 1;
|
|
81
|
+
return {
|
|
82
|
+
tokenCount: tokens.length,
|
|
83
|
+
informationBits,
|
|
84
|
+
density,
|
|
85
|
+
compressionRatio
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function estimateComplexity(data) {
|
|
89
|
+
if (data.length === 0) return 0;
|
|
90
|
+
const seen = /* @__PURE__ */ new Set();
|
|
91
|
+
let uniqueSubstrings = 0;
|
|
92
|
+
const windowSize = 8;
|
|
93
|
+
for (let i = 0; i <= data.length - windowSize; i++) {
|
|
94
|
+
const substr = data.slice(i, i + windowSize);
|
|
95
|
+
if (!seen.has(substr)) {
|
|
96
|
+
seen.add(substr);
|
|
97
|
+
uniqueSubstrings++;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const totalPatterns = Math.max(1, data.length - windowSize + 1);
|
|
101
|
+
return uniqueSubstrings / totalPatterns;
|
|
102
|
+
}
|
|
103
|
+
function klDivergence(p, q) {
|
|
104
|
+
if (p.length !== q.length) {
|
|
105
|
+
throw new Error("Distributions must have same length");
|
|
106
|
+
}
|
|
107
|
+
let divergence = 0;
|
|
108
|
+
for (let i = 0; i < p.length; i++) {
|
|
109
|
+
if (p[i] > 0 && q[i] > 0) {
|
|
110
|
+
divergence += p[i] * Math.log2(p[i] / q[i]);
|
|
111
|
+
} else if (p[i] > 0 && q[i] === 0) {
|
|
112
|
+
return Infinity;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return divergence;
|
|
116
|
+
}
|
|
117
|
+
function jsDivergence(p, q) {
|
|
118
|
+
if (p.length !== q.length) {
|
|
119
|
+
throw new Error("Distributions must have same length");
|
|
120
|
+
}
|
|
121
|
+
const m = p.map((pi, i) => 0.5 * (pi + q[i]));
|
|
122
|
+
let jsd = 0;
|
|
123
|
+
for (let i = 0; i < p.length; i++) {
|
|
124
|
+
if (p[i] > 0 && m[i] > 0) {
|
|
125
|
+
jsd += 0.5 * p[i] * Math.log2(p[i] / m[i]);
|
|
126
|
+
}
|
|
127
|
+
if (q[i] > 0 && m[i] > 0) {
|
|
128
|
+
jsd += 0.5 * q[i] * Math.log2(q[i] / m[i]);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return jsd;
|
|
132
|
+
}
|
|
133
|
+
function countFrequencies(values) {
|
|
134
|
+
const freq = {};
|
|
135
|
+
for (const v of values) {
|
|
136
|
+
const key = String(v);
|
|
137
|
+
freq[key] = (freq[key] || 0) + 1;
|
|
138
|
+
}
|
|
139
|
+
return freq;
|
|
140
|
+
}
|
|
141
|
+
function normalize(values) {
|
|
142
|
+
const sum = values.reduce((a, b) => a + b, 0);
|
|
143
|
+
if (sum === 0) return values.map(() => 1 / values.length);
|
|
144
|
+
return values.map((v) => v / sum);
|
|
145
|
+
}
|
|
146
|
+
function cosineSimilarity(a, b) {
|
|
147
|
+
if (a.length !== b.length || a.length === 0) return 0;
|
|
148
|
+
let dot = 0;
|
|
149
|
+
let normA = 0;
|
|
150
|
+
let normB = 0;
|
|
151
|
+
for (let i = 0; i < a.length; i++) {
|
|
152
|
+
dot += a[i] * b[i];
|
|
153
|
+
normA += a[i] * a[i];
|
|
154
|
+
normB += b[i] * b[i];
|
|
155
|
+
}
|
|
156
|
+
const denominator = Math.sqrt(normA) * Math.sqrt(normB);
|
|
157
|
+
return denominator === 0 ? 0 : dot / denominator;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// ../../lib/terminals-tech/core/L0/sematon.ts
|
|
161
|
+
var sematonCounter = 0;
|
|
162
|
+
function fnv1a(input) {
|
|
163
|
+
let hash = 2166136261;
|
|
164
|
+
for (let i = 0; i < input.length; i++) {
|
|
165
|
+
hash ^= input.charCodeAt(i);
|
|
166
|
+
hash = Math.imul(hash, 16777619);
|
|
167
|
+
}
|
|
168
|
+
return (hash >>> 0).toString(16).padStart(8, "0");
|
|
169
|
+
}
|
|
170
|
+
function computePayloadEntropy(payload) {
|
|
171
|
+
const json = JSON.stringify(payload);
|
|
172
|
+
if (!json || json.length === 0) return 0;
|
|
173
|
+
const freq = {};
|
|
174
|
+
for (let i = 0; i < json.length; i++) {
|
|
175
|
+
const ch = json[i];
|
|
176
|
+
freq[ch] = (freq[ch] || 0) + 1;
|
|
177
|
+
}
|
|
178
|
+
const probabilities = Object.values(freq).map((c) => c / json.length);
|
|
179
|
+
return entropy(probabilities);
|
|
180
|
+
}
|
|
181
|
+
function computeDensity(payload, entropyBits) {
|
|
182
|
+
const json = JSON.stringify(payload);
|
|
183
|
+
const tokenCount = json ? json.split(/\s+|[,{}[\]":]+/).filter(Boolean).length : 0;
|
|
184
|
+
return tokenCount > 0 ? entropyBits / tokenCount : 0;
|
|
185
|
+
}
|
|
186
|
+
function generatePadicAddress(kind, counter) {
|
|
187
|
+
const kindIndex = [
|
|
188
|
+
"signal",
|
|
189
|
+
"context",
|
|
190
|
+
"fractal",
|
|
191
|
+
"witness",
|
|
192
|
+
"combinator",
|
|
193
|
+
"interaction",
|
|
194
|
+
"custom"
|
|
195
|
+
].indexOf(kind);
|
|
196
|
+
return `${kindIndex}.0.${counter}`;
|
|
197
|
+
}
|
|
198
|
+
function createSematon(config) {
|
|
199
|
+
const counter = ++sematonCounter;
|
|
200
|
+
const id = `sem_${config.kind}_${counter}_${Date.now().toString(36)}`;
|
|
201
|
+
const payloadEntropy = computePayloadEntropy(config.payload);
|
|
202
|
+
const density = computeDensity(config.payload, payloadEntropy);
|
|
203
|
+
const padicAddress = config.padicAddress ?? generatePadicAddress(config.kind, counter);
|
|
204
|
+
const hashInput = [
|
|
205
|
+
config.kind,
|
|
206
|
+
JSON.stringify(config.payload),
|
|
207
|
+
config.witness.R.toFixed(6),
|
|
208
|
+
config.witness.converged.toString(),
|
|
209
|
+
padicAddress
|
|
210
|
+
].join("|");
|
|
211
|
+
const shapeHash = fnv1a(hashInput);
|
|
212
|
+
const constructive = config.witness.converged && Number.isFinite(payloadEntropy) && payloadEntropy > 0 && JSON.stringify(config.payload) !== "null" && JSON.stringify(config.payload) !== "undefined";
|
|
213
|
+
const impedance = density > 0 && config.witness.R > 0 ? payloadEntropy / (density * config.witness.R) : Infinity;
|
|
214
|
+
return {
|
|
215
|
+
id,
|
|
216
|
+
kind: config.kind,
|
|
217
|
+
payload: config.payload,
|
|
218
|
+
witness: { ...config.witness },
|
|
219
|
+
padicAddress,
|
|
220
|
+
entropy: payloadEntropy,
|
|
221
|
+
density,
|
|
222
|
+
impedance,
|
|
223
|
+
shapeHash,
|
|
224
|
+
constructive,
|
|
225
|
+
createdAt: Date.now(),
|
|
226
|
+
source: config.source ?? "unknown"
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
function sematonEntropy(sematon) {
|
|
230
|
+
return sematon.entropy;
|
|
231
|
+
}
|
|
232
|
+
function sematonDensity(sematon) {
|
|
233
|
+
return sematon.density;
|
|
234
|
+
}
|
|
235
|
+
function isRealizable(sematon) {
|
|
236
|
+
return sematon.constructive;
|
|
237
|
+
}
|
|
238
|
+
function sematonDistance(a, b) {
|
|
239
|
+
const vecA = payloadToVector(a.payload);
|
|
240
|
+
const vecB = payloadToVector(b.payload);
|
|
241
|
+
const cosSim = cosineSimilarity(vecA, vecB);
|
|
242
|
+
const rProximity = 1 - Math.abs(a.witness.R - b.witness.R);
|
|
243
|
+
const similarity = 0.7 * Math.max(0, cosSim) + 0.3 * rProximity;
|
|
244
|
+
return 1 - similarity;
|
|
245
|
+
}
|
|
246
|
+
function payloadToVector(payload) {
|
|
247
|
+
const json = JSON.stringify(payload);
|
|
248
|
+
const vec = new Array(128).fill(0);
|
|
249
|
+
if (!json) return vec;
|
|
250
|
+
for (let i = 0; i < json.length; i++) {
|
|
251
|
+
const code = json.charCodeAt(i);
|
|
252
|
+
if (code < 128) {
|
|
253
|
+
vec[code]++;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
const sum = vec.reduce((s, v) => s + v, 0);
|
|
257
|
+
if (sum > 0) {
|
|
258
|
+
for (let i = 0; i < vec.length; i++) {
|
|
259
|
+
vec[i] /= sum;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return vec;
|
|
263
|
+
}
|
|
264
|
+
function foldSematon(sematon) {
|
|
265
|
+
return {
|
|
266
|
+
id: sematon.id,
|
|
267
|
+
kind: sematon.kind,
|
|
268
|
+
payload: JSON.stringify(sematon.payload),
|
|
269
|
+
witness: { ...sematon.witness },
|
|
270
|
+
padicAddress: sematon.padicAddress,
|
|
271
|
+
entropy: sematon.entropy,
|
|
272
|
+
density: sematon.density,
|
|
273
|
+
impedance: sematon.impedance,
|
|
274
|
+
shapeHash: sematon.shapeHash,
|
|
275
|
+
constructive: sematon.constructive,
|
|
276
|
+
createdAt: sematon.createdAt,
|
|
277
|
+
source: sematon.source
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
function unfoldSematon(folded) {
|
|
281
|
+
return {
|
|
282
|
+
id: folded.id,
|
|
283
|
+
kind: folded.kind,
|
|
284
|
+
payload: JSON.parse(folded.payload),
|
|
285
|
+
witness: { ...folded.witness },
|
|
286
|
+
padicAddress: folded.padicAddress,
|
|
287
|
+
entropy: folded.entropy,
|
|
288
|
+
density: folded.density,
|
|
289
|
+
impedance: folded.impedance,
|
|
290
|
+
shapeHash: folded.shapeHash,
|
|
291
|
+
constructive: folded.constructive,
|
|
292
|
+
createdAt: folded.createdAt,
|
|
293
|
+
source: folded.source
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export {
|
|
298
|
+
entropy,
|
|
299
|
+
jointEntropy,
|
|
300
|
+
conditionalEntropy,
|
|
301
|
+
mutualInformation,
|
|
302
|
+
measurePreservation,
|
|
303
|
+
calculateSemanticDensity,
|
|
304
|
+
estimateComplexity,
|
|
305
|
+
klDivergence,
|
|
306
|
+
jsDivergence,
|
|
307
|
+
normalize,
|
|
308
|
+
cosineSimilarity,
|
|
309
|
+
createSematon,
|
|
310
|
+
sematonEntropy,
|
|
311
|
+
sematonDensity,
|
|
312
|
+
isRealizable,
|
|
313
|
+
sematonDistance,
|
|
314
|
+
foldSematon,
|
|
315
|
+
unfoldSematon
|
|
316
|
+
};
|
|
317
|
+
/**
|
|
318
|
+
* L0 Sematon — The Smallest Meaning-Bearing Unit
|
|
319
|
+
*
|
|
320
|
+
* The sematon is the atomic unit of operational meaning in Terminals OS.
|
|
321
|
+
* It carries a typed payload, convergence witness, p-adic address,
|
|
322
|
+
* information-theoretic metrics, and a constructor flag that guarantees
|
|
323
|
+
* the Deutsch-Marletto invariant: after transforming an input, the
|
|
324
|
+
* sematon retains the ability to transform again.
|
|
325
|
+
*
|
|
326
|
+
* The sematon unifies Signal<T>, ContextNode, FractalSnapshot,
|
|
327
|
+
* ConvergenceWitness, and CombinatorEvent into a single formal type
|
|
328
|
+
* at the L0 foundation layer.
|
|
329
|
+
*
|
|
330
|
+
* Core Engine Primitive.
|
|
331
|
+
*
|
|
332
|
+
* @license BUSL-1.1
|
|
333
|
+
* @copyright © 2026 Intuition Labs LLC. All rights reserved. Patent Pending.
|
|
334
|
+
* @module core/L0/sematon
|
|
335
|
+
*/
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
registerManifestProvider
|
|
3
|
+
} from "./chunk-WT6L6DK3.js";
|
|
4
|
+
|
|
5
|
+
// ../../lib/terminals-tech/machines/core/stacksStore.ts
|
|
6
|
+
var globalStore = globalThis;
|
|
7
|
+
var memStacks = globalStore.__memStacks || /* @__PURE__ */ new Map();
|
|
8
|
+
globalStore.__memStacks = memStacks;
|
|
9
|
+
var pendingDeletes = globalStore.__pendingStackDeletes || /* @__PURE__ */ new Set();
|
|
10
|
+
globalStore.__pendingStackDeletes = pendingDeletes;
|
|
11
|
+
registerManifestProvider("stacksStore", loadStack);
|
|
12
|
+
async function loadStack(id) {
|
|
13
|
+
const { getDB, safeDbOperation } = await import("./pgliteService-IUGNNOVU.js");
|
|
14
|
+
const dbResult = await safeDbOperation(async () => {
|
|
15
|
+
const db = await getDB();
|
|
16
|
+
await db.query(`ALTER TABLE stacks ADD COLUMN IF NOT EXISTS deleted_at TIMESTAMP`);
|
|
17
|
+
const r = await db.query(
|
|
18
|
+
`SELECT manifest FROM stacks WHERE id = $1 AND deleted_at IS NULL`,
|
|
19
|
+
[id]
|
|
20
|
+
);
|
|
21
|
+
if (!r.rows[0]) return null;
|
|
22
|
+
return r.rows[0].manifest;
|
|
23
|
+
}, null);
|
|
24
|
+
if (dbResult) return dbResult;
|
|
25
|
+
return memStacks.get(id)?.manifest || null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
loadStack
|
|
30
|
+
};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
appendMeshSinkEvent
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-D4MOOUDY.js";
|
|
4
|
+
import {
|
|
5
|
+
getProvider
|
|
6
|
+
} from "./chunk-H3POJCFA.js";
|
|
4
7
|
import {
|
|
5
8
|
blendResonance,
|
|
6
9
|
cosineResonance,
|
|
@@ -10,9 +13,6 @@ import {
|
|
|
10
13
|
phaseShift,
|
|
11
14
|
toIQ
|
|
12
15
|
} from "./chunk-WU4OTGJE.js";
|
|
13
|
-
import {
|
|
14
|
-
registerNode
|
|
15
|
-
} from "./chunk-3CEM77QZ.js";
|
|
16
16
|
import {
|
|
17
17
|
emitSignal
|
|
18
18
|
} from "./chunk-2WTYE4SW.js";
|
|
@@ -20,6 +20,65 @@ import {
|
|
|
20
20
|
Combinators,
|
|
21
21
|
createPAdicAddress
|
|
22
22
|
} from "./chunk-EXI3LJVJ.js";
|
|
23
|
+
import {
|
|
24
|
+
registerNode
|
|
25
|
+
} from "./chunk-WT6L6DK3.js";
|
|
26
|
+
|
|
27
|
+
// ../../lib/terminals-tech/machines/core/nodes/provider.chat.ts
|
|
28
|
+
var PROVIDER_CHAT_NODE_ID = "provider.chat.v1";
|
|
29
|
+
var manifest = {
|
|
30
|
+
id: PROVIDER_CHAT_NODE_ID,
|
|
31
|
+
version: "0.1.0",
|
|
32
|
+
kind: "task",
|
|
33
|
+
label: "Provider Chat",
|
|
34
|
+
description: "Calls a chat model on a selected provider",
|
|
35
|
+
runtimes: ["worker"],
|
|
36
|
+
entrypoints: { worker: { module: "local" } },
|
|
37
|
+
inputsSchema: {
|
|
38
|
+
type: "object",
|
|
39
|
+
properties: {
|
|
40
|
+
provider: {
|
|
41
|
+
type: "string",
|
|
42
|
+
description: "provider id (openai, nous, prime, ...)"
|
|
43
|
+
},
|
|
44
|
+
model: { type: "string" },
|
|
45
|
+
messages: {
|
|
46
|
+
type: "array",
|
|
47
|
+
items: {
|
|
48
|
+
type: "object",
|
|
49
|
+
properties: { role: { type: "string" }, content: { type: "string" } },
|
|
50
|
+
required: ["role", "content"]
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
temperature: { type: "number" },
|
|
54
|
+
secretRef: {
|
|
55
|
+
type: "string",
|
|
56
|
+
description: "reference key in Secrets store"
|
|
57
|
+
},
|
|
58
|
+
baseUrl: { type: "string", description: "override baseUrl for vendor" }
|
|
59
|
+
},
|
|
60
|
+
required: ["provider", "model", "messages"]
|
|
61
|
+
},
|
|
62
|
+
outputsSchema: {
|
|
63
|
+
type: "object",
|
|
64
|
+
properties: { message: { type: "string" }, usage: { type: "object" } }
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
registerNode(manifest);
|
|
68
|
+
async function executeProviderChat(inputs, context) {
|
|
69
|
+
const adapter = getProvider(inputs.provider);
|
|
70
|
+
if (!adapter?.chat?.generate) throw new Error(`provider not found: ${inputs.provider}`);
|
|
71
|
+
const secrets = inputs.secretRef && context.getSecret ? await context.getSecret(inputs.secretRef) : {};
|
|
72
|
+
const out = await adapter.chat.generate(
|
|
73
|
+
{
|
|
74
|
+
model: inputs.model,
|
|
75
|
+
messages: inputs.messages,
|
|
76
|
+
temperature: inputs.temperature
|
|
77
|
+
},
|
|
78
|
+
secrets
|
|
79
|
+
);
|
|
80
|
+
return { message: out.message, usage: out.usage };
|
|
81
|
+
}
|
|
23
82
|
|
|
24
83
|
// ../../lib/terminals-tech/machines/hvm/bridge.ts
|
|
25
84
|
function calculateValuation(node) {
|
|
@@ -100,7 +159,7 @@ function hvmToLogitBias(trace, baseMagnitude = 0.15) {
|
|
|
100
159
|
|
|
101
160
|
// ../../lib/terminals-tech/machines/core/nodes/hvm.proof.edgeCheck.ts
|
|
102
161
|
var HVM_PROOF_EDGE_CHECK_NODE_ID = "hvm.proof.edgeCheck.v1";
|
|
103
|
-
var
|
|
162
|
+
var manifest2 = {
|
|
104
163
|
id: HVM_PROOF_EDGE_CHECK_NODE_ID,
|
|
105
164
|
version: "0.1.0",
|
|
106
165
|
kind: "transform",
|
|
@@ -175,7 +234,7 @@ var manifest = {
|
|
|
175
234
|
required: ["ok", "proofTrace"]
|
|
176
235
|
}
|
|
177
236
|
};
|
|
178
|
-
registerNode(
|
|
237
|
+
registerNode(manifest2);
|
|
179
238
|
function hasPath(edges, from, to, visited = /* @__PURE__ */ new Set()) {
|
|
180
239
|
if (from === to) return true;
|
|
181
240
|
if (visited.has(from)) return false;
|
|
@@ -306,7 +365,7 @@ async function executeHvmProofEdgeCheck(input, ctx) {
|
|
|
306
365
|
|
|
307
366
|
// ../../lib/terminals-tech/machines/core/nodes/compute.bend.ts
|
|
308
367
|
var COMPUTE_BEND_NODE_ID = "compute.bend.v1";
|
|
309
|
-
var
|
|
368
|
+
var manifest3 = {
|
|
310
369
|
id: COMPUTE_BEND_NODE_ID,
|
|
311
370
|
version: "0.1.0",
|
|
312
371
|
kind: "task",
|
|
@@ -349,7 +408,7 @@ var manifest2 = {
|
|
|
349
408
|
required: ["ok"]
|
|
350
409
|
}
|
|
351
410
|
};
|
|
352
|
-
registerNode(
|
|
411
|
+
registerNode(manifest3);
|
|
353
412
|
async function executeBendCompute(input, ctx) {
|
|
354
413
|
const rawModule = String(input.hvmModule || "");
|
|
355
414
|
const bendPath = String(input.bendPath || "");
|
|
@@ -365,7 +424,7 @@ async function executeBendCompute(input, ctx) {
|
|
|
365
424
|
bendSource: bendSource ? "present" : "absent"
|
|
366
425
|
};
|
|
367
426
|
}
|
|
368
|
-
const { runInHVM } = await import("./hvm-
|
|
427
|
+
const { runInHVM } = await import("./hvm-A7DGZ3Q5.js");
|
|
369
428
|
const manifestOverride = {
|
|
370
429
|
id: COMPUTE_BEND_NODE_ID,
|
|
371
430
|
version: "0.1.0",
|
|
@@ -670,7 +729,7 @@ async function executePhaseLockingValueNode(inputs) {
|
|
|
670
729
|
|
|
671
730
|
// ../../lib/terminals-tech/machines/core/nodes/system.schedule.ts
|
|
672
731
|
var SYSTEM_SCHEDULE_NODE_ID = "system.schedule.v1";
|
|
673
|
-
var
|
|
732
|
+
var manifest4 = {
|
|
674
733
|
id: SYSTEM_SCHEDULE_NODE_ID,
|
|
675
734
|
version: "0.1.0",
|
|
676
735
|
kind: "task",
|
|
@@ -694,9 +753,9 @@ var manifest3 = {
|
|
|
694
753
|
}
|
|
695
754
|
}
|
|
696
755
|
};
|
|
697
|
-
registerNode(
|
|
756
|
+
registerNode(manifest4);
|
|
698
757
|
async function executeSystemSchedule(_input, ctx) {
|
|
699
|
-
const { scheduleStack } = await import("./scheduler-
|
|
758
|
+
const { scheduleStack } = await import("./scheduler-SAQJLKXJ.js");
|
|
700
759
|
const everySeconds = Math.max(1, Number(_input.everySeconds || 60));
|
|
701
760
|
const enabled = Boolean(_input.enabled ?? true);
|
|
702
761
|
if (enabled) await scheduleStack(ctx.stackId, everySeconds);
|
|
@@ -704,6 +763,8 @@ async function executeSystemSchedule(_input, ctx) {
|
|
|
704
763
|
}
|
|
705
764
|
|
|
706
765
|
export {
|
|
766
|
+
PROVIDER_CHAT_NODE_ID,
|
|
767
|
+
executeProviderChat,
|
|
707
768
|
HVM_PROOF_EDGE_CHECK_NODE_ID,
|
|
708
769
|
executeHvmProofEdgeCheck,
|
|
709
770
|
COMPUTE_BEND_NODE_ID,
|
|
@@ -258,8 +258,8 @@ function sanitizeTraceSegment(value, maxLen = 48) {
|
|
|
258
258
|
export {
|
|
259
259
|
createInteractionWithEvents,
|
|
260
260
|
transitionStatusWithEvent,
|
|
261
|
-
sanitizeTraceSegment,
|
|
262
261
|
parseAddress,
|
|
263
262
|
formatAddress,
|
|
264
|
-
createAddress
|
|
263
|
+
createAddress,
|
|
264
|
+
sanitizeTraceSegment
|
|
265
265
|
};
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
BASE_RESONANCE_METRICS_NODE_ID,
|
|
6
6
|
COMPUTE_BEND_NODE_ID,
|
|
7
7
|
HVM_PROOF_EDGE_CHECK_NODE_ID,
|
|
8
|
+
PROVIDER_CHAT_NODE_ID,
|
|
8
9
|
SYSTEM_SCHEDULE_NODE_ID,
|
|
9
10
|
SYSTEM_SIGNAL_EMIT_NODE_ID,
|
|
10
11
|
executeBendCompute,
|
|
@@ -12,16 +13,11 @@ import {
|
|
|
12
13
|
executeIqEncode,
|
|
13
14
|
executeIqPhaseShift,
|
|
14
15
|
executePhaseLockingValueNode,
|
|
16
|
+
executeProviderChat,
|
|
15
17
|
executeResonanceMetrics,
|
|
16
18
|
executeSystemSchedule,
|
|
17
19
|
executeSystemSignalEmit
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import {
|
|
20
|
-
getProvider
|
|
21
|
-
} from "./chunk-H3POJCFA.js";
|
|
22
|
-
import {
|
|
23
|
-
registerNode
|
|
24
|
-
} from "./chunk-3CEM77QZ.js";
|
|
20
|
+
} from "./chunk-Q4W3IUTD.js";
|
|
25
21
|
|
|
26
22
|
// ../../lib/types/safe-types.ts
|
|
27
23
|
function isObject(value) {
|
|
@@ -34,62 +30,6 @@ function isString(value) {
|
|
|
34
30
|
return typeof value === "string";
|
|
35
31
|
}
|
|
36
32
|
|
|
37
|
-
// ../../lib/terminals-tech/machines/core/nodes/provider.chat.ts
|
|
38
|
-
var PROVIDER_CHAT_NODE_ID = "provider.chat.v1";
|
|
39
|
-
var manifest = {
|
|
40
|
-
id: PROVIDER_CHAT_NODE_ID,
|
|
41
|
-
version: "0.1.0",
|
|
42
|
-
kind: "task",
|
|
43
|
-
label: "Provider Chat",
|
|
44
|
-
description: "Calls a chat model on a selected provider",
|
|
45
|
-
runtimes: ["worker"],
|
|
46
|
-
entrypoints: { worker: { module: "local" } },
|
|
47
|
-
inputsSchema: {
|
|
48
|
-
type: "object",
|
|
49
|
-
properties: {
|
|
50
|
-
provider: {
|
|
51
|
-
type: "string",
|
|
52
|
-
description: "provider id (openai, nous, prime, ...)"
|
|
53
|
-
},
|
|
54
|
-
model: { type: "string" },
|
|
55
|
-
messages: {
|
|
56
|
-
type: "array",
|
|
57
|
-
items: {
|
|
58
|
-
type: "object",
|
|
59
|
-
properties: { role: { type: "string" }, content: { type: "string" } },
|
|
60
|
-
required: ["role", "content"]
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
temperature: { type: "number" },
|
|
64
|
-
secretRef: {
|
|
65
|
-
type: "string",
|
|
66
|
-
description: "reference key in Secrets store"
|
|
67
|
-
},
|
|
68
|
-
baseUrl: { type: "string", description: "override baseUrl for vendor" }
|
|
69
|
-
},
|
|
70
|
-
required: ["provider", "model", "messages"]
|
|
71
|
-
},
|
|
72
|
-
outputsSchema: {
|
|
73
|
-
type: "object",
|
|
74
|
-
properties: { message: { type: "string" }, usage: { type: "object" } }
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
registerNode(manifest);
|
|
78
|
-
async function executeProviderChat(inputs, context) {
|
|
79
|
-
const adapter = getProvider(inputs.provider);
|
|
80
|
-
if (!adapter?.chat?.generate) throw new Error(`provider not found: ${inputs.provider}`);
|
|
81
|
-
const secrets = inputs.secretRef && context.getSecret ? await context.getSecret(inputs.secretRef) : {};
|
|
82
|
-
const out = await adapter.chat.generate(
|
|
83
|
-
{
|
|
84
|
-
model: inputs.model,
|
|
85
|
-
messages: inputs.messages,
|
|
86
|
-
temperature: inputs.temperature
|
|
87
|
-
},
|
|
88
|
-
secrets
|
|
89
|
-
);
|
|
90
|
-
return { message: out.message, usage: out.usage };
|
|
91
|
-
}
|
|
92
|
-
|
|
93
33
|
// ../../lib/terminals-tech/machines/core/runners/registry.ts
|
|
94
34
|
var RunnerRegistry = class {
|
|
95
35
|
workerRunners = /* @__PURE__ */ new Map();
|
|
@@ -134,8 +74,8 @@ var RunnerRegistry = class {
|
|
|
134
74
|
}
|
|
135
75
|
};
|
|
136
76
|
var runners = new RunnerRegistry();
|
|
137
|
-
import("./demo-
|
|
138
|
-
import("./stack-
|
|
77
|
+
import("./demo-WARANXBT.js").catch((err) => console.warn("[RunnerRegistry] demo runner import failed", err));
|
|
78
|
+
import("./stack-4QQCK7MG.js").catch((err) => console.warn("[RunnerRegistry] stack runner import failed", err));
|
|
139
79
|
runners.registerWorker(PROVIDER_CHAT_NODE_ID, async (_m, input, ctx) => {
|
|
140
80
|
const typedInput = input;
|
|
141
81
|
const secrets = typedInput.__secrets || {};
|
|
@@ -446,7 +386,7 @@ runners.registerWorker("intel.llm.http.v1", async (_m, input, ctx) => {
|
|
|
446
386
|
};
|
|
447
387
|
});
|
|
448
388
|
runners.registerWorker("integration.source.poll.v1", async (_m, input, ctx) => {
|
|
449
|
-
const { getProvider
|
|
389
|
+
const { getProvider } = await import("./registry-FW63E7FE.js");
|
|
450
390
|
const providerIdVal = isObject(input) && "provider" in input ? input.provider : void 0;
|
|
451
391
|
const providerId = String(providerIdVal || "");
|
|
452
392
|
const resourceVal = isObject(input) && "resource" in input ? input.resource : void 0;
|
|
@@ -455,7 +395,7 @@ runners.registerWorker("integration.source.poll.v1", async (_m, input, ctx) => {
|
|
|
455
395
|
const config = isObject(configVal) ? configVal : {};
|
|
456
396
|
const cursorKeyVal = isObject(input) && "cursorKey" in input ? input.cursorKey : void 0;
|
|
457
397
|
const cursorKey = String(cursorKeyVal || `${providerId}:${resource}`);
|
|
458
|
-
const prov =
|
|
398
|
+
const prov = getProvider(providerId);
|
|
459
399
|
if (!prov?.integration) throw new Error(`provider not found: ${providerId}`);
|
|
460
400
|
const secrets = {};
|
|
461
401
|
try {
|
|
@@ -495,7 +435,7 @@ runners.registerWorker("integration.source.poll.v1", async (_m, input, ctx) => {
|
|
|
495
435
|
return { items, cursor: nextCursor };
|
|
496
436
|
});
|
|
497
437
|
runners.registerWorker("integration.sink.post.v1", async (_m, input, ctx) => {
|
|
498
|
-
const { getProvider
|
|
438
|
+
const { getProvider } = await import("./registry-FW63E7FE.js");
|
|
499
439
|
const providerIdVal = isObject(input) && "provider" in input ? input.provider : void 0;
|
|
500
440
|
const providerId = String(providerIdVal || "");
|
|
501
441
|
const resourceVal = isObject(input) && "resource" in input ? input.resource : void 0;
|
|
@@ -506,7 +446,7 @@ runners.registerWorker("integration.sink.post.v1", async (_m, input, ctx) => {
|
|
|
506
446
|
const itemsVal = isObject(input) && "items" in input ? input.items : void 0;
|
|
507
447
|
const itemsArray = isArray(itemsVal) ? itemsVal : void 0;
|
|
508
448
|
const items = itemsArray || (singleItem !== void 0 ? [singleItem] : []);
|
|
509
|
-
const prov =
|
|
449
|
+
const prov = getProvider(providerId);
|
|
510
450
|
if (!prov?.integration) throw new Error(`provider not found: ${providerId}`);
|
|
511
451
|
const secrets = {};
|
|
512
452
|
try {
|