GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — claude-code-source-code/src/constants/system.ts at main · wangwang4git/claude-code-source-code Expand file tree/ Copy pathsystem.tsMore file actions 95 lines (83 loc) · 3.77 KB / Copy pathsystem.tsFile metadata and controls95 lines (83 loc) · 3.77 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 // Critical system constants extracted to break circular dependencies import { feature } from 'bun:bundle' import { getFeatureValue_CACHED_MAY_BE_STALE } from '../services/analytics/growthbook.js' import { logForDebugging } from '../utils/debug.js' import { isEnvDefinedFalsy } from '../utils/envUtils.js' import { getAPIProvider } from '../utils/model/providers.js' import { getWorkload } from '../utils/workloadContext.js' const DEFAULT_PREFIX = `You are Claude Code, Anthropic's official CLI for Claude.` const AGENT_SDK_CLAUDE_CODE_PRESET_PREFIX = `You are Claude Code, Anthropic's official CLI for Claude, running within the Claude Agent SDK.` const AGENT_SDK_PREFIX = `You are a Claude agent, built on Anthropic's Claude Agent SDK.` const CLI_SYSPROMPT_PREFIX_VALUES = [ DEFAULT_PREFIX, AGENT_SDK_CLAUDE_CODE_PRESET_PREFIX, AGENT_SDK_PREFIX, ] as const export type CLISyspromptPrefix = (typeof CLI_SYSPROMPT_PREFIX_VALUES)[number] /** * All possible CLI sysprompt prefix values, used by splitSysPromptPrefix * to identify prefix blocks by content rather than position. */ export const CLI_SYSPROMPT_PREFIXES: ReadonlySet<string> = new Set( CLI_SYSPROMPT_PREFIX_VALUES, ) export function getCLISyspromptPrefix(options?: { isNonInteractive: boolean hasAppendSystemPrompt: boolean }): CLISyspromptPrefix { const apiProvider = getAPIProvider() if (apiProvider === 'vertex') { return DEFAULT_PREFIX } if (options?.isNonInteractive) { if (options.hasAppendSystemPrompt) { return AGENT_SDK_CLAUDE_CODE_PRESET_PREFIX } return AGENT_SDK_PREFIX } return DEFAULT_PREFIX } /** * Check if attribution header is enabled. * Enabled by default, can be disabled via env var or GrowthBook killswitch. */ function isAttributionHeaderEnabled(): boolean { if (isEnvDefinedFalsy(process.env.CLAUDE_CODE_ATTRIBUTION_HEADER)) { return false } return getFeatureValue_CACHED_MAY_BE_STALE('tengu_attribution_header', true) } /** * Get attribution header for API requests. * Returns a header string with cc_version (including fingerprint) and cc_entrypoint. * Enabled by default, can be disabled via env var or GrowthBook killswitch. * * When NATIVE_CLIENT_ATTESTATION is enabled, includes a `cch=00000` placeholder. * Before the request is sent, Bun's native HTTP stack finds this placeholder * in the request body and overwrites the zeros with a computed hash. The * server verifies this token to confirm the request came from a real Claude * Code client. See bun-anthropic/src/http/Attestation.zig for implementation. * * We use a placeholder (instead of injecting from Zig) because same-length * replacement avoids Content-Length changes and buffer reallocation. */ export function getAttributionHeader(fingerprint: string): string { if (!isAttributionHeaderEnabled()) { return '' } const version = `${MACRO.VERSION}.${fingerprint}` const entrypoint = process.env.CLAUDE_CODE_ENTRYPOINT ?? 'unknown' // cch=00000 placeholder is overwritten by Bun's HTTP stack with attestation token const cch = feature('NATIVE_CLIENT_ATTESTATION') ? ' cch=00000;' : '' // cc_workload: turn-scoped hint so the API can route e.g. cron-initiated // requests to a lower QoS pool. Absent = interactive default. Safe re: // fingerprint (computed from msg chars + version only, line 78 above) and // cch attestation (placeholder overwritten in serialized body bytes after // this string is built). Server _parse_cc_header tolerates unknown extra // fields so old API deploys silently ignore this. const workload = getWorkload() const workloadPair = workload ? ` cc_workload=${workload};` : '' const header = `x-anthropic-billing-header: cc_version=${version}; cc_entrypoint=${entrypoint};${cch}${workloadPair}` logForDebugging(`attribution header ${header}`) return header } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |