@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
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ChatChunk, ChatOptions, ChatResponse, LLMProvider, LLMProviderConfig, Message } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Anthropic LLM Provider
|
|
4
|
+
* Supports Claude models (Claude 3, Claude 3.5, etc.)
|
|
5
|
+
*/
|
|
6
|
+
export declare class AnthropicProvider implements LLMProvider {
|
|
7
|
+
private client;
|
|
8
|
+
private model;
|
|
9
|
+
private maxTokens;
|
|
10
|
+
constructor(config: LLMProviderConfig);
|
|
11
|
+
chat(messages: Message[], options?: ChatOptions): Promise<ChatResponse>;
|
|
12
|
+
chatStream(messages: Message[], options?: ChatOptions): AsyncGenerator<ChatChunk>;
|
|
13
|
+
countTokens(text: string): number;
|
|
14
|
+
getMaxTokens(): number;
|
|
15
|
+
getProviderName(): string;
|
|
16
|
+
getModelName(): string;
|
|
17
|
+
private getMaxTokensForModel;
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ChatChunk, ChatOptions, ChatResponse, LLMProvider, LLMProviderConfig, Message } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Google Gemini LLM Provider
|
|
4
|
+
* Supports Gemini Pro, Gemini Pro Vision, and other Google models
|
|
5
|
+
*/
|
|
6
|
+
export declare class GoogleProvider implements LLMProvider {
|
|
7
|
+
private client;
|
|
8
|
+
private model;
|
|
9
|
+
private maxTokens;
|
|
10
|
+
constructor(config: LLMProviderConfig);
|
|
11
|
+
chat(messages: Message[], options?: ChatOptions): Promise<ChatResponse>;
|
|
12
|
+
chatStream(messages: Message[], options?: ChatOptions): AsyncGenerator<ChatChunk>;
|
|
13
|
+
countTokens(text: string): number;
|
|
14
|
+
getMaxTokens(): number;
|
|
15
|
+
getProviderName(): string;
|
|
16
|
+
getModelName(): string;
|
|
17
|
+
private getMaxTokensForModel;
|
|
18
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { AnthropicProvider } from "./anthropic";
|
|
2
|
+
import { GoogleProvider } from "./google";
|
|
3
|
+
import { OllamaProvider } from "./ollama";
|
|
4
|
+
import { OpenAIProvider } from "./openai";
|
|
5
|
+
import type { LLMProvider, LLMProviderConfig } from "./types";
|
|
6
|
+
export * from "./anthropic";
|
|
7
|
+
export * from "./google";
|
|
8
|
+
export * from "./ollama";
|
|
9
|
+
export * from "./openai";
|
|
10
|
+
export * from "./types";
|
|
11
|
+
/**
|
|
12
|
+
* Create an LLM provider based on provider name
|
|
13
|
+
*/
|
|
14
|
+
export declare function createLLMProvider(provider: string, config: LLMProviderConfig): LLMProvider;
|
|
15
|
+
/**
|
|
16
|
+
* Factory functions for easy LLM instantiation
|
|
17
|
+
*/
|
|
18
|
+
export declare const llm: {
|
|
19
|
+
/**
|
|
20
|
+
* Create OpenAI provider (GPT-4, GPT-3.5, etc.)
|
|
21
|
+
*/
|
|
22
|
+
openai: (config: Omit<LLMProviderConfig, "model"> & {
|
|
23
|
+
model?: string;
|
|
24
|
+
}) => OpenAIProvider;
|
|
25
|
+
/**
|
|
26
|
+
* Create Anthropic provider (Claude 3, Claude 3.5, etc.)
|
|
27
|
+
*/
|
|
28
|
+
anthropic: (config: Omit<LLMProviderConfig, "model"> & {
|
|
29
|
+
model?: string;
|
|
30
|
+
}) => AnthropicProvider;
|
|
31
|
+
/**
|
|
32
|
+
* Create Google provider (Gemini Pro, Gemini 1.5, etc.)
|
|
33
|
+
*/
|
|
34
|
+
google: (config: Omit<LLMProviderConfig, "model"> & {
|
|
35
|
+
model?: string;
|
|
36
|
+
}) => GoogleProvider;
|
|
37
|
+
/**
|
|
38
|
+
* Create Ollama provider (local models: Llama 2, Mistral, etc.)
|
|
39
|
+
*/
|
|
40
|
+
ollama: (config: Omit<LLMProviderConfig, "model"> & {
|
|
41
|
+
model?: string;
|
|
42
|
+
}) => OllamaProvider;
|
|
43
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ChatChunk, ChatOptions, ChatResponse, LLMProvider, LLMProviderConfig, Message } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Ollama LLM Provider
|
|
4
|
+
* Supports local models via Ollama (Llama 2, Mistral, CodeLlama, etc.)
|
|
5
|
+
*/
|
|
6
|
+
export declare class OllamaProvider implements LLMProvider {
|
|
7
|
+
private baseUrl;
|
|
8
|
+
private model;
|
|
9
|
+
private maxTokens;
|
|
10
|
+
constructor(config: LLMProviderConfig);
|
|
11
|
+
chat(messages: Message[], options?: ChatOptions): Promise<ChatResponse>;
|
|
12
|
+
chatStream(messages: Message[], options?: ChatOptions): AsyncGenerator<ChatChunk>;
|
|
13
|
+
countTokens(text: string): number;
|
|
14
|
+
getMaxTokens(): number;
|
|
15
|
+
getProviderName(): string;
|
|
16
|
+
getModelName(): string;
|
|
17
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ChatChunk, ChatOptions, ChatResponse, LLMProvider, LLMProviderConfig, Message } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* OpenAI LLM Provider
|
|
4
|
+
* Supports GPT-3.5, GPT-4, and other OpenAI models
|
|
5
|
+
*/
|
|
6
|
+
export declare class OpenAIProvider implements LLMProvider {
|
|
7
|
+
private client;
|
|
8
|
+
private model;
|
|
9
|
+
private maxTokens;
|
|
10
|
+
constructor(config: LLMProviderConfig);
|
|
11
|
+
chat(messages: Message[], options?: ChatOptions): Promise<ChatResponse>;
|
|
12
|
+
chatStream(messages: Message[], options?: ChatOptions): AsyncGenerator<ChatChunk>;
|
|
13
|
+
countTokens(text: string): number;
|
|
14
|
+
getMaxTokens(): number;
|
|
15
|
+
getProviderName(): string;
|
|
16
|
+
getModelName(): string;
|
|
17
|
+
private getMaxTokensForModel;
|
|
18
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Message format for chat conversations
|
|
3
|
+
*/
|
|
4
|
+
export interface Message {
|
|
5
|
+
role: "system" | "user" | "assistant" | "function" | "tool";
|
|
6
|
+
content: string | null;
|
|
7
|
+
name?: string;
|
|
8
|
+
tool_call_id?: string;
|
|
9
|
+
tool_calls?: any[];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Options for chat completion
|
|
13
|
+
*/
|
|
14
|
+
export interface ChatOptions {
|
|
15
|
+
temperature?: number;
|
|
16
|
+
max_tokens?: number;
|
|
17
|
+
top_p?: number;
|
|
18
|
+
frequency_penalty?: number;
|
|
19
|
+
presence_penalty?: number;
|
|
20
|
+
stop?: string[];
|
|
21
|
+
stream?: boolean;
|
|
22
|
+
tools?: any[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Response from chat completion
|
|
26
|
+
*/
|
|
27
|
+
export interface ChatResponse {
|
|
28
|
+
content: string;
|
|
29
|
+
model: string;
|
|
30
|
+
finish_reason?: string;
|
|
31
|
+
tool_calls?: any[];
|
|
32
|
+
usage?: {
|
|
33
|
+
prompt_tokens: number;
|
|
34
|
+
completion_tokens: number;
|
|
35
|
+
total_tokens: number;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Streaming chunk from chat completion
|
|
40
|
+
*/
|
|
41
|
+
export interface ChatChunk {
|
|
42
|
+
content: string;
|
|
43
|
+
finish_reason?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Base interface for LLM providers
|
|
47
|
+
*/
|
|
48
|
+
export interface LLMProvider {
|
|
49
|
+
/**
|
|
50
|
+
* Send chat messages and get response
|
|
51
|
+
*/
|
|
52
|
+
chat(messages: Message[], options?: ChatOptions): Promise<ChatResponse>;
|
|
53
|
+
/**
|
|
54
|
+
* Stream chat response
|
|
55
|
+
*/
|
|
56
|
+
chatStream(messages: Message[], options?: ChatOptions): AsyncGenerator<ChatChunk>;
|
|
57
|
+
/**
|
|
58
|
+
* Count tokens in text (approximate)
|
|
59
|
+
*/
|
|
60
|
+
countTokens(text: string): number;
|
|
61
|
+
/**
|
|
62
|
+
* Get maximum context window size
|
|
63
|
+
*/
|
|
64
|
+
getMaxTokens(): number;
|
|
65
|
+
/**
|
|
66
|
+
* Get provider name
|
|
67
|
+
*/
|
|
68
|
+
getProviderName(): string;
|
|
69
|
+
/**
|
|
70
|
+
* Get model name
|
|
71
|
+
*/
|
|
72
|
+
getModelName(): string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Configuration for creating LLM providers
|
|
76
|
+
*/
|
|
77
|
+
export interface LLMProviderConfig {
|
|
78
|
+
apiKey: string;
|
|
79
|
+
model: string;
|
|
80
|
+
baseUrl?: string;
|
|
81
|
+
organization?: string;
|
|
82
|
+
temperature?: number;
|
|
83
|
+
maxTokens?: number;
|
|
84
|
+
}
|
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 🛡️ Sekuire Logger - Asynchronous Event Logging for TypeScript SDK
|
|
3
|
+
*
|
|
4
|
+
* Provides batched, fire-and-forget logging to Sekuire Registry API
|
|
5
|
+
*/
|
|
6
|
+
export type EventType = "tool_execution" | "model_call" | "policy_violation" | "policy_check" | "network_access" | "file_access" | "health";
|
|
7
|
+
export type Severity = "debug" | "info" | "warn" | "error";
|
|
8
|
+
export interface LoggerConfig {
|
|
9
|
+
sekuireId: string;
|
|
10
|
+
apiBaseUrl: string;
|
|
11
|
+
apiKey?: string;
|
|
12
|
+
sessionId?: string;
|
|
13
|
+
workspaceId?: string;
|
|
14
|
+
environment?: string;
|
|
15
|
+
enabled?: boolean;
|
|
16
|
+
batchSize?: number;
|
|
17
|
+
flushInterval?: number;
|
|
18
|
+
}
|
|
19
|
+
export interface EventLog {
|
|
20
|
+
sekuire_id: string;
|
|
21
|
+
session_id: string;
|
|
22
|
+
workspace_id?: string;
|
|
23
|
+
event_type: EventType;
|
|
24
|
+
severity: Severity;
|
|
25
|
+
event_timestamp: string;
|
|
26
|
+
event_data: Record<string, any>;
|
|
27
|
+
metadata: Record<string, any>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Asynchronous logger for Sekuire compliance events
|
|
31
|
+
*
|
|
32
|
+
* Features:
|
|
33
|
+
* - Buffered batching (flush every N events or X seconds)
|
|
34
|
+
* - Fire-and-forget (non-blocking)
|
|
35
|
+
* - Health heartbeat tracking
|
|
36
|
+
* - Graceful shutdown
|
|
37
|
+
*/
|
|
38
|
+
export declare class SekuireLogger {
|
|
39
|
+
private config;
|
|
40
|
+
private buffer;
|
|
41
|
+
private flushTimer?;
|
|
42
|
+
private heartbeatTimer?;
|
|
43
|
+
private isFlushing;
|
|
44
|
+
private client;
|
|
45
|
+
private readonly sdkVersion;
|
|
46
|
+
constructor(config: LoggerConfig);
|
|
47
|
+
/**
|
|
48
|
+
* Log an event (buffered, non-blocking)
|
|
49
|
+
*/
|
|
50
|
+
logEvent(eventType: EventType, severity: Severity, eventData: Record<string, any>): void;
|
|
51
|
+
/**
|
|
52
|
+
* Flush buffer to API (fire-and-forget)
|
|
53
|
+
*/
|
|
54
|
+
flush(): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Send health heartbeat to API
|
|
57
|
+
*/
|
|
58
|
+
private sendHealthHeartbeat;
|
|
59
|
+
/**
|
|
60
|
+
* Start flush timer (every N milliseconds)
|
|
61
|
+
*/
|
|
62
|
+
private startFlushTimer;
|
|
63
|
+
/**
|
|
64
|
+
* Start heartbeat timer (every 30 seconds)
|
|
65
|
+
*/
|
|
66
|
+
private startHeartbeatTimer;
|
|
67
|
+
/**
|
|
68
|
+
* Stop timers
|
|
69
|
+
*/
|
|
70
|
+
private stopTimers;
|
|
71
|
+
/**
|
|
72
|
+
* Shutdown logger gracefully
|
|
73
|
+
* - Stops timers
|
|
74
|
+
* - Flushes remaining events
|
|
75
|
+
* - Safe to call multiple times
|
|
76
|
+
*/
|
|
77
|
+
shutdown(): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Get logger status for debugging
|
|
80
|
+
*/
|
|
81
|
+
getStatus(): {
|
|
82
|
+
enabled: boolean;
|
|
83
|
+
bufferedEvents: number;
|
|
84
|
+
sessionId: string;
|
|
85
|
+
environment: string;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Enable/disable logging at runtime
|
|
89
|
+
*/
|
|
90
|
+
setEnabled(enabled: boolean): void;
|
|
91
|
+
}
|
|
92
|
+
export default SekuireLogger;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface MemoryMessage {
|
|
2
|
+
role: "user" | "assistant" | "system";
|
|
3
|
+
content: string;
|
|
4
|
+
timestamp: number;
|
|
5
|
+
metadata?: Record<string, unknown>;
|
|
6
|
+
}
|
|
7
|
+
export interface MemoryStorage {
|
|
8
|
+
add(sessionId: string, message: MemoryMessage): Promise<void>;
|
|
9
|
+
get(sessionId: string, limit?: number): Promise<MemoryMessage[]>;
|
|
10
|
+
clear(sessionId: string): Promise<void>;
|
|
11
|
+
delete(sessionId: string): Promise<void>;
|
|
12
|
+
exists(sessionId: string): Promise<boolean>;
|
|
13
|
+
}
|
|
14
|
+
export declare abstract class BaseMemoryStorage implements MemoryStorage {
|
|
15
|
+
abstract add(sessionId: string, message: MemoryMessage): Promise<void>;
|
|
16
|
+
abstract get(sessionId: string, limit?: number): Promise<MemoryMessage[]>;
|
|
17
|
+
abstract clear(sessionId: string): Promise<void>;
|
|
18
|
+
abstract delete(sessionId: string): Promise<void>;
|
|
19
|
+
abstract exists(sessionId: string): Promise<boolean>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseMemoryStorage, type MemoryMessage } from "./base";
|
|
2
|
+
export declare class InMemoryStorage extends BaseMemoryStorage {
|
|
3
|
+
private storage;
|
|
4
|
+
add(sessionId: string, message: MemoryMessage): Promise<void>;
|
|
5
|
+
get(sessionId: string, limit?: number): Promise<MemoryMessage[]>;
|
|
6
|
+
clear(sessionId: string): Promise<void>;
|
|
7
|
+
delete(sessionId: string): Promise<void>;
|
|
8
|
+
exists(sessionId: string): Promise<boolean>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from "./base";
|
|
2
|
+
export * from "./in-memory";
|
|
3
|
+
export * from "./postgres";
|
|
4
|
+
export * from "./redis";
|
|
5
|
+
import type { MemoryStorage } from "./base";
|
|
6
|
+
import { type PostgresConfig } from "./postgres";
|
|
7
|
+
import { type RedisConfig } from "./redis";
|
|
8
|
+
export type MemoryType = "in-memory" | "redis" | "postgres";
|
|
9
|
+
export interface MemoryFactoryConfig {
|
|
10
|
+
type: MemoryType;
|
|
11
|
+
redis?: RedisConfig;
|
|
12
|
+
postgres?: PostgresConfig;
|
|
13
|
+
}
|
|
14
|
+
export declare function createMemoryStorage(config: MemoryFactoryConfig): MemoryStorage;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BaseMemoryStorage, type MemoryMessage } from "./base";
|
|
2
|
+
export interface PostgresConfig {
|
|
3
|
+
connectionString?: string;
|
|
4
|
+
host?: string;
|
|
5
|
+
port?: number;
|
|
6
|
+
database?: string;
|
|
7
|
+
user?: string;
|
|
8
|
+
password?: string;
|
|
9
|
+
tableName?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class PostgresStorage extends BaseMemoryStorage {
|
|
12
|
+
private pool;
|
|
13
|
+
private tableName;
|
|
14
|
+
private initialized;
|
|
15
|
+
constructor(config: PostgresConfig);
|
|
16
|
+
private initPool;
|
|
17
|
+
private createTableIfNotExists;
|
|
18
|
+
add(sessionId: string, message: MemoryMessage): Promise<void>;
|
|
19
|
+
get(sessionId: string, limit?: number): Promise<MemoryMessage[]>;
|
|
20
|
+
clear(sessionId: string): Promise<void>;
|
|
21
|
+
delete(sessionId: string): Promise<void>;
|
|
22
|
+
exists(sessionId: string): Promise<boolean>;
|
|
23
|
+
disconnect(): Promise<void>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { BaseMemoryStorage, type MemoryMessage } from "./base";
|
|
2
|
+
export interface RedisConfig {
|
|
3
|
+
host?: string;
|
|
4
|
+
port?: number;
|
|
5
|
+
password?: string;
|
|
6
|
+
db?: number;
|
|
7
|
+
url?: string;
|
|
8
|
+
keyPrefix?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class RedisStorage extends BaseMemoryStorage {
|
|
11
|
+
private client;
|
|
12
|
+
private keyPrefix;
|
|
13
|
+
private connected;
|
|
14
|
+
constructor(config: RedisConfig);
|
|
15
|
+
private initClient;
|
|
16
|
+
private getKey;
|
|
17
|
+
add(sessionId: string, message: MemoryMessage): Promise<void>;
|
|
18
|
+
get(sessionId: string, limit?: number): Promise<MemoryMessage[]>;
|
|
19
|
+
clear(sessionId: string): Promise<void>;
|
|
20
|
+
delete(sessionId: string): Promise<void>;
|
|
21
|
+
exists(sessionId: string): Promise<boolean>;
|
|
22
|
+
disconnect(): Promise<void>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { type ToolDefinition } from './config/loader';
|
|
2
|
+
import type { LLMProvider, Message, ChatOptions } from './llm/types';
|
|
3
|
+
import { PolicyEnforcer } from './policy-enforcer';
|
|
4
|
+
import { type MemoryStorage } from './memory';
|
|
5
|
+
/**
|
|
6
|
+
* Options for overriding agent configuration
|
|
7
|
+
*/
|
|
8
|
+
export interface AgentOptions {
|
|
9
|
+
llm?: LLMProvider;
|
|
10
|
+
tools?: ToolDefinition[];
|
|
11
|
+
memory?: MemoryStorage;
|
|
12
|
+
systemPrompt?: string;
|
|
13
|
+
policyPath?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Sekuire Agent - Config-first AI agent
|
|
17
|
+
*/
|
|
18
|
+
export declare class SekuireAgent {
|
|
19
|
+
readonly name: string;
|
|
20
|
+
private llm;
|
|
21
|
+
private systemPrompt;
|
|
22
|
+
private tools;
|
|
23
|
+
private sessionId;
|
|
24
|
+
private memory?;
|
|
25
|
+
private maxHistoryMessages;
|
|
26
|
+
private policyEnforcer?;
|
|
27
|
+
constructor(config: {
|
|
28
|
+
name: string;
|
|
29
|
+
llm: LLMProvider;
|
|
30
|
+
systemPrompt: string;
|
|
31
|
+
tools: ToolDefinition[];
|
|
32
|
+
memory?: MemoryStorage;
|
|
33
|
+
maxHistoryMessages?: number;
|
|
34
|
+
policyEnforcer?: PolicyEnforcer;
|
|
35
|
+
});
|
|
36
|
+
setSessionId(sessionId: string): void;
|
|
37
|
+
/**
|
|
38
|
+
* Chat with the agent
|
|
39
|
+
*/
|
|
40
|
+
chat(userMessage: string, options?: ChatOptions): Promise<string>;
|
|
41
|
+
/**
|
|
42
|
+
* Execute a tool by name
|
|
43
|
+
*/
|
|
44
|
+
executeTool(name: string, args: any): Promise<any>;
|
|
45
|
+
/**
|
|
46
|
+
* Stream chat response
|
|
47
|
+
*/
|
|
48
|
+
chatStream(userMessage: string, options?: ChatOptions): AsyncGenerator<string>;
|
|
49
|
+
/**
|
|
50
|
+
* Clear conversation history
|
|
51
|
+
*/
|
|
52
|
+
clearHistory(): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Get conversation history
|
|
55
|
+
*/
|
|
56
|
+
getHistory(): Promise<Message[]>;
|
|
57
|
+
/**
|
|
58
|
+
* Get LLM provider name
|
|
59
|
+
*/
|
|
60
|
+
getLLMProvider(): string;
|
|
61
|
+
/**
|
|
62
|
+
* Get LLM model name
|
|
63
|
+
*/
|
|
64
|
+
getModelName(): string;
|
|
65
|
+
/**
|
|
66
|
+
* Get available tools
|
|
67
|
+
*/
|
|
68
|
+
getTools(): ToolDefinition[];
|
|
69
|
+
/**
|
|
70
|
+
* Get the active policy enforcer
|
|
71
|
+
*/
|
|
72
|
+
getPolicyEnforcer(): PolicyEnforcer | undefined;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Load an agent from sekuire.yml configuration
|
|
76
|
+
*
|
|
77
|
+
* @param agentName - Name of the agent to load (for multi-agent configs)
|
|
78
|
+
* @param overrides - Optional overrides for agent configuration
|
|
79
|
+
* @param configPath - Path to sekuire.yml (defaults to './sekuire.yml')
|
|
80
|
+
* @returns Initialized agent instance
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* // Load agent from config
|
|
85
|
+
* const agent = await getAgent('my-agent-openai');
|
|
86
|
+
*
|
|
87
|
+
* // Chat with the agent
|
|
88
|
+
* const response = await agent.chat('Hello!');
|
|
89
|
+
* console.log(response);
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
export declare function getAgent(agentName?: string, overrides?: AgentOptions, configPath?: string): Promise<SekuireAgent>;
|
|
93
|
+
/**
|
|
94
|
+
* Load all agents from configuration
|
|
95
|
+
*
|
|
96
|
+
* @param configPath - Path to sekuire.yml
|
|
97
|
+
* @returns Map of agent name to agent instance
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* const agents = await getAgents();
|
|
102
|
+
* const openai = agents.get('my-agent-openai');
|
|
103
|
+
* const claude = agents.get('my-agent-claude');
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
export declare function getAgents(configPath?: string): Promise<Map<string, SekuireAgent>>;
|
|
107
|
+
/**
|
|
108
|
+
* Get system prompt for a specific agent from configuration
|
|
109
|
+
*
|
|
110
|
+
* @param agentName - Name of the agent (optional for single-agent configs)
|
|
111
|
+
* @param configPath - Path to sekuire.yml (defaults to './sekuire.yml')
|
|
112
|
+
* @returns The system prompt content
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* const prompt = await getSystemPrompt('my-agent-openai');
|
|
117
|
+
* console.log(prompt);
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
export declare function getSystemPrompt(agentName?: string, configPath?: string): Promise<string>;
|
|
121
|
+
/**
|
|
122
|
+
* Get tools for a specific agent from configuration
|
|
123
|
+
*
|
|
124
|
+
* @param agentName - Name of the agent (optional for single-agent configs)
|
|
125
|
+
* @param configPath - Path to sekuire.yml (defaults to './sekuire.yml')
|
|
126
|
+
* @returns The tools schema with tool definitions
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* const toolsSchema = await getTools('my-agent-openai');
|
|
131
|
+
* console.log(toolsSchema.tools);
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
export declare function getTools(agentName?: string, configPath?: string): Promise<ToolDefinition[]>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ActivePolicy } from "./policy";
|
|
2
|
+
type ViolationHandler = (rule: string, reason: string) => void;
|
|
3
|
+
export declare class PolicyEnforcer {
|
|
4
|
+
private readonly policy;
|
|
5
|
+
private readonly onViolation?;
|
|
6
|
+
private readonly override;
|
|
7
|
+
constructor(policy: ActivePolicy, override?: boolean, onViolation?: ViolationHandler | undefined);
|
|
8
|
+
enforceNetwork(domain: string, protocol: string): void;
|
|
9
|
+
enforceFilesystem(path: string, operation: string): void;
|
|
10
|
+
enforceTool(toolName: string): void;
|
|
11
|
+
private getCategoryPrefix;
|
|
12
|
+
enforceModel(model: string): void;
|
|
13
|
+
enforceApi(service: string): void;
|
|
14
|
+
enforceRateLimit(type: "request" | "token", count?: number): void;
|
|
15
|
+
private throw;
|
|
16
|
+
private warnOnly;
|
|
17
|
+
private matches;
|
|
18
|
+
private pathMatch;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
package/dist/policy.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface ActivePolicy {
|
|
2
|
+
policy_id: string;
|
|
3
|
+
workspace_id: string;
|
|
4
|
+
version: string;
|
|
5
|
+
status: string;
|
|
6
|
+
hash: string;
|
|
7
|
+
content: any;
|
|
8
|
+
activated_at?: string;
|
|
9
|
+
updated_at?: string;
|
|
10
|
+
signature?: string;
|
|
11
|
+
signing_key_id?: string;
|
|
12
|
+
signing_public_key?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare class PolicyClient {
|
|
15
|
+
private readonly baseUrl;
|
|
16
|
+
private cache;
|
|
17
|
+
constructor(baseUrl: string);
|
|
18
|
+
fetchActivePolicy(workspaceId: string): Promise<ActivePolicy>;
|
|
19
|
+
verify(policy: ActivePolicy): void;
|
|
20
|
+
}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type HandshakeAuth, type HandshakeHello, type HandshakeWelcome, type KeyPair } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Base class for implementing Sekuire protocol servers
|
|
4
|
+
*/
|
|
5
|
+
export declare abstract class SekuireServer {
|
|
6
|
+
protected readonly agentId: string;
|
|
7
|
+
protected readonly keyPair: KeyPair;
|
|
8
|
+
constructor(agentId: string, keyPair: KeyPair);
|
|
9
|
+
/**
|
|
10
|
+
* Handle the HELLO handshake message
|
|
11
|
+
*/
|
|
12
|
+
handleHello(hello: HandshakeHello): Promise<HandshakeWelcome>;
|
|
13
|
+
/**
|
|
14
|
+
* Handle the AUTH handshake message
|
|
15
|
+
*/
|
|
16
|
+
handleAuth(auth: HandshakeAuth, clientNonce: string): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Get the agent's public key
|
|
19
|
+
*/
|
|
20
|
+
getPublicKey(): string;
|
|
21
|
+
/**
|
|
22
|
+
* Get the agent's ID
|
|
23
|
+
*/
|
|
24
|
+
getAgentId(): string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Express.js middleware for Sekuire protocol
|
|
28
|
+
*/
|
|
29
|
+
export declare function createSekuireExpressMiddleware(server: SekuireServer): any[];
|
|
30
|
+
/**
|
|
31
|
+
* Fastify plugin for Sekuire protocol
|
|
32
|
+
*/
|
|
33
|
+
export declare function createSekuireFastifyPlugin(server: SekuireServer): (fastify: any, options: any) => Promise<void>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Tool, type ToolInput, type ToolMetadata } from './base';
|
|
2
|
+
/**
|
|
3
|
+
* Agent Discovery Tool - Find other agents by capability
|
|
4
|
+
*/
|
|
5
|
+
export declare class AgentDiscoveryTool extends Tool {
|
|
6
|
+
metadata: ToolMetadata;
|
|
7
|
+
execute(input: ToolInput): Promise<string>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Agent Delegation Tool - Delegate tasks to other agents
|
|
11
|
+
*/
|
|
12
|
+
export declare class AgentDelegationTool extends Tool {
|
|
13
|
+
metadata: ToolMetadata;
|
|
14
|
+
execute(input: ToolInput): Promise<string>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Agent Status Check Tool - Check if an agent is available
|
|
18
|
+
*/
|
|
19
|
+
export declare class AgentStatusTool extends Tool {
|
|
20
|
+
metadata: ToolMetadata;
|
|
21
|
+
execute(input: ToolInput): Promise<string>;
|
|
22
|
+
}
|