@slock-ai/daemon 0.40.1 → 0.40.2
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/chat-bridge.js +937 -780
- package/dist/{chunk-E6OOH3IC.js → chunk-JG7ONJZ6.js} +46 -46
- package/dist/{chunk-6YLMU56U.js → chunk-PB75DRIF.js} +69 -1
- package/dist/core.js +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
|
@@ -1,3 +1,46 @@
|
|
|
1
|
+
// src/logger.ts
|
|
2
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
3
|
+
function timestamp() {
|
|
4
|
+
const d = /* @__PURE__ */ new Date();
|
|
5
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
6
|
+
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;
|
|
7
|
+
}
|
|
8
|
+
function format(level, msg) {
|
|
9
|
+
return `${timestamp()} [${level}] ${msg}`;
|
|
10
|
+
}
|
|
11
|
+
function emit(event) {
|
|
12
|
+
for (const listener of listeners) {
|
|
13
|
+
listener(event);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function subscribeDaemonLogs(listener) {
|
|
17
|
+
listeners.add(listener);
|
|
18
|
+
return () => {
|
|
19
|
+
listeners.delete(listener);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
var logger = {
|
|
23
|
+
info(msg) {
|
|
24
|
+
const line = format("INFO", msg);
|
|
25
|
+
console.log(line);
|
|
26
|
+
emit({ level: "INFO", line, message: msg });
|
|
27
|
+
},
|
|
28
|
+
warn(msg) {
|
|
29
|
+
const line = format("WARN", msg);
|
|
30
|
+
console.warn(line);
|
|
31
|
+
emit({ level: "WARN", line, message: msg });
|
|
32
|
+
},
|
|
33
|
+
error(msg, err) {
|
|
34
|
+
const line = format("ERROR", msg);
|
|
35
|
+
if (err) {
|
|
36
|
+
console.error(line, err);
|
|
37
|
+
} else {
|
|
38
|
+
console.error(line);
|
|
39
|
+
}
|
|
40
|
+
emit({ level: "ERROR", line, message: msg, error: err });
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
1
44
|
// src/proxy.ts
|
|
2
45
|
import { HttpsProxyAgent } from "https-proxy-agent";
|
|
3
46
|
import { ProxyAgent } from "undici";
|
|
@@ -67,52 +110,9 @@ function buildFetchDispatcher(targetUrl, env) {
|
|
|
67
110
|
return dispatcher;
|
|
68
111
|
}
|
|
69
112
|
|
|
70
|
-
// src/logger.ts
|
|
71
|
-
var listeners = /* @__PURE__ */ new Set();
|
|
72
|
-
function timestamp() {
|
|
73
|
-
const d = /* @__PURE__ */ new Date();
|
|
74
|
-
const pad = (n) => String(n).padStart(2, "0");
|
|
75
|
-
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;
|
|
76
|
-
}
|
|
77
|
-
function format(level, msg) {
|
|
78
|
-
return `${timestamp()} [${level}] ${msg}`;
|
|
79
|
-
}
|
|
80
|
-
function emit(event) {
|
|
81
|
-
for (const listener of listeners) {
|
|
82
|
-
listener(event);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
function subscribeDaemonLogs(listener) {
|
|
86
|
-
listeners.add(listener);
|
|
87
|
-
return () => {
|
|
88
|
-
listeners.delete(listener);
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
var logger = {
|
|
92
|
-
info(msg) {
|
|
93
|
-
const line = format("INFO", msg);
|
|
94
|
-
console.log(line);
|
|
95
|
-
emit({ level: "INFO", line, message: msg });
|
|
96
|
-
},
|
|
97
|
-
warn(msg) {
|
|
98
|
-
const line = format("WARN", msg);
|
|
99
|
-
console.warn(line);
|
|
100
|
-
emit({ level: "WARN", line, message: msg });
|
|
101
|
-
},
|
|
102
|
-
error(msg, err) {
|
|
103
|
-
const line = format("ERROR", msg);
|
|
104
|
-
if (err) {
|
|
105
|
-
console.error(line, err);
|
|
106
|
-
} else {
|
|
107
|
-
console.error(line);
|
|
108
|
-
}
|
|
109
|
-
emit({ level: "ERROR", line, message: msg, error: err });
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
|
|
113
113
|
export {
|
|
114
|
-
buildWebSocketOptions,
|
|
115
|
-
buildFetchDispatcher,
|
|
116
114
|
subscribeDaemonLogs,
|
|
117
|
-
logger
|
|
115
|
+
logger,
|
|
116
|
+
buildWebSocketOptions,
|
|
117
|
+
buildFetchDispatcher
|
|
118
118
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildWebSocketOptions,
|
|
3
3
|
logger
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-JG7ONJZ6.js";
|
|
5
5
|
|
|
6
6
|
// src/core.ts
|
|
7
7
|
import path11 from "path";
|
|
@@ -1103,9 +1103,34 @@ var ClaudeDriver = class {
|
|
|
1103
1103
|
}
|
|
1104
1104
|
return args;
|
|
1105
1105
|
}
|
|
1106
|
+
buildDeprecatedShimMcpConfig(ctx) {
|
|
1107
|
+
const isTsSource = ctx.chatBridgePath.endsWith(".ts");
|
|
1108
|
+
const command = isTsSource ? "npx" : "node";
|
|
1109
|
+
const bridgeArgs = isTsSource ? ["tsx", ctx.chatBridgePath] : [ctx.chatBridgePath];
|
|
1110
|
+
return JSON.stringify({
|
|
1111
|
+
mcpServers: {
|
|
1112
|
+
chat: {
|
|
1113
|
+
command,
|
|
1114
|
+
args: [
|
|
1115
|
+
...bridgeArgs,
|
|
1116
|
+
"--agent-id",
|
|
1117
|
+
ctx.agentId,
|
|
1118
|
+
"--server-url",
|
|
1119
|
+
ctx.config.serverUrl,
|
|
1120
|
+
"--auth-token",
|
|
1121
|
+
ctx.config.authToken || ctx.daemonApiKey,
|
|
1122
|
+
"--runtime",
|
|
1123
|
+
this.id,
|
|
1124
|
+
"--deprecated-shim"
|
|
1125
|
+
]
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
});
|
|
1129
|
+
}
|
|
1106
1130
|
spawn(ctx) {
|
|
1107
1131
|
const { tokenFile, spawnEnv } = prepareCliTransport(ctx);
|
|
1108
1132
|
const args = this.buildClaudeArgs(ctx.config, ctx.standingPrompt);
|
|
1133
|
+
args.push("--mcp-config", this.buildDeprecatedShimMcpConfig(ctx));
|
|
1109
1134
|
delete spawnEnv.CLAUDECODE;
|
|
1110
1135
|
logger.info(
|
|
1111
1136
|
`[Agent ${ctx.agentId}] transport=cli cli=${ctx.slockCliPath} token_file=${tokenFile}`
|
|
@@ -1325,6 +1350,48 @@ var CodexDriver = class {
|
|
|
1325
1350
|
probe() {
|
|
1326
1351
|
return probeCodex();
|
|
1327
1352
|
}
|
|
1353
|
+
buildDeprecatedShimConfigArgs(ctx) {
|
|
1354
|
+
const isTsSource = ctx.chatBridgePath.endsWith(".ts");
|
|
1355
|
+
const command = isTsSource ? "npx" : "node";
|
|
1356
|
+
const bridgeArgs = isTsSource ? [
|
|
1357
|
+
"tsx",
|
|
1358
|
+
ctx.chatBridgePath,
|
|
1359
|
+
"--agent-id",
|
|
1360
|
+
ctx.agentId,
|
|
1361
|
+
"--server-url",
|
|
1362
|
+
ctx.config.serverUrl,
|
|
1363
|
+
"--auth-token",
|
|
1364
|
+
ctx.config.authToken || ctx.daemonApiKey,
|
|
1365
|
+
"--runtime",
|
|
1366
|
+
this.id,
|
|
1367
|
+
"--deprecated-shim"
|
|
1368
|
+
] : [
|
|
1369
|
+
ctx.chatBridgePath,
|
|
1370
|
+
"--agent-id",
|
|
1371
|
+
ctx.agentId,
|
|
1372
|
+
"--server-url",
|
|
1373
|
+
ctx.config.serverUrl,
|
|
1374
|
+
"--auth-token",
|
|
1375
|
+
ctx.config.authToken || ctx.daemonApiKey,
|
|
1376
|
+
"--runtime",
|
|
1377
|
+
this.id,
|
|
1378
|
+
"--deprecated-shim"
|
|
1379
|
+
];
|
|
1380
|
+
return [
|
|
1381
|
+
"-c",
|
|
1382
|
+
`mcp_servers.chat.command=${JSON.stringify(command)}`,
|
|
1383
|
+
"-c",
|
|
1384
|
+
`mcp_servers.chat.args=${JSON.stringify(bridgeArgs)}`,
|
|
1385
|
+
"-c",
|
|
1386
|
+
"mcp_servers.chat.startup_timeout_sec=30",
|
|
1387
|
+
"-c",
|
|
1388
|
+
"mcp_servers.chat.tool_timeout_sec=120",
|
|
1389
|
+
"-c",
|
|
1390
|
+
"mcp_servers.chat.enabled=true",
|
|
1391
|
+
"-c",
|
|
1392
|
+
"mcp_servers.chat.required=true"
|
|
1393
|
+
];
|
|
1394
|
+
}
|
|
1328
1395
|
buildThreadRequest(ctx) {
|
|
1329
1396
|
const threadParams = {
|
|
1330
1397
|
cwd: ctx.workingDirectory,
|
|
@@ -1378,6 +1445,7 @@ var CodexDriver = class {
|
|
|
1378
1445
|
this.streamedAgentMessageIds.clear();
|
|
1379
1446
|
this.streamedReasoningIds.clear();
|
|
1380
1447
|
const args = ["app-server", "--listen", "stdio://"];
|
|
1448
|
+
args.push(...this.buildDeprecatedShimConfigArgs(ctx));
|
|
1381
1449
|
const { command, args: spawnArgs } = resolveCodexSpawn(args);
|
|
1382
1450
|
const proc = spawn2(command, spawnArgs, {
|
|
1383
1451
|
cwd: ctx.workingDirectory,
|
package/dist/core.js
CHANGED
|
@@ -9,10 +9,10 @@ import {
|
|
|
9
9
|
resolveSlockCliPath,
|
|
10
10
|
resolveWorkspaceDirectoryPath,
|
|
11
11
|
scanWorkspaceDirectories
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-PB75DRIF.js";
|
|
13
13
|
import {
|
|
14
14
|
subscribeDaemonLogs
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-JG7ONJZ6.js";
|
|
16
16
|
export {
|
|
17
17
|
DAEMON_CLI_USAGE,
|
|
18
18
|
DaemonCore,
|
package/dist/index.js
CHANGED
|
@@ -3,8 +3,8 @@ import {
|
|
|
3
3
|
DAEMON_CLI_USAGE,
|
|
4
4
|
DaemonCore,
|
|
5
5
|
parseDaemonCliArgs
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-PB75DRIF.js";
|
|
7
|
+
import "./chunk-JG7ONJZ6.js";
|
|
8
8
|
|
|
9
9
|
// src/index.ts
|
|
10
10
|
var parsedArgs = parseDaemonCliArgs(process.argv.slice(2));
|