@promptowl/contextnest-community 1.11.0 → 1.13.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/CONFIGURATION.md CHANGED
@@ -73,14 +73,19 @@ The server prints a loud warning at startup when `AUTH_MODE=open` is active.
73
73
  | `TELEMETRY_INTERVAL_MS` | `3600000` (1 hour) | How often buffered telemetry is flushed to PromptOwl. |
74
74
  | `TRACE_RETENTION_DAYS` | `14` | Activity-trace retention window in days (the `api_events` rows behind `GET /admin/trace` and `GET /nests/:id/trace`). Rows older than this are pruned opportunistically (every ~500 inserts). `0` = keep forever (pruning is skipped entirely). Capped at `3650`; invalid/negative values fall back to `14`. Also editable from Settings → Advanced. |
75
75
  | `CORS_ORIGINS` | `*` in open mode; `http://localhost:5173,http://localhost:3838` in key mode | Comma-separated allowlist. Set to `*` to allow any origin (**only** safe in open mode — in key mode with Bearer tokens this enables CSRF). |
76
- | `MAX_BODY_BYTES` | `10485760` (10 MB) | Reject requests whose `Content-Length` exceeds this. Prevents giant-payload DoS. |
76
+ | `MAX_BODY_BYTES` | `10485760` (10 MB) | Reject requests whose `Content-Length` exceeds this. Prevents giant-payload DoS. The asset-upload route (`POST /nests/:id/assets`) is exempt up to the video cap below. |
77
+ | `VIDEO_MAX_MB` | `30` | Max size (in MB) of a video uploaded into a doc. Default `30` keeps it under Cloud Run's ~32 MiB HTTP/1 request-body limit, so an oversized video is rejected with a clear message instead of a bare `413` from the platform. Raise only where the deployment can actually accept larger request bodies (not behind Cloud Run, or on HTTP/2 / direct-to-bucket upload). Images are fixed at 10 MB. |
77
78
  | `LOGO_URL` | _(unset)_ | Custom logo shown in the UI header + login screen. Must start with `https://`, `http://`, or `data:image/` — other schemes (`file://`, relative, `javascript:`) are rejected with a warning and the bundled icon is used. |
78
79
  | `PROMPTOWL_TEAMS_ENABLED` | _(unset — off)_ | Lets users who signed in with PromptOwl import their PromptOwl teams as local teams. Off by default; set `true` to enable, or toggle from Settings → Advanced. When off, `GET/POST /teams/promptowl` return `404` and the PromptOwl Teams panel is hidden. Independent of `PROMPTOWL_SIGN_IN_GATE`. |
80
+ | `TYPE_ARTIFACT_ENABLED` | `true` | Set `false` to disable creation of **artifact** nodes server-wide (existing artifact nodes stay readable — never data loss). Runnable types (agent/skill/tool) are gated by `FEATURE_WORKFLOW_PLANE`, not here. Also editable from Settings (`/admin/settings`). |
81
+ | `TYPE_TABLE_ENABLED` | `true` | Same as above for **table** nodes. |
79
82
  | `FEATURE_WORKFLOW_PLANE` | _(unset — off)_ | Enables the workflow plane: typed edges, edge-type registry, governed runs. Optional feature; also toggleable from Settings. |
80
83
  | `FEATURE_SUBAGENT_RUNS` | _(unset — off)_ | Lets runs spawn nested sub-agent runs (recursion). Gated separately from the plane; requires `FEATURE_WORKFLOW_PLANE`. Also toggleable from Settings → Advanced (turning the plane off forces this off too). Opens a recursion surface — enable only after reviewing the depth/fan-out caps. |
81
84
  | `SUBAGENT_MAX_DEPTH` | `8` | Max sub-agent nesting depth (clamped 1..32) — bounds the call tree's HEIGHT so it stays finite/haltable. |
82
85
  | `SUBAGENT_MAX_CHILDREN` | `16` | Max direct children a single run may spawn (clamped 1..128) — bounds the call tree's WIDTH. Together with `SUBAGENT_MAX_DEPTH` this caps total tree size so a runner can't fork-bomb the DB. |
83
86
  | `RUN_MAX_STEPS` | `10000` | Max steps a single run may accumulate (clamped 10..100000) — bounds a runaway/hostile runner's step log. |
87
+ | `RUN_MAX_CONCURRENT_ROOTS` | `50` | Max concurrently-running root (depth-0) runs per nest (clamped 1..1000). The subagent caps bound a single tree; this bounds how many trees can run at once, so triggers can't flood a nest. |
88
+ | `ANTHROPIC_API_KEY` | _(unset)_ | Server-wide default runner key for workflow-plane agent runs. Never returned by the API — the health endpoint reports presence only, and Settings shows a masked tail. |
84
89
  | `SLACK_WEBHOOK_URL` | _(unset — connector off)_ | Slack incoming-webhook URL for governance-event notifications (review submitted/approved/rejected, collaborator added). `https://` only — the URL embeds a secret. Also editable from Settings in the UI. |
85
90
  | `SMTP_URL` | _(unset — connector off)_ | SMTP connection URL for email notifications (`smtp://` or `smtps://`, credentials inline). Requires `NOTIFY_EMAIL_FROM` and `NOTIFY_EMAIL_TO`. Also editable from Settings. |
86
91
  | `NOTIFY_EMAIL_FROM` | _(unset)_ | From address for notification emails. |
package/README.md CHANGED
@@ -101,7 +101,7 @@ For redistribution, hosted-service, OEM, or regulated-industry licensing, contac
101
101
  | Custom logo / branding | ✅ | ✅ |
102
102
  | Admin password reset + user removal (in-platform) | ✅ | ✅ |
103
103
  | Wiki backlinks, outline, hover-preview, link health | ✅ | ✅ |
104
- | Rich editor — tables, callouts, toggles, code highlight, find/replace | ✅ | ✅ |
104
+ | Rich editor — tables, callouts, toggles, code highlight, find/replace, image & video upload | ✅ | ✅ |
105
105
  | Steward version revert | ✅ | ✅ |
106
106
  | MCP server for AI agents | ✅ | ✅ |
107
107
  | Centralized multi-tenant admin console | — | ✅ |
@@ -113,67 +113,9 @@ For redistribution, hosted-service, OEM, or regulated-industry licensing, contac
113
113
 
114
114
  For Enterprise pricing and features, contact **hoot@promptowl.ai** or visit <https://promptowl.ai/contextnest/>.
115
115
 
116
- ## What's new in 1.6.0
116
+ ## What's new
117
117
 
118
- - **PostgreSQL / Cloud SQL backend** — run the server on PostgreSQL alongside SQLite via an async DB adapter, so metadata survives on Cloud Run and other deployments where local disk isn't durable. Supports the Cloud SQL Auth Proxy (unix socket) and TCP + TLS. New `DB_*` env vars (`DB_DRIVER`, `DATABASE_URL`, `CLOUD_SQL_CONNECTION_NAME`, `DB_HOST`/`DB_PORT`/`DB_USER`/`DB_PASSWORD`/`DB_NAME`, `DB_POOL_MAX`, `DB_SSL`, `DB_SSL_CA`); SQLite stays the default when nothing is configured. See [CONFIGURATION.md](./CONFIGURATION.md).
119
- - **Configurable `NEST_STORAGE_ROOT`** — store nest vault files (markdown + version history) outside `DATA_ROOT` — e.g. on a Cloud Storage (GCS) volume mount — while the database stays on `DATA_ROOT`. Defaults to `<DATA_ROOT>/nests`, so existing deployments are unchanged. On a GCS FUSE mount, set `DRIFT_SCAN_INTERVAL_MS=0` and run a single instance.
120
- - **Security fix** — the admin guard on `/admin/settings` (GET/PATCH) is now correctly awaited; without it a non-admin could read or change server-wide settings in key mode.
121
- - **AdminLoginModal respects `PROMPTOWL_SIGN_IN_GATE`** — the "Sign in with PromptOwl" affordance follows the configured gate (`open` / `admin-only` / `disabled`).
122
- - **Drift scanner toggle** — `DRIFT_SCAN_INTERVAL_MS=0` now actually disables the drift scanner (previously reset to the 30s default).
123
- - **Safer folder sync** — unsynced-folder detection no longer treats a configured nest storage root as a sync candidate, preventing accidental duplication/removal of live nests when `NEST_STORAGE_ROOT` is nested under `DATA_ROOT`.
124
-
125
- Full history in [CHANGELOG.md](./CHANGELOG.md).
126
-
127
- ## What's new in 1.3.0
128
-
129
- - **Server super-admins** — emails listed in `access.yaml: super_admins` administer every nest (change visibility, manage collaborators and stewards) without being added per-nest. Owner-only operations (delete, transfer) still require the nest owner. See [STEWARDSHIP.md](./STEWARDSHIP.md).
130
- - **License persistence under `DATA_ROOT`** — `PROMPTOWL_KEY` now writes to `$DATA_ROOT/.env` (was `$cwd/.env`, which is root-owned `/app` in the official Docker image and silently lost the key on container recreate). The License Setup Page also surfaces write failures instead of failing quietly. Override via `ENV_FILE_PATH`. See [CONFIGURATION.md](./CONFIGURATION.md).
131
- - **Case-insensitive email** across registration, login, invite, and access checks. Migration dedupes existing accounts that differ only in case; fixes "I can't log in because I capitalized my email" and access-guard / lockout mismatches.
132
- - **Document version history + inline diff** — every saved version is browsable in the document detail view, and an inline diff highlights what changed between any two versions.
133
- - **Nest Overview / index landing** — every nest opens on a grouped table-of-contents with a "recently edited" strip instead of a flat list.
134
- - **Public/private toggle on the nest header** — visibility is set directly from the header, not buried in a dialog.
135
- - **Review queue surfaces submitted-for-review edits** — reviewers see the pending versions a contributor staged, not just net-new documents.
136
- - **Internal-folder sync over MCP** — agents can list a nest's unsynced filesystem folders and pull them into the nest on demand. New `unsynced-service.ts` + MCP tools, covered by `test/unsynced-folder.test.ts` and `test/mcp-unsynced.test.ts`.
137
- - **Telemetry `batch_id` + user email** — usage events carry a stable `batch_id` (de-duped on the receiver) and the authenticated user email alongside the user id, so the PromptOwl ingest bridge can meter credits to the right account.
138
- - **Hyperlink navigation fix** — hyperlinks in the editor and viewer navigate to their configured target URL correctly.
139
- - **Repo / DX** — `CLAUDE.md` at the repo root with project-specific guidance for Claude Code; `claude.yml` (PR assistant) and `claude-code-review.yml` (auto review on PRs) GitHub Actions workflows.
140
-
141
- Full history in [CHANGELOG.md](./CHANGELOG.md).
142
-
143
- ## What's new in 1.2.0
144
-
145
- - **Admin user management (no email server needed)** — `POST /auth/admin/reset-password/:userId` sets a user's password or returns a one-time temp password; `DELETE /auth/users/:userId` removes a user and revokes their API keys, sessions, and role rows. New self-service **Change password** in the user menu blocks reusing the current password.
146
- - **`PROMPTOWL_SIGN_IN_GATE`** — `open` / `admin-only` / `disabled` restricts "Sign in with PromptOwl" (admin reaches it via `?admin=1`). See [CONFIGURATION.md](./CONFIGURATION.md).
147
- - **Plain-text agent view** — `?format=markdown` on a node returns frontmatter + body as `text/markdown` for LLM-friendly consumption.
148
- - **Steward version revert** — `POST .../revert` restores an earlier version as a new one; pending-review docs are now editable (saving withdraws the review).
149
- - **Editor — always-editable surface** — Notion-style buttery headline, selection bubble toolbar (format-on-highlight), turn-into block conversion, Cmd+F find & replace, rich blocks (tables, callouts, toggles, syntax-highlighted code, columns), and wiki/code-safety fixes.
150
- - **Wiki usability** — backlinks panel ("Linked from N documents"), outline/TOC for 3+-heading docs, hover-preview on `[[wiki links]]`, multi-tag AND filtering with clickable chips, per-doc copy link, rename-safety warning for title-form links, link-health report (broken links + orphans), recently-edited strip.
151
- - **Sharing clarity** — share button reads "Share nest"; dialog clarifies nest-wide scope; deep links open documents directly.
152
- - **Security** — hardened scanner gate (PolinRider + Shai-Hulud preflight) in `bin/`.
153
-
154
- Full history in [CHANGELOG.md](./CHANGELOG.md).
155
-
156
- ## What's new in 1.1.0
157
-
158
- - **Vault import** — import an existing folder of markdown files into a new nest in one step, from the dashboard ("Import folder") or via the API. Frontmatter, wiki links, and folder structure are preserved.
159
- - **Nest sharing + collaborators** — set per-nest visibility and add collaborators with read or write access. A Share affordance is now inline in the document view.
160
- - **Public read-only nests** — flip a nest to `visibility=public` to serve it to unauthenticated readers (bypasses auth for GETs only); writes still require a key.
161
- - **Custom logo / branding** — set `LOGO_URL` to show your own logo in the UI header and login screen. See [CONFIGURATION.md](./CONFIGURATION.md).
162
- - **Governance** — nest owners can self-approve their own changes; new per-nest auto-approve toggle; role-based action gating (buttons reflect the viewer's role); stewards can edit scope during a role change.
163
- - **Editor** — `[[wikilink]]` autocomplete, broken-link click creates a new doc with the title pre-filled, tag chips filter the nest list, Notion-style H1 title, click-to-edit, and an unsaved-changes warning.
164
- - **Stability** — added an error boundary so a render error in one view no longer blanks the whole app; bumped `uuid` to 14.
165
-
166
- Full history in [CHANGELOG.md](./CHANGELOG.md).
167
-
168
- ## What's new in 1.0.1
169
-
170
- - **Document hashing pipeline** — external-edit detection, conflict-aware safe-publish, and inline version diffs powered by `@promptowl/contextnest-engine`. When a file is edited outside the UI, the editor shows an "External edit detected" banner with a side-by-side diff and an adopt / keep choice.
171
- - **Markdown rendering** — new `DocumentViewer` (react-markdown + remark-gfm + wikilink support) renders CLI/MCP-authored markdown correctly, with a view/edit toggle.
172
- - **License revocation now blocks writes synchronously** — revoke flips an in-process "writes blocked" flag immediately; the next write returns `503`.
173
- - **Dashboard stats** — new `GET /stats` endpoint surfaces nest / document / user counts.
174
- - **Docker fix** — Dockerfile now installs via npm against the shipped `package-lock.json`; base image bumped to `node:22-slim`.
175
-
176
- Full history in [CHANGELOG.md](./CHANGELOG.md).
118
+ Release notes live in [CHANGELOG.md](./CHANGELOG.md).
177
119
 
178
120
  ## Licensing
179
121
 
@@ -12,6 +12,7 @@ import { join, dirname } from "path";
12
12
  import { existsSync } from "fs";
13
13
  import { fileURLToPath } from "url";
14
14
  import dotenv from "dotenv";
15
+ import { z } from "zod";
15
16
  var __filename = fileURLToPath(import.meta.url);
16
17
  var __dirname = dirname(__filename);
17
18
  var envCandidates = [
@@ -29,8 +30,9 @@ var slackUrlWarned = false;
29
30
  var emailFromWarned = false;
30
31
  var emailToWarned = false;
31
32
  var oidcIssuerWarned = false;
33
+ var EMAIL_SCHEMA = z.email();
32
34
  function isEmailish(v) {
33
- return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v) && !/[\r\n]/.test(v);
35
+ return EMAIL_SCHEMA.safeParse(v.trim()).success && !/[\r\n]/.test(v);
34
36
  }
35
37
  function isEmailListish(v) {
36
38
  return v.split(",").every((e) => isEmailish(e.trim()));
@@ -494,6 +496,17 @@ var config = {
494
496
  */
495
497
  get MAX_BODY_BYTES() {
496
498
  return parseInt(process.env.MAX_BODY_BYTES || String(10 * 1024 * 1024), 10);
499
+ },
500
+ /**
501
+ * Max video upload size in bytes. Default 30 MB — kept under Cloud Run's
502
+ * 32 MiB HTTP/1 request-body limit so a too-big video is rejected cleanly by
503
+ * our own check (clear message) instead of a bare 413 from the platform.
504
+ * Raise via VIDEO_MAX_MB only when the deployment can actually accept it
505
+ * (e.g. not behind Cloud Run, or on HTTP/2 / direct-to-bucket upload).
506
+ */
507
+ get VIDEO_MAX_BYTES() {
508
+ const mb = parseInt(process.env.VIDEO_MAX_MB || "30", 10);
509
+ return (Number.isFinite(mb) && mb > 0 ? mb : 30) * 1024 * 1024;
497
510
  }
498
511
  };
499
512
 
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-XQ46F76G.js";
5
5
  import {
6
6
  getDb
7
- } from "./chunk-3M7677XW.js";
7
+ } from "./chunk-5QQ7WKAI.js";
8
8
 
9
9
  // src/governance/version-service.ts
10
10
  import { createHash } from "crypto";
@@ -41,6 +41,38 @@ async function createVersion(params) {
41
41
  status: params.status
42
42
  };
43
43
  }
44
+ async function upsertVersion(params) {
45
+ const db = getDb();
46
+ const contentHash = hashContent(params.content);
47
+ const sql = insertOrReplace(
48
+ db,
49
+ `INSERT INTO node_versions (nest_id, node_id, version, content_hash, author, status, change_note, tags_json)
50
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,
51
+ ["nest_id", "node_id", "version"],
52
+ // Reset created_at on conflict too: SQLite's INSERT OR REPLACE deletes+
53
+ // reinserts (created_at → now), so mirror that on Postgres — otherwise a
54
+ // draft edited in place would keep its original (import-time) "edited at".
55
+ `content_hash = excluded.content_hash, author = excluded.author, status = excluded.status, change_note = excluded.change_note, tags_json = excluded.tags_json, created_at = ${nowExpr(db)}`
56
+ );
57
+ await db.run(sql, [
58
+ params.nestId,
59
+ params.nodeId,
60
+ params.version,
61
+ contentHash,
62
+ params.author,
63
+ params.status,
64
+ params.changeNote || null,
65
+ params.tags ? JSON.stringify(params.tags) : null
66
+ ]);
67
+ return {
68
+ version: params.version,
69
+ content: params.content,
70
+ editedBy: params.author,
71
+ editedAt: (/* @__PURE__ */ new Date()).toISOString(),
72
+ changeNote: params.changeNote,
73
+ status: params.status
74
+ };
75
+ }
44
76
  async function getVersions(nestId, nodeId) {
45
77
  const db = getDb();
46
78
  const rows = await db.all(
@@ -172,6 +204,7 @@ export {
172
204
  SYSTEM_AUTHOR_PREFIX,
173
205
  systemAuthor,
174
206
  createVersion,
207
+ upsertVersion,
175
208
  getVersions,
176
209
  getVersion,
177
210
  getCurrentVersion,
@@ -2,12 +2,12 @@ import {
2
2
  grantCoversNode,
3
3
  listUserGrants,
4
4
  resolveNodeGrant
5
- } from "./chunk-ZMSU7BCC.js";
5
+ } from "./chunk-ZQS5W45U.js";
6
6
  import {
7
7
  createVersion,
8
8
  getApprovedVersion,
9
9
  setApprovedVersion
10
- } from "./chunk-JHIU6RZU.js";
10
+ } from "./chunk-EG77SQHO.js";
11
11
  import {
12
12
  buildDocContext,
13
13
  buildTitleMap,
@@ -18,7 +18,7 @@ import {
18
18
  isPublicReader,
19
19
  isStewardshipEnabled,
20
20
  resolveStewardsForNode
21
- } from "./chunk-F7EKYNXG.js";
21
+ } from "./chunk-Q5NRCDD4.js";
22
22
  import {
23
23
  ConflictError,
24
24
  NotFoundError,
@@ -31,7 +31,7 @@ import {
31
31
  import {
32
32
  config,
33
33
  getDb
34
- } from "./chunk-3M7677XW.js";
34
+ } from "./chunk-5QQ7WKAI.js";
35
35
 
36
36
  // src/governance/review-service.ts
37
37
  import { v4 as uuid3 } from "uuid";
@@ -1226,6 +1226,13 @@ async function getReviewQueue(params) {
1226
1226
  whereClauses.push("nest_id = ?");
1227
1227
  args.push(params.nestId);
1228
1228
  }
1229
+ if (params.nestIds) {
1230
+ if (params.nestIds.length === 0) return { requests: [], total: 0 };
1231
+ whereClauses.push(
1232
+ `nest_id IN (${params.nestIds.map(() => "?").join(",")})`
1233
+ );
1234
+ args.push(...params.nestIds);
1235
+ }
1229
1236
  if (params.status) {
1230
1237
  const statuses = Array.isArray(params.status) ? params.status : [params.status];
1231
1238
  whereClauses.push(
@@ -1234,10 +1241,12 @@ async function getReviewQueue(params) {
1234
1241
  args.push(...statuses);
1235
1242
  }
1236
1243
  const where = whereClauses.length > 0 ? `WHERE ${whereClauses.join(" AND ")}` : "";
1237
- const total = (await db.get(
1238
- `SELECT COUNT(*) as c FROM review_requests ${where}`,
1239
- args
1240
- )).c;
1244
+ const total = Number(
1245
+ (await db.get(
1246
+ `SELECT COUNT(*) as c FROM review_requests ${where}`,
1247
+ args
1248
+ )).c
1249
+ );
1241
1250
  const limit = params.limit || 50;
1242
1251
  const offset = params.offset || 0;
1243
1252
  const rows = await db.all(