@sixb/sqlite 0.1.6 → 0.1.8

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 (91) hide show
  1. package/dist/agents/rows.d.ts +7 -4
  2. package/dist/agents/rows.d.ts.map +1 -1
  3. package/dist/agents/runs.d.ts +3 -2
  4. package/dist/agents/runs.d.ts.map +1 -1
  5. package/dist/agents/threads.d.ts.map +1 -1
  6. package/dist/ai-cost-groups.d.ts +5 -0
  7. package/dist/ai-cost-groups.d.ts.map +1 -0
  8. package/dist/ai-cost-storage.d.ts +2 -1
  9. package/dist/ai-cost-storage.d.ts.map +1 -1
  10. package/dist/ai-limit-storage.d.ts +35 -0
  11. package/dist/ai-limit-storage.d.ts.map +1 -0
  12. package/dist/ai-usage-storage.d.ts +1 -0
  13. package/dist/ai-usage-storage.d.ts.map +1 -1
  14. package/dist/auth-storage/access-tokens.d.ts +1 -1
  15. package/dist/auth-storage/access-tokens.d.ts.map +1 -1
  16. package/dist/auth-storage/auth-storage.d.ts +4 -1
  17. package/dist/auth-storage/auth-storage.d.ts.map +1 -1
  18. package/dist/auth-storage/device-authorizations.d.ts +29 -0
  19. package/dist/auth-storage/device-authorizations.d.ts.map +1 -0
  20. package/dist/auth-storage/rows.d.ts +19 -1
  21. package/dist/auth-storage/rows.d.ts.map +1 -1
  22. package/dist/auth-storage/shared.d.ts +1 -1
  23. package/dist/auth-storage/shared.d.ts.map +1 -1
  24. package/dist/execution-storage.d.ts +3 -2
  25. package/dist/execution-storage.d.ts.map +1 -1
  26. package/dist/index.d.ts +4 -1
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +3443 -789
  29. package/dist/index.js.map +29 -20
  30. package/dist/migrations.d.ts.map +1 -1
  31. package/dist/objects/index.d.ts +3 -0
  32. package/dist/objects/index.d.ts.map +1 -0
  33. package/dist/{object-query-compiler.d.ts → objects/query-compiler.d.ts} +16 -1
  34. package/dist/objects/query-compiler.d.ts.map +1 -0
  35. package/dist/objects/read-scope.d.ts +17 -0
  36. package/dist/objects/read-scope.d.ts.map +1 -0
  37. package/dist/objects/reader.d.ts +51 -0
  38. package/dist/objects/reader.d.ts.map +1 -0
  39. package/dist/objects/rows.d.ts +33 -0
  40. package/dist/objects/rows.d.ts.map +1 -0
  41. package/dist/objects/selected-reader.d.ts +9 -0
  42. package/dist/objects/selected-reader.d.ts.map +1 -0
  43. package/dist/{object-storage.d.ts → objects/storage.d.ts} +12 -9
  44. package/dist/objects/storage.d.ts.map +1 -0
  45. package/dist/share-grant-storage.d.ts +20 -0
  46. package/dist/share-grant-storage.d.ts.map +1 -0
  47. package/dist/share-session-storage.d.ts +19 -0
  48. package/dist/share-session-storage.d.ts.map +1 -0
  49. package/dist/storage-errors.d.ts +1 -0
  50. package/dist/storage-errors.d.ts.map +1 -1
  51. package/dist/transactions.d.ts +8 -0
  52. package/dist/transactions.d.ts.map +1 -1
  53. package/package.json +3 -3
  54. package/src/agents/rows.ts +36 -9
  55. package/src/agents/runs.ts +152 -13
  56. package/src/agents/threads.ts +2 -17
  57. package/src/ai-cost-groups.ts +100 -0
  58. package/src/ai-cost-storage.ts +67 -25
  59. package/src/ai-limit-storage.ts +981 -0
  60. package/src/ai-usage-storage.ts +24 -1
  61. package/src/auth-storage/access-tokens.ts +77 -68
  62. package/src/auth-storage/auth-storage.ts +80 -1
  63. package/src/auth-storage/device-authorizations.ts +153 -0
  64. package/src/auth-storage/rows.ts +41 -0
  65. package/src/auth-storage/shared.ts +1 -0
  66. package/src/execution-storage.ts +22 -3
  67. package/src/index.ts +24 -3
  68. package/src/migrations/029-model-accounting.sql +79 -0
  69. package/src/migrations/030-ai-usage-limits.sql +100 -0
  70. package/src/migrations/031-subagent-runs.sql +231 -0
  71. package/src/migrations/032-conversation-run-spec.sql +78 -0
  72. package/src/migrations/033-retire-agent-definitions.sql +89 -0
  73. package/src/migrations/034-device-authorizations.sql +22 -0
  74. package/src/migrations/035-share-grants.sql +66 -0
  75. package/src/migrations/036-share-sessions.sql +226 -0
  76. package/src/migrations.ts +22 -0
  77. package/src/objects/index.ts +2 -0
  78. package/src/{object-query-compiler.ts → objects/query-compiler.ts} +104 -54
  79. package/src/objects/read-scope.ts +316 -0
  80. package/src/objects/reader.ts +526 -0
  81. package/src/objects/rows.ts +123 -0
  82. package/src/objects/selected-reader.ts +119 -0
  83. package/src/objects/storage.ts +296 -0
  84. package/src/share-grant-storage.ts +252 -0
  85. package/src/share-session-storage.ts +189 -0
  86. package/src/storage-errors.ts +4 -0
  87. package/src/transactions.ts +32 -0
  88. package/src/workflow-run-storage.ts +8 -8
  89. package/dist/object-query-compiler.d.ts.map +0 -1
  90. package/dist/object-storage.d.ts.map +0 -1
  91. package/src/object-storage.ts +0 -709
@@ -1 +1 @@
1
- {"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../src/migrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAIrC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,KAAK,EAGV,YAAY,EACZ,aAAa,EACb,oBAAoB,EACrB,MAAM,oBAAoB,CAAA;AAiF3B,eAAO,MAAM,yBAAyB,sBAAsB,CAAA;AAC5D,eAAO,MAAM,mBAAmB,mBAAmB,CAAA;AAEnD,eAAO,MAAM,uBAAuB,wBAmElC,CAAA;AAEF,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,aAAa,CAAC,QAAQ,CAAC,CAQ9E;AAED,wBAAgB,UAAU,CACxB,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,CAAC,EAAE,EAAE,QAAQ,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAC1C,OAAO,GAAE,oBAAyB,GACjC,aAAa,CAAC,QAAQ,CAAC,CAEzB;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AAgB,4BAA4B,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,eAAe,EAAE,CAOzF;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE;IAC3C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,UAAU,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAA;CAC5C,GAAG,eAAe,CAoBlB;AAED,wBAAsB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAM1E"}
@@ -0,0 +1,3 @@
1
+ export type { SqliteObjectStorageOptions } from "./storage";
2
+ export { SqliteObjectStorage } from "./storage";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/objects/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAA;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA"}
@@ -39,6 +39,21 @@ type CompiledOrderField = {
39
39
  };
40
40
  export declare function compileObjectQuery(projectId: string, query: ObjectQuery, options?: {
41
41
  includeTotal?: boolean;
42
+ source?: SqliteObjectQuerySource;
42
43
  }): CompiledObjectQuery;
44
+ /** Physical relations used by the object-query compiler. */
45
+ export interface SqliteObjectQuerySource {
46
+ readonly objectsTable: string;
47
+ readonly linksTable: string;
48
+ /** Wrap a terminal SELECT without its own WITH clause; the selected source owns the only WITH. */
49
+ wrapStatement(sql: string, args?: readonly SqliteValue[]): {
50
+ readonly sql: string;
51
+ readonly args: readonly SqliteValue[];
52
+ };
53
+ wrapQuery(query: CompiledObjectQuery): CompiledObjectQuery;
54
+ }
55
+ export declare const DEFAULT_OBJECT_QUERY_SOURCE: SqliteObjectQuerySource;
56
+ /** json_each exposes JSON booleans as integer SQL values; restore their JSON representation. */
57
+ export declare function sqliteJsonEachValue(alias: string): string;
43
58
  export {};
44
- //# sourceMappingURL=object-query-compiler.d.ts.map
59
+ //# sourceMappingURL=query-compiler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-compiler.d.ts","sourceRoot":"","sources":["../../src/objects/query-compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,WAAW,EAKjB,MAAM,YAAY,CAAA;AAEnB,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAA;AAEnE,MAAM,WAAW,wBAAwB;IACvC,cAAc,EAAE,MAAM,CAAA;IACtB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED,MAAM,WAAW,mBAAmB;IAClC,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,WAAW,EAAE,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,WAAW,EAAE,CAAA;IACxB,KAAK,EAAE,aAAa,CAAA;IACpB,YAAY,CAAC,EAAE,oBAAoB,CAAA;IACnC,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IAClD,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,CAAA;IAC7C,aAAa,CAAC,IAAI,EAAE,SAAS,wBAAwB,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;CAC/F;AAED,UAAU,oBAAoB;IAC5B,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,WAAW,EAAE,CAAA;IACnB,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAA;CACnC;AAYD,UAAU,aAAa;IACrB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,WAAW,EAAE,CAAA;IACnB,MAAM,EAAE,SAAS,kBAAkB,EAAE,CAAA;IACrC,cAAc,EAAE,MAAM,CAAA;CACvB;AAED,KAAK,kBAAkB,GACnB;IACE,IAAI,EAAE,UAAU,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,KAAK,GAAG,MAAM,CAAA;CAC1B,GACD;IACE,IAAI,EAAE,QAAQ,CAAA;IACd,MAAM,EAAE,gBAAgB,GAAG,YAAY,CAAA;IACvC,SAAS,EAAE,KAAK,GAAG,MAAM,CAAA;CAC1B,CAAA;AAoBL,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,WAAW,EAClB,OAAO,GAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,uBAAuB,CAAA;CAAO,GACzE,mBAAmB,CAIrB;AAED,4DAA4D;AAC5D,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,kGAAkG;IAClG,aAAa,CACX,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,SAAS,WAAW,EAAE,GAC5B;QACD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;QACpB,QAAQ,CAAC,IAAI,EAAE,SAAS,WAAW,EAAE,CAAA;KACtC,CAAA;IACD,SAAS,CAAC,KAAK,EAAE,mBAAmB,GAAG,mBAAmB,CAAA;CAC3D;AAED,eAAO,MAAM,2BAA2B,EAAE,uBAKzC,CAAA;AA+sBD,gGAAgG;AAChG,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMzD"}
@@ -0,0 +1,17 @@
1
+ import type { CompiledSelectedObjectReadScope } from "@sixb/core/storage";
2
+ import { type SqliteObjectQuerySource, type SqliteValue } from "./query-compiler";
3
+ export interface SqliteSelectedObjectReadSource extends SqliteObjectQuerySource {
4
+ readonly objectPropertyPermissionsTable: string;
5
+ readonly traversalProbe: {
6
+ readonly sql: string;
7
+ readonly args: readonly SqliteValue[];
8
+ };
9
+ }
10
+ /**
11
+ * Prepare one immutable selected scope as live, path-sensitive SQLite relations.
12
+ *
13
+ * The complete compiled scope is serialized once. Every statement receives that one JSON document
14
+ * and the bound project id, keeping the host-parameter count constant as selections grow.
15
+ */
16
+ export declare function compileSqliteSelectedObjectReadSource(projectId: string, scope: CompiledSelectedObjectReadScope, maxTraversalFacts: number): SqliteSelectedObjectReadSource;
17
+ //# sourceMappingURL=read-scope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-scope.d.ts","sourceRoot":"","sources":["../../src/objects/read-scope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,oBAAoB,CAAA;AACzE,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,WAAW,EAEjB,MAAM,kBAAkB,CAAA;AAEzB,MAAM,WAAW,8BAA+B,SAAQ,uBAAuB;IAC7E,QAAQ,CAAC,8BAA8B,EAAE,MAAM,CAAA;IAC/C,QAAQ,CAAC,cAAc,EAAE;QACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;QACpB,QAAQ,CAAC,IAAI,EAAE,SAAS,WAAW,EAAE,CAAA;KACtC,CAAA;CACF;AAED;;;;;GAKG;AACH,wBAAgB,qCAAqC,CACnD,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,+BAA+B,EACtC,iBAAiB,EAAE,MAAM,GACxB,8BAA8B,CAiDhC"}
@@ -0,0 +1,51 @@
1
+ import type { Database } from "bun:sqlite";
2
+ import type { CountObjectsInput, CountObjectsResult, ExistsObjectsInput, ExistsObjectsResult, FacetObjectsInput, FacetObjectsResult, LinkBatchKey, LinkDirection, ObjectBatchKey, ObjectLinkRow, ObjectReadStorage, ObjectRow, QueryObjectLinksInput, QueryObjectLinksResult, QueryObjectsInput, QueryObjectsResult } from "@sixb/core/storage";
3
+ import { type SqliteObjectQuerySource } from "./query-compiler";
4
+ import type { SqliteSelectedObjectReadSource } from "./read-scope";
5
+ /** Synchronous SQL reads over one explicit source; transaction and budget ownership stay outside. */
6
+ export declare class SqliteObjectReader {
7
+ private readonly db;
8
+ private readonly source;
9
+ constructor(db: Database, source: SqliteObjectQuerySource | SqliteSelectedObjectReadSource);
10
+ queryObjects(params: QueryObjectsInput): QueryObjectsResult;
11
+ countObjects(params: CountObjectsInput): CountObjectsResult;
12
+ existsObjects(params: ExistsObjectsInput): ExistsObjectsResult;
13
+ facetObjects(params: FacetObjectsInput): FacetObjectsResult;
14
+ getByPrimaryId(params: {
15
+ projectId: string;
16
+ objectTypeId: string;
17
+ primaryId: string;
18
+ }): ObjectRow | null;
19
+ selectsObjectProperties(params: Parameters<ObjectReadStorage["selectsObjectProperties"]>[0]): readonly boolean[];
20
+ listLinks(params: {
21
+ projectId: string;
22
+ objectTypeId: string;
23
+ objectId: string;
24
+ linkId?: string;
25
+ direction?: LinkDirection;
26
+ }): readonly ObjectLinkRow[];
27
+ getByPrimaryIdBatch(params: {
28
+ projectId: string;
29
+ items: readonly {
30
+ objectTypeId: string;
31
+ primaryId: string;
32
+ }[];
33
+ }): Map<ObjectBatchKey, ObjectRow>;
34
+ listLinksBatch(params: {
35
+ projectId: string;
36
+ direction?: LinkDirection;
37
+ items: readonly {
38
+ objectTypeId: string;
39
+ objectId: string;
40
+ linkId: string;
41
+ }[];
42
+ }): Map<LinkBatchKey, ObjectLinkRow[]>;
43
+ queryLinks(params: QueryObjectLinksInput): QueryObjectLinksResult;
44
+ list(params: Parameters<ObjectReadStorage["list"]>[0]): {
45
+ objects: readonly ObjectRow[];
46
+ hasMore: boolean;
47
+ total: number;
48
+ };
49
+ }
50
+ export declare function assertLinkQueryLimit(limit: number): void;
51
+ //# sourceMappingURL=reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../../src/objects/reader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EA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,MAAM,CAAA;QACf,SAAS,CAAC,EAAE,aAAa,CAAA;KAC1B,GAAG,SAAS,aAAa,EAAE;IAgC5B,mBAAmB,CAAC,MAAM,EAAE;QAC1B,SAAS,EAAE,MAAM,CAAA;QACjB,KAAK,EAAE,SAAS;YAAE,YAAY,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAA;SAAE,EAAE,CAAA;KAC9D,GAAG,GAAG,CAAC,cAAc,EAAE,SAAS,CAAC;IA4BlC,cAAc,CAAC,MAAM,EAAE;QACrB,SAAS,EAAE,MAAM,CAAA;QACjB,SAAS,CAAC,EAAE,aAAa,CAAA;QACzB,KAAK,EAAE,SAAS;YAAE,YAAY,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,EAAE,CAAA;KAC7E,GAAG,GAAG,CAAC,YAAY,EAAE,aAAa,EAAE,CAAC;IA+CtC,UAAU,CAAC,MAAM,EAAE,qBAAqB,GAAG,sBAAsB;IAiFjE,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG;QACtD,OAAO,EAAE,SAAS,SAAS,EAAE,CAAA;QAC7B,OAAO,EAAE,OAAO,CAAA;QAChB,KAAK,EAAE,MAAM,CAAA;KACd;CA6EF;AAYD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAIxD"}
@@ -0,0 +1,33 @@
1
+ import type { ObjectLinkRow, ObjectRow } from "@sixb/core/storage";
2
+ export declare function rowToObject(row: DatabaseRow): ObjectRow;
3
+ /** Decode an expanded query row with the same shape as Core link hydration. */
4
+ export declare function queryRowToObject(row: ObjectQueryDatabaseRow): ObjectRow;
5
+ export declare function rowToLink(row: LinkDatabaseRow): ObjectLinkRow;
6
+ export interface DatabaseRow {
7
+ project_id: string;
8
+ object_type_id: string;
9
+ primary_id: string;
10
+ properties: string;
11
+ created_at: string;
12
+ updated_at: string;
13
+ version: number;
14
+ last_commit_id: string;
15
+ }
16
+ export interface ObjectQueryDatabaseRow extends DatabaseRow {
17
+ _cursor_properties?: string;
18
+ /** `json_object(linkId, value, ...)` serialized text from an `expand` pushdown; absent otherwise. */
19
+ _expand?: string | null;
20
+ }
21
+ export interface LinkDatabaseRow {
22
+ project_id: string;
23
+ source_type_id: string;
24
+ source_id: string;
25
+ link_id: string;
26
+ target_type_id: string;
27
+ target_id: string;
28
+ properties: string | null;
29
+ created_at: string;
30
+ updated_at: string;
31
+ last_commit_id: string;
32
+ }
33
+ //# sourceMappingURL=rows.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rows.d.ts","sourceRoot":"","sources":["../../src/objects/rows.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,aAAa,EACb,SAAS,EAEV,MAAM,oBAAoB,CAAA;AAE3B,wBAAgB,WAAW,CAAC,GAAG,EAAE,WAAW,GAAG,SAAS,CAWvD;AAED,+EAA+E;AAC/E,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,sBAAsB,GAAG,SAAS,CAIvE;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,eAAe,GAAG,aAAa,CAa7D;AAqDD,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAA;IAClB,cAAc,EAAE,MAAM,CAAA;IACtB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;IACf,cAAc,EAAE,MAAM,CAAA;CACvB;AAED,MAAM,WAAW,sBAAuB,SAAQ,WAAW;IACzD,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,qGAAqG;IACrG,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACxB;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAA;IAClB,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,cAAc,EAAE,MAAM,CAAA;CACvB"}
@@ -0,0 +1,9 @@
1
+ import type { Database } from "bun:sqlite";
2
+ import type { CompiledSelectedObjectReadScope, ObjectQueryCapabilities, ObjectReadExecutionLimits, ObjectReadStorage } from "@sixb/core/storage";
3
+ /** Keep the traversal probe and every terminal statement in the same synchronous snapshot. */
4
+ export declare function createSqliteSelectedReader(db: Database, params: {
5
+ projectId: string;
6
+ scope: CompiledSelectedObjectReadScope;
7
+ limits: ObjectReadExecutionLimits;
8
+ }, queryCapabilities: () => ObjectQueryCapabilities): ObjectReadStorage;
9
+ //# sourceMappingURL=selected-reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selected-reader.d.ts","sourceRoot":"","sources":["../../src/objects/selected-reader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,KAAK,EACV,+BAA+B,EAC/B,uBAAuB,EACvB,yBAAyB,EACzB,iBAAiB,EAClB,MAAM,oBAAoB,CAAA;AAe3B,8FAA8F;AAC9F,wBAAgB,0BAA0B,CACxC,EAAE,EAAE,QAAQ,EACZ,MAAM,EAAE;IACN,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,+BAA+B,CAAA;IACtC,MAAM,EAAE,yBAAyB,CAAA;CAClC,EACD,iBAAiB,EAAE,MAAM,uBAAuB,GAC/C,iBAAiB,CA2EnB"}
@@ -1,5 +1,5 @@
1
- import type { CountObjectsInput, CountObjectsResult, ExistsObjectsInput, ExistsObjectsResult, FacetObjectsInput, FacetObjectsResult, LinkBatchKey, LinkDirection, ObjectBatchKey, ObjectLinkRow, ObjectQueryCapabilities, ObjectRow, ObjectStorage, QueryObjectLinksInput, QueryObjectLinksResult, QueryObjectsInput, QueryObjectsResult } from "@sixb/core/storage";
2
- import { type SqliteStoreConnection } from "./transactions";
1
+ import type { CompiledSelectedObjectReadScope, CountObjectsInput, CountObjectsResult, ExistsObjectsInput, ExistsObjectsResult, FacetObjectsInput, FacetObjectsResult, LinkBatchKey, LinkDirection, ObjectBatchKey, ObjectLinkRow, ObjectQueryCapabilities, ObjectReadExecutionLimits, ObjectReadStorage, ObjectRow, ObjectStorage, QueryObjectLinksInput, QueryObjectLinksResult, QueryObjectsInput, QueryObjectsResult } from "@sixb/core/storage";
2
+ import { type SqliteStoreConnection } from "../transactions";
3
3
  export interface SqliteObjectStorageOptions {
4
4
  /** Path to SQLite database file. Defaults to ':memory:' for in-memory database. */
5
5
  path?: string;
@@ -15,8 +15,14 @@ export interface SqliteObjectStorageOptions {
15
15
  export declare class SqliteObjectStorage implements ObjectStorage {
16
16
  private readonly connection;
17
17
  private readonly db;
18
+ private readonly reader;
18
19
  constructor(options?: SqliteObjectStorageOptions);
19
20
  queryCapabilities(): ObjectQueryCapabilities;
21
+ createSelectedReadScope(params: {
22
+ projectId: string;
23
+ scope: CompiledSelectedObjectReadScope;
24
+ limits: ObjectReadExecutionLimits;
25
+ }): ObjectReadStorage;
20
26
  queryObjects(params: QueryObjectsInput): Promise<QueryObjectsResult>;
21
27
  countObjects(params: CountObjectsInput): Promise<CountObjectsResult>;
22
28
  existsObjects(params: ExistsObjectsInput): Promise<ExistsObjectsResult>;
@@ -26,6 +32,7 @@ export declare class SqliteObjectStorage implements ObjectStorage {
26
32
  objectTypeId: string;
27
33
  primaryId: string;
28
34
  }): Promise<ObjectRow | null>;
35
+ selectsObjectProperties(params: Parameters<ObjectReadStorage["selectsObjectProperties"]>[0]): Promise<readonly boolean[]>;
29
36
  listLinks(params: {
30
37
  projectId: string;
31
38
  objectTypeId: string;
@@ -42,6 +49,7 @@ export declare class SqliteObjectStorage implements ObjectStorage {
42
49
  }): Promise<Map<ObjectBatchKey, ObjectRow>>;
43
50
  listLinksBatch(params: {
44
51
  projectId: string;
52
+ direction?: LinkDirection;
45
53
  items: readonly {
46
54
  objectTypeId: string;
47
55
  objectId: string;
@@ -83,12 +91,7 @@ export declare class SqliteObjectStorage implements ObjectStorage {
83
91
  hasMore: boolean;
84
92
  total: number;
85
93
  }>;
86
- private rowToObject;
87
- private queryRowToObject;
88
- private rowToLink;
89
- /**
90
- * Close the database connection.
91
- */
94
+ /** Close the connection only when this provider owns it. */
92
95
  close(): void;
93
96
  }
94
- //# sourceMappingURL=object-storage.d.ts.map
97
+ //# sourceMappingURL=storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/objects/storage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,+BAA+B,EAC/B,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,cAAc,EACd,aAAa,EACb,uBAAuB,EACvB,yBAAyB,EACzB,iBAAiB,EACjB,SAAS,EACT,aAAa,EACb,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,iBAAiB,CAAA;AAMxB,MAAM,WAAW,0BAA0B;IACzC,mFAAmF;IACnF,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,gEAAgE;IAChE,UAAU,CAAC,EAAE,qBAAqB,CAAA;CACnC;AAoED;;;;;GAKG;AACH,qBAAa,mBAAoB,YAAW,aAAa;IACvD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAuB;IAClD,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAU;IAC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QACpB,YAAY,CAAC,EAAE,IAAI,CAAA;QACnB,aAAa,CAAC,EAAE,IAAI,CAAA;QACpB,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,OAAO,CAAC,EAAE,WAAW,GAAG,WAAW,GAAG,WAAW,CAAA;QACjD,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAA;KACvB,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,SAAS,SAAS,EAAE,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAI/E,4DAA4D;IAC5D,KAAK,IAAI,IAAI;CAGd"}
@@ -0,0 +1,20 @@
1
+ import type { CreateShareGrantInput, GetShareGrantByIdInput, ListShareGrantsInput, ListShareGrantsResult, RevokeShareGrantInput, ShareGrantRecord, ShareGrantStorage } from "@sixb/core/storage";
2
+ import { type SqliteStoreConnection } from "./transactions";
3
+ export interface SqliteShareGrantStorageOptions {
4
+ readonly path?: string;
5
+ readonly connection?: SqliteStoreConnection;
6
+ }
7
+ /** SQLite persistence for issued Share grants. Secret handling remains in Core. */
8
+ export declare class SqliteShareGrantStorage implements ShareGrantStorage {
9
+ private readonly connection;
10
+ private readonly db;
11
+ constructor(options?: SqliteShareGrantStorageOptions);
12
+ create(input: CreateShareGrantInput): Promise<ShareGrantRecord>;
13
+ getById(input: GetShareGrantByIdInput): Promise<ShareGrantRecord | null>;
14
+ list(input: ListShareGrantsInput): Promise<ListShareGrantsResult>;
15
+ revoke(input: RevokeShareGrantInput): Promise<ShareGrantRecord | null>;
16
+ close(): void;
17
+ private getRow;
18
+ private require;
19
+ }
20
+ //# sourceMappingURL=share-grant-storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"share-grant-storage.d.ts","sourceRoot":"","sources":["../src/share-grant-storage.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,oBAAoB,CAAA;AAI3B,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,gBAAgB,CAAA;AAEvB,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,UAAU,CAAC,EAAE,qBAAqB,CAAA;CAC5C;AAED,mFAAmF;AACnF,qBAAa,uBAAwB,YAAW,iBAAiB;IAC/D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAuB;IAClD,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAU;gBAEjB,OAAO,GAAE,8BAAmC;IAMlD,MAAM,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA0C/D,OAAO,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAKxE,IAAI,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAwCjE,MAAM,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAwB5E,KAAK,IAAI,IAAI;IAIb,OAAO,CAAC,MAAM;IAOd,OAAO,CAAC,OAAO;CAUhB"}
@@ -0,0 +1,19 @@
1
+ import type { CreateShareSessionInput, GetShareSessionByIdInput, RenewShareSessionIfValidInput, RevokeShareSessionInput, ShareSessionRecord, ShareSessionStorage } from "@sixb/core/storage";
2
+ import { type SqliteStoreConnection } from "./transactions";
3
+ export interface SqliteShareSessionStorageOptions {
4
+ readonly path?: string;
5
+ readonly connection?: SqliteStoreConnection;
6
+ }
7
+ /** SQLite persistence for short-lived Share access sessions. */
8
+ export declare class SqliteShareSessionStorage implements ShareSessionStorage {
9
+ private readonly connection;
10
+ private readonly db;
11
+ constructor(options?: SqliteShareSessionStorageOptions);
12
+ create(input: CreateShareSessionInput): Promise<ShareSessionRecord>;
13
+ getById(input: GetShareSessionByIdInput): Promise<ShareSessionRecord | null>;
14
+ renewIfValid(input: RenewShareSessionIfValidInput): Promise<ShareSessionRecord | null>;
15
+ revoke(input: RevokeShareSessionInput): Promise<ShareSessionRecord | null>;
16
+ close(): void;
17
+ private getRow;
18
+ }
19
+ //# sourceMappingURL=share-session-storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"share-session-storage.d.ts","sourceRoot":"","sources":["../src/share-session-storage.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,uBAAuB,EACvB,wBAAwB,EACxB,6BAA6B,EAC7B,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,oBAAoB,CAAA;AAI3B,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,gBAAgB,CAAA;AAEvB,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,UAAU,CAAC,EAAE,qBAAqB,CAAA;CAC5C;AAED,gEAAgE;AAChE,qBAAa,yBAA0B,YAAW,mBAAmB;IACnE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAuB;IAClD,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAU;gBAEjB,OAAO,GAAE,gCAAqC;IAMpD,MAAM,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA2CnE,OAAO,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAK5E,YAAY,CAAC,KAAK,EAAE,6BAA6B,GAAG,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAuCtF,MAAM,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAsBhF,KAAK,IAAI,IAAI;IAIb,OAAO,CAAC,MAAM;CAMf"}
@@ -1,2 +1,3 @@
1
1
  export declare function isUniqueConstraintError(error: unknown): boolean;
2
+ export declare function isForeignKeyConstraintError(error: unknown): boolean;
2
3
  //# sourceMappingURL=storage-errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"storage-errors.d.ts","sourceRoot":"","sources":["../src/storage-errors.ts"],"names":[],"mappings":"AAAA,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAE/D"}
1
+ {"version":3,"file":"storage-errors.d.ts","sourceRoot":"","sources":["../src/storage-errors.ts"],"names":[],"mappings":"AAAA,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAE/D;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEnE"}
@@ -15,4 +15,12 @@ export declare function runImmediateTransaction<T>(db: Database, run: () => T):
15
15
  /** Lets timers and request handlers run between bounded synchronous SQLite chunks. */
16
16
  export declare function yieldSqliteEventLoop(): Promise<void>;
17
17
  export declare function runImmediateTransactionAsync<T>(db: Database, run: () => Promise<T> | T): Promise<T>;
18
+ /**
19
+ * Run a multi-statement read against one proven SQLite snapshot.
20
+ *
21
+ * A provider-owned immediate transaction already has a stable snapshot and may be reused. Any
22
+ * other pre-existing transaction is rejected because this provider cannot prove who owns it or
23
+ * which lifecycle will close it.
24
+ */
25
+ export declare function runDeferredReadTransaction<T>(db: Database, run: () => T): T;
18
26
  //# sourceMappingURL=transactions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transactions.d.ts","sourceRoot":"","sources":["../src/transactions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAK1C,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAA;IACrB,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAA;IAChC,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAA;CAC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B,0BAA0B,CAAC,UAAU,EAAE,qBAAqB,GAAG,IAAI,CAIlF;AAKD,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,CAkBxE;AAED,sFAAsF;AACtF,wBAAgB,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CAEpD;AAED,wBAAsB,4BAA4B,CAAC,CAAC,EAClD,EAAE,EAAE,QAAQ,EACZ,GAAG,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GACxB,OAAO,CAAC,CAAC,CAAC,CAkBZ;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,CAsB3E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sixb/sqlite",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "SQLite storage provider for Sixb",
5
5
  "keywords": [
6
6
  "sixb",
@@ -36,10 +36,10 @@
36
36
  "prepack": "bun run build"
37
37
  },
38
38
  "peerDependencies": {
39
- "@sixb/core": "0.1.6"
39
+ "@sixb/core": "0.1.8"
40
40
  },
41
41
  "devDependencies": {
42
- "@sixb/core": "0.1.6",
42
+ "@sixb/core": "0.1.8",
43
43
  "@types/bun": "latest",
44
44
  "typescript": "^5.7.0"
45
45
  },
@@ -8,7 +8,10 @@ import {
8
8
  type AgentRunDiagnostic,
9
9
  type AgentRunRecord,
10
10
  type AgentThreadRecord,
11
+ type ConversationAgentRunSpec,
11
12
  coerceAgentRunFinishReason,
13
+ type SubagentRunResult,
14
+ type SubagentRunSpec,
12
15
  } from "@sixb/core/storage"
13
16
  import type { SqliteValue } from "../run-list-query"
14
17
 
@@ -17,7 +20,6 @@ import type { SqliteValue } from "../run-list-query"
17
20
  export interface AgentThreadRow {
18
21
  project_id: string
19
22
  id: string
20
- agent_id: string
21
23
  owner_principal_type: Principal["type"]
22
24
  owner_principal_id: string
23
25
  title: string | null
@@ -33,9 +35,13 @@ export interface AgentRunRow {
33
35
  project_id: string
34
36
  id: string
35
37
  execution_id: string
36
- thread_id: string
37
- agent_id: string
38
- trigger_message_id: string
38
+ kind: AgentRunRecord["kind"]
39
+ thread_id: string | null
40
+ trigger_message_id: string | null
41
+ parent_run_id: string | null
42
+ spawn_key: string | null
43
+ spec: string | null
44
+ result: string | null
39
45
  requester_group_ids: string
40
46
  status: AgentRunRecord["status"]
41
47
  model_id: string | null
@@ -89,7 +95,6 @@ export function rowToThreadRecord(row: AgentThreadRow): AgentThreadRecord {
89
95
  return {
90
96
  id: row.id,
91
97
  projectId: row.project_id,
92
- agentId: row.agent_id,
93
98
  ownerPrincipal: { type: row.owner_principal_type, id: row.owner_principal_id },
94
99
  title: row.title ?? undefined,
95
100
  status: row.status,
@@ -102,13 +107,10 @@ export function rowToThreadRecord(row: AgentThreadRow): AgentThreadRecord {
102
107
  }
103
108
 
104
109
  export function rowToRunRecord(row: AgentRunRow): AgentRunRecord {
105
- return {
110
+ const base = {
106
111
  id: row.id,
107
112
  projectId: row.project_id,
108
113
  executionId: row.execution_id,
109
- threadId: row.thread_id,
110
- agentId: row.agent_id,
111
- triggerMessageId: row.trigger_message_id,
112
114
  requesterGroupIds: JSON.parse(row.requester_group_ids) as string[],
113
115
  status: row.status,
114
116
  modelId: row.model_id ?? undefined,
@@ -128,6 +130,31 @@ export function rowToRunRecord(row: AgentRunRow): AgentRunRecord {
128
130
  startedAt: row.started_at ? new Date(row.started_at) : undefined,
129
131
  completedAt: row.completed_at ? new Date(row.completed_at) : undefined,
130
132
  }
133
+ if (row.kind === "conversation") {
134
+ if (!row.thread_id || !row.trigger_message_id) {
135
+ throw new Error(
136
+ `[SixbSqlite] Conversational Agent run '${row.id}' has invalid persisted fields.`
137
+ )
138
+ }
139
+ return {
140
+ ...base,
141
+ kind: "conversation",
142
+ threadId: row.thread_id,
143
+ triggerMessageId: row.trigger_message_id,
144
+ ...(row.spec === null ? {} : { spec: JSON.parse(row.spec) as ConversationAgentRunSpec }),
145
+ }
146
+ }
147
+ if (!row.parent_run_id || !row.spawn_key || row.spec === null) {
148
+ throw new Error(`[SixbSqlite] Subagent run '${row.id}' has invalid persisted fields.`)
149
+ }
150
+ return {
151
+ ...base,
152
+ kind: "subagent",
153
+ parentRunId: row.parent_run_id,
154
+ spawnKey: row.spawn_key,
155
+ spec: JSON.parse(row.spec) as SubagentRunSpec,
156
+ ...(row.result === null ? {} : { result: JSON.parse(row.result) as SubagentRunResult }),
157
+ }
131
158
  }
132
159
 
133
160
  export function rowToMessageRecord(row: AgentMessageRow): AgentMessageRecord {