@kjerneverk/agentic 1.0.5-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.kodrdriv-test-cache.json +6 -0
- package/LICENSE +18 -0
- package/README.md +167 -0
- package/SECURITY.md +94 -0
- package/dist/index.d.ts +770 -0
- package/dist/index.js +1822 -0
- package/dist/index.js.map +1 -0
- package/output/kodrdriv/260110-1207-commit-message.md +1 -0
- package/output/kodrdriv/260110-1208-commit-message.md +1 -0
- package/output/kodrdriv/260110-1210-release-notes.md +27 -0
- package/output/kodrdriv/260110-1232-commit-message.md +1 -0
- package/output/kodrdriv/260110-1234-release-notes.md +46 -0
- package/output/kodrdriv/260110-1308-release-notes.md +20 -0
- package/output/kodrdriv/260112-2155-commit-message.md +1 -0
- package/output/kodrdriv/260112-2156-release-notes.md +33 -0
- package/output/kodrdriv/260112-2340-commit-message.md +1 -0
- package/output/kodrdriv/260113-0017-commit-message.md +1 -0
- package/output/kodrdriv/260113-0017-release-notes.md +53 -0
- package/output/kodrdriv/260115-0616-commit-message.md +4 -0
- package/output/kodrdriv/260115-0739-commit-message.md +1 -0
- package/output/kodrdriv/260115-0746-commit-message.md +1 -0
- package/output/kodrdriv/260115-0747-release-notes.md +91 -0
- package/output/kodrdriv/260126-0851-commit-message.md +1 -0
- package/output/kodrdriv/260128-0900-commit-message.md +1 -0
- package/output/kodrdriv/260128-0900-release-notes.md +29 -0
- package/output/kodrdriv/260128-0905-commit-message.md +1 -0
- package/output/kodrdriv/260128-0913-commit-message.md +1 -0
- package/output/kodrdriv/260128-0913-release-notes.md +23 -0
- package/output/kodrdriv/260128-0919-commit-message.md +1 -0
- package/output/kodrdriv/260128-0919-release-notes.md +21 -0
- package/output/kodrdriv/260130-1642-commit-message.md +1 -0
- package/output/kodrdriv/260130-1642-release-notes.md +29 -0
- package/output/kodrdriv/RELEASE_NOTES.md +27 -0
- package/output/kodrdriv/RELEASE_TITLE.md +1 -0
- package/output/kodrdriv/agentic-reflection-commit-2026-01-10T19-18-11-913Z.md +187 -0
- package/output/kodrdriv/agentic-reflection-commit-2026-01-10T20-03-27-409Z.md +121 -0
- package/output/kodrdriv/agentic-reflection-commit-2026-01-10T20-07-27-813Z.md +114 -0
- package/output/kodrdriv/agentic-reflection-commit-2026-01-10T20-08-06-279Z.md +97 -0
- package/output/kodrdriv/agentic-reflection-commit-2026-01-10T20-32-25-791Z.md +114 -0
- package/output/kodrdriv/agentic-reflection-commit-2026-01-13T05-55-30-733Z.md +97 -0
- package/output/kodrdriv/agentic-reflection-commit-2026-01-13T07-40-28-878Z.md +97 -0
- package/output/kodrdriv/agentic-reflection-commit-2026-01-13T08-17-22-230Z.md +114 -0
- package/output/kodrdriv/agentic-reflection-commit-2026-01-14T14-55-10-122Z.md +177 -0
- package/output/kodrdriv/agentic-reflection-commit-2026-01-15T14-16-05-605Z.md +100 -0
- package/output/kodrdriv/agentic-reflection-commit-2026-01-15T15-39-32-200Z.md +97 -0
- package/output/kodrdriv/agentic-reflection-commit-2026-01-15T15-46-32-840Z.md +114 -0
- package/output/kodrdriv/agentic-reflection-commit-2026-01-26T16-51-00-446Z.md +152 -0
- package/output/kodrdriv/agentic-reflection-commit-2026-01-31T00-38-59-868Z.md +236 -0
- package/output/kodrdriv/agentic-reflection-commit-2026-01-31T00-42-31-993Z.md +152 -0
- package/output/kodrdriv/agentic-reflection-release-2026-01-10T20-10-49-531Z.md +329 -0
- package/output/kodrdriv/agentic-reflection-release-2026-01-10T20-34-32-038Z.md +319 -0
- package/output/kodrdriv/agentic-reflection-release-2026-01-10T21-08-36-314Z.md +168 -0
- package/output/kodrdriv/agentic-reflection-release-2026-01-13T05-56-04-802Z.md +264 -0
- package/output/kodrdriv/agentic-reflection-release-2026-01-13T08-17-56-556Z.md +255 -0
- package/output/kodrdriv/agentic-reflection-release-2026-01-15T15-47-32-509Z.md +460 -0
- package/output/kodrdriv/agentic-reflection-release-2026-01-31T00-42-59-683Z.md +400 -0
- package/package.json +59 -0
- package/package.json~ +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
Copyright 2025 Tim O'Brien
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
|
18
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# agentic
|
|
2
|
+
|
|
3
|
+
Components for building agentic AI workflows - tool registry, context management, and conversation state tracking.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install agentic
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- **ToolRegistry** - Register, execute, and manage tools with usage tracking
|
|
14
|
+
- **ContextManager** - Track and deduplicate injected context
|
|
15
|
+
- **OpenAI/Anthropic Format** - Export tools in provider-specific formats
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
### Tool Registry
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { ToolRegistry, type Tool } from 'agentic';
|
|
23
|
+
|
|
24
|
+
// Create registry
|
|
25
|
+
const registry = ToolRegistry.create({
|
|
26
|
+
workingDirectory: process.cwd(),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Register a tool
|
|
30
|
+
registry.register({
|
|
31
|
+
name: 'read_file',
|
|
32
|
+
description: 'Read contents of a file',
|
|
33
|
+
parameters: {
|
|
34
|
+
type: 'object',
|
|
35
|
+
properties: {
|
|
36
|
+
path: { type: 'string', description: 'File path to read' },
|
|
37
|
+
},
|
|
38
|
+
required: ['path'],
|
|
39
|
+
},
|
|
40
|
+
execute: async ({ path }) => {
|
|
41
|
+
const fs = await import('fs/promises');
|
|
42
|
+
return await fs.readFile(path, 'utf-8');
|
|
43
|
+
},
|
|
44
|
+
category: 'filesystem',
|
|
45
|
+
cost: 'cheap',
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Execute a tool
|
|
49
|
+
const content = await registry.execute('read_file', { path: './README.md' });
|
|
50
|
+
|
|
51
|
+
// Export for OpenAI
|
|
52
|
+
const openAITools = registry.toOpenAIFormat();
|
|
53
|
+
|
|
54
|
+
// Export for Anthropic
|
|
55
|
+
const anthropicTools = registry.toAnthropicFormat();
|
|
56
|
+
|
|
57
|
+
// Get usage statistics
|
|
58
|
+
const stats = registry.getUsageStats();
|
|
59
|
+
console.log(stats.get('read_file')); // { calls: 5, failures: 0, successRate: 1 }
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Context Manager
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import { ContextManager } from 'agentic';
|
|
66
|
+
|
|
67
|
+
const context = new ContextManager();
|
|
68
|
+
|
|
69
|
+
// Track context with deduplication
|
|
70
|
+
context.track({
|
|
71
|
+
id: 'file:main.ts',
|
|
72
|
+
content: fileContent,
|
|
73
|
+
title: 'Main File',
|
|
74
|
+
category: 'source-code',
|
|
75
|
+
priority: 'high',
|
|
76
|
+
}, 5); // position in conversation
|
|
77
|
+
|
|
78
|
+
// Check for duplicates
|
|
79
|
+
if (context.hasContext('file:main.ts')) {
|
|
80
|
+
console.log('Already provided');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Query by category
|
|
84
|
+
const sourceFiles = context.getByCategory('source-code');
|
|
85
|
+
|
|
86
|
+
// Get statistics
|
|
87
|
+
const stats = context.getStats();
|
|
88
|
+
console.log(stats.totalItems);
|
|
89
|
+
console.log(stats.byCategory);
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Tool Definition
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
interface Tool {
|
|
96
|
+
name: string;
|
|
97
|
+
description: string;
|
|
98
|
+
parameters: {
|
|
99
|
+
type: 'object';
|
|
100
|
+
properties: Record<string, ToolParameter>;
|
|
101
|
+
required?: string[];
|
|
102
|
+
};
|
|
103
|
+
execute: (params: any, context?: ToolContext) => Promise<any>;
|
|
104
|
+
category?: string;
|
|
105
|
+
cost?: 'cheap' | 'moderate' | 'expensive';
|
|
106
|
+
examples?: ToolExample[];
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Context Item
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
interface DynamicContentItem {
|
|
114
|
+
content: string;
|
|
115
|
+
title?: string;
|
|
116
|
+
weight?: number;
|
|
117
|
+
id?: string;
|
|
118
|
+
category?: string;
|
|
119
|
+
source?: string;
|
|
120
|
+
priority?: 'high' | 'medium' | 'low';
|
|
121
|
+
timestamp?: Date;
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## API Reference
|
|
126
|
+
|
|
127
|
+
### ToolRegistry
|
|
128
|
+
|
|
129
|
+
| Method | Description |
|
|
130
|
+
|--------|-------------|
|
|
131
|
+
| `create(context?)` | Create a new registry |
|
|
132
|
+
| `register(tool)` | Register a tool |
|
|
133
|
+
| `registerAll(tools)` | Register multiple tools |
|
|
134
|
+
| `execute(name, params)` | Execute a tool |
|
|
135
|
+
| `executeBatch(calls)` | Execute multiple tools |
|
|
136
|
+
| `toOpenAIFormat()` | Export for OpenAI |
|
|
137
|
+
| `toAnthropicFormat()` | Export for Anthropic |
|
|
138
|
+
| `getUsageStats()` | Get usage statistics |
|
|
139
|
+
| `getMostUsed(limit)` | Get most used tools |
|
|
140
|
+
| `getByCategory(category)` | Filter by category |
|
|
141
|
+
|
|
142
|
+
### ContextManager
|
|
143
|
+
|
|
144
|
+
| Method | Description |
|
|
145
|
+
|--------|-------------|
|
|
146
|
+
| `track(item, position)` | Track a context item |
|
|
147
|
+
| `hasContext(id)` | Check if ID exists |
|
|
148
|
+
| `hasContentHash(content)` | Check by content hash |
|
|
149
|
+
| `hasSimilarContent(content)` | Fuzzy content match |
|
|
150
|
+
| `getByCategory(category)` | Filter by category |
|
|
151
|
+
| `getByPriority(priority)` | Filter by priority |
|
|
152
|
+
| `getStats()` | Get statistics |
|
|
153
|
+
| `remove(id)` | Remove by ID |
|
|
154
|
+
| `clear()` | Clear all |
|
|
155
|
+
|
|
156
|
+
## Related Packages
|
|
157
|
+
|
|
158
|
+
- `execution` - Core provider interfaces
|
|
159
|
+
- `execution-openai` - OpenAI provider
|
|
160
|
+
- `execution-anthropic` - Anthropic provider
|
|
161
|
+
- `execution-gemini` - Gemini provider
|
|
162
|
+
|
|
163
|
+
## License
|
|
164
|
+
|
|
165
|
+
Apache-2.0
|
|
166
|
+
|
|
167
|
+
<!-- v1.0.0 -->
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported Versions
|
|
4
|
+
|
|
5
|
+
| Version | Supported |
|
|
6
|
+
| ------- | ------------------ |
|
|
7
|
+
| 0.x.x | :white_check_mark: |
|
|
8
|
+
|
|
9
|
+
## Reporting a Vulnerability
|
|
10
|
+
|
|
11
|
+
If you discover a security vulnerability, please report it responsibly.
|
|
12
|
+
|
|
13
|
+
**Do not open a public GitHub issue for security vulnerabilities.**
|
|
14
|
+
|
|
15
|
+
## Security Features
|
|
16
|
+
|
|
17
|
+
The agentic package includes security features for tool execution:
|
|
18
|
+
|
|
19
|
+
### Tool Validation (ToolGuard)
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { ToolGuard } from '@riotprompt/agentic';
|
|
23
|
+
import { z } from 'zod';
|
|
24
|
+
|
|
25
|
+
const guard = new ToolGuard({
|
|
26
|
+
enabled: true,
|
|
27
|
+
validateParams: true,
|
|
28
|
+
detectPrototypePollution: true,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// Register tool schemas
|
|
32
|
+
guard.registerSchema('read_file', z.object({
|
|
33
|
+
path: z.string().max(1000),
|
|
34
|
+
encoding: z.enum(['utf8', 'base64']).optional(),
|
|
35
|
+
}));
|
|
36
|
+
|
|
37
|
+
// Validate before execution
|
|
38
|
+
const result = guard.validate('read_file', params);
|
|
39
|
+
if (!result.valid) {
|
|
40
|
+
// Handle validation failure
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Tool Sandboxing (ToolSandbox)
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { ToolSandbox } from '@riotprompt/agentic';
|
|
48
|
+
|
|
49
|
+
const sandbox = new ToolSandbox({
|
|
50
|
+
enabled: true,
|
|
51
|
+
maxExecutionTime: 30000,
|
|
52
|
+
maxConcurrent: 5,
|
|
53
|
+
maxOutputSize: 1024 * 1024, // 1MB
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// Execute with sandboxing
|
|
57
|
+
const result = await sandbox.execute(
|
|
58
|
+
'my_tool',
|
|
59
|
+
async (signal) => {
|
|
60
|
+
// Tool implementation
|
|
61
|
+
// Check signal.aborted for cancellation
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Security Features
|
|
67
|
+
|
|
68
|
+
- **Parameter Validation**: Zod schema validation for all tool parameters
|
|
69
|
+
- **Prototype Pollution Prevention**: Blocks `__proto__`, `constructor`, `prototype`
|
|
70
|
+
- **Execution Timeouts**: Configurable timeouts for tool execution
|
|
71
|
+
- **Concurrency Limits**: Limit concurrent tool executions
|
|
72
|
+
- **Output Size Limits**: Prevent memory exhaustion from large outputs
|
|
73
|
+
- **Allow/Deny Lists**: Control which tools can be executed
|
|
74
|
+
- **Silent Logging**: Library logging disabled by default
|
|
75
|
+
|
|
76
|
+
## Environment Variables
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# Enable agentic logging
|
|
80
|
+
AGENTIC_LOGGING=true
|
|
81
|
+
|
|
82
|
+
# Or use DEBUG pattern
|
|
83
|
+
DEBUG=*agentic*
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Security Checklist
|
|
87
|
+
|
|
88
|
+
- [ ] Define Zod schemas for all tool parameters
|
|
89
|
+
- [ ] Enable prototype pollution detection
|
|
90
|
+
- [ ] Set appropriate execution timeouts
|
|
91
|
+
- [ ] Configure concurrency limits
|
|
92
|
+
- [ ] Use allow/deny lists for tools in production
|
|
93
|
+
- [ ] Monitor tool execution metrics
|
|
94
|
+
|