codex-copilot-dx 1.4.1 → 1.4.3
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.
- package/README.md +2 -1
- package/docs/ARCHITECTURE.md +10 -2
- package/docs/REFERENCE.md +15 -6
- package/package.json +1 -1
- package/src/adapter.mjs +10 -2
- package/src/antigravity-chat-bridge.mjs +2 -2
- package/src/antigravity-handler.mjs +1 -1
- package/src/antigravity-models.mjs +19 -10
- package/src/antigravity-runtime.mjs +7 -3
- package/src/carbon-tool-bridge.mjs +3 -1
- package/src/cli-command-spec.mjs +2 -2
- package/src/cli-management.mjs +4 -4
- package/src/copilot-client.mjs +8 -3
- package/src/dashboard/gemini.js +3 -3
- package/src/dashboard/index.html +3 -3
- package/src/dashboard/language.js +10 -3
- package/src/dashboard/status.js +1 -1
- package/src/dashboard/tool-activity.js +74 -28
- package/src/dashboard/ui.css +2 -1
- package/src/live-models.mjs +5 -3
- package/src/model-cache.mjs +3 -2
- package/src/model-capabilities.mjs +1 -1
- package/src/model-catalog.mjs +37 -0
- package/src/profile-model-runtime.mjs +2 -1
- package/src/provider-metadata.mjs +2 -1
- package/src/providers/api.mjs +8 -6
- package/src/providers/m365.mjs +5 -4
- package/src/responses-bridge.mjs +23 -8
- package/src/responses-request.mjs +3 -0
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Use your model services in **Codex App, Claude App and Claude Code** through one local gateway.
|
|
4
4
|
|
|
5
|
-
On macOS, the optional Gemini integration adds Copilot
|
|
5
|
+
On macOS, the optional Gemini integration adds compatible Copilot Gemini models to the original App's Antigravity. Ordinary Gemini chat keeps Google. The Antigravity page lists each model once, with its advertised reasoning levels shown in the same format as Codex and Claude. Refresh the catalog there or with `ccdx app antigravity models --refresh`. Existing clients keep their setup.
|
|
6
6
|
|
|
7
7
|
Connect GitHub Copilot, Microsoft 365 or your own API. Choose which apps can use each source, then select their models. CI and prebuilt releases cover **macOS on Apple Silicon** and **Windows on x64/ARM64**. Intel Mac code remains available, without CI coverage or new prebuilt assets.
|
|
8
8
|
|
|
@@ -57,6 +57,7 @@ Model availability depends on your account and service. Microsoft 365 also requi
|
|
|
57
57
|
| Inspect compression | `ccdx compact status` / `ccdx compact enable` / `ccdx compact disable` |
|
|
58
58
|
| Inspect failures | `ccdx requests --failed` |
|
|
59
59
|
| Inspect observed tool calls | `ccdx requests tools` / `ccdx requests tools --active` |
|
|
60
|
+
| Inspect active model requests | `ccdx requests --active` |
|
|
60
61
|
| Capture one upstream error | `ccdx requests diagnose --source api_work --model model-id --yes` |
|
|
61
62
|
| Read usage | `ccdx usage` / `ccdx usage --provider google --days 7` / `ccdx usage --purpose diagnostic` / `ccdx usage --scope run` |
|
|
62
63
|
| Inspect preferences | `ccdx config show --effective` |
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -34,13 +34,15 @@ or `/antigravity/` routes. Existing inference routes return before that dispatch
|
|
|
34
34
|
|
|
35
35
|
`antigravity-handler.mjs` preserves observed Google account/catalog control
|
|
36
36
|
requests against fixed official Code Assist origins. It merges advertised
|
|
37
|
-
Copilot
|
|
37
|
+
compatible Copilot Gemini aliases while retaining native models and defaults. The catalog drives model names, limits, vision and reasoning aliases, including xhigh; there is no per-model allowlist. Explicit image-only, disabled, non-streaming/non-tool and non-Chat declarations are excluded. Native
|
|
38
38
|
Google agent requests pass through; selected Copilot agents and all unattributed
|
|
39
39
|
background inference use Copilot. Summaries use Carbon Low, searches use the
|
|
40
40
|
existing Copilot search transport, and images use the existing GHC Images API.
|
|
41
41
|
Ordinary Gemini chat is outside this endpoint scope; parent-App route adoption
|
|
42
42
|
and ordinary-chat isolation require native App acceptance beyond engine replay.
|
|
43
43
|
|
|
44
|
+
The existing Antigravity refresh control sends an explicit `refresh` operation through the GitHub catalog runtime. Status and summary reads remain cached. Refresh failures preserve the last-good catalog; selection and draft writes remain separate. `app antigravity models --refresh` shares this boundary. The capability projection also preserves explicit Copilot `vision=false` as text-only while retaining native-template fallback for unknown vision, following [CC Switch's capability fix](https://github.com/farion1231/cc-switch/commit/fc3eb797c72e054d554eea6a2e7a8b93933c6ac5).
|
|
45
|
+
|
|
44
46
|
The Chat bridge keeps lossless tool integers, explicit effort, cancellation,
|
|
45
47
|
stream backpressure, privacy-token restoration and terminal errors. Native
|
|
46
48
|
conversation labels feed the existing source guard before main-answer dispatch.
|
|
@@ -683,6 +685,12 @@ load only when requested. Allowed function lists retain their
|
|
|
683
685
|
restriction and returned Chat calls are checked before completion. Chat cache
|
|
684
686
|
fields are forwarded only when the catalog explicitly advertises each field.
|
|
685
687
|
|
|
688
|
+
Loaded Carbon tool declarations use last-value replacement by type/namespace/name while retaining the first offered Map slot and alias. The initial list keeps its conflicting-definition check; input-carried additions and search results resolve against the effective inventory. This adopts the narrow dynamic-declaration behavior from [Floway](https://github.com/Menci/Floway/commit/2e5a4bed646f02e1054e71089232c63036c21f2f).
|
|
689
|
+
|
|
690
|
+
`model-catalog.mjs` normalizes one source/account list at ingestion and public projection. Unique lists retain their original reference. Duplicate IDs retain order and explicit first values, including false and empty arrays; copy-on-write nested merges fill only absent/null/empty-string metadata. Copilot live reads, old cache reads/writes, M365 directories and serial API discovery use this rule. API limits still count raw entries and repeated pagination cursors fail. Credentials, configured deployments and cross-source lists never enter the merge. The bounded catalog change follows [Magpie's directory normalization](https://github.com/yetone/magpie/commit/97e6ac36c9704455e2505d58f673308c0611edad).
|
|
691
|
+
|
|
692
|
+
The cache-preservation principle from [LiteLLM](https://github.com/BerriAI/litellm/pull/51796) applies to CCDX's existing Responses-to-Chat direction, without adding a reverse bridge. Catalog-advertised cache fields gate block conversion, optional caller cache options remain separately gated, and leading system order remains unchanged. Native source protocols retain their fields. Mixed thought/answer and HTTP-200 terminal-error cases remain explicit stream-contract coverage. Following [Magpie's sealed-task protection](https://github.com/yetone/magpie/commit/c747ecfa68eb095a2269771f1b6382205e9facbd), encrypted retry cleanup never strips agent-message bodies; Chat rejects opaque task content before a request is sent.
|
|
693
|
+
|
|
686
694
|
For an explicit root-combiner schema validation failure, the custom Messages
|
|
687
695
|
provider may send a bounded, model-facing object schema while retaining the
|
|
688
696
|
original validator for the response. Guarded tool frames are buffered until the
|
|
@@ -1234,4 +1242,4 @@ The implementation takes the native/gateway-state ownership separation from [Mag
|
|
|
1234
1242
|
|
|
1235
1243
|
`tool-activity.mjs` stores bounded, memory-only metadata behind each stream-performance observer. Existing parsed Responses items, Messages blocks and Gemini function calls supply tool names and scoped identifiers; no argument or output body is copied. The existing session/profile HMAC and application label isolate result matching. Results match call IDs, with a unique-name-only fallback for Gemini. Request completion changes generated calls to waiting, never to successful execution. Observable returned results, source failures and cancellation terminate the corresponding observations. Live response activity renews preparing observations with at most one notification per second per request. Missing evidence becomes unknown after 90 seconds, with a bounded late-result window. Snapshot reads perform lazy retention cleanup; there is no server polling loop.
|
|
1236
1244
|
|
|
1237
|
-
The WebUI consumes this metadata through the existing activity subscription. `dashboard/tool-activity.js` draws only the selected style, caches layout/theme measurements, caps drawing at 30 fps and DPR 1.5, pauses hidden/off-screen/reduced-motion views, and stops terminal cues within 0.9 seconds. Local deadline timers stop stale activity even when the stream has no new events. Native controls, theme variables and the language dictionary preserve the existing UI contract.
|
|
1245
|
+
The WebUI consumes this metadata through the existing activity subscription. `dashboard/tool-activity.js` draws only the selected style, caches layout/theme measurements, caps drawing at 30 fps and DPR 1.5, pauses hidden/off-screen/reduced-motion views, and stops terminal cues within 0.9 seconds. Beam ring is the default; grid, busy pulse, fast streaks and assembly line are alternatives. Removed styles fall back to the default and Off retains state text. With no pending calls, conversation-purpose active requests supply processing/reply cues; internal diagnostics and terminal requests are excluded. Non-live request snapshots expire after six seconds. Local deadline timers stop stale activity even when the stream has no new events. Native controls, theme variables and the language dictionary preserve the existing UI contract. Existing `requests --active` and `requests tools` grammar also drive TUI discovery.
|
package/docs/REFERENCE.md
CHANGED
|
@@ -70,9 +70,9 @@ inspection. Use `app antigravity status` to check the signed installation explic
|
|
|
70
70
|
The old `app gemini` commands remain available. Authorize Antigravity on the GitHub
|
|
71
71
|
Copilot source page, or with `source github access --edit --apps codex,antigravity --yes`.
|
|
72
72
|
Choose its exposed models on the Antigravity page or with
|
|
73
|
-
`app antigravity models --edit`. Each WebUI row represents one model.
|
|
73
|
+
`app antigravity models --edit`. Each WebUI row represents one model. Compatible Gemini chat models come from the current GitHub catalog, rather than a fixed Carbon/Argon list. The Reasoning column lists advertised levels, including Hydrogen's `xhigh` when available. The model checkbox controls visibility. Save/Discard, refresh, navigation, pausing and an off/on toggle preserve an existing saved route subset. CLI model editing and model files remain available for fine-grained effort selection. Refresh on this page or run `app antigravity models --refresh` to read the upstream catalog through the existing GitHub refresh runtime. Refresh does not change saved choices, save drafts, restart clients or invoke inference; failed reads retain the last usable list.
|
|
74
74
|
|
|
75
|
-
The native Gemini catalog still uses distinct routing aliases for each level so its original selector can choose the intended effort. JSON model output retains those aliases for compatibility, with a `model` field identifying the actual model; the management status also includes `model_groups`. A model file accepts `{"models":["gemini-4-
|
|
75
|
+
The native Gemini catalog still uses distinct routing aliases for each level so its original selector can choose the intended effort. JSON model output retains those aliases for compatibility, with a `model` field identifying the actual model; the management status also includes `model_groups`. A model file accepts `{"models":["gemini-4-hydrogen"]}` to expose all of its advertised levels, or individual `ccdx-copilot-...-<effort>` aliases to choose a subset. Existing Carbon/Argon aliases remain valid. Models without declared reasoning levels use one plain alias.
|
|
76
76
|
After saving, the Antigravity page reports whether the client has fetched the current model list. If the list is pending, reopen Gemini through CCDX.
|
|
77
77
|
|
|
78
78
|
The WebUI uses one authorization form for GitHub Copilot, Microsoft 365 and custom APIs. Source switches apply immediately. App-authorization and model checkboxes are drafts until **Save**; **Discard changes** restores the saved selection. Drafts survive refresh and navigation. Source authorization does not choose app models.
|
|
@@ -81,14 +81,15 @@ Pausing Antigravity Copilot access retains its saved model selection. Native Goo
|
|
|
81
81
|
|
|
82
82
|
The page distinguishes enabled access from an observed client connection.
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
Copilot account advertises them. Google models, account controls and defaults
|
|
84
|
+
Compatible Gemini models and their declared reasoning levels appear when the Copilot account advertises them. Image-only models, incompatible interfaces and explicitly unavailable models are excluded. Google models, account controls and defaults
|
|
86
85
|
are retained. Conversations keep their initial Google/Copilot source; start a
|
|
87
86
|
new conversation to change source. Unsupported PDF, audio and video inputs are refused
|
|
88
87
|
before Copilot dispatch. Text, inline images and native function tools are
|
|
89
88
|
converted to the advertised Copilot Chat interface; truncated streams report an
|
|
90
89
|
error rather than successful completion.
|
|
91
90
|
|
|
91
|
+
This Copilot selection does not restrict Antigravity's original Google model directory. Google wire IDs such as `gemini-3.8-flash-tiered` can therefore appear in usage without being CCDX-added model choices. The recorded provider distinguishes Google and GitHub Copilot; the ID alone does not establish a background task or a fallback. Known conversation compaction retains its observed source and model.
|
|
92
|
+
|
|
92
93
|
`enable` saves CCDX settings and prepares its local source guard. `open --preview` shows the launch plan.
|
|
93
94
|
`open` starts a closed, signed `/Applications/Gemini.app` with a process-local
|
|
94
95
|
Antigravity endpoint. An already running App is kept open and must be quit by
|
|
@@ -116,11 +117,11 @@ Each protocol observer retains at most 64 series of 64 request points and 16 com
|
|
|
116
117
|
|
|
117
118
|
## Observed tool calls
|
|
118
119
|
|
|
119
|
-
**Requests → Tool
|
|
120
|
+
**Requests → Tool and agent activity** uses the existing activity stream for Codex, Claude and Antigravity. Beam ring is the default; choose Grid, Busy pulse, Fast streaks, Assembly line or Off. This browser remembers valid choices; removed Orbit rings and Woven field choices fall back to Beam ring. Captions change with observed call preparation, waiting and returned results. When no tools are pending, active conversation requests show processing or reply generation. These are observed gateway request phases, not a count of native subagents. Motion runs at a faster presentation cadence, independent of event frequency; it is not a progress percentage or a call counter. System reduced motion and hidden/off-screen views pause continuous drawing. Off stops drawing and keeps the status text. Returned results have at most a 0.9-second finish cue; failure, cancellation and unavailable evidence stop continuous motion.
|
|
120
121
|
|
|
121
122
|
Calls are correlated using their IDs and the existing app/profile/session scope. A model emitting a tool call does not prove that the client executed it. Only a matching returned result ends the wait; ambiguous name-only Gemini results stay unconfirmed. Without a reliable session, completed requests show unconfirmed tool state. After 90 seconds without observable tool or response activity, the UI pauses and shows that fresh status is needed. Late results can update retained unconfirmed observations for another five minutes. These display deadlines never cancel tools or change source timeouts.
|
|
122
123
|
|
|
123
|
-
The service retains at most 128 metadata observations per protocol observer, shows at most 32, and captures at most 32 calls per request. Finished observations remain for 15 seconds. It keeps safe tool names and local display IDs in memory, not arguments, outputs or raw conversation/call IDs. Input correlation checks a bounded recent suffix rather than scanning a transcript. It adds no provider calls, tokenization, activity connections or polling. `ccdx requests tools --format json` and the TUI Requests menu expose the same observations; `--active` selects preparing/waiting calls. Restarting clears these diagnostic observations.
|
|
124
|
+
The service retains at most 128 metadata observations per protocol observer, shows at most 32, and captures at most 32 calls per request. Finished observations remain for 15 seconds. It keeps safe tool names and local display IDs in memory, not arguments, outputs or raw conversation/call IDs. Input correlation checks a bounded recent suffix rather than scanning a transcript. It adds no provider calls, tokenization, activity connections or polling. `ccdx requests tools --format json` and the TUI Requests menu expose the same tool observations; `--active` selects preparing/waiting calls. `ccdx requests --active` reads active model requests. The motion choice is a browser preference. Restarting clears these diagnostic observations.
|
|
124
125
|
|
|
125
126
|
## Sources and client access
|
|
126
127
|
|
|
@@ -138,6 +139,8 @@ Manual APIs require HTTPS. Codex requires Responses; Claude requires Messages. C
|
|
|
138
139
|
|
|
139
140
|
A running request stays with its original source, credential revision and capabilities. Refreshing a catalog does not select models or change defaults. Failed reads keep last-good data with failure evidence; they do not trigger inference, re-login or source switching. Normal API refresh uses a 30-minute cache and a one-minute minimum interval after explicit reads or failures.
|
|
140
141
|
|
|
142
|
+
Within one source/account, repeated upstream model IDs keep their first position and existing values; later entries fill missing metadata. Explicit false values and empty capability arrays remain authoritative. Live catalogs, compatible old caches and public model details use this normalization. Source and account boundaries stay separate, and duplicate deployments in user configuration remain invalid. Existing source-model CLI/TUI commands read the same normalized catalogs.
|
|
143
|
+
|
|
141
144
|
Codex selections containing only GitHub models keep native OpenAI mode and readable names. Other selections use the client's private local gateway credential. Paused access is rejected before credential validation. CCDX does not write or clear native ChatGPT sign-in data. When models are missing after a client update, check the selected models and run `ccdx doctor`; fully quit and reopen the app before changing credentials.
|
|
142
145
|
|
|
143
146
|
Old conversations keep their recorded provider identity. Codex 0.166 requires the currently selected provider to match that identity; a per-resume override does not bypass this check. Continue a legacy custom-provider chat with its original provider selected. CCDX retains the inactive, unchanged legacy provider table and does not silently rewrite chat metadata or switch the global native default back to a custom provider.
|
|
@@ -868,6 +871,8 @@ Changing the model or transport of a continuation can require removing incompati
|
|
|
868
871
|
|
|
869
872
|
Native Responses forwards Codex `agent_message` items unchanged. When a model requires Chat Completions, CCDX frames them as messages from another agent, not human input or approval, retaining author/recipient, typed text/refusal/reasoning and representable image/screenshot content. Content unsupported by Chat, including file, audio or opaque encrypted parts, receives an explicit compatibility error instead of being serialized into ordinary text. This projection does not introduce another model request or change native Responses, Fast, Auto-review or compaction routing.
|
|
870
873
|
|
|
874
|
+
Encrypted-state cleanup preserves complete agent messages, including their sealed task body. An upstream refusal never authorizes removing that task body to retry only its visible header.
|
|
875
|
+
|
|
871
876
|
GitHub Copilot's `gemini-4-carbon` uses Chat Completions. CCDX maps Codex custom,
|
|
872
877
|
namespaced and client-side tool-search calls to function tools and restores their
|
|
873
878
|
original identities in the reply and conversation history. The upstream receives
|
|
@@ -875,6 +880,10 @@ ordinary function tools; free-form grammar constraints are included in the tool
|
|
|
875
880
|
description rather than enforced by the Chat protocol. Other models retain their
|
|
876
881
|
existing routing and compatibility checks.
|
|
877
882
|
|
|
883
|
+
For Carbon, input `additional_tools` and client `tool_search_output` declarations take effect in order. A later loaded definition replaces the same type/namespace/name without changing its original offered slot or alias. Explicit tool-choice restrictions still apply; conflicting definitions inside the initial tool list remain invalid.
|
|
884
|
+
|
|
885
|
+
On the existing Responses-to-Chat route, per-model catalog flags under `capabilities.supports` control cache forwarding. `cache_control: true` preserves caller cache controls; `prompt_cache_breakpoint: true` preserves explicit breakpoints and maps caller cache controls to explicit breakpoints without inventing a TTL. `prompt_cache_options: true` separately permits caller request options. Messages keep their order, including marked system messages. Unmarked requests and undeclared fields keep their existing behavior. Native Responses and Messages retain their own cache fields. These controls do not establish a measured cache hit or latency benefit.
|
|
886
|
+
|
|
878
887
|
Carbon's standalone web search uses the current GitHub Copilot account. Only
|
|
879
888
|
search queries and requested constraints are sent to its search endpoint; the
|
|
880
889
|
conversation input and ChatGPT credentials are not forwarded. With live web
|
package/package.json
CHANGED
package/src/adapter.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { createNativeImagesHandler } from "./native-images.mjs";
|
|
|
5
5
|
import { defaultCopilotClient } from "./copilot.mjs";
|
|
6
6
|
import { buildCodexModelResponse } from "./codex-model-catalog.mjs";
|
|
7
7
|
import { isValidModelList } from "./model-cache.mjs";
|
|
8
|
+
import { normalizeModelList } from "./model-catalog.mjs";
|
|
8
9
|
import {
|
|
9
10
|
ADAPTER_STATUS_PATH,
|
|
10
11
|
classifyAdapterRoute,
|
|
@@ -148,7 +149,7 @@ async function sendModelList(res, models, {
|
|
|
148
149
|
|
|
149
150
|
async function sendLastKnownGoodModels(res, modelRegistry, options = {}) {
|
|
150
151
|
if (!isValidModelList(modelRegistry?.models) || res.destroyed || res.writableEnded) return false;
|
|
151
|
-
await sendModelList(res, modelRegistry.models, {
|
|
152
|
+
await sendModelList(res, normalizeModelList(modelRegistry.models), {
|
|
152
153
|
...options,
|
|
153
154
|
headers: { "X-CCDX-Model-Source": "last-known-good" },
|
|
154
155
|
});
|
|
@@ -192,6 +193,10 @@ export function createAdapterHandler(options = {}) {
|
|
|
192
193
|
if (!antigravityLoading) antigravityLoading = (async () => {
|
|
193
194
|
const { createAntigravityRuntime } = await import("./antigravity-runtime.mjs");
|
|
194
195
|
antigravity = createAntigravityRuntime({ client: codexClient, models: () => codexModelRegistry?.models || [], privacy, compaction, acquireRequest,
|
|
196
|
+
...(options.providerRuntime?.dashboardCatalog?{refreshModels:async()=>{
|
|
197
|
+
const result=await options.providerRuntime.dashboardCatalog({provider:"github"});
|
|
198
|
+
if(!result)throw httpError("GitHub model catalog refresh is unavailable",503);
|
|
199
|
+
}}:{}),
|
|
195
200
|
env: options.env, home: options.dashboardOptions?.home, requestBodyTimeoutMs, upstreamTimeoutMs, streamIdleTimeoutMs,
|
|
196
201
|
...options.antigravityOptions });
|
|
197
202
|
return antigravity;
|
|
@@ -415,7 +420,10 @@ export function createAdapterHandler(options = {}) {
|
|
|
415
420
|
abort.clearTimeout();
|
|
416
421
|
if (status >= 200 && status < 300) {
|
|
417
422
|
let models;
|
|
418
|
-
try {
|
|
423
|
+
try {
|
|
424
|
+
const parsed = JSON.parse(body);models = normalizeModelList(parsed);
|
|
425
|
+
if (models !== parsed) body = JSON.stringify(models);
|
|
426
|
+
} catch {}
|
|
419
427
|
if (isValidModelList(models)) {
|
|
420
428
|
if (selectedRegistry) {
|
|
421
429
|
selectedRegistry.models = models;
|
|
@@ -53,7 +53,7 @@ function contentValue(parts) {
|
|
|
53
53
|
return parts.length === 1 && parts[0].type === "text" ? parts[0].text : parts;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
export function antigravityToChat(request, { model, effort, stream = true } = {}) {
|
|
56
|
+
export function antigravityToChat(request, { model, effort, stream = true, reasoningEfforts = ["none","minimal","low","medium","high","xhigh","max"] } = {}) {
|
|
57
57
|
if (!object(request) || !Array.isArray(request.contents) || typeof model !== "string" || !model)
|
|
58
58
|
throw invalid("Invalid Gemini generation request");
|
|
59
59
|
if (Object.keys(request).some(key => !["contents", "systemInstruction", "tools", "toolConfig", "generationConfig", "labels", "sessionId"].includes(key))
|
|
@@ -143,7 +143,7 @@ export function antigravityToChat(request, { model, effort, stream = true } = {}
|
|
|
143
143
|
// A CCDX model alias advertises the Copilot effort selected in the App.
|
|
144
144
|
// Its explicit effort takes precedence over Google's internal token budget.
|
|
145
145
|
const level = effort || generation.thinkingConfig?.thinkingLevel?.toLowerCase();
|
|
146
|
-
if (level && !
|
|
146
|
+
if (level && !reasoningEfforts.includes(level)) throw invalid("Unsupported Gemini reasoning level");
|
|
147
147
|
const chat = { model, messages, stream,
|
|
148
148
|
...(stream ? { stream_options: { include_usage: true } } : {}),
|
|
149
149
|
...(tools.length ? { tools, tool_choice: choices[mode] } : {}),
|
|
@@ -169,7 +169,7 @@ export function createAntigravityHandler({client,models=()=>[],selectedModels=()
|
|
|
169
169
|
const target=body.requestType==="agent"||compactBinding&&!compactBinding.background?selected:copilotModels.find(model=>model.model==="gemini-4-carbon"&&model.effort==="low");
|
|
170
170
|
if(!target)throw httpError("Copilot Carbon is unavailable for Antigravity background tasks",503);
|
|
171
171
|
const stream=method==="streamGenerateContent";usageModel=target.model;usageMode=stream?"sse":"json";usageProvider="github";
|
|
172
|
-
const converted=antigravityToChat(request,{model:target.model,effort:target.effort,stream});
|
|
172
|
+
const converted=antigravityToChat(request,{model:target.model,effort:target.effort,reasoningEfforts:target.effort?[target.effort]:[],stream});
|
|
173
173
|
markResponseModel(target.model);markRequestObservation({usage_state:"pending"});
|
|
174
174
|
session=privacy?.prepareSession?await privacy.prepareSession(converted.chat,{protocol:"chat",client:"gemini",signal:abort.signal}):passthrough(converted.chat);
|
|
175
175
|
const callOptions={signal:abort.signal,retryOptions:{retries:0},onUpstreamStart:()=>abort.setTimeout(upstreamTimeoutMs,"upstream_timeout")};
|
|
@@ -1,16 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import {uniqueModelEntries} from "./model-catalog.mjs";
|
|
2
|
+
import {modelDisplayName} from "./model-display.mjs";
|
|
3
|
+
import {modelReasoningEfforts} from "./provider-metadata.mjs";
|
|
3
4
|
export const ANTIGRAVITY_MODEL_PREFIX = "ccdx-copilot-";
|
|
4
5
|
|
|
5
6
|
export function antigravityCopilotModels(catalog) {
|
|
6
7
|
const data=Array.isArray(catalog)?catalog:catalog?.data;
|
|
7
|
-
return (data
|
|
8
|
-
.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
return uniqueModelEntries(Array.isArray(data)?data:[]).filter(model=>/^gemini-[a-z0-9][a-z0-9._-]{0,100}$/.test(model?.id)
|
|
9
|
+
&&model.model_picker_enabled!==false&&(!model.policy?.state||model.policy.state==="enabled")
|
|
10
|
+
&&(!model.capabilities?.type||model.capabilities.type==="chat")
|
|
11
|
+
&&model.capabilities?.supports?.streaming!==false&&model.capabilities?.supports?.tool_calls!==false
|
|
12
|
+
&&model.supported_endpoints?.some(endpoint=>["/chat/completions","/v1/chat/completions"].includes(endpoint)))
|
|
13
|
+
.flatMap(model=>{
|
|
14
|
+
const efforts=modelReasoningEfforts(model)||[],fallback=model.id.split("-").map(word=>word[0].toUpperCase()+word.slice(1)).join(" ");
|
|
15
|
+
const name=modelDisplayName({...model,name:model.name||fallback}),label=/gemini/i.test(name)?name:"Gemini · "+name;
|
|
16
|
+
return (efforts.length?efforts:[null]).map(effort=>({
|
|
17
|
+
id:ANTIGRAVITY_MODEL_PREFIX+model.id+(effort?"-"+effort:""),model:model.id,effort,
|
|
18
|
+
displayName:label+" · Copilot"+(effort?" ("+effort[0].toUpperCase()+effort.slice(1)+")":""),
|
|
19
|
+
maxTokens:model.capabilities?.limits?.max_context_window_tokens,maxOutputTokens:model.capabilities?.limits?.max_output_tokens,
|
|
20
|
+
supportsImages:model.capabilities?.supports?.vision===true,
|
|
21
|
+
}));
|
|
22
|
+
});
|
|
14
23
|
}
|
|
15
24
|
|
|
16
25
|
export function mergeAntigravityModels(googleCatalog,copilotCatalog,selection=null) {
|
|
@@ -23,7 +32,7 @@ export function mergeAntigravityModels(googleCatalog,copilotCatalog,selection=nu
|
|
|
23
32
|
if(next>=600||Object.hasOwn(models,entry.id))throw new Error("Antigravity model catalog has no free client identifiers");
|
|
24
33
|
const model="MODEL_PLACEHOLDER_M"+next++;used.add(model);
|
|
25
34
|
models[entry.id]={displayName:entry.displayName,model,maxTokens:entry.maxTokens,maxOutputTokens:entry.maxOutputTokens,
|
|
26
|
-
supportsImages:entry.supportsImages,supportsThinking:
|
|
35
|
+
supportsImages:entry.supportsImages,supportsThinking:Boolean(entry.effort),apiProvider:"API_PROVIDER_GOOGLE_GEMINI"};
|
|
27
36
|
}
|
|
28
37
|
const sorts=googleCatalog.agentModelSorts?.length?structuredClone(googleCatalog.agentModelSorts):[{displayName:"Recommended",groups:[]}];
|
|
29
38
|
// Gemini App reads only the first group in the Recommended sort.
|
|
@@ -21,7 +21,7 @@ import {antigravityCopilotModels} from "./antigravity-models.mjs";
|
|
|
21
21
|
|
|
22
22
|
const execute=promisify(execFile),key="gemini_antigravity_enabled",modelKey="gemini_antigravity_models";
|
|
23
23
|
|
|
24
|
-
export function createAntigravityRuntime({client,models=()=>[],privacy,home=os.homedir(),env=process.env,inspect=inspectGeminiApp,
|
|
24
|
+
export function createAntigravityRuntime({client,models=()=>[],refreshModels,privacy,home=os.homedir(),env=process.env,inspect=inspectGeminiApp,
|
|
25
25
|
exec=execute,searchFn,imageFn,guardSource,googleFetch,acquireRequest,readToken=()=>readSavedGithubToken(home),...timeouts}={}) {
|
|
26
26
|
const options={home,env},guard=createConversationSourceGuard(options);
|
|
27
27
|
const web=searchFn?null:createCopilotWeb({client,readToken});
|
|
@@ -35,7 +35,7 @@ export function createAntigravityRuntime({client,models=()=>[],privacy,home=os.h
|
|
|
35
35
|
const settings=()=>{
|
|
36
36
|
const saved=readUserSettings({...options,strict:true});
|
|
37
37
|
if(saved[key]!==undefined&&typeof saved[key]!=="boolean")throw httpError("Invalid Gemini integration setting",409);
|
|
38
|
-
if(saved[modelKey]!==undefined&&(!Array.isArray(saved[modelKey])||saved[modelKey].length>100||new Set(saved[modelKey]).size!==saved[modelKey].length||saved[modelKey].some(id=>typeof id!=="string"||!/^ccdx-copilot-[a-z0-9-]{1,140}$/.test(id))))throw httpError("Invalid Antigravity model selection",409);
|
|
38
|
+
if(saved[modelKey]!==undefined&&(!Array.isArray(saved[modelKey])||saved[modelKey].length>100||new Set(saved[modelKey]).size!==saved[modelKey].length||saved[modelKey].some(id=>typeof id!=="string"||!/^ccdx-copilot-[a-z0-9._-]{1,140}$/.test(id))))throw httpError("Invalid Antigravity model selection",409);
|
|
39
39
|
return {configured:Object.hasOwn(saved,key),enabled:saved[key]===true,selected_models:saved[modelKey]??null};
|
|
40
40
|
};
|
|
41
41
|
const available=()=>settings().enabled&&readAccessSettings(options).providers.github?models():[];
|
|
@@ -77,8 +77,12 @@ export function createAntigravityRuntime({client,models=()=>[],privacy,home=os.h
|
|
|
77
77
|
async function action(input={},baseUrl){
|
|
78
78
|
if(input&&Object.keys(input).some(name=>!["action","accept_background_copilot","models"].includes(name)))throw httpError("Invalid Gemini operation",400);
|
|
79
79
|
const operation=input.action||"status";
|
|
80
|
-
if(!["status","summary","models","enable","disable","open","preview"].includes(operation))throw httpError("Unknown Gemini operation",400);
|
|
80
|
+
if(!["status","summary","refresh","models","enable","disable","open","preview"].includes(operation))throw httpError("Unknown Gemini operation",400);
|
|
81
81
|
if(input.models!==undefined&&operation!=="models")throw httpError("Models require the models operation",400);
|
|
82
|
+
if(operation==="refresh"){
|
|
83
|
+
if(!refreshModels)throw httpError("Antigravity model refresh is unavailable in this service",503);
|
|
84
|
+
await refreshModels();lastOperation={action:operation,status:"models_refreshed"};
|
|
85
|
+
}
|
|
82
86
|
if(operation==="models"){
|
|
83
87
|
const ids=input.models,known=new Set(antigravityCopilotModels(models()).map(model=>model.id));
|
|
84
88
|
if(!Array.isArray(ids)||ids.length>100||new Set(ids).size!==ids.length||ids.some(id=>!known.has(id)))throw httpError("Choose available Antigravity models",400);
|
|
@@ -125,9 +125,11 @@ export function prepareCarbonToolBridge(body, currentInputStart = 0) {
|
|
|
125
125
|
parameters: structuredClone(tool.parameters), strict: tool.strict };
|
|
126
126
|
}
|
|
127
127
|
const existing = offered.get(entry.key);
|
|
128
|
-
if (existing && JSON.stringify(existing) !== JSON.stringify(converted)) {
|
|
128
|
+
if (existing && !loaded && JSON.stringify(existing) !== JSON.stringify(converted)) {
|
|
129
129
|
throw requestError("Carbon received conflicting definitions for the same tool");
|
|
130
130
|
}
|
|
131
|
+
// Loaded Responses declarations replace the value without moving its slot
|
|
132
|
+
// or changing the alias used by earlier calls and tool-choice constraints.
|
|
131
133
|
offered.set(entry.key, converted);
|
|
132
134
|
}
|
|
133
135
|
|
package/src/cli-command-spec.mjs
CHANGED
|
@@ -110,7 +110,7 @@ export const MANAGED_COMMANDS = [
|
|
|
110
110
|
),
|
|
111
111
|
command("app list", "List client configuration and observed activity", read),
|
|
112
112
|
...["gemini", "antigravity"].flatMap(app => ["status", "models", "enable", "disable", "open"].map(action => command(`app ${app} ${action}`,
|
|
113
|
-
({status:"Inspect Gemini App and Antigravity setup",models:"List Copilot models
|
|
113
|
+
({status:"Inspect Gemini App and Antigravity setup",models:"List compatible Copilot models for Antigravity",enable:"Enable Antigravity routing and Copilot background requests",disable:"Pause Antigravity Copilot access; reopen Gemini for native routing",open:"Open the original Gemini App with its prepared route"})[action], {...read,...confirm,...(action==="models"?{"--edit":"flag","--file":"value","--refresh":"flag"}:{})}))),
|
|
114
114
|
command("app <app> status", "Show configuration, not process liveness", { ...read, "--details": "flag" }),
|
|
115
115
|
command("app <app> models", "Show or edit the client's selected model plan", {
|
|
116
116
|
...read,
|
|
@@ -288,7 +288,7 @@ export function parseManagedCommand(args) {
|
|
|
288
288
|
const extras = {
|
|
289
289
|
source:
|
|
290
290
|
"Status reads local/cached evidence. check/--refresh may contact the source; no inference.\nsource import --file FILE previews supplied metadata. --select N --apply saves one source using private key input; no client access is granted.\nSource access grants do not select client models. Disable previews affected clients.\nGitHub login and company-account selection are source-specific.\nChoose visible models and defaults with app <app> models --edit.",
|
|
291
|
-
app: "Configured is not App adoption or process liveness. Unknown stays unknown.\nmodels shows the selected plan;
|
|
291
|
+
app: "Configured is not App adoption or process liveness. Unknown stays unknown.\nmodels shows the selected plan; Antigravity lists compatible Copilot models and their selection.\napp antigravity models --refresh reads the GitHub catalog without inference or changing saved choices.\nsource <id> models shows the upstream catalog.\nsetup/remove changes integration setup; pause/resume retains credentials.\nsync --preview shows the model/configuration plan, not a byte-level file diff.\nNo client program is force-restarted.",
|
|
292
292
|
config:
|
|
293
293
|
"Only service and terminal preferences are in scope. Browser appearance stays in WebUI.\nReset keeps accounts, keys, model plans and chats and stores a pre-reset backup.\nSaved and effective values can differ; restart requirements remain explicit.",
|
|
294
294
|
requests:
|
package/src/cli-management.mjs
CHANGED
|
@@ -225,7 +225,7 @@ export async function runManagementCommand(command, options = {}) {
|
|
|
225
225
|
output.write(print(preview) + "\n");await confirm(action === "enable" ? "Enable this Antigravity-only routing scope?" : "Pause Copilot access? Reopen Gemini afterward to restore its native route.");
|
|
226
226
|
}
|
|
227
227
|
if(action==="models"&&flags.edit){
|
|
228
|
-
const state=await request({path:"gemini"});
|
|
228
|
+
const state=await request({path:"gemini",...(flags.refresh?{body:{action:"refresh"},timeoutMs:20000}:{})});
|
|
229
229
|
let ids;
|
|
230
230
|
if(flags.file){
|
|
231
231
|
const listed=readFile().models;if(!Array.isArray(listed))throw new Error("Model files require a models array.");
|
|
@@ -236,7 +236,7 @@ export async function runManagementCommand(command, options = {}) {
|
|
|
236
236
|
ids=[];
|
|
237
237
|
for(const index of selected){
|
|
238
238
|
const model=groups[index],previous=model.efforts.flatMap((item,i)=>item.selected?[i]:[]);
|
|
239
|
-
const efforts=await choose(model.efforts.map(item=>model.name+" / "+item.effort),previous.length?previous:model.efforts.map((_,i)=>i));
|
|
239
|
+
const efforts=await choose(model.efforts.map(item=>model.name+" / "+(item.effort||"default")),previous.length?previous:model.efforts.map((_,i)=>i));
|
|
240
240
|
ids.push(...efforts.map(i=>model.efforts[i].id));
|
|
241
241
|
}
|
|
242
242
|
}else ids=(await choose(state.models.map(model=>model.name),state.models.flatMap((model,index)=>model.selected!==false?[index]:[]))).map(index=>state.models[index].id);
|
|
@@ -245,9 +245,9 @@ export async function runManagementCommand(command, options = {}) {
|
|
|
245
245
|
await confirm("Save Antigravity model selection? Reopen Gemini afterward to reload it.");
|
|
246
246
|
return print(await request({path:"gemini",body:{action:"models",models:ids}}));
|
|
247
247
|
}
|
|
248
|
-
const state = await request({ path: "gemini", ...(["status", "models"].includes(action) ? {} : { body: { action: flags.preview ? "preview" : action, ...(action === "enable" ? { accept_background_copilot: true } : {}) }, timeoutMs: 20000 }) });
|
|
248
|
+
const state = await request({ path: "gemini", ...(action==="models"&&flags.refresh?{body:{action:"refresh"},timeoutMs:20000}:["status", "models"].includes(action) ? {} : { body: { action: flags.preview ? "preview" : action, ...(action === "enable" ? { accept_background_copilot: true } : {}) }, timeoutMs: 20000 }) });
|
|
249
249
|
if(action==="models"&&flags.format!=="json"&&state.model_groups)return print(state.model_groups.map(model=>({model:model.name,id:model.id,source:"GitHub Copilot",context:model.context_window,
|
|
250
|
-
efforts:model.efforts.map(item=>item.effort+(item.selected?" ✓":"")).join(" / ")})),[["model","Model"],["id","ID"],["source","Source"],["context","Context"],["efforts","Reasoning (selected ✓)"]]);
|
|
250
|
+
efforts:model.efforts.map(item=>(item.effort||"default")+(item.selected?" ✓":"")).join(" / ")})),[["model","Model"],["id","ID"],["source","Source"],["context","Context"],["efforts","Reasoning (selected ✓)"]]);
|
|
251
251
|
return print(action === "models" ? state.models : state);
|
|
252
252
|
}
|
|
253
253
|
const graph = await connection(), snapshot = (await readStatus()).data, view = projectTerminalState(snapshot);
|
package/src/copilot-client.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createCopilotTokenSession } from "./copilot-token-session.mjs";
|
|
2
|
+
import { normalizeModelList, uniqueModelEntries } from "./model-catalog.mjs";
|
|
2
3
|
import { MAX_UPSTREAM_MODEL_CATALOG_BYTES, readBoundedResponseText } from "./http-transport.mjs";
|
|
3
4
|
import { prepareResponsesPayload, summarizeReqBody } from "./image-optimization.mjs";
|
|
4
5
|
import { debugLog } from "./log.mjs";
|
|
@@ -66,7 +67,7 @@ export function createCopilotClientRuntime({
|
|
|
66
67
|
const data = Array.isArray(models) ? models : models?.data;
|
|
67
68
|
if (!Array.isArray(data)) return false;
|
|
68
69
|
const next = new Map();
|
|
69
|
-
for (const model of data) {
|
|
70
|
+
for (const model of uniqueModelEntries(data)) {
|
|
70
71
|
const id = String(model?.id || "").trim();
|
|
71
72
|
if (id && Array.isArray(model?.supported_endpoints)) next.set(id, [...model.supported_endpoints]);
|
|
72
73
|
}
|
|
@@ -120,12 +121,16 @@ export function createCopilotClientRuntime({
|
|
|
120
121
|
headers,
|
|
121
122
|
signal,
|
|
122
123
|
}, { fetchImpl, ...retryOptions });
|
|
123
|
-
|
|
124
|
+
let body = await readBoundedResponseText(response, {
|
|
124
125
|
maxBytes: MAX_UPSTREAM_MODEL_CATALOG_BYTES,
|
|
125
126
|
label: "Copilot model catalog",
|
|
126
127
|
});
|
|
127
128
|
if (response.ok) {
|
|
128
|
-
try {
|
|
129
|
+
try {
|
|
130
|
+
const parsed = JSON.parse(body), models = normalizeModelList(parsed);
|
|
131
|
+
cacheModelEndpoints(models);
|
|
132
|
+
if (models !== parsed) body = JSON.stringify(models);
|
|
133
|
+
} catch {}
|
|
129
134
|
}
|
|
130
135
|
return { status: response.status, body };
|
|
131
136
|
}
|
package/src/dashboard/gemini.js
CHANGED
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
label.append(input,document.createTextNode(model.name));name.append(label);row.append(name);
|
|
42
42
|
for(const [key,value]of [['source','GitHub Copilot'],['cap_context',count(model.context_window)]]){const cell=document.createElement('td');cell.textContent=value;cell.dataset.label=language.format(key);row.append(cell)}
|
|
43
43
|
const efforts=document.createElement('td');efforts.dataset.label=language.format('cap_reasoning');
|
|
44
|
-
efforts.textContent=model.efforts.map(item=>item.effort).join(' / ');
|
|
44
|
+
efforts.textContent=model.efforts.map(item=>item.effort||'—').join(' / ');
|
|
45
45
|
row.append(efforts);list.append(row);
|
|
46
46
|
}
|
|
47
47
|
if(!state.models.length){const row=document.createElement('tr'),cell=document.createElement('td');cell.colSpan=4;language.set(cell,'gemini_no_models');row.append(cell);list.append(row)}
|
|
@@ -70,8 +70,8 @@
|
|
|
70
70
|
el('gemini-model-form').addEventListener('submit',event=>{event.preventDefault();if(dirty())void load('models',{models:draft})});
|
|
71
71
|
el('gemini-cancel').addEventListener('click',()=>{draft=null;notice=null;clear('gemini-note');render()});
|
|
72
72
|
el('gemini-open').addEventListener('click',()=>void load('open'));
|
|
73
|
-
el('gemini-refresh').addEventListener('click',()=>void load());
|
|
74
|
-
el('refresh').addEventListener('click',()=>{if(['#gemini','#models'].includes(location.hash))void load(location.hash==='#models'?'summary':
|
|
73
|
+
el('gemini-refresh').addEventListener('click',()=>void load('refresh'));
|
|
74
|
+
el('refresh').addEventListener('click',()=>{if(['#gemini','#models'].includes(location.hash))void load(location.hash==='#models'?'summary':'refresh')});
|
|
75
75
|
window.addEventListener('hashchange',()=>{if(['#gemini','#models'].includes(location.hash))void load(location.hash==='#models'?'summary':undefined)});
|
|
76
76
|
new MutationObserver(render).observe(document.documentElement,{attributes:true,attributeFilter:['lang']});
|
|
77
77
|
void load(location.hash==='#gemini'?undefined:'summary');
|
package/src/dashboard/index.html
CHANGED
|
@@ -370,9 +370,9 @@
|
|
|
370
370
|
<details id="flow-active" class="tool-details"><summary id="flow-active-title" data-i18n="flow_active_requests">Active requests</summary><div class="table-wrap"><table><thead><tr><th data-i18n="client">App</th><th data-i18n="source">Source</th><th data-i18n="model">Model</th><th data-i18n="state">State</th><th data-i18n="flow_elapsed">Elapsed</th><th data-i18n="attempts">Attempts</th></tr></thead><tbody id="flow-active-body"></tbody></table></div></details>
|
|
371
371
|
</section>
|
|
372
372
|
<section id="tool-activity" class="panel dashboard-section" aria-labelledby="tool-title" data-paused="true">
|
|
373
|
-
<div class="panel-heading"><h2 id="tool-title" data-i18n="tool_heading">TOOL
|
|
374
|
-
<div id="tool-stage" class="tool-stage" data-style="
|
|
375
|
-
<div class="tool-visual"><div class="tool-orbit"><canvas id="tool-canvas" role="img" data-i18n-label="tool_heading" aria-label="Tool
|
|
373
|
+
<div class="panel-heading"><h2 id="tool-title" data-i18n="tool_heading">TOOL AND AGENT ACTIVITY</h2><label class="tool-style" for="tool-style"><span data-i18n="tool_style">Style</span><select id="tool-style"><option value="halo" data-i18n="tool_style_halo">Beam ring</option><option value="grid" data-i18n="tool_style_grid">Grid</option><option value="busy" data-i18n="tool_style_busy">Busy pulse</option><option value="speed" data-i18n="tool_style_speed">Fast streaks</option><option value="assembly" data-i18n="tool_style_assembly">Assembly line</option><option value="off" data-i18n="tool_style_off">Off</option></select></label></div>
|
|
374
|
+
<div id="tool-stage" class="tool-stage" data-style="halo">
|
|
375
|
+
<div class="tool-visual"><div class="tool-orbit"><canvas id="tool-canvas" role="img" data-i18n-label="tool_heading" aria-label="Tool and agent activity"></canvas></div><p class="tool-narration"><span id="tool-state" role="status" aria-live="polite" data-i18n="flow_status_unknown">Waiting for a fresh status</span><span id="tool-cursor" aria-hidden="true" hidden> ···</span></p></div>
|
|
376
376
|
<div class="tool-content"><p id="tool-context" class="tool-context" hidden></p><div id="tool-list"></div><p id="tool-more" class="hint" hidden></p><details id="tool-details" class="tool-details tool-technical" hidden><summary data-i18n="tool_details">Call details</summary><div id="tool-technical"></div></details></div>
|
|
377
377
|
</div>
|
|
378
378
|
</section>
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
const translations = {
|
|
3
|
-
"tool_heading": ["Tool
|
|
3
|
+
"tool_heading": ["Tool and agent activity","工具与代理活动"],
|
|
4
4
|
"tool_style": ["Style","样式"],
|
|
5
5
|
"tool_style_grid": ["Grid","格子进度条"],
|
|
6
6
|
"tool_style_halo": ["Beam ring","光束圆环"],
|
|
7
|
-
"
|
|
8
|
-
"
|
|
7
|
+
"tool_style_busy": ["Busy pulse","忙碌脉冲"],
|
|
8
|
+
"tool_style_speed": ["Fast streaks","疾速流光"],
|
|
9
|
+
"tool_style_assembly": ["Assembly line","装配流水线"],
|
|
9
10
|
"tool_style_off": ["Off","关闭"],
|
|
10
11
|
"tool_preparing": ["Preparing a tool call","正在准备调用"],
|
|
11
12
|
"tool_preparing_many": ["Preparing {count} calls","并行准备 {count} 项调用"],
|
|
@@ -14,6 +15,12 @@
|
|
|
14
15
|
"tool_failed": ["A tool call failed","调用失败"],
|
|
15
16
|
"tool_cancelled": ["Request cancelled","请求已取消"],
|
|
16
17
|
"tool_idle": ["Waiting for the next call","等待下一次调用"],
|
|
18
|
+
"tool_processing": ["Processing the request","正在处理请求"],
|
|
19
|
+
"tool_responding": ["Generating a reply","正在生成回复"],
|
|
20
|
+
"tool_requests_many": ["Processing {count} requests","正在处理 {count} 个请求"],
|
|
21
|
+
"tool_processing_action": ["Process request","处理请求"],
|
|
22
|
+
"tool_response_action": ["Generate reply","生成回复"],
|
|
23
|
+
"tool_row_active": ["Active","进行中"],
|
|
17
24
|
"tool_groups": ["{count} app and model groups","{count} 个应用及模型分组"],
|
|
18
25
|
"tool_more": ["{count} more observations in call details","另有 {count} 项观测,见调用详情"],
|
|
19
26
|
"tool_details": ["Call details","调用详情"],
|
package/src/dashboard/status.js
CHANGED
|
@@ -331,7 +331,7 @@
|
|
|
331
331
|
}
|
|
332
332
|
function renderActivity(data) {
|
|
333
333
|
globalThis.ccdxDashboardActivity?.update(data.model_activity, { live: true });
|
|
334
|
-
globalThis.ccdxDashboardFlow?.update(data, { live: true });globalThis.ccdxToolActivity?.update(data);
|
|
334
|
+
globalThis.ccdxDashboardFlow?.update(data, { live: true });globalThis.ccdxToolActivity?.update(data, { live: true });
|
|
335
335
|
text("version", `v${data.version || "?"}`);
|
|
336
336
|
text("uptime", "pid_pid_uptime_duration", { pid: number(data.pid), duration: duration(data.uptime_ms) });
|
|
337
337
|
text("requests", number(data.requests?.total));
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
const root = document.getElementById("tool-activity");if (!root) return;
|
|
3
3
|
const el = id => document.getElementById(id), canvas = el("tool-canvas"), ctx = canvas.getContext?.("2d");
|
|
4
|
-
const styles = new Set(["grid", "
|
|
4
|
+
const styles = new Set(["halo", "grid", "busy", "speed", "assembly", "off"]), storageKey = "ccdx.dashboard.toolMotionStyle";
|
|
5
5
|
const pending = state => ["preparing", "waiting"].includes(state);
|
|
6
6
|
const phrase = (key, values = {}) => globalThis.ccdxLanguage.format(key, values);
|
|
7
7
|
const text = (id, key, values) => globalThis.ccdxLanguage.set(el(id), key, values);
|
|
8
|
-
const state = { scene: "idle", style: "
|
|
8
|
+
const state = { scene: "idle", style: "halo", intensity: .8, reduce: false };
|
|
9
9
|
try { const saved = localStorage.getItem(storageKey);if (styles.has(saved)) state.style = saved; } catch {}
|
|
10
10
|
const motion = globalThis.matchMedia?.("(prefers-reduced-motion: reduce)") || { matches: false, addEventListener() {} };
|
|
11
11
|
let records = [], fresh = false, supported = false, visible = true, raf = 0, last = 0, start = performance.now(), expiry = null;
|
|
12
|
-
let signature = "", box = { width: 0, height: 0 }, color = "", omitted = 0;
|
|
12
|
+
let signature = "", box = { width: 0, height: 0 }, color = "", omitted = 0, requests = [], requestDeadline = 0;
|
|
13
|
+
const animating = () => ["calling", "parallel", "waiting", "processing", "responding"].includes(state.scene);
|
|
13
14
|
const shown = () => document.visibilityState === "visible" && !root.closest("[hidden]") && visible;
|
|
14
15
|
function measure() {
|
|
15
16
|
box = canvas.getBoundingClientRect();color = getComputedStyle(document.documentElement).getPropertyValue("--accent").trim();
|
|
@@ -21,8 +22,8 @@
|
|
|
21
22
|
if(canvas.width!==Math.round(w*dpr)||canvas.height!==Math.round(h*dpr)){canvas.width=Math.round(w*dpr);canvas.height=Math.round(h*dpr);}
|
|
22
23
|
ctx.setTransform(dpr,0,0,dpr,0,0);ctx.clearRect(0,0,w,h);
|
|
23
24
|
const cx=w/2,cy=h/2,r=Math.min(w,h)*.31;
|
|
24
|
-
const reduced=motion.matches||state.reduce,t=reduced?0:(now-start)/1000,active=['calling','parallel'].includes(state.scene),waiting=state.scene==='waiting',returned=state.scene==='returned';
|
|
25
|
-
const quiet
|
|
25
|
+
const reduced=motion.matches||state.reduce,t=reduced?0:(now-start)/1000,active=['calling','parallel','processing','responding'].includes(state.scene),waiting=state.scene==='waiting',returned=state.scene==='returned';
|
|
26
|
+
const quiet=!active&&!waiting&&!returned,power=quiet?.12:waiting?.5:returned?.5:state.intensity;
|
|
26
27
|
ctx.strokeStyle=color;ctx.fillStyle=color;ctx.lineWidth=.8;
|
|
27
28
|
function arc(radius,a,b,alpha){ctx.globalAlpha=alpha;ctx.beginPath();ctx.arc(cx,cy,radius,a,b);ctx.stroke();}
|
|
28
29
|
if(state.style==='grid'){
|
|
@@ -35,6 +36,39 @@
|
|
|
35
36
|
}
|
|
36
37
|
ctx.globalAlpha=1;return;
|
|
37
38
|
}
|
|
39
|
+
if(state.style==='busy'){
|
|
40
|
+
const n=7,bw=12,gap=11,left=cx-(n*bw+(n-1)*gap)/2;
|
|
41
|
+
for(let i=0;i<n;i++){
|
|
42
|
+
const wave=active||waiting?(Math.sin(t*(waiting?6:11)-i*.8)+1)/2:.2;
|
|
43
|
+
const bh=quiet?12:returned?22:14+wave*54;
|
|
44
|
+
ctx.globalAlpha=quiet?.15:returned?.55:.18+wave*power;ctx.fillRect(left+i*(bw+gap),cy-bh/2,bw,bh);
|
|
45
|
+
}
|
|
46
|
+
ctx.globalAlpha=1;return;
|
|
47
|
+
}
|
|
48
|
+
if(state.style==='speed'){
|
|
49
|
+
const span=Math.min(w-36,220),left=cx-span/2;
|
|
50
|
+
for(let i=0;i<7;i++){
|
|
51
|
+
const phase=(t*(waiting?1.5:3.3)+i*.173)%1,len=20+(i%3)*16,y=cy+(i-3)*13;
|
|
52
|
+
const x=active||waiting?left+phase*(span+len)-len:left+span*.43;
|
|
53
|
+
ctx.globalAlpha=quiet?.12:returned?.5:Math.sin(phase*Math.PI)*power;
|
|
54
|
+
ctx.lineWidth=i===3?3:1.5;ctx.beginPath();ctx.moveTo(Math.max(left,x),y);ctx.lineTo(Math.min(left+span,x+len),y);ctx.stroke();
|
|
55
|
+
}
|
|
56
|
+
ctx.globalAlpha=1;return;
|
|
57
|
+
}
|
|
58
|
+
if(state.style==='assembly'){
|
|
59
|
+
const span=Math.min(w-32,218),left=cx-span/2,rail=cy+23;
|
|
60
|
+
ctx.globalAlpha=quiet?.12:.26;ctx.lineWidth=1;
|
|
61
|
+
ctx.beginPath();ctx.moveTo(left,rail);ctx.lineTo(left+span,rail);ctx.moveTo(left,rail+8);ctx.lineTo(left+span,rail+8);ctx.stroke();
|
|
62
|
+
for(let i=0;i<3;i++){
|
|
63
|
+
const x=left+span*(i+.5)/3,phase=(t*(waiting?1.5:3.2)-i/3+9)%1,press=active||waiting?Math.max(0,1-Math.abs(phase-.5)*5):0;
|
|
64
|
+
ctx.globalAlpha=quiet?.16:.58;ctx.fillRect(x-14,cy-36,28,8);ctx.fillRect(x-2,cy-28,4,16+press*16);ctx.fillRect(x-9,cy-14+press*16,18,4);
|
|
65
|
+
}
|
|
66
|
+
for(let i=0;i<5;i++){
|
|
67
|
+
const phase=active||waiting?(t*(waiting?.7:1.6)+i/5)%1:(i+.5)/5,x=left+phase*span;
|
|
68
|
+
ctx.globalAlpha=quiet?.12:returned?.55:.2+Math.sin(phase*Math.PI)*power;ctx.fillRect(x-5,rail-12,10,10);
|
|
69
|
+
}
|
|
70
|
+
ctx.globalAlpha=1;return;
|
|
71
|
+
}
|
|
38
72
|
arc(r,0,Math.PI*2,.25);arc(r*.85,0,Math.PI*2,.13);arc(r*1.12,0,Math.PI*2,.1);
|
|
39
73
|
const spin=active?t*1.6:waiting?t*.9:0;
|
|
40
74
|
if(state.style==='halo'){
|
|
@@ -45,17 +79,16 @@
|
|
|
45
79
|
ctx.beginPath();ctx.moveTo(cx+Math.cos(a)*r*1.17,cy+Math.sin(a)*r*1.17);ctx.lineTo(cx+Math.cos(a)*(r*1.17+length),cy+Math.sin(a)*(r*1.17+length));ctx.stroke();
|
|
46
80
|
}
|
|
47
81
|
}
|
|
48
|
-
if(state.style==='
|
|
49
|
-
ctx.lineWidth=.65;const strands=
|
|
82
|
+
if(state.style==='halo'){
|
|
83
|
+
ctx.lineWidth=.65;const strands=28;
|
|
50
84
|
for(let i=0;i<strands;i++){
|
|
51
|
-
const a=i/strands*Math.PI*2+spin*.6,b=a+2.35+Math.sin(i*.68+t*1.7)*.48,inner=r
|
|
85
|
+
const a=i/strands*Math.PI*2+spin*.6,b=a+2.35+Math.sin(i*.68+t*1.7)*.48,inner=r*.68;
|
|
52
86
|
ctx.globalAlpha=(.1+power*.2)*(quiet?.45:1);ctx.beginPath();ctx.moveTo(cx+Math.cos(a)*inner,cy+Math.sin(a)*inner);ctx.quadraticCurveTo(cx+Math.sin(t*1.3+i)*r*.35,cy+Math.cos(i*.5+t*.7)*r*.3,cx+Math.cos(b)*inner,cy+Math.sin(b)*inner);ctx.stroke();
|
|
53
87
|
}
|
|
54
88
|
}
|
|
55
89
|
for(let i=0;i<3;i++){
|
|
56
|
-
const a=spin*(i%2?-1:1)+i*2.08,track=r*(
|
|
90
|
+
const a=spin*(i%2?-1:1)+i*2.08,track=r*(.89+i*.06);
|
|
57
91
|
ctx.lineWidth=1.3;arc(track,a,a+(active?1.25:waiting?.75:.18),quiet?.15:.75);
|
|
58
|
-
if(state.style==='orbit'){arc(track,0,Math.PI*2,.12);ctx.globalAlpha=quiet?.2:.8;ctx.beginPath();ctx.arc(cx+Math.cos(a)*track,cy+Math.sin(a)*track,active?2.8:2,0,Math.PI*2);ctx.fill();}
|
|
59
92
|
}
|
|
60
93
|
if(active||waiting){for(let i=0;i<3;i++){const q=(t*.85+i/3)%1;arc(r*(.55+q*.5),0,Math.PI*2,(1-q)*.12*power);}}
|
|
61
94
|
if(returned&&!reduced){const q=Math.min((now-start)/850,1);arc(r*(1+q*.32),0,Math.PI*2,(1-q)*.5);}
|
|
@@ -64,13 +97,13 @@
|
|
|
64
97
|
|
|
65
98
|
function animate(now) {
|
|
66
99
|
raf = 0;
|
|
67
|
-
if (!shown() || motion.matches || state.style === "off" || !
|
|
100
|
+
if (!shown() || motion.matches || state.style === "off" || !animating() && !(state.scene === "returned" && now - start < 900)) return;
|
|
68
101
|
if (now - last >= 1000 / 30) { last = now;draw(now); }raf = requestAnimationFrame(animate);
|
|
69
102
|
}
|
|
70
103
|
function refreshAnimation() {
|
|
71
104
|
cancelAnimationFrame(raf);raf = 0;root.dataset.paused = String(!shown() || motion.matches);
|
|
72
105
|
if (!shown() || state.style === "off") return;
|
|
73
|
-
draw();if (!motion.matches && (
|
|
106
|
+
draw();if (!motion.matches && (animating() || state.scene === "returned" && performance.now() - start < 900)) raf = requestAnimationFrame(animate);
|
|
74
107
|
}
|
|
75
108
|
function category(name) {
|
|
76
109
|
const value = String(name || "").toLowerCase().split(/__|\./).at(-1);
|
|
@@ -86,34 +119,43 @@
|
|
|
86
119
|
function render(force = false) {
|
|
87
120
|
if (root.closest("[hidden]")) { signature = "";refreshAnimation();return; }
|
|
88
121
|
const time = performance.now();
|
|
122
|
+
if (requestDeadline && time >= requestDeadline) { requests = [];requestDeadline = 0;fresh = false; }
|
|
89
123
|
for (const row of records) if (row.until <= time && pending(row.state)) { row.state = "unknown";row.until = time + 300000; }
|
|
90
124
|
records = records.filter(row => row.until > time);
|
|
91
125
|
const rows = records.slice(0, 32).map(row => fresh || !pending(row.state) ? row : { ...row, state: "unknown" });
|
|
92
|
-
const
|
|
126
|
+
const agents = fresh ? requests : [];
|
|
127
|
+
const next = JSON.stringify([fresh, supported, state.style, omitted, agents, rows.map(({ until, ...row }) => row)]);
|
|
93
128
|
clearTimeout(expiry);expiry = null;
|
|
94
|
-
|
|
129
|
+
const deadlines = records.map(row => row.until);if (requestDeadline) deadlines.push(requestDeadline);
|
|
130
|
+
if (deadlines.length) expiry = setTimeout(() => render(), Math.max(1, Math.min(...deadlines) - time));
|
|
95
131
|
if (!force && next === signature) return;
|
|
96
132
|
signature = next;
|
|
97
133
|
const active = rows.filter(row => pending(row.state)), preparing = active.some(row => row.state === "preparing");
|
|
98
|
-
const
|
|
134
|
+
const responding = agents.some(row => row.responding);
|
|
135
|
+
const scene = !fresh ? "idle" : active.length ? preparing ? active.length > 1 ? "parallel" : "calling" : "waiting"
|
|
136
|
+
: agents.length ? responding ? "responding" : "processing"
|
|
99
137
|
: rows.some(row => row.state === "returned") && !rows.some(row => ["failed", "cancelled", "unknown"].includes(row.state)) ? "returned" : "idle";
|
|
100
138
|
if (scene !== state.scene) start = performance.now();state.scene = scene;
|
|
101
139
|
const key = !supported || !fresh ? "flow_status_unknown" : active.length ? preparing ? active.length > 1 ? "tool_preparing_many" : "tool_preparing" : "tool_waiting"
|
|
140
|
+
: agents.length ? agents.length > 1 ? "tool_requests_many" : responding ? "tool_responding" : "tool_processing"
|
|
102
141
|
: rows.some(row => row.state === "failed") ? "tool_failed" : rows.some(row => row.state === "cancelled") ? "tool_cancelled"
|
|
103
142
|
: rows.some(row => row.state === "unknown") ? "flow_status_unknown" : rows.length ? "tool_returned" : "tool_idle";
|
|
104
|
-
|
|
105
|
-
|
|
143
|
+
const count = active.length || agents.length;
|
|
144
|
+
text("tool-state", key, { count });
|
|
145
|
+
canvas.setAttribute("aria-label", phrase(key, { count }));
|
|
106
146
|
el("tool-style").value = state.style;el("tool-stage").dataset.style = state.style;
|
|
107
|
-
el("tool-cursor").hidden = !
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
el("tool-context").
|
|
147
|
+
el("tool-cursor").hidden = !count || state.style === "off" || !fresh;
|
|
148
|
+
const displayed = active.length ? rows : agents.length ? agents : rows;
|
|
149
|
+
const groups = new Map(displayed.map(row => [`${row.application}:${row.provider}:${row.model}`, row]));
|
|
150
|
+
el("tool-context").hidden = !displayed.length;
|
|
151
|
+
el("tool-context").textContent = groups.size === 1 ? `${appName(displayed[0].application)} · ${displayed[0].model === "other" ? phrase("flow_model_pending") : displayed[0].model}` : phrase("tool_groups", { count: groups.size });
|
|
111
152
|
const list = el("tool-list");list.replaceChildren();
|
|
112
|
-
for (const row of
|
|
113
|
-
const
|
|
153
|
+
for (const row of displayed.slice(0, 6)) {
|
|
154
|
+
const agent = row.responding !== undefined;
|
|
155
|
+
const item = document.createElement("div");item.className = "tool-entry";item.dataset.state = agent ? "preparing" : row.state;
|
|
114
156
|
const mark = document.createElement("span");mark.className = "tool-mark";mark.setAttribute("aria-hidden", "true");
|
|
115
|
-
const name = document.createElement("span");name.className = "tool-name";name.textContent = phrase(category(row.name));
|
|
116
|
-
const status = document.createElement("span");status.textContent = phrase(`tool_row_${row.state}`);
|
|
157
|
+
const name = document.createElement("span");name.className = "tool-name";name.textContent = phrase(agent ? row.responding ? "tool_response_action" : "tool_processing_action" : category(row.name));
|
|
158
|
+
const status = document.createElement("span");status.textContent = phrase(agent ? "tool_row_active" : `tool_row_${row.state}`);
|
|
117
159
|
item.append(mark, name, status);list.append(item);
|
|
118
160
|
}
|
|
119
161
|
el("tool-details").hidden = !rows.length;
|
|
@@ -136,17 +178,21 @@
|
|
|
136
178
|
new IntersectionObserver(entries => { visible = entries[0].isIntersecting;refreshAnimation(); }, { threshold: .05 }).observe(canvas);
|
|
137
179
|
new MutationObserver(() => render(true)).observe(document.documentElement, { attributes: true, attributeFilter: ["lang", "data-theme", "data-palette"] });
|
|
138
180
|
globalThis.ccdxToolActivity = {
|
|
139
|
-
update(data) {
|
|
181
|
+
update(data, { live = false } = {}) {
|
|
140
182
|
const parts = [data?.stream_performance, (data?.providers?.claude || data?.providers?.m365?.claude)?.requests?.performance].filter(Boolean);
|
|
141
183
|
const views = parts.map(part => part.tool_activity).filter(value => Array.isArray(value?.items));
|
|
142
|
-
supported = views.length > 0;fresh = supported;const time = performance.now();
|
|
184
|
+
supported = views.length > 0 || parts.some(part => Array.isArray(part.active_requests));fresh = supported;const time = performance.now();
|
|
185
|
+
requests = parts.flatMap(part => (Array.isArray(part.active_requests) ? part.active_requests.slice(0, 128) : []).filter(row => row?.purpose === "conversation" && row.terminal_outcome == null
|
|
186
|
+
&& typeof row.model === "string" && ["received", "admission", "body", "history", "images", "serialization", "upstream_connection", "upstream_response", "upstream_stream"].includes(row.phase))
|
|
187
|
+
.map(row => ({ application: row.application || "api", provider: row.provider, model: row.model.slice(0, 160), responding: Number.isFinite(row.first_output_ms) && row.first_output_ms >= 0 }))).slice(0, 128);
|
|
188
|
+
requestDeadline = live || !requests.length ? 0 : time + 6000;
|
|
143
189
|
const merged = views.flatMap((view, index) => view.items.slice(0, 32).filter(row => row && typeof row.id === "string" && ["preparing", "waiting", "returned", "failed", "cancelled", "unknown"].includes(row.state)
|
|
144
190
|
&& Number.isFinite(row.expires_in_ms) && row.expires_in_ms > 0).map(row => ({ id: `${index}-${row.id}`, application: row.application || "api", provider: row.provider, model: row.model || "other", name: row.name,
|
|
145
191
|
state: row.state, until: time + Math.min(row.expires_in_ms, 300000) })));
|
|
146
192
|
merged.sort((a, b) => Number(pending(b.state)) - Number(pending(a.state)));records = merged.slice(0, 32);
|
|
147
193
|
omitted = Math.max(0, merged.length - records.length) + views.reduce((sum, view) => sum + (Number.isSafeInteger(view.omitted) ? view.omitted : 0), 0);render();
|
|
148
194
|
},
|
|
149
|
-
unavailable() { fresh = false;render(); },
|
|
195
|
+
unavailable() { fresh = false;requests = [];requestDeadline = 0;render(); },
|
|
150
196
|
visibilityChanged() { render();refreshAnimation(); },
|
|
151
197
|
};
|
|
152
198
|
render();
|
package/src/dashboard/ui.css
CHANGED
|
@@ -680,7 +680,8 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
|
|
|
680
680
|
.tool-orbit canvas { display:block;width:100%;height:100%; }
|
|
681
681
|
.tool-stage[data-style="grid"] .tool-orbit { max-height:140px; }
|
|
682
682
|
.tool-stage[data-style="off"] { grid-template-columns:1fr;min-height:110px; }
|
|
683
|
-
.tool-stage[data-style="off"] .tool-
|
|
683
|
+
.tool-stage[data-style="off"] .tool-orbit { display:none; }
|
|
684
|
+
.tool-stage[data-style="off"] .tool-narration { text-align:left; }
|
|
684
685
|
.tool-narration { margin:0;min-height:24px;text-align:center;color:var(--text);font-size:12px;line-height:1.7; }
|
|
685
686
|
.tool-context { color:var(--muted);font-size:11px;line-height:1.6;margin:0 0 16px; }
|
|
686
687
|
.tool-entry { display:grid;grid-template-columns:18px minmax(0,1fr) auto;gap:10px;align-items:center;min-height:48px;padding-block:8px;border-bottom:1px solid var(--border); }
|
package/src/live-models.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import { sourceModels } from "./client-model-plan.mjs";
|
|
|
3
3
|
import { isImageModel, imageModelCatalog } from "./image-models.mjs";
|
|
4
4
|
import os from "node:os";
|
|
5
5
|
import { publicModelCatalog } from "./provider-metadata.mjs";
|
|
6
|
+
import { uniqueModelEntries } from "./model-catalog.mjs";
|
|
6
7
|
import { createAbortAwareSingleflight } from "./bounded-result-cache.mjs";
|
|
7
8
|
import { githubTokenFingerprint } from "./github-identity.mjs";
|
|
8
9
|
import { validateGithubToken } from "./auth.mjs";
|
|
@@ -33,7 +34,8 @@ function endpointLabels(model) {
|
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
export function selectableCopilotModels(payload) {
|
|
36
|
-
const
|
|
37
|
+
const raw = Array.isArray(payload) ? payload : payload?.data;
|
|
38
|
+
const data = Array.isArray(raw) ? uniqueModelEntries(raw) : raw;
|
|
37
39
|
if (!Array.isArray(data)) throw new Error("Copilot models response contained no model list");
|
|
38
40
|
|
|
39
41
|
const models = [];
|
|
@@ -63,10 +65,10 @@ export function selectableCopilotModels(payload) {
|
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
export function publicCopilotModelCatalog(payload) {
|
|
66
|
-
const data=Array.isArray(payload)?payload:payload.data;
|
|
68
|
+
const data=uniqueModelEntries(Array.isArray(payload)?payload:payload.data);
|
|
67
69
|
const codex=new Set(sourceModels({id:"github",registry:{models:{data}}},"codex")
|
|
68
70
|
.filter(model=>model.model_picker_enabled!==false&&(!model.policy?.state||model.policy.state==="enabled")).map(model=>model.id));
|
|
69
|
-
const antigravity=new Set(antigravityCopilotModels(
|
|
71
|
+
const antigravity=new Set(antigravityCopilotModels({data}).map(model=>model.model));
|
|
70
72
|
return publicModelCatalog(data,{
|
|
71
73
|
selectable:model=>codex.has(model.id)||antigravity.has(model.id)||imageModelCatalog([model]).length>0,
|
|
72
74
|
clients:model=>[...(codex.has(model.id)||isImageModel(model)?["codex"]:[]),...(antigravity.has(model.id)?["antigravity"]:[])],
|
package/src/model-cache.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import fs from "node:fs";
|
|
|
2
2
|
import os from "node:os";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { readBoundedFileSync, MAX_MODEL_CACHE_FILE_BYTES } from "./bounded-file.mjs";
|
|
5
|
+
import { normalizeModelList } from "./model-catalog.mjs";
|
|
5
6
|
|
|
6
7
|
export const MODEL_CACHE_SOFT_TTL_MS = 2 * 60 * 60 * 1000;
|
|
7
8
|
export const MODEL_CACHE_HARD_TTL_MS = 7 * 24 * 60 * 60 * 1000;
|
|
@@ -50,7 +51,7 @@ export function loadModelCacheEntry({
|
|
|
50
51
|
const ageMs = Math.max(0, now() - savedAt);
|
|
51
52
|
if (ageMs > resolvedHardTtlMs) return null;
|
|
52
53
|
return {
|
|
53
|
-
models: parsed.models,
|
|
54
|
+
models: normalizeModelList(parsed.models),
|
|
54
55
|
savedAtMs: savedAt,
|
|
55
56
|
ageMs,
|
|
56
57
|
state: ageMs > resolvedSoftTtlMs ? "stale" : "fresh",
|
|
@@ -74,7 +75,7 @@ export function saveModelCache(models, {
|
|
|
74
75
|
if (typeof isCurrent === "function" && !isCurrent()) return false;
|
|
75
76
|
const filePath = modelCachePath(home);
|
|
76
77
|
const tempPath = `${filePath}.${process.pid}.tmp`;
|
|
77
|
-
const payload = { saved_at: new Date(now()).toISOString(), models };
|
|
78
|
+
const payload = { saved_at: new Date(now()).toISOString(), models: normalizeModelList(models) };
|
|
78
79
|
const fingerprint = String(credentialFingerprint || "").trim();
|
|
79
80
|
if (fingerprint) payload.credential_fingerprint = fingerprint;
|
|
80
81
|
fs.mkdirSync(path.dirname(filePath), { recursive: true, mode: 0o700 });
|
|
@@ -40,7 +40,7 @@ export function catalogCapabilities(model) {
|
|
|
40
40
|
max_tool_definitions: first(model.max_tool_definitions, window.max_tool_definitions),
|
|
41
41
|
reasoning: first(typeof caps.reasoning === "boolean" ? caps.reasoning : undefined, supports.reasoning),
|
|
42
42
|
reasoning_efforts: first(model.reasoning_efforts, supports.reasoning_effort),
|
|
43
|
-
input_modalities: first(model.input_modalities, caps.input_modalities, supports.vision ===
|
|
43
|
+
input_modalities: first(model.input_modalities, caps.input_modalities, typeof supports.vision === "boolean" ? supports.vision ? ["text", "image"] : ["text"] : undefined),
|
|
44
44
|
tools: first(supports.tools, supports.tool_calls), parallel_tools: supports.parallel_tool_calls, streaming: supports.streaming, mid_conversation_system: supports.mid_conversation_system,
|
|
45
45
|
structured_output: first(supports.structured_output, supports.structured_outputs), web_search: first(model.web_search, caps.web_search), thinking_modes: first(model.thinking_modes, caps.thinking_modes),
|
|
46
46
|
...Object.fromEntries(["reasoning_required", "reasoning_adaptive", "reasoning_budget_min", "reasoning_budget_max", "reasoning_format"].map(key => [key, first(model[key], caps[key])])),
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const record = value => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
2
|
+
|
|
3
|
+
function fillMissing(first, later) {
|
|
4
|
+
const updates = [];
|
|
5
|
+
for (const [key, value] of Object.entries(later)) {
|
|
6
|
+
const previous = Object.hasOwn(first, key) ? first[key] : undefined;
|
|
7
|
+
const next = previous == null || previous === "" ? value
|
|
8
|
+
: record(previous) && record(value) ? fillMissing(previous, value) : previous;
|
|
9
|
+
if (next !== previous) updates.push([key, next]);
|
|
10
|
+
}
|
|
11
|
+
return updates.length ? { ...first, ...Object.fromEntries(updates) } : first;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Call only on a single source/account catalog. Explicit values, including
|
|
15
|
+
// false and empty capability arrays, win; duplicates only supply missing data.
|
|
16
|
+
export function uniqueModelEntries(models) {
|
|
17
|
+
const positions = new Map();let result = null;
|
|
18
|
+
for (let index = 0; index < models.length; index++) {
|
|
19
|
+
const model = models[index], id = model?.id;
|
|
20
|
+
if (typeof id === "string" && id && positions.has(id)) {
|
|
21
|
+
result ||= models.slice(0, index);
|
|
22
|
+
const position = positions.get(id);
|
|
23
|
+
result[position] = fillMissing(result[position], model);
|
|
24
|
+
} else {
|
|
25
|
+
if (typeof id === "string" && id) positions.set(id, result ? result.length : index);
|
|
26
|
+
if (result) result.push(model);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return result || models;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function normalizeModelList(value) {
|
|
33
|
+
const data = Array.isArray(value) ? value : value?.data;
|
|
34
|
+
if (!Array.isArray(data)) return value;
|
|
35
|
+
const normalized = uniqueModelEntries(data);
|
|
36
|
+
return normalized === data ? value : Array.isArray(value) ? normalized : { ...value, data: normalized };
|
|
37
|
+
}
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
} from "./models.mjs";
|
|
10
10
|
import { initializeModelRegistry } from "./startup.mjs";
|
|
11
11
|
import { status } from "./status.mjs";
|
|
12
|
+
import { normalizeModelList } from "./model-catalog.mjs";
|
|
12
13
|
|
|
13
14
|
const DEFAULT_TIMEOUT_MS = 5000;
|
|
14
15
|
|
|
@@ -29,7 +30,7 @@ function parsedCatalog(result) {
|
|
|
29
30
|
if (!isValidModelList(models)) {
|
|
30
31
|
throw new Error("Copilot models response contained no valid models");
|
|
31
32
|
}
|
|
32
|
-
return models;
|
|
33
|
+
return normalizeModelList(models);
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
function createModelRegistry() {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isImageModel } from "./image-models.mjs";
|
|
2
2
|
import { autoReviewReasoningEfforts } from "./models.mjs";
|
|
3
3
|
import { modelDisplayName } from "./model-display.mjs";
|
|
4
|
+
import { uniqueModelEntries } from "./model-catalog.mjs";
|
|
4
5
|
// Public metadata only. Credentials and provider transport never enter this layer.
|
|
5
6
|
export const isProviderId = value => typeof value === "string" && /^[a-z][a-z0-9_-]{0,63}$/.test(value)
|
|
6
7
|
&& !["constructor", "prototype"].includes(value);
|
|
@@ -11,7 +12,7 @@ export function modelReasoningEfforts(model) {
|
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export function publicModelCatalog(models, { clients = () => [], selectable = () => false, maker = model => model.publisher || model.vendor || model.owned_by || "Unknown" } = {}) {
|
|
14
|
-
return models.slice(0, 1000).filter(model => typeof model?.id === "string").map(model => ({
|
|
15
|
+
return uniqueModelEntries(models.slice(0, 1000)).filter(model => typeof model?.id === "string").map(model => ({
|
|
15
16
|
id: model.id, ...(isImageModel(model) ? { kind: "image" } : {}), display_name: modelDisplayName(model), vendor: maker(model), ...(model.owned_by ? { owned_by: model.owned_by } : {}),
|
|
16
17
|
endpoints: [["responses", ["/responses", "/v1/responses"]], ["chat", ["/chat/completions", "/v1/chat/completions"]],
|
|
17
18
|
["messages", ["/v1/messages"]], ["images", ["/images/generations", "/v1/images/generations"]], ["image_edits", ["/images/edits", "/v1/images/edits"]]].filter(([, paths]) => paths.some(path => model.supported_endpoints?.includes(path))).map(([label]) => label),
|
package/src/providers/api.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { createHash } from "node:crypto";
|
|
|
2
2
|
import { createRoutePlan } from "../route-plan.mjs";
|
|
3
3
|
import { accessError } from "../access-settings.mjs";
|
|
4
4
|
import { publicModelCatalog } from "../provider-metadata.mjs";
|
|
5
|
+
import { uniqueModelEntries } from "../model-catalog.mjs";
|
|
5
6
|
import { claudeModelEntries } from "../claude-models.mjs";
|
|
6
7
|
import { prepareResponsesPayload } from "../image-optimization.mjs";
|
|
7
8
|
import { enforceResponsesPayloadByteBudget } from "../responses-byte-budget.mjs";
|
|
@@ -190,7 +191,7 @@ export function createApiProvider({ config, secrets, env = process.env, platform
|
|
|
190
191
|
clients: model => allowed.filter(id => model.supported_endpoints.includes(id === "codex" ? paths.responses : paths.messages)) }).map(model => ({ ...model,
|
|
191
192
|
capability: catalog.find(entry => entry.id === model.id)?.capability, auto_review_efforts: [...(catalog.find(entry => entry.id === model.id)?.protocol_capabilities.responses?.values.reasoning_efforts || [])] })) }; },
|
|
192
193
|
async discover({ signal } = {}) {
|
|
193
|
-
const models = [],
|
|
194
|
+
const models = [], cursors = new Set(), checked_at = new Date().toISOString();let url = modelsUrl, bytes = 0;
|
|
194
195
|
for (let page = 0; page < 25; page++) {
|
|
195
196
|
const response = await request(url, undefined, { signal }, config.endpoints.responses ? "responses" : "messages");
|
|
196
197
|
if (!response.ok) {
|
|
@@ -201,14 +202,15 @@ export function createApiProvider({ config, secrets, env = process.env, platform
|
|
|
201
202
|
const text = await readBoundedResponseText(response, { maxBytes: MAX_UPSTREAM_MODEL_CATALOG_BYTES - bytes, label: "API model catalog", signal });bytes += Buffer.byteLength(text);
|
|
202
203
|
let value;try { value = JSON.parse(text); } catch { throw accessError("ccdx_api_catalog_invalid", 502); }
|
|
203
204
|
if (!Array.isArray(value.data) || models.length + value.data.length > 500) throw accessError("ccdx_api_catalog_invalid", 502);
|
|
204
|
-
for (const model of value.data) { if (!model || typeof model.id !== "string" || !/^[\w][\w./:@+-]{0,159}$/.test(model.id) || model.id.includes("..") || model.id.includes("//")
|
|
205
|
+
for (const model of value.data) { if (!model || typeof model.id !== "string" || !/^[\w][\w./:@+-]{0,159}$/.test(model.id) || model.id.includes("..") || model.id.includes("//")) throw accessError("ccdx_api_catalog_invalid", 502); }
|
|
205
206
|
// A catalog listing is not evidence that every model supports every API.
|
|
206
|
-
models.push(...value.data
|
|
207
|
-
|
|
208
|
-
|
|
207
|
+
models.push(...value.data);
|
|
208
|
+
if (value.has_more !== true) return uniqueModelEntries(models).map(model => ({ id: model.id, display: apiModelDisplay(model), metadata: apiModelMetadata(model, { checked_at, deployment: deploymentRevision(config, env) }), protocols: Array.isArray(model.supported_endpoints)
|
|
209
|
+
? Object.entries(paths).filter(([, endpoint]) => model.supported_endpoints.includes(endpoint) || model.supported_endpoints.includes(endpoint.slice(3))).map(([api]) => api).filter(api => config.endpoints[api]) : [] }));
|
|
209
210
|
// Follow only the native cursor on the configured origin, never an
|
|
210
211
|
// upstream next-page URL that could disclose this source's credential.
|
|
211
|
-
if (!value.data.length || value.last_id !== value.data.at(-1).id || bytes >= MAX_UPSTREAM_MODEL_CATALOG_BYTES) throw accessError("ccdx_api_catalog_invalid", 502);
|
|
212
|
+
if (!value.data.length || value.last_id !== value.data.at(-1).id || cursors.has(value.last_id) || bytes >= MAX_UPSTREAM_MODEL_CATALOG_BYTES) throw accessError("ccdx_api_catalog_invalid", 502);
|
|
213
|
+
cursors.add(value.last_id);
|
|
212
214
|
const next = new URL(modelsUrl);next.searchParams.set("after_id", value.last_id);url = next.href;
|
|
213
215
|
}
|
|
214
216
|
throw accessError("ccdx_api_catalog_limit", 502);
|
package/src/providers/m365.mjs
CHANGED
|
@@ -18,6 +18,7 @@ import { limitM365CacheTtl } from "./m365-messages-policy.mjs";
|
|
|
18
18
|
import { createM365ConversationGuard } from "./m365-conversation-accounts.mjs";
|
|
19
19
|
import { catalogFailure, m365CatalogDiagnostic, m365CatalogRead } from "./m365-catalog-diagnostic.mjs";
|
|
20
20
|
import { m365NetworkDiagnostic } from "./m365-network-diagnostic.mjs";
|
|
21
|
+
import { uniqueModelEntries } from "../model-catalog.mjs";
|
|
21
22
|
|
|
22
23
|
import { M365_API_BASE, M365_API_ORIGIN } from "./m365-endpoint.mjs";
|
|
23
24
|
export { M365_API_BASE } from "./m365-endpoint.mjs";
|
|
@@ -53,13 +54,13 @@ export function m365ConversationId(body, headers = {}, profile = "m365") {
|
|
|
53
54
|
|
|
54
55
|
export function m365Catalog(payload) {
|
|
55
56
|
if (!payload || !Array.isArray(payload.data) || payload.data.length > 1000) throw m365Error("m365_catalog_invalid");
|
|
56
|
-
const seen = new Set();
|
|
57
57
|
for (const model of payload.data) {
|
|
58
58
|
if (!model || typeof model.id !== "string" || !/^[A-Za-z0-9][\w.-]{0,127}$/.test(model.id)
|
|
59
|
-
||
|
|
60
|
-
seen.add(model.id);
|
|
59
|
+
|| model.supported_endpoints != null && !Array.isArray(model.supported_endpoints)) throw m365Error("m365_catalog_invalid");
|
|
61
60
|
}
|
|
62
|
-
|
|
61
|
+
const data = uniqueModelEntries(payload.data);
|
|
62
|
+
if (data.some(model => !Array.isArray(model.supported_endpoints))) throw m365Error("m365_catalog_invalid");
|
|
63
|
+
return { data };
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
export function m365Models(catalog, family) {
|
package/src/responses-bridge.mjs
CHANGED
|
@@ -89,26 +89,38 @@ export function responsesToChat(body, { reasoningEfforts, cacheSupport } = {}) {
|
|
|
89
89
|
const messages = [];
|
|
90
90
|
if (body.instructions) messages.push({ role: "system", content: body.instructions });
|
|
91
91
|
|
|
92
|
-
const
|
|
93
|
-
if (
|
|
92
|
+
const cacheFields = value => {
|
|
93
|
+
if (cacheSupport?.prompt_cache_breakpoint === true) {
|
|
94
|
+
if (value?.prompt_cache_breakpoint != null) return { prompt_cache_breakpoint: cloneJson(value.prompt_cache_breakpoint) };
|
|
95
|
+
if (value?.cache_control != null) return { prompt_cache_breakpoint: { mode: "explicit" } };
|
|
96
|
+
}
|
|
97
|
+
return cacheSupport?.cache_control === true && value?.cache_control != null ? { cache_control: cloneJson(value.cache_control) } : null;
|
|
98
|
+
};
|
|
99
|
+
const messageContent = (content, owner) => {
|
|
100
|
+
const ownerCache = cacheFields(owner);
|
|
101
|
+
if (typeof content === "string") return ownerCache ? [{ type: "text", text: content, ...ownerCache }] : content;
|
|
94
102
|
if (content === null) return null;
|
|
95
103
|
if (!Array.isArray(content)) throw chatCompatibilityError("message content", typeof content);
|
|
96
|
-
if (content.length === 1 && ["input_text", "output_text", "text"].includes(content[0]?.type) && typeof content[0].text === "string") return content[0].text;
|
|
104
|
+
if (!ownerCache && content.length === 1 && ["input_text", "output_text", "text"].includes(content[0]?.type) && typeof content[0].text === "string" && !cacheFields(content[0])) return content[0].text;
|
|
97
105
|
const parts = [];
|
|
98
106
|
for (const part of content) {
|
|
99
107
|
if (!part || typeof part !== "object") throw chatCompatibilityError("message content", part?.type);
|
|
100
108
|
if (["input_text", "output_text", "text"].includes(part.type)) {
|
|
101
109
|
if (typeof part.text !== "string") throw chatCompatibilityError("message content", part.type);
|
|
102
|
-
parts.push({ type: "text", text: part.text });
|
|
110
|
+
parts.push({ type: "text", text: part.text, ...cacheFields(part) });
|
|
103
111
|
} else if (["input_image", "image_url", "image"].includes(part.type)) {
|
|
104
112
|
const imagePart = chatImagePart(part);
|
|
105
|
-
if (imagePart) parts.push(imagePart);
|
|
113
|
+
if (imagePart) parts.push({ ...imagePart, ...cacheFields(part) });
|
|
106
114
|
else throw chatCompatibilityError("message content", part.type);
|
|
107
115
|
} else {
|
|
108
116
|
throw chatCompatibilityError("message content", part.type);
|
|
109
117
|
}
|
|
110
118
|
}
|
|
111
|
-
if (
|
|
119
|
+
if (ownerCache) {
|
|
120
|
+
if (!parts.length) parts.push({ type: "text", text: "" });
|
|
121
|
+
const last = parts.length - 1;parts[last] = { ...ownerCache, ...parts[last] };
|
|
122
|
+
}
|
|
123
|
+
if (parts.length === 1 && parts[0].type === "text" && !Object.hasOwn(parts[0], "cache_control") && !Object.hasOwn(parts[0], "prompt_cache_breakpoint")) return parts[0].text;
|
|
112
124
|
return parts;
|
|
113
125
|
};
|
|
114
126
|
|
|
@@ -121,9 +133,9 @@ export function responsesToChat(body, { reasoningEfforts, cacheSupport } = {}) {
|
|
|
121
133
|
&& ["user", "assistant", "system", "developer"].includes(item?.role)
|
|
122
134
|
&& Object.prototype.hasOwnProperty.call(item, "content");
|
|
123
135
|
if (item?.type === "message" || isEasyMessage) {
|
|
124
|
-
messages.push({ role: item.role, content: messageContent(item.content) });
|
|
136
|
+
messages.push({ role: item.role, content: messageContent(item.content, item) });
|
|
125
137
|
} else if (item?.type === "agent_message") {
|
|
126
|
-
if (typeof item.author !== "string" || typeof item.recipient !== "string" || !Array.isArray(item.content)) {
|
|
138
|
+
if (typeof item.author !== "string" || typeof item.recipient !== "string" || !Array.isArray(item.content) || item.encrypted_content != null) {
|
|
127
139
|
throw chatCompatibilityError("input item", "agent_message");
|
|
128
140
|
}
|
|
129
141
|
const escape = (value) => value.replaceAll("&", "&").replaceAll("<", "<")
|
|
@@ -193,6 +205,9 @@ export function responsesToChat(body, { reasoningEfforts, cacheSupport } = {}) {
|
|
|
193
205
|
if (cacheSupport.prompt_cache_retention === true && ["in_memory", "24h"].includes(body.prompt_cache_retention)) {
|
|
194
206
|
chatReq.prompt_cache_retention = body.prompt_cache_retention;
|
|
195
207
|
}
|
|
208
|
+
if (cacheSupport.prompt_cache_options === true && body.prompt_cache_options && typeof body.prompt_cache_options === "object" && !Array.isArray(body.prompt_cache_options)) {
|
|
209
|
+
chatReq.prompt_cache_options = cloneJson(body.prompt_cache_options);
|
|
210
|
+
}
|
|
196
211
|
}
|
|
197
212
|
const maxTok = body.max_output_tokens ?? body.max_tokens ?? body.max_completion_tokens;
|
|
198
213
|
if (maxTok !== undefined) chatReq.max_completion_tokens = maxTok;
|
|
@@ -128,6 +128,9 @@ function stripEncryptedReasoningValue(value, state) {
|
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
function stripEncryptedReasoningInputValue(item, state) {
|
|
131
|
+
// A sealed agent message may contain the entire delegated task. Removing
|
|
132
|
+
// opaque parts would turn a rejected task into an unrelated plaintext ask.
|
|
133
|
+
if (item?.type === "agent_message") return item;
|
|
131
134
|
if (!isResponsesToolOutputItem(item)) {
|
|
132
135
|
const out = stripEncryptedReasoningValue(item, state);
|
|
133
136
|
if (item?.type === "message"
|