@promptowl/contextnest-community 1.8.0 → 1.10.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.
@@ -22,7 +22,20 @@ var HISTORICAL_MIGRATIONS = [
22
22
  // migrations gate correctly.
23
23
  "012_merge_case_colliding_users",
24
24
  "013_node_deletion_tombstones",
25
- "014_api_events"
25
+ "014_api_events",
26
+ "015_definitions",
27
+ "016_workflow_edges",
28
+ "017_workflow_runs",
29
+ "018_subagent_runs",
30
+ "019_grants",
31
+ "020_schedules",
32
+ "021_schedule_bounds",
33
+ "022_tools_and_watchers",
34
+ "023_connectors",
35
+ "024_trigger_hooks",
36
+ "025_run_claims",
37
+ "020_server_settings",
38
+ "026_api_events_nest_index"
26
39
  ];
27
40
  async function runPostgresMigrations(db) {
28
41
  await db.exec(`
@@ -260,6 +273,148 @@ async function runPostgresMigrations(db) {
260
273
  CREATE INDEX IF NOT EXISTS idx_comments_thread
261
274
  ON comments(parent_id);
262
275
 
276
+ CREATE TABLE IF NOT EXISTS grants (
277
+ id TEXT PRIMARY KEY,
278
+ nest_id TEXT NOT NULL REFERENCES nests(id) ON DELETE CASCADE,
279
+ target_type TEXT NOT NULL CHECK(target_type IN ('document', 'folder')),
280
+ target TEXT NOT NULL,
281
+ user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
282
+ role TEXT NOT NULL CHECK(role IN ('read', 'write')),
283
+ granted_by TEXT NOT NULL,
284
+ created_at TEXT NOT NULL,
285
+ updated_at TEXT NOT NULL
286
+ );
287
+ CREATE UNIQUE INDEX IF NOT EXISTS idx_grants_unique
288
+ ON grants(nest_id, target_type, target, user_id);
289
+ CREATE INDEX IF NOT EXISTS idx_grants_user ON grants(nest_id, user_id);
290
+
291
+ CREATE TABLE IF NOT EXISTS schedules (
292
+ id TEXT PRIMARY KEY,
293
+ nest_id TEXT NOT NULL REFERENCES nests(id) ON DELETE CASCADE,
294
+ agent_node TEXT NOT NULL,
295
+ every_minutes INTEGER NOT NULL CHECK(every_minutes >= 5),
296
+ enabled INTEGER NOT NULL DEFAULT 1,
297
+ last_run_at TEXT,
298
+ max_runs INTEGER,
299
+ runs_created INTEGER NOT NULL DEFAULT 0,
300
+ created_by TEXT NOT NULL,
301
+ created_at TEXT NOT NULL,
302
+ updated_at TEXT NOT NULL
303
+ );
304
+ CREATE UNIQUE INDEX IF NOT EXISTS idx_schedules_agent
305
+ ON schedules(nest_id, agent_node);
306
+
307
+ CREATE TABLE IF NOT EXISTS nest_env (
308
+ nest_id TEXT NOT NULL REFERENCES nests(id) ON DELETE CASCADE,
309
+ key TEXT NOT NULL,
310
+ value TEXT NOT NULL,
311
+ updated_by TEXT NOT NULL,
312
+ updated_at TEXT NOT NULL,
313
+ PRIMARY KEY (nest_id, key)
314
+ );
315
+ CREATE TABLE IF NOT EXISTS watchers (
316
+ id TEXT PRIMARY KEY,
317
+ nest_id TEXT NOT NULL REFERENCES nests(id) ON DELETE CASCADE,
318
+ node_id TEXT NOT NULL,
319
+ user_email TEXT NOT NULL,
320
+ created_by TEXT NOT NULL,
321
+ created_at TEXT NOT NULL
322
+ );
323
+ CREATE UNIQUE INDEX IF NOT EXISTS idx_watchers_unique
324
+ ON watchers(nest_id, node_id, user_email);
325
+ CREATE TABLE IF NOT EXISTS notifications (
326
+ id TEXT PRIMARY KEY,
327
+ nest_id TEXT NOT NULL REFERENCES nests(id) ON DELETE CASCADE,
328
+ user_email TEXT NOT NULL,
329
+ kind TEXT NOT NULL,
330
+ subject_id TEXT,
331
+ message TEXT NOT NULL,
332
+ created_at TEXT NOT NULL,
333
+ read_at TEXT
334
+ );
335
+ CREATE INDEX IF NOT EXISTS idx_notifications_user
336
+ ON notifications(user_email, read_at, created_at);
337
+
338
+ CREATE TABLE IF NOT EXISTS connectors (
339
+ id TEXT PRIMARY KEY,
340
+ nest_id TEXT NOT NULL REFERENCES nests(id) ON DELETE CASCADE,
341
+ channel TEXT NOT NULL CHECK(channel IN ('slack', 'teams', 'webhook')),
342
+ url TEXT NOT NULL,
343
+ events TEXT NOT NULL,
344
+ enabled INTEGER NOT NULL DEFAULT 1,
345
+ created_by TEXT NOT NULL,
346
+ created_at TEXT NOT NULL,
347
+ updated_at TEXT NOT NULL
348
+ );
349
+ CREATE INDEX IF NOT EXISTS idx_connectors_nest ON connectors(nest_id);
350
+
351
+ CREATE TABLE IF NOT EXISTS trigger_hooks (
352
+ id TEXT PRIMARY KEY,
353
+ nest_id TEXT NOT NULL REFERENCES nests(id) ON DELETE CASCADE,
354
+ agent_node TEXT NOT NULL,
355
+ preset TEXT NOT NULL CHECK(preset IN ('slack', 'teams', 'webhook')),
356
+ enabled INTEGER NOT NULL DEFAULT 1,
357
+ fire_count INTEGER NOT NULL DEFAULT 0,
358
+ last_fired_at TEXT,
359
+ created_by TEXT NOT NULL,
360
+ created_at TEXT NOT NULL
361
+ );
362
+ CREATE INDEX IF NOT EXISTS idx_hooks_nest ON trigger_hooks(nest_id);
363
+
364
+ CREATE TABLE IF NOT EXISTS edge_types (
365
+ id TEXT PRIMARY KEY,
366
+ nest_id TEXT NOT NULL REFERENCES nests(id) ON DELETE CASCADE,
367
+ name TEXT NOT NULL,
368
+ description TEXT NOT NULL,
369
+ direction TEXT NOT NULL DEFAULT 'directed'
370
+ CHECK(direction IN ('directed', 'undirected')),
371
+ is_flow INTEGER NOT NULL DEFAULT 0,
372
+ condition_schema TEXT,
373
+ color TEXT,
374
+ created_by TEXT NOT NULL,
375
+ created_at TEXT NOT NULL,
376
+ updated_at TEXT NOT NULL
377
+ );
378
+ CREATE UNIQUE INDEX IF NOT EXISTS idx_edge_types_name
379
+ ON edge_types(nest_id, LOWER(name));
380
+
381
+ CREATE TABLE IF NOT EXISTS edges (
382
+ id TEXT PRIMARY KEY,
383
+ nest_id TEXT NOT NULL REFERENCES nests(id) ON DELETE CASCADE,
384
+ from_node TEXT NOT NULL,
385
+ to_node TEXT NOT NULL,
386
+ -- RESTRICT (not CASCADE): the app refuses to delete an edge type while
387
+ -- edges reference it; the DB backs that invariant instead of silently
388
+ -- cascade-deleting live edges if the app check is bypassed. Keep in
389
+ -- lockstep with migrations.ts.
390
+ type_id TEXT NOT NULL REFERENCES edge_types(id) ON DELETE RESTRICT,
391
+ condition_mode TEXT
392
+ CHECK(condition_mode IN ('structured', 'nl', 'open')),
393
+ condition TEXT,
394
+ metadata TEXT,
395
+ created_by TEXT NOT NULL,
396
+ created_at TEXT NOT NULL,
397
+ updated_at TEXT NOT NULL
398
+ );
399
+ CREATE INDEX IF NOT EXISTS idx_edges_from ON edges(nest_id, from_node);
400
+ CREATE INDEX IF NOT EXISTS idx_edges_to ON edges(nest_id, to_node);
401
+ CREATE INDEX IF NOT EXISTS idx_edges_type ON edges(nest_id, type_id);
402
+
403
+ CREATE TABLE IF NOT EXISTS definitions (
404
+ id TEXT PRIMARY KEY,
405
+ nest_id TEXT NOT NULL REFERENCES nests(id) ON DELETE CASCADE,
406
+ term TEXT NOT NULL,
407
+ definition TEXT NOT NULL,
408
+ linked_tag TEXT,
409
+ defined_by TEXT NOT NULL,
410
+ created_at TEXT NOT NULL,
411
+ updated_at TEXT NOT NULL
412
+ );
413
+ -- Case-insensitive uniqueness the portable way (SQLite side uses
414
+ -- COLLATE NOCASE; Postgres has no NOCASE collation).
415
+ CREATE UNIQUE INDEX IF NOT EXISTS idx_definitions_term
416
+ ON definitions(nest_id, LOWER(term));
417
+
263
418
  -- node_deletions tombstones (migration 013). DELETE /nodes purges all other
264
419
  -- governance rows for the node; this is the only record that a doc was
265
420
  -- removed, read by GET /nests/:id/changes. One row per (nest, node); a
@@ -291,6 +446,53 @@ async function runPostgresMigrations(db) {
291
446
  duration_ms INTEGER
292
447
  );
293
448
  CREATE INDEX IF NOT EXISTS idx_api_events_ts ON api_events(ts);
449
+ -- (nest_id, id) composite (migration 026): the per-nest trace view
450
+ -- (GET /nests/:id/trace) filters by nest_id and pages newest-first by id.
451
+ CREATE INDEX IF NOT EXISTS idx_api_events_nest_ts ON api_events(nest_id, id);
452
+
453
+ CREATE TABLE IF NOT EXISTS runs (
454
+ id TEXT PRIMARY KEY,
455
+ nest_id TEXT NOT NULL REFERENCES nests(id) ON DELETE CASCADE,
456
+ agent_node TEXT NOT NULL,
457
+ triggered_by TEXT NOT NULL,
458
+ status TEXT NOT NULL DEFAULT 'running'
459
+ CHECK(status IN ('running', 'succeeded', 'failed', 'cancelled')),
460
+ inputs TEXT,
461
+ trace TEXT,
462
+ started_at TEXT NOT NULL,
463
+ finished_at TEXT,
464
+ claimed_by TEXT,
465
+ claimed_at TEXT
466
+ );
467
+ CREATE INDEX IF NOT EXISTS idx_runs_nest ON runs(nest_id, started_at);
468
+ CREATE INDEX IF NOT EXISTS idx_runs_agent ON runs(nest_id, agent_node);
469
+
470
+ CREATE TABLE IF NOT EXISTS run_steps (
471
+ id SERIAL PRIMARY KEY,
472
+ run_id TEXT NOT NULL REFERENCES runs(id) ON DELETE CASCADE,
473
+ seq INTEGER NOT NULL,
474
+ node_id TEXT,
475
+ edge_id TEXT,
476
+ action TEXT NOT NULL,
477
+ detail TEXT,
478
+ at TEXT NOT NULL
479
+ );
480
+ CREATE UNIQUE INDEX IF NOT EXISTS idx_run_steps ON run_steps(run_id, seq);
481
+ ALTER TABLE runs ADD COLUMN IF NOT EXISTS parent_run_id TEXT;
482
+ ALTER TABLE runs ADD COLUMN IF NOT EXISTS depth INTEGER NOT NULL DEFAULT 0;
483
+ CREATE INDEX IF NOT EXISTS idx_runs_parent ON runs(parent_run_id);
484
+
485
+ -- server_settings (migration 020): durable store for runtime-mutable server
486
+ -- config (admin Settings + installed license key), loaded into process.env
487
+ -- at boot. Replaces the ephemeral .env-file persistence. value NULL is a
488
+ -- tombstone (explicitly cleared); env_at_write is the deploy-env baseline
489
+ -- for reconcile precedence \u2014 see db/settings.ts.
490
+ CREATE TABLE IF NOT EXISTS server_settings (
491
+ key TEXT PRIMARY KEY,
492
+ value TEXT,
493
+ env_at_write TEXT,
494
+ updated_at TEXT NOT NULL DEFAULT ${NOW}
495
+ );
294
496
 
295
497
  CREATE TABLE IF NOT EXISTS schema_migrations (
296
498
  id TEXT PRIMARY KEY,
@@ -6,12 +6,15 @@ import {
6
6
  getReviewQueue,
7
7
  reject,
8
8
  submitForReview
9
- } from "./chunk-Z3Y46ZGU.js";
10
- import "./chunk-XNGOO6RI.js";
9
+ } from "./chunk-ZM4F7MY7.js";
10
+ import "./chunk-7PQREKSM.js";
11
+ import "./chunk-UHUU3VAK.js";
11
12
  import {
12
13
  canUserApprove
13
- } from "./chunk-PJTAUVD7.js";
14
- import "./chunk-PLAHCDQG.js";
14
+ } from "./chunk-KFGZIECB.js";
15
+ import "./chunk-3JTODC3Y.js";
16
+ import "./chunk-XQ46F76G.js";
17
+ import "./chunk-BC6KFUZH.js";
15
18
  import "./chunk-SLTQACJW.js";
16
19
  export {
17
20
  approve,
@@ -20,8 +20,10 @@ import {
20
20
  syncFromConfig,
21
21
  updateSteward,
22
22
  updateStewardRole
23
- } from "./chunk-PJTAUVD7.js";
24
- import "./chunk-PLAHCDQG.js";
23
+ } from "./chunk-KFGZIECB.js";
24
+ import "./chunk-3JTODC3Y.js";
25
+ import "./chunk-XQ46F76G.js";
26
+ import "./chunk-BC6KFUZH.js";
25
27
  import "./chunk-SLTQACJW.js";
26
28
  export {
27
29
  assignSteward,
@@ -11,8 +11,9 @@ import {
11
11
  hashContent,
12
12
  setApprovedVersion,
13
13
  systemAuthor
14
- } from "./chunk-XNGOO6RI.js";
15
- import "./chunk-PLAHCDQG.js";
14
+ } from "./chunk-UHUU3VAK.js";
15
+ import "./chunk-XQ46F76G.js";
16
+ import "./chunk-BC6KFUZH.js";
16
17
  import "./chunk-SLTQACJW.js";
17
18
  export {
18
19
  SYSTEM_AUTHOR_PREFIX,