@accomplish_ai/agent-core 0.2.1 → 0.2.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.
@@ -0,0 +1,144 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Cross-platform dev-browser server launcher.
4
+ * Replaces server.sh for Windows compatibility.
5
+ *
6
+ * This script uses the local tsx binary directly instead of npx to avoid
7
+ * issues with path resolution when running from the packaged Electron app.
8
+ */
9
+ const { spawn } = require('child_process');
10
+ const path = require('path');
11
+ const fs = require('fs');
12
+
13
+ const skillDir = __dirname;
14
+ const isWindows = process.platform === 'win32';
15
+
16
+ // Parse command line arguments
17
+ const headless = process.argv.includes('--headless');
18
+
19
+ // Logging helper - logs to stderr so it doesn't interfere with stdio inheritance
20
+ function log(...args) {
21
+ const timestamp = new Date().toISOString();
22
+ console.error(`[dev-browser server.cjs ${timestamp}]`, ...args);
23
+ }
24
+
25
+ log('Starting dev-browser server launcher...');
26
+ log(' skillDir:', skillDir);
27
+ log(' isWindows:', isWindows);
28
+ log(' headless:', headless);
29
+ log(' NODE_BIN_PATH:', process.env.NODE_BIN_PATH || '(not set)');
30
+ log(' PATH (first 500 chars):', (process.env.PATH || '').substring(0, 500));
31
+
32
+ // Find the node executable
33
+ let nodeExe = 'node';
34
+ if (process.env.NODE_BIN_PATH) {
35
+ const bundledNode = path.join(process.env.NODE_BIN_PATH, isWindows ? 'node.exe' : 'node');
36
+ if (fs.existsSync(bundledNode)) {
37
+ nodeExe = bundledNode;
38
+ log(' Using bundled node:', nodeExe);
39
+ } else {
40
+ log(' Bundled node not found at:', bundledNode, '- falling back to system node');
41
+ }
42
+ } else {
43
+ log(' Using system node');
44
+ }
45
+
46
+ // Prefer bundled server if present (no tsx needed)
47
+ const bundledServer = path.join(skillDir, 'dist', 'start-server.mjs');
48
+
49
+ let tsxCommand;
50
+ let tsxArgs;
51
+
52
+ if (fs.existsSync(bundledServer)) {
53
+ tsxCommand = nodeExe;
54
+ tsxArgs = [bundledServer];
55
+ log(' Using bundled server:', bundledServer);
56
+ } else {
57
+ // Find tsx - on Windows, ALWAYS prefer cli.mjs over tsx.cmd to avoid shell quoting issues
58
+ // with paths containing spaces (e.g., "C:\\Program Files\\...")
59
+ const localTsxJs = path.join(skillDir, 'node_modules', 'tsx', 'dist', 'cli.mjs');
60
+ const localTsxBin = path.join(skillDir, 'node_modules', '.bin', isWindows ? 'tsx.cmd' : 'tsx');
61
+
62
+ // On Windows: prefer cli.mjs (run via node.exe, no shell needed, no path quoting issues)
63
+ // On Unix: prefer the tsx binary (simpler)
64
+ if (isWindows && fs.existsSync(localTsxJs)) {
65
+ // Windows: run tsx via node directly to avoid shell quoting issues with spaces in paths
66
+ tsxCommand = nodeExe;
67
+ tsxArgs = [localTsxJs, path.join('scripts', 'start-server.ts')];
68
+ log(' Using tsx via node (Windows):', localTsxJs);
69
+ } else if (!isWindows && fs.existsSync(localTsxBin)) {
70
+ // Unix: use tsx binary directly
71
+ tsxCommand = localTsxBin;
72
+ tsxArgs = [path.join('scripts', 'start-server.ts')];
73
+ log(' Using local tsx binary (Unix):', localTsxBin);
74
+ } else if (fs.existsSync(localTsxJs)) {
75
+ // Fallback for any platform: run tsx via node directly
76
+ tsxCommand = nodeExe;
77
+ tsxArgs = [localTsxJs, path.join('scripts', 'start-server.ts')];
78
+ log(' Using tsx via node (fallback):', localTsxJs);
79
+ } else if (fs.existsSync(localTsxBin)) {
80
+ // Fallback: try tsx binary even on Windows (may have issues with spaces)
81
+ tsxCommand = localTsxBin;
82
+ tsxArgs = [path.join('scripts', 'start-server.ts')];
83
+ log(' Using local tsx binary (fallback):', localTsxBin);
84
+ } else {
85
+ // Last resort: try npx (may fail with path issues)
86
+ log(' WARNING: Local tsx not found, falling back to npx');
87
+ log(' Checked:', localTsxJs);
88
+ log(' Checked:', localTsxBin);
89
+
90
+ let npxCommand = isWindows ? 'npx.cmd' : 'npx';
91
+ if (process.env.NODE_BIN_PATH) {
92
+ npxCommand = path.join(process.env.NODE_BIN_PATH, isWindows ? 'npx.cmd' : 'npx');
93
+ }
94
+ tsxCommand = npxCommand;
95
+ tsxArgs = ['tsx', path.join('scripts', 'start-server.ts')];
96
+ log(' Using npx:', npxCommand);
97
+ }
98
+ }
99
+
100
+ // Build environment
101
+ const env = { ...process.env };
102
+ if (headless) {
103
+ env.HEADLESS = 'true';
104
+ }
105
+
106
+ log('Spawning:', tsxCommand, tsxArgs.join(' '));
107
+ log(' cwd:', skillDir);
108
+
109
+ // Spawn options
110
+ const spawnOptions = {
111
+ cwd: skillDir,
112
+ stdio: 'inherit',
113
+ env,
114
+ windowsHide: true,
115
+ };
116
+
117
+ // On Windows, .cmd batch files REQUIRE shell: true to execute.
118
+ // When running node directly (with cli.mjs), we can use shell: false.
119
+ const isCmdFile = isWindows && tsxCommand.endsWith('.cmd');
120
+ if (isCmdFile) {
121
+ spawnOptions.shell = true;
122
+ log(' shell: true (Windows .cmd file)');
123
+ } else {
124
+ // For node direct execution (cli.mjs) or Unix, shell is not needed
125
+ spawnOptions.shell = false;
126
+ log(' shell: false (direct executable)');
127
+ }
128
+
129
+ const child = spawn(tsxCommand, tsxArgs, spawnOptions);
130
+
131
+ child.on('error', (err) => {
132
+ log('ERROR: Failed to spawn:', err.message);
133
+ log(' Command:', tsxCommand);
134
+ log(' Args:', tsxArgs);
135
+ log(' Error code:', err.code);
136
+ process.exit(1);
137
+ });
138
+
139
+ child.on('close', (code, signal) => {
140
+ log('Process exited with code:', code, 'signal:', signal);
141
+ process.exit(code || 0);
142
+ });
143
+
144
+ log('Spawn initiated, waiting for process...');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@accomplish_ai/agent-core",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Core logic for Accomplish - OpenCode adapter, storage, providers, MCP tools, and skills",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -46,6 +46,7 @@
46
46
  "dist",
47
47
  "mcp-tools/*/dist",
48
48
  "mcp-tools/*/package.json",
49
+ "mcp-tools/*/*.cjs",
49
50
  "mcp-tools/*/*.md",
50
51
  "mcp-tools/package.json"
51
52
  ],