File size: 984 Bytes
68d7816
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { createDecorator } from '#/_base/di/instantiation';
import { Service } from '#/_base/di/service';
import { LifecycleScope } from '#/app/scopes';
import { ScopeActivation, registerScopedService } from '#/_base/di/scope';

import { AgentToolContribution, getAgentToolContributions } from './toolContribution';

export interface IBuiltinToolAssemblyService {
  readonly _serviceBrand: undefined;
}

export const IBuiltinToolAssemblyService = createDecorator<IBuiltinToolAssemblyService>(
  'builtinToolAssemblyService',
);

export class BuiltinToolAssemblyService extends Service implements IBuiltinToolAssemblyService {
  declare readonly _serviceBrand: undefined;

  constructor() {
    super();
    for (const record of getAgentToolContributions()) {
      this.provide(AgentToolContribution, record);
    }
  }
}

registerScopedService(
  LifecycleScope.App,
  IBuiltinToolAssemblyService,
  BuiltinToolAssemblyService,
  ScopeActivation.OnScopeCreated,
  'toolRegistry',
);