mirror of
https://github.com/MoonshotAI/kimi-code.git
synced 2026-08-10 17:29:18 +00:00
refactor(agent-core-v2): extract btw into a features/btw Feature unit (#2724)
Some checks are pending
CI / build (push) Waiting to run
CI / test (1) (push) Waiting to run
CI / test (2) (push) Waiting to run
CI / test (3) (push) Waiting to run
CI / test (4) (push) Waiting to run
CI / test (5) (push) Waiting to run
Release / Publish native release assets (push) Blocked by required conditions
CI / test-pi-tui (push) Waiting to run
CI / test-windows (push) Waiting to run
CI / lint (push) Waiting to run
CI / typecheck (push) Waiting to run
Nix Build / Check flake.nix workspace sync (push) Waiting to run
Nix Build / nix build .#kimi-code (push) Blocked by required conditions
Release / Release (push) Waiting to run
Release / Deploy docs (push) Blocked by required conditions
Release / Native release artifact (push) Blocked by required conditions
Some checks are pending
CI / build (push) Waiting to run
CI / test (1) (push) Waiting to run
CI / test (2) (push) Waiting to run
CI / test (3) (push) Waiting to run
CI / test (4) (push) Waiting to run
CI / test (5) (push) Waiting to run
Release / Publish native release assets (push) Blocked by required conditions
CI / test-pi-tui (push) Waiting to run
CI / test-windows (push) Waiting to run
CI / lint (push) Waiting to run
CI / typecheck (push) Waiting to run
Nix Build / Check flake.nix workspace sync (push) Waiting to run
Nix Build / nix build .#kimi-code (push) Blocked by required conditions
Release / Release (push) Waiting to run
Release / Deploy docs (push) Blocked by required conditions
Release / Native release artifact (push) Blocked by required conditions
- move session/btw to features/btw, mirroring the plan feature layout - contribute ISessionBtwService at Session scope through BtwFeature (contributeService) instead of a static registerScopedService call - keep the package root exports unchanged; move the test to test/features/btw
This commit is contained in:
parent
01c74e9372
commit
0401ec4286
5 changed files with 39 additions and 22 deletions
26
packages/agent-core-v2/src/features/btw/btwFeature.ts
Normal file
26
packages/agent-core-v2/src/features/btw/btwFeature.ts
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/**
|
||||
* `btw` domain — `BtwFeature`: the side-question ("by the way") capability
|
||||
* assembled as one App-scope Feature unit.
|
||||
*
|
||||
* Contributes the per-Session `ISessionBtwService` through the `features`
|
||||
* base-class seams; retracting the unit withdraws it across the scope tree.
|
||||
* Registered into the feature table at import.
|
||||
*/
|
||||
|
||||
import { LifecycleScope } from '#/app/scopes';
|
||||
import { Feature } from '#/features/feature';
|
||||
import { registerFeature } from '#/features/featureRegistry';
|
||||
|
||||
import { ISessionBtwService } from './btw';
|
||||
import { SessionBtwService } from './btwService';
|
||||
|
||||
export class BtwFeature extends Feature {
|
||||
static override readonly name = 'btw';
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.contributeService(LifecycleScope.Session, ISessionBtwService, SessionBtwService);
|
||||
}
|
||||
}
|
||||
|
||||
registerFeature(BtwFeature);
|
||||
|
|
@ -5,16 +5,14 @@
|
|||
* `IAgentLifecycleService.fork`, then disables tool calls via an
|
||||
* `onBeforeExecuteTool` veto listener (blocks every tool call with the
|
||||
* `toolApproval.formatDenyMessage`-formatted TOOL_CALL_DISABLED_MESSAGE) and
|
||||
* appends the side-channel system reminder. Bound at Session scope —
|
||||
* `fork('main')` is a session-level operation, so the service injects the
|
||||
* session's `IAgentLifecycleService` directly rather than resolving it through
|
||||
* the main agent's accessor. Callers materialize the main agent first;
|
||||
* forking a missing source throws.
|
||||
* appends the side-channel system reminder. Contributed at Session scope by
|
||||
* `BtwFeature` (`features/btw/btwFeature`) — `fork('main')` is a
|
||||
* session-level operation, so the service injects the session's
|
||||
* `IAgentLifecycleService` directly rather than resolving it through the main
|
||||
* agent's accessor. Callers materialize the main agent first; forking a
|
||||
* missing source throws.
|
||||
*/
|
||||
|
||||
import { LifecycleScope } from '#/app/scopes';
|
||||
|
||||
import { ScopeActivation, registerScopedService } from '#/_base/di/scope';
|
||||
import { IAgentSystemReminderService } from '#/agent/systemReminder/systemReminder';
|
||||
import { IAgentToolApprovalService } from '#/agent/toolApproval/toolApproval';
|
||||
import { denyToolExecution } from '#/agent/toolExecutor/beforeToolExecuteEvent';
|
||||
|
|
@ -50,11 +48,3 @@ export class SessionBtwService implements ISessionBtwService {
|
|||
return child.id;
|
||||
}
|
||||
}
|
||||
|
||||
registerScopedService(
|
||||
LifecycleScope.Session,
|
||||
ISessionBtwService,
|
||||
SessionBtwService,
|
||||
ScopeActivation.OnScopeCreated,
|
||||
'session-btw',
|
||||
);
|
||||
|
|
@ -289,6 +289,9 @@ export * from '#/app/flag/flagService';
|
|||
|
||||
export * from '#/agent/activityView/activityView';
|
||||
import '#/agent/activityView/activityViewService';
|
||||
export * from '#/features/btw/btw';
|
||||
export * from '#/features/btw/btwService';
|
||||
import '#/features/btw/btwFeature';
|
||||
import '#/features/plan/profile/plan';
|
||||
export * from '#/features/plan/tools/enter-plan-mode/enter-plan-mode';
|
||||
import '#/features/plan/tools/enter-plan-mode/enterPlanModeTool';
|
||||
|
|
@ -625,8 +628,6 @@ export * from '#/agent/rpc/prompt-metadata';
|
|||
export * from '#/agent/scopeContext/scopeContext';
|
||||
export * from '#/agent/stepRetry/stepRetry';
|
||||
export * from '#/agent/stepRetry/stepRetryService';
|
||||
export * from '#/session/btw/btw';
|
||||
export * from '#/session/btw/btwService';
|
||||
export * from '#/session/sessionInit/sessionInit';
|
||||
export * from '#/session/sessionInit/sessionInitService';
|
||||
export * from '#/session/sessionInit/profile/init';
|
||||
|
|
|
|||
|
|
@ -6,14 +6,14 @@ import { TestInstantiationService } from '#/_base/di/test';
|
|||
import { IAgentSystemReminderService } from '#/agent/systemReminder/systemReminder';
|
||||
import { IAgentToolApprovalService } from '#/agent/toolApproval/toolApproval';
|
||||
import { IAgentToolExecutorService } from '#/agent/toolExecutor/toolExecutor';
|
||||
import type { ToolCall } from '#/kosong/contract/message';
|
||||
import { IAgentLifecycleService } from '#/session/agentLifecycle/agentLifecycle';
|
||||
import {
|
||||
ISessionBtwService,
|
||||
SIDE_QUESTION_SYSTEM_REMINDER,
|
||||
TOOL_CALL_DISABLED_MESSAGE,
|
||||
} from '#/session/btw/btw';
|
||||
import { SessionBtwService } from '#/session/btw/btwService';
|
||||
} from '#/features/btw/btw';
|
||||
import { SessionBtwService } from '#/features/btw/btwService';
|
||||
import type { ToolCall } from '#/kosong/contract/message';
|
||||
import { IAgentLifecycleService } from '#/session/agentLifecycle/agentLifecycle';
|
||||
|
||||
import { stubToolExecutorEvents, type ToolExecutorEventStubs } from '../../agent/toolExecutor/stubs';
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue