@cydm/magic-shell-agent-node 0.1.14 → 0.1.16

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.
@@ -1,6 +1,8 @@
1
1
  import { readFileSync, readdirSync, existsSync } from "fs";
2
2
  import { join, extname, dirname, isAbsolute, resolve } from "path";
3
3
  import { fileURLToPath } from "url";
4
+ import { createRequire } from "module";
5
+ const require = createRequire(import.meta.url);
4
6
  /**
5
7
  * 加载单个插件配置
6
8
  */
@@ -29,12 +31,57 @@ export function loadPlugin(path) {
29
31
  if (!["stdio", "pty", "rpc"].includes(config.type)) {
30
32
  throw new Error(`Plugin ${path} invalid type: ${config.type}`);
31
33
  }
32
- return {
34
+ return normalizePluginConfigForRuntime({
33
35
  ...config,
34
36
  command: resolveCommandPath(config.command, configDir, repoRoot),
35
37
  args: resolveArgPaths(config.args, configDir, repoRoot),
36
38
  cwd: resolveOptionalPath(config.cwd, configDir, repoRoot),
37
- };
39
+ });
40
+ }
41
+ function normalizePluginConfigForRuntime(config) {
42
+ if (process.platform !== "win32") {
43
+ return config;
44
+ }
45
+ if (config.name === "pie") {
46
+ const pieEntry = resolvePackageBinEntry("@cydm/pie", "pie");
47
+ if (pieEntry) {
48
+ return {
49
+ ...config,
50
+ command: process.execPath,
51
+ args: [pieEntry, ...(config.args || [])],
52
+ };
53
+ }
54
+ }
55
+ if ((config.name === "claude-code" || config.name === "codex") && isShellCommand(config.command)) {
56
+ return {
57
+ ...config,
58
+ command: process.env.ComSpec || "C:\\Windows\\System32\\cmd.exe",
59
+ args: ["/d", "/s", "/c", [config.command, ...(config.args || [])].join(" ")],
60
+ };
61
+ }
62
+ return config;
63
+ }
64
+ function resolvePackageBinEntry(packageName, binName) {
65
+ try {
66
+ const packageJsonPath = require.resolve(`${packageName}/package.json`);
67
+ const packageDir = dirname(packageJsonPath);
68
+ const pkg = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
69
+ const binField = typeof pkg.bin === "string"
70
+ ? pkg.bin
71
+ : pkg.bin && typeof pkg.bin[binName] === "string"
72
+ ? pkg.bin[binName]
73
+ : null;
74
+ if (!binField)
75
+ return null;
76
+ const entry = resolve(packageDir, binField);
77
+ return existsSync(entry) ? entry : null;
78
+ }
79
+ catch {
80
+ return null;
81
+ }
82
+ }
83
+ function isShellCommand(command) {
84
+ return !!command && !isAbsolute(command) && !command.includes("/") && !command.includes("\\");
38
85
  }
39
86
  function resolveOptionalPath(value, configDir, repoRoot) {
40
87
  if (!value)
@@ -0,0 +1,56 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "title": "Magic Shell Agent Plugin",
4
+ "description": "Agent 插件配置 Schema",
5
+ "type": "object",
6
+ "required": ["name", "type", "command", "capabilities"],
7
+ "properties": {
8
+ "name": {
9
+ "type": "string",
10
+ "description": "插件唯一名称",
11
+ "pattern": "^[a-z0-9-]+$"
12
+ },
13
+ "type": {
14
+ "type": "string",
15
+ "enum": ["stdio", "pty", "rpc"],
16
+ "description": "连接模式"
17
+ },
18
+ "command": {
19
+ "type": "string",
20
+ "description": "启动命令"
21
+ },
22
+ "args": {
23
+ "type": "array",
24
+ "items": { "type": "string" },
25
+ "description": "启动参数"
26
+ },
27
+ "env": {
28
+ "type": "object",
29
+ "additionalProperties": { "type": "string" },
30
+ "description": "环境变量"
31
+ },
32
+ "capabilities": {
33
+ "type": "array",
34
+ "items": {
35
+ "type": "string",
36
+ "enum": [
37
+ "terminal",
38
+ "pty",
39
+ "ansi256",
40
+ "file-edit",
41
+ "web-search",
42
+ "bash",
43
+ "json-rpc",
44
+ "tool-call",
45
+ "streaming",
46
+ "mouse"
47
+ ]
48
+ },
49
+ "description": "能力列表"
50
+ },
51
+ "cwd": {
52
+ "type": "string",
53
+ "description": "工作目录(可选)"
54
+ }
55
+ }
56
+ }
@@ -3082,6 +3082,8 @@
3082
3082
  if (!summary) return true;
3083
3083
  const normalized = String(summary).toLowerCase();
3084
3084
  return normalized.includes('detail requested')
3085
+ || normalized.includes(' launched in ')
3086
+ || normalized.includes(' relaunched in ')
3085
3087
  || normalized.includes('attached from browser')
3086
3088
  || normalized.includes('control snapshot')
3087
3089
  || normalized.includes('attached ')
@@ -3093,7 +3095,7 @@
3093
3095
  if (worker.interventionReason) return worker.interventionReason;
3094
3096
  if (worker.attentionReason) return worker.attentionReason;
3095
3097
  if (worker.lastEventSummary && !isControlNoise(worker.lastEventSummary)) return worker.lastEventSummary;
3096
- return worker.cwd || '.';
3098
+ return pathBaseName(worker.cwd || '.');
3097
3099
  }
3098
3100
 
3099
3101
  function renderWorkers() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cydm/magic-shell-agent-node",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
4
4
  "description": "Magic Shell Agent Node - Local agent connector",
5
5
  "homepage": "https://magicshell.ai",
6
6
  "keywords": [