@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,784 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getProvider
|
|
3
|
+
} from "./chunk-H3POJCFA.js";
|
|
4
|
+
import {
|
|
5
|
+
appendMeshSinkEvent
|
|
6
|
+
} from "./chunk-PWAHFID5.js";
|
|
7
|
+
import {
|
|
8
|
+
blendResonance,
|
|
9
|
+
cosineResonance,
|
|
10
|
+
hierarchicalResonance,
|
|
11
|
+
iqPhaseLockResonance,
|
|
12
|
+
phaseLockingValue,
|
|
13
|
+
phaseShift,
|
|
14
|
+
toIQ
|
|
15
|
+
} from "./chunk-WU4OTGJE.js";
|
|
16
|
+
import {
|
|
17
|
+
registerNode
|
|
18
|
+
} from "./chunk-OCLSAUCD.js";
|
|
19
|
+
import {
|
|
20
|
+
emitSignal
|
|
21
|
+
} from "./chunk-2WTYE4SW.js";
|
|
22
|
+
import {
|
|
23
|
+
Combinators,
|
|
24
|
+
createPAdicAddress
|
|
25
|
+
} from "./chunk-EXI3LJVJ.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
|
+
}
|
|
82
|
+
|
|
83
|
+
// ../../lib/terminals-tech/machines/hvm/bridge.ts
|
|
84
|
+
function calculateValuation(node) {
|
|
85
|
+
let valuation = 0;
|
|
86
|
+
valuation += node.inputs.length * 1;
|
|
87
|
+
if (node.type && node.type !== "any") {
|
|
88
|
+
valuation += 1;
|
|
89
|
+
}
|
|
90
|
+
if (node.outputs.length === 0) {
|
|
91
|
+
valuation += 0.5;
|
|
92
|
+
}
|
|
93
|
+
return valuation;
|
|
94
|
+
}
|
|
95
|
+
function reconcileGraphDepths(nodes) {
|
|
96
|
+
const depths = /* @__PURE__ */ new Map();
|
|
97
|
+
const nodeMap = new Map(nodes.map((n) => [n.id, n]));
|
|
98
|
+
function getDepth(id, visited = /* @__PURE__ */ new Set()) {
|
|
99
|
+
if (visited.has(id)) return 0;
|
|
100
|
+
if (depths.has(id)) return depths.get(id);
|
|
101
|
+
visited.add(id);
|
|
102
|
+
const node = nodeMap.get(id);
|
|
103
|
+
if (!node) return 0;
|
|
104
|
+
let maxParentDepth = -1;
|
|
105
|
+
for (const inputId of node.inputs) {
|
|
106
|
+
maxParentDepth = Math.max(maxParentDepth, getDepth(inputId, visited));
|
|
107
|
+
}
|
|
108
|
+
const localVal = node.type && node.type !== "any" ? 1 : 0;
|
|
109
|
+
const depth = maxParentDepth + 1 + localVal;
|
|
110
|
+
depths.set(id, depth);
|
|
111
|
+
visited.delete(id);
|
|
112
|
+
return depth;
|
|
113
|
+
}
|
|
114
|
+
nodes.forEach((n) => getDepth(n.id));
|
|
115
|
+
return depths;
|
|
116
|
+
}
|
|
117
|
+
var TWO_PI = Math.PI * 2;
|
|
118
|
+
function addressPhase(addr) {
|
|
119
|
+
let x = 0;
|
|
120
|
+
for (let i = 0; i < addr.coefficients.length; i++) {
|
|
121
|
+
x += addr.coefficients[i] / Math.pow(addr.base, i + 1);
|
|
122
|
+
}
|
|
123
|
+
return x % 1 * TWO_PI;
|
|
124
|
+
}
|
|
125
|
+
function normalizeBiasValue(value) {
|
|
126
|
+
if (!Number.isFinite(value)) return 0;
|
|
127
|
+
return Math.max(-1, Math.min(1, value));
|
|
128
|
+
}
|
|
129
|
+
function hvmToLogitBias(trace, baseMagnitude = 0.15) {
|
|
130
|
+
const phase = addressPhase(trace.address);
|
|
131
|
+
const sin = Math.sin(phase);
|
|
132
|
+
const cos = Math.cos(phase);
|
|
133
|
+
const bias = {};
|
|
134
|
+
switch (trace.type) {
|
|
135
|
+
case Combinators.CONSTRUCT:
|
|
136
|
+
bias["control:decompose"] = normalizeBiasValue(baseMagnitude * sin);
|
|
137
|
+
bias["control:structure"] = normalizeBiasValue(baseMagnitude * 0.7);
|
|
138
|
+
break;
|
|
139
|
+
case Combinators.DUPLICATE:
|
|
140
|
+
bias["control:parallel"] = normalizeBiasValue(baseMagnitude * cos);
|
|
141
|
+
bias["control:branch"] = normalizeBiasValue(baseMagnitude * 0.6);
|
|
142
|
+
break;
|
|
143
|
+
case Combinators.ERASE:
|
|
144
|
+
bias["control:synthesize"] = normalizeBiasValue(baseMagnitude * sin);
|
|
145
|
+
bias["control:compress"] = normalizeBiasValue(baseMagnitude * 0.5);
|
|
146
|
+
break;
|
|
147
|
+
default:
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
const meta = trace.metadata;
|
|
151
|
+
const tokenHints = Array.isArray(meta?.tokenHints) ? meta?.tokenHints : [];
|
|
152
|
+
for (const hint of tokenHints) {
|
|
153
|
+
if (!bias[hint]) {
|
|
154
|
+
bias[hint] = normalizeBiasValue(baseMagnitude * 0.4);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return bias;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// ../../lib/terminals-tech/machines/core/nodes/hvm.proof.edgeCheck.ts
|
|
161
|
+
var HVM_PROOF_EDGE_CHECK_NODE_ID = "hvm.proof.edgeCheck.v1";
|
|
162
|
+
var manifest2 = {
|
|
163
|
+
id: HVM_PROOF_EDGE_CHECK_NODE_ID,
|
|
164
|
+
version: "0.1.0",
|
|
165
|
+
kind: "transform",
|
|
166
|
+
label: "HVM Edge Proof",
|
|
167
|
+
description: "Deterministic edge validation with p-adic proof trace.",
|
|
168
|
+
runtimes: ["worker"],
|
|
169
|
+
entrypoints: { worker: { module: "local" } },
|
|
170
|
+
inputsSchema: {
|
|
171
|
+
type: "object",
|
|
172
|
+
properties: {
|
|
173
|
+
graph: {
|
|
174
|
+
type: "object",
|
|
175
|
+
properties: {
|
|
176
|
+
nodes: {
|
|
177
|
+
type: "array",
|
|
178
|
+
items: {
|
|
179
|
+
type: "object",
|
|
180
|
+
properties: {
|
|
181
|
+
id: { type: "string" },
|
|
182
|
+
inputs: { type: "array", items: { type: "string" } },
|
|
183
|
+
outputs: { type: "array", items: { type: "string" } },
|
|
184
|
+
type: { type: "string" }
|
|
185
|
+
},
|
|
186
|
+
required: ["id", "inputs", "outputs"]
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
edges: {
|
|
190
|
+
type: "array",
|
|
191
|
+
items: {
|
|
192
|
+
type: "object",
|
|
193
|
+
properties: {
|
|
194
|
+
from: { type: "string" },
|
|
195
|
+
to: { type: "string" }
|
|
196
|
+
},
|
|
197
|
+
required: ["from", "to"]
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
required: ["nodes", "edges"]
|
|
202
|
+
},
|
|
203
|
+
candidate: {
|
|
204
|
+
type: "object",
|
|
205
|
+
properties: {
|
|
206
|
+
from: { type: "string" },
|
|
207
|
+
to: { type: "string" },
|
|
208
|
+
fromType: { type: "string" },
|
|
209
|
+
toType: { type: "string" }
|
|
210
|
+
},
|
|
211
|
+
required: ["from", "to"]
|
|
212
|
+
},
|
|
213
|
+
constraints: {
|
|
214
|
+
type: "object",
|
|
215
|
+
properties: {
|
|
216
|
+
disallowCycles: { type: "boolean" },
|
|
217
|
+
requireTypeMatch: { type: "boolean" }
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
required: ["graph", "candidate"]
|
|
222
|
+
},
|
|
223
|
+
outputsSchema: {
|
|
224
|
+
type: "object",
|
|
225
|
+
properties: {
|
|
226
|
+
ok: { type: "boolean" },
|
|
227
|
+
counterexample: { type: "string" },
|
|
228
|
+
suggestedAdapters: { type: "array", items: { type: "string" } },
|
|
229
|
+
valuation: { type: "number" },
|
|
230
|
+
depths: { type: "object" },
|
|
231
|
+
proofTrace: { type: "array", items: { type: "object" } },
|
|
232
|
+
logitBias: { type: "object" }
|
|
233
|
+
},
|
|
234
|
+
required: ["ok", "proofTrace"]
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
registerNode(manifest2);
|
|
238
|
+
function hasPath(edges, from, to, visited = /* @__PURE__ */ new Set()) {
|
|
239
|
+
if (from === to) return true;
|
|
240
|
+
if (visited.has(from)) return false;
|
|
241
|
+
visited.add(from);
|
|
242
|
+
const next = edges.filter((e) => e.from === from).map((e) => e.to);
|
|
243
|
+
for (const n of next) {
|
|
244
|
+
if (hasPath(edges, n, to, visited)) return true;
|
|
245
|
+
}
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
function slug(value) {
|
|
249
|
+
return value.toLowerCase().replace(/[^a-z0-9]+/g, "_").slice(0, 48);
|
|
250
|
+
}
|
|
251
|
+
async function executeHvmProofEdgeCheck(input, ctx) {
|
|
252
|
+
const typedInput = input;
|
|
253
|
+
const graph = typedInput.graph;
|
|
254
|
+
const candidate = typedInput.candidate;
|
|
255
|
+
const constraints = typedInput.constraints || {};
|
|
256
|
+
const proofTrace = [];
|
|
257
|
+
const nodeMap = new Map(graph.nodes.map((n) => [n.id, n]));
|
|
258
|
+
let ok = true;
|
|
259
|
+
let counterexample;
|
|
260
|
+
let suggestedAdapters = [];
|
|
261
|
+
const fromNode = nodeMap.get(candidate.from);
|
|
262
|
+
const toNode = nodeMap.get(candidate.to);
|
|
263
|
+
if (!fromNode || !toNode) {
|
|
264
|
+
ok = false;
|
|
265
|
+
counterexample = "Missing source or target node";
|
|
266
|
+
proofTrace.push({
|
|
267
|
+
step: "node_presence",
|
|
268
|
+
message: counterexample
|
|
269
|
+
});
|
|
270
|
+
} else {
|
|
271
|
+
proofTrace.push({
|
|
272
|
+
step: "node_presence",
|
|
273
|
+
message: "Both nodes present",
|
|
274
|
+
data: { from: fromNode.id, to: toNode.id }
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
if (ok && constraints.requireTypeMatch) {
|
|
278
|
+
const fromType = candidate.fromType || fromNode?.type || "any";
|
|
279
|
+
const toType = candidate.toType || toNode?.type || "any";
|
|
280
|
+
if (fromType !== "any" && toType !== "any" && fromType !== toType) {
|
|
281
|
+
ok = false;
|
|
282
|
+
counterexample = `Type mismatch: ${fromType} \u2192 ${toType}`;
|
|
283
|
+
suggestedAdapters = ["transform.object.pickPath.v1"];
|
|
284
|
+
proofTrace.push({
|
|
285
|
+
step: "type_check",
|
|
286
|
+
message: counterexample,
|
|
287
|
+
data: { fromType, toType }
|
|
288
|
+
});
|
|
289
|
+
} else {
|
|
290
|
+
proofTrace.push({
|
|
291
|
+
step: "type_check",
|
|
292
|
+
message: "Type compatibility satisfied",
|
|
293
|
+
data: { fromType, toType }
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
if (ok && constraints.disallowCycles) {
|
|
298
|
+
const wouldCycle = hasPath(graph.edges, candidate.to, candidate.from);
|
|
299
|
+
if (wouldCycle) {
|
|
300
|
+
ok = false;
|
|
301
|
+
counterexample = "Cycle detected in candidate edge";
|
|
302
|
+
proofTrace.push({
|
|
303
|
+
step: "cycle_check",
|
|
304
|
+
message: counterexample
|
|
305
|
+
});
|
|
306
|
+
} else {
|
|
307
|
+
proofTrace.push({
|
|
308
|
+
step: "cycle_check",
|
|
309
|
+
message: "No cycle detected"
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
const bridgeNodes = graph.nodes.map((node) => ({
|
|
314
|
+
...node,
|
|
315
|
+
type: node.type || "any"
|
|
316
|
+
}));
|
|
317
|
+
const valuation = toNode ? calculateValuation({ ...toNode, type: toNode.type || "any" }) : 0;
|
|
318
|
+
const depths = reconcileGraphDepths(bridgeNodes);
|
|
319
|
+
const depthMap = {};
|
|
320
|
+
depths.forEach((v, k) => {
|
|
321
|
+
depthMap[k] = v;
|
|
322
|
+
});
|
|
323
|
+
proofTrace.push({
|
|
324
|
+
step: "valuation",
|
|
325
|
+
message: `Valuation computed (${valuation})`,
|
|
326
|
+
data: { valuation, depth: depthMap[candidate.to] }
|
|
327
|
+
});
|
|
328
|
+
const eventType = ok ? Combinators.CONSTRUCT : suggestedAdapters.length ? Combinators.DUPLICATE : Combinators.ERASE;
|
|
329
|
+
const combinatorEvent = {
|
|
330
|
+
type: eventType,
|
|
331
|
+
address: createPAdicAddress(2, [Math.max(0, depthMap[candidate.to] || 0) % 2]),
|
|
332
|
+
timestamp: Date.now(),
|
|
333
|
+
metadata: {
|
|
334
|
+
tokenHints: ok ? ["control:structure"] : ["control:compress"]
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
const logitBias = hvmToLogitBias(combinatorEvent, 0.15);
|
|
338
|
+
const tracePath = `proofs.${slug(ctx.stackId)}.${slug(
|
|
339
|
+
ctx.nodeId
|
|
340
|
+
)}.${slug(candidate.from)}_${slug(candidate.to)}`;
|
|
341
|
+
await appendMeshSinkEvent({
|
|
342
|
+
tracePath,
|
|
343
|
+
payload: {
|
|
344
|
+
ok,
|
|
345
|
+
counterexample,
|
|
346
|
+
suggestedAdapters,
|
|
347
|
+
valuation,
|
|
348
|
+
depths: depthMap,
|
|
349
|
+
proofTrace,
|
|
350
|
+
candidate
|
|
351
|
+
},
|
|
352
|
+
logId: `proofs-${ctx.stackId}`,
|
|
353
|
+
typeOverride: "proof.edgeCheck"
|
|
354
|
+
});
|
|
355
|
+
return {
|
|
356
|
+
ok,
|
|
357
|
+
counterexample,
|
|
358
|
+
suggestedAdapters,
|
|
359
|
+
valuation,
|
|
360
|
+
depths: depthMap,
|
|
361
|
+
proofTrace,
|
|
362
|
+
logitBias
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// ../../lib/terminals-tech/machines/core/nodes/compute.bend.ts
|
|
367
|
+
var COMPUTE_BEND_NODE_ID = "compute.bend.v1";
|
|
368
|
+
var manifest3 = {
|
|
369
|
+
id: COMPUTE_BEND_NODE_ID,
|
|
370
|
+
version: "0.1.0",
|
|
371
|
+
kind: "task",
|
|
372
|
+
label: "Bend Compute",
|
|
373
|
+
description: "Execute a precompiled Bend/HVM module (.hvm or .wasm).",
|
|
374
|
+
runtimes: ["worker"],
|
|
375
|
+
entrypoints: { worker: { module: "local" } },
|
|
376
|
+
inputsSchema: {
|
|
377
|
+
type: "object",
|
|
378
|
+
properties: {
|
|
379
|
+
hvmModule: {
|
|
380
|
+
type: "string",
|
|
381
|
+
description: "Path to .hvm or .wasm module (e.g. /wasm/hvm/agent-logic.hvm)"
|
|
382
|
+
},
|
|
383
|
+
bendPath: {
|
|
384
|
+
type: "string",
|
|
385
|
+
description: "Optional .bend path (compile to .hvm/.wasm before execution)"
|
|
386
|
+
},
|
|
387
|
+
bendSource: {
|
|
388
|
+
type: "string",
|
|
389
|
+
description: "Inline Bend source (compile to .hvm/.wasm before execution)"
|
|
390
|
+
},
|
|
391
|
+
payload: {
|
|
392
|
+
type: "object",
|
|
393
|
+
description: "Input payload passed to the HVM module",
|
|
394
|
+
additionalProperties: true
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
},
|
|
398
|
+
outputsSchema: {
|
|
399
|
+
type: "object",
|
|
400
|
+
properties: {
|
|
401
|
+
ok: { type: "boolean" },
|
|
402
|
+
module: { type: "string" },
|
|
403
|
+
result: {},
|
|
404
|
+
_hvm: { type: "object" },
|
|
405
|
+
error: { type: "string" },
|
|
406
|
+
hint: { type: "string" }
|
|
407
|
+
},
|
|
408
|
+
required: ["ok"]
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
registerNode(manifest3);
|
|
412
|
+
async function executeBendCompute(input, ctx) {
|
|
413
|
+
const rawModule = String(input.hvmModule || "");
|
|
414
|
+
const bendPath = String(input.bendPath || "");
|
|
415
|
+
const bendSource = String(input.bendSource || "");
|
|
416
|
+
const payload = input.payload || {};
|
|
417
|
+
const moduleFromBendPath = bendPath ? bendPath.endsWith(".bend") ? `/wasm/hvm/${(bendPath.split("/").pop() || "module").replace(/\.bend$/, "")}.hvm` : bendPath : "";
|
|
418
|
+
const hvmModule = rawModule || moduleFromBendPath;
|
|
419
|
+
if (!hvmModule) {
|
|
420
|
+
return {
|
|
421
|
+
ok: false,
|
|
422
|
+
error: "No HVM module provided",
|
|
423
|
+
hint: "Compile a .bend file (scripts/compile-hvm.sh or /api/platform/hvm/compile) and set hvmModule to /wasm/hvm/<file>.hvm or .wasm.",
|
|
424
|
+
bendSource: bendSource ? "present" : "absent"
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
const { runInHVM } = await import("./hvm-CBEP3M4F.js");
|
|
428
|
+
const manifestOverride = {
|
|
429
|
+
id: COMPUTE_BEND_NODE_ID,
|
|
430
|
+
version: "0.1.0",
|
|
431
|
+
kind: "task",
|
|
432
|
+
runtimes: ["wasm-hvm"],
|
|
433
|
+
entrypoints: { "wasm-hvm": { module: hvmModule } }
|
|
434
|
+
};
|
|
435
|
+
const output = await runInHVM(manifestOverride, payload, ctx);
|
|
436
|
+
return {
|
|
437
|
+
ok: !output?.error,
|
|
438
|
+
module: hvmModule,
|
|
439
|
+
result: output?.result ?? output,
|
|
440
|
+
_hvm: output?._hvm,
|
|
441
|
+
error: output?.error
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
// ../../lib/terminals-tech/machines/core/nodes/system.signal.emit.ts
|
|
446
|
+
var SYSTEM_SIGNAL_EMIT_NODE_ID = "system.signal.emit.v1";
|
|
447
|
+
var SIGNAL_TYPES = [
|
|
448
|
+
"health_update",
|
|
449
|
+
"circuit_change",
|
|
450
|
+
"convergence_update",
|
|
451
|
+
"coherence_update",
|
|
452
|
+
"resonance_update",
|
|
453
|
+
"task_complete",
|
|
454
|
+
"task_failed",
|
|
455
|
+
"adaptation_required",
|
|
456
|
+
"backpressure_warning",
|
|
457
|
+
"mesh_update",
|
|
458
|
+
"mesh_query",
|
|
459
|
+
"session_state_change"
|
|
460
|
+
];
|
|
461
|
+
var LAYERS = ["L1", "L2", "L3", "L4", "L5"];
|
|
462
|
+
registerNode({
|
|
463
|
+
id: SYSTEM_SIGNAL_EMIT_NODE_ID,
|
|
464
|
+
version: "0.1.0",
|
|
465
|
+
kind: "task",
|
|
466
|
+
label: "Emit Signal",
|
|
467
|
+
description: "Emits an AXON signal (cross-layer) on the global signal bus.",
|
|
468
|
+
runtimes: ["worker"],
|
|
469
|
+
entrypoints: { worker: { module: "local" } },
|
|
470
|
+
metadata: {
|
|
471
|
+
tags: ["axon", "signals", "observability"]
|
|
472
|
+
},
|
|
473
|
+
inputsSchema: {
|
|
474
|
+
type: "object",
|
|
475
|
+
properties: {
|
|
476
|
+
type: { type: "string", enum: SIGNAL_TYPES },
|
|
477
|
+
source: { type: "string", enum: LAYERS },
|
|
478
|
+
target: { type: "string", enum: LAYERS },
|
|
479
|
+
payload: { type: "object" },
|
|
480
|
+
correlationId: { type: "string" }
|
|
481
|
+
},
|
|
482
|
+
required: ["type", "source", "target", "payload"]
|
|
483
|
+
},
|
|
484
|
+
outputsSchema: {
|
|
485
|
+
type: "object",
|
|
486
|
+
properties: {
|
|
487
|
+
emitted: { type: "boolean" },
|
|
488
|
+
signalId: { type: "string" },
|
|
489
|
+
timestamp: { type: "number" },
|
|
490
|
+
correlationId: { type: "string" }
|
|
491
|
+
},
|
|
492
|
+
required: ["emitted", "signalId", "timestamp"]
|
|
493
|
+
}
|
|
494
|
+
});
|
|
495
|
+
function isLayer(x) {
|
|
496
|
+
return typeof x === "string" && LAYERS.includes(x);
|
|
497
|
+
}
|
|
498
|
+
function isSignalType(x) {
|
|
499
|
+
return typeof x === "string" && SIGNAL_TYPES.includes(x);
|
|
500
|
+
}
|
|
501
|
+
async function executeSystemSignalEmit(input, ctx = {}) {
|
|
502
|
+
const typeRaw = input?.type;
|
|
503
|
+
const sourceRaw = input?.source;
|
|
504
|
+
const targetRaw = input?.target;
|
|
505
|
+
const payload = input?.payload;
|
|
506
|
+
const correlationId = typeof input?.correlationId === "string" ? input.correlationId : ctx.stackId || void 0;
|
|
507
|
+
if (!isSignalType(typeRaw)) {
|
|
508
|
+
throw new Error(`Invalid signal type: ${String(typeRaw)}`);
|
|
509
|
+
}
|
|
510
|
+
if (!isLayer(sourceRaw)) {
|
|
511
|
+
throw new Error(`Invalid source layer: ${String(sourceRaw)}`);
|
|
512
|
+
}
|
|
513
|
+
if (!isLayer(targetRaw)) {
|
|
514
|
+
throw new Error(`Invalid target layer: ${String(targetRaw)}`);
|
|
515
|
+
}
|
|
516
|
+
const signal = emitSignal(typeRaw, sourceRaw, targetRaw, payload, correlationId);
|
|
517
|
+
return {
|
|
518
|
+
emitted: true,
|
|
519
|
+
signalId: signal.id,
|
|
520
|
+
timestamp: signal.timestamp,
|
|
521
|
+
correlationId: signal.correlationId
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
// ../../lib/terminals-tech/machines/core/nodes/resonance.quadrature.ts
|
|
526
|
+
var BASE_RESONANCE_IQ_ENCODE_NODE_ID = "base.resonance.iq.encode.v1";
|
|
527
|
+
var BASE_RESONANCE_IQ_PHASE_SHIFT_NODE_ID = "base.resonance.iq.phaseShift.v1";
|
|
528
|
+
var BASE_RESONANCE_METRICS_NODE_ID = "base.resonance.metrics.v1";
|
|
529
|
+
var BASE_PHASE_LOCKING_VALUE_NODE_ID = "base.phase.plv.v1";
|
|
530
|
+
var PARADIGM_METADATA = {
|
|
531
|
+
paradigms: ["resonant-quadrature"],
|
|
532
|
+
tags: ["iq", "phase", "resonance", "phase-lock"]
|
|
533
|
+
};
|
|
534
|
+
var IQ_SCHEMA = {
|
|
535
|
+
type: "object",
|
|
536
|
+
properties: {
|
|
537
|
+
inPhase: { type: "array", items: { type: "number" } },
|
|
538
|
+
quadrature: { type: "array", items: { type: "number" } }
|
|
539
|
+
},
|
|
540
|
+
required: ["inPhase", "quadrature"]
|
|
541
|
+
};
|
|
542
|
+
var VEC_SCHEMA = { type: "array", items: { type: "number" } };
|
|
543
|
+
registerNode({
|
|
544
|
+
id: BASE_RESONANCE_IQ_ENCODE_NODE_ID,
|
|
545
|
+
version: "0.1.0",
|
|
546
|
+
kind: "transform",
|
|
547
|
+
label: "IQ Encode",
|
|
548
|
+
description: "Encode a real vector into a deterministic I/Q embedding.",
|
|
549
|
+
runtimes: ["worker"],
|
|
550
|
+
entrypoints: { worker: { module: "local" } },
|
|
551
|
+
metadata: PARADIGM_METADATA,
|
|
552
|
+
inputsSchema: {
|
|
553
|
+
type: "object",
|
|
554
|
+
properties: {
|
|
555
|
+
vector: VEC_SCHEMA,
|
|
556
|
+
mode: {
|
|
557
|
+
type: "string",
|
|
558
|
+
enum: ["orthogonalTransform", "dualEncoder"],
|
|
559
|
+
description: "Encoding mode. 'dualEncoder' is reserved and will error until implemented."
|
|
560
|
+
},
|
|
561
|
+
normalizePair: { type: "boolean" }
|
|
562
|
+
},
|
|
563
|
+
required: ["vector"]
|
|
564
|
+
},
|
|
565
|
+
outputsSchema: {
|
|
566
|
+
type: "object",
|
|
567
|
+
properties: { iq: IQ_SCHEMA },
|
|
568
|
+
required: ["iq"]
|
|
569
|
+
}
|
|
570
|
+
});
|
|
571
|
+
registerNode({
|
|
572
|
+
id: BASE_RESONANCE_IQ_PHASE_SHIFT_NODE_ID,
|
|
573
|
+
version: "0.1.0",
|
|
574
|
+
kind: "transform",
|
|
575
|
+
label: "IQ Phase Shift",
|
|
576
|
+
description: "Apply a global phase rotation \u0394 to an I/Q embedding.",
|
|
577
|
+
runtimes: ["worker"],
|
|
578
|
+
entrypoints: { worker: { module: "local" } },
|
|
579
|
+
metadata: PARADIGM_METADATA,
|
|
580
|
+
inputsSchema: {
|
|
581
|
+
type: "object",
|
|
582
|
+
properties: {
|
|
583
|
+
iq: IQ_SCHEMA,
|
|
584
|
+
delta: { type: "number", description: "Phase rotation \u0394 in radians." }
|
|
585
|
+
},
|
|
586
|
+
required: ["iq", "delta"]
|
|
587
|
+
},
|
|
588
|
+
outputsSchema: {
|
|
589
|
+
type: "object",
|
|
590
|
+
properties: { iq: IQ_SCHEMA },
|
|
591
|
+
required: ["iq"]
|
|
592
|
+
}
|
|
593
|
+
});
|
|
594
|
+
registerNode({
|
|
595
|
+
id: BASE_RESONANCE_METRICS_NODE_ID,
|
|
596
|
+
version: "0.1.0",
|
|
597
|
+
kind: "transform",
|
|
598
|
+
label: "Resonance Metrics",
|
|
599
|
+
description: "Compute semantic/hierarchical/phase-lock resonance components and blend into systemResonance.",
|
|
600
|
+
runtimes: ["worker"],
|
|
601
|
+
entrypoints: { worker: { module: "local" } },
|
|
602
|
+
metadata: PARADIGM_METADATA,
|
|
603
|
+
inputsSchema: {
|
|
604
|
+
type: "object",
|
|
605
|
+
properties: {
|
|
606
|
+
a: VEC_SCHEMA,
|
|
607
|
+
b: VEC_SCHEMA,
|
|
608
|
+
aIQ: IQ_SCHEMA,
|
|
609
|
+
bIQ: IQ_SCHEMA,
|
|
610
|
+
weights: {
|
|
611
|
+
type: "object",
|
|
612
|
+
properties: {
|
|
613
|
+
semantic: { type: "number" },
|
|
614
|
+
hierarchical: { type: "number" },
|
|
615
|
+
phaseLock: { type: "number" }
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
},
|
|
619
|
+
required: ["a", "b"]
|
|
620
|
+
},
|
|
621
|
+
outputsSchema: {
|
|
622
|
+
type: "object",
|
|
623
|
+
properties: {
|
|
624
|
+
metrics: {
|
|
625
|
+
type: "object",
|
|
626
|
+
properties: {
|
|
627
|
+
semantic: { type: "number" },
|
|
628
|
+
hierarchical: { type: "number" },
|
|
629
|
+
phaseLock: { type: "number" },
|
|
630
|
+
systemResonance: { type: "number" },
|
|
631
|
+
timestamp: { type: "number" }
|
|
632
|
+
},
|
|
633
|
+
required: [
|
|
634
|
+
"semantic",
|
|
635
|
+
"hierarchical",
|
|
636
|
+
"phaseLock",
|
|
637
|
+
"systemResonance",
|
|
638
|
+
"timestamp"
|
|
639
|
+
]
|
|
640
|
+
}
|
|
641
|
+
},
|
|
642
|
+
required: ["metrics"]
|
|
643
|
+
}
|
|
644
|
+
});
|
|
645
|
+
registerNode({
|
|
646
|
+
id: BASE_PHASE_LOCKING_VALUE_NODE_ID,
|
|
647
|
+
version: "0.1.0",
|
|
648
|
+
kind: "transform",
|
|
649
|
+
label: "Phase Locking Value (PLV)",
|
|
650
|
+
description: "Compute PLV between two phase sequences (0..1).",
|
|
651
|
+
runtimes: ["worker"],
|
|
652
|
+
entrypoints: { worker: { module: "local" } },
|
|
653
|
+
metadata: PARADIGM_METADATA,
|
|
654
|
+
inputsSchema: {
|
|
655
|
+
type: "object",
|
|
656
|
+
properties: {
|
|
657
|
+
phiA: { type: "array", items: { type: "number" } },
|
|
658
|
+
phiB: { type: "array", items: { type: "number" } }
|
|
659
|
+
},
|
|
660
|
+
required: ["phiA", "phiB"]
|
|
661
|
+
},
|
|
662
|
+
outputsSchema: {
|
|
663
|
+
type: "object",
|
|
664
|
+
properties: { plv: { type: "number" } },
|
|
665
|
+
required: ["plv"]
|
|
666
|
+
}
|
|
667
|
+
});
|
|
668
|
+
async function executeIqEncode(inputs) {
|
|
669
|
+
const vector = Array.isArray(inputs?.vector) ? inputs.vector : [];
|
|
670
|
+
const mode = inputs?.mode;
|
|
671
|
+
const iqMode = mode === "orthogonalTransform" || mode === "dualEncoder" ? mode : void 0;
|
|
672
|
+
const normalizePair = Boolean(inputs?.normalizePair);
|
|
673
|
+
const iq = toIQ(vector, { mode: iqMode, normalizePair });
|
|
674
|
+
return { iq: { inPhase: Array.from(iq.inPhase), quadrature: Array.from(iq.quadrature) } };
|
|
675
|
+
}
|
|
676
|
+
async function executeIqPhaseShift(inputs) {
|
|
677
|
+
const iqIn = inputs?.iq;
|
|
678
|
+
const inPhase = Array.isArray(iqIn?.inPhase) ? iqIn.inPhase : [];
|
|
679
|
+
const quadrature = Array.isArray(iqIn?.quadrature) ? iqIn.quadrature : [];
|
|
680
|
+
const delta = Number(inputs?.delta ?? 0);
|
|
681
|
+
const shifted = phaseShift(
|
|
682
|
+
{ inPhase: new Float32Array(inPhase), quadrature: new Float32Array(quadrature) },
|
|
683
|
+
delta
|
|
684
|
+
);
|
|
685
|
+
return {
|
|
686
|
+
iq: { inPhase: Array.from(shifted.inPhase), quadrature: Array.from(shifted.quadrature) }
|
|
687
|
+
};
|
|
688
|
+
}
|
|
689
|
+
async function executeResonanceMetrics(inputs) {
|
|
690
|
+
const a = Array.isArray(inputs?.a) ? inputs.a : [];
|
|
691
|
+
const b = Array.isArray(inputs?.b) ? inputs.b : [];
|
|
692
|
+
const semantic = cosineResonance(a, b);
|
|
693
|
+
const hierarchical = hierarchicalResonance(a, b);
|
|
694
|
+
let phaseLock = 0;
|
|
695
|
+
if (inputs?.aIQ && inputs?.bIQ) {
|
|
696
|
+
const aIQ = inputs.aIQ;
|
|
697
|
+
const bIQ = inputs.bIQ;
|
|
698
|
+
if (Array.isArray(aIQ?.inPhase) && Array.isArray(aIQ?.quadrature) && Array.isArray(bIQ?.inPhase) && Array.isArray(bIQ?.quadrature)) {
|
|
699
|
+
phaseLock = iqPhaseLockResonance(
|
|
700
|
+
{
|
|
701
|
+
inPhase: new Float32Array(aIQ.inPhase),
|
|
702
|
+
quadrature: new Float32Array(aIQ.quadrature)
|
|
703
|
+
},
|
|
704
|
+
{
|
|
705
|
+
inPhase: new Float32Array(bIQ.inPhase),
|
|
706
|
+
quadrature: new Float32Array(bIQ.quadrature)
|
|
707
|
+
}
|
|
708
|
+
);
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
const weights = inputs?.weights || {};
|
|
712
|
+
const systemResonance = blendResonance({ semantic, hierarchical, phaseLock }, weights);
|
|
713
|
+
return {
|
|
714
|
+
metrics: {
|
|
715
|
+
semantic,
|
|
716
|
+
hierarchical,
|
|
717
|
+
phaseLock,
|
|
718
|
+
systemResonance,
|
|
719
|
+
timestamp: Date.now()
|
|
720
|
+
}
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
async function executePhaseLockingValueNode(inputs) {
|
|
724
|
+
const phiA = Array.isArray(inputs?.phiA) ? inputs.phiA : [];
|
|
725
|
+
const phiB = Array.isArray(inputs?.phiB) ? inputs.phiB : [];
|
|
726
|
+
const plv = phaseLockingValue(phiA, phiB);
|
|
727
|
+
return { plv };
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
// ../../lib/terminals-tech/machines/core/nodes/system.schedule.ts
|
|
731
|
+
var SYSTEM_SCHEDULE_NODE_ID = "system.schedule.v1";
|
|
732
|
+
var manifest4 = {
|
|
733
|
+
id: SYSTEM_SCHEDULE_NODE_ID,
|
|
734
|
+
version: "0.1.0",
|
|
735
|
+
kind: "task",
|
|
736
|
+
label: "Schedule",
|
|
737
|
+
description: "Schedules a stack to run at a fixed interval (seconds).",
|
|
738
|
+
runtimes: ["worker"],
|
|
739
|
+
entrypoints: { worker: { module: "local" } },
|
|
740
|
+
inputsSchema: {
|
|
741
|
+
type: "object",
|
|
742
|
+
properties: {
|
|
743
|
+
everySeconds: { type: "number", description: "Interval in seconds" },
|
|
744
|
+
enabled: { type: "boolean" }
|
|
745
|
+
},
|
|
746
|
+
required: ["everySeconds"]
|
|
747
|
+
},
|
|
748
|
+
outputsSchema: {
|
|
749
|
+
type: "object",
|
|
750
|
+
properties: {
|
|
751
|
+
scheduled: { type: "boolean" },
|
|
752
|
+
everySeconds: { type: "number" }
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
};
|
|
756
|
+
registerNode(manifest4);
|
|
757
|
+
async function executeSystemSchedule(_input, ctx) {
|
|
758
|
+
const { scheduleStack } = await import("./scheduler-B5CEYKWT.js");
|
|
759
|
+
const everySeconds = Math.max(1, Number(_input.everySeconds || 60));
|
|
760
|
+
const enabled = Boolean(_input.enabled ?? true);
|
|
761
|
+
if (enabled) await scheduleStack(ctx.stackId, everySeconds);
|
|
762
|
+
return { scheduled: enabled, everySeconds };
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
export {
|
|
766
|
+
PROVIDER_CHAT_NODE_ID,
|
|
767
|
+
executeProviderChat,
|
|
768
|
+
HVM_PROOF_EDGE_CHECK_NODE_ID,
|
|
769
|
+
executeHvmProofEdgeCheck,
|
|
770
|
+
COMPUTE_BEND_NODE_ID,
|
|
771
|
+
executeBendCompute,
|
|
772
|
+
SYSTEM_SIGNAL_EMIT_NODE_ID,
|
|
773
|
+
executeSystemSignalEmit,
|
|
774
|
+
BASE_RESONANCE_IQ_ENCODE_NODE_ID,
|
|
775
|
+
BASE_RESONANCE_IQ_PHASE_SHIFT_NODE_ID,
|
|
776
|
+
BASE_RESONANCE_METRICS_NODE_ID,
|
|
777
|
+
BASE_PHASE_LOCKING_VALUE_NODE_ID,
|
|
778
|
+
executeIqEncode,
|
|
779
|
+
executeIqPhaseShift,
|
|
780
|
+
executeResonanceMetrics,
|
|
781
|
+
executePhaseLockingValueNode,
|
|
782
|
+
SYSTEM_SCHEDULE_NODE_ID,
|
|
783
|
+
executeSystemSchedule
|
|
784
|
+
};
|