all-hands-cli 0.1.2 → 0.1.4
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/.allhands/harness/ah
CHANGED
|
@@ -46,8 +46,16 @@ if [ ! -d "$SCRIPT_DIR/node_modules" ] || ! cmp -s "$SCRIPT_DIR/package.json" "$
|
|
|
46
46
|
cp "$SCRIPT_DIR/package.json" "$SCRIPT_DIR/node_modules/.package.json.cache" 2>/dev/null || true
|
|
47
47
|
fi
|
|
48
48
|
|
|
49
|
-
# CLI daemon socket path
|
|
50
|
-
|
|
49
|
+
# CLI daemon socket path - use /tmp with hash to stay under macOS 104-byte socket path limit
|
|
50
|
+
if command -v shasum >/dev/null 2>&1; then
|
|
51
|
+
DAEMON_HASH=$(printf '%s' "$PROJECT_ROOT" | shasum -a 256 | cut -c1-16)
|
|
52
|
+
elif command -v sha256sum >/dev/null 2>&1; then
|
|
53
|
+
DAEMON_HASH=$(printf '%s' "$PROJECT_ROOT" | sha256sum | cut -c1-16)
|
|
54
|
+
else
|
|
55
|
+
echo "ERROR: neither shasum nor sha256sum found" >&2
|
|
56
|
+
exit 1
|
|
57
|
+
fi
|
|
58
|
+
DAEMON_SOCKET="/tmp/ah-daemon-${DAEMON_HASH}.sock"
|
|
51
59
|
SETTINGS_FILE="$ALLHANDS_DIR/settings.json"
|
|
52
60
|
|
|
53
61
|
# Check if daemon is enabled in settings (default: true)
|
|
@@ -8,12 +8,13 @@
|
|
|
8
8
|
* The daemon runs hooks by intercepting stdout and process.exit(),
|
|
9
9
|
* so hooks don't need any modification.
|
|
10
10
|
*
|
|
11
|
-
* Socket path:
|
|
11
|
+
* Socket path: /tmp/ah-daemon-<hash>.sock (hash of project root)
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import { createServer, createConnection, type Server, type Socket } from 'net';
|
|
15
15
|
import { existsSync, mkdirSync, unlinkSync } from 'fs';
|
|
16
|
-
import {
|
|
16
|
+
import { createHash } from 'crypto';
|
|
17
|
+
import { dirname } from 'path';
|
|
17
18
|
import type { HookInput } from '../hooks/shared.js';
|
|
18
19
|
|
|
19
20
|
// Signal class to catch process.exit() calls
|
|
@@ -39,9 +40,15 @@ export interface DaemonCommand {
|
|
|
39
40
|
|
|
40
41
|
/**
|
|
41
42
|
* Get the socket path for the CLI daemon.
|
|
43
|
+
*
|
|
44
|
+
* Uses /tmp with a hash of the project directory to keep the path short.
|
|
45
|
+
* macOS limits Unix domain socket paths to 104 bytes — project-relative
|
|
46
|
+
* paths like .allhands/harness/.cache/cli-daemon.sock can exceed that
|
|
47
|
+
* in deep directory trees or multi-worktree setups.
|
|
42
48
|
*/
|
|
43
49
|
export function getSocketPath(projectDir: string): string {
|
|
44
|
-
|
|
50
|
+
const hash = createHash('sha256').update(projectDir).digest('hex').slice(0, 16);
|
|
51
|
+
return `/tmp/ah-daemon-${hash}.sock`;
|
|
45
52
|
}
|
|
46
53
|
|
|
47
54
|
/**
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* For stateless servers, uses direct one-shot connections.
|
|
8
8
|
*
|
|
9
|
-
* Daemon socket path:
|
|
9
|
+
* Daemon socket path: /tmp/ah-sessions-<hash>/{AGENT_ID}.sock
|
|
10
10
|
*
|
|
11
11
|
* Session Lifecycle (stateful servers):
|
|
12
12
|
* - Sessions are auto-started on first tool call.
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
import { connect, type Socket } from 'net';
|
|
19
19
|
import { spawn } from 'child_process';
|
|
20
20
|
import { existsSync, readFileSync, mkdirSync } from 'fs';
|
|
21
|
+
import { createHash } from 'crypto';
|
|
21
22
|
import { dirname, join } from 'path';
|
|
22
23
|
import { fileURLToPath } from 'url';
|
|
23
24
|
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
@@ -28,7 +29,12 @@ import { resolveEnvVars } from './mcp-runtime.js';
|
|
|
28
29
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
29
30
|
// Path: harness/src/lib/ -> harness/src/ -> harness/
|
|
30
31
|
const HARNESS_ROOT = join(__dirname, '..', '..');
|
|
31
|
-
|
|
32
|
+
// Derive project root: harness/ -> .allhands/ -> project/
|
|
33
|
+
const PROJECT_ROOT = join(HARNESS_ROOT, '..', '..');
|
|
34
|
+
// Use /tmp with hash of project root to stay under macOS 104-byte Unix socket path limit.
|
|
35
|
+
// Project-relative paths can exceed this in deep directory trees or worktrees.
|
|
36
|
+
const SESSIONS_HASH = createHash('sha256').update(PROJECT_ROOT).digest('hex').slice(0, 16);
|
|
37
|
+
const SESSIONS_DIR = `/tmp/ah-sessions-${SESSIONS_HASH}`;
|
|
32
38
|
const DAEMON_SCRIPT = join(__dirname, 'mcp-daemon.ts');
|
|
33
39
|
|
|
34
40
|
/**
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Each AGENT_ID gets its own daemon instance, enabling parallel sessions.
|
|
8
8
|
*
|
|
9
|
-
* Socket path:
|
|
9
|
+
* Socket path: /tmp/ah-sessions-<hash>/{AGENT_ID}.sock
|
|
10
10
|
*
|
|
11
11
|
* Commands:
|
|
12
12
|
* - { cmd: "call", server: string, tool: string, params: object, config: McpServerConfig }
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
|
|
35
35
|
import { createServer, type Server, type Socket } from 'net';
|
|
36
36
|
import { existsSync, mkdirSync, unlinkSync, writeFileSync } from 'fs';
|
|
37
|
+
import { createHash } from 'crypto';
|
|
37
38
|
import { dirname, join } from 'path';
|
|
38
39
|
import { fileURLToPath } from 'url';
|
|
39
40
|
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
@@ -44,7 +45,12 @@ import { resolveEnvVars, DAEMON_DEFAULT_MCP_TIMEOUT } from './mcp-runtime.js';
|
|
|
44
45
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
45
46
|
// Path: harness/src/lib/ -> harness/src/ -> harness/
|
|
46
47
|
const HARNESS_ROOT = join(__dirname, '..', '..');
|
|
47
|
-
|
|
48
|
+
// Derive project root: harness/ -> .allhands/ -> project/
|
|
49
|
+
const PROJECT_ROOT = join(HARNESS_ROOT, '..', '..');
|
|
50
|
+
// Use /tmp with hash of project root to stay under macOS 104-byte Unix socket path limit.
|
|
51
|
+
// Project-relative paths can exceed this in deep directory trees or worktrees.
|
|
52
|
+
const SESSIONS_HASH = createHash('sha256').update(PROJECT_ROOT).digest('hex').slice(0, 16);
|
|
53
|
+
const SESSIONS_DIR = `/tmp/ah-sessions-${SESSIONS_HASH}`;
|
|
48
54
|
|
|
49
55
|
/**
|
|
50
56
|
* How often to check for session timeouts (30 seconds).
|
package/package.json
CHANGED
package/target-lines.json
CHANGED