@adhdev/daemon-core 0.8.13 → 0.8.15
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/index.js +66 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +69 -37
- package/dist/index.mjs.map +1 -1
- package/node_modules/@adhdev/session-host-core/package.json +1 -1
- package/package.json +3 -3
- package/src/cli-adapters/provider-cli-adapter.ts +10 -10
- package/src/cli-adapters/pty-transport.ts +17 -6
- package/src/commands/workspace-commands.ts +37 -9
package/dist/index.js
CHANGED
|
@@ -705,17 +705,32 @@ var init_terminal_screen = __esm({
|
|
|
705
705
|
}
|
|
706
706
|
});
|
|
707
707
|
|
|
708
|
+
// src/cli-adapters/spawn-env.ts
|
|
709
|
+
var import_session_host_core;
|
|
710
|
+
var init_spawn_env = __esm({
|
|
711
|
+
"src/cli-adapters/spawn-env.ts"() {
|
|
712
|
+
"use strict";
|
|
713
|
+
import_session_host_core = require("@adhdev/session-host-core");
|
|
714
|
+
}
|
|
715
|
+
});
|
|
716
|
+
|
|
708
717
|
// src/cli-adapters/pty-transport.ts
|
|
709
|
-
|
|
718
|
+
function loadNodePty() {
|
|
719
|
+
if (cachedPty !== void 0) return cachedPty;
|
|
720
|
+
try {
|
|
721
|
+
cachedPty = require("node-pty");
|
|
722
|
+
(0, import_session_host_core.ensureNodePtySpawnHelperPermissions)();
|
|
723
|
+
} catch {
|
|
724
|
+
cachedPty = null;
|
|
725
|
+
}
|
|
726
|
+
return cachedPty;
|
|
727
|
+
}
|
|
728
|
+
var os7, cachedPty, NodePtyRuntimeTransport, NodePtyTransportFactory;
|
|
710
729
|
var init_pty_transport = __esm({
|
|
711
730
|
"src/cli-adapters/pty-transport.ts"() {
|
|
712
731
|
"use strict";
|
|
713
732
|
os7 = __toESM(require("os"));
|
|
714
|
-
|
|
715
|
-
pty = require("node-pty");
|
|
716
|
-
} catch {
|
|
717
|
-
pty = null;
|
|
718
|
-
}
|
|
733
|
+
init_spawn_env();
|
|
719
734
|
NodePtyRuntimeTransport = class {
|
|
720
735
|
constructor(handle) {
|
|
721
736
|
this.handle = handle;
|
|
@@ -746,6 +761,7 @@ var init_pty_transport = __esm({
|
|
|
746
761
|
};
|
|
747
762
|
NodePtyTransportFactory = class {
|
|
748
763
|
spawn(command, args, options) {
|
|
764
|
+
const pty = loadNodePty();
|
|
749
765
|
if (!pty) throw new Error("node-pty is not installed");
|
|
750
766
|
let cwd = options.cwd;
|
|
751
767
|
if (cwd) {
|
|
@@ -770,15 +786,6 @@ var init_pty_transport = __esm({
|
|
|
770
786
|
}
|
|
771
787
|
});
|
|
772
788
|
|
|
773
|
-
// src/cli-adapters/spawn-env.ts
|
|
774
|
-
var import_session_host_core;
|
|
775
|
-
var init_spawn_env = __esm({
|
|
776
|
-
"src/cli-adapters/spawn-env.ts"() {
|
|
777
|
-
"use strict";
|
|
778
|
-
import_session_host_core = require("@adhdev/session-host-core");
|
|
779
|
-
}
|
|
780
|
-
});
|
|
781
|
-
|
|
782
789
|
// src/cli-adapters/provider-cli-adapter.ts
|
|
783
790
|
var provider_cli_adapter_exports = {};
|
|
784
791
|
__export(provider_cli_adapter_exports, {
|
|
@@ -922,7 +929,7 @@ function normalizeCliProviderForRuntime(raw) {
|
|
|
922
929
|
}
|
|
923
930
|
};
|
|
924
931
|
}
|
|
925
|
-
var os8, path7, import_child_process4,
|
|
932
|
+
var os8, path7, import_child_process4, buildCliSpawnEnv, ProviderCliAdapter;
|
|
926
933
|
var init_provider_cli_adapter = __esm({
|
|
927
934
|
"src/cli-adapters/provider-cli-adapter.ts"() {
|
|
928
935
|
"use strict";
|
|
@@ -933,12 +940,6 @@ var init_provider_cli_adapter = __esm({
|
|
|
933
940
|
init_terminal_screen();
|
|
934
941
|
init_pty_transport();
|
|
935
942
|
init_spawn_env();
|
|
936
|
-
try {
|
|
937
|
-
pty2 = require("node-pty");
|
|
938
|
-
(0, import_session_host_core.ensureNodePtySpawnHelperPermissions)((msg) => LOG.info("CLI", msg));
|
|
939
|
-
} catch {
|
|
940
|
-
LOG.error("CLI", "[ProviderCliAdapter] node-pty not found. Terminal features disabled.");
|
|
941
|
-
}
|
|
942
943
|
buildCliSpawnEnv = import_session_host_core.sanitizeSpawnEnv;
|
|
943
944
|
ProviderCliAdapter = class _ProviderCliAdapter {
|
|
944
945
|
constructor(provider, workingDir, extraArgs = [], transportFactory = new NodePtyTransportFactory()) {
|
|
@@ -1262,13 +1263,16 @@ var init_provider_cli_adapter = __esm({
|
|
|
1262
1263
|
let shellArgs;
|
|
1263
1264
|
const useShellUnix = !isWin && (!!spawnConfig.shell || !path7.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
|
|
1264
1265
|
const isCmdShim = isWin && /\.(cmd|bat)$/i.test(binaryPath);
|
|
1265
|
-
const
|
|
1266
|
+
const useShellWin = isCmdShim || !path7.isAbsolute(binaryPath) || isScriptBinary(binaryPath);
|
|
1267
|
+
const useShell = isWin ? useShellWin : useShellUnix;
|
|
1266
1268
|
if (useShell) {
|
|
1267
1269
|
if (!spawnConfig.shell && !isWin) {
|
|
1268
1270
|
LOG.info("CLI", `[${this.cliType}] Using login shell (script shim or non-native binary)`);
|
|
1269
1271
|
}
|
|
1270
1272
|
if (isCmdShim) {
|
|
1271
1273
|
LOG.info("CLI", `[${this.cliType}] Using cmd.exe shell for .cmd/.bat shim: ${binaryPath}`);
|
|
1274
|
+
} else if (isWin) {
|
|
1275
|
+
LOG.info("CLI", `[${this.cliType}] Using cmd.exe shell on Windows: ${binaryPath}`);
|
|
1272
1276
|
}
|
|
1273
1277
|
shellCmd = isWin ? "cmd.exe" : process.env.SHELL || "/bin/zsh";
|
|
1274
1278
|
if (isWin) {
|
|
@@ -1278,6 +1282,9 @@ var init_provider_cli_adapter = __esm({
|
|
|
1278
1282
|
shellArgs = ["-l", "-c", fullCmd];
|
|
1279
1283
|
}
|
|
1280
1284
|
} else {
|
|
1285
|
+
if (isWin && spawnConfig.shell) {
|
|
1286
|
+
LOG.info("CLI", `[${this.cliType}] Spawning Windows binary directly without cmd.exe: ${binaryPath}`);
|
|
1287
|
+
}
|
|
1281
1288
|
shellCmd = binaryPath;
|
|
1282
1289
|
shellArgs = allArgs;
|
|
1283
1290
|
}
|
|
@@ -7328,8 +7335,24 @@ function handleSetIdeExtension(h, args) {
|
|
|
7328
7335
|
|
|
7329
7336
|
// src/commands/workspace-commands.ts
|
|
7330
7337
|
init_config();
|
|
7338
|
+
function loadWorkspaceConfig() {
|
|
7339
|
+
try {
|
|
7340
|
+
return loadConfig();
|
|
7341
|
+
} catch (e) {
|
|
7342
|
+
return { error: `Could not load config: ${e?.message || "unknown error"}` };
|
|
7343
|
+
}
|
|
7344
|
+
}
|
|
7345
|
+
function persistWorkspaceConfig(config) {
|
|
7346
|
+
try {
|
|
7347
|
+
saveConfig(config);
|
|
7348
|
+
return { ok: true };
|
|
7349
|
+
} catch (e) {
|
|
7350
|
+
return { error: `Could not save config: ${e?.message || "unknown error"}` };
|
|
7351
|
+
}
|
|
7352
|
+
}
|
|
7331
7353
|
function handleWorkspaceList() {
|
|
7332
|
-
const config =
|
|
7354
|
+
const config = loadWorkspaceConfig();
|
|
7355
|
+
if ("error" in config) return { success: false, error: config.error };
|
|
7333
7356
|
const state = getWorkspaceState(config);
|
|
7334
7357
|
return {
|
|
7335
7358
|
success: true,
|
|
@@ -7343,31 +7366,37 @@ function handleWorkspaceAdd(args) {
|
|
|
7343
7366
|
const label = (args?.label || "").trim() || void 0;
|
|
7344
7367
|
const createIfMissing = args?.createIfMissing === true;
|
|
7345
7368
|
if (!rawPath) return { success: false, error: "path required" };
|
|
7346
|
-
const config =
|
|
7369
|
+
const config = loadWorkspaceConfig();
|
|
7370
|
+
if ("error" in config) return { success: false, error: config.error };
|
|
7347
7371
|
const result = addWorkspaceEntry(config, rawPath, label, { createIfMissing });
|
|
7348
7372
|
if ("error" in result) return { success: false, error: result.error };
|
|
7349
|
-
|
|
7373
|
+
const saveResult = persistWorkspaceConfig(result.config);
|
|
7374
|
+
if ("error" in saveResult) return { success: false, error: saveResult.error };
|
|
7350
7375
|
const state = getWorkspaceState(result.config);
|
|
7351
7376
|
return { success: true, entry: result.entry, ...state };
|
|
7352
7377
|
}
|
|
7353
7378
|
function handleWorkspaceRemove(args) {
|
|
7354
7379
|
const id = (args?.id || "").trim();
|
|
7355
7380
|
if (!id) return { success: false, error: "id required" };
|
|
7356
|
-
const config =
|
|
7381
|
+
const config = loadWorkspaceConfig();
|
|
7382
|
+
if ("error" in config) return { success: false, error: config.error };
|
|
7357
7383
|
const removed = (config.workspaces || []).find((w) => w.id === id);
|
|
7358
7384
|
const result = removeWorkspaceEntry(config, id);
|
|
7359
7385
|
if ("error" in result) return { success: false, error: result.error };
|
|
7360
|
-
|
|
7386
|
+
const saveResult = persistWorkspaceConfig(result.config);
|
|
7387
|
+
if ("error" in saveResult) return { success: false, error: saveResult.error };
|
|
7361
7388
|
const state = getWorkspaceState(result.config);
|
|
7362
7389
|
return { success: true, removedId: id, ...state };
|
|
7363
7390
|
}
|
|
7364
7391
|
function handleWorkspaceSetDefault(args) {
|
|
7365
7392
|
const clear = args?.clear === true || args?.id === null || args?.id === "";
|
|
7366
7393
|
if (clear) {
|
|
7367
|
-
const config2 =
|
|
7394
|
+
const config2 = loadWorkspaceConfig();
|
|
7395
|
+
if ("error" in config2) return { success: false, error: config2.error };
|
|
7368
7396
|
const result2 = setDefaultWorkspaceId(config2, null);
|
|
7369
7397
|
if ("error" in result2) return { success: false, error: result2.error };
|
|
7370
|
-
|
|
7398
|
+
const saveResult2 = persistWorkspaceConfig(result2.config);
|
|
7399
|
+
if ("error" in saveResult2) return { success: false, error: saveResult2.error };
|
|
7371
7400
|
const state2 = getWorkspaceState(result2.config);
|
|
7372
7401
|
return {
|
|
7373
7402
|
success: true,
|
|
@@ -7379,7 +7408,9 @@ function handleWorkspaceSetDefault(args) {
|
|
|
7379
7408
|
if (!pathArg && !idArg) {
|
|
7380
7409
|
return { success: false, error: "id or path required (or clear: true)" };
|
|
7381
7410
|
}
|
|
7382
|
-
|
|
7411
|
+
const configResult = loadWorkspaceConfig();
|
|
7412
|
+
if ("error" in configResult) return { success: false, error: configResult.error };
|
|
7413
|
+
let config = configResult;
|
|
7383
7414
|
let nextId;
|
|
7384
7415
|
if (pathArg) {
|
|
7385
7416
|
let w = findWorkspaceByPath(config, pathArg);
|
|
@@ -7395,7 +7426,8 @@ function handleWorkspaceSetDefault(args) {
|
|
|
7395
7426
|
}
|
|
7396
7427
|
const result = setDefaultWorkspaceId(config, nextId);
|
|
7397
7428
|
if ("error" in result) return { success: false, error: result.error };
|
|
7398
|
-
|
|
7429
|
+
const saveResult = persistWorkspaceConfig(result.config);
|
|
7430
|
+
if ("error" in saveResult) return { success: false, error: saveResult.error };
|
|
7399
7431
|
const state = getWorkspaceState(result.config);
|
|
7400
7432
|
return { success: true, ...state };
|
|
7401
7433
|
}
|
|
@@ -16024,10 +16056,10 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
16024
16056
|
let isPty = false;
|
|
16025
16057
|
const { spawn: spawnFn } = await import("child_process");
|
|
16026
16058
|
try {
|
|
16027
|
-
const
|
|
16059
|
+
const pty = require("node-pty");
|
|
16028
16060
|
ctx.log(`Auto-implement spawn (PTY): ${shellCmd}`);
|
|
16029
16061
|
const isWin2 = os17.platform() === "win32";
|
|
16030
|
-
child =
|
|
16062
|
+
child = pty.spawn(isWin2 ? "cmd.exe" : process.env.SHELL || "/bin/zsh", [isWin2 ? "/c" : "-c", shellCmd], {
|
|
16031
16063
|
name: "xterm-256color",
|
|
16032
16064
|
cols: 120,
|
|
16033
16065
|
rows: 40,
|