@pikku/kysely 0.13.15 → 0.13.18
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 +229 -0
- package/bin/pikku-kysely-pure.ts +0 -0
- package/dist/src/coercion-plugin.d.ts +41 -0
- package/dist/src/coercion-plugin.js +150 -0
- package/dist/src/create-audited-kysely.d.ts +1 -1
- package/dist/src/index.d.ts +6 -5
- package/dist/src/index.js +5 -4
- package/dist/src/{kysely-ai-run-scores.d.ts → kysely-agent-run-scores.d.ts} +3 -3
- package/dist/src/{kysely-ai-run-scores.js → kysely-agent-run-scores.js} +3 -3
- package/dist/src/{kysely-ai-agent-run-service.d.ts → kysely-agent-run-service.d.ts} +4 -4
- package/dist/src/{kysely-ai-agent-run-service.js → kysely-agent-run-service.js} +8 -8
- package/dist/src/{kysely-ai-run-state-service.d.ts → kysely-agent-run-state-service.d.ts} +6 -5
- package/dist/src/{kysely-ai-run-state-service.js → kysely-agent-run-state-service.js} +11 -11
- package/dist/src/{kysely-ai-storage-service.d.ts → kysely-agent-storage-service.d.ts} +10 -10
- package/dist/src/{kysely-ai-storage-service.js → kysely-agent-storage-service.js} +31 -28
- package/dist/src/kysely-audit-service.d.ts +3 -1
- package/dist/src/kysely-channel-store.d.ts +1 -1
- package/dist/src/kysely-credential-service.js +1 -1
- package/dist/src/kysely-deployment-service.d.ts +2 -1
- package/dist/src/kysely-scope-service.d.ts +2 -1
- package/dist/src/kysely-secret-service.d.ts +1 -1
- package/dist/src/kysely-secret-service.js +2 -2
- package/dist/src/kysely-session-store.d.ts +1 -1
- package/dist/src/kysely-tables.d.ts +12 -12
- package/dist/src/kysely-webhook-service.d.ts +2 -1
- package/dist/src/kysely-webhook-service.js +2 -1
- package/dist/src/kysely-workflow-mirror.d.ts +1 -1
- package/dist/src/kysely-workflow-service.d.ts +3 -2
- package/dist/src/kysely-workflow-service.js +1 -1
- package/dist/src/schema/{ai.schema.d.ts → agent.schema.d.ts} +4 -4
- package/dist/src/schema/{ai.schema.js → agent.schema.js} +29 -29
- package/dist/src/schema/index.js +4 -4
- package/dist/src/serialize-plugin.d.ts +0 -4
- package/dist/src/serialize-plugin.js +0 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/src/coercion-plugin.test.ts +160 -0
- package/src/coercion-plugin.ts +187 -0
- package/src/create-audited-kysely.test.ts +1 -1
- package/src/create-audited-kysely.ts +1 -1
- package/src/index.ts +10 -5
- package/src/{kysely-ai-run-scores.ts → kysely-agent-run-scores.ts} +5 -5
- package/src/{kysely-ai-agent-run-service.ts → kysely-agent-run-service.ts} +18 -18
- package/src/{kysely-ai-run-state-service.ts → kysely-agent-run-state-service.ts} +16 -15
- package/src/{kysely-ai-storage-service.ts → kysely-agent-storage-service.ts} +53 -43
- package/src/kysely-audit-service.test.ts +1 -1
- package/src/kysely-audit-service.ts +4 -6
- package/src/kysely-channel-store.ts +1 -1
- package/src/kysely-credential-service.ts +5 -5
- package/src/kysely-deployment-service.ts +2 -1
- package/src/kysely-scope-service.ts +5 -2
- package/src/kysely-secret-service.ts +7 -6
- package/src/kysely-services.test.ts +10 -10
- package/src/kysely-session-store.ts +1 -1
- package/src/kysely-tables.ts +12 -12
- package/src/kysely-virtual-user-run-store.ts +1 -1
- package/src/kysely-webhook-service.test.ts +1 -1
- package/src/kysely-webhook-service.ts +2 -2
- package/src/kysely-workflow-mirror.ts +1 -1
- package/src/kysely-workflow-service.test.ts +0 -1
- package/src/kysely-workflow-service.ts +11 -11
- package/src/schema/{ai.schema.ts → agent.schema.ts} +29 -29
- package/src/schema/index.ts +4 -4
- package/src/schema/schema.test.ts +6 -6
- package/src/serialize-plugin.ts +0 -5
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { sql } from 'kysely';
|
|
2
2
|
import { ensurePikkuSchema } from './schema/index.js';
|
|
3
|
-
import {
|
|
4
|
-
import { getRunScores, saveRunScore } from './kysely-
|
|
5
|
-
export class
|
|
3
|
+
import { agentSchema } from './schema/agent.schema.js';
|
|
4
|
+
import { getRunScores, saveRunScore } from './kysely-agent-run-scores.js';
|
|
5
|
+
export class KyselyAgentRunStateService {
|
|
6
6
|
db;
|
|
7
7
|
initialized = false;
|
|
8
8
|
constructor(db) {
|
|
@@ -11,13 +11,13 @@ export class KyselyAIRunStateService {
|
|
|
11
11
|
async init() {
|
|
12
12
|
if (this.initialized)
|
|
13
13
|
return;
|
|
14
|
-
await ensurePikkuSchema(this.db,
|
|
14
|
+
await ensurePikkuSchema(this.db, agentSchema);
|
|
15
15
|
this.initialized = true;
|
|
16
16
|
}
|
|
17
17
|
async createRun(run) {
|
|
18
18
|
const runId = `run-${crypto.randomUUID()}`;
|
|
19
19
|
await this.db
|
|
20
|
-
.insertInto('
|
|
20
|
+
.insertInto('agentRun')
|
|
21
21
|
.values({
|
|
22
22
|
runId,
|
|
23
23
|
agentName: run.agentName,
|
|
@@ -54,14 +54,14 @@ export class KyselyAIRunStateService {
|
|
|
54
54
|
values.usageModel = updates.usage.model;
|
|
55
55
|
}
|
|
56
56
|
await this.db
|
|
57
|
-
.updateTable('
|
|
57
|
+
.updateTable('agentRun')
|
|
58
58
|
.set(values)
|
|
59
59
|
.where('runId', '=', runId)
|
|
60
60
|
.execute();
|
|
61
61
|
}
|
|
62
62
|
async getRun(runId) {
|
|
63
63
|
const row = await this.db
|
|
64
|
-
.selectFrom('
|
|
64
|
+
.selectFrom('agentRun')
|
|
65
65
|
.selectAll()
|
|
66
66
|
.where('runId', '=', runId)
|
|
67
67
|
.executeTakeFirst();
|
|
@@ -69,7 +69,7 @@ export class KyselyAIRunStateService {
|
|
|
69
69
|
}
|
|
70
70
|
async getRunsByThread(threadId) {
|
|
71
71
|
const rows = await this.db
|
|
72
|
-
.selectFrom('
|
|
72
|
+
.selectFrom('agentRun')
|
|
73
73
|
.selectAll()
|
|
74
74
|
.where('threadId', '=', threadId)
|
|
75
75
|
.orderBy('createdAt', 'desc')
|
|
@@ -78,7 +78,7 @@ export class KyselyAIRunStateService {
|
|
|
78
78
|
}
|
|
79
79
|
async resolveApproval(toolCallId, status) {
|
|
80
80
|
const rows = await this.db
|
|
81
|
-
.selectFrom('
|
|
81
|
+
.selectFrom('agentRun')
|
|
82
82
|
.select(['runId', 'pendingApprovals'])
|
|
83
83
|
.where('status', '=', 'suspended')
|
|
84
84
|
.execute();
|
|
@@ -104,7 +104,7 @@ export class KyselyAIRunStateService {
|
|
|
104
104
|
// Compare-and-swap on the list we read: a concurrent approver that got
|
|
105
105
|
// there first has already rewritten it, and this update matches no row.
|
|
106
106
|
const result = await this.db
|
|
107
|
-
.updateTable('
|
|
107
|
+
.updateTable('agentRun')
|
|
108
108
|
.set(updates)
|
|
109
109
|
.where('runId', '=', row.runId)
|
|
110
110
|
.where('status', '=', 'suspended')
|
|
@@ -117,7 +117,7 @@ export class KyselyAIRunStateService {
|
|
|
117
117
|
}
|
|
118
118
|
async findRunByToolCallId(toolCallId) {
|
|
119
119
|
const rows = await this.db
|
|
120
|
-
.selectFrom('
|
|
120
|
+
.selectFrom('agentRun')
|
|
121
121
|
.selectAll()
|
|
122
122
|
.where('status', '=', 'suspended')
|
|
123
123
|
.execute();
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
1
|
+
import type { AgentMessage, AgentRunState, AgentThread } from '@pikku/core/agent';
|
|
2
|
+
import type { AgentRunScore } from '@pikku/core/agent-scorer';
|
|
3
|
+
import type { AgentRunStateService, AgentStorageService, CreateRunInput, SaveScoreInput } from '@pikku/core/services';
|
|
4
4
|
import type { Kysely } from 'kysely';
|
|
5
5
|
import type { KyselyPikkuDB } from './kysely-tables.js';
|
|
6
|
-
export declare class
|
|
6
|
+
export declare class KyselyAgentStorageService implements AgentStorageService, AgentRunStateService {
|
|
7
7
|
private db;
|
|
8
8
|
private initialized;
|
|
9
9
|
constructor(db: Kysely<KyselyPikkuDB>);
|
|
@@ -12,15 +12,15 @@ export declare class KyselyAIStorageService implements AIStorageService, AIRunSt
|
|
|
12
12
|
threadId?: string;
|
|
13
13
|
title?: string;
|
|
14
14
|
metadata?: Record<string, unknown>;
|
|
15
|
-
}): Promise<
|
|
16
|
-
getThread(threadId: string): Promise<
|
|
17
|
-
getThreads(resourceId: string): Promise<
|
|
15
|
+
}): Promise<AgentThread>;
|
|
16
|
+
getThread(threadId: string): Promise<AgentThread>;
|
|
17
|
+
getThreads(resourceId: string): Promise<AgentThread[]>;
|
|
18
18
|
deleteThread(threadId: string): Promise<void>;
|
|
19
19
|
getMessages(threadId: string, options?: {
|
|
20
20
|
lastN?: number;
|
|
21
21
|
cursor?: string;
|
|
22
|
-
}): Promise<
|
|
23
|
-
saveMessages(threadId: string, messages:
|
|
22
|
+
}): Promise<AgentMessage[]>;
|
|
23
|
+
saveMessages(threadId: string, messages: AgentMessage[]): Promise<void>;
|
|
24
24
|
getWorkingMemory(id: string, scope: 'resource' | 'thread'): Promise<Record<string, unknown> | null>;
|
|
25
25
|
saveWorkingMemory(id: string, scope: 'resource' | 'thread', data: Record<string, unknown>): Promise<void>;
|
|
26
26
|
createRun(run: CreateRunInput): Promise<string>;
|
|
@@ -35,6 +35,6 @@ export declare class KyselyAIStorageService implements AIStorageService, AIRunSt
|
|
|
35
35
|
} | null>;
|
|
36
36
|
resolveApproval(toolCallId: string, status: 'approved' | 'denied'): Promise<boolean>;
|
|
37
37
|
saveScore(score: SaveScoreInput): Promise<void>;
|
|
38
|
-
getScores(runId: string): Promise<
|
|
38
|
+
getScores(runId: string): Promise<AgentRunScore[]>;
|
|
39
39
|
close(): Promise<void>;
|
|
40
40
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { parseJson } from './kysely-json.js';
|
|
2
|
-
import { getRunScores, saveRunScore } from './kysely-
|
|
2
|
+
import { getRunScores, saveRunScore } from './kysely-agent-run-scores.js';
|
|
3
3
|
import { ensurePikkuSchema } from './schema/index.js';
|
|
4
|
-
import {
|
|
5
|
-
export class
|
|
4
|
+
import { agentSchema } from './schema/agent.schema.js';
|
|
5
|
+
export class KyselyAgentStorageService {
|
|
6
6
|
db;
|
|
7
7
|
initialized = false;
|
|
8
8
|
constructor(db) {
|
|
@@ -11,14 +11,14 @@ export class KyselyAIStorageService {
|
|
|
11
11
|
async init() {
|
|
12
12
|
if (this.initialized)
|
|
13
13
|
return;
|
|
14
|
-
await ensurePikkuSchema(this.db,
|
|
14
|
+
await ensurePikkuSchema(this.db, agentSchema);
|
|
15
15
|
this.initialized = true;
|
|
16
16
|
}
|
|
17
17
|
async createThread(resourceId, options) {
|
|
18
18
|
const id = options?.threadId ?? crypto.randomUUID();
|
|
19
19
|
const now = new Date();
|
|
20
20
|
await this.db
|
|
21
|
-
.insertInto('
|
|
21
|
+
.insertInto('agentThreads')
|
|
22
22
|
.values({
|
|
23
23
|
id,
|
|
24
24
|
resourceId: resourceId,
|
|
@@ -39,7 +39,7 @@ export class KyselyAIStorageService {
|
|
|
39
39
|
}
|
|
40
40
|
async getThread(threadId) {
|
|
41
41
|
const row = await this.db
|
|
42
|
-
.selectFrom('
|
|
42
|
+
.selectFrom('agentThreads')
|
|
43
43
|
.select([
|
|
44
44
|
'id',
|
|
45
45
|
'resourceId',
|
|
@@ -64,7 +64,7 @@ export class KyselyAIStorageService {
|
|
|
64
64
|
}
|
|
65
65
|
async getThreads(resourceId) {
|
|
66
66
|
const result = await this.db
|
|
67
|
-
.selectFrom('
|
|
67
|
+
.selectFrom('agentThreads')
|
|
68
68
|
.select([
|
|
69
69
|
'id',
|
|
70
70
|
'resourceId',
|
|
@@ -86,16 +86,19 @@ export class KyselyAIStorageService {
|
|
|
86
86
|
}));
|
|
87
87
|
}
|
|
88
88
|
async deleteThread(threadId) {
|
|
89
|
-
await this.db
|
|
89
|
+
await this.db
|
|
90
|
+
.deleteFrom('agentThreads')
|
|
91
|
+
.where('id', '=', threadId)
|
|
92
|
+
.execute();
|
|
90
93
|
}
|
|
91
94
|
async getMessages(threadId, options) {
|
|
92
95
|
let msgQuery = this.db
|
|
93
|
-
.selectFrom('
|
|
96
|
+
.selectFrom('agentMessage')
|
|
94
97
|
.select(['id', 'role', 'content', 'createdAt'])
|
|
95
98
|
.where('threadId', '=', threadId);
|
|
96
99
|
if (options?.cursor) {
|
|
97
100
|
const cursorRow = await this.db
|
|
98
|
-
.selectFrom('
|
|
101
|
+
.selectFrom('agentMessage')
|
|
99
102
|
.select('createdAt')
|
|
100
103
|
.where('id', '=', options.cursor)
|
|
101
104
|
.executeTakeFirst();
|
|
@@ -116,7 +119,7 @@ export class KyselyAIStorageService {
|
|
|
116
119
|
msgResult = await msgQuery.orderBy('createdAt', 'asc').execute();
|
|
117
120
|
}
|
|
118
121
|
const tcResult = await this.db
|
|
119
|
-
.selectFrom('
|
|
122
|
+
.selectFrom('agentToolCall')
|
|
120
123
|
.select(['id', 'messageId', 'toolName', 'args', 'result'])
|
|
121
124
|
.where('threadId', '=', threadId)
|
|
122
125
|
.orderBy('createdAt', 'asc')
|
|
@@ -186,7 +189,7 @@ export class KyselyAIStorageService {
|
|
|
186
189
|
const nonToolMessages = messages.filter((m) => m.role !== 'tool');
|
|
187
190
|
if (nonToolMessages.length > 0) {
|
|
188
191
|
await this.db
|
|
189
|
-
.insertInto('
|
|
192
|
+
.insertInto('agentMessage')
|
|
190
193
|
.values(nonToolMessages.map((msg) => ({
|
|
191
194
|
id: msg.id,
|
|
192
195
|
threadId: threadId,
|
|
@@ -199,7 +202,7 @@ export class KyselyAIStorageService {
|
|
|
199
202
|
const toolCalls = nonToolMessages.flatMap((msg) => msg.toolCalls?.map((tc) => ({ ...tc, messageId: msg.id })) ?? []);
|
|
200
203
|
if (toolCalls.length > 0) {
|
|
201
204
|
await this.db
|
|
202
|
-
.insertInto('
|
|
205
|
+
.insertInto('agentToolCall')
|
|
203
206
|
.values(toolCalls.map((tc) => ({
|
|
204
207
|
id: tc.id,
|
|
205
208
|
threadId: threadId,
|
|
@@ -214,21 +217,21 @@ export class KyselyAIStorageService {
|
|
|
214
217
|
continue;
|
|
215
218
|
for (const tr of toolMsg.toolResults) {
|
|
216
219
|
await this.db
|
|
217
|
-
.updateTable('
|
|
220
|
+
.updateTable('agentToolCall')
|
|
218
221
|
.set({ result: tr.result })
|
|
219
222
|
.where('id', '=', tr.id)
|
|
220
223
|
.execute();
|
|
221
224
|
}
|
|
222
225
|
}
|
|
223
226
|
await this.db
|
|
224
|
-
.updateTable('
|
|
227
|
+
.updateTable('agentThreads')
|
|
225
228
|
.set({ updatedAt: new Date() })
|
|
226
229
|
.where('id', '=', threadId)
|
|
227
230
|
.execute();
|
|
228
231
|
}
|
|
229
232
|
async getWorkingMemory(id, scope) {
|
|
230
233
|
const row = await this.db
|
|
231
|
-
.selectFrom('
|
|
234
|
+
.selectFrom('agentWorkingMemory')
|
|
232
235
|
.select('data')
|
|
233
236
|
.where('id', '=', id)
|
|
234
237
|
.where('scope', '=', scope)
|
|
@@ -239,7 +242,7 @@ export class KyselyAIStorageService {
|
|
|
239
242
|
}
|
|
240
243
|
async saveWorkingMemory(id, scope, data) {
|
|
241
244
|
await this.db
|
|
242
|
-
.insertInto('
|
|
245
|
+
.insertInto('agentWorkingMemory')
|
|
243
246
|
.values({
|
|
244
247
|
id,
|
|
245
248
|
scope,
|
|
@@ -255,7 +258,7 @@ export class KyselyAIStorageService {
|
|
|
255
258
|
async createRun(run) {
|
|
256
259
|
const runId = crypto.randomUUID();
|
|
257
260
|
await this.db
|
|
258
|
-
.insertInto('
|
|
261
|
+
.insertInto('agentRun')
|
|
259
262
|
.values({
|
|
260
263
|
runId: runId,
|
|
261
264
|
agentName: run.agentName,
|
|
@@ -297,13 +300,13 @@ export class KyselyAIStorageService {
|
|
|
297
300
|
setValues.usageModel = updates.usage.model;
|
|
298
301
|
}
|
|
299
302
|
await this.db
|
|
300
|
-
.updateTable('
|
|
303
|
+
.updateTable('agentRun')
|
|
301
304
|
.set(setValues)
|
|
302
305
|
.where('runId', '=', runId)
|
|
303
306
|
.execute();
|
|
304
307
|
if (updates.pendingApprovals !== undefined) {
|
|
305
308
|
await this.db
|
|
306
|
-
.updateTable('
|
|
309
|
+
.updateTable('agentToolCall')
|
|
307
310
|
.set({
|
|
308
311
|
approvalStatus: null,
|
|
309
312
|
runId: null,
|
|
@@ -322,7 +325,7 @@ export class KyselyAIStorageService {
|
|
|
322
325
|
}
|
|
323
326
|
async getRun(runId) {
|
|
324
327
|
const row = await this.db
|
|
325
|
-
.selectFrom('
|
|
328
|
+
.selectFrom('agentRun')
|
|
326
329
|
.select([
|
|
327
330
|
'runId',
|
|
328
331
|
'agentName',
|
|
@@ -343,7 +346,7 @@ export class KyselyAIStorageService {
|
|
|
343
346
|
if (!row)
|
|
344
347
|
return null;
|
|
345
348
|
const approvals = await this.db
|
|
346
|
-
.selectFrom('
|
|
349
|
+
.selectFrom('agentToolCall')
|
|
347
350
|
.select([
|
|
348
351
|
'id',
|
|
349
352
|
'toolName',
|
|
@@ -360,7 +363,7 @@ export class KyselyAIStorageService {
|
|
|
360
363
|
}
|
|
361
364
|
async getRunsByThread(threadId) {
|
|
362
365
|
const result = await this.db
|
|
363
|
-
.selectFrom('
|
|
366
|
+
.selectFrom('agentRun')
|
|
364
367
|
.select([
|
|
365
368
|
'runId',
|
|
366
369
|
'agentName',
|
|
@@ -382,7 +385,7 @@ export class KyselyAIStorageService {
|
|
|
382
385
|
const runs = [];
|
|
383
386
|
for (const row of result) {
|
|
384
387
|
const approvals = await this.db
|
|
385
|
-
.selectFrom('
|
|
388
|
+
.selectFrom('agentToolCall')
|
|
386
389
|
.select([
|
|
387
390
|
'id',
|
|
388
391
|
'toolName',
|
|
@@ -403,7 +406,7 @@ export class KyselyAIStorageService {
|
|
|
403
406
|
for (const a of approvals) {
|
|
404
407
|
if (a.type === 'agent-call') {
|
|
405
408
|
await this.db
|
|
406
|
-
.updateTable('
|
|
409
|
+
.updateTable('agentToolCall')
|
|
407
410
|
.set({
|
|
408
411
|
approvalStatus: 'pending',
|
|
409
412
|
runId: runId,
|
|
@@ -417,7 +420,7 @@ export class KyselyAIStorageService {
|
|
|
417
420
|
}
|
|
418
421
|
else {
|
|
419
422
|
await this.db
|
|
420
|
-
.updateTable('
|
|
423
|
+
.updateTable('agentToolCall')
|
|
421
424
|
.set({
|
|
422
425
|
approvalStatus: 'pending',
|
|
423
426
|
runId: runId,
|
|
@@ -470,7 +473,7 @@ export class KyselyAIStorageService {
|
|
|
470
473
|
}
|
|
471
474
|
async findRunByToolCallId(toolCallId) {
|
|
472
475
|
const tc = await this.db
|
|
473
|
-
.selectFrom('
|
|
476
|
+
.selectFrom('agentToolCall')
|
|
474
477
|
.select([
|
|
475
478
|
'id',
|
|
476
479
|
'toolName',
|
|
@@ -513,7 +516,7 @@ export class KyselyAIStorageService {
|
|
|
513
516
|
async resolveApproval(toolCallId, status) {
|
|
514
517
|
// Only the caller that moves the tool call off 'pending' has claimed it.
|
|
515
518
|
const result = await this.db
|
|
516
|
-
.updateTable('
|
|
519
|
+
.updateTable('agentToolCall')
|
|
517
520
|
.set({ approvalStatus: status })
|
|
518
521
|
.where('id', '=', toolCallId)
|
|
519
522
|
.where('approvalStatus', '=', 'pending')
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AuditService } from '@pikku/core/services';
|
|
2
|
+
import type { AuditEvent, AuditEventBatch } from '@pikku/core/services';
|
|
3
|
+
import type { AuditFacets, AuditQuery, AuditQueryResult } from '@pikku/core/services';
|
|
2
4
|
import type { Kysely } from 'kysely';
|
|
3
5
|
/**
|
|
4
6
|
* Durable {@link AuditService} that persists AuditEvents to an `audit` table
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Channel } from '@pikku/core/channel';
|
|
2
1
|
import { ChannelStore } from '@pikku/core/channel';
|
|
2
|
+
import type { Channel } from '@pikku/core/channel';
|
|
3
3
|
import type { Kysely } from 'kysely';
|
|
4
4
|
import type { KyselyPikkuDB } from './kysely-tables.js';
|
|
5
5
|
export declare class KyselyChannelStore extends ChannelStore {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { deriveKEK,
|
|
1
|
+
import { deriveKEK, envelopeDecrypt, envelopeEncrypt, envelopeRewrap, generateKEKSalt, } from '@pikku/core/crypto-utils';
|
|
2
2
|
import { ensurePikkuSchema } from './schema/index.js';
|
|
3
3
|
import { credentialSchema } from './schema/credential.schema.js';
|
|
4
4
|
export class KyselyCredentialService {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { DeploymentService, DeploymentServiceConfig, DeploymentConfig } from '@pikku/core/services';
|
|
2
|
-
import type { JWTService
|
|
2
|
+
import type { JWTService } from '@pikku/core/services';
|
|
3
|
+
import type { SecretService } from '@pikku/core/services';
|
|
3
4
|
import type { Kysely } from 'kysely';
|
|
4
5
|
import type { KyselyPikkuDB } from './kysely-tables.js';
|
|
5
6
|
export declare class KyselyDeploymentService implements DeploymentService {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ScopeService } from '@pikku/core/services';
|
|
2
|
+
import type { Role } from '@pikku/core/services';
|
|
2
3
|
import type { FlatScope } from '@pikku/core/scope';
|
|
3
4
|
import type { SystemRole } from '@pikku/core/role';
|
|
4
5
|
import type { Kysely } from 'kysely';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type SecretValue } from '@pikku/core';
|
|
2
1
|
import type { SecretService, SecretValues } from '@pikku/core/services';
|
|
2
|
+
import type { SecretValue } from '@pikku/core/classification';
|
|
3
3
|
import type { Kysely } from 'kysely';
|
|
4
4
|
import type { KyselyPikkuDB } from './kysely-tables.js';
|
|
5
5
|
export interface KyselySecretServiceConfig {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { deriveKEK, envelopeDecrypt, envelopeEncrypt, envelopeRewrap, generateKEKSalt, } from '@pikku/core/crypto-utils';
|
|
2
|
+
import { createSecretValue, isSecretValue } from '@pikku/core/classification';
|
|
3
3
|
import { ensurePikkuSchema } from './schema/index.js';
|
|
4
4
|
import { secretSchema } from './schema/secret.schema.js';
|
|
5
5
|
export class KyselySecretService {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CoreUserSession } from '@pikku/core';
|
|
2
1
|
import type { SessionStore } from '@pikku/core/services';
|
|
2
|
+
import type { CoreUserSession } from '@pikku/core/types';
|
|
3
3
|
import type { Kysely } from 'kysely';
|
|
4
4
|
import type { KyselyPikkuDB } from './kysely-tables.js';
|
|
5
5
|
export declare class KyselySessionStore implements SessionStore {
|
|
@@ -75,7 +75,7 @@ export interface WorkflowVersionsTable {
|
|
|
75
75
|
status: Generated<WorkflowVersionStatus>;
|
|
76
76
|
createdAt: Generated<Date>;
|
|
77
77
|
}
|
|
78
|
-
export interface
|
|
78
|
+
export interface AgentThreadsTable {
|
|
79
79
|
id: string;
|
|
80
80
|
resourceId: string;
|
|
81
81
|
title: string | null;
|
|
@@ -83,14 +83,14 @@ export interface AIThreadsTable {
|
|
|
83
83
|
createdAt: Generated<Date>;
|
|
84
84
|
updatedAt: Generated<Date>;
|
|
85
85
|
}
|
|
86
|
-
export interface
|
|
86
|
+
export interface AgentMessageTable {
|
|
87
87
|
id: string;
|
|
88
88
|
threadId: string;
|
|
89
89
|
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
90
90
|
content: string | null;
|
|
91
91
|
createdAt: Generated<Date>;
|
|
92
92
|
}
|
|
93
|
-
export interface
|
|
93
|
+
export interface AgentToolCallTable {
|
|
94
94
|
id: string;
|
|
95
95
|
threadId: string;
|
|
96
96
|
messageId: string;
|
|
@@ -105,13 +105,13 @@ export interface AIToolCallTable {
|
|
|
105
105
|
displayArgs: string | null;
|
|
106
106
|
createdAt: Generated<Date>;
|
|
107
107
|
}
|
|
108
|
-
export interface
|
|
108
|
+
export interface AgentWorkingMemoryTable {
|
|
109
109
|
id: string;
|
|
110
110
|
scope: string;
|
|
111
111
|
data: string;
|
|
112
112
|
updatedAt: Generated<Date>;
|
|
113
113
|
}
|
|
114
|
-
export interface
|
|
114
|
+
export interface AgentRunTable {
|
|
115
115
|
runId: Generated<string>;
|
|
116
116
|
agentName: string;
|
|
117
117
|
threadId: string;
|
|
@@ -133,7 +133,7 @@ export interface AIRunTable {
|
|
|
133
133
|
createdAt: Generated<Date>;
|
|
134
134
|
updatedAt: Generated<Date>;
|
|
135
135
|
}
|
|
136
|
-
export interface
|
|
136
|
+
export interface AgentRunScoreTable {
|
|
137
137
|
id: string;
|
|
138
138
|
runId: string;
|
|
139
139
|
scorerName: string;
|
|
@@ -301,12 +301,12 @@ export interface KyselyPikkuDB {
|
|
|
301
301
|
workflowStep: WorkflowStepTable;
|
|
302
302
|
workflowStepHistory: WorkflowStepHistoryTable;
|
|
303
303
|
workflowVersions: WorkflowVersionsTable;
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
304
|
+
agentThreads: AgentThreadsTable;
|
|
305
|
+
agentMessage: AgentMessageTable;
|
|
306
|
+
agentToolCall: AgentToolCallTable;
|
|
307
|
+
agentWorkingMemory: AgentWorkingMemoryTable;
|
|
308
|
+
agentRun: AgentRunTable;
|
|
309
|
+
agentRunScore: AgentRunScoreTable;
|
|
310
310
|
pikkuDeployments: PikkuDeploymentsTable;
|
|
311
311
|
pikkuDeploymentFunctions: PikkuDeploymentFunctionsTable;
|
|
312
312
|
secrets: SecretsTable;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { QueueWebhookService
|
|
1
|
+
import { QueueWebhookService } from '@pikku/core/services';
|
|
2
2
|
import type { QueueService } from '@pikku/core/queue';
|
|
3
|
+
import { type SendWebhookInput, type SendWebhookResult, type WebhookAttemptResult, type WebhookDeliveryRecord, type WebhookDeliveryWithAttempts } from '@pikku/core/services';
|
|
3
4
|
import type { Kysely } from 'kysely';
|
|
4
5
|
import type { KyselyPikkuDB } from './kysely-tables.js';
|
|
5
6
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { QueueWebhookService } from '@pikku/core/services';
|
|
2
|
+
import { PIKKU_OUTGOING_WEBHOOK_QUEUE_NAME, } from '@pikku/core/services';
|
|
2
3
|
import { ensurePikkuSchema } from './schema/index.js';
|
|
3
4
|
import { webhookSchema } from './schema/webhook.schema.js';
|
|
4
5
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SerializedError } from '@pikku/core';
|
|
1
|
+
import type { SerializedError } from '@pikku/core/errors';
|
|
2
2
|
import type { StepState, WorkflowRunMirror, WorkflowRunWire, WorkflowStatus, WorkflowPlannedStep, WorkflowVersionStatus } from '@pikku/core/workflow';
|
|
3
3
|
import type { Kysely } from 'kysely';
|
|
4
4
|
import type { KyselyPikkuDB } from './kysely-tables.js';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { SerializedError } from '@pikku/core';
|
|
2
|
-
import { PikkuWorkflowService
|
|
1
|
+
import type { SerializedError } from '@pikku/core/errors';
|
|
2
|
+
import { PikkuWorkflowService } from '@pikku/core/workflow';
|
|
3
|
+
import type { WorkflowPlannedStep, WorkflowQueueOptions, WorkflowRun, WorkflowRunWire, StepState, StepStatus, WorkflowStatus, WorkflowVersionStatus } from '@pikku/core/workflow';
|
|
3
4
|
import { type Kysely } from 'kysely';
|
|
4
5
|
import type { KyselyPikkuDB } from './kysely-tables.js';
|
|
5
6
|
export declare class KyselyWorkflowService extends PikkuWorkflowService {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PikkuWorkflowService
|
|
1
|
+
import { PikkuWorkflowService } from '@pikku/core/workflow';
|
|
2
2
|
import { sql } from 'kysely';
|
|
3
3
|
import { KyselyWorkflowRunService } from './kysely-workflow-run-service.js';
|
|
4
4
|
import { parseJson } from './kysely-json.js';
|
|
@@ -2,11 +2,11 @@ import type { PikkuSchema } from './pikku-schema.types.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Threads, messages, tool calls, working memory and agent runs.
|
|
4
4
|
*
|
|
5
|
-
* `
|
|
6
|
-
* create this table disagreed about it: `
|
|
7
|
-
* column while `
|
|
5
|
+
* `agentRun` carries `pendingApprovals` even though the two services that used to
|
|
6
|
+
* create this table disagreed about it: `KyselyAgentStorageService` omitted the
|
|
7
|
+
* column while `KyselyAgentRunStateService` declared it and read it back through
|
|
8
8
|
* casts. Whichever service happened to run first decided the shape, and on a
|
|
9
9
|
* database where the storage service won, resolving an approval failed. One
|
|
10
10
|
* declaration ends that — the column is here because live code reads it.
|
|
11
11
|
*/
|
|
12
|
-
export declare const
|
|
12
|
+
export declare const agentSchema: PikkuSchema;
|