@kelceyp/caw-server 1.0.288 → 1.0.289
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/claude-config-dir-guard.mjs +105 -0
- package/dist/main.js +439 -428
- package/dist/pty-non-interactive-setup.mjs +30 -18
- package/dist/pty-wrapper.mjs +23 -8
- package/dist/public_html/main.js +519 -519
- package/dist/public_html/styles.css +1 -1
- package/package.json +4 -3
|
@@ -7,14 +7,22 @@
|
|
|
7
7
|
* `--skip-non-interactive-setup`.
|
|
8
8
|
*
|
|
9
9
|
* Fail-fast / atomic / idempotent write contract (As1016):
|
|
10
|
+
* - `CLAUDE_CONFIG_DIR` refused → before any filesystem access, throw the
|
|
11
|
+
* As1065 guard's own error (`assertClaudeConfigDirForwardable` in
|
|
12
|
+
* `claude-config-dir-guard.mjs`), whose message starts with
|
|
13
|
+
* `CLAUDE_CONFIG_DIR_REFUSED (<RULE>): ...`. This module does not own
|
|
14
|
+
* the config-dir check; it delegates to the guard, the same predicate
|
|
15
|
+
* the claude strategies' direct-mode `validatePrerequisites` apply.
|
|
10
16
|
* - Absent → seed with data = {} and mode 0o644, then atomic write.
|
|
11
17
|
* - Present but stat/read/parse fails (with one-shot SyntaxError retry) →
|
|
12
18
|
* throw a typed error whose message starts with
|
|
13
|
-
* `CLAUDE_JSON_UNREADABLE (<code>): <path>. ...`. No write.
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
19
|
+
* `CLAUDE_JSON_UNREADABLE (<code>): <path>. ...`. No write.
|
|
20
|
+
* - The wrapper's discriminating catch (the `ensureNonInteractiveSetup`
|
|
21
|
+
* call site in `pty-wrapper.mjs`) classifies both prefixes,
|
|
22
|
+
* `CLAUDE_JSON_UNREADABLE` and `CLAUDE_CONFIG_DIR_REFUSED`: it re-emits
|
|
23
|
+
* `err.message + '\n'` to stderr and calls `process.exit(1)` —
|
|
24
|
+
* byte-for-byte identical to today's inline behaviour. Every other
|
|
25
|
+
* error is rethrown by the wrapper.
|
|
18
26
|
* - Present and read succeeded → apply the guarded mutations; short-circuit
|
|
19
27
|
* via the idempotent guard when both onboarding and every trust-set entry
|
|
20
28
|
* are already recorded.
|
|
@@ -36,7 +44,9 @@
|
|
|
36
44
|
* from `server/dist/`, and the wrapper carries its own inline copy for the
|
|
37
45
|
* same reason. Three co-located literals (`shared/jobErrorPrefixes.js`,
|
|
38
46
|
* `pty-wrapper.mjs`, this module) must stay in sync per As1016 D8 (extended
|
|
39
|
-
* from dual- to triple-literal by this commit).
|
|
47
|
+
* from dual- to triple-literal by this commit). The
|
|
48
|
+
* `CLAUDE_CONFIG_DIR_REFUSED` prefix is not carried here: it lives in the
|
|
49
|
+
* guard (literal copy 2 of 2; copy 1 is in `shared/jobErrorPrefixes.js`).
|
|
40
50
|
*/
|
|
41
51
|
|
|
42
52
|
import {
|
|
@@ -53,6 +63,7 @@ import {
|
|
|
53
63
|
readdirSync,
|
|
54
64
|
} from 'fs';
|
|
55
65
|
import { join, dirname, basename, resolve, isAbsolute } from 'path';
|
|
66
|
+
import { assertClaudeConfigDirForwardable } from './claude-config-dir-guard.mjs';
|
|
56
67
|
|
|
57
68
|
export const CLAUDE_JSON_UNREADABLE_PREFIX = 'CLAUDE_JSON_UNREADABLE';
|
|
58
69
|
|
|
@@ -83,18 +94,19 @@ export const ensureNonInteractiveSetup = (cwd, { home, configDir, log = noopLog
|
|
|
83
94
|
// not consult, silently defeating both the setup and the mutex that
|
|
84
95
|
// serialises writes to it. Route the seed through `$CLAUDE_CONFIG_DIR`
|
|
85
96
|
// when it is present, else fall back to `$HOME` (Task 3 pre-AC-19
|
|
86
|
-
// behaviour).
|
|
87
|
-
//
|
|
88
|
-
//
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
97
|
+
// behaviour).
|
|
98
|
+
//
|
|
99
|
+
// The value check belongs to the As1065 guard
|
|
100
|
+
// (`assertClaudeConfigDirForwardable`), the same predicate the claude
|
|
101
|
+
// strategies' direct-mode `validatePrerequisites` apply. A refused value
|
|
102
|
+
// throws the guard's own `CLAUDE_CONFIG_DIR_REFUSED (<RULE>): ...` error,
|
|
103
|
+
// unwrapped, before anything below touches the filesystem; the wrapper's
|
|
104
|
+
// discriminating catch classifies that prefix alongside
|
|
105
|
+
// `CLAUDE_JSON_UNREADABLE`. `configDir` is `string | undefined`: a
|
|
106
|
+
// non-string, including `null`, throws the guard's `TypeError` (As1065
|
|
107
|
+
// KD5).
|
|
108
|
+
assertClaudeConfigDirForwardable(configDir);
|
|
109
|
+
const baseDir = configDir === undefined ? home : configDir;
|
|
98
110
|
|
|
99
111
|
const nominal = join(baseDir, '.claude.json');
|
|
100
112
|
|
package/dist/pty-wrapper.mjs
CHANGED
|
@@ -27,6 +27,7 @@ import { readSentinelPayload, hasPendingWork } from './pty-deferred-teardown.mjs
|
|
|
27
27
|
import { emitResult as emitResultLine } from './pty-emit-result.mjs';
|
|
28
28
|
import { TEARDOWN_REASONS } from './teardownReasons.mjs';
|
|
29
29
|
import { ensureNonInteractiveSetup } from './pty-non-interactive-setup.mjs';
|
|
30
|
+
import { CLAUDE_CONFIG_DIR_REFUSED_PREFIX } from './claude-config-dir-guard.mjs';
|
|
30
31
|
import { createTranscriptTailer } from './transcript-tailer.mjs';
|
|
31
32
|
import { createPromptRejectionDetector } from './prompt-rejection-detector.mjs';
|
|
32
33
|
|
|
@@ -91,8 +92,10 @@ try {
|
|
|
91
92
|
// (`claude-session.js#getDockerConfig`'s `commandParts` omits it by
|
|
92
93
|
// design), so the in-container wrapper still runs the setup itself. This
|
|
93
94
|
// wrapper's local call site preserves the same discriminating catch that
|
|
94
|
-
// re-emits classified
|
|
95
|
-
//
|
|
95
|
+
// re-emits classified errors byte-for-byte with today's stderr + exit
|
|
96
|
+
// contract and rethrows every other error. Two prefixes are classified:
|
|
97
|
+
// `CLAUDE_JSON_UNREADABLE` (As1016) and `CLAUDE_CONFIG_DIR_REFUSED` (As1065,
|
|
98
|
+
// the guard's refusal of the container's own `CLAUDE_CONFIG_DIR`). See As1016
|
|
96
99
|
// for the fail-fast / atomic / idempotent invariants that module preserves.
|
|
97
100
|
//
|
|
98
101
|
// The invocation stays here (post log()/stdin-drain/claude-binary,
|
|
@@ -117,6 +120,12 @@ try {
|
|
|
117
120
|
// `server/dist/`, and the wrapper keeps this local const so the
|
|
118
121
|
// discriminating catch below can classify without importing the sibling's
|
|
119
122
|
// export. Keep all three literals in sync per As1016 D8.
|
|
123
|
+
//
|
|
124
|
+
// The second classified prefix, `CLAUDE_CONFIG_DIR_REFUSED_PREFIX`, is NOT
|
|
125
|
+
// carried as a literal here: it is imported above from
|
|
126
|
+
// `./claude-config-dir-guard.mjs`, which is already in this wrapper's
|
|
127
|
+
// closure via `pty-non-interactive-setup.mjs`. It has exactly two literals
|
|
128
|
+
// (`shared/jobErrorPrefixes.js` and the guard; As1065 KD4).
|
|
120
129
|
const CLAUDE_JSON_UNREADABLE_PREFIX = 'CLAUDE_JSON_UNREADABLE';
|
|
121
130
|
|
|
122
131
|
// As1050 Commit B (C3) — the `--skip-non-interactive-setup` CLI arg is
|
|
@@ -138,14 +147,20 @@ if (!hasFlag('--skip-non-interactive-setup')) {
|
|
|
138
147
|
log
|
|
139
148
|
});
|
|
140
149
|
} catch (err) {
|
|
141
|
-
// Discriminating catch: only classified
|
|
142
|
-
//
|
|
150
|
+
// Discriminating catch: only throws with one of the two classified
|
|
151
|
+
// prefixes are re-emitted to stderr as a fail-fast (matching today's
|
|
143
152
|
// process.stderr.write + process.exit(1) contract byte-for-byte; the
|
|
144
153
|
// extracted module's `.message` omits the trailing `\n` that the wrapper
|
|
145
|
-
// concatenates here)
|
|
146
|
-
//
|
|
147
|
-
//
|
|
148
|
-
|
|
154
|
+
// concatenates here):
|
|
155
|
+
// - `CLAUDE_JSON_UNREADABLE` — the As1016 file-level and `HOME_UNSET`
|
|
156
|
+
// fail-fast branches;
|
|
157
|
+
// - `CLAUDE_CONFIG_DIR_REFUSED` — the As1065 guard refusing the
|
|
158
|
+
// container's own `CLAUDE_CONFIG_DIR` (`ensureNonInteractiveSetup`
|
|
159
|
+
// delegates its config-dir check to `assertClaudeConfigDirForwardable`).
|
|
160
|
+
// All other errors are RETHROWN — the wrapper does NOT swallow them, so
|
|
161
|
+
// today's uncaught-exception behaviour on unclassified failures is
|
|
162
|
+
// preserved.
|
|
163
|
+
if (err && typeof err.message === 'string' && (err.message.startsWith(CLAUDE_JSON_UNREADABLE_PREFIX) || err.message.startsWith(CLAUDE_CONFIG_DIR_REFUSED_PREFIX))) {
|
|
149
164
|
process.stderr.write(err.message + '\n');
|
|
150
165
|
process.exit(1);
|
|
151
166
|
}
|