MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / registerSingleton

Function registerSingleton

packages/agent-core/src/di/extensions.ts:56–74  ·  view source on GitHub ↗
(
  id: ServiceIdentifier<T>,
  ctorOrDescriptor:
    | SyncDescriptor<any>
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    | (new (...services: Services) => T),
  instantiationType?: boolean | InstantiationType,
)

Source from the content-addressed store, hash-verified

54 descriptor: SyncDescriptor<any>,
55): void;
56export function registerSingleton<T, Services extends BrandedService[]>(
57 id: ServiceIdentifier<T>,
58 ctorOrDescriptor:
59 | SyncDescriptor<any>
60 // eslint-disable-next-line @typescript-eslint/no-explicit-any
61 | (new (...services: Services) => T),
62 instantiationType?: boolean | InstantiationType,
63): void {
64 const descriptor =
65 ctorOrDescriptor instanceof SyncDescriptor
66 ? ctorOrDescriptor
67 : new SyncDescriptor<T>(
68 ctorOrDescriptor as new (...args: unknown[]) => T,
69 [],
70 Boolean(instantiationType),
71 );
72
73 _registry.push([id, descriptor]);
74}
75
76/**
77 * Return the registry as a list suitable for `ServiceCollection`

Callers 15

extensions.test.tsFile · 0.90
promptService.tsFile · 0.90
taskService.tsFile · 0.90
terminalService.tsFile · 0.90
oauthService.tsFile · 0.90
skillService.tsFile · 0.90
sessionService.tsFile · 0.90

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected