@lssm/lib.ai-agent 0.0.0-canary-20251207013726 → 0.0.0-canary-20251207043720

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lssm/lib.ai-agent",
3
- "version": "0.0.0-canary-20251207013726",
3
+ "version": "0.0.0-canary-20251207043720",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -39,36 +39,66 @@
39
39
  "typescript": "^5.9.3"
40
40
  },
41
41
  "exports": {
42
- ".": "./dist/index.js",
43
- "./agent": "./dist/agent/index.js",
44
- "./agent/agent-factory": "./dist/agent/agent-factory.js",
45
- "./agent/contract-spec-agent": "./dist/agent/contract-spec-agent.js",
46
- "./approval": "./dist/approval/index.js",
47
- "./approval/workflow": "./dist/approval/workflow.js",
48
- "./knowledge": "./dist/knowledge/index.js",
49
- "./knowledge/injector": "./dist/knowledge/injector.js",
50
- "./memory": "./dist/memory/index.js",
51
- "./memory/in-memory": "./dist/memory/in-memory.js",
52
- "./memory/manager": "./dist/memory/manager.js",
53
- "./schema": "./dist/schema/index.js",
54
- "./schema/json-schema-to-zod": "./dist/schema/json-schema-to-zod.js",
55
- "./schema/schema-output": "./dist/schema/schema-output.js",
56
- "./session": "./dist/session/index.js",
57
- "./session/store": "./dist/session/store.js",
58
- "./spec": "./dist/spec/index.js",
59
- "./spec/registry": "./dist/spec/registry.js",
60
- "./spec/spec": "./dist/spec/spec.js",
61
- "./telemetry": "./dist/telemetry/index.js",
62
- "./telemetry/adapter": "./dist/telemetry/adapter.js",
63
- "./tools": "./dist/tools/index.js",
64
- "./tools/knowledge-tool": "./dist/tools/knowledge-tool.js",
65
- "./tools/mcp-client": "./dist/tools/mcp-client.js",
66
- "./tools/mcp-server": "./dist/tools/mcp-server.js",
67
- "./tools/tool-adapter": "./dist/tools/tool-adapter.js",
68
- "./types": "./dist/types.js",
42
+ ".": "./src/index.ts",
43
+ "./agent": "./src/agent/index.ts",
44
+ "./agent/agent-factory": "./src/agent/agent-factory.ts",
45
+ "./agent/contract-spec-agent": "./src/agent/contract-spec-agent.ts",
46
+ "./approval": "./src/approval/index.ts",
47
+ "./approval/workflow": "./src/approval/workflow.ts",
48
+ "./knowledge": "./src/knowledge/index.ts",
49
+ "./knowledge/injector": "./src/knowledge/injector.ts",
50
+ "./memory": "./src/memory/index.ts",
51
+ "./memory/in-memory": "./src/memory/in-memory.ts",
52
+ "./memory/manager": "./src/memory/manager.ts",
53
+ "./schema": "./src/schema/index.ts",
54
+ "./schema/json-schema-to-zod": "./src/schema/json-schema-to-zod.ts",
55
+ "./schema/schema-output": "./src/schema/schema-output.ts",
56
+ "./session": "./src/session/index.ts",
57
+ "./session/store": "./src/session/store.ts",
58
+ "./spec": "./src/spec/index.ts",
59
+ "./spec/registry": "./src/spec/registry.ts",
60
+ "./spec/spec": "./src/spec/spec.ts",
61
+ "./telemetry": "./src/telemetry/index.ts",
62
+ "./telemetry/adapter": "./src/telemetry/adapter.ts",
63
+ "./tools": "./src/tools/index.ts",
64
+ "./tools/knowledge-tool": "./src/tools/knowledge-tool.ts",
65
+ "./tools/mcp-client": "./src/tools/mcp-client.ts",
66
+ "./tools/mcp-server": "./src/tools/mcp-server.ts",
67
+ "./tools/tool-adapter": "./src/tools/tool-adapter.ts",
68
+ "./types": "./src/types.ts",
69
69
  "./*": "./*"
70
70
  },
71
71
  "publishConfig": {
72
- "access": "public"
72
+ "access": "public",
73
+ "exports": {
74
+ ".": "./dist/index.js",
75
+ "./agent": "./dist/agent/index.js",
76
+ "./agent/agent-factory": "./dist/agent/agent-factory.js",
77
+ "./agent/contract-spec-agent": "./dist/agent/contract-spec-agent.js",
78
+ "./approval": "./dist/approval/index.js",
79
+ "./approval/workflow": "./dist/approval/workflow.js",
80
+ "./knowledge": "./dist/knowledge/index.js",
81
+ "./knowledge/injector": "./dist/knowledge/injector.js",
82
+ "./memory": "./dist/memory/index.js",
83
+ "./memory/in-memory": "./dist/memory/in-memory.js",
84
+ "./memory/manager": "./dist/memory/manager.js",
85
+ "./schema": "./dist/schema/index.js",
86
+ "./schema/json-schema-to-zod": "./dist/schema/json-schema-to-zod.js",
87
+ "./schema/schema-output": "./dist/schema/schema-output.js",
88
+ "./session": "./dist/session/index.js",
89
+ "./session/store": "./dist/session/store.js",
90
+ "./spec": "./dist/spec/index.js",
91
+ "./spec/registry": "./dist/spec/registry.js",
92
+ "./spec/spec": "./dist/spec/spec.js",
93
+ "./telemetry": "./dist/telemetry/index.js",
94
+ "./telemetry/adapter": "./dist/telemetry/adapter.js",
95
+ "./tools": "./dist/tools/index.js",
96
+ "./tools/knowledge-tool": "./dist/tools/knowledge-tool.js",
97
+ "./tools/mcp-client": "./dist/tools/mcp-client.js",
98
+ "./tools/mcp-server": "./dist/tools/mcp-server.js",
99
+ "./tools/tool-adapter": "./dist/tools/tool-adapter.js",
100
+ "./types": "./dist/types.js",
101
+ "./*": "./*"
102
+ }
73
103
  }
74
104
  }
@@ -1,103 +0,0 @@
1
- import { AgentSpec } from "../spec/spec.js";
2
- import { AgentRegistry } from "../spec/registry.js";
3
- import { ToolHandler } from "../types.js";
4
- import { AgentSessionStore } from "../session/store.js";
5
- import { TelemetryCollector } from "../telemetry/adapter.js";
6
- import { ContractSpecAgent } from "./contract-spec-agent.js";
7
- import { LanguageModel, Tool } from "ai";
8
- import { KnowledgeRetriever } from "@lssm/lib.knowledge/retriever";
9
-
10
- //#region src/agent/agent-factory.d.ts
11
-
12
- /**
13
- * Factory configuration for creating agents.
14
- */
15
- interface AgentFactoryConfig {
16
- /** Default language model to use */
17
- defaultModel: LanguageModel;
18
- /** Agent registry for looking up specs */
19
- registry: AgentRegistry;
20
- /** Global tool handlers map */
21
- toolHandlers: Map<string, ToolHandler>;
22
- /** Optional knowledge retriever */
23
- knowledgeRetriever?: KnowledgeRetriever;
24
- /** Optional session store */
25
- sessionStore?: AgentSessionStore;
26
- /** Optional telemetry collector */
27
- telemetryCollector?: TelemetryCollector;
28
- /** Additional tools to provide to all agents */
29
- additionalTools?: Record<string, Tool<unknown, unknown>>;
30
- }
31
- /**
32
- * Options for creating an agent instance.
33
- */
34
- interface CreateAgentOptions {
35
- /** Override the default model */
36
- model?: LanguageModel;
37
- /** Additional tool handlers specific to this instance */
38
- toolHandlers?: Map<string, ToolHandler>;
39
- /** Additional tools for this instance */
40
- additionalTools?: Record<string, Tool<unknown, unknown>>;
41
- }
42
- /**
43
- * Factory for creating ContractSpec agents from specs.
44
- *
45
- * Provides a centralized way to instantiate agents with
46
- * consistent configuration.
47
- *
48
- * @example
49
- * ```typescript
50
- * const factory = createAgentFactory({
51
- * defaultModel: mistral('mistral-large-latest'),
52
- * registry: agentRegistry,
53
- * toolHandlers: globalToolHandlers,
54
- * sessionStore: mySessionStore,
55
- * });
56
- *
57
- * const agent = await factory.create('support.bot');
58
- * const result = await agent.generate({ prompt: 'Help me with...' });
59
- * ```
60
- */
61
- declare class AgentFactory {
62
- private readonly config;
63
- private readonly cache;
64
- constructor(config: AgentFactoryConfig);
65
- /**
66
- * Create an agent by name.
67
- *
68
- * @param name - Agent name (e.g., "support.bot")
69
- * @param version - Optional specific version
70
- * @param options - Optional creation options
71
- */
72
- create(name: string, version?: number, options?: CreateAgentOptions): Promise<ContractSpecAgent>;
73
- /**
74
- * Create an agent from a spec directly.
75
- *
76
- * @param spec - Agent specification
77
- * @param options - Optional creation options
78
- */
79
- createFromSpec(spec: AgentSpec, options?: CreateAgentOptions): Promise<ContractSpecAgent>;
80
- /**
81
- * Get or create a cached agent instance.
82
- *
83
- * Use this when you want to reuse agent instances.
84
- *
85
- * @param name - Agent name
86
- * @param version - Optional specific version
87
- */
88
- getOrCreate(name: string, version?: number): Promise<ContractSpecAgent>;
89
- /**
90
- * Clear the agent cache.
91
- */
92
- clearCache(): void;
93
- /**
94
- * List all available agent names.
95
- */
96
- listAvailable(): string[];
97
- }
98
- /**
99
- * Create an agent factory.
100
- */
101
- declare function createAgentFactory(config: AgentFactoryConfig): AgentFactory;
102
- //#endregion
103
- export { AgentFactory, AgentFactoryConfig, CreateAgentOptions, createAgentFactory };
@@ -1,74 +0,0 @@
1
- import { AgentSpec } from "../spec/spec.js";
2
- import { AgentGenerateParams, AgentGenerateResult, AgentStreamParams, ToolHandler } from "../types.js";
3
- import { AgentSessionStore } from "../session/store.js";
4
- import { TelemetryCollector } from "../telemetry/adapter.js";
5
- import * as ai0 from "ai";
6
- import { LanguageModel, Tool, ToolSet } from "ai";
7
- import { KnowledgeRetriever } from "@lssm/lib.knowledge/retriever";
8
-
9
- //#region src/agent/contract-spec-agent.d.ts
10
-
11
- /**
12
- * Type for tool with execute function (compatible with AI SDK Tool)
13
- * Using `any` for broad compatibility with AI SDK tool types
14
- */
15
- type ExecutableTool = Tool<any, any>;
16
- /**
17
- * Configuration for creating a ContractSpecAgent.
18
- */
19
- interface ContractSpecAgentConfig {
20
- /** The agent specification */
21
- spec: AgentSpec;
22
- /** AI SDK language model */
23
- model: LanguageModel;
24
- /** Map of tool name to handler function */
25
- toolHandlers: Map<string, ToolHandler>;
26
- /** Optional knowledge retriever for RAG */
27
- knowledgeRetriever?: KnowledgeRetriever;
28
- /** Optional session store for persistence */
29
- sessionStore?: AgentSessionStore;
30
- /** Optional telemetry collector for evolution */
31
- telemetryCollector?: TelemetryCollector;
32
- /** Additional AI SDK tools (e.g., from MCP servers) */
33
- additionalTools?: Record<string, ExecutableTool>;
34
- }
35
- /**
36
- * ContractSpec Agent implementation using AI SDK v6.
37
- *
38
- * Integrates ContractSpec's spec-first governance with AI SDK's
39
- * ToolLoopAgent, providing:
40
- * - Spec-defined tools with type-safe handlers
41
- * - Hybrid knowledge injection (static + dynamic RAG)
42
- * - Session persistence
43
- * - Telemetry for evolution
44
- * - MCP interoperability
45
- */
46
- declare class ContractSpecAgent {
47
- readonly version = "agent-v1";
48
- readonly id: string;
49
- readonly spec: AgentSpec;
50
- readonly tools: Record<string, ExecutableTool>;
51
- private readonly inner;
52
- private readonly config;
53
- private instructions;
54
- private constructor();
55
- /**
56
- * Create a ContractSpecAgent instance.
57
- * This is async because knowledge injection may need to fetch static content.
58
- */
59
- static create(config: ContractSpecAgentConfig): Promise<ContractSpecAgent>;
60
- /**
61
- * Generate a response (non-streaming).
62
- */
63
- generate(params: AgentGenerateParams): Promise<AgentGenerateResult>;
64
- /**
65
- * Stream a response with real-time updates.
66
- */
67
- stream(params: AgentStreamParams): Promise<ai0.StreamTextResult<ToolSet, never>>;
68
- /**
69
- * Handle step completion for persistence and telemetry.
70
- */
71
- private handleStepFinish;
72
- }
73
- //#endregion
74
- export { ContractSpecAgent, ContractSpecAgentConfig };
@@ -1,3 +0,0 @@
1
- import { ContractSpecAgent, ContractSpecAgentConfig } from "./contract-spec-agent.js";
2
- import { AgentFactory, AgentFactoryConfig, CreateAgentOptions, createAgentFactory } from "./agent-factory.js";
3
- export { AgentFactory, AgentFactoryConfig, ContractSpecAgent, ContractSpecAgentConfig, CreateAgentOptions, createAgentFactory };
@@ -1,2 +0,0 @@
1
- import { ApprovalRequest, ApprovalStatus, ApprovalStore, ApprovalWorkflow, InMemoryApprovalStore, createApprovalWorkflow } from "./workflow.js";
2
- export { type ApprovalRequest, type ApprovalStatus, type ApprovalStore, ApprovalWorkflow, InMemoryApprovalStore, createApprovalWorkflow };
@@ -1,155 +0,0 @@
1
- import { ToolCallInfo } from "../types.js";
2
-
3
- //#region src/approval/workflow.d.ts
4
- type ApprovalStatus = 'pending' | 'approved' | 'rejected';
5
- /**
6
- * Approval request for a tool execution.
7
- *
8
- * When a tool has `needsApproval: true` in AI SDK v6, the agent
9
- * will pause and wait for approval before executing the tool.
10
- */
11
- interface ApprovalRequest {
12
- /** Unique request ID */
13
- id: string;
14
- /** Agent session ID */
15
- sessionId: string;
16
- /** Agent ID */
17
- agentId: string;
18
- /** Tenant ID for scoping */
19
- tenantId?: string;
20
- /** Tool name requiring approval */
21
- toolName: string;
22
- /** Tool call ID from AI SDK */
23
- toolCallId: string;
24
- /** Tool arguments */
25
- toolArgs: unknown;
26
- /** Human-readable reason for approval */
27
- reason: string;
28
- /** When the approval was requested */
29
- requestedAt: Date;
30
- /** Current status */
31
- status: ApprovalStatus;
32
- /** Additional context payload */
33
- payload?: Record<string, unknown>;
34
- /** Who resolved the approval */
35
- reviewer?: string;
36
- /** When the approval was resolved */
37
- resolvedAt?: Date;
38
- /** Reviewer notes */
39
- notes?: string;
40
- }
41
- /**
42
- * Storage interface for approval requests.
43
- */
44
- interface ApprovalStore {
45
- create(request: ApprovalRequest): Promise<void>;
46
- get(id: string): Promise<ApprovalRequest | null>;
47
- getByToolCallId(toolCallId: string): Promise<ApprovalRequest | null>;
48
- update(id: string, updates: Partial<Omit<ApprovalRequest, 'id' | 'sessionId'>>): Promise<void>;
49
- list(options?: {
50
- status?: ApprovalStatus;
51
- agentId?: string;
52
- tenantId?: string;
53
- }): Promise<ApprovalRequest[]>;
54
- }
55
- /**
56
- * In-memory approval store for development and testing.
57
- */
58
- declare class InMemoryApprovalStore implements ApprovalStore {
59
- private readonly items;
60
- create(request: ApprovalRequest): Promise<void>;
61
- get(id: string): Promise<ApprovalRequest | null>;
62
- getByToolCallId(toolCallId: string): Promise<ApprovalRequest | null>;
63
- update(id: string, updates: Partial<Omit<ApprovalRequest, 'id' | 'sessionId'>>): Promise<void>;
64
- list(options?: {
65
- status?: ApprovalStatus;
66
- agentId?: string;
67
- tenantId?: string;
68
- }): Promise<ApprovalRequest[]>;
69
- clear(): void;
70
- }
71
- /**
72
- * Approval workflow for managing tool execution approvals.
73
- *
74
- * Integrates with AI SDK v6's `needsApproval` feature on tools.
75
- *
76
- * @example
77
- * ```typescript
78
- * const workflow = new ApprovalWorkflow();
79
- *
80
- * // When a tool needs approval
81
- * const request = await workflow.requestApproval({
82
- * sessionId: 'sess_123',
83
- * agentId: 'support.bot.v1',
84
- * toolName: 'delete_account',
85
- * toolCallId: 'call_abc',
86
- * toolArgs: { userId: 'user_123' },
87
- * reason: 'Account deletion requires human approval',
88
- * });
89
- *
90
- * // When approval is granted
91
- * await workflow.approve(request.id, 'admin@example.com', 'Verified identity');
92
- *
93
- * // Or rejected
94
- * await workflow.reject(request.id, 'admin@example.com', 'Suspicious activity');
95
- * ```
96
- */
97
- declare class ApprovalWorkflow {
98
- private readonly store;
99
- constructor(store?: ApprovalStore);
100
- /**
101
- * Request approval for a tool execution.
102
- */
103
- requestApproval(params: {
104
- sessionId: string;
105
- agentId: string;
106
- tenantId?: string;
107
- toolName: string;
108
- toolCallId: string;
109
- toolArgs: unknown;
110
- reason: string;
111
- payload?: Record<string, unknown>;
112
- }): Promise<ApprovalRequest>;
113
- /**
114
- * Request approval from an AI SDK tool call.
115
- */
116
- requestApprovalFromToolCall(toolCall: ToolCallInfo, context: {
117
- sessionId: string;
118
- agentId: string;
119
- tenantId?: string;
120
- reason?: string;
121
- }): Promise<ApprovalRequest>;
122
- /**
123
- * Approve a pending request.
124
- */
125
- approve(id: string, reviewer: string, notes?: string): Promise<void>;
126
- /**
127
- * Reject a pending request.
128
- */
129
- reject(id: string, reviewer: string, notes?: string): Promise<void>;
130
- /**
131
- * Get approval status for a tool call.
132
- */
133
- getStatus(toolCallId: string): Promise<ApprovalStatus | null>;
134
- /**
135
- * Check if a tool call is approved.
136
- */
137
- isApproved(toolCallId: string): Promise<boolean>;
138
- /**
139
- * List pending approvals.
140
- */
141
- listPending(options?: {
142
- agentId?: string;
143
- tenantId?: string;
144
- }): Promise<ApprovalRequest[]>;
145
- /**
146
- * Get approval request by ID.
147
- */
148
- get(id: string): Promise<ApprovalRequest | null>;
149
- }
150
- /**
151
- * Create an approval workflow instance.
152
- */
153
- declare function createApprovalWorkflow(store?: ApprovalStore): ApprovalWorkflow;
154
- //#endregion
155
- export { ApprovalRequest, ApprovalStatus, ApprovalStore, ApprovalWorkflow, InMemoryApprovalStore, createApprovalWorkflow };
package/dist/index.d.ts DELETED
@@ -1,23 +0,0 @@
1
- import { AgentConfidencePolicy, AgentEscalationPolicy, AgentKnowledgeRef, AgentMemoryConfig, AgentMeta, AgentPolicy, AgentSpec, AgentToolConfig, agentKey, defineAgent } from "./spec/spec.js";
2
- import { AgentRegistry, createAgentRegistry } from "./spec/registry.js";
3
- import { AgentCallOptions, AgentEventEmitter, AgentEventName, AgentEventPayload, AgentGenerateParams, AgentGenerateResult, AgentMessage, AgentRunRequestInput, AgentRunResult, AgentSessionState, AgentStatus, AgentStepMetrics, AgentStreamParams, AgentToolContext, AgentToolInvocation, AgentToolResult, ToolCallInfo, ToolExecutionContext, ToolHandler, ToolResultInfo } from "./types.js";
4
- import { AgentSessionStore, InMemorySessionStore, createInMemorySessionStore, generateSessionId } from "./session/store.js";
5
- import { InMemoryTelemetryCollector, OperationMetricSample, TelemetryCollector, createInMemoryTelemetryCollector, noopTelemetryCollector, trackAgentStep } from "./telemetry/adapter.js";
6
- import { ContractSpecAgent, ContractSpecAgentConfig } from "./agent/contract-spec-agent.js";
7
- import { AgentFactory, AgentFactoryConfig, CreateAgentOptions, createAgentFactory } from "./agent/agent-factory.js";
8
- import "./agent/index.js";
9
- import { ApprovalRequest, ApprovalStatus, ApprovalStore, ApprovalWorkflow, InMemoryApprovalStore, createApprovalWorkflow } from "./approval/workflow.js";
10
- import "./approval/index.js";
11
- import { buildToolHandlers, createToolHandler, specToolToAISDKTool, specToolsToAISDKTools } from "./tools/tool-adapter.js";
12
- import { createKnowledgeQueryTool } from "./tools/knowledge-tool.js";
13
- import { McpClientConfig, McpClientResult, createMcpToolsets, mcpServerToTools } from "./tools/mcp-client.js";
14
- import { AgentMcpServerConfig, agentToMcpServer, createAgentMcpServer } from "./tools/mcp-server.js";
15
- import "./tools/index.js";
16
- import { jsonSchemaToZod, jsonSchemaToZodSafe } from "./schema/json-schema-to-zod.js";
17
- import { SchemaOutput, enumToChoiceOutput, jsonSchemaToArrayOutput, jsonSchemaToOutput, textOutput, zodToOutput } from "./schema/schema-output.js";
18
- import "./schema/index.js";
19
- import { createKnowledgeInjector, injectStaticKnowledge } from "./knowledge/injector.js";
20
- import "./session/index.js";
21
- import "./telemetry/index.js";
22
- import { Experimental_Agent as ToolLoopAgent, LanguageModel, LanguageModelUsage, ModelMessage, StepResult, Tool, ToolSet } from "ai";
23
- export { AgentCallOptions, AgentConfidencePolicy, AgentEscalationPolicy, AgentEventEmitter, AgentEventName, AgentEventPayload, AgentFactory, AgentFactoryConfig, AgentGenerateParams, AgentGenerateResult, AgentKnowledgeRef, AgentMcpServerConfig, AgentMemoryConfig, AgentMessage, AgentMeta, AgentPolicy, AgentRegistry, AgentRunRequestInput, AgentRunResult, AgentSessionState, AgentSessionStore, AgentSpec, AgentStatus, AgentStepMetrics, AgentStreamParams, AgentToolConfig, AgentToolContext, AgentToolInvocation, AgentToolResult, ApprovalRequest, ApprovalStatus, ApprovalStore, ApprovalWorkflow, ContractSpecAgent, ContractSpecAgentConfig, CreateAgentOptions, InMemoryApprovalStore, InMemorySessionStore, InMemoryTelemetryCollector, type LanguageModel, type LanguageModelUsage, McpClientConfig, McpClientResult, type ModelMessage, OperationMetricSample, SchemaOutput, type StepResult, TelemetryCollector, type Tool, ToolCallInfo, ToolExecutionContext, ToolHandler, ToolLoopAgent, ToolResultInfo, type ToolSet, agentKey, agentToMcpServer, buildToolHandlers, createAgentFactory, createAgentMcpServer, createAgentRegistry, createApprovalWorkflow, createInMemorySessionStore, createInMemoryTelemetryCollector, createKnowledgeInjector, createKnowledgeQueryTool, createMcpToolsets, createToolHandler, defineAgent, enumToChoiceOutput, generateSessionId, injectStaticKnowledge, jsonSchemaToArrayOutput, jsonSchemaToOutput, jsonSchemaToZod, jsonSchemaToZodSafe, mcpServerToTools, noopTelemetryCollector, specToolToAISDKTool, specToolsToAISDKTools, textOutput, trackAgentStep, zodToOutput };
@@ -1,2 +0,0 @@
1
- import { createKnowledgeInjector, injectStaticKnowledge } from "./injector.js";
2
- export { createKnowledgeInjector, injectStaticKnowledge };
@@ -1,37 +0,0 @@
1
- import { AgentKnowledgeRef } from "../spec/spec.js";
2
- import { KnowledgeRetriever } from "@lssm/lib.knowledge/retriever";
3
-
4
- //#region src/knowledge/injector.d.ts
5
-
6
- /**
7
- * Inject static knowledge into agent instructions.
8
- *
9
- * This function handles the "required" knowledge that should be
10
- * injected into the system prompt at agent initialization time.
11
- * Optional knowledge is handled by the knowledge query tool.
12
- *
13
- * @param instructions - Base agent instructions
14
- * @param knowledgeRefs - Knowledge references from the agent spec
15
- * @param retriever - Optional knowledge retriever
16
- * @returns Instructions with injected knowledge
17
- */
18
- declare function injectStaticKnowledge(instructions: string, knowledgeRefs: AgentKnowledgeRef[], retriever?: KnowledgeRetriever): Promise<string>;
19
- /**
20
- * Create a knowledge injector instance for reuse.
21
- */
22
- declare function createKnowledgeInjector(retriever?: KnowledgeRetriever): {
23
- /**
24
- * Inject static knowledge into instructions.
25
- */
26
- inject: (instructions: string, knowledgeRefs: AgentKnowledgeRef[]) => Promise<string>;
27
- /**
28
- * Check if a knowledge space is available.
29
- */
30
- hasSpace: (spaceKey: string) => boolean;
31
- /**
32
- * List available knowledge spaces.
33
- */
34
- listSpaces: () => string[];
35
- };
36
- //#endregion
37
- export { createKnowledgeInjector, injectStaticKnowledge };
@@ -1,21 +0,0 @@
1
- import { AgentSessionState } from "../types.js";
2
- import { AgentMemorySnapshot, AgentSessionMemory, BaseAgentMemoryManager } from "./manager.js";
3
-
4
- //#region src/memory/in-memory.d.ts
5
- interface InMemoryAgentMemoryOptions {
6
- ttlMinutes?: number;
7
- maxEntries?: number;
8
- }
9
- declare class InMemoryAgentMemory extends BaseAgentMemoryManager {
10
- private readonly ttlMs;
11
- private readonly maxEntries;
12
- private readonly store;
13
- constructor(options?: InMemoryAgentMemoryOptions);
14
- load(sessionId: string): Promise<AgentSessionMemory | null>;
15
- save(snapshot: AgentSessionMemory): Promise<void>;
16
- summarize(session: AgentSessionState): Promise<AgentMemorySnapshot>;
17
- private trim;
18
- private evictExpired;
19
- }
20
- //#endregion
21
- export { InMemoryAgentMemory, InMemoryAgentMemoryOptions };
@@ -1,3 +0,0 @@
1
- import { AgentMemoryEntry, AgentMemoryManager, AgentMemorySnapshot, AgentSessionMemory, BaseAgentMemoryManager, trackMessageInMemory } from "./manager.js";
2
- import { InMemoryAgentMemory, InMemoryAgentMemoryOptions } from "./in-memory.js";
3
- export { AgentMemoryEntry, AgentMemoryManager, AgentMemorySnapshot, AgentSessionMemory, BaseAgentMemoryManager, InMemoryAgentMemory, InMemoryAgentMemoryOptions, trackMessageInMemory };
@@ -1,41 +0,0 @@
1
- import { AgentMessage, AgentSessionState } from "../types.js";
2
-
3
- //#region src/memory/manager.d.ts
4
- interface AgentMemoryEntry {
5
- id: string;
6
- type: 'user' | 'assistant' | 'tool' | 'system';
7
- content: string;
8
- createdAt: Date;
9
- metadata?: Record<string, string>;
10
- }
11
- interface AgentMemorySnapshot {
12
- entries: AgentMemoryEntry[];
13
- summary?: string;
14
- lastSummarizedAt?: Date;
15
- }
16
- interface AgentSessionMemory {
17
- session: AgentSessionState;
18
- memory: AgentMemorySnapshot;
19
- }
20
- interface AgentMemoryManager {
21
- load(sessionId: string): Promise<AgentSessionMemory | null>;
22
- save(snapshot: AgentSessionMemory): Promise<void>;
23
- append(session: AgentSessionState, entry: Omit<AgentMemoryEntry, 'id' | 'createdAt'> & {
24
- createdAt?: Date;
25
- }): Promise<AgentSessionMemory>;
26
- summarize(session: AgentSessionState): Promise<AgentMemorySnapshot | undefined>;
27
- prune(session: AgentSessionState): Promise<void>;
28
- }
29
- declare abstract class BaseAgentMemoryManager implements AgentMemoryManager {
30
- abstract load(sessionId: string): Promise<AgentSessionMemory | null>;
31
- abstract save(snapshot: AgentSessionMemory): Promise<void>;
32
- append(session: AgentSessionState, entry: Omit<AgentMemoryEntry, 'id' | 'createdAt'> & {
33
- createdAt?: Date;
34
- }): Promise<AgentSessionMemory>;
35
- summarize(_session: AgentSessionState): Promise<AgentMemorySnapshot | undefined>;
36
- prune(_session: AgentSessionState): Promise<void>;
37
- protected bootstrapMemory(session: AgentSessionState): AgentSessionMemory;
38
- }
39
- declare function trackMessageInMemory(manager: AgentMemoryManager | undefined, session: AgentSessionState, message: AgentMessage): void;
40
- //#endregion
41
- export { AgentMemoryEntry, AgentMemoryManager, AgentMemorySnapshot, AgentSessionMemory, BaseAgentMemoryManager, trackMessageInMemory };
@@ -1,3 +0,0 @@
1
- import { jsonSchemaToZod, jsonSchemaToZodSafe } from "./json-schema-to-zod.js";
2
- import { SchemaOutput, enumToChoiceOutput, jsonSchemaToArrayOutput, jsonSchemaToOutput, textOutput, zodToOutput } from "./schema-output.js";
3
- export { SchemaOutput, enumToChoiceOutput, jsonSchemaToArrayOutput, jsonSchemaToOutput, jsonSchemaToZod, jsonSchemaToZodSafe, textOutput, zodToOutput };
@@ -1,54 +0,0 @@
1
- import { ZodType } from "zod";
2
-
3
- //#region src/schema/json-schema-to-zod.d.ts
4
-
5
- /**
6
- * JSON Schema type definitions for conversion.
7
- */
8
- interface JsonSchema {
9
- type?: string;
10
- properties?: Record<string, JsonSchema>;
11
- required?: string[];
12
- items?: JsonSchema;
13
- enum?: (string | number | boolean)[];
14
- const?: unknown;
15
- anyOf?: JsonSchema[];
16
- oneOf?: JsonSchema[];
17
- allOf?: JsonSchema[];
18
- description?: string;
19
- default?: unknown;
20
- minimum?: number;
21
- maximum?: number;
22
- minLength?: number;
23
- maxLength?: number;
24
- pattern?: string;
25
- format?: string;
26
- nullable?: boolean;
27
- [key: string]: unknown;
28
- }
29
- /**
30
- * Convert a JSON Schema to a Zod schema.
31
- *
32
- * Supports common JSON Schema types and constraints:
33
- * - string, number, integer, boolean, null
34
- * - object with properties and required
35
- * - array with items
36
- * - enum and const
37
- * - anyOf, oneOf, allOf
38
- * - format constraints (email, uri, uuid, date-time)
39
- * - numeric constraints (minimum, maximum)
40
- * - string constraints (minLength, maxLength, pattern)
41
- *
42
- * @param schema - JSON Schema object
43
- * @returns Zod schema
44
- */
45
- declare function jsonSchemaToZod(schema: JsonSchema | Record<string, unknown>): ZodType;
46
- /**
47
- * Convert a JSON Schema to a Zod schema with a default empty object fallback.
48
- *
49
- * @param schema - Optional JSON Schema object
50
- * @returns Zod schema (defaults to empty object schema)
51
- */
52
- declare function jsonSchemaToZodSafe(schema?: Record<string, unknown>): ZodType;
53
- //#endregion
54
- export { jsonSchemaToZod, jsonSchemaToZodSafe };