@snap-agent/core 0.1.4 → 0.1.5

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.
Files changed (35) hide show
  1. package/dist/chunk-4NN3ADDP.mjs +0 -0
  2. package/dist/chunk-52OS4FTG.mjs +382 -0
  3. package/dist/chunk-5BAE6S5E.js +382 -0
  4. package/dist/chunk-BSSVNLSO.mjs +157 -0
  5. package/dist/chunk-DKNHIS7Z.js +2227 -0
  6. package/dist/chunk-DQRG2GHR.js +157 -0
  7. package/dist/chunk-GHRDUPHS.js +1 -0
  8. package/dist/chunk-JQK3HEJ5.mjs +268 -0
  9. package/dist/chunk-JRIKISMX.js +268 -0
  10. package/dist/dist-GSDAIZQP.js +1825 -0
  11. package/dist/dist-HTV3MRC3.js +3216 -0
  12. package/dist/{index-m2vDW79n.d.mts → index-Ek8b39d1.d.mts} +1 -173
  13. package/dist/{index-m2vDW79n.d.ts → index-Ek8b39d1.d.ts} +1 -173
  14. package/dist/index.d.mts +5 -2
  15. package/dist/index.d.ts +5 -2
  16. package/dist/index.js +1270 -9400
  17. package/dist/index.mjs +8 -3
  18. package/dist/storage/MemoryStorage.d.mts +46 -0
  19. package/dist/storage/MemoryStorage.d.ts +46 -0
  20. package/dist/storage/MemoryStorage.js +6 -0
  21. package/dist/storage/MemoryStorage.mjs +6 -0
  22. package/dist/storage/MongoDBStorage.d.mts +44 -0
  23. package/dist/storage/MongoDBStorage.d.ts +44 -0
  24. package/dist/storage/MongoDBStorage.js +6 -0
  25. package/dist/storage/MongoDBStorage.mjs +6 -0
  26. package/dist/storage/UpstashStorage.d.mts +91 -0
  27. package/dist/storage/UpstashStorage.d.ts +91 -0
  28. package/dist/storage/UpstashStorage.js +6 -0
  29. package/dist/storage/UpstashStorage.mjs +6 -0
  30. package/dist/storage/index.d.mts +4 -1
  31. package/dist/storage/index.d.ts +4 -1
  32. package/dist/storage/index.js +11 -827
  33. package/dist/storage/index.mjs +8 -3
  34. package/package.json +18 -3
  35. package/dist/chunk-FS7G3ID4.mjs +0 -803
package/dist/index.mjs CHANGED
@@ -1,8 +1,13 @@
1
+ import "./chunk-4NN3ADDP.mjs";
2
+ import {
3
+ MemoryStorage
4
+ } from "./chunk-BSSVNLSO.mjs";
5
+ import {
6
+ MongoDBStorage
7
+ } from "./chunk-JQK3HEJ5.mjs";
1
8
  import {
2
- MemoryStorage,
3
- MongoDBStorage,
4
9
  UpstashStorage
5
- } from "./chunk-FS7G3ID4.mjs";
10
+ } from "./chunk-52OS4FTG.mjs";
6
11
 
7
12
  // src/core/Agent.ts
8
13
  import { generateText, streamText, Output } from "ai";
@@ -0,0 +1,46 @@
1
+ import { S as StorageAdapter, A as AgentConfig, a as AgentData, T as ThreadConfig, b as ThreadData, M as MessageRole, c as MessageAttachment, d as MessageData } from '../index-Ek8b39d1.mjs';
2
+
3
+ /**
4
+ * In-Memory Storage Adapter
5
+ * Provides temporary storage for agents and threads (useful for testing and development)
6
+ */
7
+ declare class MemoryStorage implements StorageAdapter {
8
+ private agents;
9
+ private threads;
10
+ private idCounter;
11
+ private generateId;
12
+ createAgent(config: AgentConfig): Promise<string>;
13
+ getAgent(agentId: string): Promise<AgentData | null>;
14
+ updateAgent(agentId: string, updates: Partial<AgentConfig>): Promise<void>;
15
+ deleteAgent(agentId: string): Promise<void>;
16
+ listAgents(userId: string, organizationId?: string): Promise<AgentData[]>;
17
+ createThread(config: ThreadConfig): Promise<string>;
18
+ getThread(threadId: string): Promise<ThreadData | null>;
19
+ updateThread(threadId: string, updates: Partial<ThreadConfig>): Promise<void>;
20
+ deleteThread(threadId: string): Promise<void>;
21
+ listThreads(filters: {
22
+ userId?: string;
23
+ agentId?: string;
24
+ organizationId?: string;
25
+ }): Promise<ThreadData[]>;
26
+ addMessage(threadId: string, role: MessageRole, content: string, attachments?: MessageAttachment[]): Promise<string>;
27
+ getMessages(threadId: string, limit?: number): Promise<MessageData[]>;
28
+ getConversationContext(threadId: string, maxMessages?: number): Promise<Array<{
29
+ role: string;
30
+ content: string;
31
+ }>>;
32
+ /**
33
+ * Clear all stored data
34
+ */
35
+ clear(): void;
36
+ /**
37
+ * Get statistics about stored data
38
+ */
39
+ getStats(): {
40
+ agents: number;
41
+ threads: number;
42
+ messages: number;
43
+ };
44
+ }
45
+
46
+ export { MemoryStorage };
@@ -0,0 +1,46 @@
1
+ import { S as StorageAdapter, A as AgentConfig, a as AgentData, T as ThreadConfig, b as ThreadData, M as MessageRole, c as MessageAttachment, d as MessageData } from '../index-Ek8b39d1.js';
2
+
3
+ /**
4
+ * In-Memory Storage Adapter
5
+ * Provides temporary storage for agents and threads (useful for testing and development)
6
+ */
7
+ declare class MemoryStorage implements StorageAdapter {
8
+ private agents;
9
+ private threads;
10
+ private idCounter;
11
+ private generateId;
12
+ createAgent(config: AgentConfig): Promise<string>;
13
+ getAgent(agentId: string): Promise<AgentData | null>;
14
+ updateAgent(agentId: string, updates: Partial<AgentConfig>): Promise<void>;
15
+ deleteAgent(agentId: string): Promise<void>;
16
+ listAgents(userId: string, organizationId?: string): Promise<AgentData[]>;
17
+ createThread(config: ThreadConfig): Promise<string>;
18
+ getThread(threadId: string): Promise<ThreadData | null>;
19
+ updateThread(threadId: string, updates: Partial<ThreadConfig>): Promise<void>;
20
+ deleteThread(threadId: string): Promise<void>;
21
+ listThreads(filters: {
22
+ userId?: string;
23
+ agentId?: string;
24
+ organizationId?: string;
25
+ }): Promise<ThreadData[]>;
26
+ addMessage(threadId: string, role: MessageRole, content: string, attachments?: MessageAttachment[]): Promise<string>;
27
+ getMessages(threadId: string, limit?: number): Promise<MessageData[]>;
28
+ getConversationContext(threadId: string, maxMessages?: number): Promise<Array<{
29
+ role: string;
30
+ content: string;
31
+ }>>;
32
+ /**
33
+ * Clear all stored data
34
+ */
35
+ clear(): void;
36
+ /**
37
+ * Get statistics about stored data
38
+ */
39
+ getStats(): {
40
+ agents: number;
41
+ threads: number;
42
+ messages: number;
43
+ };
44
+ }
45
+
46
+ export { MemoryStorage };
@@ -0,0 +1,6 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkDQRG2GHRjs = require('../chunk-DQRG2GHR.js');
4
+
5
+
6
+ exports.MemoryStorage = _chunkDQRG2GHRjs.MemoryStorage;
@@ -0,0 +1,6 @@
1
+ import {
2
+ MemoryStorage
3
+ } from "../chunk-BSSVNLSO.mjs";
4
+ export {
5
+ MemoryStorage
6
+ };
@@ -0,0 +1,44 @@
1
+ import { S as StorageAdapter, A as AgentConfig, a as AgentData, T as ThreadConfig, b as ThreadData, M as MessageRole, c as MessageAttachment, d as MessageData } from '../index-Ek8b39d1.mjs';
2
+
3
+ interface MongoDBStorageConfig {
4
+ uri: string;
5
+ dbName?: string;
6
+ agentsCollection?: string;
7
+ threadsCollection?: string;
8
+ }
9
+ /**
10
+ * MongoDB Storage Adapter
11
+ * Provides persistent storage for agents and threads using MongoDB
12
+ */
13
+ declare class MongoDBStorage implements StorageAdapter {
14
+ private client;
15
+ private db;
16
+ private config;
17
+ constructor(config: MongoDBStorageConfig | string);
18
+ private ensureConnection;
19
+ disconnect(): Promise<void>;
20
+ createAgent(config: AgentConfig): Promise<string>;
21
+ getAgent(agentId: string): Promise<AgentData | null>;
22
+ updateAgent(agentId: string, updates: Partial<AgentConfig>): Promise<void>;
23
+ deleteAgent(agentId: string): Promise<void>;
24
+ listAgents(userId: string, organizationId?: string): Promise<AgentData[]>;
25
+ createThread(config: ThreadConfig): Promise<string>;
26
+ getThread(threadId: string): Promise<ThreadData | null>;
27
+ updateThread(threadId: string, updates: Partial<ThreadConfig>): Promise<void>;
28
+ deleteThread(threadId: string): Promise<void>;
29
+ listThreads(filters: {
30
+ userId?: string;
31
+ agentId?: string;
32
+ organizationId?: string;
33
+ }): Promise<ThreadData[]>;
34
+ addMessage(threadId: string, role: MessageRole, content: string, attachments?: MessageAttachment[]): Promise<string>;
35
+ getMessages(threadId: string, limit?: number): Promise<MessageData[]>;
36
+ getConversationContext(threadId: string, maxMessages?: number): Promise<Array<{
37
+ role: string;
38
+ content: string;
39
+ }>>;
40
+ private agentDocToData;
41
+ private threadDocToData;
42
+ }
43
+
44
+ export { MongoDBStorage, type MongoDBStorageConfig };
@@ -0,0 +1,44 @@
1
+ import { S as StorageAdapter, A as AgentConfig, a as AgentData, T as ThreadConfig, b as ThreadData, M as MessageRole, c as MessageAttachment, d as MessageData } from '../index-Ek8b39d1.js';
2
+
3
+ interface MongoDBStorageConfig {
4
+ uri: string;
5
+ dbName?: string;
6
+ agentsCollection?: string;
7
+ threadsCollection?: string;
8
+ }
9
+ /**
10
+ * MongoDB Storage Adapter
11
+ * Provides persistent storage for agents and threads using MongoDB
12
+ */
13
+ declare class MongoDBStorage implements StorageAdapter {
14
+ private client;
15
+ private db;
16
+ private config;
17
+ constructor(config: MongoDBStorageConfig | string);
18
+ private ensureConnection;
19
+ disconnect(): Promise<void>;
20
+ createAgent(config: AgentConfig): Promise<string>;
21
+ getAgent(agentId: string): Promise<AgentData | null>;
22
+ updateAgent(agentId: string, updates: Partial<AgentConfig>): Promise<void>;
23
+ deleteAgent(agentId: string): Promise<void>;
24
+ listAgents(userId: string, organizationId?: string): Promise<AgentData[]>;
25
+ createThread(config: ThreadConfig): Promise<string>;
26
+ getThread(threadId: string): Promise<ThreadData | null>;
27
+ updateThread(threadId: string, updates: Partial<ThreadConfig>): Promise<void>;
28
+ deleteThread(threadId: string): Promise<void>;
29
+ listThreads(filters: {
30
+ userId?: string;
31
+ agentId?: string;
32
+ organizationId?: string;
33
+ }): Promise<ThreadData[]>;
34
+ addMessage(threadId: string, role: MessageRole, content: string, attachments?: MessageAttachment[]): Promise<string>;
35
+ getMessages(threadId: string, limit?: number): Promise<MessageData[]>;
36
+ getConversationContext(threadId: string, maxMessages?: number): Promise<Array<{
37
+ role: string;
38
+ content: string;
39
+ }>>;
40
+ private agentDocToData;
41
+ private threadDocToData;
42
+ }
43
+
44
+ export { MongoDBStorage, type MongoDBStorageConfig };
@@ -0,0 +1,6 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkJRIKISMXjs = require('../chunk-JRIKISMX.js');
4
+
5
+
6
+ exports.MongoDBStorage = _chunkJRIKISMXjs.MongoDBStorage;
@@ -0,0 +1,6 @@
1
+ import {
2
+ MongoDBStorage
3
+ } from "../chunk-JQK3HEJ5.mjs";
4
+ export {
5
+ MongoDBStorage
6
+ };
@@ -0,0 +1,91 @@
1
+ import { S as StorageAdapter, A as AgentConfig, a as AgentData, T as ThreadConfig, b as ThreadData, M as MessageRole, c as MessageAttachment, d as MessageData } from '../index-Ek8b39d1.mjs';
2
+
3
+ /**
4
+ * Upstash Redis configuration
5
+ */
6
+ interface UpstashStorageConfig {
7
+ /**
8
+ * Upstash Redis REST URL
9
+ * @example "https://your-redis.upstash.io"
10
+ */
11
+ url: string;
12
+ /**
13
+ * Upstash Redis REST token
14
+ */
15
+ token: string;
16
+ /**
17
+ * Optional key prefix for multi-tenancy
18
+ * @default "snap-agent"
19
+ */
20
+ prefix?: string;
21
+ }
22
+ /**
23
+ * Upstash Redis Storage Adapter
24
+ *
25
+ * Edge-compatible persistent storage using Upstash Redis REST API.
26
+ * Works with Cloudflare Workers, Vercel Edge, Deno Deploy, and any WinterCG runtime.
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * import { UpstashStorage } from '@snap-agent/core/storage';
31
+ *
32
+ * const storage = new UpstashStorage({
33
+ * url: process.env.UPSTASH_REDIS_REST_URL!,
34
+ * token: process.env.UPSTASH_REDIS_REST_TOKEN!,
35
+ * });
36
+ *
37
+ * const client = createClient({
38
+ * storage,
39
+ * providers: { openai: { apiKey: process.env.OPENAI_API_KEY! } },
40
+ * });
41
+ * ```
42
+ */
43
+ declare class UpstashStorage implements StorageAdapter {
44
+ private url;
45
+ private token;
46
+ private prefix;
47
+ constructor(config: UpstashStorageConfig);
48
+ private command;
49
+ private pipeline;
50
+ private key;
51
+ private generateId;
52
+ createAgent(config: AgentConfig): Promise<string>;
53
+ getAgent(agentId: string): Promise<AgentData | null>;
54
+ updateAgent(agentId: string, updates: Partial<AgentConfig>): Promise<void>;
55
+ deleteAgent(agentId: string): Promise<void>;
56
+ listAgents(userId: string, organizationId?: string): Promise<AgentData[]>;
57
+ createThread(config: ThreadConfig): Promise<string>;
58
+ getThread(threadId: string): Promise<ThreadData | null>;
59
+ updateThread(threadId: string, updates: Partial<ThreadConfig>): Promise<void>;
60
+ deleteThread(threadId: string): Promise<void>;
61
+ listThreads(filters: {
62
+ userId?: string;
63
+ agentId?: string;
64
+ organizationId?: string;
65
+ }): Promise<ThreadData[]>;
66
+ addMessage(threadId: string, role: MessageRole, content: string, attachments?: MessageAttachment[]): Promise<string>;
67
+ getMessages(threadId: string, limit?: number): Promise<MessageData[]>;
68
+ getConversationContext(threadId: string, maxMessages?: number): Promise<Array<{
69
+ role: string;
70
+ content: string;
71
+ }>>;
72
+ private parseStoredAgent;
73
+ private parseStoredThread;
74
+ /**
75
+ * Test connection to Upstash Redis
76
+ */
77
+ ping(): Promise<boolean>;
78
+ /**
79
+ * Clear all data with this prefix (use with caution!)
80
+ */
81
+ clear(): Promise<void>;
82
+ /**
83
+ * Get storage statistics
84
+ */
85
+ getStats(): Promise<{
86
+ agents: number;
87
+ threads: number;
88
+ }>;
89
+ }
90
+
91
+ export { UpstashStorage, type UpstashStorageConfig };
@@ -0,0 +1,91 @@
1
+ import { S as StorageAdapter, A as AgentConfig, a as AgentData, T as ThreadConfig, b as ThreadData, M as MessageRole, c as MessageAttachment, d as MessageData } from '../index-Ek8b39d1.js';
2
+
3
+ /**
4
+ * Upstash Redis configuration
5
+ */
6
+ interface UpstashStorageConfig {
7
+ /**
8
+ * Upstash Redis REST URL
9
+ * @example "https://your-redis.upstash.io"
10
+ */
11
+ url: string;
12
+ /**
13
+ * Upstash Redis REST token
14
+ */
15
+ token: string;
16
+ /**
17
+ * Optional key prefix for multi-tenancy
18
+ * @default "snap-agent"
19
+ */
20
+ prefix?: string;
21
+ }
22
+ /**
23
+ * Upstash Redis Storage Adapter
24
+ *
25
+ * Edge-compatible persistent storage using Upstash Redis REST API.
26
+ * Works with Cloudflare Workers, Vercel Edge, Deno Deploy, and any WinterCG runtime.
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * import { UpstashStorage } from '@snap-agent/core/storage';
31
+ *
32
+ * const storage = new UpstashStorage({
33
+ * url: process.env.UPSTASH_REDIS_REST_URL!,
34
+ * token: process.env.UPSTASH_REDIS_REST_TOKEN!,
35
+ * });
36
+ *
37
+ * const client = createClient({
38
+ * storage,
39
+ * providers: { openai: { apiKey: process.env.OPENAI_API_KEY! } },
40
+ * });
41
+ * ```
42
+ */
43
+ declare class UpstashStorage implements StorageAdapter {
44
+ private url;
45
+ private token;
46
+ private prefix;
47
+ constructor(config: UpstashStorageConfig);
48
+ private command;
49
+ private pipeline;
50
+ private key;
51
+ private generateId;
52
+ createAgent(config: AgentConfig): Promise<string>;
53
+ getAgent(agentId: string): Promise<AgentData | null>;
54
+ updateAgent(agentId: string, updates: Partial<AgentConfig>): Promise<void>;
55
+ deleteAgent(agentId: string): Promise<void>;
56
+ listAgents(userId: string, organizationId?: string): Promise<AgentData[]>;
57
+ createThread(config: ThreadConfig): Promise<string>;
58
+ getThread(threadId: string): Promise<ThreadData | null>;
59
+ updateThread(threadId: string, updates: Partial<ThreadConfig>): Promise<void>;
60
+ deleteThread(threadId: string): Promise<void>;
61
+ listThreads(filters: {
62
+ userId?: string;
63
+ agentId?: string;
64
+ organizationId?: string;
65
+ }): Promise<ThreadData[]>;
66
+ addMessage(threadId: string, role: MessageRole, content: string, attachments?: MessageAttachment[]): Promise<string>;
67
+ getMessages(threadId: string, limit?: number): Promise<MessageData[]>;
68
+ getConversationContext(threadId: string, maxMessages?: number): Promise<Array<{
69
+ role: string;
70
+ content: string;
71
+ }>>;
72
+ private parseStoredAgent;
73
+ private parseStoredThread;
74
+ /**
75
+ * Test connection to Upstash Redis
76
+ */
77
+ ping(): Promise<boolean>;
78
+ /**
79
+ * Clear all data with this prefix (use with caution!)
80
+ */
81
+ clear(): Promise<void>;
82
+ /**
83
+ * Get storage statistics
84
+ */
85
+ getStats(): Promise<{
86
+ agents: number;
87
+ threads: number;
88
+ }>;
89
+ }
90
+
91
+ export { UpstashStorage, type UpstashStorageConfig };
@@ -0,0 +1,6 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunk5BAE6S5Ejs = require('../chunk-5BAE6S5E.js');
4
+
5
+
6
+ exports.UpstashStorage = _chunk5BAE6S5Ejs.UpstashStorage;
@@ -0,0 +1,6 @@
1
+ import {
2
+ UpstashStorage
3
+ } from "../chunk-52OS4FTG.mjs";
4
+ export {
5
+ UpstashStorage
6
+ };
@@ -1 +1,4 @@
1
- export { W as MemoryStorage, V as MongoDBStorage, Y as MongoDBStorageConfig, X as UpstashStorage, Z as UpstashStorageConfig } from '../index-m2vDW79n.mjs';
1
+ export { MongoDBStorage, MongoDBStorageConfig } from './MongoDBStorage.mjs';
2
+ export { MemoryStorage } from './MemoryStorage.mjs';
3
+ export { UpstashStorage, UpstashStorageConfig } from './UpstashStorage.mjs';
4
+ import '../index-Ek8b39d1.mjs';
@@ -1 +1,4 @@
1
- export { W as MemoryStorage, V as MongoDBStorage, Y as MongoDBStorageConfig, X as UpstashStorage, Z as UpstashStorageConfig } from '../index-m2vDW79n.js';
1
+ export { MongoDBStorage, MongoDBStorageConfig } from './MongoDBStorage.js';
2
+ export { MemoryStorage } from './MemoryStorage.js';
3
+ export { UpstashStorage, UpstashStorageConfig } from './UpstashStorage.js';
4
+ import '../index-Ek8b39d1.js';