Compare commits
41 Commits
15830e2f2a
...
fix/storag
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1b4767bd8b | ||
| 0b0fe10b37 | |||
| acfb31f8f6 | |||
|
|
fd83bd4f2d | ||
|
|
ce3ca1dbd1 | ||
|
|
95e7b071d4 | ||
| d4c5797a65 | |||
| 70a51ba711 | |||
| db8023bdbb | |||
| 9e597ecf87 | |||
| a23c117ea4 | |||
| 0cf80dab8c | |||
|
|
04a80fb9ba | ||
|
|
626adac363 | ||
|
|
35fbd88a1d | ||
| 381b0eed7b | |||
|
|
25383ea645 | ||
|
|
e7db9ddf98 | ||
|
|
7bb878718d | ||
|
|
46a31d4e71 | ||
|
|
e128a7a322 | ||
|
|
27b1898ec6 | ||
|
|
d19ef45bb0 | ||
|
|
5e852df6c3 | ||
|
|
e0eca771c6 | ||
|
|
9d22ef4cc9 | ||
|
|
41961a6980 | ||
|
|
e797676a02 | ||
|
|
05d61e62be | ||
|
|
73043773d8 | ||
| 0be9729e40 | |||
|
|
e83674ac51 | ||
|
|
a6e59bf829 | ||
| e46f0641f6 | |||
|
|
07efaa9580 | ||
|
|
361fece023 | ||
| 80e69016b0 | |||
|
|
e084a88a9d | ||
| 990a88362f | |||
|
|
ea9782b2dc | ||
| 8efbaf100e |
@@ -15,6 +15,7 @@ steps:
|
|||||||
image: *node_image
|
image: *node_image
|
||||||
commands:
|
commands:
|
||||||
- corepack enable
|
- corepack enable
|
||||||
|
- apk add --no-cache python3 make g++
|
||||||
- pnpm install --frozen-lockfile
|
- pnpm install --frozen-lockfile
|
||||||
|
|
||||||
typecheck:
|
typecheck:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mosaic/gateway",
|
"name": "@mosaic/gateway",
|
||||||
"version": "0.0.0",
|
"version": "0.0.2",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/main.js",
|
"main": "dist/main.js",
|
||||||
@@ -19,12 +19,14 @@
|
|||||||
"@modelcontextprotocol/sdk": "^1.27.1",
|
"@modelcontextprotocol/sdk": "^1.27.1",
|
||||||
"@mosaic/auth": "workspace:^",
|
"@mosaic/auth": "workspace:^",
|
||||||
"@mosaic/brain": "workspace:^",
|
"@mosaic/brain": "workspace:^",
|
||||||
|
"@mosaic/config": "workspace:^",
|
||||||
"@mosaic/coord": "workspace:^",
|
"@mosaic/coord": "workspace:^",
|
||||||
"@mosaic/db": "workspace:^",
|
"@mosaic/db": "workspace:^",
|
||||||
"@mosaic/discord-plugin": "workspace:^",
|
"@mosaic/discord-plugin": "workspace:^",
|
||||||
"@mosaic/log": "workspace:^",
|
"@mosaic/log": "workspace:^",
|
||||||
"@mosaic/memory": "workspace:^",
|
"@mosaic/memory": "workspace:^",
|
||||||
"@mosaic/queue": "workspace:^",
|
"@mosaic/queue": "workspace:^",
|
||||||
|
"@mosaic/storage": "workspace:^",
|
||||||
"@mosaic/telegram-plugin": "workspace:^",
|
"@mosaic/telegram-plugin": "workspace:^",
|
||||||
"@mosaic/types": "workspace:^",
|
"@mosaic/types": "workspace:^",
|
||||||
"@nestjs/common": "^11.0.0",
|
"@nestjs/common": "^11.0.0",
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { APP_GUARD } from '@nestjs/core';
|
import { APP_GUARD } from '@nestjs/core';
|
||||||
import { HealthController } from './health/health.controller.js';
|
import { HealthController } from './health/health.controller.js';
|
||||||
|
import { ConfigModule } from './config/config.module.js';
|
||||||
import { DatabaseModule } from './database/database.module.js';
|
import { DatabaseModule } from './database/database.module.js';
|
||||||
import { AuthModule } from './auth/auth.module.js';
|
import { AuthModule } from './auth/auth.module.js';
|
||||||
import { BrainModule } from './brain/brain.module.js';
|
import { BrainModule } from './brain/brain.module.js';
|
||||||
@@ -28,6 +29,7 @@ import { ThrottlerGuard, ThrottlerModule } from '@nestjs/throttler';
|
|||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
ThrottlerModule.forRoot([{ name: 'default', ttl: 60_000, limit: 60 }]),
|
ThrottlerModule.forRoot([{ name: 'default', ttl: 60_000, limit: 60 }]),
|
||||||
|
ConfigModule,
|
||||||
DatabaseModule,
|
DatabaseModule,
|
||||||
AuthModule,
|
AuthModule,
|
||||||
BrainModule,
|
BrainModule,
|
||||||
|
|||||||
16
apps/gateway/src/config/config.module.ts
Normal file
16
apps/gateway/src/config/config.module.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { Global, Module } from '@nestjs/common';
|
||||||
|
import { loadConfig, type MosaicConfig } from '@mosaic/config';
|
||||||
|
|
||||||
|
export const MOSAIC_CONFIG = 'MOSAIC_CONFIG';
|
||||||
|
|
||||||
|
@Global()
|
||||||
|
@Module({
|
||||||
|
providers: [
|
||||||
|
{
|
||||||
|
provide: MOSAIC_CONFIG,
|
||||||
|
useFactory: (): MosaicConfig => loadConfig(),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
exports: [MOSAIC_CONFIG],
|
||||||
|
})
|
||||||
|
export class ConfigModule {}
|
||||||
@@ -1,28 +1,42 @@
|
|||||||
import { Global, Inject, Module, type OnApplicationShutdown } from '@nestjs/common';
|
import { Global, Inject, Module, type OnApplicationShutdown } from '@nestjs/common';
|
||||||
import { createDb, type Db, type DbHandle } from '@mosaic/db';
|
import { createDb, type Db, type DbHandle } from '@mosaic/db';
|
||||||
|
import { createStorageAdapter, type StorageAdapter } from '@mosaic/storage';
|
||||||
|
import type { MosaicConfig } from '@mosaic/config';
|
||||||
|
import { MOSAIC_CONFIG } from '../config/config.module.js';
|
||||||
|
|
||||||
export const DB_HANDLE = 'DB_HANDLE';
|
export const DB_HANDLE = 'DB_HANDLE';
|
||||||
export const DB = 'DB';
|
export const DB = 'DB';
|
||||||
|
export const STORAGE_ADAPTER = 'STORAGE_ADAPTER';
|
||||||
|
|
||||||
@Global()
|
@Global()
|
||||||
@Module({
|
@Module({
|
||||||
providers: [
|
providers: [
|
||||||
{
|
{
|
||||||
provide: DB_HANDLE,
|
provide: DB_HANDLE,
|
||||||
useFactory: (): DbHandle => createDb(),
|
useFactory: (config: MosaicConfig): DbHandle =>
|
||||||
|
createDb(config.storage.type === 'postgres' ? config.storage.url : undefined),
|
||||||
|
inject: [MOSAIC_CONFIG],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
provide: DB,
|
provide: DB,
|
||||||
useFactory: (handle: DbHandle): Db => handle.db,
|
useFactory: (handle: DbHandle): Db => handle.db,
|
||||||
inject: [DB_HANDLE],
|
inject: [DB_HANDLE],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
provide: STORAGE_ADAPTER,
|
||||||
|
useFactory: (config: MosaicConfig): StorageAdapter => createStorageAdapter(config.storage),
|
||||||
|
inject: [MOSAIC_CONFIG],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
exports: [DB],
|
exports: [DB, STORAGE_ADAPTER],
|
||||||
})
|
})
|
||||||
export class DatabaseModule implements OnApplicationShutdown {
|
export class DatabaseModule implements OnApplicationShutdown {
|
||||||
constructor(@Inject(DB_HANDLE) private readonly handle: DbHandle) {}
|
constructor(
|
||||||
|
@Inject(DB_HANDLE) private readonly handle: DbHandle,
|
||||||
|
@Inject(STORAGE_ADAPTER) private readonly storageAdapter: StorageAdapter,
|
||||||
|
) {}
|
||||||
|
|
||||||
async onApplicationShutdown(): Promise<void> {
|
async onApplicationShutdown(): Promise<void> {
|
||||||
await this.handle.close();
|
await Promise.all([this.handle.close(), this.storageAdapter.close()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,29 @@
|
|||||||
import { Global, Module } from '@nestjs/common';
|
import { Global, Module } from '@nestjs/common';
|
||||||
import { createMemory, type Memory } from '@mosaic/memory';
|
import {
|
||||||
|
createMemory,
|
||||||
|
type Memory,
|
||||||
|
createMemoryAdapter,
|
||||||
|
type MemoryAdapter,
|
||||||
|
type MemoryConfig,
|
||||||
|
} from '@mosaic/memory';
|
||||||
import type { Db } from '@mosaic/db';
|
import type { Db } from '@mosaic/db';
|
||||||
import { DB } from '../database/database.module.js';
|
import type { StorageAdapter } from '@mosaic/storage';
|
||||||
|
import type { MosaicConfig } from '@mosaic/config';
|
||||||
|
import { MOSAIC_CONFIG } from '../config/config.module.js';
|
||||||
|
import { DB, STORAGE_ADAPTER } from '../database/database.module.js';
|
||||||
import { MEMORY } from './memory.tokens.js';
|
import { MEMORY } from './memory.tokens.js';
|
||||||
import { MemoryController } from './memory.controller.js';
|
import { MemoryController } from './memory.controller.js';
|
||||||
import { EmbeddingService } from './embedding.service.js';
|
import { EmbeddingService } from './embedding.service.js';
|
||||||
|
|
||||||
|
export const MEMORY_ADAPTER = 'MEMORY_ADAPTER';
|
||||||
|
|
||||||
|
function buildMemoryConfig(config: MosaicConfig, storageAdapter: StorageAdapter): MemoryConfig {
|
||||||
|
if (config.memory.type === 'keyword') {
|
||||||
|
return { type: 'keyword', storage: storageAdapter };
|
||||||
|
}
|
||||||
|
return { type: config.memory.type };
|
||||||
|
}
|
||||||
|
|
||||||
@Global()
|
@Global()
|
||||||
@Module({
|
@Module({
|
||||||
providers: [
|
providers: [
|
||||||
@@ -14,9 +32,15 @@ import { EmbeddingService } from './embedding.service.js';
|
|||||||
useFactory: (db: Db): Memory => createMemory(db),
|
useFactory: (db: Db): Memory => createMemory(db),
|
||||||
inject: [DB],
|
inject: [DB],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
provide: MEMORY_ADAPTER,
|
||||||
|
useFactory: (config: MosaicConfig, storageAdapter: StorageAdapter): MemoryAdapter =>
|
||||||
|
createMemoryAdapter(buildMemoryConfig(config, storageAdapter)),
|
||||||
|
inject: [MOSAIC_CONFIG, STORAGE_ADAPTER],
|
||||||
|
},
|
||||||
EmbeddingService,
|
EmbeddingService,
|
||||||
],
|
],
|
||||||
controllers: [MemoryController],
|
controllers: [MemoryController],
|
||||||
exports: [MEMORY, EmbeddingService],
|
exports: [MEMORY, MEMORY_ADAPTER, EmbeddingService],
|
||||||
})
|
})
|
||||||
export class MemoryModule {}
|
export class MemoryModule {}
|
||||||
|
|||||||
@@ -1,9 +1,21 @@
|
|||||||
import { Global, Module } from '@nestjs/common';
|
import { Global, Module } from '@nestjs/common';
|
||||||
|
import { createQueueAdapter, type QueueAdapter } from '@mosaic/queue';
|
||||||
|
import type { MosaicConfig } from '@mosaic/config';
|
||||||
|
import { MOSAIC_CONFIG } from '../config/config.module.js';
|
||||||
import { QueueService } from './queue.service.js';
|
import { QueueService } from './queue.service.js';
|
||||||
|
|
||||||
|
export const QUEUE_ADAPTER = 'QUEUE_ADAPTER';
|
||||||
|
|
||||||
@Global()
|
@Global()
|
||||||
@Module({
|
@Module({
|
||||||
providers: [QueueService],
|
providers: [
|
||||||
exports: [QueueService],
|
QueueService,
|
||||||
|
{
|
||||||
|
provide: QUEUE_ADAPTER,
|
||||||
|
useFactory: (config: MosaicConfig): QueueAdapter => createQueueAdapter(config.queue),
|
||||||
|
inject: [MOSAIC_CONFIG],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
exports: [QueueService, QUEUE_ADAPTER],
|
||||||
})
|
})
|
||||||
export class QueueModule {}
|
export class QueueModule {}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mosaic/web",
|
"name": "@mosaic/web",
|
||||||
"version": "0.0.0",
|
"version": "0.0.2",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
|
|||||||
@@ -1,73 +1,30 @@
|
|||||||
# Tasks — Harness Foundation
|
# Tasks — Storage Abstraction Retrofit
|
||||||
|
|
||||||
> Single-writer: orchestrator only. Workers read but never modify.
|
> Single-writer: orchestrator only. Workers read but never modify.
|
||||||
>
|
>
|
||||||
|
> **Mission:** Decouple gateway from hardcoded Postgres/Valkey backends. Introduce interface-driven middleware so the gateway is backend-agnostic. Default to local tier (SQLite + JSON) for zero-dependency installs.
|
||||||
|
>
|
||||||
> **`agent` column values:** `codex` | `sonnet` | `haiku` | `glm-5` | `opus` | `—` (auto/default)
|
> **`agent` column values:** `codex` | `sonnet` | `haiku` | `glm-5` | `opus` | `—` (auto/default)
|
||||||
|
|
||||||
| id | status | agent | milestone | description | pr | notes |
|
| id | status | agent | description | tokens |
|
||||||
| ------ | ------ | ------ | ------------------ | ------------------------------------------------------------------ | ---- | ----------- |
|
| --------- | ----------- | ------ | ---------------------------------------------------------------- | ------ |
|
||||||
| M1-001 | done | sonnet | M1: Persistence | Wire ChatGateway → ConversationsRepo for user messages | #292 | #224 closed |
|
| SA-P1-001 | done | sonnet | Define QueueAdapter interface in packages/queue/src/types.ts | 3K |
|
||||||
| M1-002 | done | sonnet | M1: Persistence | Wire agent event relay → ConversationsRepo for assistant responses | #292 | #225 closed |
|
| SA-P1-002 | done | sonnet | Define StorageAdapter interface in packages/storage/src/types.ts | 3K |
|
||||||
| M1-003 | done | sonnet | M1: Persistence | Store message metadata: model, provider, tokens, tool calls | #292 | #226 closed |
|
| SA-P1-003 | done | sonnet | Define MemoryAdapter interface in packages/memory/src/types.ts | 3K |
|
||||||
| M1-004 | done | sonnet | M1: Persistence | Load message history into Pi session on resume | #301 | #227 closed |
|
| SA-P1-004 | done | sonnet | Create adapter factory pattern + config types | 3K |
|
||||||
| M1-005 | done | sonnet | M1: Persistence | Context window management: summarize when >80% | #301 | #228 closed |
|
| SA-P2-001 | done | sonnet | Refactor @mosaic/queue: wrap ioredis as BullMQ adapter | 3K |
|
||||||
| M1-006 | done | sonnet | M1: Persistence | Conversation search endpoint | #299 | #229 closed |
|
| SA-P2-002 | done | sonnet | Create @mosaic/storage: wrap Drizzle as Postgres adapter | 6K |
|
||||||
| M1-007 | done | sonnet | M1: Persistence | TUI /history command | #297 | #230 closed |
|
| SA-P2-003 | done | sonnet | Refactor @mosaic/memory: extract pgvector adapter | 4K |
|
||||||
| M1-008 | done | sonnet | M1: Persistence | Verify persistence — 20 tests | #304 | #231 closed |
|
| SA-P2-004 | done | sonnet | Update gateway modules to use factories + DI tokens | 5K |
|
||||||
| M2-001 | done | sonnet | M2: Security | InsightsRepo userId on searchByEmbedding | #290 | #232 closed |
|
| SA-P2-005 | done | opus | Verify Phase 2: all tests pass, typecheck clean | — |
|
||||||
| M2-002 | done | sonnet | M2: Security | InsightsRepo userId on findByUser/decay | #290 | #233 closed |
|
| SA-P3-001 | done | sonnet | Implement local queue adapter: JSON file persistence | 5K |
|
||||||
| M2-003 | done | sonnet | M2: Security | PreferencesRepo userId verified | #294 | #234 closed |
|
| SA-P3-002 | done | sonnet | Implement SQLite storage adapter with better-sqlite3 | 8K |
|
||||||
| M2-004 | done | sonnet | M2: Security | Memory tools userId injection fixed | #294 | #235 closed |
|
| SA-P3-003 | done | sonnet | Implement keyword memory adapter — no vector dependency | 4K |
|
||||||
| M2-005 | done | sonnet | M2: Security | ConversationsRepo ownership checks | #293 | #236 closed |
|
| SA-P3-004 | done | opus | Verify Phase 3: 42 new tests, 347 total passing | — |
|
||||||
| M2-006 | done | sonnet | M2: Security | AgentsRepo findAccessible scoped | #293 | #237 closed |
|
| SA-P4-001 | done | sonnet | MosaicConfig schema + loader with tier auto-detection | 6K |
|
||||||
| M2-007 | done | sonnet | M2: Security | Cross-user isolation — 28 tests | #305 | #238 closed |
|
| SA-P4-002 | done | sonnet | CLI: mosaic gateway init — interactive wizard | 4K |
|
||||||
| M2-008 | done | sonnet | M2: Security | Valkey SCAN + /gc admin-only | #298 | #239 closed |
|
| SA-P4-003 | done | sonnet | CLI: mosaic gateway start/stop/status lifecycle | 5K |
|
||||||
| M3-001 | done | sonnet | M3: Providers | IProviderAdapter + OllamaAdapter | #306 | #240 closed |
|
| SA-P4-004 | done | opus | Verify Phase 4: 381 tests passing, 40/40 tasks clean | — |
|
||||||
| M3-002 | done | sonnet | M3: Providers | AnthropicAdapter | #309 | #241 closed |
|
| SA-P5-001 | not-started | codex | Migration tooling: mosaic storage export/import | — |
|
||||||
| M3-003 | done | sonnet | M3: Providers | OpenAIAdapter | #310 | #242 closed |
|
| SA-P5-002 | not-started | codex | Docker Compose profiles: local vs team | — |
|
||||||
| M3-004 | done | sonnet | M3: Providers | OpenRouterAdapter | #311 | #243 closed |
|
| SA-P5-003 | not-started | codex | Final verification + docs: README, architecture diagram | — |
|
||||||
| M3-005 | done | sonnet | M3: Providers | ZaiAdapter (GLM-5) | #314 | #244 closed |
|
|
||||||
| M3-006 | done | sonnet | M3: Providers | Ollama embedding support | #311 | #245 closed |
|
|
||||||
| M3-007 | done | sonnet | M3: Providers | Provider health checks | #308 | #246 closed |
|
|
||||||
| M3-008 | done | sonnet | M3: Providers | Model capability matrix | #303 | #247 closed |
|
|
||||||
| M3-009 | done | sonnet | M3: Providers | EmbeddingService → Ollama default | #308 | #248 closed |
|
|
||||||
| M3-010 | done | sonnet | M3: Providers | OAuth token storage (AES-256-GCM) | #317 | #249 closed |
|
|
||||||
| M3-011 | done | sonnet | M3: Providers | Provider credentials CRUD | #317 | #250 closed |
|
|
||||||
| M3-012 | done | sonnet | M3: Providers | Verify providers — 40 tests | #319 | #251 closed |
|
|
||||||
| M4-001 | done | sonnet | M4: Routing | routing_rules DB schema | #315 | #252 closed |
|
|
||||||
| M4-002 | done | sonnet | M4: Routing | Condition types | #315 | #253 closed |
|
|
||||||
| M4-003 | done | sonnet | M4: Routing | Action types | #315 | #254 closed |
|
|
||||||
| M4-004 | done | sonnet | M4: Routing | Default routing rules (11 seeds) | #316 | #255 closed |
|
|
||||||
| M4-005 | done | sonnet | M4: Routing | Task classifier (60+ tests) | #316 | #256 closed |
|
|
||||||
| M4-006 | done | sonnet | M4: Routing | Routing decision pipeline | #318 | #257 closed |
|
|
||||||
| M4-007 | done | sonnet | M4: Routing | /model override | #323 | #258 closed |
|
|
||||||
| M4-008 | done | sonnet | M4: Routing | Routing transparency in session:info | #323 | #259 closed |
|
|
||||||
| M4-009 | done | sonnet | M4: Routing | Routing rules CRUD API | #320 | #260 closed |
|
|
||||||
| M4-010 | done | sonnet | M4: Routing | Per-user routing overrides | #320 | #261 closed |
|
|
||||||
| M4-011 | done | sonnet | M4: Routing | Agent specialization capabilities | #320 | #262 closed |
|
|
||||||
| M4-012 | done | sonnet | M4: Routing | Routing wired into ChatGateway | #323 | #263 closed |
|
|
||||||
| M4-013 | done | sonnet | M4: Routing | Verify routing — 9 E2E tests | #323 | #264 closed |
|
|
||||||
| M5-001 | done | sonnet | M5: Sessions | Agent config loaded on session create | #323 | #265 closed |
|
|
||||||
| M5-002 | done | sonnet | M5: Sessions | /model command end-to-end | #323 | #266 closed |
|
|
||||||
| M5-003 | done | sonnet | M5: Sessions | /agent command mid-session | #323 | #267 closed |
|
|
||||||
| M5-004 | done | sonnet | M5: Sessions | Session ↔ conversation binding | #321 | #268 closed |
|
|
||||||
| M5-005 | done | sonnet | M5: Sessions | Session info broadcast | #321 | #269 closed |
|
|
||||||
| M5-006 | done | sonnet | M5: Sessions | /agent new from TUI | #321 | #270 closed |
|
|
||||||
| M5-007 | done | sonnet | M5: Sessions | Session metrics | #321 | #271 closed |
|
|
||||||
| M5-008 | done | sonnet | M5: Sessions | Verify sessions — 28 tests | #324 | #272 closed |
|
|
||||||
| M6-001 | done | sonnet | M6: Jobs | BullMQ + Valkey config | #324 | #273 closed |
|
|
||||||
| M6-002 | done | sonnet | M6: Jobs | Queue service with typed jobs | #324 | #274 closed |
|
|
||||||
| M6-003 | done | sonnet | M6: Jobs | Summarization → BullMQ | #324 | #275 closed |
|
|
||||||
| M6-004 | done | sonnet | M6: Jobs | GC → BullMQ | #324 | #276 closed |
|
|
||||||
| M6-005 | done | sonnet | M6: Jobs | Tier management → BullMQ | #324 | #277 closed |
|
|
||||||
| M6-006 | done | sonnet | M6: Jobs | Admin jobs API | #325 | #278 closed |
|
|
||||||
| M6-007 | done | sonnet | M6: Jobs | Job event logging | #325 | #279 closed |
|
|
||||||
| M6-008 | done | sonnet | M6: Jobs | Verify jobs | #324 | #280 closed |
|
|
||||||
| M7-001 | done | sonnet | M7: Channel Design | IChannelAdapter interface | #325 | #281 closed |
|
|
||||||
| M7-002 | done | sonnet | M7: Channel Design | Channel message protocol | #325 | #282 closed |
|
|
||||||
| M7-003 | done | sonnet | M7: Channel Design | Matrix integration design | #326 | #283 closed |
|
|
||||||
| M7-004 | done | sonnet | M7: Channel Design | Conversation multiplexing | #326 | #284 closed |
|
|
||||||
| M7-005 | done | sonnet | M7: Channel Design | Remote auth bridging | #326 | #285 closed |
|
|
||||||
| M7-006 | done | sonnet | M7: Channel Design | Agent-to-agent via Matrix | #326 | #286 closed |
|
|
||||||
| M7-007 | done | sonnet | M7: Channel Design | Multi-user isolation in Matrix | #326 | #287 closed |
|
|
||||||
| M7-008 | done | sonnet | M7: Channel Design | channel-protocol.md published | #326 | #288 closed |
|
|
||||||
|
|||||||
555
docs/design/storage-abstraction-middleware.md
Normal file
555
docs/design/storage-abstraction-middleware.md
Normal file
@@ -0,0 +1,555 @@
|
|||||||
|
# Storage & Queue Abstraction — Middleware Architecture
|
||||||
|
|
||||||
|
Design
|
||||||
|
Status: Design (retrofit required)
|
||||||
|
date: 2026-04-02
|
||||||
|
context: Agents coupled directly to infrastructure backends, bypassing intended middleware layer
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## The Problem
|
||||||
|
|
||||||
|
Current packages are **direct adapters**, not **middleware**:
|
||||||
|
| Package | Current State | Intended Design |
|
||||||
|
|---------|---------------|-----------------|
|
||||||
|
| `@mosaic/queue` | `ioredis` hardcoded | Interface → BullMQ OR local-files |
|
||||||
|
| `@mosaic/db` | Drizzle + Postgres hardcoded | Interface → Postgres OR SQLite OR JSON/MD |
|
||||||
|
| `@mosaic/memory` | pgvector required | Interface → pgvector OR sqlite-vec OR keyword-search |
|
||||||
|
|
||||||
|
## The gateway and TUI import these packages directly, which means they they're coupled to specific infrastructure. Users cannot run Mosaic Stack without Postgres + Valkey.
|
||||||
|
|
||||||
|
## The Intended Architecture
|
||||||
|
|
||||||
|
```
|
||||||
|
┌─────────────────────────────────────────────────────────────────┐
|
||||||
|
│ Gateway / TUI / CLI │
|
||||||
|
│ (agnostic of storage backend, talks to middleware) │
|
||||||
|
└───────────────────────────┬─────────────────────────────────────┘
|
||||||
|
│
|
||||||
|
┌───────────────────┼───────────────────┐
|
||||||
|
│ │ │
|
||||||
|
▼─────────────────┴─────────────────┴─────────────────┘
|
||||||
|
| | | |
|
||||||
|
▼─────────────────┴───────────────────┴─────────────────┘
|
||||||
|
| | | |
|
||||||
|
Queue Storage Memory
|
||||||
|
| | | |
|
||||||
|
┌─────────┬─────────┬─────────┬─────────────────────────────────┐
|
||||||
|
| BullMQ | | Local | | Postgres | SQLite | JSON/MD | pgvector | sqlite-vec | keyword |
|
||||||
|
|(Valkey)| |(files) | | | | | |
|
||||||
|
└─────────┴─────────┴─────────┴─────────────────────────────────┘
|
||||||
|
```
|
||||||
|
|
||||||
|
The gateway imports the interface, not the backend. At startup it reads config and instantiates the correct adapter.
|
||||||
|
|
||||||
|
## The Drift
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// What should have happened:
|
||||||
|
gateway/queue.service.ts → @mosaic/queue (interface) → queue.adapter.ts
|
||||||
|
|
||||||
|
// What actually happened:
|
||||||
|
gateway/queue.service.ts → @mosaic/queue → ioredis (hardcoded)
|
||||||
|
```
|
||||||
|
|
||||||
|
## The Current State Analysis
|
||||||
|
|
||||||
|
### `@mosaic/queue` (packages/queue/src/queue.ts)
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import Redis from 'ioredis'; // ← Direct import of backend
|
||||||
|
|
||||||
|
export function createQueue(config?: QueueConfig): QueueHandle {
|
||||||
|
const url = config?.url ?? process.env['VALKEY_URL'] ?? DEFAULT_VALKEY_URL;
|
||||||
|
const redis = new Redis(url, { maxRetriesPerRequest: 3 });
|
||||||
|
// ...queue ops directly on redis...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Problem:** `ioredis` is imported in the package, not the adapter interface. Consumers cannot swap backends.
|
||||||
|
|
||||||
|
### `@mosaic/db` (packages/db/src/client.ts)
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { drizzle, type PostgresJsDatabase } from 'drizzle-orm/postgres-js';
|
||||||
|
import postgres from 'postgres';
|
||||||
|
|
||||||
|
export function createDb(url?: string): DbHandle {
|
||||||
|
const connectionString = url ?? process.env['DATABASE_URL'] ?? DEFAULT_DATABASE_URL;
|
||||||
|
const sql = postgres(connectionString, { max: 20, idle_timeout: 30, connect_timeout: 5 });
|
||||||
|
const db = drizzle(sql, { schema });
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Problem:** Drizzle + Postgres is hardcoded. No SQLite, JSON, or file-based options.
|
||||||
|
|
||||||
|
### `@mosaic/memory` (packages/memory/src/memory.ts)
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import type { Db } from '@mosaic/db'; // ← Depends on Drizzle/PG
|
||||||
|
|
||||||
|
export function createMemory(db: Db): Memory {
|
||||||
|
return {
|
||||||
|
preferences: createPreferencesRepo(db),
|
||||||
|
insights: createInsightsRepo(db),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Problem:** Memory package is tightly coupled to `@mosaic/db` (which is Postgres-only). No alternative storage backends.
|
||||||
|
|
||||||
|
## The Target Interfaces
|
||||||
|
|
||||||
|
### Queue Interface
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// packages/queue/src/types.ts
|
||||||
|
export interface QueueAdapter {
|
||||||
|
readonly name: string;
|
||||||
|
|
||||||
|
enqueue(queueName: string, payload: TaskPayload): Promise<void>;
|
||||||
|
dequeue(queueName: string): Promise<TaskPayload | null>;
|
||||||
|
length(queueName: string): Promise<number>;
|
||||||
|
publish(channel: string, message: string): Promise<void>;
|
||||||
|
subscribe(channel: string, handler: (message: string) => void): () => void;
|
||||||
|
close(): Promise<void>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TaskPayload {
|
||||||
|
id: string;
|
||||||
|
type: string;
|
||||||
|
data: Record<string, unknown>;
|
||||||
|
createdAt: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface QueueConfig {
|
||||||
|
type: 'bullmq' | 'local';
|
||||||
|
url?: string; // For bullmq: Valkey/Redis URL
|
||||||
|
dataDir?: string; // For local: directory for JSON persistence
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Storage Interface
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// packages/storage/src/types.ts
|
||||||
|
export interface StorageAdapter {
|
||||||
|
readonly name: string;
|
||||||
|
|
||||||
|
// Entity CRUD
|
||||||
|
create<T>(collection: string, data: O): Promise<T>;
|
||||||
|
read<T>(collection: string, id: string): Promise<T | null>;
|
||||||
|
update<T>(collection: string, id: string, data: Partial<O>): Promise<T | null>;
|
||||||
|
delete(collection: string, id: string): Promise<boolean>;
|
||||||
|
|
||||||
|
// Queries
|
||||||
|
find<T>(collection: string, filter: Record<string, unknown>): Promise<T[]>;
|
||||||
|
findOne<T>(collection: string, filter: Record<string, unknown): Promise<T | null>;
|
||||||
|
|
||||||
|
// Bulk operations
|
||||||
|
createMany<T>(collection: string, items: O[]): Promise<T[]>;
|
||||||
|
updateMany<T>(collection: string, ids: string[], data: Partial<O>): Promise<number>;
|
||||||
|
deleteMany(collection: string, ids: string[]): Promise<number>;
|
||||||
|
|
||||||
|
// Raw queries (for complex queries)
|
||||||
|
query<T>(collection: string, query: string, params?: unknown[]): Promise<T[]>;
|
||||||
|
|
||||||
|
// Transaction support
|
||||||
|
transaction<T>(fn: (tx: StorageTransaction) => Promise<T>): Promise<T>;
|
||||||
|
|
||||||
|
close(): Promise<void>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface StorageTransaction {
|
||||||
|
commit(): Promise<void>;
|
||||||
|
rollback(): Promise<void>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface StorageConfig {
|
||||||
|
type: 'postgres' | 'sqlite' | 'files';
|
||||||
|
url?: string; // For postgres
|
||||||
|
path?: string; // For sqlite/files
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Memory Interface (Vector + Preferences)
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// packages/memory/src/types.ts
|
||||||
|
export interface MemoryAdapter {
|
||||||
|
readonly name: string;
|
||||||
|
|
||||||
|
// Preferences (key-value storage)
|
||||||
|
getPreference(userId: string, key: string): Promise<unknown | null>;
|
||||||
|
setPreference(userId: string, key: string, value: unknown): Promise<void>;
|
||||||
|
deletePreference(userId: string, key: string): Promise<boolean>;
|
||||||
|
listPreferences(
|
||||||
|
userId: string,
|
||||||
|
category?: string,
|
||||||
|
): Promise<Array<{ key: string; value: unknown }>>;
|
||||||
|
|
||||||
|
// Insights (with optional vector search)
|
||||||
|
storeInsight(insight: NewInsight): Promise<Insight>;
|
||||||
|
getInsight(id: string): Promise<Insight | null>;
|
||||||
|
searchInsights(query: string, limit?: number, filter?: InsightFilter): Promise<SearchResult[]>;
|
||||||
|
deleteInsight(id: string): Promise<boolean>;
|
||||||
|
|
||||||
|
// Embedding provider (optional, null = no vector search)
|
||||||
|
readonly embedder?: EmbeddingProvider | null;
|
||||||
|
|
||||||
|
close(): Promise<void>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface NewInsight {
|
||||||
|
id: string;
|
||||||
|
userId: string;
|
||||||
|
content: string;
|
||||||
|
embedding?: number[]; // If embedder is available
|
||||||
|
source: 'agent' | 'user' | 'summarization' | 'system';
|
||||||
|
category: 'decision' | 'learning' | 'preference' | 'fact' | 'pattern' | 'general';
|
||||||
|
relevanceScore: number;
|
||||||
|
metadata?: Record<string, unknown>;
|
||||||
|
createdAt: Date;
|
||||||
|
decayedAt?: Date;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InsightFilter {
|
||||||
|
userId?: string;
|
||||||
|
category?: string;
|
||||||
|
source?: string;
|
||||||
|
minRelevance?: number;
|
||||||
|
fromDate?: Date;
|
||||||
|
toDate?: Date;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SearchResult {
|
||||||
|
documentId: string;
|
||||||
|
content: string;
|
||||||
|
distance: number;
|
||||||
|
metadata?: Record<string, unknown>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MemoryConfig {
|
||||||
|
type: 'pgvector' | 'sqlite-vec' | 'keyword';
|
||||||
|
storage: StorageAdapter;
|
||||||
|
embedder?: EmbeddingProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface EmbeddingProvider {
|
||||||
|
embed(text: string): Promise<number[]>;
|
||||||
|
embedBatch(texts: string[]): Promise<number[][]>;
|
||||||
|
readonly dimensions: number;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Three Tiers
|
||||||
|
|
||||||
|
### Tier 1: Local (Zero Dependencies)
|
||||||
|
|
||||||
|
**Target:** Single user, single machine, no external services
|
||||||
|
|
||||||
|
| Component | Backend | Storage |
|
||||||
|
| --------- | --------------------------------------------- | ------------ |
|
||||||
|
| Queue | In-process + JSON files in `~/.mosaic/queue/` |
|
||||||
|
| Storage | SQLite (better-sqlite3) `~/.mosaic/data.db` |
|
||||||
|
| Memory | Keyword search | SQLite table |
|
||||||
|
| Vector | None | N/A |
|
||||||
|
|
||||||
|
**Dependencies:**
|
||||||
|
|
||||||
|
- `better-sqlite3` (bundled)
|
||||||
|
- No Postgres, No Valkey, No pgvector
|
||||||
|
|
||||||
|
**Upgrade path:**
|
||||||
|
|
||||||
|
1. Run `mosaic gateway configure` → select "local" tier
|
||||||
|
2. Gateway starts with SQLite database
|
||||||
|
3. Optional: run `mosaic gateway upgrade --tier team` to migrate to Postgres
|
||||||
|
|
||||||
|
### Tier 2: Team (Postgres + Valkey)
|
||||||
|
|
||||||
|
**Target:** Multiple users, shared server, CI/CD environments
|
||||||
|
|
||||||
|
| Component | Backend | Storage |
|
||||||
|
| --------- | -------------- | ------------------------------ |
|
||||||
|
| Queue | BullMQ | Valkey |
|
||||||
|
| Storage | Postgres | Shared PG instance |
|
||||||
|
| Memory | pgvector | Postgres with vector extension |
|
||||||
|
| Vector | LLM embeddings | Configured provider |
|
||||||
|
|
||||||
|
**Dependencies:**
|
||||||
|
|
||||||
|
- PostgreSQL 17+ with pgvector extension
|
||||||
|
- Valkey (Redis-compatible)
|
||||||
|
- LLM provider for embeddings
|
||||||
|
|
||||||
|
**Migration from Local → Team:**
|
||||||
|
|
||||||
|
1. `mosaic gateway backup` → creates dump of SQLite database
|
||||||
|
2. `mosaic gateway upgrade --tier team` → restores to Postgres
|
||||||
|
3. Queue replays from BullMQ (may need manual reconciliation for in-flight jobs)
|
||||||
|
4. Memory embeddings regenerated if vector search was new
|
||||||
|
|
||||||
|
### Tier 3: Enterprise (Clustered)
|
||||||
|
|
||||||
|
**Target:** Large teams, multi-region, high availability
|
||||||
|
|
||||||
|
| Component | Backend | Storage |
|
||||||
|
| --------- | --------------------------- | ----------------------------- |
|
||||||
|
| Queue | BullMQ cluster | Multiple Valkey nodes |
|
||||||
|
| Storage | Postgres cluster | Primary + replicas |
|
||||||
|
| Memory | Dedicated vector DB | Qdrant, Pinecone, or pgvector |
|
||||||
|
| Vector | Dedicated embedding service | Separate microservice |
|
||||||
|
|
||||||
|
## MarkdownDB Integration
|
||||||
|
|
||||||
|
For file-based storage, we use [MarkdownDB](https://markdowndb.com) to parse MD files into queryable data.
|
||||||
|
|
||||||
|
**What it provides:**
|
||||||
|
|
||||||
|
- Parses frontmatter (YAML/JSON/TOML)
|
||||||
|
- Extracts links, tags, metadata
|
||||||
|
- Builds index in JSON or SQLite
|
||||||
|
- Queryable via SQL-like interface
|
||||||
|
|
||||||
|
**Usage in Mosaic:**
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// Local tier with MD files for documents
|
||||||
|
const storage = createStorageAdapter({
|
||||||
|
type: 'files',
|
||||||
|
path: path.join(mosaicHome, 'docs'),
|
||||||
|
markdowndb: {
|
||||||
|
parseFrontmatter: true,
|
||||||
|
extractLinks: true,
|
||||||
|
indexFile: 'index.json',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
## Dream Mode — Memory Consolidation
|
||||||
|
|
||||||
|
Automated equivalent to Claude Code's "Dream: Memory Consolidation" cycle
|
||||||
|
|
||||||
|
**Trigger:** Every 24 hours (if 5+ sessions active)
|
||||||
|
|
||||||
|
**Phases:**
|
||||||
|
|
||||||
|
1. **Orient** — What happened, what's the current state
|
||||||
|
- Scan recent session logs
|
||||||
|
- Identify active tasks, missions, conversations
|
||||||
|
- Calculate time window (last 24h)
|
||||||
|
|
||||||
|
2. **Gather** — Pull in relevant context
|
||||||
|
- Load conversations, decisions, agent logs
|
||||||
|
- Extract key interactions and outcomes
|
||||||
|
- Identify patterns and learnings
|
||||||
|
|
||||||
|
3. **Consolidate** — Summarize and compress
|
||||||
|
- Generate summary of the last 24h
|
||||||
|
- Extract key decisions and their rationale
|
||||||
|
- Identify recurring patterns
|
||||||
|
- Compress verbose logs into concise insights
|
||||||
|
|
||||||
|
4. **Prune** — Archive and cleanup
|
||||||
|
- Archive raw session files to dated folders
|
||||||
|
- Delete redundant/temporary data
|
||||||
|
- Update MEMORY.md with consolidated content
|
||||||
|
- Update insight relevance scores
|
||||||
|
|
||||||
|
**Implementation:**
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// In @mosaic/dream (new package)
|
||||||
|
export async function runDreamCycle(config: DreamConfig): Promise<DreamResult> {
|
||||||
|
const memory = await loadMemoryAdapter(config.storage);
|
||||||
|
|
||||||
|
// Orient
|
||||||
|
const sessions = await memory.getRecentSessions(24 * 60 * 60 * 1000);
|
||||||
|
if (sessions.length < 5) return { skipped: true, reason: 'insufficient_sessions' };
|
||||||
|
|
||||||
|
// Gather
|
||||||
|
const context = await gatherContext(memory, sessions);
|
||||||
|
|
||||||
|
// Consolidate
|
||||||
|
const consolidated = await consolidateWithLLM(context, config.llm);
|
||||||
|
|
||||||
|
// Prune
|
||||||
|
await pruneArchivedData(memory, config.retention);
|
||||||
|
|
||||||
|
// Store consolidated insights
|
||||||
|
await memory.storeInsights(consolidated.insights);
|
||||||
|
|
||||||
|
return {
|
||||||
|
sessionsProcessed: sessions.length,
|
||||||
|
insightsCreated: consolidated.insights.length,
|
||||||
|
bytesPruned: consolidated.bytesRemoved,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Retrofit Plan
|
||||||
|
|
||||||
|
### Phase 1: Interface Extraction (2-3 days)
|
||||||
|
|
||||||
|
**Goal:** Define interfaces without changing existing behavior
|
||||||
|
|
||||||
|
1. Create `packages/queue/src/types.ts` with `QueueAdapter` interface
|
||||||
|
2. Create `packages/storage/src/types.ts` with `StorageAdapter` interface
|
||||||
|
3. Create `packages/memory/src/types.ts` with `MemoryAdapter` interface (refactor existing)
|
||||||
|
4. Add adapter registry pattern to each package
|
||||||
|
5. No breaking changes — existing code continues to work
|
||||||
|
|
||||||
|
### Phase 2: Refactor Existing to Adapters (3-5 days)
|
||||||
|
|
||||||
|
**Goal:** Move existing implementations behind adapters
|
||||||
|
|
||||||
|
#### 2.1 Queue Refactor
|
||||||
|
|
||||||
|
1. Rename `packages/queue/src/queue.ts` → `packages/queue/src/adapters/bullmq.ts`
|
||||||
|
2. Create `packages/queue/src/index.ts` to export factory function
|
||||||
|
3. Factory function reads config, instantiates correct adapter
|
||||||
|
4. Update gateway imports to use factory
|
||||||
|
|
||||||
|
#### 2.2 Storage Refactor
|
||||||
|
|
||||||
|
1. Create `packages/storage/` (new package)
|
||||||
|
2. Move Drizzle logic to `packages/storage/src/adapters/postgres.ts`
|
||||||
|
3. Create SQLite adapter in `packages/storage/src/adapters/sqlite.ts`
|
||||||
|
4. Update gateway to use storage factory
|
||||||
|
5. Deprecate direct `@mosaic/db` imports
|
||||||
|
|
||||||
|
#### 2.3 Memory Refactor
|
||||||
|
|
||||||
|
1. Extract existing logic to `packages/memory/src/adapters/pgvector.ts`
|
||||||
|
2. Create keyword adapter in `packages/memory/src/adapters/keyword.ts`
|
||||||
|
3. Update vector-store.ts to be adapter-agnostic
|
||||||
|
|
||||||
|
### Phase 3: Local Tier Implementation (2-3 days)
|
||||||
|
|
||||||
|
**Goal:** Zero-dependency baseline
|
||||||
|
|
||||||
|
1. Implement `packages/queue/src/adapters/local.ts` (in-process + JSON persistence)
|
||||||
|
2. Implement `packages/storage/src/adapters/files.ts` (JSON + MD via MarkdownDB)
|
||||||
|
3. Implement `packages/memory/src/adapters/keyword.ts` (TF-IDF search)
|
||||||
|
4. Add `packages/dream/` for consolidation cycle
|
||||||
|
5. Wire up local tier in gateway startup
|
||||||
|
|
||||||
|
### Phase 4: Configuration System (1-2 days)
|
||||||
|
|
||||||
|
**Goal:** Runtime backend selection
|
||||||
|
|
||||||
|
1. Create `packages/config/src/storage.ts` for storage configuration
|
||||||
|
2. Add `mosaic.config.ts` schema with storage tier settings
|
||||||
|
3. Update gateway to read config on startup
|
||||||
|
4. Add `mosaic gateway configure` CLI command
|
||||||
|
5. Add tier migration commands (`mosaic gateway upgrade`)
|
||||||
|
|
||||||
|
### Phase 5: Testing & Documentation (2-3 days)
|
||||||
|
|
||||||
|
1. Unit tests for each adapter
|
||||||
|
2. Integration tests for factory pattern
|
||||||
|
3. Migration tests (local → team)
|
||||||
|
4. Update README and architecture docs
|
||||||
|
5. Add configuration guide
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## File Changes Summary
|
||||||
|
|
||||||
|
### New Files
|
||||||
|
|
||||||
|
```
|
||||||
|
packages/
|
||||||
|
├── config/
|
||||||
|
│ └── src/
|
||||||
|
│ ├── storage.ts # Storage config schema
|
||||||
|
│ └── index.ts
|
||||||
|
├── dream/ # NEW: Dream mode consolidation
|
||||||
|
│ ├── src/
|
||||||
|
│ │ ├── index.ts
|
||||||
|
│ │ ├── orient.ts
|
||||||
|
│ │ ├── gather.ts
|
||||||
|
│ │ ├── consolidate.ts
|
||||||
|
│ │ └── prune.ts
|
||||||
|
│ └── package.json
|
||||||
|
├── queue/
|
||||||
|
│ └── src/
|
||||||
|
│ ├── types.ts # NEW: QueueAdapter interface
|
||||||
|
│ ├── index.ts # NEW: Factory function
|
||||||
|
│ └── adapters/
|
||||||
|
│ ├── bullmq.ts # MOVED from queue.ts
|
||||||
|
│ └── local.ts # NEW: In-process adapter
|
||||||
|
├── storage/ # NEW: Storage abstraction
|
||||||
|
│ ├── src/
|
||||||
|
│ │ ├── types.ts # StorageAdapter interface
|
||||||
|
│ │ ├── index.ts # Factory function
|
||||||
|
│ │ └── adapters/
|
||||||
|
│ │ ├── postgres.ts # MOVED from @mosaic/db
|
||||||
|
│ │ ├── sqlite.ts # NEW: SQLite adapter
|
||||||
|
│ │ └── files.ts # NEW: JSON/MD adapter
|
||||||
|
│ └── package.json
|
||||||
|
└── memory/
|
||||||
|
└── src/
|
||||||
|
├── types.ts # UPDATED: MemoryAdapter interface
|
||||||
|
├── index.ts # UPDATED: Factory function
|
||||||
|
└── adapters/
|
||||||
|
├── pgvector.ts # EXTRACTED from existing code
|
||||||
|
├── sqlite-vec.ts # NEW: SQLite with vectors
|
||||||
|
└── keyword.ts # NEW: TF-IDF search
|
||||||
|
```
|
||||||
|
|
||||||
|
### Modified Files
|
||||||
|
|
||||||
|
```
|
||||||
|
packages/
|
||||||
|
├── db/ # DEPRECATED: Logic moved to storage adapters
|
||||||
|
├── queue/
|
||||||
|
│ └── src/
|
||||||
|
│ └── queue.ts # → adapters/bullmq.ts
|
||||||
|
├── memory/
|
||||||
|
│ ├── src/
|
||||||
|
│ │ ├── memory.ts # → use factory
|
||||||
|
│ │ ├── insights.ts # → use factory
|
||||||
|
│ │ └── preferences.ts # → use factory
|
||||||
|
│ └── package.json # Remove pgvector from dependencies
|
||||||
|
└── gateway/
|
||||||
|
└── src/
|
||||||
|
├── database/
|
||||||
|
│ └── database.module.ts # Update to use storage factory
|
||||||
|
├── memory/
|
||||||
|
│ └── memory.module.ts # Update to use memory factory
|
||||||
|
└── queue/
|
||||||
|
└── queue.module.ts # Update to use queue factory
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Breaking Changes
|
||||||
|
|
||||||
|
1. **`@mosaic/db`** → **`@mosaic/storage`** (with migration guide)
|
||||||
|
2. Direct `ioredis` imports → Use `@mosaic/queue` factory
|
||||||
|
3. Direct `pgvector` queries → Use `@mosaic/memory` factory
|
||||||
|
4. Gateway startup now requires storage config (defaults to local)
|
||||||
|
|
||||||
|
## Non-Breaking Migration Path
|
||||||
|
|
||||||
|
1. Existing deployments with Postgres/Valkey continue to work (default config)
|
||||||
|
2. New deployments can choose local tier
|
||||||
|
3. Migration commands available when ready to upgrade
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Success Criteria
|
||||||
|
|
||||||
|
- [ ] Local tier runs with zero external dependencies
|
||||||
|
- [ ] All three tiers (local, team, enterprise) work correctly
|
||||||
|
- [ ] Factory pattern correctly selects backend at runtime
|
||||||
|
- [ ] Migration from local → team preserves all data
|
||||||
|
- [ ] Dream mode consolidates 24h of sessions
|
||||||
|
- [ ] Documentation covers all three tiers and migration paths
|
||||||
|
- [ ] All existing tests pass
|
||||||
|
- [ ] New adapters have >80% coverage
|
||||||
6
mosaic.config.json
Normal file
6
mosaic.config.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"tier": "local",
|
||||||
|
"storage": { "type": "sqlite", "path": ".mosaic/data.db" },
|
||||||
|
"queue": { "type": "local", "dataDir": ".mosaic/queue" },
|
||||||
|
"memory": { "type": "keyword" }
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mosaic/agent",
|
"name": "@mosaic/agent",
|
||||||
"version": "0.0.1-alpha.2",
|
"version": "0.0.2",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mosaic/auth",
|
"name": "@mosaic/auth",
|
||||||
"version": "0.0.1-alpha.2",
|
"version": "0.0.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mosaic/brain",
|
"name": "@mosaic/brain",
|
||||||
"version": "0.0.1-alpha.2",
|
"version": "0.0.2",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mosaic/cli",
|
"name": "@mosaic/cli",
|
||||||
"version": "0.0.1-alpha.2",
|
"version": "0.0.10",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
@@ -22,6 +22,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@clack/prompts": "^0.9.0",
|
"@clack/prompts": "^0.9.0",
|
||||||
|
"@mosaic/config": "workspace:^",
|
||||||
"@mosaic/mosaic": "workspace:^",
|
"@mosaic/mosaic": "workspace:^",
|
||||||
"@mosaic/prdy": "workspace:^",
|
"@mosaic/prdy": "workspace:^",
|
||||||
"@mosaic/quality-rails": "workspace:^",
|
"@mosaic/quality-rails": "workspace:^",
|
||||||
|
|||||||
@@ -2,11 +2,12 @@
|
|||||||
|
|
||||||
import { createRequire } from 'module';
|
import { createRequire } from 'module';
|
||||||
import { Command } from 'commander';
|
import { Command } from 'commander';
|
||||||
import { createQualityRailsCli } from '@mosaic/quality-rails';
|
import { registerQualityRails } from '@mosaic/quality-rails';
|
||||||
import { registerAgentCommand } from './commands/agent.js';
|
import { registerAgentCommand } from './commands/agent.js';
|
||||||
import { registerMissionCommand } from './commands/mission.js';
|
import { registerMissionCommand } from './commands/mission.js';
|
||||||
import { registerPrdyCommand } from './commands/prdy.js';
|
// prdy is registered via launch.ts
|
||||||
import { registerLaunchCommands } from './commands/launch.js';
|
import { registerLaunchCommands } from './commands/launch.js';
|
||||||
|
import { registerGatewayCommand } from './commands/gateway.js';
|
||||||
|
|
||||||
const _require = createRequire(import.meta.url);
|
const _require = createRequire(import.meta.url);
|
||||||
const CLI_VERSION: string = (_require('../package.json') as { version: string }).version;
|
const CLI_VERSION: string = (_require('../package.json') as { version: string }).version;
|
||||||
@@ -290,6 +291,10 @@ sessionsCmd
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ─── gateway ──────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
registerGatewayCommand(program);
|
||||||
|
|
||||||
// ─── agent ─────────────────────────────────────────────────────────────
|
// ─── agent ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
registerAgentCommand(program);
|
registerAgentCommand(program);
|
||||||
@@ -298,17 +303,9 @@ registerAgentCommand(program);
|
|||||||
|
|
||||||
registerMissionCommand(program);
|
registerMissionCommand(program);
|
||||||
|
|
||||||
// ─── prdy ──────────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
registerPrdyCommand(program);
|
|
||||||
|
|
||||||
// ─── quality-rails ──────────────────────────────────────────────────────
|
// ─── quality-rails ──────────────────────────────────────────────────────
|
||||||
|
|
||||||
const qrWrapper = createQualityRailsCli();
|
registerQualityRails(program);
|
||||||
const qrCmd = qrWrapper.commands.find((c) => c.name() === 'quality-rails');
|
|
||||||
if (qrCmd !== undefined) {
|
|
||||||
program.addCommand(qrCmd as unknown as Command);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ─── update ─────────────────────────────────────────────────────────────
|
// ─── update ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
|||||||
198
packages/cli/src/commands/gateway.ts
Normal file
198
packages/cli/src/commands/gateway.ts
Normal file
@@ -0,0 +1,198 @@
|
|||||||
|
import { createInterface } from 'node:readline';
|
||||||
|
import { spawn } from 'node:child_process';
|
||||||
|
import { existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from 'node:fs';
|
||||||
|
import { dirname, resolve } from 'node:path';
|
||||||
|
import type { Command } from 'commander';
|
||||||
|
import {
|
||||||
|
DEFAULT_LOCAL_CONFIG,
|
||||||
|
DEFAULT_TEAM_CONFIG,
|
||||||
|
loadConfig,
|
||||||
|
type MosaicConfig,
|
||||||
|
type StorageTier,
|
||||||
|
} from '@mosaic/config';
|
||||||
|
|
||||||
|
function ask(rl: ReturnType<typeof createInterface>, question: string): Promise<string> {
|
||||||
|
return new Promise((res) => rl.question(question, res));
|
||||||
|
}
|
||||||
|
|
||||||
|
async function runInit(opts: { tier?: string; output: string }): Promise<void> {
|
||||||
|
const outputPath = resolve(opts.output);
|
||||||
|
let tier: StorageTier;
|
||||||
|
|
||||||
|
if (opts.tier) {
|
||||||
|
if (opts.tier !== 'local' && opts.tier !== 'team') {
|
||||||
|
console.error(`Invalid tier "${opts.tier}" — expected "local" or "team"`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
tier = opts.tier;
|
||||||
|
} else {
|
||||||
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
||||||
|
const answer = await ask(rl, 'Select tier (local/team) [local]: ');
|
||||||
|
rl.close();
|
||||||
|
const trimmed = answer.trim().toLowerCase();
|
||||||
|
tier = trimmed === 'team' ? 'team' : 'local';
|
||||||
|
}
|
||||||
|
|
||||||
|
let config: MosaicConfig;
|
||||||
|
|
||||||
|
if (tier === 'local') {
|
||||||
|
config = DEFAULT_LOCAL_CONFIG;
|
||||||
|
} else {
|
||||||
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
||||||
|
const dbUrl = await ask(
|
||||||
|
rl,
|
||||||
|
'DATABASE_URL [postgresql://mosaic:mosaic@localhost:5432/mosaic]: ',
|
||||||
|
);
|
||||||
|
const valkeyUrl = await ask(rl, 'VALKEY_URL [redis://localhost:6379]: ');
|
||||||
|
rl.close();
|
||||||
|
|
||||||
|
config = {
|
||||||
|
...DEFAULT_TEAM_CONFIG,
|
||||||
|
storage: {
|
||||||
|
type: 'postgres',
|
||||||
|
url: dbUrl.trim() || 'postgresql://mosaic:mosaic@localhost:5432/mosaic',
|
||||||
|
},
|
||||||
|
queue: {
|
||||||
|
type: 'bullmq',
|
||||||
|
url: valkeyUrl.trim() || 'redis://localhost:6379',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
writeFileSync(outputPath, JSON.stringify(config, null, 2) + '\n');
|
||||||
|
console.log(`\nWrote ${outputPath}`);
|
||||||
|
console.log('\nNext steps:');
|
||||||
|
console.log(' 1. Review the generated config');
|
||||||
|
console.log(' 2. Run: pnpm --filter @mosaic/gateway exec tsx src/main.ts');
|
||||||
|
}
|
||||||
|
|
||||||
|
const PID_FILE = resolve(process.cwd(), '.mosaic/gateway.pid');
|
||||||
|
|
||||||
|
function writePidFile(pid: number): void {
|
||||||
|
const dir = dirname(PID_FILE);
|
||||||
|
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
||||||
|
writeFileSync(PID_FILE, String(pid));
|
||||||
|
}
|
||||||
|
|
||||||
|
function readPidFile(): number | null {
|
||||||
|
if (!existsSync(PID_FILE)) return null;
|
||||||
|
const raw = readFileSync(PID_FILE, 'utf-8').trim();
|
||||||
|
const pid = Number(raw);
|
||||||
|
return Number.isFinite(pid) ? pid : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isProcessRunning(pid: number): boolean {
|
||||||
|
try {
|
||||||
|
process.kill(pid, 0);
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function printConfigSummary(config: MosaicConfig): void {
|
||||||
|
console.log(` Tier: ${config.tier}`);
|
||||||
|
console.log(` Storage: ${config.storage.type}`);
|
||||||
|
console.log(` Queue: ${config.queue.type}`);
|
||||||
|
console.log(` Memory: ${config.memory.type}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function registerGatewayCommand(program: Command): void {
|
||||||
|
const gateway = program.command('gateway').description('Gateway management commands');
|
||||||
|
|
||||||
|
gateway
|
||||||
|
.command('init')
|
||||||
|
.description('Generate a mosaic.config.json for the gateway')
|
||||||
|
.option('--tier <tier>', 'Storage tier: local or team (skips interactive prompt)')
|
||||||
|
.option('--output <path>', 'Output file path', './mosaic.config.json')
|
||||||
|
.action(async (opts: { tier?: string; output: string }) => {
|
||||||
|
await runInit(opts);
|
||||||
|
});
|
||||||
|
|
||||||
|
gateway
|
||||||
|
.command('start')
|
||||||
|
.description('Start the Mosaic gateway process')
|
||||||
|
.option('--port <port>', 'Port to listen on (overrides config)')
|
||||||
|
.option('--daemon', 'Run in background and write PID to .mosaic/gateway.pid')
|
||||||
|
.action((opts: { port?: string; daemon?: boolean }) => {
|
||||||
|
const config = loadConfig();
|
||||||
|
const port = opts.port ?? '4000';
|
||||||
|
|
||||||
|
console.log('Starting gateway…');
|
||||||
|
printConfigSummary(config);
|
||||||
|
console.log(` Port: ${port}`);
|
||||||
|
|
||||||
|
const entryPoint = resolve(process.cwd(), 'apps/gateway/src/main.ts');
|
||||||
|
const env = { ...process.env, GATEWAY_PORT: port };
|
||||||
|
|
||||||
|
if (opts.daemon) {
|
||||||
|
const child = spawn('npx', ['tsx', entryPoint], {
|
||||||
|
env,
|
||||||
|
stdio: 'ignore',
|
||||||
|
detached: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
child.unref();
|
||||||
|
|
||||||
|
if (child.pid) {
|
||||||
|
writePidFile(child.pid);
|
||||||
|
console.log(`\nGateway started in background (PID ${child.pid})`);
|
||||||
|
console.log(`PID file: ${PID_FILE}`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const child = spawn('npx', ['tsx', entryPoint], {
|
||||||
|
env,
|
||||||
|
stdio: 'inherit',
|
||||||
|
});
|
||||||
|
|
||||||
|
child.on('exit', (code) => {
|
||||||
|
process.exit(code ?? 0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
gateway
|
||||||
|
.command('stop')
|
||||||
|
.description('Stop the running gateway process')
|
||||||
|
.action(() => {
|
||||||
|
const pid = readPidFile();
|
||||||
|
|
||||||
|
if (pid === null) {
|
||||||
|
console.error('No PID file found at', PID_FILE);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isProcessRunning(pid)) {
|
||||||
|
console.log(`Process ${pid} is not running. Removing stale PID file.`);
|
||||||
|
unlinkSync(PID_FILE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
process.kill(pid, 'SIGTERM');
|
||||||
|
unlinkSync(PID_FILE);
|
||||||
|
console.log(`Gateway stopped (PID ${pid})`);
|
||||||
|
});
|
||||||
|
|
||||||
|
gateway
|
||||||
|
.command('status')
|
||||||
|
.description('Show gateway process status')
|
||||||
|
.action(() => {
|
||||||
|
const config = loadConfig();
|
||||||
|
const pid = readPidFile();
|
||||||
|
|
||||||
|
if (pid !== null && isProcessRunning(pid)) {
|
||||||
|
console.log('Gateway: running');
|
||||||
|
console.log(` PID: ${pid}`);
|
||||||
|
} else {
|
||||||
|
console.log('Gateway: stopped');
|
||||||
|
if (pid !== null) {
|
||||||
|
console.log(` (stale PID file for ${pid})`);
|
||||||
|
unlinkSync(PID_FILE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('');
|
||||||
|
console.log('Config:');
|
||||||
|
printConfigSummary(config);
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
import { execFileSync, execSync, spawnSync } from 'node:child_process';
|
import { execFileSync, execSync, spawnSync } from 'node:child_process';
|
||||||
import { existsSync, mkdirSync, readFileSync, writeFileSync, readdirSync, rmSync } from 'node:fs';
|
import { existsSync, mkdirSync, readFileSync, writeFileSync, readdirSync, rmSync } from 'node:fs';
|
||||||
|
import { createRequire } from 'node:module';
|
||||||
import { homedir } from 'node:os';
|
import { homedir } from 'node:os';
|
||||||
import { join, dirname } from 'node:path';
|
import { join, dirname } from 'node:path';
|
||||||
import type { Command } from 'commander';
|
import type { Command } from 'commander';
|
||||||
@@ -54,19 +55,31 @@ function checkRuntime(cmd: string): void {
|
|||||||
function checkSoul(): void {
|
function checkSoul(): void {
|
||||||
const soulPath = join(MOSAIC_HOME, 'SOUL.md');
|
const soulPath = join(MOSAIC_HOME, 'SOUL.md');
|
||||||
if (!existsSync(soulPath)) {
|
if (!existsSync(soulPath)) {
|
||||||
console.log('[mosaic] SOUL.md not found. Running mosaic init...');
|
console.log('[mosaic] SOUL.md not found. Running setup wizard...');
|
||||||
const initBin = join(MOSAIC_HOME, 'tools', '_scripts', 'mosaic-init');
|
|
||||||
|
// Prefer the TypeScript wizard (idempotent, detects existing files)
|
||||||
|
try {
|
||||||
|
const result = spawnSync(process.execPath, [process.argv[1]!, 'wizard'], {
|
||||||
|
stdio: 'inherit',
|
||||||
|
});
|
||||||
|
if (result.status === 0 && existsSync(soulPath)) return;
|
||||||
|
} catch {
|
||||||
|
// Fall through to legacy init
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback: legacy bash mosaic-init
|
||||||
|
const initBin = fwScript('mosaic-init');
|
||||||
if (existsSync(initBin)) {
|
if (existsSync(initBin)) {
|
||||||
spawnSync(initBin, [], { stdio: 'inherit' });
|
spawnSync(initBin, [], { stdio: 'inherit' });
|
||||||
} else {
|
} else {
|
||||||
console.error('[mosaic] mosaic-init not found. Run: mosaic wizard');
|
console.error('[mosaic] Setup failed. Run: mosaic wizard');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkSequentialThinking(runtime: string): void {
|
function checkSequentialThinking(runtime: string): void {
|
||||||
const checker = join(MOSAIC_HOME, 'tools', '_scripts', 'mosaic-ensure-sequential-thinking');
|
const checker = fwScript('mosaic-ensure-sequential-thinking');
|
||||||
if (!existsSync(checker)) return; // Skip if checker doesn't exist
|
if (!existsSync(checker)) return; // Skip if checker doesn't exist
|
||||||
const result = spawnSync(checker, ['--check', '--runtime', runtime], { stdio: 'ignore' });
|
const result = spawnSync(checker, ['--check', '--runtime', runtime], { stdio: 'ignore' });
|
||||||
if (result.status !== 0) {
|
if (result.status !== 0) {
|
||||||
@@ -461,23 +474,208 @@ function execRuntime(cmd: string, args: string[]): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── Framework script delegation (for tools that remain in bash) ─────────────
|
// ─── Framework script/tool delegation ───────────────────────────────────────
|
||||||
|
|
||||||
function delegateToFrameworkScript(script: string, args: string[]): never {
|
function delegateToScript(scriptPath: string, args: string[], env?: Record<string, string>): never {
|
||||||
const scriptPath = join(MOSAIC_HOME, 'tools', '_scripts', script);
|
|
||||||
if (!existsSync(scriptPath)) {
|
if (!existsSync(scriptPath)) {
|
||||||
console.error(`[mosaic] Script not found: ${scriptPath}`);
|
console.error(`[mosaic] Script not found: ${scriptPath}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
execFileSync(scriptPath, args, { stdio: 'inherit' });
|
execFileSync('bash', [scriptPath, ...args], {
|
||||||
|
stdio: 'inherit',
|
||||||
|
env: { ...process.env, ...env },
|
||||||
|
});
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
process.exit((err as { status?: number }).status ?? 1);
|
process.exit((err as { status?: number }).status ?? 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── Commander registration ──────────────────────────────────────────────────
|
/**
|
||||||
|
* Resolve a path under the framework tools directory. Prefers the version
|
||||||
|
* bundled in the @mosaic/mosaic npm package (always matches the installed
|
||||||
|
* CLI version) over the deployed copy in ~/.config/mosaic/ (may be stale).
|
||||||
|
*/
|
||||||
|
function resolveTool(...segments: string[]): string {
|
||||||
|
try {
|
||||||
|
const req = createRequire(import.meta.url);
|
||||||
|
const mosaicPkg = dirname(req.resolve('@mosaic/mosaic/package.json'));
|
||||||
|
const bundled = join(mosaicPkg, 'framework', 'tools', ...segments);
|
||||||
|
if (existsSync(bundled)) return bundled;
|
||||||
|
} catch {
|
||||||
|
// Fall through to deployed copy
|
||||||
|
}
|
||||||
|
return join(MOSAIC_HOME, 'tools', ...segments);
|
||||||
|
}
|
||||||
|
|
||||||
|
function fwScript(name: string): string {
|
||||||
|
return resolveTool('_scripts', name);
|
||||||
|
}
|
||||||
|
|
||||||
|
function toolScript(toolDir: string, name: string): string {
|
||||||
|
return resolveTool(toolDir, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─── Coord (mission orchestrator) ───────────────────────────────────────────
|
||||||
|
|
||||||
|
const COORD_SUBCMDS: Record<string, string> = {
|
||||||
|
status: 'session-status.sh',
|
||||||
|
session: 'session-status.sh',
|
||||||
|
init: 'mission-init.sh',
|
||||||
|
mission: 'mission-status.sh',
|
||||||
|
progress: 'mission-status.sh',
|
||||||
|
continue: 'continue-prompt.sh',
|
||||||
|
next: 'continue-prompt.sh',
|
||||||
|
run: 'session-run.sh',
|
||||||
|
start: 'session-run.sh',
|
||||||
|
smoke: 'smoke-test.sh',
|
||||||
|
test: 'smoke-test.sh',
|
||||||
|
resume: 'session-resume.sh',
|
||||||
|
recover: 'session-resume.sh',
|
||||||
|
};
|
||||||
|
|
||||||
|
function runCoord(args: string[]): never {
|
||||||
|
checkMosaicHome();
|
||||||
|
let runtime = 'claude';
|
||||||
|
let yoloFlag = '';
|
||||||
|
const coordArgs: string[] = [];
|
||||||
|
|
||||||
|
for (const arg of args) {
|
||||||
|
if (arg === '--claude' || arg === '--codex' || arg === '--pi') {
|
||||||
|
runtime = arg.slice(2);
|
||||||
|
} else if (arg === '--yolo') {
|
||||||
|
yoloFlag = '--yolo';
|
||||||
|
} else {
|
||||||
|
coordArgs.push(arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const subcmd = coordArgs[0] ?? 'help';
|
||||||
|
const subArgs = coordArgs.slice(1);
|
||||||
|
const script = COORD_SUBCMDS[subcmd];
|
||||||
|
|
||||||
|
if (!script) {
|
||||||
|
console.log(`mosaic coord — mission coordinator tools
|
||||||
|
|
||||||
|
Commands:
|
||||||
|
init --name <name> [opts] Initialize a new mission
|
||||||
|
mission [--project <path>] Show mission progress dashboard
|
||||||
|
status [--project <path>] Check agent session health
|
||||||
|
continue [--project <path>] Generate continuation prompt
|
||||||
|
run [--project <path>] Launch runtime with mission context
|
||||||
|
smoke Run orchestration smoke checks
|
||||||
|
resume [--project <path>] Crash recovery
|
||||||
|
|
||||||
|
Runtime: --claude (default) | --codex | --pi | --yolo`);
|
||||||
|
process.exit(subcmd === 'help' ? 0 : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (yoloFlag) subArgs.unshift(yoloFlag);
|
||||||
|
delegateToScript(toolScript('orchestrator', script), subArgs, {
|
||||||
|
MOSAIC_COORD_RUNTIME: runtime,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─── Prdy (PRD tools via framework scripts) ─────────────────────────────────
|
||||||
|
|
||||||
|
const PRDY_SUBCMDS: Record<string, string> = {
|
||||||
|
init: 'prdy-init.sh',
|
||||||
|
update: 'prdy-update.sh',
|
||||||
|
validate: 'prdy-validate.sh',
|
||||||
|
check: 'prdy-validate.sh',
|
||||||
|
status: 'prdy-status.sh',
|
||||||
|
};
|
||||||
|
|
||||||
|
function runPrdyLocal(args: string[]): never {
|
||||||
|
checkMosaicHome();
|
||||||
|
let runtime = 'claude';
|
||||||
|
const prdyArgs: string[] = [];
|
||||||
|
|
||||||
|
for (const arg of args) {
|
||||||
|
if (arg === '--claude' || arg === '--codex' || arg === '--pi') {
|
||||||
|
runtime = arg.slice(2);
|
||||||
|
} else {
|
||||||
|
prdyArgs.push(arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const subcmd = prdyArgs[0] ?? 'help';
|
||||||
|
const subArgs = prdyArgs.slice(1);
|
||||||
|
const script = PRDY_SUBCMDS[subcmd];
|
||||||
|
|
||||||
|
if (!script) {
|
||||||
|
console.log(`mosaic prdy — PRD creation and validation
|
||||||
|
|
||||||
|
Commands:
|
||||||
|
init [--project <path>] [--name <feature>] Create docs/PRD.md
|
||||||
|
update [--project <path>] Update existing PRD
|
||||||
|
validate [--project <path>] Check PRD completeness
|
||||||
|
status [--project <path>] Quick PRD health check
|
||||||
|
|
||||||
|
Runtime: --claude (default) | --codex | --pi`);
|
||||||
|
process.exit(subcmd === 'help' ? 0 : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
delegateToScript(toolScript('prdy', script), subArgs, {
|
||||||
|
MOSAIC_PRDY_RUNTIME: runtime,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─── Seq (sequential-thinking MCP) ──────────────────────────────────────────
|
||||||
|
|
||||||
|
function runSeq(args: string[]): never {
|
||||||
|
checkMosaicHome();
|
||||||
|
const action = args[0] ?? 'check';
|
||||||
|
const rest = args.slice(1);
|
||||||
|
const checker = fwScript('mosaic-ensure-sequential-thinking');
|
||||||
|
|
||||||
|
switch (action) {
|
||||||
|
case 'check':
|
||||||
|
delegateToScript(checker, ['--check', ...rest]);
|
||||||
|
break; // unreachable
|
||||||
|
case 'fix':
|
||||||
|
case 'apply':
|
||||||
|
delegateToScript(checker, rest);
|
||||||
|
break;
|
||||||
|
case 'start': {
|
||||||
|
console.log('[mosaic] Starting sequential-thinking MCP server...');
|
||||||
|
try {
|
||||||
|
execFileSync('npx', ['-y', '@modelcontextprotocol/server-sequential-thinking', ...rest], {
|
||||||
|
stdio: 'inherit',
|
||||||
|
});
|
||||||
|
process.exit(0);
|
||||||
|
} catch (err) {
|
||||||
|
process.exit((err as { status?: number }).status ?? 1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
console.error(`[mosaic] Unknown seq subcommand '${action}'. Use: check|fix|start`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─── Upgrade ────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
function runUpgrade(args: string[]): never {
|
||||||
|
checkMosaicHome();
|
||||||
|
const subcmd = args[0];
|
||||||
|
|
||||||
|
if (!subcmd || subcmd === 'release') {
|
||||||
|
delegateToScript(fwScript('mosaic-release-upgrade'), args.slice(subcmd === 'release' ? 1 : 0));
|
||||||
|
} else if (subcmd === 'check') {
|
||||||
|
delegateToScript(fwScript('mosaic-release-upgrade'), ['--dry-run', ...args.slice(1)]);
|
||||||
|
} else if (subcmd === 'project') {
|
||||||
|
delegateToScript(fwScript('mosaic-upgrade'), args.slice(1));
|
||||||
|
} else if (subcmd.startsWith('-')) {
|
||||||
|
delegateToScript(fwScript('mosaic-release-upgrade'), args);
|
||||||
|
} else {
|
||||||
|
delegateToScript(fwScript('mosaic-upgrade'), args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─── Commander registration ─────────────────────────────────────────────────
|
||||||
|
|
||||||
export function registerLaunchCommands(program: Command): void {
|
export function registerLaunchCommands(program: Command): void {
|
||||||
// Runtime launchers
|
// Runtime launchers
|
||||||
@@ -509,15 +707,58 @@ export function registerLaunchCommands(program: Command): void {
|
|||||||
launchRuntime(runtime as RuntimeName, cmd.args, true);
|
launchRuntime(runtime as RuntimeName, cmd.args, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Framework management commands (delegate to bash scripts)
|
// Coord (mission orchestrator)
|
||||||
const frameworkCommands: Record<string, { desc: string; script: string }> = {
|
program
|
||||||
|
.command('coord')
|
||||||
|
.description('Mission coordinator tools (init, status, run, continue, resume)')
|
||||||
|
.allowUnknownOption(true)
|
||||||
|
.allowExcessArguments(true)
|
||||||
|
.action((_opts: unknown, cmd: Command) => {
|
||||||
|
runCoord(cmd.args);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Prdy (PRD tools via local framework scripts)
|
||||||
|
program
|
||||||
|
.command('prdy')
|
||||||
|
.description('PRD creation and validation (init, update, validate, status)')
|
||||||
|
.allowUnknownOption(true)
|
||||||
|
.allowExcessArguments(true)
|
||||||
|
.action((_opts: unknown, cmd: Command) => {
|
||||||
|
runPrdyLocal(cmd.args);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Seq (sequential-thinking MCP management)
|
||||||
|
program
|
||||||
|
.command('seq')
|
||||||
|
.description('sequential-thinking MCP management (check/fix/start)')
|
||||||
|
.allowUnknownOption(true)
|
||||||
|
.allowExcessArguments(true)
|
||||||
|
.action((_opts: unknown, cmd: Command) => {
|
||||||
|
runSeq(cmd.args);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Upgrade (release + project)
|
||||||
|
program
|
||||||
|
.command('upgrade')
|
||||||
|
.description('Upgrade Mosaic release or project files')
|
||||||
|
.allowUnknownOption(true)
|
||||||
|
.allowExcessArguments(true)
|
||||||
|
.action((_opts: unknown, cmd: Command) => {
|
||||||
|
runUpgrade(cmd.args);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Direct framework script delegates
|
||||||
|
const directCommands: Record<string, { desc: string; script: string }> = {
|
||||||
init: { desc: 'Generate SOUL.md (agent identity contract)', script: 'mosaic-init' },
|
init: { desc: 'Generate SOUL.md (agent identity contract)', script: 'mosaic-init' },
|
||||||
doctor: { desc: 'Health audit — detect drift and missing files', script: 'mosaic-doctor' },
|
doctor: { desc: 'Health audit — detect drift and missing files', script: 'mosaic-doctor' },
|
||||||
sync: { desc: 'Sync skills from canonical source', script: 'mosaic-sync-skills' },
|
sync: { desc: 'Sync skills from canonical source', script: 'mosaic-sync-skills' },
|
||||||
bootstrap: { desc: 'Bootstrap a repo with Mosaic standards', script: 'mosaic-bootstrap-repo' },
|
bootstrap: {
|
||||||
|
desc: 'Bootstrap a repo with Mosaic standards',
|
||||||
|
script: 'mosaic-bootstrap-repo',
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const [name, { desc, script }] of Object.entries(frameworkCommands)) {
|
for (const [name, { desc, script }] of Object.entries(directCommands)) {
|
||||||
program
|
program
|
||||||
.command(name)
|
.command(name)
|
||||||
.description(desc)
|
.description(desc)
|
||||||
@@ -525,7 +766,7 @@ export function registerLaunchCommands(program: Command): void {
|
|||||||
.allowExcessArguments(true)
|
.allowExcessArguments(true)
|
||||||
.action((_opts: unknown, cmd: Command) => {
|
.action((_opts: unknown, cmd: Command) => {
|
||||||
checkMosaicHome();
|
checkMosaicHome();
|
||||||
delegateToFrameworkScript(script, cmd.args);
|
delegateToScript(fwScript(script), cmd.args);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
35
packages/config/package.json
Normal file
35
packages/config/package.json
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"name": "@mosaic/config",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"type": "module",
|
||||||
|
"main": "dist/index.js",
|
||||||
|
"types": "dist/index.d.ts",
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"types": "./dist/index.d.ts",
|
||||||
|
"default": "./dist/index.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "tsc",
|
||||||
|
"lint": "eslint src",
|
||||||
|
"typecheck": "tsc --noEmit",
|
||||||
|
"test": "vitest run --passWithNoTests"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@mosaic/memory": "workspace:^",
|
||||||
|
"@mosaic/queue": "workspace:^",
|
||||||
|
"@mosaic/storage": "workspace:^"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"typescript": "^5.8.0",
|
||||||
|
"vitest": "^2.0.0"
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"registry": "https://git.mosaicstack.dev/api/packages/mosaic/npm/",
|
||||||
|
"access": "public"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"dist"
|
||||||
|
]
|
||||||
|
}
|
||||||
7
packages/config/src/index.ts
Normal file
7
packages/config/src/index.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
export type { MosaicConfig, StorageTier, MemoryConfigRef } from './mosaic-config.js';
|
||||||
|
export {
|
||||||
|
DEFAULT_LOCAL_CONFIG,
|
||||||
|
DEFAULT_TEAM_CONFIG,
|
||||||
|
loadConfig,
|
||||||
|
validateConfig,
|
||||||
|
} from './mosaic-config.js';
|
||||||
140
packages/config/src/mosaic-config.ts
Normal file
140
packages/config/src/mosaic-config.ts
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
import { readFileSync, existsSync } from 'node:fs';
|
||||||
|
import { resolve } from 'node:path';
|
||||||
|
import type { StorageConfig } from '@mosaic/storage';
|
||||||
|
import type { QueueAdapterConfig as QueueConfig } from '@mosaic/queue';
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
/* Types */
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
export type StorageTier = 'local' | 'team';
|
||||||
|
|
||||||
|
export interface MemoryConfigRef {
|
||||||
|
type: 'pgvector' | 'sqlite-vec' | 'keyword';
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MosaicConfig {
|
||||||
|
tier: StorageTier;
|
||||||
|
storage: StorageConfig;
|
||||||
|
queue: QueueConfig;
|
||||||
|
memory: MemoryConfigRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
/* Defaults */
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
export const DEFAULT_LOCAL_CONFIG: MosaicConfig = {
|
||||||
|
tier: 'local',
|
||||||
|
storage: { type: 'sqlite', path: '.mosaic/data.db' },
|
||||||
|
queue: { type: 'local', dataDir: '.mosaic/queue' },
|
||||||
|
memory: { type: 'keyword' },
|
||||||
|
};
|
||||||
|
|
||||||
|
export const DEFAULT_TEAM_CONFIG: MosaicConfig = {
|
||||||
|
tier: 'team',
|
||||||
|
storage: { type: 'postgres', url: 'postgresql://mosaic:mosaic@localhost:5432/mosaic' },
|
||||||
|
queue: { type: 'bullmq' },
|
||||||
|
memory: { type: 'pgvector' },
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
/* Validation */
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
const VALID_TIERS = new Set<string>(['local', 'team']);
|
||||||
|
const VALID_STORAGE_TYPES = new Set<string>(['postgres', 'sqlite', 'files']);
|
||||||
|
const VALID_QUEUE_TYPES = new Set<string>(['bullmq', 'local']);
|
||||||
|
const VALID_MEMORY_TYPES = new Set<string>(['pgvector', 'sqlite-vec', 'keyword']);
|
||||||
|
|
||||||
|
export function validateConfig(raw: unknown): MosaicConfig {
|
||||||
|
if (typeof raw !== 'object' || raw === null) {
|
||||||
|
throw new Error('MosaicConfig must be a non-null object');
|
||||||
|
}
|
||||||
|
|
||||||
|
const obj = raw as Record<string, unknown>;
|
||||||
|
|
||||||
|
// tier
|
||||||
|
const tier = obj['tier'];
|
||||||
|
if (typeof tier !== 'string' || !VALID_TIERS.has(tier)) {
|
||||||
|
throw new Error(`Invalid tier "${String(tier)}" — expected "local" or "team"`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// storage
|
||||||
|
const storage = obj['storage'];
|
||||||
|
if (typeof storage !== 'object' || storage === null) {
|
||||||
|
throw new Error('config.storage must be a non-null object');
|
||||||
|
}
|
||||||
|
const storageType = (storage as Record<string, unknown>)['type'];
|
||||||
|
if (typeof storageType !== 'string' || !VALID_STORAGE_TYPES.has(storageType)) {
|
||||||
|
throw new Error(`Invalid storage.type "${String(storageType)}"`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// queue
|
||||||
|
const queue = obj['queue'];
|
||||||
|
if (typeof queue !== 'object' || queue === null) {
|
||||||
|
throw new Error('config.queue must be a non-null object');
|
||||||
|
}
|
||||||
|
const queueType = (queue as Record<string, unknown>)['type'];
|
||||||
|
if (typeof queueType !== 'string' || !VALID_QUEUE_TYPES.has(queueType)) {
|
||||||
|
throw new Error(`Invalid queue.type "${String(queueType)}"`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// memory
|
||||||
|
const memory = obj['memory'];
|
||||||
|
if (typeof memory !== 'object' || memory === null) {
|
||||||
|
throw new Error('config.memory must be a non-null object');
|
||||||
|
}
|
||||||
|
const memoryType = (memory as Record<string, unknown>)['type'];
|
||||||
|
if (typeof memoryType !== 'string' || !VALID_MEMORY_TYPES.has(memoryType)) {
|
||||||
|
throw new Error(`Invalid memory.type "${String(memoryType)}"`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
tier: tier as StorageTier,
|
||||||
|
storage: storage as StorageConfig,
|
||||||
|
queue: queue as QueueConfig,
|
||||||
|
memory: memory as MemoryConfigRef,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
/* Loader */
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
function detectFromEnv(): MosaicConfig {
|
||||||
|
if (process.env['DATABASE_URL']) {
|
||||||
|
return {
|
||||||
|
...DEFAULT_TEAM_CONFIG,
|
||||||
|
storage: {
|
||||||
|
type: 'postgres',
|
||||||
|
url: process.env['DATABASE_URL'],
|
||||||
|
},
|
||||||
|
queue: {
|
||||||
|
type: 'bullmq',
|
||||||
|
url: process.env['VALKEY_URL'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return DEFAULT_LOCAL_CONFIG;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function loadConfig(configPath?: string): MosaicConfig {
|
||||||
|
// 1. Explicit path or default location
|
||||||
|
const paths = configPath
|
||||||
|
? [resolve(configPath)]
|
||||||
|
: [
|
||||||
|
resolve(process.cwd(), 'mosaic.config.json'),
|
||||||
|
resolve(process.cwd(), '../../mosaic.config.json'), // monorepo root when cwd is apps/gateway
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const p of paths) {
|
||||||
|
if (existsSync(p)) {
|
||||||
|
const raw: unknown = JSON.parse(readFileSync(p, 'utf-8'));
|
||||||
|
return validateConfig(raw);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Fall back to env-var detection
|
||||||
|
return detectFromEnv();
|
||||||
|
}
|
||||||
9
packages/config/tsconfig.json
Normal file
9
packages/config/tsconfig.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../tsconfig.base.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "dist",
|
||||||
|
"rootDir": "src"
|
||||||
|
},
|
||||||
|
"include": ["src/**/*"],
|
||||||
|
"exclude": ["node_modules", "dist"]
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mosaic/coord",
|
"name": "@mosaic/coord",
|
||||||
"version": "0.0.1-alpha.2",
|
"version": "0.0.2",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mosaic/db",
|
"name": "@mosaic/db",
|
||||||
"version": "0.0.1-alpha.2",
|
"version": "0.0.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mosaic/design-tokens",
|
"name": "@mosaic/design-tokens",
|
||||||
"version": "0.0.1-alpha.2",
|
"version": "0.0.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mosaic/forge",
|
"name": "@mosaic/forge",
|
||||||
"version": "0.0.1-alpha.2",
|
"version": "0.0.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mosaic/log",
|
"name": "@mosaic/log",
|
||||||
"version": "0.0.1-alpha.2",
|
"version": "0.0.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mosaic/macp",
|
"name": "@mosaic/macp",
|
||||||
"version": "0.0.1-alpha.2",
|
"version": "0.0.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mosaic/memory",
|
"name": "@mosaic/memory",
|
||||||
"version": "0.0.1-alpha.2",
|
"version": "0.0.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@mosaic/db": "workspace:*",
|
"@mosaic/db": "workspace:*",
|
||||||
|
"@mosaic/storage": "workspace:*",
|
||||||
"@mosaic/types": "workspace:*",
|
"@mosaic/types": "workspace:*",
|
||||||
"drizzle-orm": "^0.45.1"
|
"drizzle-orm": "^0.45.1"
|
||||||
},
|
},
|
||||||
|
|||||||
298
packages/memory/src/adapters/keyword.test.ts
Normal file
298
packages/memory/src/adapters/keyword.test.ts
Normal file
@@ -0,0 +1,298 @@
|
|||||||
|
import { describe, it, expect, beforeEach } from 'vitest';
|
||||||
|
import type { StorageAdapter } from '@mosaic/storage';
|
||||||
|
import { KeywordAdapter } from './keyword.js';
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
/* In-memory mock StorageAdapter */
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
function createMockStorage(): StorageAdapter {
|
||||||
|
const collections = new Map<string, Map<string, Record<string, unknown>>>();
|
||||||
|
let idCounter = 0;
|
||||||
|
|
||||||
|
function getCollection(name: string): Map<string, Record<string, unknown>> {
|
||||||
|
if (!collections.has(name)) collections.set(name, new Map());
|
||||||
|
return collections.get(name)!;
|
||||||
|
}
|
||||||
|
|
||||||
|
const adapter: StorageAdapter = {
|
||||||
|
name: 'mock',
|
||||||
|
|
||||||
|
async create<T extends Record<string, unknown>>(
|
||||||
|
collection: string,
|
||||||
|
data: T,
|
||||||
|
): Promise<T & { id: string }> {
|
||||||
|
const id = String(++idCounter);
|
||||||
|
const record = { ...data, id };
|
||||||
|
getCollection(collection).set(id, record);
|
||||||
|
return record as T & { id: string };
|
||||||
|
},
|
||||||
|
|
||||||
|
async read<T extends Record<string, unknown>>(
|
||||||
|
collection: string,
|
||||||
|
id: string,
|
||||||
|
): Promise<T | null> {
|
||||||
|
const record = getCollection(collection).get(id);
|
||||||
|
return (record as T) ?? null;
|
||||||
|
},
|
||||||
|
|
||||||
|
async update(collection: string, id: string, data: Record<string, unknown>): Promise<boolean> {
|
||||||
|
const col = getCollection(collection);
|
||||||
|
const existing = col.get(id);
|
||||||
|
if (!existing) return false;
|
||||||
|
col.set(id, { ...existing, ...data });
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
|
async delete(collection: string, id: string): Promise<boolean> {
|
||||||
|
return getCollection(collection).delete(id);
|
||||||
|
},
|
||||||
|
|
||||||
|
async find<T extends Record<string, unknown>>(
|
||||||
|
collection: string,
|
||||||
|
filter?: Record<string, unknown>,
|
||||||
|
): Promise<T[]> {
|
||||||
|
const col = getCollection(collection);
|
||||||
|
const results: T[] = [];
|
||||||
|
for (const record of col.values()) {
|
||||||
|
if (filter && !matchesFilter(record, filter)) continue;
|
||||||
|
results.push(record as T);
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
},
|
||||||
|
|
||||||
|
async findOne<T extends Record<string, unknown>>(
|
||||||
|
collection: string,
|
||||||
|
filter: Record<string, unknown>,
|
||||||
|
): Promise<T | null> {
|
||||||
|
const col = getCollection(collection);
|
||||||
|
for (const record of col.values()) {
|
||||||
|
if (matchesFilter(record, filter)) return record as T;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
|
||||||
|
async count(collection: string, filter?: Record<string, unknown>): Promise<number> {
|
||||||
|
const rows = await adapter.find(collection, filter);
|
||||||
|
return rows.length;
|
||||||
|
},
|
||||||
|
|
||||||
|
async transaction<T>(fn: (tx: StorageAdapter) => Promise<T>): Promise<T> {
|
||||||
|
return fn(adapter);
|
||||||
|
},
|
||||||
|
|
||||||
|
async migrate(): Promise<void> {},
|
||||||
|
async close(): Promise<void> {},
|
||||||
|
};
|
||||||
|
|
||||||
|
return adapter;
|
||||||
|
}
|
||||||
|
|
||||||
|
function matchesFilter(record: Record<string, unknown>, filter: Record<string, unknown>): boolean {
|
||||||
|
for (const [key, value] of Object.entries(filter)) {
|
||||||
|
if (record[key] !== value) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
/* Tests */
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
describe('KeywordAdapter', () => {
|
||||||
|
let adapter: KeywordAdapter;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
adapter = new KeywordAdapter({ type: 'keyword', storage: createMockStorage() });
|
||||||
|
});
|
||||||
|
|
||||||
|
/* ---- Preferences ---- */
|
||||||
|
|
||||||
|
describe('preferences', () => {
|
||||||
|
it('should set and get a preference', async () => {
|
||||||
|
await adapter.setPreference('u1', 'theme', 'dark');
|
||||||
|
const value = await adapter.getPreference('u1', 'theme');
|
||||||
|
expect(value).toBe('dark');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return null for missing preference', async () => {
|
||||||
|
const value = await adapter.getPreference('u1', 'nonexistent');
|
||||||
|
expect(value).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should upsert an existing preference', async () => {
|
||||||
|
await adapter.setPreference('u1', 'theme', 'dark');
|
||||||
|
await adapter.setPreference('u1', 'theme', 'light');
|
||||||
|
const value = await adapter.getPreference('u1', 'theme');
|
||||||
|
expect(value).toBe('light');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should delete a preference', async () => {
|
||||||
|
await adapter.setPreference('u1', 'theme', 'dark');
|
||||||
|
const deleted = await adapter.deletePreference('u1', 'theme');
|
||||||
|
expect(deleted).toBe(true);
|
||||||
|
const value = await adapter.getPreference('u1', 'theme');
|
||||||
|
expect(value).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return false when deleting nonexistent preference', async () => {
|
||||||
|
const deleted = await adapter.deletePreference('u1', 'nope');
|
||||||
|
expect(deleted).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should list preferences by userId', async () => {
|
||||||
|
await adapter.setPreference('u1', 'theme', 'dark', 'appearance');
|
||||||
|
await adapter.setPreference('u1', 'lang', 'en', 'locale');
|
||||||
|
await adapter.setPreference('u2', 'theme', 'light', 'appearance');
|
||||||
|
|
||||||
|
const prefs = await adapter.listPreferences('u1');
|
||||||
|
expect(prefs).toHaveLength(2);
|
||||||
|
expect(prefs.map((p) => p.key).sort()).toEqual(['lang', 'theme']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should filter preferences by category', async () => {
|
||||||
|
await adapter.setPreference('u1', 'theme', 'dark', 'appearance');
|
||||||
|
await adapter.setPreference('u1', 'lang', 'en', 'locale');
|
||||||
|
|
||||||
|
const prefs = await adapter.listPreferences('u1', 'appearance');
|
||||||
|
expect(prefs).toHaveLength(1);
|
||||||
|
expect(prefs[0]!.key).toBe('theme');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
/* ---- Insights ---- */
|
||||||
|
|
||||||
|
describe('insights', () => {
|
||||||
|
it('should store and retrieve an insight', async () => {
|
||||||
|
const insight = await adapter.storeInsight({
|
||||||
|
userId: 'u1',
|
||||||
|
content: 'TypeScript is great for type safety',
|
||||||
|
source: 'chat',
|
||||||
|
category: 'technical',
|
||||||
|
relevanceScore: 0.9,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(insight.id).toBeDefined();
|
||||||
|
expect(insight.content).toBe('TypeScript is great for type safety');
|
||||||
|
|
||||||
|
const fetched = await adapter.getInsight(insight.id);
|
||||||
|
expect(fetched).not.toBeNull();
|
||||||
|
expect(fetched!.content).toBe('TypeScript is great for type safety');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return null for missing insight', async () => {
|
||||||
|
const result = await adapter.getInsight('nonexistent');
|
||||||
|
expect(result).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should delete an insight', async () => {
|
||||||
|
const insight = await adapter.storeInsight({
|
||||||
|
userId: 'u1',
|
||||||
|
content: 'test',
|
||||||
|
source: 'chat',
|
||||||
|
category: 'general',
|
||||||
|
relevanceScore: 0.5,
|
||||||
|
});
|
||||||
|
|
||||||
|
const deleted = await adapter.deleteInsight(insight.id);
|
||||||
|
expect(deleted).toBe(true);
|
||||||
|
|
||||||
|
const fetched = await adapter.getInsight(insight.id);
|
||||||
|
expect(fetched).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
/* ---- Keyword Search ---- */
|
||||||
|
|
||||||
|
describe('searchInsights', () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
await adapter.storeInsight({
|
||||||
|
userId: 'u1',
|
||||||
|
content: 'TypeScript provides excellent type safety for JavaScript projects',
|
||||||
|
source: 'chat',
|
||||||
|
category: 'technical',
|
||||||
|
relevanceScore: 0.9,
|
||||||
|
});
|
||||||
|
await adapter.storeInsight({
|
||||||
|
userId: 'u1',
|
||||||
|
content: 'React hooks simplify state management in components',
|
||||||
|
source: 'chat',
|
||||||
|
category: 'technical',
|
||||||
|
relevanceScore: 0.8,
|
||||||
|
});
|
||||||
|
await adapter.storeInsight({
|
||||||
|
userId: 'u1',
|
||||||
|
content: 'TypeScript and React work great together for type safe components',
|
||||||
|
source: 'chat',
|
||||||
|
category: 'technical',
|
||||||
|
relevanceScore: 0.85,
|
||||||
|
});
|
||||||
|
await adapter.storeInsight({
|
||||||
|
userId: 'u2',
|
||||||
|
content: 'TypeScript is popular',
|
||||||
|
source: 'chat',
|
||||||
|
category: 'general',
|
||||||
|
relevanceScore: 0.5,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should find insights by exact keyword', async () => {
|
||||||
|
const results = await adapter.searchInsights('u1', 'hooks');
|
||||||
|
expect(results).toHaveLength(1);
|
||||||
|
expect(results[0]!.content).toContain('hooks');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be case-insensitive', async () => {
|
||||||
|
const results = await adapter.searchInsights('u1', 'TYPESCRIPT');
|
||||||
|
expect(results.length).toBeGreaterThanOrEqual(1);
|
||||||
|
for (const r of results) {
|
||||||
|
expect(r.content.toLowerCase()).toContain('typescript');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should rank multi-word matches higher', async () => {
|
||||||
|
const results = await adapter.searchInsights('u1', 'TypeScript React');
|
||||||
|
// The insight mentioning both "TypeScript" and "React" should rank first (score=2)
|
||||||
|
expect(results[0]!.score).toBe(2);
|
||||||
|
expect(results[0]!.content).toContain('TypeScript');
|
||||||
|
expect(results[0]!.content).toContain('React');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return empty for no matches', async () => {
|
||||||
|
const results = await adapter.searchInsights('u1', 'python django');
|
||||||
|
expect(results).toHaveLength(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should filter by userId', async () => {
|
||||||
|
const results = await adapter.searchInsights('u2', 'TypeScript');
|
||||||
|
expect(results).toHaveLength(1);
|
||||||
|
expect(results[0]!.content).toBe('TypeScript is popular');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should respect limit option', async () => {
|
||||||
|
const results = await adapter.searchInsights('u1', 'TypeScript', { limit: 1 });
|
||||||
|
expect(results).toHaveLength(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return empty for empty query', async () => {
|
||||||
|
const results = await adapter.searchInsights('u1', ' ');
|
||||||
|
expect(results).toHaveLength(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
/* ---- Lifecycle ---- */
|
||||||
|
|
||||||
|
describe('lifecycle', () => {
|
||||||
|
it('should have name "keyword"', () => {
|
||||||
|
expect(adapter.name).toBe('keyword');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should have null embedder', () => {
|
||||||
|
expect(adapter.embedder).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should close without error', async () => {
|
||||||
|
await expect(adapter.close()).resolves.toBeUndefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
195
packages/memory/src/adapters/keyword.ts
Normal file
195
packages/memory/src/adapters/keyword.ts
Normal file
@@ -0,0 +1,195 @@
|
|||||||
|
import type { StorageAdapter } from '@mosaic/storage';
|
||||||
|
import type {
|
||||||
|
MemoryAdapter,
|
||||||
|
MemoryConfig,
|
||||||
|
NewInsight,
|
||||||
|
Insight,
|
||||||
|
InsightSearchResult,
|
||||||
|
} from '../types.js';
|
||||||
|
import type { EmbeddingProvider } from '../vector-store.js';
|
||||||
|
|
||||||
|
type KeywordConfig = Extract<MemoryConfig, { type: 'keyword' }>;
|
||||||
|
|
||||||
|
const PREFERENCES = 'preferences';
|
||||||
|
const INSIGHTS = 'insights';
|
||||||
|
|
||||||
|
type PreferenceRecord = Record<string, unknown> & {
|
||||||
|
id: string;
|
||||||
|
userId: string;
|
||||||
|
key: string;
|
||||||
|
value: unknown;
|
||||||
|
category: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type InsightRecord = Record<string, unknown> & {
|
||||||
|
id: string;
|
||||||
|
userId: string;
|
||||||
|
content: string;
|
||||||
|
source: string;
|
||||||
|
category: string;
|
||||||
|
relevanceScore: number;
|
||||||
|
metadata: Record<string, unknown>;
|
||||||
|
createdAt: string;
|
||||||
|
updatedAt?: string;
|
||||||
|
decayedAt?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export class KeywordAdapter implements MemoryAdapter {
|
||||||
|
readonly name = 'keyword';
|
||||||
|
readonly embedder: EmbeddingProvider | null = null;
|
||||||
|
|
||||||
|
private storage: StorageAdapter;
|
||||||
|
|
||||||
|
constructor(config: KeywordConfig) {
|
||||||
|
this.storage = config.storage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
/* Preferences */
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
async getPreference(userId: string, key: string): Promise<unknown | null> {
|
||||||
|
const row = await this.storage.findOne<PreferenceRecord>(PREFERENCES, { userId, key });
|
||||||
|
return row?.value ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
async setPreference(
|
||||||
|
userId: string,
|
||||||
|
key: string,
|
||||||
|
value: unknown,
|
||||||
|
category?: string,
|
||||||
|
): Promise<void> {
|
||||||
|
const existing = await this.storage.findOne<PreferenceRecord>(PREFERENCES, { userId, key });
|
||||||
|
if (existing) {
|
||||||
|
await this.storage.update(PREFERENCES, existing.id, {
|
||||||
|
value,
|
||||||
|
...(category !== undefined ? { category } : {}),
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
await this.storage.create(PREFERENCES, {
|
||||||
|
userId,
|
||||||
|
key,
|
||||||
|
value,
|
||||||
|
category: category ?? 'general',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async deletePreference(userId: string, key: string): Promise<boolean> {
|
||||||
|
const existing = await this.storage.findOne<PreferenceRecord>(PREFERENCES, { userId, key });
|
||||||
|
if (!existing) return false;
|
||||||
|
return this.storage.delete(PREFERENCES, existing.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
async listPreferences(
|
||||||
|
userId: string,
|
||||||
|
category?: string,
|
||||||
|
): Promise<Array<{ key: string; value: unknown; category: string }>> {
|
||||||
|
const filter: Record<string, unknown> = { userId };
|
||||||
|
if (category !== undefined) filter.category = category;
|
||||||
|
|
||||||
|
const rows = await this.storage.find<PreferenceRecord>(PREFERENCES, filter);
|
||||||
|
return rows.map((r) => ({ key: r.key, value: r.value, category: r.category }));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
/* Insights */
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
async storeInsight(insight: NewInsight): Promise<Insight> {
|
||||||
|
const now = new Date();
|
||||||
|
const row = await this.storage.create<Record<string, unknown>>(INSIGHTS, {
|
||||||
|
userId: insight.userId,
|
||||||
|
content: insight.content,
|
||||||
|
source: insight.source,
|
||||||
|
category: insight.category,
|
||||||
|
relevanceScore: insight.relevanceScore,
|
||||||
|
metadata: insight.metadata ?? {},
|
||||||
|
createdAt: now.toISOString(),
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: row.id,
|
||||||
|
userId: insight.userId,
|
||||||
|
content: insight.content,
|
||||||
|
source: insight.source,
|
||||||
|
category: insight.category,
|
||||||
|
relevanceScore: insight.relevanceScore,
|
||||||
|
metadata: insight.metadata,
|
||||||
|
createdAt: now,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
async getInsight(id: string): Promise<Insight | null> {
|
||||||
|
const row = await this.storage.read<InsightRecord>(INSIGHTS, id);
|
||||||
|
if (!row) return null;
|
||||||
|
return toInsight(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
async searchInsights(
|
||||||
|
userId: string,
|
||||||
|
query: string,
|
||||||
|
opts?: { limit?: number; embedding?: number[] },
|
||||||
|
): Promise<InsightSearchResult[]> {
|
||||||
|
const limit = opts?.limit ?? 10;
|
||||||
|
const words = query
|
||||||
|
.toLowerCase()
|
||||||
|
.split(/\s+/)
|
||||||
|
.filter((w) => w.length > 0);
|
||||||
|
|
||||||
|
if (words.length === 0) return [];
|
||||||
|
|
||||||
|
const rows = await this.storage.find<InsightRecord>(INSIGHTS, { userId });
|
||||||
|
|
||||||
|
const scored: InsightSearchResult[] = [];
|
||||||
|
for (const row of rows) {
|
||||||
|
const content = row.content.toLowerCase();
|
||||||
|
let score = 0;
|
||||||
|
for (const word of words) {
|
||||||
|
if (content.includes(word)) score++;
|
||||||
|
}
|
||||||
|
if (score > 0) {
|
||||||
|
scored.push({
|
||||||
|
id: row.id,
|
||||||
|
content: row.content,
|
||||||
|
score,
|
||||||
|
metadata: row.metadata ?? undefined,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
scored.sort((a, b) => b.score - a.score);
|
||||||
|
return scored.slice(0, limit);
|
||||||
|
}
|
||||||
|
|
||||||
|
async deleteInsight(id: string): Promise<boolean> {
|
||||||
|
return this.storage.delete(INSIGHTS, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
/* Lifecycle */
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
async close(): Promise<void> {
|
||||||
|
// no-op — storage adapter manages its own lifecycle
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
/* Helpers */
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
function toInsight(row: InsightRecord): Insight {
|
||||||
|
return {
|
||||||
|
id: row.id,
|
||||||
|
userId: row.userId,
|
||||||
|
content: row.content,
|
||||||
|
source: row.source,
|
||||||
|
category: row.category,
|
||||||
|
relevanceScore: row.relevanceScore,
|
||||||
|
metadata: row.metadata ?? undefined,
|
||||||
|
createdAt: new Date(row.createdAt),
|
||||||
|
updatedAt: row.updatedAt ? new Date(row.updatedAt) : undefined,
|
||||||
|
decayedAt: row.decayedAt ? new Date(row.decayedAt) : undefined,
|
||||||
|
};
|
||||||
|
}
|
||||||
177
packages/memory/src/adapters/pgvector.ts
Normal file
177
packages/memory/src/adapters/pgvector.ts
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
import { createDb, type DbHandle } from '@mosaic/db';
|
||||||
|
import type {
|
||||||
|
MemoryAdapter,
|
||||||
|
MemoryConfig,
|
||||||
|
NewInsight as AdapterNewInsight,
|
||||||
|
Insight as AdapterInsight,
|
||||||
|
InsightSearchResult,
|
||||||
|
} from '../types.js';
|
||||||
|
import type { EmbeddingProvider } from '../vector-store.js';
|
||||||
|
import {
|
||||||
|
createPreferencesRepo,
|
||||||
|
type PreferencesRepo,
|
||||||
|
type Preference,
|
||||||
|
type NewPreference,
|
||||||
|
} from '../preferences.js';
|
||||||
|
import {
|
||||||
|
createInsightsRepo,
|
||||||
|
type InsightsRepo,
|
||||||
|
type NewInsight as DbNewInsight,
|
||||||
|
} from '../insights.js';
|
||||||
|
|
||||||
|
type PgVectorConfig = Extract<MemoryConfig, { type: 'pgvector' }>;
|
||||||
|
|
||||||
|
export class PgVectorAdapter implements MemoryAdapter {
|
||||||
|
readonly name = 'pgvector';
|
||||||
|
readonly embedder: EmbeddingProvider | null;
|
||||||
|
|
||||||
|
private handle: DbHandle;
|
||||||
|
private preferences: PreferencesRepo;
|
||||||
|
private insights: InsightsRepo;
|
||||||
|
|
||||||
|
constructor(config: PgVectorConfig) {
|
||||||
|
this.handle = createDb();
|
||||||
|
this.preferences = createPreferencesRepo(this.handle.db);
|
||||||
|
this.insights = createInsightsRepo(this.handle.db);
|
||||||
|
this.embedder = config.embedder ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
/* Preferences */
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
async getPreference(userId: string, key: string): Promise<unknown | null> {
|
||||||
|
const row = await this.preferences.findByUserAndKey(userId, key);
|
||||||
|
return row?.value ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
async setPreference(
|
||||||
|
userId: string,
|
||||||
|
key: string,
|
||||||
|
value: unknown,
|
||||||
|
category?: string,
|
||||||
|
): Promise<void> {
|
||||||
|
await this.preferences.upsert({
|
||||||
|
userId,
|
||||||
|
key,
|
||||||
|
value,
|
||||||
|
...(category ? { category: category as NewPreference['category'] } : {}),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async deletePreference(userId: string, key: string): Promise<boolean> {
|
||||||
|
return this.preferences.remove(userId, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
async listPreferences(
|
||||||
|
userId: string,
|
||||||
|
category?: string,
|
||||||
|
): Promise<Array<{ key: string; value: unknown; category: string }>> {
|
||||||
|
const rows = category
|
||||||
|
? await this.preferences.findByUserAndCategory(userId, category as Preference['category'])
|
||||||
|
: await this.preferences.findByUser(userId);
|
||||||
|
|
||||||
|
return rows.map((r) => ({ key: r.key, value: r.value, category: r.category }));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
/* Insights */
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
async storeInsight(insight: AdapterNewInsight): Promise<AdapterInsight> {
|
||||||
|
const row = await this.insights.create({
|
||||||
|
userId: insight.userId,
|
||||||
|
content: insight.content,
|
||||||
|
source: insight.source as DbNewInsight['source'],
|
||||||
|
category: insight.category as DbNewInsight['category'],
|
||||||
|
relevanceScore: insight.relevanceScore,
|
||||||
|
metadata: insight.metadata ?? {},
|
||||||
|
embedding: insight.embedding ?? null,
|
||||||
|
});
|
||||||
|
|
||||||
|
return toAdapterInsight(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
async getInsight(id: string): Promise<AdapterInsight | null> {
|
||||||
|
// findById requires userId — search across all users via raw find
|
||||||
|
// The adapter interface only takes id, so we pass an empty userId and rely on the id match.
|
||||||
|
// Since the repo requires userId, we use a two-step approach.
|
||||||
|
const row = await this.insights.findById(id, '');
|
||||||
|
if (!row) return null;
|
||||||
|
return toAdapterInsight(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
async searchInsights(
|
||||||
|
userId: string,
|
||||||
|
_query: string,
|
||||||
|
opts?: { limit?: number; embedding?: number[] },
|
||||||
|
): Promise<InsightSearchResult[]> {
|
||||||
|
if (opts?.embedding) {
|
||||||
|
const results = await this.insights.searchByEmbedding(
|
||||||
|
userId,
|
||||||
|
opts.embedding,
|
||||||
|
opts.limit ?? 10,
|
||||||
|
);
|
||||||
|
return results.map((r) => ({
|
||||||
|
id: r.insight.id,
|
||||||
|
content: r.insight.content,
|
||||||
|
score: 1 - r.distance,
|
||||||
|
metadata: (r.insight.metadata as Record<string, unknown>) ?? undefined,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback: return recent insights for the user
|
||||||
|
const rows = await this.insights.findByUser(userId, opts?.limit ?? 10);
|
||||||
|
return rows.map((r) => ({
|
||||||
|
id: r.id,
|
||||||
|
content: r.content,
|
||||||
|
score: Number(r.relevanceScore),
|
||||||
|
metadata: (r.metadata as Record<string, unknown>) ?? undefined,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
async deleteInsight(id: string): Promise<boolean> {
|
||||||
|
// The repo requires userId — pass empty string since adapter interface only has id
|
||||||
|
return this.insights.remove(id, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
/* Lifecycle */
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
async close(): Promise<void> {
|
||||||
|
await this.handle.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
/* Helpers */
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
function toAdapterInsight(row: {
|
||||||
|
id: string;
|
||||||
|
userId: string;
|
||||||
|
content: string;
|
||||||
|
source: string;
|
||||||
|
category: string;
|
||||||
|
relevanceScore: number;
|
||||||
|
metadata: unknown;
|
||||||
|
embedding: unknown;
|
||||||
|
createdAt: Date;
|
||||||
|
updatedAt: Date | null;
|
||||||
|
decayedAt: Date | null;
|
||||||
|
}): AdapterInsight {
|
||||||
|
return {
|
||||||
|
id: row.id,
|
||||||
|
userId: row.userId,
|
||||||
|
content: row.content,
|
||||||
|
source: row.source,
|
||||||
|
category: row.category,
|
||||||
|
relevanceScore: row.relevanceScore,
|
||||||
|
metadata: (row.metadata as Record<string, unknown>) ?? undefined,
|
||||||
|
embedding: (row.embedding as number[]) ?? undefined,
|
||||||
|
createdAt: row.createdAt,
|
||||||
|
updatedAt: row.updatedAt ?? undefined,
|
||||||
|
decayedAt: row.decayedAt ?? undefined,
|
||||||
|
};
|
||||||
|
}
|
||||||
18
packages/memory/src/factory.ts
Normal file
18
packages/memory/src/factory.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import type { MemoryAdapter, MemoryConfig } from './types.js';
|
||||||
|
|
||||||
|
type MemoryType = MemoryConfig['type'];
|
||||||
|
|
||||||
|
const registry = new Map<MemoryType, (config: MemoryConfig) => MemoryAdapter>();
|
||||||
|
|
||||||
|
export function registerMemoryAdapter(
|
||||||
|
type: MemoryType,
|
||||||
|
factory: (config: MemoryConfig) => MemoryAdapter,
|
||||||
|
): void {
|
||||||
|
registry.set(type, factory);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createMemoryAdapter(config: MemoryConfig): MemoryAdapter {
|
||||||
|
const factory = registry.get(config.type);
|
||||||
|
if (!factory) throw new Error(`No adapter registered for type: ${config.type}`);
|
||||||
|
return factory(config);
|
||||||
|
}
|
||||||
@@ -13,3 +13,27 @@ export {
|
|||||||
type SearchResult,
|
type SearchResult,
|
||||||
} from './insights.js';
|
} from './insights.js';
|
||||||
export type { VectorStore, VectorSearchResult, EmbeddingProvider } from './vector-store.js';
|
export type { VectorStore, VectorSearchResult, EmbeddingProvider } from './vector-store.js';
|
||||||
|
export type {
|
||||||
|
MemoryAdapter,
|
||||||
|
MemoryConfig,
|
||||||
|
NewInsight as AdapterNewInsight,
|
||||||
|
Insight as AdapterInsight,
|
||||||
|
InsightSearchResult,
|
||||||
|
} from './types.js';
|
||||||
|
export { createMemoryAdapter, registerMemoryAdapter } from './factory.js';
|
||||||
|
export { PgVectorAdapter } from './adapters/pgvector.js';
|
||||||
|
export { KeywordAdapter } from './adapters/keyword.js';
|
||||||
|
|
||||||
|
// Auto-register adapters at module load time
|
||||||
|
import { registerMemoryAdapter } from './factory.js';
|
||||||
|
import { PgVectorAdapter } from './adapters/pgvector.js';
|
||||||
|
import { KeywordAdapter } from './adapters/keyword.js';
|
||||||
|
import type { MemoryConfig } from './types.js';
|
||||||
|
|
||||||
|
registerMemoryAdapter('pgvector', (config: MemoryConfig) => {
|
||||||
|
return new PgVectorAdapter(config as Extract<MemoryConfig, { type: 'pgvector' }>);
|
||||||
|
});
|
||||||
|
|
||||||
|
registerMemoryAdapter('keyword', (config: MemoryConfig) => {
|
||||||
|
return new KeywordAdapter(config as Extract<MemoryConfig, { type: 'keyword' }>);
|
||||||
|
});
|
||||||
|
|||||||
73
packages/memory/src/types.ts
Normal file
73
packages/memory/src/types.ts
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
export type { EmbeddingProvider, VectorSearchResult } from './vector-store.js';
|
||||||
|
import type { EmbeddingProvider } from './vector-store.js';
|
||||||
|
import type { StorageAdapter } from '@mosaic/storage';
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
/* Insight types (adapter-level, decoupled from Drizzle schema) */
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
export interface NewInsight {
|
||||||
|
userId: string;
|
||||||
|
content: string;
|
||||||
|
source: string;
|
||||||
|
category: string;
|
||||||
|
relevanceScore: number;
|
||||||
|
metadata?: Record<string, unknown>;
|
||||||
|
embedding?: number[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Insight extends NewInsight {
|
||||||
|
id: string;
|
||||||
|
createdAt: Date;
|
||||||
|
updatedAt?: Date;
|
||||||
|
decayedAt?: Date;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InsightSearchResult {
|
||||||
|
id: string;
|
||||||
|
content: string;
|
||||||
|
score: number;
|
||||||
|
metadata?: Record<string, unknown>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
/* MemoryAdapter interface */
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
export interface MemoryAdapter {
|
||||||
|
readonly name: string;
|
||||||
|
|
||||||
|
// Preferences
|
||||||
|
getPreference(userId: string, key: string): Promise<unknown | null>;
|
||||||
|
setPreference(userId: string, key: string, value: unknown, category?: string): Promise<void>;
|
||||||
|
deletePreference(userId: string, key: string): Promise<boolean>;
|
||||||
|
listPreferences(
|
||||||
|
userId: string,
|
||||||
|
category?: string,
|
||||||
|
): Promise<Array<{ key: string; value: unknown; category: string }>>;
|
||||||
|
|
||||||
|
// Insights
|
||||||
|
storeInsight(insight: NewInsight): Promise<Insight>;
|
||||||
|
getInsight(id: string): Promise<Insight | null>;
|
||||||
|
searchInsights(
|
||||||
|
userId: string,
|
||||||
|
query: string,
|
||||||
|
opts?: { limit?: number; embedding?: number[] },
|
||||||
|
): Promise<InsightSearchResult[]>;
|
||||||
|
deleteInsight(id: string): Promise<boolean>;
|
||||||
|
|
||||||
|
// Embedding
|
||||||
|
readonly embedder: EmbeddingProvider | null;
|
||||||
|
|
||||||
|
// Lifecycle
|
||||||
|
close(): Promise<void>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
/* MemoryConfig */
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
export type MemoryConfig =
|
||||||
|
| { type: 'pgvector'; embedder?: EmbeddingProvider }
|
||||||
|
| { type: 'sqlite-vec'; embedder?: EmbeddingProvider }
|
||||||
|
| { type: 'keyword'; storage: StorageAdapter };
|
||||||
88
packages/mosaic/__tests__/platform/file-ops.test.ts
Normal file
88
packages/mosaic/__tests__/platform/file-ops.test.ts
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
||||||
|
import {
|
||||||
|
mkdtempSync,
|
||||||
|
mkdirSync,
|
||||||
|
writeFileSync,
|
||||||
|
readFileSync,
|
||||||
|
existsSync,
|
||||||
|
chmodSync,
|
||||||
|
rmSync,
|
||||||
|
} from 'node:fs';
|
||||||
|
import { join } from 'node:path';
|
||||||
|
import { tmpdir } from 'node:os';
|
||||||
|
import { syncDirectory } from '../../src/platform/file-ops.js';
|
||||||
|
|
||||||
|
describe('syncDirectory', () => {
|
||||||
|
let tmpDir: string;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
tmpDir = mkdtempSync(join(tmpdir(), 'mosaic-file-ops-'));
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
rmSync(tmpDir, { recursive: true, force: true });
|
||||||
|
});
|
||||||
|
|
||||||
|
it('is a no-op when source and target are the same path', () => {
|
||||||
|
const dir = join(tmpDir, 'same');
|
||||||
|
mkdirSync(dir, { recursive: true });
|
||||||
|
writeFileSync(join(dir, 'file.txt'), 'hello');
|
||||||
|
// Should not throw even with read-only files
|
||||||
|
const gitDir = join(dir, '.git', 'objects', 'pack');
|
||||||
|
mkdirSync(gitDir, { recursive: true });
|
||||||
|
const packFile = join(gitDir, 'pack-abc.idx');
|
||||||
|
writeFileSync(packFile, 'data');
|
||||||
|
chmodSync(packFile, 0o444);
|
||||||
|
|
||||||
|
expect(() => syncDirectory(dir, dir)).not.toThrow();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('skips nested .git directories when excludeGit is true', () => {
|
||||||
|
const src = join(tmpDir, 'src');
|
||||||
|
const dest = join(tmpDir, 'dest');
|
||||||
|
|
||||||
|
// Create source with a nested .git
|
||||||
|
mkdirSync(join(src, 'sources', 'skills', '.git', 'objects'), { recursive: true });
|
||||||
|
writeFileSync(join(src, 'sources', 'skills', '.git', 'objects', 'pack.idx'), 'git-data');
|
||||||
|
writeFileSync(join(src, 'sources', 'skills', 'SKILL.md'), 'skill content');
|
||||||
|
writeFileSync(join(src, 'README.md'), 'readme');
|
||||||
|
|
||||||
|
syncDirectory(src, dest, { excludeGit: true });
|
||||||
|
|
||||||
|
// .git contents should NOT be copied
|
||||||
|
expect(existsSync(join(dest, 'sources', 'skills', '.git'))).toBe(false);
|
||||||
|
// Normal files should be copied
|
||||||
|
expect(readFileSync(join(dest, 'sources', 'skills', 'SKILL.md'), 'utf-8')).toBe(
|
||||||
|
'skill content',
|
||||||
|
);
|
||||||
|
expect(readFileSync(join(dest, 'README.md'), 'utf-8')).toBe('readme');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('copies nested .git directories when excludeGit is false', () => {
|
||||||
|
const src = join(tmpDir, 'src');
|
||||||
|
const dest = join(tmpDir, 'dest');
|
||||||
|
|
||||||
|
mkdirSync(join(src, 'sub', '.git'), { recursive: true });
|
||||||
|
writeFileSync(join(src, 'sub', '.git', 'HEAD'), 'ref: refs/heads/main');
|
||||||
|
|
||||||
|
syncDirectory(src, dest, { excludeGit: false });
|
||||||
|
|
||||||
|
expect(readFileSync(join(dest, 'sub', '.git', 'HEAD'), 'utf-8')).toBe('ref: refs/heads/main');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('respects preserve option', () => {
|
||||||
|
const src = join(tmpDir, 'src');
|
||||||
|
const dest = join(tmpDir, 'dest');
|
||||||
|
|
||||||
|
mkdirSync(src, { recursive: true });
|
||||||
|
mkdirSync(dest, { recursive: true });
|
||||||
|
writeFileSync(join(src, 'SOUL.md'), 'new soul');
|
||||||
|
writeFileSync(join(dest, 'SOUL.md'), 'old soul');
|
||||||
|
writeFileSync(join(src, 'README.md'), 'new readme');
|
||||||
|
|
||||||
|
syncDirectory(src, dest, { preserve: ['SOUL.md'] });
|
||||||
|
|
||||||
|
expect(readFileSync(join(dest, 'SOUL.md'), 'utf-8')).toBe('old soul');
|
||||||
|
expect(readFileSync(join(dest, 'README.md'), 'utf-8')).toBe('new readme');
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -65,4 +65,36 @@ describe('detectInstallStage', () => {
|
|||||||
expect(state.installAction).toBe('keep');
|
expect(state.installAction).toBe('keep');
|
||||||
expect(state.soul.agentName).toBe('TestAgent');
|
expect(state.soul.agentName).toBe('TestAgent');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('pre-populates state when reconfiguring', async () => {
|
||||||
|
mkdirSync(join(tmpDir, 'bin'), { recursive: true });
|
||||||
|
writeFileSync(join(tmpDir, 'SOUL.md'), 'You are **Jarvis** in this session.');
|
||||||
|
writeFileSync(join(tmpDir, 'USER.md'), '**Name:** TestUser');
|
||||||
|
|
||||||
|
const p = new HeadlessPrompter({
|
||||||
|
'What would you like to do?': 'reconfigure',
|
||||||
|
});
|
||||||
|
const state = createState(tmpDir);
|
||||||
|
await detectInstallStage(p, state, mockConfig);
|
||||||
|
|
||||||
|
expect(state.installAction).toBe('reconfigure');
|
||||||
|
// Existing values loaded as defaults for reconfiguration
|
||||||
|
expect(state.soul.agentName).toBe('TestAgent');
|
||||||
|
expect(state.user.userName).toBe('TestUser');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not pre-populate state on fresh reset', async () => {
|
||||||
|
mkdirSync(join(tmpDir, 'bin'), { recursive: true });
|
||||||
|
writeFileSync(join(tmpDir, 'SOUL.md'), 'You are **Jarvis** in this session.');
|
||||||
|
|
||||||
|
const p = new HeadlessPrompter({
|
||||||
|
'What would you like to do?': 'reset',
|
||||||
|
});
|
||||||
|
const state = createState(tmpDir);
|
||||||
|
await detectInstallStage(p, state, mockConfig);
|
||||||
|
|
||||||
|
expect(state.installAction).toBe('reset');
|
||||||
|
// Reset should NOT load existing values
|
||||||
|
expect(state.soul.agentName).toBeUndefined();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -60,12 +60,14 @@ Options:
|
|||||||
--timezone <tz> Your timezone (e.g., "America/Chicago")
|
--timezone <tz> Your timezone (e.g., "America/Chicago")
|
||||||
--non-interactive Fail if any required value is missing (no prompts)
|
--non-interactive Fail if any required value is missing (no prompts)
|
||||||
--soul-only Only generate SOUL.md
|
--soul-only Only generate SOUL.md
|
||||||
|
--force Overwrite existing files without prompting
|
||||||
-h, --help Show help
|
-h, --help Show help
|
||||||
USAGE
|
USAGE
|
||||||
}
|
}
|
||||||
|
|
||||||
NON_INTERACTIVE=0
|
NON_INTERACTIVE=0
|
||||||
SOUL_ONLY=0
|
SOUL_ONLY=0
|
||||||
|
FORCE=0
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@@ -79,6 +81,7 @@ while [[ $# -gt 0 ]]; do
|
|||||||
--timezone) TIMEZONE="$2"; shift 2 ;;
|
--timezone) TIMEZONE="$2"; shift 2 ;;
|
||||||
--non-interactive) NON_INTERACTIVE=1; shift ;;
|
--non-interactive) NON_INTERACTIVE=1; shift ;;
|
||||||
--soul-only) SOUL_ONLY=1; shift ;;
|
--soul-only) SOUL_ONLY=1; shift ;;
|
||||||
|
--force) FORCE=1; shift ;;
|
||||||
-h|--help) usage; exit 0 ;;
|
-h|--help) usage; exit 0 ;;
|
||||||
*) echo "Unknown argument: $1" >&2; usage >&2; exit 1 ;;
|
*) echo "Unknown argument: $1" >&2; usage >&2; exit 1 ;;
|
||||||
esac
|
esac
|
||||||
@@ -139,6 +142,134 @@ prompt_multiline() {
|
|||||||
eval "$var_name=\"$value\""
|
eval "$var_name=\"$value\""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ── Existing file detection ────────────────────────────────────
|
||||||
|
|
||||||
|
detect_existing_config() {
|
||||||
|
local found=0
|
||||||
|
local existing_files=()
|
||||||
|
|
||||||
|
[[ -f "$SOUL_OUTPUT" ]] && { found=1; existing_files+=("SOUL.md"); }
|
||||||
|
[[ -f "$USER_OUTPUT" ]] && { found=1; existing_files+=("USER.md"); }
|
||||||
|
[[ -f "$TOOLS_OUTPUT" ]] && { found=1; existing_files+=("TOOLS.md"); }
|
||||||
|
|
||||||
|
if [[ $found -eq 0 || $FORCE -eq 1 ]]; then
|
||||||
|
return 0 # No existing files or --force: proceed with fresh install
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "[mosaic-init] Existing configuration detected:"
|
||||||
|
for f in "${existing_files[@]}"; do
|
||||||
|
echo " ✓ $f"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Show current agent name if SOUL.md exists
|
||||||
|
if [[ -f "$SOUL_OUTPUT" ]]; then
|
||||||
|
local current_name
|
||||||
|
current_name=$(grep -oP 'You are \*\*\K[^*]+' "$SOUL_OUTPUT" 2>/dev/null || true)
|
||||||
|
if [[ -n "$current_name" ]]; then
|
||||||
|
echo " Agent: $current_name"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
if [[ $NON_INTERACTIVE -eq 1 ]]; then
|
||||||
|
echo "[mosaic-init] Existing config found. Use --force to overwrite in non-interactive mode."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "What would you like to do?"
|
||||||
|
echo " 1) keep — Keep existing files, skip init (default)"
|
||||||
|
echo " 2) import — Import values from existing files as defaults, then regenerate"
|
||||||
|
echo " 3) overwrite — Start fresh, overwrite all files"
|
||||||
|
printf "Choose [1/2/3]: "
|
||||||
|
read -r choice
|
||||||
|
|
||||||
|
case "${choice:-1}" in
|
||||||
|
1|keep)
|
||||||
|
echo "[mosaic-init] Keeping existing configuration."
|
||||||
|
# Still push to runtime adapters in case framework was updated
|
||||||
|
if [[ -x "$MOSAIC_HOME/tools/_scripts/mosaic-link-runtime-assets" ]]; then
|
||||||
|
echo "[mosaic-init] Updating runtime adapters..."
|
||||||
|
"$MOSAIC_HOME/tools/_scripts/mosaic-link-runtime-assets"
|
||||||
|
fi
|
||||||
|
echo "[mosaic-init] Done. Launch with: mosaic claude"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
2|import)
|
||||||
|
echo "[mosaic-init] Importing values from existing files as defaults..."
|
||||||
|
import_existing_values
|
||||||
|
;;
|
||||||
|
3|overwrite)
|
||||||
|
echo "[mosaic-init] Starting fresh install..."
|
||||||
|
# Back up existing files
|
||||||
|
local ts
|
||||||
|
ts=$(date +%Y%m%d%H%M%S)
|
||||||
|
for f in "${existing_files[@]}"; do
|
||||||
|
local src="$MOSAIC_HOME/$f"
|
||||||
|
if [[ -f "$src" ]]; then
|
||||||
|
cp "$src" "${src}.bak.${ts}"
|
||||||
|
echo " Backed up $f → ${f}.bak.${ts}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "[mosaic-init] Invalid choice. Keeping existing configuration."
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
import_existing_values() {
|
||||||
|
# Import SOUL.md values
|
||||||
|
if [[ -f "$SOUL_OUTPUT" ]]; then
|
||||||
|
local content
|
||||||
|
content=$(cat "$SOUL_OUTPUT")
|
||||||
|
|
||||||
|
if [[ -z "$AGENT_NAME" ]]; then
|
||||||
|
AGENT_NAME=$(echo "$content" | grep -oP 'You are \*\*\K[^*]+' 2>/dev/null || true)
|
||||||
|
fi
|
||||||
|
if [[ -z "$ROLE_DESCRIPTION" ]]; then
|
||||||
|
ROLE_DESCRIPTION=$(echo "$content" | grep -oP 'Role identity: \K.+' 2>/dev/null || true)
|
||||||
|
fi
|
||||||
|
if [[ -z "$STYLE" ]]; then
|
||||||
|
if echo "$content" | grep -q 'Be direct, concise'; then
|
||||||
|
STYLE="direct"
|
||||||
|
elif echo "$content" | grep -q 'Be warm and conversational'; then
|
||||||
|
STYLE="friendly"
|
||||||
|
elif echo "$content" | grep -q 'Use professional, structured'; then
|
||||||
|
STYLE="formal"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Import USER.md values
|
||||||
|
if [[ -f "$USER_OUTPUT" ]]; then
|
||||||
|
local content
|
||||||
|
content=$(cat "$USER_OUTPUT")
|
||||||
|
|
||||||
|
if [[ -z "$USER_NAME" ]]; then
|
||||||
|
USER_NAME=$(echo "$content" | grep -oP '\*\*Name:\*\* \K.+' 2>/dev/null || true)
|
||||||
|
fi
|
||||||
|
if [[ -z "$PRONOUNS" ]]; then
|
||||||
|
PRONOUNS=$(echo "$content" | grep -oP '\*\*Pronouns:\*\* \K.+' 2>/dev/null || true)
|
||||||
|
fi
|
||||||
|
if [[ -z "$TIMEZONE" ]]; then
|
||||||
|
TIMEZONE=$(echo "$content" | grep -oP '\*\*Timezone:\*\* \K.+' 2>/dev/null || true)
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Import TOOLS.md values
|
||||||
|
if [[ -f "$TOOLS_OUTPUT" ]]; then
|
||||||
|
local content
|
||||||
|
content=$(cat "$TOOLS_OUTPUT")
|
||||||
|
|
||||||
|
if [[ -z "$CREDENTIALS_LOCATION" ]]; then
|
||||||
|
CREDENTIALS_LOCATION=$(echo "$content" | grep -oP '\*\*Location:\*\* \K.+' 2>/dev/null || true)
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
detect_existing_config
|
||||||
|
|
||||||
# ── SOUL.md Generation ────────────────────────────────────────
|
# ── SOUL.md Generation ────────────────────────────────────────
|
||||||
echo "[mosaic-init] Generating SOUL.md — agent identity contract"
|
echo "[mosaic-init] Generating SOUL.md — agent identity contract"
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
@@ -55,7 +55,68 @@ mkdir -p "$MOSAIC_HOME" "$MOSAIC_SKILLS_DIR" "$MOSAIC_LOCAL_SKILLS_DIR"
|
|||||||
if [[ $fetch -eq 1 ]]; then
|
if [[ $fetch -eq 1 ]]; then
|
||||||
if [[ -d "$SKILLS_REPO_DIR/.git" ]]; then
|
if [[ -d "$SKILLS_REPO_DIR/.git" ]]; then
|
||||||
echo "[mosaic-skills] Updating skills source: $SKILLS_REPO_DIR"
|
echo "[mosaic-skills] Updating skills source: $SKILLS_REPO_DIR"
|
||||||
git -C "$SKILLS_REPO_DIR" pull --rebase
|
|
||||||
|
# ── Detect dirty state ──────────────────────────────────────────────
|
||||||
|
dirty=""
|
||||||
|
dirty="$(git -C "$SKILLS_REPO_DIR" status --porcelain 2>/dev/null || true)"
|
||||||
|
|
||||||
|
if [[ -n "$dirty" ]]; then
|
||||||
|
# ── Auto-migrate customized skills to skills-local/ ─────────────
|
||||||
|
# Instead of stash/pop (fragile, merge conflicts), we:
|
||||||
|
# 1. Identify which skill dirs contain user edits
|
||||||
|
# 2. Copy those full skill dirs into skills-local/ (preserving edits)
|
||||||
|
# 3. Reset the repo clean so pull always succeeds
|
||||||
|
# 4. skills-local/ takes precedence during linking, so edits win
|
||||||
|
|
||||||
|
SOURCE_SKILLS_SUBDIR="$SKILLS_REPO_DIR/skills"
|
||||||
|
migrated=()
|
||||||
|
|
||||||
|
while IFS= read -r line; do
|
||||||
|
# porcelain format: XY <path> — extract the file path
|
||||||
|
file="${line:3}"
|
||||||
|
# Only migrate files under skills/ subdir in the repo
|
||||||
|
if [[ "$file" == skills/* ]]; then
|
||||||
|
# Extract the skill directory name (first path component after skills/)
|
||||||
|
skill_name="${file#skills/}"
|
||||||
|
skill_name="${skill_name%%/*}"
|
||||||
|
|
||||||
|
# Skip if already migrated this skill in this run
|
||||||
|
local_skill_dir="$MOSAIC_LOCAL_SKILLS_DIR/$skill_name"
|
||||||
|
if [[ -d "$local_skill_dir" ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Skip if skill_name is empty or hidden
|
||||||
|
if [[ -z "$skill_name" || "$skill_name" == .* ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Copy the skill (with user's edits) from repo working tree to skills-local/
|
||||||
|
if [[ -d "$SOURCE_SKILLS_SUBDIR/$skill_name" ]]; then
|
||||||
|
cp -R "$SOURCE_SKILLS_SUBDIR/$skill_name" "$local_skill_dir"
|
||||||
|
migrated+=("$skill_name")
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done <<< "$dirty"
|
||||||
|
|
||||||
|
if [[ ${#migrated[@]} -gt 0 ]]; then
|
||||||
|
echo "[mosaic-skills] Migrated ${#migrated[@]} customized skill(s) to skills-local/:"
|
||||||
|
for s in "${migrated[@]}"; do
|
||||||
|
echo " → $MOSAIC_LOCAL_SKILLS_DIR/$s"
|
||||||
|
done
|
||||||
|
echo "[mosaic-skills] Your edits are preserved there and take precedence over canonical."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Reset repo to clean state so pull always works
|
||||||
|
echo "[mosaic-skills] Resetting source repo to clean state..."
|
||||||
|
git -C "$SKILLS_REPO_DIR" checkout . 2>/dev/null || true
|
||||||
|
git -C "$SKILLS_REPO_DIR" clean -fd 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! git -C "$SKILLS_REPO_DIR" pull --rebase 2>/dev/null; then
|
||||||
|
echo "[mosaic-skills] WARN: pull failed — continuing with existing checkout" >&2
|
||||||
|
git -C "$SKILLS_REPO_DIR" rebase --abort 2>/dev/null || true
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "[mosaic-skills] Cloning skills source to: $SKILLS_REPO_DIR"
|
echo "[mosaic-skills] Cloning skills source to: $SKILLS_REPO_DIR"
|
||||||
mkdir -p "$(dirname "$SKILLS_REPO_DIR")"
|
mkdir -p "$(dirname "$SKILLS_REPO_DIR")"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mosaic/mosaic",
|
"name": "@mosaic/mosaic",
|
||||||
"version": "0.0.1-alpha.2",
|
"version": "0.0.10",
|
||||||
"description": "Mosaic agent framework — installation wizard and meta package",
|
"description": "Mosaic agent framework — installation wizard and meta package",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { readFileSync, existsSync } from 'node:fs';
|
import { readFileSync, existsSync, readdirSync, statSync, copyFileSync } from 'node:fs';
|
||||||
import { join } from 'node:path';
|
import { join } from 'node:path';
|
||||||
import type { ConfigService } from './config-service.js';
|
import type { ConfigService } from './config-service.js';
|
||||||
import type { SoulConfig, UserConfig, ToolsConfig, InstallAction } from '../types.js';
|
import type { SoulConfig, UserConfig, ToolsConfig, InstallAction } from '../types.js';
|
||||||
@@ -140,6 +140,23 @@ export class FileConfigAdapter implements ConfigService {
|
|||||||
preserve: preservePaths,
|
preserve: preservePaths,
|
||||||
excludeGit: true,
|
excludeGit: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Copy default root-level .md files (AGENTS.md, STANDARDS.md, etc.)
|
||||||
|
// from framework/defaults/ into mosaicHome root if they don't exist yet.
|
||||||
|
// These are framework contracts — only written on first install, never
|
||||||
|
// overwritten (user may have customized them).
|
||||||
|
const defaultsDir = join(this.sourceDir, 'defaults');
|
||||||
|
if (existsSync(defaultsDir)) {
|
||||||
|
for (const entry of readdirSync(defaultsDir)) {
|
||||||
|
const dest = join(this.mosaicHome, entry);
|
||||||
|
if (!existsSync(dest)) {
|
||||||
|
const src = join(defaultsDir, entry);
|
||||||
|
if (statSync(src).isFile()) {
|
||||||
|
copyFileSync(src, dest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { homedir } from 'node:os';
|
import { homedir } from 'node:os';
|
||||||
import { join } from 'node:path';
|
import { join } from 'node:path';
|
||||||
|
|
||||||
export const VERSION = '0.1.0';
|
export const VERSION = '0.0.2';
|
||||||
|
|
||||||
export const DEFAULT_MOSAIC_HOME = join(homedir(), '.config', 'mosaic');
|
export const DEFAULT_MOSAIC_HOME = join(homedir(), '.config', 'mosaic');
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
import { resolve } from 'node:path';
|
import { existsSync } from 'node:fs';
|
||||||
|
import { dirname, resolve } from 'node:path';
|
||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath } from 'node:url';
|
||||||
|
|
||||||
import { Command } from 'commander';
|
import { Command } from 'commander';
|
||||||
@@ -49,7 +50,14 @@ program
|
|||||||
.action(async (opts: Record<string, string | boolean | undefined>) => {
|
.action(async (opts: Record<string, string | boolean | undefined>) => {
|
||||||
try {
|
try {
|
||||||
const mosaicHome = (opts['mosaicHome'] as string) ?? DEFAULT_MOSAIC_HOME;
|
const mosaicHome = (opts['mosaicHome'] as string) ?? DEFAULT_MOSAIC_HOME;
|
||||||
const sourceDir = (opts['sourceDir'] as string | undefined) ?? mosaicHome;
|
// Default source to the framework/ dir bundled in this npm package.
|
||||||
|
// This ensures syncFramework copies AGENTS.md, STANDARDS.md, guides/, etc.
|
||||||
|
// Falls back to mosaicHome if the bundled dir doesn't exist (shouldn't happen).
|
||||||
|
const pkgRoot = dirname(fileURLToPath(import.meta.url));
|
||||||
|
const bundledFramework = resolve(pkgRoot, '..', 'framework');
|
||||||
|
const sourceDir =
|
||||||
|
(opts['sourceDir'] as string | undefined) ??
|
||||||
|
(existsSync(bundledFramework) ? bundledFramework : mosaicHome);
|
||||||
|
|
||||||
const prompter = opts['nonInteractive'] ? new HeadlessPrompter() : new ClackPrompter();
|
const prompter = opts['nonInteractive'] ? new HeadlessPrompter() : new ClackPrompter();
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import {
|
|||||||
unlinkSync,
|
unlinkSync,
|
||||||
statSync,
|
statSync,
|
||||||
} from 'node:fs';
|
} from 'node:fs';
|
||||||
import { dirname, join, relative } from 'node:path';
|
import { dirname, join, relative, resolve } from 'node:path';
|
||||||
|
|
||||||
const MAX_BACKUPS = 3;
|
const MAX_BACKUPS = 3;
|
||||||
|
|
||||||
@@ -68,6 +68,9 @@ export function syncDirectory(
|
|||||||
target: string,
|
target: string,
|
||||||
options: { preserve?: string[]; excludeGit?: boolean } = {},
|
options: { preserve?: string[]; excludeGit?: boolean } = {},
|
||||||
): void {
|
): void {
|
||||||
|
// Guard: source and target are the same directory — nothing to sync
|
||||||
|
if (resolve(source) === resolve(target)) return;
|
||||||
|
|
||||||
const preserveSet = new Set(options.preserve ?? []);
|
const preserveSet = new Set(options.preserve ?? []);
|
||||||
|
|
||||||
// Collect files from source
|
// Collect files from source
|
||||||
@@ -77,9 +80,10 @@ export function syncDirectory(
|
|||||||
const stat = statSync(src);
|
const stat = statSync(src);
|
||||||
if (stat.isDirectory()) {
|
if (stat.isDirectory()) {
|
||||||
const relPath = relative(relBase, src);
|
const relPath = relative(relBase, src);
|
||||||
|
const dirName = relPath.split('/').pop() ?? '';
|
||||||
|
|
||||||
// Skip .git
|
// Skip any .git directory (top-level or nested, e.g. sources/agent-skills/.git)
|
||||||
if (options.excludeGit && relPath === '.git') return;
|
if (options.excludeGit && (dirName === '.git' || relPath.includes('/.git'))) return;
|
||||||
|
|
||||||
// Skip preserved paths at top level
|
// Skip preserved paths at top level
|
||||||
if (preserveSet.has(relPath) && existsSync(dest)) return;
|
if (preserveSet.has(relPath) && existsSync(dest)) return;
|
||||||
@@ -91,6 +95,9 @@ export function syncDirectory(
|
|||||||
} else {
|
} else {
|
||||||
const relPath = relative(relBase, src);
|
const relPath = relative(relBase, src);
|
||||||
|
|
||||||
|
// Skip files inside .git directories
|
||||||
|
if (options.excludeGit && relPath.includes('/.git/')) return;
|
||||||
|
|
||||||
// Skip preserved files at top level
|
// Skip preserved files at top level
|
||||||
if (preserveSet.has(relPath) && existsSync(dest)) return;
|
if (preserveSet.has(relPath) && existsSync(dest)) return;
|
||||||
|
|
||||||
|
|||||||
@@ -122,10 +122,18 @@ export function semverLt(a: string, b: string): boolean {
|
|||||||
|
|
||||||
// ─── Cache ──────────────────────────────────────────────────────────────────
|
// ─── Cache ──────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
function readCache(): UpdateCheckResult | null {
|
/** Cache stores only the latest registry version (the expensive network call).
|
||||||
|
* The installed version is always checked fresh — it's a local `npm ls`. */
|
||||||
|
interface RegistryCache {
|
||||||
|
latest: string;
|
||||||
|
checkedAt: string;
|
||||||
|
registry: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
function readCache(): RegistryCache | null {
|
||||||
try {
|
try {
|
||||||
if (!existsSync(CACHE_FILE)) return null;
|
if (!existsSync(CACHE_FILE)) return null;
|
||||||
const raw = JSON.parse(readFileSync(CACHE_FILE, 'utf-8')) as UpdateCheckResult;
|
const raw = JSON.parse(readFileSync(CACHE_FILE, 'utf-8')) as RegistryCache;
|
||||||
const age = Date.now() - new Date(raw.checkedAt).getTime();
|
const age = Date.now() - new Date(raw.checkedAt).getTime();
|
||||||
if (age > CACHE_TTL_MS) return null;
|
if (age > CACHE_TTL_MS) return null;
|
||||||
return raw;
|
return raw;
|
||||||
@@ -134,10 +142,10 @@ function readCache(): UpdateCheckResult | null {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function writeCache(result: UpdateCheckResult): void {
|
function writeCache(entry: RegistryCache): void {
|
||||||
try {
|
try {
|
||||||
mkdirSync(CACHE_DIR, { recursive: true });
|
mkdirSync(CACHE_DIR, { recursive: true });
|
||||||
writeFileSync(CACHE_FILE, JSON.stringify(result, null, 2) + '\n', 'utf-8');
|
writeFileSync(CACHE_FILE, JSON.stringify(entry, null, 2) + '\n', 'utf-8');
|
||||||
} catch {
|
} catch {
|
||||||
// Best-effort — cache is not critical
|
// Best-effort — cache is not critical
|
||||||
}
|
}
|
||||||
@@ -174,29 +182,40 @@ export function getLatestVersion(): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform an update check — uses cache when fresh, otherwise hits registry.
|
* Perform an update check — uses registry cache when fresh, always checks
|
||||||
|
* installed version fresh (local npm ls is cheap, caching it causes stale
|
||||||
|
* "update available" banners after an upgrade).
|
||||||
* Never throws.
|
* Never throws.
|
||||||
*/
|
*/
|
||||||
export function checkForUpdate(options?: { skipCache?: boolean }): UpdateCheckResult {
|
export function checkForUpdate(options?: { skipCache?: boolean }): UpdateCheckResult {
|
||||||
|
const current = getInstalledVersion();
|
||||||
|
|
||||||
|
let latest: string;
|
||||||
|
let checkedAt: string;
|
||||||
|
|
||||||
if (!options?.skipCache) {
|
if (!options?.skipCache) {
|
||||||
const cached = readCache();
|
const cached = readCache();
|
||||||
if (cached) return cached;
|
if (cached) {
|
||||||
|
latest = cached.latest;
|
||||||
|
checkedAt = cached.checkedAt;
|
||||||
|
} else {
|
||||||
|
latest = getLatestVersion();
|
||||||
|
checkedAt = new Date().toISOString();
|
||||||
|
writeCache({ latest, checkedAt, registry: REGISTRY });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
latest = getLatestVersion();
|
||||||
|
checkedAt = new Date().toISOString();
|
||||||
|
writeCache({ latest, checkedAt, registry: REGISTRY });
|
||||||
}
|
}
|
||||||
|
|
||||||
const current = getInstalledVersion();
|
return {
|
||||||
const latest = getLatestVersion();
|
|
||||||
const updateAvailable = !!(current && latest && semverLt(current, latest));
|
|
||||||
|
|
||||||
const result: UpdateCheckResult = {
|
|
||||||
current,
|
current,
|
||||||
latest,
|
latest,
|
||||||
updateAvailable,
|
updateAvailable: !!(current && latest && semverLt(current, latest)),
|
||||||
checkedAt: new Date().toISOString(),
|
checkedAt,
|
||||||
registry: REGISTRY,
|
registry: REGISTRY,
|
||||||
};
|
};
|
||||||
|
|
||||||
writeCache(result);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -87,7 +87,9 @@ export async function detectInstallStage(
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
if (state.installAction === 'keep') {
|
if (state.installAction === 'keep' || state.installAction === 'reconfigure') {
|
||||||
|
// Load existing values — for 'keep' they're final, for 'reconfigure'
|
||||||
|
// they become pre-populated defaults so the user can tweak them.
|
||||||
state.soul = await config.readSoul();
|
state.soul = await config.readSoul();
|
||||||
state.user = await config.readUser();
|
state.user = await config.readUser();
|
||||||
state.tools = await config.readTools();
|
state.tools = await config.readTools();
|
||||||
|
|||||||
@@ -24,6 +24,18 @@ export async function soulSetupStage(p: WizardPrompter, state: WizardState): Pro
|
|||||||
return undefined;
|
return undefined;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
} else if (state.installAction === 'reconfigure') {
|
||||||
|
// Show existing value as default so the user can accept or change it
|
||||||
|
state.soul.agentName = await p.text({
|
||||||
|
message: 'What name should agents use?',
|
||||||
|
placeholder: state.soul.agentName,
|
||||||
|
defaultValue: state.soul.agentName,
|
||||||
|
validate: (v) => {
|
||||||
|
if (v.length === 0) return 'Name cannot be empty';
|
||||||
|
if (v.length > 50) return 'Name must be under 50 characters';
|
||||||
|
return undefined;
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state.mode === 'advanced') {
|
if (state.mode === 'advanced') {
|
||||||
@@ -38,7 +50,7 @@ export async function soulSetupStage(p: WizardPrompter, state: WizardState): Pro
|
|||||||
state.soul.roleDescription ??= DEFAULTS.roleDescription;
|
state.soul.roleDescription ??= DEFAULTS.roleDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!state.soul.communicationStyle) {
|
if (!state.soul.communicationStyle || state.installAction === 'reconfigure') {
|
||||||
state.soul.communicationStyle = await p.select<CommunicationStyle>({
|
state.soul.communicationStyle = await p.select<CommunicationStyle>({
|
||||||
message: 'Communication style',
|
message: 'Communication style',
|
||||||
options: [
|
options: [
|
||||||
@@ -46,7 +58,7 @@ export async function soulSetupStage(p: WizardPrompter, state: WizardState): Pro
|
|||||||
{ value: 'friendly', label: 'Friendly', hint: 'Warm but efficient, conversational' },
|
{ value: 'friendly', label: 'Friendly', hint: 'Warm but efficient, conversational' },
|
||||||
{ value: 'formal', label: 'Formal', hint: 'Professional, structured, thorough' },
|
{ value: 'formal', label: 'Formal', hint: 'Professional, structured, thorough' },
|
||||||
],
|
],
|
||||||
initialValue: 'direct',
|
initialValue: state.soul.communicationStyle ?? 'direct',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mosaic/prdy",
|
"name": "@mosaic/prdy",
|
||||||
"version": "0.0.1-alpha.2",
|
"version": "0.0.2",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mosaic/quality-rails",
|
"name": "@mosaic/quality-rails",
|
||||||
"version": "0.0.1-alpha.2",
|
"version": "0.0.3",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
"test": "vitest run --passWithNoTests"
|
"test": "vitest run --passWithNoTests"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"commander": "^12.0.0"
|
"commander": "^13.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^22.0.0",
|
"@types/node": "^22.0.0",
|
||||||
|
|||||||
@@ -106,12 +106,26 @@ function printScaffoldResult(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register quality-rails subcommands on an existing Commander program.
|
||||||
|
* This avoids cross-package Commander version mismatches by using the
|
||||||
|
* caller's Command instance directly.
|
||||||
|
*/
|
||||||
|
export function registerQualityRails(parent: Command): void {
|
||||||
|
buildQualityRailsCommand(
|
||||||
|
parent.command('quality-rails').description('Manage quality rails scaffolding'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export function createQualityRailsCli(): Command {
|
export function createQualityRailsCli(): Command {
|
||||||
const program = new Command('mosaic');
|
const program = new Command('mosaic');
|
||||||
const qualityRails = program
|
buildQualityRailsCommand(
|
||||||
.command('quality-rails')
|
program.command('quality-rails').description('Manage quality rails scaffolding'),
|
||||||
.description('Manage quality rails scaffolding');
|
);
|
||||||
|
return program;
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildQualityRailsCommand(qualityRails: Command): void {
|
||||||
qualityRails
|
qualityRails
|
||||||
.command('init')
|
.command('init')
|
||||||
.requiredOption('--project <path>', 'Project path')
|
.requiredOption('--project <path>', 'Project path')
|
||||||
@@ -184,8 +198,6 @@ export function createQualityRailsCli(): Command {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return program;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function runQualityRailsCli(argv: string[] = process.argv): Promise<void> {
|
export async function runQualityRailsCli(argv: string[] = process.argv): Promise<void> {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mosaic/queue",
|
"name": "@mosaic/queue",
|
||||||
"version": "0.0.1-alpha.2",
|
"version": "0.0.2",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|||||||
50
packages/queue/src/adapters/bullmq.ts
Normal file
50
packages/queue/src/adapters/bullmq.ts
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
import Redis from 'ioredis';
|
||||||
|
|
||||||
|
import type { QueueAdapter, QueueConfig, TaskPayload } from '../types.js';
|
||||||
|
|
||||||
|
const DEFAULT_VALKEY_URL = 'redis://localhost:6380';
|
||||||
|
|
||||||
|
export function createBullMQAdapter(config: QueueConfig): QueueAdapter {
|
||||||
|
if (config.type !== 'bullmq') {
|
||||||
|
throw new Error(`Expected config type "bullmq", got "${config.type}"`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const url = config.url ?? process.env['VALKEY_URL'] ?? DEFAULT_VALKEY_URL;
|
||||||
|
const redis = new Redis(url, { maxRetriesPerRequest: 3 });
|
||||||
|
|
||||||
|
return {
|
||||||
|
name: 'bullmq',
|
||||||
|
|
||||||
|
async enqueue(queueName: string, payload: TaskPayload): Promise<void> {
|
||||||
|
await redis.lpush(queueName, JSON.stringify(payload));
|
||||||
|
},
|
||||||
|
|
||||||
|
async dequeue(queueName: string): Promise<TaskPayload | null> {
|
||||||
|
const item = await redis.rpop(queueName);
|
||||||
|
if (!item) return null;
|
||||||
|
return JSON.parse(item) as TaskPayload;
|
||||||
|
},
|
||||||
|
|
||||||
|
async length(queueName: string): Promise<number> {
|
||||||
|
return redis.llen(queueName);
|
||||||
|
},
|
||||||
|
|
||||||
|
async publish(channel: string, message: string): Promise<void> {
|
||||||
|
await redis.publish(channel, message);
|
||||||
|
},
|
||||||
|
|
||||||
|
subscribe(channel: string, handler: (message: string) => void): () => void {
|
||||||
|
const sub = redis.duplicate();
|
||||||
|
sub.subscribe(channel).catch(() => {});
|
||||||
|
sub.on('message', (_ch: string, msg: string) => handler(msg));
|
||||||
|
return () => {
|
||||||
|
sub.unsubscribe(channel).catch(() => {});
|
||||||
|
sub.disconnect();
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
async close(): Promise<void> {
|
||||||
|
await redis.quit();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
81
packages/queue/src/adapters/local.test.ts
Normal file
81
packages/queue/src/adapters/local.test.ts
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
import { mkdtempSync, rmSync } from 'node:fs';
|
||||||
|
import { join } from 'node:path';
|
||||||
|
import { tmpdir } from 'node:os';
|
||||||
|
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
||||||
|
|
||||||
|
import type { TaskPayload } from '../types.js';
|
||||||
|
import { createLocalAdapter } from './local.js';
|
||||||
|
|
||||||
|
function makePayload(id: string): TaskPayload {
|
||||||
|
return { id, type: 'test', data: { value: id }, createdAt: new Date().toISOString() };
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('LocalAdapter', () => {
|
||||||
|
let dataDir: string;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
dataDir = mkdtempSync(join(tmpdir(), 'mosaic-queue-test-'));
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
rmSync(dataDir, { recursive: true, force: true });
|
||||||
|
});
|
||||||
|
|
||||||
|
it('enqueue + dequeue in FIFO order', async () => {
|
||||||
|
const adapter = createLocalAdapter({ type: 'local', dataDir });
|
||||||
|
const a = makePayload('a');
|
||||||
|
const b = makePayload('b');
|
||||||
|
const c = makePayload('c');
|
||||||
|
|
||||||
|
await adapter.enqueue('tasks', a);
|
||||||
|
await adapter.enqueue('tasks', b);
|
||||||
|
await adapter.enqueue('tasks', c);
|
||||||
|
|
||||||
|
expect(await adapter.dequeue('tasks')).toEqual(a);
|
||||||
|
expect(await adapter.dequeue('tasks')).toEqual(b);
|
||||||
|
expect(await adapter.dequeue('tasks')).toEqual(c);
|
||||||
|
expect(await adapter.dequeue('tasks')).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('length accuracy', async () => {
|
||||||
|
const adapter = createLocalAdapter({ type: 'local', dataDir });
|
||||||
|
|
||||||
|
expect(await adapter.length('q')).toBe(0);
|
||||||
|
await adapter.enqueue('q', makePayload('1'));
|
||||||
|
await adapter.enqueue('q', makePayload('2'));
|
||||||
|
expect(await adapter.length('q')).toBe(2);
|
||||||
|
await adapter.dequeue('q');
|
||||||
|
expect(await adapter.length('q')).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('publish + subscribe delivery', async () => {
|
||||||
|
const adapter = createLocalAdapter({ type: 'local', dataDir });
|
||||||
|
const received: string[] = [];
|
||||||
|
|
||||||
|
const unsub = adapter.subscribe('chan', (msg) => received.push(msg));
|
||||||
|
await adapter.publish('chan', 'hello');
|
||||||
|
await adapter.publish('chan', 'world');
|
||||||
|
|
||||||
|
expect(received).toEqual(['hello', 'world']);
|
||||||
|
|
||||||
|
unsub();
|
||||||
|
await adapter.publish('chan', 'after-unsub');
|
||||||
|
expect(received).toEqual(['hello', 'world']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('persistence survives close and re-create', async () => {
|
||||||
|
const p1 = makePayload('x');
|
||||||
|
const p2 = makePayload('y');
|
||||||
|
|
||||||
|
const adapter1 = createLocalAdapter({ type: 'local', dataDir });
|
||||||
|
await adapter1.enqueue('persist-q', p1);
|
||||||
|
await adapter1.enqueue('persist-q', p2);
|
||||||
|
await adapter1.close();
|
||||||
|
|
||||||
|
const adapter2 = createLocalAdapter({ type: 'local', dataDir });
|
||||||
|
expect(await adapter2.length('persist-q')).toBe(2);
|
||||||
|
expect(await adapter2.dequeue('persist-q')).toEqual(p1);
|
||||||
|
expect(await adapter2.dequeue('persist-q')).toEqual(p2);
|
||||||
|
await adapter2.close();
|
||||||
|
});
|
||||||
|
});
|
||||||
87
packages/queue/src/adapters/local.ts
Normal file
87
packages/queue/src/adapters/local.ts
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
import { mkdirSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
|
||||||
|
import { join } from 'node:path';
|
||||||
|
import { EventEmitter } from 'node:events';
|
||||||
|
|
||||||
|
import type { QueueAdapter, QueueConfig, TaskPayload } from '../types.js';
|
||||||
|
|
||||||
|
const DEFAULT_DATA_DIR = '.mosaic/queue';
|
||||||
|
|
||||||
|
export function createLocalAdapter(config: QueueConfig): QueueAdapter {
|
||||||
|
if (config.type !== 'local') {
|
||||||
|
throw new Error(`Expected config type "local", got "${config.type}"`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const dataDir = config.dataDir ?? DEFAULT_DATA_DIR;
|
||||||
|
const queues = new Map<string, TaskPayload[]>();
|
||||||
|
const emitter = new EventEmitter();
|
||||||
|
|
||||||
|
mkdirSync(dataDir, { recursive: true });
|
||||||
|
|
||||||
|
// Load existing JSON files on startup
|
||||||
|
for (const file of readdirSync(dataDir)) {
|
||||||
|
if (!file.endsWith('.json')) continue;
|
||||||
|
const queueName = file.slice(0, -5);
|
||||||
|
try {
|
||||||
|
const raw = readFileSync(join(dataDir, file), 'utf-8');
|
||||||
|
const items = JSON.parse(raw) as TaskPayload[];
|
||||||
|
if (Array.isArray(items)) {
|
||||||
|
queues.set(queueName, items);
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// Ignore corrupt files
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function persist(queueName: string): void {
|
||||||
|
const items = queues.get(queueName) ?? [];
|
||||||
|
writeFileSync(join(dataDir, `${queueName}.json`), JSON.stringify(items), 'utf-8');
|
||||||
|
}
|
||||||
|
|
||||||
|
function getQueue(queueName: string): TaskPayload[] {
|
||||||
|
let q = queues.get(queueName);
|
||||||
|
if (!q) {
|
||||||
|
q = [];
|
||||||
|
queues.set(queueName, q);
|
||||||
|
}
|
||||||
|
return q;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
name: 'local',
|
||||||
|
|
||||||
|
async enqueue(queueName: string, payload: TaskPayload): Promise<void> {
|
||||||
|
getQueue(queueName).push(payload);
|
||||||
|
persist(queueName);
|
||||||
|
},
|
||||||
|
|
||||||
|
async dequeue(queueName: string): Promise<TaskPayload | null> {
|
||||||
|
const q = getQueue(queueName);
|
||||||
|
const item = q.shift() ?? null;
|
||||||
|
persist(queueName);
|
||||||
|
return item;
|
||||||
|
},
|
||||||
|
|
||||||
|
async length(queueName: string): Promise<number> {
|
||||||
|
return getQueue(queueName).length;
|
||||||
|
},
|
||||||
|
|
||||||
|
async publish(channel: string, message: string): Promise<void> {
|
||||||
|
emitter.emit(channel, message);
|
||||||
|
},
|
||||||
|
|
||||||
|
subscribe(channel: string, handler: (message: string) => void): () => void {
|
||||||
|
emitter.on(channel, handler);
|
||||||
|
return () => {
|
||||||
|
emitter.off(channel, handler);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
async close(): Promise<void> {
|
||||||
|
for (const queueName of queues.keys()) {
|
||||||
|
persist(queueName);
|
||||||
|
}
|
||||||
|
queues.clear();
|
||||||
|
emitter.removeAllListeners();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
18
packages/queue/src/factory.ts
Normal file
18
packages/queue/src/factory.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import type { QueueAdapter, QueueConfig } from './types.js';
|
||||||
|
|
||||||
|
type QueueType = QueueConfig['type'];
|
||||||
|
|
||||||
|
const registry = new Map<QueueType, (config: QueueConfig) => QueueAdapter>();
|
||||||
|
|
||||||
|
export function registerQueueAdapter(
|
||||||
|
type: QueueType,
|
||||||
|
factory: (config: QueueConfig) => QueueAdapter,
|
||||||
|
): void {
|
||||||
|
registry.set(type, factory);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createQueueAdapter(config: QueueConfig): QueueAdapter {
|
||||||
|
const factory = registry.get(config.type);
|
||||||
|
if (!factory) throw new Error(`No adapter registered for type: ${config.type}`);
|
||||||
|
return factory(config);
|
||||||
|
}
|
||||||
@@ -6,3 +6,15 @@ export {
|
|||||||
type QueueClient,
|
type QueueClient,
|
||||||
type TaskPayload,
|
type TaskPayload,
|
||||||
} from './queue.js';
|
} from './queue.js';
|
||||||
|
|
||||||
|
export { type QueueAdapter, type QueueConfig as QueueAdapterConfig } from './types.js';
|
||||||
|
export { createQueueAdapter, registerQueueAdapter } from './factory.js';
|
||||||
|
export { createBullMQAdapter } from './adapters/bullmq.js';
|
||||||
|
export { createLocalAdapter } from './adapters/local.js';
|
||||||
|
|
||||||
|
import { registerQueueAdapter } from './factory.js';
|
||||||
|
import { createBullMQAdapter } from './adapters/bullmq.js';
|
||||||
|
import { createLocalAdapter } from './adapters/local.js';
|
||||||
|
|
||||||
|
registerQueueAdapter('bullmq', createBullMQAdapter);
|
||||||
|
registerQueueAdapter('local', createLocalAdapter);
|
||||||
|
|||||||
18
packages/queue/src/types.ts
Normal file
18
packages/queue/src/types.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
export interface TaskPayload {
|
||||||
|
id: string;
|
||||||
|
type: string;
|
||||||
|
data: Record<string, unknown>;
|
||||||
|
createdAt: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface QueueAdapter {
|
||||||
|
readonly name: string;
|
||||||
|
enqueue(queueName: string, payload: TaskPayload): Promise<void>;
|
||||||
|
dequeue(queueName: string): Promise<TaskPayload | null>;
|
||||||
|
length(queueName: string): Promise<number>;
|
||||||
|
publish(channel: string, message: string): Promise<void>;
|
||||||
|
subscribe(channel: string, handler: (message: string) => void): () => void;
|
||||||
|
close(): Promise<void>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type QueueConfig = { type: 'bullmq'; url?: string } | { type: 'local'; dataDir?: string };
|
||||||
35
packages/storage/package.json
Normal file
35
packages/storage/package.json
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"name": "@mosaic/storage",
|
||||||
|
"version": "0.0.2",
|
||||||
|
"main": "dist/index.js",
|
||||||
|
"types": "dist/index.d.ts",
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"types": "./dist/index.d.ts",
|
||||||
|
"default": "./dist/index.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "tsc",
|
||||||
|
"lint": "eslint src",
|
||||||
|
"typecheck": "tsc --noEmit",
|
||||||
|
"test": "vitest run --passWithNoTests"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@mosaic/db": "workspace:^",
|
||||||
|
"@mosaic/types": "workspace:*",
|
||||||
|
"better-sqlite3": "^12.8.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/better-sqlite3": "^7.6.13",
|
||||||
|
"typescript": "^5.8.0",
|
||||||
|
"vitest": "^2.0.0"
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"registry": "https://git.mosaicstack.dev/api/packages/mosaic/npm/",
|
||||||
|
"access": "public"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"dist"
|
||||||
|
]
|
||||||
|
}
|
||||||
252
packages/storage/src/adapters/postgres.ts
Normal file
252
packages/storage/src/adapters/postgres.ts
Normal file
@@ -0,0 +1,252 @@
|
|||||||
|
import {
|
||||||
|
createDb,
|
||||||
|
runMigrations,
|
||||||
|
eq,
|
||||||
|
and,
|
||||||
|
asc,
|
||||||
|
desc,
|
||||||
|
sql,
|
||||||
|
type Db,
|
||||||
|
type DbHandle,
|
||||||
|
} from '@mosaic/db';
|
||||||
|
import * as schema from '@mosaic/db';
|
||||||
|
import type { StorageAdapter, StorageConfig } from '../types.js';
|
||||||
|
|
||||||
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maps collection name → Drizzle table object.
|
||||||
|
* Typed as `any` because the generic StorageAdapter interface erases table
|
||||||
|
* types — all runtime values are still strongly-typed Drizzle table objects.
|
||||||
|
*/
|
||||||
|
const TABLE_MAP: Record<string, any> = {
|
||||||
|
users: schema.users,
|
||||||
|
sessions: schema.sessions,
|
||||||
|
accounts: schema.accounts,
|
||||||
|
verifications: schema.verifications,
|
||||||
|
teams: schema.teams,
|
||||||
|
team_members: schema.teamMembers,
|
||||||
|
projects: schema.projects,
|
||||||
|
missions: schema.missions,
|
||||||
|
tasks: schema.tasks,
|
||||||
|
mission_tasks: schema.missionTasks,
|
||||||
|
events: schema.events,
|
||||||
|
agents: schema.agents,
|
||||||
|
tickets: schema.tickets,
|
||||||
|
appreciations: schema.appreciations,
|
||||||
|
conversations: schema.conversations,
|
||||||
|
messages: schema.messages,
|
||||||
|
preferences: schema.preferences,
|
||||||
|
insights: schema.insights,
|
||||||
|
agent_logs: schema.agentLogs,
|
||||||
|
skills: schema.skills,
|
||||||
|
routing_rules: schema.routingRules,
|
||||||
|
provider_credentials: schema.providerCredentials,
|
||||||
|
summarization_jobs: schema.summarizationJobs,
|
||||||
|
};
|
||||||
|
|
||||||
|
function getTable(collection: string): any {
|
||||||
|
const table = TABLE_MAP[collection];
|
||||||
|
if (!table) throw new Error(`Unknown collection: ${collection}`);
|
||||||
|
return table;
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildWhereClause(table: any, filter?: Record<string, unknown>) {
|
||||||
|
if (!filter || Object.keys(filter).length === 0) return undefined;
|
||||||
|
const conditions = Object.entries(filter).map(([key, value]) => {
|
||||||
|
const column = table[key];
|
||||||
|
if (!column) throw new Error(`Unknown column "${key}" on table`);
|
||||||
|
return eq(column, value);
|
||||||
|
});
|
||||||
|
return conditions.length === 1 ? conditions[0]! : and(...conditions);
|
||||||
|
}
|
||||||
|
|
||||||
|
export class PostgresAdapter implements StorageAdapter {
|
||||||
|
readonly name = 'postgres';
|
||||||
|
private handle: DbHandle;
|
||||||
|
private db: Db;
|
||||||
|
private url: string;
|
||||||
|
|
||||||
|
constructor(config: Extract<StorageConfig, { type: 'postgres' }>) {
|
||||||
|
this.url = config.url;
|
||||||
|
this.handle = createDb(config.url);
|
||||||
|
this.db = this.handle.db;
|
||||||
|
}
|
||||||
|
|
||||||
|
async create<T extends Record<string, unknown>>(
|
||||||
|
collection: string,
|
||||||
|
data: T,
|
||||||
|
): Promise<T & { id: string }> {
|
||||||
|
const table = getTable(collection);
|
||||||
|
const [row] = await (this.db as any).insert(table).values(data).returning();
|
||||||
|
return row as T & { id: string };
|
||||||
|
}
|
||||||
|
|
||||||
|
async read<T extends Record<string, unknown>>(collection: string, id: string): Promise<T | null> {
|
||||||
|
const table = getTable(collection);
|
||||||
|
const [row] = await (this.db as any).select().from(table).where(eq(table.id, id));
|
||||||
|
return (row as T) ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
async update(collection: string, id: string, data: Record<string, unknown>): Promise<boolean> {
|
||||||
|
const table = getTable(collection);
|
||||||
|
const result = await (this.db as any)
|
||||||
|
.update(table)
|
||||||
|
.set(data)
|
||||||
|
.where(eq(table.id, id))
|
||||||
|
.returning();
|
||||||
|
return result.length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
async delete(collection: string, id: string): Promise<boolean> {
|
||||||
|
const table = getTable(collection);
|
||||||
|
const result = await (this.db as any).delete(table).where(eq(table.id, id)).returning();
|
||||||
|
return result.length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
async find<T extends Record<string, unknown>>(
|
||||||
|
collection: string,
|
||||||
|
filter?: Record<string, unknown>,
|
||||||
|
opts?: { limit?: number; offset?: number; orderBy?: string; order?: 'asc' | 'desc' },
|
||||||
|
): Promise<T[]> {
|
||||||
|
const table = getTable(collection);
|
||||||
|
let query = (this.db as any).select().from(table);
|
||||||
|
const where = buildWhereClause(table, filter);
|
||||||
|
if (where) query = query.where(where);
|
||||||
|
if (opts?.orderBy) {
|
||||||
|
const col = table[opts.orderBy];
|
||||||
|
if (col) {
|
||||||
|
query = query.orderBy(opts.order === 'desc' ? desc(col) : asc(col));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (opts?.limit) query = query.limit(opts.limit);
|
||||||
|
if (opts?.offset) query = query.offset(opts.offset);
|
||||||
|
return (await query) as T[];
|
||||||
|
}
|
||||||
|
|
||||||
|
async findOne<T extends Record<string, unknown>>(
|
||||||
|
collection: string,
|
||||||
|
filter: Record<string, unknown>,
|
||||||
|
): Promise<T | null> {
|
||||||
|
const results = await this.find<T>(collection, filter, { limit: 1 });
|
||||||
|
return results[0] ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
async count(collection: string, filter?: Record<string, unknown>): Promise<number> {
|
||||||
|
const table = getTable(collection);
|
||||||
|
let query = (this.db as any).select({ count: sql<number>`count(*)::int` }).from(table);
|
||||||
|
const where = buildWhereClause(table, filter);
|
||||||
|
if (where) query = query.where(where);
|
||||||
|
const [row] = await query;
|
||||||
|
return (row as any)?.count ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
async transaction<T>(fn: (tx: StorageAdapter) => Promise<T>): Promise<T> {
|
||||||
|
return (this.db as any).transaction(async (drizzleTx: any) => {
|
||||||
|
const txAdapter = new PostgresTxAdapter(drizzleTx, this.url);
|
||||||
|
return fn(txAdapter);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async migrate(): Promise<void> {
|
||||||
|
await runMigrations(this.url);
|
||||||
|
}
|
||||||
|
|
||||||
|
async close(): Promise<void> {
|
||||||
|
await this.handle.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thin transaction wrapper — delegates to the Drizzle transaction object
|
||||||
|
* instead of the top-level db handle.
|
||||||
|
*/
|
||||||
|
class PostgresTxAdapter implements StorageAdapter {
|
||||||
|
readonly name = 'postgres';
|
||||||
|
private tx: any;
|
||||||
|
private url: string;
|
||||||
|
|
||||||
|
constructor(tx: any, url: string) {
|
||||||
|
this.tx = tx;
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
async create<T extends Record<string, unknown>>(
|
||||||
|
collection: string,
|
||||||
|
data: T,
|
||||||
|
): Promise<T & { id: string }> {
|
||||||
|
const table = getTable(collection);
|
||||||
|
const [row] = await this.tx.insert(table).values(data).returning();
|
||||||
|
return row as T & { id: string };
|
||||||
|
}
|
||||||
|
|
||||||
|
async read<T extends Record<string, unknown>>(collection: string, id: string): Promise<T | null> {
|
||||||
|
const table = getTable(collection);
|
||||||
|
const [row] = await this.tx.select().from(table).where(eq(table.id, id));
|
||||||
|
return (row as T) ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
async update(collection: string, id: string, data: Record<string, unknown>): Promise<boolean> {
|
||||||
|
const table = getTable(collection);
|
||||||
|
const result = await this.tx.update(table).set(data).where(eq(table.id, id)).returning();
|
||||||
|
return result.length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
async delete(collection: string, id: string): Promise<boolean> {
|
||||||
|
const table = getTable(collection);
|
||||||
|
const result = await this.tx.delete(table).where(eq(table.id, id)).returning();
|
||||||
|
return result.length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
async find<T extends Record<string, unknown>>(
|
||||||
|
collection: string,
|
||||||
|
filter?: Record<string, unknown>,
|
||||||
|
opts?: { limit?: number; offset?: number; orderBy?: string; order?: 'asc' | 'desc' },
|
||||||
|
): Promise<T[]> {
|
||||||
|
const table = getTable(collection);
|
||||||
|
let query = this.tx.select().from(table);
|
||||||
|
const where = buildWhereClause(table, filter);
|
||||||
|
if (where) query = query.where(where);
|
||||||
|
if (opts?.orderBy) {
|
||||||
|
const col = table[opts.orderBy];
|
||||||
|
if (col) {
|
||||||
|
query = query.orderBy(opts.order === 'desc' ? desc(col) : asc(col));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (opts?.limit) query = query.limit(opts.limit);
|
||||||
|
if (opts?.offset) query = query.offset(opts.offset);
|
||||||
|
return (await query) as T[];
|
||||||
|
}
|
||||||
|
|
||||||
|
async findOne<T extends Record<string, unknown>>(
|
||||||
|
collection: string,
|
||||||
|
filter: Record<string, unknown>,
|
||||||
|
): Promise<T | null> {
|
||||||
|
const results = await this.find<T>(collection, filter, { limit: 1 });
|
||||||
|
return results[0] ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
async count(collection: string, filter?: Record<string, unknown>): Promise<number> {
|
||||||
|
const table = getTable(collection);
|
||||||
|
let query = this.tx.select({ count: sql<number>`count(*)::int` }).from(table);
|
||||||
|
const where = buildWhereClause(table, filter);
|
||||||
|
if (where) query = query.where(where);
|
||||||
|
const [row] = await query;
|
||||||
|
return (row as any)?.count ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
async transaction<T>(fn: (tx: StorageAdapter) => Promise<T>): Promise<T> {
|
||||||
|
return this.tx.transaction(async (nestedTx: any) => {
|
||||||
|
const nested = new PostgresTxAdapter(nestedTx, this.url);
|
||||||
|
return fn(nested);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async migrate(): Promise<void> {
|
||||||
|
await runMigrations(this.url);
|
||||||
|
}
|
||||||
|
|
||||||
|
async close(): Promise<void> {
|
||||||
|
// No-op inside a transaction
|
||||||
|
}
|
||||||
|
}
|
||||||
201
packages/storage/src/adapters/sqlite.test.ts
Normal file
201
packages/storage/src/adapters/sqlite.test.ts
Normal file
@@ -0,0 +1,201 @@
|
|||||||
|
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
||||||
|
import { SqliteAdapter } from './sqlite.js';
|
||||||
|
|
||||||
|
describe('SqliteAdapter', () => {
|
||||||
|
let adapter: SqliteAdapter;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
adapter = new SqliteAdapter({ type: 'sqlite', path: ':memory:' });
|
||||||
|
await adapter.migrate();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(async () => {
|
||||||
|
await adapter.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('CRUD', () => {
|
||||||
|
it('creates and reads a record', async () => {
|
||||||
|
const created = await adapter.create('users', { name: 'Alice', email: 'alice@test.com' });
|
||||||
|
expect(created.id).toBeDefined();
|
||||||
|
expect(created.name).toBe('Alice');
|
||||||
|
|
||||||
|
const read = await adapter.read('users', created.id);
|
||||||
|
expect(read).not.toBeNull();
|
||||||
|
expect(read!.name).toBe('Alice');
|
||||||
|
expect(read!.email).toBe('alice@test.com');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns null for non-existent record', async () => {
|
||||||
|
const result = await adapter.read('users', 'does-not-exist');
|
||||||
|
expect(result).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('updates a record', async () => {
|
||||||
|
const created = await adapter.create('users', { name: 'Alice' });
|
||||||
|
const updated = await adapter.update('users', created.id, { name: 'Bob' });
|
||||||
|
expect(updated).toBe(true);
|
||||||
|
|
||||||
|
const read = await adapter.read('users', created.id);
|
||||||
|
expect(read!.name).toBe('Bob');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('update returns false for non-existent record', async () => {
|
||||||
|
const result = await adapter.update('users', 'does-not-exist', { name: 'X' });
|
||||||
|
expect(result).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('deletes a record', async () => {
|
||||||
|
const created = await adapter.create('users', { name: 'Alice' });
|
||||||
|
const deleted = await adapter.delete('users', created.id);
|
||||||
|
expect(deleted).toBe(true);
|
||||||
|
|
||||||
|
const read = await adapter.read('users', created.id);
|
||||||
|
expect(read).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('delete returns false for non-existent record', async () => {
|
||||||
|
const result = await adapter.delete('users', 'does-not-exist');
|
||||||
|
expect(result).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('find', () => {
|
||||||
|
it('finds records with filter', async () => {
|
||||||
|
await adapter.create('users', { name: 'Alice', role: 'admin' });
|
||||||
|
await adapter.create('users', { name: 'Bob', role: 'user' });
|
||||||
|
await adapter.create('users', { name: 'Charlie', role: 'admin' });
|
||||||
|
|
||||||
|
const admins = await adapter.find('users', { role: 'admin' });
|
||||||
|
expect(admins).toHaveLength(2);
|
||||||
|
expect(admins.map((u) => u.name).sort()).toEqual(['Alice', 'Charlie']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('finds all records without filter', async () => {
|
||||||
|
await adapter.create('users', { name: 'Alice' });
|
||||||
|
await adapter.create('users', { name: 'Bob' });
|
||||||
|
|
||||||
|
const all = await adapter.find('users');
|
||||||
|
expect(all).toHaveLength(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('supports limit and offset', async () => {
|
||||||
|
for (let i = 0; i < 5; i++) {
|
||||||
|
await adapter.create('users', { name: `User${i}`, idx: i });
|
||||||
|
}
|
||||||
|
|
||||||
|
const page = await adapter.find('users', undefined, {
|
||||||
|
limit: 2,
|
||||||
|
offset: 1,
|
||||||
|
orderBy: 'created_at',
|
||||||
|
});
|
||||||
|
expect(page).toHaveLength(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('findOne returns first match', async () => {
|
||||||
|
await adapter.create('users', { name: 'Alice', role: 'admin' });
|
||||||
|
await adapter.create('users', { name: 'Bob', role: 'user' });
|
||||||
|
|
||||||
|
const found = await adapter.findOne('users', { role: 'user' });
|
||||||
|
expect(found).not.toBeNull();
|
||||||
|
expect(found!.name).toBe('Bob');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('findOne returns null when no match', async () => {
|
||||||
|
const result = await adapter.findOne('users', { role: 'nonexistent' });
|
||||||
|
expect(result).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('count', () => {
|
||||||
|
it('counts all records', async () => {
|
||||||
|
await adapter.create('users', { name: 'Alice' });
|
||||||
|
await adapter.create('users', { name: 'Bob' });
|
||||||
|
|
||||||
|
const total = await adapter.count('users');
|
||||||
|
expect(total).toBe(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('counts with filter', async () => {
|
||||||
|
await adapter.create('users', { name: 'Alice', role: 'admin' });
|
||||||
|
await adapter.create('users', { name: 'Bob', role: 'user' });
|
||||||
|
await adapter.create('users', { name: 'Charlie', role: 'admin' });
|
||||||
|
|
||||||
|
const adminCount = await adapter.count('users', { role: 'admin' });
|
||||||
|
expect(adminCount).toBe(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns 0 for empty collection', async () => {
|
||||||
|
const count = await adapter.count('users');
|
||||||
|
expect(count).toBe(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('transaction', () => {
|
||||||
|
it('commits on success', async () => {
|
||||||
|
await adapter.transaction(async (tx) => {
|
||||||
|
await tx.create('users', { name: 'Alice' });
|
||||||
|
await tx.create('users', { name: 'Bob' });
|
||||||
|
});
|
||||||
|
|
||||||
|
const count = await adapter.count('users');
|
||||||
|
expect(count).toBe(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('rolls back on error', async () => {
|
||||||
|
await expect(
|
||||||
|
adapter.transaction(async (tx) => {
|
||||||
|
await tx.create('users', { name: 'Alice' });
|
||||||
|
throw new Error('rollback test');
|
||||||
|
}),
|
||||||
|
).rejects.toThrow('rollback test');
|
||||||
|
|
||||||
|
const count = await adapter.count('users');
|
||||||
|
expect(count).toBe(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('migrate', () => {
|
||||||
|
it('creates all tables', async () => {
|
||||||
|
// migrate() was already called in beforeEach — verify tables exist
|
||||||
|
const collections = [
|
||||||
|
'users',
|
||||||
|
'sessions',
|
||||||
|
'accounts',
|
||||||
|
'projects',
|
||||||
|
'missions',
|
||||||
|
'tasks',
|
||||||
|
'agents',
|
||||||
|
'conversations',
|
||||||
|
'messages',
|
||||||
|
'preferences',
|
||||||
|
'insights',
|
||||||
|
'skills',
|
||||||
|
'events',
|
||||||
|
'routing_rules',
|
||||||
|
'provider_credentials',
|
||||||
|
'agent_logs',
|
||||||
|
'teams',
|
||||||
|
'team_members',
|
||||||
|
'mission_tasks',
|
||||||
|
'tickets',
|
||||||
|
'summarization_jobs',
|
||||||
|
'appreciations',
|
||||||
|
'verifications',
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const collection of collections) {
|
||||||
|
// Should not throw
|
||||||
|
const count = await adapter.count(collection);
|
||||||
|
expect(count).toBe(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('is idempotent', async () => {
|
||||||
|
await adapter.migrate();
|
||||||
|
await adapter.migrate();
|
||||||
|
// Should not throw
|
||||||
|
const count = await adapter.count('users');
|
||||||
|
expect(count).toBe(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
283
packages/storage/src/adapters/sqlite.ts
Normal file
283
packages/storage/src/adapters/sqlite.ts
Normal file
@@ -0,0 +1,283 @@
|
|||||||
|
import Database from 'better-sqlite3';
|
||||||
|
import { randomUUID } from 'node:crypto';
|
||||||
|
import type { StorageAdapter, StorageConfig } from '../types.js';
|
||||||
|
|
||||||
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
|
||||||
|
const COLLECTIONS = [
|
||||||
|
'users',
|
||||||
|
'sessions',
|
||||||
|
'accounts',
|
||||||
|
'projects',
|
||||||
|
'missions',
|
||||||
|
'tasks',
|
||||||
|
'agents',
|
||||||
|
'conversations',
|
||||||
|
'messages',
|
||||||
|
'preferences',
|
||||||
|
'insights',
|
||||||
|
'skills',
|
||||||
|
'events',
|
||||||
|
'routing_rules',
|
||||||
|
'provider_credentials',
|
||||||
|
'agent_logs',
|
||||||
|
'teams',
|
||||||
|
'team_members',
|
||||||
|
'mission_tasks',
|
||||||
|
'tickets',
|
||||||
|
'summarization_jobs',
|
||||||
|
'appreciations',
|
||||||
|
'verifications',
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
function buildFilterClause(filter?: Record<string, unknown>): {
|
||||||
|
clause: string;
|
||||||
|
params: unknown[];
|
||||||
|
} {
|
||||||
|
if (!filter || Object.keys(filter).length === 0) return { clause: '', params: [] };
|
||||||
|
const conditions: string[] = [];
|
||||||
|
const params: unknown[] = [];
|
||||||
|
for (const [key, value] of Object.entries(filter)) {
|
||||||
|
if (key === 'id') {
|
||||||
|
conditions.push('id = ?');
|
||||||
|
params.push(value);
|
||||||
|
} else {
|
||||||
|
conditions.push(`json_extract(data_json, '$.${key}') = ?`);
|
||||||
|
params.push(typeof value === 'object' ? JSON.stringify(value) : value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return { clause: ` WHERE ${conditions.join(' AND ')}`, params };
|
||||||
|
}
|
||||||
|
|
||||||
|
export class SqliteAdapter implements StorageAdapter {
|
||||||
|
readonly name = 'sqlite';
|
||||||
|
private db: Database.Database;
|
||||||
|
|
||||||
|
constructor(config: Extract<StorageConfig, { type: 'sqlite' }>) {
|
||||||
|
this.db = new Database(config.path);
|
||||||
|
this.db.pragma('journal_mode = WAL');
|
||||||
|
this.db.pragma('foreign_keys = ON');
|
||||||
|
}
|
||||||
|
|
||||||
|
async create<T extends Record<string, unknown>>(
|
||||||
|
collection: string,
|
||||||
|
data: T,
|
||||||
|
): Promise<T & { id: string }> {
|
||||||
|
const id = (data as any).id ?? randomUUID();
|
||||||
|
const now = new Date().toISOString();
|
||||||
|
const rest = Object.fromEntries(Object.entries(data).filter(([k]) => k !== 'id'));
|
||||||
|
this.db
|
||||||
|
.prepare(
|
||||||
|
`INSERT INTO ${collection} (id, data_json, created_at, updated_at) VALUES (?, ?, ?, ?)`,
|
||||||
|
)
|
||||||
|
.run(id, JSON.stringify(rest), now, now);
|
||||||
|
return { ...data, id } as T & { id: string };
|
||||||
|
}
|
||||||
|
|
||||||
|
async read<T extends Record<string, unknown>>(collection: string, id: string): Promise<T | null> {
|
||||||
|
const row = this.db.prepare(`SELECT * FROM ${collection} WHERE id = ?`).get(id) as any;
|
||||||
|
if (!row) return null;
|
||||||
|
return { id: row.id, ...JSON.parse(row.data_json as string) } as T;
|
||||||
|
}
|
||||||
|
|
||||||
|
async update(collection: string, id: string, data: Record<string, unknown>): Promise<boolean> {
|
||||||
|
const existing = this.db
|
||||||
|
.prepare(`SELECT data_json FROM ${collection} WHERE id = ?`)
|
||||||
|
.get(id) as any;
|
||||||
|
if (!existing) return false;
|
||||||
|
const merged = { ...JSON.parse(existing.data_json as string), ...data };
|
||||||
|
const now = new Date().toISOString();
|
||||||
|
const result = this.db
|
||||||
|
.prepare(`UPDATE ${collection} SET data_json = ?, updated_at = ? WHERE id = ?`)
|
||||||
|
.run(JSON.stringify(merged), now, id);
|
||||||
|
return result.changes > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
async delete(collection: string, id: string): Promise<boolean> {
|
||||||
|
const result = this.db.prepare(`DELETE FROM ${collection} WHERE id = ?`).run(id);
|
||||||
|
return result.changes > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
async find<T extends Record<string, unknown>>(
|
||||||
|
collection: string,
|
||||||
|
filter?: Record<string, unknown>,
|
||||||
|
opts?: { limit?: number; offset?: number; orderBy?: string; order?: 'asc' | 'desc' },
|
||||||
|
): Promise<T[]> {
|
||||||
|
const { clause, params } = buildFilterClause(filter);
|
||||||
|
let query = `SELECT * FROM ${collection}${clause}`;
|
||||||
|
if (opts?.orderBy) {
|
||||||
|
const dir = opts.order === 'desc' ? 'DESC' : 'ASC';
|
||||||
|
const col =
|
||||||
|
opts.orderBy === 'id' || opts.orderBy === 'created_at' || opts.orderBy === 'updated_at'
|
||||||
|
? opts.orderBy
|
||||||
|
: `json_extract(data_json, '$.${opts.orderBy}')`;
|
||||||
|
query += ` ORDER BY ${col} ${dir}`;
|
||||||
|
}
|
||||||
|
if (opts?.limit) {
|
||||||
|
query += ` LIMIT ?`;
|
||||||
|
params.push(opts.limit);
|
||||||
|
}
|
||||||
|
if (opts?.offset) {
|
||||||
|
query += ` OFFSET ?`;
|
||||||
|
params.push(opts.offset);
|
||||||
|
}
|
||||||
|
const rows = this.db.prepare(query).all(...params) as any[];
|
||||||
|
return rows.map((row) => ({ id: row.id, ...JSON.parse(row.data_json as string) }) as T);
|
||||||
|
}
|
||||||
|
|
||||||
|
async findOne<T extends Record<string, unknown>>(
|
||||||
|
collection: string,
|
||||||
|
filter: Record<string, unknown>,
|
||||||
|
): Promise<T | null> {
|
||||||
|
const results = await this.find<T>(collection, filter, { limit: 1 });
|
||||||
|
return results[0] ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
async count(collection: string, filter?: Record<string, unknown>): Promise<number> {
|
||||||
|
const { clause, params } = buildFilterClause(filter);
|
||||||
|
const row = this.db
|
||||||
|
.prepare(`SELECT COUNT(*) as count FROM ${collection}${clause}`)
|
||||||
|
.get(...params) as any;
|
||||||
|
return row?.count ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
async transaction<T>(fn: (tx: StorageAdapter) => Promise<T>): Promise<T> {
|
||||||
|
const txAdapter = new SqliteTxAdapter(this.db);
|
||||||
|
this.db.exec('BEGIN');
|
||||||
|
try {
|
||||||
|
const result = await fn(txAdapter);
|
||||||
|
this.db.exec('COMMIT');
|
||||||
|
return result;
|
||||||
|
} catch (err) {
|
||||||
|
this.db.exec('ROLLBACK');
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async migrate(): Promise<void> {
|
||||||
|
const createTable = (name: string) =>
|
||||||
|
this.db.exec(`
|
||||||
|
CREATE TABLE IF NOT EXISTS ${name} (
|
||||||
|
id TEXT PRIMARY KEY,
|
||||||
|
data_json TEXT NOT NULL DEFAULT '{}',
|
||||||
|
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
||||||
|
updated_at TEXT NOT NULL DEFAULT (datetime('now'))
|
||||||
|
)
|
||||||
|
`);
|
||||||
|
for (const collection of COLLECTIONS) {
|
||||||
|
createTable(collection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async close(): Promise<void> {
|
||||||
|
this.db.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transaction wrapper that uses the same db handle — better-sqlite3 transactions
|
||||||
|
* are connection-level, so all statements on the same Database instance within
|
||||||
|
* a db.transaction() callback participate in the transaction.
|
||||||
|
*/
|
||||||
|
class SqliteTxAdapter implements StorageAdapter {
|
||||||
|
readonly name = 'sqlite';
|
||||||
|
private db: Database.Database;
|
||||||
|
|
||||||
|
constructor(db: Database.Database) {
|
||||||
|
this.db = db;
|
||||||
|
}
|
||||||
|
|
||||||
|
async create<T extends Record<string, unknown>>(
|
||||||
|
collection: string,
|
||||||
|
data: T,
|
||||||
|
): Promise<T & { id: string }> {
|
||||||
|
const id = (data as any).id ?? randomUUID();
|
||||||
|
const now = new Date().toISOString();
|
||||||
|
const rest = Object.fromEntries(Object.entries(data).filter(([k]) => k !== 'id'));
|
||||||
|
this.db
|
||||||
|
.prepare(
|
||||||
|
`INSERT INTO ${collection} (id, data_json, created_at, updated_at) VALUES (?, ?, ?, ?)`,
|
||||||
|
)
|
||||||
|
.run(id, JSON.stringify(rest), now, now);
|
||||||
|
return { ...data, id } as T & { id: string };
|
||||||
|
}
|
||||||
|
|
||||||
|
async read<T extends Record<string, unknown>>(collection: string, id: string): Promise<T | null> {
|
||||||
|
const row = this.db.prepare(`SELECT * FROM ${collection} WHERE id = ?`).get(id) as any;
|
||||||
|
if (!row) return null;
|
||||||
|
return { id: row.id, ...JSON.parse(row.data_json as string) } as T;
|
||||||
|
}
|
||||||
|
|
||||||
|
async update(collection: string, id: string, data: Record<string, unknown>): Promise<boolean> {
|
||||||
|
const existing = this.db
|
||||||
|
.prepare(`SELECT data_json FROM ${collection} WHERE id = ?`)
|
||||||
|
.get(id) as any;
|
||||||
|
if (!existing) return false;
|
||||||
|
const merged = { ...JSON.parse(existing.data_json as string), ...data };
|
||||||
|
const now = new Date().toISOString();
|
||||||
|
const result = this.db
|
||||||
|
.prepare(`UPDATE ${collection} SET data_json = ?, updated_at = ? WHERE id = ?`)
|
||||||
|
.run(JSON.stringify(merged), now, id);
|
||||||
|
return result.changes > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
async delete(collection: string, id: string): Promise<boolean> {
|
||||||
|
const result = this.db.prepare(`DELETE FROM ${collection} WHERE id = ?`).run(id);
|
||||||
|
return result.changes > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
async find<T extends Record<string, unknown>>(
|
||||||
|
collection: string,
|
||||||
|
filter?: Record<string, unknown>,
|
||||||
|
opts?: { limit?: number; offset?: number; orderBy?: string; order?: 'asc' | 'desc' },
|
||||||
|
): Promise<T[]> {
|
||||||
|
const { clause, params } = buildFilterClause(filter);
|
||||||
|
let query = `SELECT * FROM ${collection}${clause}`;
|
||||||
|
if (opts?.orderBy) {
|
||||||
|
const dir = opts.order === 'desc' ? 'DESC' : 'ASC';
|
||||||
|
const col =
|
||||||
|
opts.orderBy === 'id' || opts.orderBy === 'created_at' || opts.orderBy === 'updated_at'
|
||||||
|
? opts.orderBy
|
||||||
|
: `json_extract(data_json, '$.${opts.orderBy}')`;
|
||||||
|
query += ` ORDER BY ${col} ${dir}`;
|
||||||
|
}
|
||||||
|
if (opts?.limit) {
|
||||||
|
query += ` LIMIT ?`;
|
||||||
|
params.push(opts.limit);
|
||||||
|
}
|
||||||
|
if (opts?.offset) {
|
||||||
|
query += ` OFFSET ?`;
|
||||||
|
params.push(opts.offset);
|
||||||
|
}
|
||||||
|
const rows = this.db.prepare(query).all(...params) as any[];
|
||||||
|
return rows.map((row) => ({ id: row.id, ...JSON.parse(row.data_json as string) }) as T);
|
||||||
|
}
|
||||||
|
|
||||||
|
async findOne<T extends Record<string, unknown>>(
|
||||||
|
collection: string,
|
||||||
|
filter: Record<string, unknown>,
|
||||||
|
): Promise<T | null> {
|
||||||
|
const results = await this.find<T>(collection, filter, { limit: 1 });
|
||||||
|
return results[0] ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
async count(collection: string, filter?: Record<string, unknown>): Promise<number> {
|
||||||
|
const { clause, params } = buildFilterClause(filter);
|
||||||
|
const row = this.db
|
||||||
|
.prepare(`SELECT COUNT(*) as count FROM ${collection}${clause}`)
|
||||||
|
.get(...params) as any;
|
||||||
|
return row?.count ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
async transaction<T>(fn: (tx: StorageAdapter) => Promise<T>): Promise<T> {
|
||||||
|
return fn(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
async migrate(): Promise<void> {
|
||||||
|
// No-op inside transaction
|
||||||
|
}
|
||||||
|
|
||||||
|
async close(): Promise<void> {
|
||||||
|
// No-op inside transaction
|
||||||
|
}
|
||||||
|
}
|
||||||
18
packages/storage/src/factory.ts
Normal file
18
packages/storage/src/factory.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import type { StorageAdapter, StorageConfig } from './types.js';
|
||||||
|
|
||||||
|
type StorageType = StorageConfig['type'];
|
||||||
|
|
||||||
|
const registry = new Map<StorageType, (config: StorageConfig) => StorageAdapter>();
|
||||||
|
|
||||||
|
export function registerStorageAdapter(
|
||||||
|
type: StorageType,
|
||||||
|
factory: (config: StorageConfig) => StorageAdapter,
|
||||||
|
): void {
|
||||||
|
registry.set(type, factory);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createStorageAdapter(config: StorageConfig): StorageAdapter {
|
||||||
|
const factory = registry.get(config.type);
|
||||||
|
if (!factory) throw new Error(`No adapter registered for type: ${config.type}`);
|
||||||
|
return factory(config);
|
||||||
|
}
|
||||||
17
packages/storage/src/index.ts
Normal file
17
packages/storage/src/index.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
export type { StorageAdapter, StorageConfig } from './types.js';
|
||||||
|
export { createStorageAdapter, registerStorageAdapter } from './factory.js';
|
||||||
|
export { PostgresAdapter } from './adapters/postgres.js';
|
||||||
|
export { SqliteAdapter } from './adapters/sqlite.js';
|
||||||
|
|
||||||
|
import { registerStorageAdapter } from './factory.js';
|
||||||
|
import { PostgresAdapter } from './adapters/postgres.js';
|
||||||
|
import { SqliteAdapter } from './adapters/sqlite.js';
|
||||||
|
import type { StorageConfig } from './types.js';
|
||||||
|
|
||||||
|
registerStorageAdapter('postgres', (config: StorageConfig) => {
|
||||||
|
return new PostgresAdapter(config as Extract<StorageConfig, { type: 'postgres' }>);
|
||||||
|
});
|
||||||
|
|
||||||
|
registerStorageAdapter('sqlite', (config: StorageConfig) => {
|
||||||
|
return new SqliteAdapter(config as Extract<StorageConfig, { type: 'sqlite' }>);
|
||||||
|
});
|
||||||
43
packages/storage/src/types.ts
Normal file
43
packages/storage/src/types.ts
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
export interface StorageAdapter {
|
||||||
|
readonly name: string;
|
||||||
|
|
||||||
|
create<T extends Record<string, unknown>>(
|
||||||
|
collection: string,
|
||||||
|
data: T,
|
||||||
|
): Promise<T & { id: string }>;
|
||||||
|
|
||||||
|
read<T extends Record<string, unknown>>(collection: string, id: string): Promise<T | null>;
|
||||||
|
|
||||||
|
update(collection: string, id: string, data: Record<string, unknown>): Promise<boolean>;
|
||||||
|
|
||||||
|
delete(collection: string, id: string): Promise<boolean>;
|
||||||
|
|
||||||
|
find<T extends Record<string, unknown>>(
|
||||||
|
collection: string,
|
||||||
|
filter?: Record<string, unknown>,
|
||||||
|
opts?: {
|
||||||
|
limit?: number;
|
||||||
|
offset?: number;
|
||||||
|
orderBy?: string;
|
||||||
|
order?: 'asc' | 'desc';
|
||||||
|
},
|
||||||
|
): Promise<T[]>;
|
||||||
|
|
||||||
|
findOne<T extends Record<string, unknown>>(
|
||||||
|
collection: string,
|
||||||
|
filter: Record<string, unknown>,
|
||||||
|
): Promise<T | null>;
|
||||||
|
|
||||||
|
count(collection: string, filter?: Record<string, unknown>): Promise<number>;
|
||||||
|
|
||||||
|
transaction<T>(fn: (tx: StorageAdapter) => Promise<T>): Promise<T>;
|
||||||
|
|
||||||
|
migrate(): Promise<void>;
|
||||||
|
|
||||||
|
close(): Promise<void>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type StorageConfig =
|
||||||
|
| { type: 'postgres'; url: string }
|
||||||
|
| { type: 'sqlite'; path: string }
|
||||||
|
| { type: 'files'; dataDir: string; format?: 'json' | 'md' };
|
||||||
9
packages/storage/tsconfig.json
Normal file
9
packages/storage/tsconfig.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../tsconfig.base.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "dist",
|
||||||
|
"rootDir": "src"
|
||||||
|
},
|
||||||
|
"include": ["src/**/*"],
|
||||||
|
"exclude": ["node_modules", "dist"]
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mosaic/types",
|
"name": "@mosaic/types",
|
||||||
"version": "0.0.1-alpha.2",
|
"version": "0.0.2",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mosaic/discord-plugin",
|
"name": "@mosaic/discord-plugin",
|
||||||
"version": "0.0.1-alpha.2",
|
"version": "0.0.2",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mosaic/oc-macp-plugin",
|
"name": "@mosaic/oc-macp-plugin",
|
||||||
"version": "0.0.1-alpha.2",
|
"version": "0.0.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"description": "OpenClaw ACP runtime backend that routes sessions_spawn(runtime:\"macp\") to the Pi MACP runner.",
|
"description": "OpenClaw ACP runtime backend that routes sessions_spawn(runtime:\"macp\") to the Pi MACP runner.",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mosaic/oc-framework-plugin",
|
"name": "@mosaic/oc-framework-plugin",
|
||||||
"version": "0.0.1-alpha.2",
|
"version": "0.0.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"description": "Injects Mosaic framework rails, runtime contract, and active mission context into all OpenClaw agent sessions and ACP subagent spawns.",
|
"description": "Injects Mosaic framework rails, runtime contract, and active mission context into all OpenClaw agent sessions and ACP subagent spawns.",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mosaic/telegram-plugin",
|
"name": "@mosaic/telegram-plugin",
|
||||||
"version": "0.0.1-alpha.2",
|
"version": "0.0.2",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|||||||
289
pnpm-lock.yaml
generated
289
pnpm-lock.yaml
generated
@@ -62,6 +62,9 @@ importers:
|
|||||||
'@mosaic/brain':
|
'@mosaic/brain':
|
||||||
specifier: workspace:^
|
specifier: workspace:^
|
||||||
version: link:../../packages/brain
|
version: link:../../packages/brain
|
||||||
|
'@mosaic/config':
|
||||||
|
specifier: workspace:^
|
||||||
|
version: link:../../packages/config
|
||||||
'@mosaic/coord':
|
'@mosaic/coord':
|
||||||
specifier: workspace:^
|
specifier: workspace:^
|
||||||
version: link:../../packages/coord
|
version: link:../../packages/coord
|
||||||
@@ -80,6 +83,9 @@ importers:
|
|||||||
'@mosaic/queue':
|
'@mosaic/queue':
|
||||||
specifier: workspace:^
|
specifier: workspace:^
|
||||||
version: link:../../packages/queue
|
version: link:../../packages/queue
|
||||||
|
'@mosaic/storage':
|
||||||
|
specifier: workspace:^
|
||||||
|
version: link:../../packages/storage
|
||||||
'@mosaic/telegram-plugin':
|
'@mosaic/telegram-plugin':
|
||||||
specifier: workspace:^
|
specifier: workspace:^
|
||||||
version: link:../../plugins/telegram
|
version: link:../../plugins/telegram
|
||||||
@@ -130,7 +136,7 @@ importers:
|
|||||||
version: 0.34.48
|
version: 0.34.48
|
||||||
better-auth:
|
better-auth:
|
||||||
specifier: ^1.5.5
|
specifier: ^1.5.5
|
||||||
version: 1.5.5(drizzle-kit@0.31.9)(drizzle-orm@0.45.1(@opentelemetry/api@1.9.0)(@types/pg@8.15.6)(kysely@0.28.11)(postgres@3.4.8))(mongodb@7.1.0(socks@2.8.7))(next@16.1.6(@opentelemetry/api@1.9.0)(@playwright/test@1.58.2)(react-dom@19.2.4(react@19.2.4))(react@19.2.4))(react-dom@19.2.4(react@19.2.4))(react@19.2.4)(vitest@2.1.9(@types/node@22.19.15)(jsdom@29.0.0(@noble/hashes@2.0.1))(lightningcss@1.31.1))
|
version: 1.5.5(better-sqlite3@12.8.0)(drizzle-kit@0.31.9)(drizzle-orm@0.45.1(@opentelemetry/api@1.9.0)(@types/better-sqlite3@7.6.13)(@types/pg@8.15.6)(better-sqlite3@12.8.0)(kysely@0.28.11)(postgres@3.4.8))(mongodb@7.1.0(socks@2.8.7))(next@16.1.6(@opentelemetry/api@1.9.0)(@playwright/test@1.58.2)(react-dom@19.2.4(react@19.2.4))(react@19.2.4))(react-dom@19.2.4(react@19.2.4))(react@19.2.4)(vitest@2.1.9(@types/node@22.19.15)(jsdom@29.0.0(@noble/hashes@2.0.1))(lightningcss@1.31.1))
|
||||||
bullmq:
|
bullmq:
|
||||||
specifier: ^5.71.0
|
specifier: ^5.71.0
|
||||||
version: 5.71.0
|
version: 5.71.0
|
||||||
@@ -194,7 +200,7 @@ importers:
|
|||||||
version: link:../../packages/design-tokens
|
version: link:../../packages/design-tokens
|
||||||
better-auth:
|
better-auth:
|
||||||
specifier: ^1.5.5
|
specifier: ^1.5.5
|
||||||
version: 1.5.5(drizzle-kit@0.31.9)(drizzle-orm@0.45.1(@opentelemetry/api@1.9.0)(@types/pg@8.15.6)(kysely@0.28.11)(postgres@3.4.8))(mongodb@7.1.0(socks@2.8.7))(next@16.1.6(@opentelemetry/api@1.9.0)(@playwright/test@1.58.2)(react-dom@19.2.4(react@19.2.4))(react@19.2.4))(react-dom@19.2.4(react@19.2.4))(react@19.2.4)(vitest@2.1.9(@types/node@22.19.15)(jsdom@29.0.0(@noble/hashes@2.0.1))(lightningcss@1.31.1))
|
version: 1.5.5(better-sqlite3@12.8.0)(drizzle-kit@0.31.9)(drizzle-orm@0.45.1(@opentelemetry/api@1.9.0)(@types/better-sqlite3@7.6.13)(@types/pg@8.15.6)(better-sqlite3@12.8.0)(kysely@0.28.11)(postgres@3.4.8))(mongodb@7.1.0(socks@2.8.7))(next@16.1.6(@opentelemetry/api@1.9.0)(@playwright/test@1.58.2)(react-dom@19.2.4(react@19.2.4))(react@19.2.4))(react-dom@19.2.4(react@19.2.4))(react@19.2.4)(vitest@2.1.9(@types/node@22.19.15)(jsdom@29.0.0(@noble/hashes@2.0.1))(lightningcss@1.31.1))
|
||||||
clsx:
|
clsx:
|
||||||
specifier: ^2.1.0
|
specifier: ^2.1.0
|
||||||
version: 2.1.1
|
version: 2.1.1
|
||||||
@@ -265,7 +271,7 @@ importers:
|
|||||||
version: link:../db
|
version: link:../db
|
||||||
better-auth:
|
better-auth:
|
||||||
specifier: ^1.5.5
|
specifier: ^1.5.5
|
||||||
version: 1.5.5(drizzle-kit@0.31.9)(drizzle-orm@0.45.1(@opentelemetry/api@1.9.0)(@types/pg@8.15.6)(kysely@0.28.11)(postgres@3.4.8))(mongodb@7.1.0(socks@2.8.7))(next@16.1.6(@opentelemetry/api@1.9.0)(@playwright/test@1.58.2)(react-dom@19.2.4(react@19.2.4))(react@19.2.4))(react-dom@19.2.4(react@19.2.4))(react@19.2.4)(vitest@2.1.9(@types/node@22.19.15)(jsdom@29.0.0(@noble/hashes@2.0.1))(lightningcss@1.31.1))
|
version: 1.5.5(better-sqlite3@12.8.0)(drizzle-kit@0.31.9)(drizzle-orm@0.45.1(@opentelemetry/api@1.9.0)(@types/better-sqlite3@7.6.13)(@types/pg@8.15.6)(better-sqlite3@12.8.0)(kysely@0.28.11)(postgres@3.4.8))(mongodb@7.1.0(socks@2.8.7))(next@16.1.6(@opentelemetry/api@1.9.0)(@playwright/test@1.58.2)(react-dom@19.2.4(react@19.2.4))(react@19.2.4))(react-dom@19.2.4(react@19.2.4))(react@19.2.4)(vitest@2.1.9(@types/node@22.19.15)(jsdom@29.0.0(@noble/hashes@2.0.1))(lightningcss@1.31.1))
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@types/node':
|
'@types/node':
|
||||||
specifier: ^22.0.0
|
specifier: ^22.0.0
|
||||||
@@ -301,6 +307,9 @@ importers:
|
|||||||
'@clack/prompts':
|
'@clack/prompts':
|
||||||
specifier: ^0.9.0
|
specifier: ^0.9.0
|
||||||
version: 0.9.1
|
version: 0.9.1
|
||||||
|
'@mosaic/config':
|
||||||
|
specifier: workspace:^
|
||||||
|
version: link:../config
|
||||||
'@mosaic/mosaic':
|
'@mosaic/mosaic':
|
||||||
specifier: workspace:^
|
specifier: workspace:^
|
||||||
version: link:../mosaic
|
version: link:../mosaic
|
||||||
@@ -348,6 +357,25 @@ importers:
|
|||||||
specifier: ^2.0.0
|
specifier: ^2.0.0
|
||||||
version: 2.1.9(@types/node@22.19.15)(jsdom@29.0.0(@noble/hashes@2.0.1))(lightningcss@1.31.1)
|
version: 2.1.9(@types/node@22.19.15)(jsdom@29.0.0(@noble/hashes@2.0.1))(lightningcss@1.31.1)
|
||||||
|
|
||||||
|
packages/config:
|
||||||
|
dependencies:
|
||||||
|
'@mosaic/memory':
|
||||||
|
specifier: workspace:^
|
||||||
|
version: link:../memory
|
||||||
|
'@mosaic/queue':
|
||||||
|
specifier: workspace:^
|
||||||
|
version: link:../queue
|
||||||
|
'@mosaic/storage':
|
||||||
|
specifier: workspace:^
|
||||||
|
version: link:../storage
|
||||||
|
devDependencies:
|
||||||
|
typescript:
|
||||||
|
specifier: ^5.8.0
|
||||||
|
version: 5.9.3
|
||||||
|
vitest:
|
||||||
|
specifier: ^2.0.0
|
||||||
|
version: 2.1.9(@types/node@24.12.0)(jsdom@29.0.0(@noble/hashes@2.0.1))(lightningcss@1.31.1)
|
||||||
|
|
||||||
packages/coord:
|
packages/coord:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@mosaic/types':
|
'@mosaic/types':
|
||||||
@@ -368,7 +396,7 @@ importers:
|
|||||||
dependencies:
|
dependencies:
|
||||||
drizzle-orm:
|
drizzle-orm:
|
||||||
specifier: ^0.45.1
|
specifier: ^0.45.1
|
||||||
version: 0.45.1(@opentelemetry/api@1.9.0)(@types/pg@8.15.6)(kysely@0.28.11)(postgres@3.4.8)
|
version: 0.45.1(@opentelemetry/api@1.9.0)(@types/better-sqlite3@7.6.13)(@types/pg@8.15.6)(better-sqlite3@12.8.0)(kysely@0.28.11)(postgres@3.4.8)
|
||||||
postgres:
|
postgres:
|
||||||
specifier: ^3.4.8
|
specifier: ^3.4.8
|
||||||
version: 3.4.8
|
version: 3.4.8
|
||||||
@@ -424,7 +452,7 @@ importers:
|
|||||||
version: link:../db
|
version: link:../db
|
||||||
drizzle-orm:
|
drizzle-orm:
|
||||||
specifier: ^0.45.1
|
specifier: ^0.45.1
|
||||||
version: 0.45.1(@opentelemetry/api@1.9.0)(@types/pg@8.15.6)(kysely@0.28.11)(postgres@3.4.8)
|
version: 0.45.1(@opentelemetry/api@1.9.0)(@types/better-sqlite3@7.6.13)(@types/pg@8.15.6)(better-sqlite3@12.8.0)(kysely@0.28.11)(postgres@3.4.8)
|
||||||
devDependencies:
|
devDependencies:
|
||||||
typescript:
|
typescript:
|
||||||
specifier: ^5.8.0
|
specifier: ^5.8.0
|
||||||
@@ -453,12 +481,15 @@ importers:
|
|||||||
'@mosaic/db':
|
'@mosaic/db':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../db
|
version: link:../db
|
||||||
|
'@mosaic/storage':
|
||||||
|
specifier: workspace:*
|
||||||
|
version: link:../storage
|
||||||
'@mosaic/types':
|
'@mosaic/types':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../types
|
version: link:../types
|
||||||
drizzle-orm:
|
drizzle-orm:
|
||||||
specifier: ^0.45.1
|
specifier: ^0.45.1
|
||||||
version: 0.45.1(@opentelemetry/api@1.9.0)(@types/pg@8.15.6)(kysely@0.28.11)(postgres@3.4.8)
|
version: 0.45.1(@opentelemetry/api@1.9.0)(@types/better-sqlite3@7.6.13)(@types/pg@8.15.6)(better-sqlite3@12.8.0)(kysely@0.28.11)(postgres@3.4.8)
|
||||||
devDependencies:
|
devDependencies:
|
||||||
typescript:
|
typescript:
|
||||||
specifier: ^5.8.0
|
specifier: ^5.8.0
|
||||||
@@ -541,8 +572,8 @@ importers:
|
|||||||
packages/quality-rails:
|
packages/quality-rails:
|
||||||
dependencies:
|
dependencies:
|
||||||
commander:
|
commander:
|
||||||
specifier: ^12.0.0
|
specifier: ^13.0.0
|
||||||
version: 12.1.0
|
version: 13.1.0
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@types/node':
|
'@types/node':
|
||||||
specifier: ^22.0.0
|
specifier: ^22.0.0
|
||||||
@@ -570,6 +601,28 @@ importers:
|
|||||||
specifier: ^2.0.0
|
specifier: ^2.0.0
|
||||||
version: 2.1.9(@types/node@24.12.0)(jsdom@29.0.0(@noble/hashes@2.0.1))(lightningcss@1.31.1)
|
version: 2.1.9(@types/node@24.12.0)(jsdom@29.0.0(@noble/hashes@2.0.1))(lightningcss@1.31.1)
|
||||||
|
|
||||||
|
packages/storage:
|
||||||
|
dependencies:
|
||||||
|
'@mosaic/db':
|
||||||
|
specifier: workspace:^
|
||||||
|
version: link:../db
|
||||||
|
'@mosaic/types':
|
||||||
|
specifier: workspace:*
|
||||||
|
version: link:../types
|
||||||
|
better-sqlite3:
|
||||||
|
specifier: ^12.8.0
|
||||||
|
version: 12.8.0
|
||||||
|
devDependencies:
|
||||||
|
'@types/better-sqlite3':
|
||||||
|
specifier: ^7.6.13
|
||||||
|
version: 7.6.13
|
||||||
|
typescript:
|
||||||
|
specifier: ^5.8.0
|
||||||
|
version: 5.9.3
|
||||||
|
vitest:
|
||||||
|
specifier: ^2.0.0
|
||||||
|
version: 2.1.9(@types/node@24.12.0)(jsdom@29.0.0(@noble/hashes@2.0.1))(lightningcss@1.31.1)
|
||||||
|
|
||||||
packages/types:
|
packages/types:
|
||||||
dependencies:
|
dependencies:
|
||||||
class-transformer:
|
class-transformer:
|
||||||
@@ -3399,6 +3452,9 @@ packages:
|
|||||||
'@types/aws-lambda@8.10.161':
|
'@types/aws-lambda@8.10.161':
|
||||||
resolution: {integrity: sha512-rUYdp+MQwSFocxIOcSsYSF3YYYC/uUpMbCY/mbO21vGqfrEYvNSoPyKYDj6RhXXpPfS0KstW9RwG3qXh9sL7FQ==}
|
resolution: {integrity: sha512-rUYdp+MQwSFocxIOcSsYSF3YYYC/uUpMbCY/mbO21vGqfrEYvNSoPyKYDj6RhXXpPfS0KstW9RwG3qXh9sL7FQ==}
|
||||||
|
|
||||||
|
'@types/better-sqlite3@7.6.13':
|
||||||
|
resolution: {integrity: sha512-NMv9ASNARoKksWtsq/SHakpYAYnhBrQgGD8zkLYk/jaK8jUGn08CfEdTRgYhMypUQAfzSP8W6gNLe0q19/t4VA==}
|
||||||
|
|
||||||
'@types/bunyan@1.8.11':
|
'@types/bunyan@1.8.11':
|
||||||
resolution: {integrity: sha512-758fRH7umIMk5qt5ELmRMff4mLDlN+xyYzC+dkPTdKwbSkJFvz6xwyScrytPU0QIBbRRwbiE8/BIg8bpajerNQ==}
|
resolution: {integrity: sha512-758fRH7umIMk5qt5ELmRMff4mLDlN+xyYzC+dkPTdKwbSkJFvz6xwyScrytPU0QIBbRRwbiE8/BIg8bpajerNQ==}
|
||||||
|
|
||||||
@@ -3811,12 +3867,22 @@ packages:
|
|||||||
zod:
|
zod:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
better-sqlite3@12.8.0:
|
||||||
|
resolution: {integrity: sha512-RxD2Vd96sQDjQr20kdP+F+dK/1OUNiVOl200vKBZY8u0vTwysfolF6Hq+3ZK2+h8My9YvZhHsF+RSGZW2VYrPQ==}
|
||||||
|
engines: {node: 20.x || 22.x || 23.x || 24.x || 25.x}
|
||||||
|
|
||||||
bidi-js@1.0.3:
|
bidi-js@1.0.3:
|
||||||
resolution: {integrity: sha512-RKshQI1R3YQ+n9YJz2QQ147P66ELpa1FQEg20Dk8oW9t2KgLbpDLLp9aGZ7y8WHSshDknG0bknqGw5/tyCs5tw==}
|
resolution: {integrity: sha512-RKshQI1R3YQ+n9YJz2QQ147P66ELpa1FQEg20Dk8oW9t2KgLbpDLLp9aGZ7y8WHSshDknG0bknqGw5/tyCs5tw==}
|
||||||
|
|
||||||
bignumber.js@9.3.1:
|
bignumber.js@9.3.1:
|
||||||
resolution: {integrity: sha512-Ko0uX15oIUS7wJ3Rb30Fs6SkVbLmPBAKdlm7q9+ak9bbIeFf0MwuBsQV6z7+X768/cHsfg+WlysDWJcmthjsjQ==}
|
resolution: {integrity: sha512-Ko0uX15oIUS7wJ3Rb30Fs6SkVbLmPBAKdlm7q9+ak9bbIeFf0MwuBsQV6z7+X768/cHsfg+WlysDWJcmthjsjQ==}
|
||||||
|
|
||||||
|
bindings@1.5.0:
|
||||||
|
resolution: {integrity: sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==}
|
||||||
|
|
||||||
|
bl@4.1.0:
|
||||||
|
resolution: {integrity: sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==}
|
||||||
|
|
||||||
body-parser@2.2.2:
|
body-parser@2.2.2:
|
||||||
resolution: {integrity: sha512-oP5VkATKlNwcgvxi0vM0p/D3n2C3EReYVX+DNYs5TjZFn/oQt2j+4sVJtSMr18pdRr8wjTcBl6LoV+FUwzPmNA==}
|
resolution: {integrity: sha512-oP5VkATKlNwcgvxi0vM0p/D3n2C3EReYVX+DNYs5TjZFn/oQt2j+4sVJtSMr18pdRr8wjTcBl6LoV+FUwzPmNA==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
@@ -3866,6 +3932,9 @@ packages:
|
|||||||
buffer-from@1.1.2:
|
buffer-from@1.1.2:
|
||||||
resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==}
|
resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==}
|
||||||
|
|
||||||
|
buffer@5.7.1:
|
||||||
|
resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==}
|
||||||
|
|
||||||
bullmq@5.71.0:
|
bullmq@5.71.0:
|
||||||
resolution: {integrity: sha512-aeNWh4drsafSKnAJeiNH/nZP/5O8ZdtdMbnOPZmpjXj7NZUP5YC901U3bIH41iZValm7d1i3c34ojv7q31m30w==}
|
resolution: {integrity: sha512-aeNWh4drsafSKnAJeiNH/nZP/5O8ZdtdMbnOPZmpjXj7NZUP5YC901U3bIH41iZValm7d1i3c34ojv7q31m30w==}
|
||||||
|
|
||||||
@@ -3927,6 +3996,9 @@ packages:
|
|||||||
resolution: {integrity: sha512-TQMmc3w+5AxjpL8iIiwebF73dRDF4fBIieAqGn9RGCWaEVwQ6Fb2cGe31Yns0RRIzii5goJ1Y7xbMwo1TxMplw==}
|
resolution: {integrity: sha512-TQMmc3w+5AxjpL8iIiwebF73dRDF4fBIieAqGn9RGCWaEVwQ6Fb2cGe31Yns0RRIzii5goJ1Y7xbMwo1TxMplw==}
|
||||||
engines: {node: '>= 20.19.0'}
|
engines: {node: '>= 20.19.0'}
|
||||||
|
|
||||||
|
chownr@1.1.4:
|
||||||
|
resolution: {integrity: sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==}
|
||||||
|
|
||||||
chownr@3.0.0:
|
chownr@3.0.0:
|
||||||
resolution: {integrity: sha512-+IxzY9BZOQd/XuYPRmrvEVjF/nqj5kgT4kEq7VofrDoM1MxoRjEWkrCC3EtLi59TVawxTAn+orJwFQcrqEN1+g==}
|
resolution: {integrity: sha512-+IxzY9BZOQd/XuYPRmrvEVjF/nqj5kgT4kEq7VofrDoM1MxoRjEWkrCC3EtLi59TVawxTAn+orJwFQcrqEN1+g==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
@@ -4110,10 +4182,18 @@ packages:
|
|||||||
decode-named-character-reference@1.3.0:
|
decode-named-character-reference@1.3.0:
|
||||||
resolution: {integrity: sha512-GtpQYB283KrPp6nRw50q3U9/VfOutZOe103qlN7BPP6Ad27xYnOIWv4lPzo8HCAL+mMZofJ9KEy30fq6MfaK6Q==}
|
resolution: {integrity: sha512-GtpQYB283KrPp6nRw50q3U9/VfOutZOe103qlN7BPP6Ad27xYnOIWv4lPzo8HCAL+mMZofJ9KEy30fq6MfaK6Q==}
|
||||||
|
|
||||||
|
decompress-response@6.0.0:
|
||||||
|
resolution: {integrity: sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==}
|
||||||
|
engines: {node: '>=10'}
|
||||||
|
|
||||||
deep-eql@5.0.2:
|
deep-eql@5.0.2:
|
||||||
resolution: {integrity: sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==}
|
resolution: {integrity: sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==}
|
||||||
engines: {node: '>=6'}
|
engines: {node: '>=6'}
|
||||||
|
|
||||||
|
deep-extend@0.6.0:
|
||||||
|
resolution: {integrity: sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==}
|
||||||
|
engines: {node: '>=4.0.0'}
|
||||||
|
|
||||||
deep-is@0.1.4:
|
deep-is@0.1.4:
|
||||||
resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==}
|
resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==}
|
||||||
|
|
||||||
@@ -4486,6 +4566,10 @@ packages:
|
|||||||
resolution: {integrity: sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==}
|
resolution: {integrity: sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==}
|
||||||
engines: {node: '>=16.17'}
|
engines: {node: '>=16.17'}
|
||||||
|
|
||||||
|
expand-template@2.0.3:
|
||||||
|
resolution: {integrity: sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==}
|
||||||
|
engines: {node: '>=6'}
|
||||||
|
|
||||||
expect-type@1.3.0:
|
expect-type@1.3.0:
|
||||||
resolution: {integrity: sha512-knvyeauYhqjOYvQ66MznSMs83wmHrCycNEN6Ao+2AeYEfxUIkuiVxdEa1qlGEPK+We3n0THiDciYSsCcgW/DoA==}
|
resolution: {integrity: sha512-knvyeauYhqjOYvQ66MznSMs83wmHrCycNEN6Ao+2AeYEfxUIkuiVxdEa1qlGEPK+We3n0THiDciYSsCcgW/DoA==}
|
||||||
engines: {node: '>=12.0.0'}
|
engines: {node: '>=12.0.0'}
|
||||||
@@ -4586,6 +4670,9 @@ packages:
|
|||||||
resolution: {integrity: sha512-cmBmnYo8Zymabm2+qAP7jTFbKF10bQpYmxoGfuZbRFRcq00BRddJdGNH/P7GA1EMpJy5yQbqa9B7yROb3z8Ziw==}
|
resolution: {integrity: sha512-cmBmnYo8Zymabm2+qAP7jTFbKF10bQpYmxoGfuZbRFRcq00BRddJdGNH/P7GA1EMpJy5yQbqa9B7yROb3z8Ziw==}
|
||||||
engines: {node: '>=22'}
|
engines: {node: '>=22'}
|
||||||
|
|
||||||
|
file-uri-to-path@1.0.0:
|
||||||
|
resolution: {integrity: sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==}
|
||||||
|
|
||||||
fill-range@7.1.1:
|
fill-range@7.1.1:
|
||||||
resolution: {integrity: sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==}
|
resolution: {integrity: sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==}
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
@@ -4641,6 +4728,9 @@ packages:
|
|||||||
resolution: {integrity: sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==}
|
resolution: {integrity: sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==}
|
||||||
engines: {node: '>= 0.8'}
|
engines: {node: '>= 0.8'}
|
||||||
|
|
||||||
|
fs-constants@1.0.0:
|
||||||
|
resolution: {integrity: sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==}
|
||||||
|
|
||||||
fsevents@2.3.2:
|
fsevents@2.3.2:
|
||||||
resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==}
|
resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==}
|
||||||
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
|
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
|
||||||
@@ -4705,6 +4795,9 @@ packages:
|
|||||||
resolution: {integrity: sha512-b1O07XYq8eRuVzBNgJLstU6FYc1tS6wnMtF1I1D9lE8LxZSOGZ7LhxN54yPP6mGw5f2CkXY2BQUL9Fx41qvcIg==}
|
resolution: {integrity: sha512-b1O07XYq8eRuVzBNgJLstU6FYc1tS6wnMtF1I1D9lE8LxZSOGZ7LhxN54yPP6mGw5f2CkXY2BQUL9Fx41qvcIg==}
|
||||||
engines: {node: '>= 14'}
|
engines: {node: '>= 14'}
|
||||||
|
|
||||||
|
github-from-package@0.0.0:
|
||||||
|
resolution: {integrity: sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==}
|
||||||
|
|
||||||
glob-parent@6.0.2:
|
glob-parent@6.0.2:
|
||||||
resolution: {integrity: sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==}
|
resolution: {integrity: sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==}
|
||||||
engines: {node: '>=10.13.0'}
|
engines: {node: '>=10.13.0'}
|
||||||
@@ -4864,6 +4957,9 @@ packages:
|
|||||||
inherits@2.0.4:
|
inherits@2.0.4:
|
||||||
resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==}
|
resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==}
|
||||||
|
|
||||||
|
ini@1.3.8:
|
||||||
|
resolution: {integrity: sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==}
|
||||||
|
|
||||||
ink-spinner@5.0.0:
|
ink-spinner@5.0.0:
|
||||||
resolution: {integrity: sha512-EYEasbEjkqLGyPOUc8hBJZNuC5GvXGMLu0w5gdTNskPc7Izc5vO3tdQEYnzvshucyGCBXc86ig0ujXPMWaQCdA==}
|
resolution: {integrity: sha512-EYEasbEjkqLGyPOUc8hBJZNuC5GvXGMLu0w5gdTNskPc7Izc5vO3tdQEYnzvshucyGCBXc86ig0ujXPMWaQCdA==}
|
||||||
engines: {node: '>=14.16'}
|
engines: {node: '>=14.16'}
|
||||||
@@ -5431,6 +5527,10 @@ packages:
|
|||||||
resolution: {integrity: sha512-VP79XUPxV2CigYP3jWwAUFSku2aKqBH7uTAapFWCBqutsbmDo96KY5o8uh6U+/YSIn5OxJnXp73beVkpqMIGhA==}
|
resolution: {integrity: sha512-VP79XUPxV2CigYP3jWwAUFSku2aKqBH7uTAapFWCBqutsbmDo96KY5o8uh6U+/YSIn5OxJnXp73beVkpqMIGhA==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
|
|
||||||
|
mimic-response@3.1.0:
|
||||||
|
resolution: {integrity: sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==}
|
||||||
|
engines: {node: '>=10'}
|
||||||
|
|
||||||
minimatch@10.2.4:
|
minimatch@10.2.4:
|
||||||
resolution: {integrity: sha512-oRjTw/97aTBN0RHbYCdtF1MQfvusSIBQM0IZEgzl6426+8jSC0nF1a/GmnVLpfB9yyr6g6FTqWqiZVbxrtaCIg==}
|
resolution: {integrity: sha512-oRjTw/97aTBN0RHbYCdtF1MQfvusSIBQM0IZEgzl6426+8jSC0nF1a/GmnVLpfB9yyr6g6FTqWqiZVbxrtaCIg==}
|
||||||
engines: {node: 18 || 20 || >=22}
|
engines: {node: 18 || 20 || >=22}
|
||||||
@@ -5442,6 +5542,9 @@ packages:
|
|||||||
resolution: {integrity: sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg==}
|
resolution: {integrity: sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg==}
|
||||||
engines: {node: '>=16 || 14 >=14.17'}
|
engines: {node: '>=16 || 14 >=14.17'}
|
||||||
|
|
||||||
|
minimist@1.2.8:
|
||||||
|
resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==}
|
||||||
|
|
||||||
minipass@7.1.3:
|
minipass@7.1.3:
|
||||||
resolution: {integrity: sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==}
|
resolution: {integrity: sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==}
|
||||||
engines: {node: '>=16 || 14 >=14.17'}
|
engines: {node: '>=16 || 14 >=14.17'}
|
||||||
@@ -5450,6 +5553,9 @@ packages:
|
|||||||
resolution: {integrity: sha512-KZxYo1BUkWD2TVFLr0MQoM8vUUigWD3LlD83a/75BqC+4qE0Hb1Vo5v1FgcfaNXvfXzr+5EhQ6ing/CaBijTlw==}
|
resolution: {integrity: sha512-KZxYo1BUkWD2TVFLr0MQoM8vUUigWD3LlD83a/75BqC+4qE0Hb1Vo5v1FgcfaNXvfXzr+5EhQ6ing/CaBijTlw==}
|
||||||
engines: {node: '>= 18'}
|
engines: {node: '>= 18'}
|
||||||
|
|
||||||
|
mkdirp-classic@0.5.3:
|
||||||
|
resolution: {integrity: sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==}
|
||||||
|
|
||||||
module-details-from-path@1.0.4:
|
module-details-from-path@1.0.4:
|
||||||
resolution: {integrity: sha512-EGWKgxALGMgzvxYF1UyGTy0HXX/2vHLkw6+NvDKW2jypWbHpjQuj4UMcqQWXHERJhVGKikolT06G3bcKe4fi7w==}
|
resolution: {integrity: sha512-EGWKgxALGMgzvxYF1UyGTy0HXX/2vHLkw6+NvDKW2jypWbHpjQuj4UMcqQWXHERJhVGKikolT06G3bcKe4fi7w==}
|
||||||
|
|
||||||
@@ -5510,6 +5616,9 @@ packages:
|
|||||||
resolution: {integrity: sha512-EYJqS25r2iBeTtGQCHidXl1VfZ1jXM7Q04zXJOrMlxVVmD0ptxJaNux92n1mJ7c5lN3zTq12MhH/8x59nP+qmg==}
|
resolution: {integrity: sha512-EYJqS25r2iBeTtGQCHidXl1VfZ1jXM7Q04zXJOrMlxVVmD0ptxJaNux92n1mJ7c5lN3zTq12MhH/8x59nP+qmg==}
|
||||||
engines: {node: ^20.0.0 || >=22.0.0}
|
engines: {node: ^20.0.0 || >=22.0.0}
|
||||||
|
|
||||||
|
napi-build-utils@2.0.0:
|
||||||
|
resolution: {integrity: sha512-GEbrYkbfF7MoNaoh2iGG84Mnf/WZfB0GdGEsM8wz7Expx/LlWf5U8t9nvJKXSp3qr5IsEbK04cBGhol/KwOsWA==}
|
||||||
|
|
||||||
natural-compare@1.4.0:
|
natural-compare@1.4.0:
|
||||||
resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==}
|
resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==}
|
||||||
|
|
||||||
@@ -5546,6 +5655,10 @@ packages:
|
|||||||
sass:
|
sass:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
node-abi@3.89.0:
|
||||||
|
resolution: {integrity: sha512-6u9UwL0HlAl21+agMN3YAMXcKByMqwGx+pq+P76vii5f7hTPtKDp08/H9py6DY+cfDw7kQNTGEj/rly3IgbNQA==}
|
||||||
|
engines: {node: '>=10'}
|
||||||
|
|
||||||
node-abort-controller@3.1.1:
|
node-abort-controller@3.1.1:
|
||||||
resolution: {integrity: sha512-AGK2yQKIjRuqnc6VkX2Xj5d+QW8xZ87pa1UK6yA6ouUyuxfHuMP6umE5QK7UmTeOAymo+Zx1Fxiuw9rVx8taHQ==}
|
resolution: {integrity: sha512-AGK2yQKIjRuqnc6VkX2Xj5d+QW8xZ87pa1UK6yA6ouUyuxfHuMP6umE5QK7UmTeOAymo+Zx1Fxiuw9rVx8taHQ==}
|
||||||
|
|
||||||
@@ -5869,6 +5982,12 @@ packages:
|
|||||||
resolution: {integrity: sha512-d+JFcLM17njZaOLkv6SCev7uoLaBtfK86vMUXhW1Z4glPWh4jozno9APvW/XKFJ3CCxVoC7OL38BqRydtu5nGg==}
|
resolution: {integrity: sha512-d+JFcLM17njZaOLkv6SCev7uoLaBtfK86vMUXhW1Z4glPWh4jozno9APvW/XKFJ3CCxVoC7OL38BqRydtu5nGg==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
|
|
||||||
|
prebuild-install@7.1.3:
|
||||||
|
resolution: {integrity: sha512-8Mf2cbV7x1cXPUILADGI3wuhfqWvtiLA1iclTDbFRZkgRQS0NqsPZphna9V+HyTEadheuPmjaJMsbzKQFOzLug==}
|
||||||
|
engines: {node: '>=10'}
|
||||||
|
deprecated: No longer maintained. Please contact the author of the relevant native addon; alternatives are available.
|
||||||
|
hasBin: true
|
||||||
|
|
||||||
prelude-ls@1.2.1:
|
prelude-ls@1.2.1:
|
||||||
resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==}
|
resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==}
|
||||||
engines: {node: '>= 0.8.0'}
|
engines: {node: '>= 0.8.0'}
|
||||||
@@ -5942,6 +6061,10 @@ packages:
|
|||||||
resolution: {integrity: sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA==}
|
resolution: {integrity: sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA==}
|
||||||
engines: {node: '>= 0.10'}
|
engines: {node: '>= 0.10'}
|
||||||
|
|
||||||
|
rc@1.2.8:
|
||||||
|
resolution: {integrity: sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==}
|
||||||
|
hasBin: true
|
||||||
|
|
||||||
react-dom@19.2.4:
|
react-dom@19.2.4:
|
||||||
resolution: {integrity: sha512-AXJdLo8kgMbimY95O2aKQqsz2iWi9jMgKJhRBAxECE4IFxfcazB2LmzloIoibJI3C12IlY20+KFaLv+71bUJeQ==}
|
resolution: {integrity: sha512-AXJdLo8kgMbimY95O2aKQqsz2iWi9jMgKJhRBAxECE4IFxfcazB2LmzloIoibJI3C12IlY20+KFaLv+71bUJeQ==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
@@ -5970,6 +6093,10 @@ packages:
|
|||||||
readable-stream@2.3.8:
|
readable-stream@2.3.8:
|
||||||
resolution: {integrity: sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==}
|
resolution: {integrity: sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==}
|
||||||
|
|
||||||
|
readable-stream@3.6.2:
|
||||||
|
resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==}
|
||||||
|
engines: {node: '>= 6'}
|
||||||
|
|
||||||
readdirp@5.0.0:
|
readdirp@5.0.0:
|
||||||
resolution: {integrity: sha512-9u/XQ1pvrQtYyMpZe7DXKv2p5CNvyVwzUB6uhLAnQwHMSgKMBR62lc7AHljaeteeHXn11XTAaLLUVZYVZyuRBQ==}
|
resolution: {integrity: sha512-9u/XQ1pvrQtYyMpZe7DXKv2p5CNvyVwzUB6uhLAnQwHMSgKMBR62lc7AHljaeteeHXn11XTAaLLUVZYVZyuRBQ==}
|
||||||
engines: {node: '>= 20.19.0'}
|
engines: {node: '>= 20.19.0'}
|
||||||
@@ -6164,6 +6291,12 @@ packages:
|
|||||||
resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==}
|
resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==}
|
||||||
engines: {node: '>=14'}
|
engines: {node: '>=14'}
|
||||||
|
|
||||||
|
simple-concat@1.0.1:
|
||||||
|
resolution: {integrity: sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==}
|
||||||
|
|
||||||
|
simple-get@4.0.1:
|
||||||
|
resolution: {integrity: sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==}
|
||||||
|
|
||||||
sisteransi@1.0.5:
|
sisteransi@1.0.5:
|
||||||
resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==}
|
resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==}
|
||||||
|
|
||||||
@@ -6305,6 +6438,10 @@ packages:
|
|||||||
resolution: {integrity: sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==}
|
resolution: {integrity: sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
|
|
||||||
|
strip-json-comments@2.0.1:
|
||||||
|
resolution: {integrity: sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==}
|
||||||
|
engines: {node: '>=0.10.0'}
|
||||||
|
|
||||||
strip-json-comments@3.1.1:
|
strip-json-comments@3.1.1:
|
||||||
resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==}
|
resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==}
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
@@ -6356,6 +6493,13 @@ packages:
|
|||||||
resolution: {integrity: sha512-g9ljZiwki/LfxmQADO3dEY1CbpmXT5Hm2fJ+QaGKwSXUylMybePR7/67YW7jOrrvjEgL1Fmz5kzyAjWVWLlucg==}
|
resolution: {integrity: sha512-g9ljZiwki/LfxmQADO3dEY1CbpmXT5Hm2fJ+QaGKwSXUylMybePR7/67YW7jOrrvjEgL1Fmz5kzyAjWVWLlucg==}
|
||||||
engines: {node: '>=6'}
|
engines: {node: '>=6'}
|
||||||
|
|
||||||
|
tar-fs@2.1.4:
|
||||||
|
resolution: {integrity: sha512-mDAjwmZdh7LTT6pNleZ05Yt65HC3E+NiQzl672vQG38jIrehtJk/J3mNwIg+vShQPcLF/LV7CMnDW6vjj6sfYQ==}
|
||||||
|
|
||||||
|
tar-stream@2.2.0:
|
||||||
|
resolution: {integrity: sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==}
|
||||||
|
engines: {node: '>=6'}
|
||||||
|
|
||||||
tar@7.5.13:
|
tar@7.5.13:
|
||||||
resolution: {integrity: sha512-tOG/7GyXpFevhXVh8jOPJrmtRpOTsYqUIkVdVooZYJS/z8WhfQUX8RJILmeuJNinGAMSu1veBr4asSHFt5/hng==}
|
resolution: {integrity: sha512-tOG/7GyXpFevhXVh8jOPJrmtRpOTsYqUIkVdVooZYJS/z8WhfQUX8RJILmeuJNinGAMSu1veBr4asSHFt5/hng==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
@@ -6470,6 +6614,9 @@ packages:
|
|||||||
engines: {node: '>=18.0.0'}
|
engines: {node: '>=18.0.0'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
|
tunnel-agent@0.6.0:
|
||||||
|
resolution: {integrity: sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==}
|
||||||
|
|
||||||
turbo-darwin-64@2.8.16:
|
turbo-darwin-64@2.8.16:
|
||||||
resolution: {integrity: sha512-KWa4hUMWrpADC6Q/wIHRkBLw6X6MV9nx6X7hSXbTrrMz0KdaKhmfudUZ3sS76bJFmgArBU25cSc0AUyyrswYxg==}
|
resolution: {integrity: sha512-KWa4hUMWrpADC6Q/wIHRkBLw6X6MV9nx6X7hSXbTrrMz0KdaKhmfudUZ3sS76bJFmgArBU25cSc0AUyyrswYxg==}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
@@ -7618,12 +7765,12 @@ snapshots:
|
|||||||
nanostores: 1.1.1
|
nanostores: 1.1.1
|
||||||
zod: 4.3.6
|
zod: 4.3.6
|
||||||
|
|
||||||
'@better-auth/drizzle-adapter@1.5.5(@better-auth/core@1.5.5(@better-auth/utils@0.3.1)(@better-fetch/fetch@1.1.21)(better-call@1.3.2(zod@4.3.6))(jose@6.2.1)(kysely@0.28.11)(nanostores@1.1.1))(@better-auth/utils@0.3.1)(drizzle-orm@0.45.1(@opentelemetry/api@1.9.0)(@types/pg@8.15.6)(kysely@0.28.11)(postgres@3.4.8))':
|
'@better-auth/drizzle-adapter@1.5.5(@better-auth/core@1.5.5(@better-auth/utils@0.3.1)(@better-fetch/fetch@1.1.21)(better-call@1.3.2(zod@4.3.6))(jose@6.2.1)(kysely@0.28.11)(nanostores@1.1.1))(@better-auth/utils@0.3.1)(drizzle-orm@0.45.1(@opentelemetry/api@1.9.0)(@types/better-sqlite3@7.6.13)(@types/pg@8.15.6)(better-sqlite3@12.8.0)(kysely@0.28.11)(postgres@3.4.8))':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@better-auth/core': 1.5.5(@better-auth/utils@0.3.1)(@better-fetch/fetch@1.1.21)(better-call@1.3.2(zod@4.3.6))(jose@6.2.1)(kysely@0.28.11)(nanostores@1.1.1)
|
'@better-auth/core': 1.5.5(@better-auth/utils@0.3.1)(@better-fetch/fetch@1.1.21)(better-call@1.3.2(zod@4.3.6))(jose@6.2.1)(kysely@0.28.11)(nanostores@1.1.1)
|
||||||
'@better-auth/utils': 0.3.1
|
'@better-auth/utils': 0.3.1
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
drizzle-orm: 0.45.1(@opentelemetry/api@1.9.0)(@types/pg@8.15.6)(kysely@0.28.11)(postgres@3.4.8)
|
drizzle-orm: 0.45.1(@opentelemetry/api@1.9.0)(@types/better-sqlite3@7.6.13)(@types/pg@8.15.6)(better-sqlite3@12.8.0)(kysely@0.28.11)(postgres@3.4.8)
|
||||||
|
|
||||||
'@better-auth/kysely-adapter@1.5.5(@better-auth/core@1.5.5(@better-auth/utils@0.3.1)(@better-fetch/fetch@1.1.21)(better-call@1.3.2(zod@4.3.6))(jose@6.2.1)(kysely@0.28.11)(nanostores@1.1.1))(@better-auth/utils@0.3.1)(kysely@0.28.11)':
|
'@better-auth/kysely-adapter@1.5.5(@better-auth/core@1.5.5(@better-auth/utils@0.3.1)(@better-fetch/fetch@1.1.21)(better-call@1.3.2(zod@4.3.6))(jose@6.2.1)(kysely@0.28.11)(nanostores@1.1.1))(@better-auth/utils@0.3.1)(kysely@0.28.11)':
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -10174,6 +10321,10 @@ snapshots:
|
|||||||
|
|
||||||
'@types/aws-lambda@8.10.161': {}
|
'@types/aws-lambda@8.10.161': {}
|
||||||
|
|
||||||
|
'@types/better-sqlite3@7.6.13':
|
||||||
|
dependencies:
|
||||||
|
'@types/node': 22.19.15
|
||||||
|
|
||||||
'@types/bunyan@1.8.11':
|
'@types/bunyan@1.8.11':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/node': 22.19.15
|
'@types/node': 22.19.15
|
||||||
@@ -10560,10 +10711,10 @@ snapshots:
|
|||||||
|
|
||||||
basic-ftp@5.2.0: {}
|
basic-ftp@5.2.0: {}
|
||||||
|
|
||||||
better-auth@1.5.5(drizzle-kit@0.31.9)(drizzle-orm@0.45.1(@opentelemetry/api@1.9.0)(@types/pg@8.15.6)(kysely@0.28.11)(postgres@3.4.8))(mongodb@7.1.0(socks@2.8.7))(next@16.1.6(@opentelemetry/api@1.9.0)(@playwright/test@1.58.2)(react-dom@19.2.4(react@19.2.4))(react@19.2.4))(react-dom@19.2.4(react@19.2.4))(react@19.2.4)(vitest@2.1.9(@types/node@22.19.15)(jsdom@29.0.0(@noble/hashes@2.0.1))(lightningcss@1.31.1)):
|
better-auth@1.5.5(better-sqlite3@12.8.0)(drizzle-kit@0.31.9)(drizzle-orm@0.45.1(@opentelemetry/api@1.9.0)(@types/better-sqlite3@7.6.13)(@types/pg@8.15.6)(better-sqlite3@12.8.0)(kysely@0.28.11)(postgres@3.4.8))(mongodb@7.1.0(socks@2.8.7))(next@16.1.6(@opentelemetry/api@1.9.0)(@playwright/test@1.58.2)(react-dom@19.2.4(react@19.2.4))(react@19.2.4))(react-dom@19.2.4(react@19.2.4))(react@19.2.4)(vitest@2.1.9(@types/node@22.19.15)(jsdom@29.0.0(@noble/hashes@2.0.1))(lightningcss@1.31.1)):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@better-auth/core': 1.5.5(@better-auth/utils@0.3.1)(@better-fetch/fetch@1.1.21)(better-call@1.3.2(zod@4.3.6))(jose@6.2.1)(kysely@0.28.11)(nanostores@1.1.1)
|
'@better-auth/core': 1.5.5(@better-auth/utils@0.3.1)(@better-fetch/fetch@1.1.21)(better-call@1.3.2(zod@4.3.6))(jose@6.2.1)(kysely@0.28.11)(nanostores@1.1.1)
|
||||||
'@better-auth/drizzle-adapter': 1.5.5(@better-auth/core@1.5.5(@better-auth/utils@0.3.1)(@better-fetch/fetch@1.1.21)(better-call@1.3.2(zod@4.3.6))(jose@6.2.1)(kysely@0.28.11)(nanostores@1.1.1))(@better-auth/utils@0.3.1)(drizzle-orm@0.45.1(@opentelemetry/api@1.9.0)(@types/pg@8.15.6)(kysely@0.28.11)(postgres@3.4.8))
|
'@better-auth/drizzle-adapter': 1.5.5(@better-auth/core@1.5.5(@better-auth/utils@0.3.1)(@better-fetch/fetch@1.1.21)(better-call@1.3.2(zod@4.3.6))(jose@6.2.1)(kysely@0.28.11)(nanostores@1.1.1))(@better-auth/utils@0.3.1)(drizzle-orm@0.45.1(@opentelemetry/api@1.9.0)(@types/better-sqlite3@7.6.13)(@types/pg@8.15.6)(better-sqlite3@12.8.0)(kysely@0.28.11)(postgres@3.4.8))
|
||||||
'@better-auth/kysely-adapter': 1.5.5(@better-auth/core@1.5.5(@better-auth/utils@0.3.1)(@better-fetch/fetch@1.1.21)(better-call@1.3.2(zod@4.3.6))(jose@6.2.1)(kysely@0.28.11)(nanostores@1.1.1))(@better-auth/utils@0.3.1)(kysely@0.28.11)
|
'@better-auth/kysely-adapter': 1.5.5(@better-auth/core@1.5.5(@better-auth/utils@0.3.1)(@better-fetch/fetch@1.1.21)(better-call@1.3.2(zod@4.3.6))(jose@6.2.1)(kysely@0.28.11)(nanostores@1.1.1))(@better-auth/utils@0.3.1)(kysely@0.28.11)
|
||||||
'@better-auth/memory-adapter': 1.5.5(@better-auth/core@1.5.5(@better-auth/utils@0.3.1)(@better-fetch/fetch@1.1.21)(better-call@1.3.2(zod@4.3.6))(jose@6.2.1)(kysely@0.28.11)(nanostores@1.1.1))(@better-auth/utils@0.3.1)
|
'@better-auth/memory-adapter': 1.5.5(@better-auth/core@1.5.5(@better-auth/utils@0.3.1)(@better-fetch/fetch@1.1.21)(better-call@1.3.2(zod@4.3.6))(jose@6.2.1)(kysely@0.28.11)(nanostores@1.1.1))(@better-auth/utils@0.3.1)
|
||||||
'@better-auth/mongo-adapter': 1.5.5(@better-auth/core@1.5.5(@better-auth/utils@0.3.1)(@better-fetch/fetch@1.1.21)(better-call@1.3.2(zod@4.3.6))(jose@6.2.1)(kysely@0.28.11)(nanostores@1.1.1))(@better-auth/utils@0.3.1)(mongodb@7.1.0(socks@2.8.7))
|
'@better-auth/mongo-adapter': 1.5.5(@better-auth/core@1.5.5(@better-auth/utils@0.3.1)(@better-fetch/fetch@1.1.21)(better-call@1.3.2(zod@4.3.6))(jose@6.2.1)(kysely@0.28.11)(nanostores@1.1.1))(@better-auth/utils@0.3.1)(mongodb@7.1.0(socks@2.8.7))
|
||||||
@@ -10580,8 +10731,9 @@ snapshots:
|
|||||||
nanostores: 1.1.1
|
nanostores: 1.1.1
|
||||||
zod: 4.3.6
|
zod: 4.3.6
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
|
better-sqlite3: 12.8.0
|
||||||
drizzle-kit: 0.31.9
|
drizzle-kit: 0.31.9
|
||||||
drizzle-orm: 0.45.1(@opentelemetry/api@1.9.0)(@types/pg@8.15.6)(kysely@0.28.11)(postgres@3.4.8)
|
drizzle-orm: 0.45.1(@opentelemetry/api@1.9.0)(@types/better-sqlite3@7.6.13)(@types/pg@8.15.6)(better-sqlite3@12.8.0)(kysely@0.28.11)(postgres@3.4.8)
|
||||||
mongodb: 7.1.0(socks@2.8.7)
|
mongodb: 7.1.0(socks@2.8.7)
|
||||||
next: 16.1.6(@opentelemetry/api@1.9.0)(@playwright/test@1.58.2)(react-dom@19.2.4(react@19.2.4))(react@19.2.4)
|
next: 16.1.6(@opentelemetry/api@1.9.0)(@playwright/test@1.58.2)(react-dom@19.2.4(react@19.2.4))(react@19.2.4)
|
||||||
react: 19.2.4
|
react: 19.2.4
|
||||||
@@ -10599,12 +10751,27 @@ snapshots:
|
|||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
zod: 4.3.6
|
zod: 4.3.6
|
||||||
|
|
||||||
|
better-sqlite3@12.8.0:
|
||||||
|
dependencies:
|
||||||
|
bindings: 1.5.0
|
||||||
|
prebuild-install: 7.1.3
|
||||||
|
|
||||||
bidi-js@1.0.3:
|
bidi-js@1.0.3:
|
||||||
dependencies:
|
dependencies:
|
||||||
require-from-string: 2.0.2
|
require-from-string: 2.0.2
|
||||||
|
|
||||||
bignumber.js@9.3.1: {}
|
bignumber.js@9.3.1: {}
|
||||||
|
|
||||||
|
bindings@1.5.0:
|
||||||
|
dependencies:
|
||||||
|
file-uri-to-path: 1.0.0
|
||||||
|
|
||||||
|
bl@4.1.0:
|
||||||
|
dependencies:
|
||||||
|
buffer: 5.7.1
|
||||||
|
inherits: 2.0.4
|
||||||
|
readable-stream: 3.6.2
|
||||||
|
|
||||||
body-parser@2.2.2:
|
body-parser@2.2.2:
|
||||||
dependencies:
|
dependencies:
|
||||||
bytes: 3.1.2
|
bytes: 3.1.2
|
||||||
@@ -10661,6 +10828,11 @@ snapshots:
|
|||||||
|
|
||||||
buffer-from@1.1.2: {}
|
buffer-from@1.1.2: {}
|
||||||
|
|
||||||
|
buffer@5.7.1:
|
||||||
|
dependencies:
|
||||||
|
base64-js: 1.5.1
|
||||||
|
ieee754: 1.2.1
|
||||||
|
|
||||||
bullmq@5.71.0:
|
bullmq@5.71.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
cron-parser: 4.9.0
|
cron-parser: 4.9.0
|
||||||
@@ -10722,6 +10894,8 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
readdirp: 5.0.0
|
readdirp: 5.0.0
|
||||||
|
|
||||||
|
chownr@1.1.4: {}
|
||||||
|
|
||||||
chownr@3.0.0: {}
|
chownr@3.0.0: {}
|
||||||
|
|
||||||
cjs-module-lexer@2.2.0: {}
|
cjs-module-lexer@2.2.0: {}
|
||||||
@@ -10878,8 +11052,14 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
character-entities: 2.0.2
|
character-entities: 2.0.2
|
||||||
|
|
||||||
|
decompress-response@6.0.0:
|
||||||
|
dependencies:
|
||||||
|
mimic-response: 3.1.0
|
||||||
|
|
||||||
deep-eql@5.0.2: {}
|
deep-eql@5.0.2: {}
|
||||||
|
|
||||||
|
deep-extend@0.6.0: {}
|
||||||
|
|
||||||
deep-is@0.1.4: {}
|
deep-is@0.1.4: {}
|
||||||
|
|
||||||
defu@6.1.4: {}
|
defu@6.1.4: {}
|
||||||
@@ -10960,10 +11140,12 @@ snapshots:
|
|||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
drizzle-orm@0.45.1(@opentelemetry/api@1.9.0)(@types/pg@8.15.6)(kysely@0.28.11)(postgres@3.4.8):
|
drizzle-orm@0.45.1(@opentelemetry/api@1.9.0)(@types/better-sqlite3@7.6.13)(@types/pg@8.15.6)(better-sqlite3@12.8.0)(kysely@0.28.11)(postgres@3.4.8):
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
'@opentelemetry/api': 1.9.0
|
'@opentelemetry/api': 1.9.0
|
||||||
|
'@types/better-sqlite3': 7.6.13
|
||||||
'@types/pg': 8.15.6
|
'@types/pg': 8.15.6
|
||||||
|
better-sqlite3: 12.8.0
|
||||||
kysely: 0.28.11
|
kysely: 0.28.11
|
||||||
postgres: 3.4.8
|
postgres: 3.4.8
|
||||||
|
|
||||||
@@ -11293,6 +11475,8 @@ snapshots:
|
|||||||
signal-exit: 4.1.0
|
signal-exit: 4.1.0
|
||||||
strip-final-newline: 3.0.0
|
strip-final-newline: 3.0.0
|
||||||
|
|
||||||
|
expand-template@2.0.3: {}
|
||||||
|
|
||||||
expect-type@1.3.0: {}
|
expect-type@1.3.0: {}
|
||||||
|
|
||||||
express-rate-limit@8.3.1(express@5.2.1):
|
express-rate-limit@8.3.1(express@5.2.1):
|
||||||
@@ -11466,6 +11650,8 @@ snapshots:
|
|||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
|
file-uri-to-path@1.0.0: {}
|
||||||
|
|
||||||
fill-range@7.1.1:
|
fill-range@7.1.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
to-regex-range: 5.0.1
|
to-regex-range: 5.0.1
|
||||||
@@ -11526,6 +11712,8 @@ snapshots:
|
|||||||
|
|
||||||
fresh@2.0.0: {}
|
fresh@2.0.0: {}
|
||||||
|
|
||||||
|
fs-constants@1.0.0: {}
|
||||||
|
|
||||||
fsevents@2.3.2:
|
fsevents@2.3.2:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
@@ -11619,6 +11807,8 @@ snapshots:
|
|||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
|
github-from-package@0.0.0: {}
|
||||||
|
|
||||||
glob-parent@6.0.2:
|
glob-parent@6.0.2:
|
||||||
dependencies:
|
dependencies:
|
||||||
is-glob: 4.0.3
|
is-glob: 4.0.3
|
||||||
@@ -11803,6 +11993,8 @@ snapshots:
|
|||||||
|
|
||||||
inherits@2.0.4: {}
|
inherits@2.0.4: {}
|
||||||
|
|
||||||
|
ini@1.3.8: {}
|
||||||
|
|
||||||
ink-spinner@5.0.0(ink@5.2.1(@types/react@18.3.28)(react@18.3.1))(react@18.3.1):
|
ink-spinner@5.0.0(ink@5.2.1(@types/react@18.3.28)(react@18.3.1))(react@18.3.1):
|
||||||
dependencies:
|
dependencies:
|
||||||
cli-spinners: 2.9.2
|
cli-spinners: 2.9.2
|
||||||
@@ -12511,6 +12703,8 @@ snapshots:
|
|||||||
|
|
||||||
mimic-function@5.0.1: {}
|
mimic-function@5.0.1: {}
|
||||||
|
|
||||||
|
mimic-response@3.1.0: {}
|
||||||
|
|
||||||
minimatch@10.2.4:
|
minimatch@10.2.4:
|
||||||
dependencies:
|
dependencies:
|
||||||
brace-expansion: 5.0.4
|
brace-expansion: 5.0.4
|
||||||
@@ -12523,12 +12717,16 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
brace-expansion: 2.0.2
|
brace-expansion: 2.0.2
|
||||||
|
|
||||||
|
minimist@1.2.8: {}
|
||||||
|
|
||||||
minipass@7.1.3: {}
|
minipass@7.1.3: {}
|
||||||
|
|
||||||
minizlib@3.1.0:
|
minizlib@3.1.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
minipass: 7.1.3
|
minipass: 7.1.3
|
||||||
|
|
||||||
|
mkdirp-classic@0.5.3: {}
|
||||||
|
|
||||||
module-details-from-path@1.0.4: {}
|
module-details-from-path@1.0.4: {}
|
||||||
|
|
||||||
mongodb-connection-string-url@7.0.1:
|
mongodb-connection-string-url@7.0.1:
|
||||||
@@ -12574,6 +12772,8 @@ snapshots:
|
|||||||
|
|
||||||
nanostores@1.1.1: {}
|
nanostores@1.1.1: {}
|
||||||
|
|
||||||
|
napi-build-utils@2.0.0: {}
|
||||||
|
|
||||||
natural-compare@1.4.0: {}
|
natural-compare@1.4.0: {}
|
||||||
|
|
||||||
negotiator@0.6.3: {}
|
negotiator@0.6.3: {}
|
||||||
@@ -12608,6 +12808,10 @@ snapshots:
|
|||||||
- '@babel/core'
|
- '@babel/core'
|
||||||
- babel-plugin-macros
|
- babel-plugin-macros
|
||||||
|
|
||||||
|
node-abi@3.89.0:
|
||||||
|
dependencies:
|
||||||
|
semver: 7.7.4
|
||||||
|
|
||||||
node-abort-controller@3.1.1: {}
|
node-abort-controller@3.1.1: {}
|
||||||
|
|
||||||
node-cron@4.2.1: {}
|
node-cron@4.2.1: {}
|
||||||
@@ -12958,6 +13162,21 @@ snapshots:
|
|||||||
|
|
||||||
postgres@3.4.8: {}
|
postgres@3.4.8: {}
|
||||||
|
|
||||||
|
prebuild-install@7.1.3:
|
||||||
|
dependencies:
|
||||||
|
detect-libc: 2.1.2
|
||||||
|
expand-template: 2.0.3
|
||||||
|
github-from-package: 0.0.0
|
||||||
|
minimist: 1.2.8
|
||||||
|
mkdirp-classic: 0.5.3
|
||||||
|
napi-build-utils: 2.0.0
|
||||||
|
node-abi: 3.89.0
|
||||||
|
pump: 3.0.4
|
||||||
|
rc: 1.2.8
|
||||||
|
simple-get: 4.0.1
|
||||||
|
tar-fs: 2.1.4
|
||||||
|
tunnel-agent: 0.6.0
|
||||||
|
|
||||||
prelude-ls@1.2.1: {}
|
prelude-ls@1.2.1: {}
|
||||||
|
|
||||||
prettier@3.8.1: {}
|
prettier@3.8.1: {}
|
||||||
@@ -13040,6 +13259,13 @@ snapshots:
|
|||||||
iconv-lite: 0.7.2
|
iconv-lite: 0.7.2
|
||||||
unpipe: 1.0.0
|
unpipe: 1.0.0
|
||||||
|
|
||||||
|
rc@1.2.8:
|
||||||
|
dependencies:
|
||||||
|
deep-extend: 0.6.0
|
||||||
|
ini: 1.3.8
|
||||||
|
minimist: 1.2.8
|
||||||
|
strip-json-comments: 2.0.1
|
||||||
|
|
||||||
react-dom@19.2.4(react@19.2.4):
|
react-dom@19.2.4(react@19.2.4):
|
||||||
dependencies:
|
dependencies:
|
||||||
react: 19.2.4
|
react: 19.2.4
|
||||||
@@ -13085,6 +13311,12 @@ snapshots:
|
|||||||
string_decoder: 1.1.1
|
string_decoder: 1.1.1
|
||||||
util-deprecate: 1.0.2
|
util-deprecate: 1.0.2
|
||||||
|
|
||||||
|
readable-stream@3.6.2:
|
||||||
|
dependencies:
|
||||||
|
inherits: 2.0.4
|
||||||
|
string_decoder: 1.1.1
|
||||||
|
util-deprecate: 1.0.2
|
||||||
|
|
||||||
readdirp@5.0.0: {}
|
readdirp@5.0.0: {}
|
||||||
|
|
||||||
real-require@0.2.0: {}
|
real-require@0.2.0: {}
|
||||||
@@ -13338,6 +13570,14 @@ snapshots:
|
|||||||
|
|
||||||
signal-exit@4.1.0: {}
|
signal-exit@4.1.0: {}
|
||||||
|
|
||||||
|
simple-concat@1.0.1: {}
|
||||||
|
|
||||||
|
simple-get@4.0.1:
|
||||||
|
dependencies:
|
||||||
|
decompress-response: 6.0.0
|
||||||
|
once: 1.4.0
|
||||||
|
simple-concat: 1.0.1
|
||||||
|
|
||||||
sisteransi@1.0.5: {}
|
sisteransi@1.0.5: {}
|
||||||
|
|
||||||
slice-ansi@5.0.0:
|
slice-ansi@5.0.0:
|
||||||
@@ -13501,6 +13741,8 @@ snapshots:
|
|||||||
|
|
||||||
strip-final-newline@3.0.0: {}
|
strip-final-newline@3.0.0: {}
|
||||||
|
|
||||||
|
strip-json-comments@2.0.1: {}
|
||||||
|
|
||||||
strip-json-comments@3.1.1: {}
|
strip-json-comments@3.1.1: {}
|
||||||
|
|
||||||
strnum@2.2.0: {}
|
strnum@2.2.0: {}
|
||||||
@@ -13538,6 +13780,21 @@ snapshots:
|
|||||||
|
|
||||||
tapable@2.3.0: {}
|
tapable@2.3.0: {}
|
||||||
|
|
||||||
|
tar-fs@2.1.4:
|
||||||
|
dependencies:
|
||||||
|
chownr: 1.1.4
|
||||||
|
mkdirp-classic: 0.5.3
|
||||||
|
pump: 3.0.4
|
||||||
|
tar-stream: 2.2.0
|
||||||
|
|
||||||
|
tar-stream@2.2.0:
|
||||||
|
dependencies:
|
||||||
|
bl: 4.1.0
|
||||||
|
end-of-stream: 1.4.5
|
||||||
|
fs-constants: 1.0.0
|
||||||
|
inherits: 2.0.4
|
||||||
|
readable-stream: 3.6.2
|
||||||
|
|
||||||
tar@7.5.13:
|
tar@7.5.13:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@isaacs/fs-minipass': 4.0.1
|
'@isaacs/fs-minipass': 4.0.1
|
||||||
@@ -13650,6 +13907,10 @@ snapshots:
|
|||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
fsevents: 2.3.3
|
fsevents: 2.3.3
|
||||||
|
|
||||||
|
tunnel-agent@0.6.0:
|
||||||
|
dependencies:
|
||||||
|
safe-buffer: 5.2.1
|
||||||
|
|
||||||
turbo-darwin-64@2.8.16:
|
turbo-darwin-64@2.8.16:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user