@pikku/kysely 0.13.16 → 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 (68) hide show
  1. package/CHANGELOG.md +135 -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 +4 -3
  7. package/dist/src/index.js +1 -0
  8. package/dist/src/kysely-agent-run-scores.d.ts +1 -1
  9. package/dist/src/kysely-agent-run-service.d.ts +1 -2
  10. package/dist/src/kysely-agent-run-state-service.d.ts +2 -2
  11. package/dist/src/kysely-agent-storage-service.d.ts +2 -2
  12. package/dist/src/kysely-audit-service.d.ts +3 -3
  13. package/dist/src/kysely-channel-store.d.ts +1 -1
  14. package/dist/src/kysely-credential-service.js +1 -1
  15. package/dist/src/kysely-deployment-service.d.ts +3 -2
  16. package/dist/src/kysely-deployment-service.js +2 -2
  17. package/dist/src/kysely-eventhub-store.d.ts +1 -1
  18. package/dist/src/kysely-eventhub-store.js +1 -1
  19. package/dist/src/kysely-scope-service.d.ts +3 -3
  20. package/dist/src/kysely-secret-service.d.ts +1 -1
  21. package/dist/src/kysely-secret-service.js +2 -2
  22. package/dist/src/kysely-session-store.d.ts +1 -1
  23. package/dist/src/kysely-tables.d.ts +1 -1
  24. package/dist/src/kysely-virtual-user-run-store.d.ts +1 -1
  25. package/dist/src/kysely-webhook-service.d.ts +1 -1
  26. package/dist/src/kysely-webhook-service.js +1 -1
  27. package/dist/src/kysely-workflow-mirror.d.ts +2 -2
  28. package/dist/src/kysely-workflow-run-service.d.ts +1 -1
  29. package/dist/src/kysely-workflow-service.d.ts +2 -2
  30. package/dist/tsconfig.tsbuildinfo +1 -1
  31. package/package.json +7 -7
  32. package/src/coercion-plugin.test.ts +160 -0
  33. package/src/coercion-plugin.ts +187 -0
  34. package/src/create-audited-kysely.test.ts +1 -1
  35. package/src/create-audited-kysely.ts +1 -1
  36. package/src/index.ts +9 -6
  37. package/src/kysely-agent-run-scores.ts +1 -1
  38. package/src/kysely-agent-run-service.ts +3 -2
  39. package/src/kysely-agent-run-state-service.ts +3 -3
  40. package/src/kysely-agent-storage-service.ts +7 -7
  41. package/src/kysely-audit-service.test.ts +1 -1
  42. package/src/kysely-audit-service.ts +4 -8
  43. package/src/kysely-channel-store.ts +1 -1
  44. package/src/kysely-credential-service.ts +5 -5
  45. package/src/kysely-deployment-service.ts +5 -4
  46. package/src/kysely-eventhub-store.ts +1 -1
  47. package/src/kysely-scope-service.ts +3 -3
  48. package/src/kysely-secret-service.ts +7 -6
  49. package/src/kysely-services.test.ts +1 -1
  50. package/src/kysely-session-store.ts +1 -1
  51. package/src/kysely-tables.ts +1 -1
  52. package/src/kysely-virtual-user-run-store.ts +1 -1
  53. package/src/kysely-webhook-service.test.ts +1 -1
  54. package/src/kysely-webhook-service.ts +2 -2
  55. package/src/kysely-workflow-mirror.ts +2 -2
  56. package/src/kysely-workflow-run-service.ts +1 -1
  57. package/src/kysely-workflow-service.test.ts +0 -1
  58. package/src/kysely-workflow-service.ts +11 -2
  59. package/dist/src/kysely-ai-agent-run-service.d.ts +0 -22
  60. package/dist/src/kysely-ai-agent-run-service.js +0 -190
  61. package/dist/src/kysely-ai-run-scores.d.ts +0 -10
  62. package/dist/src/kysely-ai-run-scores.js +0 -34
  63. package/dist/src/kysely-ai-run-state-service.d.ts +0 -24
  64. package/dist/src/kysely-ai-run-state-service.js +0 -169
  65. package/dist/src/kysely-ai-storage-service.d.ts +0 -40
  66. package/dist/src/kysely-ai-storage-service.js +0 -530
  67. package/dist/src/schema/ai.schema.d.ts +0 -12
  68. package/dist/src/schema/ai.schema.js +0 -102
package/CHANGELOG.md CHANGED
@@ -1,3 +1,138 @@
1
+ ## 0.13.18
2
+
3
+ ### Patch Changes
4
+
5
+ - 746ed6a: fix: one coercion plugin, not three
6
+
7
+ The Kysely coercion plugin existed in three copies — the CLI's local database,
8
+ `@pikku/kysely-node-sqlite` and `@pikku/kysely-bun-sqlite` — and all three had
9
+ drifted apart. Only the CLI's resolved a column against the tables the query
10
+ actually named, so two tables that disagree on the kind of a same-named column
11
+ coerced correctly in local development and silently did not at runtime; only
12
+ bun's dropped a genuinely ambiguous column instead of letting the last table
13
+ processed win.
14
+
15
+ The single implementation now lives in `@pikku/kysely`, which all three already
16
+ depended on, and keeps both behaviours: table-qualified resolution first, an
17
+ ambiguity-safe bare-name fallback second.
18
+
19
+ `ColumnKind` — the value type of the generated `coercion.gen.ts` — is
20
+ `'date' | 'bool' | 'json'`. The CLI's fourth member, `uuid`, was never a
21
+ coercion kind: the codegen excludes it from the map by construction, because a
22
+ UUID is a string in both Postgres and SQLite. It is now `AnnotationKind` in the
23
+ CLI, the union a column may declare in `db/annotations.ts`, of which
24
+ `ColumnKind` is the coercible subset.
25
+
26
+ `@pikku/cli` also drops its unused dependency on the Node-only
27
+ `@pikku/kysely-node-sqlite`.
28
+
29
+ - Updated dependencies [5a1a962]
30
+ - @pikku/core@0.12.86
31
+
32
+ ## 0.13.17
33
+
34
+ ### Patch Changes
35
+
36
+ - 266e3bc: One door per name: `@pikku/core/ecosystem/*` and the package root are gone
37
+
38
+ `@pikku/core` published every module twice. `ecosystem/http` re-exported
39
+ `./http`, `ecosystem/services` re-exported `./services`, and a name was
40
+ reachable through either — so every addition had to be made in two places, and a
41
+ consumer's import said nothing about what it actually used. The package root was
42
+ the same problem at a larger scale: a single barrel of 206 names that no bundler
43
+ could take apart, and the one specifier that revealed nothing at all.
44
+
45
+ Both are deleted. Every name now lives on the subpath that owns it, and every
46
+ import carries that subpath — `@pikku/core/http`, `@pikku/core/services`,
47
+ `@pikku/core/errors`, `@pikku/core/types`.
48
+
49
+ Deleting the facades meant the raw subpaths had to become a superset of them,
50
+ which they were not: the facade tree had accumulated 25 names with no raw home
51
+ and about 26 more filed under a different area than the module they came from.
52
+ Those names moved to the area that owns them, and three areas were published as
53
+ new entry points rather than left on a root that is going away — `./types` (the
54
+ shared type surface, the largest single destination), `./state` and
55
+ `./classification`.
56
+
57
+ `./classification` is one door onto one subject: what a value is and how it must
58
+ be handled. Its three halves would each have been an entry point — the brands
59
+ and manifest types, the stored-form helpers (`hashToken`, `unsafeAsSealed` and
60
+ friends), and `SecretValue` — split by whether a name happens to be a type or a
61
+ value, which is the same defect as the facades. The duration and versioned-id
62
+ helpers went to `./utils`, which already published, and `PikkuRequest` went to
63
+ `./function`: it is the transport-agnostic request base, not an HTTP one — HTTP
64
+ has `PikkuHTTPAbstractRequest`, and the only thing outside core that extends
65
+ `PikkuRequest` is Azure's timer request.
66
+
67
+ `./types` inherited the root barrel's habit before it inherited its contents, so
68
+ the names with an owner elsewhere were moved off it. The middleware types and the
69
+ five middleware factories — `pikkuMiddleware`, `pikkuMiddlewareFactory`,
70
+ `pikkuChannelMiddleware`, `pikkuChannelMiddlewareFactory` and
71
+ `pikkuAgentMiddleware`, runtime values on a types entry point — are now
72
+ `@pikku/core/middleware`; the function meta types are `@pikku/core/function`;
73
+ `SerializedError` is `@pikku/core/errors`; and the generic TypeScript helpers
74
+ (`MakeRequired`, `PickRequired`, `PickOptional`, `RequireAtLeastOne`,
75
+ `JSONPrimitive`, `JSONValue`) are `@pikku/core/utils`. What is left on `./types`
76
+ is the vocabulary the wirings share, which no single module owns.
77
+
78
+ `pikku` was itself a root barrel — `export * from '@pikku/core'` — and
79
+ now exports only the services it bundles.
80
+
81
+ One module survives at the old specifier, and only for the bootstrap:
82
+ `packages/cli` is generated by the _published_ CLI pinned in its `build.sh`, and
83
+ that CLI still writes a bare `@pikku/core` into the files it generates for the
84
+ CLI itself. `bootstrap-compat/root.ts` carries the eight types it names, a test
85
+ in core fails if that list grows, and it goes when the pin moves to a CLI
86
+ released from this branch. The adapter names the pinned CLI reaches for —
87
+ `pikkuState` and `CreateWireServices` — are rewritten to `@pikku/core/state` and
88
+ `@pikku/core/types` by the same `build.sh` patch pass, so no second shim is
89
+ needed for them.
90
+
91
+ A guard test keeps the root shut: it parses imports and rejects a bare
92
+ `@pikku/core` rather than grepping for it, because several tests hold a user's
93
+ file as a template literal, where `import … from '@pikku/core'` is fixture text
94
+ rather than an import this repo makes.
95
+
96
+ An agent scaffold a project generated under an older CLI is refreshed rather
97
+ than left to fail: `pikku all` already deleted one importing an entry point
98
+ `@pikku/core` no longer publishes, and the `#pikku` hub joins that list.
99
+ Without it a project that scaffolds the agent endpoint but
100
+ declares no agents keeps the old file forever — the generator that would rewrite
101
+ it only runs when agents exist, and the file being present is what stops it
102
+ being regenerated as missing.
103
+
104
+ `pikku new addon` also wrote a tsconfig `paths` map naming only the deleted hub.
105
+ An addon's `imports` map points into `dist`, so `paths` is what resolves
106
+ `#pikku/<leaf>` for the addon's own source build — it now names the two leaf
107
+ patterns, in both the addon and its test harness.
108
+
109
+ - 786dae5: Bump every dependency whose latest release is a major across the monorepo, and
110
+ port the code the majors broke: `cookie` 2's `parseCookie`/`stringifySetCookie`
111
+ API in `@pikku/core` and the three runtime HTTP adapters, and assistant-ui 0.15's
112
+ store client in `@pikku/assistant-ui`.
113
+ - 6eef0a0: Bump every dependency to its latest compatible minor/patch across the monorepo.
114
+ - Updated dependencies [7722ceb]
115
+ - Updated dependencies [375c1ff]
116
+ - Updated dependencies [02a70cd]
117
+ - Updated dependencies [aeef159]
118
+ - Updated dependencies [a281de6]
119
+ - Updated dependencies [266e3bc]
120
+ - Updated dependencies [02a70cd]
121
+ - Updated dependencies [786dae5]
122
+ - Updated dependencies [6eef0a0]
123
+ - Updated dependencies [3561d67]
124
+ - Updated dependencies [a91c433]
125
+ - Updated dependencies [02a70cd]
126
+ - Updated dependencies [9537f74]
127
+ - Updated dependencies [2b57ca8]
128
+ - Updated dependencies [266e3bc]
129
+ - Updated dependencies [9fce0f1]
130
+ - Updated dependencies [83683a0]
131
+ - Updated dependencies [456c88b]
132
+ - Updated dependencies [456c88b]
133
+ - Updated dependencies [c127273]
134
+ - @pikku/core@0.12.85
135
+
1
136
  ## 0.13.16
2
137
 
3
138
  ### Patch Changes
File without changes
@@ -0,0 +1,41 @@
1
+ import type { KyselyPlugin } from 'kysely';
2
+ /**
3
+ * The kinds a column can be coerced *to* at runtime. This is the value type of
4
+ * the generated `CoercionMap`, so it is a public artifact contract — a kind may
5
+ * only appear here if `fromDb` below actually does something with it.
6
+ *
7
+ * `uuid` is deliberately absent: it is an annotation kind (it selects the `Uuid`
8
+ * TypeScript type in the generated schema) but not a coercion kind, and the
9
+ * codegen filters it out of `coercion.gen.ts` for exactly that reason — a UUID
10
+ * is a string in both Postgres and SQLite.
11
+ */
12
+ export type ColumnKind = 'date' | 'bool' | 'json';
13
+ /**
14
+ * Per-table column kind map. Keys are the table names queries are written
15
+ * against; inner keys are snake_case column names.
16
+ * Generated into `outDir/db/coercion.gen.ts` by `pikku db migrate` from the
17
+ * explicit `kind` entries in `db/annotations.ts`.
18
+ */
19
+ export type CoercionMap = Record<string, Record<string, ColumnKind>>;
20
+ export interface CreateCoercionPluginOptions {
21
+ map: CoercionMap;
22
+ }
23
+ /**
24
+ * Convert values stored in a dialect's on-disk representation back into the
25
+ * logical types app code expects (Date / boolean / parsed JSON).
26
+ *
27
+ * SQLite is what makes this necessary — it stores dates as TEXT, booleans as
28
+ * INTEGER and JSON as TEXT — but the plugin is dialect-neutral: on Postgres the
29
+ * driver already returns Date/boolean/object, and every branch of `fromDb`
30
+ * passes a non-string, non-number value straight through. That is why it lives
31
+ * in `@pikku/kysely` next to `SerializePlugin` rather than in a SQLite package:
32
+ * the CLI installs it on its local Postgres database too.
33
+ *
34
+ * Write-side coercion (Date → ISO string, boolean → 0/1, object → JSON) is
35
+ * handled in the SQLite database adapters (always-on), so this plugin is
36
+ * read-only.
37
+ *
38
+ * Place AFTER CamelCasePlugin in the plugin array (or it handles both
39
+ * orderings via the dual-keyed maps).
40
+ */
41
+ export declare function createCoercionPlugin(options: CreateCoercionPluginOptions): KyselyPlugin;
@@ -0,0 +1,150 @@
1
+ function fromDb(value, kind) {
2
+ if (value == null)
3
+ return value;
4
+ switch (kind) {
5
+ case 'date':
6
+ if (typeof value === 'string') {
7
+ const d = new Date(value);
8
+ return Number.isNaN(d.getTime()) ? value : d;
9
+ }
10
+ return value;
11
+ case 'bool':
12
+ if (typeof value === 'number')
13
+ return value !== 0;
14
+ if (typeof value === 'bigint')
15
+ return value !== 0n;
16
+ return value;
17
+ case 'json':
18
+ if (typeof value !== 'string')
19
+ return value;
20
+ try {
21
+ return JSON.parse(value);
22
+ }
23
+ catch {
24
+ return value;
25
+ }
26
+ }
27
+ }
28
+ function snakeToCamel(name) {
29
+ return name.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
30
+ }
31
+ /**
32
+ * Flatten the per-table map into a table-qualified lookup plus a bare
33
+ * column-name fallback. Both are indexed by BOTH snake_case and camelCase so
34
+ * they work regardless of CamelCasePlugin ordering in the plugin array.
35
+ *
36
+ * When two tables disagree on the kind for the same column name, the bare name
37
+ * is ambiguous (a joined/aliased query could carry either) and is dropped from
38
+ * the flat map rather than letting whichever table was processed last win. The
39
+ * qualified map still resolves it whenever the query names its tables.
40
+ */
41
+ function buildMaps(map) {
42
+ const qualified = {};
43
+ const flat = {};
44
+ const ambiguous = new Set();
45
+ const assignFlat = (key, kind) => {
46
+ const existing = flat[key];
47
+ if (existing !== undefined && existing !== kind) {
48
+ ambiguous.add(key);
49
+ return;
50
+ }
51
+ flat[key] = kind;
52
+ };
53
+ for (const [table, cols] of Object.entries(map)) {
54
+ for (const [col, kind] of Object.entries(cols)) {
55
+ const camel = snakeToCamel(col);
56
+ qualified[`${table}.${col}`] = kind;
57
+ qualified[`${table}.${camel}`] = kind;
58
+ assignFlat(col, kind);
59
+ assignFlat(camel, kind);
60
+ }
61
+ }
62
+ for (const key of ambiguous)
63
+ delete flat[key];
64
+ return { qualified, flat };
65
+ }
66
+ /**
67
+ * Collect every table named anywhere in the query's operation node, so a result
68
+ * column can be resolved against the tables the query actually touched instead
69
+ * of against every table in the schema.
70
+ */
71
+ function collectQueryTables(node, out) {
72
+ if (!node || typeof node !== 'object')
73
+ return;
74
+ const op = node;
75
+ if (op.kind === 'TableNode') {
76
+ const tableName = op.table?.identifier?.name;
77
+ if (typeof tableName === 'string' && tableName.length > 0)
78
+ out.add(tableName);
79
+ }
80
+ for (const value of Object.values(node)) {
81
+ if (Array.isArray(value)) {
82
+ for (const item of value)
83
+ collectQueryTables(item, out);
84
+ }
85
+ else {
86
+ collectQueryTables(value, out);
87
+ }
88
+ }
89
+ }
90
+ /**
91
+ * Resolve a result column's kind against the query's tables, falling back to
92
+ * the bare column name. Tables that disagree with each other are as ambiguous
93
+ * as two schema tables are, so they fall back too.
94
+ */
95
+ function lookupKind(maps, tables, col) {
96
+ let matchedKind;
97
+ for (const table of tables) {
98
+ const kind = maps.qualified[`${table}.${col}`];
99
+ if (!kind)
100
+ continue;
101
+ if (matchedKind && matchedKind !== kind)
102
+ return maps.flat[col];
103
+ matchedKind = kind;
104
+ }
105
+ return matchedKind ?? maps.flat[col];
106
+ }
107
+ /**
108
+ * Convert values stored in a dialect's on-disk representation back into the
109
+ * logical types app code expects (Date / boolean / parsed JSON).
110
+ *
111
+ * SQLite is what makes this necessary — it stores dates as TEXT, booleans as
112
+ * INTEGER and JSON as TEXT — but the plugin is dialect-neutral: on Postgres the
113
+ * driver already returns Date/boolean/object, and every branch of `fromDb`
114
+ * passes a non-string, non-number value straight through. That is why it lives
115
+ * in `@pikku/kysely` next to `SerializePlugin` rather than in a SQLite package:
116
+ * the CLI installs it on its local Postgres database too.
117
+ *
118
+ * Write-side coercion (Date → ISO string, boolean → 0/1, object → JSON) is
119
+ * handled in the SQLite database adapters (always-on), so this plugin is
120
+ * read-only.
121
+ *
122
+ * Place AFTER CamelCasePlugin in the plugin array (or it handles both
123
+ * orderings via the dual-keyed maps).
124
+ */
125
+ export function createCoercionPlugin(options) {
126
+ const maps = buildMaps(options.map);
127
+ const queryTables = new WeakMap();
128
+ return {
129
+ transformQuery(args) {
130
+ const tables = new Set();
131
+ collectQueryTables(args.node, tables);
132
+ queryTables.set(args.queryId, [...tables]);
133
+ return args.node;
134
+ },
135
+ async transformResult(args) {
136
+ const tables = queryTables.get(args.queryId) ?? [];
137
+ const out = [];
138
+ for (const row of args.result.rows) {
139
+ const next = { ...row };
140
+ for (const [col, val] of Object.entries(row)) {
141
+ const kind = lookupKind(maps, tables, col);
142
+ if (kind)
143
+ next[col] = fromDb(val, kind);
144
+ }
145
+ out.push(next);
146
+ }
147
+ return { ...args.result, rows: out };
148
+ },
149
+ };
150
+ }
@@ -1,4 +1,4 @@
1
- import type { AuditLog } from '@pikku/core';
1
+ import type { AuditLog } from '@pikku/core/services';
2
2
  import type { Kysely } from 'kysely';
3
3
  export interface CreateAuditedKyselyOptions {
4
4
  audit: AuditLog;
@@ -16,8 +16,9 @@ export { createAuditedKysely, type CreateAuditedKyselyOptions, } from './create-
16
16
  export { KyselyAuditService } from './kysely-audit-service.js';
17
17
  export { KyselyVirtualUserRunStore } from './kysely-virtual-user-run-store.js';
18
18
  export { SerializePlugin, BaseSerializePlugin, type Serializer, type Deserializer, } from './serialize-plugin.js';
19
+ export { createCoercionPlugin, type ColumnKind, type CoercionMap, type CreateCoercionPluginOptions, } from './coercion-plugin.js';
19
20
  export { auditSchema, pikkuSchemas, applyPikkuSchemas, compilePikkuSchemas, ensurePikkuSchema, type EnsureOutcome, resolveRequirements, type PikkuSchema, type RequiredTypes, type UnmetRequirement, type SchemaStatementFactory, } from './schema/index.js';
20
21
  export type { KyselyPikkuDB } from './kysely-tables.js';
21
- export type { WorkflowRunService } from '@pikku/core/ecosystem/workflow';
22
- export type { AgentRunService, AgentRunRow, } from '@pikku/core/ecosystem/agent';
23
- export type { VirtualUserRunStore, VirtualUserRunRecord, } from '@pikku/core/ecosystem/virtual-user';
22
+ export type { WorkflowRunService } from '@pikku/core/workflow';
23
+ export type { AgentRunService, AgentRunRow } from '@pikku/core/agent';
24
+ export type { VirtualUserRunStore, VirtualUserRunRecord, } from '@pikku/core/virtual-user';
package/dist/src/index.js CHANGED
@@ -16,4 +16,5 @@ export { createAuditedKysely, } from './create-audited-kysely.js';
16
16
  export { KyselyAuditService } from './kysely-audit-service.js';
17
17
  export { KyselyVirtualUserRunStore } from './kysely-virtual-user-run-store.js';
18
18
  export { SerializePlugin, BaseSerializePlugin, } from './serialize-plugin.js';
19
+ export { createCoercionPlugin, } from './coercion-plugin.js';
19
20
  export { auditSchema, pikkuSchemas, applyPikkuSchemas, compilePikkuSchemas, ensurePikkuSchema, resolveRequirements, } from './schema/index.js';
@@ -1,7 +1,7 @@
1
1
  import type { Kysely } from 'kysely';
2
2
  import type { KyselyPikkuDB } from './kysely-tables.js';
3
- import type { SaveScoreInput } from '@pikku/core/services';
4
3
  import type { AgentRunScore } from '@pikku/core/agent-scorer';
4
+ import type { SaveScoreInput } from '@pikku/core/services';
5
5
  /**
6
6
  * Shared by the two Kysely services that implement `AgentRunStateService` — they
7
7
  * differ in how they store approvals, not in how they store grades.
@@ -1,5 +1,4 @@
1
- import type { AgentThread, AgentMessage } from '@pikku/core/agent';
2
- import type { AgentRunRow, AgentRunService } from '@pikku/core/ecosystem/agent';
1
+ import type { AgentThread, AgentMessage, AgentRunRow, AgentRunService } from '@pikku/core/agent';
3
2
  import type { Kysely } from 'kysely';
4
3
  import type { KyselyPikkuDB } from './kysely-tables.js';
5
4
  export declare class KyselyAgentRunService implements AgentRunService {
@@ -1,9 +1,9 @@
1
1
  import type { Kysely } from 'kysely';
2
2
  import type { KyselyPikkuDB } from './kysely-tables.js';
3
- import type { AgentRunStateService, CreateRunInput, SaveScoreInput } from '@pikku/core/services';
4
3
  import type { AgentRunState } from '@pikku/core/agent';
5
- import type { PendingApproval } from '@pikku/core/ecosystem/agent';
6
4
  import type { AgentRunScore } from '@pikku/core/agent-scorer';
5
+ import type { AgentRunStateService, CreateRunInput, SaveScoreInput } from '@pikku/core/services';
6
+ import type { PendingApproval } from '@pikku/core/agent';
7
7
  export declare class KyselyAgentRunStateService implements AgentRunStateService {
8
8
  private db;
9
9
  private initialized;
@@ -1,6 +1,6 @@
1
- import type { AgentStorageService, AgentRunStateService, CreateRunInput, SaveScoreInput } from '@pikku/core/services';
2
- import type { AgentThread, AgentMessage, AgentRunState } from '@pikku/core/agent';
1
+ import type { AgentMessage, AgentRunState, AgentThread } from '@pikku/core/agent';
3
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
6
  export declare class KyselyAgentStorageService implements AgentStorageService, AgentRunStateService {
@@ -1,6 +1,6 @@
1
- import type { AuditService } from '@pikku/core';
2
- import type { AuditEvent, AuditEventBatch } from '@pikku/core/ecosystem/services';
3
- import type { AuditFacets, AuditQuery, AuditQueryResult } from '@pikku/core/ecosystem/types';
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';
4
4
  import type { Kysely } from 'kysely';
5
5
  /**
6
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
- import type { DeploymentService, DeploymentServiceConfig, DeploymentConfig } from '@pikku/core/ecosystem/services';
2
- import type { JWTService, SecretService } from '@pikku/core/services';
1
+ import type { DeploymentService, DeploymentServiceConfig, DeploymentConfig } 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,5 +1,5 @@
1
- import { buildRemoteHeaders } from '@pikku/core/ecosystem/remote';
2
- import { getAllFunctionNames } from '@pikku/core/ecosystem/function';
1
+ import { buildRemoteHeaders } from '@pikku/core/remote';
2
+ import { getAllFunctionNames } from '@pikku/core/function';
3
3
  import { ensurePikkuSchema } from './schema/index.js';
4
4
  import { deploymentSchema } from './schema/deployment.schema.js';
5
5
  export class KyselyDeploymentService {
@@ -1,4 +1,4 @@
1
- import { EventHubStore } from '@pikku/core/ecosystem/channel';
1
+ import { EventHubStore } from '@pikku/core/channel';
2
2
  import type { Kysely } from 'kysely';
3
3
  import type { KyselyPikkuDB } from './kysely-tables.js';
4
4
  export declare class KyselyEventHubStore extends EventHubStore {
@@ -1,4 +1,4 @@
1
- import { EventHubStore } from '@pikku/core/ecosystem/channel';
1
+ import { EventHubStore } from '@pikku/core/channel';
2
2
  export class KyselyEventHubStore extends EventHubStore {
3
3
  db;
4
4
  initialized = false;
@@ -1,7 +1,7 @@
1
1
  import type { ScopeService } from '@pikku/core/services';
2
- import type { Role } from '@pikku/core/ecosystem/services';
3
- import type { FlatScope } from '@pikku/core/ecosystem/scope';
4
- import type { SystemRole } from '@pikku/core/ecosystem/role';
2
+ import type { Role } from '@pikku/core/services';
3
+ import type { FlatScope } from '@pikku/core/scope';
4
+ import type { SystemRole } from '@pikku/core/role';
5
5
  import type { Kysely } from 'kysely';
6
6
  import type { KyselyPikkuDB } from './kysely-tables.js';
7
7
  /**
@@ -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 {
@@ -1,5 +1,5 @@
1
1
  import type { Generated } from 'kysely';
2
- import type { WorkflowStatus, StepStatus, WorkflowVersionStatus } from '@pikku/core/ecosystem/workflow';
2
+ import type { WorkflowStatus, StepStatus, WorkflowVersionStatus } from '@pikku/core/workflow';
3
3
  export interface ChannelsTable {
4
4
  channelId: string;
5
5
  channelName: string;
@@ -1,5 +1,5 @@
1
1
  import type { Kysely } from 'kysely';
2
- import type { VirtualUserRunOutcome, VirtualUserRunRecord, VirtualUserRunStart, VirtualUserRunStore } from '@pikku/core/ecosystem/virtual-user';
2
+ import type { VirtualUserRunOutcome, VirtualUserRunRecord, VirtualUserRunStart, VirtualUserRunStore } from '@pikku/core/virtual-user';
3
3
  import type { KyselyPikkuDB } from './kysely-tables.js';
4
4
  /**
5
5
  * Records virtual-user runs in a `virtualUserRun` table.
@@ -1,6 +1,6 @@
1
1
  import { QueueWebhookService } from '@pikku/core/services';
2
- import { type SendWebhookInput, type SendWebhookResult, type WebhookAttemptResult, type WebhookDeliveryRecord, type WebhookDeliveryWithAttempts } from '@pikku/core/ecosystem/services';
3
2
  import type { QueueService } from '@pikku/core/queue';
3
+ import { type SendWebhookInput, type SendWebhookResult, type WebhookAttemptResult, type WebhookDeliveryRecord, type WebhookDeliveryWithAttempts } from '@pikku/core/services';
4
4
  import type { Kysely } from 'kysely';
5
5
  import type { KyselyPikkuDB } from './kysely-tables.js';
6
6
  /**
@@ -1,5 +1,5 @@
1
1
  import { QueueWebhookService } from '@pikku/core/services';
2
- import { PIKKU_OUTGOING_WEBHOOK_QUEUE_NAME, } from '@pikku/core/ecosystem/services';
2
+ import { PIKKU_OUTGOING_WEBHOOK_QUEUE_NAME, } from '@pikku/core/services';
3
3
  import { ensurePikkuSchema } from './schema/index.js';
4
4
  import { webhookSchema } from './schema/webhook.schema.js';
5
5
  /**
@@ -1,5 +1,5 @@
1
- import type { SerializedError } from '@pikku/core/ecosystem/types';
2
- import type { StepState, WorkflowRunMirror, WorkflowRunWire, WorkflowStatus, WorkflowPlannedStep, WorkflowVersionStatus } from '@pikku/core/ecosystem/workflow';
1
+ import type { SerializedError } from '@pikku/core/errors';
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';
5
5
  /**
@@ -1,4 +1,4 @@
1
- import type { WorkflowRun, StepState, WorkflowRunService } from '@pikku/core/ecosystem/workflow';
1
+ import type { WorkflowRun, StepState, WorkflowRunService } from '@pikku/core/workflow';
2
2
  import type { Kysely } from 'kysely';
3
3
  import type { KyselyPikkuDB } from './kysely-tables.js';
4
4
  export declare class KyselyWorkflowRunService implements WorkflowRunService {
@@ -1,6 +1,6 @@
1
- import type { SerializedError } from '@pikku/core/ecosystem/types';
1
+ import type { SerializedError } from '@pikku/core/errors';
2
2
  import { PikkuWorkflowService } from '@pikku/core/workflow';
3
- import type { WorkflowPlannedStep, WorkflowQueueOptions, WorkflowRun, WorkflowRunWire, StepState, StepStatus, WorkflowStatus, WorkflowVersionStatus } from '@pikku/core/ecosystem/workflow';
3
+ import type { WorkflowPlannedStep, WorkflowQueueOptions, WorkflowRun, WorkflowRunWire, StepState, StepStatus, WorkflowStatus, WorkflowVersionStatus } from '@pikku/core/workflow';
4
4
  import { type Kysely } from 'kysely';
5
5
  import type { KyselyPikkuDB } from './kysely-tables.js';
6
6
  export declare class KyselyWorkflowService extends PikkuWorkflowService {
@@ -1 +1 @@
1
- {"root":["../src/create-audited-kysely.ts","../src/index.ts","../src/kysely-agent-run-scores.ts","../src/kysely-agent-run-service.ts","../src/kysely-agent-run-state-service.ts","../src/kysely-agent-storage-service.ts","../src/kysely-audit-service.ts","../src/kysely-channel-store.ts","../src/kysely-credential-service.ts","../src/kysely-deployment-service.ts","../src/kysely-eventhub-store.ts","../src/kysely-json.ts","../src/kysely-scope-service.ts","../src/kysely-secret-service.ts","../src/kysely-session-store.ts","../src/kysely-tables.ts","../src/kysely-virtual-user-run-store.ts","../src/kysely-webhook-service.ts","../src/kysely-workflow-mirror.ts","../src/kysely-workflow-run-service.ts","../src/kysely-workflow-service.ts","../src/serialize-plugin.ts","../src/schema/agent.schema.ts","../src/schema/audit.schema.ts","../src/schema/channel.schema.ts","../src/schema/credential.schema.ts","../src/schema/deployment.schema.ts","../src/schema/index.ts","../src/schema/pikku-schema.types.ts","../src/schema/scope.schema.ts","../src/schema/secret.schema.ts","../src/schema/session.schema.ts","../src/schema/virtual-user.schema.ts","../src/schema/webhook.schema.ts","../src/schema/workflow.schema.ts","../bin/pikku-kysely-pure.ts"],"version":"6.0.3"}
1
+ {"root":["../src/coercion-plugin.ts","../src/create-audited-kysely.ts","../src/index.ts","../src/kysely-agent-run-scores.ts","../src/kysely-agent-run-service.ts","../src/kysely-agent-run-state-service.ts","../src/kysely-agent-storage-service.ts","../src/kysely-audit-service.ts","../src/kysely-channel-store.ts","../src/kysely-credential-service.ts","../src/kysely-deployment-service.ts","../src/kysely-eventhub-store.ts","../src/kysely-json.ts","../src/kysely-scope-service.ts","../src/kysely-secret-service.ts","../src/kysely-session-store.ts","../src/kysely-tables.ts","../src/kysely-virtual-user-run-store.ts","../src/kysely-webhook-service.ts","../src/kysely-workflow-mirror.ts","../src/kysely-workflow-run-service.ts","../src/kysely-workflow-service.ts","../src/serialize-plugin.ts","../src/schema/agent.schema.ts","../src/schema/audit.schema.ts","../src/schema/channel.schema.ts","../src/schema/credential.schema.ts","../src/schema/deployment.schema.ts","../src/schema/index.ts","../src/schema/pikku-schema.types.ts","../src/schema/scope.schema.ts","../src/schema/secret.schema.ts","../src/schema/session.schema.ts","../src/schema/virtual-user.schema.ts","../src/schema/webhook.schema.ts","../src/schema/workflow.schema.ts","../bin/pikku-kysely-pure.ts"],"version":"6.0.3"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pikku/kysely",
3
- "version": "0.13.16",
3
+ "version": "0.13.18",
4
4
  "description": "Kysely-backed Pikku services — workflow state, secrets, sessions, scopes and audit",
5
5
  "author": "yasser.fadl@gmail.com",
6
6
  "license": "MIT",
@@ -21,20 +21,20 @@
21
21
  "prepublishOnly": "yarn build"
22
22
  },
23
23
  "peerDependencies": {
24
- "@pikku/core": "^0.12.84"
24
+ "@pikku/core": "^0.12.86"
25
25
  },
26
26
  "dependencies": {
27
- "kysely": "^0.29.0"
27
+ "kysely": "^0.29.5"
28
28
  },
29
29
  "devDependencies": {
30
- "@types/better-sqlite3": "^7.6.13",
31
- "better-sqlite3": "^12.10.0",
30
+ "@types/better-sqlite3": "^9.6.0",
31
+ "better-sqlite3": "^13.0.3",
32
32
  "kysely-codegen": "^0.20.0",
33
33
  "kysely-postgres-js": "^3.0.0",
34
- "postgres": "^3.4.8",
34
+ "postgres": "^3.4.9",
35
35
  "typescript": "^6.0.3"
36
36
  },
37
37
  "exports": {
38
38
  ".": "./dist/src/index.js"
39
39
  }
40
- }
40
+ }