mirror of
https://github.com/MoonshotAI/kimi-code.git
synced 2026-07-10 01:39:25 +00:00
feat(agent-core): propagate app version into agent record metadata
- add appVersion option to AgentOptions, SessionOptions, and KimiCoreOptions\n- forward appVersion through Agent, Session, and SDKRpcClient\n- include app_version in agent record metadata events
This commit is contained in:
parent
91b292e898
commit
0866893dd0
6 changed files with 13 additions and 0 deletions
|
|
@ -86,6 +86,7 @@ export interface AgentOptions {
|
|||
readonly log?: Logger;
|
||||
readonly telemetry?: TelemetryClient | undefined;
|
||||
readonly pluginSessionStarts?: readonly EnabledPluginSessionStart[];
|
||||
readonly appVersion?: string;
|
||||
}
|
||||
|
||||
export class Agent {
|
||||
|
|
@ -103,6 +104,7 @@ export class Agent {
|
|||
readonly hooks?: HookEngine;
|
||||
readonly log: Logger;
|
||||
readonly telemetry: TelemetryClient;
|
||||
readonly appVersion?: string;
|
||||
|
||||
readonly blobStore: BlobStore | undefined;
|
||||
readonly records: AgentRecords;
|
||||
|
|
@ -136,6 +138,7 @@ export class Agent {
|
|||
this.subagentHost = options.subagentHost;
|
||||
this.mcp = options.mcp;
|
||||
this.hooks = options.hookEngine;
|
||||
this.appVersion = options.appVersion;
|
||||
this.log = options.log ?? log;
|
||||
this.telemetry = options.telemetry ?? noopTelemetryClient;
|
||||
|
||||
|
|
|
|||
|
|
@ -127,6 +127,7 @@ export class AgentRecords {
|
|||
type: 'metadata',
|
||||
protocol_version: AGENT_WIRE_PROTOCOL_VERSION,
|
||||
created_at: Date.now(),
|
||||
app_version: this.agent.appVersion,
|
||||
});
|
||||
this.metadataInitialized = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ export interface AgentRecordEvents {
|
|||
metadata: {
|
||||
protocol_version: string;
|
||||
created_at: number;
|
||||
app_version?: string;
|
||||
};
|
||||
|
||||
'turn.prompt': {
|
||||
|
|
|
|||
|
|
@ -109,6 +109,7 @@ export interface KimiCoreOptions {
|
|||
readonly resolveOAuthTokenProvider?: OAuthTokenProviderResolver | undefined;
|
||||
readonly skillDirs?: readonly string[];
|
||||
readonly telemetry?: TelemetryClient | undefined;
|
||||
readonly appVersion?: string;
|
||||
}
|
||||
|
||||
export class KimiCore implements PromisableMethods<CoreAPI> {
|
||||
|
|
@ -129,6 +130,7 @@ export class KimiCore implements PromisableMethods<CoreAPI> {
|
|||
readonly plugins: PluginManager;
|
||||
private pluginsReady: Promise<void>;
|
||||
private pluginsLoadError: Error | undefined;
|
||||
private readonly appVersion: string | undefined;
|
||||
|
||||
constructor(
|
||||
protected readonly rpcClient: CoreRPCClient,
|
||||
|
|
@ -151,6 +153,7 @@ export class KimiCore implements PromisableMethods<CoreAPI> {
|
|||
this.resolveOAuthTokenProvider = options.resolveOAuthTokenProvider;
|
||||
this.skillDirs = options.skillDirs ?? [];
|
||||
this.telemetry = options.telemetry ?? noopTelemetryClient;
|
||||
this.appVersion = options.appVersion;
|
||||
ensureKimiHome(this.homeDir);
|
||||
this.config = loadRuntimeConfig(this.configPath);
|
||||
this.sessionStore = new SessionStore(this.homeDir);
|
||||
|
|
@ -209,6 +212,7 @@ export class KimiCore implements PromisableMethods<CoreAPI> {
|
|||
mcpConfig,
|
||||
telemetry: withTelemetryContext(this.telemetry, { sessionId: summary.id }),
|
||||
pluginSessionStarts,
|
||||
appVersion: this.appVersion,
|
||||
});
|
||||
try {
|
||||
session.metadata = {
|
||||
|
|
@ -296,6 +300,7 @@ export class KimiCore implements PromisableMethods<CoreAPI> {
|
|||
telemetry: withTelemetryContext(this.telemetry, { sessionId: summary.id }),
|
||||
initializeMainAgent: false,
|
||||
pluginSessionStarts,
|
||||
appVersion: this.appVersion,
|
||||
});
|
||||
let warning: string | undefined;
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ export interface SessionOptions {
|
|||
readonly mcpConfig?: SessionMcpConfig;
|
||||
readonly telemetry?: TelemetryClient | undefined;
|
||||
readonly pluginSessionStarts?: readonly EnabledPluginSessionStart[];
|
||||
readonly appVersion?: string;
|
||||
}
|
||||
|
||||
export interface SessionSkillConfig {
|
||||
|
|
@ -427,6 +428,7 @@ export class Session {
|
|||
telemetry: this.telemetry,
|
||||
log: this.log.createChild({ agentId: id }),
|
||||
pluginSessionStarts: type === 'main' ? this.options.pluginSessionStarts : undefined,
|
||||
appVersion: this.options.appVersion,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -127,6 +127,7 @@ export class SDKRpcClient {
|
|||
resolveOAuthTokenProvider: options.resolveOAuthTokenProvider,
|
||||
skillDirs: options.skillDirs,
|
||||
telemetry: options.telemetry,
|
||||
appVersion: options.identity?.version,
|
||||
});
|
||||
this.ready = sdkRpc(new ClientAPI(this)).then((rpc) => {
|
||||
this.rpc = rpc;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue