@codesys/mcp-toolkit 1.5.8 → 2.0.0
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/CHANGELOG.md +153 -189
- package/LICENSE +21 -21
- package/README.md +269 -152
- package/dist/actions.d.ts +28 -0
- package/dist/actions.js +98 -0
- package/dist/actions.js.map +1 -0
- package/dist/bridge/bridge.d.ts +105 -0
- package/dist/bridge/bridge.js +400 -0
- package/dist/bridge/bridge.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +196 -0
- package/dist/cli.js.map +1 -0
- package/dist/codesys/cache.d.ts +48 -0
- package/dist/codesys/cache.js +82 -0
- package/dist/codesys/cache.js.map +1 -0
- package/dist/codesys/changes.d.ts +57 -0
- package/dist/codesys/changes.js +133 -0
- package/dist/codesys/changes.js.map +1 -0
- package/dist/codesys/decl.d.ts +45 -0
- package/dist/codesys/decl.js +251 -0
- package/dist/codesys/decl.js.map +1 -0
- package/dist/codesys/devices.d.ts +34 -0
- package/dist/codesys/devices.js +82 -0
- package/dist/codesys/devices.js.map +1 -0
- package/dist/codesys/diff.d.ts +13 -0
- package/dist/codesys/diff.js +61 -0
- package/dist/codesys/diff.js.map +1 -0
- package/dist/codesys/install.d.ts +40 -0
- package/dist/codesys/install.js +144 -0
- package/dist/codesys/install.js.map +1 -0
- package/dist/codesys/library-browse.d.ts +19 -0
- package/dist/codesys/library-browse.js +57 -0
- package/dist/codesys/library-browse.js.map +1 -0
- package/dist/codesys/outline.d.ts +32 -0
- package/dist/codesys/outline.js +219 -0
- package/dist/codesys/outline.js.map +1 -0
- package/dist/codesys/simulation.d.ts +34 -0
- package/dist/codesys/simulation.js +57 -0
- package/dist/codesys/simulation.js.map +1 -0
- package/dist/codesys/st.d.ts +36 -0
- package/dist/codesys/st.js +69 -0
- package/dist/codesys/st.js.map +1 -0
- package/dist/daemon.d.ts +46 -0
- package/dist/daemon.js +173 -0
- package/dist/daemon.js.map +1 -0
- package/dist/driver.d.ts +25 -0
- package/dist/driver.js +33 -0
- package/dist/driver.js.map +1 -0
- package/dist/panel/sim-panel.html +357 -0
- package/dist/panel/viewer.html +126 -0
- package/dist/panel-types.d.ts +20 -0
- package/dist/panel-types.js +3 -0
- package/dist/panel-types.js.map +1 -0
- package/dist/panel.d.ts +27 -0
- package/dist/panel.js +208 -0
- package/dist/panel.js.map +1 -0
- package/dist/server.d.ts +5 -0
- package/dist/server.js +33 -974
- package/dist/server.js.map +1 -0
- package/dist/tools.d.ts +103 -0
- package/dist/tools.js +793 -0
- package/dist/tools.js.map +1 -0
- package/dist/viewer.d.ts +14 -0
- package/dist/viewer.js +125 -0
- package/dist/viewer.js.map +1 -0
- package/package.json +66 -51
- package/watcher/mcp_compat.py +147 -0
- package/watcher/mcp_ops.py +1178 -0
- package/watcher/mcp_sim.py +246 -0
- package/watcher/watcher.py +255 -0
- package/.claude/settings.local.json +0 -29
- package/CLAUDE.md +0 -26
- package/CONTRIBUTING.md +0 -72
- package/README.md.enhanced +0 -155
- package/codesys-mcp-toolkit-1.2.0.tgz +0 -0
- package/codesys-mcp-toolkit-1.2.1.tgz +0 -0
- package/codesys-mcp-toolkit-1.5.7.tgz +0 -0
- package/codesys-mcp-toolkit-1.5.8.tgz +0 -0
- package/dist/bin.js +0 -75
- package/dist/check_session_paths.js +0 -149
- package/dist/codesys_interop.js +0 -435
- package/dist/direct_session_command.js +0 -293
- package/dist/scriptLoader.js +0 -165
- package/dist/scripts/check_status.py +0 -21
- package/dist/scripts/compile_project.py +0 -65
- package/dist/scripts/create_method.py +0 -80
- package/dist/scripts/create_pou.py +0 -102
- package/dist/scripts/create_project.py +0 -116
- package/dist/scripts/create_property.py +0 -78
- package/dist/scripts/ensure_project_open.py +0 -154
- package/dist/scripts/find_object_by_path.py +0 -111
- package/dist/scripts/get_pou_code.py +0 -91
- package/dist/scripts/get_project_structure.py +0 -72
- package/dist/scripts/open_project.py +0 -25
- package/dist/scripts/save_project.py +0 -29
- package/dist/scripts/session_status.py +0 -281
- package/dist/scripts/set_pou_code.py +0 -109
- package/dist/scripts/start_session.py +0 -809
- package/dist/scripts/stop_session.py +0 -324
- package/dist/sessionManager.js +0 -798
- package/docs/configuration.md +0 -141
- package/docs/index.md +0 -26
- package/docs/installation.md +0 -84
- package/docs/session_management.md +0 -110
- package/examples/README.md +0 -78
- package/examples/sample_config.json +0 -32
- package/replacements_session_status.txt +0 -16
- package/scriptDoc.txt +0 -8679
- package/scripts/build.js +0 -25
- package/scripts/fix_fstrings.py +0 -76
package/README.md.enhanced
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
# @codesys/mcp-toolkit
|
|
2
|
-
|
|
3
|
-

|
|
4
|
-

|
|
5
|
-
|
|
6
|
-
A Model Context Protocol (MCP) server for CODESYS V3 programming environments. This toolkit enables seamless interaction between MCP clients (like Claude Desktop) and CODESYS, allowing automation of project management, POU creation, code editing, and compilation tasks.
|
|
7
|
-
|
|
8
|
-
<p align="center">
|
|
9
|
-
<img src="https://github.com/yourusername/codesys-mcp-toolkit/raw/main/docs/assets/diagram.png" alt="CODESYS MCP Toolkit Architecture" width="600">
|
|
10
|
-
</p>
|
|
11
|
-
|
|
12
|
-
## 🌟 Features
|
|
13
|
-
|
|
14
|
-
- **Project Management**
|
|
15
|
-
- Open existing CODESYS projects
|
|
16
|
-
- Create new projects from templates
|
|
17
|
-
- Save project changes
|
|
18
|
-
|
|
19
|
-
- **POU Management**
|
|
20
|
-
- Create Programs, Function Blocks, and Functions
|
|
21
|
-
- Set declaration and implementation code
|
|
22
|
-
- Create properties and methods for Function Blocks
|
|
23
|
-
- Compile projects
|
|
24
|
-
|
|
25
|
-
- **MCP Resources**
|
|
26
|
-
- `codesys://project/status`: Check scripting status and project state
|
|
27
|
-
- `codesys://project/{+project_path}/structure`: Retrieve project structure
|
|
28
|
-
- `codesys://project/{+project_path}/pou/{+pou_path}/code`: Read POU code
|
|
29
|
-
|
|
30
|
-
- **MCP Tools**
|
|
31
|
-
- `open_project`: Open specified CODESYS project
|
|
32
|
-
- `create_project`: Create new CODESYS project
|
|
33
|
-
- `save_project`: Save currently open project
|
|
34
|
-
- `create_pou`: Create new Program, Function Block, or Function
|
|
35
|
-
- `set_pou_code`: Update code for a specified POU
|
|
36
|
-
- `create_property`: Create property in a Function Block
|
|
37
|
-
- `create_method`: Create method in a Function Block
|
|
38
|
-
- `compile_project`: Compile the open project
|
|
39
|
-
|
|
40
|
-
## 📋 Prerequisites
|
|
41
|
-
|
|
42
|
-
- **CODESYS V3**: A working CODESYS V3 installation (tested with 3.5 SP21) with **Scripting Engine** component enabled
|
|
43
|
-
- **Node.js**: Version 18 or later required
|
|
44
|
-
- **MCP Client**: An MCP-enabled application (e.g., Claude Desktop)
|
|
45
|
-
|
|
46
|
-
## 🚀 Installation
|
|
47
|
-
|
|
48
|
-
### Option 1: Install from npm (Recommended)
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
npm install -g @codesys/mcp-toolkit
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
This installs the package globally, making the `codesys-mcp-toolkit` command available in your terminal.
|
|
55
|
-
|
|
56
|
-
### Option 2: Install from Source
|
|
57
|
-
|
|
58
|
-
```bash
|
|
59
|
-
# Clone the repository
|
|
60
|
-
git clone https://github.com/yourusername/codesys-mcp-toolkit.git
|
|
61
|
-
cd codesys-mcp-toolkit
|
|
62
|
-
|
|
63
|
-
# Install dependencies
|
|
64
|
-
npm install
|
|
65
|
-
|
|
66
|
-
# Build the project
|
|
67
|
-
npm run build
|
|
68
|
-
|
|
69
|
-
# Install globally
|
|
70
|
-
npm install -g .
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
## 🔧 Configuration
|
|
74
|
-
|
|
75
|
-
### Claude Desktop Configuration
|
|
76
|
-
|
|
77
|
-
1. Locate your Claude Desktop configuration file:
|
|
78
|
-
- Windows: `C:\Users\<YourUsername>\AppData\Roaming\Claude\claude_desktop_config.json`
|
|
79
|
-
|
|
80
|
-
2. Add the CODESYS MCP server entry:
|
|
81
|
-
|
|
82
|
-
```json
|
|
83
|
-
{
|
|
84
|
-
"mcpServers": {
|
|
85
|
-
"codesys_local": {
|
|
86
|
-
"command": "npx",
|
|
87
|
-
"args": [
|
|
88
|
-
"-y",
|
|
89
|
-
"@codesys/mcp-toolkit",
|
|
90
|
-
"--codesys-path", "C:\\Program Files\\CODESYS 3.5.21.0\\CODESYS\\Common\\CODESYS.exe",
|
|
91
|
-
"--codesys-profile", "CODESYS V3.5 SP21"
|
|
92
|
-
]
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
3. Customize the paths to match your CODESYS installation:
|
|
99
|
-
- `--codesys-path`: Path to your CODESYS.exe
|
|
100
|
-
- `--codesys-profile`: Your CODESYS profile name
|
|
101
|
-
|
|
102
|
-
4. Restart Claude Desktop to apply the changes
|
|
103
|
-
|
|
104
|
-
## 🛠️ Usage Examples
|
|
105
|
-
|
|
106
|
-
### Creating a Function Block with Properties
|
|
107
|
-
|
|
108
|
-
```
|
|
109
|
-
Ask Claude: "Using the CODESYS Local server, please create a Motor Controller function block with Start and Stop methods, plus CurrentSpeed property."
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
Claude will execute these MCP tool calls:
|
|
113
|
-
1. `create_pou` to create the MotorController Function Block
|
|
114
|
-
2. `create_property` to add the CurrentSpeed property
|
|
115
|
-
3. `create_method` to add Start and Stop methods
|
|
116
|
-
4. `set_pou_code` to implement each method and property
|
|
117
|
-
|
|
118
|
-
### Opening and Compiling a Project
|
|
119
|
-
|
|
120
|
-
```
|
|
121
|
-
Ask Claude: "Can you open the project at C:/MyProjects/TestProject.project using CODESYS Local and compile it?"
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
Claude will:
|
|
125
|
-
1. Use `open_project` to open the specified file
|
|
126
|
-
2. Use `compile_project` to build the application
|
|
127
|
-
|
|
128
|
-
## 🔍 Troubleshooting
|
|
129
|
-
|
|
130
|
-
### Common Issues
|
|
131
|
-
|
|
132
|
-
- **Connection Failures**: Check Claude Desktop logs for error messages
|
|
133
|
-
- **Path Issues**: Ensure CODESYS executable path is correct
|
|
134
|
-
- **Profile Mismatch**: Verify profile name matches exactly
|
|
135
|
-
- **Permission Problems**: Ensure Claude has appropriate permissions
|
|
136
|
-
- **CODESYS Already Running**: Close other CODESYS instances
|
|
137
|
-
|
|
138
|
-
### Debug Logs
|
|
139
|
-
|
|
140
|
-
Check logs at:
|
|
141
|
-
- Windows: `C:\Users\<YourUsername>\AppData\Roaming\Claude\logs\`
|
|
142
|
-
|
|
143
|
-
## 🤝 Contributing
|
|
144
|
-
|
|
145
|
-
Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
|
|
146
|
-
|
|
147
|
-
## 📝 License
|
|
148
|
-
|
|
149
|
-
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
150
|
-
|
|
151
|
-
## 🙏 Acknowledgements
|
|
152
|
-
|
|
153
|
-
- The [CODESYS](https://www.codesys.com/) team for their scripting engine
|
|
154
|
-
- [Model Context Protocol](https://github.com/m-ld/model-context-protocol) project
|
|
155
|
-
- All contributors who have helped improve this toolkit
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/bin.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
/**
|
|
4
|
-
* CODESYS MCP Server CLI
|
|
5
|
-
* Command-line interface for starting the CODESYS MCP server
|
|
6
|
-
* with configurable CODESYS executable paths and profile names.
|
|
7
|
-
*
|
|
8
|
-
* This is the entry point for the MCP toolkit when invoked as a command-line tool.
|
|
9
|
-
* It handles argument parsing and passes configuration to server.ts via function parameters.
|
|
10
|
-
*/
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
// Use Commander for initial parsing
|
|
13
|
-
const commander_1 = require("commander");
|
|
14
|
-
// Import the server setup function
|
|
15
|
-
const server_js_1 = require("./server.js"); // Adjust path if needed
|
|
16
|
-
console.error(">>> BIN.TS Starting <<<");
|
|
17
|
-
// Define version from package.json
|
|
18
|
-
// Use import assertion for JSON in ES modules if possible, otherwise require is okay for CommonJS
|
|
19
|
-
let version = 'unknown';
|
|
20
|
-
try {
|
|
21
|
-
// Assuming CommonJS based on package.json type="commonjs"
|
|
22
|
-
const packageJson = require('../package.json');
|
|
23
|
-
version = packageJson.version;
|
|
24
|
-
}
|
|
25
|
-
catch (e) {
|
|
26
|
-
console.error("BIN.TS: Warning - Could not read package.json for version.", e);
|
|
27
|
-
}
|
|
28
|
-
commander_1.program
|
|
29
|
-
.name('codesys-mcp-tool') // Set the command name users will see
|
|
30
|
-
.description('Model Context Protocol (MCP) server for CODESYS automation platform')
|
|
31
|
-
.version(version)
|
|
32
|
-
.option(// Use options consistently
|
|
33
|
-
'-p, --codesys-path <path>', 'Path to CODESYS executable (can contain spaces, use quotes if needed)', process.env.CODESYS_PATH || 'C:\\Program Files\\CODESYS 3.5.21.0\\CODESYS\\Common\\CODESYS.exe' // Default AFTER reading env var
|
|
34
|
-
)
|
|
35
|
-
.option('-f, --codesys-profile <profile>', // Changed alias to 'f' to avoid conflict if you add other '-p' options
|
|
36
|
-
'CODESYS profile name (overrides CODESYS_PROFILE env var)', process.env.CODESYS_PROFILE || 'CODESYS V3.5 SP21' // Default AFTER reading env var
|
|
37
|
-
)
|
|
38
|
-
// Add workspace option if needed, defaults to cwd
|
|
39
|
-
.option('-w, --workspace <dir>', 'Workspace directory for relative project paths', process.cwd() // Default to current working directory
|
|
40
|
-
)
|
|
41
|
-
// Add option to disable session management
|
|
42
|
-
.option('--no-session', 'Disable session management (use one-time script execution only)', false)
|
|
43
|
-
.parse(process.argv); // Parse the arguments
|
|
44
|
-
const options = commander_1.program.opts();
|
|
45
|
-
// --- Log the options Commander parsed ---
|
|
46
|
-
console.error(`========================================`);
|
|
47
|
-
console.error(`Starting CODESYS MCP Server v${version}`);
|
|
48
|
-
console.error(`BIN.TS Options: ${JSON.stringify(options)}`);
|
|
49
|
-
console.error(` CODESYS Path Used: ${options.codesysPath}`);
|
|
50
|
-
console.error(` CODESYS Profile Used: ${options.codesysProfile}`);
|
|
51
|
-
console.error(` Workspace Used: ${options.workspace}`);
|
|
52
|
-
console.error(` Node.js: ${process.version}`);
|
|
53
|
-
console.error(`========================================`);
|
|
54
|
-
// --- End Logging ---
|
|
55
|
-
// --- Prepare Config for Server ---
|
|
56
|
-
const serverConfig = {
|
|
57
|
-
codesysPath: options.codesysPath.trim(),
|
|
58
|
-
profileName: options.codesysProfile.trim(),
|
|
59
|
-
workspaceDir: options.workspace.trim(), // Pass workspace dir
|
|
60
|
-
enableSessionManagement: options.session // Determined by --no-session flag (default: true)
|
|
61
|
-
};
|
|
62
|
-
console.error(`BIN.TS: Session management is ${serverConfig.enableSessionManagement ? 'enabled' : 'disabled'}`);
|
|
63
|
-
// --- End Prepare Config ---
|
|
64
|
-
// --- Call the server setup function ---
|
|
65
|
-
console.error("BIN.TS: Calling startMcpServer...");
|
|
66
|
-
(0, server_js_1.startMcpServer)(serverConfig)
|
|
67
|
-
.then(() => {
|
|
68
|
-
console.error("BIN.TS: startMcpServer finished (likely connected and listening).");
|
|
69
|
-
// Keep process alive (server handles shutdown)
|
|
70
|
-
})
|
|
71
|
-
.catch(error => {
|
|
72
|
-
console.error("BIN.TS: FATAL error during server startup:", error);
|
|
73
|
-
process.exit(1);
|
|
74
|
-
});
|
|
75
|
-
console.error(">>> BIN.TS End of synchronous execution <<<");
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Session Path Diagnostic Tool
|
|
4
|
-
* This script checks the consistency of paths used in the session management system.
|
|
5
|
-
*/
|
|
6
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
-
if (k2 === undefined) k2 = k;
|
|
8
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
-
}
|
|
12
|
-
Object.defineProperty(o, k2, desc);
|
|
13
|
-
}) : (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
o[k2] = m[k];
|
|
16
|
-
}));
|
|
17
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
-
}) : function(o, v) {
|
|
20
|
-
o["default"] = v;
|
|
21
|
-
});
|
|
22
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
-
var ownKeys = function(o) {
|
|
24
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
-
var ar = [];
|
|
26
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
-
return ar;
|
|
28
|
-
};
|
|
29
|
-
return ownKeys(o);
|
|
30
|
-
};
|
|
31
|
-
return function (mod) {
|
|
32
|
-
if (mod && mod.__esModule) return mod;
|
|
33
|
-
var result = {};
|
|
34
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
-
__setModuleDefault(result, mod);
|
|
36
|
-
return result;
|
|
37
|
-
};
|
|
38
|
-
})();
|
|
39
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
const path = __importStar(require("path"));
|
|
41
|
-
const os = __importStar(require("os"));
|
|
42
|
-
const fs = __importStar(require("fs"));
|
|
43
|
-
// Session directory paths from direct_session_command.ts
|
|
44
|
-
const DIRECT_SESSION_DIR = path.join(os.tmpdir(), 'codesys_session');
|
|
45
|
-
const DIRECT_COMMAND_FILE = path.join(DIRECT_SESSION_DIR, 'command.json');
|
|
46
|
-
const DIRECT_RESULT_FILE = path.join(DIRECT_SESSION_DIR, 'result.json');
|
|
47
|
-
const DIRECT_SESSION_LOCK_FILE = path.join(DIRECT_SESSION_DIR, 'session.lock');
|
|
48
|
-
const DIRECT_STATE_FILE = path.join(DIRECT_SESSION_DIR, 'session_state.json');
|
|
49
|
-
// Constants from sessionManager.ts
|
|
50
|
-
const SESSION_DIR = path.join(os.tmpdir(), 'codesys_session');
|
|
51
|
-
const COMMAND_FILE = 'command.json';
|
|
52
|
-
const RESULT_FILE = 'result.json';
|
|
53
|
-
const STATE_FILE = 'session_state.json';
|
|
54
|
-
const SESSION_LOCK_FILE = 'session.lock';
|
|
55
|
-
console.log("==== Session Path Diagnostics ====");
|
|
56
|
-
console.log("\nBase session directory check:");
|
|
57
|
-
console.log(`- DIRECT_SESSION_DIR: ${DIRECT_SESSION_DIR}`);
|
|
58
|
-
console.log(`- SESSION_DIR: ${SESSION_DIR}`);
|
|
59
|
-
console.log(` Direct and manager directories match: ${DIRECT_SESSION_DIR === SESSION_DIR}`);
|
|
60
|
-
console.log("\nExpected file paths in direct_session_command.ts:");
|
|
61
|
-
console.log(`- Command file: ${DIRECT_COMMAND_FILE}`);
|
|
62
|
-
console.log(`- Result file: ${DIRECT_RESULT_FILE}`);
|
|
63
|
-
console.log(`- Lock file: ${DIRECT_SESSION_LOCK_FILE}`);
|
|
64
|
-
console.log(`- State file: ${DIRECT_STATE_FILE}`);
|
|
65
|
-
console.log("\nFile names in sessionManager.ts:");
|
|
66
|
-
console.log(`- Command file: ${COMMAND_FILE}`);
|
|
67
|
-
console.log(`- Result file: ${RESULT_FILE}`);
|
|
68
|
-
console.log(`- Lock file: ${SESSION_LOCK_FILE}`);
|
|
69
|
-
console.log(`- State file: ${STATE_FILE}`);
|
|
70
|
-
console.log("\nFile existence checks:");
|
|
71
|
-
console.log(`- Base session directory exists: ${fs.existsSync(SESSION_DIR)}`);
|
|
72
|
-
if (fs.existsSync(SESSION_DIR)) {
|
|
73
|
-
console.log(`- Command file exists: ${fs.existsSync(DIRECT_COMMAND_FILE)}`);
|
|
74
|
-
console.log(`- Result file exists: ${fs.existsSync(DIRECT_RESULT_FILE)}`);
|
|
75
|
-
console.log(`- Lock file exists: ${fs.existsSync(DIRECT_SESSION_LOCK_FILE)}`);
|
|
76
|
-
console.log(`- State file exists: ${fs.existsSync(DIRECT_STATE_FILE)}`);
|
|
77
|
-
console.log("\nContent checks (if files exist):");
|
|
78
|
-
if (fs.existsSync(DIRECT_COMMAND_FILE)) {
|
|
79
|
-
try {
|
|
80
|
-
const commandContent = fs.readFileSync(DIRECT_COMMAND_FILE, 'utf8');
|
|
81
|
-
console.log(`- Command file content: ${commandContent.substring(0, 150)}...`);
|
|
82
|
-
try {
|
|
83
|
-
const commandJson = JSON.parse(commandContent);
|
|
84
|
-
console.log(` Status: ${commandJson.status}`);
|
|
85
|
-
console.log(` Has command object: ${commandJson.command !== null}`);
|
|
86
|
-
if (commandJson.command) {
|
|
87
|
-
console.log(` Command type: ${commandJson.command.type}`);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
catch (e) {
|
|
91
|
-
console.log(` Error parsing command file JSON: ${e}`);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
catch (e) {
|
|
95
|
-
console.log(`- Error reading command file: ${e}`);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
if (fs.existsSync(DIRECT_RESULT_FILE)) {
|
|
99
|
-
try {
|
|
100
|
-
const resultContent = fs.readFileSync(DIRECT_RESULT_FILE, 'utf8');
|
|
101
|
-
console.log(`- Result file content: ${resultContent.substring(0, 150)}...`);
|
|
102
|
-
try {
|
|
103
|
-
const resultJson = JSON.parse(resultContent);
|
|
104
|
-
console.log(` Status: ${resultJson.status}`);
|
|
105
|
-
console.log(` Has result object: ${resultJson.result !== null}`);
|
|
106
|
-
}
|
|
107
|
-
catch (e) {
|
|
108
|
-
console.log(` Error parsing result file JSON: ${e}`);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
catch (e) {
|
|
112
|
-
console.log(`- Error reading result file: ${e}`);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
if (fs.existsSync(DIRECT_SESSION_LOCK_FILE)) {
|
|
116
|
-
try {
|
|
117
|
-
const lockContent = fs.readFileSync(DIRECT_SESSION_LOCK_FILE, 'utf8');
|
|
118
|
-
console.log(`- Lock file content: ${lockContent}`);
|
|
119
|
-
const lockTime = parseFloat(lockContent);
|
|
120
|
-
const currentTime = Date.now() / 1000; // convert to seconds
|
|
121
|
-
const lockAgeSeconds = currentTime - lockTime;
|
|
122
|
-
console.log(` Lock age: ${lockAgeSeconds.toFixed(1)} seconds`);
|
|
123
|
-
}
|
|
124
|
-
catch (e) {
|
|
125
|
-
console.log(`- Error reading lock file: ${e}`);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
if (fs.existsSync(DIRECT_STATE_FILE)) {
|
|
129
|
-
try {
|
|
130
|
-
const stateContent = fs.readFileSync(DIRECT_STATE_FILE, 'utf8');
|
|
131
|
-
console.log(`- State file content: ${stateContent.substring(0, 150)}...`);
|
|
132
|
-
try {
|
|
133
|
-
const stateJson = JSON.parse(stateContent);
|
|
134
|
-
console.log(` Session ID: ${stateJson.sessionId || stateJson.session_id}`);
|
|
135
|
-
console.log(` Status: ${stateJson.status}`);
|
|
136
|
-
}
|
|
137
|
-
catch (e) {
|
|
138
|
-
console.log(` Error parsing state file JSON: ${e}`);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
catch (e) {
|
|
142
|
-
console.log(`- Error reading state file: ${e}`);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
console.log(" Cannot check files as base directory does not exist");
|
|
148
|
-
}
|
|
149
|
-
console.log("\n==== End of Session Path Diagnostics ====");
|