db4ai 0.3.0 → 0.3.1
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/dist/chunk-3DWAMVV5.js +305 -0
- package/dist/chunk-3DWAMVV5.js.map +1 -0
- package/dist/chunk-COTPYBYM.js +618 -0
- package/dist/chunk-COTPYBYM.js.map +1 -0
- package/dist/chunk-EERD6CDF.js +735 -0
- package/dist/chunk-EERD6CDF.js.map +1 -0
- package/dist/chunk-FUF4HJTC.js +758 -0
- package/dist/chunk-FUF4HJTC.js.map +1 -0
- package/dist/chunk-JLL6FH5L.js +16 -0
- package/dist/chunk-JLL6FH5L.js.map +1 -0
- package/dist/chunk-JXFW6AIT.js +192 -0
- package/dist/chunk-JXFW6AIT.js.map +1 -0
- package/dist/chunk-XLSYCQPG.js +854 -0
- package/dist/chunk-XLSYCQPG.js.map +1 -0
- package/dist/chunk-Y5IXAS7F.js +569 -0
- package/dist/chunk-Y5IXAS7F.js.map +1 -0
- package/dist/cli/bin.d.ts +13 -12
- package/dist/cli/bin.js +277 -307
- package/dist/cli/bin.js.map +1 -1
- package/dist/cli/dashboard/index.d.ts +295 -14
- package/dist/cli/dashboard/index.js +60 -15
- package/dist/cli/dashboard/index.js.map +1 -1
- package/dist/cli/index.d.ts +10 -16
- package/dist/cli/index.js +94 -47
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/runtime/index.d.ts +52 -23
- package/dist/cli/runtime/index.js +10 -704
- package/dist/cli/runtime/index.js.map +1 -1
- package/dist/cli/scanner/index.d.ts +17 -15
- package/dist/cli/scanner/index.js +8 -639
- package/dist/cli/scanner/index.js.map +1 -1
- package/dist/cli/seed/index.d.ts +16 -12
- package/dist/cli/seed/index.js +12 -773
- package/dist/cli/seed/index.js.map +1 -1
- package/dist/cli/sync/index.d.ts +54 -53
- package/dist/cli/sync/index.js +23 -704
- package/dist/cli/sync/index.js.map +1 -1
- package/dist/cli/terminal.d.ts +9 -8
- package/dist/cli/terminal.js +6 -209
- package/dist/cli/terminal.js.map +1 -1
- package/dist/cli/workflow/index.d.ts +18 -10
- package/dist/cli/workflow/index.js +6 -307
- package/dist/cli/workflow/index.js.map +1 -1
- package/dist/handlers.d.ts +10 -9
- package/dist/handlers.js +6 -38
- package/dist/handlers.js.map +1 -1
- package/dist/index.d.ts +120 -118
- package/dist/index.js +1963 -3125
- package/dist/index.js.map +1 -1
- package/package.json +3 -4
- package/dist/cli/bin.d.ts.map +0 -1
- package/dist/cli/dashboard/App.d.ts +0 -16
- package/dist/cli/dashboard/App.d.ts.map +0 -1
- package/dist/cli/dashboard/App.js +0 -116
- package/dist/cli/dashboard/App.js.map +0 -1
- package/dist/cli/dashboard/components/index.d.ts +0 -70
- package/dist/cli/dashboard/components/index.d.ts.map +0 -1
- package/dist/cli/dashboard/components/index.js +0 -192
- package/dist/cli/dashboard/components/index.js.map +0 -1
- package/dist/cli/dashboard/hooks/index.d.ts +0 -76
- package/dist/cli/dashboard/hooks/index.d.ts.map +0 -1
- package/dist/cli/dashboard/hooks/index.js +0 -201
- package/dist/cli/dashboard/hooks/index.js.map +0 -1
- package/dist/cli/dashboard/index.d.ts.map +0 -1
- package/dist/cli/dashboard/types.d.ts +0 -84
- package/dist/cli/dashboard/types.d.ts.map +0 -1
- package/dist/cli/dashboard/types.js +0 -5
- package/dist/cli/dashboard/types.js.map +0 -1
- package/dist/cli/dashboard/views/index.d.ts +0 -51
- package/dist/cli/dashboard/views/index.d.ts.map +0 -1
- package/dist/cli/dashboard/views/index.js +0 -72
- package/dist/cli/dashboard/views/index.js.map +0 -1
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/runtime/index.d.ts.map +0 -1
- package/dist/cli/scanner/index.d.ts.map +0 -1
- package/dist/cli/seed/index.d.ts.map +0 -1
- package/dist/cli/sync/index.d.ts.map +0 -1
- package/dist/cli/terminal.d.ts.map +0 -1
- package/dist/cli/workflow/index.d.ts.map +0 -1
- package/dist/errors.d.ts +0 -43
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -47
- package/dist/errors.js.map +0 -1
- package/dist/handlers.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/types.d.ts +0 -276
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -12
- package/dist/types.js.map +0 -1
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import Database from 'better-sqlite3';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Module 14: Local Runtime
|
|
3
5
|
*
|
|
@@ -5,8 +7,8 @@
|
|
|
5
7
|
* Provides the same interface as the Cloudflare Durable Object for
|
|
6
8
|
* seamless local development and testing.
|
|
7
9
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
|
|
11
|
+
interface Thing {
|
|
10
12
|
rowid: number;
|
|
11
13
|
type: string;
|
|
12
14
|
id: string;
|
|
@@ -15,28 +17,28 @@ export interface Thing {
|
|
|
15
17
|
created_at: number;
|
|
16
18
|
created_by_action?: number;
|
|
17
19
|
}
|
|
18
|
-
|
|
20
|
+
interface UpsertResult {
|
|
19
21
|
rowid: number;
|
|
20
22
|
created: boolean;
|
|
21
23
|
}
|
|
22
|
-
|
|
24
|
+
interface UpsertParams {
|
|
23
25
|
type: string;
|
|
24
26
|
id: string;
|
|
25
27
|
data: Record<string, unknown>;
|
|
26
28
|
created_by_action?: number;
|
|
27
29
|
}
|
|
28
|
-
|
|
30
|
+
interface GetParams {
|
|
29
31
|
type: string;
|
|
30
32
|
id: string;
|
|
31
33
|
}
|
|
32
|
-
|
|
34
|
+
interface ListParams {
|
|
33
35
|
type?: string;
|
|
34
36
|
limit?: number;
|
|
35
37
|
offset?: number;
|
|
36
38
|
where?: Record<string, unknown>;
|
|
37
39
|
order?: 'asc' | 'desc';
|
|
38
40
|
}
|
|
39
|
-
|
|
41
|
+
interface Relationship {
|
|
40
42
|
rowid: number;
|
|
41
43
|
from_rowid: number;
|
|
42
44
|
to_rowid: number;
|
|
@@ -46,7 +48,7 @@ export interface Relationship {
|
|
|
46
48
|
created_at: number;
|
|
47
49
|
created_by_action?: number;
|
|
48
50
|
}
|
|
49
|
-
|
|
51
|
+
interface CreateRelationshipParams {
|
|
50
52
|
from_rowid: number;
|
|
51
53
|
to_rowid: number;
|
|
52
54
|
type: string;
|
|
@@ -54,24 +56,24 @@ export interface CreateRelationshipParams {
|
|
|
54
56
|
label: string;
|
|
55
57
|
created_by_action?: number;
|
|
56
58
|
}
|
|
57
|
-
|
|
59
|
+
interface TraverseParams {
|
|
58
60
|
from_rowid: number;
|
|
59
61
|
type?: string;
|
|
60
62
|
}
|
|
61
|
-
|
|
63
|
+
interface IncomingParams {
|
|
62
64
|
to_rowid: number;
|
|
63
65
|
type?: string;
|
|
64
66
|
}
|
|
65
|
-
|
|
67
|
+
interface TraverseMultiHopParams {
|
|
66
68
|
from_rowid: number;
|
|
67
69
|
depth: number;
|
|
68
70
|
type?: string;
|
|
69
71
|
}
|
|
70
|
-
|
|
72
|
+
interface TraverseMultiHopResult {
|
|
71
73
|
to_rowid: number;
|
|
72
74
|
depth: number;
|
|
73
75
|
}
|
|
74
|
-
|
|
76
|
+
interface Action {
|
|
75
77
|
rowid: number;
|
|
76
78
|
type: 'mutation' | 'generation' | 'resolution' | 'function' | 'evaluate';
|
|
77
79
|
input_hash: string;
|
|
@@ -84,22 +86,22 @@ export interface Action {
|
|
|
84
86
|
cost_tokens?: number;
|
|
85
87
|
created_at: number;
|
|
86
88
|
}
|
|
87
|
-
|
|
89
|
+
interface CreateActionParams {
|
|
88
90
|
type: 'mutation' | 'generation' | 'resolution' | 'function' | 'evaluate';
|
|
89
91
|
input: Record<string, unknown>;
|
|
90
92
|
model?: string;
|
|
91
93
|
}
|
|
92
|
-
|
|
94
|
+
interface CompleteActionParams {
|
|
93
95
|
rowid: number;
|
|
94
96
|
output: Record<string, unknown>;
|
|
95
97
|
duration_ms?: number;
|
|
96
98
|
cost_tokens?: number;
|
|
97
99
|
}
|
|
98
|
-
|
|
100
|
+
interface FailActionParams {
|
|
99
101
|
rowid: number;
|
|
100
102
|
error: string;
|
|
101
103
|
}
|
|
102
|
-
|
|
104
|
+
interface DBEvent {
|
|
103
105
|
rowid: number;
|
|
104
106
|
type: string;
|
|
105
107
|
action: 'created' | 'updated' | 'deleted' | 'generated';
|
|
@@ -112,7 +114,7 @@ export interface DBEvent {
|
|
|
112
114
|
action_id?: number;
|
|
113
115
|
correlation_id?: string;
|
|
114
116
|
}
|
|
115
|
-
|
|
117
|
+
interface EmitEventParams {
|
|
116
118
|
type: string;
|
|
117
119
|
action: 'created' | 'updated' | 'deleted' | 'generated';
|
|
118
120
|
entity_type: string;
|
|
@@ -123,23 +125,50 @@ export interface EmitEventParams {
|
|
|
123
125
|
action_id?: number;
|
|
124
126
|
correlation_id?: string;
|
|
125
127
|
}
|
|
126
|
-
|
|
128
|
+
interface ListEventsParams {
|
|
127
129
|
type?: string;
|
|
128
130
|
action?: 'created' | 'updated' | 'deleted' | 'generated';
|
|
129
131
|
since?: number;
|
|
130
132
|
correlation_id?: string;
|
|
131
133
|
limit?: number;
|
|
132
134
|
}
|
|
133
|
-
|
|
135
|
+
/**
|
|
136
|
+
* Connection pool for reusing database instances.
|
|
137
|
+
* SQLite with better-sqlite3 uses file-level locking, so we maintain
|
|
138
|
+
* a singleton instance per database path to avoid resource contention.
|
|
139
|
+
*/
|
|
140
|
+
declare class ConnectionPool {
|
|
141
|
+
private static instances;
|
|
142
|
+
/**
|
|
143
|
+
* Acquire a database connection. Creates a new one or returns existing.
|
|
144
|
+
*/
|
|
145
|
+
static acquire(dbPath: string): Database.Database;
|
|
146
|
+
/**
|
|
147
|
+
* Release a database connection. Closes when ref count reaches 0.
|
|
148
|
+
*/
|
|
149
|
+
static release(dbPath: string): void;
|
|
150
|
+
/**
|
|
151
|
+
* Force close all connections (for testing cleanup).
|
|
152
|
+
*/
|
|
153
|
+
static closeAll(): void;
|
|
154
|
+
}
|
|
155
|
+
declare class LocalDB {
|
|
134
156
|
private db;
|
|
157
|
+
private usePool;
|
|
135
158
|
readonly path: string;
|
|
136
159
|
readonly version: number;
|
|
137
160
|
readonly things: ThingsAPI;
|
|
138
161
|
readonly relationships: RelationshipsAPI;
|
|
139
162
|
readonly actions: ActionsAPI;
|
|
140
163
|
readonly events: EventsAPI;
|
|
141
|
-
constructor(dbPath?: string
|
|
164
|
+
constructor(dbPath?: string, options?: {
|
|
165
|
+
usePool?: boolean;
|
|
166
|
+
});
|
|
142
167
|
private initSchema;
|
|
168
|
+
/**
|
|
169
|
+
* Run any pending database migrations.
|
|
170
|
+
*/
|
|
171
|
+
private runMigrations;
|
|
143
172
|
/**
|
|
144
173
|
* Closes the database connection.
|
|
145
174
|
*/
|
|
@@ -232,5 +261,5 @@ declare class EventsAPI {
|
|
|
232
261
|
*/
|
|
233
262
|
list(params?: ListEventsParams): Promise<DBEvent[]>;
|
|
234
263
|
}
|
|
235
|
-
|
|
236
|
-
|
|
264
|
+
|
|
265
|
+
export { type Action, type CompleteActionParams, ConnectionPool, type CreateActionParams, type CreateRelationshipParams, type DBEvent, type EmitEventParams, type FailActionParams, type GetParams, type IncomingParams, type ListEventsParams, type ListParams, LocalDB, type Relationship, type Thing, type TraverseMultiHopParams, type TraverseMultiHopResult, type TraverseParams, type UpsertParams, type UpsertResult, LocalDB as default };
|