@pikku/kysely 0.13.23 → 0.13.27

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 (80) hide show
  1. package/CHANGELOG.md +248 -0
  2. package/dist/src/index.d.ts +4 -1
  3. package/dist/src/index.js +3 -1
  4. package/dist/src/kysely-analytics-service.d.ts +30 -0
  5. package/dist/src/kysely-analytics-service.js +80 -0
  6. package/dist/src/kysely-feature-flag-store.d.ts +37 -0
  7. package/dist/src/kysely-feature-flag-store.js +239 -0
  8. package/dist/src/kysely-tables.d.ts +45 -0
  9. package/dist/src/kysely-webhook-service.d.ts +1 -1
  10. package/dist/src/kysely-webhook-service.js +1 -1
  11. package/dist/src/schema/analytics.schema.d.ts +17 -0
  12. package/dist/src/schema/analytics.schema.js +48 -0
  13. package/dist/src/schema/flag.schema.d.ts +16 -0
  14. package/dist/src/schema/flag.schema.js +62 -0
  15. package/dist/src/schema/index.d.ts +2 -0
  16. package/dist/src/schema/index.js +6 -0
  17. package/package.json +11 -6
  18. package/run-tests.sh +9 -1
  19. package/bin/pikku-kysely-pure.ts +0 -59
  20. package/dist/src/kysely-lock-vault.d.ts +0 -34
  21. package/dist/src/kysely-lock-vault.js +0 -77
  22. package/dist/src/schema/data-lock.schema.d.ts +0 -15
  23. package/dist/src/schema/data-lock.schema.js +0 -27
  24. package/dist/tsconfig.tsbuildinfo +0 -1
  25. package/src/classification-crypto.test.ts +0 -143
  26. package/src/classification-crypto.ts +0 -163
  27. package/src/classification-plugin.pglite.test.ts +0 -226
  28. package/src/classification-plugin.test.ts +0 -265
  29. package/src/classification-plugin.ts +0 -249
  30. package/src/coercion-plugin.test.ts +0 -160
  31. package/src/coercion-plugin.ts +0 -187
  32. package/src/create-audited-kysely.test.ts +0 -560
  33. package/src/create-audited-kysely.ts +0 -254
  34. package/src/index.ts +0 -81
  35. package/src/kysely-agent-run-scores.ts +0 -47
  36. package/src/kysely-agent-run-service.ts +0 -244
  37. package/src/kysely-agent-run-state-service.ts +0 -200
  38. package/src/kysely-agent-storage-service.ts +0 -632
  39. package/src/kysely-audit-service.test.ts +0 -352
  40. package/src/kysely-audit-service.ts +0 -237
  41. package/src/kysely-channel-store.ts +0 -107
  42. package/src/kysely-credential-service.ts +0 -286
  43. package/src/kysely-deployment-service.ts +0 -163
  44. package/src/kysely-eventhub-store.ts +0 -53
  45. package/src/kysely-json.ts +0 -5
  46. package/src/kysely-scope-service.test.ts +0 -418
  47. package/src/kysely-scope-service.ts +0 -425
  48. package/src/kysely-secret-service.ts +0 -242
  49. package/src/kysely-services.test.ts +0 -405
  50. package/src/kysely-session-store.ts +0 -57
  51. package/src/kysely-tables.test.ts +0 -110
  52. package/src/kysely-tables.ts +0 -434
  53. package/src/kysely-virtual-user-run-store.test.ts +0 -369
  54. package/src/kysely-virtual-user-run-store.ts +0 -235
  55. package/src/kysely-virtual-user-schedule-store.test.ts +0 -187
  56. package/src/kysely-virtual-user-schedule-store.ts +0 -187
  57. package/src/kysely-webhook-service.test.ts +0 -124
  58. package/src/kysely-webhook-service.ts +0 -137
  59. package/src/kysely-workflow-mirror.test.ts +0 -259
  60. package/src/kysely-workflow-mirror.ts +0 -374
  61. package/src/kysely-workflow-run-service.ts +0 -305
  62. package/src/kysely-workflow-service.test.ts +0 -544
  63. package/src/kysely-workflow-service.ts +0 -820
  64. package/src/schema/agent.schema.ts +0 -162
  65. package/src/schema/audit.schema.ts +0 -57
  66. package/src/schema/channel.schema.ts +0 -38
  67. package/src/schema/credential.schema.ts +0 -58
  68. package/src/schema/deployment.schema.ts +0 -47
  69. package/src/schema/index.ts +0 -441
  70. package/src/schema/pikku-schema.types.ts +0 -169
  71. package/src/schema/schema.test.ts +0 -591
  72. package/src/schema/scope.schema.ts +0 -110
  73. package/src/schema/secret.schema.ts +0 -49
  74. package/src/schema/session.schema.ts +0 -20
  75. package/src/schema/virtual-user-schedule.schema.ts +0 -48
  76. package/src/schema/virtual-user.schema.ts +0 -106
  77. package/src/schema/webhook.schema.ts +0 -58
  78. package/src/schema/workflow.schema.ts +0 -150
  79. package/src/serialize-plugin.ts +0 -233
  80. package/tsconfig.json +0 -17
@@ -1,434 +0,0 @@
1
- import type { Generated } from 'kysely'
2
- import type {
3
- WorkflowStatus,
4
- StepStatus,
5
- WorkflowVersionStatus,
6
- } from '@pikku/core/workflow'
7
-
8
- export interface ChannelsTable {
9
- channelId: string
10
- channelName: string
11
- createdAt: Generated<Date>
12
- openingData: string
13
- pikkuUserId: string | null
14
- /** JSON-serialized per-socket channel state, keyed by channelId. */
15
- state: string | null
16
- lastWire: Generated<Date>
17
- }
18
-
19
- export interface ChannelSubscriptionsTable {
20
- channelId: string
21
- topic: string
22
- }
23
-
24
- export interface WorkflowRunsTable {
25
- workflowRunId: Generated<string>
26
- workflow: string
27
- status: WorkflowStatus
28
- input: string
29
- output: string | null
30
- error: string | null
31
- state: Generated<string>
32
- inline: Generated<boolean>
33
- graphHash: string | null
34
- deterministic: Generated<boolean>
35
- plannedSteps: string | null
36
- wire: string | null
37
- createdAt: Generated<Date>
38
- updatedAt: Generated<Date>
39
- }
40
-
41
- export interface WorkflowStepTable {
42
- workflowStepId: Generated<string>
43
- workflowRunId: string
44
- stepName: string
45
- rpcName: string | null
46
- data: string | null
47
- status: Generated<StepStatus>
48
- result: string | null
49
- error: string | null
50
- childRunId: string | null
51
- branchTaken: string | null
52
- retries: number | null
53
- retryDelay: string | null
54
- fromStepName: string | null
55
- /** The history attempt currently in flight; see WorkflowStepHistoryTable.attempt. */
56
- currentAttempt: number | null
57
- createdAt: Generated<Date>
58
- updatedAt: Generated<Date>
59
- }
60
-
61
- export interface WorkflowStepHistoryTable {
62
- historyId: Generated<string>
63
- workflowStepId: string
64
- status: StepStatus
65
- result: string | null
66
- error: string | null
67
- /**
68
- * Monotonic attempt number within the step, starting at 1. Orders attempts
69
- * and identifies the live one without relying on `createdAt`, which cannot
70
- * separate a retry from the attempt it replaces in the same millisecond.
71
- */
72
- attempt: number | null
73
- createdAt: Generated<Date>
74
- runningAt: Date | null
75
- scheduledAt: Date | null
76
- succeededAt: Date | null
77
- failedAt: Date | null
78
- }
79
-
80
- export interface WorkflowVersionsTable {
81
- workflowName: string
82
- graphHash: string
83
- graph: string
84
- source: string
85
- status: Generated<WorkflowVersionStatus>
86
- createdAt: Generated<Date>
87
- }
88
-
89
- export interface AgentThreadsTable {
90
- id: string
91
- resourceId: string
92
- title: string | null
93
- metadata: string | null
94
- createdAt: Generated<Date>
95
- updatedAt: Generated<Date>
96
- }
97
-
98
- export interface AgentMessageTable {
99
- id: string
100
- threadId: string
101
- role: 'system' | 'user' | 'assistant' | 'tool'
102
- content: string | null
103
- createdAt: Generated<Date>
104
- }
105
-
106
- export interface AgentToolCallTable {
107
- id: string
108
- threadId: string
109
- messageId: string
110
- runId: string | null
111
- toolName: string
112
- args: string
113
- result: string | null
114
- approvalStatus: 'approved' | 'denied' | 'pending' | null
115
- approvalType: 'agent-call' | 'tool-call' | null
116
- agentRunId: string | null
117
- displayToolName: string | null
118
- displayArgs: string | null
119
- createdAt: Generated<Date>
120
- }
121
-
122
- export interface AgentWorkingMemoryTable {
123
- id: string
124
- scope: string
125
- data: string
126
- updatedAt: Generated<Date>
127
- }
128
-
129
- export interface AgentRunTable {
130
- runId: Generated<string>
131
- agentName: string
132
- threadId: string
133
- resourceId: string
134
- /**
135
- * `interrupted` is distinct from `failed`: the run was stopped on purpose,
136
- * usually because the user talked over it. Nothing went wrong, so it should
137
- * not show up in error reporting.
138
- */
139
- status: Generated<
140
- 'running' | 'suspended' | 'completed' | 'failed' | 'interrupted'
141
- >
142
- errorMessage: string | null
143
- suspendReason: 'approval' | 'credential' | 'rpc-missing' | null
144
- missingRpcs: string | null
145
- /** JSON-serialized approvals the run is suspended on. */
146
- pendingApprovals: string | null
147
- usageInputTokens: Generated<number>
148
- usageOutputTokens: Generated<number>
149
- usageModel: Generated<string>
150
- createdAt: Generated<Date>
151
- updatedAt: Generated<Date>
152
- }
153
-
154
- export interface AgentRunScoreTable {
155
- id: string
156
- runId: string
157
- scorerName: string
158
- /** 0..1, so grades are comparable across scorers. */
159
- score: number
160
- reason: string | null
161
- /** JSON-serialized structured detail the scorer returned alongside the score. */
162
- metadata: string | null
163
- createdAt: Generated<Date>
164
- }
165
-
166
- export interface PikkuDeploymentsTable {
167
- deploymentId: string
168
- endpoint: string
169
- lastHeartbeat: Generated<Date>
170
- createdAt: Generated<Date>
171
- }
172
-
173
- export interface PikkuDeploymentFunctionsTable {
174
- deploymentId: string
175
- functionName: string
176
- }
177
-
178
- export interface SecretsTable {
179
- key: string
180
- ciphertext: string
181
- wrappedDek: string
182
- keyVersion: number
183
- createdAt: Generated<Date>
184
- updatedAt: Generated<Date>
185
- }
186
-
187
- export interface KekSaltsTable {
188
- keyVersion: number
189
- salt: string
190
- createdAt: Generated<Date>
191
- }
192
-
193
- export interface SecretsAuditTable {
194
- id: string
195
- secretKey: string
196
- action: string
197
- performedAt: Generated<Date>
198
- }
199
-
200
- export interface CredentialsTable {
201
- name: string
202
- userId: string | null
203
- ciphertext: string
204
- wrappedDek: string
205
- keyVersion: number
206
- createdAt: Generated<Date>
207
- updatedAt: Generated<Date>
208
- }
209
-
210
- export interface CredentialsAuditTable {
211
- id: string
212
- credentialName: string
213
- userId: string | null
214
- action: string
215
- performedAt: Generated<Date>
216
- }
217
-
218
- export interface UserSessionsTable {
219
- pikkuUserId: string
220
- session: string
221
- createdAt: Generated<Date>
222
- updatedAt: Generated<Date>
223
- }
224
-
225
- /**
226
- * The declared scope set, synced from generated SCOPES.
227
- *
228
- * Additive: a scope removed from code leaves an inert row rather than
229
- * cascading a grant away mid-deploy. `pikku scopes prune` removes them
230
- * deliberately.
231
- */
232
- export interface PikkuScopesTable {
233
- name: string
234
- description: string | null
235
- /**
236
- * False once a scope is no longer declared in code. Marking is
237
- * non-destructive — grants survive until `pikku scopes prune` removes them
238
- * deliberately.
239
- */
240
- declared: Generated<boolean>
241
- }
242
-
243
- /** A role: a bag of scopes, composed by an admin or declared in code. */
244
- export interface PikkuRolesTable {
245
- name: string
246
- description: string | null
247
- /** Declared with `defineSystemRole`, and therefore not editable here. */
248
- system: Generated<boolean>
249
- /** False for a system role whose declaration has gone: held, but inert. */
250
- declared: Generated<boolean>
251
- createdAt: Generated<Date>
252
- }
253
-
254
- export interface PikkuRoleScopesTable {
255
- role: string
256
- scope: string
257
- }
258
-
259
- export interface PikkuUserRoleTable {
260
- userId: string
261
- role: string
262
- grantedBy: string | null
263
- grantedAt: Generated<Date>
264
- }
265
-
266
- /** A scope granted directly to a user, outside of any role. */
267
- export interface PikkuUserScopeTable {
268
- userId: string
269
- scope: string
270
- grantedBy: string | null
271
- grantedAt: Generated<Date>
272
- }
273
-
274
- export interface WebhookDeliveryTable {
275
- deliveryId: string
276
- organizationId: string | null
277
- url: string
278
- event: string | null
279
- status: Generated<'pending' | 'delivered' | 'failed'>
280
- attempts: Generated<number>
281
- createdAt: Generated<Date>
282
- updatedAt: Generated<Date>
283
- deliveredAt: Date | null
284
- }
285
-
286
- export interface WebhookDeliveryAttemptTable {
287
- attemptId: string
288
- deliveryId: string
289
- attemptNumber: number
290
- statusCode: number | null
291
- responseBody: string | null
292
- error: string | null
293
- createdAt: Generated<Date>
294
- }
295
-
296
- /**
297
- * One virtual-user run. The JSON columns (`goals`, `memory`, `findings`,
298
- * `tally`) are text the store serialises itself, so the row is byte-identical
299
- * on every engine.
300
- */
301
- export interface VirtualUserRunTable {
302
- runId: string
303
- persona: string
304
- disposition: string
305
- /**
306
- * Read back as a string by some drivers — a BIGINT does not always fit a JS
307
- * number — so the store narrows it rather than trusting the column type.
308
- */
309
- seed: string | number | bigint
310
- status: Generated<'running' | 'completed' | 'failed'>
311
- goals: Generated<string>
312
- memory: Generated<string>
313
- findings: Generated<string>
314
- intents: Generated<string>
315
- tally: string | null
316
- stoppedBy: string | null
317
- error: string | null
318
- startedBy: string | null
319
- /**
320
- * Written as an ISO string and read back as whatever the driver returns — a
321
- * bare SQLite driver cannot bind a `Date` at all, and the store normalises
322
- * both ends.
323
- */
324
- createdAt: Generated<Date | string>
325
- finishedAt: Date | string | null
326
- }
327
-
328
- /**
329
- * One audit event. Every column is text on every engine so a locally-run
330
- * project and a deployed stage write rows the same reader can read; the JSON
331
- * columns (`tables`, `changedCols`, `event`, `old`, `data`) are serialised by
332
- * {@link KyselyAuditService} rather than by a plugin.
333
- */
334
- export interface AuditTable {
335
- auditId: string
336
- /** ISO 8601, because string ordering is chronological ordering. */
337
- occurredAt: string
338
- type: string
339
- source: Generated<string>
340
- outcome: string | null
341
- functionId: string | null
342
- wireType: string | null
343
- traceId: string | null
344
- transactionId: string | null
345
- queryId: string | null
346
- userId: string | null
347
- orgId: string | null
348
- pikkuUserId: string | null
349
- tables: string | null
350
- changedCols: string | null
351
- event: string | null
352
- old: string | null
353
- data: string | null
354
- }
355
-
356
- /**
357
- * One turn of a run's transcript.
358
- *
359
- * Its own table rather than a column on {@link VirtualUserRunTable}: a run at a
360
- * 500-step budget carries more transcript than every other column together, and
361
- * the run list would pay for it on every row.
362
- */
363
- export interface VirtualUserRunStepTable {
364
- runId: string
365
- /** The engine's step number. `stepIndex` because `index` is reserved in mysql. */
366
- stepIndex: number
367
- intentId: string | null
368
- /** JSON: the action the engine scheduled, or the `invalid` shape. */
369
- action: string
370
- status: number | null
371
- /** 0 or 1: not every driver in this package can bind a boolean. */
372
- ok: number | null
373
- /** JSON-encoded, so a brace-leading response is not read back as an object. */
374
- response: string | null
375
- /** JSON array, null when the turn produced no finding. */
376
- findingKinds: string | null
377
- tokensIn: Generated<number>
378
- tokensOut: Generated<number>
379
- }
380
-
381
- /**
382
- * One persona's cadence. Nullable timestamps and 0/1 flags for the same driver
383
- * reasons as {@link VirtualUserRunTable}.
384
- */
385
- export interface VirtualUserScheduleTable {
386
- persona: string
387
- /** 0 or 1: not every driver in this package can bind a boolean. */
388
- enabled: Generated<number>
389
- disposition: string
390
- goals: Generated<string>
391
- /** JSON, or null for the engine's own default budget. */
392
- budget: string | null
393
- /** BIGINT, so a driver may hand either back. */
394
- minIntervalMs: string | number | bigint
395
- maxIntervalMs: string | number | bigint
396
- nextRunAt: Date | string
397
- lastRunId: string | null
398
- lastRunAt: Date | string | null
399
- }
400
-
401
- export interface KyselyPikkuDB {
402
- pikkuScopes: PikkuScopesTable
403
- pikkuRoles: PikkuRolesTable
404
- pikkuRoleScopes: PikkuRoleScopesTable
405
- pikkuUserRole: PikkuUserRoleTable
406
- pikkuUserScope: PikkuUserScopeTable
407
- channels: ChannelsTable
408
- channelSubscriptions: ChannelSubscriptionsTable
409
- workflowRuns: WorkflowRunsTable
410
- workflowStep: WorkflowStepTable
411
- workflowStepHistory: WorkflowStepHistoryTable
412
- workflowVersions: WorkflowVersionsTable
413
- agentThreads: AgentThreadsTable
414
- agentMessage: AgentMessageTable
415
- agentToolCall: AgentToolCallTable
416
- agentWorkingMemory: AgentWorkingMemoryTable
417
- agentRun: AgentRunTable
418
- agentRunScore: AgentRunScoreTable
419
- pikkuDeployments: PikkuDeploymentsTable
420
- pikkuDeploymentFunctions: PikkuDeploymentFunctionsTable
421
- secrets: SecretsTable
422
- secretKekSalts: KekSaltsTable
423
- secretsAudit: SecretsAuditTable
424
- credentials: CredentialsTable
425
- credentialKekSalts: KekSaltsTable
426
- credentialsAudit: CredentialsAuditTable
427
- pikkuUserSessions: UserSessionsTable
428
- webhookDelivery: WebhookDeliveryTable
429
- webhookDeliveryAttempt: WebhookDeliveryAttemptTable
430
- virtualUserRun: VirtualUserRunTable
431
- virtualUserRunStep: VirtualUserRunStepTable
432
- virtualUserSchedule: VirtualUserScheduleTable
433
- audit: AuditTable
434
- }