@pikku/kysely 0.12.6 → 0.12.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.
- package/CHANGELOG.md +6 -0
- package/dist/src/kysely-agent-run-service.js +59 -59
- package/dist/src/kysely-ai-storage-service.js +174 -174
- package/dist/src/kysely-channel-store.js +12 -12
- package/dist/src/kysely-credential-service.js +29 -29
- package/dist/src/kysely-deployment-service.js +22 -22
- package/dist/src/kysely-eventhub-store.js +8 -8
- package/dist/src/kysely-secret-service.js +19 -19
- package/dist/src/kysely-tables.d.ts +91 -91
- package/dist/src/kysely-workflow-run-service.js +73 -73
- package/dist/src/kysely-workflow-service.js +127 -127
- package/package.json +1 -1
- package/src/kysely-agent-run-service.ts +59 -59
- package/src/kysely-ai-storage-service.ts +174 -174
- package/src/kysely-channel-store.ts +12 -12
- package/src/kysely-credential-service.ts +29 -29
- package/src/kysely-deployment-service.ts +24 -24
- package/src/kysely-eventhub-store.ts +8 -8
- package/src/kysely-secret-service.ts +19 -19
- package/src/kysely-services.test.ts +19 -18
- package/src/kysely-tables.ts +91 -91
- package/src/kysely-workflow-run-service.ts +76 -76
- package/src/kysely-workflow-service.ts +129 -129
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
## 0.12.0
|
|
2
2
|
|
|
3
|
+
## 0.12.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- c485aab: Fix CamelCasePlugin mismatch: convert all table types, query references, and result property accesses from snake_case to camelCase to match Kysely CamelCasePlugin runtime behavior
|
|
8
|
+
|
|
3
9
|
## 0.12.6
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -7,24 +7,24 @@ export class KyselyAgentRunService {
|
|
|
7
7
|
async listThreads(options) {
|
|
8
8
|
const { agentName, limit = 50, offset = 0 } = options ?? {};
|
|
9
9
|
let query = this.db
|
|
10
|
-
.selectFrom('
|
|
10
|
+
.selectFrom('aiThreads as t')
|
|
11
11
|
.select([
|
|
12
12
|
't.id',
|
|
13
|
-
't.
|
|
13
|
+
't.resourceId',
|
|
14
14
|
't.title',
|
|
15
15
|
't.metadata',
|
|
16
|
-
't.
|
|
17
|
-
't.
|
|
16
|
+
't.createdAt',
|
|
17
|
+
't.updatedAt',
|
|
18
18
|
]);
|
|
19
19
|
if (agentName) {
|
|
20
20
|
query = query.where('t.id', 'in', this.db
|
|
21
|
-
.selectFrom('
|
|
22
|
-
.select('
|
|
23
|
-
.where('
|
|
21
|
+
.selectFrom('aiRun')
|
|
22
|
+
.select('threadId')
|
|
23
|
+
.where('agentName', '=', agentName)
|
|
24
24
|
.distinct());
|
|
25
25
|
}
|
|
26
26
|
const result = await query
|
|
27
|
-
.orderBy('t.
|
|
27
|
+
.orderBy('t.updatedAt', 'desc')
|
|
28
28
|
.limit(limit)
|
|
29
29
|
.offset(offset)
|
|
30
30
|
.execute();
|
|
@@ -32,14 +32,14 @@ export class KyselyAgentRunService {
|
|
|
32
32
|
}
|
|
33
33
|
async getThread(threadId) {
|
|
34
34
|
const row = await this.db
|
|
35
|
-
.selectFrom('
|
|
35
|
+
.selectFrom('aiThreads')
|
|
36
36
|
.select([
|
|
37
37
|
'id',
|
|
38
|
-
'
|
|
38
|
+
'resourceId',
|
|
39
39
|
'title',
|
|
40
40
|
'metadata',
|
|
41
|
-
'
|
|
42
|
-
'
|
|
41
|
+
'createdAt',
|
|
42
|
+
'updatedAt',
|
|
43
43
|
])
|
|
44
44
|
.where('id', '=', threadId)
|
|
45
45
|
.executeTakeFirst();
|
|
@@ -50,21 +50,21 @@ export class KyselyAgentRunService {
|
|
|
50
50
|
async getThreadMessages(threadId) {
|
|
51
51
|
const [msgResult, tcResult] = await Promise.all([
|
|
52
52
|
this.db
|
|
53
|
-
.selectFrom('
|
|
54
|
-
.select(['id', 'role', 'content', '
|
|
55
|
-
.where('
|
|
56
|
-
.orderBy('
|
|
53
|
+
.selectFrom('aiMessage')
|
|
54
|
+
.select(['id', 'role', 'content', 'createdAt'])
|
|
55
|
+
.where('threadId', '=', threadId)
|
|
56
|
+
.orderBy('createdAt', 'asc')
|
|
57
57
|
.execute(),
|
|
58
58
|
this.db
|
|
59
|
-
.selectFrom('
|
|
60
|
-
.select(['id', '
|
|
61
|
-
.where('
|
|
62
|
-
.orderBy('
|
|
59
|
+
.selectFrom('aiToolCall')
|
|
60
|
+
.select(['id', 'messageId', 'toolName', 'args', 'result'])
|
|
61
|
+
.where('threadId', '=', threadId)
|
|
62
|
+
.orderBy('createdAt', 'asc')
|
|
63
63
|
.execute(),
|
|
64
64
|
]);
|
|
65
65
|
const tcByMessage = new Map();
|
|
66
66
|
for (const tc of tcResult) {
|
|
67
|
-
const msgId = tc.
|
|
67
|
+
const msgId = tc.messageId;
|
|
68
68
|
if (!tcByMessage.has(msgId))
|
|
69
69
|
tcByMessage.set(msgId, []);
|
|
70
70
|
tcByMessage.get(msgId).push(tc);
|
|
@@ -75,13 +75,13 @@ export class KyselyAgentRunService {
|
|
|
75
75
|
id: row.id,
|
|
76
76
|
role: row.role,
|
|
77
77
|
content: row.content ?? undefined,
|
|
78
|
-
createdAt: new Date(row.
|
|
78
|
+
createdAt: new Date(row.createdAt),
|
|
79
79
|
};
|
|
80
80
|
const tcs = tcByMessage.get(msg.id);
|
|
81
81
|
if (tcs?.length) {
|
|
82
82
|
msg.toolCalls = tcs.map((tc) => ({
|
|
83
83
|
id: tc.id,
|
|
84
|
-
name: tc.
|
|
84
|
+
name: tc.toolName,
|
|
85
85
|
args: parseJson(tc.args),
|
|
86
86
|
}));
|
|
87
87
|
const completed = tcs.filter((tc) => tc.result != null);
|
|
@@ -92,7 +92,7 @@ export class KyselyAgentRunService {
|
|
|
92
92
|
role: 'tool',
|
|
93
93
|
toolResults: completed.map((tc) => ({
|
|
94
94
|
id: tc.id,
|
|
95
|
-
name: tc.
|
|
95
|
+
name: tc.toolName,
|
|
96
96
|
result: tc.result,
|
|
97
97
|
})),
|
|
98
98
|
createdAt: msg.createdAt,
|
|
@@ -106,68 +106,68 @@ export class KyselyAgentRunService {
|
|
|
106
106
|
}
|
|
107
107
|
async getThreadRuns(threadId) {
|
|
108
108
|
const result = await this.db
|
|
109
|
-
.selectFrom('
|
|
109
|
+
.selectFrom('aiRun')
|
|
110
110
|
.select([
|
|
111
|
-
'
|
|
112
|
-
'
|
|
113
|
-
'
|
|
114
|
-
'
|
|
111
|
+
'runId',
|
|
112
|
+
'agentName',
|
|
113
|
+
'threadId',
|
|
114
|
+
'resourceId',
|
|
115
115
|
'status',
|
|
116
|
-
'
|
|
117
|
-
'
|
|
118
|
-
'
|
|
119
|
-
'
|
|
120
|
-
'
|
|
121
|
-
'
|
|
122
|
-
'
|
|
123
|
-
'
|
|
116
|
+
'errorMessage',
|
|
117
|
+
'suspendReason',
|
|
118
|
+
'missingRpcs',
|
|
119
|
+
'usageInputTokens',
|
|
120
|
+
'usageOutputTokens',
|
|
121
|
+
'usageModel',
|
|
122
|
+
'createdAt',
|
|
123
|
+
'updatedAt',
|
|
124
124
|
])
|
|
125
|
-
.where('
|
|
126
|
-
.orderBy('
|
|
125
|
+
.where('threadId', '=', threadId)
|
|
126
|
+
.orderBy('createdAt', 'desc')
|
|
127
127
|
.execute();
|
|
128
128
|
return result.map((row) => this.mapRunRow(row));
|
|
129
129
|
}
|
|
130
130
|
async deleteThread(threadId) {
|
|
131
131
|
const result = await this.db
|
|
132
|
-
.deleteFrom('
|
|
132
|
+
.deleteFrom('aiThreads')
|
|
133
133
|
.where('id', '=', threadId)
|
|
134
134
|
.executeTakeFirst();
|
|
135
135
|
return BigInt(result.numDeletedRows) > 0n;
|
|
136
136
|
}
|
|
137
137
|
async getDistinctAgentNames() {
|
|
138
138
|
const result = await this.db
|
|
139
|
-
.selectFrom('
|
|
140
|
-
.select('
|
|
139
|
+
.selectFrom('aiRun')
|
|
140
|
+
.select('agentName')
|
|
141
141
|
.distinct()
|
|
142
|
-
.orderBy('
|
|
142
|
+
.orderBy('agentName')
|
|
143
143
|
.execute();
|
|
144
|
-
return result.map((row) => row.
|
|
144
|
+
return result.map((row) => row.agentName);
|
|
145
145
|
}
|
|
146
146
|
mapThreadRow(row) {
|
|
147
147
|
return {
|
|
148
148
|
id: row.id,
|
|
149
|
-
resourceId: row.
|
|
149
|
+
resourceId: row.resourceId,
|
|
150
150
|
title: row.title ?? undefined,
|
|
151
151
|
metadata: parseJson(row.metadata),
|
|
152
|
-
createdAt: new Date(row.
|
|
153
|
-
updatedAt: new Date(row.
|
|
152
|
+
createdAt: new Date(row.createdAt),
|
|
153
|
+
updatedAt: new Date(row.updatedAt),
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
156
|
mapRunRow(row) {
|
|
157
157
|
return {
|
|
158
|
-
runId: row.
|
|
159
|
-
agentName: row.
|
|
160
|
-
threadId: row.
|
|
161
|
-
resourceId: row.
|
|
158
|
+
runId: row.runId,
|
|
159
|
+
agentName: row.agentName,
|
|
160
|
+
threadId: row.threadId,
|
|
161
|
+
resourceId: row.resourceId,
|
|
162
162
|
status: row.status,
|
|
163
|
-
errorMessage: row.
|
|
164
|
-
suspendReason: row.
|
|
165
|
-
missingRpcs: parseJson(row.
|
|
166
|
-
usageInputTokens: Number(row.
|
|
167
|
-
usageOutputTokens: Number(row.
|
|
168
|
-
usageModel: row.
|
|
169
|
-
createdAt: new Date(row.
|
|
170
|
-
updatedAt: new Date(row.
|
|
163
|
+
errorMessage: row.errorMessage ?? undefined,
|
|
164
|
+
suspendReason: row.suspendReason ?? undefined,
|
|
165
|
+
missingRpcs: parseJson(row.missingRpcs),
|
|
166
|
+
usageInputTokens: Number(row.usageInputTokens),
|
|
167
|
+
usageOutputTokens: Number(row.usageOutputTokens),
|
|
168
|
+
usageModel: row.usageModel,
|
|
169
|
+
createdAt: new Date(row.createdAt),
|
|
170
|
+
updatedAt: new Date(row.updatedAt),
|
|
171
171
|
};
|
|
172
172
|
}
|
|
173
173
|
}
|