caveat-cli 0.20.3 → 0.21.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.
package/dist/caveat.js CHANGED
@@ -1,10 +1,54 @@
1
1
  #!/usr/bin/env node
2
+ import { spawn } from 'node:child_process';
3
+ import { fileURLToPath } from 'node:url';
4
+
5
+ // Install the warning handler before loading any SQLite-dependent product module.
2
6
  process.removeAllListeners('warning');
3
- process.on('warning', (w) => {
4
- if (w && w.name === 'ExperimentalWarning' && typeof w.message === 'string' && w.message.includes('SQLite')) return;
5
- process.stderr.write('(' + (w && w.name) + ') ' + (w && w.message) + '\n');
6
- });
7
- import('./index.js').catch((err) => {
8
- process.stderr.write('[caveat:fatal] ' + (err && err.stack || err) + '\n');
9
- process.exit(1);
7
+ process.on('warning', (warning) => {
8
+ if (warning?.name === 'ExperimentalWarning' && warning.message.includes('SQLite')) return;
9
+ process.stderr.write(`(${warning?.name}) ${warning?.message}\n`);
10
10
  });
11
+
12
+ // Node 22.5 includes SQLite behind a startup flag. Own that requirement in the
13
+ // shipped launcher, so ordinary npm-bin/MCP/hook commands keep the public floor.
14
+ // Feature detection also covers other supported Node versions before unflagging.
15
+ const hasSqlite = Boolean(process.getBuiltinModule?.('node:sqlite'));
16
+ const flagPattern = /^--(?:no-)?experimental-sqlite(?:=|$)/;
17
+ // Node treats underscores as hyphens in option names, but retains original
18
+ // tokens in execArgv. Normalize comparisons only; forward argv/env unchanged.
19
+ const explicitFlag = process.execArgv.some((arg) => flagPattern.test(arg.replaceAll('_', '-'))) ||
20
+ /(?:^|[\s"'])--(?:no-)?experimental-sqlite(?:$|[\s"'=])/.test((process.env.NODE_OPTIONS ?? '').replaceAll('_', '-'));
21
+
22
+ if (!hasSqlite && !explicitFlag && process.allowedNodeEnvironmentFlags.has('--experimental-sqlite')) {
23
+ const child = spawn(process.execPath, [
24
+ ...process.execArgv, '--experimental-sqlite', process.argv[1] ?? fileURLToPath(import.meta.url), ...process.argv.slice(2),
25
+ ], { stdio: 'inherit', shell: false });
26
+ const forwardInterrupt = () => child.kill('SIGINT');
27
+ const forwardTerminate = () => child.kill('SIGTERM');
28
+ process.on('SIGINT', forwardInterrupt);
29
+ process.on('SIGTERM', forwardTerminate);
30
+ const detachSignals = () => {
31
+ process.removeListener('SIGINT', forwardInterrupt);
32
+ process.removeListener('SIGTERM', forwardTerminate);
33
+ };
34
+ child.once('error', () => {
35
+ detachSignals();
36
+ process.stderr.write('[caveat:fatal] unable to start the SQLite-enabled runtime\n');
37
+ process.exitCode = 1;
38
+ });
39
+ child.once('exit', (code, signal) => {
40
+ detachSignals();
41
+ if (signal) {
42
+ // Preserve signal termination rather than turn a killed child into success.
43
+ try { process.kill(process.pid, signal); }
44
+ catch { process.exitCode = 1; }
45
+ } else process.exitCode = code ?? 1;
46
+ });
47
+ } else {
48
+ // An explicit enable/disable is never overridden. A failed flagged child
49
+ // reaches this branch once, so unavailable SQLite cannot create a retry loop.
50
+ import('./index.js').catch((error) => {
51
+ process.stderr.write('[caveat:fatal] ' + (error?.stack || error) + '\n');
52
+ process.exit(1);
53
+ });
54
+ }
@@ -0,0 +1,157 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "urn:caveat:factory-private-evidence-capability:v1",
4
+ "title": "Draft: Caveat official private evidence capability v1",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "schema",
9
+ "product",
10
+ "package_version",
11
+ "public_diagnostic_schema",
12
+ "private_protocol",
13
+ "transports",
14
+ "max_channel_bytes",
15
+ "operation_receipt"
16
+ ],
17
+ "properties": {
18
+ "schema": {
19
+ "const": "caveat.factory_private_evidence_capability.v1"
20
+ },
21
+ "product": {
22
+ "const": "caveat"
23
+ },
24
+ "package_version": {
25
+ "type": "string",
26
+ "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(?:-(?:0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)(?:\\.(?:0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*))*)?(?:\\+[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$",
27
+ "maxLength": 128
28
+ },
29
+ "public_diagnostic_schema": {
30
+ "const": "caveat.native_factory_diagnostics.v1"
31
+ },
32
+ "private_protocol": {
33
+ "const": "caveat.factory_private_evidence.v1"
34
+ },
35
+ "transports": {
36
+ "type": "array",
37
+ "maxItems": 2,
38
+ "uniqueItems": true,
39
+ "items": {
40
+ "oneOf": [
41
+ {
42
+ "type": "object",
43
+ "additionalProperties": false,
44
+ "required": [
45
+ "id",
46
+ "platforms",
47
+ "launch_paths"
48
+ ],
49
+ "properties": {
50
+ "id": {
51
+ "const": "posix-fd-v1"
52
+ },
53
+ "platforms": {
54
+ "type": "array",
55
+ "minItems": 1,
56
+ "maxItems": 2,
57
+ "uniqueItems": true,
58
+ "items": {
59
+ "enum": [
60
+ "linux",
61
+ "darwin"
62
+ ]
63
+ }
64
+ },
65
+ "launch_paths": {
66
+ "type": "array",
67
+ "minItems": 1,
68
+ "maxItems": 1,
69
+ "uniqueItems": true,
70
+ "items": {
71
+ "enum": [
72
+ "direct_node_entry"
73
+ ]
74
+ }
75
+ }
76
+ }
77
+ },
78
+ {
79
+ "type": "object",
80
+ "additionalProperties": false,
81
+ "required": [
82
+ "id",
83
+ "platforms",
84
+ "launch_paths"
85
+ ],
86
+ "properties": {
87
+ "id": {
88
+ "const": "windows-named-pipe-v1"
89
+ },
90
+ "platforms": {
91
+ "type": "array",
92
+ "minItems": 1,
93
+ "maxItems": 1,
94
+ "uniqueItems": true,
95
+ "items": {
96
+ "enum": [
97
+ "win32"
98
+ ]
99
+ }
100
+ },
101
+ "launch_paths": {
102
+ "type": "array",
103
+ "minItems": 1,
104
+ "maxItems": 2,
105
+ "uniqueItems": true,
106
+ "items": {
107
+ "enum": [
108
+ "native_exe",
109
+ "powershell_standard_shim"
110
+ ]
111
+ }
112
+ }
113
+ }
114
+ }
115
+ ]
116
+ },
117
+ "allOf": [
118
+ {
119
+ "contains": {
120
+ "type": "object",
121
+ "required": [
122
+ "id"
123
+ ],
124
+ "properties": {
125
+ "id": {
126
+ "const": "posix-fd-v1"
127
+ }
128
+ }
129
+ },
130
+ "minContains": 0,
131
+ "maxContains": 1
132
+ },
133
+ {
134
+ "contains": {
135
+ "type": "object",
136
+ "required": [
137
+ "id"
138
+ ],
139
+ "properties": {
140
+ "id": {
141
+ "const": "windows-named-pipe-v1"
142
+ }
143
+ }
144
+ },
145
+ "minContains": 0,
146
+ "maxContains": 1
147
+ }
148
+ ]
149
+ },
150
+ "max_channel_bytes": {
151
+ "const": 16384
152
+ },
153
+ "operation_receipt": {
154
+ "const": "not_supported"
155
+ }
156
+ }
157
+ }