confused-ai-core 0.1.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/FEATURES.md +169 -0
- package/package.json +119 -0
- package/src/agent.ts +187 -0
- package/src/agentic/index.ts +87 -0
- package/src/agentic/runner.ts +386 -0
- package/src/agentic/types.ts +91 -0
- package/src/artifacts/artifact.ts +417 -0
- package/src/artifacts/index.ts +42 -0
- package/src/artifacts/media.ts +304 -0
- package/src/cli/index.ts +122 -0
- package/src/core/base-agent.ts +151 -0
- package/src/core/context-builder.ts +106 -0
- package/src/core/index.ts +8 -0
- package/src/core/schemas.ts +17 -0
- package/src/core/types.ts +158 -0
- package/src/create-agent.ts +309 -0
- package/src/debug-logger.ts +188 -0
- package/src/dx/agent.ts +88 -0
- package/src/dx/define-agent.ts +183 -0
- package/src/dx/dev-logger.ts +57 -0
- package/src/dx/index.ts +11 -0
- package/src/errors.ts +175 -0
- package/src/execution/engine.ts +522 -0
- package/src/execution/graph-builder.ts +362 -0
- package/src/execution/index.ts +8 -0
- package/src/execution/types.ts +257 -0
- package/src/execution/worker-pool.ts +308 -0
- package/src/extensions/index.ts +123 -0
- package/src/guardrails/allowlist.ts +155 -0
- package/src/guardrails/index.ts +17 -0
- package/src/guardrails/types.ts +159 -0
- package/src/guardrails/validator.ts +265 -0
- package/src/index.ts +74 -0
- package/src/knowledge/index.ts +5 -0
- package/src/knowledge/types.ts +52 -0
- package/src/learning/in-memory-store.ts +72 -0
- package/src/learning/index.ts +6 -0
- package/src/learning/types.ts +42 -0
- package/src/llm/cache.ts +300 -0
- package/src/llm/index.ts +22 -0
- package/src/llm/model-resolver.ts +81 -0
- package/src/llm/openai-provider.ts +313 -0
- package/src/llm/openrouter-provider.ts +29 -0
- package/src/llm/types.ts +131 -0
- package/src/memory/in-memory-store.ts +255 -0
- package/src/memory/index.ts +7 -0
- package/src/memory/types.ts +193 -0
- package/src/memory/vector-store.ts +251 -0
- package/src/observability/console-logger.ts +123 -0
- package/src/observability/index.ts +12 -0
- package/src/observability/metrics.ts +85 -0
- package/src/observability/otlp-exporter.ts +417 -0
- package/src/observability/tracer.ts +105 -0
- package/src/observability/types.ts +341 -0
- package/src/orchestration/agent-adapter.ts +33 -0
- package/src/orchestration/index.ts +34 -0
- package/src/orchestration/load-balancer.ts +151 -0
- package/src/orchestration/mcp-types.ts +59 -0
- package/src/orchestration/message-bus.ts +192 -0
- package/src/orchestration/orchestrator.ts +349 -0
- package/src/orchestration/pipeline.ts +66 -0
- package/src/orchestration/supervisor.ts +107 -0
- package/src/orchestration/swarm.ts +1099 -0
- package/src/orchestration/toolkit.ts +47 -0
- package/src/orchestration/types.ts +339 -0
- package/src/planner/classical-planner.ts +383 -0
- package/src/planner/index.ts +8 -0
- package/src/planner/llm-planner.ts +353 -0
- package/src/planner/types.ts +227 -0
- package/src/planner/validator.ts +297 -0
- package/src/production/circuit-breaker.ts +290 -0
- package/src/production/graceful-shutdown.ts +251 -0
- package/src/production/health.ts +333 -0
- package/src/production/index.ts +57 -0
- package/src/production/latency-eval.ts +62 -0
- package/src/production/rate-limiter.ts +287 -0
- package/src/production/resumable-stream.ts +289 -0
- package/src/production/types.ts +81 -0
- package/src/sdk/index.ts +374 -0
- package/src/session/db-driver.ts +50 -0
- package/src/session/in-memory-store.ts +235 -0
- package/src/session/index.ts +12 -0
- package/src/session/sql-store.ts +315 -0
- package/src/session/sqlite-store.ts +61 -0
- package/src/session/types.ts +153 -0
- package/src/tools/base-tool.ts +223 -0
- package/src/tools/browser-tool.ts +123 -0
- package/src/tools/calculator-tool.ts +265 -0
- package/src/tools/file-tools.ts +394 -0
- package/src/tools/github-tool.ts +432 -0
- package/src/tools/hackernews-tool.ts +187 -0
- package/src/tools/http-tool.ts +118 -0
- package/src/tools/index.ts +99 -0
- package/src/tools/jira-tool.ts +373 -0
- package/src/tools/notion-tool.ts +322 -0
- package/src/tools/openai-tool.ts +236 -0
- package/src/tools/registry.ts +131 -0
- package/src/tools/serpapi-tool.ts +234 -0
- package/src/tools/shell-tool.ts +118 -0
- package/src/tools/slack-tool.ts +327 -0
- package/src/tools/telegram-tool.ts +127 -0
- package/src/tools/types.ts +229 -0
- package/src/tools/websearch-tool.ts +335 -0
- package/src/tools/wikipedia-tool.ts +177 -0
- package/src/tools/yfinance-tool.ts +33 -0
- package/src/voice/index.ts +17 -0
- package/src/voice/voice-provider.ts +228 -0
- package/tests/artifact.test.ts +241 -0
- package/tests/circuit-breaker.test.ts +171 -0
- package/tests/health.test.ts +192 -0
- package/tests/llm-cache.test.ts +186 -0
- package/tests/rate-limiter.test.ts +161 -0
- package/tsconfig.json +29 -0
- package/vitest.config.ts +47 -0
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Artifact System - Agno-Style Structured Outputs and Storage
|
|
3
|
+
*
|
|
4
|
+
* Implements production-grade artifact management:
|
|
5
|
+
* - Typed artifacts (files, images, audio, code, data)
|
|
6
|
+
* - Versioned storage with metadata
|
|
7
|
+
* - Agent-produced outputs that persist across sessions
|
|
8
|
+
* - Media artifact support (images, audio, video)
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { MetricsCollector } from '../observability/types.js';
|
|
12
|
+
|
|
13
|
+
/** Artifact types following Agno patterns */
|
|
14
|
+
export type ArtifactType =
|
|
15
|
+
| 'file'
|
|
16
|
+
| 'image'
|
|
17
|
+
| 'audio'
|
|
18
|
+
| 'video'
|
|
19
|
+
| 'code'
|
|
20
|
+
| 'data'
|
|
21
|
+
| 'document'
|
|
22
|
+
| 'markdown'
|
|
23
|
+
| 'json'
|
|
24
|
+
| 'reasoning'
|
|
25
|
+
| 'plan'
|
|
26
|
+
| 'report';
|
|
27
|
+
|
|
28
|
+
/** Base artifact metadata */
|
|
29
|
+
export interface ArtifactMetadata {
|
|
30
|
+
/** Unique artifact ID */
|
|
31
|
+
readonly id: string;
|
|
32
|
+
/** Human-readable name */
|
|
33
|
+
readonly name: string;
|
|
34
|
+
/** Artifact type */
|
|
35
|
+
readonly type: ArtifactType;
|
|
36
|
+
/** MIME type (e.g., image/png) */
|
|
37
|
+
readonly mimeType?: string;
|
|
38
|
+
/** Size in bytes */
|
|
39
|
+
readonly sizeBytes?: number;
|
|
40
|
+
/** Creation timestamp */
|
|
41
|
+
readonly createdAt: Date;
|
|
42
|
+
/** Last modified timestamp */
|
|
43
|
+
readonly updatedAt: Date;
|
|
44
|
+
/** Version number (for versioning) */
|
|
45
|
+
readonly version: number;
|
|
46
|
+
/** Tags for categorization */
|
|
47
|
+
readonly tags?: string[];
|
|
48
|
+
/** Custom metadata */
|
|
49
|
+
readonly metadata?: Record<string, unknown>;
|
|
50
|
+
/** Agent that created this artifact */
|
|
51
|
+
readonly createdBy?: string;
|
|
52
|
+
/** Session ID when created */
|
|
53
|
+
readonly sessionId?: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Full artifact with content */
|
|
57
|
+
export interface Artifact<T = unknown> extends ArtifactMetadata {
|
|
58
|
+
/** Artifact content (type depends on artifact type) */
|
|
59
|
+
readonly content: T;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Text-based artifact */
|
|
63
|
+
export interface TextArtifact extends Artifact<string> {
|
|
64
|
+
type: 'file' | 'code' | 'markdown' | 'document';
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** JSON data artifact */
|
|
68
|
+
export interface DataArtifact<T = Record<string, unknown>> extends Artifact<T> {
|
|
69
|
+
type: 'data' | 'json';
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Binary artifact (images, audio, video) */
|
|
73
|
+
export interface BinaryArtifact extends Artifact<Uint8Array | ArrayBuffer | string> {
|
|
74
|
+
type: 'image' | 'audio' | 'video';
|
|
75
|
+
/** URL if stored externally */
|
|
76
|
+
readonly url?: string;
|
|
77
|
+
/** Base64 encoded if inline */
|
|
78
|
+
readonly base64?: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Reasoning artifact (agent thought process) */
|
|
82
|
+
export interface ReasoningArtifact extends Artifact<{
|
|
83
|
+
thoughts: string[];
|
|
84
|
+
conclusion: string;
|
|
85
|
+
confidence: number;
|
|
86
|
+
}> {
|
|
87
|
+
type: 'reasoning';
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Plan artifact (agent action plan) */
|
|
91
|
+
export interface PlanArtifact extends Artifact<{
|
|
92
|
+
goal: string;
|
|
93
|
+
steps: Array<{
|
|
94
|
+
id: string;
|
|
95
|
+
description: string;
|
|
96
|
+
status: 'pending' | 'in_progress' | 'completed' | 'failed';
|
|
97
|
+
result?: string;
|
|
98
|
+
}>;
|
|
99
|
+
status: 'draft' | 'executing' | 'completed' | 'failed';
|
|
100
|
+
}> {
|
|
101
|
+
type: 'plan';
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Report artifact */
|
|
105
|
+
export interface ReportArtifact extends Artifact<{
|
|
106
|
+
title: string;
|
|
107
|
+
sections: Array<{
|
|
108
|
+
heading: string;
|
|
109
|
+
content: string;
|
|
110
|
+
}>;
|
|
111
|
+
summary?: string;
|
|
112
|
+
}> {
|
|
113
|
+
type: 'report';
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// --- Artifact Storage ---
|
|
117
|
+
|
|
118
|
+
/** Storage configuration */
|
|
119
|
+
export interface ArtifactStorageConfig {
|
|
120
|
+
/** Base path for file storage */
|
|
121
|
+
readonly basePath?: string;
|
|
122
|
+
/** Maximum artifact size in bytes (default: 100MB) */
|
|
123
|
+
readonly maxSizeBytes?: number;
|
|
124
|
+
/** Enable versioning (default: true) */
|
|
125
|
+
readonly versioning?: boolean;
|
|
126
|
+
/** TTL for artifacts in ms (default: no expiration) */
|
|
127
|
+
readonly ttlMs?: number;
|
|
128
|
+
/** Metrics collector */
|
|
129
|
+
readonly metrics?: MetricsCollector;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** Artifact storage interface */
|
|
133
|
+
export interface ArtifactStorage {
|
|
134
|
+
/** Save an artifact */
|
|
135
|
+
save<T>(artifact: Omit<Artifact<T>, 'id' | 'createdAt' | 'updatedAt' | 'version'>): Promise<Artifact<T>>;
|
|
136
|
+
|
|
137
|
+
/** Get an artifact by ID */
|
|
138
|
+
get<T>(id: string): Promise<Artifact<T> | null>;
|
|
139
|
+
|
|
140
|
+
/** Get a specific version of an artifact */
|
|
141
|
+
getVersion<T>(id: string, version: number): Promise<Artifact<T> | null>;
|
|
142
|
+
|
|
143
|
+
/** List all versions of an artifact */
|
|
144
|
+
listVersions(id: string): Promise<ArtifactMetadata[]>;
|
|
145
|
+
|
|
146
|
+
/** Update an artifact (creates new version) */
|
|
147
|
+
update<T>(id: string, updates: Partial<Omit<Artifact<T>, 'id' | 'createdAt' | 'version'>>): Promise<Artifact<T>>;
|
|
148
|
+
|
|
149
|
+
/** Delete an artifact (all versions) */
|
|
150
|
+
delete(id: string): Promise<boolean>;
|
|
151
|
+
|
|
152
|
+
/** List artifacts with optional filters */
|
|
153
|
+
list(filters?: {
|
|
154
|
+
type?: ArtifactType;
|
|
155
|
+
tags?: string[];
|
|
156
|
+
createdBy?: string;
|
|
157
|
+
sessionId?: string;
|
|
158
|
+
limit?: number;
|
|
159
|
+
offset?: number;
|
|
160
|
+
}): Promise<ArtifactMetadata[]>;
|
|
161
|
+
|
|
162
|
+
/** Search artifacts by name or content */
|
|
163
|
+
search(query: string, limit?: number): Promise<ArtifactMetadata[]>;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* In-Memory Artifact Storage - for development and testing.
|
|
168
|
+
*/
|
|
169
|
+
export class InMemoryArtifactStorage implements ArtifactStorage {
|
|
170
|
+
private readonly artifacts = new Map<string, Artifact<unknown>[]>();
|
|
171
|
+
private readonly config: Required<Omit<ArtifactStorageConfig, 'metrics' | 'basePath'>> &
|
|
172
|
+
Pick<ArtifactStorageConfig, 'metrics' | 'basePath'>;
|
|
173
|
+
|
|
174
|
+
constructor(config: ArtifactStorageConfig = {}) {
|
|
175
|
+
this.config = {
|
|
176
|
+
basePath: config.basePath,
|
|
177
|
+
maxSizeBytes: config.maxSizeBytes ?? 100 * 1024 * 1024, // 100MB
|
|
178
|
+
versioning: config.versioning ?? true,
|
|
179
|
+
ttlMs: config.ttlMs ?? 0,
|
|
180
|
+
metrics: config.metrics,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
async save<T>(artifact: Omit<Artifact<T>, 'id' | 'createdAt' | 'updatedAt' | 'version'>): Promise<Artifact<T>> {
|
|
185
|
+
const id = this.generateId();
|
|
186
|
+
const now = new Date();
|
|
187
|
+
|
|
188
|
+
const fullArtifact: Artifact<T> = {
|
|
189
|
+
...artifact,
|
|
190
|
+
id,
|
|
191
|
+
createdAt: now,
|
|
192
|
+
updatedAt: now,
|
|
193
|
+
version: 1,
|
|
194
|
+
} as Artifact<T>;
|
|
195
|
+
|
|
196
|
+
this.artifacts.set(id, [fullArtifact as Artifact<unknown>]);
|
|
197
|
+
this.recordMetric('artifact_saved', 1);
|
|
198
|
+
|
|
199
|
+
return fullArtifact;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
async get<T>(id: string): Promise<Artifact<T> | null> {
|
|
203
|
+
const versions = this.artifacts.get(id);
|
|
204
|
+
if (!versions || versions.length === 0) {
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// Return latest version
|
|
209
|
+
return versions[versions.length - 1] as Artifact<T>;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
async getVersion<T>(id: string, version: number): Promise<Artifact<T> | null> {
|
|
213
|
+
const versions = this.artifacts.get(id);
|
|
214
|
+
if (!versions) return null;
|
|
215
|
+
|
|
216
|
+
const artifact = versions.find(v => v.version === version);
|
|
217
|
+
return artifact as Artifact<T> | null;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
async listVersions(id: string): Promise<ArtifactMetadata[]> {
|
|
221
|
+
const versions = this.artifacts.get(id);
|
|
222
|
+
if (!versions) return [];
|
|
223
|
+
|
|
224
|
+
return versions.map(({ content, ...meta }) => meta);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
async update<T>(
|
|
228
|
+
id: string,
|
|
229
|
+
updates: Partial<Omit<Artifact<T>, 'id' | 'createdAt' | 'version'>>
|
|
230
|
+
): Promise<Artifact<T>> {
|
|
231
|
+
const current = await this.get<T>(id);
|
|
232
|
+
if (!current) {
|
|
233
|
+
throw new Error(`Artifact not found: ${id}`);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const newVersion: Artifact<T> = {
|
|
237
|
+
...current,
|
|
238
|
+
...updates,
|
|
239
|
+
updatedAt: new Date(),
|
|
240
|
+
version: current.version + 1,
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
if (this.config.versioning) {
|
|
244
|
+
this.artifacts.get(id)!.push(newVersion as Artifact<unknown>);
|
|
245
|
+
} else {
|
|
246
|
+
this.artifacts.set(id, [newVersion as Artifact<unknown>]);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
this.recordMetric('artifact_updated', 1);
|
|
250
|
+
return newVersion;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
async delete(id: string): Promise<boolean> {
|
|
254
|
+
const deleted = this.artifacts.delete(id);
|
|
255
|
+
if (deleted) {
|
|
256
|
+
this.recordMetric('artifact_deleted', 1);
|
|
257
|
+
}
|
|
258
|
+
return deleted;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
async list(filters?: {
|
|
262
|
+
type?: ArtifactType;
|
|
263
|
+
tags?: string[];
|
|
264
|
+
createdBy?: string;
|
|
265
|
+
sessionId?: string;
|
|
266
|
+
limit?: number;
|
|
267
|
+
offset?: number;
|
|
268
|
+
}): Promise<ArtifactMetadata[]> {
|
|
269
|
+
const allArtifacts: ArtifactMetadata[] = [];
|
|
270
|
+
|
|
271
|
+
for (const versions of this.artifacts.values()) {
|
|
272
|
+
const latest = versions[versions.length - 1];
|
|
273
|
+
const { content, ...meta } = latest;
|
|
274
|
+
allArtifacts.push(meta);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
let filtered = allArtifacts;
|
|
278
|
+
|
|
279
|
+
if (filters?.type) {
|
|
280
|
+
filtered = filtered.filter(a => a.type === filters.type);
|
|
281
|
+
}
|
|
282
|
+
if (filters?.tags?.length) {
|
|
283
|
+
filtered = filtered.filter(a =>
|
|
284
|
+
filters.tags!.some(tag => a.tags?.includes(tag))
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
if (filters?.createdBy) {
|
|
288
|
+
filtered = filtered.filter(a => a.createdBy === filters.createdBy);
|
|
289
|
+
}
|
|
290
|
+
if (filters?.sessionId) {
|
|
291
|
+
filtered = filtered.filter(a => a.sessionId === filters.sessionId);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
const offset = filters?.offset ?? 0;
|
|
295
|
+
const limit = filters?.limit ?? filtered.length;
|
|
296
|
+
|
|
297
|
+
return filtered.slice(offset, offset + limit);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
async search(query: string, limit = 10): Promise<ArtifactMetadata[]> {
|
|
301
|
+
const results: ArtifactMetadata[] = [];
|
|
302
|
+
const lowerQuery = query.toLowerCase();
|
|
303
|
+
|
|
304
|
+
for (const versions of this.artifacts.values()) {
|
|
305
|
+
const latest = versions[versions.length - 1];
|
|
306
|
+
if (latest.name.toLowerCase().includes(lowerQuery)) {
|
|
307
|
+
const { content, ...meta } = latest;
|
|
308
|
+
results.push(meta);
|
|
309
|
+
}
|
|
310
|
+
if (results.length >= limit) break;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
return results;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// --- Private ---
|
|
317
|
+
|
|
318
|
+
private generateId(): string {
|
|
319
|
+
return `art_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
private recordMetric(name: string, value: number): void {
|
|
323
|
+
this.config.metrics?.counter(`artifact.${name}`, value);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// --- Helper Functions ---
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Create a text artifact
|
|
331
|
+
*/
|
|
332
|
+
export function createTextArtifact(
|
|
333
|
+
name: string,
|
|
334
|
+
content: string,
|
|
335
|
+
options?: Partial<Omit<TextArtifact, 'id' | 'createdAt' | 'updatedAt' | 'version' | 'content' | 'name'>>
|
|
336
|
+
): Omit<TextArtifact, 'id' | 'createdAt' | 'updatedAt' | 'version'> {
|
|
337
|
+
return {
|
|
338
|
+
name,
|
|
339
|
+
type: options?.type ?? 'file',
|
|
340
|
+
content,
|
|
341
|
+
mimeType: options?.mimeType ?? 'text/plain',
|
|
342
|
+
...options,
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Create a markdown artifact
|
|
348
|
+
*/
|
|
349
|
+
export function createMarkdownArtifact(
|
|
350
|
+
name: string,
|
|
351
|
+
content: string,
|
|
352
|
+
tags?: string[]
|
|
353
|
+
): Omit<TextArtifact, 'id' | 'createdAt' | 'updatedAt' | 'version'> {
|
|
354
|
+
return {
|
|
355
|
+
name,
|
|
356
|
+
type: 'markdown',
|
|
357
|
+
content,
|
|
358
|
+
mimeType: 'text/markdown',
|
|
359
|
+
tags,
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Create a JSON data artifact
|
|
365
|
+
*/
|
|
366
|
+
export function createDataArtifact<T extends Record<string, unknown>>(
|
|
367
|
+
name: string,
|
|
368
|
+
data: T,
|
|
369
|
+
tags?: string[]
|
|
370
|
+
): Omit<DataArtifact<T>, 'id' | 'createdAt' | 'updatedAt' | 'version'> {
|
|
371
|
+
return {
|
|
372
|
+
name,
|
|
373
|
+
type: 'data',
|
|
374
|
+
content: data,
|
|
375
|
+
mimeType: 'application/json',
|
|
376
|
+
tags,
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Create a reasoning artifact
|
|
382
|
+
*/
|
|
383
|
+
export function createReasoningArtifact(
|
|
384
|
+
name: string,
|
|
385
|
+
thoughts: string[],
|
|
386
|
+
conclusion: string,
|
|
387
|
+
confidence: number
|
|
388
|
+
): Omit<ReasoningArtifact, 'id' | 'createdAt' | 'updatedAt' | 'version'> {
|
|
389
|
+
return {
|
|
390
|
+
name,
|
|
391
|
+
type: 'reasoning',
|
|
392
|
+
content: { thoughts, conclusion, confidence },
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Create a plan artifact
|
|
398
|
+
*/
|
|
399
|
+
export function createPlanArtifact(
|
|
400
|
+
name: string,
|
|
401
|
+
goal: string,
|
|
402
|
+
steps: Array<{ description: string }>
|
|
403
|
+
): Omit<PlanArtifact, 'id' | 'createdAt' | 'updatedAt' | 'version'> {
|
|
404
|
+
return {
|
|
405
|
+
name,
|
|
406
|
+
type: 'plan',
|
|
407
|
+
content: {
|
|
408
|
+
goal,
|
|
409
|
+
steps: steps.map((s, i) => ({
|
|
410
|
+
id: `step_${i + 1}`,
|
|
411
|
+
description: s.description,
|
|
412
|
+
status: 'pending' as const,
|
|
413
|
+
})),
|
|
414
|
+
status: 'draft',
|
|
415
|
+
},
|
|
416
|
+
};
|
|
417
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Artifact Module Exports - Agno-Style Artifact System
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// Core artifacts
|
|
6
|
+
export {
|
|
7
|
+
InMemoryArtifactStorage,
|
|
8
|
+
createTextArtifact,
|
|
9
|
+
createMarkdownArtifact,
|
|
10
|
+
createDataArtifact,
|
|
11
|
+
createReasoningArtifact,
|
|
12
|
+
createPlanArtifact,
|
|
13
|
+
} from './artifact.js';
|
|
14
|
+
|
|
15
|
+
export type {
|
|
16
|
+
ArtifactType,
|
|
17
|
+
ArtifactMetadata,
|
|
18
|
+
Artifact,
|
|
19
|
+
TextArtifact,
|
|
20
|
+
DataArtifact,
|
|
21
|
+
BinaryArtifact,
|
|
22
|
+
ReasoningArtifact,
|
|
23
|
+
PlanArtifact,
|
|
24
|
+
ReportArtifact,
|
|
25
|
+
ArtifactStorage,
|
|
26
|
+
ArtifactStorageConfig,
|
|
27
|
+
} from './artifact.js';
|
|
28
|
+
|
|
29
|
+
// Media artifacts
|
|
30
|
+
export {
|
|
31
|
+
MediaManager,
|
|
32
|
+
createImageFromUrl,
|
|
33
|
+
createImageFromBase64,
|
|
34
|
+
createAudioFromUrl,
|
|
35
|
+
createVideoFromUrl,
|
|
36
|
+
} from './media.js';
|
|
37
|
+
|
|
38
|
+
export type {
|
|
39
|
+
ImageArtifact,
|
|
40
|
+
AudioArtifact,
|
|
41
|
+
VideoArtifact,
|
|
42
|
+
} from './media.js';
|