ciscollm-cli 1.1.1 โ†’ 1.1.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.
package/README.md CHANGED
@@ -1,279 +1,122 @@
1
- # ciscollm-cli
2
-
3
- `ciscollm-cli` is a premium, autonomous Cisco IOS automation agent CLI designed for network configuration, troubleshooting, and simulation. By leveraging LLM tool-calling capabilities, it allows engineers to manage local, remote, or simulated Cisco hardware safely and efficiently.
4
-
5
- The CLI features an **Interactive Setup Wizard**, **Multi-Device Coordination**, **Safety Guardrails (Command Firewall)**, **Automatic Configuration Rollbacks**, **Mock Device Simulation**, and **Strict Command Reference Validation**.
6
-
7
- ---
8
-
9
- ## ๐Ÿš€ Key Features
10
-
11
- ### 1. โš™๏ธ Interactive Setup Wizard
12
- If `ciscollm run` is executed without a `--goal` parameter, the CLI automatically launches a step-by-step interactive setup wizard (using `inquirer`). The wizard guides the user through:
13
- * **LLM Provider Selection:** Local (Ollama / LM Studio) or Cloud (OpenRouter).
14
- * **Local LLM Settings:** Service type (Ollama/LM Studio), API endpoint URL, and model name.
15
- * **Cloud LLM Settings:** OpenRouter API Key, model name, and endpoint.
16
- * **Connection Protocol:** Serial (with automated COM port scanning), SSH, Telnet, or Mock simulation.
17
- * **Connection Details:** COM port and Baud rate (for serial), or Host target, Port, Username, and Password (for SSH/Telnet).
18
- * **Configuration Goal:** Prompting for the network task the agent needs to achieve.
19
- * **Configuration Summary:** Displays a summary of the setup and prompts for final confirmation before starting execution.
20
-
21
- ### 2. ๐Ÿ”€ Multi-Device & Multi-Agent Coordination
22
- Manage configurations across multiple Cisco hardware devices simultaneously. The `--com` (for serial) and `--host` (for SSH/Telnet) flags accept comma-separated inputs (e.g. `--com COM3,COM4` or `--host 10.0.0.1,10.0.0.2`). The internal `MultiAgentCoordinator` manages all connections in parallel, tracks status, and handles clean disconnections upon exit.
23
-
24
- ### 3. ๐Ÿ›ก๏ธ Command Firewall & Safety Guardrails
25
- To prevent accidental lockouts, service disruptions, or losing device access, the built-in `CommandFirewall` monitors all LLM-generated commands.
26
- * **Blocked Operations:**
27
- * Removing default static routes (`no ip route 0.0.0.0...`) which can break management access.
28
- * Disabling AAA authentication (`no aaa new-model`) or zeroizing crypto keys (`crypto key zeroize`).
29
- * Deleting access lists or access groups (`no access-list`, `no ip access-group`).
30
- * Shutting down active protected interfaces (e.g. `GigabitEthernet0/0`, `GigabitEthernet0/1`, `GigabitEthernet1/0`, `Vlan1`).
31
- * Removing configured IP addresses on protected interfaces (`no ip address`).
32
- * **Human-in-the-Loop Validation:** High-risk commands trigger a warning prompt, requiring the operator to manually authorize the execution.
33
- * **Non-Interactive Mode:** Running with `--non-interactive` (or setting environment variable `CISCOLLM_NON_INTERACTIVE=true`) automatically rejects all blocked/high-risk commands.
34
-
35
- ### 4. ๐Ÿ”„ Transaction Rollback & Inversion Manager
36
- If a configuration step fails or the agent encounters command errors, the `TransactionManager` restores the device state:
37
- * **Atomic Backup:** Before modifying config, the agent attempts to back up the current running-config to `flash:backup-agent.cfg`.
38
- * **Atomic Configuration Replace:** Rollbacks prioritize replacing the configuration atomically using `configure replace flash:backup-agent.cfg force`.
39
- * **Command Inversion Fallback:** If flash storage is unreachable, it builds an inverse command sequence in reverse order (e.g. `ip address ...` -> `no ip address`, `shutdown` -> `no shutdown`, `no shutdown` -> `shutdown`, `description ...` -> `no description`) and executes them sequentially in their respective submodes.
40
-
41
- ### 5. ๐Ÿ“š Strict Command Reference Validation
42
- Enforces compliance against an official Cisco IOS Command Reference index:
43
- * **Strict Validation Mode:** Enabled via `--strict-command-ref` (or setting `CISCOLLM_STRICT_COMMAND_REF=true`). The agent will block any command not listed in the command-reference index.
44
- * **PDF Command Indexer:** The engine reads `cf_command_ref.pdf`, extracts structural commands, and caches them in `.cache/cf_command_ref.index.json` to speed up startup times.
45
- * **Fuzzy Command Family Expansion:** Automatically expands shortened commands (e.g. `sh` -> `show`, `conf t` -> `configure terminal`, `int gig0/1` -> `interface GigabitEthernet0/1`) to check they match valid command families in the index.
46
- * **Reference Telemetry:** Telemetry logs detail the warmup time, source (PDF, cache, or memory), and matched command count. Can be disabled with `--no-ref-telemetry`.
47
-
48
- ### 6. ๐Ÿงช Mock Device Simulation
49
- Mock mode (`--protocol mock`) provides a stateful simulation of a Cisco IOS device, allowing offline development and testing. It features:
50
- * **Stateful Database:** Maintains interfaces, VLANs, shell variables, shell functions, and static routing tables, saved locally under `.mock-state-<device>.json`.
51
- * **Interactive CLI Simulator:** Simulates user and privileged EXEC modes, configuration modes, VLAN databases, DHCP pools, OSPF routers, and IP routing tables.
52
- * **Output Filtering (Pipes):** Supports standard IOS output piping such as `| include`, `| grep`, `| exclude`, and `| begin`.
53
- * **Network Testing:** Simulates latency and ICMP ping responses.
54
-
55
- ### 7. ๐Ÿ›ก๏ธ Pre-Execution Safety Validation (Dry-Run Check)
56
- Before executing any state-mutating command, the agent runs a dry-run check against the known network topology:
57
- * **Topology Awareness:** Analyzes active physical/logical links between core, distribution, and access segments.
58
- * **Accidental Disruption Prevention:** Detects and intercepts commands that could accidentally shut down critical uplink ports or neighbor nodes, ensuring continuous uptime.
59
- * **Inspection Throttling:** Repeated inspection commands such as `show ip interface brief` are not treated as a harmful loop, but repeated configuration retries still are.
60
-
61
- ### 8. ๐Ÿง  Prompt Discipline for Safe Change Windows
62
- The agent prompt now follows a tighter inspection/configuration/verification flow:
63
- * **Single Pre-Check:** Perform one inspection pass before a configuration block instead of repeatedly polling the same status command.
64
- * **Configuration Block:** Apply the requested changes as a focused sequence of commands.
65
- * **Single Verification Pass:** Verify the applied change once with `show` or `ping_test`, then stop if the result is clean.
66
-
67
- ### 9. ๐Ÿ“Š Live Configuration State Diff Engine
68
- Maintains deep visibility of system modifications:
69
- * **Before/After Snapshots:** Takes memory-efficient snapshots of device interfaces, IP addresses, subnets, routing tables, and active VLAN databases before and after executing any command.
70
- * **Visual Colorized Diffs:** Automatically outputs a structured difference report highlighting additions in green, removals in red, and updates/modifications in yellow.
71
-
72
- ### 10. ๐Ÿชต Continuous Enterprise Audit Trails
73
- Ensures accountability for automated activities:
74
- * **Detailed Logs:** Generates structured records containing the timestamp, target device, active agent role, LLM reasoning thoughts, executed commands, and final output status.
75
- * **Local Audit Store:** Persists all interactions locally to `audit.log` for easy integration with standard security information and event management (SIEM) systems.
76
-
77
- ### 11. ๐Ÿ”€ Hierarchical Network Swarms
78
- Supports role-specific command delegation and intelligence:
79
- * **Role Routing:** Multi-agent coordinator routes tasks to specialized personalitiesโ€”**Core Agent**, **Distribution Agent**, and **Access Agent**โ€”matching the logical tier of the configuration task.
80
- * **RBAC Constraints:** Restricts operations according to the `--rbac-role` parameter. The `read_only` role safely blocks any modifying actions and logs violations to the audit log.
81
-
82
- ### 12. ๐Ÿ”Œ NETCONF & CML Simulation Adapters
83
- Extends sandbox capabilities beyond local mock devices:
84
- * **Cisco Modeling Labs (CML):** Provides sessions to interact directly with digital twin network simulations.
85
- * **NETCONF XML Sessions:** Supports programmatic configuration using structured XML RPC calls and YANG schemas.
86
- * **NETCONF SSH Auth:** Supports username/password, SSH private key, passphrase, and NETCONF timeout tuning for real devices.
87
-
88
- ### 13. ๐Ÿš Interactive Mock Shell Simulator
89
- Directly access a simulated stateful Cisco IOS shell on the terminal using `ciscollm shell`. Ideal for testing config commands, interface setups, routing tables, and VLANs interactively without a live device connection.
90
-
91
- ### 14. ๐Ÿ“Š Live Visual Control Dashboard
92
- Start a native, zero-dependency visual server starting on port `3000` (or custom `--dashboard-port`) using `ciscollm dashboard` or automatically during agent runs. It offers an interactive SPA showing:
93
- * **Interactive Swarm Topology Map:** Visualized dynamically using Vis.js.
94
- * **Real-time Agent Action Logs:** Monitor command firewalls, thoughts, and rule violations.
95
- * **Dynamic Configuration Diffs:** Detailed green/red difference reports of all configuration modifications.
96
- * **Emergency Rollback:** An instant, manual trigger to restore configuration states across all synchronized devices.
97
- * **Mobile/Responsive Layout:** Clean HSL-curated dark slate glassmorphism designed to fit desktop, tablet, and mobile views.
98
-
99
- ### 15. ๐Ÿ›ก๏ธ Network Pre & Post-Flight Audits
100
- Executes automated preflight and postflight network safety scans:
101
- * **Gateway Reachability:** Verifies default gateway ping connectivity.
102
- * **Interface Administrative Status:** Inspects status and alerts if protected links go down.
103
- * **OSPF neighbor counts and route tallies:** Automatically audits the number of active routing peers and OSPF-learned paths.
104
- * Displays a clean, tabular side-by-side audit report directly in the console terminal upon completing any run.
105
-
106
- ---
107
-
108
- ## ๐Ÿ“ฆ Installation
109
-
110
- To install `ciscollm-cli` globally from npm:
111
-
112
- ```bash
113
- npm install -g ciscollm-cli
114
- ```
115
-
116
- Once installed, the global executable `ciscollm` becomes available.
117
-
118
- ---
119
-
120
- ## ๐Ÿ› ๏ธ CLI Usage & Options
121
-
122
- You can invoke `ciscollm` using one of the following subcommands:
123
-
124
- ### 1. `ciscollm run`
125
- Execute network configuration or optimization tasks on target Cisco hardware.
126
-
127
- ```bash
128
- ciscollm run [options]
129
- ```
130
-
131
- | Option / Flag | Alias | Description | Default Value |
132
- |---|---|---|---|
133
- | `-g, --goal <intent>` | - | The goal of the configuration/troubleshooting task. If not specified, launches the Interactive Setup Wizard. | - |
134
- | `--protocol <type>` | - | Connection protocol (`serial`, `ssh`, `telnet`, `mock`, `netconf`, `cml`). | `serial` |
135
- | `--provider <type>` | - | LLM provider mode (`local`, `cloud`). | `local` |
136
- | `--local-type <type>` | - | Local LLM server flavor (`ollama`, `lmstudio`). | `ollama` |
137
- | `--model <name>` | - | Name of the LLM model to compile. | - |
138
- | `--endpoint <url>` | - | The LLM API endpoint URL. | - |
139
- | `--api-key <key>` | - | API key for the cloud provider (OpenRouter). | - |
140
- | `-c, --com <ports>` | - | COM Port(s), comma-separated (e.g., `COM3` or `COM3,COM4`). | - |
141
- | `-b, --baud <rate>` | - | Serial transmission baud rate. | `9600` |
142
- | `--host <address>` | - | Target IP address or hostname (comma-separated for multi-device). | - |
143
- | `--port <port>` | - | Target connection port. | - |
144
- | `-u, --username <name>` | - | Device login username. | - |
145
- | `-p, --password <pass>` | - | Device login password. | - |
146
- | `--env-password` | - | Read the device password from the `CISCOLLM_PASS` environment variable. | `false` |
147
- | `--private-key <path>` | - | SSH private key file path for SSH and NETCONF sessions. | - |
148
- | `--passphrase <passphrase>` | - | Passphrase for the SSH private key file. | - |
149
- | `--netconf-ready-timeout <ms>` | - | NETCONF SSH ready timeout in milliseconds. | `20000` |
150
- | `--netconf-hello-timeout <ms>` | - | NETCONF hello exchange timeout in milliseconds. | `15000` |
151
- | `--netconf-rpc-timeout <ms>` | - | NETCONF RPC response timeout in milliseconds. | `15000` |
152
- | `--netconf-keepalive-interval <ms>` | - | NETCONF SSH keepalive interval in milliseconds. | `10000` |
153
- | `--strict-command-ref` | - | Block commands not found in the `cf_command_ref.pdf` index. | `false` |
154
- | `--no-ref-telemetry` | - | Disable command-reference warmup telemetry logs. | `false` |
155
- | `--non-interactive` | - | Run without interactive prompts (auto-rejects dangerous commands). | `false` |
156
- | `--rbac-role <role>` | - | Specify the Active Agent RBAC authorization role (`admin`, `read_only`). | `admin` |
157
- | `--dashboard-port <port>` | - | Port to host the live Visual Control Dashboard server. | `3000` |
158
-
159
- ### 2. `ciscollm server`
160
- Start the Cisco IOS Multi-Protocol Test Simulator (SSH, Telnet, NETCONF, and HTTP LLM Mock).
161
-
162
- ```bash
163
- ciscollm server [options]
164
- ```
165
-
166
- | Option / Flag | Description | Default Value |
167
- |---|---|---|
168
- | `--ssh-port <port>` | Port for the mock SSH & NETCONF server | `2222` |
169
- | `--telnet-port <port>` | Port for the mock Telnet server | `2323` |
170
- | `--http-port <port>` | Port for the mock HTTP LLM server | `11434` |
171
-
172
- ### 3. `ciscollm shell`
173
- Launch the interactive stateful Cisco IOS mock shell simulator directly.
174
-
175
- ```bash
176
- ciscollm shell
177
- ```
178
-
179
- ### 4. `ciscollm dashboard`
180
- Start the visual control dashboard server standalone to inspect historical records and active topology.
181
-
182
- ```bash
183
- ciscollm dashboard [options]
184
- ```
185
-
186
- | Option / Flag | Description | Default Value |
187
- |---|---|---|
188
- | `--port <port>` | Port for the dashboard server | `3000` |
189
-
190
- ---
191
-
192
- ## ๐Ÿ’ก Usage Examples
193
-
194
- ### 1. Launching the Interactive Setup Wizard
195
- Start the interactive CLI configuration process:
196
- ```bash
197
- ciscollm run
198
- ```
199
-
200
- ### 2. Running a Quick Mock Simulation
201
- ```bash
202
- ciscollm run --protocol mock --goal "Configure GigabitEthernet0/1 with IP 192.168.2.1/24 and interface description 'LAN B'"
203
- ```
204
-
205
- ### 3. Local Model (Ollama)
206
- ```bash
207
- ciscollm run --provider local --local-type ollama --endpoint http://127.0.0.1:11434/v1 --model qwen3.5-4b --protocol mock --goal "Show IP routing table"
208
- ```
209
-
210
- ### 4. Cloud Inference via OpenRouter
211
- ```bash
212
- ciscollm run --provider cloud --api-key YOUR_OPENROUTER_API_KEY --protocol mock --goal "Verify interface states"
213
- ```
214
-
215
- ### 5. Enforcing Strict Validation Mode
216
- ```bash
217
- ciscollm run --strict-command-ref --protocol mock --goal "Configure router ospf 1 and advertise network 192.168.1.0/24"
218
- ```
219
-
220
- ### 6. NETCONF Session with SSH Key Auth
221
- ```bash
222
- ciscollm run --protocol netconf --host 192.168.1.188 --port 830 --username admin --private-key C:\\Users\\me\\.ssh\\id_rsa --passphrase YOUR_PASSPHRASE --netconf-rpc-timeout 20000 --goal "Show running configuration"
223
- ```
224
-
225
- ### 7. NETCONF Session with Password from Environment
226
- ```bash
227
- $env:CISCOLLM_PASS = '!@admin1234'
228
- ciscollm run --protocol netconf --host 192.168.1.188 --username admin --env-password --goal "Show interface brief"
229
- ```
230
-
231
- ### 8. Starting the Multi-Protocol Test Simulator
232
- Start the simulator server which handles SSH/Telnet connections and hosts a mock LLM endpoint:
233
- ```bash
234
- ciscollm server --ssh-port 2222 --telnet-port 2323 --http-port 11434
235
- ```
236
-
237
- ### 9. Launching the Stateful Interactive Shell
238
- Directly test and play with IOS commands:
239
- ```bash
240
- ciscollm shell
241
- ```
242
-
243
- ### 10. Running the Dashboard Standalone
244
- Inspect previous change runs, active state differences, or network topologies:
245
- ```bash
246
- ciscollm dashboard --port 3000
247
- ```
248
-
249
- ---
250
-
251
- ## ๐Ÿ’ป Development & Contribution
252
-
253
- Follow these steps to set up the project locally for development:
254
-
255
- ### 1. Clone & Install Dependencies
256
- ```bash
257
- git clone https://github.com/ThemeHackers/ciscollm-cli.git
258
- cd ciscollm-cli
259
- npm install
260
- ```
261
-
262
- ### 2. Build the Project
263
- Compile the TypeScript code to target JavaScript inside `dist/`:
264
- ```bash
265
- npm run build
266
- ```
267
-
268
- ### 3. Run Development Build
269
- Run the CLI locally from source code:
270
- ```bash
271
- npm start -- run --protocol mock --goal "Show running config"
272
- ```
273
-
274
- ### 4. Run Unit Tests
275
- Validate features including the Command Firewall, Transaction Manager, and Error Analyzer:
276
- ```bash
277
- npm run test
278
- ```
279
-
1
+ # ciscollm-cli
2
+
3
+ `ciscollm-cli` is an autonomous Cisco IOS automation agent CLI powered by LLM tool-calling. It allows network engineers to configure, troubleshoot, and simulate Cisco hardware safely and efficiently with strict safety guardrails.
4
+
5
+ ---
6
+
7
+ ## ๐Ÿš€ Core Capabilities
8
+
9
+ 1. **Intelligent Cisco Automation Swarm**
10
+ * Multi-agent coordination with role-based routing (Core, Distribution, Access).
11
+ * Supports both local models (Ollama, LM Studio) and cloud endpoints (OpenRouter).
12
+
13
+ 2. **Enterprise-Grade Safety Guardrails**
14
+ * **Command Firewall**: Intercepts high-risk commands (e.g. disabling AAA, removing access groups, shutting management interfaces).
15
+ * **Dry-Run Validation**: Analyzes network topology beforehand to prevent accidental disruptions.
16
+ * **Strict Command Reference**: Restricts execution to valid Cisco IOS command sets indexed from `cf_command_ref.pdf`.
17
+
18
+ 3. **Atomic Transactions & Recovery**
19
+ * **Atomic Replace**: Backs up configuration to flash and uses `configure replace` to restore state on failures.
20
+ * **Command Inversion Fallback**: Generates reverse commands (e.g. `shutdown` -> `no shutdown`) to recover state if flash storage is unavailable.
21
+
22
+ 4. **Live Visualization & Audits**
23
+ * **Visual Control Dashboard**: A real-time SPA showing network topology maps, agent thinking logs, configuration diffs, and manual rollbacks.
24
+ * **State Diff Engine**: Displays colorized differences (green/red/yellow) in routing tables, VLANs, and interfaces.
25
+ * **Enterprise Audit Log**: Local, structured audit logging (`audit.log`) for compliance.
26
+
27
+ 5. **Multi-Protocol Simulation & Adapters**
28
+ * Adapters for Serial (Plink), SSH, Telnet, NETCONF XML, and Cisco Modeling Labs (CML).
29
+ * Stateful mock IOS simulator server and local interactive shell (`ciscollm shell`).
30
+
31
+ ---
32
+
33
+ ## ๐Ÿ“ฆ Quick Start
34
+
35
+ ### Installation
36
+ Install the global executable via `npm`:
37
+ ```bash
38
+ npm install -g ciscollm-cli
39
+ ```
40
+
41
+ ### Starting the Simulator Server (For Testing)
42
+ Start the multi-protocol test server (SSH, Telnet, NETCONF, and Mock LLM endpoint):
43
+ ```bash
44
+ ciscollm server --ssh-port 2222 --telnet-port 2323 --http-port 11434
45
+ ```
46
+
47
+ ### Launching the Agent
48
+ Run the interactive setup wizard to configure the agent target and goals:
49
+ ```bash
50
+ ciscollm run
51
+ ```
52
+
53
+ ---
54
+
55
+ ## ๐Ÿ› ๏ธ CLI Usage & Options
56
+
57
+ ### `ciscollm run [options]`
58
+ Execute configuration or optimization tasks on target hardware.
59
+
60
+ | Option / Flag | Description | Default |
61
+ |---|---|---|
62
+ | `-g, --goal <intent>` | Configuration goal. Omit to launch the Interactive Setup Wizard. | - |
63
+ | `--protocol <type>` | Connection protocol (`serial`, `ssh`, `telnet`, `netconf`, `cml`). | `serial` |
64
+ | `--provider <type>` | LLM provider mode (`local`, `cloud`). | `local` |
65
+ | `--local-type <type>` | Local LLM service flavor (`ollama`, `lmstudio`). | `ollama` |
66
+ | `--model <name>` | LLM model name. | - |
67
+ | `--endpoint <url>` | LLM API server endpoint. | - |
68
+ | `--api-key <key>` | Cloud provider (OpenRouter) API key. | - |
69
+ | `-c, --com <ports>` | COM Port(s), comma-separated (e.g., `COM3,COM4`). | - |
70
+ | `--host <address>` | Target IP / hostnames, comma-separated. | - |
71
+ | `-u, --username <name>` | Login username. | - |
72
+ | `-p, --password <pass>` | Login password. | - |
73
+ | `--strict-command-ref` | Block commands not listed in `cf_command_ref.pdf`. | `false` |
74
+ | `--non-interactive` | Auto-reject high-risk commands instead of prompting for approval. | `false` |
75
+ | `--rbac-role <role>` | Authorization role (`admin`, `read_only`). | `admin` |
76
+ | `--dashboard-port <port>` | Live Visual Dashboard port. | `3000` |
77
+
78
+ ### Other Commands
79
+ * `ciscollm server [options]` - Start mock SSH, Telnet, and LLM servers for sandbox testing.
80
+ * `ciscollm shell` - Launch a stateful interactive mock Cisco IOS command line directly.
81
+ * `ciscollm dashboard [--port <port>]` - Start the visual dashboard standalone.
82
+
83
+ ---
84
+
85
+ ## ๐Ÿ’ก Quick Examples
86
+
87
+ #### 1. Configuring Interfaces via Local Simulation (SSH)
88
+ ```bash
89
+ ciscollm run --protocol ssh --host 127.0.0.1 --port 2222 -u admin -p admin --goal "Configure GigabitEthernet0/1 with IP 192.168.2.1/24 and interface description 'LAN B'"
90
+ ```
91
+
92
+ #### 2. Running local LLM (Ollama) against Simulation
93
+ ```bash
94
+ ciscollm run --provider local --local-type ollama --endpoint http://127.0.0.1:11434/v1 --model qwen3.5:4b --protocol ssh --host 127.0.0.1 --port 2222 -u admin -p admin --goal "Show IP routing table"
95
+ ```
96
+
97
+ #### 3. Strict Command Reference compliance
98
+ ```bash
99
+ ciscollm run --strict-command-ref --protocol ssh --host 127.0.0.1 --port 2222 -u admin -p admin --goal "Configure router ospf 1 and advertise 192.168.1.0/24"
100
+ ```
101
+
102
+ ---
103
+
104
+ ## ๐Ÿ’ป Development
105
+
106
+ 1. **Setup Workspace:**
107
+ ```bash
108
+ git clone https://github.com/ThemeHackers/ciscollm-cli.git
109
+ cd ciscollm-cli
110
+ npm install
111
+ ```
112
+
113
+ 2. **Build and Run:**
114
+ ```bash
115
+ npm run build
116
+ npm start -- run
117
+ ```
118
+
119
+ 3. **Run Unit Tests:**
120
+ ```bash
121
+ npm run test
122
+ ```
@@ -18,6 +18,7 @@ const AuditLogger_1 = require("../guardrails/AuditLogger");
18
18
  const HierarchicalAgentManager_1 = require("./HierarchicalAgentManager");
19
19
  const StateDiff_1 = require("../rollback/StateDiff");
20
20
  const NetworkAudit_1 = require("../guardrails/NetworkAudit");
21
+ const utils_1 = require("../../shared/utils");
21
22
  class CiscoAgentLoop {
22
23
  llmClient;
23
24
  coordinator;
@@ -462,7 +463,7 @@ class CiscoAgentLoop {
462
463
  async handleExecuteCommandCall(call) {
463
464
  let args;
464
465
  try {
465
- args = JSON.parse(call.function.arguments);
466
+ args = (0, utils_1.safeJsonParse)(call.function.arguments);
466
467
  }
467
468
  catch (e) {
468
469
  this.injectToolResponse(call.id, 'execute_ios_command', `Format Error: Invalid Tool Call arguments. Must be JSON.`);
@@ -647,29 +648,6 @@ class CiscoAgentLoop {
647
648
  const session = this.coordinator.getSession(deviceId);
648
649
  if (!session)
649
650
  return null;
650
- if (typeof session.interfaces !== 'undefined') {
651
- const mock = session;
652
- const interfaceList = [];
653
- for (const [name, conf] of mock.interfaces.entries()) {
654
- interfaceList.push({
655
- name,
656
- ip: conf.ip,
657
- subnet: conf.subnet,
658
- adminShutdown: conf.adminShutdown,
659
- lineProtocolUp: conf.lineProtocolUp,
660
- description: conf.description
661
- });
662
- }
663
- return {
664
- deviceId,
665
- timestamp: new Date().toISOString(),
666
- sessionState: session.getState(),
667
- interfaces: interfaceList,
668
- routes: [...mock.routes],
669
- vlans: Array.from(mock.vlans)
670
- };
671
- }
672
- // Real devices over SSH, Telnet, Serial, etc.
673
651
  try {
674
652
  const state = session.getState();
675
653
  const prefix = (state.currentMode === 'GLOBAL_CONFIG' || state.currentMode === 'INTERFACE_CONFIG') ? 'do ' : '';
@@ -799,7 +777,7 @@ class CiscoAgentLoop {
799
777
  async handleEnableIosShellCall(call) {
800
778
  let args;
801
779
  try {
802
- args = JSON.parse(call.function.arguments);
780
+ args = (0, utils_1.safeJsonParse)(call.function.arguments);
803
781
  }
804
782
  catch (e) {
805
783
  this.injectToolResponse(call.id, 'enable_ios_shell', `Format Error: Invalid Tool Call arguments. Must be JSON.`);
@@ -838,7 +816,7 @@ class CiscoAgentLoop {
838
816
  async handleDefineShellVariableCall(call) {
839
817
  let args;
840
818
  try {
841
- args = JSON.parse(call.function.arguments);
819
+ args = (0, utils_1.safeJsonParse)(call.function.arguments);
842
820
  }
843
821
  catch (e) {
844
822
  this.injectToolResponse(call.id, 'define_shell_variable', `Format Error: Invalid Tool Call arguments. Must be JSON.`);
@@ -868,7 +846,7 @@ class CiscoAgentLoop {
868
846
  async handleExecuteShellLoopCall(call) {
869
847
  let args;
870
848
  try {
871
- args = JSON.parse(call.function.arguments);
849
+ args = (0, utils_1.safeJsonParse)(call.function.arguments);
872
850
  }
873
851
  catch (e) {
874
852
  this.injectToolResponse(call.id, 'execute_shell_loop', `Format Error: Invalid Tool Call arguments. Must be JSON.`);
@@ -900,7 +878,7 @@ class CiscoAgentLoop {
900
878
  async handleDefineShellFunctionCall(call) {
901
879
  let args;
902
880
  try {
903
- args = JSON.parse(call.function.arguments);
881
+ args = (0, utils_1.safeJsonParse)(call.function.arguments);
904
882
  }
905
883
  catch (e) {
906
884
  this.injectToolResponse(call.id, 'define_shell_function', `Format Error: Invalid Tool Call arguments. Must be JSON.`);
@@ -931,7 +909,7 @@ class CiscoAgentLoop {
931
909
  async handlePingTestCall(call) {
932
910
  let args;
933
911
  try {
934
- args = JSON.parse(call.function.arguments);
912
+ args = (0, utils_1.safeJsonParse)(call.function.arguments);
935
913
  }
936
914
  catch (e) {
937
915
  this.injectToolResponse(call.id, 'ping_test', `Format Error: Invalid Tool Call arguments. Must be JSON.`);