@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.
Files changed (65) hide show
  1. package/CHANGELOG.md +229 -0
  2. package/bin/pikku-kysely-pure.ts +0 -0
  3. package/dist/src/coercion-plugin.d.ts +41 -0
  4. package/dist/src/coercion-plugin.js +150 -0
  5. package/dist/src/create-audited-kysely.d.ts +1 -1
  6. package/dist/src/index.d.ts +6 -5
  7. package/dist/src/index.js +5 -4
  8. package/dist/src/{kysely-ai-run-scores.d.ts → kysely-agent-run-scores.d.ts} +3 -3
  9. package/dist/src/{kysely-ai-run-scores.js → kysely-agent-run-scores.js} +3 -3
  10. package/dist/src/{kysely-ai-agent-run-service.d.ts → kysely-agent-run-service.d.ts} +4 -4
  11. package/dist/src/{kysely-ai-agent-run-service.js → kysely-agent-run-service.js} +8 -8
  12. package/dist/src/{kysely-ai-run-state-service.d.ts → kysely-agent-run-state-service.d.ts} +6 -5
  13. package/dist/src/{kysely-ai-run-state-service.js → kysely-agent-run-state-service.js} +11 -11
  14. package/dist/src/{kysely-ai-storage-service.d.ts → kysely-agent-storage-service.d.ts} +10 -10
  15. package/dist/src/{kysely-ai-storage-service.js → kysely-agent-storage-service.js} +31 -28
  16. package/dist/src/kysely-audit-service.d.ts +3 -1
  17. package/dist/src/kysely-channel-store.d.ts +1 -1
  18. package/dist/src/kysely-credential-service.js +1 -1
  19. package/dist/src/kysely-deployment-service.d.ts +2 -1
  20. package/dist/src/kysely-scope-service.d.ts +2 -1
  21. package/dist/src/kysely-secret-service.d.ts +1 -1
  22. package/dist/src/kysely-secret-service.js +2 -2
  23. package/dist/src/kysely-session-store.d.ts +1 -1
  24. package/dist/src/kysely-tables.d.ts +12 -12
  25. package/dist/src/kysely-webhook-service.d.ts +2 -1
  26. package/dist/src/kysely-webhook-service.js +2 -1
  27. package/dist/src/kysely-workflow-mirror.d.ts +1 -1
  28. package/dist/src/kysely-workflow-service.d.ts +3 -2
  29. package/dist/src/kysely-workflow-service.js +1 -1
  30. package/dist/src/schema/{ai.schema.d.ts → agent.schema.d.ts} +4 -4
  31. package/dist/src/schema/{ai.schema.js → agent.schema.js} +29 -29
  32. package/dist/src/schema/index.js +4 -4
  33. package/dist/src/serialize-plugin.d.ts +0 -4
  34. package/dist/src/serialize-plugin.js +0 -4
  35. package/dist/tsconfig.tsbuildinfo +1 -1
  36. package/package.json +7 -7
  37. package/src/coercion-plugin.test.ts +160 -0
  38. package/src/coercion-plugin.ts +187 -0
  39. package/src/create-audited-kysely.test.ts +1 -1
  40. package/src/create-audited-kysely.ts +1 -1
  41. package/src/index.ts +10 -5
  42. package/src/{kysely-ai-run-scores.ts → kysely-agent-run-scores.ts} +5 -5
  43. package/src/{kysely-ai-agent-run-service.ts → kysely-agent-run-service.ts} +18 -18
  44. package/src/{kysely-ai-run-state-service.ts → kysely-agent-run-state-service.ts} +16 -15
  45. package/src/{kysely-ai-storage-service.ts → kysely-agent-storage-service.ts} +53 -43
  46. package/src/kysely-audit-service.test.ts +1 -1
  47. package/src/kysely-audit-service.ts +4 -6
  48. package/src/kysely-channel-store.ts +1 -1
  49. package/src/kysely-credential-service.ts +5 -5
  50. package/src/kysely-deployment-service.ts +2 -1
  51. package/src/kysely-scope-service.ts +5 -2
  52. package/src/kysely-secret-service.ts +7 -6
  53. package/src/kysely-services.test.ts +10 -10
  54. package/src/kysely-session-store.ts +1 -1
  55. package/src/kysely-tables.ts +12 -12
  56. package/src/kysely-virtual-user-run-store.ts +1 -1
  57. package/src/kysely-webhook-service.test.ts +1 -1
  58. package/src/kysely-webhook-service.ts +2 -2
  59. package/src/kysely-workflow-mirror.ts +1 -1
  60. package/src/kysely-workflow-service.test.ts +0 -1
  61. package/src/kysely-workflow-service.ts +11 -11
  62. package/src/schema/{ai.schema.ts → agent.schema.ts} +29 -29
  63. package/src/schema/index.ts +4 -4
  64. package/src/schema/schema.test.ts +6 -6
  65. 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 { aiSchema } from './schema/ai.schema.js';
4
- import { getRunScores, saveRunScore } from './kysely-ai-run-scores.js';
5
- export class KyselyAIRunStateService {
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, aiSchema);
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('aiRun')
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('aiRun')
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('aiRun')
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('aiRun')
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('aiRun')
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('aiRun')
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('aiRun')
120
+ .selectFrom('agentRun')
121
121
  .selectAll()
122
122
  .where('status', '=', 'suspended')
123
123
  .execute();
@@ -1,9 +1,9 @@
1
- import type { AIStorageService, AIRunStateService, CreateRunInput, SaveScoreInput } from '@pikku/core/services';
2
- import type { AIThread, AIMessage, AgentRunState } from '@pikku/core/ai-agent';
3
- import type { AIRunScore } from '@pikku/core/ai-scorer';
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 KyselyAIStorageService implements AIStorageService, AIRunStateService {
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<AIThread>;
16
- getThread(threadId: string): Promise<AIThread>;
17
- getThreads(resourceId: string): Promise<AIThread[]>;
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<AIMessage[]>;
23
- saveMessages(threadId: string, messages: AIMessage[]): Promise<void>;
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<AIRunScore[]>;
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-ai-run-scores.js';
2
+ import { getRunScores, saveRunScore } from './kysely-agent-run-scores.js';
3
3
  import { ensurePikkuSchema } from './schema/index.js';
4
- import { aiSchema } from './schema/ai.schema.js';
5
- export class KyselyAIStorageService {
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, aiSchema);
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('aiThreads')
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('aiThreads')
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('aiThreads')
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.deleteFrom('aiThreads').where('id', '=', threadId).execute();
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('aiMessage')
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('aiMessage')
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('aiToolCall')
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('aiMessage')
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('aiToolCall')
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('aiToolCall')
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('aiThreads')
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('aiWorkingMemory')
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('aiWorkingMemory')
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('aiRun')
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('aiRun')
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('aiToolCall')
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('aiRun')
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('aiToolCall')
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('aiRun')
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('aiToolCall')
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('aiToolCall')
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('aiToolCall')
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('aiToolCall')
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('aiToolCall')
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 { AuditEvent, AuditEventBatch, AuditFacets, AuditQuery, AuditQueryResult, AuditService } from '@pikku/core';
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, generateKEKSalt, envelopeEncrypt, envelopeDecrypt, envelopeRewrap, } from '@pikku/core/crypto-utils';
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, SecretService } from '@pikku/core/services';
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 { Role, ScopeService } from '@pikku/core/services';
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 { createSecretValue, isSecretValue } from '@pikku/core';
2
- import { deriveKEK, generateKEKSalt, envelopeEncrypt, envelopeDecrypt, envelopeRewrap, } from '@pikku/core/crypto-utils';
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 AIThreadsTable {
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 AIMessageTable {
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 AIToolCallTable {
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 AIWorkingMemoryTable {
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 AIRunTable {
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 AIRunScoreTable {
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
- aiThreads: AIThreadsTable;
305
- aiMessage: AIMessageTable;
306
- aiToolCall: AIToolCallTable;
307
- aiWorkingMemory: AIWorkingMemoryTable;
308
- aiRun: AIRunTable;
309
- aiRunScore: AIRunScoreTable;
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, type SendWebhookInput, type SendWebhookResult, type WebhookAttemptResult, type WebhookDeliveryRecord, type WebhookDeliveryWithAttempts } from '@pikku/core/services';
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 { PIKKU_OUTGOING_WEBHOOK_QUEUE_NAME, QueueWebhookService, } from '@pikku/core/services';
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, type WorkflowPlannedStep, type WorkflowQueueOptions, type WorkflowRun, type WorkflowRunWire, type StepState, type StepStatus, type WorkflowStatus, type WorkflowVersionStatus } from '@pikku/core/workflow';
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, } from '@pikku/core/workflow';
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
- * `aiRun` carries `pendingApprovals` even though the two services that used to
6
- * create this table disagreed about it: `KyselyAIStorageService` omitted the
7
- * column while `KyselyAIRunStateService` declared it and read it back through
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 aiSchema: PikkuSchema;
12
+ export declare const agentSchema: PikkuSchema;