@north-light/api 0.3.741 → 0.3.742

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.
@@ -1,6 +1,6 @@
1
1
  import { type HealthDTO, type StartupPhaseDTO } from '../api/index.js';
2
2
  import type { DumpResult } from '../core/import/export/dump.js';
3
- /** Env keys that must NEVER reach the daemon process. Restarting crtrd is
3
+ /** Non-`CRTR_*` env keys that must NEVER reach the daemon process. Restarting crtrd is
4
4
  * overwhelmingly done from inside an agent node's own bash tool (`crtr sys
5
5
  * daemon stop && start`), which inherits that node's FULL env — its identity
6
6
  * (`CRTR_NODE_ID`/`CRTR_KIND`/…, the `nodeEnv()` shape in `core/runtime/
@@ -15,10 +15,10 @@ import type { DumpResult } from '../core/import/export/dump.js';
15
15
  * relaunch it ever attempts, for its whole lifetime — the 2026-07-06 diagnosis
16
16
  * root cause behind 19 nodes killed with "failed to relaunch and is now dead". */
17
17
  export declare const DAEMON_ENV_STRIP_KEYS: readonly string[];
18
- /** A copy of `process.env` with every `DAEMON_ENV_STRIP_KEYS` entry removed.
19
- * Deliberate global config the user actually wants the daemon to see —
20
- * `CRTR_HOME`, `CRTR_SUBTREE`, `CRTR_LOG`, `CRTR_DEBUG`, etc. — passes through
21
- * untouched; only the node-identity/engine-poisoning surface is stripped. */
18
+ /** Whether a daemon process inherits this env name. */
19
+ export declare function daemonKeepsEnv(key: string): boolean;
20
+ /** A copy of `process.env` for a daemon process: the ordinary host env and the operator `CRTR_*` settings pass; every
21
+ * per-execution `CRTR_*` name and every `DAEMON_ENV_STRIP_KEYS` entry is dropped. */
22
22
  export declare function sanitizedDaemonEnv(): NodeJS.ProcessEnv;
23
23
  /** A crtrd declares its owning canvas in argv, so ownership is an exact match
24
24
  * on this process's canvas home. Untagged daemons retain their own
@@ -23,7 +23,7 @@ import { envNoDaemonAutostart } from '../shared/env.js';
23
23
  import { waitForDaemonAvailability } from '../api/index.js';
24
24
  import { localClient } from '../api/node-transport.js';
25
25
  // Daemon env sanitization
26
- /** Env keys that must NEVER reach the daemon process. Restarting crtrd is
26
+ /** Non-`CRTR_*` env keys that must NEVER reach the daemon process. Restarting crtrd is
27
27
  * overwhelmingly done from inside an agent node's own bash tool (`crtr sys
28
28
  * daemon stop && start`), which inherits that node's FULL env — its identity
29
29
  * (`CRTR_NODE_ID`/`CRTR_KIND`/…, the `nodeEnv()` shape in `core/runtime/
@@ -38,19 +38,6 @@ import { localClient } from '../api/node-transport.js';
38
38
  * relaunch it ever attempts, for its whole lifetime — the 2026-07-06 diagnosis
39
39
  * root cause behind 19 nodes killed with "failed to relaunch and is now dead". */
40
40
  export const DAEMON_ENV_STRIP_KEYS = [
41
- // Node identity (nodeEnv() shape) — meaningless for a process supervising
42
- // many nodes rather than being one.
43
- 'CRTR_NODE_ID',
44
- 'CRTR_KIND',
45
- 'CRTR_MODE',
46
- 'CRTR_LIFECYCLE',
47
- 'CRTR_NODE_CWD',
48
- 'CRTR_CONTEXT_DIR',
49
- 'CRTR_CYCLES',
50
- 'CRTR_PROFILE_ID',
51
- 'CRTR_PARENT_NODE_ID',
52
- // Recursion-guard flag — only meaningful inside a pi engine process.
53
- 'CRTR_FRONT_DOOR',
54
41
  // Ambient tmux identity of whatever shell first autostarted the daemon. The
55
42
  // daemon is a headless supervisor with no pane of its own, but `spawnNode`
56
43
  // reads `currentTmux()` for a --root's foreground viewer placement; a stale
@@ -63,22 +50,46 @@ export const DAEMON_ENV_STRIP_KEYS = [
63
50
  // unaffected — the tmux CLI reaches the server via its default socket.
64
51
  'TMUX',
65
52
  'TMUX_PANE',
66
- // Engine-resolution seams NOT overridden per child launch — the proven and
67
- // suspected poison vectors.
68
- 'CRTR_BROKER_ENGINE',
69
- 'CRTR_PI_BINARY',
70
53
  // Generic Node.js env poisoning (a stray dev/debug flag from the restarting
71
54
  // shell).
72
55
  'NODE_OPTIONS',
73
56
  ];
74
- /** A copy of `process.env` with every `DAEMON_ENV_STRIP_KEYS` entry removed.
75
- * Deliberate global config the user actually wants the daemon to see —
76
- * `CRTR_HOME`, `CRTR_SUBTREE`, `CRTR_LOG`, `CRTR_DEBUG`, etc. — passes through
77
- * untouched; only the node-identity/engine-poisoning surface is stripped. */
57
+ /** The `CRTR_*` names the daemon keeps: deployment and operator settings for the whole canvas. Every other `CRTR_*` name is
58
+ * dropped, because crtr sets the rest on one node, cron, job or broker (its identity, its relay socket, its tokens, its
59
+ * model), and a daemon started from that shell would otherwise act as that one execution. `CRTR_API_SOCKET` reaching the
60
+ * daemon made a Mac's self-update restart refuse with `no_local_daemon`. `CRTR_BROKER_ENGINE` and `CRTR_PI_BINARY` stay
61
+ * out on purpose: an inherited engine override broke every broker relaunch on 2026-07-06. A new operator setting the
62
+ * daemon must read is added here; a new per-execution name needs nothing. */
63
+ const DAEMON_CRTR_ENV_NAMES = new Set([
64
+ 'CRTR_HOME', 'CRTR_RUNTIME_HOME', 'CRTR_PIDFILE', 'CRTR_RUNTIME', 'CRTR_INSTALL_ID',
65
+ 'CRTR_LOG', 'CRTR_DEBUG', 'CRTR_DEBUG_PID_LIVENESS', 'CRTR_TIMING', 'CRTR_TIMING_PROC',
66
+ 'CRTR_NO_DAEMON_AUTOSTART', 'CRTR_NO_AUTO_UPDATE', 'CRTR_NO_AUTO_INIT', 'CRTR_NO_EXPORTS', 'CRTR_LAYOUT_REFUSE',
67
+ 'CRTR_POSTGRES_HOME', 'CRTR_DATABASE_URL', 'CRTR_DATABASE_SCHEMA', 'CRTR_DATABASE_POOL_MAX', 'CRTR_SCHEMA_DATABASE_URL',
68
+ 'CRTR_DOCUMENT_PORT', 'CRTR_LAUNCHER_SOCKET', 'CRTR_API_ADDRESS', 'CRTR_DIRECTORY_URL', 'CRTR_PUBLIC_API_URL',
69
+ 'CRTR_CANVAS_URL', 'CRTR_CANVAS_CLIENT_ID', 'CRTR_CANVAS_JWK_FILE', 'CRTR_SECRETS_KEY', 'CRTR_IMPORT_SERVICE_TOKEN',
70
+ 'CRTR_PACKAGES_TOKEN', 'CRTR_FEEDBACK_ENDPOINT', 'CRTR_FEEDBACK_TOKEN', 'CRTR_SUPPORT_REPO',
71
+ 'CRTR_BRANDED_HOST', 'CRTR_CODESIGN_IDENTITY', 'CRTR_PLUGIN_REVALIDATE_TTL_MS', 'CRTR_IMPORT_BLOB_WORKERS',
72
+ 'CRTR_MAX_LIVE_BROKERS', 'CRTR_WARN_LIVE_BROKERS', 'CRTR_BROKER_RSS_CAP_MB', 'CRTR_UNATTENDED_PARK_MS', 'CRTR_WARM_POOL',
73
+ 'CRTR_STREAM_WATCHDOG_MS', 'CRTR_CONVERSATION_COMMIT_DEADLINE_MS', 'CRTR_NAME_MODEL', 'CRTR_MODEL_PROVIDER',
74
+ 'CRTR_BROKER_SIGNAL_LONG_PROOF',
75
+ ]);
76
+ /** Operator setting families the daemon keeps whole. `CRTR_TEST_` and `CRTR_FAULT_` are test-lane settings a lane exports for the daemon it starts. */
77
+ const DAEMON_CRTR_ENV_PREFIXES = ['CRTR_DB_', 'CRTR_BOOT_', 'CRTR_R2_', 'CRTR_LEDGER_', 'CRTR_BASH_', 'CRTR_WATCHER_', 'CRTR_RECAP_', 'CRTR_MODEL_AUTH_', 'CRTR_TEST_', 'CRTR_FAULT_'];
78
+ /** Whether a daemon process inherits this env name. */
79
+ export function daemonKeepsEnv(key) {
80
+ if (DAEMON_ENV_STRIP_KEYS.includes(key))
81
+ return false;
82
+ if (!key.startsWith('CRTR_'))
83
+ return true;
84
+ return DAEMON_CRTR_ENV_NAMES.has(key) || DAEMON_CRTR_ENV_PREFIXES.some((prefix) => key.startsWith(prefix));
85
+ }
86
+ /** A copy of `process.env` for a daemon process: the ordinary host env and the operator `CRTR_*` settings pass; every
87
+ * per-execution `CRTR_*` name and every `DAEMON_ENV_STRIP_KEYS` entry is dropped. */
78
88
  export function sanitizedDaemonEnv() {
79
- const env = { ...process.env };
80
- for (const key of DAEMON_ENV_STRIP_KEYS)
81
- delete env[key];
89
+ const env = {};
90
+ for (const [key, value] of Object.entries(process.env))
91
+ if (daemonKeepsEnv(key))
92
+ env[key] = value;
82
93
  return env;
83
94
  }
84
95
  // Entry point resolution
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/api",
3
- "version": "0.3.741",
3
+ "version": "0.3.742",
4
4
  "description": "Typed crtrd /v1 API contract — DTOs, route builders, the error contract, the CrtrClient, and the command-plugin manifest format. Zero runtime dependencies.",
5
5
  "type": "module",
6
6
  "main": "./dist/api/index.js",