@aigne/afs-history 1.2.0-beta.5 → 1.2.0-beta.7

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/CHANGELOG.md +16 -0
  2. package/lib/cjs/index.d.ts +2 -2
  3. package/lib/cjs/index.js +164 -142
  4. package/lib/cjs/storage/index.d.ts +4 -6
  5. package/lib/cjs/storage/index.js +49 -52
  6. package/lib/cjs/storage/migrate.js +9 -1
  7. package/lib/cjs/storage/migrations/004-add-memory-table.d.ts +2 -0
  8. package/lib/cjs/storage/migrations/004-add-memory-table.js +23 -0
  9. package/lib/cjs/storage/migrations/005-add-indexes.d.ts +2 -0
  10. package/lib/cjs/storage/migrations/005-add-indexes.js +31 -0
  11. package/lib/cjs/storage/models/compact.d.ts +1 -1
  12. package/lib/cjs/storage/models/memory.d.ts +182 -0
  13. package/lib/cjs/storage/models/memory.js +27 -0
  14. package/lib/cjs/storage/type.d.ts +20 -8
  15. package/lib/dts/index.d.ts +2 -2
  16. package/lib/dts/storage/index.d.ts +4 -6
  17. package/lib/dts/storage/migrations/004-add-memory-table.d.ts +2 -0
  18. package/lib/dts/storage/migrations/005-add-indexes.d.ts +2 -0
  19. package/lib/dts/storage/models/compact.d.ts +1 -1
  20. package/lib/dts/storage/models/memory.d.ts +182 -0
  21. package/lib/dts/storage/type.d.ts +20 -8
  22. package/lib/esm/index.d.ts +2 -2
  23. package/lib/esm/index.js +164 -142
  24. package/lib/esm/storage/index.d.ts +4 -6
  25. package/lib/esm/storage/index.js +49 -52
  26. package/lib/esm/storage/migrate.js +9 -1
  27. package/lib/esm/storage/migrations/004-add-memory-table.d.ts +2 -0
  28. package/lib/esm/storage/migrations/004-add-memory-table.js +20 -0
  29. package/lib/esm/storage/migrations/005-add-indexes.d.ts +2 -0
  30. package/lib/esm/storage/migrations/005-add-indexes.js +28 -0
  31. package/lib/esm/storage/models/compact.d.ts +1 -1
  32. package/lib/esm/storage/models/memory.d.ts +182 -0
  33. package/lib/esm/storage/models/memory.js +22 -0
  34. package/lib/esm/storage/type.d.ts +20 -8
  35. package/package.json +2 -2
@@ -143,7 +143,7 @@ export declare const compactTable: (module: AFSModule) => import("@aigne/sqlite"
143
143
  dataType: "custom";
144
144
  columnType: "SQLiteCustomColumn";
145
145
  data: {
146
- type?: string;
146
+ scope?: string;
147
147
  latestEntryId?: string;
148
148
  } & Record<string, unknown>;
149
149
  driverParam: string;
@@ -0,0 +1,182 @@
1
+ import type { AFSModule } from "@aigne/afs";
2
+ export declare const memoryTableName: (module: AFSModule) => string;
3
+ export declare const memoryTable: (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
+ agentId: import("@aigne/sqlite").SQLiteColumn<{
122
+ name: "agentId";
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: {
146
+ scope?: string;
147
+ } & Record<string, unknown>;
148
+ driverParam: string;
149
+ notNull: false;
150
+ hasDefault: false;
151
+ isPrimaryKey: false;
152
+ isAutoincrement: false;
153
+ hasRuntimeDefault: false;
154
+ enumValues: undefined;
155
+ baseColumn: never;
156
+ identity: undefined;
157
+ generated: undefined;
158
+ }, {}, {
159
+ sqliteColumnBuilderBrand: "SQLiteCustomColumnBuilderBrand";
160
+ }>;
161
+ content: import("@aigne/sqlite").SQLiteColumn<{
162
+ name: string;
163
+ tableName: string;
164
+ dataType: "custom";
165
+ columnType: "SQLiteCustomColumn";
166
+ data: unknown;
167
+ driverParam: string;
168
+ notNull: false;
169
+ hasDefault: false;
170
+ isPrimaryKey: false;
171
+ isAutoincrement: false;
172
+ hasRuntimeDefault: false;
173
+ enumValues: undefined;
174
+ baseColumn: never;
175
+ identity: undefined;
176
+ generated: undefined;
177
+ }, {}, {
178
+ sqliteColumnBuilderBrand: "SQLiteCustomColumnBuilderBrand";
179
+ }>;
180
+ };
181
+ dialect: "sqlite";
182
+ }>;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.memoryTable = exports.memoryTableName = void 0;
4
+ const sqlite_1 = require("@aigne/sqlite");
5
+ const uuid_1 = require("@aigne/uuid");
6
+ const memoryTableName = (module) => `Entries_${module.name}_memory`;
7
+ exports.memoryTableName = memoryTableName;
8
+ const memoryTable = (module) => (0, sqlite_1.sqliteTable)((0, exports.memoryTableName)(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
+ agentId: (0, sqlite_1.text)("agentId"),
24
+ metadata: (0, sqlite_1.json)("metadata"),
25
+ content: (0, sqlite_1.json)("content"),
26
+ });
27
+ exports.memoryTable = memoryTable;
@@ -2,7 +2,11 @@ import type { AFSEntry, AFSModule } from "@aigne/afs";
2
2
  import type { SQL } from "@aigne/sqlite";
3
3
  export interface AFSStorageCreatePayload extends AFSEntry {
4
4
  }
5
- export interface AFSStorageListOptions {
5
+ export interface AFSStorageTypeOptions {
6
+ type?: EntryType;
7
+ scope?: Scope;
8
+ }
9
+ export interface AFSStorageListOptions extends AFSStorageTypeOptions {
6
10
  filter?: {
7
11
  agentId?: string;
8
12
  userId?: string;
@@ -13,25 +17,33 @@ export interface AFSStorageListOptions {
13
17
  limit?: number;
14
18
  orderBy?: [string, "asc" | "desc"][];
15
19
  }
16
- export interface AFSStorageReadOptions {
20
+ export interface AFSStorageReadOptions extends AFSStorageTypeOptions {
17
21
  filter?: {
18
22
  agentId?: string;
19
23
  userId?: string;
20
24
  sessionId?: string;
21
25
  };
22
26
  }
23
- export type CompactType = "session" | "user" | "agent";
27
+ export interface AFSStorageDeleteOptions extends AFSStorageTypeOptions {
28
+ filter?: {
29
+ agentId?: string;
30
+ userId?: string;
31
+ sessionId?: string;
32
+ };
33
+ }
34
+ export type EntryType = "history" | "compact" | "memory";
35
+ export type Scope = "session" | "user" | "agent";
36
+ export interface AFSStorageCreateOptions extends AFSStorageTypeOptions {
37
+ }
24
38
  export interface AFSStorage {
25
- create(entry: AFSStorageCreatePayload): Promise<AFSEntry>;
39
+ create(entry: AFSStorageCreatePayload, options?: AFSStorageCreateOptions): Promise<AFSEntry>;
26
40
  list(options?: AFSStorageListOptions): Promise<{
27
41
  data: AFSEntry[];
28
42
  }>;
29
43
  read(id: string, options?: AFSStorageReadOptions): Promise<AFSEntry | undefined>;
30
- createCompact(type: CompactType, entry: AFSStorageCreatePayload): Promise<AFSEntry>;
31
- listCompact(type: CompactType, options?: AFSStorageListOptions): Promise<{
32
- data: AFSEntry[];
44
+ delete(id: string, options?: AFSStorageDeleteOptions): Promise<{
45
+ deletedCount: number;
33
46
  }>;
34
- readCompact(type: CompactType, id: string, options?: AFSStorageReadOptions): Promise<AFSEntry | undefined>;
35
47
  }
36
48
  export type AFSStorageMigrations = {
37
49
  hash: string;
@@ -1,4 +1,4 @@
1
- import type { AFSListOptions, AFSListResult, AFSModule, AFSReadOptions, AFSReadResult, AFSRoot, AFSWriteEntryPayload, AFSWriteResult } from "@aigne/afs";
1
+ import type { AFSDeleteOptions, AFSDeleteResult, AFSListOptions, AFSListResult, AFSModule, AFSReadOptions, AFSReadResult, AFSRoot, AFSWriteEntryPayload, AFSWriteResult } from "@aigne/afs";
2
2
  import { SharedAFSStorage, type SharedAFSStorageOptions } from "./storage/index.js";
3
3
  export * from "./storage/index.js";
4
4
  export interface AFSHistoryOptions {
@@ -15,6 +15,6 @@ export declare class AFSHistory implements AFSModule {
15
15
  list(path: string, options?: AFSListOptions): Promise<AFSListResult>;
16
16
  read(path: string, options?: AFSReadOptions): Promise<AFSReadResult>;
17
17
  write(path: string, content: AFSWriteEntryPayload): Promise<AFSWriteResult>;
18
- private getCompactType;
18
+ delete(path: string, _options?: AFSDeleteOptions): Promise<AFSDeleteResult>;
19
19
  private normalizePath;
20
20
  }
@@ -1,6 +1,6 @@
1
1
  import type { AFSEntry, AFSModule } from "@aigne/afs";
2
2
  import { initDatabase } from "@aigne/sqlite";
3
- import type { AFSStorage, AFSStorageCreatePayload, AFSStorageListOptions, AFSStorageReadOptions, CompactType } from "./type.js";
3
+ import type { AFSStorage, AFSStorageCreateOptions, AFSStorageCreatePayload, AFSStorageDeleteOptions, AFSStorageListOptions, AFSStorageReadOptions } from "./type.js";
4
4
  export * from "./type.js";
5
5
  export interface SharedAFSStorageOptions {
6
6
  url?: string;
@@ -24,10 +24,8 @@ export declare class AFSStorageWithModule implements AFSStorage {
24
24
  data: AFSEntry[];
25
25
  }>;
26
26
  read(id: string, options?: AFSStorageReadOptions): Promise<AFSEntry | undefined>;
27
- create(entry: AFSStorageCreatePayload): Promise<AFSEntry>;
28
- createCompact(type: CompactType, entry: AFSStorageCreatePayload): Promise<AFSEntry>;
29
- listCompact(type: CompactType, options?: AFSStorageListOptions): Promise<{
30
- data: AFSEntry[];
27
+ create(entry: AFSStorageCreatePayload, options?: AFSStorageCreateOptions): Promise<AFSEntry>;
28
+ delete(id: string, options?: AFSStorageDeleteOptions): Promise<{
29
+ deletedCount: number;
31
30
  }>;
32
- readCompact(type: CompactType, id: string, options?: AFSStorageReadOptions): Promise<AFSEntry | undefined>;
33
31
  }
@@ -0,0 +1,2 @@
1
+ import type { AFSStorageMigrations } from "../type.js";
2
+ export declare const addMemoryTable: AFSStorageMigrations;
@@ -0,0 +1,2 @@
1
+ import type { AFSStorageMigrations } from "../type.js";
2
+ export declare const addIndexes: AFSStorageMigrations;
@@ -143,7 +143,7 @@ export declare const compactTable: (module: AFSModule) => import("@aigne/sqlite"
143
143
  dataType: "custom";
144
144
  columnType: "SQLiteCustomColumn";
145
145
  data: {
146
- type?: string;
146
+ scope?: string;
147
147
  latestEntryId?: string;
148
148
  } & Record<string, unknown>;
149
149
  driverParam: string;
@@ -0,0 +1,182 @@
1
+ import type { AFSModule } from "@aigne/afs";
2
+ export declare const memoryTableName: (module: AFSModule) => string;
3
+ export declare const memoryTable: (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
+ agentId: import("@aigne/sqlite").SQLiteColumn<{
122
+ name: "agentId";
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: {
146
+ scope?: string;
147
+ } & Record<string, unknown>;
148
+ driverParam: string;
149
+ notNull: false;
150
+ hasDefault: false;
151
+ isPrimaryKey: false;
152
+ isAutoincrement: false;
153
+ hasRuntimeDefault: false;
154
+ enumValues: undefined;
155
+ baseColumn: never;
156
+ identity: undefined;
157
+ generated: undefined;
158
+ }, {}, {
159
+ sqliteColumnBuilderBrand: "SQLiteCustomColumnBuilderBrand";
160
+ }>;
161
+ content: import("@aigne/sqlite").SQLiteColumn<{
162
+ name: string;
163
+ tableName: string;
164
+ dataType: "custom";
165
+ columnType: "SQLiteCustomColumn";
166
+ data: unknown;
167
+ driverParam: string;
168
+ notNull: false;
169
+ hasDefault: false;
170
+ isPrimaryKey: false;
171
+ isAutoincrement: false;
172
+ hasRuntimeDefault: false;
173
+ enumValues: undefined;
174
+ baseColumn: never;
175
+ identity: undefined;
176
+ generated: undefined;
177
+ }, {}, {
178
+ sqliteColumnBuilderBrand: "SQLiteCustomColumnBuilderBrand";
179
+ }>;
180
+ };
181
+ dialect: "sqlite";
182
+ }>;
@@ -2,7 +2,11 @@ import type { AFSEntry, AFSModule } from "@aigne/afs";
2
2
  import type { SQL } from "@aigne/sqlite";
3
3
  export interface AFSStorageCreatePayload extends AFSEntry {
4
4
  }
5
- export interface AFSStorageListOptions {
5
+ export interface AFSStorageTypeOptions {
6
+ type?: EntryType;
7
+ scope?: Scope;
8
+ }
9
+ export interface AFSStorageListOptions extends AFSStorageTypeOptions {
6
10
  filter?: {
7
11
  agentId?: string;
8
12
  userId?: string;
@@ -13,25 +17,33 @@ export interface AFSStorageListOptions {
13
17
  limit?: number;
14
18
  orderBy?: [string, "asc" | "desc"][];
15
19
  }
16
- export interface AFSStorageReadOptions {
20
+ export interface AFSStorageReadOptions extends AFSStorageTypeOptions {
17
21
  filter?: {
18
22
  agentId?: string;
19
23
  userId?: string;
20
24
  sessionId?: string;
21
25
  };
22
26
  }
23
- export type CompactType = "session" | "user" | "agent";
27
+ export interface AFSStorageDeleteOptions extends AFSStorageTypeOptions {
28
+ filter?: {
29
+ agentId?: string;
30
+ userId?: string;
31
+ sessionId?: string;
32
+ };
33
+ }
34
+ export type EntryType = "history" | "compact" | "memory";
35
+ export type Scope = "session" | "user" | "agent";
36
+ export interface AFSStorageCreateOptions extends AFSStorageTypeOptions {
37
+ }
24
38
  export interface AFSStorage {
25
- create(entry: AFSStorageCreatePayload): Promise<AFSEntry>;
39
+ create(entry: AFSStorageCreatePayload, options?: AFSStorageCreateOptions): Promise<AFSEntry>;
26
40
  list(options?: AFSStorageListOptions): Promise<{
27
41
  data: AFSEntry[];
28
42
  }>;
29
43
  read(id: string, options?: AFSStorageReadOptions): Promise<AFSEntry | undefined>;
30
- createCompact(type: CompactType, entry: AFSStorageCreatePayload): Promise<AFSEntry>;
31
- listCompact(type: CompactType, options?: AFSStorageListOptions): Promise<{
32
- data: AFSEntry[];
44
+ delete(id: string, options?: AFSStorageDeleteOptions): Promise<{
45
+ deletedCount: number;
33
46
  }>;
34
- readCompact(type: CompactType, id: string, options?: AFSStorageReadOptions): Promise<AFSEntry | undefined>;
35
47
  }
36
48
  export type AFSStorageMigrations = {
37
49
  hash: string;
@@ -1,4 +1,4 @@
1
- import type { AFSListOptions, AFSListResult, AFSModule, AFSReadOptions, AFSReadResult, AFSRoot, AFSWriteEntryPayload, AFSWriteResult } from "@aigne/afs";
1
+ import type { AFSDeleteOptions, AFSDeleteResult, AFSListOptions, AFSListResult, AFSModule, AFSReadOptions, AFSReadResult, AFSRoot, AFSWriteEntryPayload, AFSWriteResult } from "@aigne/afs";
2
2
  import { SharedAFSStorage, type SharedAFSStorageOptions } from "./storage/index.js";
3
3
  export * from "./storage/index.js";
4
4
  export interface AFSHistoryOptions {
@@ -15,6 +15,6 @@ export declare class AFSHistory implements AFSModule {
15
15
  list(path: string, options?: AFSListOptions): Promise<AFSListResult>;
16
16
  read(path: string, options?: AFSReadOptions): Promise<AFSReadResult>;
17
17
  write(path: string, content: AFSWriteEntryPayload): Promise<AFSWriteResult>;
18
- private getCompactType;
18
+ delete(path: string, _options?: AFSDeleteOptions): Promise<AFSDeleteResult>;
19
19
  private normalizePath;
20
20
  }