@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.
Files changed (36) hide show
  1. package/README.md +62 -20
  2. package/dist/{WebContainerManager-SHXC5VKI.js → WebContainerManager-NUGGUIWB.js} +2 -2
  3. package/dist/catalog-XA5VYWXG.js +16 -0
  4. package/dist/{chunk-PWAHFID5.js → chunk-D4MOOUDY.js} +3 -3
  5. package/dist/{chunk-FOXUEYWK.js → chunk-GOQHOLBG.js} +4 -3
  6. package/dist/{chunk-PUZ2S62E.js → chunk-ICFYWOI5.js} +61 -36
  7. package/dist/chunk-PKINKOW2.js +335 -0
  8. package/dist/chunk-PWEICJ47.js +30 -0
  9. package/dist/{chunk-BKB3MD5Y.js → chunk-Q4W3IUTD.js} +73 -12
  10. package/dist/{chunk-BCOQMFKT.js → chunk-TO7ETE5K.js} +2 -2
  11. package/dist/{chunk-Q2VI6ICE.js → chunk-UB5OINTA.js} +1 -1
  12. package/dist/{chunk-Q4B7YS7T.js → chunk-WJCIX7RO.js} +9 -69
  13. package/dist/{chunk-3CEM77QZ.js → chunk-WT6L6DK3.js} +30 -2
  14. package/dist/{chunk-UKVUPKZP.js → chunk-Y5WLSLLW.js} +1 -1
  15. package/dist/{container-lite-KQX3NMPY.js → container-lite-Q3O3EP6R.js} +9 -9
  16. package/dist/core.machine.orchestrator-NW73YDTL.js +24 -0
  17. package/dist/{demo-VXMGMJNK.js → demo-WARANXBT.js} +11 -11
  18. package/dist/{hvm-DRQK2MUT.js → hvm-A7DGZ3Q5.js} +1 -1
  19. package/dist/index.cjs +65114 -12973
  20. package/dist/index.d.cts +643 -146
  21. package/dist/index.d.ts +643 -146
  22. package/dist/index.js +2460 -454
  23. package/dist/{neuro-state-XHRGIRVO.js → neuro-state-KINIFV2D.js} +6 -6
  24. package/dist/{nodes-DXKYDTVO.js → nodes-TWQZUZRM.js} +153 -13
  25. package/dist/pglite-adapter-43IOUBMV.js +50 -0
  26. package/dist/{registry-BL3TDQDB.js → registry-UARRB6CF.js} +9 -9
  27. package/dist/resolver-ALOJSOK5.js +24 -0
  28. package/dist/{scheduler-H6Q53IMI.js → scheduler-SAQJLKXJ.js} +52 -45
  29. package/dist/sematon-2EUEZESN.js +19 -0
  30. package/dist/{server-7DM74VFW.js → server-JXM4Y2T6.js} +1 -1
  31. package/dist/{skills-KLTTT2RM.js → skills-XOFGMUP4.js} +2 -2
  32. package/dist/{stack-CHDAFU2S.js → stack-4QQCK7MG.js} +17 -15
  33. package/dist/{supabaseService-6AYP2VY3.js → supabaseService-O4ZFFLZP.js} +2 -2
  34. package/dist/{webcontainer-3LDJVIIL.js → webcontainer-PMWNRO4I.js} +2 -2
  35. package/package.json +10 -4
  36. package/dist/{chunk-SHPGIVDH.js → chunk-P4D4RNAV.js} +4 -4
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @terminals-tech/sdk
2
2
 
3
- Terminals OS SDK — publish-safe facades and primitives for building observable, coherence-aware software.
3
+ Terminals OS SDK — observable, coherence-aware primitives for building intelligent software. Available as TypeScript (`@terminals-tech/sdk`) and Rust (`terminals-core`).
4
4
 
5
5
  ## Install
6
6
 
@@ -8,10 +8,17 @@ Terminals OS SDK — publish-safe facades and primitives for building observable
8
8
  npm install @terminals-tech/sdk
9
9
  ```
10
10
 
11
+ ## Install (Rust)
12
+
13
+ ```toml
14
+ [dependencies]
15
+ terminals-core = "0.1"
16
+ ```
17
+
11
18
  ## Quickstart
12
19
 
13
20
  ```typescript
14
- import { SDK_VERSION, Brain, L0, calculateCoherence, createAxonBus } from "@terminals-tech/sdk";
21
+ import { SDK_VERSION, Brain, L0, createAxonBus } from "@terminals-tech/sdk";
15
22
 
16
23
  // 1. The L0 Engine: Think of a Sematon as a "smart data envelope"
17
24
  // It holds your payload but also guarantees it can be mathematically transformed.
@@ -24,7 +31,7 @@ const mySematon = L0.createSematon({
24
31
  console.log("Is my payload constructive?", mySematon.constructive); // true!
25
32
 
26
33
  // 2. The L4 Brain: Measure how aligned things are
27
- const metrics = calculateCoherence({
34
+ const metrics = Brain.calculateCoherence({
28
35
  output: "Execution is observable, coherence-aware, and locally steerable.",
29
36
  groundTruth: ["Execution is observable."],
30
37
  });
@@ -32,18 +39,42 @@ const metrics = calculateCoherence({
32
39
  console.log("Coherence:", metrics.overall);
33
40
  ```
34
41
 
42
+ ## Quickstart (Rust)
43
+
44
+ ```rust
45
+ use terminals_core::phase::{kuramoto_step, order_parameter, phase_locking_value, Omega};
46
+ use terminals_core::substrate::{Sematon, witness::ConvergenceWitness, graph::PadicAddr};
47
+
48
+ // 1. Phase dynamics — same math as Brain.kuramotoStep in TypeScript
49
+ let phases = vec![0.0, 1.2, 2.6, 4.1];
50
+ let next = kuramoto_step(&phases, &Omega::Uniform(0.0), 0.8, None, 0.1, true);
51
+ let op = order_parameter(&next);
52
+ println!("Kuramoto R = {:.3}, psi = {:.3}", op.r, op.psi);
53
+
54
+ // 2. Sematon — same concept as L0.createSematon in TypeScript
55
+ let witness = ConvergenceWitness { r: 0.95, entropy: 0.3, converged: true, step: 10 };
56
+ let sem = Sematon::new(vec![1.0f32, 2.0, 3.0], witness, PadicAddr::default(), "demo");
57
+ println!("Constructive: {}", sem.constructive);
58
+ ```
59
+
35
60
  ## Architecture
36
61
 
37
62
  The published package exposes a curated surface oriented around stable facades and runtime-safe primitives:
38
63
 
39
- | Surface | Namespace / Export | Coverage |
40
- | ---------- | ----------------------------- | ---------------------------------------------------------------- |
41
- | Foundation | `L0` | Core engine math, Sematons, and Deterministic Constructor traces |
42
- | Terminal | `Terminal` | interaction lifecycle, surface identity, platform types |
43
- | Core | `Core` | result types, validation, DAG, registry, retry/event primitives |
44
- | Mesh | `Mesh` | signals, action bus, delegation helpers |
45
- | Brain | `Brain`, `calculateCoherence` | coherence metrics and phase primitives |
46
- | Protocol | `Protocol`, `createAxonBus` | delegation helpers and the AXON protocol bridge |
64
+ | Surface | Namespace / Export | Coverage | Rust crate |
65
+ | --------------------- | ------------------ | ------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
66
+ | Foundation | `L0` | Core engine math, Sematons, and Deterministic Constructor traces | `terminals_core::substrate` (Sematon, fold/unfold) |
67
+ | Brain | `Brain` | coherence metrics and phase primitives (`Brain.calculateCoherence`, etc.) | `terminals_core::phase` (kuramoto, PLV, order parameter) |
68
+ | Core | `Core` | result types, validation, DAG, registry, retry/event primitives | `terminals_core::primitives` (Result, DAG, Registry, Validated) |
69
+ | Wire (Rust-only) | | — | `terminals_core::wire` (AXON binary protocol) |
70
+ | Audio (Rust-only) | — | — | `terminals_core::audio` (spectral entropy, band analysis) |
71
+ | Substrate (Rust-only) | — | — | `terminals_core::substrate` (ComputeAtom, ProjectionLayout, SubstrateEngine) |
72
+ | Terminal | `Terminal` | interaction lifecycle, surface identity, platform types | — |
73
+ | Mesh | `Mesh` | signals, action bus, delegation helpers | — |
74
+ | Protocol | `Protocol` | delegation helpers and the AXON protocol bridge | — |
75
+ | Skill | `Skill` | skill manifest types, registry access, signal codes | — |
76
+ | Manifold | `Manifold` | annihilation pipeline helpers and ordinal execution surfaces | — |
77
+ | Observer | `Observer` | observer kernel primitives and witness-oriented runtime inspection | — |
47
78
 
48
79
  ## ELI5: The L0 Foundation (Sematons & Constructors)
49
80
 
@@ -55,17 +86,10 @@ Developers use `L0` primitives to make sure complex AI workflows behave predicta
55
86
  ## Usage
56
87
 
57
88
  ```typescript
58
- import {
59
- Brain,
60
- Core,
61
- Mesh,
62
- Protocol,
63
- calculateCoherence,
64
- createAxonBus,
65
- } from "@terminals-tech/sdk";
89
+ import { Brain, Core, Mesh, Protocol, createAxonBus } from "@terminals-tech/sdk";
66
90
 
67
91
  const bus = createAxonBus();
68
- const metrics = calculateCoherence({
92
+ const metrics = Brain.calculateCoherence({
69
93
  output: "The mesh is synchronized and the route is clear.",
70
94
  groundTruth: ["The mesh is synchronized.", "Routing remains observable."],
71
95
  });
@@ -81,6 +105,23 @@ await bus.publishSDK({
81
105
  console.log({ Core, Mesh, Protocol });
82
106
  ```
83
107
 
108
+ ## TypeScript / Rust Parity
109
+
110
+ The same core math runs in both runtimes. Phase dynamics, sematonic types, DAG, registry, and validation exist in both `@terminals-tech/sdk` (TypeScript) and `terminals-core` (Rust/WASM). Higher-level orchestration (Mesh signals, Protocol delegation, Observer kernel) is TypeScript-only. Low-level substrate and wire protocol are Rust-only.
111
+
112
+ | Domain | TypeScript | Rust | Status |
113
+ | -------------------- | -------------------------- | ---------------------------------------- | --------- |
114
+ | Phase dynamics | `Brain.*` | `terminals_core::phase` | Both |
115
+ | Sematon / L0 | `L0.createSematon` | `terminals_core::substrate::Sematon` | Both |
116
+ | DAG | `Core.createDAG` | `terminals_core::primitives::dag` | Both |
117
+ | Validation (proof) | `Core.validated` | `terminals_core::primitives::validation` | Both |
118
+ | Coherence scoring | `Brain.calculateCoherence` | — | TS only |
119
+ | Mesh signals | `Mesh.*` | — | TS only |
120
+ | Protocol/AXON bridge | `Protocol.*` | — | TS only |
121
+ | AXON wire format | — | `terminals_core::wire` | Rust only |
122
+ | Substrate engine | — | `terminals_core::substrate` | Rust only |
123
+ | Audio analysis | — | `terminals_core::audio` | Rust only |
124
+
84
125
  ## Local verification
85
126
 
86
127
  From the monorepo root:
@@ -103,6 +144,7 @@ npm run -w @terminals-tech/sdk pack:dry-run
103
144
  2. Run `npm run sdk:publish:check`
104
145
  3. Inspect the dry-run tarball summary
105
146
  4. Publish when ready with `npm publish --workspace @terminals-tech/sdk`
147
+ 5. For `terminals-core`: `cargo publish --manifest-path crates/terminals-core/Cargo.toml`
106
148
 
107
149
  ## License
108
150
 
@@ -2,15 +2,15 @@ import {
2
2
  ProcessPriority,
3
3
  WebContainerManager,
4
4
  WebContainerManager_default
5
- } from "./chunk-SHPGIVDH.js";
5
+ } from "./chunk-P4D4RNAV.js";
6
6
  import "./chunk-DKFJIILR.js";
7
7
  import "./chunk-KHR7ZYCX.js";
8
+ import "./chunk-WGBCRNMB.js";
8
9
  import "./chunk-QWZRZKLZ.js";
9
10
  import "./chunk-OSSRZOGC.js";
10
11
  import "./chunk-TSQ3BGLA.js";
11
12
  import "./chunk-2WTYE4SW.js";
12
13
  import "./chunk-QJFKEQHF.js";
13
- import "./chunk-WGBCRNMB.js";
14
14
  import "./chunk-3LFMIVJM.js";
15
15
  import "./chunk-AFDUOYHD.js";
16
16
  import "./chunk-NTMBOESX.js";
@@ -0,0 +1,16 @@
1
+ import {
2
+ getCatalog,
3
+ listNodes,
4
+ registerManifestProvider,
5
+ registerNode,
6
+ resolveNode
7
+ } from "./chunk-WT6L6DK3.js";
8
+ import "./chunk-XPJ63Y6T.js";
9
+ import "./chunk-2ESYSVXG.js";
10
+ export {
11
+ getCatalog,
12
+ listNodes,
13
+ registerManifestProvider,
14
+ registerNode,
15
+ resolveNode
16
+ };
@@ -6,10 +6,10 @@ import {
6
6
  createInteractionWithEvents,
7
7
  sanitizeTraceSegment,
8
8
  transitionStatusWithEvent
9
- } from "./chunk-BCOQMFKT.js";
9
+ } from "./chunk-TO7ETE5K.js";
10
10
  import {
11
11
  secureValidate
12
- } from "./chunk-FOXUEYWK.js";
12
+ } from "./chunk-GOQHOLBG.js";
13
13
  import {
14
14
  DEFAULT_EMBEDDING_DIM
15
15
  } from "./chunk-ZVO47SQV.js";
@@ -175,7 +175,7 @@ async function emitInteractionEvent(interactionId, type, payload, metadata) {
175
175
  const userId = enrichedMeta.userId ?? enrichedMeta.user_id;
176
176
  if (userId && typeof window !== "undefined") {
177
177
  try {
178
- const { appendSupabaseMeshEvent } = await import("./supabaseService-6AYP2VY3.js");
178
+ const { appendSupabaseMeshEvent } = await import("./supabaseService-O4ZFFLZP.js");
179
179
  await appendSupabaseMeshEvent({
180
180
  user_id: userId,
181
181
  interaction_id: interactionId,
@@ -1,10 +1,10 @@
1
+ import {
2
+ require_ajv
3
+ } from "./chunk-QJFKEQHF.js";
1
4
  import {
2
5
  untrusted,
3
6
  validate
4
7
  } from "./chunk-EXI3LJVJ.js";
5
- import {
6
- require_ajv
7
- } from "./chunk-QJFKEQHF.js";
8
8
  import {
9
9
  __toESM
10
10
  } from "./chunk-2ESYSVXG.js";
@@ -37,6 +37,7 @@ function secureValidate(data, schema) {
37
37
  }
38
38
 
39
39
  export {
40
+ getValidator,
40
41
  validateWithSchema,
41
42
  secureValidate
42
43
  };
@@ -1,46 +1,33 @@
1
+ import {
2
+ onMeshFeedback,
3
+ orchestratorToMesh
4
+ } from "./chunk-UB5OINTA.js";
1
5
  import {
2
6
  getGlobalStore
3
7
  } from "./chunk-VZA2NUH3.js";
4
8
  import {
5
9
  resolveSecretValue
6
10
  } from "./chunk-QWXPVB2L.js";
7
- import {
8
- onMeshFeedback,
9
- orchestratorToMesh
10
- } from "./chunk-Q2VI6ICE.js";
11
- import {
12
- registerManifestProvider
13
- } from "./chunk-3CEM77QZ.js";
14
11
  import {
15
12
  safeDbOperation
16
13
  } from "./chunk-WGBCRNMB.js";
14
+ import {
15
+ getValidator
16
+ } from "./chunk-GOQHOLBG.js";
17
17
  import {
18
18
  getDB,
19
19
  isDatabaseReady,
20
20
  withDB
21
21
  } from "./chunk-AFDUOYHD.js";
22
22
 
23
- // ../../lib/terminals-tech/machines/core/stacksStore.ts
24
- var globalStore = globalThis;
25
- var memStacks = globalStore.__memStacks || /* @__PURE__ */ new Map();
26
- globalStore.__memStacks = memStacks;
27
- var pendingDeletes = globalStore.__pendingStackDeletes || /* @__PURE__ */ new Set();
28
- globalStore.__pendingStackDeletes = pendingDeletes;
29
- registerManifestProvider("stacksStore", loadStack);
30
- async function loadStack(id) {
31
- const { getDB: getDB2, safeDbOperation: safeDbOperation2 } = await import("./pgliteService-IUGNNOVU.js");
32
- const dbResult = await safeDbOperation2(async () => {
33
- const db = await getDB2();
34
- await db.query(`ALTER TABLE stacks ADD COLUMN IF NOT EXISTS deleted_at TIMESTAMP`);
35
- const r = await db.query(
36
- `SELECT manifest FROM stacks WHERE id = $1 AND deleted_at IS NULL`,
37
- [id]
38
- );
39
- if (!r.rows[0]) return null;
40
- return r.rows[0].manifest;
41
- }, null);
42
- if (dbResult) return dbResult;
43
- return memStacks.get(id)?.manifest || null;
23
+ // ../../lib/terminals-tech/machines/core/types/trigger.ts
24
+ function buildScheduleTriggerContext(config, scheduleId) {
25
+ return {
26
+ triggerKind: config.kind,
27
+ triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
28
+ cronExpression: config.kind === "cron" ? config.expression : void 0,
29
+ scheduleId
30
+ };
44
31
  }
45
32
 
46
33
  // ../../lib/terminals-tech/machines/core/manifests.ts
@@ -557,7 +544,7 @@ var OrchestratorV0 = class {
557
544
  return true;
558
545
  }
559
546
  try {
560
- const { neuroState } = await import("./neuro-state-XHRGIRVO.js");
547
+ const { neuroState } = await import("./neuro-state-KINIFV2D.js");
561
548
  const currentState = await new Promise((resolve) => {
562
549
  let resolved = false;
563
550
  let subscription = null;
@@ -680,8 +667,8 @@ var OrchestratorV0 = class {
680
667
  };
681
668
  let shapeHash;
682
669
  try {
683
- const { computeShapeHash: computeShapeHash2 } = await import("./topology-CIWWNVAN.js");
684
- shapeHash = await computeShapeHash2(stack);
670
+ const { computeShapeHash } = await import("./topology-CIWWNVAN.js");
671
+ shapeHash = await computeShapeHash(stack);
685
672
  } catch (err) {
686
673
  console.error("[OrchestratorV0] Failed to compute shape hash:", err);
687
674
  }
@@ -695,6 +682,44 @@ var OrchestratorV0 = class {
695
682
  ...baseInput,
696
683
  ...opts.configOverrides?.[node.id] || {}
697
684
  };
685
+ if (isNodeManifest(manifest) && manifest.inputsSchema && opts.configOverrides?.[node.id]) {
686
+ try {
687
+ const validator = getValidator(manifest.inputsSchema);
688
+ const publicInput = {};
689
+ for (const [k, v] of Object.entries(input)) {
690
+ if (!k.startsWith("__")) publicInput[k] = v;
691
+ }
692
+ const isValid = validator(publicInput);
693
+ if (!isValid) {
694
+ console.warn(
695
+ `[OrchestratorV0] configOverrides for node "${node.id}" produced input that does not match inputsSchema:`,
696
+ validator.errors
697
+ );
698
+ }
699
+ } catch (schemaErr) {
700
+ console.warn(
701
+ `[OrchestratorV0] Failed to validate configOverrides for node "${node.id}":`,
702
+ schemaErr
703
+ );
704
+ }
705
+ }
706
+ if (opts.triggerContext) {
707
+ input.__triggerContext = opts.triggerContext;
708
+ }
709
+ if (node.connectorRef) {
710
+ try {
711
+ const { resolveConnectorData } = await import("./resolver-ALOJSOK5.js");
712
+ const chunks = await resolveConnectorData(node.connectorRef);
713
+ if (chunks && chunks.length > 0) {
714
+ input.__connectorData = chunks;
715
+ }
716
+ } catch (connErr) {
717
+ console.warn(
718
+ `[OrchestratorV0] ConnectorRef resolution failed for node ${node.id}:`,
719
+ connErr
720
+ );
721
+ }
722
+ }
698
723
  const modelId = input.model || node.config?.model || "default";
699
724
  const span = this.tracer.startSpan(`node:${node.id}`, {
700
725
  stackId: stack.id,
@@ -895,10 +920,10 @@ var OrchestratorV0 = class {
895
920
  void stackId;
896
921
  void node;
897
922
  if (typeof window === "undefined") {
898
- const { ensureServerRunnersRegistered } = await import("./server-7DM74VFW.js");
923
+ const { ensureServerRunnersRegistered } = await import("./server-JXM4Y2T6.js");
899
924
  await ensureServerRunnersRegistered();
900
925
  }
901
- const { runners } = await import("./registry-BL3TDQDB.js");
926
+ const { runners } = await import("./registry-UARRB6CF.js");
902
927
  const tierRunner = runners.getRunner(tier);
903
928
  if (tierRunner) {
904
929
  return await tierRunner(manifest, input, {
@@ -944,7 +969,7 @@ var OrchestratorV0 = class {
944
969
  return { ...input };
945
970
  }
946
971
  if (tier === "webcontainer") {
947
- const { runInWebContainer } = await import("./webcontainer-3LDJVIIL.js");
972
+ const { runInWebContainer } = await import("./webcontainer-PMWNRO4I.js");
948
973
  return await runInWebContainer(manifest, input, {
949
974
  stackId,
950
975
  nodeId: node.id,
@@ -952,7 +977,7 @@ var OrchestratorV0 = class {
952
977
  });
953
978
  }
954
979
  if (tier === "wasm-hvm") {
955
- const { runInHVM } = await import("./hvm-DRQK2MUT.js");
980
+ const { runInHVM } = await import("./hvm-A7DGZ3Q5.js");
956
981
  return await runInHVM(manifest, input, {
957
982
  stackId,
958
983
  nodeId: node.id,
@@ -972,6 +997,6 @@ var OrchestratorV0 = class {
972
997
  };
973
998
 
974
999
  export {
975
- loadStack,
1000
+ buildScheduleTriggerContext,
976
1001
  OrchestratorV0
977
1002
  };