@platless/axom-cli 0.5.9 → 0.6.36
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 +18 -5
- package/dist/axom-patch/cli/README.md +100 -12
- package/dist/axom-patch/cli/account-limits/generate.py +15 -12
- package/dist/axom-patch/cli/account-limits/kimi-proxy.mjs +20 -3
- package/dist/axom-patch/cli/claude-account-limits.json +9 -9
- package/dist/axom-patch/cli/codex-account-limits.json +11 -11
- package/dist/axom-patch/cli/codex-terminal-output.json +16 -0
- package/dist/axom-patch/cli/commandcode-account-limits.json +9 -9
- package/dist/axom-patch/cli/kimi-quota.mjs +12 -0
- package/dist/axom-patch/cli/kimi-subagents.mjs +173 -0
- package/dist/axom-patch/cli/nightly-task.md +55 -13
- package/dist/axom-patch/cli/probes/codex-terminal-output.mjs +33 -0
- package/dist/axom-patch/cli/probes/kimi-subagent-subwork.mjs +82 -0
- package/dist/axom-patch/cli/qoder/dist/axom-acp-compat.mjs +1591 -0
- package/dist/axom-patch/cli/qoder/releases/1.1.75.json +360 -0
- package/dist/axom-patch/cli/qoder-background-terminal.md +13 -6
- package/dist/axom-patch/cli/qoder-foreground-output.md +14 -8
- package/dist/axom-patch/cli/qoder-native-acp.json +227 -0
- package/dist/axom-patch/cli/qoder-steering.md +20 -25
- package/dist/axom-patch/cli/qoder-subagent-subwork.md +17 -68
- package/dist/axom-patch/cli/runtime.json +16 -18
- package/dist/axom-patch/cli/zcode-account-limits.json +10 -11
- package/dist/axom-patch/cli/zcode-models.json +1 -2
- package/dist/axom-patch/cli/zcode-subagent-subwork.json +9 -10
- package/dist/cli.js +4 -36
- package/dist/commands/knowledge.js +47 -0
- package/dist/commands/update.js +65 -3
- package/dist/commands/workstation.js +73 -7
- package/dist/install/claude/commands.js +13 -13
- package/dist/mcp.js +1 -1
- package/dist/native/darwin-arm64/axom-quic +0 -0
- package/dist/workstation/acp/acpAgents.js +102 -98
- package/dist/workstation/acp/acpClient.js +26 -0
- package/dist/workstation/acp/builds/install/npm.js +99 -10
- package/dist/workstation/acp/initializeResponse.js +6 -1
- package/dist/workstation/acp/managedPatches.js +189 -25
- package/dist/workstation/acp/managedRuntime.js +314 -0
- package/dist/workstation/acp/patchAssets.js +40 -0
- package/dist/workstation/acp/processor/checkpoint.js +25 -34
- package/dist/workstation/acp/processor/control.js +5 -78
- package/dist/workstation/acp/processor/runtime.js +5 -81
- package/dist/workstation/acp/processor/session.js +51 -80
- package/dist/workstation/acp/processor/state.js +6 -13
- package/dist/workstation/acp/processor/step.js +3 -20
- package/dist/workstation/acp/processor/test/fixtureLog.js +9 -16
- package/dist/workstation/acp/processor/updates.js +131 -105
- package/dist/workstation/acp/processorSession.js +8 -172
- package/dist/workstation/acp/registry/catalog.js +65 -39
- package/dist/workstation/acp/registry/launch.js +16 -1
- package/dist/workstation/acp/switching.js +0 -3
- package/dist/workstation/acp/test/fakeAgent.js +13 -0
- package/dist/workstation/acp/test/keeperWorld.js +28 -0
- package/dist/workstation/acp/test/raw/sources.js +16 -130
- package/dist/workstation/acp/test/realAdapter.js +1 -47
- package/dist/workstation/acp/test/scriptAgent.js +11 -3
- package/dist/workstation/agentFlow.js +1 -1
- package/dist/workstation/agentSessions.js +38 -143
- package/dist/workstation/channels/management.js +95 -11
- package/dist/workstation/channels/url.js +1 -1
- package/dist/workstation/config.js +16 -4
- package/dist/workstation/connection/encryptedChannel.js +4 -1
- package/dist/workstation/control/bindingStore.js +200 -0
- package/dist/workstation/control/commands.js +124 -0
- package/dist/workstation/control/daemonIdentity.js +53 -0
- package/dist/workstation/control/enrollment.js +106 -0
- package/dist/workstation/control/inspect.js +71 -0
- package/dist/workstation/control/locks.js +63 -0
- package/dist/workstation/control/protocol.js +40 -0
- package/dist/workstation/control/restartGuard.js +46 -0
- package/dist/workstation/control/runtimeClient.js +97 -0
- package/dist/workstation/control/runtimeHost.js +148 -0
- package/dist/workstation/control/serverIdentity.js +35 -0
- package/dist/workstation/daemon.js +106 -6
- package/dist/workstation/daemonctl.js +77 -14
- package/dist/workstation/desktopControl/audio.js +99 -0
- package/dist/workstation/desktopControl/capabilities.js +92 -0
- package/dist/workstation/desktopControl/captureModes.js +9 -0
- package/dist/workstation/desktopControl/captureTargetLabel.js +9 -0
- package/dist/workstation/desktopControl/deviceSockets.js +246 -0
- package/dist/workstation/desktopControl/helperProcess.js +353 -0
- package/dist/workstation/desktopControl/lobby.js +129 -0
- package/dist/workstation/desktopControl/macProvider.js +155 -0
- package/dist/workstation/desktopControl/media.js +331 -0
- package/dist/workstation/desktopControl/nativeProvider.js +1018 -0
- package/dist/workstation/desktopControl/networkEvidence.js +43 -0
- package/dist/workstation/desktopControl/overview.js +58 -0
- package/dist/workstation/desktopControl/protocol.js +302 -0
- package/dist/workstation/desktopControl/quicMedia.js +240 -0
- package/dist/workstation/desktopControl/rateController.js +226 -0
- package/dist/workstation/desktopControl/supervisor.js +1681 -0
- package/dist/workstation/desktopControl/transport.js +27 -0
- package/dist/workstation/desktopControl/wallpaper.js +78 -0
- package/dist/workstation/files/credentials.js +142 -0
- package/dist/workstation/files/text.js +42 -8
- package/dist/workstation/keepers/kit/bundle.js +21 -17
- package/dist/workstation/keepers/kit/launcher.js +47 -7
- package/dist/workstation/keepers/kit/paths.js +2 -1
- package/dist/workstation/managedInstall.js +57 -0
- package/dist/workstation/protocol/agent.js +2 -15
- package/dist/workstation/protocol/management.js +93 -4
- package/dist/workstation/protocol/runtimeDiagnostics.js +15 -0
- package/dist/workstation/rd/artifact.js +119 -0
- package/dist/workstation/rd/control.js +119 -0
- package/dist/workstation/rd/display.js +29 -0
- package/dist/workstation/rd/provider.js +222 -0
- package/dist/workstation/rd/sessions.js +391 -0
- package/dist/workstation/rd/state.js +45 -0
- package/dist/workstation/rd/update.js +171 -0
- package/dist/workstation/rd/upkeep.js +38 -0
- package/dist/workstation/register.js +27 -37
- package/dist/workstation/service/installer.js +104 -13
- package/dist/workstation/service/launchd.js +1 -0
- package/dist/workstation/storageMetrics.js +118 -0
- package/dist/workstation/systemMetrics.js +44 -92
- package/dist/workstation/toolchain.js +94 -0
- package/dist/workstation/tools/browser.js +28 -4
- package/dist/workstation/update/artifact.js +2 -1
- package/dist/workstation/update/globalInstall.js +116 -0
- package/dist/workstation/update/npmInstaller.js +49 -23
- package/dist/workstation/update/rdRollback.js +145 -0
- package/dist/workstation/update/runUpdate.js +3 -2
- package/dist/workstation/update/watchdog.js +16790 -334
- package/package.json +5 -5
- package/skills/axom/SKILL.md +11 -11
- package/skills/axom-definition/SKILL.md +3 -3
- package/skills/axom-platform/SKILL.md +3 -3
- package/dist/axom-patch/cli/probes/qoder-steering.mjs +0 -89
- package/dist/axom-patch/cli/probes/qoder-subagent-origin.mjs +0 -61
- package/dist/axom-patch/cli/qoder-steering.json +0 -52
- package/dist/axom-patch/cli/qoder-subagent-origin.json +0 -73
- package/dist/commands/guide.js +0 -38
- package/dist/runtime-deps/qoder-sdk/package-lock.json +0 -1189
- package/dist/runtime-deps/qoder-sdk/package.json +0 -8
- package/dist/workstation/acp/delegationMcp.js +0 -24
- package/dist/workstation/acp/processor/sideChannel.js +0 -80
- package/dist/workstation/acp/qoderStartup.js +0 -45
- package/dist/workstation/acp/test/raw/qoderCaptures.js +0 -125
- package/dist/workstation/qoderAdapter/backgroundProcess.js +0 -118
- package/dist/workstation/qoderAdapter/backgroundTerminal.js +0 -193
- package/dist/workstation/qoderAdapter/backgroundTerminalFold.js +0 -372
- package/dist/workstation/qoderAdapter/callbackContext.js +0 -76
- package/dist/workstation/qoderAdapter/completedContinuation.js +0 -139
- package/dist/workstation/qoderAdapter/contract.js +0 -78
- package/dist/workstation/qoderAdapter/foregroundOutput.js +0 -36
- package/dist/workstation/qoderAdapter/history.js +0 -85
- package/dist/workstation/qoderAdapter/identityIndex.js +0 -191
- package/dist/workstation/qoderAdapter/inputQueue.js +0 -42
- package/dist/workstation/qoderAdapter/main.js +0 -95
- package/dist/workstation/qoderAdapter/mapper.js +0 -117
- package/dist/workstation/qoderAdapter/observerPlugin.js +0 -245
- package/dist/workstation/qoderAdapter/observerReceiver.js +0 -187
- package/dist/workstation/qoderAdapter/permissions.js +0 -61
- package/dist/workstation/qoderAdapter/profile.js +0 -93
- package/dist/workstation/qoderAdapter/sdkDriver.js +0 -48
- package/dist/workstation/qoderAdapter/sdkRuntime.js +0 -93
- package/dist/workstation/qoderAdapter/sdkRuntimeInstall.js +0 -145
- package/dist/workstation/qoderAdapter/session.js +0 -319
- package/dist/workstation/qoderAdapter/subagentMeta.js +0 -28
- package/dist/workstation/qoderAdapter/subwork.js +0 -85
- package/dist/workstation/qoderAdapter/taskControl.js +0 -38
- package/dist/workstation/qoderAdapter/taskLedger.js +0 -163
- package/dist/workstation/qoderAdapter/usage.js +0 -37
- /package/dist/workstation/{qoderAdapter/types.js → desktopControl/provider.js} +0 -0
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { DesktopNetworkEvidence } from './networkEvidence.js';
|
|
2
|
+
export class DesktopRateController {
|
|
3
|
+
min;
|
|
4
|
+
max;
|
|
5
|
+
maxFps;
|
|
6
|
+
networkEvidence = new DesktopNetworkEvidence();
|
|
7
|
+
target;
|
|
8
|
+
fps;
|
|
9
|
+
lastNow = -Infinity;
|
|
10
|
+
lastWindow = -Infinity;
|
|
11
|
+
lastRateChange = -Infinity;
|
|
12
|
+
lastFpsChange = -Infinity;
|
|
13
|
+
lastReopen = -Infinity;
|
|
14
|
+
cooldown = -Infinity;
|
|
15
|
+
reopens = [];
|
|
16
|
+
networkPressure = 0;
|
|
17
|
+
processingPressure = 0;
|
|
18
|
+
networkHealthy = 0;
|
|
19
|
+
headroom = 0;
|
|
20
|
+
recoveryWindows = 0;
|
|
21
|
+
recoveryFps;
|
|
22
|
+
fpsTrialUntil = -Infinity;
|
|
23
|
+
fpsRecoveryAfter = -Infinity;
|
|
24
|
+
paused = false;
|
|
25
|
+
demandBps = 0;
|
|
26
|
+
demandKnown = false;
|
|
27
|
+
windowHadActivity = false;
|
|
28
|
+
windowHadProgress = false;
|
|
29
|
+
windowHadProbeEvidence = false;
|
|
30
|
+
processingSamples = [];
|
|
31
|
+
encodeSamples = [];
|
|
32
|
+
lastEncodeObservation = -Infinity;
|
|
33
|
+
lastDecodeObservation = -Infinity;
|
|
34
|
+
lastNetworkPolicySample;
|
|
35
|
+
lastPath;
|
|
36
|
+
snapshot = { networkState: 'unknown',
|
|
37
|
+
networkQueueMs: 0, observedPayloadBps: 0, processingP95Ms: 0, encodeP95Ms: 0, receiverBudgetMs: 0, reasons: [] };
|
|
38
|
+
constructor(options = {}) {
|
|
39
|
+
const min = options.minBps ?? 500_000, max = options.maxBps ?? 20_000_000;
|
|
40
|
+
if (![min, max, options.targetBps ?? 4_000_000].every(Number.isFinite) || min < 500_000 || max > 20_000_000)
|
|
41
|
+
throw new Error('invalid rate bounds');
|
|
42
|
+
this.min = Math.ceil(min / 4000) * 4000;
|
|
43
|
+
this.max = Math.floor(max / 4000) * 4000;
|
|
44
|
+
if (this.min > this.max)
|
|
45
|
+
throw new Error('unrepresentable rate bounds');
|
|
46
|
+
this.target = this.quantize(options.targetBps ?? 4_000_000);
|
|
47
|
+
this.maxFps = options.maxFps ?? options.fpsCeiling ?? 60;
|
|
48
|
+
this.fps = options.fpsCeiling ?? this.maxFps;
|
|
49
|
+
this.recoveryFps = this.fps;
|
|
50
|
+
if (![15, 30, 60].includes(this.fps) || ![15, 30, 60].includes(this.maxFps) || this.fps > this.maxFps)
|
|
51
|
+
throw new Error('invalid fps bounds');
|
|
52
|
+
}
|
|
53
|
+
get diagnostics() { return { ...this.snapshot, reasons: [...this.snapshot.reasons] }; }
|
|
54
|
+
quantize(rate) {
|
|
55
|
+
return Math.max(this.min, Math.min(this.max, Math.floor(rate / 4000) * 4000));
|
|
56
|
+
}
|
|
57
|
+
sample(s, runtimeRateReconfigure = false) {
|
|
58
|
+
const optional = [s.rttBaselineMs, s.deliveryDelayMs, s.deliveryObservedAtMs, s.encodeObservedAtMs, s.decodeObservedAtMs];
|
|
59
|
+
if (![s.nowMs, s.activeBytes, s.excessRttMs, s.queueAgeMs, s.queuedSendMs, s.encodeMs, s.decodeMs]
|
|
60
|
+
.every(value => Number.isFinite(value) && value >= 0) ||
|
|
61
|
+
optional.some(value => value !== undefined && (!Number.isFinite(value) || value < 0)) ||
|
|
62
|
+
s.nowMs < this.lastNow)
|
|
63
|
+
throw new Error('invalid rate sample');
|
|
64
|
+
const elapsed = Number.isFinite(this.lastNow) ? s.nowMs - this.lastNow : 1000;
|
|
65
|
+
if (elapsed > 0) {
|
|
66
|
+
const observed = Math.min(this.max * 4, s.activeBytes * 8000 / elapsed);
|
|
67
|
+
const weight = -Math.expm1(-elapsed / 1000);
|
|
68
|
+
this.demandBps = this.demandKnown ? this.demandBps + (observed - this.demandBps) * weight : observed;
|
|
69
|
+
this.demandKnown = true;
|
|
70
|
+
}
|
|
71
|
+
this.lastNow = s.nowMs;
|
|
72
|
+
const window = Math.floor(s.nowMs / 1000);
|
|
73
|
+
const contiguous = window === this.lastWindow + 1;
|
|
74
|
+
const activeWindow = s.activeBytes > 0 || (contiguous && this.windowHadActivity);
|
|
75
|
+
const freshnessMs = Math.max(1500, (s.rttBaselineMs ?? 0) * 3);
|
|
76
|
+
const progress = s.deliveryObservedAtMs !== undefined
|
|
77
|
+
? s.deliveryObservedAtMs <= s.nowMs && s.nowMs - s.deliveryObservedAtMs <= freshnessMs
|
|
78
|
+
: s.deliveryDelayMs !== undefined && s.deliveryDelayMs <= 40;
|
|
79
|
+
const progressWindow = progress || contiguous && this.windowHadProgress;
|
|
80
|
+
this.windowHadActivity = window === this.lastWindow ? this.windowHadActivity || s.activeBytes > 0 : s.activeBytes > 0;
|
|
81
|
+
this.windowHadProgress = window === this.lastWindow ? this.windowHadProgress || progress : progress;
|
|
82
|
+
if (s.queuedSendMs > 100)
|
|
83
|
+
this.paused = true;
|
|
84
|
+
else if (s.queuedSendMs === 0)
|
|
85
|
+
this.paused = false;
|
|
86
|
+
const evidence = this.networkEvidence.sample(s.nowMs, s.network, this.demandBps);
|
|
87
|
+
const probeEvidence = progress && (evidence.state === 'usable' || evidence.state === 'unknown' &&
|
|
88
|
+
s.deliveryDelayMs !== undefined && s.deliveryDelayMs <= 40);
|
|
89
|
+
const probeWindow = probeEvidence || contiguous && this.windowHadProbeEvidence;
|
|
90
|
+
this.windowHadProbeEvidence = window === this.lastWindow ? this.windowHadProbeEvidence || probeEvidence : probeEvidence;
|
|
91
|
+
const path = s.network ? `${s.network.id}:${s.network.pathGeneration}` : undefined;
|
|
92
|
+
if (path !== this.lastPath) {
|
|
93
|
+
this.networkPressure = this.networkHealthy = 0;
|
|
94
|
+
this.lastNetworkPolicySample = undefined;
|
|
95
|
+
this.lastPath = path;
|
|
96
|
+
}
|
|
97
|
+
const sampleKey = s.network ? `${path}:${s.network.sequence}` : undefined;
|
|
98
|
+
const freshNetworkWindow = sampleKey !== undefined && sampleKey !== this.lastNetworkPolicySample;
|
|
99
|
+
if (window !== this.lastWindow && !contiguous) {
|
|
100
|
+
this.processingSamples = [];
|
|
101
|
+
this.encodeSamples = [];
|
|
102
|
+
}
|
|
103
|
+
const encodeAt = s.encodeObservedAtMs ?? (s.encodeMs > 0 ? s.nowMs : undefined);
|
|
104
|
+
const decodeAt = s.decodeObservedAtMs ?? (s.decodeMs > 0 ? s.nowMs : undefined);
|
|
105
|
+
const costs = [];
|
|
106
|
+
if (encodeAt !== undefined && encodeAt > this.lastEncodeObservation && encodeAt <= s.nowMs && s.nowMs - encodeAt <= freshnessMs) {
|
|
107
|
+
this.lastEncodeObservation = encodeAt;
|
|
108
|
+
costs.push(s.encodeMs);
|
|
109
|
+
this.encodeSamples.push(s.encodeMs);
|
|
110
|
+
}
|
|
111
|
+
if (decodeAt !== undefined && decodeAt > this.lastDecodeObservation && decodeAt <= s.nowMs && s.nowMs - decodeAt <= freshnessMs) {
|
|
112
|
+
this.lastDecodeObservation = decodeAt;
|
|
113
|
+
costs.push(s.decodeMs);
|
|
114
|
+
}
|
|
115
|
+
if (costs.length)
|
|
116
|
+
this.processingSamples.push(Math.max(...costs));
|
|
117
|
+
if (this.processingSamples.length > 128)
|
|
118
|
+
this.processingSamples.shift();
|
|
119
|
+
if (this.encodeSamples.length > 128)
|
|
120
|
+
this.encodeSamples.shift();
|
|
121
|
+
this.snapshot = { ...this.snapshot, networkState: evidence.state, networkQueueMs: evidence.queueMs,
|
|
122
|
+
observedPayloadBps: Math.round(this.demandBps), reasons: this.paused ? ['sender-backpressure'] : [] };
|
|
123
|
+
const decision = (reopenEpoch = false) => ({ targetBps: this.target,
|
|
124
|
+
fpsCeiling: this.fps, pauseCapture: this.paused, reopenEpoch });
|
|
125
|
+
if (window === this.lastWindow)
|
|
126
|
+
return decision();
|
|
127
|
+
this.lastWindow = window;
|
|
128
|
+
if (!contiguous)
|
|
129
|
+
this.networkPressure = this.processingPressure = this.networkHealthy = this.headroom = this.recoveryWindows = 0;
|
|
130
|
+
const costsInWindow = this.processingSamples.sort((left, right) => left - right);
|
|
131
|
+
this.processingSamples = [];
|
|
132
|
+
const cost = costsInWindow[Math.max(0, Math.ceil(costsInWindow.length * 0.95) - 1)] ?? 0;
|
|
133
|
+
this.snapshot.processingP95Ms = cost;
|
|
134
|
+
const encodeCosts = this.encodeSamples.sort((left, right) => left - right);
|
|
135
|
+
this.encodeSamples = [];
|
|
136
|
+
const encodeCost = encodeCosts[Math.max(0, Math.ceil(encodeCosts.length * 0.95) - 1)] ?? 0;
|
|
137
|
+
const receiverBudget = Math.max(80, 3000 / this.fps);
|
|
138
|
+
this.snapshot.encodeP95Ms = encodeCost;
|
|
139
|
+
this.snapshot.receiverBudgetMs = receiverBudget;
|
|
140
|
+
if (!activeWindow) {
|
|
141
|
+
this.networkPressure = this.processingPressure = this.networkHealthy = this.headroom = this.recoveryWindows = 0;
|
|
142
|
+
this.snapshot.reasons.push('content-idle');
|
|
143
|
+
return decision();
|
|
144
|
+
}
|
|
145
|
+
const net = evidence.state === 'congested' && freshNetworkWindow;
|
|
146
|
+
this.lastNetworkPolicySample = sampleKey;
|
|
147
|
+
const receiverPressure = costsInWindow.length > 0 && cost > 0.8 * 1000 / this.fps && s.queueAgeMs > receiverBudget;
|
|
148
|
+
const sourcePressure = encodeCosts.length > 0 && encodeCost > 0.8 * 1000 / this.fps;
|
|
149
|
+
const processing = sourcePressure || receiverPressure;
|
|
150
|
+
this.networkPressure = net ? this.networkPressure + 1 : 0;
|
|
151
|
+
this.processingPressure = processing ? this.processingPressure + 1 : 0;
|
|
152
|
+
this.networkHealthy = !net && probeWindow && progressWindow && !this.paused ? this.networkHealthy + 1 : 0;
|
|
153
|
+
const nextFps = Math.min(this.maxFps, this.fps === 15 ? 30 : 60);
|
|
154
|
+
this.headroom = encodeCosts.length > 0 && !processing && s.queueAgeMs <= 40 && !this.paused &&
|
|
155
|
+
encodeCost < 0.6 * 1000 / nextFps ? this.headroom + 1 : 0;
|
|
156
|
+
this.recoveryWindows = nextFps > this.fps && nextFps <= this.recoveryFps && encodeCosts.length > 0 &&
|
|
157
|
+
progressWindow && !net && s.queueAgeMs <= 40 && !this.paused && encodeCost < 0.8 * 1000 / nextFps
|
|
158
|
+
? this.recoveryWindows + 1 : 0;
|
|
159
|
+
if (net)
|
|
160
|
+
this.snapshot.reasons.push('sender-path-congestion');
|
|
161
|
+
if (processing)
|
|
162
|
+
this.snapshot.reasons.push('processing-pressure');
|
|
163
|
+
if (sourcePressure)
|
|
164
|
+
this.snapshot.reasons.push('source-encode-pressure');
|
|
165
|
+
if (receiverPressure)
|
|
166
|
+
this.snapshot.reasons.push('receiver-backlog');
|
|
167
|
+
if (evidence.state === 'unknown')
|
|
168
|
+
this.snapshot.reasons.push('network-unknown');
|
|
169
|
+
if (this.fps < this.recoveryFps && s.nowMs < this.fpsRecoveryAfter)
|
|
170
|
+
this.snapshot.reasons.push('fps-recovery-backoff');
|
|
171
|
+
if (s.nowMs < this.cooldown)
|
|
172
|
+
return decision();
|
|
173
|
+
let target = this.target, fps = this.fps;
|
|
174
|
+
if (this.networkPressure >= 2 && s.nowMs - this.lastRateChange >= 2000) {
|
|
175
|
+
target = this.quantize(Math.min(target * 0.85, evidence.bandwidthBps ? evidence.bandwidthBps * 0.9 : target));
|
|
176
|
+
}
|
|
177
|
+
else if (this.networkHealthy >= 3 && s.nowMs - this.lastRateChange >= (runtimeRateReconfigure ? 2000 : 10000) &&
|
|
178
|
+
this.demandBps >= target * 0.25) {
|
|
179
|
+
target = this.quantize(target * (runtimeRateReconfigure ? evidence.state === 'usable' ? 1.5 : 1.2 : 1.1));
|
|
180
|
+
if (target > this.target)
|
|
181
|
+
this.snapshot.reasons.push('bandwidth-probe');
|
|
182
|
+
}
|
|
183
|
+
if (this.processingPressure >= 2 && s.nowMs - this.lastFpsChange >= 2000)
|
|
184
|
+
fps = fps === 60 ? 30 : 15;
|
|
185
|
+
else if ((this.headroom >= 3 || this.recoveryWindows >= 5) && s.nowMs >= this.fpsRecoveryAfter &&
|
|
186
|
+
s.nowMs - this.lastFpsChange >= (runtimeRateReconfigure ? 2000 : 10000)) {
|
|
187
|
+
fps = nextFps;
|
|
188
|
+
if (fps > this.fps && this.headroom < 3)
|
|
189
|
+
this.snapshot.reasons.push('fps-recovery-probe');
|
|
190
|
+
}
|
|
191
|
+
if (target === this.max)
|
|
192
|
+
this.snapshot.reasons.push('policy-limit');
|
|
193
|
+
if (target === this.target && fps === this.fps)
|
|
194
|
+
return decision();
|
|
195
|
+
if (!runtimeRateReconfigure && s.nowMs - this.lastReopen < 2000)
|
|
196
|
+
return decision();
|
|
197
|
+
this.reopens = this.reopens.filter(at => s.nowMs - at < 10000);
|
|
198
|
+
if (!runtimeRateReconfigure && this.reopens.length === 2) {
|
|
199
|
+
fps = 15;
|
|
200
|
+
this.cooldown = s.nowMs + 10000;
|
|
201
|
+
}
|
|
202
|
+
if (target !== this.target) {
|
|
203
|
+
this.lastRateChange = s.nowMs;
|
|
204
|
+
this.networkPressure = this.networkHealthy = 0;
|
|
205
|
+
}
|
|
206
|
+
if (fps !== this.fps) {
|
|
207
|
+
if (fps < this.fps) {
|
|
208
|
+
this.recoveryFps = Math.max(this.recoveryFps, this.fps);
|
|
209
|
+
if (s.nowMs <= this.fpsTrialUntil)
|
|
210
|
+
this.fpsRecoveryAfter = s.nowMs + 30000;
|
|
211
|
+
this.fpsTrialUntil = -Infinity;
|
|
212
|
+
}
|
|
213
|
+
else
|
|
214
|
+
this.fpsTrialUntil = s.nowMs + 10000;
|
|
215
|
+
this.lastFpsChange = s.nowMs;
|
|
216
|
+
this.processingPressure = this.headroom = this.recoveryWindows = 0;
|
|
217
|
+
}
|
|
218
|
+
this.target = target;
|
|
219
|
+
this.fps = fps;
|
|
220
|
+
if (!runtimeRateReconfigure) {
|
|
221
|
+
this.reopens.push(s.nowMs);
|
|
222
|
+
this.lastReopen = s.nowMs;
|
|
223
|
+
}
|
|
224
|
+
return decision(!runtimeRateReconfigure);
|
|
225
|
+
}
|
|
226
|
+
}
|