@albinocrabs/o-switcher 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/mode/detection.ts","../src/errors/corpus.ts","../src/errors/classifier.ts","../src/errors/direct-adapter.ts","../src/errors/heuristic-adapter.ts","../src/execution/stream-buffer.ts","../src/execution/stream-stitcher.ts","../src/execution/audit-collector.ts","../src/execution/orchestrator.ts","../src/execution/adapters/plugin-adapter.ts","../src/execution/adapters/server-adapter.ts","../src/execution/adapters/sdk-adapter.ts","../src/execution/adapters/adapter-factory.ts","../src/operator/server-auth.ts"],"sourcesContent":["/**\n * Deployment mode detection.\n *\n * Determines the active deployment mode from a config hint.\n * When hint is 'auto', defaults to 'plugin-only' (auto-detection\n * logic will be refined in Phase 3 when mode adapters are built).\n *\n * Maps each mode to its signal fidelity and capability set (FOUN-03, FOUN-04).\n */\n\nimport type { DeploymentMode, SignalFidelity, ModeCapabilities } from './types.js';\n\n/**\n * Detects the deployment mode from a configuration hint.\n *\n * If hint is not 'auto', returns the hint directly.\n * If 'auto', defaults to 'plugin-only' (conservative default).\n */\nexport const detectDeploymentMode = (\n hint: 'plugin-only' | 'server-companion' | 'sdk-control' | 'auto',\n): DeploymentMode => {\n if (hint !== 'auto') {\n return hint;\n }\n // Auto-detection defaults to plugin-only (most restrictive / conservative).\n // Refined in Phase 3 when mode adapters provide runtime probing.\n return 'plugin-only';\n};\n\n/**\n * Returns the signal fidelity for a given deployment mode.\n *\n * - plugin-only: 'heuristic' (no raw HTTP status codes)\n * - server-companion / sdk-control: 'direct' (full HTTP access)\n */\nexport const getSignalFidelity = (mode: DeploymentMode): SignalFidelity => {\n if (mode === 'plugin-only') {\n return 'heuristic';\n }\n return 'direct';\n};\n\n/**\n * Returns the full capability map for a deployment mode.\n *\n * plugin-only has no HTTP status, no Retry-After, no operator API.\n * server-companion and sdk-control have all capabilities.\n */\nexport const getModeCapabilities = (mode: DeploymentMode): ModeCapabilities => {\n if (mode === 'plugin-only') {\n return {\n mode,\n signalFidelity: 'heuristic',\n hasHttpStatus: false,\n hasRetryAfterHeader: false,\n hasOperatorApi: false,\n };\n }\n return {\n mode,\n signalFidelity: 'direct',\n hasHttpStatus: true,\n hasRetryAfterHeader: true,\n hasOperatorApi: true,\n };\n};\n","/**\n * Provider-specific error pattern corpus.\n *\n * Contains known error response patterns for Anthropic, OpenAI, Google,\n * and AWS Bedrock (direct classification) and heuristic message patterns\n * for plugin-only mode classification.\n *\n * Per ERRC-02, ERRC-05, Pitfalls 1-3.\n */\n\n/** A provider-specific error response pattern for direct classification. */\nexport interface ProviderErrorPattern {\n readonly provider: string;\n readonly http_status: number;\n readonly error_type_field: string;\n readonly error_type_value: string;\n readonly error_class: string;\n readonly notes?: string;\n}\n\n/**\n * Known provider error patterns for direct HTTP status classification.\n *\n * Order matters for matching: more specific patterns (with error_type_value)\n * should be checked before generic status-code fallbacks.\n */\nexport const PROVIDER_PATTERNS: ReadonlyArray<ProviderErrorPattern> = [\n // Anthropic\n { provider: 'anthropic', http_status: 400, error_type_field: 'error.type', error_type_value: 'invalid_request_error', error_class: 'PolicyFailure' },\n { provider: 'anthropic', http_status: 401, error_type_field: 'error.type', error_type_value: 'authentication_error', error_class: 'AuthFailure' },\n { provider: 'anthropic', http_status: 402, error_type_field: 'error.type', error_type_value: 'billing_error', error_class: 'QuotaExhausted' },\n { provider: 'anthropic', http_status: 403, error_type_field: 'error.type', error_type_value: 'permission_error', error_class: 'PermissionFailure' },\n { provider: 'anthropic', http_status: 404, error_type_field: 'error.type', error_type_value: 'not_found_error', error_class: 'ModelUnavailable' },\n { provider: 'anthropic', http_status: 429, error_type_field: 'error.type', error_type_value: 'rate_limit_error', error_class: 'RateLimited' },\n { provider: 'anthropic', http_status: 500, error_type_field: 'error.type', error_type_value: 'api_error', error_class: 'TransientServerFailure' },\n { provider: 'anthropic', http_status: 504, error_type_field: 'error.type', error_type_value: 'timeout_error', error_class: 'TransportFailure' },\n { provider: 'anthropic', http_status: 529, error_type_field: 'error.type', error_type_value: 'overloaded_error', error_class: 'RateLimited', notes: 'Server capacity exhaustion; backoff on same provider, do NOT failover' },\n\n // OpenAI\n { provider: 'openai', http_status: 400, error_type_field: 'error.code', error_type_value: '', error_class: 'PolicyFailure' },\n { provider: 'openai', http_status: 401, error_type_field: 'error.code', error_type_value: 'invalid_api_key', error_class: 'AuthFailure' },\n { provider: 'openai', http_status: 403, error_type_field: 'error.code', error_type_value: 'unsupported_country_region_territory', error_class: 'RegionRestriction', notes: 'GeoIP block — collected 2026-04-11 from real API' },\n { provider: 'openai', http_status: 403, error_type_field: 'error.code', error_type_value: '', error_class: 'PermissionFailure' },\n { provider: 'openai', http_status: 429, error_type_field: 'error.code', error_type_value: 'rate_limit_exceeded', error_class: 'RateLimited' },\n { provider: 'openai', http_status: 429, error_type_field: 'error.code', error_type_value: 'insufficient_quota', error_class: 'QuotaExhausted', notes: 'Billing exhausted -- NOT retryable' },\n { provider: 'openai', http_status: 500, error_type_field: 'error.code', error_type_value: '', error_class: 'TransientServerFailure' },\n { provider: 'openai', http_status: 503, error_type_field: 'error.code', error_type_value: '', error_class: 'TransientServerFailure' },\n\n // Google Vertex AI / Gemini\n { provider: 'google', http_status: 400, error_type_field: 'error.status', error_type_value: 'INVALID_ARGUMENT', error_class: 'PolicyFailure' },\n { provider: 'google', http_status: 403, error_type_field: 'error.status', error_type_value: 'PERMISSION_DENIED', error_class: 'PermissionFailure' },\n { provider: 'google', http_status: 429, error_type_field: 'error.status', error_type_value: 'RESOURCE_EXHAUSTED', error_class: 'RateLimited' },\n { provider: 'google', http_status: 500, error_type_field: 'error.status', error_type_value: 'INTERNAL', error_class: 'TransientServerFailure' },\n { provider: 'google', http_status: 503, error_type_field: 'error.status', error_type_value: 'UNAVAILABLE', error_class: 'TransientServerFailure' },\n\n // AWS Bedrock\n { provider: 'bedrock', http_status: 429, error_type_field: '__type', error_type_value: 'ThrottlingException', error_class: 'RateLimited' },\n { provider: 'bedrock', http_status: 408, error_type_field: '__type', error_type_value: 'ModelTimeoutException', error_class: 'TransportFailure' },\n { provider: 'bedrock', http_status: 424, error_type_field: '__type', error_type_value: 'ModelNotReadyException', error_class: 'ModelUnavailable' },\n { provider: 'bedrock', http_status: 403, error_type_field: '__type', error_type_value: 'AccessDeniedException', error_class: 'PermissionFailure' },\n { provider: 'bedrock', http_status: 400, error_type_field: '__type', error_type_value: 'ValidationException', error_class: 'PolicyFailure' },\n { provider: 'bedrock', http_status: 500, error_type_field: '__type', error_type_value: 'InternalServerException', error_class: 'TransientServerFailure' },\n];\n\n/** A heuristic pattern for plugin-only mode message classification. */\nexport interface HeuristicPattern {\n readonly pattern: RegExp;\n readonly error_class: string;\n readonly confidence: 'high' | 'medium' | 'low';\n readonly provider?: string;\n readonly notes?: string;\n}\n\n/**\n * Heuristic patterns for plugin-only mode classification.\n *\n * Order matters: more specific patterns should come first.\n * TEMPORAL_QUOTA_PATTERN is checked separately before these patterns\n * to correctly handle Pitfall 2.\n */\nexport const HEURISTIC_PATTERNS: ReadonlyArray<HeuristicPattern> = [\n // Transport errors (high confidence -- these are unambiguous)\n { pattern: /ECONNREFUSED|ECONNRESET|ETIMEDOUT/, error_class: 'TransportFailure', confidence: 'high' },\n\n // Quota patterns (before rate limit to avoid misclassification -- Pitfall 2/3)\n { pattern: /quota\\s*(?:exceeded|exhausted)/i, error_class: 'QuotaExhausted', confidence: 'medium' },\n { pattern: /insufficient\\s*quota/i, error_class: 'QuotaExhausted', confidence: 'medium', provider: 'openai' },\n { pattern: /billing/i, error_class: 'QuotaExhausted', confidence: 'low', provider: 'openai' },\n\n // Rate limit patterns\n { pattern: /rate\\s*limit/i, error_class: 'RateLimited', confidence: 'medium' },\n { pattern: /too many requests/i, error_class: 'RateLimited', confidence: 'medium' },\n { pattern: /retry\\s*after/i, error_class: 'RateLimited', confidence: 'medium' },\n { pattern: /overloaded/i, error_class: 'RateLimited', confidence: 'medium', provider: 'anthropic' },\n { pattern: /resource\\s*exhausted/i, error_class: 'RateLimited', confidence: 'medium', provider: 'google' },\n\n // Auth patterns\n { pattern: /authentication/i, error_class: 'AuthFailure', confidence: 'medium' },\n { pattern: /invalid\\s*api\\s*key/i, error_class: 'AuthFailure', confidence: 'medium' },\n { pattern: /unauthorized/i, error_class: 'AuthFailure', confidence: 'medium' },\n\n // Permission patterns\n { pattern: /permission\\s*denied/i, error_class: 'PermissionFailure', confidence: 'medium' },\n { pattern: /forbidden/i, error_class: 'PermissionFailure', confidence: 'low' },\n\n // Model availability patterns\n { pattern: /model\\s*not\\s*(?:available|ready|found)/i, error_class: 'ModelUnavailable', confidence: 'medium' },\n { pattern: /not\\s*found/i, error_class: 'ModelUnavailable', confidence: 'low' },\n\n // Transport patterns (lower confidence than ECONNREFUSED)\n { pattern: /timeout/i, error_class: 'TransportFailure', confidence: 'low' },\n\n // Region restriction (requires both keywords)\n { pattern: /unsupported.country.*region.*territory/i, error_class: 'RegionRestriction', confidence: 'high', notes: 'OpenAI GeoIP block — collected 2026-04-11' },\n { pattern: /country.*region.*not supported/i, error_class: 'RegionRestriction', confidence: 'high' },\n { pattern: /region.*restrict|restrict.*region/i, error_class: 'RegionRestriction', confidence: 'low' },\n];\n\n/**\n * Temporal quota pattern to distinguish quota exhaustion from transient rate limits.\n *\n * Matches messages like \"Too many tokens per day\" from Bedrock, which arrive as\n * ThrottlingException but represent non-retryable quota exhaustion (Pitfall 2).\n */\nexport const TEMPORAL_QUOTA_PATTERN = /too many tokens per (?:day|month|hour|week)/i;\n","/**\n * Mode-agnostic error classifier core.\n *\n * Accepts a NormalizedSignal and routes to direct (HTTP) or heuristic\n * (message pattern) classification based on signal content.\n *\n * Per D-01, ERRC-01.\n */\n\nimport type { NormalizedSignal, ClassificationResult, ErrorClass } from './taxonomy.js';\nimport { PROVIDER_PATTERNS, HEURISTIC_PATTERNS, TEMPORAL_QUOTA_PATTERN } from './corpus.js';\n\n/**\n * Builds an ErrorClass object from a class name string.\n *\n * Maps class name to the correct discriminated union variant\n * with appropriate metadata fields.\n */\nconst buildErrorClass = (\n className: string,\n extras?: {\n readonly retry_after_ms?: number;\n readonly provider_reason?: string;\n readonly http_status?: number;\n },\n): ErrorClass => {\n switch (className) {\n case 'RateLimited':\n return {\n class: 'RateLimited',\n retryable: true,\n retry_after_ms: extras?.retry_after_ms,\n provider_reason: extras?.provider_reason,\n };\n case 'QuotaExhausted':\n return {\n class: 'QuotaExhausted',\n retryable: false,\n provider_reason: extras?.provider_reason,\n };\n case 'AuthFailure':\n return { class: 'AuthFailure', retryable: false, recovery_attempted: false };\n case 'PermissionFailure':\n return { class: 'PermissionFailure', retryable: false };\n case 'PolicyFailure':\n return { class: 'PolicyFailure', retryable: false };\n case 'RegionRestriction':\n return { class: 'RegionRestriction', retryable: false };\n case 'ModelUnavailable':\n return { class: 'ModelUnavailable', retryable: false, failover_eligible: true };\n case 'TransientServerFailure':\n return {\n class: 'TransientServerFailure',\n retryable: true,\n http_status: extras?.http_status,\n };\n case 'TransportFailure':\n return { class: 'TransportFailure', retryable: true };\n case 'InterruptedExecution':\n return { class: 'InterruptedExecution', retryable: true };\n default:\n return { class: 'TransientServerFailure', retryable: true, http_status: extras?.http_status };\n }\n};\n\n/**\n * Extracts an error type string from a response body, trying\n * multiple provider-specific field paths.\n */\nconst extractErrorTypeFromBody = (body: unknown): string | undefined => {\n if (typeof body !== 'object' || body === null) return undefined;\n const b = body as Record<string, unknown>;\n\n const errorObj = b.error as Record<string, unknown> | undefined;\n if (typeof errorObj === 'object' && errorObj !== null) {\n if (typeof errorObj.type === 'string') return errorObj.type;\n if (typeof errorObj.code === 'string') return errorObj.code;\n if (typeof errorObj.status === 'string') return errorObj.status;\n }\n\n if (typeof b.__type === 'string') return b.__type;\n return undefined;\n};\n\n/**\n * Classifies a signal with HTTP status code (direct mode).\n *\n * Classification priority:\n * 1. Temporal quota pattern on error message (Pitfall 2)\n * 2. Provider-specific error type matching from corpus\n * 3. OpenAI insufficient_quota special case (Pitfall 3)\n * 4. Anthropic 529 overloaded_error special case (Pitfall 3)\n * 5. Generic HTTP status fallback\n */\nconst classifyDirect = (signal: NormalizedSignal): ClassificationResult => {\n const status = signal.http_status!;\n const errorType = signal.error_type ?? extractErrorTypeFromBody(signal.response_body);\n const errorMessage = signal.error_message ?? '';\n\n // Pitfall 2: temporal quota qualifiers override status code classification\n if (status === 429 && TEMPORAL_QUOTA_PATTERN.test(errorMessage)) {\n return {\n error_class: buildErrorClass('QuotaExhausted'),\n detection_mode: 'direct',\n confidence: 'high',\n raw_signal: signal,\n };\n }\n\n // Pitfall 3: OpenAI insufficient_quota on 429 is QuotaExhausted, NOT RateLimited\n if (status === 429 && errorType === 'insufficient_quota') {\n return {\n error_class: buildErrorClass('QuotaExhausted'),\n detection_mode: 'direct',\n confidence: 'high',\n raw_signal: signal,\n };\n }\n\n // Pitfall 3: Anthropic 529 overloaded_error is capacity, not account rate limit\n if (status === 529 && errorType === 'overloaded_error') {\n return {\n error_class: buildErrorClass('RateLimited', {\n retry_after_ms: signal.retry_after_ms,\n provider_reason: 'server_capacity_exhaustion',\n }),\n detection_mode: 'direct',\n confidence: 'high',\n raw_signal: signal,\n };\n }\n\n // Match against provider corpus by error type\n if (errorType) {\n const match = PROVIDER_PATTERNS.find(\n (p) => p.http_status === status && p.error_type_value === errorType,\n );\n if (match) {\n return {\n error_class: buildErrorClass(match.error_class, {\n retry_after_ms: signal.retry_after_ms,\n http_status: status,\n }),\n detection_mode: 'direct',\n confidence: 'high',\n raw_signal: signal,\n };\n }\n }\n\n // Also check for Bedrock temporal quota on ThrottlingException\n if (errorType === 'ThrottlingException' && TEMPORAL_QUOTA_PATTERN.test(errorMessage)) {\n return {\n error_class: buildErrorClass('QuotaExhausted'),\n detection_mode: 'direct',\n confidence: 'high',\n raw_signal: signal,\n };\n }\n\n // Generic HTTP status fallback\n const fallbackClass = getClassFromStatus(status);\n return {\n error_class: buildErrorClass(fallbackClass, {\n retry_after_ms: signal.retry_after_ms,\n http_status: status,\n }),\n detection_mode: 'direct',\n confidence: 'high',\n raw_signal: signal,\n };\n};\n\n/**\n * Maps an HTTP status code to a default error class.\n */\nconst getClassFromStatus = (status: number): string => {\n if (status === 400) return 'PolicyFailure';\n if (status === 401) return 'AuthFailure';\n if (status === 402) return 'QuotaExhausted';\n if (status === 403) return 'PermissionFailure';\n if (status === 404) return 'ModelUnavailable';\n if (status === 408) return 'TransportFailure';\n if (status === 429) return 'RateLimited';\n if (status >= 500) return 'TransientServerFailure';\n return 'TransientServerFailure';\n};\n\n/**\n * Classifies a signal without HTTP status code (heuristic mode).\n *\n * Classification priority:\n * 1. Temporal quota pattern (Pitfall 2 heuristic path)\n * 2. Heuristic patterns from corpus (first match wins)\n * 3. Conservative fallback to TransientServerFailure with low confidence\n */\nconst classifyHeuristic = (signal: NormalizedSignal): ClassificationResult => {\n const message = signal.error_message ?? '';\n\n // Pitfall 2: temporal quota qualifiers checked first\n if (TEMPORAL_QUOTA_PATTERN.test(message)) {\n return {\n error_class: buildErrorClass('QuotaExhausted'),\n detection_mode: 'heuristic',\n confidence: 'medium',\n raw_signal: signal,\n };\n }\n\n // Match against heuristic pattern corpus -- first match wins\n for (const hp of HEURISTIC_PATTERNS) {\n if (hp.pattern.test(message)) {\n return {\n error_class: buildErrorClass(hp.error_class),\n detection_mode: 'heuristic',\n confidence: hp.confidence,\n raw_signal: signal,\n };\n }\n }\n\n // Conservative fallback: TransientServerFailure with low confidence\n // Prefer false negatives over false positives per CONTEXT.md\n return {\n error_class: buildErrorClass('TransientServerFailure'),\n detection_mode: 'heuristic',\n confidence: 'low',\n raw_signal: signal,\n };\n};\n\n/**\n * Classifies a NormalizedSignal into an ErrorClass.\n *\n * Routes to direct (HTTP) or heuristic (message pattern) classification\n * based on whether http_status is present in the signal.\n *\n * @param signal - The normalized error signal to classify.\n * @returns ClassificationResult with error class, mode, confidence, and raw signal.\n */\nexport const classify = (signal: NormalizedSignal): ClassificationResult => {\n if (signal.http_status !== undefined) {\n return classifyDirect(signal);\n }\n return classifyHeuristic(signal);\n};\n","/**\n * Direct signal adapter: HTTP status + body to NormalizedSignal.\n *\n * Used in server-companion and SDK-control modes where raw HTTP\n * status codes, response bodies, and headers are available.\n *\n * Per D-01, ERRC-02.\n */\n\nimport type { NormalizedSignal } from './taxonomy.js';\n\n/**\n * Extracts error type from a provider response body.\n *\n * Tries multiple provider-specific field paths:\n * - body.error.type (Anthropic)\n * - body.error.code (OpenAI)\n * - body.error.status (Google)\n * - body.__type (Bedrock)\n */\nconst extractErrorType = (body: unknown): string | undefined => {\n if (typeof body !== 'object' || body === null) {\n return undefined;\n }\n const b = body as Record<string, unknown>;\n\n // Anthropic: { error: { type: \"rate_limit_error\" } }\n const errorObj = b.error as Record<string, unknown> | undefined;\n if (typeof errorObj === 'object' && errorObj !== null) {\n if (typeof errorObj.type === 'string') return errorObj.type;\n if (typeof errorObj.code === 'string') return errorObj.code;\n if (typeof errorObj.status === 'string') return errorObj.status;\n }\n\n // Bedrock: { __type: \"ThrottlingException\" }\n if (typeof b.__type === 'string') return b.__type;\n\n return undefined;\n};\n\n/**\n * Extracts error message from a provider response body.\n *\n * Tries: body.error.message, body.message.\n */\nconst extractErrorMessage = (body: unknown): string | undefined => {\n if (typeof body !== 'object' || body === null) {\n return undefined;\n }\n const b = body as Record<string, unknown>;\n\n const errorObj = b.error as Record<string, unknown> | undefined;\n if (typeof errorObj === 'object' && errorObj !== null) {\n if (typeof errorObj.message === 'string') return errorObj.message;\n }\n\n if (typeof b.message === 'string') return b.message;\n\n return undefined;\n};\n\n/**\n * Extracts Retry-After value from response headers as milliseconds.\n *\n * Supports integer seconds format. HTTP-date format is not supported\n * (providers typically send integer seconds).\n *\n * @param headers - Response headers (case-insensitive lookup for retry-after).\n * @returns Retry-After in milliseconds, or undefined if not present/parseable.\n */\nexport const extractRetryAfterMs = (\n headers?: Record<string, string>,\n): number | undefined => {\n if (!headers) return undefined;\n\n const value = headers['retry-after'] ?? headers['Retry-After'];\n if (!value) return undefined;\n\n const seconds = Number(value);\n if (Number.isNaN(seconds) || seconds < 0) return undefined;\n\n return seconds * 1000;\n};\n\n/**\n * Creates a NormalizedSignal from an HTTP response.\n *\n * Always sets detection_mode='direct' since we have raw HTTP access.\n *\n * @param status - HTTP status code.\n * @param body - Parsed response body.\n * @param headers - Response headers (optional; used for Retry-After).\n * @returns NormalizedSignal ready for classifier.\n */\nexport const directSignalFromResponse = (\n status: number,\n body: unknown,\n headers?: Record<string, string>,\n): NormalizedSignal => ({\n http_status: status,\n error_type: extractErrorType(body),\n error_message: extractErrorMessage(body),\n response_body: body,\n detection_mode: 'direct',\n retry_after_ms: extractRetryAfterMs(headers),\n});\n","/**\n * Heuristic signal adapter: message pattern to NormalizedSignal.\n *\n * Used in plugin-only mode where HTTP status codes are not available.\n * Classification relies on message string matching against known patterns.\n *\n * Per D-01, ERRC-03.\n */\n\nimport type { NormalizedSignal } from './taxonomy.js';\n\n/**\n * Creates a NormalizedSignal from a session event message.\n *\n * Always sets detection_mode='heuristic' since no HTTP access is available.\n * No http_status field is set (not available in plugin-only mode).\n *\n * @param eventType - The event type (e.g., 'error', 'retry', 'status').\n * @param message - The error or status message string.\n * @param providerId - Optional provider identifier.\n * @returns NormalizedSignal ready for classifier.\n */\nexport const heuristicSignalFromEvent = (\n eventType: string,\n message: string,\n providerId?: string,\n): NormalizedSignal => ({\n error_type: eventType,\n error_message: message,\n detection_mode: 'heuristic',\n provider_id: providerId,\n});\n","/**\n * Append-only stream buffer with confirmed boundary per D-30.\n *\n * Accumulates StreamChunks during a streaming response.\n * On interruption, confirmed() returns all chunks received so far,\n * and snapshot() returns the concatenated confirmed text for\n * stream stitching.\n */\n\nimport type { StreamChunk, StreamBuffer } from './types.js';\n\n/**\n * Creates a new StreamBuffer instance.\n *\n * The buffer is append-only: chunks can be added but never removed.\n * This preserves a reliable confirmed boundary for stream resume.\n *\n * @returns A StreamBuffer instance.\n */\nexport const createStreamBuffer = (): StreamBuffer => {\n const chunks: StreamChunk[] = [];\n\n return {\n /**\n * Appends a chunk to the buffer.\n *\n * @param chunk - The stream chunk to append.\n * @returns The index of the appended chunk (0-based).\n */\n append(chunk: StreamChunk): number {\n chunks.push(chunk);\n return chunks.length - 1;\n },\n\n /**\n * Returns a readonly copy of all accumulated chunks.\n *\n * The returned array is a shallow copy; mutations to it\n * do not affect the internal buffer.\n *\n * @returns Readonly array of confirmed chunks.\n */\n confirmed(): readonly StreamChunk[] {\n return [...chunks];\n },\n\n /**\n * Returns the total character count across all confirmed chunks.\n *\n * Used to compute visible_offset for segment provenance.\n *\n * @returns Total character count.\n */\n confirmedCharCount(): number {\n return chunks.reduce((sum, c) => sum + c.text.length, 0);\n },\n\n /**\n * Returns the concatenated text of all confirmed chunks.\n *\n * This is the confirmed output that can be preserved on\n * interruption and used as prefix for stream stitching.\n *\n * @returns Concatenated confirmed text.\n */\n snapshot(): string {\n return chunks.map((c) => c.text).join('');\n },\n };\n};\n","/**\n * Multi-segment stream stitcher with provenance metadata per D-31 through D-33.\n *\n * Assembles output from multiple segments (potentially from different targets\n * after failover) into a single StitchedOutput with per-segment provenance\n * and continuation boundary markers.\n *\n * Cross-target continuations are annotated as non_deterministic per D-33/TRAN-02\n * because the output may not be semantically consistent across model boundaries.\n */\n\nimport type {\n ContinuationMode,\n SegmentProvenance,\n StitchedOutput,\n StreamBuffer,\n} from './types.js';\n\n/**\n * StreamStitcher interface for assembling multi-segment output.\n */\nexport interface StreamStitcher {\n addSegment(\n buffer: StreamBuffer,\n provenance: Omit<SegmentProvenance, 'visible_offset'>,\n ): void;\n assemble(): StitchedOutput;\n segmentCount(): number;\n}\n\n/**\n * Internal segment entry combining text with full provenance.\n */\ninterface SegmentEntry {\n readonly text: string;\n readonly provenance: SegmentProvenance;\n}\n\n/**\n * Determines the continuation mode based on target and model relationship per D-31.\n *\n * - Same target: same_target_resume (deterministic)\n * - Different target, same model: same_model_alternate_target\n * - Different target, different model: cross_model_semantic (non-deterministic)\n *\n * Note: controlled_reexecution is set by the orchestrator when no viable\n * continuation target exists, not by the stitcher.\n *\n * @param oldTargetId - The target ID of the previous segment.\n * @param newTargetId - The target ID of the new segment.\n * @param sameModel - Whether both targets serve the same model.\n * @returns The appropriate ContinuationMode.\n */\nexport const determineContinuationMode = (\n oldTargetId: string,\n newTargetId: string,\n sameModel: boolean,\n): ContinuationMode => {\n if (oldTargetId === newTargetId) {\n return 'same_target_resume';\n }\n return sameModel ? 'same_model_alternate_target' : 'cross_model_semantic';\n};\n\n/**\n * Creates a new StreamStitcher instance.\n *\n * The stitcher accumulates segments via addSegment() and produces\n * a final StitchedOutput via assemble() with:\n * - Concatenated text from all segments\n * - Per-segment provenance with computed visible_offset\n * - continuation_boundaries marking join points between segments\n *\n * @param _requestId - The correlation request ID (reserved for future audit use).\n * @returns A StreamStitcher instance.\n */\nexport const createStreamStitcher = (_requestId: string): StreamStitcher => {\n const segments: SegmentEntry[] = [];\n\n return {\n /**\n * Adds a segment to the stitcher.\n *\n * Computes visible_offset as the cumulative character count\n * of all previously added segments.\n *\n * @param buffer - The stream buffer containing the segment's chunks.\n * @param provenance - Segment provenance without visible_offset (computed here).\n */\n addSegment(\n buffer: StreamBuffer,\n provenance: Omit<SegmentProvenance, 'visible_offset'>,\n ): void {\n const visibleOffset = segments.reduce(\n (sum, entry) => sum + entry.text.length,\n 0,\n );\n segments.push({\n text: buffer.snapshot(),\n provenance: { ...provenance, visible_offset: visibleOffset },\n });\n },\n\n /**\n * Assembles the final stitched output.\n *\n * @returns StitchedOutput with concatenated text, segments, and boundaries.\n */\n assemble(): StitchedOutput {\n const text = segments.map((s) => s.text).join('');\n const provenanceList = segments.map((s) => s.provenance);\n const continuationBoundaries = provenanceList\n .slice(1)\n .map((p) => p.visible_offset);\n\n return {\n text,\n segments: provenanceList,\n continuation_boundaries: continuationBoundaries,\n };\n },\n\n /**\n * Returns the number of segments added so far.\n *\n * @returns Segment count.\n */\n segmentCount(): number {\n return segments.length;\n },\n };\n};\n","/**\n * Audit collector for per-request audit trail accumulation.\n *\n * Subscribes to routing events and accumulates FailoverAttempt\n * and SegmentProvenance records per request. On flush(), emits\n * a complete AuditRecord to pino with all AUDT-02 fields\n * (request_id, attempt_no, segment_no, selected_target, candidates,\n * selection_reason, failure_class, retry_no, failover_no, latency_ms, outcome).\n *\n * flush() is always called in a finally block even on zero-attempt\n * failures per Pitfall 3.\n */\n\nimport type pino from 'pino';\nimport type { FailoverAttempt } from '../routing/failover.js';\nimport type { SegmentProvenance } from './types.js';\nimport { createRequestLogger } from '../audit/logger.js';\n\n/**\n * AuditCollector interface for accumulating and flushing audit records.\n *\n * Single-use per request: after flush(), the collector emits\n * its accumulated data and is considered complete.\n */\nexport interface AuditCollector {\n /** Records a failover attempt. */\n recordAttempt(attempt: FailoverAttempt): void;\n /** Records a segment provenance entry. */\n recordSegment(segment: SegmentProvenance): void;\n /** Flushes the accumulated audit record to pino. */\n flush(\n outcome: 'success' | 'failure',\n finalTarget?: string,\n stats?: { total_retries?: number; total_failovers?: number; latency_ms?: number },\n ): void;\n}\n\n/**\n * Creates an AuditCollector for a specific request.\n *\n * The collector accumulates FailoverAttempt and SegmentProvenance\n * records and flushes them as a single pino log entry with\n * event_type 'request_complete'.\n *\n * @param logger - The base pino logger (a child logger with request_id is created internally).\n * @param requestId - The correlation request ID for this request.\n * @returns An AuditCollector instance.\n */\nexport const createAuditCollector = (\n logger: pino.Logger,\n requestId: string,\n): AuditCollector => {\n const requestLogger = createRequestLogger(logger, requestId);\n const attempts: FailoverAttempt[] = [];\n const segments: SegmentProvenance[] = [];\n\n return {\n recordAttempt(attempt) {\n attempts.push(attempt);\n },\n\n recordSegment(segment) {\n segments.push(segment);\n },\n\n flush(outcome, finalTarget, stats) {\n requestLogger.info({\n event_type: 'request_complete',\n outcome,\n final_target: finalTarget,\n total_attempts: attempts.length,\n total_segments: segments.length,\n total_retries: stats?.total_retries,\n total_failovers: stats?.total_failovers,\n latency_ms: stats?.latency_ms,\n attempts: [...attempts],\n segments: [...segments],\n });\n },\n };\n};\n","/**\n * Execution orchestrator: wires ModeAdapter + FailoverOrchestrator +\n * StreamStitcher + AuditCollector into a single execute call.\n *\n * Produces ExecutionResult with full provenance metadata including\n * segments, continuation_modes, targets_involved, degraded flag (D-38),\n * and heuristic_detection flag (D-37).\n *\n * AuditCollector.flush() is ALWAYS called via try/finally even on\n * zero-attempt failures (Pitfall 3).\n */\n\nimport type pino from 'pino';\nimport type {\n ModeAdapter,\n AdapterRequest,\n AdapterResult,\n ExecutionResult,\n ExecutionProvenance,\n ContinuationMode,\n StreamBuffer,\n} from './types.js';\nimport type {\n FailoverOrchestrator,\n FailoverResult,\n} from '../routing/failover.js';\nimport type { DeploymentMode } from '../mode/types.js';\nimport { generateCorrelationId, createRequestLogger } from '../audit/logger.js';\nimport { createAuditCollector } from './audit-collector.js';\nimport { createStreamBuffer } from './stream-buffer.js';\nimport { createStreamStitcher } from './stream-stitcher.js';\n\n/**\n * Dependencies for the execution orchestrator.\n */\nexport interface ExecutionDeps {\n /** Mode adapter for executing requests against targets. */\n readonly adapter: ModeAdapter;\n /** Failover orchestrator for retry-failover logic. */\n readonly failover: FailoverOrchestrator;\n /** Base pino logger for audit trail. */\n readonly logger: pino.Logger;\n /** Current deployment mode. */\n readonly mode: DeploymentMode;\n}\n\n/**\n * Execution orchestrator interface.\n */\nexport interface ExecutionOrchestrator {\n /** Executes a request through the full pipeline. */\n execute(request: AdapterRequest): Promise<ExecutionResult>;\n}\n\n/**\n * Internal value carried through the failover loop.\n *\n * Captures the adapter result and stream buffer from a successful attempt.\n */\ninterface AttemptValue {\n readonly buffer: StreamBuffer;\n readonly adapterResult: AdapterResult;\n}\n\n/**\n * Creates an execution orchestrator that composes adapter, failover,\n * stream stitcher, and audit collector into an end-to-end pipeline.\n *\n * @param deps - Execution dependencies.\n * @returns An ExecutionOrchestrator instance.\n */\nexport const createExecutionOrchestrator = (\n deps: ExecutionDeps,\n): ExecutionOrchestrator => ({\n async execute(request: AdapterRequest): Promise<ExecutionResult> {\n const requestId = request.request_id || generateCorrelationId();\n const auditCollector = createAuditCollector(deps.logger, requestId);\n const stitcher = createStreamStitcher(requestId);\n const startMs = Date.now();\n\n const heuristicFlags: boolean[] = [];\n let outcome: 'success' | 'failure' = 'failure';\n let finalTarget: string | undefined;\n let summaryAttempts = 0;\n let summaryRetries = 0;\n let summaryFailovers = 0;\n let summaryTargets: string[] = [];\n\n try {\n const failoverResult: FailoverResult = await deps.failover.execute(\n requestId,\n async (targetId) => {\n const buffer = createStreamBuffer();\n const adapterResult = await deps.adapter.execute(targetId, request);\n\n // Accumulate chunks into buffer\n for (const chunk of adapterResult.chunks) {\n buffer.append(chunk);\n }\n\n heuristicFlags.push(\n adapterResult.detection_mode === 'heuristic',\n );\n\n const value: AttemptValue = { buffer, adapterResult };\n return {\n success: adapterResult.success,\n value,\n error_class: adapterResult.error_class,\n latency_ms: adapterResult.latency_ms,\n };\n },\n [],\n );\n\n // Record all attempts to audit collector\n for (const attempt of failoverResult.attempts) {\n auditCollector.recordAttempt(attempt);\n }\n\n // Capture summary data for finally-block logging\n summaryAttempts = failoverResult.attempts.length;\n summaryRetries = failoverResult.total_retries;\n summaryFailovers = failoverResult.total_failovers;\n summaryTargets = [...new Set(failoverResult.attempts.map((a) => a.target_id))];\n\n if (failoverResult.outcome === 'success') {\n outcome = 'success';\n finalTarget = failoverResult.target_id;\n const attemptValue = failoverResult.value as AttemptValue;\n\n // Add segment to stitcher\n const continuationMode: ContinuationMode =\n stitcher.segmentCount() === 0\n ? 'same_target_resume'\n : 'same_target_resume';\n\n stitcher.addSegment(attemptValue.buffer, {\n request_id: requestId,\n segment_id: stitcher.segmentCount(),\n source_target_id: failoverResult.target_id,\n continuation_mode: continuationMode,\n non_deterministic: false,\n });\n\n const segmentProvenance = stitcher.assemble().segments;\n for (const seg of segmentProvenance) {\n auditCollector.recordSegment(seg);\n }\n\n const stitchedOutput = stitcher.assemble();\n const isDegraded = deps.mode === 'plugin-only';\n const isHeuristic = heuristicFlags.some(Boolean);\n\n const uniqueModes = [\n ...new Set(stitchedOutput.segments.map((s) => s.continuation_mode)),\n ];\n const uniqueTargets = [\n ...new Set(stitchedOutput.segments.map((s) => s.source_target_id)),\n ];\n\n const provenance: ExecutionProvenance = {\n request_id: requestId,\n segments: stitchedOutput.segments,\n continuation_modes: uniqueModes,\n targets_involved: uniqueTargets,\n total_attempts: failoverResult.attempts.length,\n degraded: isDegraded,\n degraded_reason: isDegraded\n ? 'plugin-only mode: limited failover capability'\n : undefined,\n heuristic_detection: isHeuristic,\n };\n\n return {\n success: true,\n output: stitchedOutput.text,\n provenance,\n };\n }\n\n // Failure path\n const isDegraded = deps.mode === 'plugin-only';\n const isHeuristic = heuristicFlags.some(Boolean);\n\n const provenance: ExecutionProvenance = {\n request_id: requestId,\n segments: [],\n continuation_modes: [],\n targets_involved: [],\n total_attempts: failoverResult.attempts.length,\n degraded: isDegraded,\n degraded_reason: isDegraded\n ? 'plugin-only mode: limited failover capability'\n : undefined,\n heuristic_detection: isHeuristic,\n };\n\n return {\n success: false,\n output: '',\n provenance,\n };\n } finally {\n auditCollector.flush(outcome, finalTarget);\n\n // Per-request summary log (D-83)\n const requestLogger = createRequestLogger(deps.logger, requestId);\n const endMs = Date.now();\n requestLogger.info({\n event: 'request_summary',\n component: 'execution',\n outcome,\n total_attempts: summaryAttempts,\n total_failovers: summaryFailovers,\n total_retries: summaryRetries,\n latency_ms: endMs - startMs,\n targets_used: summaryTargets,\n final_target: finalTarget ?? null,\n }, 'Request complete');\n }\n },\n});\n","/**\n * Plugin-only mode adapter per D-27, D-28.\n *\n * In plugin-only mode, the adapter operates within OpenCode's plugin lifecycle.\n * The chat.params hook is param-adjust-only (D-16, D-28): it can adjust\n * temperature, topP, topK, maxOutputTokens, and options but CANNOT redirect\n * requests to different providers or models.\n *\n * Error detection is heuristic-only because plugin-only mode lacks access\n * to raw HTTP status codes (Pitfall 1). Classification is based on\n * error message patterns from the chat.message error event.\n *\n * This adapter is a stub for Phase 3. The real implementation requires\n * integration with OpenCode plugin lifecycle hooks (chat.params, chat.message)\n * which cannot be unit-tested in isolation. The interface contract is\n * established here; full wiring happens in Phase 4 integration testing.\n */\n\nimport type { ModeAdapter, AdapterRequest, AdapterResult } from '../types.js';\nimport type { AdapterDeps } from './types.js';\n\n/**\n * Creates a plugin-only mode adapter.\n *\n * Per D-50, D-51: targetId maps to TargetEntry.profile for credential resolution.\n * The adapter receives target_id which encodes the profile. The credential lookup\n * uses the registry's TargetEntry.profile to resolve the correct auth entry from\n * OpenCode's provider context.\n *\n * @param _deps - Adapter dependencies (classifier, reserved for Phase 4 wiring).\n * @returns A ModeAdapter for plugin-only deployment mode.\n */\nexport const createPluginAdapter = (_deps: AdapterDeps): ModeAdapter => ({\n /**\n * Executes a request in plugin-only mode.\n *\n * Phase 3 stub: returns a not-yet-implemented result.\n * Phase 4 will wire this to OpenCode plugin lifecycle hooks.\n *\n * @param _targetId - The target to execute against.\n * @param _request - The adapter request payload.\n * @returns AdapterResult with heuristic detection mode.\n */\n async execute(\n _targetId: string,\n _request: AdapterRequest,\n ): Promise<AdapterResult> {\n const start = Date.now();\n return {\n success: false,\n chunks: [],\n error_class: undefined,\n latency_ms: Date.now() - start,\n detection_mode: 'heuristic' as const,\n };\n },\n});\n","/**\n * Server-companion mode adapter per D-27, D-29.\n *\n * In server-companion mode, the adapter communicates with the OpenCode\n * server's HTTP/WebSocket API via the @opencode-ai/sdk client.\n *\n * Error detection is direct: the SDK's ApiError provides statusCode\n * and responseHeaders (including Retry-After) for precise classification\n * (per Pitfall 5).\n *\n * This adapter is a stub for Phase 3. The real implementation requires\n * an HTTP client to the companion server, which is wired in Phase 4\n * integration testing.\n */\n\nimport type { ModeAdapter, AdapterRequest, AdapterResult } from '../types.js';\nimport type { AdapterDeps } from './types.js';\n\n/**\n * Creates a server-companion mode adapter.\n *\n * Per D-51: targetId maps to TargetEntry.profile. Server/SDK adapters pass the\n * profile identifier to the OpenCode SDK for credential lookup, enabling\n * per-profile authentication when multiple auth profiles exist for the same provider.\n *\n * @param _deps - Adapter dependencies (classifier, reserved for Phase 4 wiring).\n * @returns A ModeAdapter for server-companion deployment mode.\n */\nexport const createServerAdapter = (_deps: AdapterDeps): ModeAdapter => ({\n /**\n * Executes a request in server-companion mode.\n *\n * Phase 3 stub: returns a not-yet-implemented result.\n * Phase 4 will wire this to the OpenCode SDK client, extracting\n * statusCode, responseHeaders['retry-after'], and responseBody\n * from SDK ApiError for direct error classification.\n *\n * @param _targetId - The target to execute against.\n * @param _request - The adapter request payload.\n * @returns AdapterResult with direct detection mode.\n */\n async execute(\n _targetId: string,\n _request: AdapterRequest,\n ): Promise<AdapterResult> {\n const start = Date.now();\n return {\n success: false,\n chunks: [],\n error_class: undefined,\n latency_ms: Date.now() - start,\n detection_mode: 'direct' as const,\n };\n },\n});\n","/**\n * SDK-control mode adapter per D-27, D-29.\n *\n * In SDK-control mode, the adapter uses the @opencode-ai/sdk client\n * to directly control the OpenCode server, managing sessions,\n * provider selection, and auth credential injection.\n *\n * Error detection is direct: the SDK provides full HTTP status codes\n * and response headers for precise error classification.\n *\n * This adapter is a stub for Phase 3. The real implementation requires\n * the OpenCode SDK client with session management, which is wired\n * in Phase 4 integration testing.\n */\n\nimport type { ModeAdapter, AdapterRequest, AdapterResult } from '../types.js';\nimport type { AdapterDeps } from './types.js';\n\n/**\n * Creates an SDK-control mode adapter.\n *\n * @param _deps - Adapter dependencies (classifier, reserved for Phase 4 wiring).\n * @returns A ModeAdapter for SDK-control deployment mode.\n */\nexport const createSdkAdapter = (_deps: AdapterDeps): ModeAdapter => ({\n /**\n * Executes a request in SDK-control mode.\n *\n * Phase 3 stub: returns a not-yet-implemented result.\n * Phase 4 will wire this to the OpenCode SDK client with full\n * session management and provider control capabilities.\n *\n * @param _targetId - The target to execute against.\n * @param _request - The adapter request payload.\n * @returns AdapterResult with direct detection mode.\n */\n async execute(\n _targetId: string,\n _request: AdapterRequest,\n ): Promise<AdapterResult> {\n const start = Date.now();\n return {\n success: false,\n chunks: [],\n error_class: undefined,\n latency_ms: Date.now() - start,\n detection_mode: 'direct' as const,\n };\n },\n});\n","/**\n * Adapter factory: selects the correct ModeAdapter by DeploymentMode.\n *\n * Provides a single entry point for creating the appropriate adapter\n * based on the resolved deployment mode. Uses exhaustive switch\n * with never default for type safety.\n */\n\nimport type { DeploymentMode } from '../../mode/types.js';\nimport type { ModeAdapter } from '../types.js';\nimport type { AdapterDeps } from './types.js';\nimport { createPluginAdapter } from './plugin-adapter.js';\nimport { createServerAdapter } from './server-adapter.js';\nimport { createSdkAdapter } from './sdk-adapter.js';\n\n/**\n * Creates the appropriate ModeAdapter for the given deployment mode.\n *\n * @param mode - The resolved deployment mode.\n * @param deps - Shared adapter dependencies.\n * @returns The ModeAdapter implementation for the specified mode.\n * @throws Error if an unknown deployment mode is provided (compile-time exhaustive check).\n */\nexport const createModeAdapter = (\n mode: DeploymentMode,\n deps: AdapterDeps,\n): ModeAdapter => {\n switch (mode) {\n case 'plugin-only':\n return createPluginAdapter(deps);\n case 'server-companion':\n return createServerAdapter(deps);\n case 'sdk-control':\n return createSdkAdapter(deps);\n default: {\n const _exhaustive: never = mode;\n throw new Error(`Unknown deployment mode: ${String(_exhaustive)}`);\n }\n }\n};\n","/**\n * Bearer token authentication middleware for server-companion mode.\n *\n * Per D-44: Server-companion mode operator endpoints require Bearer token\n * authentication. Plugin-only mode commands inherit OpenCode session auth.\n *\n * Per Pitfall 3: Uses crypto.timingSafeEqual for constant-time token\n * comparison to prevent timing attacks.\n */\n\nimport { timingSafeEqual } from 'node:crypto';\n\n/** Result of bearer token validation. */\nexport interface AuthResult {\n readonly authorized: boolean;\n readonly reason?: string;\n}\n\n/**\n * Validates a Bearer token from the Authorization header.\n *\n * @param authHeader - The raw Authorization header value, or undefined if absent.\n * @param expectedToken - The expected token to compare against.\n * @returns AuthResult indicating whether the request is authorized.\n */\nexport const validateBearerToken = (\n authHeader: string | undefined,\n expectedToken: string,\n): AuthResult => {\n if (authHeader === undefined) {\n return { authorized: false, reason: 'missing Authorization header' };\n }\n\n if (!authHeader.startsWith('Bearer ')) {\n return { authorized: false, reason: 'invalid Authorization scheme' };\n }\n\n const token = authHeader.slice(7); // 'Bearer '.length === 7\n\n // Length check before timingSafeEqual: the function requires equal-length\n // buffers. Different lengths immediately reveal mismatch without timing leak\n // because the length itself is not secret information.\n if (token.length !== expectedToken.length) {\n return { authorized: false, reason: 'invalid token' };\n }\n\n const tokenBuffer = Buffer.from(token);\n const expectedBuffer = Buffer.from(expectedToken);\n\n if (!timingSafeEqual(tokenBuffer, expectedBuffer)) {\n return { authorized: false, reason: 'invalid token' };\n }\n\n return { authorized: true };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBO,IAAM,uBAAuB,CAClC,SACmB;AACnB,MAAI,SAAS,QAAQ;AACnB,WAAO;AAAA,EACT;AAGA,SAAO;AACT;AAQO,IAAM,oBAAoB,CAAC,SAAyC;AACzE,MAAI,SAAS,eAAe;AAC1B,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAQO,IAAM,sBAAsB,CAAC,SAA2C;AAC7E,MAAI,SAAS,eAAe;AAC1B,WAAO;AAAA,MACL;AAAA,MACA,gBAAgB;AAAA,MAChB,eAAe;AAAA,MACf,qBAAqB;AAAA,MACrB,gBAAgB;AAAA,IAClB;AAAA,EACF;AACA,SAAO;AAAA,IACL;AAAA,IACA,gBAAgB;AAAA,IAChB,eAAe;AAAA,IACf,qBAAqB;AAAA,IACrB,gBAAgB;AAAA,EAClB;AACF;;;ACvCO,IAAM,oBAAyD;AAAA;AAAA,EAEpE,EAAE,UAAU,aAAa,aAAa,KAAK,kBAAkB,cAAc,kBAAkB,yBAAyB,aAAa,gBAAgB;AAAA,EACnJ,EAAE,UAAU,aAAa,aAAa,KAAK,kBAAkB,cAAc,kBAAkB,wBAAwB,aAAa,cAAc;AAAA,EAChJ,EAAE,UAAU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