codex-copilot-dx 1.4.0 → 1.4.2
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 -0
- package/docs/ARCHITECTURE.md +12 -0
- package/docs/REFERENCE.md +17 -0
- package/package.json +1 -1
- package/src/adapter.mjs +6 -2
- package/src/antigravity-handler.mjs +6 -2
- package/src/carbon-tool-bridge.mjs +3 -1
- package/src/claude-gateway.mjs +3 -1
- package/src/cli-command-spec.mjs +2 -1
- package/src/cli-management.mjs +7 -0
- package/src/context-metrics.mjs +2 -1
- package/src/copilot-client.mjs +8 -3
- package/src/dashboard/console.js +1 -1
- package/src/dashboard/index.html +7 -0
- package/src/dashboard/language.js +36 -0
- package/src/dashboard/status.js +2 -2
- package/src/dashboard/tool-activity.js +199 -0
- package/src/dashboard/ui.css +27 -0
- package/src/dashboard/ui.js +2 -2
- package/src/dashboard.mjs +1 -0
- package/src/live-models.mjs +5 -3
- package/src/model-cache.mjs +3 -2
- 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 +25 -8
- package/src/responses-handler.mjs +2 -0
- package/src/responses-proxy.mjs +4 -0
- package/src/responses-request.mjs +3 -0
- package/src/stream-performance.mjs +16 -0
- package/src/tool-activity.mjs +135 -0
package/README.md
CHANGED
|
@@ -56,6 +56,8 @@ Model availability depends on your account and service. Microsoft 365 also requi
|
|
|
56
56
|
| Set up Antigravity | `ccdx app antigravity status` / `enable` / `open` |
|
|
57
57
|
| Inspect compression | `ccdx compact status` / `ccdx compact enable` / `ccdx compact disable` |
|
|
58
58
|
| Inspect failures | `ccdx requests --failed` |
|
|
59
|
+
| Inspect observed tool calls | `ccdx requests tools` / `ccdx requests tools --active` |
|
|
60
|
+
| Inspect active model requests | `ccdx requests --active` |
|
|
59
61
|
| Capture one upstream error | `ccdx requests diagnose --source api_work --model model-id --yes` |
|
|
60
62
|
| Read usage | `ccdx usage` / `ccdx usage --provider google --days 7` / `ccdx usage --purpose diagnostic` / `ccdx usage --scope run` |
|
|
61
63
|
| Inspect preferences | `ccdx config show --effective` |
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -683,6 +683,12 @@ load only when requested. Allowed function lists retain their
|
|
|
683
683
|
restriction and returned Chat calls are checked before completion. Chat cache
|
|
684
684
|
fields are forwarded only when the catalog explicitly advertises each field.
|
|
685
685
|
|
|
686
|
+
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).
|
|
687
|
+
|
|
688
|
+
`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).
|
|
689
|
+
|
|
690
|
+
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.
|
|
691
|
+
|
|
686
692
|
For an explicit root-combiner schema validation failure, the custom Messages
|
|
687
693
|
provider may send a bounded, model-facing object schema while retaining the
|
|
688
694
|
original validator for the response. Guarded tool frames are buffered until the
|
|
@@ -1229,3 +1235,9 @@ Responses accepts both the compact endpoint and a terminal inline compaction tri
|
|
|
1229
1235
|
|
|
1230
1236
|
|
|
1231
1237
|
The implementation takes the native/gateway-state ownership separation from [Magpie's native compaction design](https://github.com/yetone/magpie/blob/main/internal/gateway/native_compaction.go). The empty-reasoning boundary follows [Floway's input fix](https://github.com/Menci/Floway/commit/02f819f41a2e), and source/model-scoped observations follow its isolation principle. Counting/generation control parity follows [LiteLLM's correction](https://github.com/BerriAI/litellm/commit/5849906ddb2f); source endpoint declarations retain the protocol-selection principle demonstrated by [CC Switch](https://github.com/farion1231/cc-switch/commit/86c749b98e76). No upstream runtime, Redis or wholesale intermediate representation is added.
|
|
1238
|
+
|
|
1239
|
+
## Tool activity
|
|
1240
|
+
|
|
1241
|
+
`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.
|
|
1242
|
+
|
|
1243
|
+
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
|
@@ -39,6 +39,7 @@ For installation and first use, start with the [README](../README.md). This refe
|
|
|
39
39
|
| `ccdx config reset --preview` / `restore` | Preview defaults or restore the pre-reset backup |
|
|
40
40
|
| `ccdx requests [--failed] [--active]` | Inspect retained requests |
|
|
41
41
|
| `ccdx requests show <request_id>` | Read one retained request |
|
|
42
|
+
| `ccdx requests tools [--active]` | Read observed tool-call metadata; no arguments or outputs |
|
|
42
43
|
| `ccdx usage [--scope all\|run] [--provider ID] [--model ID] [--purpose VALUE] [--days N\|all]` | Read filtered retained usage or current-run totals |
|
|
43
44
|
| `ccdx doctor [--online] [--compat] [--fix] [--json]` | Check local setup; optional access checks and repairs |
|
|
44
45
|
| `ccdx doctor config` / `network` / `report` | Read configuration, routing or a redacted local report |
|
|
@@ -113,6 +114,14 @@ Only explicit, bounded session IDs can link requests. Local display identifiers
|
|
|
113
114
|
|
|
114
115
|
Each protocol observer retains at most 64 series of 64 request points and 16 compaction records, plus 20 unidentified requests. These numeric observations are memory-only and reset on restart. The page reads them on demand and after observed request completion through the existing dashboard refresh controller; ordinary status payloads do not include them. There is no prompt storage, text tokenization, transcript scan, extra provider request, content breakdown or compression control.
|
|
115
116
|
|
|
117
|
+
## Observed tool calls
|
|
118
|
+
|
|
119
|
+
**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
|
+
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
|
+
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
|
+
|
|
116
125
|
## Sources and client access
|
|
117
126
|
|
|
118
127
|
When Claude App encrypts a CCDX-owned gateway key, synchronization keeps the encrypted value and can still update owned model fields. The expected local key must match CCDX's ownership record; foreign profiles, addresses, rotated keys and user edits are not adopted. The sync result can report that the key was kept encrypted without claiming verified access. No system keystore decryption or extra permission is used.
|
|
@@ -129,6 +138,8 @@ Manual APIs require HTTPS. Codex requires Responses; Claude requires Messages. C
|
|
|
129
138
|
|
|
130
139
|
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.
|
|
131
140
|
|
|
141
|
+
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.
|
|
142
|
+
|
|
132
143
|
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.
|
|
133
144
|
|
|
134
145
|
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.
|
|
@@ -859,6 +870,8 @@ Changing the model or transport of a continuation can require removing incompati
|
|
|
859
870
|
|
|
860
871
|
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.
|
|
861
872
|
|
|
873
|
+
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.
|
|
874
|
+
|
|
862
875
|
GitHub Copilot's `gemini-4-carbon` uses Chat Completions. CCDX maps Codex custom,
|
|
863
876
|
namespaced and client-side tool-search calls to function tools and restores their
|
|
864
877
|
original identities in the reply and conversation history. The upstream receives
|
|
@@ -866,6 +879,10 @@ ordinary function tools; free-form grammar constraints are included in the tool
|
|
|
866
879
|
description rather than enforced by the Chat protocol. Other models retain their
|
|
867
880
|
existing routing and compatibility checks.
|
|
868
881
|
|
|
882
|
+
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.
|
|
883
|
+
|
|
884
|
+
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.
|
|
885
|
+
|
|
869
886
|
Carbon's standalone web search uses the current GitHub Copilot account. Only
|
|
870
887
|
search queries and requested constraints are sent to its search endpoint; the
|
|
871
888
|
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
|
});
|
|
@@ -415,7 +416,10 @@ export function createAdapterHandler(options = {}) {
|
|
|
415
416
|
abort.clearTimeout();
|
|
416
417
|
if (status >= 200 && status < 300) {
|
|
417
418
|
let models;
|
|
418
|
-
try {
|
|
419
|
+
try {
|
|
420
|
+
const parsed = JSON.parse(body);models = normalizeModelList(parsed);
|
|
421
|
+
if (models !== parsed) body = JSON.stringify(models);
|
|
422
|
+
} catch {}
|
|
419
423
|
if (isValidModelList(models)) {
|
|
420
424
|
if (selectedRegistry) {
|
|
421
425
|
selectedRegistry.models = models;
|
|
@@ -8,7 +8,7 @@ import {ANTIGRAVITY_MODEL_PREFIX,antigravityCopilotModels,mergeAntigravityModels
|
|
|
8
8
|
import {createPrivacyTextFragments} from "./privacy-stream.mjs";
|
|
9
9
|
import {createGoogleResponseObserver,googleUsageEvent} from "./antigravity-usage.mjs";
|
|
10
10
|
import {currentRequestContext,observeRequestedModel} from "./request-context.mjs";
|
|
11
|
-
import {markUpstreamStarted,markUpstreamHeaders,markFirstOutput,markOutputTokens,markRequestObservation,markResponseModel,markResponseTerminal} from "./stream-performance.mjs";
|
|
11
|
+
import {markUpstreamStarted,markUpstreamHeaders,markFirstOutput,markOutputTokens,markRequestObservation,markResponseModel,markResponseTerminal,markToolActivity} from "./stream-performance.mjs";
|
|
12
12
|
import {isCompactionRequest} from "./context-compaction.mjs";
|
|
13
13
|
import {compactionSummarizer} from "./context-compaction-wire.mjs";
|
|
14
14
|
import {requestPurpose} from "./request-context.mjs";
|
|
@@ -85,6 +85,7 @@ export function createAntigravityHandler({client,models=()=>[],selectedModels=()
|
|
|
85
85
|
usageModel=body.model;usageProvider="google";usageMode=method==="streamGenerateContent"?"sse":"json";
|
|
86
86
|
if(context){context.provider="google";context.streamPerformance?.setProvider?.("google")}
|
|
87
87
|
observeContextSession(null,{session_id:body.request?.labels?.root_cascade_id||body.request?.labels?.cascade_id},{profileId:()=>"google:gemini-native"},"gemini");
|
|
88
|
+
context?.streamPerformance?.observeToolInput?.(body.request,"gemini");
|
|
88
89
|
markRequestObservation({usage_state:"pending"});
|
|
89
90
|
}
|
|
90
91
|
const open=async(value,options={})=>{
|
|
@@ -107,6 +108,7 @@ export function createAntigravityHandler({client,models=()=>[],selectedModels=()
|
|
|
107
108
|
const nativeStreaming=/text\/event-stream/i.test(upstream.headers.get("content-type")||"");
|
|
108
109
|
if(generation)usageMode=nativeStreaming?"sse":"json";
|
|
109
110
|
const observer=generation&&upstream.ok?createGoogleResponseObserver({streaming:nativeStreaming,onEvent:value=>{
|
|
111
|
+
markToolActivity(value,"gemini");
|
|
110
112
|
const response=value?.response||value,event=googleUsageEvent(value);if(event)captureUsage(event);
|
|
111
113
|
const candidates=response?.candidates||[];
|
|
112
114
|
if(candidates.some(candidate=>candidate.content?.parts?.some(part=>part.functionCall||!part.thought&&typeof part.text==="string"&&part.text)))markFirstOutput("delta");
|
|
@@ -145,6 +147,7 @@ export function createAntigravityHandler({client,models=()=>[],selectedModels=()
|
|
|
145
147
|
observed=true;counts.copilot++;
|
|
146
148
|
if(context){context.provider="github";context.streamPerformance?.setProvider?.("github")}
|
|
147
149
|
observeContextSession(null,{session_id:body.request?.labels?.root_cascade_id||body.request?.labels?.cascade_id},{profileId:()=>"github:codex"},"chat");
|
|
150
|
+
context?.streamPerformance?.observeToolInput?.(body.request,"gemini");
|
|
148
151
|
const request=body.request;
|
|
149
152
|
if(body.requestType==="web_search"){
|
|
150
153
|
counts.search++;if(!searchFn)throw httpError("Copilot search is unavailable",503);
|
|
@@ -177,7 +180,7 @@ export function createAntigravityHandler({client,models=()=>[],selectedModels=()
|
|
|
177
180
|
if(!upstream.ok){await upstream.body?.cancel();throw httpError("Copilot generation was refused (HTTP "+upstream.status+")",upstream.status)}
|
|
178
181
|
if(!stream){
|
|
179
182
|
const data=JSON.parse(await readBoundedResponseText(upstream,{maxBytes:MAX_REPLY,signal:abort.signal,label:"Copilot response"}));captureUsage(data);
|
|
180
|
-
const result=chatToAntigravity(data,converted.originalNames);
|
|
183
|
+
const result=chatToAntigravity(data,converted.originalNames);markToolActivity(result,"gemini");
|
|
181
184
|
outcome=result.candidates[0].finishReason==="STOP"?"completed":"incomplete";markResponseTerminal(outcome);
|
|
182
185
|
res.writeHead(200,{"Content-Type":"application/json"});res.end(JSON.stringify({response:session.restoreValue(result)}));return;
|
|
183
186
|
}
|
|
@@ -185,6 +188,7 @@ export function createAntigravityHandler({client,models=()=>[],selectedModels=()
|
|
|
185
188
|
res.writeHead(200,{"Content-Type":"text/event-stream","Cache-Control":"no-cache"});
|
|
186
189
|
const emit=chunk=>writeOrDrain(res,"data: "+JSON.stringify(chunk)+"\n\n",{signal:abort.signal});
|
|
187
190
|
for await(const chunk of chatStreamToAntigravity(upstream,converted.originalNames,{onChunk:()=>abort.setTimeout(streamIdleTimeoutMs,"stream_idle_timeout"),onUsage:captureUsage})){
|
|
191
|
+
markToolActivity(chunk,"gemini");
|
|
188
192
|
const candidate=chunk.response?.candidates?.[0];
|
|
189
193
|
for(const part of candidate?.content?.parts||[]){
|
|
190
194
|
if(part.functionCall||typeof part.text==="string"&&part.text&&!part.thought)markFirstOutput("delta");
|
|
@@ -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/claude-gateway.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import { isLoopbackAddress, isLoopbackHostHeader } from "./security.mjs";
|
|
|
9
9
|
import { safeUpstreamResponseHeaders } from "./upstream-headers.mjs";
|
|
10
10
|
import { runWithRequestContext, currentRequestContext, observeRequestedModel } from "./request-context.mjs";
|
|
11
11
|
import { upstreamErrorEvidence, requestOptionsEvidence } from "./response-failures.mjs";
|
|
12
|
-
import { createStreamPerformanceMetrics, isMessagesOutputDelta, markRequestObservation } from "./stream-performance.mjs";
|
|
12
|
+
import { createStreamPerformanceMetrics, isMessagesOutputDelta, markRequestObservation, markToolActivity } from "./stream-performance.mjs";
|
|
13
13
|
import { buildMessagesUsageRecord, recordUsage } from "./usage-store.mjs";
|
|
14
14
|
import { redactDiagnosticText } from "./diagnostic-text.mjs";
|
|
15
15
|
import { decodedBodyLimitPreference } from "./user-settings.mjs";
|
|
@@ -337,6 +337,7 @@ export function createClaudeGatewayHandler({ provider, apiKey, desktopAliases =
|
|
|
337
337
|
if (!upstream.ok) context.onHttpError?.({ ...upstreamErrorEvidence(raw, { status: upstream.status }),
|
|
338
338
|
origin: context.countObservation?.cached ? "capability_cache" : "upstream_http", headers: upstream.headers });
|
|
339
339
|
if (!countTokens && upstream.ok && value?.type === "message" && Array.isArray(value.content)) {
|
|
340
|
+
markToolActivity(value, "messages");
|
|
340
341
|
if (value.content.some(hasMessageState)) await conversation?.commit?.({ tool: value.content.some(block => block?.type === "tool_use") });
|
|
341
342
|
abort.signal.throwIfAborted();
|
|
342
343
|
model = value.model || model;responseId = value.id;usage = value.usage;stopReason = value.stop_reason;
|
|
@@ -363,6 +364,7 @@ export function createClaudeGatewayHandler({ provider, apiKey, desktopAliases =
|
|
|
363
364
|
context.onHttpError?.({ ...evidence, code: evidence.code || evidence.error_type || "upstream_error", model_error: true, origin: "upstream_event", headers: upstream.headers });return;
|
|
364
365
|
}
|
|
365
366
|
if (sawStop || failedEvent) return;
|
|
367
|
+
if (event.type === "content_block_start") markToolActivity(event, "messages");
|
|
366
368
|
if (event.type === "content_block_start" && hasMessageState(event.content_block)
|
|
367
369
|
|| event.type === "content_block_delta" && (isMessagesOutputDelta(event.delta) || event.delta?.type === "signature_delta" && event.delta.signature)) {
|
|
368
370
|
if (!conversationCommitted) commitState = { tool: commitState?.tool === true || event.content_block?.type === "tool_use" };
|
package/src/cli-command-spec.mjs
CHANGED
|
@@ -183,6 +183,7 @@ export const MANAGED_COMMANDS = [
|
|
|
183
183
|
"--limit": "integer",
|
|
184
184
|
}),
|
|
185
185
|
command("requests show <request>", "Show a retained request and its original diagnostic fields", read),
|
|
186
|
+
command("requests tools", "Show observed tool-call metadata without arguments or outputs", { ...read, "--active": "flag" }),
|
|
186
187
|
command("requests diagnose", "Capture one redacted upstream Messages error; expires after ten minutes", { ...read, ...confirm, "--source": "value", "--model": "value", "--cancel": "flag" }),
|
|
187
188
|
command("compact status", "Show native and gateway compression observations without model calls", read),
|
|
188
189
|
command("compact enable", "Enable bounded recovery using the current source and model; uses quota", { ...read, ...confirm }),
|
|
@@ -291,7 +292,7 @@ const extras = {
|
|
|
291
292
|
config:
|
|
292
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.",
|
|
293
294
|
requests:
|
|
294
|
-
"Only retained records are available. Unknown clients are not guessed from an API route.\nApp filters: codex, claude-app, claude-code, antigravity.\n--failed filters failed model outcomes and structured HTTP/model errors.\nUsage records, HTTP calls and model outcomes are distinct counters.",
|
|
295
|
+
"Only retained records are available. Use requests tools to inspect observed tool metadata without model calls. Unknown clients are not guessed from an API route.\nApp filters: codex, claude-app, claude-code, antigravity.\n--failed filters failed model outcomes and structured HTTP/model errors.\nUsage records, HTTP calls and model outcomes are distinct counters.",
|
|
295
296
|
status:
|
|
296
297
|
"Default interactive status is brief; --details retains the complete diagnostic view.\nThe installed package version can differ from the running service.\nA listening gateway does not prove upstream model access.",
|
|
297
298
|
usage:
|
package/src/cli-management.mjs
CHANGED
|
@@ -122,6 +122,13 @@ export async function runManagementCommand(command, options = {}) {
|
|
|
122
122
|
return print(result.compaction);
|
|
123
123
|
}
|
|
124
124
|
if (group === "requests") {
|
|
125
|
+
if (action === "tools") {
|
|
126
|
+
const { data } = await readStatus();
|
|
127
|
+
const parts = [data.stream_performance, (data.providers?.claude || data.providers?.m365?.claude)?.requests?.performance].filter(Boolean);
|
|
128
|
+
if (!parts.some(part => part.tool_activity)) throw new Error("This command needs the updated running service; no settings changed.");
|
|
129
|
+
const items = parts.flatMap(part => part.tool_activity?.items || []).filter(row => !flags.active || ["preparing", "waiting"].includes(row.state));
|
|
130
|
+
return print(items, [["application", "Client"], ["provider", "Source"], ["model", "Model"], ["name", "Tool"], ["state", "State"]]);
|
|
131
|
+
}
|
|
125
132
|
if (action === "diagnose") {
|
|
126
133
|
if (flags.source || flags.model || flags.cancel) {
|
|
127
134
|
if (!flags.cancel && (!flags.source || !flags.model)) throw new Error("Use --source ID and --model ID together.");
|
package/src/context-metrics.mjs
CHANGED
|
@@ -14,7 +14,7 @@ export function observeContextSession(body, headers = {}, provider, protocol = "
|
|
|
14
14
|
try { session = JSON.parse(body.metadata.user_id)?.session_id; }
|
|
15
15
|
catch { session = /(?:^|_)session_([\w-]{8,128})$/.exec(body.metadata.user_id)?.[1]; }
|
|
16
16
|
}
|
|
17
|
-
if (!bounded(session)) return;
|
|
17
|
+
if (!bounded(session)) { tracker.observeToolInput?.(body, protocol);return; }
|
|
18
18
|
try {
|
|
19
19
|
const profile = provider?.profileId?.(protocol);
|
|
20
20
|
if (!bounded(profile)) return;
|
|
@@ -22,6 +22,7 @@ export function observeContextSession(body, headers = {}, provider, protocol = "
|
|
|
22
22
|
const key = createHmac("sha256", salt).update(`${profile}\0${session}\0${bounded(agent) ? agent : ""}`).digest("hex");
|
|
23
23
|
tracker.observeSession(key);
|
|
24
24
|
} catch { /* Optional metadata cannot change request admission or routing. */ }
|
|
25
|
+
tracker.observeToolInput?.(body, protocol);
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
export function createContextMetrics() {
|
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/console.js
CHANGED
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
if (snapshot) render(snapshot);
|
|
60
60
|
void refreshStatus();
|
|
61
61
|
globalThis.ccdxDashboardActivity?.visibilityChanged();
|
|
62
|
-
globalThis.ccdxDashboardFlow?.visibilityChanged();
|
|
62
|
+
globalThis.ccdxDashboardFlow?.visibilityChanged();globalThis.ccdxToolActivity?.visibilityChanged();
|
|
63
63
|
for (const item of document.querySelectorAll("[data-route]")) {
|
|
64
64
|
if (item.dataset.route === next) item.setAttribute("aria-current", "page");else item.removeAttribute("aria-current");
|
|
65
65
|
}
|
package/src/dashboard/index.html
CHANGED
|
@@ -369,6 +369,13 @@
|
|
|
369
369
|
<div class="flow-caption"><span id="flow-caption" data-i18n="flow_status_unknown">Status unavailable</span><button id="flow-clear" type="button" data-i18n="flow_show_all" hidden>Show all</button><button id="flow-more" type="button" hidden>More models</button></div>
|
|
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
|
+
<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 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
|
+
<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
|
+
</div>
|
|
378
|
+
</section>
|
|
372
379
|
<details class="panel dashboard-section" id="source-requests" open>
|
|
373
380
|
<summary data-i18n="requests_by_source">REQUESTS BY SOURCE</summary>
|
|
374
381
|
<p class="hint" data-i18n="results_since_startup_partial_usage_is_marked_separately">Results since startup. Partial usage is marked separately.</p>
|
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
const translations = {
|
|
3
|
+
"tool_heading": ["Tool and agent activity","工具与代理活动"],
|
|
4
|
+
"tool_style": ["Style","样式"],
|
|
5
|
+
"tool_style_grid": ["Grid","格子进度条"],
|
|
6
|
+
"tool_style_halo": ["Beam ring","光束圆环"],
|
|
7
|
+
"tool_style_busy": ["Busy pulse","忙碌脉冲"],
|
|
8
|
+
"tool_style_speed": ["Fast streaks","疾速流光"],
|
|
9
|
+
"tool_style_assembly": ["Assembly line","装配流水线"],
|
|
10
|
+
"tool_style_off": ["Off","关闭"],
|
|
11
|
+
"tool_preparing": ["Preparing a tool call","正在准备调用"],
|
|
12
|
+
"tool_preparing_many": ["Preparing {count} calls","并行准备 {count} 项调用"],
|
|
13
|
+
"tool_waiting": ["Waiting for tool results","等待工具返回"],
|
|
14
|
+
"tool_returned": ["Tool results received","工具结果已返回"],
|
|
15
|
+
"tool_failed": ["A tool call failed","调用失败"],
|
|
16
|
+
"tool_cancelled": ["Request cancelled","请求已取消"],
|
|
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","进行中"],
|
|
24
|
+
"tool_groups": ["{count} app and model groups","{count} 个应用及模型分组"],
|
|
25
|
+
"tool_more": ["{count} more observations in call details","另有 {count} 项观测,见调用详情"],
|
|
26
|
+
"tool_details": ["Call details","调用详情"],
|
|
27
|
+
"tool_action_read": ["Read file","读取文件"],
|
|
28
|
+
"tool_action_search": ["Search files","搜索文件"],
|
|
29
|
+
"tool_action_command": ["Run command","运行命令"],
|
|
30
|
+
"tool_action_edit": ["Edit file","修改文件"],
|
|
31
|
+
"tool_action_web": ["Search web","检索网页"],
|
|
32
|
+
"tool_action_generic": ["Tool call","工具调用"],
|
|
33
|
+
"tool_row_preparing": ["Preparing","准备中"],
|
|
34
|
+
"tool_row_waiting": ["Waiting for result","等待返回"],
|
|
35
|
+
"tool_row_returned": ["Returned","已返回"],
|
|
36
|
+
"tool_row_failed": ["Failed","失败"],
|
|
37
|
+
"tool_row_cancelled": ["Cancelled","已取消"],
|
|
38
|
+
"tool_row_unknown": ["Waiting for a fresh status","状态待更新"],
|
|
3
39
|
gemini_access_title: ["Copilot access", "Copilot 接入"],
|
|
4
40
|
gemini_model_selection: ["Model selection", "模型选择"],
|
|
5
41
|
gemini_route_waiting: ["No Antigravity request observed yet", "尚未观察到 Antigravity 请求"],
|
package/src/dashboard/status.js
CHANGED
|
@@ -235,7 +235,7 @@
|
|
|
235
235
|
for (const source of data.providers?.connections?.providers || []) sourceNames.set(source.id, source.name);
|
|
236
236
|
globalThis.ccdxConnections?.updateMemory?.(data.providers?.connections);
|
|
237
237
|
globalThis.ccdxDashboardActivity?.update(data.model_activity);
|
|
238
|
-
globalThis.ccdxDashboardFlow?.update(data);
|
|
238
|
+
globalThis.ccdxDashboardFlow?.update(data);globalThis.ccdxToolActivity?.update(data);
|
|
239
239
|
text("version", `v${data.version || "?"}`);
|
|
240
240
|
text("uptime", "pid_pid_uptime_duration", { pid: number(data.pid), duration: duration(data.uptime_ms) });
|
|
241
241
|
|
|
@@ -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 });
|
|
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));
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
(() => {
|
|
2
|
+
const root = document.getElementById("tool-activity");if (!root) return;
|
|
3
|
+
const el = id => document.getElementById(id), canvas = el("tool-canvas"), ctx = canvas.getContext?.("2d");
|
|
4
|
+
const styles = new Set(["halo", "grid", "busy", "speed", "assembly", "off"]), storageKey = "ccdx.dashboard.toolMotionStyle";
|
|
5
|
+
const pending = state => ["preparing", "waiting"].includes(state);
|
|
6
|
+
const phrase = (key, values = {}) => globalThis.ccdxLanguage.format(key, values);
|
|
7
|
+
const text = (id, key, values) => globalThis.ccdxLanguage.set(el(id), key, values);
|
|
8
|
+
const state = { scene: "idle", style: "halo", intensity: .8, reduce: false };
|
|
9
|
+
try { const saved = localStorage.getItem(storageKey);if (styles.has(saved)) state.style = saved; } catch {}
|
|
10
|
+
const motion = globalThis.matchMedia?.("(prefers-reduced-motion: reduce)") || { matches: false, addEventListener() {} };
|
|
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, requests = [], requestDeadline = 0;
|
|
13
|
+
const animating = () => ["calling", "parallel", "waiting", "processing", "responding"].includes(state.scene);
|
|
14
|
+
const shown = () => document.visibilityState === "visible" && !root.closest("[hidden]") && visible;
|
|
15
|
+
function measure() {
|
|
16
|
+
box = canvas.getBoundingClientRect();color = getComputedStyle(document.documentElement).getPropertyValue("--accent").trim();
|
|
17
|
+
refreshAnimation();
|
|
18
|
+
}
|
|
19
|
+
function draw(now=performance.now()){
|
|
20
|
+
if(!ctx||!box.width||!box.height)return;
|
|
21
|
+
const dpr=Math.min(devicePixelRatio||1,1.5),w=box.width,h=box.height;
|
|
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);}
|
|
23
|
+
ctx.setTransform(dpr,0,0,dpr,0,0);ctx.clearRect(0,0,w,h);
|
|
24
|
+
const cx=w/2,cy=h/2,r=Math.min(w,h)*.31;
|
|
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;
|
|
27
|
+
ctx.strokeStyle=color;ctx.fillStyle=color;ctx.lineWidth=.8;
|
|
28
|
+
function arc(radius,a,b,alpha){ctx.globalAlpha=alpha;ctx.beginPath();ctx.arc(cx,cy,radius,a,b);ctx.stroke();}
|
|
29
|
+
if(state.style==='grid'){
|
|
30
|
+
const cols=12,rows=3,gap=5,size=Math.min(13,(w-32)/cols-gap),left=cx-(cols*size+(cols-1)*gap)/2,top=cy-(rows*size+(rows-1)*gap)/2;
|
|
31
|
+
const head=active||waiting?(t*(waiting?11:19))%(cols*rows):-8;
|
|
32
|
+
for(let row=0;row<rows;row++)for(let col=0;col<cols;col++){
|
|
33
|
+
const index=row*cols+(row%2?cols-col-1:col),distance=(head-index+cols*rows)%(cols*rows),wave=Math.max(0,1-distance/8);
|
|
34
|
+
ctx.globalAlpha=quiet?.1:returned?.16+Math.max(0,1-(now-start)/900)*.42:.1+wave*power;
|
|
35
|
+
ctx.fillRect(left+col*(size+gap),top+row*(size+gap),size,size);
|
|
36
|
+
}
|
|
37
|
+
ctx.globalAlpha=1;return;
|
|
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
|
+
}
|
|
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);
|
|
73
|
+
const spin=active?t*1.6:waiting?t*.9:0;
|
|
74
|
+
if(state.style==='halo'){
|
|
75
|
+
for(let i=0;i<64;i++){
|
|
76
|
+
const a=i/64*Math.PI*2+spin,pulse=active||waiting?(Math.sin(t*7+i*.7)*.5+.5):returned?.6:.05;
|
|
77
|
+
const length=3+(i%4===0?8:3)+pulse*(active?20:waiting?9:2)*state.intensity;
|
|
78
|
+
ctx.globalAlpha=(.16+pulse*.55)*power;ctx.lineWidth=i%8===0?1.4:.75;
|
|
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();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if(state.style==='halo'){
|
|
83
|
+
ctx.lineWidth=.65;const strands=28;
|
|
84
|
+
for(let i=0;i<strands;i++){
|
|
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;
|
|
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();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
for(let i=0;i<3;i++){
|
|
90
|
+
const a=spin*(i%2?-1:1)+i*2.08,track=r*(.89+i*.06);
|
|
91
|
+
ctx.lineWidth=1.3;arc(track,a,a+(active?1.25:waiting?.75:.18),quiet?.15:.75);
|
|
92
|
+
}
|
|
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);}}
|
|
94
|
+
if(returned&&!reduced){const q=Math.min((now-start)/850,1);arc(r*(1+q*.32),0,Math.PI*2,(1-q)*.5);}
|
|
95
|
+
ctx.globalAlpha=1;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function animate(now) {
|
|
99
|
+
raf = 0;
|
|
100
|
+
if (!shown() || motion.matches || state.style === "off" || !animating() && !(state.scene === "returned" && now - start < 900)) return;
|
|
101
|
+
if (now - last >= 1000 / 30) { last = now;draw(now); }raf = requestAnimationFrame(animate);
|
|
102
|
+
}
|
|
103
|
+
function refreshAnimation() {
|
|
104
|
+
cancelAnimationFrame(raf);raf = 0;root.dataset.paused = String(!shown() || motion.matches);
|
|
105
|
+
if (!shown() || state.style === "off") return;
|
|
106
|
+
draw();if (!motion.matches && (animating() || state.scene === "returned" && performance.now() - start < 900)) raf = requestAnimationFrame(animate);
|
|
107
|
+
}
|
|
108
|
+
function category(name) {
|
|
109
|
+
const value = String(name || "").toLowerCase().split(/__|\./).at(-1);
|
|
110
|
+
if (["read_file", "readfile", "view_file", "open_file", "get_file_content"].includes(value)) return "tool_action_read";
|
|
111
|
+
if (["search_files", "file_search", "grep", "rg"].includes(value)) return "tool_action_search";
|
|
112
|
+
if (["exec_command", "run_command", "bash", "shell"].includes(value)) return "tool_action_command";
|
|
113
|
+
if (["write_file", "edit_file", "apply_patch"].includes(value)) return "tool_action_edit";
|
|
114
|
+
if (["web_search", "search_web"].includes(value)) return "tool_action_web";
|
|
115
|
+
return "tool_action_generic";
|
|
116
|
+
}
|
|
117
|
+
function appName(id) { return phrase(`flow_app_${id}`); }
|
|
118
|
+
const sourceName = id => id === "github" ? "GitHub Copilot" : id === "m365" ? "Microsoft 365" : id === "google" ? "Google" : globalThis.ccdxConnectionNames?.[id] || phrase("flow_source_unknown");
|
|
119
|
+
function render(force = false) {
|
|
120
|
+
if (root.closest("[hidden]")) { signature = "";refreshAnimation();return; }
|
|
121
|
+
const time = performance.now();
|
|
122
|
+
if (requestDeadline && time >= requestDeadline) { requests = [];requestDeadline = 0;fresh = false; }
|
|
123
|
+
for (const row of records) if (row.until <= time && pending(row.state)) { row.state = "unknown";row.until = time + 300000; }
|
|
124
|
+
records = records.filter(row => row.until > time);
|
|
125
|
+
const rows = records.slice(0, 32).map(row => fresh || !pending(row.state) ? row : { ...row, state: "unknown" });
|
|
126
|
+
const agents = fresh ? requests : [];
|
|
127
|
+
const next = JSON.stringify([fresh, supported, state.style, omitted, agents, rows.map(({ until, ...row }) => row)]);
|
|
128
|
+
clearTimeout(expiry);expiry = null;
|
|
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));
|
|
131
|
+
if (!force && next === signature) return;
|
|
132
|
+
signature = next;
|
|
133
|
+
const active = rows.filter(row => pending(row.state)), preparing = active.some(row => row.state === "preparing");
|
|
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"
|
|
137
|
+
: rows.some(row => row.state === "returned") && !rows.some(row => ["failed", "cancelled", "unknown"].includes(row.state)) ? "returned" : "idle";
|
|
138
|
+
if (scene !== state.scene) start = performance.now();state.scene = scene;
|
|
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"
|
|
141
|
+
: rows.some(row => row.state === "failed") ? "tool_failed" : rows.some(row => row.state === "cancelled") ? "tool_cancelled"
|
|
142
|
+
: rows.some(row => row.state === "unknown") ? "flow_status_unknown" : rows.length ? "tool_returned" : "tool_idle";
|
|
143
|
+
const count = active.length || agents.length;
|
|
144
|
+
text("tool-state", key, { count });
|
|
145
|
+
canvas.setAttribute("aria-label", phrase(key, { count }));
|
|
146
|
+
el("tool-style").value = state.style;el("tool-stage").dataset.style = state.style;
|
|
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 });
|
|
152
|
+
const list = el("tool-list");list.replaceChildren();
|
|
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;
|
|
156
|
+
const mark = document.createElement("span");mark.className = "tool-mark";mark.setAttribute("aria-hidden", "true");
|
|
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}`);
|
|
159
|
+
item.append(mark, name, status);list.append(item);
|
|
160
|
+
}
|
|
161
|
+
el("tool-details").hidden = !rows.length;
|
|
162
|
+
el("tool-technical").replaceChildren();
|
|
163
|
+
for (const row of rows) {
|
|
164
|
+
const line = document.createElement("p");line.textContent = `${appName(row.application)} · ${sourceName(row.provider)} · ${row.model} · ${row.name || phrase("tool_action_generic")} · ${phrase(`tool_row_${row.state}`)}`;el("tool-technical").append(line);
|
|
165
|
+
}
|
|
166
|
+
el("tool-more").hidden = rows.length <= 6 && !omitted;
|
|
167
|
+
text("tool-more", "tool_more", { count: Math.max(0, rows.length - 6) + omitted });
|
|
168
|
+
measure();
|
|
169
|
+
}
|
|
170
|
+
el("tool-style").addEventListener("change", () => {
|
|
171
|
+
const next = el("tool-style").value;if (!styles.has(next)) return;state.style = next;
|
|
172
|
+
try { localStorage.setItem(storageKey, next); } catch {}render(true);
|
|
173
|
+
});
|
|
174
|
+
document.addEventListener("visibilitychange", () => { if (shown()) render();refreshAnimation(); });
|
|
175
|
+
globalThis.addEventListener("pagehide", () => { cancelAnimationFrame(raf);raf = 0;root.dataset.paused = "true"; });
|
|
176
|
+
motion.addEventListener("change", refreshAnimation);
|
|
177
|
+
new ResizeObserver(measure).observe(canvas.parentElement);
|
|
178
|
+
new IntersectionObserver(entries => { visible = entries[0].isIntersecting;refreshAnimation(); }, { threshold: .05 }).observe(canvas);
|
|
179
|
+
new MutationObserver(() => render(true)).observe(document.documentElement, { attributes: true, attributeFilter: ["lang", "data-theme", "data-palette"] });
|
|
180
|
+
globalThis.ccdxToolActivity = {
|
|
181
|
+
update(data, { live = false } = {}) {
|
|
182
|
+
const parts = [data?.stream_performance, (data?.providers?.claude || data?.providers?.m365?.claude)?.requests?.performance].filter(Boolean);
|
|
183
|
+
const views = parts.map(part => part.tool_activity).filter(value => Array.isArray(value?.items));
|
|
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;
|
|
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)
|
|
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,
|
|
191
|
+
state: row.state, until: time + Math.min(row.expires_in_ms, 300000) })));
|
|
192
|
+
merged.sort((a, b) => Number(pending(b.state)) - Number(pending(a.state)));records = merged.slice(0, 32);
|
|
193
|
+
omitted = Math.max(0, merged.length - records.length) + views.reduce((sum, view) => sum + (Number.isSafeInteger(view.omitted) ? view.omitted : 0), 0);render();
|
|
194
|
+
},
|
|
195
|
+
unavailable() { fresh = false;requests = [];requestDeadline = 0;render(); },
|
|
196
|
+
visibilityChanged() { render();refreshAnimation(); },
|
|
197
|
+
};
|
|
198
|
+
render();
|
|
199
|
+
})();
|