@terminals-tech/sdk 1.0.0-rc.2 → 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.
@@ -15,13 +15,15 @@ import {
15
15
  executeResonanceMetrics,
16
16
  executeSystemSchedule,
17
17
  executeSystemSignalEmit
18
- } from "./chunk-BKB3MD5Y.js";
18
+ } from "./chunk-KASHT6C5.js";
19
+ import "./chunk-H3POJCFA.js";
20
+ import "./chunk-KHR7ZYCX.js";
19
21
  import "./chunk-PWAHFID5.js";
20
22
  import "./chunk-Y2EULKA2.js";
21
23
  import "./chunk-WU4OTGJE.js";
22
24
  import {
23
25
  registerNode
24
- } from "./chunk-3CEM77QZ.js";
26
+ } from "./chunk-OCLSAUCD.js";
25
27
  import "./chunk-BYXBJQAS.js";
26
28
  import "./chunk-BCOQMFKT.js";
27
29
  import "./chunk-2WTYE4SW.js";
@@ -36,9 +38,147 @@ import "./chunk-AFDUOYHD.js";
36
38
  import "./chunk-NTMBOESX.js";
37
39
  import "./chunk-2ESYSVXG.js";
38
40
 
41
+ // ../../lib/terminals-tech/machines/core/nodes/system.cron.ts
42
+ var SYSTEM_CRON_NODE_ID = "system.cron.v1";
43
+ var manifest = {
44
+ id: SYSTEM_CRON_NODE_ID,
45
+ version: "0.1.0",
46
+ kind: "task",
47
+ label: "Cron Trigger",
48
+ description: "Triggers a stack run on a cron schedule using a standard 5-field expression. Supports IANA timezone specification.",
49
+ runtimes: ["worker"],
50
+ entrypoints: { worker: { module: "local" } },
51
+ inputsSchema: {
52
+ type: "object",
53
+ properties: {
54
+ expression: {
55
+ type: "string",
56
+ description: '5-field cron expression (e.g. "0 9 * * 1-5" for weekdays at 09:00 UTC).'
57
+ },
58
+ timezone: {
59
+ type: "string",
60
+ description: "IANA timezone name (default: UTC)."
61
+ },
62
+ enabled: {
63
+ type: "boolean",
64
+ description: "Whether the cron trigger is active (default: true)."
65
+ }
66
+ },
67
+ required: ["expression"]
68
+ },
69
+ outputsSchema: {
70
+ type: "object",
71
+ properties: {
72
+ scheduled: { type: "boolean" },
73
+ expression: { type: "string" },
74
+ timezone: { type: "string" }
75
+ }
76
+ },
77
+ observability: {
78
+ emitLogs: true,
79
+ traceAttributes: ["expression", "timezone"]
80
+ }
81
+ };
82
+ registerNode(manifest);
83
+
84
+ // ../../lib/terminals-tech/machines/core/nodes/system.webhook.ts
85
+ var SYSTEM_WEBHOOK_NODE_ID = "system.webhook.v1";
86
+ var manifest2 = {
87
+ id: SYSTEM_WEBHOOK_NODE_ID,
88
+ version: "0.1.0",
89
+ kind: "webhook",
90
+ label: "Webhook Trigger",
91
+ description: "Triggers a stack run when an HTTP webhook event is received. Supports HMAC signature verification via vault-backed secret references.",
92
+ runtimes: ["edge"],
93
+ entrypoints: { edge: { endpoint: "system://webhook" } },
94
+ inputsSchema: {
95
+ type: "object",
96
+ properties: {
97
+ path: {
98
+ type: "string",
99
+ description: "Relative path segment for the webhook endpoint (default: stack ID)."
100
+ },
101
+ method: {
102
+ type: "string",
103
+ enum: ["GET", "POST", "PUT", "PATCH"],
104
+ description: "Accepted HTTP method (default: POST)."
105
+ },
106
+ secretRef: {
107
+ type: "object",
108
+ description: "Vault-backed secret reference for HMAC signature verification.",
109
+ properties: {
110
+ name: { type: "string" },
111
+ scope: { type: "string", enum: ["node", "stack"] },
112
+ env: { type: "string" },
113
+ required: { type: "boolean" }
114
+ },
115
+ required: ["name", "scope"]
116
+ }
117
+ }
118
+ },
119
+ outputsSchema: {
120
+ type: "object",
121
+ properties: {
122
+ triggered: { type: "boolean" },
123
+ eventId: { type: "string", description: "Unique ID assigned to this webhook event." },
124
+ method: { type: "string" },
125
+ path: { type: "string" },
126
+ payload: {
127
+ type: "object",
128
+ description: "Parsed request body forwarded to the next node."
129
+ }
130
+ },
131
+ required: ["triggered"]
132
+ },
133
+ capabilities: ["network"],
134
+ observability: {
135
+ emitLogs: true,
136
+ traceAttributes: ["eventId", "method", "path"]
137
+ }
138
+ };
139
+ registerNode(manifest2);
140
+
141
+ // ../../lib/terminals-tech/machines/core/nodes/resonance.swarm.bridge.ts
142
+ var RESONANCE_SWARM_BRIDGE_NODE_ID = "resonance.swarm.bridge.v1";
143
+ registerNode({
144
+ id: RESONANCE_SWARM_BRIDGE_NODE_ID,
145
+ version: "0.1.0",
146
+ kind: "transform",
147
+ label: "Resonance Swarm Bridge",
148
+ description: "Maps System Resonance metrics to Swarm Phase Lock configuration, enabling physical synchronization of agents.",
149
+ runtimes: ["worker"],
150
+ entrypoints: { worker: { module: "local" } },
151
+ metadata: {
152
+ tags: ["resonance", "swarm", "physics", "bridge"]
153
+ },
154
+ inputsSchema: {
155
+ type: "object",
156
+ properties: {
157
+ resonance: {
158
+ type: "object",
159
+ description: "ResonanceMetrics object"
160
+ },
161
+ swarmId: {
162
+ type: "string",
163
+ description: "Target Swarm ID"
164
+ }
165
+ },
166
+ required: ["resonance", "swarmId"]
167
+ },
168
+ outputsSchema: {
169
+ type: "object",
170
+ properties: {
171
+ coupling: { type: "number" },
172
+ jitter: { type: "number" },
173
+ success: { type: "boolean" }
174
+ },
175
+ required: ["success", "coupling"]
176
+ }
177
+ });
178
+
39
179
  // ../../lib/terminals-tech/machines/core/nodes/integration.generic.ts
40
180
  function registerIntegrationNode(opts) {
41
- const manifest = {
181
+ const manifest3 = {
42
182
  id: opts.id,
43
183
  version: "0.1.0",
44
184
  kind: "custom",
@@ -85,8 +225,8 @@ function registerIntegrationNode(opts) {
85
225
  },
86
226
  capabilities: ["integration"]
87
227
  };
88
- registerNode(manifest);
89
- return manifest;
228
+ registerNode(manifest3);
229
+ return manifest3;
90
230
  }
91
231
 
92
232
  // ../../lib/terminals-tech/machines/core/nodes/integration.nodes.ts
@@ -0,0 +1,50 @@
1
+ import "./chunk-2ESYSVXG.js";
2
+
3
+ // ../../lib/brain/connectors/pglite-adapter.ts
4
+ function createDBClientFromPGLite(db) {
5
+ return {
6
+ async executeDDL(sql, _params) {
7
+ await db.exec(sql);
8
+ },
9
+ async executeQuery(sql, params) {
10
+ const result = await db.query(sql, params);
11
+ return { rows: result.rows };
12
+ }
13
+ };
14
+ }
15
+ async function getConnectorChunks(connectorId) {
16
+ try {
17
+ const pglitePath = "@/lib/pglite/client";
18
+ const mod = await import(
19
+ /* webpackIgnore: true */
20
+ pglitePath
21
+ );
22
+ const db = mod.getDB?.();
23
+ if (!db) return [];
24
+ const result = await db.query(
25
+ `SELECT id, connector_id, content, metadata
26
+ FROM connector_chunks
27
+ WHERE connector_id = $1
28
+ ORDER BY id`,
29
+ [connectorId]
30
+ );
31
+ return (result.rows || []).map((row) => ({
32
+ id: row.id,
33
+ connectorId: row.connector_id,
34
+ content: row.content,
35
+ metadata: {
36
+ source: String(row.metadata?.source ?? ""),
37
+ title: String(row.metadata?.title ?? ""),
38
+ mimeType: String(row.metadata?.mimeType ?? "application/octet-stream"),
39
+ extractedAt: Number(row.metadata?.extractedAt ?? Date.now()),
40
+ ...row.metadata
41
+ }
42
+ }));
43
+ } catch {
44
+ return [];
45
+ }
46
+ }
47
+ export {
48
+ createDBClientFromPGLite,
49
+ getConnectorChunks
50
+ };
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  runners
3
- } from "./chunk-Q4B7YS7T.js";
4
- import "./chunk-BKB3MD5Y.js";
3
+ } from "./chunk-PPFTKJDB.js";
4
+ import "./chunk-KASHT6C5.js";
5
5
  import "./chunk-H3POJCFA.js";
6
6
  import "./chunk-KHR7ZYCX.js";
7
7
  import "./chunk-PWAHFID5.js";
8
8
  import "./chunk-Y2EULKA2.js";
9
9
  import "./chunk-WU4OTGJE.js";
10
- import "./chunk-3CEM77QZ.js";
10
+ import "./chunk-OCLSAUCD.js";
11
11
  import "./chunk-BYXBJQAS.js";
12
12
  import "./chunk-BCOQMFKT.js";
13
13
  import "./chunk-2WTYE4SW.js";
@@ -0,0 +1,24 @@
1
+ import "./chunk-2ESYSVXG.js";
2
+
3
+ // ../../lib/brain/connectors/resolver.ts
4
+ async function resolveConnectorData(ref) {
5
+ try {
6
+ const { getConnectorChunks } = await import("./pglite-adapter-43IOUBMV.js");
7
+ const chunks = await getConnectorChunks(ref.connectorId);
8
+ if (!ref.dataChunkFilter || Object.keys(ref.dataChunkFilter).length === 0) {
9
+ return chunks;
10
+ }
11
+ return chunks.filter((chunk) => {
12
+ for (const [key, value] of Object.entries(ref.dataChunkFilter)) {
13
+ if (chunk.metadata[key] !== value) return false;
14
+ }
15
+ return true;
16
+ });
17
+ } catch (err) {
18
+ console.warn(`[connector-resolver] Failed to resolve connector ${ref.connectorId}:`, err);
19
+ return [];
20
+ }
21
+ }
22
+ export {
23
+ resolveConnectorData
24
+ };
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  OrchestratorV0,
3
+ buildScheduleTriggerContext,
3
4
  loadStack
4
- } from "./chunk-PUZ2S62E.js";
5
+ } from "./chunk-STMI72WH.js";
5
6
  import "./chunk-GJWAJAX3.js";
6
7
  import "./chunk-VZA2NUH3.js";
7
8
  import "./chunk-QWXPVB2L.js";
@@ -14,7 +15,7 @@ import "./chunk-PWAHFID5.js";
14
15
  import "./chunk-Y2EULKA2.js";
15
16
  import {
16
17
  resolveNode
17
- } from "./chunk-3CEM77QZ.js";
18
+ } from "./chunk-OCLSAUCD.js";
18
19
  import "./chunk-BYXBJQAS.js";
19
20
  import "./chunk-BCOQMFKT.js";
20
21
  import "./chunk-2WTYE4SW.js";
@@ -31,6 +32,12 @@ import "./chunk-2ESYSVXG.js";
31
32
 
32
33
  // ../../lib/terminals-tech/machines/core/scheduler.ts
33
34
  init_dist();
35
+ function getSupabase() {
36
+ const url = process.env.NEXT_PUBLIC_SUPABASE_URL;
37
+ const key = process.env.SUPABASE_SERVICE_ROLE_KEY;
38
+ if (!url || !key) return null;
39
+ return createClient(url, key, { auth: { persistSession: false } });
40
+ }
34
41
  var globalWithJobs = globalThis;
35
42
  var jobs = globalWithJobs.__terminals_jobs__ || /* @__PURE__ */ new Map();
36
43
  globalWithJobs.__terminals_jobs__ = jobs;
@@ -39,26 +46,31 @@ function getSchedule(stackId) {
39
46
  if (!j) return null;
40
47
  return { everySeconds: Math.max(1, Math.floor(j.intervalMs / 1e3)) };
41
48
  }
42
- async function scheduleStack(stackId, everySeconds) {
49
+ async function scheduleStack(stackId, everySeconds, triggerConfig) {
43
50
  cancelSchedule(stackId);
44
51
  const intervalMs = Math.max(1e3, everySeconds * 1e3);
45
- const url = process.env.NEXT_PUBLIC_SUPABASE_URL;
46
- const key = process.env.SUPABASE_SERVICE_ROLE_KEY;
47
- if (url && key) {
48
- const supabase = createClient(url, key, {
49
- auth: { persistSession: false }
50
- });
51
- await supabase.from("stack_schedules").upsert(
52
+ const supabase = getSupabase();
53
+ if (supabase) {
54
+ const { error } = await supabase.from("stack_schedules").upsert(
52
55
  {
53
56
  stack_id: stackId,
54
57
  every_seconds: everySeconds,
55
58
  active: true,
56
- next_run_at: new Date(Date.now() + intervalMs).toISOString()
59
+ next_run_at: new Date(Date.now() + intervalMs).toISOString(),
60
+ ...triggerConfig ? { trigger_config: triggerConfig, trigger_kind: triggerConfig.kind } : {}
57
61
  },
58
62
  { onConflict: "stack_id" }
59
63
  );
64
+ if (error) {
65
+ console.warn("[scheduler] Failed to persist schedule in Supabase", error);
66
+ }
60
67
  }
61
- const job = { intervalMs, timer: null, running: false };
68
+ const job = {
69
+ intervalMs,
70
+ timer: null,
71
+ running: false,
72
+ triggerConfig
73
+ };
62
74
  jobs.set(stackId, job);
63
75
  const timer = setInterval(async () => {
64
76
  if (job.running) {
@@ -72,23 +84,21 @@ async function scheduleStack(stackId, everySeconds) {
72
84
  const stack = await loadStack(stackId);
73
85
  if (!stack) return;
74
86
  const orchestrator = new OrchestratorV0(resolveNode);
87
+ const trigCtx = job.triggerConfig ? buildScheduleTriggerContext(job.triggerConfig) : { triggerKind: "interval", triggeredAt: (/* @__PURE__ */ new Date()).toISOString() };
75
88
  try {
76
- await orchestrator.run(stack);
77
- const url2 = process.env.NEXT_PUBLIC_SUPABASE_URL;
78
- const key2 = process.env.SUPABASE_SERVICE_ROLE_KEY;
79
- if (url2 && key2) {
80
- const supabase = createClient(url2, key2, {
81
- auth: { persistSession: false }
82
- });
83
- await supabase.from("stack_schedules").update({
84
- next_run_at: new Date(Date.now() + intervalMs).toISOString()
85
- }).eq("stack_id", stackId);
89
+ await orchestrator.run(stack, { triggerContext: trigCtx });
90
+ const sb = getSupabase();
91
+ if (sb) {
92
+ const { error: updateError } = await sb.from("stack_schedules").update({ next_run_at: new Date(Date.now() + intervalMs).toISOString() }).eq("stack_id", stackId);
93
+ if (updateError) {
94
+ console.warn("[scheduler] Failed to bump next_run_at", updateError);
95
+ }
86
96
  }
87
97
  } finally {
88
98
  orchestrator.dispose();
89
99
  }
90
100
  } catch (e) {
91
- console.warn("schedule run failed", e);
101
+ console.warn(`[scheduler] Stack ${stackId} run failed`, e);
92
102
  } finally {
93
103
  job.running = false;
94
104
  }
@@ -101,18 +111,13 @@ function cancelSchedule(stackId) {
101
111
  clearInterval(j.timer);
102
112
  jobs.delete(stackId);
103
113
  }
104
- const url = process.env.NEXT_PUBLIC_SUPABASE_URL;
105
- const key = process.env.SUPABASE_SERVICE_ROLE_KEY;
106
- if (url && key) {
107
- const supabase = createClient(url, key, {
108
- auth: { persistSession: false }
109
- });
110
- void supabase.from("stack_schedules").update({ active: false }).eq("stack_id", stackId).then(
111
- () => {
112
- },
113
- () => {
114
+ const sb = getSupabase();
115
+ if (sb) {
116
+ sb.from("stack_schedules").update({ active: false }).eq("stack_id", stackId).then(({ error }) => {
117
+ if (error) {
118
+ console.warn("[scheduler] Failed to mark schedule inactive in Supabase", error);
114
119
  }
115
- );
120
+ });
116
121
  }
117
122
  }
118
123
  export {
@@ -7,7 +7,7 @@ async function ensureServerRunnersRegistered() {
7
7
  return;
8
8
  }
9
9
  if (!serverRunnersReady) {
10
- serverRunnersReady = Promise.all([import("./stack-CHDAFU2S.js"), import("./container-lite-KQX3NMPY.js")]).then(
10
+ serverRunnersReady = Promise.all([import("./stack-4KWCQQP7.js"), import("./container-lite-QD3CRLS4.js")]).then(
11
11
  () => void 0
12
12
  );
13
13
  }
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  registerSkill
3
- } from "./chunk-UKVUPKZP.js";
4
- import "./chunk-3CEM77QZ.js";
3
+ } from "./chunk-L45BSQDJ.js";
4
+ import "./chunk-OCLSAUCD.js";
5
5
  import "./chunk-ABCK4FWN.js";
6
6
  import "./chunk-XPJ63Y6T.js";
7
7
  import "./chunk-2ESYSVXG.js";
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  OrchestratorV0,
3
3
  loadStack
4
- } from "./chunk-PUZ2S62E.js";
4
+ } from "./chunk-STMI72WH.js";
5
5
  import {
6
6
  runners
7
- } from "./chunk-Q4B7YS7T.js";
8
- import "./chunk-BKB3MD5Y.js";
7
+ } from "./chunk-PPFTKJDB.js";
8
+ import "./chunk-KASHT6C5.js";
9
9
  import "./chunk-GJWAJAX3.js";
10
10
  import "./chunk-VZA2NUH3.js";
11
11
  import "./chunk-H3POJCFA.js";
@@ -18,7 +18,7 @@ import "./chunk-Y2EULKA2.js";
18
18
  import "./chunk-WU4OTGJE.js";
19
19
  import {
20
20
  resolveNode
21
- } from "./chunk-3CEM77QZ.js";
21
+ } from "./chunk-OCLSAUCD.js";
22
22
  import "./chunk-BYXBJQAS.js";
23
23
  import "./chunk-BCOQMFKT.js";
24
24
  import "./chunk-2WTYE4SW.js";
@@ -9,7 +9,7 @@ import "./chunk-UJDUQNE2.js";
9
9
  import {
10
10
  WebContainerManager,
11
11
  WebContainerManager_default
12
- } from "./chunk-SHPGIVDH.js";
12
+ } from "./chunk-LLGZTP3G.js";
13
13
  import "./chunk-DKFJIILR.js";
14
14
  import "./chunk-KHR7ZYCX.js";
15
15
  import "./chunk-QWZRZKLZ.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@terminals-tech/sdk",
3
- "version": "1.0.0-rc.2",
4
- "description": "Private Terminals OS SDK facade for internal packaging and dry-run verification. Patent Pending.",
3
+ "version": "1.0.0",
4
+ "description": "Terminals OS SDK observable, coherence-aware primitives for building intelligent software. Patent Pending.",
5
5
  "license": "BUSL-1.1",
6
6
  "author": "Intuition Labs LLC",
7
7
  "notice": "Terminals OS architecture is Patent Pending. © 2026 Intuition Labs LLC.",
@@ -41,6 +41,12 @@
41
41
  "publish:check": "npm run clean && npm run build && node ../../scripts/verify-sdk-package.mjs",
42
42
  "prepack": "npm run build"
43
43
  },
44
+ "dependencies": {
45
+ "rxjs": "^7.8.0"
46
+ },
47
+ "optionalDependencies": {
48
+ "@electric-sql/pglite": ">=0.2.0"
49
+ },
44
50
  "peerDependencies": {
45
51
  "typescript": ">=5.0.0"
46
52
  }
File without changes