@cydm/magic-shell-agent-node 0.1.18 → 0.1.20
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/adapters/pty-adapter.js +27 -93
- package/dist/adapters/rpc-adapter.js +39 -0
- package/dist/adapters/stdio-adapter.js +39 -0
- package/dist/claude-exec.js +15 -3
- package/dist/codex-exec.js +15 -3
- package/dist/command-resolution.d.ts +4 -0
- package/dist/command-resolution.js +85 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/local-direct-server.js +2 -21
- package/dist/node.js +33 -4
- package/dist/plugin-loader.js +8 -17
- package/dist/primary-agent-bridge.d.ts +0 -1
- package/dist/primary-agent-bridge.js +35 -5
- package/dist/primary-pie-extension/magic-shell-agent/index.js +1019 -0
- package/dist/primary-pie-extension/magic-shell-agent/package.json +9 -0
- package/dist/runtime-assets.d.ts +4 -0
- package/dist/runtime-assets.js +83 -0
- package/package.json +1 -1
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
function currentDistDir() {
|
|
5
|
+
return path.dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
}
|
|
7
|
+
function findExistingDirectory(candidates) {
|
|
8
|
+
for (const candidate of candidates) {
|
|
9
|
+
if (!candidate)
|
|
10
|
+
continue;
|
|
11
|
+
try {
|
|
12
|
+
if (existsSync(candidate)) {
|
|
13
|
+
return candidate;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
// Ignore invalid paths while probing runtime assets.
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
function findExistingFile(candidates) {
|
|
23
|
+
for (const candidate of candidates) {
|
|
24
|
+
if (!candidate)
|
|
25
|
+
continue;
|
|
26
|
+
try {
|
|
27
|
+
if (existsSync(candidate)) {
|
|
28
|
+
return candidate;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// Ignore invalid paths while probing runtime assets.
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
export function getPackagedPluginDir() {
|
|
38
|
+
const currentDir = currentDistDir();
|
|
39
|
+
return findExistingDirectory([
|
|
40
|
+
process.env.MAGIC_SHELL_PLUGINS_DIR ? path.resolve(process.env.MAGIC_SHELL_PLUGINS_DIR) : null,
|
|
41
|
+
path.resolve(currentDir, "./plugins"),
|
|
42
|
+
// Development-only fallback for source checkouts.
|
|
43
|
+
path.resolve(currentDir, "../../../plugins"),
|
|
44
|
+
]);
|
|
45
|
+
}
|
|
46
|
+
export function getWorkbenchRoot() {
|
|
47
|
+
const currentDir = currentDistDir();
|
|
48
|
+
const candidates = [
|
|
49
|
+
process.env.MAGIC_SHELL_WORKBENCH_ROOT ? path.resolve(process.env.MAGIC_SHELL_WORKBENCH_ROOT) : null,
|
|
50
|
+
path.resolve(currentDir, "./workbench"),
|
|
51
|
+
// Development-only fallback for source checkouts.
|
|
52
|
+
path.resolve(currentDir, "../../../apps/web/src"),
|
|
53
|
+
];
|
|
54
|
+
for (const candidate of candidates) {
|
|
55
|
+
if (!candidate)
|
|
56
|
+
continue;
|
|
57
|
+
if (existsSync(path.join(candidate, "index.html"))) {
|
|
58
|
+
return candidate;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
export function getPrimaryPieExtensionDistDir() {
|
|
64
|
+
const currentDir = currentDistDir();
|
|
65
|
+
return findExistingDirectory([
|
|
66
|
+
process.env.MAGIC_SHELL_PRIMARY_EXTENSION_DIR ? path.resolve(process.env.MAGIC_SHELL_PRIMARY_EXTENSION_DIR) : null,
|
|
67
|
+
path.resolve(currentDir, "./primary-pie-extension"),
|
|
68
|
+
// Development-only fallback for source checkouts.
|
|
69
|
+
path.resolve(currentDir, "../../primary-pie-extension/dist"),
|
|
70
|
+
]);
|
|
71
|
+
}
|
|
72
|
+
export function getMagicShellCliPath() {
|
|
73
|
+
const currentDir = currentDistDir();
|
|
74
|
+
return findExistingFile([
|
|
75
|
+
process.env.MAGIC_SHELL_CLI_PATH ? path.resolve(process.env.MAGIC_SHELL_CLI_PATH) : null,
|
|
76
|
+
// Installed alongside @cydm/magic-shell under the same @cydm scope.
|
|
77
|
+
path.resolve(currentDir, "../../magic-shell/dist/cli.js"),
|
|
78
|
+
// Installed under @cydm/magic-shell -> node_modules/@cydm/magic-shell-agent-node/dist
|
|
79
|
+
path.resolve(currentDir, "../../../../dist/cli.js"),
|
|
80
|
+
// Development-only fallback for source checkouts.
|
|
81
|
+
path.resolve(currentDir, "../../cli/dist/cli.js"),
|
|
82
|
+
]);
|
|
83
|
+
}
|