refactor(agent-core-v2): remove barrel re-exports in favor of direct imports

- delete per-directory index.ts barrel files across src/ submodules
- update src and test imports to reference concrete module files directly
- rename a few index.ts entry files to named modules (migration.ts, providers.ts, builtin.ts)
- rewire src/index.ts to export from concrete modules instead of directory barrels
- add patch changeset noting the production-build fix
This commit is contained in:
haozhe.yang 2026-07-07 16:13:52 +08:00
parent b37345e5d5
commit 3dcb8ef4dd
377 changed files with 1237 additions and 1977 deletions

View file

@ -0,0 +1,5 @@
---
"@moonshot-ai/agent-core-v2": patch
---
Fix the production build by resolving internal module imports directly instead of through directory re-exports.

View file

@ -11,7 +11,7 @@ Domain-slice scenarios that used to live in `examples/<name>.example.ts` are now
## Comment conventions
- **Header only, external role only.** Comments live solely in the top-of-file `/** */` block — never beside functions, methods, or statements. Say what the module exposes and the responsibility it owns; the code is the source of truth for how it works, so do not narrate implementation steps, enumerate every export, or note porting / skeleton status.
- **Identity line first.** Start with `` `<domain>` domain (Ln) — <one-line role>. `` Keep an existing `(cross-cutting)` label as-is; barrels omit the layer (`` `<domain>` domain barrel — … ``). Write the role as a responsibility ("drives the turn lifecycle"), not a symbol list ("turn driver + context + loop runner").
- **Identity line first.** Start with `` `<domain>` domain (Ln) — <one-line role>. `` Keep an existing `(cross-cutting)` label as-is. Write the role as a responsibility ("drives the turn lifecycle"), not a symbol list ("turn driver + context + loop runner").
- **Impl files add collaborators + scope; contract files add the public contract + scope.** For impls, list every imported cross-domain collaborator as a role ("persists records through `records`") — declared dependencies count even if not yet wired in this WIP port; infrastructure imports (`_base/**`) are not collaborators. Read scope from `registerScopedService(LifecycleScope.X, …)`.
### Examples
@ -30,17 +30,6 @@ Impl (`src/session/sessionMetadata/sessionMetadataService.ts`):
*/
```
Barrel (`src/session/sessionMetadata/index.ts`):
```ts
/**
* `sessionMetadata` domain barrel — re-exports the session metadata contract
* (`sessionMetadata`) and its scoped service (`sessionMetadataService`).
* Importing this barrel registers the `ISessionMetadata` binding into the scope
* registry.
*/
```
## Persistence
Business domains **do not implement persistence themselves** — they depend on a Service that owns the access pattern. Business code expresses *what* to store or fetch, never *how*.

View file

@ -1,15 +0,0 @@
/**
* `di` domain barrel re-exports the dependency-injection primitives:
* service identifiers and decorators, descriptors, the instantiation service,
* scope registration, the service collection, and disposable lifecycle.
*/
export * from './descriptors';
export * from './errors';
export * from './extensions';
export * from './graph';
export * from './instantiation';
export * from './instantiationService';
export * from './lifecycle';
export * from './scope';
export * from './serviceCollection';

View file

@ -1,11 +0,0 @@
/**
* `errors` domain barrel re-exports the error primitives: the code registry,
* base error classes, message rendering, wire serialization, and unexpected-
* error reporting.
*/
export * from './codes';
export * from './errorMessage';
export * from './errors';
export * from './serialize';
export * from './unexpectedError';

View file

@ -1,22 +0,0 @@
/**
* `_base/execEnv` (L0) pure execution-environment primitives.
*
* Vendored helpers previously imported from `@moonshot-ai/kaos`. None of them
* carry DI dependencies; higher layers wrap them into services:
* - `os/interface/hostEnvironment` memoises the OS/shell probe as `IHostEnvironment`
* - `session/sessionFs` reuses the fs helpers to implement the session fs
* - `session/process` reuses `BufferedReadable` for the spawned process
*/
export { BufferedReadable } from './bufferedReadable';
export { decodeTextWithErrors, type TextDecodeErrors } from './decodeText';
export { globPatternToRegex } from './globPattern';
export {
probeHostEnvironment,
probeHostEnvironmentFromNode,
type HostEnvironmentInfo,
type HostEnvironmentProbeDeps,
type OsKind,
type PathClass,
type ShellName,
} from './environmentProbe';

View file

@ -1,11 +0,0 @@
/**
* `_base/log` barrel re-exports the logging contract, plain sinks, and the
* App-scope `ILogService` binding. Importing this barrel registers the App-scope
* `ILogService` into the scope registry.
*/
export * from './log';
export * from './logConfig';
export * from './formatter';
export * from './fileLog';
export * from './logService';

View file

@ -1,18 +0,0 @@
/**
* `_base` utility barrel re-exports the shared primitive helpers used
* across domains.
*/
export * from './abort';
export * from './canonical-args';
export * from './env';
export * from './fs';
export * from './hero-slug';
export * from './promise';
export * from './proxy';
export * from './render-prompt';
export * from './timer';
export * from './tokens';
export * from './types';
export * from './workdir-slug';
export * from './xml-escape';

View file

@ -11,7 +11,7 @@ import { createHash } from 'node:crypto';
import type { ContentPart } from '#/app/llmProtocol/message';
import { InstantiationType } from '#/_base/di/extensions';
import { LifecycleScope, registerScopedService } from '#/_base/di/scope';
import { IAgentScopeContext } from '#/agent/scopeContext';
import { IAgentScopeContext } from '#/agent/scopeContext/scopeContext';
import { IBlobStore } from '#/persistence/interface/blobStore';
import {
BLOBREF_PROTOCOL,

View file

@ -1,6 +0,0 @@
/**
* `blob` domain barrel.
*/
export * from './agentBlobService';
export * from './agentBlobServiceImpl';

View file

@ -2,12 +2,12 @@ import { Disposable, toDisposable } from "#/_base/di/lifecycle";
import { InstantiationType } from '#/_base/di/extensions';
import { LifecycleScope, registerScopedService } from '#/_base/di/scope';
import { IAgentContextMemoryService } from '#/agent/contextMemory';
import { IAgentLoopService } from '#/agent/loop';
import { IAgentSystemReminderService } from '#/agent/systemReminder';
import { IAgentTurnService } from '#/agent/turn';
import { IAgentContextMemoryService } from '#/agent/contextMemory/contextMemory';
import { IAgentLoopService } from '#/agent/loop/loop';
import { IAgentSystemReminderService } from '#/agent/systemReminder/systemReminder';
import { IAgentTurnService } from '#/agent/turn/turn';
import { IEventBus } from '#/app/event/eventBus';
import type { ContextMessage } from '#/agent/contextMemory';
import type { ContextMessage } from '#/agent/contextMemory/types';
import {
IAgentContextInjectorService,
type ContextInjectionOptions,

View file

@ -1,7 +0,0 @@
/**
* `dynamicInjector` domain barrel - re-exports the dynamicInjector service contract and implementation.
*/
export * from './contextInjector';
export * from './contextInjectorService';
export * from './pluginSessionStart';

View file

@ -16,14 +16,14 @@ import { createDecorator, type ServiceIdentifier } from '#/_base/di/instantiatio
import { InstantiationType } from '#/_base/di/extensions';
import { LifecycleScope, registerScopedService } from '#/_base/di/scope';
import { escapeXmlAttr } from '#/_base/utils/xml-escape';
import { IAgentContextMemoryService } from '#/agent/contextMemory';
import { IAgentContextMemoryService } from '#/agent/contextMemory/contextMemory';
import { ILogService } from '#/_base/log/log';
import { IPluginService } from '#/app/plugin/plugin';
import type { EnabledPluginSessionStart } from '#/app/plugin/types';
import { ISessionSkillCatalog } from '#/session/sessionSkillCatalog/skillCatalog';
import { ISessionContext } from '#/session/sessionContext/sessionContext';
import type { SkillCatalog, SkillDefinition } from '#/app/skillCatalog/types';
import { IAgentSystemReminderService } from '#/agent/systemReminder';
import { IAgentSystemReminderService } from '#/agent/systemReminder/systemReminder';
import { IAgentContextInjectorService } from './contextInjector';

View file

@ -18,7 +18,8 @@ import { Disposable } from '#/_base/di/lifecycle';
import { InstantiationType } from '#/_base/di/extensions';
import { LifecycleScope, registerScopedService } from '#/_base/di/scope';
import { IEventBus } from '#/app/event/eventBus';
import { IAgentWireService, type IWireService } from '#/wire';
import { IAgentWireService } from '#/wire/tokens';
import type { IWireService } from '#/wire/wireService';
import { IAgentContextMemoryService, type ContextCompactionInput } from './contextMemory';
import {
@ -34,7 +35,7 @@ import {
import { ensureMessageId } from './messageId';
import type { ContextMessage } from './types';
declare module '#/agent/wireRecord' {
declare module '#/agent/wireRecord/wireRecord' {
interface WireRecordMap {
'context.splice': {
start: number;

View file

@ -32,8 +32,9 @@
*/
import type { ContentPart } from '#/app/llmProtocol/message';
import { defineModel, defineOp, type PartsTransformer } from '#/wire';
import type { PersistedRecord } from '#/wire';
import { defineModel, type PartsTransformer } from '#/wire/model';
import { defineOp } from '#/wire/op';
import type { PersistedRecord } from '#/wire/wireService';
import {
foldAppendMessage,

View file

@ -1,12 +0,0 @@
/**
* `contextMemory` domain barrel - re-exports the contextMemory service contract and implementation.
*/
export * from './contextMemory';
export * from './contextMemoryService';
export * from './contextOps';
export * from './loopEventFold';
export * from './messageId';
export * from './messageProjection';
export * from './types';

View file

@ -1,6 +1,6 @@
import type { ContentPart, Message } from '#/app/llmProtocol/message';
import type { AgentTaskStatus } from '#/agent/task';
import type { AgentTaskStatus } from '#/agent/task/task';
import type { CronJobOrigin, CronMissedOrigin } from '@moonshot-ai/protocol';
export type SkillSource = 'project' | 'user' | 'extra' | 'builtin';

View file

@ -1,7 +1,7 @@
import { createDecorator } from "#/_base/di/instantiation";
import type { Message } from '#/app/llmProtocol/message';
import type { ContextMessage } from '#/agent/contextMemory';
import type { ContextMessage } from '#/agent/contextMemory/types';
export interface IAgentContextProjectorService {
readonly _serviceBrand: undefined;

View file

@ -3,7 +3,7 @@ import { InstantiationType } from '#/_base/di/extensions';
import { LifecycleScope, registerScopedService } from '#/_base/di/scope';
import type { ContextMessage } from '#/agent/contextMemory/types';
import { ErrorCodes, KimiError } from '#/errors';
import { IAgentMicroCompactionService } from '#/agent/microCompaction';
import { IAgentMicroCompactionService } from '#/agent/microCompaction/microCompaction';
import type { ContentPart, Message } from '#/app/llmProtocol/message';
import { IAgentContextProjectorService } from './contextProjector';

View file

@ -1,6 +0,0 @@
/**
* `contextProjector` domain barrel - re-exports the contextProjector service contract and implementation.
*/
export * from './contextProjector';
export * from './contextProjectorService';

View file

@ -18,7 +18,8 @@
* the Agent-scope `contextSizeService`.
*/
import { defineModel, defineOp } from '#/wire';
import { defineModel } from '#/wire/model';
import { defineOp } from '#/wire/op';
export interface ContextSizeState {
readonly length: number;

View file

@ -18,11 +18,12 @@ import { Disposable } from '#/_base/di/lifecycle';
import { InstantiationType } from '#/_base/di/extensions';
import { LifecycleScope, registerScopedService } from '#/_base/di/scope';
import { estimateTokensForMessage } from '#/_base/utils/tokens';
import type { ContextMessage } from '#/agent/contextMemory';
import { IAgentContextMemoryService } from '#/agent/contextMemory';
import { IAgentContextMemoryService } from '#/agent/contextMemory/contextMemory';
import type { ContextMessage } from '#/agent/contextMemory/types';
import type { Message } from '#/app/llmProtocol/message';
import type { TokenUsage } from '#/app/llmProtocol/usage';
import { IAgentWireService, type IWireService } from '#/wire';
import { IAgentWireService } from '#/wire/tokens';
import type { IWireService } from '#/wire/wireService';
import { IAgentContextSizeService, type ContextSizeStatus } from './contextSize';
import { ContextSizeModel, contextSizeMeasured } from './contextSizeOps';

View file

@ -1,7 +0,0 @@
/**
* `contextSize` domain barrel - re-exports the contextSize service contract and implementation.
*/
export * from './contextSize';
export * from './contextSizeOps';
export * from './contextSizeService';

View file

@ -19,32 +19,28 @@ import { InstantiationType } from '#/_base/di/extensions';
import { LifecycleScope, registerScopedService } from '#/_base/di/scope';
import { isUserCancellation } from '#/_base/utils/abort';
import { isPlainRecord } from '#/_base/utils/canonical-args';
import { IAgentTaskService, type AgentTaskNotificationContext } from '#/agent/task';
import { IAgentContextMemoryService, USER_PROMPT_ORIGIN } from '#/agent/contextMemory';
import { IAgentTaskService, type AgentTaskNotificationContext } from '#/agent/task/task';
import { IAgentContextMemoryService } from '#/agent/contextMemory/contextMemory';
import { USER_PROMPT_ORIGIN } from '#/agent/contextMemory/types';
import {
IAgentFullCompactionService,
type FullCompactionWillCompactContext,
} from '#/agent/fullCompaction';
} from '#/agent/fullCompaction/fullCompaction';
import type { CompactionResult, CompactionSource } from '#/agent/fullCompaction/types';
import { IAgentLoopService, type TurnAfterStepContext } from '#/agent/loop';
import { IAgentLoopService, type TurnAfterStepContext } from '#/agent/loop/loop';
import {
IAgentPermissionGate,
} from '#/agent/permissionGate';
} from '#/agent/permissionGate/permissionGate';
import {
IAgentPromptService,
type PromptSubmitContext,
} from '#/agent/prompt';
} from '#/agent/prompt/prompt';
import type { HookResultEvent, TurnEndReason } from '@moonshot-ai/protocol';
import { IEventBus } from '#/app/event/eventBus';
import type {
ExecutableToolResult,
ToolDidExecuteContext,
ToolWillExecuteContext,
} from '#/agent/tool';
import { IAgentToolExecutorService } from '#/agent/toolExecutor';
import {
IAgentTurnService,
} from '#/agent/turn';
import type { ExecutableToolResult } from '#/agent/tool/toolContract';
import type { ToolDidExecuteContext, ToolWillExecuteContext } from '#/agent/tool/toolHooks';
import { IAgentToolExecutorService } from '#/agent/toolExecutor/toolExecutor';
import { IAgentTurnService } from '#/agent/turn/turn';
import { IBootstrapService } from '#/app/bootstrap/bootstrap';
import { IConfigService } from '#/app/config/config';
import { IPluginService } from '#/app/plugin/plugin';

View file

@ -1,8 +0,0 @@
/**
* `externalHooks` domain (L5) barrel - re-exports the externalHooks service contract and implementation.
*/
import './configSection';
export * from './externalHooks';
export * from './externalHooksService';

View file

@ -44,7 +44,8 @@ import type {
CompactionCompletedEvent,
CompactionStartedEvent,
} from '@moonshot-ai/protocol';
import { defineModel, defineOp } from '#/wire';
import { defineModel } from '#/wire/model';
import { defineOp } from '#/wire/op';
import type { FullCompactionCompleteData } from './fullCompaction';
import type { CompactionBeginData, CompactionSource } from './types';

View file

@ -3,19 +3,15 @@ import { InstantiationType } from '#/_base/di/extensions';
import { LifecycleScope, registerScopedService } from '#/_base/di/scope';
import { renderPrompt } from "#/_base/utils/render-prompt";
import { estimateTokens, estimateTokensForMessages } from "#/_base/utils/tokens";
import type { ContextMessage } from '#/agent/contextMemory';
import { IAgentContextMemoryService } from '#/agent/contextMemory';
import { IAgentContextSizeService } from '#/agent/contextSize';
import {
IAgentLLMRequesterService,
retryBackoffDelays,
sleepForRetry,
type LLMRequestFinish,
} from '#/agent/llmRequester';
import { IAgentLoopService, type TurnErrorContext } from '#/agent/loop';
import { IAgentContextMemoryService } from '#/agent/contextMemory/contextMemory';
import type { ContextMessage } from '#/agent/contextMemory/types';
import { IAgentContextSizeService } from '#/agent/contextSize/contextSize';
import { IAgentLLMRequesterService, type LLMRequestFinish } from '#/agent/llmRequester/llmRequester';
import { retryBackoffDelays, sleepForRetry } from '#/agent/llmRequester/retry';
import { IAgentLoopService, type TurnErrorContext } from '#/agent/loop/loop';
import { isAbortError, isContextOverflowError } from '#/agent/loop/errors';
import { IAgentProfileService } from '#/agent/profile';
import { IAgentTurnService } from '#/agent/turn';
import { IAgentProfileService } from '#/agent/profile/profile';
import { IAgentTurnService } from '#/agent/turn/turn';
import { ISessionTodoService } from '#/session/todo/sessionTodo';
import { renderTodoList, type TodoItem } from '#/session/todo/todoItem';
import { APIContextOverflowError, APIEmptyResponseError } from '#/app/llmProtocol/errors';
@ -24,7 +20,8 @@ import { type TokenUsage } from '#/app/llmProtocol/usage';
import { IEventBus } from '#/app/event/eventBus';
import { ITelemetryService } from '#/app/telemetry/telemetry';
import { ErrorCodes, KimiError, isKimiError, toKimiErrorPayload } from "#/errors";
import { IAgentWireService, type IWireService } from '#/wire';
import { IAgentWireService } from '#/wire/tokens';
import type { IWireService } from '#/wire/wireService';
import compactionInstructionTemplate from './compaction-instruction.md?raw';
import {
IAgentFullCompactionService,
@ -55,7 +52,7 @@ import { OrderedHookSlot } from '#/hooks';
// `full_compaction.complete` resumer against that stream. fullCompaction itself
// no longer registers resumers here — its state rebuilds from the same log via
// `wire.replay` into `CompactionModel`.
declare module '#/agent/wireRecord' {
declare module '#/agent/wireRecord/wireRecord' {
interface WireRecordMap {
'full_compaction.begin': CompactionBeginData;
'full_compaction.cancel': {};

View file

@ -1,9 +0,0 @@
/**
* `fullCompaction` domain barrel - re-exports the fullCompaction service contract and implementation.
*/
export * from './strategy';
export * from './fullCompaction';
export * from './fullCompactionService';
export * from './compactionOps';
export * from './types';

View file

@ -1,5 +1,5 @@
import type { Message } from '#/app/llmProtocol/message';
import type { ProfileModelContext } from '#/agent/profile';
import type { ProfileModelContext } from '#/agent/profile/profile';
import type { CompactionSource } from './types';
import { estimateTokensForMessage } from '#/_base/utils/tokens';

View file

@ -19,7 +19,8 @@
* `goalService`.
*/
import { defineModel, defineOp } from '#/wire';
import { defineModel } from '#/wire/model';
import { defineOp } from '#/wire/op';
import type {
GoalActor,

View file

@ -24,13 +24,10 @@ import { randomUUID } from 'node:crypto';
import { Disposable } from '#/_base/di/lifecycle';
import { InstantiationType } from '#/_base/di/extensions';
import { LifecycleScope, registerScopedService } from '#/_base/di/scope';
import { IAgentContextInjectorService } from '#/agent/contextInjector';
import {
ensureMessageId,
IAgentContextMemoryService,
type ContextMessage,
type PromptOrigin,
} from '#/agent/contextMemory';
import { IAgentContextInjectorService } from '#/agent/contextInjector/contextInjector';
import { IAgentContextMemoryService } from '#/agent/contextMemory/contextMemory';
import { ensureMessageId } from '#/agent/contextMemory/messageId';
import type { ContextMessage, PromptOrigin } from '#/agent/contextMemory/types';
import { GoalInjection } from '#/agent/goal/injection/goalInjection';
import {
buildGoalBlockedReasonPrompt,
@ -40,14 +37,15 @@ import {
IAgentLoopService,
type TurnAfterStepContext,
type TurnBeforeStepContext,
} from '#/agent/loop';
import { IAgentSystemReminderService } from '#/agent/systemReminder';
import { IAgentTurnService, type TurnResult } from '#/agent/turn';
} from '#/agent/loop/loop';
import { IAgentSystemReminderService } from '#/agent/systemReminder/systemReminder';
import { IAgentTurnService, type TurnResult } from '#/agent/turn/turn';
import type { TokenUsage } from '#/app/llmProtocol/usage';
import type { TelemetryProperties } from '#/app/telemetry/telemetry';
import { ITelemetryService } from '#/app/telemetry/telemetry';
import { ErrorCodes, KimiError, toKimiErrorPayload, type KimiErrorPayload } from '#/errors';
import { IAgentWireService, type IWireService } from '#/wire';
import { IAgentWireService } from '#/wire/tokens';
import type { IWireService } from '#/wire/wireService';
import { IEventBus } from '#/app/event/eventBus';
import { IAgentGoalService, type GoalReasonInput } from './goal';
@ -64,7 +62,7 @@ import type {
GoalToolResult,
} from './types';
declare module '#/agent/wireRecord' {
declare module '#/agent/wireRecord/wireRecord' {
interface WireRecordMap {
forked: {};
'goal.create': {

View file

@ -1,17 +0,0 @@
/**
* `goal` domain barrel re-exports the goal contract (`goal`) and its scoped
* service (`goalService`), plus a side-effect import of each goal tool so its
* `registerTool(...)` call runs at module load. Importing this barrel wires
* `IAgentGoalService` into the scope registry and adds the four goal tools
* (`CreateGoal` / `GetGoal` / `SetGoalBudget` / `UpdateGoal`) to the tool
* contribution list.
*/
import './tools/create-goal';
import './tools/get-goal';
import './tools/set-goal-budget';
import './tools/update-goal';
export * from './goal';
export * from './goalService';
export * from './types';

View file

@ -1,4 +1,4 @@
import type { GoalSnapshot } from '#/agent/goal';
import type { GoalSnapshot } from '#/agent/goal/types';
import { Disposable } from "#/_base/di/lifecycle";
import { renderPrompt } from "#/_base/utils/render-prompt";
import { IAgentContextInjectorService } from '#/agent/contextInjector/contextInjector';

View file

@ -9,9 +9,9 @@ import { z } from 'zod';
import type { ToolInputDisplay } from '@moonshot-ai/protocol';
import { toInputJsonSchema } from '#/_base/tools/support/input-schema';
import { IAgentPermissionModeService } from '#/agent/permissionMode';
import type { BuiltinTool, ToolExecution } from '#/agent/tool';
import { registerTool } from '#/agent/toolRegistry';
import { IAgentPermissionModeService } from '#/agent/permissionMode/permissionMode';
import type { BuiltinTool, ToolExecution } from '#/agent/tool/toolContract';
import { registerTool } from '#/agent/toolRegistry/toolContribution';
import { IAgentGoalService } from '#/agent/goal/goal';
import DESCRIPTION from './create-goal.md?raw';

View file

@ -7,8 +7,8 @@
import { z } from 'zod';
import { toInputJsonSchema } from '#/_base/tools/support/input-schema';
import type { BuiltinTool, ToolExecution } from '#/agent/tool';
import { registerTool } from '#/agent/toolRegistry';
import type { BuiltinTool, ToolExecution } from '#/agent/tool/toolContract';
import { registerTool } from '#/agent/toolRegistry/toolContribution';
import { IAgentGoalService } from '#/agent/goal/goal';
import DESCRIPTION from './get-goal.md?raw';

View file

@ -7,8 +7,8 @@
import { z } from 'zod';
import { toInputJsonSchema } from '#/_base/tools/support/input-schema';
import type { BuiltinTool, ToolExecution } from '#/agent/tool';
import { registerTool } from '#/agent/toolRegistry';
import type { BuiltinTool, ToolExecution } from '#/agent/tool/toolContract';
import { registerTool } from '#/agent/toolRegistry/toolContribution';
import { IAgentGoalService } from '#/agent/goal/goal';
import type { GoalBudgetLimits } from '#/agent/goal/types';

View file

@ -12,8 +12,8 @@
import { z } from 'zod';
import { toInputJsonSchema } from '#/_base/tools/support/input-schema';
import type { BuiltinTool, ToolExecution } from '#/agent/tool';
import { registerTool } from '#/agent/toolRegistry';
import type { BuiltinTool, ToolExecution } from '#/agent/tool/toolContract';
import { registerTool } from '#/agent/toolRegistry/toolContribution';
import { IAgentGoalService } from '#/agent/goal/goal';
import DESCRIPTION from './update-goal.md?raw';

View file

@ -1,8 +0,0 @@
/**
* `llmRequester` domain barrel - re-exports the llmRequester service contract and implementation.
*/
export * from './asyncEventQueue';
export * from './llmRequester';
export * from './llmRequesterService';
export * from './retry';

View file

@ -16,12 +16,12 @@
import { createHash } from 'node:crypto';
import { InstantiationType } from '#/_base/di/extensions';
import { LifecycleScope, registerScopedService } from '#/_base/di/scope';
import { IAgentContextMemoryService } from '#/agent/contextMemory';
import { IAgentContextProjectorService } from '#/agent/contextProjector';
import { IAgentContextSizeService } from '#/agent/contextSize';
import { IAgentProfileService } from '#/agent/profile';
import { IAgentToolRegistryService } from '#/agent/toolRegistry';
import { IAgentUsageService } from '#/agent/usage';
import { IAgentContextMemoryService } from '#/agent/contextMemory/contextMemory';
import { IAgentContextProjectorService } from '#/agent/contextProjector/contextProjector';
import { IAgentContextSizeService } from '#/agent/contextSize/contextSize';
import { IAgentProfileService } from '#/agent/profile/profile';
import { IAgentToolRegistryService } from '#/agent/toolRegistry/toolRegistry';
import { IAgentUsageService } from '#/agent/usage/usage';
import { IConfigService } from '#/app/config/config';
import { APIConnectionError, APIContextOverflowError, APIEmptyResponseError, APIStatusError, APITimeoutError, isContextOverflowStatusError, isRetryableGenerateError } from '#/app/llmProtocol/errors';
import { type Message } from '#/app/llmProtocol/message';
@ -42,7 +42,7 @@ import type {
LLMRequestPartHandler,
LLMRequestSource,
LLMStreamTiming,
} from './index';
} from './llmRequester';
import { IAgentLLMRequesterService } from './llmRequester';
import {
DEFAULT_MAX_RETRY_ATTEMPTS,

View file

@ -1,9 +0,0 @@
/**
* `loop` domain barrel re-exports the loop contracts and scoped
* service contract/implementation.
*/
import './configSection';
export * from './loop';
export * from './loopService';

View file

@ -11,9 +11,9 @@ import type {
TurnStepRetryingEvent,
TurnStepStartedEvent,
} from '@moonshot-ai/protocol';
import { IAgentLLMRequesterService, type LLMRequestFinish } from '#/agent/llmRequester';
import type { ToolResult } from '#/agent/tool';
import { IAgentToolExecutorService } from '#/agent/toolExecutor';
import { IAgentLLMRequesterService, type LLMRequestFinish } from '#/agent/llmRequester/llmRequester';
import type { ToolResult } from '#/agent/tool/toolContract';
import { IAgentToolExecutorService } from '#/agent/toolExecutor/toolExecutor';
import { IConfigService } from '#/app/config/config';
import { IEventBus } from '#/app/event/eventBus';
import { type FinishReason } from '#/app/llmProtocol/finishReason';
@ -22,7 +22,9 @@ import { type TokenUsage } from '#/app/llmProtocol/usage';
import { ErrorCodes, KimiError } from '#/errors';
import { OrderedHookSlot } from '#/hooks';
import { IAgentContextMemoryService, newMessageId, type ContextMessage } from '../contextMemory';
import { IAgentContextMemoryService } from '#/agent/contextMemory/contextMemory';
import { newMessageId } from '#/agent/contextMemory/messageId';
import { type ContextMessage } from '#/agent/contextMemory/types';
import { LOOP_CONTROL_SECTION, type LoopControl } from './configSection';
import {
createMaxStepsExceededError,

View file

@ -20,7 +20,7 @@ import { isRemoteMcpConfig } from './client-remote';
import { SseMcpClient } from './client-sse';
import type { UnexpectedCloseReason } from './client-shared';
import { StdioMcpClient } from './client-stdio';
import type { McpOAuthService } from '#/agent/mcp/oauth';
import type { McpOAuthService } from '#/agent/mcp/oauth/service';
import { assertMcpInputSchema, type MCPClient } from './types';
export type McpServerStatus = 'pending' | 'connected' | 'failed' | 'disabled' | 'needs-auth';

View file

@ -1,7 +0,0 @@
/**
* `mcp` domain barrel - re-exports the mcp service contract and implementation.
*/
export * from './mcp';
export * from './mcpService';
export * from './config-schema';

View file

@ -6,7 +6,7 @@ import type {
McpConnectionManager,
McpServerEntry,
} from './connection-manager';
import type { McpOAuthService } from '#/agent/mcp/oauth';
import type { McpOAuthService } from '#/agent/mcp/oauth/service';
import type { MCPClient } from './types';
export interface McpResolvedServer {

View file

@ -10,8 +10,8 @@ import type {
ToolListUpdatedEvent,
} from '@moonshot-ai/protocol';
import { IEventBus } from '#/app/event/eventBus';
import { IAgentToolExecutorService } from '#/agent/toolExecutor';
import { IAgentToolRegistryService } from '#/agent/toolRegistry';
import { IAgentToolExecutorService } from '#/agent/toolExecutor/toolExecutor';
import { IAgentToolRegistryService } from '#/agent/toolRegistry/toolRegistry';
import { createMcpAuthTool } from '#/agent/mcp/tools/auth';
import { createMcpTool } from '#/agent/mcp/tools/mcp';
import type { McpServerEntry } from './connection-manager';

View file

@ -1,4 +0,0 @@
export * from './callback-server';
export * from './provider';
export * from './service';
export * from './store';

View file

@ -1,7 +1,7 @@
const MCP_NAME_PREFIX = 'mcp__';
const MCP_NAME_SEPARATOR = '__';
export { isMcpToolName } from '#/agent/tool';
export { isMcpToolName } from '#/agent/tool/toolName';
/**
* Most LLM providers cap tool names around 64 characters. Leave headroom
* for the prefix and a separator and truncate longer names with a stable

View file

@ -30,13 +30,13 @@ import {
type ExecutableTool,
type ExecutableToolContext,
type ExecutableToolResult,
} from '#/agent/tool';
} from '#/agent/tool/toolContract';
import { toInputJsonSchema } from '#/_base/tools/support/input-schema';
import {
MCP_OAUTH_AUTHORIZATION_URL_TOOL_UPDATE,
type McpOAuthAuthorizationUrlUpdateData,
} from '@moonshot-ai/protocol';
import { AlreadyAuthorizedError, type McpOAuthService } from '#/agent/mcp/oauth';
import { AlreadyAuthorizedError, type McpOAuthService } from '#/agent/mcp/oauth/service';
import { qualifyMcpToolName } from '#/agent/mcp/tool-naming';
const DEFAULT_AUTH_TIMEOUT_MS = 15 * 60 * 1000; // 15 minutes

View file

@ -8,7 +8,7 @@
import type { Tool as KosongTool } from '#/app/llmProtocol/tool';
import type { ExecutableTool, ExecutableToolResult } from '#/agent/tool';
import type { ExecutableTool, ExecutableToolResult } from '#/agent/tool/toolContract';
import { mcpResultToExecutableOutput } from '#/agent/mcp/output';
import type { MCPClient } from '#/agent/mcp/types';

View file

@ -1,11 +0,0 @@
/**
* `media` domain built-in tools that read multi-modal file content.
*
* Currently only `ReadMediaFile`, plus the capability-gated
* `registerMediaTools` registrar and the `createVideoUploader` helper. The
* shared magic-byte detection lives in `#/_base/tools/support/file-type` so
* the future Read/Write/Edit tools can reuse it.
*/
export * from './registerMediaTools';
export * from '#/agent/media/tools/read-media';

View file

@ -20,7 +20,7 @@ import { toDisposable, type IDisposable } from '#/_base/di/lifecycle';
import type { WorkspaceConfig } from '#/_base/tools/support/workspace';
import type { IHostFileSystem } from '#/os/interface/hostFileSystem';
import type { IHostEnvironment } from '#/os/interface/hostEnvironment';
import type { IAgentToolRegistryService } from '#/agent/toolRegistry';
import type { IAgentToolRegistryService } from '#/agent/toolRegistry/toolRegistry';
import { ReadMediaFileTool, type VideoUploader } from '#/agent/media/tools/read-media';
export interface RegisterMediaToolsDeps {

View file

@ -34,8 +34,8 @@ import { z } from 'zod';
import { IHostFileSystem } from '#/os/interface/hostFileSystem';
import { IHostEnvironment } from '#/os/interface/hostEnvironment';
import { ToolAccesses } from '#/agent/tool';
import type { BuiltinTool, ExecutableToolResult, ToolExecution } from '#/agent/tool';
import { ToolAccesses } from '#/agent/tool/tool-access';
import type { BuiltinTool, ExecutableToolResult, ToolExecution } from '#/agent/tool/toolContract';
import { resolvePathAccessPath } from '#/_base/tools/policies/path-access';
import {
MEDIA_SNIFF_BYTES,

View file

@ -1,11 +0,0 @@
/**
* `microCompaction` domain barrel - re-exports the microCompaction config
* section, flag contribution, service contract, and scoped implementation.
*/
import './flag';
export * from './configSection';
export * from './microCompaction';
export * from './microCompactionOps';
export * from './flag';
export * from './microCompactionService';

View file

@ -6,7 +6,7 @@
*/
import { createDecorator } from "#/_base/di/instantiation";
import type { ContextMessage } from '#/agent/contextMemory';
import type { ContextMessage } from '#/agent/contextMemory/types';
export interface MicroCompactionConfig {
keepRecentMessages: number;

View file

@ -16,7 +16,8 @@
* context-clear paths. Consumed by the Agent-scope `microCompactionService`.
*/
import { defineModel, defineOp } from '#/wire';
import { defineModel } from '#/wire/model';
import { defineOp } from '#/wire/op';
export interface MicroCompactionState {
readonly cutoff: number;

View file

@ -27,14 +27,15 @@ import {
import type { TelemetryProperties } from '#/app/telemetry/telemetry';
import { IConfigService } from '#/app/config/config';
import { IEventBus } from '#/app/event/eventBus';
import { IAgentContextMemoryService } from '#/agent/contextMemory';
import { IAgentContextSizeService } from '#/agent/contextSize';
import { IAgentContextMemoryService } from '#/agent/contextMemory/contextMemory';
import { IAgentContextSizeService } from '#/agent/contextSize/contextSize';
import { IFlagService } from '#/app/flag/flag';
import { IAgentLoopService } from '#/agent/loop';
import { IAgentProfileService } from '#/agent/profile';
import { IAgentLoopService } from '#/agent/loop/loop';
import { IAgentProfileService } from '#/agent/profile/profile';
import { ITelemetryService } from '#/app/telemetry/telemetry';
import type { ContextMessage } from '#/agent/contextMemory';
import { IAgentWireService, type IWireService } from '#/wire';
import type { ContextMessage } from '#/agent/contextMemory/types';
import { IAgentWireService } from '#/wire/tokens';
import type { IWireService } from '#/wire/wireService';
import {
IAgentMicroCompactionService,
type MicroCompactionConfig,

View file

@ -1,8 +0,0 @@
/**
* `permissionGate` domain barrel - re-exports the permission gate contract
* (`permissionGate`) and its scoped service (`permissionGateService`). Importing
* this barrel registers the permission gate binding into the scope registry.
*/
export * from './permissionGate';
export * from './permissionGateService';

View file

@ -2,12 +2,12 @@ import type {
ApprovalRequest,
ApprovalResponse,
PermissionData,
} from '#/agent/permissionPolicy';
} from '#/agent/permissionPolicy/types';
import { createDecorator } from "#/_base/di/instantiation";
import type {
AuthorizeToolExecutionResult,
ResolvedToolExecutionHookContext,
} from '#/agent/tool';
} from '#/agent/tool/toolHooks';
import type { Hooks } from '#/hooks';
export type PermissionApprovalRequestContext = ApprovalRequest & {

View file

@ -1,25 +1,25 @@
import {
IAgentPermissionPolicyService,
type ApprovalResponse,
type PermissionData,
type PermissionPolicyResolution,
type PermissionPolicyResult,
} from '#/agent/permissionPolicy';
import { IAgentPermissionPolicyService } from '#/agent/permissionPolicy/permissionPolicy';
import type {
ApprovalResponse,
PermissionData,
PermissionPolicyResolution,
PermissionPolicyResult,
} from '#/agent/permissionPolicy/types';
import { IInstantiationService } from "#/_base/di/instantiation";
import { Disposable } from "#/_base/di/lifecycle";
import { abortable, isUserCancellation } from '#/_base/utils/abort';
import type {
AuthorizeToolExecutionResult,
ResolvedToolExecutionHookContext,
} from '#/agent/tool';
} from '#/agent/tool/toolHooks';
import type { ToolInputDisplay } from '@moonshot-ai/protocol';
import { ISessionApprovalService } from "#/session/approval/approval";
import { IAgentPermissionModeService } from '#/agent/permissionMode';
import { IAgentPermissionRulesService } from '#/agent/permissionRules';
import { IAgentPermissionModeService } from '#/agent/permissionMode/permissionMode';
import { IAgentPermissionRulesService } from '#/agent/permissionRules/permissionRules';
import { ISessionContext } from '#/session/sessionContext/sessionContext';
import { ITelemetryService } from '#/app/telemetry/telemetry';
import { IAgentToolExecutorService } from '#/agent/toolExecutor';
import { IAgentScopeContext } from '#/agent/scopeContext';
import { IAgentToolExecutorService } from '#/agent/toolExecutor/toolExecutor';
import { IAgentScopeContext } from '#/agent/scopeContext/scopeContext';
import {
IAgentPermissionGate,
type PermissionApprovalRequestContext,

View file

@ -1,6 +0,0 @@
/**
* `permissionMode` domain barrel - re-exports the permissionMode service contract and implementation.
*/
export * from './permissionMode';
export * from './permissionModeService';

View file

@ -1,4 +1,4 @@
import type { PermissionMode } from '#/agent/permissionPolicy';
import type { PermissionMode } from '#/agent/permissionPolicy/types';
import type { IDisposable } from "#/_base/di/lifecycle";
import type { IAgentContextInjectorService } from '#/agent/contextInjector/contextInjector';
import type { IAgentPermissionModeService } from '#/agent/permissionMode/permissionMode';

View file

@ -1,4 +1,4 @@
import type { PermissionMode } from '#/agent/permissionPolicy';
import type { PermissionMode } from '#/agent/permissionPolicy/types';
import { createDecorator } from "#/_base/di/instantiation";
import type { Hooks } from '#/hooks';

View file

@ -9,8 +9,9 @@
* type). Consumed by the Agent-scope `permissionModeService`.
*/
import type { PermissionMode } from '#/agent/permissionPolicy';
import { defineModel, defineOp } from '#/wire';
import type { PermissionMode } from '#/agent/permissionPolicy/types';
import { defineModel } from '#/wire/model';
import { defineOp } from '#/wire/op';
export const PermissionModeModel = defineModel<PermissionMode>('permissionMode', () => 'manual');

View file

@ -9,14 +9,15 @@
* `contextInjector`. Bound at Agent scope.
*/
import type { PermissionMode } from '#/agent/permissionPolicy';
import type { PermissionMode } from '#/agent/permissionPolicy/types';
import { Disposable } from '#/_base/di/lifecycle';
import { InstantiationType } from '#/_base/di/extensions';
import { LifecycleScope, registerScopedService } from '#/_base/di/scope';
import { IAgentContextInjectorService } from '#/agent/contextInjector';
import { IAgentContextInjectorService } from '#/agent/contextInjector/contextInjector';
import { OrderedHookSlot } from '#/hooks';
import { registerPermissionModeInjection } from '#/agent/permissionMode/injection/permissionModeInjection';
import { IAgentWireService, type IWireService } from '#/wire';
import { IAgentWireService } from '#/wire/tokens';
import type { IWireService } from '#/wire/wireService';
import { IAgentPermissionModeService } from './permissionMode';
import { PermissionModeModel, setMode } from './permissionModeOps';

View file

@ -1,8 +0,0 @@
/**
* `permissionPolicy` domain barrel - re-exports the permissionPolicy service contract and implementation.
*/
export * from './permissionPolicy';
export * from './permissionPolicyService';
export * from './types';
export * from '#/agent/permissionPolicy/policies/deny-all';

View file

@ -2,7 +2,7 @@ import { createDecorator } from "#/_base/di/instantiation";
import { type IDisposable } from "#/_base/di/lifecycle";
import type {
ResolvedToolExecutionHookContext
} from '#/agent/tool';
} from '#/agent/tool/toolHooks';
import type { PermissionPolicy, PermissionPolicyResult } from './types';

View file

@ -1,6 +1,6 @@
import { IInstantiationService } from "#/_base/di/instantiation";
import { Disposable, type IDisposable } from "#/_base/di/lifecycle";
import type { ResolvedToolExecutionHookContext } from '#/agent/tool';
import type { ResolvedToolExecutionHookContext } from '#/agent/tool/toolHooks';
import { AgentSwarmExclusiveDenyPermissionPolicyService } from '#/agent/permissionPolicy/policies/agent-swarm-exclusive-deny';
import { AutoModeApprovePermissionPolicyService } from '#/agent/permissionPolicy/policies/auto-mode-approve';
import { AutoModeAskUserQuestionDenyPermissionPolicyService } from '#/agent/permissionPolicy/policies/auto-mode-ask-user-question-deny';

View file

@ -1,4 +1,4 @@
import type { ResolvedToolExecutionHookContext } from '#/agent/tool';
import type { ResolvedToolExecutionHookContext } from '#/agent/tool/toolHooks';
import type {
PermissionPolicy,
PermissionPolicyResult,

View file

@ -1,4 +1,4 @@
import type { ResolvedToolExecutionHookContext } from '#/agent/tool';
import type { ResolvedToolExecutionHookContext } from '#/agent/tool/toolHooks';
import { IAgentPermissionModeService } from '#/agent/permissionMode/permissionMode';
import type {
PermissionPolicy,

View file

@ -1,4 +1,4 @@
import type { ResolvedToolExecutionHookContext } from '#/agent/tool';
import type { ResolvedToolExecutionHookContext } from '#/agent/tool/toolHooks';
import type {
PermissionPolicy,
PermissionPolicyResult,

View file

@ -1,6 +1,5 @@
import { IAgentPlanService } from '#/agent/plan';
import type { IAgentPlanService as AgentPlanService } from '#/agent/plan';
import type { ResolvedToolExecutionHookContext } from '#/agent/tool';
import { IAgentPlanService, type IAgentPlanService as AgentPlanService } from '#/agent/plan/plan';
import type { ResolvedToolExecutionHookContext } from '#/agent/tool/toolHooks';
import { IAgentPermissionModeService } from '#/agent/permissionMode/permissionMode';
import { ITelemetryService } from '#/app/telemetry/telemetry';
import type {

View file

@ -1,4 +1,4 @@
import type { ResolvedToolExecutionHookContext } from '#/agent/tool';
import type { ResolvedToolExecutionHookContext } from '#/agent/tool/toolHooks';
import { IHostEnvironment } from '#/os/interface/hostEnvironment';
import type { IHostEnvironment as HostEnvironment } from '#/os/interface/hostEnvironment';
import { ISessionWorkspaceContext } from '#/session/workspaceContext/workspaceContext';

View file

@ -1,4 +1,4 @@
import type { ResolvedToolExecutionHookContext } from '#/agent/tool';
import type { ResolvedToolExecutionHookContext } from '#/agent/tool/toolHooks';
import { isWithinWorkspace } from '#/_base/tools/policies/path-access';
import { IHostEnvironment } from '#/os/interface/hostEnvironment';
import type { IHostEnvironment as HostEnvironment } from '#/os/interface/hostEnvironment';

View file

@ -1,4 +1,4 @@
import type { ResolvedToolExecutionHookContext } from '#/agent/tool';
import type { ResolvedToolExecutionHookContext } from '#/agent/tool/toolHooks';
import { IAgentPermissionModeService } from '#/agent/permissionMode/permissionMode';
import type {
PermissionPolicy,

View file

@ -3,8 +3,8 @@ import * as nodePath from 'node:path';
import * as posixPath from 'node:path/posix';
import * as win32Path from 'node:path/win32';
import type { ToolFileAccess } from '#/agent/tool';
import type { ResolvedToolExecutionHookContext } from '#/agent/tool';
import type { ToolFileAccess } from '#/agent/tool/tool-access';
import type { ResolvedToolExecutionHookContext } from '#/agent/tool/toolHooks';
import {
isWithinDirectory,
type PathClass,

View file

@ -1,6 +1,5 @@
import { IAgentPlanService } from '#/agent/plan';
import type { IAgentPlanService as AgentPlanService } from '#/agent/plan';
import type { ResolvedToolExecutionHookContext } from '#/agent/tool';
import { IAgentPlanService, type IAgentPlanService as AgentPlanService } from '#/agent/plan/plan';
import type { ResolvedToolExecutionHookContext } from '#/agent/tool/toolHooks';
import type {
PermissionPolicy,
PermissionPolicyResult,

View file

@ -1,6 +1,5 @@
import { IAgentPlanService } from '#/agent/plan';
import type { IAgentPlanService as AgentPlanService } from '#/agent/plan';
import type { ResolvedToolExecutionHookContext } from '#/agent/tool';
import { IAgentPlanService, type IAgentPlanService as AgentPlanService } from '#/agent/plan/plan';
import type { ResolvedToolExecutionHookContext } from '#/agent/tool/toolHooks';
import type {
PermissionPolicy,
PermissionPolicyResult,

View file

@ -1,4 +1,4 @@
import type { ResolvedToolExecutionHookContext } from '#/agent/tool';
import type { ResolvedToolExecutionHookContext } from '#/agent/tool/toolHooks';
import { isSensitiveFile } from '#/_base/tools/policies/sensitive';
import type {
PermissionPolicy,

View file

@ -1,5 +1,5 @@
import type { ResolvedToolExecutionHookContext } from '#/agent/tool';
import { matchPermissionRule } from '#/agent/permissionRules';
import type { ResolvedToolExecutionHookContext } from '#/agent/tool/toolHooks';
import { matchPermissionRule } from '#/agent/permissionRules/matchesRule';
import { IAgentPermissionRulesService } from '#/agent/permissionRules/permissionRules';
import type {
PermissionPolicy,

View file

@ -1,6 +1,6 @@
import { IAgentSwarmService } from '#/agent/swarm';
import type { IAgentSwarmService as AgentSwarmService } from '#/agent/swarm';
import type { ResolvedToolExecutionHookContext } from '#/agent/tool';
import { IAgentSwarmService } from '#/agent/swarm/swarm';
import type { IAgentSwarmService as AgentSwarmService } from '#/agent/swarm/swarm';
import type { ResolvedToolExecutionHookContext } from '#/agent/tool/toolHooks';
import type {
PermissionPolicy,
PermissionPolicyResult,

View file

@ -1,4 +1,4 @@
import type { ResolvedToolExecutionHookContext } from '#/agent/tool';
import type { ResolvedToolExecutionHookContext } from '#/agent/tool/toolHooks';
import { IAgentPermissionRulesService } from '#/agent/permissionRules/permissionRules';
import type {
PermissionPolicy,

View file

@ -1,4 +1,4 @@
import type { ResolvedToolExecutionHookContext } from '#/agent/tool';
import type { ResolvedToolExecutionHookContext } from '#/agent/tool/toolHooks';
import { IAgentPermissionRulesService } from '#/agent/permissionRules/permissionRules';
import type {
PermissionPolicy,

View file

@ -1,4 +1,4 @@
import type { ResolvedToolExecutionHookContext } from '#/agent/tool';
import type { ResolvedToolExecutionHookContext } from '#/agent/tool/toolHooks';
import { IAgentPermissionRulesService } from '#/agent/permissionRules/permissionRules';
import type {
PermissionPolicy,

View file

@ -2,12 +2,12 @@ import type {
PermissionRule,
PermissionRuleDecision,
PermissionRuleScope,
} from '#/agent/permissionRules';
} from '#/agent/permissionRules/permissionRules';
import {
matchPermissionRule,
type PermissionRuleMatch,
} from '#/agent/permissionRules';
import type { ResolvedToolExecutionHookContext } from '#/agent/tool';
} from '#/agent/permissionRules/matchesRule';
import type { ResolvedToolExecutionHookContext } from '#/agent/tool/toolHooks';
import type { IAgentPermissionRulesService } from '#/agent/permissionRules/permissionRules';
import type { PermissionPolicyResult } from '#/agent/permissionPolicy/types';

View file

@ -1,6 +1,6 @@
import type { PrepareToolExecutionResult, ResolvedToolExecutionHookContext } from '#/agent/tool';
import type { PrepareToolExecutionResult, ResolvedToolExecutionHookContext } from '#/agent/tool/toolHooks';
import type { ToolInputDisplay } from '@moonshot-ai/protocol';
import type { PermissionRule } from '#/agent/permissionRules';
import type { PermissionRule } from '#/agent/permissionRules/permissionRules';
/**
* Top-level user-facing permission posture. Controls how non-deny rules

View file

@ -1,9 +0,0 @@
/**
* `permissionRules` domain barrel - re-exports the permissionRules service contract and implementation.
*/
import './configSection';
export * from './permissionRules';
export * from './matchesRule';
export * from './permissionRulesService';

View file

@ -1,6 +1,6 @@
import picomatch from 'picomatch';
import type { RunnableToolExecution } from '#/agent/tool';
import type { RunnableToolExecution } from '#/agent/tool/toolContract';
import type { PermissionRule } from './permissionRules';
/**

View file

@ -16,7 +16,8 @@
* the Agent-scope `permissionRulesService`.
*/
import { defineModel, defineOp } from '#/wire';
import { defineModel } from '#/wire/model';
import { defineOp } from '#/wire/op';
import type { PermissionApprovalResultRecord, PermissionRule } from './permissionRules';

View file

@ -16,7 +16,8 @@ import { InstantiationType } from '#/_base/di/extensions';
import { LifecycleScope, registerScopedService } from '#/_base/di/scope';
import { OrderedHookSlot } from '#/hooks';
import { IAgentWireService, type IWireService } from '#/wire';
import { IAgentWireService } from '#/wire/tokens';
import type { IWireService } from '#/wire/wireService';
import {
IAgentPermissionRulesService,
type PermissionApprovalResultRecord,

View file

@ -1,15 +0,0 @@
/**
* `plan` domain barrel re-exports the plan contract (`plan`) and its scoped
* service (`planService`), plus side-effect imports of the plan profile and each
* plan tool so their contribution calls run at module load. Importing this barrel
* wires `IAgentPlanService` into the scope registry, registers the `plan` agent
* profile, and adds `EnterPlanMode` / `ExitPlanMode` to the tool contribution list.
*/
import './profile';
import './tools/enter-plan-mode';
import './tools/exit-plan-mode';
export * from './plan';
export * from './planOps';
export * from './planService';

View file

@ -18,7 +18,8 @@
* Consumed by the Agent-scope `planService`.
*/
import { defineModel, defineOp } from '#/wire';
import { defineModel } from '#/wire/model';
import { defineOp } from '#/wire/op';
export interface PlanState {
readonly active: boolean;

View file

@ -10,15 +10,17 @@ import {
import { Disposable } from "#/_base/di/lifecycle";
import { generateHeroSlug } from "#/_base/utils/hero-slug";
import { IAgentContextMemoryService, type ContextMessage } from '#/agent/contextMemory';
import { IAgentContextInjectorService } from '#/agent/contextInjector';
import { IAgentContextMemoryService } from '#/agent/contextMemory/contextMemory';
import type { ContextMessage } from '#/agent/contextMemory/types';
import { IAgentContextInjectorService } from '#/agent/contextInjector/contextInjector';
import { IHostFileSystem } from '#/os/interface/hostFileSystem';
import { IAgentProfileService } from '#/agent/profile';
import { IAgentProfileService } from '#/agent/profile/profile';
import { IAgentTelemetryContextService } from '#/app/telemetry/agentTelemetryContext';
import { ITelemetryService } from '#/app/telemetry/telemetry';
import { IAgentWireService, type IWireService } from '#/wire';
import { IAgentWireService } from '#/wire/tokens';
import type { IWireService } from '#/wire/wireService';
import type { ToolInputDisplay } from '@moonshot-ai/protocol';
import type { ExecutableToolResult } from '#/agent/tool';
import type { ExecutableToolResult } from '#/agent/tool/toolContract';
import { type ExitPlanModeInput } from '#/agent/plan/tools/exit-plan-mode';
import {
IAgentPlanService,

View file

@ -1,9 +0,0 @@
/**
* `plan` domain (L4) builtin profile contribution barrel.
*
* Side-effect import: pulling this file triggers the `registerAgentProfile`
* call in `./plan.ts`, populating the module-level catalog before
* `AgentProfileCatalogService` is instantiated.
*/
import './plan';

View file

@ -7,9 +7,8 @@
import { z } from 'zod';
import type { BuiltinTool } from '#/agent/tool';
import type { ToolExecution } from '#/agent/tool';
import { registerTool } from '#/agent/toolRegistry';
import type { BuiltinTool, ToolExecution } from '#/agent/tool/toolContract';
import { registerTool } from '#/agent/toolRegistry/toolContribution';
import { toInputJsonSchema } from '#/_base/tools/support/input-schema';
import { ITelemetryService } from '#/app/telemetry/telemetry';
import { IAgentPlanService } from '#/agent/plan/plan';

View file

@ -9,9 +9,8 @@
import type { ToolInputDisplay } from '@moonshot-ai/protocol';
import { z } from 'zod';
import type { BuiltinTool } from '#/agent/tool';
import type { ExecutableToolResult, ToolExecution } from '#/agent/tool';
import { registerTool } from '#/agent/toolRegistry';
import type { BuiltinTool, ExecutableToolResult, ToolExecution } from '#/agent/tool/toolContract';
import { registerTool } from '#/agent/toolRegistry/toolContribution';
import { toInputJsonSchema } from '#/_base/tools/support/input-schema';
import { ITelemetryService } from '#/app/telemetry/telemetry';
import { IAgentPlanService } from '#/agent/plan/plan';

View file

@ -1,9 +0,0 @@
/**
* `profile` domain barrel - re-exports the profile service contract and implementation.
*/
import './configSection';
export * from './profile';
export * from './profileService';
export * from './context';

View file

@ -4,7 +4,7 @@ import type { ThinkingEffort } from '#/app/llmProtocol/thinkingEffort';
import type { Model } from '#/app/model/modelInstance';
import { createDecorator } from "#/_base/di/instantiation";
import type { ToolSource } from '#/agent/tool';
import type { ToolSource } from '#/agent/tool/toolContract';
/**
* Data required to configure an agent: active model id, its capability

View file

@ -27,7 +27,8 @@
*/
import type { ThinkingEffort } from '#/app/llmProtocol/thinkingEffort';
import { defineModel, defineOp } from '#/wire';
import { defineModel } from '#/wire/model';
import { defineOp } from '#/wire/op';
export interface ProfileModelState {
readonly cwd?: string;

View file

@ -40,15 +40,16 @@ import type { LoopControl } from '#/agent/loop/configSection';
import { IHostEnvironment } from '#/os/interface/hostEnvironment';
import { IHostFileSystem } from '#/os/interface/hostFileSystem';
import { ISessionContext } from '#/session/sessionContext/sessionContext';
import { isMcpToolName } from '#/agent/tool';
import { isMcpToolName } from '#/agent/tool/toolName';
import { ISessionWorkspaceContext } from '#/session/workspaceContext/workspaceContext';
import { ISessionSkillCatalog } from '#/session/sessionSkillCatalog/skillCatalog';
import type { ResolvedAgentProfile, SystemPromptContext } from '#/agent/profile';
import type { ResolvedAgentProfile, SystemPromptContext } from '#/agent/profile/profile';
import type { WarningEvent } from '@moonshot-ai/protocol';
import { ITelemetryService } from '#/app/telemetry/telemetry';
import type { ToolSource } from '#/agent/tool';
import { IAgentWireService, type IWireService } from '#/wire';
import type { ToolSource } from '#/agent/tool/toolContract';
import { IAgentWireService } from '#/wire/tokens';
import type { IWireService } from '#/wire/wireService';
import { IEventBus } from '#/app/event/eventBus';
import { prepareSystemPromptContext } from './context';
import type {
@ -75,7 +76,7 @@ import {
type ProfileModelState,
} from './profileOps';
declare module '#/agent/wireRecord' {
declare module '#/agent/wireRecord/wireRecord' {
interface WireRecordMap {
'tools.set_active_tools': {
names: readonly string[];

View file

@ -1,6 +0,0 @@
/**
* `prompt` domain barrel - re-exports the prompt service contract and implementation.
*/
export * from './prompt';
export * from './promptService';

View file

@ -1,6 +1,6 @@
import { createDecorator } from "#/_base/di/instantiation";
import type { ContextMessage } from "#/agent/contextMemory";
import type { Turn } from "#/agent/turn";
import type { ContextMessage } from "#/agent/contextMemory/types";
import type { Turn } from "#/agent/turn/turn";
import type { Hooks } from '#/hooks';
export interface PromptSubmitContext {

Some files were not shown because too many files have changed in this diff Show more