@pikku/kysely 0.12.6 → 0.12.8

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 CHANGED
@@ -1,5 +1,29 @@
1
1
  ## 0.12.0
2
2
 
3
+ ## 0.12.8
4
+
5
+ ### Patch Changes
6
+
7
+ - f85c234: Add unified credential system with per-user OAuth and AI agent pre-flight checks
8
+
9
+ - Unified CredentialService with lazy loading per user via pikkuUserId
10
+ - wire.getCredential() for typed single credential lookup
11
+ - MissingCredentialError with structured payload for client-side connect flows
12
+ - Console UI: Global/Users credential tabs, per-user OAuth connect/revoke
13
+ - AI agent pre-flight check: detects missing OAuth credentials from addon metadata, shows "Connect your accounts" prompt before chat
14
+ - CLI codegen: generates credentialsMeta per addon package for runtime lookup
15
+ - Vercel AI runner: catches MissingCredentialError as runtime fallback
16
+
17
+ - Updated dependencies [f85c234]
18
+ - Updated dependencies [88d3100]
19
+ - @pikku/core@0.12.14
20
+
21
+ ## 0.12.7
22
+
23
+ ### Patch Changes
24
+
25
+ - 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
26
+
3
27
  ## 0.12.6
4
28
 
5
29
  ### 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('ai_threads as t')
10
+ .selectFrom('aiThreads as t')
11
11
  .select([
12
12
  't.id',
13
- 't.resource_id',
13
+ 't.resourceId',
14
14
  't.title',
15
15
  't.metadata',
16
- 't.created_at',
17
- 't.updated_at',
16
+ 't.createdAt',
17
+ 't.updatedAt',
18
18
  ]);
19
19
  if (agentName) {
20
20
  query = query.where('t.id', 'in', this.db
21
- .selectFrom('ai_run')
22
- .select('thread_id')
23
- .where('agent_name', '=', agentName)
21
+ .selectFrom('aiRun')
22
+ .select('threadId')
23
+ .where('agentName', '=', agentName)
24
24
  .distinct());
25
25
  }
26
26
  const result = await query
27
- .orderBy('t.updated_at', 'desc')
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('ai_threads')
35
+ .selectFrom('aiThreads')
36
36
  .select([
37
37
  'id',
38
- 'resource_id',
38
+ 'resourceId',
39
39
  'title',
40
40
  'metadata',
41
- 'created_at',
42
- 'updated_at',
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('ai_message')
54
- .select(['id', 'role', 'content', 'created_at'])
55
- .where('thread_id', '=', threadId)
56
- .orderBy('created_at', 'asc')
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('ai_tool_call')
60
- .select(['id', 'message_id', 'tool_name', 'args', 'result'])
61
- .where('thread_id', '=', threadId)
62
- .orderBy('created_at', 'asc')
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.message_id;
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.created_at),
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.tool_name,
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.tool_name,
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('ai_run')
109
+ .selectFrom('aiRun')
110
110
  .select([
111
- 'run_id',
112
- 'agent_name',
113
- 'thread_id',
114
- 'resource_id',
111
+ 'runId',
112
+ 'agentName',
113
+ 'threadId',
114
+ 'resourceId',
115
115
  'status',
116
- 'error_message',
117
- 'suspend_reason',
118
- 'missing_rpcs',
119
- 'usage_input_tokens',
120
- 'usage_output_tokens',
121
- 'usage_model',
122
- 'created_at',
123
- 'updated_at',
116
+ 'errorMessage',
117
+ 'suspendReason',
118
+ 'missingRpcs',
119
+ 'usageInputTokens',
120
+ 'usageOutputTokens',
121
+ 'usageModel',
122
+ 'createdAt',
123
+ 'updatedAt',
124
124
  ])
125
- .where('thread_id', '=', threadId)
126
- .orderBy('created_at', 'desc')
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('ai_threads')
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('ai_run')
140
- .select('agent_name')
139
+ .selectFrom('aiRun')
140
+ .select('agentName')
141
141
  .distinct()
142
- .orderBy('agent_name')
142
+ .orderBy('agentName')
143
143
  .execute();
144
- return result.map((row) => row.agent_name);
144
+ return result.map((row) => row.agentName);
145
145
  }
146
146
  mapThreadRow(row) {
147
147
  return {
148
148
  id: row.id,
149
- resourceId: row.resource_id,
149
+ resourceId: row.resourceId,
150
150
  title: row.title ?? undefined,
151
151
  metadata: parseJson(row.metadata),
152
- createdAt: new Date(row.created_at),
153
- updatedAt: new Date(row.updated_at),
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.run_id,
159
- agentName: row.agent_name,
160
- threadId: row.thread_id,
161
- resourceId: row.resource_id,
158
+ runId: row.runId,
159
+ agentName: row.agentName,
160
+ threadId: row.threadId,
161
+ resourceId: row.resourceId,
162
162
  status: row.status,
163
- errorMessage: row.error_message ?? undefined,
164
- suspendReason: row.suspend_reason ?? undefined,
165
- missingRpcs: parseJson(row.missing_rpcs),
166
- usageInputTokens: Number(row.usage_input_tokens),
167
- usageOutputTokens: Number(row.usage_output_tokens),
168
- usageModel: row.usage_model,
169
- createdAt: new Date(row.created_at),
170
- updatedAt: new Date(row.updated_at),
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
  }