@pikku/kysely 0.12.5 → 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.
@@ -19,14 +19,14 @@ export class KyselyAgentRunService implements AgentRunService {
19
19
  const { agentName, limit = 50, offset = 0 } = options ?? {}
20
20
 
21
21
  let query = this.db
22
- .selectFrom('ai_threads as t')
22
+ .selectFrom('aiThreads as t')
23
23
  .select([
24
24
  't.id',
25
- 't.resource_id',
25
+ 't.resourceId',
26
26
  't.title',
27
27
  't.metadata',
28
- 't.created_at',
29
- 't.updated_at',
28
+ 't.createdAt',
29
+ 't.updatedAt',
30
30
  ])
31
31
 
32
32
  if (agentName) {
@@ -34,15 +34,15 @@ export class KyselyAgentRunService implements AgentRunService {
34
34
  't.id',
35
35
  'in',
36
36
  this.db
37
- .selectFrom('ai_run')
38
- .select('thread_id')
39
- .where('agent_name', '=', agentName)
37
+ .selectFrom('aiRun')
38
+ .select('threadId')
39
+ .where('agentName', '=', agentName)
40
40
  .distinct()
41
41
  )
42
42
  }
43
43
 
44
44
  const result = await query
45
- .orderBy('t.updated_at', 'desc')
45
+ .orderBy('t.updatedAt', 'desc')
46
46
  .limit(limit)
47
47
  .offset(offset)
48
48
  .execute()
@@ -52,14 +52,14 @@ export class KyselyAgentRunService implements AgentRunService {
52
52
 
53
53
  async getThread(threadId: string): Promise<AIThread | null> {
54
54
  const row = await this.db
55
- .selectFrom('ai_threads')
55
+ .selectFrom('aiThreads')
56
56
  .select([
57
57
  'id',
58
- 'resource_id',
58
+ 'resourceId',
59
59
  'title',
60
60
  'metadata',
61
- 'created_at',
62
- 'updated_at',
61
+ 'createdAt',
62
+ 'updatedAt',
63
63
  ])
64
64
  .where('id', '=', threadId)
65
65
  .executeTakeFirst()
@@ -71,22 +71,22 @@ export class KyselyAgentRunService implements AgentRunService {
71
71
  async getThreadMessages(threadId: string): Promise<AIMessage[]> {
72
72
  const [msgResult, tcResult] = await Promise.all([
73
73
  this.db
74
- .selectFrom('ai_message')
75
- .select(['id', 'role', 'content', 'created_at'])
76
- .where('thread_id', '=', threadId)
77
- .orderBy('created_at', 'asc')
74
+ .selectFrom('aiMessage')
75
+ .select(['id', 'role', 'content', 'createdAt'])
76
+ .where('threadId', '=', threadId)
77
+ .orderBy('createdAt', 'asc')
78
78
  .execute(),
79
79
  this.db
80
- .selectFrom('ai_tool_call')
81
- .select(['id', 'message_id', 'tool_name', 'args', 'result'])
82
- .where('thread_id', '=', threadId)
83
- .orderBy('created_at', 'asc')
80
+ .selectFrom('aiToolCall')
81
+ .select(['id', 'messageId', 'toolName', 'args', 'result'])
82
+ .where('threadId', '=', threadId)
83
+ .orderBy('createdAt', 'asc')
84
84
  .execute(),
85
85
  ])
86
86
 
87
87
  const tcByMessage = new Map<string, (typeof tcResult)[number][]>()
88
88
  for (const tc of tcResult) {
89
- const msgId = tc.message_id
89
+ const msgId = tc.messageId
90
90
  if (!tcByMessage.has(msgId)) tcByMessage.set(msgId, [])
91
91
  tcByMessage.get(msgId)!.push(tc)
92
92
  }
@@ -97,14 +97,14 @@ export class KyselyAgentRunService implements AgentRunService {
97
97
  id: row.id,
98
98
  role: row.role as AIMessage['role'],
99
99
  content: row.content ?? undefined,
100
- createdAt: new Date(row.created_at as unknown as string),
100
+ createdAt: new Date(row.createdAt as unknown as string),
101
101
  }
102
102
 
103
103
  const tcs = tcByMessage.get(msg.id)
104
104
  if (tcs?.length) {
105
105
  msg.toolCalls = tcs.map((tc) => ({
106
106
  id: tc.id,
107
- name: tc.tool_name,
107
+ name: tc.toolName,
108
108
  args: parseJson(tc.args) as Record<string, unknown>,
109
109
  }))
110
110
 
@@ -116,7 +116,7 @@ export class KyselyAgentRunService implements AgentRunService {
116
116
  role: 'tool',
117
117
  toolResults: completed.map((tc) => ({
118
118
  id: tc.id,
119
- name: tc.tool_name,
119
+ name: tc.toolName,
120
120
  result: tc.result!,
121
121
  })),
122
122
  createdAt: msg.createdAt,
@@ -133,24 +133,24 @@ export class KyselyAgentRunService implements AgentRunService {
133
133
 
134
134
  async getThreadRuns(threadId: string): Promise<AgentRunRow[]> {
135
135
  const result = await this.db
136
- .selectFrom('ai_run')
136
+ .selectFrom('aiRun')
137
137
  .select([
138
- 'run_id',
139
- 'agent_name',
140
- 'thread_id',
141
- 'resource_id',
138
+ 'runId',
139
+ 'agentName',
140
+ 'threadId',
141
+ 'resourceId',
142
142
  'status',
143
- 'error_message',
144
- 'suspend_reason',
145
- 'missing_rpcs',
146
- 'usage_input_tokens',
147
- 'usage_output_tokens',
148
- 'usage_model',
149
- 'created_at',
150
- 'updated_at',
143
+ 'errorMessage',
144
+ 'suspendReason',
145
+ 'missingRpcs',
146
+ 'usageInputTokens',
147
+ 'usageOutputTokens',
148
+ 'usageModel',
149
+ 'createdAt',
150
+ 'updatedAt',
151
151
  ])
152
- .where('thread_id', '=', threadId)
153
- .orderBy('created_at', 'desc')
152
+ .where('threadId', '=', threadId)
153
+ .orderBy('createdAt', 'desc')
154
154
  .execute()
155
155
 
156
156
  return result.map((row) => this.mapRunRow(row))
@@ -158,7 +158,7 @@ export class KyselyAgentRunService implements AgentRunService {
158
158
 
159
159
  async deleteThread(threadId: string): Promise<boolean> {
160
160
  const result = await this.db
161
- .deleteFrom('ai_threads')
161
+ .deleteFrom('aiThreads')
162
162
  .where('id', '=', threadId)
163
163
  .executeTakeFirst()
164
164
 
@@ -167,41 +167,41 @@ export class KyselyAgentRunService implements AgentRunService {
167
167
 
168
168
  async getDistinctAgentNames(): Promise<string[]> {
169
169
  const result = await this.db
170
- .selectFrom('ai_run')
171
- .select('agent_name')
170
+ .selectFrom('aiRun')
171
+ .select('agentName')
172
172
  .distinct()
173
- .orderBy('agent_name')
173
+ .orderBy('agentName')
174
174
  .execute()
175
175
 
176
- return result.map((row) => row.agent_name)
176
+ return result.map((row) => row.agentName)
177
177
  }
178
178
 
179
179
  private mapThreadRow(row: any): AIThread {
180
180
  return {
181
181
  id: row.id as string,
182
- resourceId: row.resource_id as string,
182
+ resourceId: row.resourceId as string,
183
183
  title: (row.title as string) ?? undefined,
184
184
  metadata: parseJson(row.metadata),
185
- createdAt: new Date(row.created_at as string),
186
- updatedAt: new Date(row.updated_at as string),
185
+ createdAt: new Date(row.createdAt as string),
186
+ updatedAt: new Date(row.updatedAt as string),
187
187
  }
188
188
  }
189
189
 
190
190
  private mapRunRow(row: any): AgentRunRow {
191
191
  return {
192
- runId: row.run_id as string,
193
- agentName: row.agent_name as string,
194
- threadId: row.thread_id as string,
195
- resourceId: row.resource_id as string,
192
+ runId: row.runId as string,
193
+ agentName: row.agentName as string,
194
+ threadId: row.threadId as string,
195
+ resourceId: row.resourceId as string,
196
196
  status: row.status as string,
197
- errorMessage: (row.error_message as string) ?? undefined,
198
- suspendReason: (row.suspend_reason as string) ?? undefined,
199
- missingRpcs: parseJson(row.missing_rpcs),
200
- usageInputTokens: Number(row.usage_input_tokens),
201
- usageOutputTokens: Number(row.usage_output_tokens),
202
- usageModel: row.usage_model as string,
203
- createdAt: new Date(row.created_at as string),
204
- updatedAt: new Date(row.updated_at as string),
197
+ errorMessage: (row.errorMessage as string) ?? undefined,
198
+ suspendReason: (row.suspendReason as string) ?? undefined,
199
+ missingRpcs: parseJson(row.missingRpcs),
200
+ usageInputTokens: Number(row.usageInputTokens),
201
+ usageOutputTokens: Number(row.usageOutputTokens),
202
+ usageModel: row.usageModel as string,
203
+ createdAt: new Date(row.createdAt as string),
204
+ updatedAt: new Date(row.updatedAt as string),
205
205
  }
206
206
  }
207
207
  }