forked from boos/BoosAPI
refactor: keep downstream client metadata on cli profiles
This commit is contained in:
@@ -48,6 +48,9 @@ export const claudeCodeCliProfile: CliProfileDefinition = {
|
||||
id: 'claude_code',
|
||||
sessionId,
|
||||
traceHint: sessionId,
|
||||
clientAppId: 'claude_code',
|
||||
clientAppName: 'Claude Code',
|
||||
clientConfidence: 'exact',
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
@@ -189,9 +189,21 @@ export const codexCliProfile: CliProfileDefinition = {
|
||||
if (!isCodexRequest(input)) return null;
|
||||
|
||||
const sessionId = getCodexSessionId(input.headers) || undefined;
|
||||
const clientApp = detectCodexOfficialClientApp(input.headers);
|
||||
return {
|
||||
id: 'codex',
|
||||
...(sessionId ? { sessionId, traceHint: sessionId } : {}),
|
||||
...(clientApp
|
||||
? {
|
||||
clientAppId: clientApp.clientAppId,
|
||||
clientAppName: clientApp.clientAppName,
|
||||
clientConfidence: 'exact' as const,
|
||||
}
|
||||
: {
|
||||
clientAppId: 'codex',
|
||||
clientAppName: 'Codex',
|
||||
clientConfidence: 'heuristic' as const,
|
||||
}),
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
@@ -32,6 +32,9 @@ export const geminiCliProfile: CliProfileDefinition = {
|
||||
if (input.body !== undefined && !hasGeminiCliBodyShape(input.body)) return null;
|
||||
return {
|
||||
id: 'gemini_cli',
|
||||
clientAppId: 'gemini_cli',
|
||||
clientAppName: 'Gemini CLI',
|
||||
clientConfidence: 'exact',
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
@@ -14,6 +14,9 @@ describe('detectCliProfile', () => {
|
||||
id: 'codex',
|
||||
sessionId: 'codex-session-123',
|
||||
traceHint: 'codex-session-123',
|
||||
clientAppId: 'codex_cli_rs',
|
||||
clientAppName: 'Codex CLI',
|
||||
clientConfidence: 'exact',
|
||||
capabilities: {
|
||||
supportsResponsesCompact: true,
|
||||
supportsResponsesWebsocketIncremental: true,
|
||||
@@ -79,6 +82,9 @@ describe('detectCliProfile', () => {
|
||||
id: 'claude_code',
|
||||
sessionId: 'f25958b8-e75c-455d-8b40-f006d87cc2a4',
|
||||
traceHint: 'f25958b8-e75c-455d-8b40-f006d87cc2a4',
|
||||
clientAppId: 'claude_code',
|
||||
clientAppName: 'Claude Code',
|
||||
clientConfidence: 'exact',
|
||||
capabilities: {
|
||||
supportsResponsesCompact: false,
|
||||
supportsResponsesWebsocketIncremental: false,
|
||||
@@ -98,6 +104,9 @@ describe('detectCliProfile', () => {
|
||||
},
|
||||
})).toEqual({
|
||||
id: 'gemini_cli',
|
||||
clientAppId: 'gemini_cli',
|
||||
clientAppName: 'Gemini CLI',
|
||||
clientConfidence: 'exact',
|
||||
capabilities: {
|
||||
supportsResponsesCompact: false,
|
||||
supportsResponsesWebsocketIncremental: false,
|
||||
|
||||
@@ -12,6 +12,8 @@ export type CliProfileCapabilities = {
|
||||
echoesTurnState: boolean;
|
||||
};
|
||||
|
||||
export type CliProfileClientConfidence = 'exact' | 'heuristic';
|
||||
|
||||
export type DetectCliProfileInput = {
|
||||
downstreamPath: string;
|
||||
headers?: Record<string, unknown>;
|
||||
@@ -22,6 +24,9 @@ export type DetectedCliProfile = {
|
||||
id: CliProfileId;
|
||||
sessionId?: string;
|
||||
traceHint?: string;
|
||||
clientAppId?: string;
|
||||
clientAppName?: string;
|
||||
clientConfidence?: CliProfileClientConfidence;
|
||||
capabilities: CliProfileCapabilities;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user