@radnine/claude-session-daemon 0.7.5 → 0.8.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/package.json
CHANGED
package/src/claude-process.js
CHANGED
|
@@ -48,6 +48,7 @@ class ClaudeProcess extends EventEmitter {
|
|
|
48
48
|
this._sessionEnv = options.sessionEnv || {};
|
|
49
49
|
this._systemPrompt = options.systemPrompt || null;
|
|
50
50
|
this._model = options.model || null;
|
|
51
|
+
this._effort = options.effort || null;
|
|
51
52
|
|
|
52
53
|
this._state = 'idle';
|
|
53
54
|
this._child = null;
|
|
@@ -95,6 +96,10 @@ class ClaudeProcess extends EventEmitter {
|
|
|
95
96
|
args.push('--model', this._model);
|
|
96
97
|
}
|
|
97
98
|
|
|
99
|
+
if (this._effort) {
|
|
100
|
+
args.push('--effort', this._effort);
|
|
101
|
+
}
|
|
102
|
+
|
|
98
103
|
if (this._systemPrompt) {
|
|
99
104
|
args.push('--append-system-prompt', this._systemPrompt);
|
|
100
105
|
}
|
|
@@ -8,6 +8,7 @@ const WebSocket = require('ws');
|
|
|
8
8
|
const { BaseConnection } = require('./base-connection');
|
|
9
9
|
const { getGitContext } = require('../git-context');
|
|
10
10
|
const { getClaudeAccount } = require('../claude-account');
|
|
11
|
+
const { getMachineEffort } = require('../machine-effort');
|
|
11
12
|
const { scanPersonas, readPersonaBody } = require('../persona-scanner');
|
|
12
13
|
const daemonPkg = require('../../package.json');
|
|
13
14
|
|
|
@@ -564,13 +565,15 @@ class ActionCableClient extends BaseConnection {
|
|
|
564
565
|
async _sendDaemonRegistration() {
|
|
565
566
|
this._logger.info('Sending daemon registration');
|
|
566
567
|
|
|
567
|
-
const [gitContext, claudeAccount] = await Promise.all([
|
|
568
|
+
const [gitContext, claudeAccount, machineEffort] = await Promise.all([
|
|
568
569
|
this._getGitContext(),
|
|
569
570
|
this._getClaudeAccount(),
|
|
571
|
+
this._getMachineEffort(),
|
|
570
572
|
]);
|
|
571
573
|
|
|
572
574
|
this.sendDaemonMessage({
|
|
573
575
|
type: 'pilot_connect',
|
|
576
|
+
machine_effort: machineEffort,
|
|
574
577
|
version: daemonPkg.version,
|
|
575
578
|
auth: {
|
|
576
579
|
token: this._authToken,
|
|
@@ -653,6 +656,7 @@ class ActionCableClient extends BaseConnection {
|
|
|
653
656
|
const resetGit = !!message.reset_git_state;
|
|
654
657
|
const systemPromptPath = message.system_prompt_path || undefined;
|
|
655
658
|
const model = message.model || undefined;
|
|
659
|
+
const effort = message.reasoning_effort || undefined;
|
|
656
660
|
let systemPrompt = message.system_prompt || undefined;
|
|
657
661
|
|
|
658
662
|
if (systemPromptPath) {
|
|
@@ -684,6 +688,7 @@ class ActionCableClient extends BaseConnection {
|
|
|
684
688
|
resetGit,
|
|
685
689
|
systemPrompt,
|
|
686
690
|
model,
|
|
691
|
+
effort,
|
|
687
692
|
});
|
|
688
693
|
|
|
689
694
|
this.sendDaemonMessage({
|
|
@@ -1147,10 +1152,11 @@ class ActionCableClient extends BaseConnection {
|
|
|
1147
1152
|
* Send a heartbeat message to the server.
|
|
1148
1153
|
*/
|
|
1149
1154
|
async _sendHeartbeat() {
|
|
1150
|
-
const [gitContext, claudeAccount, personas] = await Promise.all([
|
|
1155
|
+
const [gitContext, claudeAccount, personas, machineEffort] = await Promise.all([
|
|
1151
1156
|
this._getGitContext(),
|
|
1152
1157
|
this._getClaudeAccount(),
|
|
1153
1158
|
this._getPersonas(),
|
|
1159
|
+
this._getMachineEffort(),
|
|
1154
1160
|
]);
|
|
1155
1161
|
|
|
1156
1162
|
this.sendDaemonMessage({
|
|
@@ -1162,6 +1168,7 @@ class ActionCableClient extends BaseConnection {
|
|
|
1162
1168
|
resource_usage: this._getResourceUsage(),
|
|
1163
1169
|
git_context: gitContext,
|
|
1164
1170
|
claude_account: claudeAccount,
|
|
1171
|
+
machine_effort: machineEffort,
|
|
1165
1172
|
personas,
|
|
1166
1173
|
timestamp: new Date().toISOString(),
|
|
1167
1174
|
});
|
|
@@ -1212,6 +1219,19 @@ class ActionCableClient extends BaseConnection {
|
|
|
1212
1219
|
}
|
|
1213
1220
|
}
|
|
1214
1221
|
|
|
1222
|
+
/**
|
|
1223
|
+
* Get this machine's effective default reasoning effort (CLAUDE_EFFORT env or
|
|
1224
|
+
* ~/.claude/settings.json `effort`). Returns null when unknown. 60s cache.
|
|
1225
|
+
*/
|
|
1226
|
+
async _getMachineEffort() {
|
|
1227
|
+
try {
|
|
1228
|
+
return await getMachineEffort();
|
|
1229
|
+
} catch (err) {
|
|
1230
|
+
this._logger.warn('Failed to read machine effort', { error: err.message });
|
|
1231
|
+
return null;
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1215
1235
|
/**
|
|
1216
1236
|
* Get a summary of daemon sessions from the daemon health check.
|
|
1217
1237
|
* @returns {object}
|
package/src/daemon.js
CHANGED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('node:fs').promises;
|
|
4
|
+
const os = require('node:os');
|
|
5
|
+
const path = require('node:path');
|
|
6
|
+
|
|
7
|
+
const CACHE_TTL_MS = 60_000;
|
|
8
|
+
let _cache = null; // { value, expiresAt }
|
|
9
|
+
|
|
10
|
+
// The reasoning-effort levels the Claude CLI accepts (`claude --effort <level>`).
|
|
11
|
+
// Anything outside this set is treated as unknown.
|
|
12
|
+
const ALLOWED_EFFORTS = ['low', 'medium', 'high', 'xhigh', 'max'];
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Read this machine's effective default reasoning effort.
|
|
16
|
+
*
|
|
17
|
+
* The Claude CLI does not report its effective effort anywhere observable, so
|
|
18
|
+
* the daemon — which legitimately owns machine config — reads it directly.
|
|
19
|
+
* Precedence: the `CLAUDE_EFFORT` env var (the CLI's runtime override), then
|
|
20
|
+
* the `effort` key in `~/.claude/settings.json`. Returns null ("unknown") when
|
|
21
|
+
* neither source provides a valid level — never a fabricated default.
|
|
22
|
+
*
|
|
23
|
+
* Cached for 60s; returns null if the settings file is missing/malformed.
|
|
24
|
+
*
|
|
25
|
+
* @param {string} [filePath] - Override settings.json path for tests.
|
|
26
|
+
* @returns {Promise<string|null>}
|
|
27
|
+
*/
|
|
28
|
+
async function getMachineEffort(filePath) {
|
|
29
|
+
const now = Date.now();
|
|
30
|
+
if (!filePath && _cache && _cache.expiresAt > now) {
|
|
31
|
+
return _cache.value;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
let value = null;
|
|
35
|
+
|
|
36
|
+
const fromEnv = process.env.CLAUDE_EFFORT;
|
|
37
|
+
if (ALLOWED_EFFORTS.includes(fromEnv)) {
|
|
38
|
+
value = fromEnv;
|
|
39
|
+
} else {
|
|
40
|
+
const target = filePath || path.join(os.homedir(), '.claude', 'settings.json');
|
|
41
|
+
try {
|
|
42
|
+
const raw = await fs.readFile(target, 'utf8');
|
|
43
|
+
const parsed = JSON.parse(raw);
|
|
44
|
+
if (parsed && ALLOWED_EFFORTS.includes(parsed.effort)) {
|
|
45
|
+
value = parsed.effort;
|
|
46
|
+
}
|
|
47
|
+
} catch (_) {
|
|
48
|
+
value = null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (!filePath) {
|
|
53
|
+
_cache = { value, expiresAt: now + CACHE_TTL_MS };
|
|
54
|
+
}
|
|
55
|
+
return value;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function _resetCacheForTests() {
|
|
59
|
+
_cache = null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
module.exports = { getMachineEffort, ALLOWED_EFFORTS, _resetCacheForTests };
|