weave-typescript 0.26.0 → 0.28.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/dist/weaveapi/consolidation/v1/consolidation.pb.d.ts +134 -0
- package/dist/weaveapi/consolidation/v1/consolidation.pb.js +1620 -0
- package/dist/weaveapi/consolidation/v1/service.pb.d.ts +93 -0
- package/dist/weaveapi/consolidation/v1/service.pb.js +427 -0
- package/dist/weaveapi/ingestion/v1/ingestion.pb.d.ts +433 -0
- package/dist/weaveapi/ingestion/v1/ingestion.pb.js +5626 -0
- package/dist/weaveapi/ingestion/v1/service.pb.d.ts +181 -0
- package/dist/weaveapi/ingestion/v1/service.pb.js +917 -0
- package/dist/weaveapi/model/v1/model.pb.d.ts +10 -0
- package/dist/weaveapi/model/v1/model.pb.js +181 -1
- package/dist/weaveapi/model/v1/service.pb.d.ts +50 -1
- package/dist/weaveapi/model/v1/service.pb.js +464 -1
- package/dist/weaveapi/retrieval/v1/retrieval.pb.d.ts +161 -0
- package/dist/weaveapi/retrieval/v1/retrieval.pb.js +1885 -0
- package/dist/weaveapi/retrieval/v1/service.pb.d.ts +51 -0
- package/dist/weaveapi/retrieval/v1/service.pb.js +164 -0
- package/dist/weavesql/weavedb/chat_sql.d.ts +12 -5
- package/dist/weavesql/weavedb/chat_sql.js +21 -14
- package/dist/weavesql/weavedb/consolidation_sql.d.ts +212 -0
- package/dist/weavesql/weavedb/consolidation_sql.js +470 -0
- package/dist/weavesql/weavedb/document_security_sql.d.ts +128 -0
- package/dist/weavesql/weavedb/document_security_sql.js +284 -0
- package/dist/weavesql/weavedb/ingestion_sql.d.ts +1108 -0
- package/dist/weavesql/weavedb/ingestion_sql.js +2503 -0
- package/dist/weavesql/weavedb/retrieval_sql.d.ts +284 -0
- package/dist/weavesql/weavedb/retrieval_sql.js +769 -0
- package/package.json +2 -2
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ExplainRetrievalRequest, ExplainRetrievalResponse, RetrieveRequest, RetrieveResponse } from "./retrieval.pb";
|
|
2
|
+
export declare const protobufPackage = "weaveapi.retrieval.v1";
|
|
3
|
+
export interface RetrievalService {
|
|
4
|
+
Retrieve(request: RetrieveRequest): Promise<RetrieveResponse>;
|
|
5
|
+
ExplainRetrieval(request: ExplainRetrievalRequest): Promise<ExplainRetrievalResponse>;
|
|
6
|
+
}
|
|
7
|
+
export declare const RetrievalServiceServiceName = "weaveapi.retrieval.v1.RetrievalService";
|
|
8
|
+
export declare class RetrievalServiceClientImpl implements RetrievalService {
|
|
9
|
+
private readonly rpc;
|
|
10
|
+
private readonly service;
|
|
11
|
+
constructor(rpc: Rpc, opts?: {
|
|
12
|
+
service?: string;
|
|
13
|
+
});
|
|
14
|
+
Retrieve(request: RetrieveRequest): Promise<RetrieveResponse>;
|
|
15
|
+
ExplainRetrieval(request: ExplainRetrievalRequest): Promise<ExplainRetrievalResponse>;
|
|
16
|
+
}
|
|
17
|
+
export type RetrievalServiceDefinition = typeof RetrievalServiceDefinition;
|
|
18
|
+
export declare const RetrievalServiceDefinition: {
|
|
19
|
+
readonly name: "RetrievalService";
|
|
20
|
+
readonly fullName: "weaveapi.retrieval.v1.RetrievalService";
|
|
21
|
+
readonly methods: {
|
|
22
|
+
readonly retrieve: {
|
|
23
|
+
readonly name: "Retrieve";
|
|
24
|
+
readonly requestType: typeof RetrieveRequest;
|
|
25
|
+
readonly requestStream: false;
|
|
26
|
+
readonly responseType: typeof RetrieveResponse;
|
|
27
|
+
readonly responseStream: false;
|
|
28
|
+
readonly options: {
|
|
29
|
+
readonly _unknownFields: {
|
|
30
|
+
readonly 578365826: readonly [Uint8Array];
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
readonly explainRetrieval: {
|
|
35
|
+
readonly name: "ExplainRetrieval";
|
|
36
|
+
readonly requestType: typeof ExplainRetrievalRequest;
|
|
37
|
+
readonly requestStream: false;
|
|
38
|
+
readonly responseType: typeof ExplainRetrievalResponse;
|
|
39
|
+
readonly responseStream: false;
|
|
40
|
+
readonly options: {
|
|
41
|
+
readonly _unknownFields: {
|
|
42
|
+
readonly 578365826: readonly [Uint8Array];
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
interface Rpc {
|
|
49
|
+
request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>;
|
|
50
|
+
}
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
|
+
// versions:
|
|
4
|
+
// protoc-gen-ts_proto v2.11.6
|
|
5
|
+
// protoc unknown
|
|
6
|
+
// source: weaveapi/retrieval/v1/service.proto
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.RetrievalServiceDefinition = exports.RetrievalServiceClientImpl = exports.RetrievalServiceServiceName = exports.protobufPackage = void 0;
|
|
9
|
+
/* eslint-disable */
|
|
10
|
+
const wire_1 = require("@bufbuild/protobuf/wire");
|
|
11
|
+
const retrieval_pb_1 = require("./retrieval.pb");
|
|
12
|
+
exports.protobufPackage = "weaveapi.retrieval.v1";
|
|
13
|
+
exports.RetrievalServiceServiceName = "weaveapi.retrieval.v1.RetrievalService";
|
|
14
|
+
class RetrievalServiceClientImpl {
|
|
15
|
+
constructor(rpc, opts) {
|
|
16
|
+
this.service = (opts === null || opts === void 0 ? void 0 : opts.service) || exports.RetrievalServiceServiceName;
|
|
17
|
+
this.rpc = rpc;
|
|
18
|
+
this.Retrieve = this.Retrieve.bind(this);
|
|
19
|
+
this.ExplainRetrieval = this.ExplainRetrieval.bind(this);
|
|
20
|
+
}
|
|
21
|
+
Retrieve(request) {
|
|
22
|
+
const data = retrieval_pb_1.RetrieveRequest.encode(request).finish();
|
|
23
|
+
const promise = this.rpc.request(this.service, "Retrieve", data);
|
|
24
|
+
return promise.then((data) => retrieval_pb_1.RetrieveResponse.decode(new wire_1.BinaryReader(data)));
|
|
25
|
+
}
|
|
26
|
+
ExplainRetrieval(request) {
|
|
27
|
+
const data = retrieval_pb_1.ExplainRetrievalRequest.encode(request).finish();
|
|
28
|
+
const promise = this.rpc.request(this.service, "ExplainRetrieval", data);
|
|
29
|
+
return promise.then((data) => retrieval_pb_1.ExplainRetrievalResponse.decode(new wire_1.BinaryReader(data)));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.RetrievalServiceClientImpl = RetrievalServiceClientImpl;
|
|
33
|
+
exports.RetrievalServiceDefinition = {
|
|
34
|
+
name: "RetrievalService",
|
|
35
|
+
fullName: "weaveapi.retrieval.v1.RetrievalService",
|
|
36
|
+
methods: {
|
|
37
|
+
retrieve: {
|
|
38
|
+
name: "Retrieve",
|
|
39
|
+
requestType: retrieval_pb_1.RetrieveRequest,
|
|
40
|
+
requestStream: false,
|
|
41
|
+
responseType: retrieval_pb_1.RetrieveResponse,
|
|
42
|
+
responseStream: false,
|
|
43
|
+
options: {
|
|
44
|
+
_unknownFields: {
|
|
45
|
+
578365826: [
|
|
46
|
+
new Uint8Array([
|
|
47
|
+
46,
|
|
48
|
+
58,
|
|
49
|
+
1,
|
|
50
|
+
42,
|
|
51
|
+
34,
|
|
52
|
+
41,
|
|
53
|
+
47,
|
|
54
|
+
118,
|
|
55
|
+
49,
|
|
56
|
+
47,
|
|
57
|
+
111,
|
|
58
|
+
114,
|
|
59
|
+
103,
|
|
60
|
+
47,
|
|
61
|
+
123,
|
|
62
|
+
111,
|
|
63
|
+
114,
|
|
64
|
+
103,
|
|
65
|
+
97,
|
|
66
|
+
110,
|
|
67
|
+
105,
|
|
68
|
+
122,
|
|
69
|
+
97,
|
|
70
|
+
116,
|
|
71
|
+
105,
|
|
72
|
+
111,
|
|
73
|
+
110,
|
|
74
|
+
95,
|
|
75
|
+
105,
|
|
76
|
+
100,
|
|
77
|
+
125,
|
|
78
|
+
47,
|
|
79
|
+
114,
|
|
80
|
+
101,
|
|
81
|
+
116,
|
|
82
|
+
114,
|
|
83
|
+
105,
|
|
84
|
+
101,
|
|
85
|
+
118,
|
|
86
|
+
97,
|
|
87
|
+
108,
|
|
88
|
+
47,
|
|
89
|
+
113,
|
|
90
|
+
117,
|
|
91
|
+
101,
|
|
92
|
+
114,
|
|
93
|
+
121,
|
|
94
|
+
]),
|
|
95
|
+
],
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
explainRetrieval: {
|
|
100
|
+
name: "ExplainRetrieval",
|
|
101
|
+
requestType: retrieval_pb_1.ExplainRetrievalRequest,
|
|
102
|
+
requestStream: false,
|
|
103
|
+
responseType: retrieval_pb_1.ExplainRetrievalResponse,
|
|
104
|
+
responseStream: false,
|
|
105
|
+
options: {
|
|
106
|
+
_unknownFields: {
|
|
107
|
+
578365826: [
|
|
108
|
+
new Uint8Array([
|
|
109
|
+
48,
|
|
110
|
+
58,
|
|
111
|
+
1,
|
|
112
|
+
42,
|
|
113
|
+
34,
|
|
114
|
+
43,
|
|
115
|
+
47,
|
|
116
|
+
118,
|
|
117
|
+
49,
|
|
118
|
+
47,
|
|
119
|
+
111,
|
|
120
|
+
114,
|
|
121
|
+
103,
|
|
122
|
+
47,
|
|
123
|
+
123,
|
|
124
|
+
111,
|
|
125
|
+
114,
|
|
126
|
+
103,
|
|
127
|
+
97,
|
|
128
|
+
110,
|
|
129
|
+
105,
|
|
130
|
+
122,
|
|
131
|
+
97,
|
|
132
|
+
116,
|
|
133
|
+
105,
|
|
134
|
+
111,
|
|
135
|
+
110,
|
|
136
|
+
95,
|
|
137
|
+
105,
|
|
138
|
+
100,
|
|
139
|
+
125,
|
|
140
|
+
47,
|
|
141
|
+
114,
|
|
142
|
+
101,
|
|
143
|
+
116,
|
|
144
|
+
114,
|
|
145
|
+
105,
|
|
146
|
+
101,
|
|
147
|
+
118,
|
|
148
|
+
97,
|
|
149
|
+
108,
|
|
150
|
+
47,
|
|
151
|
+
101,
|
|
152
|
+
120,
|
|
153
|
+
112,
|
|
154
|
+
108,
|
|
155
|
+
97,
|
|
156
|
+
105,
|
|
157
|
+
110,
|
|
158
|
+
]),
|
|
159
|
+
],
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
};
|
|
@@ -151,12 +151,13 @@ export interface ListProjectsForChatSessionRow {
|
|
|
151
151
|
projectId: string;
|
|
152
152
|
}
|
|
153
153
|
export declare function listProjectsForChatSession(client: Client, args: ListProjectsForChatSessionArgs): Promise<ListProjectsForChatSessionRow[]>;
|
|
154
|
-
export declare const insertChatMessageQuery = "-- name: InsertChatMessage :one\nINSERT INTO weave.chat_messages (\n id, session_id, role, content,\n parent_message_id, tool_call_id, tool_call_state,\n model_id, ephemeral_attachment_count, ephemeral_attachment_mime_types,\n token_usage, stream_state\n) VALUES (\n $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12\n)\nRETURNING id, session_id, role, content, parent_message_id, tool_call_id, tool_call_state, model_id, ephemeral_attachment_count, ephemeral_attachment_mime_types, token_usage, stream_state, created_at, completed_at";
|
|
154
|
+
export declare const insertChatMessageQuery = "-- name: InsertChatMessage :one\nINSERT INTO weave.chat_messages (\n id, session_id, role, content,\n reasoning_content,\n parent_message_id, tool_call_id, tool_call_state,\n model_id, ephemeral_attachment_count, ephemeral_attachment_mime_types,\n token_usage, stream_state\n) VALUES (\n $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13\n)\nRETURNING id, session_id, role, content, parent_message_id, tool_call_id, tool_call_state, model_id, ephemeral_attachment_count, ephemeral_attachment_mime_types, token_usage, stream_state, created_at, completed_at, reasoning_content";
|
|
155
155
|
export interface InsertChatMessageArgs {
|
|
156
156
|
id: string;
|
|
157
157
|
sessionId: string;
|
|
158
158
|
role: string;
|
|
159
159
|
content: string;
|
|
160
|
+
reasoningContent: string;
|
|
160
161
|
parentMessageId: string | null;
|
|
161
162
|
toolCallId: string | null;
|
|
162
163
|
toolCallState: string;
|
|
@@ -181,9 +182,10 @@ export interface InsertChatMessageRow {
|
|
|
181
182
|
streamState: string;
|
|
182
183
|
createdAt: Date;
|
|
183
184
|
completedAt: Date | null;
|
|
185
|
+
reasoningContent: string;
|
|
184
186
|
}
|
|
185
187
|
export declare function insertChatMessage(client: Client, args: InsertChatMessageArgs): Promise<InsertChatMessageRow | null>;
|
|
186
|
-
export declare const getChatMessageQuery = "-- name: GetChatMessage :one\nSELECT id, session_id, role, content, parent_message_id, tool_call_id, tool_call_state, model_id, ephemeral_attachment_count, ephemeral_attachment_mime_types, token_usage, stream_state, created_at, completed_at FROM weave.chat_messages WHERE id = $1";
|
|
188
|
+
export declare const getChatMessageQuery = "-- name: GetChatMessage :one\nSELECT id, session_id, role, content, parent_message_id, tool_call_id, tool_call_state, model_id, ephemeral_attachment_count, ephemeral_attachment_mime_types, token_usage, stream_state, created_at, completed_at, reasoning_content FROM weave.chat_messages WHERE id = $1";
|
|
187
189
|
export interface GetChatMessageArgs {
|
|
188
190
|
id: string;
|
|
189
191
|
}
|
|
@@ -202,9 +204,10 @@ export interface GetChatMessageRow {
|
|
|
202
204
|
streamState: string;
|
|
203
205
|
createdAt: Date;
|
|
204
206
|
completedAt: Date | null;
|
|
207
|
+
reasoningContent: string;
|
|
205
208
|
}
|
|
206
209
|
export declare function getChatMessage(client: Client, args: GetChatMessageArgs): Promise<GetChatMessageRow | null>;
|
|
207
|
-
export declare const listChatMessagesForSessionQuery = "-- name: ListChatMessagesForSession :many\nSELECT id, session_id, role, content, parent_message_id, tool_call_id, tool_call_state, model_id, ephemeral_attachment_count, ephemeral_attachment_mime_types, token_usage, stream_state, created_at, completed_at FROM weave.chat_messages\nWHERE session_id = $1\nORDER BY created_at";
|
|
210
|
+
export declare const listChatMessagesForSessionQuery = "-- name: ListChatMessagesForSession :many\nSELECT id, session_id, role, content, parent_message_id, tool_call_id, tool_call_state, model_id, ephemeral_attachment_count, ephemeral_attachment_mime_types, token_usage, stream_state, created_at, completed_at, reasoning_content FROM weave.chat_messages\nWHERE session_id = $1\nORDER BY created_at";
|
|
208
211
|
export interface ListChatMessagesForSessionArgs {
|
|
209
212
|
sessionId: string;
|
|
210
213
|
}
|
|
@@ -223,9 +226,10 @@ export interface ListChatMessagesForSessionRow {
|
|
|
223
226
|
streamState: string;
|
|
224
227
|
createdAt: Date;
|
|
225
228
|
completedAt: Date | null;
|
|
229
|
+
reasoningContent: string;
|
|
226
230
|
}
|
|
227
231
|
export declare function listChatMessagesForSession(client: Client, args: ListChatMessagesForSessionArgs): Promise<ListChatMessagesForSessionRow[]>;
|
|
228
|
-
export declare const updateChatMessageToolCallStateQuery = "-- name: UpdateChatMessageToolCallState :one\nUPDATE weave.chat_messages\nSET tool_call_state = $2\nWHERE id = $1\nRETURNING id, session_id, role, content, parent_message_id, tool_call_id, tool_call_state, model_id, ephemeral_attachment_count, ephemeral_attachment_mime_types, token_usage, stream_state, created_at, completed_at";
|
|
232
|
+
export declare const updateChatMessageToolCallStateQuery = "-- name: UpdateChatMessageToolCallState :one\nUPDATE weave.chat_messages\nSET tool_call_state = $2\nWHERE id = $1\nRETURNING id, session_id, role, content, parent_message_id, tool_call_id, tool_call_state, model_id, ephemeral_attachment_count, ephemeral_attachment_mime_types, token_usage, stream_state, created_at, completed_at, reasoning_content";
|
|
229
233
|
export interface UpdateChatMessageToolCallStateArgs {
|
|
230
234
|
id: string;
|
|
231
235
|
toolCallState: string;
|
|
@@ -245,13 +249,15 @@ export interface UpdateChatMessageToolCallStateRow {
|
|
|
245
249
|
streamState: string;
|
|
246
250
|
createdAt: Date;
|
|
247
251
|
completedAt: Date | null;
|
|
252
|
+
reasoningContent: string;
|
|
248
253
|
}
|
|
249
254
|
export declare function updateChatMessageToolCallState(client: Client, args: UpdateChatMessageToolCallStateArgs): Promise<UpdateChatMessageToolCallStateRow | null>;
|
|
250
|
-
export declare const completeChatMessageQuery = "-- name: CompleteChatMessage :one\nUPDATE weave.chat_messages\nSET stream_state = $2,\n content = $3,\n
|
|
255
|
+
export declare const completeChatMessageQuery = "-- name: CompleteChatMessage :one\nUPDATE weave.chat_messages\nSET stream_state = $2,\n content = $3,\n reasoning_content = $4,\n token_usage = $5,\n completed_at = now()\nWHERE id = $1\nRETURNING id, session_id, role, content, parent_message_id, tool_call_id, tool_call_state, model_id, ephemeral_attachment_count, ephemeral_attachment_mime_types, token_usage, stream_state, created_at, completed_at, reasoning_content";
|
|
251
256
|
export interface CompleteChatMessageArgs {
|
|
252
257
|
id: string;
|
|
253
258
|
streamState: string;
|
|
254
259
|
content: string;
|
|
260
|
+
reasoningContent: string;
|
|
255
261
|
tokenUsage: any | null;
|
|
256
262
|
}
|
|
257
263
|
export interface CompleteChatMessageRow {
|
|
@@ -269,6 +275,7 @@ export interface CompleteChatMessageRow {
|
|
|
269
275
|
streamState: string;
|
|
270
276
|
createdAt: Date;
|
|
271
277
|
completedAt: Date | null;
|
|
278
|
+
reasoningContent: string;
|
|
272
279
|
}
|
|
273
280
|
export declare function completeChatMessage(client: Client, args: CompleteChatMessageArgs): Promise<CompleteChatMessageRow | null>;
|
|
274
281
|
export declare const createOrganizationApprovedModelQuery = "-- name: CreateOrganizationApprovedModel :one\nINSERT INTO weave.organization_approved_models (\n id, organization_id, provider_configuration_id, model_id, approved_by_user_id\n) VALUES (\n $1, $2, $3, $4, $5\n)\nRETURNING id, organization_id, provider_configuration_id, model_id, approved_by_user_id, approved_at";
|
|
@@ -266,17 +266,18 @@ async function listProjectsForChatSession(client, args) {
|
|
|
266
266
|
exports.insertChatMessageQuery = `-- name: InsertChatMessage :one
|
|
267
267
|
INSERT INTO weave.chat_messages (
|
|
268
268
|
id, session_id, role, content,
|
|
269
|
+
reasoning_content,
|
|
269
270
|
parent_message_id, tool_call_id, tool_call_state,
|
|
270
271
|
model_id, ephemeral_attachment_count, ephemeral_attachment_mime_types,
|
|
271
272
|
token_usage, stream_state
|
|
272
273
|
) VALUES (
|
|
273
|
-
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12
|
|
274
|
+
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13
|
|
274
275
|
)
|
|
275
|
-
RETURNING id, session_id, role, content, parent_message_id, tool_call_id, tool_call_state, model_id, ephemeral_attachment_count, ephemeral_attachment_mime_types, token_usage, stream_state, created_at, completed_at`;
|
|
276
|
+
RETURNING id, session_id, role, content, parent_message_id, tool_call_id, tool_call_state, model_id, ephemeral_attachment_count, ephemeral_attachment_mime_types, token_usage, stream_state, created_at, completed_at, reasoning_content`;
|
|
276
277
|
async function insertChatMessage(client, args) {
|
|
277
278
|
const result = await client.query({
|
|
278
279
|
text: exports.insertChatMessageQuery,
|
|
279
|
-
values: [args.id, args.sessionId, args.role, args.content, args.parentMessageId, args.toolCallId, args.toolCallState, args.modelId, args.ephemeralAttachmentCount, args.ephemeralAttachmentMimeTypes, args.tokenUsage, args.streamState],
|
|
280
|
+
values: [args.id, args.sessionId, args.role, args.content, args.reasoningContent, args.parentMessageId, args.toolCallId, args.toolCallState, args.modelId, args.ephemeralAttachmentCount, args.ephemeralAttachmentMimeTypes, args.tokenUsage, args.streamState],
|
|
280
281
|
rowMode: "array"
|
|
281
282
|
});
|
|
282
283
|
if (result.rows.length !== 1) {
|
|
@@ -297,11 +298,12 @@ async function insertChatMessage(client, args) {
|
|
|
297
298
|
tokenUsage: row[10],
|
|
298
299
|
streamState: row[11],
|
|
299
300
|
createdAt: row[12],
|
|
300
|
-
completedAt: row[13]
|
|
301
|
+
completedAt: row[13],
|
|
302
|
+
reasoningContent: row[14]
|
|
301
303
|
};
|
|
302
304
|
}
|
|
303
305
|
exports.getChatMessageQuery = `-- name: GetChatMessage :one
|
|
304
|
-
SELECT id, session_id, role, content, parent_message_id, tool_call_id, tool_call_state, model_id, ephemeral_attachment_count, ephemeral_attachment_mime_types, token_usage, stream_state, created_at, completed_at FROM weave.chat_messages WHERE id = $1`;
|
|
306
|
+
SELECT id, session_id, role, content, parent_message_id, tool_call_id, tool_call_state, model_id, ephemeral_attachment_count, ephemeral_attachment_mime_types, token_usage, stream_state, created_at, completed_at, reasoning_content FROM weave.chat_messages WHERE id = $1`;
|
|
305
307
|
async function getChatMessage(client, args) {
|
|
306
308
|
const result = await client.query({
|
|
307
309
|
text: exports.getChatMessageQuery,
|
|
@@ -326,11 +328,12 @@ async function getChatMessage(client, args) {
|
|
|
326
328
|
tokenUsage: row[10],
|
|
327
329
|
streamState: row[11],
|
|
328
330
|
createdAt: row[12],
|
|
329
|
-
completedAt: row[13]
|
|
331
|
+
completedAt: row[13],
|
|
332
|
+
reasoningContent: row[14]
|
|
330
333
|
};
|
|
331
334
|
}
|
|
332
335
|
exports.listChatMessagesForSessionQuery = `-- name: ListChatMessagesForSession :many
|
|
333
|
-
SELECT id, session_id, role, content, parent_message_id, tool_call_id, tool_call_state, model_id, ephemeral_attachment_count, ephemeral_attachment_mime_types, token_usage, stream_state, created_at, completed_at FROM weave.chat_messages
|
|
336
|
+
SELECT id, session_id, role, content, parent_message_id, tool_call_id, tool_call_state, model_id, ephemeral_attachment_count, ephemeral_attachment_mime_types, token_usage, stream_state, created_at, completed_at, reasoning_content FROM weave.chat_messages
|
|
334
337
|
WHERE session_id = $1
|
|
335
338
|
ORDER BY created_at`;
|
|
336
339
|
async function listChatMessagesForSession(client, args) {
|
|
@@ -354,7 +357,8 @@ async function listChatMessagesForSession(client, args) {
|
|
|
354
357
|
tokenUsage: row[10],
|
|
355
358
|
streamState: row[11],
|
|
356
359
|
createdAt: row[12],
|
|
357
|
-
completedAt: row[13]
|
|
360
|
+
completedAt: row[13],
|
|
361
|
+
reasoningContent: row[14]
|
|
358
362
|
};
|
|
359
363
|
});
|
|
360
364
|
}
|
|
@@ -362,7 +366,7 @@ exports.updateChatMessageToolCallStateQuery = `-- name: UpdateChatMessageToolCal
|
|
|
362
366
|
UPDATE weave.chat_messages
|
|
363
367
|
SET tool_call_state = $2
|
|
364
368
|
WHERE id = $1
|
|
365
|
-
RETURNING id, session_id, role, content, parent_message_id, tool_call_id, tool_call_state, model_id, ephemeral_attachment_count, ephemeral_attachment_mime_types, token_usage, stream_state, created_at, completed_at`;
|
|
369
|
+
RETURNING id, session_id, role, content, parent_message_id, tool_call_id, tool_call_state, model_id, ephemeral_attachment_count, ephemeral_attachment_mime_types, token_usage, stream_state, created_at, completed_at, reasoning_content`;
|
|
366
370
|
async function updateChatMessageToolCallState(client, args) {
|
|
367
371
|
const result = await client.query({
|
|
368
372
|
text: exports.updateChatMessageToolCallStateQuery,
|
|
@@ -387,21 +391,23 @@ async function updateChatMessageToolCallState(client, args) {
|
|
|
387
391
|
tokenUsage: row[10],
|
|
388
392
|
streamState: row[11],
|
|
389
393
|
createdAt: row[12],
|
|
390
|
-
completedAt: row[13]
|
|
394
|
+
completedAt: row[13],
|
|
395
|
+
reasoningContent: row[14]
|
|
391
396
|
};
|
|
392
397
|
}
|
|
393
398
|
exports.completeChatMessageQuery = `-- name: CompleteChatMessage :one
|
|
394
399
|
UPDATE weave.chat_messages
|
|
395
400
|
SET stream_state = $2,
|
|
396
401
|
content = $3,
|
|
397
|
-
|
|
402
|
+
reasoning_content = $4,
|
|
403
|
+
token_usage = $5,
|
|
398
404
|
completed_at = now()
|
|
399
405
|
WHERE id = $1
|
|
400
|
-
RETURNING id, session_id, role, content, parent_message_id, tool_call_id, tool_call_state, model_id, ephemeral_attachment_count, ephemeral_attachment_mime_types, token_usage, stream_state, created_at, completed_at`;
|
|
406
|
+
RETURNING id, session_id, role, content, parent_message_id, tool_call_id, tool_call_state, model_id, ephemeral_attachment_count, ephemeral_attachment_mime_types, token_usage, stream_state, created_at, completed_at, reasoning_content`;
|
|
401
407
|
async function completeChatMessage(client, args) {
|
|
402
408
|
const result = await client.query({
|
|
403
409
|
text: exports.completeChatMessageQuery,
|
|
404
|
-
values: [args.id, args.streamState, args.content, args.tokenUsage],
|
|
410
|
+
values: [args.id, args.streamState, args.content, args.reasoningContent, args.tokenUsage],
|
|
405
411
|
rowMode: "array"
|
|
406
412
|
});
|
|
407
413
|
if (result.rows.length !== 1) {
|
|
@@ -422,7 +428,8 @@ async function completeChatMessage(client, args) {
|
|
|
422
428
|
tokenUsage: row[10],
|
|
423
429
|
streamState: row[11],
|
|
424
430
|
createdAt: row[12],
|
|
425
|
-
completedAt: row[13]
|
|
431
|
+
completedAt: row[13],
|
|
432
|
+
reasoningContent: row[14]
|
|
426
433
|
};
|
|
427
434
|
}
|
|
428
435
|
exports.createOrganizationApprovedModelQuery = `-- name: CreateOrganizationApprovedModel :one
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { QueryArrayConfig, QueryArrayResult } from "pg";
|
|
2
|
+
interface Client {
|
|
3
|
+
query: (config: QueryArrayConfig) => Promise<QueryArrayResult>;
|
|
4
|
+
}
|
|
5
|
+
export declare const createConsolidationRunQuery = "-- name: CreateConsolidationRun :one\nINSERT INTO weave.consolidation_runs (\n id,\n organization_id,\n status\n) VALUES (\n $1,\n $2,\n $3\n)\nRETURNING\n id,\n organization_id,\n status,\n thread_count,\n cluster_count,\n hierarchy_depth,\n error,\n started_at,\n completed_at";
|
|
6
|
+
export interface CreateConsolidationRunArgs {
|
|
7
|
+
id: string;
|
|
8
|
+
organizationId: string;
|
|
9
|
+
status: string;
|
|
10
|
+
}
|
|
11
|
+
export interface CreateConsolidationRunRow {
|
|
12
|
+
id: string;
|
|
13
|
+
organizationId: string;
|
|
14
|
+
status: string;
|
|
15
|
+
threadCount: number;
|
|
16
|
+
clusterCount: number;
|
|
17
|
+
hierarchyDepth: number;
|
|
18
|
+
error: string;
|
|
19
|
+
startedAt: Date;
|
|
20
|
+
completedAt: Date | null;
|
|
21
|
+
}
|
|
22
|
+
export declare function createConsolidationRun(client: Client, args: CreateConsolidationRunArgs): Promise<CreateConsolidationRunRow | null>;
|
|
23
|
+
export declare const getConsolidationRunByOrganizationAndIDQuery = "-- name: GetConsolidationRunByOrganizationAndID :one\nSELECT\n id,\n organization_id,\n status,\n thread_count,\n cluster_count,\n hierarchy_depth,\n error,\n started_at,\n completed_at\nFROM weave.consolidation_runs\nWHERE organization_id = $1\n AND id = $2";
|
|
24
|
+
export interface GetConsolidationRunByOrganizationAndIDArgs {
|
|
25
|
+
organizationId: string;
|
|
26
|
+
id: string;
|
|
27
|
+
}
|
|
28
|
+
export interface GetConsolidationRunByOrganizationAndIDRow {
|
|
29
|
+
id: string;
|
|
30
|
+
organizationId: string;
|
|
31
|
+
status: string;
|
|
32
|
+
threadCount: number;
|
|
33
|
+
clusterCount: number;
|
|
34
|
+
hierarchyDepth: number;
|
|
35
|
+
error: string;
|
|
36
|
+
startedAt: Date;
|
|
37
|
+
completedAt: Date | null;
|
|
38
|
+
}
|
|
39
|
+
export declare function getConsolidationRunByOrganizationAndID(client: Client, args: GetConsolidationRunByOrganizationAndIDArgs): Promise<GetConsolidationRunByOrganizationAndIDRow | null>;
|
|
40
|
+
export declare const updateConsolidationRunStateQuery = "-- name: UpdateConsolidationRunState :one\nUPDATE weave.consolidation_runs\nSET\n status = $1,\n thread_count = $2,\n cluster_count = $3,\n hierarchy_depth = $4,\n error = $5,\n completed_at = $6\nWHERE id = $7\n AND organization_id = $8\nRETURNING\n id,\n organization_id,\n status,\n thread_count,\n cluster_count,\n hierarchy_depth,\n error,\n started_at,\n completed_at";
|
|
41
|
+
export interface UpdateConsolidationRunStateArgs {
|
|
42
|
+
status: string;
|
|
43
|
+
threadCount: number;
|
|
44
|
+
clusterCount: number;
|
|
45
|
+
hierarchyDepth: number;
|
|
46
|
+
error: string;
|
|
47
|
+
completedAt: Date | null;
|
|
48
|
+
id: string;
|
|
49
|
+
organizationId: string;
|
|
50
|
+
}
|
|
51
|
+
export interface UpdateConsolidationRunStateRow {
|
|
52
|
+
id: string;
|
|
53
|
+
organizationId: string;
|
|
54
|
+
status: string;
|
|
55
|
+
threadCount: number;
|
|
56
|
+
clusterCount: number;
|
|
57
|
+
hierarchyDepth: number;
|
|
58
|
+
error: string;
|
|
59
|
+
startedAt: Date;
|
|
60
|
+
completedAt: Date | null;
|
|
61
|
+
}
|
|
62
|
+
export declare function updateConsolidationRunState(client: Client, args: UpdateConsolidationRunStateArgs): Promise<UpdateConsolidationRunStateRow | null>;
|
|
63
|
+
export declare const listConsolidationRunsByOrganizationQuery = "-- name: ListConsolidationRunsByOrganization :many\nSELECT\n id,\n organization_id,\n status,\n thread_count,\n cluster_count,\n hierarchy_depth,\n error,\n started_at,\n completed_at\nFROM weave.consolidation_runs\nWHERE organization_id = $1\nORDER BY started_at DESC\nLIMIT $3 OFFSET $2";
|
|
64
|
+
export interface ListConsolidationRunsByOrganizationArgs {
|
|
65
|
+
organizationId: string;
|
|
66
|
+
pageOffset: string;
|
|
67
|
+
pageSize: string;
|
|
68
|
+
}
|
|
69
|
+
export interface ListConsolidationRunsByOrganizationRow {
|
|
70
|
+
id: string;
|
|
71
|
+
organizationId: string;
|
|
72
|
+
status: string;
|
|
73
|
+
threadCount: number;
|
|
74
|
+
clusterCount: number;
|
|
75
|
+
hierarchyDepth: number;
|
|
76
|
+
error: string;
|
|
77
|
+
startedAt: Date;
|
|
78
|
+
completedAt: Date | null;
|
|
79
|
+
}
|
|
80
|
+
export declare function listConsolidationRunsByOrganization(client: Client, args: ListConsolidationRunsByOrganizationArgs): Promise<ListConsolidationRunsByOrganizationRow[]>;
|
|
81
|
+
export declare const upsertConceptClusterQuery = "-- name: UpsertConceptCluster :one\nINSERT INTO weave.concept_clusters (\n id,\n organization_id,\n realm_kind,\n realm_key,\n name,\n description,\n knowledge_type,\n level,\n parent_id,\n embedding,\n centroid,\n thread_count,\n consolidation_run_id\n) VALUES (\n $1,\n $2,\n $3,\n $4,\n $5,\n $6,\n $7,\n $8,\n $9,\n $10::vector,\n $11::vector,\n $12,\n $13\n)\nON CONFLICT (id) DO UPDATE\nSET\n name = EXCLUDED.name,\n description = EXCLUDED.description,\n realm_kind = EXCLUDED.realm_kind,\n realm_key = EXCLUDED.realm_key,\n knowledge_type = EXCLUDED.knowledge_type,\n level = EXCLUDED.level,\n parent_id = EXCLUDED.parent_id,\n embedding = EXCLUDED.embedding,\n centroid = EXCLUDED.centroid,\n thread_count = EXCLUDED.thread_count,\n consolidation_run_id = EXCLUDED.consolidation_run_id,\n updated_at = now()\nRETURNING\n id,\n organization_id,\n realm_kind,\n realm_key,\n name,\n description,\n knowledge_type,\n level,\n parent_id,\n thread_count,\n consolidation_run_id,\n created_at,\n updated_at";
|
|
82
|
+
export interface UpsertConceptClusterArgs {
|
|
83
|
+
id: string;
|
|
84
|
+
organizationId: string;
|
|
85
|
+
realmKind: string;
|
|
86
|
+
realmKey: string;
|
|
87
|
+
name: string;
|
|
88
|
+
description: string;
|
|
89
|
+
knowledgeType: string;
|
|
90
|
+
level: number;
|
|
91
|
+
parentId: string | null;
|
|
92
|
+
embedding: string;
|
|
93
|
+
centroid: string;
|
|
94
|
+
threadCount: number;
|
|
95
|
+
consolidationRunId: string;
|
|
96
|
+
}
|
|
97
|
+
export interface UpsertConceptClusterRow {
|
|
98
|
+
id: string;
|
|
99
|
+
organizationId: string;
|
|
100
|
+
realmKind: string;
|
|
101
|
+
realmKey: string;
|
|
102
|
+
name: string;
|
|
103
|
+
description: string;
|
|
104
|
+
knowledgeType: string;
|
|
105
|
+
level: number;
|
|
106
|
+
parentId: string | null;
|
|
107
|
+
threadCount: number;
|
|
108
|
+
consolidationRunId: string;
|
|
109
|
+
createdAt: Date;
|
|
110
|
+
updatedAt: Date;
|
|
111
|
+
}
|
|
112
|
+
export declare function upsertConceptCluster(client: Client, args: UpsertConceptClusterArgs): Promise<UpsertConceptClusterRow | null>;
|
|
113
|
+
export declare const getConceptClusterByOrganizationRealmAndIDQuery = "-- name: GetConceptClusterByOrganizationRealmAndID :one\nSELECT\n id,\n organization_id,\n realm_kind,\n realm_key,\n name,\n description,\n knowledge_type,\n level,\n parent_id,\n thread_count,\n consolidation_run_id,\n created_at,\n updated_at\nFROM weave.concept_clusters\nWHERE organization_id = $1\n AND realm_kind = $2\n AND realm_key = $3\n AND id = $4";
|
|
114
|
+
export interface GetConceptClusterByOrganizationRealmAndIDArgs {
|
|
115
|
+
organizationId: string;
|
|
116
|
+
realmKind: string;
|
|
117
|
+
realmKey: string;
|
|
118
|
+
id: string;
|
|
119
|
+
}
|
|
120
|
+
export interface GetConceptClusterByOrganizationRealmAndIDRow {
|
|
121
|
+
id: string;
|
|
122
|
+
organizationId: string;
|
|
123
|
+
realmKind: string;
|
|
124
|
+
realmKey: string;
|
|
125
|
+
name: string;
|
|
126
|
+
description: string;
|
|
127
|
+
knowledgeType: string;
|
|
128
|
+
level: number;
|
|
129
|
+
parentId: string | null;
|
|
130
|
+
threadCount: number;
|
|
131
|
+
consolidationRunId: string;
|
|
132
|
+
createdAt: Date;
|
|
133
|
+
updatedAt: Date;
|
|
134
|
+
}
|
|
135
|
+
export declare function getConceptClusterByOrganizationRealmAndID(client: Client, args: GetConceptClusterByOrganizationRealmAndIDArgs): Promise<GetConceptClusterByOrganizationRealmAndIDRow | null>;
|
|
136
|
+
export declare const listConceptClustersByRealmQuery = "-- name: ListConceptClustersByRealm :many\nSELECT\n id,\n organization_id,\n realm_kind,\n realm_key,\n name,\n description,\n knowledge_type,\n level,\n parent_id,\n thread_count,\n consolidation_run_id,\n created_at,\n updated_at\nFROM weave.concept_clusters\nWHERE organization_id = $1\n AND realm_kind = $2\n AND realm_key = $3\n AND ($4 = '' OR knowledge_type = $4)\n AND ($5 <= 0 OR level <= $5)\nORDER BY level ASC, updated_at DESC, id ASC";
|
|
137
|
+
export interface ListConceptClustersByRealmArgs {
|
|
138
|
+
organizationId: string;
|
|
139
|
+
realmKind: string;
|
|
140
|
+
realmKey: string;
|
|
141
|
+
knowledgeType: string | null;
|
|
142
|
+
maxDepth: string | null;
|
|
143
|
+
}
|
|
144
|
+
export interface ListConceptClustersByRealmRow {
|
|
145
|
+
id: string;
|
|
146
|
+
organizationId: string;
|
|
147
|
+
realmKind: string;
|
|
148
|
+
realmKey: string;
|
|
149
|
+
name: string;
|
|
150
|
+
description: string;
|
|
151
|
+
knowledgeType: string;
|
|
152
|
+
level: number;
|
|
153
|
+
parentId: string | null;
|
|
154
|
+
threadCount: number;
|
|
155
|
+
consolidationRunId: string;
|
|
156
|
+
createdAt: Date;
|
|
157
|
+
updatedAt: Date;
|
|
158
|
+
}
|
|
159
|
+
export declare function listConceptClustersByRealm(client: Client, args: ListConceptClustersByRealmArgs): Promise<ListConceptClustersByRealmRow[]>;
|
|
160
|
+
export declare const listConceptClustersByParentAndRealmQuery = "-- name: ListConceptClustersByParentAndRealm :many\nSELECT\n id,\n organization_id,\n realm_kind,\n realm_key,\n name,\n description,\n knowledge_type,\n level,\n parent_id,\n thread_count,\n consolidation_run_id,\n created_at,\n updated_at\nFROM weave.concept_clusters\nWHERE organization_id = $1\n AND realm_kind = $2\n AND realm_key = $3\n AND parent_id = $4\nORDER BY updated_at DESC, id ASC";
|
|
161
|
+
export interface ListConceptClustersByParentAndRealmArgs {
|
|
162
|
+
organizationId: string;
|
|
163
|
+
realmKind: string;
|
|
164
|
+
realmKey: string;
|
|
165
|
+
parentId: string | null;
|
|
166
|
+
}
|
|
167
|
+
export interface ListConceptClustersByParentAndRealmRow {
|
|
168
|
+
id: string;
|
|
169
|
+
organizationId: string;
|
|
170
|
+
realmKind: string;
|
|
171
|
+
realmKey: string;
|
|
172
|
+
name: string;
|
|
173
|
+
description: string;
|
|
174
|
+
knowledgeType: string;
|
|
175
|
+
level: number;
|
|
176
|
+
parentId: string | null;
|
|
177
|
+
threadCount: number;
|
|
178
|
+
consolidationRunId: string;
|
|
179
|
+
createdAt: Date;
|
|
180
|
+
updatedAt: Date;
|
|
181
|
+
}
|
|
182
|
+
export declare function listConceptClustersByParentAndRealm(client: Client, args: ListConceptClustersByParentAndRealmArgs): Promise<ListConceptClustersByParentAndRealmRow[]>;
|
|
183
|
+
export declare const listApprovedThreadsForConsolidationQuery = "-- name: ListApprovedThreadsForConsolidation :many\nSELECT\n t.id,\n t.organization_id,\n t.document_id,\n t.ingestion_run_id,\n t.text,\n t.knowledge_type,\n t.embedding::text AS embedding_text,\n t.approved_at,\n CASE\n WHEN d.scope = 'DOCUMENT_SCOPE_ORG'\n THEN 'KNOWLEDGE_REALM_KIND_ORG'::text\n WHEN d.scope = 'DOCUMENT_SCOPE_RESTRICTED'\n THEN 'KNOWLEDGE_REALM_KIND_TAG'::text\n WHEN d.scope = 'DOCUMENT_SCOPE_PRIVATE'\n THEN 'KNOWLEDGE_REALM_KIND_USER'::text\n END AS realm_kind,\n CASE\n WHEN d.scope = 'DOCUMENT_SCOPE_ORG'\n THEN ''::text\n WHEN d.scope = 'DOCUMENT_SCOPE_RESTRICTED'\n THEN COALESCE(d.sensitivity_tags[1], ''::text)\n WHEN d.scope = 'DOCUMENT_SCOPE_PRIVATE'\n THEN d.uploaded_by_user_id::text\n END AS realm_key\nFROM weave.threads t\nJOIN weave.documents d ON d.id = t.document_id\nWHERE t.organization_id = $1\n AND t.retrieval_status = 'THREAD_RETRIEVAL_STATUS_APPROVED'\n AND t.embedding IS NOT NULL\nORDER BY t.approved_at DESC, t.id ASC\nLIMIT $3 OFFSET $2";
|
|
184
|
+
export interface ListApprovedThreadsForConsolidationArgs {
|
|
185
|
+
organizationId: string;
|
|
186
|
+
pageOffset: string;
|
|
187
|
+
pageSize: string;
|
|
188
|
+
}
|
|
189
|
+
export interface ListApprovedThreadsForConsolidationRow {
|
|
190
|
+
id: string;
|
|
191
|
+
organizationId: string;
|
|
192
|
+
documentId: string;
|
|
193
|
+
ingestionRunId: string;
|
|
194
|
+
text: string;
|
|
195
|
+
knowledgeType: string;
|
|
196
|
+
embeddingText: string;
|
|
197
|
+
approvedAt: Date | null;
|
|
198
|
+
realmKind: string | null;
|
|
199
|
+
realmKey: string | null;
|
|
200
|
+
}
|
|
201
|
+
export declare function listApprovedThreadsForConsolidation(client: Client, args: ListApprovedThreadsForConsolidationArgs): Promise<ListApprovedThreadsForConsolidationRow[]>;
|
|
202
|
+
export declare const assignThreadsToClusterQuery = "-- name: AssignThreadsToCluster :execrows\nUPDATE weave.threads AS t\nSET cluster_id = cc.id\nFROM weave.concept_clusters cc,\n weave.documents d\nWHERE t.organization_id = $1\n AND t.id = ANY($2::uuid[])\n AND cc.organization_id = t.organization_id\n AND cc.id = $3\n AND d.id = t.document_id\n AND (\n (cc.realm_kind = 'KNOWLEDGE_REALM_KIND_ORG'\n AND cc.realm_key = ''\n AND d.scope = 'DOCUMENT_SCOPE_ORG')\n OR (cc.realm_kind = 'KNOWLEDGE_REALM_KIND_TAG'\n AND d.scope = 'DOCUMENT_SCOPE_RESTRICTED'\n AND cardinality(d.sensitivity_tags) = 1\n AND cc.realm_key = d.sensitivity_tags[1])\n OR (cc.realm_kind = 'KNOWLEDGE_REALM_KIND_USER'\n AND d.scope = 'DOCUMENT_SCOPE_PRIVATE'\n AND cc.realm_key = d.uploaded_by_user_id::text)\n )";
|
|
203
|
+
export interface AssignThreadsToClusterArgs {
|
|
204
|
+
organizationId: string;
|
|
205
|
+
threadIds: string[];
|
|
206
|
+
clusterId: string;
|
|
207
|
+
}
|
|
208
|
+
export declare const clearThreadClusterAssignmentsByOrganizationQuery = "-- name: ClearThreadClusterAssignmentsByOrganization :execrows\nUPDATE weave.threads\nSET cluster_id = NULL\nWHERE organization_id = $1\n AND cluster_id IS NOT NULL";
|
|
209
|
+
export interface ClearThreadClusterAssignmentsByOrganizationArgs {
|
|
210
|
+
organizationId: string;
|
|
211
|
+
}
|
|
212
|
+
export {};
|