@vinhnt-sdk/core 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +194 -12
- package/dist/event-bus/global-bus.d.ts +8 -0
- package/dist/event-bus/global-bus.d.ts.map +1 -1
- package/dist/event-bus/global-bus.js +48 -0
- package/dist/event-bus/global-bus.js.map +1 -1
- package/dist/event-bus/in-memory-bus.d.ts +14 -0
- package/dist/event-bus/in-memory-bus.d.ts.map +1 -1
- package/dist/event-bus/in-memory-bus.js +53 -0
- package/dist/event-bus/in-memory-bus.js.map +1 -1
- package/dist/event-bus/types.d.ts +17 -0
- package/dist/event-bus/types.d.ts.map +1 -1
- package/dist/index.d.ts +222 -105
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +180 -63
- package/dist/index.js.map +1 -1
- package/dist/kernel/circuit-breaker.d.ts +19 -1
- package/dist/kernel/circuit-breaker.d.ts.map +1 -1
- package/dist/kernel/circuit-breaker.js +50 -9
- package/dist/kernel/circuit-breaker.js.map +1 -1
- package/dist/kernel/kernel-error.d.ts +4 -2
- package/dist/kernel/kernel-error.d.ts.map +1 -1
- package/dist/kernel/kernel-error.js +7 -7
- package/dist/kernel/kernel-error.js.map +1 -1
- package/dist/kernel/kernel-types.d.ts +76 -1
- package/dist/kernel/kernel-types.d.ts.map +1 -1
- package/dist/kernel/kernel-types.js.map +1 -1
- package/dist/kernel/kernel.d.ts +34 -4
- package/dist/kernel/kernel.d.ts.map +1 -1
- package/dist/kernel/kernel.js +181 -12
- package/dist/kernel/kernel.js.map +1 -1
- package/dist/kernel/model-caller.d.ts +2 -0
- package/dist/kernel/model-caller.d.ts.map +1 -1
- package/dist/kernel/model-caller.js +8 -8
- package/dist/kernel/model-caller.js.map +1 -1
- package/dist/system-context/sources/instructions-source.js +1 -1
- package/dist/system-context/sources/instructions-source.js.map +1 -1
- package/package.json +8 -61
package/dist/index.d.ts
CHANGED
|
@@ -1,115 +1,232 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
export
|
|
36
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Core agent kernel for building AI coding agents.
|
|
3
|
+
*
|
|
4
|
+
* The kernel manages agent lifecycle, tool execution, permissions, and LLM interactions.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { AgentKernel } from "@vinhnt-sdk/core";
|
|
9
|
+
*
|
|
10
|
+
* const kernel = new AgentKernel({
|
|
11
|
+
* workspaceRoot: "/path/to/project",
|
|
12
|
+
* maxConcurrent: 3,
|
|
13
|
+
* });
|
|
14
|
+
*
|
|
15
|
+
* await kernel.start();
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Main agent kernel class - manages agent lifecycle and execution.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const kernel = new AgentKernel({
|
|
24
|
+
* workspaceRoot: "/path/to/project",
|
|
25
|
+
* maxConcurrent: 3,
|
|
26
|
+
* toolRegistry: myToolRegistry,
|
|
27
|
+
* });
|
|
28
|
+
*
|
|
29
|
+
* const run = await kernel.startRun({
|
|
30
|
+
* agentId: "coder",
|
|
31
|
+
* prompt: "Write a hello world program",
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export { AgentKernel, KernelError } from "./kernel/kernel.js";
|
|
36
|
+
/**
|
|
37
|
+
* Configuration for the agent kernel.
|
|
38
|
+
*/
|
|
39
|
+
export type { AgentKernelConfig, RunHandle, AgentRunHandle, AgentRunResult } from "./kernel/kernel-types.js";
|
|
40
|
+
/**
|
|
41
|
+
* Factory function for creating agent configurations.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* const agent = createAgent({
|
|
46
|
+
* id: "coder",
|
|
47
|
+
* name: "Coder Agent",
|
|
48
|
+
* model: "gpt-4",
|
|
49
|
+
* systemPrompt: "You are a helpful coding assistant.",
|
|
50
|
+
* });
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export { createAgent } from "./agent/agent-factory.js";
|
|
54
|
+
/**
|
|
55
|
+
* Parameters for creating an agent.
|
|
56
|
+
*/
|
|
57
|
+
export type { CreateAgentParams } from "./agent/agent-factory.js";
|
|
58
|
+
/**
|
|
59
|
+
* In-memory event bus for publishing and subscribing to events.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* const bus = new InMemoryEventBus();
|
|
64
|
+
*
|
|
65
|
+
* bus.on("tool.executed", (event) => {
|
|
66
|
+
* console.log("Tool executed:", event.toolId);
|
|
67
|
+
* });
|
|
68
|
+
*
|
|
69
|
+
* await bus.publish({
|
|
70
|
+
* type: "tool.executed",
|
|
71
|
+
* toolId: "read_file",
|
|
72
|
+
* timestamp: Date.now(),
|
|
73
|
+
* });
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
37
76
|
export { InMemoryEventBus } from "./event-bus/in-memory-bus.js";
|
|
77
|
+
/**
|
|
78
|
+
* Event bus interface and types.
|
|
79
|
+
*/
|
|
38
80
|
export type { EventBus, EventHandler, Unsubscribe } from "./event-bus/types.js";
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
81
|
+
/**
|
|
82
|
+
* In-memory session state management.
|
|
83
|
+
*/
|
|
42
84
|
export { InMemorySessionState } from "./session/in-memory-session-state.js";
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
export {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
export type {
|
|
51
|
-
|
|
85
|
+
/**
|
|
86
|
+
* Coordinates multiple runs within a session.
|
|
87
|
+
*/
|
|
88
|
+
export { SessionRunCoordinator } from "./session/run-coordinator.js";
|
|
89
|
+
/**
|
|
90
|
+
* Session and run event store interfaces.
|
|
91
|
+
*/
|
|
92
|
+
export type { RunEventStore, SessionStore } from "./session/store.js";
|
|
93
|
+
/**
|
|
94
|
+
* In-memory agent registry for managing agent configurations.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```typescript
|
|
98
|
+
* const registry = new InMemoryAgentRegistry();
|
|
99
|
+
* registry.register({
|
|
100
|
+
* id: "coder",
|
|
101
|
+
* name: "Coder Agent",
|
|
102
|
+
* model: "gpt-4",
|
|
103
|
+
* });
|
|
104
|
+
*
|
|
105
|
+
* const agent = registry.get("coder");
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
52
108
|
export { InMemoryAgentRegistry } from "./agent/agent-registry.js";
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
export type {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
export { createSkillTool, createSkillSearchTool } from "./skill/skill-tool.js";
|
|
71
|
-
export type { SkillToolInput } from "./skill/skill-tool.js";
|
|
72
|
-
export { createCreateSkillTool } from "./skill/create-skill-tool.js";
|
|
73
|
-
export type { CreateSkillInput } from "./skill/create-skill-tool.js";
|
|
74
|
-
export { checkRiskAllowed, resolveEffectivePermissions, mergeRulesets, normalizePermissions, evaluatePermission } from "./permission/checker.js";
|
|
75
|
-
export type { PermissionResult } from "./permission/checker.js";
|
|
76
|
-
export { matchPermission, buildPermissionRules } from "./permission/evaluator.js";
|
|
77
|
-
export type { ContextSourceKey, ContextSourceValue, ContextSnapshot, SystemContext, ReconcileResult, ContextRegistry } from "./system-context/types.js";
|
|
78
|
-
export { createContextRegistry } from "./system-context/registry.js";
|
|
79
|
-
export { createDateSource } from "./system-context/sources/date-source.js";
|
|
80
|
-
export { createWorkspaceSource } from "./system-context/sources/workspace-source.js";
|
|
81
|
-
export type { WorkspaceInfo } from "./system-context/sources/workspace-source.js";
|
|
82
|
-
export { createInstructionsSource } from "./system-context/sources/instructions-source.js";
|
|
83
|
-
export type { InstructionsInfo } from "./system-context/sources/instructions-source.js";
|
|
84
|
-
export { createAgentSource } from "./system-context/sources/agent-source.js";
|
|
85
|
-
export type { AgentContextInfo } from "./system-context/sources/agent-source.js";
|
|
86
|
-
export { createSystemPromptSource } from "./system-context/prompts/system-prompt-source.js";
|
|
87
|
-
export { createSkillGuidanceSource } from "./system-context/sources/skill-guidance-source.js";
|
|
88
|
-
export type { SkillGuidanceInfo } from "./system-context/sources/skill-guidance-source.js";
|
|
89
|
-
export { InMemoryMemoryStore, SessionMemory, BoundedMemory, ContextCompressor, LlmCompactor, WriteApprovalQueue, BackgroundReview, LearningEngine, createMemorySearchTool, buildPrompt } from "@vinhnt-sdk/knowledge";
|
|
90
|
-
export type { MemoryItem, MemoryStore, MemoryTier, Skill, CompressorOptions, ReviewOptions, PromptBuilderOptions } from "@vinhnt-sdk/knowledge";
|
|
91
|
-
export { AgentKernel, KernelError, CircuitBreaker, CircuitBreakerOpenError } from "./kernel/kernel.js";
|
|
92
|
-
export type { RunState, KernelErrorCode, CircuitState, CircuitBreakerOptions } from "./kernel/kernel.js";
|
|
93
|
-
export type { AgentKernelConfig, RunHandle, KernelSandboxConfig, PermissionConfig, ModelRoutingConfig, HookConfig } from "./kernel/kernel-types.js";
|
|
94
|
-
export { normalizeConfig } from "./kernel/kernel-types.js";
|
|
95
|
-
export { RunStateMachine } from "./kernel/run-state.js";
|
|
96
|
-
export { PermissionGate } from "./kernel/permission-gate.js";
|
|
97
|
-
export type { PermissionCheckResult, ApprovalDecision, DynamicRule } from "./kernel/permission-gate.js";
|
|
98
|
-
export { ModelCaller } from "./kernel/model-caller.js";
|
|
99
|
-
export { evaluateStopConditions, toToolCallOutcome } from "./kernel/termination.js";
|
|
100
|
-
export type { StopCondition, TerminationPolicy, ToolCallOutcome, StepVerificationContext } from "./kernel/termination.js";
|
|
101
|
-
export { LifecycleManager, type LifecycleResource, type LifecycleManagerConfig } from "./kernel/lifecycle-manager.js";
|
|
102
|
-
export { canTransitionRun, terminalRunStatuses } from "./kernel/state-machine.js";
|
|
103
|
-
export { ToolSaga } from "./kernel/tool-saga.js";
|
|
104
|
-
export { DefaultPluginManager } from "./plugin/manager.js";
|
|
105
|
-
export { WorkspaceManager } from "./workspace.js";
|
|
106
|
-
export type { Workspace, WorkspaceEventType, WorkspaceEvent } from "./workspace.js";
|
|
109
|
+
/**
|
|
110
|
+
* Agent registry interface.
|
|
111
|
+
*/
|
|
112
|
+
export type { AgentRegistry } from "./agent/agent-registry.js";
|
|
113
|
+
/**
|
|
114
|
+
* In-memory model registry for managing model providers.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```typescript
|
|
118
|
+
* const registry = new InMemoryModelRegistry();
|
|
119
|
+
* registry.register({
|
|
120
|
+
* id: "openai",
|
|
121
|
+
* name: "OpenAI",
|
|
122
|
+
* baseUrl: "https://api.openai.com",
|
|
123
|
+
* });
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
107
126
|
export { InMemoryModelRegistry } from "./model.js";
|
|
127
|
+
/**
|
|
128
|
+
* Model provider interfaces and types.
|
|
129
|
+
*/
|
|
130
|
+
export type { ModelProvider, ModelRequest, ModelResponse, ModelStreamEvent } from "./model.js";
|
|
131
|
+
/**
|
|
132
|
+
* In-memory approval store for managing permission approvals.
|
|
133
|
+
*/
|
|
108
134
|
export { InMemoryApprovalStore } from "./permission/saved.js";
|
|
135
|
+
/**
|
|
136
|
+
* Approval store interface.
|
|
137
|
+
*/
|
|
138
|
+
export type { ApprovalStore } from "./permission/saved.js";
|
|
139
|
+
/**
|
|
140
|
+
* Workspace manager for handling file operations and workspace context.
|
|
141
|
+
*/
|
|
142
|
+
export { WorkspaceManager } from "./workspace.js";
|
|
143
|
+
/**
|
|
144
|
+
* In-memory skill definition registry.
|
|
145
|
+
*/
|
|
146
|
+
export { InMemorySkillDefRegistry } from "./skill/skill-def-registry.js";
|
|
147
|
+
/**
|
|
148
|
+
* Request tracing for monitoring and debugging.
|
|
149
|
+
*/
|
|
109
150
|
export { Tracer } from "./tracer.js";
|
|
110
|
-
|
|
151
|
+
/**
|
|
152
|
+
* Set the global logger instance.
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```typescript
|
|
156
|
+
* import { setLogger } from "@vinhnt-sdk/core";
|
|
157
|
+
*
|
|
158
|
+
* setLogger({
|
|
159
|
+
* info: (msg, ...args) => console.log(msg, ...args),
|
|
160
|
+
* warn: (msg, ...args) => console.warn(msg, ...args),
|
|
161
|
+
* error: (msg, ...args) => console.error(msg, ...args),
|
|
162
|
+
* debug: (msg, ...args) => console.debug(msg, ...args),
|
|
163
|
+
* });
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
111
166
|
export { setLogger, setLogLevel, getLogger } from "./logger.js";
|
|
167
|
+
/**
|
|
168
|
+
* Logger interface and log level types.
|
|
169
|
+
*/
|
|
112
170
|
export type { Logger, LogLevel } from "./logger.js";
|
|
113
|
-
|
|
114
|
-
|
|
171
|
+
/**
|
|
172
|
+
* Plugin system interfaces and types.
|
|
173
|
+
*/
|
|
174
|
+
export type { PluginManifest, PluginContext, PluginHooks, Plugin } from "./plugin.js";
|
|
175
|
+
/**
|
|
176
|
+
* System context types.
|
|
177
|
+
*/
|
|
178
|
+
export type { ContextSourceValue, ContextSourceKey } from "./system-context/types.js";
|
|
179
|
+
/**
|
|
180
|
+
* Core type identifiers.
|
|
181
|
+
*/
|
|
182
|
+
export type { RunId, SessionId, AgentId, TraceId, RequestId, RunStatus, RequestContext, AgentConfig, AgentProfile, Session, Message, } from "@vinhnt-sdk/schema";
|
|
183
|
+
/**
|
|
184
|
+
* Error classes for the SDK.
|
|
185
|
+
*
|
|
186
|
+
* All errors extend VntError and include error codes and retryable flags.
|
|
187
|
+
*/
|
|
188
|
+
export { VntError, AgentNotFoundError, AgentValidationError, AgentPermissionDenied, ToolNotFoundError, ToolExecutionError, ToolPermissionDenied, RunNotFoundError, RunAbortedError, RunTimeoutError, CircuitBreakerOpenError, ToolInputError, PermissionDeniedError, ValidationError, TimeoutError, NetworkError, RateLimitError, AuthenticationError, ConfigurationError, PluginError, } from "@vinhnt-sdk/schema";
|
|
189
|
+
/**
|
|
190
|
+
* Error context type.
|
|
191
|
+
*/
|
|
192
|
+
export type { VntErrorCtx } from "@vinhnt-sdk/schema";
|
|
193
|
+
/**
|
|
194
|
+
* Define a custom tool.
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* ```typescript
|
|
198
|
+
* import { defineTool } from "@vinhnt-sdk/core";
|
|
199
|
+
* import { z } from "zod";
|
|
200
|
+
*
|
|
201
|
+
* const myTool = defineTool({
|
|
202
|
+
* name: "my_tool",
|
|
203
|
+
* description: "A custom tool",
|
|
204
|
+
* risk: "read",
|
|
205
|
+
* input: z.object({
|
|
206
|
+
* query: z.string(),
|
|
207
|
+
* }),
|
|
208
|
+
* async execute(input, ctx) {
|
|
209
|
+
* return `Result: ${input.query}`;
|
|
210
|
+
* },
|
|
211
|
+
* });
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
214
|
+
export { defineTool, ToolRegistry } from "@vinhnt-sdk/tools";
|
|
215
|
+
/**
|
|
216
|
+
* Tool system types.
|
|
217
|
+
*/
|
|
218
|
+
export type { Tool, ToolConfig, ToolRisk, ToolDefinition } from "@vinhnt-sdk/tools";
|
|
219
|
+
export type { ToolContext, ToolHook, ToolProvider } from "@vinhnt-sdk/tools";
|
|
220
|
+
/**
|
|
221
|
+
* Bounded memory store with size limits.
|
|
222
|
+
*/
|
|
223
|
+
export { BoundedMemory, ContextCompressor } from "@vinhnt-sdk/knowledge";
|
|
224
|
+
/**
|
|
225
|
+
* Memory system types.
|
|
226
|
+
*/
|
|
227
|
+
export type { MemoryItem, MemoryStore } from "@vinhnt-sdk/knowledge";
|
|
228
|
+
/**
|
|
229
|
+
* Redact secrets from text.
|
|
230
|
+
*/
|
|
231
|
+
export { redactSecrets, detectSecrets } from "@vinhnt-sdk/security";
|
|
115
232
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;GAgBG;AAIH;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAE9D;;GAEG;AACH,YAAY,EAAE,iBAAiB,EAAE,SAAS,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAI7G;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD;;GAEG;AACH,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAIlE;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE;;GAEG;AACH,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAIhF;;GAEG;AACH,OAAO,EAAE,oBAAoB,EAAE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13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
3
|
+
//
|
|
4
|
+
// PUBLIC API - Only essential exports for users
|
|
5
|
+
// Internal implementation details are NOT exported here
|
|
6
|
+
/**
|
|
7
|
+
* Core agent kernel for building AI coding agents.
|
|
8
|
+
*
|
|
9
|
+
* The kernel manages agent lifecycle, tool execution, permissions, and LLM interactions.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { AgentKernel } from "@vinhnt-sdk/core";
|
|
14
|
+
*
|
|
15
|
+
* const kernel = new AgentKernel({
|
|
16
|
+
* workspaceRoot: "/path/to/project",
|
|
17
|
+
* maxConcurrent: 3,
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* await kernel.start();
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
// === Kernel (core runtime) ===
|
|
24
|
+
/**
|
|
25
|
+
* Main agent kernel class - manages agent lifecycle and execution.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const kernel = new AgentKernel({
|
|
30
|
+
* workspaceRoot: "/path/to/project",
|
|
31
|
+
* maxConcurrent: 3,
|
|
32
|
+
* toolRegistry: myToolRegistry,
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* const run = await kernel.startRun({
|
|
36
|
+
* agentId: "coder",
|
|
37
|
+
* prompt: "Write a hello world program",
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export { AgentKernel, KernelError } from "./kernel/kernel.js";
|
|
42
|
+
// === Agent system ===
|
|
43
|
+
/**
|
|
44
|
+
* Factory function for creating agent configurations.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const agent = createAgent({
|
|
49
|
+
* id: "coder",
|
|
50
|
+
* name: "Coder Agent",
|
|
51
|
+
* model: "gpt-4",
|
|
52
|
+
* systemPrompt: "You are a helpful coding assistant.",
|
|
53
|
+
* });
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export { createAgent } from "./agent/agent-factory.js";
|
|
20
57
|
// === Event bus ===
|
|
58
|
+
/**
|
|
59
|
+
* In-memory event bus for publishing and subscribing to events.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* const bus = new InMemoryEventBus();
|
|
64
|
+
*
|
|
65
|
+
* bus.on("tool.executed", (event) => {
|
|
66
|
+
* console.log("Tool executed:", event.toolId);
|
|
67
|
+
* });
|
|
68
|
+
*
|
|
69
|
+
* await bus.publish({
|
|
70
|
+
* type: "tool.executed",
|
|
71
|
+
* toolId: "read_file",
|
|
72
|
+
* timestamp: Date.now(),
|
|
73
|
+
* });
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
21
76
|
export { InMemoryEventBus } from "./event-bus/in-memory-bus.js";
|
|
77
|
+
// === Session management ===
|
|
78
|
+
/**
|
|
79
|
+
* In-memory session state management.
|
|
80
|
+
*/
|
|
22
81
|
export { InMemorySessionState } from "./session/in-memory-session-state.js";
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export {
|
|
27
|
-
|
|
82
|
+
/**
|
|
83
|
+
* Coordinates multiple runs within a session.
|
|
84
|
+
*/
|
|
85
|
+
export { SessionRunCoordinator } from "./session/run-coordinator.js";
|
|
86
|
+
// === Agent registry ===
|
|
87
|
+
/**
|
|
88
|
+
* In-memory agent registry for managing agent configurations.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* const registry = new InMemoryAgentRegistry();
|
|
93
|
+
* registry.register({
|
|
94
|
+
* id: "coder",
|
|
95
|
+
* name: "Coder Agent",
|
|
96
|
+
* model: "gpt-4",
|
|
97
|
+
* });
|
|
98
|
+
*
|
|
99
|
+
* const agent = registry.get("coder");
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
28
102
|
export { InMemoryAgentRegistry } from "./agent/agent-registry.js";
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
export { matchPermission, buildPermissionRules } from "./permission/evaluator.js";
|
|
44
|
-
export { createContextRegistry } from "./system-context/registry.js";
|
|
45
|
-
export { createDateSource } from "./system-context/sources/date-source.js";
|
|
46
|
-
export { createWorkspaceSource } from "./system-context/sources/workspace-source.js";
|
|
47
|
-
export { createInstructionsSource } from "./system-context/sources/instructions-source.js";
|
|
48
|
-
export { createAgentSource } from "./system-context/sources/agent-source.js";
|
|
49
|
-
export { createSystemPromptSource } from "./system-context/prompts/system-prompt-source.js";
|
|
50
|
-
export { createSkillGuidanceSource } from "./system-context/sources/skill-guidance-source.js";
|
|
51
|
-
// === Knowledge system ===
|
|
52
|
-
export { InMemoryMemoryStore, SessionMemory, BoundedMemory, ContextCompressor, LlmCompactor, WriteApprovalQueue, BackgroundReview, LearningEngine, createMemorySearchTool, buildPrompt } from "@vinhnt-sdk/knowledge";
|
|
53
|
-
// === Kernel (core runtime) ===
|
|
54
|
-
export { AgentKernel, KernelError, CircuitBreaker, CircuitBreakerOpenError } from "./kernel/kernel.js";
|
|
55
|
-
export { normalizeConfig } from "./kernel/kernel-types.js";
|
|
56
|
-
export { RunStateMachine } from "./kernel/run-state.js";
|
|
57
|
-
export { PermissionGate } from "./kernel/permission-gate.js";
|
|
58
|
-
export { ModelCaller } from "./kernel/model-caller.js";
|
|
59
|
-
export { evaluateStopConditions, toToolCallOutcome } from "./kernel/termination.js";
|
|
60
|
-
export { LifecycleManager } from "./kernel/lifecycle-manager.js";
|
|
61
|
-
export { canTransitionRun, terminalRunStatuses } from "./kernel/state-machine.js";
|
|
62
|
-
export { ToolSaga } from "./kernel/tool-saga.js";
|
|
63
|
-
export { DefaultPluginManager } from "./plugin/manager.js";
|
|
64
|
-
// === Workspace ===
|
|
65
|
-
export { WorkspaceManager } from "./workspace.js";
|
|
66
|
-
// === Model ===
|
|
103
|
+
// === Model registry ===
|
|
104
|
+
/**
|
|
105
|
+
* In-memory model registry for managing model providers.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```typescript
|
|
109
|
+
* const registry = new InMemoryModelRegistry();
|
|
110
|
+
* registry.register({
|
|
111
|
+
* id: "openai",
|
|
112
|
+
* name: "OpenAI",
|
|
113
|
+
* baseUrl: "https://api.openai.com",
|
|
114
|
+
* });
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
67
117
|
export { InMemoryModelRegistry } from "./model.js";
|
|
68
118
|
// === Permission stores ===
|
|
119
|
+
/**
|
|
120
|
+
* In-memory approval store for managing permission approvals.
|
|
121
|
+
*/
|
|
69
122
|
export { InMemoryApprovalStore } from "./permission/saved.js";
|
|
123
|
+
// === Workspace ===
|
|
124
|
+
/**
|
|
125
|
+
* Workspace manager for handling file operations and workspace context.
|
|
126
|
+
*/
|
|
127
|
+
export { WorkspaceManager } from "./workspace.js";
|
|
128
|
+
// === Skill system ===
|
|
129
|
+
/**
|
|
130
|
+
* In-memory skill definition registry.
|
|
131
|
+
*/
|
|
132
|
+
export { InMemorySkillDefRegistry } from "./skill/skill-def-registry.js";
|
|
70
133
|
// === Tracing ===
|
|
134
|
+
/**
|
|
135
|
+
* Request tracing for monitoring and debugging.
|
|
136
|
+
*/
|
|
71
137
|
export { Tracer } from "./tracer.js";
|
|
72
138
|
// === Logger ===
|
|
139
|
+
/**
|
|
140
|
+
* Set the global logger instance.
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* import { setLogger } from "@vinhnt-sdk/core";
|
|
145
|
+
*
|
|
146
|
+
* setLogger({
|
|
147
|
+
* info: (msg, ...args) => console.log(msg, ...args),
|
|
148
|
+
* warn: (msg, ...args) => console.warn(msg, ...args),
|
|
149
|
+
* error: (msg, ...args) => console.error(msg, ...args),
|
|
150
|
+
* debug: (msg, ...args) => console.debug(msg, ...args),
|
|
151
|
+
* });
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
73
154
|
export { setLogger, setLogLevel, getLogger } from "./logger.js";
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
155
|
+
/**
|
|
156
|
+
* Error classes for the SDK.
|
|
157
|
+
*
|
|
158
|
+
* All errors extend VntError and include error codes and retryable flags.
|
|
159
|
+
*/
|
|
160
|
+
export { VntError, AgentNotFoundError, AgentValidationError, AgentPermissionDenied, ToolNotFoundError, ToolExecutionError, ToolPermissionDenied, RunNotFoundError, RunAbortedError, RunTimeoutError, CircuitBreakerOpenError, ToolInputError, PermissionDeniedError, ValidationError, TimeoutError, NetworkError, RateLimitError, AuthenticationError, ConfigurationError, PluginError, } from "@vinhnt-sdk/schema";
|
|
161
|
+
// === Re-export essential types from tools ===
|
|
162
|
+
/**
|
|
163
|
+
* Define a custom tool.
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```typescript
|
|
167
|
+
* import { defineTool } from "@vinhnt-sdk/core";
|
|
168
|
+
* import { z } from "zod";
|
|
169
|
+
*
|
|
170
|
+
* const myTool = defineTool({
|
|
171
|
+
* name: "my_tool",
|
|
172
|
+
* description: "A custom tool",
|
|
173
|
+
* risk: "read",
|
|
174
|
+
* input: z.object({
|
|
175
|
+
* query: z.string(),
|
|
176
|
+
* }),
|
|
177
|
+
* async execute(input, ctx) {
|
|
178
|
+
* return `Result: ${input.query}`;
|
|
179
|
+
* },
|
|
180
|
+
* });
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
export { defineTool, ToolRegistry } from "@vinhnt-sdk/tools";
|
|
184
|
+
// === Re-export essential types from knowledge ===
|
|
185
|
+
/**
|
|
186
|
+
* Bounded memory store with size limits.
|
|
187
|
+
*/
|
|
188
|
+
export { BoundedMemory, ContextCompressor } from "@vinhnt-sdk/knowledge";
|
|
189
|
+
// === Re-export essential types from security ===
|
|
190
|
+
/**
|
|
191
|
+
* Redact secrets from text.
|
|
192
|
+
*/
|
|
193
|
+
export { redactSecrets, detectSecrets } from "@vinhnt-sdk/security";
|
|
77
194
|
//# sourceMappingURL=index.js.map
|