mirror of
https://github.com/MoonshotAI/kimi-code.git
synced 2026-08-11 09:47:40 +00:00
chore: remove IMessageService
This commit is contained in:
parent
b21d8820d1
commit
1e031182f9
3 changed files with 0 additions and 68 deletions
|
|
@ -1,8 +0,0 @@
|
|||
/**
|
||||
* `message` domain barrel — re-exports the message contract (`message`) and
|
||||
* its scoped service (`messageService`). Importing this barrel registers the
|
||||
* `IMessageService` binding into the scope registry.
|
||||
*/
|
||||
|
||||
export * from './message';
|
||||
export * from './messageService';
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
/**
|
||||
* `message` domain (L4) — protocol message projection over context.
|
||||
*
|
||||
* Defines the public contract for messages: the `ProtocolMessage` model and the
|
||||
* `IMessageService` used to list and look up projected protocol messages.
|
||||
* Agent-scoped — one instance per agent.
|
||||
*/
|
||||
|
||||
import { createDecorator, type ServiceIdentifier } from '#/_base/di/instantiation';
|
||||
|
||||
export interface ProtocolMessage {
|
||||
readonly id: string;
|
||||
readonly role: string;
|
||||
readonly content: unknown;
|
||||
}
|
||||
|
||||
export interface IMessageService {
|
||||
readonly _serviceBrand: undefined;
|
||||
list(): readonly ProtocolMessage[];
|
||||
get(id: string): ProtocolMessage | undefined;
|
||||
}
|
||||
|
||||
export const IMessageService: ServiceIdentifier<IMessageService> =
|
||||
createDecorator<IMessageService>('messageService');
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
/**
|
||||
* `message` domain (L4) — `IMessageService` implementation.
|
||||
*
|
||||
* Projects context history into protocol messages; reads history through
|
||||
* `context`. Bound at Agent scope.
|
||||
*/
|
||||
|
||||
import { InstantiationType } from '#/_base/di/extensions';
|
||||
import { LifecycleScope, registerScopedService } from '#/_base/di/scope';
|
||||
import { IContextService } from '#/context';
|
||||
|
||||
import { type ProtocolMessage, IMessageService } from './message';
|
||||
|
||||
function deriveId(index: number): string {
|
||||
return `msg-${index}`;
|
||||
}
|
||||
|
||||
export class MessageService implements IMessageService {
|
||||
declare readonly _serviceBrand: undefined;
|
||||
|
||||
constructor(@IContextService private readonly context: IContextService) {}
|
||||
|
||||
list(): readonly ProtocolMessage[] {
|
||||
return this.context.project().map((m, i) => ({
|
||||
id: deriveId(i),
|
||||
role: m.role,
|
||||
content: m.content,
|
||||
}));
|
||||
}
|
||||
|
||||
get(id: string): ProtocolMessage | undefined {
|
||||
return this.list().find((m) => m.id === id);
|
||||
}
|
||||
}
|
||||
|
||||
registerScopedService(LifecycleScope.Agent, IMessageService, MessageService, InstantiationType.Delayed, 'message');
|
||||
Loading…
Add table
Add a link
Reference in a new issue