Download packages/agent-core-v2/src/app/agentIdentity/agentIdentityService.ts from SaylorTwift/kimi-code: direct link, hf CLI and curl.
- Browser
- Download file 1.78 kB
-
https://huggingface.co/SaylorTwift/kimi-code/resolve/main/packages/agent-core-v2/src/app/agentIdentity/agentIdentityService.ts
- Command line
-
hf download hf://SaylorTwift/kimi-code/packages/agent-core-v2/src/app/agentIdentity/agentIdentityService.ts
-
curl -L -o agentIdentityService.ts https://huggingface.co/SaylorTwift/kimi-code/resolve/main/packages/agent-core-v2/src/app/agentIdentity/agentIdentityService.ts
1.78 kB
| import { LifecycleScope } from '#/app/scopes'; | |
| import { ScopeActivation, registerScopedService } from '#/_base/di/scope'; | |
| import { CoreErrors } from '#/_base/errors/codes'; | |
| import { Error2 } from '#/_base/errors/errors'; | |
| import { IBootstrapService } from '#/app/bootstrap/bootstrap'; | |
| import { IConfigService } from '#/app/config/config'; | |
| import { | |
| buildAgentIdentitySnapshot, | |
| IAgentIdentity, | |
| type AgentIdentitySnapshot, | |
| } from './agentIdentity'; | |
| import { IDENTITY_SECTION, type IdentityConfig } from './configSection'; | |
| export class AgentIdentityService implements IAgentIdentity { | |
| declare readonly _serviceBrand: undefined; | |
| private snapshot: AgentIdentitySnapshot | undefined; | |
| private readonly frozen: Promise<AgentIdentitySnapshot>; | |
| constructor( | |
| config: IConfigService, | |
| bootstrap: IBootstrapService, | |
| ) { | |
| this.frozen = config.ready | |
| .catch(() => undefined) | |
| .then(() => { | |
| const section = config.get<IdentityConfig | undefined>(IDENTITY_SECTION) ?? {}; | |
| this.snapshot = buildAgentIdentitySnapshot({ | |
| name: section.name, | |
| slug: section.slug, | |
| hostDisplayName: bootstrap.args.displayName, | |
| hostRequestHeaders: bootstrap.args.requestHeaders, | |
| }); | |
| return this.snapshot; | |
| }); | |
| } | |
| resolved(): Promise<AgentIdentitySnapshot> { | |
| return this.frozen; | |
| } | |
| current(): AgentIdentitySnapshot { | |
| if (this.snapshot === undefined) { | |
| throw new Error2( | |
| CoreErrors.codes.INTERNAL, | |
| 'agent identity read before config load completed', | |
| ); | |
| } | |
| return this.snapshot; | |
| } | |
| } | |
| registerScopedService( | |
| LifecycleScope.App, | |
| IAgentIdentity, | |
| AgentIdentityService, | |
| ScopeActivation.OnScopeCreated, | |
| 'agentIdentity', | |
| ); | |