@agentuity/runtime 1.0.22 → 1.0.24

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 (48) hide show
  1. package/dist/_context.d.ts +4 -1
  2. package/dist/_context.d.ts.map +1 -1
  3. package/dist/_context.js +3 -0
  4. package/dist/_context.js.map +1 -1
  5. package/dist/_services.d.ts +4 -1
  6. package/dist/_services.d.ts.map +1 -1
  7. package/dist/_services.js +28 -3
  8. package/dist/_services.js.map +1 -1
  9. package/dist/_standalone.d.ts +4 -1
  10. package/dist/_standalone.d.ts.map +1 -1
  11. package/dist/_standalone.js +3 -0
  12. package/dist/_standalone.js.map +1 -1
  13. package/dist/agent.d.ts +43 -1
  14. package/dist/agent.d.ts.map +1 -1
  15. package/dist/agent.js.map +1 -1
  16. package/dist/app.d.ts +12 -1
  17. package/dist/app.d.ts.map +1 -1
  18. package/dist/app.js.map +1 -1
  19. package/dist/middleware.d.ts +1 -1
  20. package/dist/middleware.d.ts.map +1 -1
  21. package/dist/middleware.js +6 -0
  22. package/dist/middleware.js.map +1 -1
  23. package/dist/services/local/_db.d.ts.map +1 -1
  24. package/dist/services/local/_db.js +49 -1
  25. package/dist/services/local/_db.js.map +1 -1
  26. package/dist/services/local/email.d.ts +20 -0
  27. package/dist/services/local/email.d.ts.map +1 -0
  28. package/dist/services/local/email.js +46 -0
  29. package/dist/services/local/email.js.map +1 -0
  30. package/dist/services/local/index.d.ts +2 -0
  31. package/dist/services/local/index.d.ts.map +1 -1
  32. package/dist/services/local/index.js +2 -0
  33. package/dist/services/local/index.js.map +1 -1
  34. package/dist/services/local/task.d.ts +16 -0
  35. package/dist/services/local/task.d.ts.map +1 -0
  36. package/dist/services/local/task.js +425 -0
  37. package/dist/services/local/task.js.map +1 -0
  38. package/package.json +7 -7
  39. package/src/_context.ts +6 -0
  40. package/src/_services.ts +33 -1
  41. package/src/_standalone.ts +6 -0
  42. package/src/agent.ts +48 -0
  43. package/src/app.ts +14 -0
  44. package/src/middleware.ts +7 -3
  45. package/src/services/local/_db.ts +64 -3
  46. package/src/services/local/email.ts +75 -0
  47. package/src/services/local/index.ts +2 -0
  48. package/src/services/local/task.ts +595 -0
package/src/app.ts CHANGED
@@ -12,6 +12,9 @@ import type {
12
12
  VectorStorage,
13
13
  SandboxService,
14
14
  QueueService,
15
+ EmailService,
16
+ ScheduleService,
17
+ TaskStorage,
15
18
  SessionStartEvent,
16
19
  } from '@agentuity/core';
17
20
 
@@ -182,6 +185,10 @@ export interface AppConfig<TAppState = Record<string, never>> {
182
185
  * the VectorStorage to override instead of the default
183
186
  */
184
187
  vector?: VectorStorage;
188
+ /**
189
+ * the TaskStorage to override instead of the default
190
+ */
191
+ task?: TaskStorage;
185
192
  /**
186
193
  * the ThreadProvider to override instead of the default
187
194
  */
@@ -198,6 +205,10 @@ export interface AppConfig<TAppState = Record<string, never>> {
198
205
  * the EvalRunEventProvider to override instead of the default
199
206
  */
200
207
  evalRunEvent?: EvalRunEventProvider;
208
+ /**
209
+ * the EmailService to override instead of the default
210
+ */
211
+ email?: EmailService;
201
212
  };
202
213
  /**
203
214
  * Optional setup function called before server starts
@@ -229,6 +240,9 @@ export interface Variables<TAppState = Record<string, never>> {
229
240
  vector: VectorStorage;
230
241
  sandbox: SandboxService;
231
242
  queue: QueueService;
243
+ email: EmailService;
244
+ schedule: ScheduleService;
245
+ task: TaskStorage;
232
246
  app: TAppState;
233
247
  // Web analytics context (set by createWebSessionMiddleware, thread-only tracking)
234
248
  _webThreadId?: string;
package/src/middleware.ts CHANGED
@@ -61,6 +61,9 @@ export const AGENT_CONTEXT_PROPERTIES = [
61
61
  'vector',
62
62
  'sandbox',
63
63
  'queue',
64
+ 'email',
65
+ 'schedule',
66
+ 'task',
64
67
  'state',
65
68
  'thread',
66
69
  'session',
@@ -118,6 +121,9 @@ export function createBaseMiddleware(config: MiddlewareConfig) {
118
121
  c.set('vector', services.vector);
119
122
  c.set('sandbox', services.sandbox);
120
123
  c.set('queue', services.queue);
124
+ c.set('email', services.email);
125
+ c.set('schedule', services.schedule);
126
+ c.set('task', services.task);
121
127
 
122
128
  installContextPropertyHelpers(c);
123
129
 
@@ -509,9 +515,7 @@ export function createOtelMiddleware() {
509
515
 
510
516
  // Check if this is a WebSocket response that needs deferred finalization
511
517
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
512
- const wsDone = (c as any).get(WS_DONE_PROMISE_KEY) as
513
- | Promise<void>
514
- | undefined;
518
+ const wsDone = (c as any).get(WS_DONE_PROMISE_KEY) as Promise<void> | undefined;
515
519
 
516
520
  // Check if Hono caught an error (c.error is set by Hono's error handler)
517
521
  // or if the response status indicates an error
@@ -96,6 +96,49 @@ function initializeTables(db: Database): void {
96
96
  CREATE INDEX IF NOT EXISTS idx_vector_name
97
97
  ON vector_storage(project_path, name)
98
98
  `);
99
+
100
+ // Task Storage table
101
+ db.run(`
102
+ CREATE TABLE IF NOT EXISTS task_storage (
103
+ project_path TEXT NOT NULL,
104
+ id TEXT NOT NULL,
105
+ title TEXT NOT NULL,
106
+ description TEXT,
107
+ metadata TEXT,
108
+ priority TEXT NOT NULL DEFAULT 'none',
109
+ parent_id TEXT,
110
+ type TEXT NOT NULL,
111
+ status TEXT NOT NULL DEFAULT 'open',
112
+ open_date TEXT,
113
+ in_progress_date TEXT,
114
+ closed_date TEXT,
115
+ created_id TEXT NOT NULL,
116
+ assigned_id TEXT,
117
+ closed_id TEXT,
118
+ created_at INTEGER NOT NULL,
119
+ updated_at INTEGER NOT NULL,
120
+ PRIMARY KEY (project_path, id)
121
+ )
122
+ `);
123
+
124
+ // Task Changelog table
125
+ db.run(`
126
+ CREATE TABLE IF NOT EXISTS task_changelog_storage (
127
+ project_path TEXT NOT NULL,
128
+ id TEXT NOT NULL,
129
+ task_id TEXT NOT NULL,
130
+ field TEXT NOT NULL,
131
+ old_value TEXT,
132
+ new_value TEXT,
133
+ created_at INTEGER NOT NULL,
134
+ PRIMARY KEY (project_path, id)
135
+ )
136
+ `);
137
+
138
+ db.run(`
139
+ CREATE INDEX IF NOT EXISTS idx_task_changelog_lookup
140
+ ON task_changelog_storage(project_path, task_id)
141
+ `);
99
142
  }
100
143
 
101
144
  function cleanupOrphanedProjects(db: Database): void {
@@ -112,12 +155,22 @@ function cleanupOrphanedProjects(db: Database): void {
112
155
  const vectorPaths = db.query('SELECT DISTINCT project_path FROM vector_storage').all() as Array<{
113
156
  project_path: string;
114
157
  }>;
158
+ const taskPaths = db.query('SELECT DISTINCT project_path FROM task_storage').all() as Array<{
159
+ project_path: string;
160
+ }>;
161
+ const taskChangelogPaths = db
162
+ .query('SELECT DISTINCT project_path FROM task_changelog_storage')
163
+ .all() as Array<{
164
+ project_path: string;
165
+ }>;
115
166
 
116
167
  // Combine and deduplicate all project paths
117
168
  const allPaths = new Set<string>();
118
- [...kvPaths, ...streamPaths, ...vectorPaths].forEach((row) => {
119
- allPaths.add(row.project_path);
120
- });
169
+ [...kvPaths, ...streamPaths, ...vectorPaths, ...taskPaths, ...taskChangelogPaths].forEach(
170
+ (row) => {
171
+ allPaths.add(row.project_path);
172
+ }
173
+ );
121
174
 
122
175
  // Check which paths no longer exist and are not the current project
123
176
  const pathsToDelete: string[] = [];
@@ -139,10 +192,18 @@ function cleanupOrphanedProjects(db: Database): void {
139
192
  const deleteVector = db.prepare(
140
193
  `DELETE FROM vector_storage WHERE project_path IN (${placeholders})`
141
194
  );
195
+ const deleteTasks = db.prepare(
196
+ `DELETE FROM task_storage WHERE project_path IN (${placeholders})`
197
+ );
198
+ const deleteTaskChangelog = db.prepare(
199
+ `DELETE FROM task_changelog_storage WHERE project_path IN (${placeholders})`
200
+ );
142
201
 
143
202
  deleteKv.run(...pathsToDelete);
144
203
  deleteStream.run(...pathsToDelete);
145
204
  deleteVector.run(...pathsToDelete);
205
+ deleteTasks.run(...pathsToDelete);
206
+ deleteTaskChangelog.run(...pathsToDelete);
146
207
 
147
208
  console.log(`[LocalDB] Cleaned up data for ${pathsToDelete.length} orphaned project(s)`);
148
209
  }
@@ -0,0 +1,75 @@
1
+ import {
2
+ StructuredError,
3
+ type EmailService,
4
+ type EmailAddress,
5
+ type EmailDestination,
6
+ type EmailInbound,
7
+ type EmailOutbound,
8
+ type EmailSendParams,
9
+ } from '@agentuity/core';
10
+
11
+ const ERROR_MESSAGE =
12
+ 'Email service is not available in local development mode. Deploy to Agentuity Cloud to use email.';
13
+
14
+ const LocalEmailNotAvailableError = StructuredError(
15
+ 'LocalEmailNotAvailableError',
16
+ ERROR_MESSAGE
17
+ );
18
+
19
+ /**
20
+ * Local development stub for the email service.
21
+ * All methods throw a descriptive error directing users to deploy to Agentuity Cloud.
22
+ */
23
+ export class LocalEmailStorage implements EmailService {
24
+ async createAddress(_localPart: string): Promise<EmailAddress> {
25
+ throw new LocalEmailNotAvailableError();
26
+ }
27
+
28
+ async listAddresses(): Promise<EmailAddress[]> {
29
+ throw new LocalEmailNotAvailableError();
30
+ }
31
+
32
+ async getAddress(_id: string): Promise<EmailAddress | null> {
33
+ throw new LocalEmailNotAvailableError();
34
+ }
35
+
36
+ async deleteAddress(_id: string): Promise<void> {
37
+ throw new LocalEmailNotAvailableError();
38
+ }
39
+
40
+ async createDestination(
41
+ _addressId: string,
42
+ _type: string,
43
+ _config: Record<string, unknown>
44
+ ): Promise<EmailDestination> {
45
+ throw new LocalEmailNotAvailableError();
46
+ }
47
+
48
+ async listDestinations(_addressId: string): Promise<EmailDestination[]> {
49
+ throw new LocalEmailNotAvailableError();
50
+ }
51
+
52
+ async deleteDestination(_addressId: string, _destinationId: string): Promise<void> {
53
+ throw new LocalEmailNotAvailableError();
54
+ }
55
+
56
+ async send(_params: EmailSendParams): Promise<EmailOutbound> {
57
+ throw new LocalEmailNotAvailableError();
58
+ }
59
+
60
+ async listInbound(_addressId?: string): Promise<EmailInbound[]> {
61
+ throw new LocalEmailNotAvailableError();
62
+ }
63
+
64
+ async getInbound(_id: string): Promise<EmailInbound | null> {
65
+ throw new LocalEmailNotAvailableError();
66
+ }
67
+
68
+ async listOutbound(_addressId?: string): Promise<EmailOutbound[]> {
69
+ throw new LocalEmailNotAvailableError();
70
+ }
71
+
72
+ async getOutbound(_id: string): Promise<EmailOutbound | null> {
73
+ throw new LocalEmailNotAvailableError();
74
+ }
75
+ }
@@ -5,3 +5,5 @@ export { LocalKeyValueStorage } from './keyvalue';
5
5
  export { LocalStreamStorage } from './stream';
6
6
  export { LocalVectorStorage } from './vector';
7
7
  export { LocalQueueStorage } from './queue';
8
+ export { LocalEmailStorage } from './email';
9
+ export { LocalTaskStorage } from './task';