@dcyfr/ai 3.0.1 → 3.0.3
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/CHANGELOG.md +10 -0
- package/LICENSE +11 -30
- package/README.md +216 -145
- package/dist/.tsbuildinfo +1 -1
- package/dist/ai/agents/agent-router.d.ts.map +1 -1
- package/dist/ai/agents/agent-router.js +3 -1
- package/dist/ai/agents/agent-router.js.map +1 -1
- package/dist/ai/config/loader.d.ts +5 -1
- package/dist/ai/config/loader.d.ts.map +1 -1
- package/dist/ai/config/loader.js +24 -4
- package/dist/ai/config/loader.js.map +1 -1
- package/dist/ai/core/provider-registry.d.ts +9 -1
- package/dist/ai/core/provider-registry.d.ts.map +1 -1
- package/dist/ai/core/provider-registry.js +97 -138
- package/dist/ai/core/provider-registry.js.map +1 -1
- package/dist/ai/core/telemetry-engine.d.ts +1 -1
- package/dist/ai/core/telemetry-engine.d.ts.map +1 -1
- package/dist/ai/core/telemetry-engine.js +14 -10
- package/dist/ai/core/telemetry-engine.js.map +1 -1
- package/dist/ai/delegation/contract-manager.d.ts.map +1 -1
- package/dist/ai/delegation/contract-manager.js +5 -2
- package/dist/ai/delegation/contract-manager.js.map +1 -1
- package/dist/ai/delegation/execution-mode-dashboard.d.ts.map +1 -1
- package/dist/ai/delegation/execution-mode-dashboard.js +4 -2
- package/dist/ai/delegation/execution-mode-dashboard.js.map +1 -1
- package/dist/ai/mcp/servers/shared/utils.d.ts.map +1 -1
- package/dist/ai/mcp/servers/shared/utils.js +4 -2
- package/dist/ai/mcp/servers/shared/utils.js.map +1 -1
- package/dist/ai/memory/file-memory-adapter.d.ts.map +1 -1
- package/dist/ai/memory/file-memory-adapter.js +11 -13
- package/dist/ai/memory/file-memory-adapter.js.map +1 -1
- package/dist/ai/memory/working-memory-persistence.d.ts.map +1 -1
- package/dist/ai/memory/working-memory-persistence.js +4 -2
- package/dist/ai/memory/working-memory-persistence.js.map +1 -1
- package/dist/ai/metacognition/config.d.ts +41 -0
- package/dist/ai/metacognition/config.d.ts.map +1 -0
- package/dist/ai/metacognition/config.js +51 -0
- package/dist/ai/metacognition/config.js.map +1 -0
- package/dist/ai/metacognition/governance.d.ts +68 -0
- package/dist/ai/metacognition/governance.d.ts.map +1 -0
- package/dist/ai/metacognition/governance.js +118 -0
- package/dist/ai/metacognition/governance.js.map +1 -0
- package/dist/ai/metacognition/index.d.ts +24 -0
- package/dist/ai/metacognition/index.d.ts.map +1 -0
- package/dist/ai/metacognition/index.js +18 -0
- package/dist/ai/metacognition/index.js.map +1 -0
- package/dist/ai/metacognition/ledger.d.ts +121 -0
- package/dist/ai/metacognition/ledger.d.ts.map +1 -0
- package/dist/ai/metacognition/ledger.js +268 -0
- package/dist/ai/metacognition/ledger.js.map +1 -0
- package/dist/ai/metacognition/runtime.d.ts +205 -0
- package/dist/ai/metacognition/runtime.d.ts.map +1 -0
- package/dist/ai/metacognition/runtime.js +391 -0
- package/dist/ai/metacognition/runtime.js.map +1 -0
- package/dist/ai/metacognition/telemetry.d.ts +144 -0
- package/dist/ai/metacognition/telemetry.d.ts.map +1 -0
- package/dist/ai/metacognition/telemetry.js +149 -0
- package/dist/ai/metacognition/telemetry.js.map +1 -0
- package/dist/ai/metacognition/transfer.d.ts +153 -0
- package/dist/ai/metacognition/transfer.d.ts.map +1 -0
- package/dist/ai/metacognition/transfer.js +182 -0
- package/dist/ai/metacognition/transfer.js.map +1 -0
- package/dist/ai/metacognition/types.d.ts +302 -0
- package/dist/ai/metacognition/types.d.ts.map +1 -0
- package/dist/ai/metacognition/types.js +79 -0
- package/dist/ai/metacognition/types.js.map +1 -0
- package/dist/ai/runtime/agent-runtime.d.ts.map +1 -1
- package/dist/ai/runtime/agent-runtime.js +12 -18
- package/dist/ai/runtime/agent-runtime.js.map +1 -1
- package/dist/ai/src/capability-manifest-generator.d.ts.map +1 -1
- package/dist/ai/src/capability-manifest-generator.js +11 -5
- package/dist/ai/src/capability-manifest-generator.js.map +1 -1
- package/dist/ai/src/cli/telemetry-dashboard.js +3 -3
- package/dist/ai/src/cli/telemetry-dashboard.js.map +1 -1
- package/dist/ai/src/compaction/memory-compaction.d.ts.map +1 -1
- package/dist/ai/src/compaction/memory-compaction.js +5 -4
- package/dist/ai/src/compaction/memory-compaction.js.map +1 -1
- package/dist/ai/src/integrations/linear/index.d.ts +19 -0
- package/dist/ai/src/integrations/linear/index.d.ts.map +1 -0
- package/dist/ai/src/integrations/linear/index.js +20 -0
- package/dist/ai/src/integrations/linear/index.js.map +1 -0
- package/dist/ai/src/integrations/linear/issue-mapper.d.ts +93 -0
- package/dist/ai/src/integrations/linear/issue-mapper.d.ts.map +1 -0
- package/dist/ai/src/integrations/linear/issue-mapper.js +186 -0
- package/dist/ai/src/integrations/linear/issue-mapper.js.map +1 -0
- package/dist/ai/src/integrations/linear/linear-client.d.ts +199 -0
- package/dist/ai/src/integrations/linear/linear-client.d.ts.map +1 -0
- package/dist/ai/src/integrations/linear/linear-client.js +300 -0
- package/dist/ai/src/integrations/linear/linear-client.js.map +1 -0
- package/dist/ai/src/plugins/security/secret-detector.js +3 -3
- package/dist/ai/src/plugins/security/secret-detector.js.map +1 -1
- package/dist/ai/src/runtime/agent-runtime.js +1 -1
- package/dist/ai/src/runtime/agent-runtime.js.map +1 -1
- package/dist/ai/src/security/prompt-scan-worker.d.ts +63 -0
- package/dist/ai/src/security/prompt-scan-worker.d.ts.map +1 -0
- package/dist/ai/src/security/prompt-scan-worker.js +177 -0
- package/dist/ai/src/security/prompt-scan-worker.js.map +1 -0
- package/dist/ai/src/telemetry/delegation-telemetry.d.ts +10 -0
- package/dist/ai/src/telemetry/delegation-telemetry.d.ts.map +1 -1
- package/dist/ai/src/telemetry/delegation-telemetry.js +23 -0
- package/dist/ai/src/telemetry/delegation-telemetry.js.map +1 -1
- package/dist/ai/types/index.d.ts +8 -3
- package/dist/ai/types/index.d.ts.map +1 -1
- package/dist/ai/types/index.js.map +1 -1
- package/dist/ai/utils/safe-fs.d.ts +19 -0
- package/dist/ai/utils/safe-fs.d.ts.map +1 -0
- package/dist/ai/utils/safe-fs.js +64 -0
- package/dist/ai/utils/safe-fs.js.map +1 -0
- package/package.json +33 -22
package/README.md
CHANGED
|
@@ -1,42 +1,61 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/dcyfr-labs/dcyfr-labs/main/public/images/dcyfr-avatar.svg" alt="DCYFR Logo" width="120" height="120" />
|
|
3
|
+
<h1>@dcyfr/ai</h1>
|
|
4
|
+
<p><em>Portable AI agent harness with plugin architecture for multi-provider integration, telemetry tracking, and quality validation.</em></p>
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
<!-- README-META
|
|
8
|
+
tlp_clearance: GREEN
|
|
9
|
+
status: active
|
|
10
|
+
name: dcyfr-ai
|
|
11
|
+
description: Portable AI agent harness with plugin architecture
|
|
12
|
+
last_validated: 2026-03-29
|
|
13
|
+
-->
|
|
2
14
|
|
|
3
15
|
[](https://deepwiki.com/dcyfr/dcyfr-ai)
|
|
4
16
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
[](https://www.npmjs.com/package/@dcyfr/ai)
|
|
8
|
-
[](https://www.npmjs.com/package/@dcyfr/ai)
|
|
17
|
+
[](https://www.npmjs.com/package/@dcyfr/ai)
|
|
18
|
+
[](https://www.npmjs.com/package/@dcyfr/ai)
|
|
9
19
|
[](https://opensource.org/licenses/MIT)
|
|
10
|
-
[](https://www.typescriptlang.org/)
|
|
21
|
+
[](https://bundlephobia.com/package/@dcyfr/ai)
|
|
12
22
|
|
|
13
23
|
Portable AI agent harness with plugin architecture for managing multiple AI providers, tracking telemetry, and ensuring quality compliance.
|
|
14
24
|
|
|
25
|
+
## About DCYFR
|
|
26
|
+
|
|
27
|
+
`@dcyfr/ai` is maintained by **DCYFR Labs** as part of the DCYFR AI tooling portfolio.
|
|
28
|
+
|
|
29
|
+
- **DCYFR** is a registered trademark of DCYFR Labs.
|
|
30
|
+
- Primary domain: [www.dcyfr.ai](https://www.dcyfr.ai)
|
|
31
|
+
- Trademark guidance: [../TRADEMARK.md](../TRADEMARK.md)
|
|
32
|
+
- Licensing details: [LICENSE](./LICENSE)
|
|
33
|
+
|
|
15
34
|
## 🔍 @dcyfr/ai vs. Alternatives
|
|
16
35
|
|
|
17
|
-
| Feature
|
|
18
|
-
|
|
|
19
|
-
| Multi-Provider
|
|
20
|
-
| Plugin System
|
|
21
|
-
| Telemetry
|
|
22
|
-
| Zero Config
|
|
23
|
-
| Bundle Size
|
|
24
|
-
| TypeScript
|
|
25
|
-
| Quality Gates
|
|
26
|
-
| Config System
|
|
27
|
-
| Learning Curve
|
|
36
|
+
| Feature | @dcyfr/ai | LangChain | Vercel AI SDK | AutoGPT |
|
|
37
|
+
| -------------- | ------------------------------ | ---------- | ------------- | ------- |
|
|
38
|
+
| Multi-Provider | ✅ | ✅ | ✅ | ❌ |
|
|
39
|
+
| Plugin System | ✅ Custom | ✅ Complex | ❌ | ❌ |
|
|
40
|
+
| Telemetry | ✅ Built-in | ❌ | ❌ | ❌ |
|
|
41
|
+
| Zero Config | ✅ | ❌ | ✅ | ❌ |
|
|
42
|
+
| Bundle Size | [](https://bundlephobia.com/package/@dcyfr/ai) | ~2.3MB | ~450KB | N/A |
|
|
43
|
+
| TypeScript | ✅ Strict | Partial | ✅ | ❌ |
|
|
44
|
+
| Quality Gates | ✅ | ❌ | ❌ | ❌ |
|
|
45
|
+
| Config System | YAML/JSON/package | Code-only | Code-only | JSON |
|
|
46
|
+
| Learning Curve | Low | High | Low | High |
|
|
28
47
|
|
|
29
48
|
---
|
|
30
49
|
|
|
31
50
|
## 📊 npm Statistics
|
|
32
51
|
|
|
33
|
-
[](https://www.npmjs.com/package/@dcyfr/ai)
|
|
53
|
+
[](https://www.npmjs.com/package/@dcyfr/ai)
|
|
54
|
+
[](https://bundlephobia.com/package/@dcyfr/ai)
|
|
36
55
|
|
|
37
56
|
- **Weekly Downloads:** Check [npm stats](https://www.npmjs.com/package/@dcyfr/ai)
|
|
38
|
-
- **Dependencies:**
|
|
39
|
-
- **Bundle Size:**
|
|
57
|
+
- **Dependencies:** 28 production dependencies
|
|
58
|
+
- **Bundle Size:** See badge above ([](https://bundlephobia.com/package/@dcyfr/ai))
|
|
40
59
|
- **TypeScript:** Full type definitions included
|
|
41
60
|
- **ESM Support:** ✅ Full ESM modules with tree shaking
|
|
42
61
|
|
|
@@ -83,10 +102,6 @@ Portable AI agent harness with plugin architecture for managing multiple AI prov
|
|
|
83
102
|
- ⚙️ **Configuration System** - YAML/JSON config with three-layer merge
|
|
84
103
|
- 📊 **Comprehensive Telemetry** - Track usage, costs, quality metrics, performance
|
|
85
104
|
- ✅ **Validation Harness** - Quality gates with parallel/serial execution
|
|
86
|
-
- 💾 **Pluggable Storage** - Memory, file-based, or custom adapters
|
|
87
|
-
- ⚡ **Type-Safe** - Full TypeScript support with Zod validation
|
|
88
|
-
- 📦 **Lightweight** - ~200KB gzipped bundle size
|
|
89
|
-
- 🛠️ **CLI Tools** - Config validation and initialization
|
|
90
105
|
|
|
91
106
|
## Installation
|
|
92
107
|
|
|
@@ -105,7 +120,7 @@ npx @dcyfr/ai config:init
|
|
|
105
120
|
This creates a `.dcyfr.yaml` configuration file:
|
|
106
121
|
|
|
107
122
|
```yaml
|
|
108
|
-
version:
|
|
123
|
+
version: "1.0.0"
|
|
109
124
|
projectName: my-app
|
|
110
125
|
|
|
111
126
|
agents:
|
|
@@ -124,7 +139,7 @@ agents:
|
|
|
124
139
|
### 2. Load and Use Configuration
|
|
125
140
|
|
|
126
141
|
```typescript
|
|
127
|
-
import { loadConfig, ValidationFramework } from
|
|
142
|
+
import { loadConfig, ValidationFramework } from "@dcyfr/ai";
|
|
128
143
|
|
|
129
144
|
// Load configuration (auto-detects .dcyfr.yaml, .dcyfr.json, package.json)
|
|
130
145
|
const config = await loadConfig();
|
|
@@ -142,7 +157,7 @@ const report = await framework.validate({
|
|
|
142
157
|
config: config.agents,
|
|
143
158
|
});
|
|
144
159
|
|
|
145
|
-
console.log(`Validation: ${report.valid ?
|
|
160
|
+
console.log(`Validation: ${report.valid ? "PASS" : "FAIL"}`);
|
|
146
161
|
```
|
|
147
162
|
|
|
148
163
|
### 3. Validate Configuration
|
|
@@ -161,7 +176,7 @@ npx @dcyfr/ai config:validate --verbose
|
|
|
161
176
|
|
|
162
177
|
### Migrating from LangChain
|
|
163
178
|
|
|
164
|
-
**Why migrate:**
|
|
179
|
+
**Why migrate:** Smaller bundle footprint than LangChain (see [bundlephobia](https://bundlephobia.com/package/@dcyfr/ai)), built-in telemetry, simpler API
|
|
165
180
|
|
|
166
181
|
```typescript
|
|
167
182
|
// LangChain (before)
|
|
@@ -172,21 +187,24 @@ const model = new ChatOpenAI({ temperature: 0.9 });
|
|
|
172
187
|
const response = await model.call([new HumanMessage("Hello")]);
|
|
173
188
|
|
|
174
189
|
// @dcyfr/ai (after)
|
|
175
|
-
import { AgentRuntime } from
|
|
190
|
+
import { AgentRuntime } from "@dcyfr/ai";
|
|
176
191
|
|
|
177
192
|
const runtime = new AgentRuntime({
|
|
178
|
-
provider:
|
|
179
|
-
model:
|
|
180
|
-
temperature: 0.9
|
|
193
|
+
provider: "openai",
|
|
194
|
+
model: "gpt-4",
|
|
195
|
+
temperature: 0.9,
|
|
181
196
|
});
|
|
182
197
|
|
|
183
|
-
const response = await runtime.chat({
|
|
198
|
+
const response = await runtime.chat({
|
|
199
|
+
messages: [{ role: "user", content: "Hello" }],
|
|
200
|
+
});
|
|
184
201
|
```
|
|
185
202
|
|
|
186
203
|
**Key Differences:**
|
|
204
|
+
|
|
187
205
|
- Simpler configuration (YAML/JSON vs code-only)
|
|
188
206
|
- Built-in telemetry tracking (no additional setup)
|
|
189
|
-
- Smaller bundle size (
|
|
207
|
+
- Smaller bundle size than LangChain (see [bundlephobia](https://bundlephobia.com/package/@dcyfr/ai))
|
|
190
208
|
- Type-safe validation with Zod
|
|
191
209
|
- Quality gates included out of the box
|
|
192
210
|
|
|
@@ -196,32 +214,35 @@ const response = await runtime.chat({ messages: [{ role: 'user', content: 'Hello
|
|
|
196
214
|
|
|
197
215
|
```typescript
|
|
198
216
|
// Vercel AI SDK (before)
|
|
199
|
-
import { openai } from
|
|
200
|
-
import { generateText } from
|
|
217
|
+
import { openai } from "@ai-sdk/openai";
|
|
218
|
+
import { generateText } from "ai";
|
|
201
219
|
|
|
202
220
|
const { text } = await generateText({
|
|
203
|
-
model: openai(
|
|
204
|
-
prompt:
|
|
221
|
+
model: openai("gpt-4-turbo"),
|
|
222
|
+
prompt: "Hello",
|
|
205
223
|
});
|
|
206
224
|
|
|
207
225
|
// @dcyfr/ai (after)
|
|
208
|
-
import { AgentRuntime, ValidationFramework } from
|
|
226
|
+
import { AgentRuntime, ValidationFramework } from "@dcyfr/ai";
|
|
209
227
|
|
|
210
228
|
const runtime = new AgentRuntime({
|
|
211
|
-
provider:
|
|
212
|
-
model:
|
|
229
|
+
provider: "openai",
|
|
230
|
+
model: "gpt-4-turbo",
|
|
213
231
|
});
|
|
214
232
|
|
|
215
233
|
const response = await runtime.chat({
|
|
216
|
-
messages: [{ role:
|
|
234
|
+
messages: [{ role: "user", content: "Hello" }],
|
|
217
235
|
});
|
|
218
236
|
|
|
219
237
|
// Bonus: Built-in validation
|
|
220
238
|
const validator = new ValidationFramework();
|
|
221
|
-
const report = await validator.validate({
|
|
239
|
+
const report = await validator.validate({
|
|
240
|
+
/* config */
|
|
241
|
+
});
|
|
222
242
|
```
|
|
223
243
|
|
|
224
244
|
**Key Differences:**
|
|
245
|
+
|
|
225
246
|
- Configuration system (YAML/JSON files)
|
|
226
247
|
- Validation harness with quality gates
|
|
227
248
|
- Comprehensive telemetry tracking
|
|
@@ -237,7 +258,7 @@ const report = await validator.validate({ /* config */ });
|
|
|
237
258
|
### Prerequisites
|
|
238
259
|
|
|
239
260
|
```bash
|
|
240
|
-
# Node.js
|
|
261
|
+
# Node.js 24+ required
|
|
241
262
|
node --version
|
|
242
263
|
|
|
243
264
|
# Install @dcyfr/ai
|
|
@@ -251,23 +272,23 @@ export ANTHROPIC_API_KEY=your_anthropic_key
|
|
|
251
272
|
### 1. Basic AgentRuntime Setup
|
|
252
273
|
|
|
253
274
|
```typescript
|
|
254
|
-
import {
|
|
255
|
-
AgentRuntime,
|
|
256
|
-
ProviderRegistry,
|
|
257
|
-
TelemetryEngine,
|
|
258
|
-
DCYFRMemory
|
|
259
|
-
} from
|
|
275
|
+
import {
|
|
276
|
+
AgentRuntime,
|
|
277
|
+
ProviderRegistry,
|
|
278
|
+
TelemetryEngine,
|
|
279
|
+
DCYFRMemory,
|
|
280
|
+
} from "@dcyfr/ai";
|
|
260
281
|
|
|
261
282
|
// Initialize components
|
|
262
283
|
const providerRegistry = new ProviderRegistry();
|
|
263
|
-
const telemetryEngine = new TelemetryEngine({ storage:
|
|
264
|
-
const memory = new DCYFRMemory({ storage:
|
|
284
|
+
const telemetryEngine = new TelemetryEngine({ storage: "sqlite" });
|
|
285
|
+
const memory = new DCYFRMemory({ storage: "memory" });
|
|
265
286
|
|
|
266
287
|
// Create runtime
|
|
267
288
|
const runtime = new AgentRuntime({
|
|
268
289
|
providerRegistry,
|
|
269
290
|
memory,
|
|
270
|
-
telemetry: telemetryEngine
|
|
291
|
+
telemetry: telemetryEngine,
|
|
271
292
|
});
|
|
272
293
|
|
|
273
294
|
// Verify setup
|
|
@@ -278,13 +299,13 @@ console.log(`Runtime ready: ${runtime.isReady()}`);
|
|
|
278
299
|
|
|
279
300
|
```typescript
|
|
280
301
|
// Simple task execution
|
|
281
|
-
const result = await runtime.executeTask(
|
|
302
|
+
const result = await runtime.executeTask("Explain quantum computing briefly");
|
|
282
303
|
|
|
283
304
|
if (result.success) {
|
|
284
|
-
console.log(
|
|
285
|
-
console.log(
|
|
305
|
+
console.log("Output:", result.output);
|
|
306
|
+
console.log("Memory used:", result.memoryRetrievalUsed);
|
|
286
307
|
} else {
|
|
287
|
-
console.error(
|
|
308
|
+
console.error("Error:", result.error);
|
|
288
309
|
}
|
|
289
310
|
```
|
|
290
311
|
|
|
@@ -292,16 +313,19 @@ if (result.success) {
|
|
|
292
313
|
|
|
293
314
|
```typescript
|
|
294
315
|
// Task with memory context
|
|
295
|
-
const result = await runtime.executeTask(
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
316
|
+
const result = await runtime.executeTask(
|
|
317
|
+
"Continue the quantum computing explanation",
|
|
318
|
+
{
|
|
319
|
+
timeout: 30000,
|
|
320
|
+
memoryConfig: {
|
|
321
|
+
maxResults: 10, // Maximum context entries
|
|
322
|
+
minScore: 0.7, // Relevance threshold (0.0-1.0)
|
|
323
|
+
},
|
|
324
|
+
},
|
|
325
|
+
);
|
|
302
326
|
|
|
303
327
|
// Memory is automatically retrieved, injected, and persisted
|
|
304
|
-
console.log(
|
|
328
|
+
console.log("Previous context used:", result.memoryRetrievalUsed);
|
|
305
329
|
```
|
|
306
330
|
|
|
307
331
|
### 4. Working Memory for Multi-Step Tasks
|
|
@@ -311,45 +335,45 @@ console.log('Previous context used:', result.memoryRetrievalUsed);
|
|
|
311
335
|
const workingMemory = runtime.getWorkingMemory();
|
|
312
336
|
|
|
313
337
|
// Step 1: Research overview
|
|
314
|
-
workingMemory.set(
|
|
338
|
+
workingMemory.set("research-topic", "AI ethics");
|
|
315
339
|
const overviewResult = await runtime.executeTask(
|
|
316
|
-
|
|
340
|
+
"Provide overview of AI ethics and key considerations",
|
|
317
341
|
);
|
|
318
342
|
|
|
319
|
-
// Step 2: Deep dive (with context from step 1)
|
|
320
|
-
workingMemory.set(
|
|
343
|
+
// Step 2: Deep dive (with context from step 1)
|
|
344
|
+
workingMemory.set("overview-complete", overviewResult.output);
|
|
321
345
|
const deepDiveResult = await runtime.executeTask(
|
|
322
|
-
|
|
346
|
+
"Analyze specific ethical challenges in AI deployment",
|
|
323
347
|
);
|
|
324
348
|
|
|
325
|
-
console.log(
|
|
349
|
+
console.log("Working memory keys:", Array.from(workingMemory.keys()));
|
|
326
350
|
```
|
|
327
351
|
|
|
328
352
|
### 5. Hook System for Extensions
|
|
329
353
|
|
|
330
354
|
```typescript
|
|
331
355
|
// Add before-execution hook
|
|
332
|
-
runtime.addHook(
|
|
356
|
+
runtime.addHook("beforeExecute", async (task: string) => {
|
|
333
357
|
console.log(`🚀 Starting task: ${task}`);
|
|
334
|
-
|
|
358
|
+
|
|
335
359
|
// Custom validation
|
|
336
|
-
if (task.includes(
|
|
337
|
-
return { approved: false, reason:
|
|
360
|
+
if (task.includes("sensitive")) {
|
|
361
|
+
return { approved: false, reason: "Sensitive content detected" };
|
|
338
362
|
}
|
|
339
|
-
|
|
363
|
+
|
|
340
364
|
return { approved: true };
|
|
341
365
|
});
|
|
342
366
|
|
|
343
367
|
// Add after-execution hook
|
|
344
|
-
runtime.addHook(
|
|
345
|
-
console.log(`✅ Task completed: ${success ?
|
|
346
|
-
|
|
368
|
+
runtime.addHook("afterExecute", async (task, result, success) => {
|
|
369
|
+
console.log(`✅ Task completed: ${success ? "SUCCESS" : "FAILED"}`);
|
|
370
|
+
|
|
347
371
|
// Custom telemetry
|
|
348
372
|
if (success) {
|
|
349
373
|
await customAnalytics.track({
|
|
350
374
|
task: task.substring(0, 50),
|
|
351
375
|
duration: result.duration,
|
|
352
|
-
memoryUsed: result.memoryRetrievalUsed
|
|
376
|
+
memoryUsed: result.memoryRetrievalUsed,
|
|
353
377
|
});
|
|
354
378
|
}
|
|
355
379
|
});
|
|
@@ -362,16 +386,16 @@ runtime.addHook('afterExecute', async (task, result, success) => {
|
|
|
362
386
|
const runtime = new AgentRuntime({
|
|
363
387
|
providerRegistry: new ProviderRegistry(),
|
|
364
388
|
memory,
|
|
365
|
-
telemetry
|
|
389
|
+
telemetry,
|
|
366
390
|
});
|
|
367
391
|
|
|
368
392
|
// Providers automatically fallback: OpenAI → Anthropic → Ollama
|
|
369
|
-
const result = await runtime.executeTask(
|
|
393
|
+
const result = await runtime.executeTask("Analyze market trends");
|
|
370
394
|
|
|
371
395
|
// Check which provider was used
|
|
372
396
|
const events = await telemetryEngine.getEvents();
|
|
373
|
-
const lastExecution = events.filter(e => e.type ===
|
|
374
|
-
console.log(
|
|
397
|
+
const lastExecution = events.filter((e) => e.type === "start").pop();
|
|
398
|
+
console.log("Provider used:", lastExecution?.provider);
|
|
375
399
|
```
|
|
376
400
|
|
|
377
401
|
### 7. Telemetry Monitoring & Analysis
|
|
@@ -385,10 +409,12 @@ const events = await telemetry.getEvents();
|
|
|
385
409
|
console.log(`Total events: ${events.length}`);
|
|
386
410
|
|
|
387
411
|
// Filter memory events
|
|
388
|
-
const memoryEvents = events.filter(e => e.type ===
|
|
389
|
-
const hitRate =
|
|
390
|
-
|
|
391
|
-
|
|
412
|
+
const memoryEvents = events.filter((e) => e.type === "memory_retrieval");
|
|
413
|
+
const hitRate =
|
|
414
|
+
memoryEvents.length > 0
|
|
415
|
+
? memoryEvents.filter((e) => e.memoriesRelevant > 0).length /
|
|
416
|
+
memoryEvents.length
|
|
417
|
+
: 0;
|
|
392
418
|
console.log(`Memory hit rate: ${(hitRate * 100).toFixed(1)}%`);
|
|
393
419
|
```
|
|
394
420
|
|
|
@@ -417,18 +443,21 @@ npx @dcyfr/ai telemetry --export usage_data.csv
|
|
|
417
443
|
### 9. Provider Setup
|
|
418
444
|
|
|
419
445
|
**OpenAI:**
|
|
446
|
+
|
|
420
447
|
```bash
|
|
421
448
|
export OPENAI_API_KEY=sk-your-key-here
|
|
422
449
|
# Supports: gpt-4, gpt-4o, gpt-3.5-turbo
|
|
423
450
|
```
|
|
424
451
|
|
|
425
452
|
**Anthropic:**
|
|
453
|
+
|
|
426
454
|
```bash
|
|
427
|
-
export ANTHROPIC_API_KEY=sk-ant-your-key-here
|
|
455
|
+
export ANTHROPIC_API_KEY=sk-ant-your-key-here
|
|
428
456
|
# Supports: claude-3-5-sonnet, claude-3-haiku, claude-3-opus
|
|
429
457
|
```
|
|
430
458
|
|
|
431
459
|
**Ollama (Local):**
|
|
460
|
+
|
|
432
461
|
```bash
|
|
433
462
|
# Install Ollama
|
|
434
463
|
curl -fsSL https://ollama.ai/install.sh | sh
|
|
@@ -444,31 +473,33 @@ export OLLAMA_HOST=localhost:11434
|
|
|
444
473
|
### 10. Configuration Examples
|
|
445
474
|
|
|
446
475
|
**Development:**
|
|
476
|
+
|
|
447
477
|
```typescript
|
|
448
478
|
const devConfig = {
|
|
449
479
|
providerRegistry: new ProviderRegistry(),
|
|
450
|
-
memory: new DCYFRMemory({
|
|
451
|
-
storage:
|
|
452
|
-
maxEntries: 100
|
|
480
|
+
memory: new DCYFRMemory({
|
|
481
|
+
storage: "memory",
|
|
482
|
+
maxEntries: 100,
|
|
483
|
+
}),
|
|
484
|
+
telemetry: new TelemetryEngine({
|
|
485
|
+
storage: "memory", // No persistence for dev
|
|
453
486
|
}),
|
|
454
|
-
telemetry: new TelemetryEngine({
|
|
455
|
-
storage: 'memory' // No persistence for dev
|
|
456
|
-
})
|
|
457
487
|
};
|
|
458
488
|
```
|
|
459
489
|
|
|
460
490
|
**Production:**
|
|
461
|
-
|
|
491
|
+
|
|
492
|
+
```typescript
|
|
462
493
|
const prodConfig = {
|
|
463
494
|
providerRegistry: new ProviderRegistry(),
|
|
464
|
-
memory: new DCYFRMemory({
|
|
465
|
-
storage:
|
|
466
|
-
filePath:
|
|
495
|
+
memory: new DCYFRMemory({
|
|
496
|
+
storage: "file",
|
|
497
|
+
filePath: "./data/memory.json",
|
|
498
|
+
}),
|
|
499
|
+
telemetry: new TelemetryEngine({
|
|
500
|
+
storage: "sqlite",
|
|
501
|
+
dbPath: "./data/telemetry.db",
|
|
467
502
|
}),
|
|
468
|
-
telemetry: new TelemetryEngine({
|
|
469
|
-
storage: 'sqlite',
|
|
470
|
-
dbPath: './data/telemetry.db'
|
|
471
|
-
})
|
|
472
503
|
};
|
|
473
504
|
```
|
|
474
505
|
|
|
@@ -482,10 +513,11 @@ npm run demo -- --topic "quantum computing applications"
|
|
|
482
513
|
```
|
|
483
514
|
|
|
484
515
|
This example demonstrates:
|
|
516
|
+
|
|
485
517
|
- 5-step autonomous research pipeline
|
|
486
518
|
- Memory context integration
|
|
487
519
|
- Working memory coordination
|
|
488
|
-
- Hook system extensions
|
|
520
|
+
- Hook system extensions
|
|
489
521
|
- Telemetry monitoring
|
|
490
522
|
- Provider fallback handling
|
|
491
523
|
- Configuration management
|
|
@@ -499,41 +531,45 @@ Build agents that operate independently with persistent memory, scheduled execut
|
|
|
499
531
|
### Subpath Imports
|
|
500
532
|
|
|
501
533
|
```typescript
|
|
502
|
-
import {
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
import {
|
|
508
|
-
import {
|
|
534
|
+
import {
|
|
535
|
+
FileMemoryAdapter,
|
|
536
|
+
SQLiteIndex,
|
|
537
|
+
flushWorkingMemory,
|
|
538
|
+
} from "@dcyfr/ai/memory";
|
|
539
|
+
import { ContextCompactor, MemoryCompaction } from "@dcyfr/ai/compaction";
|
|
540
|
+
import { SkillRegistry } from "@dcyfr/ai/skills";
|
|
541
|
+
import { MCPToolBridge } from "@dcyfr/ai/mcp";
|
|
542
|
+
import { SessionManager } from "@dcyfr/ai/session";
|
|
543
|
+
import { AgentScheduler } from "@dcyfr/ai/scheduler";
|
|
544
|
+
import { MessageGateway, TelegramAdapter, CLIAdapter } from "@dcyfr/ai/gateway";
|
|
509
545
|
```
|
|
510
546
|
|
|
511
547
|
### Key Capabilities
|
|
512
548
|
|
|
513
|
-
| Module
|
|
514
|
-
|
|
515
|
-
| **File Memory**
|
|
516
|
-
| **Context Compaction** | LLM-powered pre-flush summarization to prevent context overflow
|
|
517
|
-
| **Skill Injection**
|
|
518
|
-
| **MCP Tool Bridge**
|
|
519
|
-
| **Session Management** | Trust-level tool policies (full/sandboxed/readonly), session lifecycle
|
|
520
|
-
| **Agent Scheduler**
|
|
521
|
-
| **Messaging Gateway**
|
|
522
|
-
| **Memory Compaction**
|
|
523
|
-
| **Working Memory**
|
|
549
|
+
| Module | Description |
|
|
550
|
+
| ---------------------- | ------------------------------------------------------------------------------------------ |
|
|
551
|
+
| **File Memory** | Markdown-based persistent memory with SHA-256 dedup and optional SQLite FTS5 hybrid search |
|
|
552
|
+
| **Context Compaction** | LLM-powered pre-flush summarization to prevent context overflow |
|
|
553
|
+
| **Skill Injection** | BM25-powered matching of `.md` skill files to inject relevant knowledge |
|
|
554
|
+
| **MCP Tool Bridge** | Bridges MCP server tool discovery → AgentRuntime tools |
|
|
555
|
+
| **Session Management** | Trust-level tool policies (full/sandboxed/readonly), session lifecycle |
|
|
556
|
+
| **Agent Scheduler** | Built-in cron parser, webhooks, event subscriptions, quiet hours |
|
|
557
|
+
| **Messaging Gateway** | Telegram/CLI/HTTP adapters, input sanitization, rate limiting |
|
|
558
|
+
| **Memory Compaction** | Cross-backend dedup, monthly conversation summarization, stale fact archival |
|
|
559
|
+
| **Working Memory** | Persist `Map<string, unknown>` as human-readable Markdown |
|
|
524
560
|
|
|
525
561
|
### Quick Example
|
|
526
562
|
|
|
527
563
|
```typescript
|
|
528
|
-
import { MessageGateway, TelegramAdapter } from
|
|
529
|
-
import { SessionManager } from
|
|
530
|
-
import { AgentScheduler } from
|
|
564
|
+
import { MessageGateway, TelegramAdapter } from "@dcyfr/ai/gateway";
|
|
565
|
+
import { SessionManager } from "@dcyfr/ai/session";
|
|
566
|
+
import { AgentScheduler } from "@dcyfr/ai/scheduler";
|
|
531
567
|
|
|
532
568
|
// Create a messaging gateway with platform adapters
|
|
533
569
|
const gateway = new MessageGateway({
|
|
534
570
|
adapters: [new TelegramAdapter({ sendFn: telegramBot.sendMessage })],
|
|
535
571
|
trustRules: [
|
|
536
|
-
{ name:
|
|
572
|
+
{ name: "admin", userIds: ["admin-id"], trustLevel: "full", priority: 10 },
|
|
537
573
|
],
|
|
538
574
|
});
|
|
539
575
|
|
|
@@ -541,7 +577,7 @@ const gateway = new MessageGateway({
|
|
|
541
577
|
const scheduler = new AgentScheduler({
|
|
542
578
|
executor: async (task) => runAgent(task),
|
|
543
579
|
});
|
|
544
|
-
scheduler.schedule(
|
|
580
|
+
scheduler.schedule("0 9 * * *", { name: "morning-report" });
|
|
545
581
|
scheduler.start();
|
|
546
582
|
```
|
|
547
583
|
|
|
@@ -591,6 +627,7 @@ graph TB
|
|
|
591
627
|
### File Formats
|
|
592
628
|
|
|
593
629
|
Supports multiple configuration formats (auto-detected):
|
|
630
|
+
|
|
594
631
|
- `.dcyfr.yaml` / `.dcyfr.yml` - YAML format (recommended)
|
|
595
632
|
- `.dcyfr.json` / `dcyfr.config.json` - JSON format
|
|
596
633
|
- `package.json` - Under `dcyfr` key
|
|
@@ -622,7 +659,7 @@ DCYFR comes with specialized validation agents:
|
|
|
622
659
|
|
|
623
660
|
- **Design Token Validator** - Enforces design system compliance
|
|
624
661
|
- **Barrel Export Checker** - Ensures import conventions
|
|
625
|
-
- **PageLayout Enforcer** - Validates layout usage patterns
|
|
662
|
+
- **PageLayout Enforcer** - Validates layout usage patterns
|
|
626
663
|
- **Test Data Guardian** - Prevents production data in tests
|
|
627
664
|
|
|
628
665
|
See `@dcyfr/agents` for specialized DCYFR agents.
|
|
@@ -630,13 +667,13 @@ See `@dcyfr/agents` for specialized DCYFR agents.
|
|
|
630
667
|
### Custom Plugins
|
|
631
668
|
|
|
632
669
|
```typescript
|
|
633
|
-
import { PluginLoader } from
|
|
670
|
+
import { PluginLoader } from "@dcyfr/ai";
|
|
634
671
|
|
|
635
672
|
const customPlugin = {
|
|
636
673
|
manifest: {
|
|
637
|
-
name:
|
|
638
|
-
version:
|
|
639
|
-
description:
|
|
674
|
+
name: "my-validator",
|
|
675
|
+
version: "1.0.0",
|
|
676
|
+
description: "Custom validation logic",
|
|
640
677
|
},
|
|
641
678
|
async onValidate(context) {
|
|
642
679
|
// Your validation logic
|
|
@@ -683,6 +720,9 @@ npx @dcyfr/ai help
|
|
|
683
720
|
## Examples
|
|
684
721
|
|
|
685
722
|
See [examples/](./examples/) directory:
|
|
723
|
+
|
|
724
|
+
- [Examples index](./examples/README.md) - prerequisites and run commands
|
|
725
|
+
|
|
686
726
|
- `basic-usage.ts` - Getting started
|
|
687
727
|
- `plugin-system.ts` - Plugin development
|
|
688
728
|
- `configuration.ts` - Configuration usage
|
|
@@ -699,6 +739,7 @@ See [examples/](./examples/) directory:
|
|
|
699
739
|
- [Quick Release Guide](./docs/RELEASE_QUICK_START.md) - TL;DR for releases
|
|
700
740
|
|
|
701
741
|
### Plugin Marketplace Security
|
|
742
|
+
|
|
702
743
|
- [GVISOR_SETUP.md](./docs/guides/GVISOR_SETUP.md) - gVisor runtime sandboxing for untrusted plugins
|
|
703
744
|
- [BEHAVIORAL_ANOMALY_DETECTION.md](./docs/guides/BEHAVIORAL_ANOMALY_DETECTION.md) - Behavioral anomaly detection system
|
|
704
745
|
- [CERTIFICATION_PROGRAM.md](./docs/guides/CERTIFICATION_PROGRAM.md) - Plugin Certification Program (Bronze/Silver/Gold tiers)
|
|
@@ -714,6 +755,7 @@ See [CONTRIBUTING.md](./CONTRIBUTING.md) for contribution guidelines.
|
|
|
714
755
|
We use [Changesets](https://github.com/changesets/changesets) for automated versioning and publishing.
|
|
715
756
|
|
|
716
757
|
**For contributors:**
|
|
758
|
+
|
|
717
759
|
```bash
|
|
718
760
|
# Add a changeset describing your changes
|
|
719
761
|
npm run changeset
|
|
@@ -724,6 +766,7 @@ git commit -m "feat: your feature"
|
|
|
724
766
|
```
|
|
725
767
|
|
|
726
768
|
**For maintainers:**
|
|
769
|
+
|
|
727
770
|
- Changesets automatically creates Release PRs
|
|
728
771
|
- Merging a Release PR publishes to npm
|
|
729
772
|
- See [Release Management](./docs/RELEASE_MANAGEMENT.md) for full details
|
|
@@ -737,11 +780,13 @@ git commit -m "feat: your feature"
|
|
|
737
780
|
### Installation Issues
|
|
738
781
|
|
|
739
782
|
**Issue: `npm install @dcyfr/ai` fails with 404**
|
|
783
|
+
|
|
740
784
|
- **Cause:** Package may not be published yet or npm registry issue
|
|
741
785
|
- **Solution:** Verify package exists: `npm view @dcyfr/ai`, or install from GitHub: `npm install git+https://github.com/dcyfr/dcyfr-ai.git`
|
|
742
786
|
- **Check:** Visit https://www.npmjs.com/package/@dcyfr/ai to confirm publication status
|
|
743
787
|
|
|
744
788
|
**Issue: "Cannot find module '@dcyfr/ai'"**
|
|
789
|
+
|
|
745
790
|
- **Cause:** Package not in `node_modules` or incorrect import path
|
|
746
791
|
- **Solution:** Run `npm install`, verify import: `import { loadConfig } from '@dcyfr/ai'`
|
|
747
792
|
- **TypeScript:** Ensure `moduleResolution: "bundler"` or `"node16"` in tsconfig.json
|
|
@@ -749,6 +794,7 @@ git commit -m "feat: your feature"
|
|
|
749
794
|
### Configuration Issues
|
|
750
795
|
|
|
751
796
|
**Issue: `.dcyfr.yaml` not detected**
|
|
797
|
+
|
|
752
798
|
- **Cause:** File in wrong location or invalid YAML syntax
|
|
753
799
|
- **Solution:**
|
|
754
800
|
1. Place `.dcyfr.yaml` in project root (same directory as package.json)
|
|
@@ -757,18 +803,21 @@ git commit -m "feat: your feature"
|
|
|
757
803
|
- **Alternative:** Use `.dcyfr.json` or add `dcyfr` key to `package.json`
|
|
758
804
|
|
|
759
805
|
**Issue: "Invalid configuration schema"**
|
|
806
|
+
|
|
760
807
|
- **Cause:** Missing required fields or incorrect types
|
|
761
808
|
- **Solution:**
|
|
762
809
|
1. Run `npx @dcyfr/ai config:schema` to see full schema
|
|
763
810
|
2. Ensure required fields present: `version`, `projectName`
|
|
764
811
|
3. Check types match (strings in quotes, booleans without quotes, arrays with brackets)
|
|
765
812
|
- **Example:** Valid config minimum:
|
|
813
|
+
|
|
766
814
|
```yaml
|
|
767
|
-
version:
|
|
815
|
+
version: "1.0.0"
|
|
768
816
|
projectName: my-app
|
|
769
817
|
```
|
|
770
818
|
|
|
771
819
|
**Issue: Environment variables not overriding config**
|
|
820
|
+
|
|
772
821
|
- **Cause:** Incorrect env var naming or precedence
|
|
773
822
|
- **Solution:** Use `DCYFR_` prefix with nested path: `DCYFR_AGENTS_DESIGNTOKENS_COMPLIANCE=0.95`
|
|
774
823
|
- **Format:** `DCYFR_<SECTION>_<SUBSECTION>_<KEY>=<value>` (uppercase, underscores)
|
|
@@ -777,6 +826,7 @@ projectName: my-app
|
|
|
777
826
|
### Plugin Issues
|
|
778
827
|
|
|
779
828
|
**Issue: Custom plugin not loading**
|
|
829
|
+
|
|
780
830
|
- **Cause:** Plugin doesn't implement required interface or missing manifest
|
|
781
831
|
- **Solution:** Ensure plugin exports:
|
|
782
832
|
1. `manifest` object with `name`, `version`, `description`
|
|
@@ -785,10 +835,12 @@ projectName: my-app
|
|
|
785
835
|
- **Example:** See [examples/plugin-system.ts](./examples/plugin-system.ts)
|
|
786
836
|
|
|
787
837
|
**Issue: Validation fails with "No plugins loaded"**
|
|
838
|
+
|
|
788
839
|
- **Cause:** Plugins not registered with PluginLoader before validation
|
|
789
840
|
- **Solution:**
|
|
841
|
+
|
|
790
842
|
```typescript
|
|
791
|
-
import { PluginLoader } from
|
|
843
|
+
import { PluginLoader } from "@dcyfr/ai";
|
|
792
844
|
const loader = new PluginLoader();
|
|
793
845
|
await loader.loadPlugin(myPlugin);
|
|
794
846
|
await loader.runValidation();
|
|
@@ -797,6 +849,7 @@ await loader.runValidation();
|
|
|
797
849
|
### CLI Issues
|
|
798
850
|
|
|
799
851
|
**Issue: `npx @dcyfr/ai` command not found**
|
|
852
|
+
|
|
800
853
|
- **Cause:** Package not installed or PATH issue
|
|
801
854
|
- **Solution:**
|
|
802
855
|
- Local: Add to devDependencies: `npm install --save-dev @dcyfr/ai`
|
|
@@ -804,6 +857,7 @@ await loader.runValidation();
|
|
|
804
857
|
- npx: Use full package name: `npx @dcyfr/ai@latest`
|
|
805
858
|
|
|
806
859
|
**Issue: CLI commands hang or timeout**
|
|
860
|
+
|
|
807
861
|
- **Cause:** Large project or slow file system operations
|
|
808
862
|
- **Solution:**
|
|
809
863
|
1. Use `--files` flag to target specific files: `npx @dcyfr/ai validate --files "src/**/*.ts"`
|
|
@@ -827,19 +881,21 @@ A: Yes, but TypeScript is strongly recommended for better type safety and IDE su
|
|
|
827
881
|
**Q: How do I create a custom validation plugin?**
|
|
828
882
|
|
|
829
883
|
A: Implement the `Plugin` interface with `manifest` and `onValidate` method:
|
|
884
|
+
|
|
830
885
|
```typescript
|
|
831
886
|
export const myPlugin = {
|
|
832
887
|
manifest: {
|
|
833
|
-
name:
|
|
834
|
-
version:
|
|
835
|
-
description:
|
|
888
|
+
name: "my-plugin",
|
|
889
|
+
version: "1.0.0",
|
|
890
|
+
description: "My custom validation",
|
|
836
891
|
},
|
|
837
892
|
async onValidate(context) {
|
|
838
893
|
// Your validation logic here
|
|
839
894
|
return { passed: true, issues: [] };
|
|
840
|
-
}
|
|
895
|
+
},
|
|
841
896
|
};
|
|
842
897
|
```
|
|
898
|
+
|
|
843
899
|
See [docs/plugins.md](./docs/plugins.md) and [examples/plugin-system.ts](./examples/plugin-system.ts) for complete guide.
|
|
844
900
|
|
|
845
901
|
**Q: What's the difference between @dcyfr/ai and @dcyfr/agents?**
|
|
@@ -849,6 +905,7 @@ A: `@dcyfr/ai` is the **public harness** (plugin architecture, config management
|
|
|
849
905
|
**Q: Can I use this with other AI providers (non-Claude)?**
|
|
850
906
|
|
|
851
907
|
A: Yes! The harness supports multi-provider integration including Claude, GitHub Copilot, Groq, Ollama, OpenAI, Anthropic. Configure providers in `.dcyfr.yaml`:
|
|
908
|
+
|
|
852
909
|
```yaml
|
|
853
910
|
providers:
|
|
854
911
|
- name: openai
|
|
@@ -860,12 +917,14 @@ providers:
|
|
|
860
917
|
**Q: How do I track telemetry and costs?**
|
|
861
918
|
|
|
862
919
|
A: Use the `TelemetryEngine` with storage adapters:
|
|
920
|
+
|
|
863
921
|
```typescript
|
|
864
|
-
import { TelemetryEngine, FileStorageAdapter } from
|
|
922
|
+
import { TelemetryEngine, FileStorageAdapter } from "@dcyfr/ai";
|
|
865
923
|
const telemetry = new TelemetryEngine({
|
|
866
|
-
storage: new FileStorageAdapter(
|
|
924
|
+
storage: new FileStorageAdapter("./telemetry"),
|
|
867
925
|
});
|
|
868
926
|
```
|
|
927
|
+
|
|
869
928
|
Telemetry tracks: API calls, token usage, costs, latency, quality scores.
|
|
870
929
|
|
|
871
930
|
**Q: Is this harness production-ready?**
|
|
@@ -879,21 +938,24 @@ A: Yes! @dcyfr/ai is used in production at dcyfr-labs and other projects. It has
|
|
|
879
938
|
## 📊 Performance Benchmarks
|
|
880
939
|
|
|
881
940
|
### Framework Performance
|
|
941
|
+
|
|
882
942
|
- **Config Loading:** ~10ms (cached), ~50ms (first load with file I/O)
|
|
883
943
|
- **Validation Framework:** Parallel execution 2-5x faster than serial (depends on plugin count)
|
|
884
944
|
- **Plugin System:** Minimal overhead ~5ms per plugin registration
|
|
885
|
-
- **Bundle Size:**
|
|
945
|
+
- **Bundle Size:** See [bundlephobia.com/@dcyfr/ai](https://bundlephobia.com/package/@dcyfr/ai) for current minzip size
|
|
886
946
|
|
|
887
947
|
### Recommended Usage Patterns
|
|
948
|
+
|
|
888
949
|
- **Use parallel validation** for independent checks (faster): `mode: 'parallel'`
|
|
889
950
|
- **Cache config loading** (use singleton pattern): Load once, reuse across app
|
|
890
951
|
- **Batch telemetry writes** (reduce I/O overhead): Buffer writes, flush periodically
|
|
891
952
|
- **Lazy load plugins** (faster startup): Only load plugins you need for current validation
|
|
892
953
|
|
|
893
954
|
### Comparison with Alternatives
|
|
955
|
+
|
|
894
956
|
- **vs. Custom Scripts:** 10-20x faster due to optimized plugin execution
|
|
895
957
|
- **vs. Serial Validation:** 2-5x faster with parallel execution mode
|
|
896
|
-
- **vs. LangChain:**
|
|
958
|
+
- **vs. LangChain:** Smaller bundle footprint ([bundlephobia](https://bundlephobia.com/package/@dcyfr/ai))
|
|
897
959
|
|
|
898
960
|
[⬆️ Back to top](#dcyfr-ai)
|
|
899
961
|
|
|
@@ -902,11 +964,14 @@ A: Yes! @dcyfr/ai is used in production at dcyfr-labs and other projects. It has
|
|
|
902
964
|
## 🔒 Security
|
|
903
965
|
|
|
904
966
|
### Reporting Vulnerabilities
|
|
967
|
+
|
|
905
968
|
Found a security issue? Report it privately:
|
|
969
|
+
|
|
906
970
|
- **GitHub Security Advisories:** [dcyfr-ai/security](https://github.com/dcyfr/dcyfr-ai/security/advisories/new)
|
|
907
971
|
- **Expected Response:** Within 48 hours
|
|
908
972
|
|
|
909
973
|
### Security Considerations
|
|
974
|
+
|
|
910
975
|
- **No API keys stored:** Use environment variables for sensitive data (Zod validates but doesn't store)
|
|
911
976
|
- **Zod validation:** All inputs validated with schemas before processing
|
|
912
977
|
- **No remote code execution:** Plugins run in local environment only (no sandboxing yet - see limitations)
|
|
@@ -914,6 +979,7 @@ Found a security issue? Report it privately:
|
|
|
914
979
|
- **Dependencies:** Regular Dependabot updates, npm audit on CI
|
|
915
980
|
|
|
916
981
|
### Best Practices
|
|
982
|
+
|
|
917
983
|
- Never commit `.env` files (use `.env.example`)
|
|
918
984
|
- Use environment variables for API keys: `${OPENAI_API_KEY}`
|
|
919
985
|
- Review plugin code before loading (plugins have full access to filesystem)
|
|
@@ -927,6 +993,7 @@ Found a security issue? Report it privately:
|
|
|
927
993
|
## ⚙️ Known Limitations
|
|
928
994
|
|
|
929
995
|
### Current Constraints
|
|
996
|
+
|
|
930
997
|
- **Plugin isolation:** Plugins run in same process (no sandboxing yet) - trust plugin code before loading
|
|
931
998
|
- **File-based telemetry only:** No database storage adapter yet (planned for v2.0)
|
|
932
999
|
- **Config caching:** Requires manual cache invalidation on config changes (no hot-reload yet)
|
|
@@ -934,11 +1001,13 @@ Found a security issue? Report it privately:
|
|
|
934
1001
|
- **TypeScript required for development:** JavaScript works at runtime but TypeScript recommended for development
|
|
935
1002
|
|
|
936
1003
|
### Platform-Specific Issues
|
|
1004
|
+
|
|
937
1005
|
- **Windows:** Path separators handled automatically but some plugins may have issues
|
|
938
1006
|
- **Node.js version:** Requires ≥24.13.0 (uses native fetch, modern APIs)
|
|
939
1007
|
- **ESM-only:** Package is ESM (ECMAScript Modules) - CommonJS require() not supported
|
|
940
1008
|
|
|
941
1009
|
### Planned Improvements
|
|
1010
|
+
|
|
942
1011
|
- [ ] Database storage adapter for telemetry (PostgreSQL, SQLite)
|
|
943
1012
|
- [ ] Plugin sandboxing for security (worker threads or VM isolation)
|
|
944
1013
|
- [ ] Hot-reload config watching (auto-reload on file changes)
|
|
@@ -959,10 +1028,12 @@ See [GitHub Issues](https://github.com/dcyfr/dcyfr-ai/issues) for tracked featur
|
|
|
959
1028
|
### Commercial Use
|
|
960
1029
|
|
|
961
1030
|
This package is dual-licensed:
|
|
1031
|
+
|
|
962
1032
|
- **MIT License** for personal, educational, and non-commercial use (free)
|
|
963
1033
|
- **Commercial License** for business and revenue-generating use (paid)
|
|
964
1034
|
|
|
965
1035
|
**Commercial use includes:**
|
|
1036
|
+
|
|
966
1037
|
- Using @dcyfr/ai in SaaS products or revenue-generating services
|
|
967
1038
|
- Deploying in companies with >5 employees
|
|
968
1039
|
- Providing paid consulting/services using @dcyfr/ai
|