ciscollm-cli 1.0.1
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/LICENSE +21 -0
- package/README.md +112 -0
- package/dist/cli/ui/ui.d.ts +10 -0
- package/dist/cli/ui/ui.js +25 -0
- package/dist/cli/ui/ui.js.map +1 -0
- package/dist/core/agent/AgentLoop.d.ts +38 -0
- package/dist/core/agent/AgentLoop.js +562 -0
- package/dist/core/agent/AgentLoop.js.map +1 -0
- package/dist/core/agent/CommandReferenceEngine.d.ts +43 -0
- package/dist/core/agent/CommandReferenceEngine.js +366 -0
- package/dist/core/agent/CommandReferenceEngine.js.map +1 -0
- package/dist/core/agent/MultiAgentCoordinator.d.ts +12 -0
- package/dist/core/agent/MultiAgentCoordinator.js +57 -0
- package/dist/core/agent/MultiAgentCoordinator.js.map +1 -0
- package/dist/core/agent/PromptEngine.d.ts +3 -0
- package/dist/core/agent/PromptEngine.js +57 -0
- package/dist/core/agent/PromptEngine.js.map +1 -0
- package/dist/core/guardrails/CommandFirewall.d.ts +10 -0
- package/dist/core/guardrails/CommandFirewall.js +108 -0
- package/dist/core/guardrails/CommandFirewall.js.map +1 -0
- package/dist/core/guardrails/ErrorAnalyzer.d.ts +7 -0
- package/dist/core/guardrails/ErrorAnalyzer.js +16 -0
- package/dist/core/guardrails/ErrorAnalyzer.js.map +1 -0
- package/dist/core/rollback/TransactionManager.d.ts +13 -0
- package/dist/core/rollback/TransactionManager.js +144 -0
- package/dist/core/rollback/TransactionManager.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +578 -0
- package/dist/index.js.map +1 -0
- package/dist/infrastructure/llm/LLMClient.d.ts +11 -0
- package/dist/infrastructure/llm/LLMClient.js +94 -0
- package/dist/infrastructure/llm/LLMClient.js.map +1 -0
- package/dist/infrastructure/llm/LocalLLMClient.d.ts +7 -0
- package/dist/infrastructure/llm/LocalLLMClient.js +39 -0
- package/dist/infrastructure/llm/LocalLLMClient.js.map +1 -0
- package/dist/infrastructure/llm/ToolDefinitions.d.ts +179 -0
- package/dist/infrastructure/llm/ToolDefinitions.js +150 -0
- package/dist/infrastructure/llm/ToolDefinitions.js.map +1 -0
- package/dist/infrastructure/protocols/BaseSession.d.ts +10 -0
- package/dist/infrastructure/protocols/BaseSession.js +39 -0
- package/dist/infrastructure/protocols/BaseSession.js.map +1 -0
- package/dist/infrastructure/protocols/MockSession.d.ts +43 -0
- package/dist/infrastructure/protocols/MockSession.js +505 -0
- package/dist/infrastructure/protocols/MockSession.js.map +1 -0
- package/dist/infrastructure/protocols/PlinkSerial.d.ts +16 -0
- package/dist/infrastructure/protocols/PlinkSerial.js +132 -0
- package/dist/infrastructure/protocols/PlinkSerial.js.map +1 -0
- package/dist/infrastructure/protocols/SshSession.d.ts +19 -0
- package/dist/infrastructure/protocols/SshSession.js +110 -0
- package/dist/infrastructure/protocols/SshSession.js.map +1 -0
- package/dist/infrastructure/protocols/TelnetSession.d.ts +17 -0
- package/dist/infrastructure/protocols/TelnetSession.js +177 -0
- package/dist/infrastructure/protocols/TelnetSession.js.map +1 -0
- package/dist/shared/constants.d.ts +8 -0
- package/dist/shared/constants.js +25 -0
- package/dist/shared/constants.js.map +1 -0
- package/dist/shared/types.d.ts +22 -0
- package/dist/shared/types.js +3 -0
- package/dist/shared/types.js.map +1 -0
- package/package.json +49 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.LLMClient = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const ToolDefinitions_1 = require("./ToolDefinitions");
|
|
9
|
+
class LLMClient {
|
|
10
|
+
provider;
|
|
11
|
+
endpoint;
|
|
12
|
+
modelName;
|
|
13
|
+
apiKey;
|
|
14
|
+
constructor(provider = 'local', endpoint, modelName, apiKey) {
|
|
15
|
+
this.provider = provider;
|
|
16
|
+
this.apiKey = apiKey;
|
|
17
|
+
if (this.provider === 'cloud') {
|
|
18
|
+
this.endpoint = endpoint || 'https://openrouter.ai/api/v1';
|
|
19
|
+
this.modelName = modelName || 'nvidia/nemotron-3-super-120b-a12b:free';
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
this.endpoint = endpoint || 'http://127.0.0.1:11434/v1';
|
|
23
|
+
this.modelName = modelName || 'qwen3.5-4b';
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
async generateCompletion(messages, tools = ToolDefinitions_1.CiscoAgentTools) {
|
|
27
|
+
try {
|
|
28
|
+
const url = `${this.endpoint.replace(/\/$/, '')}/chat/completions`;
|
|
29
|
+
const headers = {
|
|
30
|
+
'Content-Type': 'application/json'
|
|
31
|
+
};
|
|
32
|
+
if (this.provider === 'cloud') {
|
|
33
|
+
const key = this.apiKey || process.env.OPENROUTER_API_KEY;
|
|
34
|
+
if (!key) {
|
|
35
|
+
throw new Error('API key is required for cloud provider. Set OPENROUTER_API_KEY environment variable or pass --api-key.');
|
|
36
|
+
}
|
|
37
|
+
headers['Authorization'] = `Bearer ${key}`;
|
|
38
|
+
headers['HTTP-Referer'] = 'https://github.com/ThemeHackers/LearnSync';
|
|
39
|
+
headers['X-Title'] = 'ciscollm-cli';
|
|
40
|
+
}
|
|
41
|
+
const response = await axios_1.default.post(url, {
|
|
42
|
+
model: this.modelName,
|
|
43
|
+
messages: messages,
|
|
44
|
+
tools: tools,
|
|
45
|
+
tool_choice: 'auto',
|
|
46
|
+
temperature: 0.1
|
|
47
|
+
}, { headers });
|
|
48
|
+
return response.data.choices[0].message;
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
let details = error.message;
|
|
52
|
+
if (error.response && error.response.data) {
|
|
53
|
+
details = typeof error.response.data === 'string'
|
|
54
|
+
? error.response.data
|
|
55
|
+
: JSON.stringify(error.response.data);
|
|
56
|
+
}
|
|
57
|
+
throw new Error(`LLM Client Error [${this.provider}]: ${details}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async ensureReachable(timeoutMs = 3500) {
|
|
61
|
+
const base = this.endpoint.replace(/\/$/, '');
|
|
62
|
+
const probeUrls = [];
|
|
63
|
+
probeUrls.push(`${base}/models`);
|
|
64
|
+
if (this.provider === 'local') {
|
|
65
|
+
const withoutV1 = base.replace(/\/v1$/i, '');
|
|
66
|
+
if (withoutV1 !== base) {
|
|
67
|
+
probeUrls.push(`${withoutV1}/api/tags`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const errors = [];
|
|
71
|
+
for (const url of probeUrls) {
|
|
72
|
+
try {
|
|
73
|
+
const response = await axios_1.default.get(url, { timeout: timeoutMs });
|
|
74
|
+
if (response.status >= 200 && response.status < 500) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
errors.push(`${url} -> HTTP ${response.status}`);
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
errors.push(`${url} -> ${err.message}`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const guidance = this.provider === 'local'
|
|
84
|
+
? [
|
|
85
|
+
'For Ollama: run "ollama serve" and ensure your model is pulled (e.g., "ollama pull qwen3.5:4b").',
|
|
86
|
+
'For LM Studio: start the local server and use --local-type lmstudio --endpoint http://127.0.0.1:1234/v1.'
|
|
87
|
+
].join(' ')
|
|
88
|
+
: 'Check endpoint URL, API key, network, and provider availability.';
|
|
89
|
+
throw new Error(`LLM endpoint preflight failed for [${this.provider}] at "${this.endpoint}". ` +
|
|
90
|
+
`Probes: ${errors.join(' | ')}. ${guidance}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.LLMClient = LLMClient;
|
|
94
|
+
//# sourceMappingURL=LLMClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":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importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.LocalLLMClient = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const ToolDefinitions_1 = require("./ToolDefinitions");
|
|
9
|
+
class LocalLLMClient {
|
|
10
|
+
endpoint;
|
|
11
|
+
modelName;
|
|
12
|
+
constructor(endpoint = 'http://127.0.0.1:11434/v1', modelName = 'llama3:8b') {
|
|
13
|
+
this.endpoint = endpoint;
|
|
14
|
+
this.modelName = modelName;
|
|
15
|
+
}
|
|
16
|
+
async generateCompletion(messages) {
|
|
17
|
+
try {
|
|
18
|
+
const response = await axios_1.default.post(`${this.endpoint}/chat/completions`, {
|
|
19
|
+
model: this.modelName,
|
|
20
|
+
messages: messages,
|
|
21
|
+
tools: ToolDefinitions_1.CiscoAgentTools,
|
|
22
|
+
tool_choice: 'auto',
|
|
23
|
+
temperature: 0.1 // Kept low to enforce analytical consistency
|
|
24
|
+
});
|
|
25
|
+
return response.data.choices[0].message;
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
let details = error.message;
|
|
29
|
+
if (error.response && error.response.data) {
|
|
30
|
+
details = typeof error.response.data === 'string'
|
|
31
|
+
? error.response.data
|
|
32
|
+
: JSON.stringify(error.response.data);
|
|
33
|
+
}
|
|
34
|
+
throw new Error(`LLM Service Error: ${details}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.LocalLLMClient = LocalLLMClient;
|
|
39
|
+
//# sourceMappingURL=LocalLLMClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalLLMClient.js","sourceRoot":"","sources":["../../../src/infrastructure/llm/LocalLLMClient.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,uDAAoD;AAGpD,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5
|
+
description: string;
|
|
6
|
+
parameters: {
|
|
7
|
+
type: string;
|
|
8
|
+
properties: {
|
|
9
|
+
command: {
|
|
10
|
+
type: string;
|
|
11
|
+
description: string;
|
|
12
|
+
};
|
|
13
|
+
device: {
|
|
14
|
+
type: string;
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
destination?: undefined;
|
|
18
|
+
mode?: undefined;
|
|
19
|
+
name?: undefined;
|
|
20
|
+
value?: undefined;
|
|
21
|
+
variable?: undefined;
|
|
22
|
+
items?: undefined;
|
|
23
|
+
body?: undefined;
|
|
24
|
+
};
|
|
25
|
+
required: string[];
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
} | {
|
|
29
|
+
type: string;
|
|
30
|
+
function: {
|
|
31
|
+
name: string;
|
|
32
|
+
description: string;
|
|
33
|
+
parameters: {
|
|
34
|
+
type: string;
|
|
35
|
+
properties: {
|
|
36
|
+
destination: {
|
|
37
|
+
type: string;
|
|
38
|
+
description: string;
|
|
39
|
+
};
|
|
40
|
+
device: {
|
|
41
|
+
type: string;
|
|
42
|
+
description: string;
|
|
43
|
+
};
|
|
44
|
+
command?: undefined;
|
|
45
|
+
mode?: undefined;
|
|
46
|
+
name?: undefined;
|
|
47
|
+
value?: undefined;
|
|
48
|
+
variable?: undefined;
|
|
49
|
+
items?: undefined;
|
|
50
|
+
body?: undefined;
|
|
51
|
+
};
|
|
52
|
+
required: string[];
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
} | {
|
|
56
|
+
type: string;
|
|
57
|
+
function: {
|
|
58
|
+
name: string;
|
|
59
|
+
description: string;
|
|
60
|
+
parameters: {
|
|
61
|
+
type: string;
|
|
62
|
+
properties: {
|
|
63
|
+
mode: {
|
|
64
|
+
type: string;
|
|
65
|
+
enum: string[];
|
|
66
|
+
description: string;
|
|
67
|
+
};
|
|
68
|
+
device: {
|
|
69
|
+
type: string;
|
|
70
|
+
description: string;
|
|
71
|
+
};
|
|
72
|
+
command?: undefined;
|
|
73
|
+
destination?: undefined;
|
|
74
|
+
name?: undefined;
|
|
75
|
+
value?: undefined;
|
|
76
|
+
variable?: undefined;
|
|
77
|
+
items?: undefined;
|
|
78
|
+
body?: undefined;
|
|
79
|
+
};
|
|
80
|
+
required: string[];
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
} | {
|
|
84
|
+
type: string;
|
|
85
|
+
function: {
|
|
86
|
+
name: string;
|
|
87
|
+
description: string;
|
|
88
|
+
parameters: {
|
|
89
|
+
type: string;
|
|
90
|
+
properties: {
|
|
91
|
+
name: {
|
|
92
|
+
type: string;
|
|
93
|
+
description: string;
|
|
94
|
+
};
|
|
95
|
+
value: {
|
|
96
|
+
type: string;
|
|
97
|
+
description: string;
|
|
98
|
+
};
|
|
99
|
+
device: {
|
|
100
|
+
type: string;
|
|
101
|
+
description: string;
|
|
102
|
+
};
|
|
103
|
+
command?: undefined;
|
|
104
|
+
destination?: undefined;
|
|
105
|
+
mode?: undefined;
|
|
106
|
+
variable?: undefined;
|
|
107
|
+
items?: undefined;
|
|
108
|
+
body?: undefined;
|
|
109
|
+
};
|
|
110
|
+
required: string[];
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
} | {
|
|
114
|
+
type: string;
|
|
115
|
+
function: {
|
|
116
|
+
name: string;
|
|
117
|
+
description: string;
|
|
118
|
+
parameters: {
|
|
119
|
+
type: string;
|
|
120
|
+
properties: {
|
|
121
|
+
variable: {
|
|
122
|
+
type: string;
|
|
123
|
+
description: string;
|
|
124
|
+
};
|
|
125
|
+
items: {
|
|
126
|
+
type: string;
|
|
127
|
+
items: {
|
|
128
|
+
type: string;
|
|
129
|
+
};
|
|
130
|
+
description: string;
|
|
131
|
+
};
|
|
132
|
+
command: {
|
|
133
|
+
type: string;
|
|
134
|
+
description: string;
|
|
135
|
+
};
|
|
136
|
+
device: {
|
|
137
|
+
type: string;
|
|
138
|
+
description: string;
|
|
139
|
+
};
|
|
140
|
+
destination?: undefined;
|
|
141
|
+
mode?: undefined;
|
|
142
|
+
name?: undefined;
|
|
143
|
+
value?: undefined;
|
|
144
|
+
body?: undefined;
|
|
145
|
+
};
|
|
146
|
+
required: string[];
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
} | {
|
|
150
|
+
type: string;
|
|
151
|
+
function: {
|
|
152
|
+
name: string;
|
|
153
|
+
description: string;
|
|
154
|
+
parameters: {
|
|
155
|
+
type: string;
|
|
156
|
+
properties: {
|
|
157
|
+
name: {
|
|
158
|
+
type: string;
|
|
159
|
+
description: string;
|
|
160
|
+
};
|
|
161
|
+
body: {
|
|
162
|
+
type: string;
|
|
163
|
+
description: string;
|
|
164
|
+
};
|
|
165
|
+
device: {
|
|
166
|
+
type: string;
|
|
167
|
+
description: string;
|
|
168
|
+
};
|
|
169
|
+
command?: undefined;
|
|
170
|
+
destination?: undefined;
|
|
171
|
+
mode?: undefined;
|
|
172
|
+
value?: undefined;
|
|
173
|
+
variable?: undefined;
|
|
174
|
+
items?: undefined;
|
|
175
|
+
};
|
|
176
|
+
required: string[];
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
})[];
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CiscoAgentTools = void 0;
|
|
4
|
+
exports.CiscoAgentTools = [
|
|
5
|
+
{
|
|
6
|
+
type: 'function',
|
|
7
|
+
function: {
|
|
8
|
+
name: 'execute_ios_command',
|
|
9
|
+
description: 'Executes a single raw Cisco IOS command onto a target device and returns raw terminal output.',
|
|
10
|
+
parameters: {
|
|
11
|
+
type: 'object',
|
|
12
|
+
properties: {
|
|
13
|
+
command: {
|
|
14
|
+
type: 'string',
|
|
15
|
+
description: 'Cisco IOS command string (e.g., "show ip interface brief", "vlan 10"). Do not chain commands.'
|
|
16
|
+
},
|
|
17
|
+
device: {
|
|
18
|
+
type: 'string',
|
|
19
|
+
description: 'Optional. The target device identifier (e.g., "COM3", "COM4"). Required if multiple devices are connected.'
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
required: ['command']
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
type: 'function',
|
|
28
|
+
function: {
|
|
29
|
+
name: 'ping_test',
|
|
30
|
+
description: 'Executes a network ping test from the local host or from a target Cisco device to verify connection to a destination IP.',
|
|
31
|
+
parameters: {
|
|
32
|
+
type: 'object',
|
|
33
|
+
properties: {
|
|
34
|
+
destination: {
|
|
35
|
+
type: 'string',
|
|
36
|
+
description: 'The target IP address to ping (e.g. "192.168.1.1").'
|
|
37
|
+
},
|
|
38
|
+
device: {
|
|
39
|
+
type: 'string',
|
|
40
|
+
description: 'Optional. The source device identifier (e.g., "COM3") to perform ping from. If omitted, executes ping from the local host.'
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
required: ['destination']
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
type: 'function',
|
|
49
|
+
function: {
|
|
50
|
+
name: 'enable_ios_shell',
|
|
51
|
+
description: 'Enables Cisco IOS Shell (IOS.sh) globally or for the current terminal session.',
|
|
52
|
+
parameters: {
|
|
53
|
+
type: 'object',
|
|
54
|
+
properties: {
|
|
55
|
+
mode: {
|
|
56
|
+
type: 'string',
|
|
57
|
+
enum: ['global', 'session'],
|
|
58
|
+
description: 'Method to enable shell processing. "global" configures full processing globally, "session" enables it for the current terminal only.'
|
|
59
|
+
},
|
|
60
|
+
device: {
|
|
61
|
+
type: 'string',
|
|
62
|
+
description: 'Optional. The target device identifier (e.g., "COM3").'
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
required: ['mode']
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
type: 'function',
|
|
71
|
+
function: {
|
|
72
|
+
name: 'define_shell_variable',
|
|
73
|
+
description: 'Binds a value to a Cisco IOS Shell environment variable.',
|
|
74
|
+
parameters: {
|
|
75
|
+
type: 'object',
|
|
76
|
+
properties: {
|
|
77
|
+
name: {
|
|
78
|
+
type: 'string',
|
|
79
|
+
description: 'The variable identifier name (e.g., "IP_TARGET").'
|
|
80
|
+
},
|
|
81
|
+
value: {
|
|
82
|
+
type: 'string',
|
|
83
|
+
description: 'The value to associate with the variable (e.g., "10.0.1.1").'
|
|
84
|
+
},
|
|
85
|
+
device: {
|
|
86
|
+
type: 'string',
|
|
87
|
+
description: 'Optional. The target device identifier (e.g., "COM3").'
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
required: ['name', 'value']
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
type: 'function',
|
|
96
|
+
function: {
|
|
97
|
+
name: 'execute_shell_loop',
|
|
98
|
+
description: 'Runs a command loop over a list of items using Cisco IOS Shell syntax.',
|
|
99
|
+
parameters: {
|
|
100
|
+
type: 'object',
|
|
101
|
+
properties: {
|
|
102
|
+
variable: {
|
|
103
|
+
type: 'string',
|
|
104
|
+
description: 'The loop variable name (e.g., "i").'
|
|
105
|
+
},
|
|
106
|
+
items: {
|
|
107
|
+
type: 'array',
|
|
108
|
+
items: { type: 'string' },
|
|
109
|
+
description: 'The list of items to iterate over.'
|
|
110
|
+
},
|
|
111
|
+
command: {
|
|
112
|
+
type: 'string',
|
|
113
|
+
description: 'The Cisco command to execute inside the loop body, using the variable (e.g., "ping 10.0.1.$i").'
|
|
114
|
+
},
|
|
115
|
+
device: {
|
|
116
|
+
type: 'string',
|
|
117
|
+
description: 'Optional. The target device identifier (e.g., "COM3").'
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
required: ['variable', 'items', 'command']
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
type: 'function',
|
|
126
|
+
function: {
|
|
127
|
+
name: 'define_shell_function',
|
|
128
|
+
description: 'Creates a custom user-defined function in Cisco IOS Shell.',
|
|
129
|
+
parameters: {
|
|
130
|
+
type: 'object',
|
|
131
|
+
properties: {
|
|
132
|
+
name: {
|
|
133
|
+
type: 'string',
|
|
134
|
+
description: 'The name of the function (e.g., "run_pings").'
|
|
135
|
+
},
|
|
136
|
+
body: {
|
|
137
|
+
type: 'string',
|
|
138
|
+
description: 'The command body of the function (e.g., "ping 10.0.1.1").'
|
|
139
|
+
},
|
|
140
|
+
device: {
|
|
141
|
+
type: 'string',
|
|
142
|
+
description: 'Optional. The target device identifier (e.g., "COM3").'
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
required: ['name', 'body']
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
];
|
|
150
|
+
//# sourceMappingURL=ToolDefinitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolDefinitions.js","sourceRoot":"","sources":["../../../src/infrastructure/llm/ToolDefinitions.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG;IAC3B;QACI,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE;YACN,IAAI,EAAE,qBAAqB;YAC3B,WAAW,EAAE,+FAA+F;YAC5G,UAAU,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACR,OAAO,EAAE;wBACL,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,+FAA+F;qBAC/G;oBACD,MAAM,EAAE;wBACJ,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,4GAA4G;qBAC5H;iBACJ;gBACD,QAAQ,EAAE,CAAC,SAAS,CAAC;aACxB;SACJ;KACJ;IACD;QACI,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE;YACN,IAAI,EAAE,WAAW;YACjB,WAAW,EAAE,0HAA0H;YACvI,UAAU,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACR,WAAW,EAAE;wBACT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AE,QAAQ;gBACd,UAAU,EAAE;oBACR,QAAQ,EAAE;wBACN,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,qCAAqC;qBACrD;oBACD,KAAK,EAAE;wBACH,IAAI,EAAE,OAAO;wBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;wBACzB,WAAW,EAAE,oCAAoC;qBACpD;oBACD,OAAO,EAAE;wBACL,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,iGAAiG;qBACjH;oBACD,MAAM,EAAE;wBACJ,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,wDAAwD;qBACxE;iBACJ;gBACD,QAAQ,EAAE,CAAC,UAAU,EAAE,OAAO,EAAE,SAAS,CAAC;aAC7C;SACJ;KACJ;IACD;QACI,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE;YACN,IAAI,EAAE,uBAAuB;YAC7B,WAAW,EAAE,4DAA4D;YACzE,UAAU,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACR,IAAI,EAAE;wBACF,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,+CAA+C;qBAC/D;oBACD,IAAI,EAAE;wBACF,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,2DAA2D;qBAC3E;oBACD,MAAM,EAAE;wBACJ,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,wDAAwD;qBACxE;iBACJ;gBACD,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;aAC7B;SACJ;KACJ;CACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SessionState } from '../../shared/types';
|
|
2
|
+
export declare abstract class BaseSession {
|
|
3
|
+
protected state: SessionState;
|
|
4
|
+
abstract connect(): Promise<void>;
|
|
5
|
+
abstract execute(command: string, timeoutMs?: number): Promise<string>;
|
|
6
|
+
abstract disconnect(): Promise<void>;
|
|
7
|
+
getState(): SessionState;
|
|
8
|
+
isShellEnabled(): boolean;
|
|
9
|
+
protected updateStateFromPrompt(promptStr: string): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseSession = void 0;
|
|
4
|
+
class BaseSession {
|
|
5
|
+
state = { currentMode: 'UNKNOWN', hostname: 'Router', prompt: '>' };
|
|
6
|
+
getState() {
|
|
7
|
+
return { ...this.state };
|
|
8
|
+
}
|
|
9
|
+
isShellEnabled() {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
updateStateFromPrompt(promptStr) {
|
|
13
|
+
const target = promptStr.trim();
|
|
14
|
+
if (!target)
|
|
15
|
+
return;
|
|
16
|
+
if (target.endsWith('>')) {
|
|
17
|
+
this.state.currentMode = 'USER_EXEC';
|
|
18
|
+
}
|
|
19
|
+
else if (target.endsWith('config-if)#')) {
|
|
20
|
+
this.state.currentMode = 'INTERFACE_CONFIG';
|
|
21
|
+
}
|
|
22
|
+
else if (target.endsWith('config)#')) {
|
|
23
|
+
this.state.currentMode = 'GLOBAL_CONFIG';
|
|
24
|
+
}
|
|
25
|
+
else if (target.endsWith('#')) {
|
|
26
|
+
this.state.currentMode = 'PRIVILEGED_EXEC';
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
this.state.currentMode = 'UNKNOWN';
|
|
30
|
+
}
|
|
31
|
+
const hostMatch = /^([A-Za-z0-9_\-]+)/.exec(target);
|
|
32
|
+
if (hostMatch) {
|
|
33
|
+
this.state.hostname = hostMatch[1];
|
|
34
|
+
}
|
|
35
|
+
this.state.prompt = target;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.BaseSession = BaseSession;
|
|
39
|
+
//# sourceMappingURL=BaseSession.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseSession.js","sourceRoot":"","sources":["../../../src/infrastructure/protocols/BaseSession.ts"],"names":[],"mappings":";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vCD,kCAuCC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { BaseSession } from './BaseSession';
|
|
2
|
+
export declare class MockSession extends BaseSession {
|
|
3
|
+
private deviceId;
|
|
4
|
+
private interfaces;
|
|
5
|
+
private activeInterface;
|
|
6
|
+
private vlans;
|
|
7
|
+
private shellEnabled;
|
|
8
|
+
private shellVariables;
|
|
9
|
+
private shellFunctions;
|
|
10
|
+
private readonly commandPatterns;
|
|
11
|
+
constructor(deviceId?: string);
|
|
12
|
+
isShellEnabled(): boolean;
|
|
13
|
+
connect(): Promise<void>;
|
|
14
|
+
execute(command: string, timeoutMs?: number): Promise<string>;
|
|
15
|
+
executeBase(command: string, timeoutMs?: number): Promise<string>;
|
|
16
|
+
disconnect(): Promise<void>;
|
|
17
|
+
private updateMode;
|
|
18
|
+
private matchCommand;
|
|
19
|
+
private matchesPattern;
|
|
20
|
+
private formatInvalidInput;
|
|
21
|
+
private formatIncompleteCommand;
|
|
22
|
+
private findInvalidTokenIndex;
|
|
23
|
+
private transitionToGlobalConfig;
|
|
24
|
+
private transitionToPrivilegedExec;
|
|
25
|
+
private transitionToUserExec;
|
|
26
|
+
private toggleShell;
|
|
27
|
+
private requireGlobalConfigAndToggleShell;
|
|
28
|
+
private handleInterfaceCommand;
|
|
29
|
+
private handleVlanCommand;
|
|
30
|
+
private handleExitCommand;
|
|
31
|
+
private handleEndCommand;
|
|
32
|
+
private handleIpAddressCommand;
|
|
33
|
+
private handleNoIpAddressCommand;
|
|
34
|
+
private handleShutdownCommand;
|
|
35
|
+
private handleNoShutdownCommand;
|
|
36
|
+
private handleDescriptionCommand;
|
|
37
|
+
private handleNoDescriptionCommand;
|
|
38
|
+
private handleShowIpInterfaceBrief;
|
|
39
|
+
private handleShowRunningConfig;
|
|
40
|
+
private handleShowVlanBrief;
|
|
41
|
+
private formatBadInterfaceParameter;
|
|
42
|
+
private resolveInterfaceName;
|
|
43
|
+
}
|