@mako10k/shell-server 0.1.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/LICENSE +21 -0
- package/README.md +114 -0
- package/dist/backoffice/index.d.ts +2 -0
- package/dist/backoffice/index.d.ts.map +1 -0
- package/dist/backoffice/index.js +47 -0
- package/dist/backoffice/index.js.map +1 -0
- package/dist/backoffice/server.d.ts +45 -0
- package/dist/backoffice/server.d.ts.map +1 -0
- package/dist/backoffice/server.js +610 -0
- package/dist/backoffice/server.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +525 -0
- package/dist/cli.js.map +1 -0
- package/dist/core/config-manager.d.ts +80 -0
- package/dist/core/config-manager.d.ts.map +1 -0
- package/dist/core/config-manager.js +218 -0
- package/dist/core/config-manager.js.map +1 -0
- package/dist/core/enhanced-history-manager.d.ts +84 -0
- package/dist/core/enhanced-history-manager.d.ts.map +1 -0
- package/dist/core/enhanced-history-manager.js +319 -0
- package/dist/core/enhanced-history-manager.js.map +1 -0
- package/dist/core/file-manager.d.ts +79 -0
- package/dist/core/file-manager.d.ts.map +1 -0
- package/dist/core/file-manager.js +338 -0
- package/dist/core/file-manager.js.map +1 -0
- package/dist/core/file-storage-subscriber.d.ts +38 -0
- package/dist/core/file-storage-subscriber.d.ts.map +1 -0
- package/dist/core/file-storage-subscriber.js +132 -0
- package/dist/core/file-storage-subscriber.js.map +1 -0
- package/dist/core/monitoring-manager.d.ts +32 -0
- package/dist/core/monitoring-manager.d.ts.map +1 -0
- package/dist/core/monitoring-manager.js +296 -0
- package/dist/core/monitoring-manager.js.map +1 -0
- package/dist/core/process-manager.d.ts +105 -0
- package/dist/core/process-manager.d.ts.map +1 -0
- package/dist/core/process-manager.js +1374 -0
- package/dist/core/process-manager.js.map +1 -0
- package/dist/core/realtime-stream-subscriber.d.ts +93 -0
- package/dist/core/realtime-stream-subscriber.d.ts.map +1 -0
- package/dist/core/realtime-stream-subscriber.js +200 -0
- package/dist/core/realtime-stream-subscriber.js.map +1 -0
- package/dist/core/remote-http-client.d.ts +15 -0
- package/dist/core/remote-http-client.d.ts.map +1 -0
- package/dist/core/remote-http-client.js +60 -0
- package/dist/core/remote-http-client.js.map +1 -0
- package/dist/core/remote-process-service.d.ts +50 -0
- package/dist/core/remote-process-service.d.ts.map +1 -0
- package/dist/core/remote-process-service.js +20 -0
- package/dist/core/remote-process-service.js.map +1 -0
- package/dist/core/server-manager.d.ts +71 -0
- package/dist/core/server-manager.d.ts.map +1 -0
- package/dist/core/server-manager.js +680 -0
- package/dist/core/server-manager.js.map +1 -0
- package/dist/core/stream-publisher.d.ts +75 -0
- package/dist/core/stream-publisher.d.ts.map +1 -0
- package/dist/core/stream-publisher.js +127 -0
- package/dist/core/stream-publisher.js.map +1 -0
- package/dist/core/streaming-pipeline-reader.d.ts +67 -0
- package/dist/core/streaming-pipeline-reader.d.ts.map +1 -0
- package/dist/core/streaming-pipeline-reader.js +191 -0
- package/dist/core/streaming-pipeline-reader.js.map +1 -0
- package/dist/core/terminal-manager.d.ts +96 -0
- package/dist/core/terminal-manager.d.ts.map +1 -0
- package/dist/core/terminal-manager.js +515 -0
- package/dist/core/terminal-manager.js.map +1 -0
- package/dist/daemon/server.d.ts +8 -0
- package/dist/daemon/server.d.ts.map +1 -0
- package/dist/daemon/server.js +416 -0
- package/dist/daemon/server.js.map +1 -0
- package/dist/daemon/uds-transport.d.ts +31 -0
- package/dist/daemon/uds-transport.d.ts.map +1 -0
- package/dist/daemon/uds-transport.js +149 -0
- package/dist/daemon/uds-transport.js.map +1 -0
- package/dist/executor/server.d.ts +20 -0
- package/dist/executor/server.d.ts.map +1 -0
- package/dist/executor/server.js +375 -0
- package/dist/executor/server.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +73 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime/daemon-runtime.d.ts +4 -0
- package/dist/runtime/daemon-runtime.d.ts.map +1 -0
- package/dist/runtime/daemon-runtime.js +4 -0
- package/dist/runtime/daemon-runtime.js.map +1 -0
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +3 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/tool-runtime.d.ts +52 -0
- package/dist/runtime/tool-runtime.d.ts.map +1 -0
- package/dist/runtime/tool-runtime.js +161 -0
- package/dist/runtime/tool-runtime.js.map +1 -0
- package/dist/security/chat-completion-adapter.d.ts +443 -0
- package/dist/security/chat-completion-adapter.d.ts.map +1 -0
- package/dist/security/chat-completion-adapter.js +475 -0
- package/dist/security/chat-completion-adapter.js.map +1 -0
- package/dist/security/enhanced-evaluator.d.ts +139 -0
- package/dist/security/enhanced-evaluator.d.ts.map +1 -0
- package/dist/security/enhanced-evaluator.js +1208 -0
- package/dist/security/enhanced-evaluator.js.map +1 -0
- package/dist/security/evaluator-types.d.ts +614 -0
- package/dist/security/evaluator-types.d.ts.map +1 -0
- package/dist/security/evaluator-types.js +124 -0
- package/dist/security/evaluator-types.js.map +1 -0
- package/dist/security/manager.d.ts +76 -0
- package/dist/security/manager.d.ts.map +1 -0
- package/dist/security/manager.js +445 -0
- package/dist/security/manager.js.map +1 -0
- package/dist/security/security-llm-prompt-generator.d.ts +105 -0
- package/dist/security/security-llm-prompt-generator.d.ts.map +1 -0
- package/dist/security/security-llm-prompt-generator.js +323 -0
- package/dist/security/security-llm-prompt-generator.js.map +1 -0
- package/dist/security/security-tools.d.ts +174 -0
- package/dist/security/security-tools.d.ts.map +1 -0
- package/dist/security/security-tools.js +159 -0
- package/dist/security/security-tools.js.map +1 -0
- package/dist/security/validator-criteria-manager.d.ts +47 -0
- package/dist/security/validator-criteria-manager.d.ts.map +1 -0
- package/dist/security/validator-criteria-manager.js +169 -0
- package/dist/security/validator-criteria-manager.js.map +1 -0
- package/dist/tools/shell-tools.d.ts +474 -0
- package/dist/tools/shell-tools.d.ts.map +1 -0
- package/dist/tools/shell-tools.js +861 -0
- package/dist/tools/shell-tools.js.map +1 -0
- package/dist/types/enhanced-security.d.ts +529 -0
- package/dist/types/enhanced-security.d.ts.map +1 -0
- package/dist/types/enhanced-security.js +286 -0
- package/dist/types/enhanced-security.js.map +1 -0
- package/dist/types/index.d.ts +282 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +158 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/quick-schemas.d.ts +177 -0
- package/dist/types/quick-schemas.d.ts.map +1 -0
- package/dist/types/quick-schemas.js +113 -0
- package/dist/types/quick-schemas.js.map +1 -0
- package/dist/types/response-schemas.d.ts +41 -0
- package/dist/types/response-schemas.d.ts.map +1 -0
- package/dist/types/response-schemas.js +41 -0
- package/dist/types/response-schemas.js.map +1 -0
- package/dist/types/schemas.d.ts +578 -0
- package/dist/types/schemas.d.ts.map +1 -0
- package/dist/types/schemas.js +498 -0
- package/dist/types/schemas.js.map +1 -0
- package/dist/utils/criteria-manager.d.ts +47 -0
- package/dist/utils/criteria-manager.d.ts.map +1 -0
- package/dist/utils/criteria-manager.js +228 -0
- package/dist/utils/criteria-manager.js.map +1 -0
- package/dist/utils/errors.d.ts +27 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +67 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/helpers.d.ts +85 -0
- package/dist/utils/helpers.d.ts.map +1 -0
- package/dist/utils/helpers.js +400 -0
- package/dist/utils/helpers.js.map +1 -0
- package/dist/utils/json-repair.d.ts +23 -0
- package/dist/utils/json-repair.d.ts.map +1 -0
- package/dist/utils/json-repair.js +208 -0
- package/dist/utils/json-repair.js.map +1 -0
- package/dist/utils/process-utils.d.ts +31 -0
- package/dist/utils/process-utils.d.ts.map +1 -0
- package/dist/utils/process-utils.js +217 -0
- package/dist/utils/process-utils.js.map +1 -0
- package/dist/utils/server-helpers.d.ts +4 -0
- package/dist/utils/server-helpers.d.ts.map +1 -0
- package/dist/utils/server-helpers.js +10 -0
- package/dist/utils/server-helpers.js.map +1 -0
- package/dist/utils/sse.d.ts +2 -0
- package/dist/utils/sse.d.ts.map +1 -0
- package/dist/utils/sse.js +6 -0
- package/dist/utils/sse.js.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manager.js","sourceRoot":"","sources":["../../src/security/manager.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,gCAAgC,EAChC,0BAA0B,GAG3B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AACnF,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,kCAAkC,EAA8B,MAAM,8BAA8B,CAAC;AAQ9G,MAAM,OAAO,eAAe;IAClB,YAAY,GAAgC,IAAI,CAAC;IACjD,cAAc,CAAyB;IACvC,gBAAgB,CAAoB;IACpC,iBAAiB,CAA2B;IAC5C,cAAc,CAAyB;IAE/C,YAAY,MAA+B;QACzC,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,gCAAgC,EAAE,CAAC;QACvF,IAAI,CAAC,gBAAgB,GAAG,CAAC,GAAG,0BAA0B,CAAC,CAAC;QAExD,kEAAkE;QAClE,IAAI,CAAC,yBAAyB,EAAE,CAAC;QAEjC,oCAAoC;QACpC,IAAI,CAAC,sBAAsB,EAAE,CAAC;IAChC,CAAC;IAEO,sBAAsB;QAC5B,kDAAkD;QAClD,MAAM,WAAW,GAAI,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAkB,IAAI,YAAY,CAAC;QAC7F,MAAM,oBAAoB,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,C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C,KAAK,CAAC,yCAAyC,OAAO,EAAE,CAAC,CAAC;QAClE,OAAO,CAAC,KAAK,CAAC,iDAAiD,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QACjF,OAAO,CAAC,KAAK,CAAC,kDAAkD,OAAO,CAAC,GAAG,CAAC,CAAC,CAAsB,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEjI,OAAO,MAAM,IAAI,CAAC,iBAAiB,CAAC,qBAAqB,CAAC,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAC;IAC3H,CAAC;CACF"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security LLM Prompt Generator
|
|
3
|
+
* Use mcp-llm-generator FunctionCall emulation pattern
|
|
4
|
+
* Generate Structured Output format prompts to request type-safe output from LLM
|
|
5
|
+
*/
|
|
6
|
+
import { SafetyLevel } from '../types/enhanced-security.js';
|
|
7
|
+
export interface ElicitationHistoryEntry {
|
|
8
|
+
command: string;
|
|
9
|
+
timestamp: string;
|
|
10
|
+
question: string;
|
|
11
|
+
userResponse: string;
|
|
12
|
+
evaluationResult?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface CommandHistoryEntry {
|
|
15
|
+
command: string;
|
|
16
|
+
timestamp: string;
|
|
17
|
+
exitCode?: number;
|
|
18
|
+
workingDirectory?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface SecurityPromptContext {
|
|
21
|
+
command: string;
|
|
22
|
+
workingDirectory: string;
|
|
23
|
+
sessionId?: string;
|
|
24
|
+
comment?: string;
|
|
25
|
+
detectedPatterns?: string[];
|
|
26
|
+
userContextFromHistory?: ElicitationHistoryEntry[];
|
|
27
|
+
commandHistoryWithTimestamp?: CommandHistoryEntry[];
|
|
28
|
+
}
|
|
29
|
+
export interface UserIntentContext {
|
|
30
|
+
originalCommand: string;
|
|
31
|
+
initialEvaluation: unknown;
|
|
32
|
+
userResponse: string;
|
|
33
|
+
additionalContext?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface AdditionalContextContext {
|
|
36
|
+
originalCommand: string;
|
|
37
|
+
initialEvaluation: unknown;
|
|
38
|
+
additionalHistory: string[];
|
|
39
|
+
environmentInfo?: string;
|
|
40
|
+
}
|
|
41
|
+
export declare class SecurityLLMPromptGenerator {
|
|
42
|
+
/**
|
|
43
|
+
* コマンド履歴とELICITATION履歴を時系列でマージ
|
|
44
|
+
*/
|
|
45
|
+
private mergeHistoryByTimestamp;
|
|
46
|
+
/**
|
|
47
|
+
* Common helper to extract initial evaluation results and reasoning
|
|
48
|
+
*/
|
|
49
|
+
private extractInitialEvaluation;
|
|
50
|
+
/**
|
|
51
|
+
* Generate system prompt for initial security evaluation
|
|
52
|
+
* Function Call format is handled by ChatCompletionAdapter automatically
|
|
53
|
+
*/
|
|
54
|
+
generateSecurityEvaluationPrompt(context: SecurityPromptContext): Promise<{
|
|
55
|
+
systemPrompt: string;
|
|
56
|
+
userMessage: string;
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* Generate history section (chronological merge or individual display)
|
|
60
|
+
*/
|
|
61
|
+
private generateHistorySection;
|
|
62
|
+
/**
|
|
63
|
+
* Generate re-evaluation prompt after user intent confirmation
|
|
64
|
+
* Function Call format is handled by ChatCompletionAdapter automatically
|
|
65
|
+
*/
|
|
66
|
+
generateUserIntentReevaluationPrompt(context: UserIntentContext): {
|
|
67
|
+
systemPrompt: string;
|
|
68
|
+
userMessage: string;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Generate re-evaluation prompt after additional context collection
|
|
72
|
+
* Function Call format is handled by ChatCompletionAdapter automatically
|
|
73
|
+
*/
|
|
74
|
+
generateAdditionalContextReevaluationPrompt(context: AdditionalContextContext): {
|
|
75
|
+
systemPrompt: string;
|
|
76
|
+
userMessage: string;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Generate system prompt for Function Call emulation
|
|
80
|
+
* Refer to mcp-llm-generator patterns
|
|
81
|
+
*/
|
|
82
|
+
generateFunctionCallEmulationPrompt(functionName: 'security_evaluate' | 'user_intent_reevaluate' | 'context_reevaluate', args: Record<string, unknown>): {
|
|
83
|
+
systemPrompt: string;
|
|
84
|
+
userMessage: string;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Generate debug prompt (for development use only)
|
|
88
|
+
*/
|
|
89
|
+
generateDebugPrompt(context: SecurityPromptContext): Promise<{
|
|
90
|
+
systemPrompt: string;
|
|
91
|
+
userMessage: string;
|
|
92
|
+
expectedSchema: Record<string, unknown>;
|
|
93
|
+
}>;
|
|
94
|
+
/**
|
|
95
|
+
* Safety Levelに基づくプロンプト調整
|
|
96
|
+
*/
|
|
97
|
+
adjustPromptForSafetyLevel(basePrompt: {
|
|
98
|
+
systemPrompt: string;
|
|
99
|
+
userMessage: string;
|
|
100
|
+
}, targetSafetyLevel: SafetyLevel): {
|
|
101
|
+
systemPrompt: string;
|
|
102
|
+
userMessage: string;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=security-llm-prompt-generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security-llm-prompt-generator.d.ts","sourceRoot":"","sources":["../../src/security/security-llm-prompt-generator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAG5D,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB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,WAAW,EAAE,MAAM,CAAC;KACrB;IAgCD;;;OAGG;IACH,mCAAmC,CACjC,YAAY,EAAE,mBAAmB,GAAG,wBAAwB,GAAG,oBAAoB,EACnF,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B;QACD,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE,MAAM,CAAC;KACrB;IAqBD;;OAEG;IACG,mBAAmB,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC;QACjE,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE,MAAM,CAAC;QACpB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACzC,CAAC;IAgBF;;OAEG;IACH,0BAA0B,CACxB,UAAU,EAAE;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,EACzD,iBAAiB,EAAE,WAAW,GAC7B;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE;CAkBjD"}
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security LLM Prompt Generator
|
|
3
|
+
* Use mcp-llm-generator FunctionCall emulation pattern
|
|
4
|
+
* Generate Structured Output format prompts to request type-safe output from LLM
|
|
5
|
+
*/
|
|
6
|
+
import { loadCriteria } from '../utils/criteria-manager.js';
|
|
7
|
+
export class SecurityLLMPromptGenerator {
|
|
8
|
+
/**
|
|
9
|
+
* コマンド履歴とELICITATION履歴を時系列でマージ
|
|
10
|
+
*/
|
|
11
|
+
mergeHistoryByTimestamp(commandHistory, elicitationHistory) {
|
|
12
|
+
const merged = [];
|
|
13
|
+
// Add command history
|
|
14
|
+
commandHistory.forEach(entry => {
|
|
15
|
+
merged.push({
|
|
16
|
+
type: 'command',
|
|
17
|
+
timestamp: entry.timestamp,
|
|
18
|
+
content: `Command: ${entry.command}${entry.exitCode !== undefined ? ` (exit: ${entry.exitCode})` : ''}${entry.workingDirectory ? ` [${entry.workingDirectory}]` : ''}`
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
// Add ELICITATION history
|
|
22
|
+
elicitationHistory.forEach(entry => {
|
|
23
|
+
merged.push({
|
|
24
|
+
type: 'elicitation',
|
|
25
|
+
timestamp: entry.timestamp,
|
|
26
|
+
content: `Security Question: "${entry.question}" for command "${entry.command}"
|
|
27
|
+
User Response: "${entry.userResponse}"${entry.evaluationResult ? `
|
|
28
|
+
Final Decision: ${entry.evaluationResult}` : ''}`
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
// 時系列でソート(新しい順)
|
|
32
|
+
return merged.sort((a, b) => new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime());
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Common helper to extract initial evaluation results and reasoning
|
|
36
|
+
*/
|
|
37
|
+
extractInitialEvaluation(initialEvaluation) {
|
|
38
|
+
let initialEvalResult = '';
|
|
39
|
+
let initialReasoning = '';
|
|
40
|
+
if (typeof initialEvaluation === 'object' && initialEvaluation !== null) {
|
|
41
|
+
const evalObj = initialEvaluation;
|
|
42
|
+
initialEvalResult = evalObj.evaluation_result ?? '';
|
|
43
|
+
initialReasoning = evalObj.reasoning ?? '';
|
|
44
|
+
}
|
|
45
|
+
return { result: initialEvalResult, reasoning: initialReasoning };
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Generate system prompt for initial security evaluation
|
|
49
|
+
* Function Call format is handled by ChatCompletionAdapter automatically
|
|
50
|
+
*/
|
|
51
|
+
async generateSecurityEvaluationPrompt(context) {
|
|
52
|
+
// Load dynamic criteria
|
|
53
|
+
const adjustedCriteria = await loadCriteria();
|
|
54
|
+
const systemPrompt = `# Security Command Evaluator
|
|
55
|
+
|
|
56
|
+
You are an expert security evaluator specialized in analyzing shell commands for safety and risk assessment.
|
|
57
|
+
|
|
58
|
+
## Your Role
|
|
59
|
+
Analyze the provided shell command to prevent reckless, careless, or commands that deviate from user intent.
|
|
60
|
+
|
|
61
|
+
## Adjusted Security Criteria
|
|
62
|
+
${adjustedCriteria}
|
|
63
|
+
|
|
64
|
+
**Dynamic Adjustment**: Security criteria can be refined using the adjust_criteria tool to better align with user workflow patterns and intent.
|
|
65
|
+
|
|
66
|
+
## Security Focus
|
|
67
|
+
**Primary Goal**: Prevent commands that could cause harm through:
|
|
68
|
+
- **Reckless behavior**: Commands with destructive potential without clear purpose
|
|
69
|
+
- **Careless execution**: Commands that could cause unintended side effects
|
|
70
|
+
- **Intent deviation**: Commands that don't align with established user workflow patterns
|
|
71
|
+
|
|
72
|
+
## Evaluation Guidelines
|
|
73
|
+
**Primary Security Goal**: Prevent reckless, careless, or commands that deviate from user intent
|
|
74
|
+
- **Reckless**: Commands with destructive potential without clear purpose or context
|
|
75
|
+
- **Careless**: Commands that could cause unintended side effects or data loss
|
|
76
|
+
- **Intent Deviation**: Commands that don't align with established user workflow patterns or stated objectives
|
|
77
|
+
|
|
78
|
+
**Assessment Factors**:
|
|
79
|
+
- Consider the execution context: working directory, session history, user intent
|
|
80
|
+
- Evaluate proportional risk vs. legitimate use case
|
|
81
|
+
- Assess if command aligns with user's demonstrated workflow patterns
|
|
82
|
+
- Provide clear reasoning for your security assessment
|
|
83
|
+
- Suggest safer alternatives when appropriate
|
|
84
|
+
|
|
85
|
+
## Important: Command Reference in Reasoning
|
|
86
|
+
**CRITICAL**: When referencing the command in your reasoning field, ALWAYS use the variable $COMMAND:
|
|
87
|
+
- ✅ CORRECT: "The command $COMMAND is safe because..."
|
|
88
|
+
- ✅ CORRECT: "$COMMAND performs a file search operation..."
|
|
89
|
+
- ✅ CORRECT: "This $COMMAND does not require elevated privileges..."
|
|
90
|
+
- ❌ WRONG: "The command 'find /tmp -name \\"*.tmp\\"' is..." (causes JSON parsing errors)
|
|
91
|
+
|
|
92
|
+
**MANDATORY**: Use ONLY $COMMAND - no other variable names, no literal command text, no quotes around commands.
|
|
93
|
+
|
|
94
|
+
## JSON Response Formatting for Security Evaluation
|
|
95
|
+
**SIMPLIFIED**: Always use $COMMAND instead of literal commands to avoid ALL JSON escaping issues.
|
|
96
|
+
No complex escaping needed when using the $COMMAND variable.
|
|
97
|
+
|
|
98
|
+
## Safety Evaluation Tools
|
|
99
|
+
|
|
100
|
+
**Choose the appropriate tool based on your evaluation:**
|
|
101
|
+
|
|
102
|
+
### Direct Execution Decisions:
|
|
103
|
+
- **allow()**: Command is safe and aligns with reasonable use patterns
|
|
104
|
+
- **deny()**: Command is reckless, destructive, or clearly malicious
|
|
105
|
+
|
|
106
|
+
### Information Required Decisions:
|
|
107
|
+
- **add_more_history()**: Need context from system history to understand user intent
|
|
108
|
+
- **user_confirm()**: Command has legitimate use but requires explicit user permission due to potential impact
|
|
109
|
+
- **ai_assistant_confirm()**: Need additional information to properly assess intent and safety
|
|
110
|
+
|
|
111
|
+
### Tool Usage Guidelines:
|
|
112
|
+
- **allow()**: Use for commands with clear purpose and reasonable risk profile
|
|
113
|
+
- **add_more_history()**: Use when command pattern requires workflow context for proper evaluation
|
|
114
|
+
- **user_confirm()**: Use when command could cause consequences but serves legitimate purposes
|
|
115
|
+
- **ai_assistant_confirm()**: Use when genuinely missing essential information for security assessment
|
|
116
|
+
- **deny()**: Use for commands with clear destructive intent or unjustifiable risk
|
|
117
|
+
|
|
118
|
+
**Example Tool Selection:**
|
|
119
|
+
- Configuration file content → **ai_assistant_confirm()** (request file contents when security-relevant)
|
|
120
|
+
- Previous command context → **add_more_history()** (understand user workflow patterns)
|
|
121
|
+
- System modification commands → **user_confirm()** (legitimate but impactful operations)
|
|
122
|
+
- Mass file deletion → **deny()** (if clearly reckless) or **user_confirm()** (if context-appropriate)
|
|
123
|
+
- File read operations → **allow()** (if reasonable and safe)
|
|
124
|
+
|
|
125
|
+
## Tool-Specific Parameters:
|
|
126
|
+
**add_more_history()**: Use when you need additional SYSTEM data:
|
|
127
|
+
- command_history_depth: How many more commands back to examine
|
|
128
|
+
- execution_results_count: How many recent commands need their execution details
|
|
129
|
+
- user_intent_search_keywords: Keywords to search in previous user responses
|
|
130
|
+
|
|
131
|
+
**ai_assistant_confirm()**: Use when you need NEW information from AI Assistant:
|
|
132
|
+
- assistant_request_message: Specific question/request for the assistant
|
|
133
|
+
- next_action: REQUIRED - Provide detailed guidance for the assistant:
|
|
134
|
+
- instruction: Clear step-by-step instruction for what the assistant should do
|
|
135
|
+
- method: How the assistant should gather the required information
|
|
136
|
+
- expected_outcome: What result is expected from the assistant action
|
|
137
|
+
- executable_commands: Array of specific commands the assistant should run (e.g., ["cat tsconfig.json", "npm list typescript"])
|
|
138
|
+
|
|
139
|
+
Example ai_assistant_confirm() usage:
|
|
140
|
+
When you need TypeScript config before allowing build commands, provide:
|
|
141
|
+
- reasoning: "Need to verify TypeScript configuration before allowing npx tsc"
|
|
142
|
+
- assistant_request_message: "Please provide TypeScript configuration details"
|
|
143
|
+
- next_action with executable_commands: ["cat tsconfig.json", "cat package.json | grep -A3 scripts"]
|
|
144
|
+
|
|
145
|
+
**user_confirm()**: Use when you need explicit human confirmation:
|
|
146
|
+
- confirmation_question: Specific question to ask the user (include alternatives if applicable)
|
|
147
|
+
|
|
148
|
+
**Tool Selection Rules**:
|
|
149
|
+
- ❌ Don't use add_more_history() for file contents (use ai_assistant_confirm())
|
|
150
|
+
- ❌ Don't use add_more_history() for script definitions (use ai_assistant_confirm())
|
|
151
|
+
- ❌ Don't use ai_assistant_confirm() for available system history (use add_more_history())
|
|
152
|
+
|
|
153
|
+
## Tool Call Requirements
|
|
154
|
+
- **CRITICAL**: Use individual tools (allow, deny, user_confirm, add_more_history, ai_assistant_confirm)
|
|
155
|
+
- Each tool has specific parameters - use only what's required for that tool
|
|
156
|
+
- If user confirmation is needed, use ELICITATION for the first attempt
|
|
157
|
+
- If ELICITATION fails or subsequent evaluation is needed, default to NEED_ASSISTANT_CONFIRM
|
|
158
|
+
- **DO NOT** trigger multiple ELICITATION attempts in a single evaluation sequence
|
|
159
|
+
- ELICITATION results are reference information - do not re-evaluate them repeatedly`;
|
|
160
|
+
const userMessage = `# Security Evaluation Request
|
|
161
|
+
|
|
162
|
+
## Command Analysis Required
|
|
163
|
+
**Command**: \`${context.command}\`
|
|
164
|
+
**Working Directory**: ${context.workingDirectory}
|
|
165
|
+
${context.comment ? `**AI Assistant Context**: ${context.comment}` : ''}
|
|
166
|
+
|
|
167
|
+
${this.generateHistorySection(context)}
|
|
168
|
+
|
|
169
|
+
${context.detectedPatterns ? `**Detected Patterns**: ${context.detectedPatterns.join(', ')}` : ''}
|
|
170
|
+
|
|
171
|
+
**INSTRUCTION**: Use the evaluate_command_security function to provide your security evaluation.`;
|
|
172
|
+
return { systemPrompt, userMessage };
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Generate history section (chronological merge or individual display)
|
|
176
|
+
*/
|
|
177
|
+
generateHistorySection(context) {
|
|
178
|
+
const commandHistory = context.commandHistoryWithTimestamp;
|
|
179
|
+
const elicitationHistory = context.userContextFromHistory;
|
|
180
|
+
const hasCommandHistory = commandHistory && commandHistory.length > 0;
|
|
181
|
+
const hasElicitationHistory = elicitationHistory && elicitationHistory.length > 0;
|
|
182
|
+
// 両方の履歴がある場合は時系列マージ
|
|
183
|
+
if (hasCommandHistory && hasElicitationHistory) {
|
|
184
|
+
const mergedHistory = this.mergeHistoryByTimestamp(commandHistory, elicitationHistory);
|
|
185
|
+
return `Recent Activity Timeline (most recent first):
|
|
186
|
+
${mergedHistory.slice(0, 10).map((entry, i) => `${i + 1}. [${entry.timestamp}] ${entry.type.toUpperCase()}: ${entry.content}`).join('\n')}`;
|
|
187
|
+
}
|
|
188
|
+
// Display individual history
|
|
189
|
+
const sections = [];
|
|
190
|
+
if (hasCommandHistory) {
|
|
191
|
+
sections.push(`Recent Command History:
|
|
192
|
+
${commandHistory.slice(-5).map((entry, i) => `${i + 1}. [${entry.timestamp}] ${entry.command}${entry.exitCode !== undefined ? ` (exit: ${entry.exitCode})` : ''}`).join('\n')}`);
|
|
193
|
+
}
|
|
194
|
+
if (hasElicitationHistory) {
|
|
195
|
+
sections.push(`Previous User Intent Confirmation History:
|
|
196
|
+
${elicitationHistory.map(entry => `- Command: ${entry.command} (${entry.timestamp})
|
|
197
|
+
Question: ${entry.question}
|
|
198
|
+
User Response: ${entry.userResponse}${entry.evaluationResult ? `\n Final Decision: ${entry.evaluationResult}` : ''}`).join('\n')}`);
|
|
199
|
+
}
|
|
200
|
+
return sections.length > 0 ? sections.join('\n\n') : 'No activity history available';
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Generate re-evaluation prompt after user intent confirmation
|
|
204
|
+
* Function Call format is handled by ChatCompletionAdapter automatically
|
|
205
|
+
*/
|
|
206
|
+
generateUserIntentReevaluationPrompt(context) {
|
|
207
|
+
const systemPrompt = `# Security Re-evaluator
|
|
208
|
+
|
|
209
|
+
You are a security re-evaluator. Based on user clarification of their intent, provide a final security decision.
|
|
210
|
+
|
|
211
|
+
## Your Role
|
|
212
|
+
Re-assess the command security based on the new user context and intent clarification provided.
|
|
213
|
+
|
|
214
|
+
## Guidelines
|
|
215
|
+
- Consider both the original evaluation and the new user context
|
|
216
|
+
- Make a final security decision based on the clarified intent
|
|
217
|
+
- Provide clear reasoning for the updated assessment`;
|
|
218
|
+
const { result: initialEvalResult, reasoning: initialReasoning } = this.extractInitialEvaluation(context.initialEvaluation);
|
|
219
|
+
const userMessage = `Re-evaluate the security of this command based on AI assistant's user intent clarification:
|
|
220
|
+
|
|
221
|
+
Original Command: \`${context.originalCommand}\`
|
|
222
|
+
|
|
223
|
+
Initial Evaluation Result: ${initialEvalResult}
|
|
224
|
+
Initial Reasoning: ${initialReasoning}
|
|
225
|
+
|
|
226
|
+
AI Assistant's User Intent Clarification: "${context.userResponse}"
|
|
227
|
+
|
|
228
|
+
${context.additionalContext ? `Additional Context: ${context.additionalContext}` : ''}
|
|
229
|
+
|
|
230
|
+
Provide final security evaluation as JSON only.`;
|
|
231
|
+
return { systemPrompt, userMessage };
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Generate re-evaluation prompt after additional context collection
|
|
235
|
+
* Function Call format is handled by ChatCompletionAdapter automatically
|
|
236
|
+
*/
|
|
237
|
+
generateAdditionalContextReevaluationPrompt(context) {
|
|
238
|
+
const systemPrompt = `# Security Re-evaluator with Additional Context
|
|
239
|
+
|
|
240
|
+
You are a security re-evaluator with additional context. Provide a comprehensive final security decision.
|
|
241
|
+
|
|
242
|
+
## Your Role
|
|
243
|
+
Re-assess the command security with the benefit of additional command history and environmental context.
|
|
244
|
+
|
|
245
|
+
## Guidelines
|
|
246
|
+
- Analyze patterns in the additional command history
|
|
247
|
+
- Consider how the new context affects the risk assessment
|
|
248
|
+
- Provide a comprehensive final evaluation with detailed reasoning`;
|
|
249
|
+
const { result: initialEvalResult, reasoning: initialReasoning } = this.extractInitialEvaluation(context.initialEvaluation);
|
|
250
|
+
const userMessage = `Re-evaluate security with additional context:
|
|
251
|
+
|
|
252
|
+
Original Command: \`${context.originalCommand}\`
|
|
253
|
+
|
|
254
|
+
Initial Evaluation: ${initialEvalResult}
|
|
255
|
+
Initial Reasoning: ${initialReasoning}
|
|
256
|
+
|
|
257
|
+
Additional Command History:
|
|
258
|
+
${context.additionalHistory.map((cmd, i) => `${i + 1}. ${cmd}`).join('\n')}
|
|
259
|
+
|
|
260
|
+
${context.environmentInfo ? `Environment Information: ${context.environmentInfo}` : ''}
|
|
261
|
+
|
|
262
|
+
Provide comprehensive final security evaluation.`;
|
|
263
|
+
return { systemPrompt, userMessage };
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Generate system prompt for Function Call emulation
|
|
267
|
+
* Refer to mcp-llm-generator patterns
|
|
268
|
+
*/
|
|
269
|
+
generateFunctionCallEmulationPrompt(functionName, args) {
|
|
270
|
+
const systemPrompt = `You are a function execution emulator. You must respond as if you are executing the specified function and return the result in the exact JSON format.
|
|
271
|
+
|
|
272
|
+
CRITICAL: Your response must be ONLY valid JSON with no additional text, explanations, or formatting.
|
|
273
|
+
|
|
274
|
+
Available Functions:
|
|
275
|
+
1. security_evaluate: Evaluates shell command security
|
|
276
|
+
2. user_intent_reevaluate: Re-evaluates based on AI assistant's user intent clarification
|
|
277
|
+
3. context_reevaluate: Re-evaluates with additional context
|
|
278
|
+
|
|
279
|
+
Execute the requested function and return results as JSON only.`;
|
|
280
|
+
const userMessage = `Execute function: ${functionName}
|
|
281
|
+
|
|
282
|
+
Arguments: ${JSON.stringify(args, null, 2)}
|
|
283
|
+
|
|
284
|
+
Return function execution result as JSON only.`;
|
|
285
|
+
return { systemPrompt, userMessage };
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Generate debug prompt (for development use only)
|
|
289
|
+
*/
|
|
290
|
+
async generateDebugPrompt(context) {
|
|
291
|
+
const { systemPrompt, userMessage } = await this.generateSecurityEvaluationPrompt(context);
|
|
292
|
+
return {
|
|
293
|
+
systemPrompt: systemPrompt + '\n\nDEBUG MODE: Include parsing metadata in response.',
|
|
294
|
+
userMessage: userMessage + '\n\nDEBUG: This is a test evaluation.',
|
|
295
|
+
expectedSchema: {
|
|
296
|
+
evaluation_result: 'string',
|
|
297
|
+
confidence: 'number',
|
|
298
|
+
reasoning: 'string',
|
|
299
|
+
risk_factors: 'array',
|
|
300
|
+
metadata: 'object',
|
|
301
|
+
},
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Safety Levelに基づくプロンプト調整
|
|
306
|
+
*/
|
|
307
|
+
adjustPromptForSafetyLevel(basePrompt, targetSafetyLevel) {
|
|
308
|
+
const safetyInstructions = {
|
|
309
|
+
1: 'Be very permissive. Only block clearly dangerous commands.',
|
|
310
|
+
2: 'Be somewhat permissive. Allow most common operations.',
|
|
311
|
+
3: 'Be balanced. Careful evaluation of moderate risks.',
|
|
312
|
+
4: 'Be conservative. Require confirmation for risky operations.',
|
|
313
|
+
5: 'Be very strict. Block any potentially dangerous commands.',
|
|
314
|
+
};
|
|
315
|
+
const enhancedSystemPrompt = basePrompt.systemPrompt +
|
|
316
|
+
`\n\nSAFETY LEVEL ${targetSafetyLevel}: ${safetyInstructions[targetSafetyLevel]}`;
|
|
317
|
+
return {
|
|
318
|
+
systemPrompt: enhancedSystemPrompt,
|
|
319
|
+
userMessage: basePrompt.userMessage,
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
//# sourceMappingURL=security-llm-prompt-generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security-llm-prompt-generator.js","sourceRoot":"","sources":["../../src/security/security-llm-prompt-generator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAyC5D,MAAM,OAAO,0BAA0B;IACrC;;OAEG;IACK,uBAAuB,CAC7B,cAAqC,EACrC,kBAA6C;QAM7C,MAAM,MAAM,GAIP,EAAE,CAAC;QAER,sBAAsB;QACtB,cAAc,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YAC7B,MAAM,CAAC,IAAI,CAAC;gBACV,IAAI,EAAE,SAAS;gBACf,SAAS,EAAE,KAAK,CAAC,SAAS;gBAC1B,OAAO,EAAE,YAAY,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,gBAAgB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;aACvK,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,0BAA0B;QAC1B,kBAAkB,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YACjC,MAAM,CAAC,IAAI,CAAC;gBACV,IAAI,EAAE,aAAa;gBACnB,SAAS,EAAE,KAAK,CAAC,SAAS;gBAC1B,OAAO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,CAAC,mBAAmB,CAAC,OAA8B;QAKtD,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,GAAG,MAAM,IAAI,CAAC,gCAAgC,CAAC,OAAO,CAAC,CAAC;QAE3F,OAAO;YACL,YAAY,EAAE,YAAY,GAAG,uDAAuD;YACpF,WAAW,EAAE,WAAW,GAAG,uCAAuC;YAClE,cAAc,EAAE;gBACd,iBAAiB,EAAE,QAAQ;gBAC3B,UAAU,EAAE,QAAQ;gBACpB,SAAS,EAAE,QAAQ;gBACnB,YAAY,EAAE,OAAO;gBACrB,QAAQ,EAAE,QAAQ;aACnB;SACF,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,0BAA0B,CACxB,UAAyD,EACzD,iBAA8B;QAE9B,MAAM,kBAAkB,GAAgC;YACtD,CAAC,EAAE,4DAA4D;YAC/D,CAAC,EAAE,uDAAuD;YAC1D,CAAC,EAAE,oDAAoD;YACvD,CAAC,EAAE,6DAA6D;YAChE,CAAC,EAAE,2DAA2D;SAC/D,CAAC;QAEF,MAAM,oBAAoB,GACxB,UAAU,CAAC,YAAY;YACvB,oBAAoB,iBAAiB,KAAK,kBAAkB,CAAC,iBAAiB,CAAC,EAAE,CAAC;QAEpF,OAAO;YACL,YAAY,EAAE,oBAAoB;YAClC,WAAW,EAAE,UAAU,CAAC,WAAW;SACpC,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security Evaluation Tools for Function Calling
|
|
3
|
+
* New individual tool approach - each evaluation result has its own tool
|
|
4
|
+
*/
|
|
5
|
+
export declare const allowTool: {
|
|
6
|
+
type: "function";
|
|
7
|
+
function: {
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
parameters: {
|
|
11
|
+
type: "object";
|
|
12
|
+
properties: {
|
|
13
|
+
reasoning: {
|
|
14
|
+
type: "string";
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
required: string[];
|
|
19
|
+
additionalProperties: boolean;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export declare const denyTool: {
|
|
24
|
+
type: "function";
|
|
25
|
+
function: {
|
|
26
|
+
name: string;
|
|
27
|
+
description: string;
|
|
28
|
+
parameters: {
|
|
29
|
+
type: "object";
|
|
30
|
+
properties: {
|
|
31
|
+
reasoning: {
|
|
32
|
+
type: "string";
|
|
33
|
+
description: string;
|
|
34
|
+
};
|
|
35
|
+
suggested_alternatives: {
|
|
36
|
+
type: "array";
|
|
37
|
+
items: {
|
|
38
|
+
type: "string";
|
|
39
|
+
};
|
|
40
|
+
description: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
required: string[];
|
|
44
|
+
additionalProperties: boolean;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export declare const userConfirmTool: {
|
|
49
|
+
type: "function";
|
|
50
|
+
function: {
|
|
51
|
+
name: string;
|
|
52
|
+
description: string;
|
|
53
|
+
parameters: {
|
|
54
|
+
type: "object";
|
|
55
|
+
properties: {
|
|
56
|
+
reasoning: {
|
|
57
|
+
type: "string";
|
|
58
|
+
description: string;
|
|
59
|
+
};
|
|
60
|
+
confirmation_question: {
|
|
61
|
+
type: "string";
|
|
62
|
+
description: string;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
required: string[];
|
|
66
|
+
additionalProperties: boolean;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
export declare const addMoreHistoryTool: {
|
|
71
|
+
type: "function";
|
|
72
|
+
function: {
|
|
73
|
+
name: string;
|
|
74
|
+
description: string;
|
|
75
|
+
parameters: {
|
|
76
|
+
type: "object";
|
|
77
|
+
properties: {
|
|
78
|
+
reasoning: {
|
|
79
|
+
type: "string";
|
|
80
|
+
description: string;
|
|
81
|
+
};
|
|
82
|
+
command_history_depth: {
|
|
83
|
+
type: "number";
|
|
84
|
+
minimum: number;
|
|
85
|
+
maximum: number;
|
|
86
|
+
description: string;
|
|
87
|
+
};
|
|
88
|
+
execution_results_count: {
|
|
89
|
+
type: "number";
|
|
90
|
+
minimum: number;
|
|
91
|
+
maximum: number;
|
|
92
|
+
description: string;
|
|
93
|
+
};
|
|
94
|
+
user_intent_search_keywords: {
|
|
95
|
+
type: "array";
|
|
96
|
+
items: {
|
|
97
|
+
type: "string";
|
|
98
|
+
};
|
|
99
|
+
description: string;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
required: string[];
|
|
103
|
+
additionalProperties: boolean;
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
export declare const aiAssistantConfirmTool: {
|
|
108
|
+
type: "function";
|
|
109
|
+
function: {
|
|
110
|
+
name: string;
|
|
111
|
+
description: string;
|
|
112
|
+
parameters: {
|
|
113
|
+
type: "object";
|
|
114
|
+
properties: {
|
|
115
|
+
reasoning: {
|
|
116
|
+
type: "string";
|
|
117
|
+
description: string;
|
|
118
|
+
};
|
|
119
|
+
assistant_request_message: {
|
|
120
|
+
type: "string";
|
|
121
|
+
description: string;
|
|
122
|
+
};
|
|
123
|
+
next_action: {
|
|
124
|
+
type: "object";
|
|
125
|
+
description: string;
|
|
126
|
+
properties: {
|
|
127
|
+
instruction: {
|
|
128
|
+
type: "string";
|
|
129
|
+
description: string;
|
|
130
|
+
};
|
|
131
|
+
method: {
|
|
132
|
+
type: "string";
|
|
133
|
+
description: string;
|
|
134
|
+
};
|
|
135
|
+
expected_outcome: {
|
|
136
|
+
type: "string";
|
|
137
|
+
description: string;
|
|
138
|
+
};
|
|
139
|
+
executable_commands: {
|
|
140
|
+
type: "array";
|
|
141
|
+
items: {
|
|
142
|
+
type: "string";
|
|
143
|
+
};
|
|
144
|
+
description: string;
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
required: string[];
|
|
148
|
+
additionalProperties: boolean;
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
required: string[];
|
|
152
|
+
additionalProperties: boolean;
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
export declare const newSecurityEvaluationTools: {
|
|
157
|
+
type: "function";
|
|
158
|
+
function: {
|
|
159
|
+
name: string;
|
|
160
|
+
description: string;
|
|
161
|
+
parameters: {
|
|
162
|
+
type: "object";
|
|
163
|
+
properties: {
|
|
164
|
+
reasoning: {
|
|
165
|
+
type: "string";
|
|
166
|
+
description: string;
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
required: string[];
|
|
170
|
+
additionalProperties: boolean;
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
}[];
|
|
174
|
+
//# sourceMappingURL=security-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security-tools.d.ts","sourceRoot":"","sources":["../../src/security/security-tools.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;CAiBrB,CAAC;AAEF,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;CAsBpB,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;CAqB3B,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkC9B,CAAC;AAEF,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8ClC,CAAC;AAGF,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;GAMtC,CAAC"}
|