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:
haozhe.yang 2026-06-02 13:01:11 +08:00
parent 91b292e898
commit 0866893dd0
6 changed files with 13 additions and 0 deletions

View file

@ -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;

View file

@ -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;
}

View file

@ -13,6 +13,7 @@ export interface AgentRecordEvents {
metadata: {
protocol_version: string;
created_at: number;
app_version?: string;
};
'turn.prompt': {

View file

@ -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 {

View file

@ -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,
});
}

View file

@ -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;