@aigne/afs 1.0.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/CHANGELOG.md +15 -0
- package/LICENSE.md +93 -0
- package/lib/cjs/afs.d.ts +26 -0
- package/lib/cjs/afs.js +126 -0
- package/lib/cjs/history/index.d.ts +14 -0
- package/lib/cjs/history/index.js +45 -0
- package/lib/cjs/index.d.ts +4 -0
- package/lib/cjs/index.js +20 -0
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/storage/index.d.ts +24 -0
- package/lib/cjs/storage/index.js +72 -0
- package/lib/cjs/storage/migrate.d.ts +3 -0
- package/lib/cjs/storage/migrate.js +31 -0
- package/lib/cjs/storage/migrations/001-init.d.ts +2 -0
- package/lib/cjs/storage/migrations/001-init.js +25 -0
- package/lib/cjs/storage/models/entries.d.ts +199 -0
- package/lib/cjs/storage/models/entries.js +28 -0
- package/lib/cjs/storage/type.d.ts +23 -0
- package/lib/cjs/storage/type.js +2 -0
- package/lib/cjs/type.d.ts +54 -0
- package/lib/cjs/type.js +2 -0
- package/lib/dts/afs.d.ts +26 -0
- package/lib/dts/history/index.d.ts +14 -0
- package/lib/dts/index.d.ts +4 -0
- package/lib/dts/storage/index.d.ts +24 -0
- package/lib/dts/storage/migrate.d.ts +3 -0
- package/lib/dts/storage/migrations/001-init.d.ts +2 -0
- package/lib/dts/storage/models/entries.d.ts +199 -0
- package/lib/dts/storage/type.d.ts +23 -0
- package/lib/dts/type.d.ts +54 -0
- package/lib/esm/afs.d.ts +26 -0
- package/lib/esm/afs.js +122 -0
- package/lib/esm/history/index.d.ts +14 -0
- package/lib/esm/history/index.js +41 -0
- package/lib/esm/index.d.ts +4 -0
- package/lib/esm/index.js +4 -0
- package/lib/esm/package.json +3 -0
- package/lib/esm/storage/index.d.ts +24 -0
- package/lib/esm/storage/index.js +67 -0
- package/lib/esm/storage/migrate.d.ts +3 -0
- package/lib/esm/storage/migrate.js +28 -0
- package/lib/esm/storage/migrations/001-init.d.ts +2 -0
- package/lib/esm/storage/migrations/001-init.js +22 -0
- package/lib/esm/storage/models/entries.d.ts +199 -0
- package/lib/esm/storage/models/entries.js +23 -0
- package/lib/esm/storage/type.d.ts +23 -0
- package/lib/esm/storage/type.js +1 -0
- package/lib/esm/type.d.ts +54 -0
- package/lib/esm/type.js +1 -0
- package/package.json +69 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import type { AFSModule } from "../../type.js";
|
|
2
|
+
export declare const entriesTableName: (module: AFSModule) => string;
|
|
3
|
+
export declare const entriesTable: (module: AFSModule) => import("@aigne/sqlite").SQLiteTableWithColumns<{
|
|
4
|
+
name: string;
|
|
5
|
+
schema: undefined;
|
|
6
|
+
columns: {
|
|
7
|
+
id: import("@aigne/sqlite").SQLiteColumn<{
|
|
8
|
+
name: "id";
|
|
9
|
+
tableName: string;
|
|
10
|
+
dataType: "string";
|
|
11
|
+
columnType: "SQLiteText";
|
|
12
|
+
data: string;
|
|
13
|
+
driverParam: string;
|
|
14
|
+
notNull: true;
|
|
15
|
+
hasDefault: true;
|
|
16
|
+
isPrimaryKey: true;
|
|
17
|
+
isAutoincrement: false;
|
|
18
|
+
hasRuntimeDefault: true;
|
|
19
|
+
enumValues: [string, ...string[]];
|
|
20
|
+
baseColumn: never;
|
|
21
|
+
identity: undefined;
|
|
22
|
+
generated: undefined;
|
|
23
|
+
}, {}, {
|
|
24
|
+
length: number | undefined;
|
|
25
|
+
}>;
|
|
26
|
+
createdAt: import("@aigne/sqlite").SQLiteColumn<{
|
|
27
|
+
name: "createdAt";
|
|
28
|
+
tableName: string;
|
|
29
|
+
dataType: "custom";
|
|
30
|
+
columnType: "SQLiteCustomColumn";
|
|
31
|
+
data: Date;
|
|
32
|
+
driverParam: string;
|
|
33
|
+
notNull: true;
|
|
34
|
+
hasDefault: true;
|
|
35
|
+
isPrimaryKey: false;
|
|
36
|
+
isAutoincrement: false;
|
|
37
|
+
hasRuntimeDefault: true;
|
|
38
|
+
enumValues: undefined;
|
|
39
|
+
baseColumn: never;
|
|
40
|
+
identity: undefined;
|
|
41
|
+
generated: undefined;
|
|
42
|
+
}, {}, {
|
|
43
|
+
sqliteColumnBuilderBrand: "SQLiteCustomColumnBuilderBrand";
|
|
44
|
+
}>;
|
|
45
|
+
updatedAt: import("@aigne/sqlite").SQLiteColumn<{
|
|
46
|
+
name: "updatedAt";
|
|
47
|
+
tableName: string;
|
|
48
|
+
dataType: "custom";
|
|
49
|
+
columnType: "SQLiteCustomColumn";
|
|
50
|
+
data: Date;
|
|
51
|
+
driverParam: string;
|
|
52
|
+
notNull: true;
|
|
53
|
+
hasDefault: true;
|
|
54
|
+
isPrimaryKey: false;
|
|
55
|
+
isAutoincrement: false;
|
|
56
|
+
hasRuntimeDefault: true;
|
|
57
|
+
enumValues: undefined;
|
|
58
|
+
baseColumn: never;
|
|
59
|
+
identity: undefined;
|
|
60
|
+
generated: undefined;
|
|
61
|
+
}, {}, {
|
|
62
|
+
sqliteColumnBuilderBrand: "SQLiteCustomColumnBuilderBrand";
|
|
63
|
+
}>;
|
|
64
|
+
path: import("@aigne/sqlite").SQLiteColumn<{
|
|
65
|
+
name: "path";
|
|
66
|
+
tableName: string;
|
|
67
|
+
dataType: "string";
|
|
68
|
+
columnType: "SQLiteText";
|
|
69
|
+
data: string;
|
|
70
|
+
driverParam: string;
|
|
71
|
+
notNull: true;
|
|
72
|
+
hasDefault: false;
|
|
73
|
+
isPrimaryKey: false;
|
|
74
|
+
isAutoincrement: false;
|
|
75
|
+
hasRuntimeDefault: false;
|
|
76
|
+
enumValues: [string, ...string[]];
|
|
77
|
+
baseColumn: never;
|
|
78
|
+
identity: undefined;
|
|
79
|
+
generated: undefined;
|
|
80
|
+
}, {}, {
|
|
81
|
+
length: number | undefined;
|
|
82
|
+
}>;
|
|
83
|
+
userId: import("@aigne/sqlite").SQLiteColumn<{
|
|
84
|
+
name: "userId";
|
|
85
|
+
tableName: string;
|
|
86
|
+
dataType: "string";
|
|
87
|
+
columnType: "SQLiteText";
|
|
88
|
+
data: string;
|
|
89
|
+
driverParam: string;
|
|
90
|
+
notNull: false;
|
|
91
|
+
hasDefault: false;
|
|
92
|
+
isPrimaryKey: false;
|
|
93
|
+
isAutoincrement: false;
|
|
94
|
+
hasRuntimeDefault: false;
|
|
95
|
+
enumValues: [string, ...string[]];
|
|
96
|
+
baseColumn: never;
|
|
97
|
+
identity: undefined;
|
|
98
|
+
generated: undefined;
|
|
99
|
+
}, {}, {
|
|
100
|
+
length: number | undefined;
|
|
101
|
+
}>;
|
|
102
|
+
sessionId: import("@aigne/sqlite").SQLiteColumn<{
|
|
103
|
+
name: "sessionId";
|
|
104
|
+
tableName: string;
|
|
105
|
+
dataType: "string";
|
|
106
|
+
columnType: "SQLiteText";
|
|
107
|
+
data: string;
|
|
108
|
+
driverParam: string;
|
|
109
|
+
notNull: false;
|
|
110
|
+
hasDefault: false;
|
|
111
|
+
isPrimaryKey: false;
|
|
112
|
+
isAutoincrement: false;
|
|
113
|
+
hasRuntimeDefault: false;
|
|
114
|
+
enumValues: [string, ...string[]];
|
|
115
|
+
baseColumn: never;
|
|
116
|
+
identity: undefined;
|
|
117
|
+
generated: undefined;
|
|
118
|
+
}, {}, {
|
|
119
|
+
length: number | undefined;
|
|
120
|
+
}>;
|
|
121
|
+
summary: import("@aigne/sqlite").SQLiteColumn<{
|
|
122
|
+
name: "summary";
|
|
123
|
+
tableName: string;
|
|
124
|
+
dataType: "string";
|
|
125
|
+
columnType: "SQLiteText";
|
|
126
|
+
data: string;
|
|
127
|
+
driverParam: string;
|
|
128
|
+
notNull: false;
|
|
129
|
+
hasDefault: false;
|
|
130
|
+
isPrimaryKey: false;
|
|
131
|
+
isAutoincrement: false;
|
|
132
|
+
hasRuntimeDefault: false;
|
|
133
|
+
enumValues: [string, ...string[]];
|
|
134
|
+
baseColumn: never;
|
|
135
|
+
identity: undefined;
|
|
136
|
+
generated: undefined;
|
|
137
|
+
}, {}, {
|
|
138
|
+
length: number | undefined;
|
|
139
|
+
}>;
|
|
140
|
+
metadata: import("@aigne/sqlite").SQLiteColumn<{
|
|
141
|
+
name: string;
|
|
142
|
+
tableName: string;
|
|
143
|
+
dataType: "custom";
|
|
144
|
+
columnType: "SQLiteCustomColumn";
|
|
145
|
+
data: Record<string, unknown>;
|
|
146
|
+
driverParam: string;
|
|
147
|
+
notNull: false;
|
|
148
|
+
hasDefault: false;
|
|
149
|
+
isPrimaryKey: false;
|
|
150
|
+
isAutoincrement: false;
|
|
151
|
+
hasRuntimeDefault: false;
|
|
152
|
+
enumValues: undefined;
|
|
153
|
+
baseColumn: never;
|
|
154
|
+
identity: undefined;
|
|
155
|
+
generated: undefined;
|
|
156
|
+
}, {}, {
|
|
157
|
+
sqliteColumnBuilderBrand: "SQLiteCustomColumnBuilderBrand";
|
|
158
|
+
}>;
|
|
159
|
+
linkTo: import("@aigne/sqlite").SQLiteColumn<{
|
|
160
|
+
name: "linkTo";
|
|
161
|
+
tableName: string;
|
|
162
|
+
dataType: "string";
|
|
163
|
+
columnType: "SQLiteText";
|
|
164
|
+
data: string;
|
|
165
|
+
driverParam: string;
|
|
166
|
+
notNull: false;
|
|
167
|
+
hasDefault: false;
|
|
168
|
+
isPrimaryKey: false;
|
|
169
|
+
isAutoincrement: false;
|
|
170
|
+
hasRuntimeDefault: false;
|
|
171
|
+
enumValues: [string, ...string[]];
|
|
172
|
+
baseColumn: never;
|
|
173
|
+
identity: undefined;
|
|
174
|
+
generated: undefined;
|
|
175
|
+
}, {}, {
|
|
176
|
+
length: number | undefined;
|
|
177
|
+
}>;
|
|
178
|
+
content: import("@aigne/sqlite").SQLiteColumn<{
|
|
179
|
+
name: string;
|
|
180
|
+
tableName: string;
|
|
181
|
+
dataType: "custom";
|
|
182
|
+
columnType: "SQLiteCustomColumn";
|
|
183
|
+
data: any;
|
|
184
|
+
driverParam: string;
|
|
185
|
+
notNull: false;
|
|
186
|
+
hasDefault: false;
|
|
187
|
+
isPrimaryKey: false;
|
|
188
|
+
isAutoincrement: false;
|
|
189
|
+
hasRuntimeDefault: false;
|
|
190
|
+
enumValues: undefined;
|
|
191
|
+
baseColumn: never;
|
|
192
|
+
identity: undefined;
|
|
193
|
+
generated: undefined;
|
|
194
|
+
}, {}, {
|
|
195
|
+
sqliteColumnBuilderBrand: "SQLiteCustomColumnBuilderBrand";
|
|
196
|
+
}>;
|
|
197
|
+
};
|
|
198
|
+
dialect: "sqlite";
|
|
199
|
+
}>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.entriesTable = exports.entriesTableName = void 0;
|
|
4
|
+
const sqlite_1 = require("@aigne/sqlite");
|
|
5
|
+
const uuid_1 = require("@aigne/uuid");
|
|
6
|
+
const entriesTableName = (module) => `Entries_${module.moduleId}`;
|
|
7
|
+
exports.entriesTableName = entriesTableName;
|
|
8
|
+
const entriesTable = (module) => (0, sqlite_1.sqliteTable)((0, exports.entriesTableName)(module), {
|
|
9
|
+
id: (0, sqlite_1.text)("id")
|
|
10
|
+
.notNull()
|
|
11
|
+
.primaryKey()
|
|
12
|
+
.$defaultFn(() => (0, uuid_1.v7)()),
|
|
13
|
+
createdAt: (0, sqlite_1.datetime)("createdAt")
|
|
14
|
+
.notNull()
|
|
15
|
+
.$defaultFn(() => new Date()),
|
|
16
|
+
updatedAt: (0, sqlite_1.datetime)("updatedAt")
|
|
17
|
+
.notNull()
|
|
18
|
+
.$defaultFn(() => new Date())
|
|
19
|
+
.$onUpdateFn(() => new Date()),
|
|
20
|
+
path: (0, sqlite_1.text)("path").notNull(),
|
|
21
|
+
userId: (0, sqlite_1.text)("userId"),
|
|
22
|
+
sessionId: (0, sqlite_1.text)("sessionId"),
|
|
23
|
+
summary: (0, sqlite_1.text)("summary"),
|
|
24
|
+
metadata: (0, sqlite_1.json)("metadata"),
|
|
25
|
+
linkTo: (0, sqlite_1.text)("linkTo"),
|
|
26
|
+
content: (0, sqlite_1.json)("content"),
|
|
27
|
+
});
|
|
28
|
+
exports.entriesTable = entriesTable;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { SQL } from "@aigne/sqlite";
|
|
2
|
+
import type { AFSEntry, AFSModule } from "../type.js";
|
|
3
|
+
export interface AFSStorageCreatePayload extends Omit<AFSEntry, "id"> {
|
|
4
|
+
}
|
|
5
|
+
export interface AFSStorageListOptions {
|
|
6
|
+
filter?: {
|
|
7
|
+
userId?: string;
|
|
8
|
+
sessionId?: string;
|
|
9
|
+
};
|
|
10
|
+
limit?: number;
|
|
11
|
+
orderBy?: [string, "asc" | "desc"][];
|
|
12
|
+
}
|
|
13
|
+
export interface AFSStorage {
|
|
14
|
+
create(entry: AFSStorageCreatePayload): Promise<AFSEntry>;
|
|
15
|
+
list(options?: AFSStorageListOptions): Promise<{
|
|
16
|
+
list: AFSEntry[];
|
|
17
|
+
}>;
|
|
18
|
+
read(path: string): Promise<AFSEntry | undefined>;
|
|
19
|
+
}
|
|
20
|
+
export type AFSStorageMigrations = {
|
|
21
|
+
hash: string;
|
|
22
|
+
sql: (module: AFSModule) => SQL[];
|
|
23
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Emitter } from "strict-event-emitter";
|
|
2
|
+
import type { AFSStorage } from "./storage/type.js";
|
|
3
|
+
export interface AFSListOptions {
|
|
4
|
+
filter?: {
|
|
5
|
+
userId?: string;
|
|
6
|
+
sessionId?: string;
|
|
7
|
+
};
|
|
8
|
+
recursive?: boolean;
|
|
9
|
+
maxDepth?: number;
|
|
10
|
+
limit?: number;
|
|
11
|
+
orderBy?: [string, "asc" | "desc"][];
|
|
12
|
+
}
|
|
13
|
+
export interface AFSSearchOptions {
|
|
14
|
+
limit?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface AFSWriteEntryPayload extends Omit<AFSEntry, "id" | "path"> {
|
|
17
|
+
}
|
|
18
|
+
export interface AFSModule {
|
|
19
|
+
readonly moduleId: string;
|
|
20
|
+
readonly path: string;
|
|
21
|
+
onMount?(root: AFSRoot): void;
|
|
22
|
+
list?(path: string, options?: AFSListOptions): Promise<{
|
|
23
|
+
list: AFSEntry[];
|
|
24
|
+
}>;
|
|
25
|
+
read?(path: string): Promise<AFSEntry | undefined>;
|
|
26
|
+
write?(path: string, content: AFSWriteEntryPayload): Promise<AFSEntry>;
|
|
27
|
+
search?(path: string, query: string, options?: AFSSearchOptions): Promise<{
|
|
28
|
+
list: AFSEntry[];
|
|
29
|
+
}>;
|
|
30
|
+
}
|
|
31
|
+
export type AFSRootEvents = {
|
|
32
|
+
agentSucceed: [{
|
|
33
|
+
input: object;
|
|
34
|
+
output: object;
|
|
35
|
+
}];
|
|
36
|
+
historyCreated: [{
|
|
37
|
+
entry: AFSEntry;
|
|
38
|
+
}];
|
|
39
|
+
};
|
|
40
|
+
export interface AFSRoot extends Emitter<AFSRootEvents>, AFSModule {
|
|
41
|
+
storage(module: AFSModule): AFSStorage;
|
|
42
|
+
}
|
|
43
|
+
export interface AFSEntry<T = any> {
|
|
44
|
+
id: string;
|
|
45
|
+
createdAt?: Date;
|
|
46
|
+
updatedAt?: Date;
|
|
47
|
+
path: string;
|
|
48
|
+
userId?: string | null;
|
|
49
|
+
sessionId?: string | null;
|
|
50
|
+
summary?: string | null;
|
|
51
|
+
metadata?: Record<string, any> | null;
|
|
52
|
+
linkTo?: string | null;
|
|
53
|
+
content?: T;
|
|
54
|
+
}
|
package/lib/cjs/type.js
ADDED
package/lib/dts/afs.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Emitter } from "strict-event-emitter";
|
|
2
|
+
import { SharedAFSStorage, type SharedAFSStorageOptions } from "./storage/index.js";
|
|
3
|
+
import type { AFSStorage } from "./storage/type.js";
|
|
4
|
+
import type { AFSEntry, AFSListOptions, AFSModule, AFSRoot, AFSRootEvents, AFSSearchOptions, AFSWriteEntryPayload } from "./type.js";
|
|
5
|
+
export interface AFSOptions {
|
|
6
|
+
storage?: SharedAFSStorage | SharedAFSStorageOptions;
|
|
7
|
+
}
|
|
8
|
+
export declare class AFS extends Emitter<AFSRootEvents> implements AFSRoot {
|
|
9
|
+
moduleId: string;
|
|
10
|
+
path: string;
|
|
11
|
+
constructor(options?: AFSOptions);
|
|
12
|
+
private _storage;
|
|
13
|
+
storage(module: AFSModule): AFSStorage;
|
|
14
|
+
private modules;
|
|
15
|
+
use(module: AFSModule): this;
|
|
16
|
+
list(path: string, options?: AFSListOptions): Promise<{
|
|
17
|
+
list: AFSEntry[];
|
|
18
|
+
}>;
|
|
19
|
+
private findModules;
|
|
20
|
+
private isSubpath;
|
|
21
|
+
read(path: string): Promise<AFSEntry | undefined>;
|
|
22
|
+
write(path: string, content: AFSWriteEntryPayload): Promise<AFSEntry>;
|
|
23
|
+
search(path: string, query: string, options?: AFSSearchOptions): Promise<{
|
|
24
|
+
list: AFSEntry[];
|
|
25
|
+
}>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AFSEntry, AFSListOptions, AFSModule, AFSRoot, AFSWriteEntryPayload } from "../type.js";
|
|
2
|
+
export declare class AFSHistory implements AFSModule {
|
|
3
|
+
static Path: string;
|
|
4
|
+
path: string;
|
|
5
|
+
moduleId: string;
|
|
6
|
+
private _afs?;
|
|
7
|
+
get afs(): AFSRoot;
|
|
8
|
+
onMount(afs: AFSRoot): void;
|
|
9
|
+
list(path: string, options?: AFSListOptions): Promise<{
|
|
10
|
+
list: AFSEntry[];
|
|
11
|
+
}>;
|
|
12
|
+
read(path: string): Promise<AFSEntry | undefined>;
|
|
13
|
+
write(path: string, content: AFSWriteEntryPayload): Promise<AFSEntry>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { initDatabase } from "@aigne/sqlite";
|
|
2
|
+
import type { AFSEntry, AFSModule } from "../type.js";
|
|
3
|
+
import { entriesTable } from "./models/entries.js";
|
|
4
|
+
import type { AFSStorage, AFSStorageCreatePayload, AFSStorageListOptions } from "./type.js";
|
|
5
|
+
export interface SharedAFSStorageOptions {
|
|
6
|
+
url?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class SharedAFSStorage {
|
|
9
|
+
options?: SharedAFSStorageOptions | undefined;
|
|
10
|
+
constructor(options?: SharedAFSStorageOptions | undefined);
|
|
11
|
+
private _db;
|
|
12
|
+
get db(): Promise<import("drizzle-orm/libsql").LibSQLDatabase<Record<string, never>>>;
|
|
13
|
+
withModule(module: AFSModule): AFSStorage;
|
|
14
|
+
}
|
|
15
|
+
export declare class AFSStorageWithModule implements AFSStorage {
|
|
16
|
+
private db;
|
|
17
|
+
private table;
|
|
18
|
+
constructor(db: ReturnType<typeof initDatabase>, table: Promise<ReturnType<typeof entriesTable>>);
|
|
19
|
+
list(options?: AFSStorageListOptions): Promise<{
|
|
20
|
+
list: AFSEntry[];
|
|
21
|
+
}>;
|
|
22
|
+
read(path: string): Promise<AFSEntry | undefined>;
|
|
23
|
+
create(entry: AFSStorageCreatePayload): Promise<AFSEntry>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import type { AFSModule } from "../../type.js";
|
|
2
|
+
export declare const entriesTableName: (module: AFSModule) => string;
|
|
3
|
+
export declare const entriesTable: (module: AFSModule) => import("@aigne/sqlite").SQLiteTableWithColumns<{
|
|
4
|
+
name: string;
|
|
5
|
+
schema: undefined;
|
|
6
|
+
columns: {
|
|
7
|
+
id: import("@aigne/sqlite").SQLiteColumn<{
|
|
8
|
+
name: "id";
|
|
9
|
+
tableName: string;
|
|
10
|
+
dataType: "string";
|
|
11
|
+
columnType: "SQLiteText";
|
|
12
|
+
data: string;
|
|
13
|
+
driverParam: string;
|
|
14
|
+
notNull: true;
|
|
15
|
+
hasDefault: true;
|
|
16
|
+
isPrimaryKey: true;
|
|
17
|
+
isAutoincrement: false;
|
|
18
|
+
hasRuntimeDefault: true;
|
|
19
|
+
enumValues: [string, ...string[]];
|
|
20
|
+
baseColumn: never;
|
|
21
|
+
identity: undefined;
|
|
22
|
+
generated: undefined;
|
|
23
|
+
}, {}, {
|
|
24
|
+
length: number | undefined;
|
|
25
|
+
}>;
|
|
26
|
+
createdAt: import("@aigne/sqlite").SQLiteColumn<{
|
|
27
|
+
name: "createdAt";
|
|
28
|
+
tableName: string;
|
|
29
|
+
dataType: "custom";
|
|
30
|
+
columnType: "SQLiteCustomColumn";
|
|
31
|
+
data: Date;
|
|
32
|
+
driverParam: string;
|
|
33
|
+
notNull: true;
|
|
34
|
+
hasDefault: true;
|
|
35
|
+
isPrimaryKey: false;
|
|
36
|
+
isAutoincrement: false;
|
|
37
|
+
hasRuntimeDefault: true;
|
|
38
|
+
enumValues: undefined;
|
|
39
|
+
baseColumn: never;
|
|
40
|
+
identity: undefined;
|
|
41
|
+
generated: undefined;
|
|
42
|
+
}, {}, {
|
|
43
|
+
sqliteColumnBuilderBrand: "SQLiteCustomColumnBuilderBrand";
|
|
44
|
+
}>;
|
|
45
|
+
updatedAt: import("@aigne/sqlite").SQLiteColumn<{
|
|
46
|
+
name: "updatedAt";
|
|
47
|
+
tableName: string;
|
|
48
|
+
dataType: "custom";
|
|
49
|
+
columnType: "SQLiteCustomColumn";
|
|
50
|
+
data: Date;
|
|
51
|
+
driverParam: string;
|
|
52
|
+
notNull: true;
|
|
53
|
+
hasDefault: true;
|
|
54
|
+
isPrimaryKey: false;
|
|
55
|
+
isAutoincrement: false;
|
|
56
|
+
hasRuntimeDefault: true;
|
|
57
|
+
enumValues: undefined;
|
|
58
|
+
baseColumn: never;
|
|
59
|
+
identity: undefined;
|
|
60
|
+
generated: undefined;
|
|
61
|
+
}, {}, {
|
|
62
|
+
sqliteColumnBuilderBrand: "SQLiteCustomColumnBuilderBrand";
|
|
63
|
+
}>;
|
|
64
|
+
path: import("@aigne/sqlite").SQLiteColumn<{
|
|
65
|
+
name: "path";
|
|
66
|
+
tableName: string;
|
|
67
|
+
dataType: "string";
|
|
68
|
+
columnType: "SQLiteText";
|
|
69
|
+
data: string;
|
|
70
|
+
driverParam: string;
|
|
71
|
+
notNull: true;
|
|
72
|
+
hasDefault: false;
|
|
73
|
+
isPrimaryKey: false;
|
|
74
|
+
isAutoincrement: false;
|
|
75
|
+
hasRuntimeDefault: false;
|
|
76
|
+
enumValues: [string, ...string[]];
|
|
77
|
+
baseColumn: never;
|
|
78
|
+
identity: undefined;
|
|
79
|
+
generated: undefined;
|
|
80
|
+
}, {}, {
|
|
81
|
+
length: number | undefined;
|
|
82
|
+
}>;
|
|
83
|
+
userId: import("@aigne/sqlite").SQLiteColumn<{
|
|
84
|
+
name: "userId";
|
|
85
|
+
tableName: string;
|
|
86
|
+
dataType: "string";
|
|
87
|
+
columnType: "SQLiteText";
|
|
88
|
+
data: string;
|
|
89
|
+
driverParam: string;
|
|
90
|
+
notNull: false;
|
|
91
|
+
hasDefault: false;
|
|
92
|
+
isPrimaryKey: false;
|
|
93
|
+
isAutoincrement: false;
|
|
94
|
+
hasRuntimeDefault: false;
|
|
95
|
+
enumValues: [string, ...string[]];
|
|
96
|
+
baseColumn: never;
|
|
97
|
+
identity: undefined;
|
|
98
|
+
generated: undefined;
|
|
99
|
+
}, {}, {
|
|
100
|
+
length: number | undefined;
|
|
101
|
+
}>;
|
|
102
|
+
sessionId: import("@aigne/sqlite").SQLiteColumn<{
|
|
103
|
+
name: "sessionId";
|
|
104
|
+
tableName: string;
|
|
105
|
+
dataType: "string";
|
|
106
|
+
columnType: "SQLiteText";
|
|
107
|
+
data: string;
|
|
108
|
+
driverParam: string;
|
|
109
|
+
notNull: false;
|
|
110
|
+
hasDefault: false;
|
|
111
|
+
isPrimaryKey: false;
|
|
112
|
+
isAutoincrement: false;
|
|
113
|
+
hasRuntimeDefault: false;
|
|
114
|
+
enumValues: [string, ...string[]];
|
|
115
|
+
baseColumn: never;
|
|
116
|
+
identity: undefined;
|
|
117
|
+
generated: undefined;
|
|
118
|
+
}, {}, {
|
|
119
|
+
length: number | undefined;
|
|
120
|
+
}>;
|
|
121
|
+
summary: import("@aigne/sqlite").SQLiteColumn<{
|
|
122
|
+
name: "summary";
|
|
123
|
+
tableName: string;
|
|
124
|
+
dataType: "string";
|
|
125
|
+
columnType: "SQLiteText";
|
|
126
|
+
data: string;
|
|
127
|
+
driverParam: string;
|
|
128
|
+
notNull: false;
|
|
129
|
+
hasDefault: false;
|
|
130
|
+
isPrimaryKey: false;
|
|
131
|
+
isAutoincrement: false;
|
|
132
|
+
hasRuntimeDefault: false;
|
|
133
|
+
enumValues: [string, ...string[]];
|
|
134
|
+
baseColumn: never;
|
|
135
|
+
identity: undefined;
|
|
136
|
+
generated: undefined;
|
|
137
|
+
}, {}, {
|
|
138
|
+
length: number | undefined;
|
|
139
|
+
}>;
|
|
140
|
+
metadata: import("@aigne/sqlite").SQLiteColumn<{
|
|
141
|
+
name: string;
|
|
142
|
+
tableName: string;
|
|
143
|
+
dataType: "custom";
|
|
144
|
+
columnType: "SQLiteCustomColumn";
|
|
145
|
+
data: Record<string, unknown>;
|
|
146
|
+
driverParam: string;
|
|
147
|
+
notNull: false;
|
|
148
|
+
hasDefault: false;
|
|
149
|
+
isPrimaryKey: false;
|
|
150
|
+
isAutoincrement: false;
|
|
151
|
+
hasRuntimeDefault: false;
|
|
152
|
+
enumValues: undefined;
|
|
153
|
+
baseColumn: never;
|
|
154
|
+
identity: undefined;
|
|
155
|
+
generated: undefined;
|
|
156
|
+
}, {}, {
|
|
157
|
+
sqliteColumnBuilderBrand: "SQLiteCustomColumnBuilderBrand";
|
|
158
|
+
}>;
|
|
159
|
+
linkTo: import("@aigne/sqlite").SQLiteColumn<{
|
|
160
|
+
name: "linkTo";
|
|
161
|
+
tableName: string;
|
|
162
|
+
dataType: "string";
|
|
163
|
+
columnType: "SQLiteText";
|
|
164
|
+
data: string;
|
|
165
|
+
driverParam: string;
|
|
166
|
+
notNull: false;
|
|
167
|
+
hasDefault: false;
|
|
168
|
+
isPrimaryKey: false;
|
|
169
|
+
isAutoincrement: false;
|
|
170
|
+
hasRuntimeDefault: false;
|
|
171
|
+
enumValues: [string, ...string[]];
|
|
172
|
+
baseColumn: never;
|
|
173
|
+
identity: undefined;
|
|
174
|
+
generated: undefined;
|
|
175
|
+
}, {}, {
|
|
176
|
+
length: number | undefined;
|
|
177
|
+
}>;
|
|
178
|
+
content: import("@aigne/sqlite").SQLiteColumn<{
|
|
179
|
+
name: string;
|
|
180
|
+
tableName: string;
|
|
181
|
+
dataType: "custom";
|
|
182
|
+
columnType: "SQLiteCustomColumn";
|
|
183
|
+
data: any;
|
|
184
|
+
driverParam: string;
|
|
185
|
+
notNull: false;
|
|
186
|
+
hasDefault: false;
|
|
187
|
+
isPrimaryKey: false;
|
|
188
|
+
isAutoincrement: false;
|
|
189
|
+
hasRuntimeDefault: false;
|
|
190
|
+
enumValues: undefined;
|
|
191
|
+
baseColumn: never;
|
|
192
|
+
identity: undefined;
|
|
193
|
+
generated: undefined;
|
|
194
|
+
}, {}, {
|
|
195
|
+
sqliteColumnBuilderBrand: "SQLiteCustomColumnBuilderBrand";
|
|
196
|
+
}>;
|
|
197
|
+
};
|
|
198
|
+
dialect: "sqlite";
|
|
199
|
+
}>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { SQL } from "@aigne/sqlite";
|
|
2
|
+
import type { AFSEntry, AFSModule } from "../type.js";
|
|
3
|
+
export interface AFSStorageCreatePayload extends Omit<AFSEntry, "id"> {
|
|
4
|
+
}
|
|
5
|
+
export interface AFSStorageListOptions {
|
|
6
|
+
filter?: {
|
|
7
|
+
userId?: string;
|
|
8
|
+
sessionId?: string;
|
|
9
|
+
};
|
|
10
|
+
limit?: number;
|
|
11
|
+
orderBy?: [string, "asc" | "desc"][];
|
|
12
|
+
}
|
|
13
|
+
export interface AFSStorage {
|
|
14
|
+
create(entry: AFSStorageCreatePayload): Promise<AFSEntry>;
|
|
15
|
+
list(options?: AFSStorageListOptions): Promise<{
|
|
16
|
+
list: AFSEntry[];
|
|
17
|
+
}>;
|
|
18
|
+
read(path: string): Promise<AFSEntry | undefined>;
|
|
19
|
+
}
|
|
20
|
+
export type AFSStorageMigrations = {
|
|
21
|
+
hash: string;
|
|
22
|
+
sql: (module: AFSModule) => SQL[];
|
|
23
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Emitter } from "strict-event-emitter";
|
|
2
|
+
import type { AFSStorage } from "./storage/type.js";
|
|
3
|
+
export interface AFSListOptions {
|
|
4
|
+
filter?: {
|
|
5
|
+
userId?: string;
|
|
6
|
+
sessionId?: string;
|
|
7
|
+
};
|
|
8
|
+
recursive?: boolean;
|
|
9
|
+
maxDepth?: number;
|
|
10
|
+
limit?: number;
|
|
11
|
+
orderBy?: [string, "asc" | "desc"][];
|
|
12
|
+
}
|
|
13
|
+
export interface AFSSearchOptions {
|
|
14
|
+
limit?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface AFSWriteEntryPayload extends Omit<AFSEntry, "id" | "path"> {
|
|
17
|
+
}
|
|
18
|
+
export interface AFSModule {
|
|
19
|
+
readonly moduleId: string;
|
|
20
|
+
readonly path: string;
|
|
21
|
+
onMount?(root: AFSRoot): void;
|
|
22
|
+
list?(path: string, options?: AFSListOptions): Promise<{
|
|
23
|
+
list: AFSEntry[];
|
|
24
|
+
}>;
|
|
25
|
+
read?(path: string): Promise<AFSEntry | undefined>;
|
|
26
|
+
write?(path: string, content: AFSWriteEntryPayload): Promise<AFSEntry>;
|
|
27
|
+
search?(path: string, query: string, options?: AFSSearchOptions): Promise<{
|
|
28
|
+
list: AFSEntry[];
|
|
29
|
+
}>;
|
|
30
|
+
}
|
|
31
|
+
export type AFSRootEvents = {
|
|
32
|
+
agentSucceed: [{
|
|
33
|
+
input: object;
|
|
34
|
+
output: object;
|
|
35
|
+
}];
|
|
36
|
+
historyCreated: [{
|
|
37
|
+
entry: AFSEntry;
|
|
38
|
+
}];
|
|
39
|
+
};
|
|
40
|
+
export interface AFSRoot extends Emitter<AFSRootEvents>, AFSModule {
|
|
41
|
+
storage(module: AFSModule): AFSStorage;
|
|
42
|
+
}
|
|
43
|
+
export interface AFSEntry<T = any> {
|
|
44
|
+
id: string;
|
|
45
|
+
createdAt?: Date;
|
|
46
|
+
updatedAt?: Date;
|
|
47
|
+
path: string;
|
|
48
|
+
userId?: string | null;
|
|
49
|
+
sessionId?: string | null;
|
|
50
|
+
summary?: string | null;
|
|
51
|
+
metadata?: Record<string, any> | null;
|
|
52
|
+
linkTo?: string | null;
|
|
53
|
+
content?: T;
|
|
54
|
+
}
|