Commit Graph

1473 Commits

Author SHA1 Message Date
Luis Pater
81018ba473 fix(antigravity): mark TOS pause 503 error as request-scoped
- Add a requestScoped flag and IsRequestScoped method on statusErr so executor errors can explicitly opt into request-scoped handling without affecting ordinary status errors.
- Return a request-scoped 503 via newAntigravityTOSPauseStatusErr across Execute, executeClaudeNonStream, ExecuteStream, and CountTokens so the conductor stops immediately without rotating or cooling healthy credentials.
- Add executor and manager regression tests covering non-streaming, Claude non-streaming, streaming, and token-counting paths under an active TOS pause.

Closes: #7748
2026-11-21 15:11:50 +08:00
Luis Pater
8e5a98e886 fix(antigravity): publish unavailable credits hint when no GOOGLE_ONE_AI entry matches
- Publish a known-unavailable credits hint after inspecting paidTier.availableCredits when the array is missing, empty, or lacks a parseable GOOGLE_ONE_AI entry.
- Bound loadCodeAssist response reads with io.LimitReader and validate JSON before publishing to avoid unbounded reads or false negative hints.
- Add race-tested unit tests covering empty/unmatched availableCredits, stale positive hint replacement, oversized bodies, and invalid JSON responses.

Closes: #7750
2026-11-21 15:10:25 +08:00
Luis Pater
8906442bd4 fix(auth): align VerifyInference with per-auth transport, auth prep, and cancellation
- Attach per-auth RoundTripper before prepareRequestAuth and retry once after 401 while fencing credential epoch and version.
- Select text-capable models without forcing gpt-5 on non-Codex/OpenAI providers and restrict max_output_tokens=16 to Codex.
- Honor caller cancellation across preparation, refresh, and stream drain without recording failure or cooldown, with unit and end-to-end tests.

Closes: #7737
2026-11-21 12:30:11 +08:00
hkfires
20211183c5 fix(copilot): use execution mode for claude stream translation
Force the stream hint for the OpenAI-to-Claude response translator
whenever ExecuteStream is used, even if the original request set
stream:false or omitted it. Keep the original request unchanged
and add coverage for omitted, true, and false values.
2026-11-21 12:14:05 +08:00
hkfires
9792ac281e fix(copilot): translate copilot streaming responses
Forward typed SSE events through response translators instead of
emitting them raw, so non-native formats receive translated chunks.
2026-11-21 11:38:49 +08:00
hkfires
b824c05297 fix(copilot): return gemini format for count tokens
Use GeminiTokenCountJSON for Gemini-format requests instead of
falling back to OpenAI usage JSON, and reuse the shared Claude
input_tokens helper for Claude and OpenAI Response formats.
2026-11-21 10:58:18 +08:00
Luis Pater
5dff8b6728 feat(copilot): support OAuth model aliases and exact route-aware selection
- Publish Copilot catalog and plugin models with native IDs, aliases, and auth prefixes while preserving suffixed routes.
- Route requests through exact registered Copilot models and send the resolved native model upstream.
- Reconcile Copilot model states and route metadata against published routes; document Copilot support in OAuth alias and error configuration.
2026-11-21 09:54:53 +08:00
hkfires
7ae771fcb4 feat(copilot): add GitHub Copilot provider support
Add device OAuth login via `--copilot-login`, trusted-endpoint token
exchange, and per-account model catalog discovery with independent
refresh so accounts expose only entitled Chat, Messages, or Responses
routes.

Implement the executor with official CLI parity defaults, cross-protocol
translation, account-scoped thinking, turn linking, and server-side
replay of private reasoning and signatures, keeping payload rules final.
2026-11-20 23:14:11 +08:00
Luis Pater
2f57a5a67e fix(auth): honor request-scoped-errors, Retry-After, and credential scope on PrepareRequestAuth failure
- Route errPrepare through the same error pipeline as execution errors in all four conductor paths (Execute/CountTokens/Stream/Home): record RetryAfter and CredentialScope, match request-scoped error rules, stop on stop-actions and invalid requests, and preserve the upstream attempt via markUpstreamExecutionAttemptFromContext plus annotateTrustedRetryAfterByHint/syncPreferredUpstreamError so stop responses keep their retry hint.
- Mark upstream attempts only at real HTTP boundaries (OAuth token refresh, project discovery) and propagate upstream Retry-After and credential scope from Antigravity prepare failures, while keeping local missing-credential errors and status-less transport faults from being misclassified or outranking a genuine upstream rejection.

Closes: #7726
2026-11-20 20:56:13 +08:00
sususu98
2e940ba1e5 test(meta): add regression coverage for incomplete synthesis and refusal fallbacks
- Cover response.incomplete synthesis and multi-part (output_text + refusal) message synthesis in ResponsesStreamOutputTracker and MetaExecutor.ExecuteStream.
- Add empty-delta fallback, response.created delta-state reset, and empty refusal->text fallback tests for Codex OpenAI Chat, Gemini, and Interactions translators.
2026-11-20 19:19:24 +08:00
sususu98
e442c32d4f fix(meta): tighten Responses output synthesis tracking and refusal fallbacks
- Mark unkeyed message response.output_item.done as seen to prevent duplicate terminal synthesis.
- Preserve fallback output_index tracking for ID-bearing events without colliding with shifted item IDs, require item.type == message in Observe, and skip duplicate response.content_part.added frames.
- Guard Claude HasTextDelta on non-empty deltas, skip empty strings in Interactions codexContentText fallback, reset HasMessageTextDelta on OpenAI Chat response.created, and build Gemini refusal parts via ojson.Doc.
2026-11-20 18:57:46 +08:00
sususu98
ca459712c0 fix(meta): synthesize unstreamed Responses messages and translate refusal parts
- Track streamed message items in ResponsesStreamOutputTracker and synthesize missing item/part/delta/done events before terminal response.completed or response.incomplete when upstream omits item-level SSE frames.
- Include response.refusal.delta in HasMeaningfulCodexOutputDelta.
- Support refusal content parts and response.refusal.delta across Codex response translators (OpenAI Chat, Claude, Gemini, and Interactions) with regression tests.
2026-11-20 18:20:36 +08:00
Luis Pater
bba22ed9be fix(executor): ignore Claude Code attribution block in reasoning replay lane
- Filter x-anthropic-billing-header: system text and text blocks via util.IsClaudeCodeAttributionSystemText before hashing the Claude replay system lane, matching translator stripping behavior.
- Return an empty lane when system contains only attribution content so per-request cch and cc_prompt_id changes no longer break multi-turn thoughtSignature replay.
- Add regression tests verifying signature replay across changing attribution headers, attribution-only edge cases, and preserved main vs. title lane isolation.

Closes: #7766
2026-11-20 09:00:53 +08:00
Luis Pater
3a24d03cdd feat(antigravity): scope synthesized request.sessionId per credential
- Derive synthesized Antigravity request.sessionId deterministically from auth.ID and canonical, execution, or derived session identity across non-stream, Claude non-stream, and streaming paths.
- Scope the content-based fallback session ID by auth.ID so credential failovers emit a fresh request.sessionId while keeping explicit request.sessionId values and reasoning replay keys unchanged.
- Add regression tests verifying cross-model stability on the same credential and sessionId rotation across credential failover.

Closes: #7706
2026-11-20 08:30:42 +08:00
Luis Pater
99a1c1caad fix(antigravity): bound post-refresh credits warm to prevent goroutine leak and refresh deadlock
- Use context.WithTimeout(lifecycle, antigravityCreditsHintRefreshTimeout) for the post-OAuth-refresh credits warm so a stalled loadCodeAssist no longer leaks the goroutine or permanently wedges state.task.
- Keep lifecycle bound to the caller context to preserve issue-6199 caller-cancellation semantics while giving the request an independent bounded budget.
- Add a regression test proving the stalled task self-releases and a subsequent refresh republishes the credits balance.

Closes: #7702
2026-11-20 02:32:04 +08:00
Luis Pater
0861f9e1d1 fix(antigravity): align OAuth token refresh transport and User-Agent
- Remove hardcoded Go-http-client/2.0 User-Agent and redundant Host header in refreshTokenSingleFlight so net/http emits a User-Agent matching the negotiated wire protocol.
- Route Antigravity OAuth token refreshes through an isolated HTTP/2-capable client with per-refresh idle connection cleanup while keeping HTTP/1.1 without ALPN scoped to Cloud Code PA endpoints.
- Add real-TLS regression tests covering HTTP/2 negotiation, HTTP/1.1 fallback, CONNECT proxy tunneling, decorator behavior, and per-credential connection isolation.

Closes: #7700
2026-11-20 02:15:31 +08:00
Luis Pater
91a3f455ea fix(claude): strip foreign advisor blocks after credential rebind
- Track advisor tool_use_id credential ownership in a bounded sliding-TTL store with shared KV first-writer-wins persistence and record minted blocks from 2xx JSON/SSE responses as well as post-rule accepted requests.
- Strip foreign advisor blocks and empty advisor-only turns via ojson.Doc in Execute, ExecuteStream, and countTokensUpstream before cloaking, payload rules, and CCH signing while preserving own-credential advisor state and paired ordinary tool_result blocks.
- Add regression tests covering streaming/non-streaming rebinds, 429 in-request failover, count_tokens, KV persistence/consistency, sliding TTL renewal, and payload-rule barrier ordering.

Closes: #7638
2026-11-19 23:08:32 +08:00
Luis Pater
6faa8d20b2 fix(codex): strip uniqueItems keyword from tool parameter schemas
- Add "uniqueItems" to the stripIncompatiblePatternsFromJSON fast-path guard and remove schema-level uniqueItems keys in stripIncompatiblePatterns while preserving literal properties.uniqueItems fields and non-schema user data.
- Update NormalizeCodexToolSchemas documentation and add regression tests across tool-schema, helps, and Codex HTTP and WebSocket executors.

Closes: #7690
2026-11-19 21:10:33 +08:00
Luis Pater
db7f177d6b feat(codex): manage session instructions across requests
- Add session-scoped instruction baselines with validation, expiration, and optional KV storage.
- Preserve instruction state across HTTP and WebSocket turns, rejecting invalid or unreconstructable session requests.
- Prevent internal session markers from reaching upstream or request logs.
2026-11-19 08:23:04 +08:00
Luis Pater
56ab15490a fix(codex): convert Interactions system instructions to developer messages
- Insert Interactions system instructions as a leading developer message in Codex input instead of forwarding them as `instructions`.
- Preserve instruction text and aliases while keeping Responses-format instructions unchanged.
2026-11-19 02:53:40 +08:00
Luis Pater
51e6095890 Merge pull request #7624 from router-for-me/payload
feat(payload): add regex and system/developer targets to replace
2026-11-17 22:47:13 +08:00
hkfires
9f6672f568 feat(payload): add path targets to payload replace rules
Allow payload replace rules to target arbitrary existing string
nodes via JSON paths relative to the provider payload root, as a
mutually exclusive alternative to role, positions, and all.

Resolve paths against the pre-write document, deduplicate nodes,
and skip missing, non-string, and computed values. Support queries,
projections, wildcard keys, escaped keys, and identity suffixes
while preserving concrete write tracking. Validate path targets
in config and document the new form in the example config.
2026-11-17 22:44:03 +08:00
sususu98
687caf786b feat(plugin): add optional executor usage attribution 2026-11-17 17:56:16 +08:00
Luis Pater
593df3274c Merge pull request #7625 from router-for-me/logging
fix(logging): separate local errors from upstream responses
2026-11-17 16:22:31 +08:00
sususu98
3b5de44b82 test(meta): verify documented inline audio request contract
Cover WAV and MP3 Chat audio through MetaExecutor streaming and non-streaming requests. Require nested input_audio data/format and reject flattened fields. Avoid injecting an empty format when the caller omits it.
2026-11-17 15:34:36 +08:00
hkfires
1c0ec3cec1 fix(logging): separate local errors from upstream responses
Store bounded local read, dial, and stream errors as diagnostics
instead of rendering them inside API RESPONSE sections, and render
them in the downstream RESPONSE section after status selection.
Prevent handler-synthesized payloads from appending to executor
capture or fabricating upstream responses for failed attempts.
2026-11-17 15:13:51 +08:00
hkfires
25501b6baa feat(payload): extend replace to system and developer roles
Allow payload replace rules to target system and developer
messages in addition to user, using final upstream roles after
translation. Count Claude system, Gemini systemInstruction,
and Responses instructions as the first system message, while
keeping assistant, tool, thinking, and non-text content
unmodified. Update validation, docs, and executor coverage.
2026-11-17 15:09:01 +08:00
hkfires
cc1d5d789a feat(payload): add regex support to payload replace rules
Allow payload.replace entries to use Go RE2 patterns via
{pattern, replacement} alongside existing literal mappings,
including capture expansion such as $1 and ${1}.

Skip invalid regex entries individually with index-only
warnings so valid replacements still apply without leaking
pattern text. Update YAML/JSON parsing, validation, docs,
and executor handling while preserving ordered, per-block
replacement semantics across supported layouts.
2026-11-17 13:20:51 +08:00
Luis Pater
4ed882f14d Merge pull request #7605 from router-for-me/payload
fix(executor): enforce payload rules as final barrier
2026-11-16 22:23:47 +08:00
hkfires
b4410dd590 fix(executor): enforce payload rules as final barrier
Move Claude prompt-cache stripping before payload finalization so
user-injected values survive, and extract count-tokens betas only
after finalization without changing business semantics.

Capture Codex instructions and xAI transcript input before payload
rules for duplex, replay, and compaction inheritance, and reuse the
exact finalized xAI websocket frame on retries. This prevents rules
from being applied twice, overwritten, or accumulating across turns.
2026-11-16 22:06:14 +08:00
Luis Pater
deacbf2199 fix(codex): preserve nested Retry-After headers on overload errors
- Extract error headers from nested Codex error and response.error payloads while keeping outer header precedence.
- Parse Retry-After hints on 502/503 and other recoverable transient status codes across terminal, WebSocket, and bootstrap failover paths.
- Add regression tests covering captured WS overload payloads, explicit 503 responses, header precedence, and cooldown scheduling.

Closes: #7600

 Conflicts:
	internal/runtime/executor/codex_executor_stream.go
	internal/runtime/executor/codex_websockets_errors.go
	internal/runtime/executor/codex_websockets_stream.go
2026-11-16 19:21:23 +08:00
sususu98
d11ff49978 Merge pull request #7457 from sususu98/fix/bio-policy-request-fault
fix(clienterror,openai): classify bio_policy and safety policy blocks as 400 request faults
2026-11-16 18:00:21 +08:00
sususu98
7dd360d9a2 fix(codex): preserve Retry-After headers on inferred WebSocket statuses 2026-11-16 17:14:51 +08:00
hkfires
5aa44948bd perf(executor): optimize payload user text replacement
Compute replacements during a single ForEach traversal and collect
only changed values before mutating the document, avoiding array
allocations and second lookups for unchanged text. Stop scanning
after the last targeted user position.
2026-11-16 15:03:59 +08:00
sususu98
5a373ede5b fix(codex,openai): preserve nested WS error headers and honor explicit SSE event types
- Read nested body/error HTTP status codes in parseCodexWebsocketErrorWithCooling and clearCodexReasoningReplayOnWebsocketError so Retry-After and request headers are preserved on typeless WebSocket errors.
- Guard responsesSSEPayloadHasError and SSE error inference behind explicit event/payload type checks so non-error frames such as response.metadata containing body.error are not rewritten into terminal errors.
2026-11-16 14:09:15 +08:00
sususu98
80e8350c95 fix(openai,codex): build stream errors via ojson.Doc and preserve SSE status
- Build OpenAI Responses stream error and failed chunks directly through ojson.Doc with single-exit serialization, supporting scalar error strings without map mutations.
- Preserve valid top-level and body envelope HTTP error status codes when normalizing typeless Codex SSE failures and Responses SSE frames.
- Normalize scalar and blank WebSocket error fields purely via ojson.Doc.
2026-11-16 13:50:58 +08:00
hkfires
f00a3d3910 feat(payload): add user text replacement payload rules
Add ordered literal replace rules that rewrite existing user
text at selected one-based positions, or all users, in the final
upstream payload after overrides and before filters.

Support OpenAI Chat, Claude, Responses/Codex, Gemini, and
Antigravity layouts while leaving system prompts, tools, images,
and thinking untouched. Validate and sanitize rule config,
preserve it through YAML/JSON and runtime cloning, surface it
in config diffs and SDK types, and document it in the example
config.
2026-11-16 13:36:40 +08:00
sususu98
20df0c25b2 fix(codex): preserve string errors and recognize untyped failures
Normalize string websocket errors without discarding their messages. Recognize untyped and body-wrapped failures across SSE, websocket, and duplex paths while retaining status, headers, and sequence numbers.

Cover transport and format combinations, replay invalidation, credential status precedence, and Responses framing with regression tests.
2026-11-16 12:28:56 +08:00
sususu98
1f76e479c4 fix(clienterror,openai): classify bio_policy and safety policy blocks as 400 request faults
- Add bio_policy, cyber_policy_violation, misalignment_policy_violation, content_policy_violation, and image_content_policy_violation to request-fault codes so policy rejections stop failover without cooling down credentials.
- Unify trusted error JSON extraction across auth, model-not-found, credit-balance, and request-fault checks while restricting wrapper unwrapping and policy-text matching to prevent prompt-echo false positives.
- Map typeless policy error codes and body.error layouts consistently across Codex SSE/WebSocket, Responses, xAI, and Claude stream translation paths, filling blank messages with official fallback copy.
2026-11-16 12:28:56 +08:00
Luis Pater
8bdffcadc1 fix(claude): strip thinking suffix from advisor tool model
- Strip thinking suffixes from `advisor_*` tool `model` fields inside `sanitizeClaudeMessagesForClaudeUpstreamWithDebugDoc` before payload config rules run.
- Preserve each advisor tool's own base model and leave non-advisor tool entries untouched.
- Add regression tests covering API key and OAuth flows across `Execute`, `ExecuteStream`, `CountTokens`, payload overrides, and edge cases.

Closes: #7591
2026-11-16 10:31:56 +08:00
Luis Pater
508f8708d0 chore: replace standard JSON package with moego JSON throughout the project 2026-11-16 09:58:12 +08:00
Luis Pater
b4fdfdece3 chore: replace standard regexp with moego regexp throughout the project 2026-11-16 03:02:43 +08:00
Luis Pater
43806c865d fix(translator): map Claude json_schema format to output_config.format
- Route OpenAI Chat Completions response_format and Responses text.format json_schema payloads to Claude output_config.format via ojson.Doc while keeping system-prompt fallback for legacy Claude models and non-schema formats.
- Preserve optional schema name and description in a short system instruction without repeating the JSON schema body.
- Include output_config.format.schema in local Claude input token estimation and add translator and executor regression tests.

Closes: #7576
2026-11-15 22:32:47 +08:00
Luis Pater
7e82d0d1ca fix(executor): skip credential cooldown on Gemini zero-output 502 errors
- Tag Gemini-family zero-output HTTP 502 errors and translated Claude MALFORMED_FUNCTION_CALL error payloads with ErrorCodeTransientTransport across Antigravity, Gemini, Vertex, and AI Studio executors so Conductor skips credential cooldown while preserving per-request rotation and cross-provider failover.
- Update existing Claude MALFORMED_FUNCTION_CALL conductor tests to assert failed execution results and failed usage metrics without placing credentials into cooldown.
- Add unit and HTTP handler regression tests verifying uncooled rotation, cross-provider failover, and groundingChunks-only Claude fallback paths across Gemini-family executors.

Closes: #7571
2026-11-15 22:00:34 +08:00
Luis Pater
ed1c23f9ac fix(gemini): honor 429 Retry-After and RetryInfo hints in cooldown
- Extract positive HTTP 429 retry delays from Google RPC RetryInfo/ErrorInfo details, Retry-After headers, and human-readable error messages while preserving zero-delay semantics in ParseRetryDelay.
- Propagate parsed retryAfter hints on non-2xx status errors across Gemini and Vertex executors, including Gemini Interactions non-stream and stream paths.
- Add deterministic regression tests covering cooldown scheduling, Retry-After header and message parsing edge cases, and Antigravity zero-delay compatibility.

Closes: #7565
2026-11-15 16:30:38 +08:00
Luis Pater
3d1a0e0d10 fix(thinking,registry): preserve native Gemini thinkingLevel and isolate provider lookups
- Preserve ModeLevel in normalizeUserDefinedConfig for native Gemini/Interactions requests and user-defined models with explicit thinking levels.
- Enforce strict provider scoping in ModelRegistry.GetModelInfo and prioritize channel-specific static catalog fallback in LookupModelInfo.
- Add unit and Vertex executor regression tests covering user-defined Gemini thinkingLevel preservation and cross-provider shadowing.

Closes: #7558
2026-11-15 15:07:18 +08:00
Luis Pater
e96d4c4818 fix(antigravity): disable pool-wide TOS pause by default
- Only enable the protective pause when a positive duration is explicitly configured.
- Treat unset, invalid, and nonpositive windows as disabled.
2026-11-15 03:40:53 +08:00
Luis Pater
1d39a9de84 fix(translator): translate gemini response format and builtin tools for interactions
- Convert generationConfig responseModalities, imageConfig, responseMimeType, and responseSchema fields into top-level response_format entries while stripping unsupported nested fields from generation_config.
- Flatten urlContext, codeExecution, and googleSearch builtin tool options onto the tool object top level and convert searchTypes objects into snake_case search_types arrays.
- Update builtin tool tests and add translator and Gemini executor regression tests for Issue #7544.

Closes: #7544
2026-11-14 19:13:54 +08:00
Luis Pater
905e70c48b feat(executor): add Go RE2 sensitive-patterns-replace support for Antigravity, Devin, and Claude
- Add sensitive-patterns-replace configuration rules with load-time RE2 validation, comment-preserving YAML persistence, config diffing, and bounded matcher caching across Antigravity, Devin, and Claude cloak paths.
- Apply ordered non-cascading regex replacements against original text boundaries while preserving Devin original-line drop ownership and existing sensitive-words-replace semantics.

Closes: #7540
2026-11-14 16:33:48 +08:00
Luis Pater
f2efe2c413 fix(antigravity): fail signature-only zero-output streams without finishReason before HTTP 200 commit
- Stop counting signature-only empty-text parts as thought output in InspectGeminiZeroOutputPayload so leading signature-only frames stay buffered until real content arrives.
- Fail buffered candidate-bearing zero-output streams with a retryable 502 on EOF in GeminiZeroOutputStreamGuard.Finalize and harden Antigravity OpenAI streaming translation against all-null delta emission.
- Add unit, executor, and HTTP failover regression tests covering signature-only zero-output streams across downstream formats and credential rotation.

Closes: #7536
2026-11-14 14:30:19 +08:00