From b2cb0c7ede3292bfab4c0ba88cd3c8009051a686 Mon Sep 17 00:00:00 2001 From: "haozhe.yang" Date: Fri, 3 Jul 2026 13:27:32 +0800 Subject: [PATCH] refactor: rename store services to domain-specific terms - rename ToolStore to ToolState - rename CronTaskStore to CronTaskPersistence - rename SkillCatalogStore to SkillDiscovery - rename WorkspaceStore to WorkspacePersistence - rename IFileStore to IFileService and update server call sites --- .../scripts/check-domain-layers.mjs | 8 ++++---- .../scripts/dep-graph/analyzer/analyze.ts | 6 +++--- .../agent-core-v2/src/agent/cron/index.ts | 2 +- .../src/agent/cron/tools/cron-create.ts | 2 +- .../src/agent/cron/tools/cron-list.ts | 2 +- .../fullCompaction/fullCompactionService.ts | 4 ++-- .../src/agent/todoList/todoListService.ts | 4 ++-- .../src/agent/todoList/tools/todo-list.ts | 6 +++--- .../src/agent/toolState/index.ts | 6 ++++++ .../toolStore.ts => toolState/toolState.ts} | 4 ++-- .../toolStateService.ts} | 10 +++++----- .../src/agent/toolStore/index.ts | 6 ------ .../cronTask.ts | 2 +- .../cronTaskPersistence.ts} | 12 +++++------ .../cronTaskPersistenceService.ts} | 10 +++++----- .../src/app/cronPersistence/index.ts | 8 ++++++++ .../agent-core-v2/src/app/cronStore/index.ts | 8 -------- .../app/globalSkillCatalog/builtin/index.ts | 2 +- ...lCatalogStore.ts => fileSkillDiscovery.ts} | 8 ++++---- .../globalSkillCatalogService.ts | 6 +++--- ...alogStore.ts => inMemorySkillDiscovery.ts} | 12 +++++------ .../src/app/globalSkillCatalog/index.ts | 6 +++--- ...skillCatalogStore.ts => skillDiscovery.ts} | 8 ++++---- ...ceStore.ts => fileWorkspacePersistence.ts} | 14 ++++++------- .../src/app/workspaceRegistry/index.ts | 4 ++-- ...kspaceStore.ts => workspacePersistence.ts} | 8 ++++---- .../src/session/cron/sessionCronService.ts | 4 ++-- .../session/cron/sessionCronServiceImpl.ts | 8 ++++---- .../skillCatalogService.ts | 6 +++--- .../test/contextInjector/manager.test.ts | 4 ++-- .../agent-core-v2/test/cron/manager.test.ts | 2 +- .../agent-core-v2/test/cron/persist.test.ts | 4 ++-- .../agent-core-v2/test/cron/resume.test.ts | 2 +- .../agent-core-v2/test/cron/tools.test.ts | 2 +- .../test/fullCompaction/full.test.ts | 4 ++-- ...ore.test.ts => fileSkillDiscovery.test.ts} | 20 +++++++++---------- .../test/skill/skillCatalog.test.ts | 16 +++++++-------- .../test/todoList/todo-list.test.ts | 6 +++--- packages/server-v2/src/routes/files.ts | 10 +++++----- packages/server-v2/src/transport/actionMap.ts | 8 ++++---- packages/server/src/routes/files.ts | 8 ++++---- packages/server/src/routes/prompts.ts | 6 +++--- packages/server/src/start.ts | 4 ++-- 43 files changed, 141 insertions(+), 141 deletions(-) create mode 100644 packages/agent-core-v2/src/agent/toolState/index.ts rename packages/agent-core-v2/src/agent/{toolStore/toolStore.ts => toolState/toolState.ts} (80%) rename packages/agent-core-v2/src/agent/{toolStore/toolStoreService.ts => toolState/toolStateService.ts} (87%) delete mode 100644 packages/agent-core-v2/src/agent/toolStore/index.ts rename packages/agent-core-v2/src/app/{cronStore => cronPersistence}/cronTask.ts (90%) rename packages/agent-core-v2/src/app/{cronStore/cronTaskStore.ts => cronPersistence/cronTaskPersistence.ts} (59%) rename packages/agent-core-v2/src/app/{cronStore/cronTaskStoreService.ts => cronPersistence/cronTaskPersistenceService.ts} (91%) create mode 100644 packages/agent-core-v2/src/app/cronPersistence/index.ts delete mode 100644 packages/agent-core-v2/src/app/cronStore/index.ts rename packages/agent-core-v2/src/app/globalSkillCatalog/{fileSkillCatalogStore.ts => fileSkillDiscovery.ts} (97%) rename packages/agent-core-v2/src/app/globalSkillCatalog/{inMemorySkillCatalogStore.ts => inMemorySkillDiscovery.ts} (78%) rename packages/agent-core-v2/src/app/globalSkillCatalog/{skillCatalogStore.ts => skillDiscovery.ts} (77%) rename packages/agent-core-v2/src/app/workspaceRegistry/{fileWorkspaceStore.ts => fileWorkspacePersistence.ts} (90%) rename packages/agent-core-v2/src/app/workspaceRegistry/{workspaceStore.ts => workspacePersistence.ts} (86%) rename packages/agent-core-v2/test/skill/{fileSkillCatalogStore.test.ts => fileSkillDiscovery.test.ts} (82%) diff --git a/packages/agent-core-v2/scripts/check-domain-layers.mjs b/packages/agent-core-v2/scripts/check-domain-layers.mjs index 7fc3b1307..055a90416 100644 --- a/packages/agent-core-v2/scripts/check-domain-layers.mjs +++ b/packages/agent-core-v2/scripts/check-domain-layers.mjs @@ -98,8 +98,8 @@ const DOMAIN_LAYER = new Map([ // L2 — data & cross-cutting capabilities ['records', 2], ['wireRecord', 2], - ['blobStore', 2], - ['filestore', 2], + ['blob', 2], + ['file', 2], ['config', 2], ['agentFs', 2], ['process', 2], @@ -120,7 +120,7 @@ const DOMAIN_LAYER = new Map([ ['flag', 3], ['toolExecutor', 3], ['toolRegistry', 3], - ['toolStore', 3], + ['toolState', 3], ['userTool', 3], ['permissionMode', 3], ['permissionPolicy', 3], @@ -163,7 +163,7 @@ const DOMAIN_LAYER = new Map([ ['background', 5], ['mcp', 5], ['cron', 5], - ['cronStore', 5], + ['cronPersistence', 5], // `btw` forks a single side-question sub-agent via `agentLifecycle`, // parallel to how the `Agent` tool spawns child agents. Agent-scope, L5. ['btw', 5], diff --git a/packages/agent-core-v2/scripts/dep-graph/analyzer/analyze.ts b/packages/agent-core-v2/scripts/dep-graph/analyzer/analyze.ts index a2a93ab5a..b01c7e6af 100644 --- a/packages/agent-core-v2/scripts/dep-graph/analyzer/analyze.ts +++ b/packages/agent-core-v2/scripts/dep-graph/analyzer/analyze.ts @@ -76,8 +76,8 @@ const FRAMEWORK_BINDINGS: readonly { token: string; scope: ServiceScope; impl: s * Production composition-root bindings seeded by `bootstrap()` via * `ScopeOptions.extra`. `buildCollection` applies `extra` AFTER the static * `registerScopedService` registry, so these take precedence at runtime: they - * override a static default where one exists (e.g. `ISkillCatalogStore` → - * `FileSkillCatalogStore`) and supply the binding where the layer ships no + * override a static default where one exists (e.g. `ISkillDiscovery` → + * `FileSkillDiscovery`) and supply the binding where the layer ships no * in-package default (the Storage-layer tokens → `FileStorageService`, whose * in-memory backend is no longer auto-registered). The analyzer mirrors that * so the graph reflects the backend that actually runs in production. @@ -91,7 +91,7 @@ const PRODUCTION_OVERRIDES: readonly { token: string; scope: ServiceScope; impl: { token: 'IAppendLogStorage', scope: 'App', impl: 'FileStorageService' }, { token: 'IAtomicDocumentStorage', scope: 'App', impl: 'FileStorageService' }, { token: 'IBlobStorage', scope: 'App', impl: 'FileStorageService' }, - { token: 'ISkillCatalogStore', scope: 'App', impl: 'FileSkillCatalogStore' }, + { token: 'ISkillDiscovery', scope: 'App', impl: 'FileSkillDiscovery' }, ]; /** diff --git a/packages/agent-core-v2/src/agent/cron/index.ts b/packages/agent-core-v2/src/agent/cron/index.ts index e5684e80a..43696308a 100644 --- a/packages/agent-core-v2/src/agent/cron/index.ts +++ b/packages/agent-core-v2/src/agent/cron/index.ts @@ -2,7 +2,7 @@ * `cron` domain barrel — re-exports cron utilities (expression parser, jitter, * format, clock, config) and registers the three cron tools (`CronCreate` / * `CronList` / `CronDelete`) via side-effect imports. The cron task record - * type lives in `app/cronStore`; the scheduling engine lives in `session/cron`. + * type lives in `app/cronPersistence`; the scheduling engine lives in `session/cron`. */ import './configSection'; diff --git a/packages/agent-core-v2/src/agent/cron/tools/cron-create.ts b/packages/agent-core-v2/src/agent/cron/tools/cron-create.ts index 4094a21e6..5ddd1196e 100644 --- a/packages/agent-core-v2/src/agent/cron/tools/cron-create.ts +++ b/packages/agent-core-v2/src/agent/cron/tools/cron-create.ts @@ -4,7 +4,7 @@ * cron cadence (`recurring: true`, the default). * * Tasks live in `ISessionCronService` (Session scope) and are persisted - * through the App-scoped `ICronTaskStore` under the project's cron + * through the App-scoped `ICronTaskPersistence` under the project's cron * scope, so a `kimi resume` of the same session reloads them and the * scheduler picks up where it left off (fires that fell during downtime * are collapsed into a single delivery with `coalescedCount`). Tasks do diff --git a/packages/agent-core-v2/src/agent/cron/tools/cron-list.ts b/packages/agent-core-v2/src/agent/cron/tools/cron-list.ts index 22893fa30..f51d63a56 100644 --- a/packages/agent-core-v2/src/agent/cron/tools/cron-list.ts +++ b/packages/agent-core-v2/src/agent/cron/tools/cron-list.ts @@ -46,7 +46,7 @@ import type { ExecutableTool as BuiltinTool, ToolExecution } from '#/agent/tool' import { registerTool } from '#/agent/toolRegistry'; import { toInputJsonSchema } from '#/_base/tools/support/input-schema'; import { ISessionCronService } from '#/session/cron'; -import type { CronTask } from '#/app/cronStore'; +import type { CronTask } from '#/app/cronPersistence'; import { cronToHuman, parseCronExpression, diff --git a/packages/agent-core-v2/src/agent/fullCompaction/fullCompactionService.ts b/packages/agent-core-v2/src/agent/fullCompaction/fullCompactionService.ts index 5513d3c0f..8c8f4fba0 100644 --- a/packages/agent-core-v2/src/agent/fullCompaction/fullCompactionService.ts +++ b/packages/agent-core-v2/src/agent/fullCompaction/fullCompactionService.ts @@ -25,7 +25,7 @@ import { renderTodoList, type TodoItem, } from '#/agent/todoList/tools/todo-list'; -import { IAgentToolStoreService } from '#/agent/toolStore'; +import { IAgentToolState } from '#/agent/toolState'; import { IAgentTurnService } from '#/agent/turn'; import { APIContextOverflowError, @@ -102,7 +102,7 @@ export class AgentFullCompactionService extends Disposable implements IAgentFull @IAgentContextSizeService private readonly contextSize: IAgentContextSizeService, @IAgentLLMRequesterService private readonly llmRequester: IAgentLLMRequesterService, @IAgentProfileService private readonly profile: IAgentProfileService, - @IAgentToolStoreService private readonly toolStore: IAgentToolStoreService, + @IAgentToolState private readonly toolStore: IAgentToolState, @ITelemetryService private readonly telemetry: ITelemetryService, @IAgentRecordService private readonly record: IAgentRecordService, @IAgentExternalHooksService private readonly externalHooks: IAgentExternalHooksService, diff --git a/packages/agent-core-v2/src/agent/todoList/todoListService.ts b/packages/agent-core-v2/src/agent/todoList/todoListService.ts index f50caabb2..c2f989aa4 100644 --- a/packages/agent-core-v2/src/agent/todoList/todoListService.ts +++ b/packages/agent-core-v2/src/agent/todoList/todoListService.ts @@ -17,7 +17,7 @@ import { IAgentContextMemoryService } from '#/agent/contextMemory'; import { IAgentContextInjectorService } from '#/agent/contextInjector'; import { IAgentProfileService } from '#/agent/profile'; import { IAgentToolRegistryService } from '#/agent/toolRegistry'; -import { IAgentToolStoreService } from '#/agent/toolStore'; +import { IAgentToolState } from '#/agent/toolState'; import { IAgentTodoListService } from './todoList'; import { InstantiationType } from '#/_base/di/extensions'; import { LifecycleScope, registerScopedService } from '#/_base/di/scope'; @@ -28,7 +28,7 @@ export class AgentTodoListService extends Disposable implements IAgentTodoListSe constructor( @IAgentContextMemoryService private readonly context: IAgentContextMemoryService, @IAgentProfileService private readonly profile: IAgentProfileService, - @IAgentToolStoreService private readonly toolStore: IAgentToolStoreService, + @IAgentToolState private readonly toolStore: IAgentToolState, @IAgentToolRegistryService toolRegistry: IAgentToolRegistryService, @IAgentContextInjectorService dynamicInjector: IAgentContextInjectorService, @IInstantiationService private readonly instantiationService: IInstantiationService, diff --git a/packages/agent-core-v2/src/agent/todoList/tools/todo-list.ts b/packages/agent-core-v2/src/agent/todoList/tools/todo-list.ts index fca96e9e6..8a80d2dab 100644 --- a/packages/agent-core-v2/src/agent/todoList/tools/todo-list.ts +++ b/packages/agent-core-v2/src/agent/todoList/tools/todo-list.ts @@ -18,7 +18,7 @@ import { z } from 'zod'; import type { BuiltinTool } from '#/agent/tool'; import type { ToolExecution } from '#/agent/tool'; import { toInputJsonSchema } from '#/_base/tools/support/input-schema'; -import { IAgentToolStoreService } from '#/agent/toolStore'; +import { IAgentToolState } from '#/agent/toolState'; import DESCRIPTION from './todo-list.md?raw'; import TODO_LIST_WRITE_REMINDER from './todo-list-write-reminder.md?raw'; @@ -42,7 +42,7 @@ export function readTodoItems(raw: unknown): readonly TodoItem[] { })); } -declare module '#/agent/toolStore' { +declare module '#/agent/toolState' { interface ToolStoreData { todo: readonly TodoItem[]; } @@ -111,7 +111,7 @@ export class TodoListTool implements BuiltinTool { readonly description: string = DESCRIPTION; readonly parameters: Record = toInputJsonSchema(TodoListInputSchema); - constructor(@IAgentToolStoreService private readonly store: IAgentToolStoreService) {} + constructor(@IAgentToolState private readonly store: IAgentToolState) {} resolveExecution(args: TodoListInput): ToolExecution { const description = diff --git a/packages/agent-core-v2/src/agent/toolState/index.ts b/packages/agent-core-v2/src/agent/toolState/index.ts new file mode 100644 index 000000000..10c9e6b2f --- /dev/null +++ b/packages/agent-core-v2/src/agent/toolState/index.ts @@ -0,0 +1,6 @@ +/** + * `toolState` domain barrel - re-exports the tool state service contract and implementation. + */ + +export * from './toolState'; +export * from './toolStateService'; diff --git a/packages/agent-core-v2/src/agent/toolStore/toolStore.ts b/packages/agent-core-v2/src/agent/toolState/toolState.ts similarity index 80% rename from packages/agent-core-v2/src/agent/toolStore/toolStore.ts rename to packages/agent-core-v2/src/agent/toolState/toolState.ts index 475805e18..05f1700f5 100644 --- a/packages/agent-core-v2/src/agent/toolStore/toolStore.ts +++ b/packages/agent-core-v2/src/agent/toolState/toolState.ts @@ -15,7 +15,7 @@ export interface ToolStoreUpdate { readonly value: ToolStoreData[K]; } -export interface IAgentToolStoreService extends ToolStore { +export interface IAgentToolState extends ToolStore { readonly _serviceBrand: undefined; data(): Readonly>; @@ -24,4 +24,4 @@ export interface IAgentToolStoreService extends ToolStore { }>; } -export const IAgentToolStoreService = createDecorator('agentToolStoreService'); +export const IAgentToolState = createDecorator('agentToolState'); diff --git a/packages/agent-core-v2/src/agent/toolStore/toolStoreService.ts b/packages/agent-core-v2/src/agent/toolState/toolStateService.ts similarity index 87% rename from packages/agent-core-v2/src/agent/toolStore/toolStoreService.ts rename to packages/agent-core-v2/src/agent/toolState/toolStateService.ts index e537d84a8..5470b7f39 100644 --- a/packages/agent-core-v2/src/agent/toolStore/toolStoreService.ts +++ b/packages/agent-core-v2/src/agent/toolState/toolStateService.ts @@ -4,7 +4,7 @@ import { import { InstantiationType } from '#/_base/di/extensions'; import { LifecycleScope, registerScopedService } from '#/_base/di/scope'; import { OrderedHookSlot } from '#/hooks'; -import { IAgentToolStoreService, type ToolStoreData, type ToolStoreKey } from './toolStore'; +import { IAgentToolState, type ToolStoreData, type ToolStoreKey } from './toolState'; import { IAgentRecordService, type AgentRecord } from '#/agent/record'; declare module '#/agent/wireRecord' { @@ -16,7 +16,7 @@ declare module '#/agent/wireRecord' { } } -export class AgentToolStoreService extends Disposable implements IAgentToolStoreService { +export class AgentToolStateService extends Disposable implements IAgentToolState { declare readonly _serviceBrand: undefined; private readonly store: Partial = {}; @@ -66,8 +66,8 @@ export class AgentToolStoreService extends Disposable implements IAgentToolStore registerScopedService( LifecycleScope.Agent, - IAgentToolStoreService, - AgentToolStoreService, + IAgentToolState, + AgentToolStateService, InstantiationType.Delayed, - 'toolStore', + 'toolState', ); diff --git a/packages/agent-core-v2/src/agent/toolStore/index.ts b/packages/agent-core-v2/src/agent/toolStore/index.ts deleted file mode 100644 index d4cedcc15..000000000 --- a/packages/agent-core-v2/src/agent/toolStore/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -/** - * `toolStore` domain barrel - re-exports the toolStore service contract and implementation. - */ - -export * from './toolStore'; -export * from './toolStoreService'; diff --git a/packages/agent-core-v2/src/app/cronStore/cronTask.ts b/packages/agent-core-v2/src/app/cronPersistence/cronTask.ts similarity index 90% rename from packages/agent-core-v2/src/app/cronStore/cronTask.ts rename to packages/agent-core-v2/src/app/cronPersistence/cronTask.ts index 202c75085..954fec767 100644 --- a/packages/agent-core-v2/src/app/cronStore/cronTask.ts +++ b/packages/agent-core-v2/src/app/cronPersistence/cronTask.ts @@ -2,7 +2,7 @@ * `cron` domain (L5) — shared `CronTask` data record. * * The authoritative definition of a cron task's persistent shape. Used by - * `ICronTaskStore` (App scope) for project-level persistence and by + * `ICronTaskPersistence` (App scope) for project-level persistence and by * `ISessionCronService` (Session scope) for the live scheduling engine. * The `tags` map carries arbitrary metadata (e.g. `sessionId`) that the * Session projection uses to filter tasks belonging to the current session. diff --git a/packages/agent-core-v2/src/app/cronStore/cronTaskStore.ts b/packages/agent-core-v2/src/app/cronPersistence/cronTaskPersistence.ts similarity index 59% rename from packages/agent-core-v2/src/app/cronStore/cronTaskStore.ts rename to packages/agent-core-v2/src/app/cronPersistence/cronTaskPersistence.ts index 58ff5efa5..8f1e536a9 100644 --- a/packages/agent-core-v2/src/app/cronStore/cronTaskStore.ts +++ b/packages/agent-core-v2/src/app/cronPersistence/cronTaskPersistence.ts @@ -1,11 +1,11 @@ /** - * `cron` domain (L5) — `ICronTaskStore` contract. + * `cron` domain (L5) — `ICronTaskPersistence` contract. * - * Project-level persistence catalog for cron tasks. Stores tasks under + * Project-level persistence for cron tasks. Persists tasks under * `bootstrap.scope('cron')` as atomic documents keyed by * `/.json`. Provides CRUD and query-by-workspace. - * The store is a pure data layer — scheduling, timers, and fire delivery - * are owned by `ISessionCronService` at Session scope. Bound at App scope. + * A pure data layer — scheduling, timers, and fire delivery are owned by + * `ISessionCronService` at Session scope. Bound at App scope. */ import { createDecorator } from '#/_base/di'; @@ -16,7 +16,7 @@ export interface CronTaskQuery { readonly workspaceId: string; } -export interface ICronTaskStore { +export interface ICronTaskPersistence { readonly _serviceBrand: undefined; get(workspaceId: string, taskId: string): Promise; list(query: CronTaskQuery): Promise; @@ -24,4 +24,4 @@ export interface ICronTaskStore { delete(workspaceId: string, taskId: string): Promise; } -export const ICronTaskStore = createDecorator('cronTaskStore'); +export const ICronTaskPersistence = createDecorator('cronTaskPersistence'); diff --git a/packages/agent-core-v2/src/app/cronStore/cronTaskStoreService.ts b/packages/agent-core-v2/src/app/cronPersistence/cronTaskPersistenceService.ts similarity index 91% rename from packages/agent-core-v2/src/app/cronStore/cronTaskStoreService.ts rename to packages/agent-core-v2/src/app/cronPersistence/cronTaskPersistenceService.ts index 0f36b1ea0..8132940c2 100644 --- a/packages/agent-core-v2/src/app/cronStore/cronTaskStoreService.ts +++ b/packages/agent-core-v2/src/app/cronPersistence/cronTaskPersistenceService.ts @@ -1,5 +1,5 @@ /** - * `cron` domain (L5) — `ICronTaskStore` implementation. + * `cron` domain (L5) — `ICronTaskPersistence` implementation. * * Persists cron tasks as atomic JSON documents under the `cron` persistence * scope (`bootstrap.scope('cron')`), laid out as `/.json`. @@ -12,7 +12,7 @@ import { LifecycleScope, registerScopedService } from '#/_base/di/scope'; import { IAtomicDocumentStore } from '#/persistence/interface'; import { IBootstrapService } from '#/app/bootstrap'; -import { ICronTaskStore, type CronTaskQuery } from './cronTaskStore'; +import { ICronTaskPersistence, type CronTaskQuery } from './cronTaskPersistence'; import type { CronTask } from './cronTask'; export const CRON_ID_REGEX: RegExp = /^[0-9a-f]{8}$/; @@ -41,7 +41,7 @@ export function isValidCronTask(obj: unknown): obj is CronTask { return true; } -export class CronTaskStoreService extends Disposable implements ICronTaskStore { +export class CronTaskPersistenceService extends Disposable implements ICronTaskPersistence { declare readonly _serviceBrand: undefined; private readonly cronScope: string; @@ -93,8 +93,8 @@ export class CronTaskStoreService extends Disposable implements ICronTaskStore { registerScopedService( LifecycleScope.App, - ICronTaskStore, - CronTaskStoreService, + ICronTaskPersistence, + CronTaskPersistenceService, InstantiationType.Delayed, 'cron', ); diff --git a/packages/agent-core-v2/src/app/cronPersistence/index.ts b/packages/agent-core-v2/src/app/cronPersistence/index.ts new file mode 100644 index 000000000..b197e4f99 --- /dev/null +++ b/packages/agent-core-v2/src/app/cronPersistence/index.ts @@ -0,0 +1,8 @@ +/** + * `cron` domain barrel — re-exports the cron task data record, the + * `ICronTaskPersistence` contract, and registers the App-scoped persistence service. + */ + +export * from './cronTask'; +export * from './cronTaskPersistence'; +export * from './cronTaskPersistenceService'; diff --git a/packages/agent-core-v2/src/app/cronStore/index.ts b/packages/agent-core-v2/src/app/cronStore/index.ts deleted file mode 100644 index ad1b14397..000000000 --- a/packages/agent-core-v2/src/app/cronStore/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * `cron` domain barrel — re-exports the cron task data record, the - * `ICronTaskStore` contract, and registers the App-scoped store service. - */ - -export * from './cronTask'; -export * from './cronTaskStore'; -export * from './cronTaskStoreService'; diff --git a/packages/agent-core-v2/src/app/globalSkillCatalog/builtin/index.ts b/packages/agent-core-v2/src/app/globalSkillCatalog/builtin/index.ts index 6c4d38b14..3b211199c 100644 --- a/packages/agent-core-v2/src/app/globalSkillCatalog/builtin/index.ts +++ b/packages/agent-core-v2/src/app/globalSkillCatalog/builtin/index.ts @@ -3,7 +3,7 @@ * * Registers the code-defined builtin skills into an in-memory catalog. Builtin * skills are constants (not discovered from storage), so they bypass the - * `ISkillCatalogStore` and are registered directly by the global catalog. + * `ISkillDiscovery` and are registered directly by the global catalog. */ import type { InMemorySkillCatalog } from '#/app/globalSkillCatalog/registry'; diff --git a/packages/agent-core-v2/src/app/globalSkillCatalog/fileSkillCatalogStore.ts b/packages/agent-core-v2/src/app/globalSkillCatalog/fileSkillDiscovery.ts similarity index 97% rename from packages/agent-core-v2/src/app/globalSkillCatalog/fileSkillCatalogStore.ts rename to packages/agent-core-v2/src/app/globalSkillCatalog/fileSkillDiscovery.ts index 2170ff983..fda82d890 100644 --- a/packages/agent-core-v2/src/app/globalSkillCatalog/fileSkillCatalogStore.ts +++ b/packages/agent-core-v2/src/app/globalSkillCatalog/fileSkillDiscovery.ts @@ -1,10 +1,10 @@ /** - * `globalSkillCatalog` domain (L5) — filesystem `ISkillCatalogStore` backend. + * `globalSkillCatalog` domain (L5) — filesystem `ISkillDiscovery` backend. * * Discovers skill bundles by walking skill roots on the local filesystem and * parsing each SKILL.md through `parser`. This is the only file in the skill * domain that imports `node:fs`; the rest of the domain depends on the - * `ISkillCatalogStore` interface and stays filesystem-agnostic. Bound at App + * `ISkillDiscovery` interface and stays filesystem-agnostic. Bound at App * scope by the composition root (tests register the in-memory backend instead). */ @@ -16,7 +16,7 @@ import { UnsupportedSkillTypeError, parseSkillText, } from './parser'; -import type { SkillDiscoveryResult, ISkillCatalogStore } from './skillCatalogStore'; +import type { SkillDiscoveryResult, ISkillDiscovery } from './skillDiscovery'; import type { SkillDefinition, SkillRoot, SkillSource, SkippedSkill } from './types'; import { normalizeSkillName } from './types'; @@ -31,7 +31,7 @@ const PROJECT_GENERIC_DIRS = ['.agents/skills'] as const; // loop forever. Real skill trees are 1-3 levels deep. const MAX_SKILL_SCAN_DEPTH = 8; -export class FileSkillCatalogStore implements ISkillCatalogStore { +export class FileSkillDiscovery implements ISkillDiscovery { declare readonly _serviceBrand: undefined; async discoverProject( diff --git a/packages/agent-core-v2/src/app/globalSkillCatalog/globalSkillCatalogService.ts b/packages/agent-core-v2/src/app/globalSkillCatalog/globalSkillCatalogService.ts index 5d54e6042..41b8f1945 100644 --- a/packages/agent-core-v2/src/app/globalSkillCatalog/globalSkillCatalogService.ts +++ b/packages/agent-core-v2/src/app/globalSkillCatalog/globalSkillCatalogService.ts @@ -2,7 +2,7 @@ * `globalSkillCatalog` domain (L5) — `IGlobalSkillCatalog` implementation. * * Registers the builtin skills and discovers user / brand skills through the - * `ISkillCatalogStore`, using the user home directories from `bootstrap`. The + * `ISkillDiscovery`, using the user home directories from `bootstrap`. The * result is cached after the first `load()`. Bound at App scope. */ @@ -13,7 +13,7 @@ import { IBootstrapService } from '#/app/bootstrap'; import { registerBuiltinSkills } from '#/app/globalSkillCatalog/builtin'; import { IGlobalSkillCatalog } from './globalSkillCatalog'; import { InMemorySkillCatalog } from './registry'; -import { ISkillCatalogStore } from './skillCatalogStore'; +import { ISkillDiscovery } from './skillDiscovery'; import type { SkillCatalog } from './types'; export class GlobalSkillCatalogService implements IGlobalSkillCatalog { @@ -23,7 +23,7 @@ export class GlobalSkillCatalogService implements IGlobalSkillCatalog { private loaded = false; constructor( - @ISkillCatalogStore private readonly store: ISkillCatalogStore, + @ISkillDiscovery private readonly store: ISkillDiscovery, @IBootstrapService private readonly bootstrap: IBootstrapService, ) {} diff --git a/packages/agent-core-v2/src/app/globalSkillCatalog/inMemorySkillCatalogStore.ts b/packages/agent-core-v2/src/app/globalSkillCatalog/inMemorySkillDiscovery.ts similarity index 78% rename from packages/agent-core-v2/src/app/globalSkillCatalog/inMemorySkillCatalogStore.ts rename to packages/agent-core-v2/src/app/globalSkillCatalog/inMemorySkillDiscovery.ts index 44ce12dc7..f0f87bea3 100644 --- a/packages/agent-core-v2/src/app/globalSkillCatalog/inMemorySkillCatalogStore.ts +++ b/packages/agent-core-v2/src/app/globalSkillCatalog/inMemorySkillDiscovery.ts @@ -1,5 +1,5 @@ /** - * `globalSkillCatalog` domain (L5) — in-memory `ISkillCatalogStore` backend. + * `globalSkillCatalog` domain (L5) — in-memory `ISkillDiscovery` backend. * * Returns preset skill lists for project / user discovery without any IO. * Registered as the App-scope default so tests and scopes work without a @@ -10,11 +10,11 @@ import { InstantiationType } from '#/_base/di/extensions'; import { LifecycleScope, registerScopedService } from '#/_base/di/scope'; -import type { SkillDiscoveryResult } from './skillCatalogStore'; -import { ISkillCatalogStore } from './skillCatalogStore'; +import type { SkillDiscoveryResult } from './skillDiscovery'; +import { ISkillDiscovery } from './skillDiscovery'; import type { SkillDefinition } from './types'; -export class InMemorySkillCatalogStore implements ISkillCatalogStore { +export class InMemorySkillDiscovery implements ISkillDiscovery { declare readonly _serviceBrand: undefined; private projectSkills: readonly SkillDefinition[] = []; @@ -39,8 +39,8 @@ export class InMemorySkillCatalogStore implements ISkillCatalogStore { registerScopedService( LifecycleScope.App, - ISkillCatalogStore, - InMemorySkillCatalogStore, + ISkillDiscovery, + InMemorySkillDiscovery, InstantiationType.Delayed, 'skill', ); diff --git a/packages/agent-core-v2/src/app/globalSkillCatalog/index.ts b/packages/agent-core-v2/src/app/globalSkillCatalog/index.ts index c1c42e1bd..9ec0da55e 100644 --- a/packages/agent-core-v2/src/app/globalSkillCatalog/index.ts +++ b/packages/agent-core-v2/src/app/globalSkillCatalog/index.ts @@ -2,13 +2,13 @@ * `globalSkillCatalog` domain barrel — re-exports the skill catalog * contracts, parsers, registry, and the App-scope catalog services. Importing * this barrel registers the `IGlobalSkillCatalog` and the default in-memory - * `ISkillCatalogStore` bindings into the scope registry. + * `ISkillDiscovery` bindings into the scope registry. */ export * from './types'; export * from './parser'; export * from './registry'; -export * from './skillCatalogStore'; -export * from './inMemorySkillCatalogStore'; +export * from './skillDiscovery'; +export * from './inMemorySkillDiscovery'; export * from './globalSkillCatalog'; export * from './globalSkillCatalogService'; diff --git a/packages/agent-core-v2/src/app/globalSkillCatalog/skillCatalogStore.ts b/packages/agent-core-v2/src/app/globalSkillCatalog/skillDiscovery.ts similarity index 77% rename from packages/agent-core-v2/src/app/globalSkillCatalog/skillCatalogStore.ts rename to packages/agent-core-v2/src/app/globalSkillCatalog/skillDiscovery.ts index 190a586a1..eb521cb51 100644 --- a/packages/agent-core-v2/src/app/globalSkillCatalog/skillCatalogStore.ts +++ b/packages/agent-core-v2/src/app/globalSkillCatalog/skillDiscovery.ts @@ -1,7 +1,7 @@ /** - * `globalSkillCatalog` domain (L5) — catalog Store contract. + * `globalSkillCatalog` domain (L5) — catalog discovery contract. * - * `ISkillCatalogStore` is a business-specific Store that hides how skill + * `ISkillDiscovery` is a business-specific interface that hides how skill * bundles are discovered: a backend walks a skill root, reads each SKILL.md, * and parses it into `SkillDefinition`s. The skill domain depends on this * interface only and never touches `node:fs` / `hostFs`; the backend is chosen @@ -19,7 +19,7 @@ export interface SkillDiscoveryResult { readonly scannedRoots: readonly string[]; } -export interface ISkillCatalogStore { +export interface ISkillDiscovery { readonly _serviceBrand: undefined; discoverProject( @@ -30,4 +30,4 @@ export interface ISkillCatalogStore { discoverUser(homeDir: string, osHomeDir: string): Promise; } -export const ISkillCatalogStore = createDecorator('skillCatalogStore'); +export const ISkillDiscovery = createDecorator('skillDiscovery'); diff --git a/packages/agent-core-v2/src/app/workspaceRegistry/fileWorkspaceStore.ts b/packages/agent-core-v2/src/app/workspaceRegistry/fileWorkspacePersistence.ts similarity index 90% rename from packages/agent-core-v2/src/app/workspaceRegistry/fileWorkspaceStore.ts rename to packages/agent-core-v2/src/app/workspaceRegistry/fileWorkspacePersistence.ts index 93d13634f..dc159d48f 100644 --- a/packages/agent-core-v2/src/app/workspaceRegistry/fileWorkspaceStore.ts +++ b/packages/agent-core-v2/src/app/workspaceRegistry/fileWorkspacePersistence.ts @@ -1,7 +1,7 @@ /** - * `workspaceRegistry` domain (L1) — `FileWorkspaceStore` implementation. + * `workspaceRegistry` domain (L1) — `FileWorkspacePersistence` implementation. * - * File backend of `IWorkspaceStore`. Persists the catalog as a single + * File backend of `IWorkspacePersistence`. Persists the catalog as a single * v1-compatible `workspaces.json` document at the storage root * (`/workspaces.json`, via `scope = ''`) through the * `IAtomicDocumentStore` access-pattern Store. Bound at App scope. @@ -13,10 +13,10 @@ import { IAtomicDocumentStore } from '#/app/storage'; import type { Workspace } from './workspaceRegistry'; import { - IWorkspaceStore, + IWorkspacePersistence, type PersistedWorkspaceEntry, type PersistedWorkspaceFile, -} from './workspaceStore'; +} from './workspacePersistence'; const WORKSPACE_REGISTRY_VERSION = 1; // Empty scope resolves to `/` (join skips empty segments), @@ -24,7 +24,7 @@ const WORKSPACE_REGISTRY_VERSION = 1; const WORKSPACE_REGISTRY_SCOPE = ''; const WORKSPACE_REGISTRY_KEY = 'workspaces.json'; -export class FileWorkspaceStore implements IWorkspaceStore { +export class FileWorkspacePersistence implements IWorkspacePersistence { declare readonly _serviceBrand: undefined; constructor(@IAtomicDocumentStore private readonly docs: IAtomicDocumentStore) {} @@ -105,8 +105,8 @@ function parseTime(value: string, fallback: number): number { registerScopedService( LifecycleScope.App, - IWorkspaceStore, - FileWorkspaceStore, + IWorkspacePersistence, + FileWorkspacePersistence, InstantiationType.Delayed, 'workspaceRegistry', ); diff --git a/packages/agent-core-v2/src/app/workspaceRegistry/index.ts b/packages/agent-core-v2/src/app/workspaceRegistry/index.ts index 4482cea12..49d443921 100644 --- a/packages/agent-core-v2/src/app/workspaceRegistry/index.ts +++ b/packages/agent-core-v2/src/app/workspaceRegistry/index.ts @@ -7,5 +7,5 @@ export * from './workspaceRegistry'; export * from './workspaceRegistryService'; -export * from './workspaceStore'; -export * from './fileWorkspaceStore'; +export * from './workspacePersistence'; +export * from './fileWorkspacePersistence'; diff --git a/packages/agent-core-v2/src/app/workspaceRegistry/workspaceStore.ts b/packages/agent-core-v2/src/app/workspaceRegistry/workspacePersistence.ts similarity index 86% rename from packages/agent-core-v2/src/app/workspaceRegistry/workspaceStore.ts rename to packages/agent-core-v2/src/app/workspaceRegistry/workspacePersistence.ts index 1f11c9d37..95ba0bf3b 100644 --- a/packages/agent-core-v2/src/app/workspaceRegistry/workspaceStore.ts +++ b/packages/agent-core-v2/src/app/workspaceRegistry/workspacePersistence.ts @@ -1,5 +1,5 @@ /** - * `workspaceRegistry` domain (L1) — `IWorkspaceStore` contract. + * `workspaceRegistry` domain (L1) — `IWorkspacePersistence` contract. * * Domain-specific persistence Store for the known-workspaces catalog. It hides * the on-disk document layout (`/workspaces.json`, the v1-compatible @@ -30,7 +30,7 @@ export interface PersistedWorkspaceFile { readonly workspaces: Record; } -export interface IWorkspaceStore { +export interface IWorkspacePersistence { readonly _serviceBrand: undefined; /** @@ -46,5 +46,5 @@ export interface IWorkspaceStore { save(workspaces: readonly Workspace[]): Promise; } -export const IWorkspaceStore: ServiceIdentifier = - createDecorator('workspaceStore'); +export const IWorkspacePersistence: ServiceIdentifier = + createDecorator('workspacePersistence'); diff --git a/packages/agent-core-v2/src/session/cron/sessionCronService.ts b/packages/agent-core-v2/src/session/cron/sessionCronService.ts index fc4f90e33..cbacbbefa 100644 --- a/packages/agent-core-v2/src/session/cron/sessionCronService.ts +++ b/packages/agent-core-v2/src/session/cron/sessionCronService.ts @@ -2,7 +2,7 @@ * `cron` domain (L5) — `ISessionCronService` contract. * * Session-level scheduling engine for cron tasks. Owns the live task set - * (filtered from `ICronTaskStore` by `sessionId` tag), the polling timer, + * (filtered from `ICronTaskPersistence` by `sessionId` tag), the polling timer, * and the fire/coalesce/jitter logic. On fire, borrows the main agent's * `IAgentPromptService` via `IAgentLifecycleService` handle to steer a new * turn. Bound at Session scope. @@ -12,7 +12,7 @@ import type { ContentPart } from '#/app/llmProtocol'; import { createDecorator } from '#/_base/di'; import type { Turn } from '#/agent/turn'; -import type { CronTask, CronTaskInit } from '#/app/cronStore'; +import type { CronTask, CronTaskInit } from '#/app/cronPersistence'; export interface CronLoadOptions { readonly replace?: boolean; diff --git a/packages/agent-core-v2/src/session/cron/sessionCronServiceImpl.ts b/packages/agent-core-v2/src/session/cron/sessionCronServiceImpl.ts index 648326ed1..ff4d7b64b 100644 --- a/packages/agent-core-v2/src/session/cron/sessionCronServiceImpl.ts +++ b/packages/agent-core-v2/src/session/cron/sessionCronServiceImpl.ts @@ -2,9 +2,9 @@ * `cron` domain (L5) — `SessionCronService` implementation. * * Session-level scheduling engine. Holds the in-memory task map (filtered - * from `ICronTaskStore` by `sessionId` tag), runs the polling timer + * from `ICronTaskPersistence` by `sessionId` tag), runs the polling timer * (tick / coalesce / jitter / cursor), persists mutations through the - * App-scoped `ICronTaskStore`, mirrors mutations onto `wireRecord` for + * App-scoped `ICronTaskPersistence`, mirrors mutations onto `wireRecord` for * replay via the main agent's `IAgentRecordService` (cross-scope borrow), * and steers the main agent through `IAgentPromptService` when a task fires. * Bound at Session scope. @@ -22,7 +22,7 @@ import { IntervalTimer } from '#/_base/utils'; import { IConfigService } from '#/app/config'; import { ITelemetryService } from '#/app/telemetry'; -import { ICronTaskStore, type CronTask, type CronTaskInit } from '#/app/cronStore'; +import { ICronTaskPersistence, type CronTask, type CronTaskInit } from '#/app/cronPersistence'; import { ISessionContext } from '#/session/sessionContext'; import { IAgentLifecycleService } from '#/session/agentLifecycle'; import type { ContextMessage } from '#/agent/contextMemory'; @@ -98,7 +98,7 @@ export class SessionCronServiceImpl extends Disposable implements ISessionCronSe constructor( @ISessionContext private readonly ctx: ISessionContext, - @ICronTaskStore private readonly store: ICronTaskStore, + @ICronTaskPersistence private readonly store: ICronTaskPersistence, @IAgentLifecycleService private readonly agentLifecycle: IAgentLifecycleService, @ITelemetryService private readonly telemetry: ITelemetryService, @IConfigService private readonly config: IConfigService, diff --git a/packages/agent-core-v2/src/session/sessionSkillCatalog/skillCatalogService.ts b/packages/agent-core-v2/src/session/sessionSkillCatalog/skillCatalogService.ts index 92fe87b55..7255e8a74 100644 --- a/packages/agent-core-v2/src/session/sessionSkillCatalog/skillCatalogService.ts +++ b/packages/agent-core-v2/src/session/sessionSkillCatalog/skillCatalogService.ts @@ -2,7 +2,7 @@ * `sessionSkillCatalog` domain (L5) — `ISessionSkillCatalog` implementation. * * Merges the global catalog (`IGlobalSkillCatalog`) with the project skills - * discovered through `ISkillCatalogStore` for the session's current workDir + * discovered through `ISkillDiscovery` for the session's current workDir * (`workspaceContext`). Project skills override global skills on name * collision. `ready` resolves once the first `load()` completes, so consumers * (e.g. skill activation) can await it instead of racing the asynchronous @@ -18,7 +18,7 @@ import { ISessionWorkspaceContext } from '#/session/workspaceContext'; import { IGlobalSkillCatalog } from '#/app/globalSkillCatalog/globalSkillCatalog'; import { InMemorySkillCatalog } from '#/app/globalSkillCatalog/registry'; import { ISessionSkillCatalog } from './skillCatalog'; -import { ISkillCatalogStore } from '#/app/globalSkillCatalog/skillCatalogStore'; +import { ISkillDiscovery } from '#/app/globalSkillCatalog/skillDiscovery'; import type { SkillCatalog } from '#/app/globalSkillCatalog/types'; export class SessionSkillCatalogService extends Disposable implements ISessionSkillCatalog { @@ -30,7 +30,7 @@ export class SessionSkillCatalogService extends Disposable implements ISessionSk constructor( @IGlobalSkillCatalog private readonly global: IGlobalSkillCatalog, - @ISkillCatalogStore private readonly store: ISkillCatalogStore, + @ISkillDiscovery private readonly store: ISkillDiscovery, @ISessionWorkspaceContext private readonly workspace: ISessionWorkspaceContext, @IPluginService private readonly plugins: IPluginService, ) { diff --git a/packages/agent-core-v2/test/contextInjector/manager.test.ts b/packages/agent-core-v2/test/contextInjector/manager.test.ts index 402043f5a..3cd5bd409 100644 --- a/packages/agent-core-v2/test/contextInjector/manager.test.ts +++ b/packages/agent-core-v2/test/contextInjector/manager.test.ts @@ -15,7 +15,7 @@ import { AgentSystemReminderService } from '#/agent/systemReminder/systemReminde import { IAgentTodoListService, TODO_LIST_REMINDER_VARIANT } from '#/agent/todoList'; import { AgentTodoListService } from '#/agent/todoList/todoListService'; import { IAgentToolRegistryService } from '#/agent/toolRegistry'; -import { IAgentToolStoreService } from '#/agent/toolStore'; +import { IAgentToolState } from '#/agent/toolState'; import { IAgentTurnService } from '#/agent/turn'; import { registerContextMemoryServices } from '../contextMemory/stubs'; import { stubLoopWithHooks, stubTurnWithHooks } from '../turn/stubs'; @@ -227,7 +227,7 @@ describe('AgentContextInjectorService registration', () => { reg.definePartialInstance(IAgentProfileService, { isToolActive: () => false, }); - reg.definePartialInstance(IAgentToolStoreService, { + reg.definePartialInstance(IAgentToolState, { data: () => ({}), }); reg.definePartialInstance(IAgentToolRegistryService, { diff --git a/packages/agent-core-v2/test/cron/manager.test.ts b/packages/agent-core-v2/test/cron/manager.test.ts index 1806c4b2d..664305cf8 100644 --- a/packages/agent-core-v2/test/cron/manager.test.ts +++ b/packages/agent-core-v2/test/cron/manager.test.ts @@ -7,7 +7,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; import type { ContentPart } from '#/app/llmProtocol/kosong'; -import type { CronTask } from '#/app/cronStore'; +import type { CronTask } from '#/app/cronPersistence'; import { CRON_FIRED, CRON_MISSED, diff --git a/packages/agent-core-v2/test/cron/persist.test.ts b/packages/agent-core-v2/test/cron/persist.test.ts index 823c0bea6..089ac6664 100644 --- a/packages/agent-core-v2/test/cron/persist.test.ts +++ b/packages/agent-core-v2/test/cron/persist.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from 'vitest'; -import type { CronTask } from '#/app/cronStore'; -import { CRON_ID_REGEX, isValidCronTask } from '#/app/cronStore'; +import type { CronTask } from '#/app/cronPersistence'; +import { CRON_ID_REGEX, isValidCronTask } from '#/app/cronPersistence'; const validTask: CronTask = { id: '0123abcd', diff --git a/packages/agent-core-v2/test/cron/resume.test.ts b/packages/agent-core-v2/test/cron/resume.test.ts index 57a50c767..b6a8dbc7d 100644 --- a/packages/agent-core-v2/test/cron/resume.test.ts +++ b/packages/agent-core-v2/test/cron/resume.test.ts @@ -18,7 +18,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; import type { ContentPart } from '#/app/llmProtocol/kosong'; import type { ContextMessage, PromptOrigin } from '#/agent/contextMemory'; import { IAgentPromptService } from '#/agent/prompt'; -import type { CronTask } from '#/app/cronStore'; +import type { CronTask } from '#/app/cronPersistence'; import { ISessionCronService } from '#/session/cron'; import { IBootstrapService } from '#/app/bootstrap'; import { IAtomicDocumentStore } from '#/app/storage'; diff --git a/packages/agent-core-v2/test/cron/tools.test.ts b/packages/agent-core-v2/test/cron/tools.test.ts index a1b81a9ae..6fb646f6f 100644 --- a/packages/agent-core-v2/test/cron/tools.test.ts +++ b/packages/agent-core-v2/test/cron/tools.test.ts @@ -8,7 +8,7 @@ import type { RunnableToolExecution, ToolExecution, } from '#/agent/tool'; -import type { CronTask, CronTaskInit } from '#/app/cronStore'; +import type { CronTask, CronTaskInit } from '#/app/cronPersistence'; import type { ISessionCronService } from '#/session/cron'; import { computeNextCronRun, diff --git a/packages/agent-core-v2/test/fullCompaction/full.test.ts b/packages/agent-core-v2/test/fullCompaction/full.test.ts index 8256dcb2d..1df90eec2 100644 --- a/packages/agent-core-v2/test/fullCompaction/full.test.ts +++ b/packages/agent-core-v2/test/fullCompaction/full.test.ts @@ -33,7 +33,7 @@ import { IAgentMicroCompactionService, IOAuthService, IAgentProfileService, - IAgentToolStoreService, + IAgentToolState, } from '#/index'; import { TODO_STORE_KEY } from '#/agent/todoList/tools/todo-list'; @@ -2080,7 +2080,7 @@ describe('FullCompaction', () => { ctx.appendExchange(1, 'old user one', 'old assistant one', 20); ctx.appendExchange(2, 'recent user two', 'recent assistant two', 80); - ctx.get(IAgentToolStoreService).set(TODO_STORE_KEY, [ + ctx.get(IAgentToolState).set(TODO_STORE_KEY, [ { title: 'Fix the auth bug', status: 'in_progress' }, { title: 'Add tests', status: 'pending' }, ]); diff --git a/packages/agent-core-v2/test/skill/fileSkillCatalogStore.test.ts b/packages/agent-core-v2/test/skill/fileSkillDiscovery.test.ts similarity index 82% rename from packages/agent-core-v2/test/skill/fileSkillCatalogStore.test.ts rename to packages/agent-core-v2/test/skill/fileSkillDiscovery.test.ts index d04d3e9a0..785192866 100644 --- a/packages/agent-core-v2/test/skill/fileSkillCatalogStore.test.ts +++ b/packages/agent-core-v2/test/skill/fileSkillDiscovery.test.ts @@ -4,9 +4,9 @@ import { tmpdir } from 'node:os'; import { dirname, join } from 'pathe'; import { afterEach, beforeEach, describe, expect, it } from 'vitest'; -import { FileSkillCatalogStore } from '#/app/globalSkillCatalog/fileSkillCatalogStore'; +import { FileSkillDiscovery } from '#/app/globalSkillCatalog/fileSkillDiscovery'; -describe('FileSkillCatalogStore', () => { +describe('FileSkillDiscovery', () => { let root: string; beforeEach(async () => { @@ -31,7 +31,7 @@ describe('FileSkillCatalogStore', () => { await markGitRoot(); await writeSkill('.kimi-code/skills/commit/SKILL.md', 'name: commit\ndescription: commit changes'); - const result = await new FileSkillCatalogStore().discoverProject(root); + const result = await new FileSkillDiscovery().discoverProject(root); expect(result.skills.map((s) => s.name)).toEqual(['commit']); expect(result.skills[0]?.source).toBe('project'); @@ -41,7 +41,7 @@ describe('FileSkillCatalogStore', () => { await markGitRoot(); await writeSkill('.agents/skills/review/SKILL.md', 'name: review\ndescription: review code'); - const result = await new FileSkillCatalogStore().discoverProject(root); + const result = await new FileSkillDiscovery().discoverProject(root); expect(result.skills.map((s) => s.name)).toEqual(['review']); }); @@ -49,7 +49,7 @@ describe('FileSkillCatalogStore', () => { it('returns an empty result when no skill directories exist', async () => { await markGitRoot(); - const result = await new FileSkillCatalogStore().discoverProject(root); + const result = await new FileSkillDiscovery().discoverProject(root); expect(result.skills).toEqual([]); expect(result.scannedRoots).toEqual([]); @@ -59,7 +59,7 @@ describe('FileSkillCatalogStore', () => { await markGitRoot(); await writeSkill('.kimi-code/skills/summarize.md', 'name: summarize\ndescription: summarize text'); - const result = await new FileSkillCatalogStore().discoverProject(root); + const result = await new FileSkillDiscovery().discoverProject(root); expect(result.skills.map((s) => s.name)).toEqual(['summarize']); }); @@ -69,7 +69,7 @@ describe('FileSkillCatalogStore', () => { await writeSkill('.kimi-code/skills/dup/SKILL.md', 'name: dup\ndescription: from brand'); await writeSkill('.agents/skills/dup/SKILL.md', 'name: dup\ndescription: from generic'); - const result = await new FileSkillCatalogStore().discoverProject(root); + const result = await new FileSkillDiscovery().discoverProject(root); expect(result.skills).toHaveLength(1); expect(result.skills[0]?.description).toBe('from brand'); @@ -78,7 +78,7 @@ describe('FileSkillCatalogStore', () => { it('discovers user skills under homeDir/skills', async () => { await writeSkill('skills/notes/SKILL.md', 'name: notes\ndescription: personal notes'); - const result = await new FileSkillCatalogStore().discoverUser(root, root); + const result = await new FileSkillDiscovery().discoverUser(root, root); expect(result.skills.map((s) => s.name)).toEqual(['notes']); expect(result.skills[0]?.source).toBe('user'); @@ -95,7 +95,7 @@ describe('FileSkillCatalogStore', () => { 'name: child\ndescription: child skill', ); - const result = await new FileSkillCatalogStore().discoverProject(root); + const result = await new FileSkillDiscovery().discoverProject(root); const names = result.skills.map((s) => s.name).toSorted(); expect(names).toEqual(['parent', 'parent.child']); @@ -109,7 +109,7 @@ describe('FileSkillCatalogStore', () => { 'name: hidden\ndescription: hidden', ); - const result = await new FileSkillCatalogStore().discoverProject(root); + const result = await new FileSkillDiscovery().discoverProject(root); expect(result.skills.map((s) => s.name)).not.toContain('hidden'); }); diff --git a/packages/agent-core-v2/test/skill/skillCatalog.test.ts b/packages/agent-core-v2/test/skill/skillCatalog.test.ts index d14c897b0..c5d8c0cec 100644 --- a/packages/agent-core-v2/test/skill/skillCatalog.test.ts +++ b/packages/agent-core-v2/test/skill/skillCatalog.test.ts @@ -8,9 +8,9 @@ import { ISessionWorkspaceContext } from '#/session/workspaceContext'; import '#/app/globalSkillCatalog'; import '#/session/sessionSkillCatalog'; import '#/agent/skill';; -import { InMemorySkillCatalogStore } from '#/app/globalSkillCatalog/inMemorySkillCatalogStore'; +import { InMemorySkillDiscovery } from '#/app/globalSkillCatalog/inMemorySkillDiscovery'; import { ISessionSkillCatalog } from '#/session/sessionSkillCatalog/skillCatalog'; -import { ISkillCatalogStore } from '#/app/globalSkillCatalog/skillCatalogStore'; +import { ISkillDiscovery } from '#/app/globalSkillCatalog/skillDiscovery'; import type { SkillRoot } from '#/app/globalSkillCatalog/types'; import { stubSkill } from './stubs'; @@ -65,12 +65,12 @@ function workspaceStub(workDir: string): { } function makeHost( - store: ISkillCatalogStore, + store: ISkillDiscovery, ws: ISessionWorkspaceContext, pluginRoots: readonly SkillRoot[] = [], ) { const host = createScopedTestHost([ - stubPair(ISkillCatalogStore, store), + stubPair(ISkillDiscovery, store), stubPair(IBootstrapService, bootstrapStub), stubPair(IPluginService, pluginStub(pluginRoots)), ]); @@ -80,7 +80,7 @@ function makeHost( describe('SessionSkillCatalogService', () => { it('merges global and project skills; project wins on name collision', async () => { - const store = new InMemorySkillCatalogStore(); + const store = new InMemorySkillDiscovery(); store.setUserSkills([ stubSkill('global-only'), stubSkill('shared', { description: 'from user' }), @@ -104,7 +104,7 @@ describe('SessionSkillCatalogService', () => { }); it('reload replaces project skills when the workDir changes', async () => { - const store = new InMemorySkillCatalogStore(); + const store = new InMemorySkillDiscovery(); store.setUserSkills([stubSkill('global-only')]); store.setProjectSkills([stubSkill('first')]); const { stub: ws, setWorkDir } = workspaceStub('/work1'); @@ -125,7 +125,7 @@ describe('SessionSkillCatalogService', () => { }); it('does not reload when the workDir is unchanged', async () => { - const store = new InMemorySkillCatalogStore(); + const store = new InMemorySkillDiscovery(); store.setProjectSkills([stubSkill('first')]); const { stub: ws } = workspaceStub('/work'); const { host, session } = makeHost(store, ws); @@ -147,7 +147,7 @@ describe('SessionSkillCatalogService', () => { source: 'extra', plugin: { id: 'demo', instructions: 'Use the demo tools.' }, }; - class ExtraRootStore implements ISkillCatalogStore { + class ExtraRootStore implements ISkillDiscovery { declare readonly _serviceBrand: undefined; receivedRoots: readonly SkillRoot[] | undefined; async discoverProject(_workDir: string, extraRoots?: readonly SkillRoot[]) { diff --git a/packages/agent-core-v2/test/todoList/todo-list.test.ts b/packages/agent-core-v2/test/todoList/todo-list.test.ts index 53b0690e5..13f1d058c 100644 --- a/packages/agent-core-v2/test/todoList/todo-list.test.ts +++ b/packages/agent-core-v2/test/todoList/todo-list.test.ts @@ -7,13 +7,13 @@ import { TodoListTool, type TodoItem, } from '#/agent/todoList/tools/todo-list'; -import type { IAgentToolStoreService } from '#/agent/toolStore'; +import type { IAgentToolState } from '#/agent/toolState'; import { executeTool } from '../tools/fixtures/execute-tool'; const signal = new AbortController().signal; function makeStore(initial: readonly TodoItem[] = []): { - readonly store: IAgentToolStoreService; + readonly store: IAgentToolState; readonly getTodos: () => readonly TodoItem[]; } { let todos = [...initial]; @@ -28,7 +28,7 @@ function makeStore(initial: readonly TodoItem[] = []): { }, data: () => ({ [TODO_STORE_KEY]: todos }), hooks: { onUpdated: { register: () => ({ dispose: () => {} }) } }, - } as unknown as IAgentToolStoreService, + } as unknown as IAgentToolState, getTodos: () => todos, }; } diff --git a/packages/server-v2/src/routes/files.ts b/packages/server-v2/src/routes/files.ts index 5a63f549c..57c66aa07 100644 --- a/packages/server-v2/src/routes/files.ts +++ b/packages/server-v2/src/routes/files.ts @@ -5,7 +5,7 @@ * GET /files/{file_id} download a file (binary stream) * DELETE /files/{file_id} delete a file → { deleted: true } * - * Backed by the v2 `IFileStore` (Core scope), which stores bytes in + * Backed by the v2 `IFileService` (Core scope), which stores bytes in * `IBlobStorage` and the metadata index alongside them. Mirrors the v1 server's * wire behavior (envelope codes 40407 / 41301, 50 MiB cap, content-disposition) * but resolves the store through `core.accessor.get` and streams downloads from @@ -17,7 +17,7 @@ import multipart from '@fastify/multipart'; import { DEFAULT_MAX_UPLOAD_BYTES, ErrorCodes, - IFileStore, + IFileService, KimiError, type Scope, } from '@moonshot-ai/agent-core-v2'; @@ -107,7 +107,7 @@ export function registerFilesRoutes(app: FilesRouteHost, core: Scope): void { const nameOverride = readFieldString(part.fields['name']); const expiresInSec = readFieldNumber(part.fields['expires_in_sec']); - const store = core.accessor.get(IFileStore); + const store = core.accessor.get(IFileService); const partFile = part.file as NodeJS.ReadableStream & { truncated?: boolean }; let busboyTruncated = false; @@ -168,7 +168,7 @@ export function registerFilesRoutes(app: FilesRouteHost, core: Scope): void { async (req, reply) => { try { const { file_id } = req.params; - const store = core.accessor.get(IFileStore); + const store = core.accessor.get(IFileService); const { meta, stream } = await store.get(file_id); const r = reply as unknown as FilesReply; r.type(meta.media_type) @@ -201,7 +201,7 @@ export function registerFilesRoutes(app: FilesRouteHost, core: Scope): void { async (req, reply) => { try { const { file_id } = req.params; - const store = core.accessor.get(IFileStore); + const store = core.accessor.get(IFileService); await store.delete(file_id); reply.send(okEnvelope({ deleted: true as const }, req.id)); } catch (err) { diff --git a/packages/server-v2/src/transport/actionMap.ts b/packages/server-v2/src/transport/actionMap.ts index 6ff07dcba..b4aa34a95 100644 --- a/packages/server-v2/src/transport/actionMap.ts +++ b/packages/server-v2/src/transport/actionMap.ts @@ -51,7 +51,7 @@ import { ISessionMetadata, IAgentSwarmService, IAgentToolRegistryService, - IAgentToolStoreService, + IAgentToolState, IAgentUsageService, ISessionWorkspaceContext, IWorkspaceRegistry, @@ -222,9 +222,9 @@ export const actionMap: Record> = { 'messages:list': { service: IAgentContextMemoryService, method: 'get', readonly: true }, 'messages:splice': { service: IAgentContextMemoryService, method: 'splice' }, - 'toolStore:get': { service: IAgentToolStoreService, method: 'get', readonly: true }, - 'toolStore:data': { service: IAgentToolStoreService, method: 'data', readonly: true }, - 'toolStore:set': { service: IAgentToolStoreService, method: 'set' }, + 'toolStore:get': { service: IAgentToolState, method: 'get', readonly: true }, + 'toolStore:data': { service: IAgentToolState, method: 'data', readonly: true }, + 'toolStore:set': { service: IAgentToolState, method: 'set' }, 'mcp:list': { service: IAgentMcpService, method: 'list', readonly: true }, 'mcp:reconnect': { service: IAgentMcpService, method: 'reconnect' }, diff --git a/packages/server/src/routes/files.ts b/packages/server/src/routes/files.ts index 984451c3a..ae55475d6 100644 --- a/packages/server/src/routes/files.ts +++ b/packages/server/src/routes/files.ts @@ -13,7 +13,7 @@ import { } from '@moonshot-ai/protocol'; import { z } from 'zod'; -import { DEFAULT_MAX_UPLOAD_BYTES, FileNotFoundError, FileTooLargeError, IFileStore, type IInstantiationService } from '@moonshot-ai/agent-core'; +import { DEFAULT_MAX_UPLOAD_BYTES, FileNotFoundError, FileTooLargeError, IFileService, type IInstantiationService } from '@moonshot-ai/agent-core'; import { errEnvelope, okEnvelope } from '../envelope'; import { defineRoute } from '../middleware/defineRoute'; @@ -119,7 +119,7 @@ export function registerFilesRoutes( const nameOverride = readFieldString(part.fields['name']); const expiresInSec = readFieldNumber(part.fields['expires_in_sec']); - const store = ix.invokeFunction((a) => a.get(IFileStore)); + const store = ix.invokeFunction((a) => a.get(IFileService)); const partFile = part.file as NodeJS.ReadableStream & { truncated?: boolean }; let busboyTruncated = false; @@ -178,7 +178,7 @@ export function registerFilesRoutes( async (req, reply) => { try { const { file_id } = req.params; - const store = ix.invokeFunction((a) => a.get(IFileStore)); + const store = ix.invokeFunction((a) => a.get(IFileService)); const { meta, blobPath } = await store.get(file_id); const r = reply as unknown as FilesReply; r.type(meta.media_type) @@ -212,7 +212,7 @@ export function registerFilesRoutes( async (req, reply) => { try { const { file_id } = req.params; - const store = ix.invokeFunction((a) => a.get(IFileStore)); + const store = ix.invokeFunction((a) => a.get(IFileService)); await store.delete(file_id); reply.send(okEnvelope({ deleted: true as const }, req.id)); } catch (err) { diff --git a/packages/server/src/routes/prompts.ts b/packages/server/src/routes/prompts.ts index 4e10d8b06..30cb80c5d 100644 --- a/packages/server/src/routes/prompts.ts +++ b/packages/server/src/routes/prompts.ts @@ -12,7 +12,7 @@ import { promptSteerResultSchema, type PromptSubmission, } from '@moonshot-ai/protocol'; -import { IPromptService, AuthModelNotResolvedError, AuthProvisioningRequiredError, AuthTokenMissingError, AuthTokenUnauthorizedError, PromptAlreadyCompletedError, PromptNotFoundError, SessionBusyError, SessionNotFoundError, FileNotFoundError, IFileStore, type IInstantiationService, type GetResult } from '@moonshot-ai/agent-core'; +import { IPromptService, AuthModelNotResolvedError, AuthProvisioningRequiredError, AuthTokenMissingError, AuthTokenUnauthorizedError, PromptAlreadyCompletedError, PromptNotFoundError, SessionBusyError, SessionNotFoundError, FileNotFoundError, IFileService, type IInstantiationService, type GetResult } from '@moonshot-ai/agent-core'; import { z } from 'zod'; @@ -126,7 +126,7 @@ export function registerPromptsRoutes( const result = await ix.invokeFunction(async (a) => a.get(IPromptService).submit( session_id, - await resolvePromptMediaFiles(body, a.get(IFileStore)), + await resolvePromptMediaFiles(body, a.get(IFileService)), ), ); reply.send(okEnvelope(result, req.id)); @@ -249,7 +249,7 @@ export function registerPromptsRoutes( async function resolvePromptMediaFiles( body: PromptSubmission, - store: IFileStore, + store: IFileService, ): Promise { let changed = false; const content: PromptSubmission['content'] = []; diff --git a/packages/server/src/start.ts b/packages/server/src/start.ts index dda05f458..0c2a11489 100644 --- a/packages/server/src/start.ts +++ b/packages/server/src/start.ts @@ -1,4 +1,4 @@ -import { InstantiationService, resolveConfigPath, resolveKimiHome, setUnexpectedErrorHandler, IApprovalService, IAuthSummaryService, IEnvironmentService, IEventService, ICoreProcessService, IModelCatalogService, IMcpService, IMessageService, IOAuthService, IFileStore, IFsGitService, IFsSearchService, IFsService, IFsWatcher, ILogService, IPromptService, IQuestionService, ISessionService, ISkillService, ITaskService, ITerminalService, IToolService, IWorkspaceFsService, IWorkspaceRegistry, FsPathEscapesError, FsWatchLimitError, FsWatcherService, SessionNotFoundError, createConnectionLookup, resolveSafePath, type ServiceIdentifier, type CoreProcessServiceOptions } from '@moonshot-ai/agent-core'; +import { InstantiationService, resolveConfigPath, resolveKimiHome, setUnexpectedErrorHandler, IApprovalService, IAuthSummaryService, IEnvironmentService, IEventService, ICoreProcessService, IModelCatalogService, IMcpService, IMessageService, IOAuthService, IFileService, IFsGitService, IFsSearchService, IFsService, IFsWatcher, ILogService, IPromptService, IQuestionService, ISessionService, ISkillService, ITaskService, ITerminalService, IToolService, IWorkspaceFsService, IWorkspaceRegistry, FsPathEscapesError, FsWatchLimitError, FsWatcherService, SessionNotFoundError, createConnectionLookup, resolveSafePath, type ServiceIdentifier, type CoreProcessServiceOptions } from '@moonshot-ai/agent-core'; import { ErrorCode, createAsyncApiDocument } from '@moonshot-ai/protocol'; import Fastify from 'fastify'; import { promises as fspPromises } from 'node:fs'; @@ -518,7 +518,7 @@ export async function startServer(opts: ServerStartOptions): Promise