swarm-mail 0.1.0 → 0.1.2
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/README.md +28 -0
- package/dist/adapter.d.ts +36 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23131 -0
- package/{src/pglite.ts → dist/pglite.d.ts} +7 -93
- package/dist/pglite.d.ts.map +1 -0
- package/dist/streams/agent-mail.d.ts +139 -0
- package/dist/streams/agent-mail.d.ts.map +1 -0
- package/dist/streams/debug.d.ts +173 -0
- package/dist/streams/debug.d.ts.map +1 -0
- package/dist/streams/effect/ask.d.ts +124 -0
- package/dist/streams/effect/ask.d.ts.map +1 -0
- package/dist/streams/effect/cursor.d.ts +87 -0
- package/dist/streams/effect/cursor.d.ts.map +1 -0
- package/dist/streams/effect/deferred.d.ts +108 -0
- package/dist/streams/effect/deferred.d.ts.map +1 -0
- package/{src/streams/effect/index.ts → dist/streams/effect/index.d.ts} +1 -0
- package/dist/streams/effect/index.d.ts.map +1 -0
- package/{src/streams/effect/layers.ts → dist/streams/effect/layers.d.ts} +8 -33
- package/dist/streams/effect/layers.d.ts.map +1 -0
- package/dist/streams/effect/lock.d.ts +137 -0
- package/dist/streams/effect/lock.d.ts.map +1 -0
- package/dist/streams/effect/mailbox.d.ts +98 -0
- package/dist/streams/effect/mailbox.d.ts.map +1 -0
- package/dist/streams/events.d.ts +487 -0
- package/dist/streams/events.d.ts.map +1 -0
- package/dist/streams/index.d.ts +106 -0
- package/dist/streams/index.d.ts.map +1 -0
- package/dist/streams/migrations.d.ts +102 -0
- package/dist/streams/migrations.d.ts.map +1 -0
- package/dist/streams/projections.d.ts +173 -0
- package/dist/streams/projections.d.ts.map +1 -0
- package/dist/streams/store.d.ts +171 -0
- package/dist/streams/store.d.ts.map +1 -0
- package/dist/streams/swarm-mail.d.ts +153 -0
- package/dist/streams/swarm-mail.d.ts.map +1 -0
- package/dist/types/adapter.d.ts +267 -0
- package/dist/types/adapter.d.ts.map +1 -0
- package/dist/types/database.d.ts +117 -0
- package/dist/types/database.d.ts.map +1 -0
- package/{src/types/index.ts → dist/types/index.d.ts} +2 -15
- package/dist/types/index.d.ts.map +1 -0
- package/package.json +20 -4
- package/src/adapter.ts +0 -306
- package/src/index.ts +0 -57
- package/src/streams/agent-mail.test.ts +0 -777
- package/src/streams/agent-mail.ts +0 -535
- package/src/streams/debug.test.ts +0 -500
- package/src/streams/debug.ts +0 -727
- package/src/streams/effect/ask.integration.test.ts +0 -314
- package/src/streams/effect/ask.ts +0 -202
- package/src/streams/effect/cursor.integration.test.ts +0 -418
- package/src/streams/effect/cursor.ts +0 -288
- package/src/streams/effect/deferred.test.ts +0 -357
- package/src/streams/effect/deferred.ts +0 -445
- package/src/streams/effect/lock.test.ts +0 -385
- package/src/streams/effect/lock.ts +0 -399
- package/src/streams/effect/mailbox.test.ts +0 -260
- package/src/streams/effect/mailbox.ts +0 -318
- package/src/streams/events.test.ts +0 -924
- package/src/streams/events.ts +0 -329
- package/src/streams/index.test.ts +0 -229
- package/src/streams/index.ts +0 -578
- package/src/streams/migrations.test.ts +0 -359
- package/src/streams/migrations.ts +0 -362
- package/src/streams/projections.test.ts +0 -611
- package/src/streams/projections.ts +0 -564
- package/src/streams/store.integration.test.ts +0 -658
- package/src/streams/store.ts +0 -1129
- package/src/streams/swarm-mail.ts +0 -552
- package/src/types/adapter.ts +0 -392
- package/src/types/database.ts +0 -127
- package/tsconfig.json +0 -22
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema Migration System
|
|
3
|
+
*
|
|
4
|
+
* Handles database schema evolution for the PGLite event store.
|
|
5
|
+
*
|
|
6
|
+
* ## How It Works
|
|
7
|
+
*
|
|
8
|
+
* 1. Each migration has a unique version number (incrementing integer)
|
|
9
|
+
* 2. On startup, `runMigrations()` checks current schema version
|
|
10
|
+
* 3. Migrations are applied in order until schema is current
|
|
11
|
+
* 4. Version is stored in `schema_version` table
|
|
12
|
+
*
|
|
13
|
+
* ## Adding a New Migration
|
|
14
|
+
*
|
|
15
|
+
* ```typescript
|
|
16
|
+
* // In migrations.ts
|
|
17
|
+
* export const migrations: Migration[] = [
|
|
18
|
+
* // ... existing migrations
|
|
19
|
+
* {
|
|
20
|
+
* version: 3,
|
|
21
|
+
* description: "add_new_column",
|
|
22
|
+
* up: `ALTER TABLE events ADD COLUMN new_col TEXT`,
|
|
23
|
+
* down: `ALTER TABLE events DROP COLUMN new_col`,
|
|
24
|
+
* },
|
|
25
|
+
* ];
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* ## Rollback
|
|
29
|
+
*
|
|
30
|
+
* Rollback is supported via `rollbackTo(db, targetVersion)`.
|
|
31
|
+
* Note: Some migrations may not be fully reversible (data loss).
|
|
32
|
+
*
|
|
33
|
+
* ## Best Practices
|
|
34
|
+
*
|
|
35
|
+
* - Always test migrations on a copy of production data
|
|
36
|
+
* - Keep migrations small and focused
|
|
37
|
+
* - Include both `up` and `down` SQL
|
|
38
|
+
* - Use transactions for multi-statement migrations
|
|
39
|
+
* - Document any data transformations
|
|
40
|
+
*
|
|
41
|
+
* @module migrations
|
|
42
|
+
*/
|
|
43
|
+
import type { PGlite } from "@electric-sql/pglite";
|
|
44
|
+
/**
|
|
45
|
+
* A database migration definition.
|
|
46
|
+
*/
|
|
47
|
+
export interface Migration {
|
|
48
|
+
/** Unique version number (must be sequential) */
|
|
49
|
+
version: number;
|
|
50
|
+
/** Human-readable migration description */
|
|
51
|
+
description: string;
|
|
52
|
+
/** SQL to apply the migration */
|
|
53
|
+
up: string;
|
|
54
|
+
/** SQL to rollback the migration (best effort) */
|
|
55
|
+
down: string;
|
|
56
|
+
}
|
|
57
|
+
interface SchemaVersion {
|
|
58
|
+
version: number;
|
|
59
|
+
applied_at: number;
|
|
60
|
+
description: string | null;
|
|
61
|
+
}
|
|
62
|
+
export declare const migrations: Migration[];
|
|
63
|
+
/**
|
|
64
|
+
* Get the current schema version
|
|
65
|
+
*
|
|
66
|
+
* Returns 0 if no migrations have been applied
|
|
67
|
+
*/
|
|
68
|
+
export declare function getCurrentVersion(db: PGlite): Promise<number>;
|
|
69
|
+
/**
|
|
70
|
+
* Get all applied migrations
|
|
71
|
+
*/
|
|
72
|
+
export declare function getAppliedMigrations(db: PGlite): Promise<SchemaVersion[]>;
|
|
73
|
+
/**
|
|
74
|
+
* Run all pending migrations
|
|
75
|
+
*
|
|
76
|
+
* Idempotent - safe to run multiple times.
|
|
77
|
+
* Only runs migrations that haven't been applied yet.
|
|
78
|
+
*/
|
|
79
|
+
export declare function runMigrations(db: PGlite): Promise<{
|
|
80
|
+
applied: number[];
|
|
81
|
+
current: number;
|
|
82
|
+
}>;
|
|
83
|
+
/**
|
|
84
|
+
* Rollback to a specific version
|
|
85
|
+
*
|
|
86
|
+
* WARNING: This will DROP tables and LOSE DATA.
|
|
87
|
+
* Only use for testing or emergency recovery.
|
|
88
|
+
*/
|
|
89
|
+
export declare function rollbackTo(db: PGlite, targetVersion: number): Promise<{
|
|
90
|
+
rolledBack: number[];
|
|
91
|
+
current: number;
|
|
92
|
+
}>;
|
|
93
|
+
/**
|
|
94
|
+
* Check if a specific migration has been applied
|
|
95
|
+
*/
|
|
96
|
+
export declare function isMigrationApplied(db: PGlite, version: number): Promise<boolean>;
|
|
97
|
+
/**
|
|
98
|
+
* Get pending migrations (not yet applied)
|
|
99
|
+
*/
|
|
100
|
+
export declare function getPendingMigrations(db: PGlite): Promise<Migration[]>;
|
|
101
|
+
export {};
|
|
102
|
+
//# sourceMappingURL=migrations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../src/streams/migrations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,s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from "../types/database";
|
|
2
|
+
export interface Agent {
|
|
3
|
+
id: number;
|
|
4
|
+
name: string;
|
|
5
|
+
program: string;
|
|
6
|
+
model: string;
|
|
7
|
+
task_description: string | null;
|
|
8
|
+
registered_at: number;
|
|
9
|
+
last_active_at: number;
|
|
10
|
+
}
|
|
11
|
+
export interface Message {
|
|
12
|
+
id: number;
|
|
13
|
+
from_agent: string;
|
|
14
|
+
subject: string;
|
|
15
|
+
body?: string;
|
|
16
|
+
thread_id: string | null;
|
|
17
|
+
importance: string;
|
|
18
|
+
ack_required: boolean;
|
|
19
|
+
created_at: number;
|
|
20
|
+
read_at?: number | null;
|
|
21
|
+
acked_at?: number | null;
|
|
22
|
+
}
|
|
23
|
+
export interface Reservation {
|
|
24
|
+
id: number;
|
|
25
|
+
agent_name: string;
|
|
26
|
+
path_pattern: string;
|
|
27
|
+
exclusive: boolean;
|
|
28
|
+
reason: string | null;
|
|
29
|
+
created_at: number;
|
|
30
|
+
expires_at: number;
|
|
31
|
+
}
|
|
32
|
+
export interface Conflict {
|
|
33
|
+
path: string;
|
|
34
|
+
holder: string;
|
|
35
|
+
pattern: string;
|
|
36
|
+
exclusive: boolean;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get all agents for a project
|
|
40
|
+
*
|
|
41
|
+
* @param projectKey - Project identifier
|
|
42
|
+
* @param projectPath - Optional project path for database location
|
|
43
|
+
* @param dbOverride - Optional database adapter for dependency injection
|
|
44
|
+
*/
|
|
45
|
+
export declare function getAgents(projectKey: string, projectPath?: string, dbOverride?: DatabaseAdapter): Promise<Agent[]>;
|
|
46
|
+
/**
|
|
47
|
+
* Get a specific agent by name
|
|
48
|
+
*
|
|
49
|
+
* @param projectKey - Project identifier
|
|
50
|
+
* @param agentName - Agent name to lookup
|
|
51
|
+
* @param projectPath - Optional project path for database location
|
|
52
|
+
* @param dbOverride - Optional database adapter for dependency injection
|
|
53
|
+
*/
|
|
54
|
+
export declare function getAgent(projectKey: string, agentName: string, projectPath?: string, dbOverride?: DatabaseAdapter): Promise<Agent | null>;
|
|
55
|
+
export interface InboxOptions {
|
|
56
|
+
limit?: number;
|
|
57
|
+
urgentOnly?: boolean;
|
|
58
|
+
unreadOnly?: boolean;
|
|
59
|
+
includeBodies?: boolean;
|
|
60
|
+
sinceTs?: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get inbox messages for an agent
|
|
64
|
+
*
|
|
65
|
+
* @param projectKey - Project identifier
|
|
66
|
+
* @param agentName - Agent name to get inbox for
|
|
67
|
+
* @param options - Inbox query options
|
|
68
|
+
* @param projectPath - Optional project path for database location
|
|
69
|
+
* @param dbOverride - Optional database adapter for dependency injection
|
|
70
|
+
*/
|
|
71
|
+
export declare function getInbox(projectKey: string, agentName: string, options?: InboxOptions, projectPath?: string, dbOverride?: DatabaseAdapter): Promise<Message[]>;
|
|
72
|
+
/**
|
|
73
|
+
* Get a single message by ID with full body
|
|
74
|
+
*
|
|
75
|
+
* @param projectKey - Project identifier
|
|
76
|
+
* @param messageId - Message ID to lookup
|
|
77
|
+
* @param projectPath - Optional project path for database location
|
|
78
|
+
* @param dbOverride - Optional database adapter for dependency injection
|
|
79
|
+
*/
|
|
80
|
+
export declare function getMessage(projectKey: string, messageId: number, projectPath?: string, dbOverride?: DatabaseAdapter): Promise<Message | null>;
|
|
81
|
+
/**
|
|
82
|
+
* Get all messages in a thread
|
|
83
|
+
*
|
|
84
|
+
* @param projectKey - Project identifier
|
|
85
|
+
* @param threadId - Thread ID to lookup
|
|
86
|
+
* @param projectPath - Optional project path for database location
|
|
87
|
+
* @param dbOverride - Optional database adapter for dependency injection
|
|
88
|
+
*/
|
|
89
|
+
export declare function getThreadMessages(projectKey: string, threadId: string, projectPath?: string, dbOverride?: DatabaseAdapter): Promise<Message[]>;
|
|
90
|
+
/**
|
|
91
|
+
* Get active (non-expired, non-released) reservations
|
|
92
|
+
*
|
|
93
|
+
* @param projectKey - Project identifier
|
|
94
|
+
* @param projectPath - Optional project path for database location
|
|
95
|
+
* @param agentName - Optional agent name to filter by
|
|
96
|
+
* @param dbOverride - Optional database adapter for dependency injection
|
|
97
|
+
*/
|
|
98
|
+
export declare function getActiveReservations(projectKey: string, projectPath?: string, agentName?: string, dbOverride?: DatabaseAdapter): Promise<Reservation[]>;
|
|
99
|
+
/**
|
|
100
|
+
* Check for conflicts with existing reservations
|
|
101
|
+
*
|
|
102
|
+
* Returns conflicts where:
|
|
103
|
+
* - Another agent holds an exclusive reservation
|
|
104
|
+
* - The path matches (exact or glob pattern)
|
|
105
|
+
* - The reservation is still active
|
|
106
|
+
*
|
|
107
|
+
* @param projectKey - Project identifier
|
|
108
|
+
* @param agentName - Agent attempting reservation
|
|
109
|
+
* @param paths - Paths to check for conflicts
|
|
110
|
+
* @param projectPath - Optional project path for database location
|
|
111
|
+
* @param dbOverride - Optional database adapter for dependency injection
|
|
112
|
+
*/
|
|
113
|
+
export declare function checkConflicts(projectKey: string, agentName: string, paths: string[], projectPath?: string, dbOverride?: DatabaseAdapter): Promise<Conflict[]>;
|
|
114
|
+
export interface EvalRecord {
|
|
115
|
+
id: string;
|
|
116
|
+
project_key: string;
|
|
117
|
+
task: string;
|
|
118
|
+
context: string | null;
|
|
119
|
+
strategy: string;
|
|
120
|
+
epic_title: string;
|
|
121
|
+
subtasks: Array<{
|
|
122
|
+
title: string;
|
|
123
|
+
files: string[];
|
|
124
|
+
priority?: number;
|
|
125
|
+
}>;
|
|
126
|
+
outcomes?: Array<{
|
|
127
|
+
bead_id: string;
|
|
128
|
+
planned_files: string[];
|
|
129
|
+
actual_files: string[];
|
|
130
|
+
duration_ms: number;
|
|
131
|
+
error_count: number;
|
|
132
|
+
retry_count: number;
|
|
133
|
+
success: boolean;
|
|
134
|
+
}>;
|
|
135
|
+
overall_success: boolean | null;
|
|
136
|
+
total_duration_ms: number | null;
|
|
137
|
+
total_errors: number | null;
|
|
138
|
+
human_accepted: boolean | null;
|
|
139
|
+
human_modified: boolean | null;
|
|
140
|
+
human_notes: string | null;
|
|
141
|
+
file_overlap_count: number | null;
|
|
142
|
+
scope_accuracy: number | null;
|
|
143
|
+
time_balance_ratio: number | null;
|
|
144
|
+
created_at: number;
|
|
145
|
+
updated_at: number;
|
|
146
|
+
}
|
|
147
|
+
export interface EvalStats {
|
|
148
|
+
totalRecords: number;
|
|
149
|
+
successRate: number;
|
|
150
|
+
avgDurationMs: number;
|
|
151
|
+
byStrategy: Record<string, number>;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Get eval records with optional filters
|
|
155
|
+
*
|
|
156
|
+
* @param projectKey - Project identifier
|
|
157
|
+
* @param options - Query options
|
|
158
|
+
* @param projectPath - Optional project path for database location
|
|
159
|
+
* @param dbOverride - Optional database adapter for dependency injection
|
|
160
|
+
*/
|
|
161
|
+
export declare function getEvalRecords(projectKey: string, options?: {
|
|
162
|
+
limit?: number;
|
|
163
|
+
strategy?: string;
|
|
164
|
+
}, projectPath?: string, dbOverride?: DatabaseAdapter): Promise<EvalRecord[]>;
|
|
165
|
+
/**
|
|
166
|
+
* Get eval statistics for a project
|
|
167
|
+
*
|
|
168
|
+
* @param projectKey - Project identifier
|
|
169
|
+
* @param projectPath - Optional project path for database location
|
|
170
|
+
* @param dbOverride - Optional database adapter for dependency injection
|
|
171
|
+
*/
|
|
172
|
+
export declare function getEvalStats(projectKey: string, projectPath?: string, dbOverride?: DatabaseAdapter): Promise<EvalStats>;
|
|
173
|
+
//# sourceMappingURL=projections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projections.d.ts","sourceRoot":"","sources":["../../src/streams/projections.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAOzD,MAAM,WAAW,KAAK;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,gB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a,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,EAC/C,WAAW,CAAC,EAAE,MAAM,EACpB,UAAU,CAAC,EAAE,eAAe,GAC3B,OAAO,CAAC,UAAU,EAAE,CAAC,CAgFvB;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAChC,UAAU,EAAE,MAAM,EAClB,WAAW,CAAC,EAAE,MAAM,EACpB,UAAU,CAAC,EAAE,eAAe,GAC3B,OAAO,CAAC,SAAS,CAAC,CA6CpB"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import type { DatabaseAdapter } from "../types/database";
|
|
2
|
+
import { type AgentEvent, type AgentRegisteredEvent, type MessageSentEvent, type FileReservedEvent } from "./events";
|
|
3
|
+
/**
|
|
4
|
+
* Append an event to the log
|
|
5
|
+
*
|
|
6
|
+
* Also updates materialized views (agents, messages, reservations)
|
|
7
|
+
*
|
|
8
|
+
* @param event - Event to append
|
|
9
|
+
* @param projectPath - Optional project path for database location
|
|
10
|
+
* @param dbOverride - Optional database adapter for dependency injection
|
|
11
|
+
*/
|
|
12
|
+
export declare function appendEvent(event: AgentEvent, projectPath?: string, dbOverride?: DatabaseAdapter): Promise<AgentEvent & {
|
|
13
|
+
id: number;
|
|
14
|
+
sequence: number;
|
|
15
|
+
}>;
|
|
16
|
+
/**
|
|
17
|
+
* Append multiple events in a transaction
|
|
18
|
+
*
|
|
19
|
+
* @param events - Events to append
|
|
20
|
+
* @param projectPath - Optional project path for database location
|
|
21
|
+
* @param dbOverride - Optional database adapter for dependency injection
|
|
22
|
+
*/
|
|
23
|
+
export declare function appendEvents(events: AgentEvent[], projectPath?: string, dbOverride?: DatabaseAdapter): Promise<Array<AgentEvent & {
|
|
24
|
+
id: number;
|
|
25
|
+
sequence: number;
|
|
26
|
+
}>>;
|
|
27
|
+
/**
|
|
28
|
+
* Read events with optional filters
|
|
29
|
+
*
|
|
30
|
+
* @param options - Filter options
|
|
31
|
+
* @param projectPath - Optional project path for database location
|
|
32
|
+
* @param dbOverride - Optional database adapter for dependency injection
|
|
33
|
+
*/
|
|
34
|
+
export declare function readEvents(options?: {
|
|
35
|
+
projectKey?: string;
|
|
36
|
+
types?: AgentEvent["type"][];
|
|
37
|
+
since?: number;
|
|
38
|
+
until?: number;
|
|
39
|
+
afterSequence?: number;
|
|
40
|
+
limit?: number;
|
|
41
|
+
offset?: number;
|
|
42
|
+
}, projectPath?: string, dbOverride?: DatabaseAdapter): Promise<Array<AgentEvent & {
|
|
43
|
+
id: number;
|
|
44
|
+
sequence: number;
|
|
45
|
+
}>>;
|
|
46
|
+
/**
|
|
47
|
+
* Get the latest sequence number
|
|
48
|
+
*
|
|
49
|
+
* @param projectKey - Optional project key to filter by
|
|
50
|
+
* @param projectPath - Optional project path for database location
|
|
51
|
+
* @param dbOverride - Optional database adapter for dependency injection
|
|
52
|
+
*/
|
|
53
|
+
export declare function getLatestSequence(projectKey?: string, projectPath?: string, dbOverride?: DatabaseAdapter): Promise<number>;
|
|
54
|
+
/**
|
|
55
|
+
* Replay events to rebuild materialized views
|
|
56
|
+
*
|
|
57
|
+
* Useful for:
|
|
58
|
+
* - Recovering from corruption
|
|
59
|
+
* - Migrating to new schema
|
|
60
|
+
* - Debugging state issues
|
|
61
|
+
*
|
|
62
|
+
* @param options - Replay options
|
|
63
|
+
* @param projectPath - Optional project path for database location
|
|
64
|
+
* @param dbOverride - Optional database adapter for dependency injection
|
|
65
|
+
*/
|
|
66
|
+
export declare function replayEvents(options?: {
|
|
67
|
+
projectKey?: string;
|
|
68
|
+
fromSequence?: number;
|
|
69
|
+
clearViews?: boolean;
|
|
70
|
+
}, projectPath?: string, dbOverride?: DatabaseAdapter): Promise<{
|
|
71
|
+
eventsReplayed: number;
|
|
72
|
+
duration: number;
|
|
73
|
+
}>;
|
|
74
|
+
/**
|
|
75
|
+
* Replay events in batches to avoid OOM
|
|
76
|
+
*
|
|
77
|
+
* For large event logs (>100k events), use this instead of replayEvents()
|
|
78
|
+
* to keep memory usage constant.
|
|
79
|
+
*
|
|
80
|
+
* Example:
|
|
81
|
+
* ```typescript
|
|
82
|
+
* const result = await replayEventsBatched(
|
|
83
|
+
* "my-project",
|
|
84
|
+
* async (events, progress) => {
|
|
85
|
+
* console.log(`Replayed ${progress.processed}/${progress.total} (${progress.percent}%)`);
|
|
86
|
+
* },
|
|
87
|
+
* { batchSize: 1000, clearViews: true },
|
|
88
|
+
* "/path/to/project"
|
|
89
|
+
* );
|
|
90
|
+
* console.log(`Replayed ${result.eventsReplayed} events in ${result.duration}ms`);
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* @param projectKey Project key to filter events
|
|
94
|
+
* @param onBatch Callback invoked for each batch with progress
|
|
95
|
+
* @param options Configuration options
|
|
96
|
+
* @param options.batchSize Number of events per batch (default 1000)
|
|
97
|
+
* @param options.fromSequence Start from this sequence number (default 0)
|
|
98
|
+
* @param options.clearViews Clear materialized views before replay (default false)
|
|
99
|
+
* @param projectPath Path to project database
|
|
100
|
+
*/
|
|
101
|
+
export declare function replayEventsBatched(projectKey: string, onBatch: (events: Array<AgentEvent & {
|
|
102
|
+
id: number;
|
|
103
|
+
sequence: number;
|
|
104
|
+
}>, progress: {
|
|
105
|
+
processed: number;
|
|
106
|
+
total: number;
|
|
107
|
+
percent: number;
|
|
108
|
+
}) => Promise<void>, options?: {
|
|
109
|
+
batchSize?: number;
|
|
110
|
+
fromSequence?: number;
|
|
111
|
+
clearViews?: boolean;
|
|
112
|
+
}, projectPath?: string, dbOverride?: DatabaseAdapter): Promise<{
|
|
113
|
+
eventsReplayed: number;
|
|
114
|
+
duration: number;
|
|
115
|
+
}>;
|
|
116
|
+
/**
|
|
117
|
+
* Register an agent (creates event + updates view)
|
|
118
|
+
*
|
|
119
|
+
* @param projectKey - Project identifier
|
|
120
|
+
* @param agentName - Agent name
|
|
121
|
+
* @param options - Registration options
|
|
122
|
+
* @param projectPath - Optional project path for database location
|
|
123
|
+
* @param dbOverride - Optional database adapter for dependency injection
|
|
124
|
+
*/
|
|
125
|
+
export declare function registerAgent(projectKey: string, agentName: string, options?: {
|
|
126
|
+
program?: string;
|
|
127
|
+
model?: string;
|
|
128
|
+
taskDescription?: string;
|
|
129
|
+
}, projectPath?: string, dbOverride?: DatabaseAdapter): Promise<AgentRegisteredEvent & {
|
|
130
|
+
id: number;
|
|
131
|
+
sequence: number;
|
|
132
|
+
}>;
|
|
133
|
+
/**
|
|
134
|
+
* Send a message (creates event + updates view)
|
|
135
|
+
*
|
|
136
|
+
* @param projectKey - Project identifier
|
|
137
|
+
* @param fromAgent - Sender agent name
|
|
138
|
+
* @param toAgents - Recipient agent names
|
|
139
|
+
* @param subject - Message subject
|
|
140
|
+
* @param body - Message body
|
|
141
|
+
* @param options - Message options
|
|
142
|
+
* @param projectPath - Optional project path for database location
|
|
143
|
+
* @param dbOverride - Optional database adapter for dependency injection
|
|
144
|
+
*/
|
|
145
|
+
export declare function sendMessage(projectKey: string, fromAgent: string, toAgents: string[], subject: string, body: string, options?: {
|
|
146
|
+
threadId?: string;
|
|
147
|
+
importance?: "low" | "normal" | "high" | "urgent";
|
|
148
|
+
ackRequired?: boolean;
|
|
149
|
+
}, projectPath?: string, dbOverride?: DatabaseAdapter): Promise<MessageSentEvent & {
|
|
150
|
+
id: number;
|
|
151
|
+
sequence: number;
|
|
152
|
+
}>;
|
|
153
|
+
/**
|
|
154
|
+
* Reserve files (creates event + updates view)
|
|
155
|
+
*
|
|
156
|
+
* @param projectKey - Project identifier
|
|
157
|
+
* @param agentName - Agent reserving the files
|
|
158
|
+
* @param paths - File paths to reserve
|
|
159
|
+
* @param options - Reservation options
|
|
160
|
+
* @param projectPath - Optional project path for database location
|
|
161
|
+
* @param dbOverride - Optional database adapter for dependency injection
|
|
162
|
+
*/
|
|
163
|
+
export declare function reserveFiles(projectKey: string, agentName: string, paths: string[], options?: {
|
|
164
|
+
reason?: string;
|
|
165
|
+
exclusive?: boolean;
|
|
166
|
+
ttlSeconds?: number;
|
|
167
|
+
}, projectPath?: string, dbOverride?: DatabaseAdapter): Promise<FileReservedEvent & {
|
|
168
|
+
id: number;
|
|
169
|
+
sequence: number;
|
|
170
|
+
}>;
|
|
171
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/streams/store.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EACL,KAAK,UAAU,EAEf,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACvB,MAAM,UAAU,CAAC;AAwClB;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAC/B,KAAK,EAAE,UAAU,EACjB,WAAW,CAAC,EAAE,MAAM,EACpB,UAAU,CAAC,EAAE,eAAe,GAC3B,OAAO,CAAC,UAAU,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAsCxD;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,UAAU,EAAE,EACpB,WAAW,CAAC,EAAE,MAAM,EACpB,UAAU,CAAC,EAAE,eAAe,GAC3B,OAAO,CAAC,KAAK,CAAC,UAAU,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,CAsD/D;AAED;;;;;;GAMG;AACH,wBAAsB,UAAU,CAC9B,OAAO,GAAE;IACP,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,UAAU,CA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e9D;AAED;;;;;;;;;GASG;AACH,wBAAsB,YAAY,CAChC,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EAAE,EACf,OAAO,GAAE;IACP,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CAChB,EACN,WAAW,CAAC,EAAE,MAAM,EACpB,UAAU,CAAC,EAAE,eAAe,GAC3B,OAAO,CAAC,iBAAiB,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAe/D"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
export interface SwarmMailContext {
|
|
2
|
+
projectKey: string;
|
|
3
|
+
agentName: string;
|
|
4
|
+
}
|
|
5
|
+
export interface InitSwarmAgentOptions {
|
|
6
|
+
projectPath: string;
|
|
7
|
+
agentName?: string;
|
|
8
|
+
program?: string;
|
|
9
|
+
model?: string;
|
|
10
|
+
taskDescription?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface SendSwarmMessageOptions {
|
|
13
|
+
projectPath: string;
|
|
14
|
+
fromAgent: string;
|
|
15
|
+
toAgents: string[];
|
|
16
|
+
subject: string;
|
|
17
|
+
body: string;
|
|
18
|
+
threadId?: string;
|
|
19
|
+
importance?: "low" | "normal" | "high" | "urgent";
|
|
20
|
+
ackRequired?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface SendSwarmMessageResult {
|
|
23
|
+
success: boolean;
|
|
24
|
+
messageId: number;
|
|
25
|
+
threadId?: string;
|
|
26
|
+
recipientCount: number;
|
|
27
|
+
}
|
|
28
|
+
export interface GetSwarmInboxOptions {
|
|
29
|
+
projectPath: string;
|
|
30
|
+
agentName: string;
|
|
31
|
+
limit?: number;
|
|
32
|
+
urgentOnly?: boolean;
|
|
33
|
+
unreadOnly?: boolean;
|
|
34
|
+
includeBodies?: boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface SwarmInboxMessage {
|
|
37
|
+
id: number;
|
|
38
|
+
from_agent: string;
|
|
39
|
+
subject: string;
|
|
40
|
+
body?: string;
|
|
41
|
+
thread_id: string | null;
|
|
42
|
+
importance: string;
|
|
43
|
+
created_at: number;
|
|
44
|
+
}
|
|
45
|
+
export interface SwarmInboxResult {
|
|
46
|
+
messages: SwarmInboxMessage[];
|
|
47
|
+
total: number;
|
|
48
|
+
}
|
|
49
|
+
export interface ReadSwarmMessageOptions {
|
|
50
|
+
projectPath: string;
|
|
51
|
+
messageId: number;
|
|
52
|
+
agentName?: string;
|
|
53
|
+
markAsRead?: boolean;
|
|
54
|
+
}
|
|
55
|
+
export interface ReserveSwarmFilesOptions {
|
|
56
|
+
projectPath: string;
|
|
57
|
+
agentName: string;
|
|
58
|
+
paths: string[];
|
|
59
|
+
reason?: string;
|
|
60
|
+
exclusive?: boolean;
|
|
61
|
+
ttlSeconds?: number;
|
|
62
|
+
force?: boolean;
|
|
63
|
+
}
|
|
64
|
+
export interface GrantedSwarmReservation {
|
|
65
|
+
id: number;
|
|
66
|
+
path_pattern: string;
|
|
67
|
+
exclusive: boolean;
|
|
68
|
+
expiresAt: number;
|
|
69
|
+
}
|
|
70
|
+
export interface SwarmReservationConflict {
|
|
71
|
+
path: string;
|
|
72
|
+
holder: string;
|
|
73
|
+
pattern: string;
|
|
74
|
+
}
|
|
75
|
+
export interface ReserveSwarmFilesResult {
|
|
76
|
+
granted: GrantedSwarmReservation[];
|
|
77
|
+
conflicts: SwarmReservationConflict[];
|
|
78
|
+
}
|
|
79
|
+
export interface ReleaseSwarmFilesOptions {
|
|
80
|
+
projectPath: string;
|
|
81
|
+
agentName: string;
|
|
82
|
+
paths?: string[];
|
|
83
|
+
reservationIds?: number[];
|
|
84
|
+
}
|
|
85
|
+
export interface ReleaseSwarmFilesResult {
|
|
86
|
+
released: number;
|
|
87
|
+
releasedAt: number;
|
|
88
|
+
}
|
|
89
|
+
export interface AcknowledgeSwarmOptions {
|
|
90
|
+
projectPath: string;
|
|
91
|
+
messageId: number;
|
|
92
|
+
agentName: string;
|
|
93
|
+
}
|
|
94
|
+
export interface AcknowledgeSwarmResult {
|
|
95
|
+
acknowledged: boolean;
|
|
96
|
+
acknowledgedAt: string | null;
|
|
97
|
+
}
|
|
98
|
+
export interface SwarmHealthResult {
|
|
99
|
+
healthy: boolean;
|
|
100
|
+
database: "connected" | "disconnected";
|
|
101
|
+
stats?: {
|
|
102
|
+
events: number;
|
|
103
|
+
agents: number;
|
|
104
|
+
messages: number;
|
|
105
|
+
reservations: number;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Initialize a swarm agent for this session
|
|
110
|
+
*
|
|
111
|
+
* Future: Can use DurableMailbox.create() for actor-style message consumption
|
|
112
|
+
*/
|
|
113
|
+
export declare function initSwarmAgent(options: InitSwarmAgentOptions): Promise<SwarmMailContext>;
|
|
114
|
+
/**
|
|
115
|
+
* Send a message to other swarm agents
|
|
116
|
+
*
|
|
117
|
+
* Future: Use DurableMailbox.send() for envelope pattern with replyTo support
|
|
118
|
+
*/
|
|
119
|
+
export declare function sendSwarmMessage(options: SendSwarmMessageOptions): Promise<SendSwarmMessageResult>;
|
|
120
|
+
/**
|
|
121
|
+
* Get inbox messages for a swarm agent
|
|
122
|
+
*
|
|
123
|
+
* Future: Use DurableCursor.consume() for positioned consumption with checkpointing
|
|
124
|
+
*/
|
|
125
|
+
export declare function getSwarmInbox(options: GetSwarmInboxOptions): Promise<SwarmInboxResult>;
|
|
126
|
+
/**
|
|
127
|
+
* Read a single message with full body
|
|
128
|
+
*/
|
|
129
|
+
export declare function readSwarmMessage(options: ReadSwarmMessageOptions): Promise<SwarmInboxMessage | null>;
|
|
130
|
+
/**
|
|
131
|
+
* Reserve files for exclusive editing
|
|
132
|
+
*
|
|
133
|
+
* Always grants reservations (even with conflicts) - conflicts are warnings, not blockers.
|
|
134
|
+
* This matches the test expectations and allows agents to proceed with awareness.
|
|
135
|
+
*
|
|
136
|
+
* Future: Use DurableLock.acquire() for distributed mutex with automatic expiry
|
|
137
|
+
*/
|
|
138
|
+
export declare function reserveSwarmFiles(options: ReserveSwarmFilesOptions): Promise<ReserveSwarmFilesResult>;
|
|
139
|
+
/**
|
|
140
|
+
* Release file reservations
|
|
141
|
+
*
|
|
142
|
+
* Future: Use DurableLock.release() for automatic cleanup
|
|
143
|
+
*/
|
|
144
|
+
export declare function releaseSwarmFiles(options: ReleaseSwarmFilesOptions): Promise<ReleaseSwarmFilesResult>;
|
|
145
|
+
/**
|
|
146
|
+
* Acknowledge a swarm message
|
|
147
|
+
*/
|
|
148
|
+
export declare function acknowledgeSwarmMessage(options: AcknowledgeSwarmOptions): Promise<AcknowledgeSwarmResult>;
|
|
149
|
+
/**
|
|
150
|
+
* Check if the swarm mail store is healthy
|
|
151
|
+
*/
|
|
152
|
+
export declare function checkSwarmHealth(projectPath?: string): Promise<SwarmHealthResult>;
|
|
153
|
+
//# sourceMappingURL=swarm-mail.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swarm-mail.d.ts","sourceRoot":"","sources":["../../src/streams/swarm-mail.ts"],"names":[],"mappings":"AAmFA,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,qBAAqB;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,uBAAuB;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,IA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