@pikku/mongodb 0.12.17 → 0.12.19

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,181 @@
1
1
  # @pikku/mongodb
2
2
 
3
+ ## 0.12.19
4
+
5
+ ### Patch Changes
6
+
7
+ - 266e3bc: One door per name: `@pikku/core/ecosystem/*` and the package root are gone
8
+
9
+ `@pikku/core` published every module twice. `ecosystem/http` re-exported
10
+ `./http`, `ecosystem/services` re-exported `./services`, and a name was
11
+ reachable through either — so every addition had to be made in two places, and a
12
+ consumer's import said nothing about what it actually used. The package root was
13
+ the same problem at a larger scale: a single barrel of 206 names that no bundler
14
+ could take apart, and the one specifier that revealed nothing at all.
15
+
16
+ Both are deleted. Every name now lives on the subpath that owns it, and every
17
+ import carries that subpath — `@pikku/core/http`, `@pikku/core/services`,
18
+ `@pikku/core/errors`, `@pikku/core/types`.
19
+
20
+ Deleting the facades meant the raw subpaths had to become a superset of them,
21
+ which they were not: the facade tree had accumulated 25 names with no raw home
22
+ and about 26 more filed under a different area than the module they came from.
23
+ Those names moved to the area that owns them, and three areas were published as
24
+ new entry points rather than left on a root that is going away — `./types` (the
25
+ shared type surface, the largest single destination), `./state` and
26
+ `./classification`.
27
+
28
+ `./classification` is one door onto one subject: what a value is and how it must
29
+ be handled. Its three halves would each have been an entry point — the brands
30
+ and manifest types, the stored-form helpers (`hashToken`, `unsafeAsSealed` and
31
+ friends), and `SecretValue` — split by whether a name happens to be a type or a
32
+ value, which is the same defect as the facades. The duration and versioned-id
33
+ helpers went to `./utils`, which already published, and `PikkuRequest` went to
34
+ `./function`: it is the transport-agnostic request base, not an HTTP one — HTTP
35
+ has `PikkuHTTPAbstractRequest`, and the only thing outside core that extends
36
+ `PikkuRequest` is Azure's timer request.
37
+
38
+ `./types` inherited the root barrel's habit before it inherited its contents, so
39
+ the names with an owner elsewhere were moved off it. The middleware types and the
40
+ five middleware factories — `pikkuMiddleware`, `pikkuMiddlewareFactory`,
41
+ `pikkuChannelMiddleware`, `pikkuChannelMiddlewareFactory` and
42
+ `pikkuAgentMiddleware`, runtime values on a types entry point — are now
43
+ `@pikku/core/middleware`; the function meta types are `@pikku/core/function`;
44
+ `SerializedError` is `@pikku/core/errors`; and the generic TypeScript helpers
45
+ (`MakeRequired`, `PickRequired`, `PickOptional`, `RequireAtLeastOne`,
46
+ `JSONPrimitive`, `JSONValue`) are `@pikku/core/utils`. What is left on `./types`
47
+ is the vocabulary the wirings share, which no single module owns.
48
+
49
+ `pikku` was itself a root barrel — `export * from '@pikku/core'` — and
50
+ now exports only the services it bundles.
51
+
52
+ One module survives at the old specifier, and only for the bootstrap:
53
+ `packages/cli` is generated by the _published_ CLI pinned in its `build.sh`, and
54
+ that CLI still writes a bare `@pikku/core` into the files it generates for the
55
+ CLI itself. `bootstrap-compat/root.ts` carries the eight types it names, a test
56
+ in core fails if that list grows, and it goes when the pin moves to a CLI
57
+ released from this branch. The adapter names the pinned CLI reaches for —
58
+ `pikkuState` and `CreateWireServices` — are rewritten to `@pikku/core/state` and
59
+ `@pikku/core/types` by the same `build.sh` patch pass, so no second shim is
60
+ needed for them.
61
+
62
+ A guard test keeps the root shut: it parses imports and rejects a bare
63
+ `@pikku/core` rather than grepping for it, because several tests hold a user's
64
+ file as a template literal, where `import … from '@pikku/core'` is fixture text
65
+ rather than an import this repo makes.
66
+
67
+ An agent scaffold a project generated under an older CLI is refreshed rather
68
+ than left to fail: `pikku all` already deleted one importing an entry point
69
+ `@pikku/core` no longer publishes, and the `#pikku` hub joins that list.
70
+ Without it a project that scaffolds the agent endpoint but
71
+ declares no agents keeps the old file forever — the generator that would rewrite
72
+ it only runs when agents exist, and the file being present is what stops it
73
+ being regenerated as missing.
74
+
75
+ `pikku new addon` also wrote a tsconfig `paths` map naming only the deleted hub.
76
+ An addon's `imports` map points into `dist`, so `paths` is what resolves
77
+ `#pikku/<leaf>` for the addon's own source build — it now names the two leaf
78
+ patterns, in both the addon and its test harness.
79
+
80
+ - 786dae5: Bump every dependency whose latest release is a major across the monorepo, and
81
+ port the code the majors broke: `cookie` 2's `parseCookie`/`stringifySetCookie`
82
+ API in `@pikku/core` and the three runtime HTTP adapters, and assistant-ui 0.15's
83
+ store client in `@pikku/assistant-ui`.
84
+ - 6eef0a0: Bump every dependency to its latest compatible minor/patch across the monorepo.
85
+ - Updated dependencies [7722ceb]
86
+ - Updated dependencies [375c1ff]
87
+ - Updated dependencies [02a70cd]
88
+ - Updated dependencies [aeef159]
89
+ - Updated dependencies [a281de6]
90
+ - Updated dependencies [266e3bc]
91
+ - Updated dependencies [02a70cd]
92
+ - Updated dependencies [786dae5]
93
+ - Updated dependencies [6eef0a0]
94
+ - Updated dependencies [3561d67]
95
+ - Updated dependencies [a91c433]
96
+ - Updated dependencies [02a70cd]
97
+ - Updated dependencies [9537f74]
98
+ - Updated dependencies [2b57ca8]
99
+ - Updated dependencies [266e3bc]
100
+ - Updated dependencies [9fce0f1]
101
+ - Updated dependencies [83683a0]
102
+ - Updated dependencies [456c88b]
103
+ - Updated dependencies [456c88b]
104
+ - Updated dependencies [c127273]
105
+ - @pikku/core@0.12.85
106
+
107
+ ## 0.12.18
108
+
109
+ ### Patch Changes
110
+
111
+ - 7406bfe: Rename the agent runtime from `AI*` to `Agent*` (#596)
112
+
113
+ `AI` described the model provider, not the thing being named. Every symbol that
114
+ belongs to the agent runtime now says `Agent`; the symbols that genuinely wrap a
115
+ model provider — `AIEmbeddingService`, `AIProviderOptions`, `AIEmbedParams`,
116
+ `AITranscriptionParams`, `AIGenerateImageParams` and their siblings, and the
117
+ `@pikku/ai-vercel` / `@pikku/ai-deepinfra` / `@pikku/ai-voice` packages — keep
118
+ their names.
119
+
120
+ **Wiring**
121
+ - `pikkuAIAgent` → `pikkuAgent`, `pikkuAIScorer` → `pikkuAgentScorer`,
122
+ `pikkuAIJudge` → `pikkuAgentJudge`
123
+ - `CoreAIAgent` → `CoreAgent`, `AIAgentInput` → `AgentInput`, `AIAgentStep` →
124
+ `AgentStep`, `AIMessage` → `AgentMessage`, and the rest of the agent types
125
+ - `AIAgentRunnerService` → `AgentRunnerService`, `AIStorageService` →
126
+ `AgentStorageService`, `AIRunStateService` → `AgentRunStateService`
127
+
128
+ **Entry points**
129
+
130
+ `@pikku/core/agent` → `@pikku/core/agent`, `@pikku/core/agent-scorer` →
131
+ `@pikku/core/agent-scorer`.
132
+
133
+ **Queues**
134
+
135
+ The scorer queues are now `agent-score-fast` and `agent-score-slow`. Drain the
136
+ old `ai-score-fast` / `ai-score-slow` queues before deploying — jobs still
137
+ sitting on them when the new workers start will never be picked up.
138
+
139
+ **Scaffolds**
140
+
141
+ The agent scaffold pikku wrote for your project — `<scaffold>/agent/agent.gen.ts`
142
+ and its schemas file — imports `@pikku/core/ai-agent`, which no longer exists. A
143
+ scaffold is normally written once and then left alone, so `pikku all` would find
144
+ it present and leave the broken import in place. It now deletes an agent scaffold
145
+ importing either removed entry point and regenerates it in the same run. Anything
146
+ you added to that file goes with it, so move local edits out first.
147
+
148
+ **Database**
149
+
150
+ The agent tables are renamed: `ai_threads`, `ai_message`, `ai_tool_call`,
151
+ `ai_working_memory`, `ai_run` and `ai_run_score` become `agent_threads`,
152
+ `agent_message`, `agent_tool_call`, `agent_working_memory`, `agent_run` and
153
+ `agent_run_score`, along with their indexes and the `ai_working_memory_pk`
154
+ constraint. The same rename applies to the MongoDB collections.
155
+
156
+ `ensurePikkuSchema` creates tables it cannot find, so an existing database will
157
+ get empty `agent_*` tables and leave the old data stranded in `ai_*`. Rename
158
+ them before the first boot on the new version:
159
+
160
+ ```sql
161
+ ALTER TABLE ai_threads RENAME TO agent_threads;
162
+ ALTER TABLE ai_message RENAME TO agent_message;
163
+ ALTER TABLE ai_tool_call RENAME TO agent_tool_call;
164
+ ALTER TABLE ai_working_memory RENAME TO agent_working_memory;
165
+ ALTER TABLE ai_run RENAME TO agent_run;
166
+ ALTER TABLE ai_run_score RENAME TO agent_run_score;
167
+ ```
168
+
169
+ - 6794681: Publish the ecosystem surface as per-area sub-barrels under `@pikku/core/ecosystem/*`, and point generated code, the CLI, the inspector and the runtime adapters at them.
170
+
171
+ 348 names that only generated code, the toolchain or a runtime adapter ever imports now have a second home on `@pikku/core/ecosystem/<area>` — one sub-barrel per area, matching how core already publishes its entrypoints, so no single barrel grows without bound and a consumer only pulls in the area it uses.
172
+
173
+ This step is additive: every name is still exported from the entrypoint it was published from before, so nothing downstream breaks. Removing them from the app-facing barrels is a later change, and needs a release carrying `./ecosystem/*` first.
174
+
175
+ - Updated dependencies [7406bfe]
176
+ - Updated dependencies [6794681]
177
+ - @pikku/core@0.12.84
178
+
3
179
  ## 0.12.17
4
180
 
5
181
  ### Patch Changes
@@ -4,9 +4,9 @@ export { MongoDBEventHubStore } from './mongodb-eventhub-store.js';
4
4
  export { MongoDBWorkflowService } from './mongodb-workflow-service.js';
5
5
  export { MongoDBWorkflowRunService } from './mongodb-workflow-run-service.js';
6
6
  export { MongoDBDeploymentService } from './mongodb-deployment-service.js';
7
- export { MongoDBAIStorageService } from './mongodb-ai-storage-service.js';
7
+ export { MongoDBAgentStorageService } from './mongodb-agent-storage-service.js';
8
8
  export { MongoDBAgentRunService } from './mongodb-agent-run-service.js';
9
9
  export { MongoDBSecretService } from './mongodb-secret-service.js';
10
10
  export type { WorkflowRunService } from '@pikku/core/workflow';
11
- export type { AgentRunService, AgentRunRow } from '@pikku/core/ai-agent';
11
+ export type { AgentRunService, AgentRunRow } from '@pikku/core/agent';
12
12
  export { MongoDBSessionStore } from './mongodb-session-store.js';
package/dist/src/index.js CHANGED
@@ -4,7 +4,7 @@ export { MongoDBEventHubStore } from './mongodb-eventhub-store.js';
4
4
  export { MongoDBWorkflowService } from './mongodb-workflow-service.js';
5
5
  export { MongoDBWorkflowRunService } from './mongodb-workflow-run-service.js';
6
6
  export { MongoDBDeploymentService } from './mongodb-deployment-service.js';
7
- export { MongoDBAIStorageService } from './mongodb-ai-storage-service.js';
7
+ export { MongoDBAgentStorageService } from './mongodb-agent-storage-service.js';
8
8
  export { MongoDBAgentRunService } from './mongodb-agent-run-service.js';
9
9
  export { MongoDBSecretService } from './mongodb-secret-service.js';
10
10
  export { MongoDBSessionStore } from './mongodb-session-store.js';
@@ -1,4 +1,4 @@
1
- import type { AIThread, AIMessage, AgentRunRow, AgentRunService } from '@pikku/core/ai-agent';
1
+ import type { AgentThread, AgentMessage, AgentRunRow, AgentRunService } from '@pikku/core/agent';
2
2
  import type { Db } from 'mongodb';
3
3
  export declare class MongoDBAgentRunService implements AgentRunService {
4
4
  private threads;
@@ -12,9 +12,9 @@ export declare class MongoDBAgentRunService implements AgentRunService {
12
12
  owners?: string[];
13
13
  limit?: number;
14
14
  offset?: number;
15
- }): Promise<AIThread[]>;
16
- getThread(threadId: string): Promise<AIThread | null>;
17
- getThreadMessages(threadId: string): Promise<AIMessage[]>;
15
+ }): Promise<AgentThread[]>;
16
+ getThread(threadId: string): Promise<AgentThread | null>;
17
+ getThreadMessages(threadId: string): Promise<AgentMessage[]>;
18
18
  getThreadRuns(threadId: string): Promise<AgentRunRow[]>;
19
19
  deleteThread(threadId: string): Promise<boolean>;
20
20
  getDistinctAgentNames(): Promise<string[]>;
@@ -7,10 +7,10 @@ export class MongoDBAgentRunService {
7
7
  toolCalls;
8
8
  runs;
9
9
  constructor(db) {
10
- this.threads = db.collection('ai_threads');
11
- this.messages = db.collection('ai_message');
12
- this.toolCalls = db.collection('ai_tool_call');
13
- this.runs = db.collection('ai_run');
10
+ this.threads = db.collection('agent_threads');
11
+ this.messages = db.collection('agent_message');
12
+ this.toolCalls = db.collection('agent_tool_call');
13
+ this.runs = db.collection('agent_run');
14
14
  }
15
15
  async listThreads(options) {
16
16
  const { agentName, resourceId, owners, limit = 50, offset = 0, } = options ?? {};
@@ -1,31 +1,31 @@
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 { Db } from 'mongodb';
5
- export declare class MongoDBAIStorageService implements AIStorageService, AIRunStateService {
5
+ export declare class MongoDBAgentStorageService implements AgentStorageService, AgentRunStateService {
6
6
  private db;
7
7
  private initialized;
8
8
  private threads;
9
- private aiMessages;
9
+ private agentMessages;
10
10
  private toolCalls;
11
11
  private workingMemory;
12
- private aiRuns;
13
- private aiRunScores;
12
+ private agentRuns;
13
+ private agentRunScores;
14
14
  constructor(db: Db);
15
15
  init(): Promise<void>;
16
16
  createThread(resourceId: string, options?: {
17
17
  threadId?: string;
18
18
  title?: string;
19
19
  metadata?: Record<string, unknown>;
20
- }): Promise<AIThread>;
21
- getThread(threadId: string): Promise<AIThread>;
22
- getThreads(resourceId: string): Promise<AIThread[]>;
20
+ }): Promise<AgentThread>;
21
+ getThread(threadId: string): Promise<AgentThread>;
22
+ getThreads(resourceId: string): Promise<AgentThread[]>;
23
23
  deleteThread(threadId: string): Promise<void>;
24
24
  getMessages(threadId: string, options?: {
25
25
  lastN?: number;
26
26
  cursor?: string;
27
- }): Promise<AIMessage[]>;
28
- saveMessages(threadId: string, messages: AIMessage[]): Promise<void>;
27
+ }): Promise<AgentMessage[]>;
28
+ saveMessages(threadId: string, messages: AgentMessage[]): Promise<void>;
29
29
  getWorkingMemory(id: string, scope: 'resource' | 'thread'): Promise<Record<string, unknown> | null>;
30
30
  saveWorkingMemory(id: string, scope: 'resource' | 'thread', data: Record<string, unknown>): Promise<void>;
31
31
  createRun(run: CreateRunInput): Promise<string>;
@@ -40,6 +40,6 @@ export declare class MongoDBAIStorageService implements AIStorageService, AIRunS
40
40
  } | null>;
41
41
  resolveApproval(toolCallId: string, status: 'approved' | 'denied'): Promise<boolean>;
42
42
  saveScore(score: SaveScoreInput): Promise<void>;
43
- getScores(runId: string): Promise<AIRunScore[]>;
43
+ getScores(runId: string): Promise<AgentRunScore[]>;
44
44
  close(): Promise<void>;
45
45
  }
@@ -1,32 +1,32 @@
1
- export class MongoDBAIStorageService {
1
+ export class MongoDBAgentStorageService {
2
2
  db;
3
3
  initialized = false;
4
4
  threads;
5
- aiMessages;
5
+ agentMessages;
6
6
  toolCalls;
7
7
  workingMemory;
8
- aiRuns;
9
- aiRunScores;
8
+ agentRuns;
9
+ agentRunScores;
10
10
  constructor(db) {
11
11
  this.db = db;
12
12
  }
13
13
  async init() {
14
14
  if (this.initialized)
15
15
  return;
16
- this.threads = this.db.collection('ai_threads');
17
- this.aiMessages = this.db.collection('ai_message');
18
- this.toolCalls = this.db.collection('ai_tool_call');
19
- this.workingMemory =
20
- this.db.collection('ai_working_memory');
21
- this.aiRuns = this.db.collection('ai_run');
22
- this.aiRunScores = this.db.collection('ai_run_score');
16
+ this.threads = this.db.collection('agent_threads');
17
+ this.agentMessages = this.db.collection('agent_message');
18
+ this.toolCalls = this.db.collection('agent_tool_call');
19
+ this.workingMemory = this.db.collection('agent_working_memory');
20
+ this.agentRuns = this.db.collection('agent_run');
21
+ this.agentRunScores =
22
+ this.db.collection('agent_run_score');
23
23
  await this.threads.createIndex({ resourceId: 1 });
24
- await this.aiMessages.createIndex({ threadId: 1, createdAt: 1 });
24
+ await this.agentMessages.createIndex({ threadId: 1, createdAt: 1 });
25
25
  await this.toolCalls.createIndex({ threadId: 1 });
26
26
  await this.toolCalls.createIndex({ messageId: 1 });
27
27
  await this.workingMemory.createIndex({ id: 1, scope: 1 }, { unique: true });
28
- await this.aiRuns.createIndex({ threadId: 1, createdAt: 1 });
29
- await this.aiRunScores.createIndex({ runId: 1, createdAt: 1 });
28
+ await this.agentRuns.createIndex({ threadId: 1, createdAt: 1 });
29
+ await this.agentRunScores.createIndex({ runId: 1, createdAt: 1 });
30
30
  this.initialized = true;
31
31
  }
32
32
  async createThread(resourceId, options) {
@@ -79,21 +79,23 @@ export class MongoDBAIStorageService {
79
79
  }
80
80
  async deleteThread(threadId) {
81
81
  await this.toolCalls.deleteMany({ threadId });
82
- await this.aiMessages.deleteMany({ threadId });
83
- await this.aiRuns.deleteMany({ threadId });
82
+ await this.agentMessages.deleteMany({ threadId });
83
+ await this.agentRuns.deleteMany({ threadId });
84
84
  await this.threads.deleteOne({ _id: threadId });
85
85
  }
86
86
  async getMessages(threadId, options) {
87
87
  let filter = { threadId };
88
88
  if (options?.cursor) {
89
- const cursorRow = await this.aiMessages.findOne({ _id: options.cursor });
89
+ const cursorRow = await this.agentMessages.findOne({
90
+ _id: options.cursor,
91
+ });
90
92
  if (cursorRow) {
91
93
  filter.createdAt = { $lt: cursorRow.createdAt };
92
94
  }
93
95
  }
94
96
  let msgResult;
95
97
  if (options?.cursor || options?.lastN) {
96
- const innerResult = await this.aiMessages
98
+ const innerResult = await this.agentMessages
97
99
  .find(filter)
98
100
  .sort({ createdAt: -1 })
99
101
  .limit(options?.lastN ?? 50)
@@ -102,7 +104,7 @@ export class MongoDBAIStorageService {
102
104
  msgResult = innerResult;
103
105
  }
104
106
  else {
105
- msgResult = await this.aiMessages
107
+ msgResult = await this.agentMessages
106
108
  .find(filter)
107
109
  .sort({ createdAt: 1 })
108
110
  .toArray();
@@ -174,7 +176,7 @@ export class MongoDBAIStorageService {
174
176
  const toolMessages = messages.filter((m) => m.role === 'tool');
175
177
  const nonToolMessages = messages.filter((m) => m.role !== 'tool');
176
178
  if (nonToolMessages.length > 0) {
177
- await this.aiMessages.insertMany(nonToolMessages.map((msg) => ({
179
+ await this.agentMessages.insertMany(nonToolMessages.map((msg) => ({
178
180
  _id: msg.id,
179
181
  threadId,
180
182
  role: msg.role,
@@ -229,7 +231,7 @@ export class MongoDBAIStorageService {
229
231
  }
230
232
  async createRun(run) {
231
233
  const runId = crypto.randomUUID();
232
- await this.aiRuns.insertOne({
234
+ await this.agentRuns.insertOne({
233
235
  _id: runId,
234
236
  agentName: run.agentName,
235
237
  threadId: run.threadId,
@@ -268,7 +270,7 @@ export class MongoDBAIStorageService {
268
270
  setValues.usageOutputTokens = updates.usage.outputTokens;
269
271
  setValues.usageModel = updates.usage.model;
270
272
  }
271
- await this.aiRuns.updateOne({ _id: runId }, { $set: setValues });
273
+ await this.agentRuns.updateOne({ _id: runId }, { $set: setValues });
272
274
  if (updates.pendingApprovals !== undefined) {
273
275
  await this.toolCalls.updateMany({ runId, approvalStatus: { $ne: null } }, {
274
276
  $set: {
@@ -286,7 +288,7 @@ export class MongoDBAIStorageService {
286
288
  }
287
289
  }
288
290
  async getRun(runId) {
289
- const row = await this.aiRuns.findOne({ _id: runId });
291
+ const row = await this.agentRuns.findOne({ _id: runId });
290
292
  if (!row)
291
293
  return null;
292
294
  const approvals = await this.toolCalls
@@ -295,7 +297,7 @@ export class MongoDBAIStorageService {
295
297
  return this.mapRunRow(row, approvals);
296
298
  }
297
299
  async getRunsByThread(threadId) {
298
- const result = await this.aiRuns
300
+ const result = await this.agentRuns
299
301
  .find({ threadId })
300
302
  .sort({ createdAt: -1 })
301
303
  .toArray();
@@ -410,7 +412,7 @@ export class MongoDBAIStorageService {
410
412
  return result.modifiedCount > 0;
411
413
  }
412
414
  async saveScore(score) {
413
- await this.aiRunScores.insertOne({
415
+ await this.agentRunScores.insertOne({
414
416
  _id: crypto.randomUUID(),
415
417
  runId: score.runId,
416
418
  scorerName: score.scorerName,
@@ -421,7 +423,7 @@ export class MongoDBAIStorageService {
421
423
  });
422
424
  }
423
425
  async getScores(runId) {
424
- const rows = await this.aiRunScores
426
+ const rows = await this.agentRunScores
425
427
  .find({ runId })
426
428
  .sort({ createdAt: 1 })
427
429
  .toArray();
@@ -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 { Db } from 'mongodb';
4
4
  export declare class MongoDBChannelStore extends ChannelStore {
5
5
  private db;
@@ -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 { Db } from 'mongodb';
4
5
  export declare class MongoDBDeploymentService implements DeploymentService {
5
6
  private db;
@@ -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 { Db } from 'mongodb';
4
4
  export interface MongoDBSecretServiceConfig {
5
5
  key: string;
@@ -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
  export class MongoDBSecretService {
4
4
  db;
5
5
  initialized = false;
@@ -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 { Db } from 'mongodb';
4
4
  export declare class MongoDBSessionStore implements SessionStore {
5
5
  private db;
@@ -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 { Db } from 'mongodb';
4
5
  export declare class MongoDBWorkflowService extends PikkuWorkflowService {
5
6
  private initialized;
@@ -1,4 +1,4 @@
1
- import { PikkuWorkflowService, } from '@pikku/core/workflow';
1
+ import { PikkuWorkflowService } from '@pikku/core/workflow';
2
2
  import { MongoDBWorkflowRunService } from './mongodb-workflow-run-service.js';
3
3
  export class MongoDBWorkflowService extends PikkuWorkflowService {
4
4
  initialized = false;
@@ -1 +1 @@
1
- {"root":["../src/index.ts","../src/mongodb-agent-run-service.ts","../src/mongodb-ai-storage-service.ts","../src/mongodb-channel-store.ts","../src/mongodb-deployment-service.ts","../src/mongodb-eventhub-store.ts","../src/mongodb-secret-service.ts","../src/mongodb-session-store.ts","../src/mongodb-workflow-run-service.ts","../src/mongodb-workflow-service.ts","../src/pikku-mongodb.ts"],"version":"6.0.3"}
1
+ {"root":["../src/index.ts","../src/mongodb-agent-run-service.ts","../src/mongodb-agent-storage-service.ts","../src/mongodb-channel-store.ts","../src/mongodb-deployment-service.ts","../src/mongodb-eventhub-store.ts","../src/mongodb-secret-service.ts","../src/mongodb-session-store.ts","../src/mongodb-workflow-run-service.ts","../src/mongodb-workflow-service.ts","../src/pikku-mongodb.ts"],"version":"6.0.3"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pikku/mongodb",
3
- "version": "0.12.17",
3
+ "version": "0.12.19",
4
4
  "description": "MongoDB services for Pikku — workflow state, agent runs, secrets and channel stores",
5
5
  "author": "yasser.fadl@gmail.com",
6
6
  "license": "MIT",
@@ -18,17 +18,17 @@
18
18
  "prepublishOnly": "yarn build"
19
19
  },
20
20
  "peerDependencies": {
21
- "@pikku/core": "^0.12.82"
21
+ "@pikku/core": "^0.12.85"
22
22
  },
23
23
  "dependencies": {
24
- "mongodb": "^6.12.0"
24
+ "mongodb": "^7.5.0"
25
25
  },
26
26
  "devDependencies": {
27
- "mongodb": "^6.12.0",
28
- "mongodb-memory-server": "^10.4.0",
27
+ "mongodb": "^7.5.0",
28
+ "mongodb-memory-server": "^11.2.0",
29
29
  "typescript": "^6.0.3"
30
30
  },
31
31
  "exports": {
32
32
  ".": "./dist/src/index.js"
33
33
  }
34
- }
34
+ }
package/src/index.ts CHANGED
@@ -5,10 +5,10 @@ export { MongoDBEventHubStore } from './mongodb-eventhub-store.js'
5
5
  export { MongoDBWorkflowService } from './mongodb-workflow-service.js'
6
6
  export { MongoDBWorkflowRunService } from './mongodb-workflow-run-service.js'
7
7
  export { MongoDBDeploymentService } from './mongodb-deployment-service.js'
8
- export { MongoDBAIStorageService } from './mongodb-ai-storage-service.js'
8
+ export { MongoDBAgentStorageService } from './mongodb-agent-storage-service.js'
9
9
  export { MongoDBAgentRunService } from './mongodb-agent-run-service.js'
10
10
  export { MongoDBSecretService } from './mongodb-secret-service.js'
11
11
 
12
12
  export type { WorkflowRunService } from '@pikku/core/workflow'
13
- export type { AgentRunService, AgentRunRow } from '@pikku/core/ai-agent'
13
+ export type { AgentRunService, AgentRunRow } from '@pikku/core/agent'
14
14
  export { MongoDBSessionStore } from './mongodb-session-store.js'
@@ -1,9 +1,9 @@
1
1
  import type {
2
- AIThread,
3
- AIMessage,
2
+ AgentThread,
3
+ AgentMessage,
4
4
  AgentRunRow,
5
5
  AgentRunService,
6
- } from '@pikku/core/ai-agent'
6
+ } from '@pikku/core/agent'
7
7
  import type { Db, Collection } from 'mongodb'
8
8
 
9
9
  // Owner ids are untrusted input to the regex, so metacharacters must not be
@@ -11,7 +11,7 @@ import type { Db, Collection } from 'mongodb'
11
11
  const escapeRegExp = (value: string) =>
12
12
  value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
13
13
 
14
- interface AIThreadDoc {
14
+ interface AgentThreadDoc {
15
15
  _id: string
16
16
  resourceId: string
17
17
  title: string | null
@@ -20,7 +20,7 @@ interface AIThreadDoc {
20
20
  updatedAt: Date
21
21
  }
22
22
 
23
- interface AIMessageDoc {
23
+ interface AgentMessageDoc {
24
24
  _id: string
25
25
  threadId: string
26
26
  role: string
@@ -28,7 +28,7 @@ interface AIMessageDoc {
28
28
  createdAt: Date
29
29
  }
30
30
 
31
- interface AIToolCallDoc {
31
+ interface AgentToolCallDoc {
32
32
  _id: string
33
33
  threadId: string
34
34
  messageId: string
@@ -44,7 +44,7 @@ interface AIToolCallDoc {
44
44
  createdAt: Date
45
45
  }
46
46
 
47
- interface AIRunDoc {
47
+ interface AgentRunDoc {
48
48
  _id: string
49
49
  agentName: string
50
50
  threadId: string
@@ -61,16 +61,16 @@ interface AIRunDoc {
61
61
  }
62
62
 
63
63
  export class MongoDBAgentRunService implements AgentRunService {
64
- private threads: Collection<AIThreadDoc>
65
- private messages: Collection<AIMessageDoc>
66
- private toolCalls: Collection<AIToolCallDoc>
67
- private runs: Collection<AIRunDoc>
64
+ private threads: Collection<AgentThreadDoc>
65
+ private messages: Collection<AgentMessageDoc>
66
+ private toolCalls: Collection<AgentToolCallDoc>
67
+ private runs: Collection<AgentRunDoc>
68
68
 
69
69
  constructor(db: Db) {
70
- this.threads = db.collection<AIThreadDoc>('ai_threads')
71
- this.messages = db.collection<AIMessageDoc>('ai_message')
72
- this.toolCalls = db.collection<AIToolCallDoc>('ai_tool_call')
73
- this.runs = db.collection<AIRunDoc>('ai_run')
70
+ this.threads = db.collection<AgentThreadDoc>('agent_threads')
71
+ this.messages = db.collection<AgentMessageDoc>('agent_message')
72
+ this.toolCalls = db.collection<AgentToolCallDoc>('agent_tool_call')
73
+ this.runs = db.collection<AgentRunDoc>('agent_run')
74
74
  }
75
75
 
76
76
  async listThreads(options?: {
@@ -79,7 +79,7 @@ export class MongoDBAgentRunService implements AgentRunService {
79
79
  owners?: string[]
80
80
  limit?: number
81
81
  offset?: number
82
- }): Promise<AIThread[]> {
82
+ }): Promise<AgentThread[]> {
83
83
  const {
84
84
  agentName,
85
85
  resourceId,
@@ -122,13 +122,13 @@ export class MongoDBAgentRunService implements AgentRunService {
122
122
  return result.map((row) => this.mapThreadRow(row))
123
123
  }
124
124
 
125
- async getThread(threadId: string): Promise<AIThread | null> {
125
+ async getThread(threadId: string): Promise<AgentThread | null> {
126
126
  const row = await this.threads.findOne({ _id: threadId })
127
127
  if (!row) return null
128
128
  return this.mapThreadRow(row)
129
129
  }
130
130
 
131
- async getThreadMessages(threadId: string): Promise<AIMessage[]> {
131
+ async getThreadMessages(threadId: string): Promise<AgentMessage[]> {
132
132
  const [msgResult, tcResult] = await Promise.all([
133
133
  this.messages.find({ threadId }).sort({ createdAt: 1 }).toArray(),
134
134
  this.toolCalls.find({ threadId }).sort({ createdAt: 1 }).toArray(),
@@ -141,11 +141,11 @@ export class MongoDBAgentRunService implements AgentRunService {
141
141
  tcByMessage.get(msgId)!.push(tc)
142
142
  }
143
143
 
144
- const messages: AIMessage[] = []
144
+ const messages: AgentMessage[] = []
145
145
  for (const row of msgResult) {
146
- const msg: AIMessage = {
146
+ const msg: AgentMessage = {
147
147
  id: row._id,
148
- role: row.role as AIMessage['role'],
148
+ role: row.role as AgentMessage['role'],
149
149
  content: row.content ?? undefined,
150
150
  createdAt: new Date(row.createdAt),
151
151
  }
@@ -203,7 +203,7 @@ export class MongoDBAgentRunService implements AgentRunService {
203
203
  return result.sort()
204
204
  }
205
205
 
206
- private mapThreadRow(row: AIThreadDoc): AIThread {
206
+ private mapThreadRow(row: AgentThreadDoc): AgentThread {
207
207
  return {
208
208
  id: row._id,
209
209
  resourceId: row.resourceId,
@@ -214,7 +214,7 @@ export class MongoDBAgentRunService implements AgentRunService {
214
214
  }
215
215
  }
216
216
 
217
- private mapRunRow(row: AIRunDoc): AgentRunRow {
217
+ private mapRunRow(row: AgentRunDoc): AgentRunRow {
218
218
  return {
219
219
  runId: row._id,
220
220
  agentName: row.agentName,
@@ -1,14 +1,18 @@
1
1
  import type {
2
- AIStorageService,
3
- AIRunStateService,
2
+ AgentMessage,
3
+ AgentRunState,
4
+ AgentThread,
5
+ } from '@pikku/core/agent'
6
+ import type { AgentRunScore } from '@pikku/core/agent-scorer'
7
+ import type {
8
+ AgentRunStateService,
9
+ AgentStorageService,
4
10
  CreateRunInput,
5
11
  SaveScoreInput,
6
12
  } from '@pikku/core/services'
7
- import type { AIThread, AIMessage, AgentRunState } from '@pikku/core/ai-agent'
8
- import type { AIRunScore } from '@pikku/core/ai-scorer'
9
13
  import type { Db, Collection } from 'mongodb'
10
14
 
11
- interface AIThreadDoc {
15
+ interface AgentThreadDoc {
12
16
  _id: string
13
17
  resourceId: string
14
18
  title: string | null
@@ -17,7 +21,7 @@ interface AIThreadDoc {
17
21
  updatedAt: Date
18
22
  }
19
23
 
20
- interface AIMessageDoc {
24
+ interface AgentMessageDoc {
21
25
  _id: string
22
26
  threadId: string
23
27
  role: string
@@ -25,7 +29,7 @@ interface AIMessageDoc {
25
29
  createdAt: Date
26
30
  }
27
31
 
28
- interface AIToolCallDoc {
32
+ interface AgentToolCallDoc {
29
33
  _id: string
30
34
  threadId: string
31
35
  messageId: string
@@ -41,14 +45,14 @@ interface AIToolCallDoc {
41
45
  createdAt: Date
42
46
  }
43
47
 
44
- interface AIWorkingMemoryDoc {
48
+ interface AgentWorkingMemoryDoc {
45
49
  id: string
46
50
  scope: string
47
51
  data: any
48
52
  updatedAt: Date
49
53
  }
50
54
 
51
- interface AIRunScoreDoc {
55
+ interface AgentRunScoreDoc {
52
56
  _id: string
53
57
  runId: string
54
58
  scorerName: string
@@ -58,7 +62,7 @@ interface AIRunScoreDoc {
58
62
  createdAt: Date
59
63
  }
60
64
 
61
- interface AIRunDoc {
65
+ interface AgentRunDoc {
62
66
  _id: string
63
67
  agentName: string
64
68
  threadId: string
@@ -74,42 +78,44 @@ interface AIRunDoc {
74
78
  updatedAt: Date
75
79
  }
76
80
 
77
- export class MongoDBAIStorageService
78
- implements AIStorageService, AIRunStateService
81
+ export class MongoDBAgentStorageService
82
+ implements AgentStorageService, AgentRunStateService
79
83
  {
80
84
  private initialized = false
81
- private threads!: Collection<AIThreadDoc>
82
- private aiMessages!: Collection<AIMessageDoc>
83
- private toolCalls!: Collection<AIToolCallDoc>
84
- private workingMemory!: Collection<AIWorkingMemoryDoc>
85
- private aiRuns!: Collection<AIRunDoc>
86
- private aiRunScores!: Collection<AIRunScoreDoc>
85
+ private threads!: Collection<AgentThreadDoc>
86
+ private agentMessages!: Collection<AgentMessageDoc>
87
+ private toolCalls!: Collection<AgentToolCallDoc>
88
+ private workingMemory!: Collection<AgentWorkingMemoryDoc>
89
+ private agentRuns!: Collection<AgentRunDoc>
90
+ private agentRunScores!: Collection<AgentRunScoreDoc>
87
91
 
88
92
  constructor(private db: Db) {}
89
93
 
90
94
  public async init(): Promise<void> {
91
95
  if (this.initialized) return
92
96
 
93
- this.threads = this.db.collection<AIThreadDoc>('ai_threads')
94
- this.aiMessages = this.db.collection<AIMessageDoc>('ai_message')
95
- this.toolCalls = this.db.collection<AIToolCallDoc>('ai_tool_call')
96
- this.workingMemory =
97
- this.db.collection<AIWorkingMemoryDoc>('ai_working_memory')
98
- this.aiRuns = this.db.collection<AIRunDoc>('ai_run')
99
- this.aiRunScores = this.db.collection<AIRunScoreDoc>('ai_run_score')
97
+ this.threads = this.db.collection<AgentThreadDoc>('agent_threads')
98
+ this.agentMessages = this.db.collection<AgentMessageDoc>('agent_message')
99
+ this.toolCalls = this.db.collection<AgentToolCallDoc>('agent_tool_call')
100
+ this.workingMemory = this.db.collection<AgentWorkingMemoryDoc>(
101
+ 'agent_working_memory'
102
+ )
103
+ this.agentRuns = this.db.collection<AgentRunDoc>('agent_run')
104
+ this.agentRunScores =
105
+ this.db.collection<AgentRunScoreDoc>('agent_run_score')
100
106
 
101
107
  await this.threads.createIndex({ resourceId: 1 })
102
108
 
103
- await this.aiMessages.createIndex({ threadId: 1, createdAt: 1 })
109
+ await this.agentMessages.createIndex({ threadId: 1, createdAt: 1 })
104
110
 
105
111
  await this.toolCalls.createIndex({ threadId: 1 })
106
112
  await this.toolCalls.createIndex({ messageId: 1 })
107
113
 
108
114
  await this.workingMemory.createIndex({ id: 1, scope: 1 }, { unique: true })
109
115
 
110
- await this.aiRuns.createIndex({ threadId: 1, createdAt: 1 })
116
+ await this.agentRuns.createIndex({ threadId: 1, createdAt: 1 })
111
117
 
112
- await this.aiRunScores.createIndex({ runId: 1, createdAt: 1 })
118
+ await this.agentRunScores.createIndex({ runId: 1, createdAt: 1 })
113
119
 
114
120
  this.initialized = true
115
121
  }
@@ -121,7 +127,7 @@ export class MongoDBAIStorageService
121
127
  title?: string
122
128
  metadata?: Record<string, unknown>
123
129
  }
124
- ): Promise<AIThread> {
130
+ ): Promise<AgentThread> {
125
131
  const id = options?.threadId ?? crypto.randomUUID()
126
132
  const now = new Date()
127
133
 
@@ -144,7 +150,7 @@ export class MongoDBAIStorageService
144
150
  }
145
151
  }
146
152
 
147
- async getThread(threadId: string): Promise<AIThread> {
153
+ async getThread(threadId: string): Promise<AgentThread> {
148
154
  const row = await this.threads.findOne({ _id: threadId })
149
155
 
150
156
  if (!row) {
@@ -161,7 +167,7 @@ export class MongoDBAIStorageService
161
167
  }
162
168
  }
163
169
 
164
- async getThreads(resourceId: string): Promise<AIThread[]> {
170
+ async getThreads(resourceId: string): Promise<AgentThread[]> {
165
171
  const result = await this.threads
166
172
  .find({ resourceId })
167
173
  .sort({ updatedAt: -1 })
@@ -179,19 +185,21 @@ export class MongoDBAIStorageService
179
185
 
180
186
  async deleteThread(threadId: string): Promise<void> {
181
187
  await this.toolCalls.deleteMany({ threadId })
182
- await this.aiMessages.deleteMany({ threadId })
183
- await this.aiRuns.deleteMany({ threadId })
188
+ await this.agentMessages.deleteMany({ threadId })
189
+ await this.agentRuns.deleteMany({ threadId })
184
190
  await this.threads.deleteOne({ _id: threadId })
185
191
  }
186
192
 
187
193
  async getMessages(
188
194
  threadId: string,
189
195
  options?: { lastN?: number; cursor?: string }
190
- ): Promise<AIMessage[]> {
196
+ ): Promise<AgentMessage[]> {
191
197
  let filter: Record<string, any> = { threadId }
192
198
 
193
199
  if (options?.cursor) {
194
- const cursorRow = await this.aiMessages.findOne({ _id: options.cursor })
200
+ const cursorRow = await this.agentMessages.findOne({
201
+ _id: options.cursor,
202
+ })
195
203
  if (cursorRow) {
196
204
  filter.createdAt = { $lt: cursorRow.createdAt }
197
205
  }
@@ -199,7 +207,7 @@ export class MongoDBAIStorageService
199
207
 
200
208
  let msgResult
201
209
  if (options?.cursor || options?.lastN) {
202
- const innerResult = await this.aiMessages
210
+ const innerResult = await this.agentMessages
203
211
  .find(filter)
204
212
  .sort({ createdAt: -1 })
205
213
  .limit(options?.lastN ?? 50)
@@ -207,7 +215,7 @@ export class MongoDBAIStorageService
207
215
  innerResult.reverse()
208
216
  msgResult = innerResult
209
217
  } else {
210
- msgResult = await this.aiMessages
218
+ msgResult = await this.agentMessages
211
219
  .find(filter)
212
220
  .sort({ createdAt: 1 })
213
221
  .toArray()
@@ -225,9 +233,9 @@ export class MongoDBAIStorageService
225
233
  tcByMessage.get(msgId)!.push(tc)
226
234
  }
227
235
 
228
- const messages: AIMessage[] = []
236
+ const messages: AgentMessage[] = []
229
237
  for (const row of msgResult) {
230
- let parsedContent: AIMessage['content'] = row.content ?? undefined
238
+ let parsedContent: AgentMessage['content'] = row.content ?? undefined
231
239
  if (typeof row.content === 'string') {
232
240
  try {
233
241
  const parsed = JSON.parse(row.content)
@@ -241,9 +249,9 @@ export class MongoDBAIStorageService
241
249
  }
242
250
  }
243
251
 
244
- const msg: AIMessage = {
252
+ const msg: AgentMessage = {
245
253
  id: row._id,
246
- role: row.role as AIMessage['role'],
254
+ role: row.role as AgentMessage['role'],
247
255
  content: parsedContent,
248
256
  createdAt: new Date(row.createdAt),
249
257
  }
@@ -279,14 +287,17 @@ export class MongoDBAIStorageService
279
287
  return messages
280
288
  }
281
289
 
282
- async saveMessages(threadId: string, messages: AIMessage[]): Promise<void> {
290
+ async saveMessages(
291
+ threadId: string,
292
+ messages: AgentMessage[]
293
+ ): Promise<void> {
283
294
  if (messages.length === 0) return
284
295
 
285
296
  const toolMessages = messages.filter((m) => m.role === 'tool')
286
297
  const nonToolMessages = messages.filter((m) => m.role !== 'tool')
287
298
 
288
299
  if (nonToolMessages.length > 0) {
289
- await this.aiMessages.insertMany(
300
+ await this.agentMessages.insertMany(
290
301
  nonToolMessages.map((msg) => ({
291
302
  _id: msg.id,
292
303
  threadId,
@@ -369,7 +380,7 @@ export class MongoDBAIStorageService
369
380
  async createRun(run: CreateRunInput): Promise<string> {
370
381
  const runId = crypto.randomUUID()
371
382
 
372
- await this.aiRuns.insertOne({
383
+ await this.agentRuns.insertOne({
373
384
  _id: runId,
374
385
  agentName: run.agentName,
375
386
  threadId: run.threadId,
@@ -416,7 +427,7 @@ export class MongoDBAIStorageService
416
427
  setValues.usageModel = updates.usage.model
417
428
  }
418
429
 
419
- await this.aiRuns.updateOne({ _id: runId }, { $set: setValues })
430
+ await this.agentRuns.updateOne({ _id: runId }, { $set: setValues })
420
431
 
421
432
  if (updates.pendingApprovals !== undefined) {
422
433
  await this.toolCalls.updateMany(
@@ -440,7 +451,7 @@ export class MongoDBAIStorageService
440
451
  }
441
452
 
442
453
  async getRun(runId: string): Promise<AgentRunState | null> {
443
- const row = await this.aiRuns.findOne({ _id: runId })
454
+ const row = await this.agentRuns.findOne({ _id: runId })
444
455
  if (!row) return null
445
456
 
446
457
  const approvals = await this.toolCalls
@@ -451,7 +462,7 @@ export class MongoDBAIStorageService
451
462
  }
452
463
 
453
464
  async getRunsByThread(threadId: string): Promise<AgentRunState[]> {
454
- const result = await this.aiRuns
465
+ const result = await this.agentRuns
455
466
  .find({ threadId })
456
467
  .sort({ createdAt: -1 })
457
468
  .toArray()
@@ -591,7 +602,7 @@ export class MongoDBAIStorageService
591
602
  }
592
603
 
593
604
  async saveScore(score: SaveScoreInput): Promise<void> {
594
- await this.aiRunScores.insertOne({
605
+ await this.agentRunScores.insertOne({
595
606
  _id: crypto.randomUUID(),
596
607
  runId: score.runId,
597
608
  scorerName: score.scorerName,
@@ -602,8 +613,8 @@ export class MongoDBAIStorageService
602
613
  })
603
614
  }
604
615
 
605
- async getScores(runId: string): Promise<AIRunScore[]> {
606
- const rows = await this.aiRunScores
616
+ async getScores(runId: string): Promise<AgentRunScore[]> {
617
+ const rows = await this.agentRunScores
607
618
  .find({ runId })
608
619
  .sort({ createdAt: 1 })
609
620
  .toArray()
@@ -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 { Db, Collection } from 'mongodb'
4
4
 
5
5
  interface ChannelDoc {
@@ -4,7 +4,8 @@ import type {
4
4
  DeploymentServiceConfig,
5
5
  DeploymentConfig,
6
6
  } from '@pikku/core/services'
7
- import type { JWTService, SecretService } from '@pikku/core/services'
7
+ import type { JWTService } from '@pikku/core/services'
8
+ import type { SecretService } from '@pikku/core/services'
8
9
  import { getAllFunctionNames } from '@pikku/core/function'
9
10
  import type { Db, Collection } from 'mongodb'
10
11
 
@@ -1,13 +1,14 @@
1
- import { createSecretValue, isSecretValue, type SecretValue } from '@pikku/core'
2
- import type { SecretService, SecretValues } from '@pikku/core/services'
3
- import type { Db, Collection } from 'mongodb'
4
1
  import {
5
2
  deriveKEK,
6
- generateKEKSalt,
7
- envelopeEncrypt,
8
3
  envelopeDecrypt,
4
+ envelopeEncrypt,
9
5
  envelopeRewrap,
6
+ generateKEKSalt,
10
7
  } from '@pikku/core/crypto-utils'
8
+ import { createSecretValue, isSecretValue } from '@pikku/core/classification'
9
+ import type { SecretService, SecretValues } from '@pikku/core/services'
10
+ import type { SecretValue } from '@pikku/core/classification'
11
+ import type { Db, Collection } from 'mongodb'
11
12
 
12
13
  export interface MongoDBSecretServiceConfig {
13
14
  key: string
@@ -9,7 +9,7 @@ import { MongoDBEventHubStore } from './mongodb-eventhub-store.js'
9
9
  import { MongoDBWorkflowService } from './mongodb-workflow-service.js'
10
10
  import { MongoDBWorkflowRunService } from './mongodb-workflow-run-service.js'
11
11
  import { MongoDBDeploymentService } from './mongodb-deployment-service.js'
12
- import { MongoDBAIStorageService } from './mongodb-ai-storage-service.js'
12
+ import { MongoDBAgentStorageService } from './mongodb-agent-storage-service.js'
13
13
  import { MongoDBAgentRunService } from './mongodb-agent-run-service.js'
14
14
  import { MongoDBSecretService } from './mongodb-secret-service.js'
15
15
  import { MongoDBSessionStore } from './mongodb-session-store.js'
@@ -42,8 +42,8 @@ function registerTests(name: string, getDb: () => Db) {
42
42
  await s.init()
43
43
  return s
44
44
  },
45
- aiStorageService: async () => {
46
- const s = new MongoDBAIStorageService(getDb())
45
+ agentStorageService: async () => {
46
+ const s = new MongoDBAgentStorageService(getDb())
47
47
  await s.init()
48
48
  return s
49
49
  },
@@ -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 { Db, Collection } from 'mongodb'
4
4
 
5
5
  interface SessionDoc {
@@ -1,14 +1,14 @@
1
- import type { SerializedError } from '@pikku/core'
2
- import {
3
- PikkuWorkflowService,
4
- type WorkflowPlannedStep,
5
- type WorkflowQueueOptions,
6
- type WorkflowRun,
7
- type WorkflowRunWire,
8
- type StepState,
9
- type StepStatus,
10
- type WorkflowStatus,
11
- type WorkflowVersionStatus,
1
+ import type { SerializedError } from '@pikku/core/errors'
2
+ import { PikkuWorkflowService } from '@pikku/core/workflow'
3
+ import type {
4
+ WorkflowPlannedStep,
5
+ WorkflowQueueOptions,
6
+ WorkflowRun,
7
+ WorkflowRunWire,
8
+ StepState,
9
+ StepStatus,
10
+ WorkflowStatus,
11
+ WorkflowVersionStatus,
12
12
  } from '@pikku/core/workflow'
13
13
  import type { Db, Collection } from 'mongodb'
14
14
  import { MongoDBWorkflowRunService } from './mongodb-workflow-run-service.js'