@sekuire/sdk 0.1.4
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 +77 -0
- package/dist/agent.d.ts +186 -0
- package/dist/client.d.ts +37 -0
- package/dist/compliance.d.ts +236 -0
- package/dist/config/loader.d.ts +138 -0
- package/dist/crypto.d.ts +60 -0
- package/dist/identity.d.ts +9 -0
- package/dist/index.d.ts +1987 -0
- package/dist/index.esm.js +20089 -0
- package/dist/index.js +20166 -0
- package/dist/llm/anthropic.d.ts +18 -0
- package/dist/llm/google.d.ts +18 -0
- package/dist/llm/index.d.ts +43 -0
- package/dist/llm/ollama.d.ts +17 -0
- package/dist/llm/openai.d.ts +18 -0
- package/dist/llm/types.d.ts +84 -0
- package/dist/logger.d.ts +92 -0
- package/dist/memory/base.d.ts +20 -0
- package/dist/memory/in-memory.d.ts +9 -0
- package/dist/memory/index.d.ts +14 -0
- package/dist/memory/postgres.d.ts +24 -0
- package/dist/memory/redis.d.ts +23 -0
- package/dist/new-agent.d.ts +134 -0
- package/dist/policy-enforcer.d.ts +20 -0
- package/dist/policy.d.ts +20 -0
- package/dist/server.d.ts +33 -0
- package/dist/tools/agent-delegation.d.ts +22 -0
- package/dist/tools/agent-invocation.d.ts +90 -0
- package/dist/tools/base.d.ts +40 -0
- package/dist/tools/calculator.d.ts +5 -0
- package/dist/tools/compliance-operations.d.ts +40 -0
- package/dist/tools/data-formats.d.ts +36 -0
- package/dist/tools/data-operations.d.ts +17 -0
- package/dist/tools/directory-operations.d.ts +46 -0
- package/dist/tools/file-operations.d.ts +46 -0
- package/dist/tools/http-request.d.ts +5 -0
- package/dist/tools/index.d.ts +96 -0
- package/dist/tools/network-operations.d.ts +52 -0
- package/dist/tools/pattern-parser.d.ts +25 -0
- package/dist/tools/system-operations.d.ts +24 -0
- package/dist/tools/utility-operations.d.ts +44 -0
- package/dist/tools/verification-status.d.ts +40 -0
- package/dist/tools/web-search.d.ts +5 -0
- package/dist/types/policy.d.ts +13 -0
- package/dist/types.d.ts +170 -0
- package/dist/utils.d.ts +68 -0
- package/package.json +99 -0
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Sekuire TypeScript SDK
|
|
2
|
+
|
|
3
|
+
TypeScript/JavaScript SDK for building AI agents with the Sekuire Trust Protocol.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @sekuire/sdk
|
|
9
|
+
# or
|
|
10
|
+
pnpm add @sekuire/sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
### Config-First Approach (Recommended)
|
|
16
|
+
|
|
17
|
+
Create a `sekuire.yml` file:
|
|
18
|
+
|
|
19
|
+
```yaml
|
|
20
|
+
project:
|
|
21
|
+
name: "my-agent"
|
|
22
|
+
version: "1.0.0"
|
|
23
|
+
|
|
24
|
+
agents:
|
|
25
|
+
assistant:
|
|
26
|
+
name: "AI Assistant"
|
|
27
|
+
system_prompt: "./prompts/assistant.md"
|
|
28
|
+
tools: "./tools.json"
|
|
29
|
+
llm:
|
|
30
|
+
provider: "openai"
|
|
31
|
+
model: "gpt-4-turbo"
|
|
32
|
+
api_key_env: "OPENAI_API_KEY"
|
|
33
|
+
temperature: 0.7
|
|
34
|
+
memory:
|
|
35
|
+
type: "buffer"
|
|
36
|
+
max_messages: 10
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Load and use your agent:
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { getAgent } from '@sekuire/sdk';
|
|
43
|
+
|
|
44
|
+
const agent = await getAgent('assistant');
|
|
45
|
+
const response = await agent.chat('Hello!');
|
|
46
|
+
console.log(response);
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Features
|
|
50
|
+
|
|
51
|
+
- ✅ **4 LLM Providers**: OpenAI, Anthropic, Google, Ollama
|
|
52
|
+
- ✅ **Built-in Tools**: Calculator, Web Search, HTTP, File Operations
|
|
53
|
+
- ✅ **Streaming**: Token-by-token responses
|
|
54
|
+
- ✅ **Config-First**: Declarative YAML configuration
|
|
55
|
+
- ✅ **Type-Safe**: Full TypeScript support
|
|
56
|
+
|
|
57
|
+
## API Reference
|
|
58
|
+
|
|
59
|
+
### `getAgent(name?, configPath?)`
|
|
60
|
+
Load a single agent from configuration.
|
|
61
|
+
|
|
62
|
+
### `getAgents(configPath?)`
|
|
63
|
+
Load all agents from configuration.
|
|
64
|
+
|
|
65
|
+
### `SekuireAgent`
|
|
66
|
+
- `chat(message, options?)` - Send message and get response
|
|
67
|
+
- `chatStream(message, options?)` - Stream response
|
|
68
|
+
- `getHistory()` - Get conversation history
|
|
69
|
+
- `clearHistory()` - Clear history
|
|
70
|
+
|
|
71
|
+
## Examples
|
|
72
|
+
|
|
73
|
+
See [examples](../../examples/config-first-agent/) for full examples.
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
MIT
|
package/dist/agent.d.ts
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sekuire Agent Framework
|
|
3
|
+
*
|
|
4
|
+
* High-level API for building compliant AI agents with automatic
|
|
5
|
+
* identity verification, compliance enforcement, and event logging.
|
|
6
|
+
*/
|
|
7
|
+
import type * as z from "zod";
|
|
8
|
+
import { ComplianceMonitor } from "./compliance";
|
|
9
|
+
import { AgentIdentity } from "./identity";
|
|
10
|
+
import { SekuireLogger } from "./logger";
|
|
11
|
+
export interface SekuireAgentConfig {
|
|
12
|
+
/** Agent identity (sekuire.json) */
|
|
13
|
+
identity?: AgentIdentity;
|
|
14
|
+
/** Compliance configuration file path */
|
|
15
|
+
configPath?: string;
|
|
16
|
+
/** Logger configuration */
|
|
17
|
+
logger?: {
|
|
18
|
+
apiBaseUrl?: string;
|
|
19
|
+
environment?: string;
|
|
20
|
+
enabled?: boolean;
|
|
21
|
+
};
|
|
22
|
+
/** Optional custom compliance monitor */
|
|
23
|
+
compliance?: ComplianceMonitor;
|
|
24
|
+
}
|
|
25
|
+
export interface ToolDefinition<T extends z.ZodObject<any> = any> {
|
|
26
|
+
/** Unique tool name */
|
|
27
|
+
name: string;
|
|
28
|
+
/** Human-readable description */
|
|
29
|
+
description: string;
|
|
30
|
+
/** Zod schema for input validation */
|
|
31
|
+
schema: T;
|
|
32
|
+
/** Tool execution function */
|
|
33
|
+
execute: (input: z.infer<T>) => Promise<any> | any;
|
|
34
|
+
/** Optional: Additional compliance checks */
|
|
35
|
+
beforeExecute?: (input: z.infer<T>) => Promise<void> | void;
|
|
36
|
+
}
|
|
37
|
+
export interface Message {
|
|
38
|
+
role: "user" | "assistant" | "system";
|
|
39
|
+
content: string;
|
|
40
|
+
}
|
|
41
|
+
export interface AgentInvokeOptions {
|
|
42
|
+
messages: Message[];
|
|
43
|
+
tools?: string[];
|
|
44
|
+
}
|
|
45
|
+
export interface AgentResponse {
|
|
46
|
+
message: string;
|
|
47
|
+
toolCalls?: ToolCall[];
|
|
48
|
+
metadata?: {
|
|
49
|
+
tokensUsed?: number;
|
|
50
|
+
toolsInvoked?: string[];
|
|
51
|
+
complianceViolations?: number;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export interface ToolCall {
|
|
55
|
+
tool: string;
|
|
56
|
+
input: any;
|
|
57
|
+
output: any;
|
|
58
|
+
allowed: boolean;
|
|
59
|
+
reason?: string;
|
|
60
|
+
}
|
|
61
|
+
export declare class SekuireAgent {
|
|
62
|
+
private identity;
|
|
63
|
+
private compliance;
|
|
64
|
+
private logger;
|
|
65
|
+
private tools;
|
|
66
|
+
constructor(identity: AgentIdentity, compliance: ComplianceMonitor, logger: SekuireLogger);
|
|
67
|
+
/**
|
|
68
|
+
* Get agent identity
|
|
69
|
+
*/
|
|
70
|
+
getIdentity(): AgentIdentity;
|
|
71
|
+
/**
|
|
72
|
+
* Get compliance monitor
|
|
73
|
+
*/
|
|
74
|
+
getCompliance(): ComplianceMonitor;
|
|
75
|
+
/**
|
|
76
|
+
* Get logger
|
|
77
|
+
*/
|
|
78
|
+
getLogger(): SekuireLogger;
|
|
79
|
+
/**
|
|
80
|
+
* Register a tool with the agent
|
|
81
|
+
*/
|
|
82
|
+
registerTool<T extends z.ZodObject<any>>(tool: ToolDefinition<T>): this;
|
|
83
|
+
/**
|
|
84
|
+
* Register multiple tools at once
|
|
85
|
+
*/
|
|
86
|
+
registerTools(tools: ToolDefinition[]): this;
|
|
87
|
+
/**
|
|
88
|
+
* Get registered tools
|
|
89
|
+
*/
|
|
90
|
+
getTools(names?: string[]): ToolDefinition[];
|
|
91
|
+
/**
|
|
92
|
+
* Execute a tool by name
|
|
93
|
+
*/
|
|
94
|
+
executeTool(name: string, input: any): Promise<any>;
|
|
95
|
+
/**
|
|
96
|
+
* Invoke the agent (to be implemented by subclasses or plugins)
|
|
97
|
+
*/
|
|
98
|
+
invoke(options: AgentInvokeOptions): Promise<AgentResponse>;
|
|
99
|
+
/**
|
|
100
|
+
* Shutdown agent and flush logs
|
|
101
|
+
*/
|
|
102
|
+
shutdown(): Promise<void>;
|
|
103
|
+
}
|
|
104
|
+
export declare class SekuireAgentBuilder {
|
|
105
|
+
private config;
|
|
106
|
+
private tools;
|
|
107
|
+
/**
|
|
108
|
+
* Set agent identity
|
|
109
|
+
*/
|
|
110
|
+
withIdentity(identity: AgentIdentity): this;
|
|
111
|
+
/**
|
|
112
|
+
* Load identity from disk
|
|
113
|
+
*/
|
|
114
|
+
loadIdentity(path?: string): Promise<this>;
|
|
115
|
+
/**
|
|
116
|
+
* Set compliance config path
|
|
117
|
+
*/
|
|
118
|
+
withConfig(path: string): this;
|
|
119
|
+
/**
|
|
120
|
+
* Set logger options
|
|
121
|
+
*/
|
|
122
|
+
withLogger(options: NonNullable<SekuireAgentConfig["logger"]>): this;
|
|
123
|
+
/**
|
|
124
|
+
* Add a tool
|
|
125
|
+
*/
|
|
126
|
+
withTool<T extends z.ZodObject<any>>(tool: ToolDefinition<T>): this;
|
|
127
|
+
/**
|
|
128
|
+
* Add multiple tools
|
|
129
|
+
*/
|
|
130
|
+
withTools(tools: ToolDefinition[]): this;
|
|
131
|
+
/**
|
|
132
|
+
* Build the agent
|
|
133
|
+
*/
|
|
134
|
+
build(): Promise<SekuireAgent>;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Create a new Sekuire agent with compliance and identity
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```typescript
|
|
141
|
+
* const agent = await createAgent({
|
|
142
|
+
* configPath: './sekuire.yaml',
|
|
143
|
+
* tools: [weatherTool, calculatorTool],
|
|
144
|
+
* });
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
export declare function createAgent(config?: {
|
|
148
|
+
identity?: AgentIdentity;
|
|
149
|
+
configPath?: string;
|
|
150
|
+
tools?: ToolDefinition[];
|
|
151
|
+
logger?: SekuireAgentConfig["logger"];
|
|
152
|
+
}): Promise<SekuireAgent>;
|
|
153
|
+
/**
|
|
154
|
+
* Create a compliant tool definition
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```typescript
|
|
158
|
+
* const weatherTool = tool({
|
|
159
|
+
* name: 'get_weather',
|
|
160
|
+
* description: 'Get weather for a city',
|
|
161
|
+
* schema: z.object({
|
|
162
|
+
* city: z.string(),
|
|
163
|
+
* }),
|
|
164
|
+
* execute: async ({ city }) => {
|
|
165
|
+
* return `Weather in ${city}: Sunny`;
|
|
166
|
+
* },
|
|
167
|
+
* });
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
export declare function tool<T extends z.ZodObject<any>>(definition: ToolDefinition<T>): ToolDefinition<T>;
|
|
171
|
+
/**
|
|
172
|
+
* Create multiple tools at once
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```typescript
|
|
176
|
+
* const [weather, calc] = tools(
|
|
177
|
+
* { name: 'weather', ... },
|
|
178
|
+
* { name: 'calculator', ... }
|
|
179
|
+
* );
|
|
180
|
+
* ```
|
|
181
|
+
*/
|
|
182
|
+
export declare function tools<T extends ToolDefinition[]>(...definitions: T): T;
|
|
183
|
+
/**
|
|
184
|
+
* Get tools registered with an agent
|
|
185
|
+
*/
|
|
186
|
+
export declare function getTools(agent: SekuireAgent, names?: string[]): ToolDefinition[];
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type AgentResponse, type HandshakeResult, type KeyPair, type SekuireClientConfig } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Sekuire client for verifying agents and performing handshakes
|
|
4
|
+
*/
|
|
5
|
+
export declare class SekuireClient {
|
|
6
|
+
private readonly keyPair;
|
|
7
|
+
private readonly httpClient;
|
|
8
|
+
constructor(keyPair: KeyPair, config: SekuireClientConfig);
|
|
9
|
+
/**
|
|
10
|
+
* Perform the full handshake with a remote agent
|
|
11
|
+
*/
|
|
12
|
+
connect(agentUrl: string, expectedAgentId?: string): Promise<HandshakeResult>;
|
|
13
|
+
/**
|
|
14
|
+
* Verify an agent's signature
|
|
15
|
+
*/
|
|
16
|
+
private verifyAgentSignature;
|
|
17
|
+
/**
|
|
18
|
+
* Fetch agent's public key from the registry
|
|
19
|
+
*/
|
|
20
|
+
fetchAgentPublicKey(agentId: string): Promise<string>;
|
|
21
|
+
/**
|
|
22
|
+
* Get agent information from the registry
|
|
23
|
+
*/
|
|
24
|
+
getAgentInfo(agentId: string): Promise<AgentResponse>;
|
|
25
|
+
/**
|
|
26
|
+
* Search for agents in the registry
|
|
27
|
+
*/
|
|
28
|
+
searchAgents(query: string): Promise<AgentResponse[]>;
|
|
29
|
+
/**
|
|
30
|
+
* Sign data with the client's private key
|
|
31
|
+
*/
|
|
32
|
+
sign(data: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* Get the client's public key
|
|
35
|
+
*/
|
|
36
|
+
getPublicKey(): string;
|
|
37
|
+
}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 🛡️ Sekuire Compliance Enforcement System for TypeScript
|
|
3
|
+
*
|
|
4
|
+
* Runtime compliance enforcement that blocks all unauthorized behavior.
|
|
5
|
+
* Everything blocked unless explicitly allowed in sekuire.yaml.
|
|
6
|
+
*/
|
|
7
|
+
import type { SekuireLogger } from "./logger";
|
|
8
|
+
export interface ComplianceConfig {
|
|
9
|
+
agent: {
|
|
10
|
+
name: string;
|
|
11
|
+
version: string;
|
|
12
|
+
tenant?: string;
|
|
13
|
+
compliance_level?: string;
|
|
14
|
+
};
|
|
15
|
+
permissions: {
|
|
16
|
+
network: {
|
|
17
|
+
default_deny?: boolean;
|
|
18
|
+
allow: string[];
|
|
19
|
+
block?: string[];
|
|
20
|
+
};
|
|
21
|
+
filesystem: {
|
|
22
|
+
default_deny?: boolean;
|
|
23
|
+
allow_read: string[];
|
|
24
|
+
allow_write: string[];
|
|
25
|
+
block_all?: string[];
|
|
26
|
+
};
|
|
27
|
+
env: {
|
|
28
|
+
default_deny?: boolean;
|
|
29
|
+
allow: string[];
|
|
30
|
+
block?: string[];
|
|
31
|
+
};
|
|
32
|
+
tools: {
|
|
33
|
+
enforce_whitelist: boolean;
|
|
34
|
+
audit_all_calls?: boolean;
|
|
35
|
+
blocked_patterns: string[];
|
|
36
|
+
timeout_seconds?: number;
|
|
37
|
+
};
|
|
38
|
+
model: {
|
|
39
|
+
allowed_models: string[];
|
|
40
|
+
max_temperature: number;
|
|
41
|
+
max_tokens: number;
|
|
42
|
+
audit_api_calls?: boolean;
|
|
43
|
+
};
|
|
44
|
+
content: {
|
|
45
|
+
blocked_input_patterns: string[];
|
|
46
|
+
blocked_output_patterns: string[];
|
|
47
|
+
max_response_length?: number;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
logging?: {
|
|
51
|
+
level: string;
|
|
52
|
+
audit_all_requests?: boolean;
|
|
53
|
+
audit_all_tool_calls?: boolean;
|
|
54
|
+
log_network_requests?: boolean;
|
|
55
|
+
log_file_access?: boolean;
|
|
56
|
+
retention_days?: number;
|
|
57
|
+
};
|
|
58
|
+
alerts?: {
|
|
59
|
+
real_time_monitoring?: boolean;
|
|
60
|
+
security_violation_alerts?: boolean;
|
|
61
|
+
compliance_breach_alerts?: boolean;
|
|
62
|
+
performance_anomaly_alerts?: boolean;
|
|
63
|
+
};
|
|
64
|
+
enterprise?: {
|
|
65
|
+
tenant_id?: string;
|
|
66
|
+
department?: string;
|
|
67
|
+
cost_center?: string;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export interface ComplianceViolation {
|
|
71
|
+
timestamp: Date;
|
|
72
|
+
category: string;
|
|
73
|
+
message: string;
|
|
74
|
+
details: Record<string, any>;
|
|
75
|
+
agentId: string;
|
|
76
|
+
}
|
|
77
|
+
export declare class ComplianceError extends Error {
|
|
78
|
+
readonly category: string;
|
|
79
|
+
readonly details: Record<string, any>;
|
|
80
|
+
constructor(message: string, category?: string, details?: Record<string, any>);
|
|
81
|
+
}
|
|
82
|
+
export declare class NetworkComplianceError extends ComplianceError {
|
|
83
|
+
constructor(message: string, details?: Record<string, any>);
|
|
84
|
+
}
|
|
85
|
+
export declare class FileAccessError extends ComplianceError {
|
|
86
|
+
constructor(message: string, details?: Record<string, any>);
|
|
87
|
+
}
|
|
88
|
+
export declare class ToolUsageError extends ComplianceError {
|
|
89
|
+
constructor(message: string, details?: Record<string, any>);
|
|
90
|
+
}
|
|
91
|
+
export declare class ContentPolicyError extends ComplianceError {
|
|
92
|
+
constructor(message: string, details?: Record<string, any>);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* 🔒 Runtime compliance enforcement system
|
|
96
|
+
*
|
|
97
|
+
* Enforces all rules defined in sekuire.yaml:
|
|
98
|
+
* - Network access control
|
|
99
|
+
* - File system restrictions
|
|
100
|
+
* - Tool usage limits
|
|
101
|
+
* - Content filtering
|
|
102
|
+
* - Environment variable access
|
|
103
|
+
*/
|
|
104
|
+
export declare class ComplianceMonitor {
|
|
105
|
+
private configPath;
|
|
106
|
+
private config;
|
|
107
|
+
private violations;
|
|
108
|
+
private logger?;
|
|
109
|
+
private networkAllowSet;
|
|
110
|
+
private networkBlockSet;
|
|
111
|
+
private filesReadSet;
|
|
112
|
+
private filesWriteSet;
|
|
113
|
+
private filesBlockPatterns;
|
|
114
|
+
private envAllowSet;
|
|
115
|
+
private envBlockSet;
|
|
116
|
+
private allowedToolsSet;
|
|
117
|
+
private toolBlockPatterns;
|
|
118
|
+
private inputBlockPatterns;
|
|
119
|
+
private outputBlockPatterns;
|
|
120
|
+
private allowedModelsSet;
|
|
121
|
+
private networkCache;
|
|
122
|
+
private contentCache;
|
|
123
|
+
private readonly maxCacheSize;
|
|
124
|
+
constructor(configPath?: string, logger?: SekuireLogger);
|
|
125
|
+
private loadConfig;
|
|
126
|
+
private buildIndexes;
|
|
127
|
+
private loadAllowedTools;
|
|
128
|
+
/**
|
|
129
|
+
* 🌐 Check if network access is allowed
|
|
130
|
+
*
|
|
131
|
+
* @param url Target URL
|
|
132
|
+
* @param method HTTP method (GET, POST, etc.)
|
|
133
|
+
* @throws NetworkComplianceError If access is blocked
|
|
134
|
+
*/
|
|
135
|
+
checkNetworkAccess(url: string, method?: string): boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Create a safe fetch function with compliance enforcement
|
|
138
|
+
*/
|
|
139
|
+
createSafeFetch(originalFetch?: typeof fetch): typeof fetch;
|
|
140
|
+
/**
|
|
141
|
+
* 📁 Check if file access is allowed
|
|
142
|
+
*
|
|
143
|
+
* @param filePath File path
|
|
144
|
+
* @param mode 'read', 'write', 'execute'
|
|
145
|
+
* @throws FileAccessError If access is blocked
|
|
146
|
+
*/
|
|
147
|
+
checkFileAccess(filePath: string, mode?: "read" | "write" | "execute"): boolean;
|
|
148
|
+
/**
|
|
149
|
+
* Safe file reading with compliance check
|
|
150
|
+
*/
|
|
151
|
+
safeReadFile(filePath: string, encoding?: BufferEncoding): string;
|
|
152
|
+
/**
|
|
153
|
+
* Safe file writing with compliance check
|
|
154
|
+
*/
|
|
155
|
+
safeWriteFile(filePath: string, data: string | Buffer, encoding?: BufferEncoding): void;
|
|
156
|
+
/**
|
|
157
|
+
* 🔐 Check if environment variable access is allowed
|
|
158
|
+
*
|
|
159
|
+
* @param varName Environment variable name
|
|
160
|
+
* @throws ComplianceError If access is blocked
|
|
161
|
+
*/
|
|
162
|
+
checkEnvAccess(varName: string): boolean;
|
|
163
|
+
/**
|
|
164
|
+
* Safe environment variable access
|
|
165
|
+
*/
|
|
166
|
+
safeGetEnv(varName: string, defaultValue?: string): string | undefined;
|
|
167
|
+
/**
|
|
168
|
+
* 🛠️ Check if tool usage is allowed
|
|
169
|
+
*
|
|
170
|
+
* @param toolName Name of the tool
|
|
171
|
+
* @param codeSnippet Code snippet for pattern checking
|
|
172
|
+
* @throws ToolUsageError If tool usage is blocked
|
|
173
|
+
*/
|
|
174
|
+
checkToolUsage(toolName: string, codeSnippet?: string): boolean;
|
|
175
|
+
/**
|
|
176
|
+
* 💬 Check input content for policy violations
|
|
177
|
+
*
|
|
178
|
+
* @param content Input content to check
|
|
179
|
+
* @throws ContentPolicyError If content violates policy
|
|
180
|
+
*/
|
|
181
|
+
checkInputContent(content: string): boolean;
|
|
182
|
+
/**
|
|
183
|
+
* 📤 Check output content for policy violations
|
|
184
|
+
*
|
|
185
|
+
* @param content Output content to check
|
|
186
|
+
* @throws ContentPolicyError If content violates policy
|
|
187
|
+
*/
|
|
188
|
+
checkOutputContent(content: string): boolean;
|
|
189
|
+
private checkContent;
|
|
190
|
+
/**
|
|
191
|
+
* 🤖 Check AI model usage compliance
|
|
192
|
+
*
|
|
193
|
+
* @param model Model name
|
|
194
|
+
* @param temperature Temperature setting
|
|
195
|
+
* @param maxTokens Max tokens setting
|
|
196
|
+
* @throws ComplianceError If model usage violates rules
|
|
197
|
+
*/
|
|
198
|
+
checkModelUsage(model: string, temperature?: number, maxTokens?: number): boolean;
|
|
199
|
+
/**
|
|
200
|
+
* 🔢 Generate BLAKE3 hash for content integrity checking
|
|
201
|
+
*/
|
|
202
|
+
hashContent(content: string): string;
|
|
203
|
+
/**
|
|
204
|
+
* Verify file hasn't been modified
|
|
205
|
+
*/
|
|
206
|
+
checkFileIntegrity(filePath: string, expectedHash: string): boolean;
|
|
207
|
+
/**
|
|
208
|
+
* Log compliance violation
|
|
209
|
+
*/
|
|
210
|
+
private logViolation;
|
|
211
|
+
/**
|
|
212
|
+
* 🚨 Send security alert to monitoring systems
|
|
213
|
+
*/
|
|
214
|
+
private sendSecurityAlert;
|
|
215
|
+
/**
|
|
216
|
+
* 📊 Get current compliance status and statistics
|
|
217
|
+
*/
|
|
218
|
+
getComplianceStatus(): Record<string, any>;
|
|
219
|
+
/**
|
|
220
|
+
* Get recent violations
|
|
221
|
+
*/
|
|
222
|
+
getViolations(category?: string, limit?: number): ComplianceViolation[];
|
|
223
|
+
/**
|
|
224
|
+
* Clear violation log
|
|
225
|
+
*/
|
|
226
|
+
clearViolations(): void;
|
|
227
|
+
/**
|
|
228
|
+
* Set cache value with size limit
|
|
229
|
+
*/
|
|
230
|
+
private setCacheValue;
|
|
231
|
+
/**
|
|
232
|
+
* Pre-warm caches with common operations
|
|
233
|
+
*/
|
|
234
|
+
preWarmCaches(): void;
|
|
235
|
+
}
|
|
236
|
+
export default ComplianceMonitor;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
export interface SekuireConfig {
|
|
2
|
+
project: {
|
|
3
|
+
name: string;
|
|
4
|
+
version: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
author?: string;
|
|
7
|
+
license?: string;
|
|
8
|
+
};
|
|
9
|
+
agents?: {
|
|
10
|
+
[key: string]: AgentConfig;
|
|
11
|
+
};
|
|
12
|
+
agent?: AgentConfig;
|
|
13
|
+
llm?: LLMConfig;
|
|
14
|
+
logger?: LoggerConfig;
|
|
15
|
+
permissions?: PermissionsConfig;
|
|
16
|
+
rate_limits?: RateLimitsConfig;
|
|
17
|
+
}
|
|
18
|
+
export interface PermissionsConfig {
|
|
19
|
+
network?: {
|
|
20
|
+
enabled?: boolean;
|
|
21
|
+
require_tls?: boolean;
|
|
22
|
+
allowed_domains?: string[];
|
|
23
|
+
blocked_domains?: string[];
|
|
24
|
+
};
|
|
25
|
+
filesystem?: {
|
|
26
|
+
enabled?: boolean;
|
|
27
|
+
allowed_paths?: string[];
|
|
28
|
+
blocked_paths?: string[];
|
|
29
|
+
allowed_extensions?: string[];
|
|
30
|
+
};
|
|
31
|
+
api?: {
|
|
32
|
+
enabled?: boolean;
|
|
33
|
+
allowed_services?: Array<{
|
|
34
|
+
service_name: string;
|
|
35
|
+
endpoints?: string[];
|
|
36
|
+
}>;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export interface RateLimitsConfig {
|
|
40
|
+
per_agent?: {
|
|
41
|
+
requests_per_minute?: number;
|
|
42
|
+
tokens_per_hour?: number;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export interface AgentConfig {
|
|
46
|
+
name: string;
|
|
47
|
+
system_prompt: string;
|
|
48
|
+
tools: string;
|
|
49
|
+
llm: LLMConfig;
|
|
50
|
+
memory?: MemoryConfig;
|
|
51
|
+
compliance?: ComplianceConfig;
|
|
52
|
+
models?: {
|
|
53
|
+
allowed_models?: string[];
|
|
54
|
+
blocked_models?: string[];
|
|
55
|
+
};
|
|
56
|
+
toolsets?: {
|
|
57
|
+
allowed_tools?: Array<{
|
|
58
|
+
name: string;
|
|
59
|
+
description?: string;
|
|
60
|
+
}>;
|
|
61
|
+
blocked_tools?: string[];
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export interface LLMConfig {
|
|
65
|
+
provider: string;
|
|
66
|
+
model: string;
|
|
67
|
+
api_key_env: string;
|
|
68
|
+
temperature?: number;
|
|
69
|
+
max_tokens?: number;
|
|
70
|
+
streaming?: boolean;
|
|
71
|
+
base_url?: string;
|
|
72
|
+
}
|
|
73
|
+
export interface MemoryConfig {
|
|
74
|
+
type: "in-memory" | "redis" | "postgres";
|
|
75
|
+
max_messages?: number;
|
|
76
|
+
redis?: {
|
|
77
|
+
url?: string;
|
|
78
|
+
host?: string;
|
|
79
|
+
port?: number;
|
|
80
|
+
password?: string;
|
|
81
|
+
db?: number;
|
|
82
|
+
keyPrefix?: string;
|
|
83
|
+
};
|
|
84
|
+
postgres?: {
|
|
85
|
+
connectionString?: string;
|
|
86
|
+
host?: string;
|
|
87
|
+
port?: number;
|
|
88
|
+
database?: string;
|
|
89
|
+
user?: string;
|
|
90
|
+
password?: string;
|
|
91
|
+
tableName?: string;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
export interface ComplianceConfig {
|
|
95
|
+
framework?: string;
|
|
96
|
+
audit_logging?: boolean;
|
|
97
|
+
sensitive_data_detection?: boolean;
|
|
98
|
+
require_approval?: string[];
|
|
99
|
+
}
|
|
100
|
+
export interface LoggerConfig {
|
|
101
|
+
api_base_url?: string;
|
|
102
|
+
environment?: string;
|
|
103
|
+
enabled?: boolean;
|
|
104
|
+
}
|
|
105
|
+
export interface ToolsSchema {
|
|
106
|
+
version: string;
|
|
107
|
+
tools: ToolDefinition[];
|
|
108
|
+
}
|
|
109
|
+
export interface ToolDefinition {
|
|
110
|
+
name: string;
|
|
111
|
+
description: string;
|
|
112
|
+
category?: string;
|
|
113
|
+
schema: {
|
|
114
|
+
type: string;
|
|
115
|
+
properties: Record<string, unknown>;
|
|
116
|
+
required?: string[];
|
|
117
|
+
};
|
|
118
|
+
implementation: string;
|
|
119
|
+
permissions?: any;
|
|
120
|
+
compliance?: any;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Load sekuire.yml configuration file
|
|
124
|
+
*/
|
|
125
|
+
export declare function loadConfig(configPath?: string): Promise<SekuireConfig>;
|
|
126
|
+
/**
|
|
127
|
+
* Load system prompt from file
|
|
128
|
+
*/
|
|
129
|
+
export declare function loadSystemPrompt(promptPath: string, basePath?: string): Promise<string>;
|
|
130
|
+
/**
|
|
131
|
+
* Load tools configuration from JSON file
|
|
132
|
+
*/
|
|
133
|
+
export declare function loadTools(toolsPath: string, basePath?: string): Promise<ToolsSchema>;
|
|
134
|
+
/**
|
|
135
|
+
* Get agent configuration by name
|
|
136
|
+
* Supports both single agent and multi-agent configs
|
|
137
|
+
*/
|
|
138
|
+
export declare function getAgentConfig(config: SekuireConfig, agentName?: string): AgentConfig;
|