@terminals-tech/sdk 1.0.0-rc.1 → 1.0.0-rc.2
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/dist/WebContainerManager-SHXC5VKI.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-3CEM77QZ.js +474 -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-BKB3MD5Y.js +723 -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-KHR7ZYCX.js +4034 -0
- package/dist/chunk-NTMBOESX.js +152 -0
- package/dist/chunk-OSSRZOGC.js +190 -0
- package/dist/chunk-PUZ2S62E.js +977 -0
- package/dist/chunk-PWAHFID5.js +381 -0
- package/dist/chunk-Q2VI6ICE.js +188 -0
- package/dist/chunk-Q4B7YS7T.js +557 -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-SHPGIVDH.js +5521 -0
- package/dist/chunk-TSQ3BGLA.js +11945 -0
- package/dist/chunk-UJDUQNE2.js +79 -0
- package/dist/chunk-UKVUPKZP.js +296 -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-KQX3NMPY.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-VXMGMJNK.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-DRQK2MUT.js +126 -0
- package/dist/index.cjs +11706 -4004
- package/dist/index.d.cts +1299 -1339
- package/dist/index.d.ts +1299 -1339
- package/dist/index.js +189 -7938
- 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-DXKYDTVO.js +224 -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/pgliteService-IUGNNOVU.js +258 -0
- package/dist/policy-IRJCM6FS.js +13 -0
- package/dist/registry-BL3TDQDB.js +26 -0
- package/dist/registry-FW63E7FE.js +16 -0
- package/dist/registry-ZQ2IBLF6.js +9 -0
- package/dist/scheduler-H6Q53IMI.js +122 -0
- package/dist/secret-store-H7273UIT.js +18 -0
- package/dist/server-7DM74VFW.js +18 -0
- package/dist/skills-KLTTT2RM.js +6375 -0
- package/dist/stack-CHDAFU2S.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-3LDJVIIL.js +281 -0
- package/package.json +2 -2
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
// ../../lib/terminals-tech/core/primitives/interaction.ts
|
|
2
|
+
function createInteractionId() {
|
|
3
|
+
return `int_${crypto.randomUUID()}`;
|
|
4
|
+
}
|
|
5
|
+
var InteractionBuilder = class {
|
|
6
|
+
interaction;
|
|
7
|
+
/**
|
|
8
|
+
* Create a new InteractionBuilder.
|
|
9
|
+
*
|
|
10
|
+
* @param type - The interaction classification
|
|
11
|
+
*/
|
|
12
|
+
constructor(type) {
|
|
13
|
+
this.interaction = {
|
|
14
|
+
id: createInteractionId(),
|
|
15
|
+
type,
|
|
16
|
+
status: "initiated",
|
|
17
|
+
participants: [],
|
|
18
|
+
childIds: [],
|
|
19
|
+
createdAt: Date.now(),
|
|
20
|
+
labels: [],
|
|
21
|
+
exitCriteria: []
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Set the domain-specific context.
|
|
26
|
+
*/
|
|
27
|
+
withContext(context) {
|
|
28
|
+
this.interaction.context = context;
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Add a participant to the interaction.
|
|
33
|
+
*
|
|
34
|
+
* @param address - Universal address of the participant
|
|
35
|
+
* @param role - Role within the interaction
|
|
36
|
+
* @param metadata - Optional participant metadata
|
|
37
|
+
*/
|
|
38
|
+
addParticipant(address, role, metadata) {
|
|
39
|
+
const participant = {
|
|
40
|
+
address,
|
|
41
|
+
role,
|
|
42
|
+
joinedAt: Date.now(),
|
|
43
|
+
metadata
|
|
44
|
+
};
|
|
45
|
+
this.interaction.participants.push(participant);
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Set the parent interaction for nesting.
|
|
50
|
+
*/
|
|
51
|
+
withParent(parentId) {
|
|
52
|
+
this.interaction.parentId = parentId;
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Add categorical labels for filtering.
|
|
57
|
+
*/
|
|
58
|
+
addLabel(...labels) {
|
|
59
|
+
this.interaction.labels.push(...labels);
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Add an exit criterion for workflow completion.
|
|
64
|
+
*
|
|
65
|
+
* @param description - Human-readable description
|
|
66
|
+
* @param condition - Expression or description of the condition
|
|
67
|
+
*/
|
|
68
|
+
addExitCriterion(description, condition) {
|
|
69
|
+
this.interaction.exitCriteria.push({
|
|
70
|
+
id: crypto.randomUUID(),
|
|
71
|
+
description,
|
|
72
|
+
condition,
|
|
73
|
+
met: false
|
|
74
|
+
});
|
|
75
|
+
return this;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Set semantic embedding for search.
|
|
79
|
+
*/
|
|
80
|
+
withEmbedding(embedding) {
|
|
81
|
+
this.interaction.embedding = embedding;
|
|
82
|
+
return this;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Set the monotonic ordinal for strict action sequencing.
|
|
86
|
+
*/
|
|
87
|
+
withOrdinal(ordinal) {
|
|
88
|
+
this.interaction.ordinal = ordinal;
|
|
89
|
+
return this;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Track cognitive entropy (uncertainty/complexity) for UI resonance.
|
|
93
|
+
*/
|
|
94
|
+
withEntropy(entropy) {
|
|
95
|
+
this.interaction.entropy = entropy;
|
|
96
|
+
return this;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Track token momentum (generation speed/derivative of attention).
|
|
100
|
+
*/
|
|
101
|
+
withMomentum(momentum) {
|
|
102
|
+
this.interaction.momentum = momentum;
|
|
103
|
+
return this;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Set custom metadata.
|
|
107
|
+
*/
|
|
108
|
+
withMetadata(metadata) {
|
|
109
|
+
this.interaction.metadata = metadata;
|
|
110
|
+
return this;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Override the generated ID (use sparingly).
|
|
114
|
+
*/
|
|
115
|
+
withId(id) {
|
|
116
|
+
if (!id.startsWith("int_")) {
|
|
117
|
+
throw new Error('Interaction ID must start with "int_"');
|
|
118
|
+
}
|
|
119
|
+
this.interaction.id = id;
|
|
120
|
+
return this;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Set custom creation timestamp (use for testing/replay).
|
|
124
|
+
*/
|
|
125
|
+
withCreatedAt(timestamp) {
|
|
126
|
+
this.interaction.createdAt = timestamp;
|
|
127
|
+
return this;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Build and return the Interaction.
|
|
131
|
+
*
|
|
132
|
+
* @throws Error if no participants have been added
|
|
133
|
+
* @returns The constructed Interaction
|
|
134
|
+
*/
|
|
135
|
+
build() {
|
|
136
|
+
if (!this.interaction.participants?.length) {
|
|
137
|
+
throw new Error("Interaction must have at least one participant");
|
|
138
|
+
}
|
|
139
|
+
if (!("context" in this.interaction)) {
|
|
140
|
+
this.interaction.context = void 0;
|
|
141
|
+
}
|
|
142
|
+
return this.interaction;
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
function transitionStatus(interaction, newStatus) {
|
|
146
|
+
const updates = { status: newStatus };
|
|
147
|
+
if (newStatus === "active" && !interaction.startedAt) {
|
|
148
|
+
updates.startedAt = Date.now();
|
|
149
|
+
}
|
|
150
|
+
if (["completed", "failed", "cancelled"].includes(newStatus) && !interaction.completedAt) {
|
|
151
|
+
updates.completedAt = Date.now();
|
|
152
|
+
}
|
|
153
|
+
return { ...interaction, ...updates };
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// ../../lib/terminals-tech/core/primitives/interaction-lifecycle.ts
|
|
157
|
+
function buildLifecycleEvent(type, payload) {
|
|
158
|
+
return { type, payload };
|
|
159
|
+
}
|
|
160
|
+
function createInteractionWithEvents(input, options = {}) {
|
|
161
|
+
const type = input.type ?? "workflow";
|
|
162
|
+
const status = input.status ?? "initiated";
|
|
163
|
+
const builder = new InteractionBuilder(type);
|
|
164
|
+
if (input.id) {
|
|
165
|
+
builder.withId(input.id);
|
|
166
|
+
}
|
|
167
|
+
if (input.parentId) {
|
|
168
|
+
builder.withParent(input.parentId);
|
|
169
|
+
}
|
|
170
|
+
if (input.participants && input.participants.length > 0) {
|
|
171
|
+
input.participants.forEach((p) => builder.addParticipant(p.address, p.role, p.metadata));
|
|
172
|
+
} else {
|
|
173
|
+
throw new Error("Interaction must include at least one participant");
|
|
174
|
+
}
|
|
175
|
+
if (input.labels && input.labels.length > 0) {
|
|
176
|
+
builder.addLabel(...input.labels);
|
|
177
|
+
}
|
|
178
|
+
builder.withContext(input.context);
|
|
179
|
+
let interaction = builder.build();
|
|
180
|
+
const events = [];
|
|
181
|
+
const createdEvent = buildLifecycleEvent("interaction:created", {
|
|
182
|
+
interaction,
|
|
183
|
+
sequence: options.sequence
|
|
184
|
+
});
|
|
185
|
+
events.push(createdEvent);
|
|
186
|
+
if (status !== "initiated") {
|
|
187
|
+
const transitioned = transitionStatus(interaction, status);
|
|
188
|
+
const resolvedTimestamp = options.timestamp ?? (status === "active" ? transitioned.startedAt : ["completed", "failed", "cancelled"].includes(status) ? transitioned.completedAt : void 0) ?? Date.now();
|
|
189
|
+
const statusEvent = buildLifecycleEvent("interaction:status_changed", {
|
|
190
|
+
interactionId: transitioned.id,
|
|
191
|
+
from: interaction.status,
|
|
192
|
+
to: transitioned.status,
|
|
193
|
+
at: resolvedTimestamp,
|
|
194
|
+
sequence: options.sequence !== void 0 ? options.sequence + 1 : void 0
|
|
195
|
+
});
|
|
196
|
+
interaction = transitioned;
|
|
197
|
+
events.push(statusEvent);
|
|
198
|
+
}
|
|
199
|
+
return { interaction, events };
|
|
200
|
+
}
|
|
201
|
+
function transitionStatusWithEvent(interaction, newStatus, options = {}) {
|
|
202
|
+
const updated = transitionStatus(interaction, newStatus);
|
|
203
|
+
const resolvedTimestamp = options.timestamp ?? (newStatus === "active" ? updated.startedAt : ["completed", "failed", "cancelled"].includes(newStatus) ? updated.completedAt : void 0) ?? Date.now();
|
|
204
|
+
const event = buildLifecycleEvent("interaction:status_changed", {
|
|
205
|
+
interactionId: updated.id,
|
|
206
|
+
from: interaction.status,
|
|
207
|
+
to: updated.status,
|
|
208
|
+
at: resolvedTimestamp,
|
|
209
|
+
sequence: options.sequence
|
|
210
|
+
});
|
|
211
|
+
return { interaction: updated, event };
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// ../../lib/terminals-tech/core/primitives/message.ts
|
|
215
|
+
var VALID_LAYER_LEVELS = ["L1", "L2", "L3", "L4", "L5"];
|
|
216
|
+
function isValidLayerLevel(value) {
|
|
217
|
+
return VALID_LAYER_LEVELS.includes(value);
|
|
218
|
+
}
|
|
219
|
+
function parseAddress(str) {
|
|
220
|
+
const parts = str.split(":");
|
|
221
|
+
if (parts.length < 3) {
|
|
222
|
+
throw new Error(`Invalid address format: ${str}. Expected {layer}:{nodeType}:{nodeId}`);
|
|
223
|
+
}
|
|
224
|
+
const layerCandidate = parts[0];
|
|
225
|
+
if (!isValidLayerLevel(layerCandidate)) {
|
|
226
|
+
throw new Error(
|
|
227
|
+
`Invalid layer level: "${layerCandidate}". Must be one of: ${VALID_LAYER_LEVELS.join(", ")}`
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
return {
|
|
231
|
+
layer: layerCandidate,
|
|
232
|
+
nodeType: parts[1],
|
|
233
|
+
nodeId: parts[2],
|
|
234
|
+
userId: parts[3]
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
function formatAddress(addr) {
|
|
238
|
+
const base = `${addr.layer}:${addr.nodeType}:${addr.nodeId}`;
|
|
239
|
+
return addr.userId ? `${base}:${addr.userId}` : base;
|
|
240
|
+
}
|
|
241
|
+
function createAddress(layer, nodeType, nodeId, userId) {
|
|
242
|
+
return { layer, nodeType, nodeId, userId };
|
|
243
|
+
}
|
|
244
|
+
var SDK_ADDRESSES = {
|
|
245
|
+
/** AXON kernel address */
|
|
246
|
+
KERNEL: createAddress("L3", "kernel", "v0"),
|
|
247
|
+
/** Orchestrator address */
|
|
248
|
+
ORCHESTRATOR: createAddress("L2", "orchestrator", "v0"),
|
|
249
|
+
/** Broadcast address (all nodes) */
|
|
250
|
+
BROADCAST: createAddress("L1", "broadcast", "*")
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
// ../../lib/terminals-tech/core/primitives/strings.ts
|
|
254
|
+
function sanitizeTraceSegment(value, maxLen = 48) {
|
|
255
|
+
return value.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "").slice(0, maxLen);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export {
|
|
259
|
+
createInteractionWithEvents,
|
|
260
|
+
transitionStatusWithEvent,
|
|
261
|
+
sanitizeTraceSegment,
|
|
262
|
+
parseAddress,
|
|
263
|
+
formatAddress,
|
|
264
|
+
createAddress
|
|
265
|
+
};
|