@sixb/pg 0.1.11 → 0.1.12
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 +34 -0
- package/dist/agents/rows.d.ts +3 -1
- package/dist/agents/rows.d.ts.map +1 -1
- package/dist/agents/threads.d.ts +3 -2
- package/dist/agents/threads.d.ts.map +1 -1
- package/dist/index.js +553 -54
- package/dist/index.js.map +16 -14
- package/dist/migrations.d.ts.map +1 -1
- package/dist/objects/query-compiler.d.ts +8 -1
- package/dist/objects/query-compiler.d.ts.map +1 -1
- package/dist/objects/read-scope.d.ts +1 -0
- package/dist/objects/read-scope.d.ts.map +1 -1
- package/dist/objects/reader.d.ts +1 -0
- package/dist/objects/reader.d.ts.map +1 -1
- package/dist/objects/rows.d.ts +1 -0
- package/dist/objects/rows.d.ts.map +1 -1
- package/dist/objects/storage.d.ts +1 -1
- package/dist/objects/storage.d.ts.map +1 -1
- package/dist/ontology-storage/index.d.ts +4 -0
- package/dist/ontology-storage/index.d.ts.map +1 -1
- package/dist/ontology-storage/materializations.d.ts +1 -0
- package/dist/ontology-storage/materializations.d.ts.map +1 -1
- package/dist/ontology-storage/vector-indexing.d.ts +20 -0
- package/dist/ontology-storage/vector-indexing.d.ts.map +1 -0
- package/dist/ontology-storage/vectors.d.ts +16 -0
- package/dist/ontology-storage/vectors.d.ts.map +1 -0
- package/dist/pg-ai-cost-storage.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/agents/rows.ts +21 -0
- package/src/agents/threads.ts +47 -2
- package/src/migrations/041-agent-thread-workspaces.sql +2 -0
- package/src/migrations/042-vector-profiles.sql +28 -0
- package/src/migrations/043-vector-indexing.sql +24 -0
- package/src/migrations/044-vector-batching.sql +3 -0
- package/src/migrations/045-agent-thread-sandbox-state.sql +2 -0
- package/src/migrations.ts +14 -0
- package/src/objects/query-compiler.ts +102 -11
- package/src/objects/read-scope.ts +26 -25
- package/src/objects/reader.ts +33 -1
- package/src/objects/rows.ts +5 -1
- package/src/objects/storage.ts +20 -2
- package/src/ontology-storage/index.ts +15 -0
- package/src/ontology-storage/materializations.ts +13 -0
- package/src/ontology-storage/vector-indexing.ts +168 -0
- package/src/ontology-storage/vectors.ts +172 -0
- package/src/pg-ai-cost-storage.ts +4 -0
package/README.md
CHANGED
|
@@ -39,6 +39,40 @@ applied step fails startup instead of silently rewriting migration history. Befo
|
|
|
39
39
|
breaking migration may still require recreating the database. `dropSchema()` exists for exactly
|
|
40
40
|
that, and for test teardown — it deletes every Sixb table and the schema itself.
|
|
41
41
|
|
|
42
|
+
## Vector profiles
|
|
43
|
+
|
|
44
|
+
Named `search.vectors` profiles persist by default after the standard migrations. Embeddings
|
|
45
|
+
and provenance live in `object_vectors`, using native `real[]` values; pgvector is not required.
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
await sixb.objects(Product).byId("product-1").vector("content").index()
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Generation runs outside the transaction. The subsequent write checks object and vector revisions;
|
|
52
|
+
source changes invalidate affected profiles atomically, including projection updates. Reindexing
|
|
53
|
+
leaves the business object's version and events unchanged.
|
|
54
|
+
|
|
55
|
+
Search requires pgvector installed in the `public` schema by the database administrator:
|
|
56
|
+
|
|
57
|
+
```sql
|
|
58
|
+
CREATE EXTENSION vector WITH SCHEMA public;
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
const result = await sixb.objects(Product).query()
|
|
63
|
+
.vector("content", "lightweight running shoes", { k: 10 }).list()
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The exact cosine search applies filters and source-property permissions before ranking.
|
|
67
|
+
Sixb normalizes stored and query vectors to unit length. At most 10,000 eligible vectors and
|
|
68
|
+
16 million coordinates may be scored per search; larger queries fail explicitly. Configure
|
|
69
|
+
`statementTimeoutMillis` to bound SQL execution time.
|
|
70
|
+
|
|
71
|
+
Projections refresh embeddings in the background. Use `index()` to index existing objects after
|
|
72
|
+
adding or changing a profile, or to retry explicitly.
|
|
73
|
+
|
|
74
|
+
Tested with pgvector 0.8.1; no approximate index is created.
|
|
75
|
+
|
|
42
76
|
## Pooling and timeouts
|
|
43
77
|
|
|
44
78
|
| Option | Default | Why you would set it |
|
package/dist/agents/rows.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AgentMessagePart, JsonValue, Principal } from "@sixb/core";
|
|
2
|
-
import { type AgentContextCheckpointRecord, type AgentMessageRecord, type AgentRunDiagnostic, type AgentRunRecord, type AgentThreadRecord, type ConversationAgentRunSpec, type SubagentRunResult, type SubagentRunSpec } from "@sixb/core/storage";
|
|
2
|
+
import { type AgentContextCheckpointRecord, type AgentMessageRecord, type AgentRunDiagnostic, type AgentRunRecord, type AgentThreadRecord, type AgentThreadSandboxState, type ConversationAgentRunSpec, type SubagentRunResult, type SubagentRunSpec } from "@sixb/core/storage";
|
|
3
3
|
import type { SQLClient, SqlParameter } from "../pg-client";
|
|
4
4
|
export interface AgentThreadRow {
|
|
5
5
|
project_id: string;
|
|
@@ -7,6 +7,8 @@ export interface AgentThreadRow {
|
|
|
7
7
|
owner_principal_type: Principal["type"];
|
|
8
8
|
owner_principal_id: string;
|
|
9
9
|
title: string | null;
|
|
10
|
+
sandbox_params: JsonValue | string | null;
|
|
11
|
+
sandbox_state: AgentThreadSandboxState | string | null;
|
|
10
12
|
status: AgentThreadRecord["status"];
|
|
11
13
|
active_run_id: string | null;
|
|
12
14
|
last_message_at: Date | string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rows.d.ts","sourceRoot":"","sources":["../../src/agents/rows.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"rows.d.ts","sourceRoot":"","sources":["../../src/agents/rows.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAA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OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CACzB,GAAG,OAAO,CAAC;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,IAAI,EAAE,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAwBjG"}
|
package/dist/agents/threads.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { type AgentThreadRecord, type AgentThreadStore, type CreateAgentThreadInput, type ListAgentThreadsInput, type ListAgentThreadsResult } from "@sixb/core/storage";
|
|
2
|
-
import type
|
|
1
|
+
import { type AgentThreadRecord, type AgentThreadSandboxState, type AgentThreadStore, type CreateAgentThreadInput, type ListAgentThreadsInput, type ListAgentThreadsResult, type TransitionAgentThreadSandboxInput } from "@sixb/core/storage";
|
|
2
|
+
import { type PgStoreClient } from "../transactions";
|
|
3
3
|
export declare class PgAgentThreadStore implements AgentThreadStore {
|
|
4
4
|
private readonly sql;
|
|
5
5
|
constructor(sql: PgStoreClient);
|
|
6
|
+
transitionSandbox(input: TransitionAgentThreadSandboxInput): Promise<AgentThreadSandboxState>;
|
|
6
7
|
create(input: CreateAgentThreadInput): Promise<AgentThreadRecord>;
|
|
7
8
|
getById(params: {
|
|
8
9
|
projectId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"threads.d.ts","sourceRoot":"","sources":["../../src/agents/threads.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"threads.d.ts","sourceRoot":"","sources":["../../src/agents/threads.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,iCAAiC,EACvC,MAAM,oBAAoB,CAAA;AAG3B,OAAO,EAAE,KAAK,aAAa,EAAoB,MAAM,iBAAiB,CAAA;AAStE,qBAAa,kBAAmB,YAAW,gBAAgB;IAC7C,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,aAAa;IAEzC,iBAAiB,CACrB,KAAK,EAAE,iCAAiC,GACvC,OAAO,CAAC,uBAAuB,CAAC;IAyB7B,MAAM,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA+CjE,OAAO,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAQrF,IAAI,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC;CAkC1E"}
|