Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions packages/agent-core-v2/src/features/btw/btwFeature.ts
Original file line number Diff line number Diff line change
@@ -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);
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -50,11 +48,3 @@ export class SessionBtwService implements ISessionBtwService {
return child.id;
}
}

registerScopedService(
LifecycleScope.Session,
ISessionBtwService,
SessionBtwService,
ScopeActivation.OnScopeCreated,
'session-btw',
);
5 changes: 3 additions & 2 deletions packages/agent-core-v2/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
Loading