@andorra-labs/code 0.1.17 → 0.1.19
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/dist/src/account-jev-savings.d.ts +4 -0
- package/dist/src/account-jev-savings.js +92 -0
- package/dist/src/acp-agent.js +2 -2
- package/dist/src/agent-execution.js +441 -53
- package/dist/src/agent-mcp.js +7 -1
- package/dist/src/agent-modifiers.js +5 -7
- package/dist/src/analytics.d.ts +19 -1
- package/dist/src/analytics.js +9 -1
- package/dist/src/andorra/entry.js +15 -6
- package/dist/src/andorra/errors.js +3 -0
- package/dist/src/andorra/hosted.d.ts +8 -0
- package/dist/src/andorra/hosted.js +22 -3
- package/dist/src/andorra/streams.d.ts +49 -0
- package/dist/src/andorra/streams.js +98 -0
- package/dist/src/antigravity-acp.d.ts +28 -0
- package/dist/src/antigravity-acp.js +150 -0
- package/dist/src/antigravity-terminal.d.ts +2 -0
- package/dist/src/antigravity-terminal.js +214 -0
- package/dist/src/app-server/adaptive-routing-settings.d.ts +37 -0
- package/dist/src/app-server/adaptive-routing-settings.js +69 -0
- package/dist/src/app-server/artifact.d.ts +14 -0
- package/dist/src/app-server/artifact.js +46 -0
- package/dist/src/app-server/legal-protocol.d.ts +33 -0
- package/dist/src/app-server/legal-protocol.js +16 -0
- package/dist/src/app-server/protocol.d.ts +34 -3
- package/dist/src/app-server/protocol.js +3 -1
- package/dist/src/app-server/telemetry-protocol.d.ts +53 -0
- package/dist/src/app-server/telemetry-protocol.js +2 -0
- package/dist/src/app-server/telemetry.d.ts +38 -0
- package/dist/src/app-server/telemetry.js +163 -0
- package/dist/src/app-server/workspace.d.ts +21 -0
- package/dist/src/app-server/workspace.js +192 -10
- package/dist/src/app-server.d.ts +82 -26
- package/dist/src/app-server.js +1573 -417
- package/dist/src/attachments.d.ts +10 -0
- package/dist/src/attachments.js +102 -7
- package/dist/src/auth/AuthManager.d.ts +11 -2
- package/dist/src/auth/AuthManager.js +56 -13
- package/dist/src/auth/index.d.ts +5 -1
- package/dist/src/auth/index.js +8 -1
- package/dist/src/auth/lifecycle.d.ts +13 -0
- package/dist/src/auth/lifecycle.js +109 -0
- package/dist/src/auth/store.d.ts +1 -0
- package/dist/src/auth/store.js +12 -0
- package/dist/src/auth/types.d.ts +12 -0
- package/dist/src/automation-runner.js +2 -0
- package/dist/src/automation-service.js +7 -2
- package/dist/src/automation-tool.js +2 -1
- package/dist/src/benchmark-scores.d.ts +88 -0
- package/dist/src/benchmark-scores.js +302 -0
- package/dist/src/bridge/command.js +16 -1
- package/dist/src/bridge/control.d.ts +3 -1
- package/dist/src/bridge/control.js +9 -3
- package/dist/src/bridge/engines.d.ts +2 -0
- package/dist/src/bridge/engines.js +9 -0
- package/dist/src/bridge/github.d.ts +108 -0
- package/dist/src/bridge/github.js +378 -0
- package/dist/src/bridge/host-ops.d.ts +3 -3
- package/dist/src/bridge/host-ops.js +14 -2
- package/dist/src/bridge/host.d.ts +2 -0
- package/dist/src/bridge/host.js +70 -16
- package/dist/src/bridge/protocol.d.ts +1 -0
- package/dist/src/bridge/protocol.js +1 -0
- package/dist/src/browser-panel-tool.d.ts +12 -0
- package/dist/src/browser-panel-tool.js +30 -3
- package/dist/src/browser-runner.js +53 -62
- package/dist/src/browser-server.js +10 -4
- package/dist/src/browser-session.d.ts +14 -0
- package/dist/src/browser-session.js +57 -12
- package/dist/src/browser-view.d.ts +40 -1
- package/dist/src/browser-view.js +163 -9
- package/dist/src/browser-window-style.d.ts +27 -0
- package/dist/src/browser-window-style.js +244 -0
- package/dist/src/bug-report-attachments.d.ts +48 -0
- package/dist/src/bug-report-attachments.js +327 -0
- package/dist/src/bug-report.d.ts +23 -3
- package/dist/src/bug-report.js +72 -9
- package/dist/src/claude-provider.d.ts +1 -0
- package/dist/src/claude-provider.js +77 -36
- package/dist/src/cli.d.ts +1 -3
- package/dist/src/cli.js +245 -62
- package/dist/src/codex-provider.d.ts +1 -0
- package/dist/src/codex-provider.js +44 -8
- package/dist/src/coding-tools.d.ts +1 -0
- package/dist/src/coding-tools.js +28 -7
- package/dist/src/command-screens.d.ts +1 -1
- package/dist/src/command-screens.js +2 -2
- package/dist/src/commands.d.ts +9 -2
- package/dist/src/commands.js +69 -64
- package/dist/src/completion.js +13 -7
- package/dist/src/config.d.ts +14 -3
- package/dist/src/config.js +57 -17
- package/dist/src/context-budget.d.ts +11 -2
- package/dist/src/context-budget.js +38 -4
- package/dist/src/context-compaction.d.ts +10 -8
- package/dist/src/context-compaction.js +23 -24
- package/dist/src/deadline.js +1 -1
- package/dist/src/decision/DecisionEngine.d.ts +2 -0
- package/dist/src/decision/DecisionManager.d.ts +16 -0
- package/dist/src/decision/DecisionManager.js +75 -2
- package/dist/src/decision/applyTaskKind.d.ts +8 -0
- package/dist/src/decision/applyTaskKind.js +53 -0
- package/dist/src/decision/applyToolMenu.js +6 -2
- package/dist/src/decision/hostedPolicy.js +6 -3
- package/dist/src/decision/optimizationPolicy.d.ts +10 -0
- package/dist/src/decision/optimizationPolicy.js +23 -3
- package/dist/src/decision/providers/AndorraDecisionProvider.d.ts +4 -1
- package/dist/src/decision/providers/AndorraDecisionProvider.js +29 -7
- package/dist/src/decision/providers/index.js +1 -1
- package/dist/src/decision/taskKind.d.ts +52 -0
- package/dist/src/decision/taskKind.js +76 -0
- package/dist/src/decision/toolFamilies.js +1 -1
- package/dist/src/decision/types.d.ts +3 -1
- package/dist/src/default-graph.js +1 -1
- package/dist/src/efficiency.d.ts +80 -1
- package/dist/src/efficiency.js +119 -4
- package/dist/src/effort-routing.d.ts +27 -0
- package/dist/src/effort-routing.js +34 -0
- package/dist/src/evidence.d.ts +110 -0
- package/dist/src/evidence.js +195 -0
- package/dist/src/extensions.d.ts +2 -0
- package/dist/src/extensions.js +30 -20
- package/dist/src/github-app/agent-writes.d.ts +1 -1
- package/dist/src/github-app/agent-writes.js +1 -1
- package/dist/src/github-app/client.d.ts +19 -0
- package/dist/src/github-app/client.js +21 -1
- package/dist/src/github-app/event-source.d.ts +0 -5
- package/dist/src/github-app/event-source.js +1 -31
- package/dist/src/github-app/metrics.d.ts +2 -5
- package/dist/src/github-app/metrics.js +2 -14
- package/dist/src/github-app/review-loop.d.ts +5 -5
- package/dist/src/github-app/review-loop.js +1 -1
- package/dist/src/github-app/review-node.d.ts +2 -2
- package/dist/src/github-app/triggers.d.ts +3 -3
- package/dist/src/github-names.d.ts +7 -0
- package/dist/src/github-names.js +7 -0
- package/dist/src/glob-search.d.ts +1 -0
- package/dist/src/glob-search.js +3 -0
- package/dist/src/google-provider.d.ts +5 -28
- package/dist/src/google-provider.js +6 -141
- package/dist/src/graph-editor-session.d.ts +1 -0
- package/dist/src/graph-editor-session.js +2 -0
- package/dist/src/graph-health.js +3 -1
- package/dist/src/graph-preview.d.ts +2 -0
- package/dist/src/graph-preview.js +1 -0
- package/dist/src/graph-runner.js +20 -14
- package/dist/src/graph-selection.d.ts +3 -1
- package/dist/src/graph-selection.js +2 -2
- package/dist/src/graph-server.d.ts +8 -1
- package/dist/src/graph-server.js +49 -12
- package/dist/src/graph-sync.d.ts +2 -1
- package/dist/src/graph-sync.js +13 -0
- package/dist/src/graph-ui/app.js +49 -8
- package/dist/src/graph-ui/index.html +1 -1
- package/dist/src/graphs.d.ts +23 -1
- package/dist/src/graphs.js +58 -7
- package/dist/src/grok-provider.js +17 -14
- package/dist/src/hardened-runtime.js +39 -25
- package/dist/src/jev-savings.d.ts +4 -0
- package/dist/src/jev-savings.js +13 -0
- package/dist/src/legal/client.d.ts +25 -0
- package/dist/src/legal/client.js +47 -0
- package/dist/src/legal/command.d.ts +13 -0
- package/dist/src/legal/command.js +98 -0
- package/dist/src/legal/documents.d.ts +2 -0
- package/dist/src/legal/documents.js +14 -0
- package/dist/src/legal/gate.d.ts +13 -0
- package/dist/src/legal/gate.js +96 -0
- package/dist/src/legal/manifest.d.ts +21 -0
- package/dist/src/legal/manifest.js +23 -0
- package/dist/src/legal/receipt.d.ts +13 -0
- package/dist/src/legal/receipt.js +137 -0
- package/dist/src/legal/release.d.ts +27 -0
- package/dist/src/legal/release.js +28 -0
- package/dist/src/managed-sign-in.d.ts +0 -1
- package/dist/src/managed-sign-in.js +0 -13
- package/dist/src/membership.d.ts +27 -1
- package/dist/src/membership.js +139 -7
- package/dist/src/model-health-cache.js +1 -1
- package/dist/src/model-metadata.js +3 -7
- package/dist/src/model-override.d.ts +2 -1
- package/dist/src/model-override.js +9 -0
- package/dist/src/model-pool.d.ts +99 -0
- package/dist/src/model-pool.js +136 -0
- package/dist/src/model-relay/local.js +5 -0
- package/dist/src/model-relay/remote.d.ts +2 -0
- package/dist/src/model-relay/remote.js +4 -0
- package/dist/src/model-tiers.d.ts +16 -1
- package/dist/src/model-tiers.js +31 -7
- package/dist/src/opencode-cli-provider.js +59 -56
- package/dist/src/opencode-provider.js +16 -13
- package/dist/src/permissions.d.ts +5 -0
- package/dist/src/permissions.js +7 -0
- package/dist/src/plan-pass.js +2 -1
- package/dist/src/pool-scores.d.ts +45 -0
- package/dist/src/pool-scores.js +40 -0
- package/dist/src/provider-connection.js +3 -17
- package/dist/src/provider-engine.d.ts +13 -1
- package/dist/src/provider-engine.js +116 -12
- package/dist/src/provider-request-error.d.ts +8 -0
- package/dist/src/provider-request-error.js +12 -0
- package/dist/src/provider-settings.d.ts +1 -1
- package/dist/src/provider-settings.js +36 -18
- package/dist/src/provider-turn-deadline.d.ts +39 -0
- package/dist/src/provider-turn-deadline.js +139 -0
- package/dist/src/providers.d.ts +8 -9
- package/dist/src/providers.js +211 -150
- package/dist/src/pull-request-merge.d.ts +1 -8
- package/dist/src/pull-request-merge.js +0 -4
- package/dist/src/pull-requests.d.ts +83 -57
- package/dist/src/pull-requests.js +266 -225
- package/dist/src/qa/runtime/ProcessManager.d.ts +5 -1
- package/dist/src/qa/runtime/ProcessManager.js +9 -3
- package/dist/src/react-runtime.js +245 -71
- package/dist/src/reasoning-probe-cloud.d.ts +10 -0
- package/dist/src/reasoning-probe-cloud.js +209 -0
- package/dist/src/remote/engine-pool.d.ts +3 -0
- package/dist/src/remote/engine-pool.js +88 -21
- package/dist/src/remote/recovery.d.ts +6 -0
- package/dist/src/remote/recovery.js +37 -0
- package/dist/src/run-records.d.ts +13 -3
- package/dist/src/run-records.js +59 -34
- package/dist/src/runtime.d.ts +47 -2
- package/dist/src/runtime.js +33 -7
- package/dist/src/session-summary.d.ts +8 -0
- package/dist/src/session-summary.js +34 -0
- package/dist/src/sessions.d.ts +32 -0
- package/dist/src/sessions.js +65 -3
- package/dist/src/shell.js +6 -0
- package/dist/src/side-panel.js +36 -2
- package/dist/src/sign-in-detection.d.ts +1 -1
- package/dist/src/sign-in-detection.js +4 -10
- package/dist/src/sign-in-offer.js +1 -1
- package/dist/src/skill-commands.js +1 -1
- package/dist/src/skills/bundled/bug-report/SKILL.md +51 -7
- package/dist/src/skills/bundled/graph-manager/SKILL.md +2 -2
- package/dist/src/skills/bundled/graph-manager/patterns.md +13 -19
- package/dist/src/skills/bundled/provenance.json +3 -3
- package/dist/src/subagent-run.js +50 -50
- package/dist/src/subscription-usage.d.ts +50 -0
- package/dist/src/subscription-usage.js +92 -0
- package/dist/src/task-checkout.d.ts +157 -0
- package/dist/src/task-checkout.js +628 -0
- package/dist/src/telemetry/access.d.ts +18 -0
- package/dist/src/telemetry/access.js +43 -0
- package/dist/src/telemetry/aggregate.d.ts +18 -2
- package/dist/src/telemetry/aggregate.js +22 -9
- package/dist/src/telemetry/capture-core.d.ts +33 -14
- package/dist/src/telemetry/capture-core.js +124 -25
- package/dist/src/telemetry/capture.d.ts +3 -2
- package/dist/src/telemetry/capture.js +21 -1
- package/dist/src/telemetry/decision-capture.js +4 -0
- package/dist/src/telemetry/emitter.d.ts +6 -7
- package/dist/src/telemetry/emitter.js +124 -29
- package/dist/src/telemetry/gate.d.ts +41 -2
- package/dist/src/telemetry/gate.js +89 -4
- package/dist/src/telemetry/home.d.ts +1 -0
- package/dist/src/telemetry/home.js +20 -0
- package/dist/src/telemetry/identity.d.ts +6 -3
- package/dist/src/telemetry/identity.js +19 -6
- package/dist/src/telemetry/lifecycle.d.ts +8 -0
- package/dist/src/telemetry/lifecycle.js +76 -0
- package/dist/src/telemetry/outbox.d.ts +13 -8
- package/dist/src/telemetry/outbox.js +68 -12
- package/dist/src/telemetry/permission-command.d.ts +38 -0
- package/dist/src/telemetry/permission-command.js +208 -0
- package/dist/src/telemetry/permission.d.ts +168 -0
- package/dist/src/telemetry/permission.js +662 -0
- package/dist/src/telemetry/record-installation.d.ts +1 -0
- package/dist/src/telemetry/record-installation.js +9 -0
- package/dist/src/telemetry/region-data.d.ts +12 -0
- package/dist/src/telemetry/region-data.js +1314 -0
- package/dist/src/telemetry/region.d.ts +34 -0
- package/dist/src/telemetry/region.js +87 -0
- package/dist/src/telemetry/run-privacy.d.ts +11 -0
- package/dist/src/telemetry/run-privacy.js +165 -0
- package/dist/src/telemetry/schema.d.ts +27 -6
- package/dist/src/telemetry/schema.js +109 -14
- package/dist/src/telemetry/state.d.ts +11 -7
- package/dist/src/telemetry/state.js +39 -6
- package/dist/src/telemetry/surface.d.ts +20 -3
- package/dist/src/telemetry/surface.js +71 -15
- package/dist/src/telemetry/uploader.d.ts +6 -11
- package/dist/src/telemetry/uploader.js +72 -46
- package/dist/src/telemetry/uploads.d.ts +5 -1
- package/dist/src/telemetry/uploads.js +25 -6
- package/dist/src/telemetry/version.d.ts +5 -0
- package/dist/src/telemetry/version.js +34 -0
- package/dist/src/telemetry/workspace.d.ts +4 -1
- package/dist/src/telemetry/workspace.js +18 -3
- package/dist/src/terminal-ui.d.ts +3 -0
- package/dist/src/terminal-ui.js +48 -6
- package/dist/src/test-edit-guard.d.ts +30 -0
- package/dist/src/test-edit-guard.js +167 -2
- package/dist/src/thinking-level-detect.d.ts +13 -0
- package/dist/src/thinking-level-detect.js +52 -0
- package/dist/src/thinking-levels.d.ts +30 -0
- package/dist/src/thinking-levels.js +131 -0
- package/dist/src/timers.d.ts +3 -0
- package/dist/src/todos.d.ts +2 -1
- package/dist/src/todos.js +24 -4
- package/dist/src/tool-argument-coercion.d.ts +7 -0
- package/dist/src/tool-argument-coercion.js +49 -0
- package/dist/src/tool-catalog.d.ts +2 -2
- package/dist/src/tool-catalog.js +1 -1
- package/dist/src/tools.js +67 -22
- package/dist/src/transcript.js +3 -2
- package/dist/src/types.d.ts +48 -1
- package/dist/src/update.js +4 -0
- package/dist/src/usage-analytics.d.ts +7 -0
- package/dist/src/usage-analytics.js +85 -13
- package/dist/telemetry-consent-v1 +1 -0
- package/package.json +97 -96
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** Shared path/epoch plumbing. Privacy admission ALWAYS precedes analytics/spool locks. */
|
|
2
|
+
import { basename, dirname, resolve } from 'node:path';
|
|
3
|
+
import { telemetryHome } from './home.js';
|
|
4
|
+
import { currentTelemetryAdmission, withTelemetryAdmission, sameTelemetryLease } from './permission.js';
|
|
5
|
+
export function telemetryEpoch(lease) {
|
|
6
|
+
return lease.mode === 'consent' ? { mode: 'consent', revision: lease.revision, activationId: lease.activationId } : undefined;
|
|
7
|
+
}
|
|
8
|
+
export function epochMatches(epoch, lease) {
|
|
9
|
+
if (epoch === undefined)
|
|
10
|
+
return lease.mode === 'out'; // unchanged legacy outside backlog
|
|
11
|
+
if (!epoch || typeof epoch !== 'object' || lease.mode !== 'consent')
|
|
12
|
+
return false;
|
|
13
|
+
const value = epoch;
|
|
14
|
+
return value.mode === 'consent' && value.revision === lease.revision && value.activationId === lease.activationId;
|
|
15
|
+
}
|
|
16
|
+
export function epochLease(home, epoch) {
|
|
17
|
+
if (!epoch || typeof epoch !== 'object')
|
|
18
|
+
return undefined;
|
|
19
|
+
const value = epoch;
|
|
20
|
+
return value.mode === 'consent' && Number.isSafeInteger(value.revision) && value.revision > 0 && typeof value.activationId === 'string' && /^[a-f0-9]{32}$/.test(value.activationId)
|
|
21
|
+
? { home: telemetryHome(home), mode: 'consent', revision: value.revision, activationId: value.activationId } : undefined;
|
|
22
|
+
}
|
|
23
|
+
export function telemetryDirectoryHome(directory) {
|
|
24
|
+
const path = resolve(directory);
|
|
25
|
+
if (basename(path) !== 'telemetry')
|
|
26
|
+
throw new Error('Expected an installation telemetry directory');
|
|
27
|
+
return telemetryHome(dirname(path));
|
|
28
|
+
}
|
|
29
|
+
export function spoolTelemetryDirectory(path) {
|
|
30
|
+
const directory = dirname(resolve(path));
|
|
31
|
+
if (basename(directory) !== 'outbox' || !basename(path).endsWith('.jsonl'))
|
|
32
|
+
throw new Error('Expected a telemetry spool path');
|
|
33
|
+
return dirname(directory);
|
|
34
|
+
}
|
|
35
|
+
export function admitTelemetryDirectory(directory, run, access = {}) {
|
|
36
|
+
const parent = currentTelemetryAdmission();
|
|
37
|
+
return withTelemetryAdmission({ home: telemetryDirectoryHome(directory), signals: access.signals }, async (admission) => {
|
|
38
|
+
if (admission.lease.mode === 'consent' && !access.lease && parent !== admission)
|
|
39
|
+
return undefined;
|
|
40
|
+
return run(admission);
|
|
41
|
+
}, access.lease);
|
|
42
|
+
}
|
|
43
|
+
export { sameTelemetryLease };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Usage } from '../types.js';
|
|
2
2
|
import { type TelemetryModelRecord, type TelemetryToolRecord } from './schema.js';
|
|
3
|
-
|
|
3
|
+
type ModelAttribution = Pick<TelemetryModelRecord, 'provider' | 'authMode' | 'servedModel'>;
|
|
4
|
+
export interface ModelObservation extends ModelAttribution {
|
|
4
5
|
providerType: string;
|
|
5
6
|
baseUrl: string;
|
|
6
7
|
model: string;
|
|
@@ -9,7 +10,7 @@ export interface ModelObservation {
|
|
|
9
10
|
costMicroUsd?: number;
|
|
10
11
|
pricingVersion?: string;
|
|
11
12
|
}
|
|
12
|
-
export interface ModelTuple {
|
|
13
|
+
export interface ModelTuple extends ModelAttribution {
|
|
13
14
|
providerType: string;
|
|
14
15
|
endpoint: string;
|
|
15
16
|
model: string;
|
|
@@ -30,6 +31,20 @@ export interface ModelTuple {
|
|
|
30
31
|
costVersions: Set<string | undefined>;
|
|
31
32
|
};
|
|
32
33
|
}
|
|
34
|
+
export declare function modelTupleIdentity(input: ModelAttribution & {
|
|
35
|
+
providerType?: string;
|
|
36
|
+
baseUrl?: string;
|
|
37
|
+
model?: string;
|
|
38
|
+
role: string;
|
|
39
|
+
}): {
|
|
40
|
+
providerType: "other" | "openai-compatible" | "anthropic" | "codex";
|
|
41
|
+
endpoint: "other" | "hosted" | "local";
|
|
42
|
+
model: string;
|
|
43
|
+
role: string;
|
|
44
|
+
provider: "andorra" | "other" | "anthropic" | "codex" | "claude" | "google" | "grok" | "opencode" | "opencode-go" | "openai" | "deepseek" | "openrouter" | "ollama" | undefined;
|
|
45
|
+
authMode: "other" | "linked-account" | "api-key" | undefined;
|
|
46
|
+
servedModel: string | undefined;
|
|
47
|
+
};
|
|
33
48
|
export declare function aggregateModels(observations: ModelObservation[]): TelemetryModelRecord[];
|
|
34
49
|
export declare function aggregateModelTuples(input: ModelTuple[]): TelemetryModelRecord[];
|
|
35
50
|
export interface ToolObservation {
|
|
@@ -41,3 +56,4 @@ export declare function countToolObservations(observations: ToolObservation[]):
|
|
|
41
56
|
calls: number;
|
|
42
57
|
failures: number;
|
|
43
58
|
};
|
|
59
|
+
export {};
|
|
@@ -1,18 +1,26 @@
|
|
|
1
|
-
import { TELEMETRY_ENDPOINTS, TELEMETRY_MODELS, TELEMETRY_PROVIDER_TYPES, TELEMETRY_ROLES, TELEMETRY_TOOL_NAMES, bucketEndpoint, bucketModel, bucketProviderType, bucketToolName, isMetadataTool, rankByTable, } from './schema.js';
|
|
1
|
+
import { TELEMETRY_ENDPOINTS, TELEMETRY_MODELS, TELEMETRY_PROVIDER_TYPES, TELEMETRY_ROLES, TELEMETRY_TOOL_NAMES, bucketEndpoint, bucketModel, bucketProvider, bucketProviderType, bucketToolName, isMetadataTool, modelTupleKey, rankByTable, reportedModel, } from './schema.js';
|
|
2
2
|
const rankIndex = (table, value) => {
|
|
3
3
|
const index = table.indexOf(value);
|
|
4
4
|
return index < 0 ? table.length : index;
|
|
5
5
|
};
|
|
6
|
+
export function modelTupleIdentity(input) {
|
|
7
|
+
return {
|
|
8
|
+
providerType: bucketProviderType(input.providerType),
|
|
9
|
+
endpoint: bucketEndpoint(input.baseUrl),
|
|
10
|
+
model: bucketModel(input.model),
|
|
11
|
+
role: input.role,
|
|
12
|
+
provider: input.provider ?? bucketProvider(input.providerType, input.baseUrl),
|
|
13
|
+
authMode: input.authMode,
|
|
14
|
+
servedModel: reportedModel(input.servedModel),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
6
17
|
function fold(observations) {
|
|
7
18
|
const tuples = new Map();
|
|
8
19
|
for (const observation of observations) {
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const model = bucketModel(observation.model);
|
|
12
|
-
const role = observation.role;
|
|
13
|
-
const key = `${providerType}\0${endpoint}\0${model}\0${role}`;
|
|
20
|
+
const identity = modelTupleIdentity(observation);
|
|
21
|
+
const key = modelTupleKey(identity);
|
|
14
22
|
const tuple = tuples.get(key) ?? {
|
|
15
|
-
|
|
23
|
+
...identity, requests: 0,
|
|
16
24
|
reported: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, costVersions: new Set() },
|
|
17
25
|
};
|
|
18
26
|
tuple.requests += 1;
|
|
@@ -50,6 +58,9 @@ function ordinary(tuple) {
|
|
|
50
58
|
model: tuple.model,
|
|
51
59
|
role: tuple.role,
|
|
52
60
|
requests: tuple.requests,
|
|
61
|
+
...(tuple.provider === undefined ? {} : { provider: tuple.provider }),
|
|
62
|
+
...(tuple.authMode === undefined ? {} : { authMode: tuple.authMode }),
|
|
63
|
+
...(tuple.servedModel === undefined ? {} : { servedModel: tuple.servedModel }),
|
|
53
64
|
};
|
|
54
65
|
if (complete(tuple.reported.input))
|
|
55
66
|
record.inputTokens = tuple.inputTokens;
|
|
@@ -130,7 +141,8 @@ export function aggregateModelTuples(input) {
|
|
|
130
141
|
|| rankIndex(TELEMETRY_PROVIDER_TYPES, a.providerType) - rankIndex(TELEMETRY_PROVIDER_TYPES, b.providerType)
|
|
131
142
|
|| rankIndex(TELEMETRY_ENDPOINTS, a.endpoint) - rankIndex(TELEMETRY_ENDPOINTS, b.endpoint)
|
|
132
143
|
|| rankIndex(TELEMETRY_MODELS, a.model) - rankIndex(TELEMETRY_MODELS, b.model)
|
|
133
|
-
|| rankIndex(TELEMETRY_ROLES, a.role) - rankIndex(TELEMETRY_ROLES, b.role)
|
|
144
|
+
|| rankIndex(TELEMETRY_ROLES, a.role) - rankIndex(TELEMETRY_ROLES, b.role)
|
|
145
|
+
|| modelTupleKey(a).localeCompare(modelTupleKey(b), 'en'));
|
|
134
146
|
const overflowNeeded = tuples.length > 16;
|
|
135
147
|
if (!overflowNeeded)
|
|
136
148
|
return tuples.map(ordinary);
|
|
@@ -144,7 +156,8 @@ export function aggregateModelTuples(input) {
|
|
|
144
156
|
return records;
|
|
145
157
|
}
|
|
146
158
|
function isOverflowIdentity(tuple) {
|
|
147
|
-
return tuple.providerType === 'other' && tuple.endpoint === 'other' && tuple.model === 'other' && tuple.role === 'other'
|
|
159
|
+
return tuple.providerType === 'other' && tuple.endpoint === 'other' && tuple.model === 'other' && tuple.role === 'other' &&
|
|
160
|
+
tuple.provider === undefined && tuple.authMode === undefined && tuple.servedModel === undefined;
|
|
148
161
|
}
|
|
149
162
|
export function aggregateTools(observations) {
|
|
150
163
|
const counts = new Map();
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { type JevSavings } from '../jev-savings.js';
|
|
1
2
|
import type { Usage } from '../types.js';
|
|
2
|
-
import { type
|
|
3
|
-
import type
|
|
3
|
+
import { type TelemetryLease, type TelemetryPermissionInput } from './permission.js';
|
|
4
|
+
import { type TelemetryAuthMode, type TelemetryErrorRecord, type TelemetrySavings } from './schema.js';
|
|
5
|
+
import { type ModelTuple } from './aggregate.js';
|
|
4
6
|
import type { ModelPricing } from '../efficiency.js';
|
|
5
7
|
export interface JevTally {
|
|
6
8
|
requested: number;
|
|
@@ -88,33 +90,50 @@ export interface RunTelemetry {
|
|
|
88
90
|
pendingDecisions?: Promise<unknown>[];
|
|
89
91
|
task: TaskTally;
|
|
90
92
|
efficiency?: EfficiencyTally;
|
|
93
|
+
jevSavings?: JevSavings;
|
|
91
94
|
}
|
|
92
95
|
export declare function createEfficiencyTally(): EfficiencyTally;
|
|
93
|
-
export declare function recordEfficiencyEvent(telemetry: RunTelemetry, type: string, data: Record<string, unknown>): void;
|
|
94
|
-
export
|
|
96
|
+
export declare function recordEfficiencyEvent(telemetry: RunTelemetry | undefined, type: string, data: Record<string, unknown>): void;
|
|
97
|
+
export interface TelemetryCaptureInput extends TelemetryPermissionInput {
|
|
98
|
+
lease?: TelemetryLease;
|
|
99
|
+
}
|
|
100
|
+
/** Latch start authority once; children must not enable capture after a later Yes/Auto. */
|
|
101
|
+
export declare function resolveTelemetryCapture(input?: TelemetryCaptureInput | false): TelemetryCaptureInput | false;
|
|
102
|
+
/** A typed inert sink preserves functional callers, but cannot collect or serialize anything. */
|
|
103
|
+
export declare function createRunTelemetry(input?: TelemetryCaptureInput | false): RunTelemetry;
|
|
104
|
+
/** Fresh necessary-choice read; callbacks from another process's old epoch are permanently inert. */
|
|
105
|
+
export declare function captureIsActive(value: unknown): boolean;
|
|
95
106
|
export declare function hasRunTelemetry(value: unknown): value is RunTelemetry;
|
|
96
|
-
export declare function
|
|
107
|
+
export declare function captureLease(value: RunTelemetry | undefined): TelemetryLease | undefined;
|
|
108
|
+
/** Result getters drop revoked captures at every finalizer/spread/serialization boundary. */
|
|
109
|
+
export declare function bindRunTelemetry<T extends {
|
|
110
|
+
telemetry?: RunTelemetry;
|
|
111
|
+
}>(result: T, value: RunTelemetry): T;
|
|
112
|
+
export declare function recordModelUse(telemetry: RunTelemetry | undefined, input: {
|
|
97
113
|
providerType?: string;
|
|
98
114
|
baseUrl?: string;
|
|
99
115
|
model?: string;
|
|
116
|
+
servedModel?: string;
|
|
117
|
+
authMode?: TelemetryAuthMode;
|
|
100
118
|
role: 'agent' | 'orchestrator' | 'subagent' | 'jev' | 'other';
|
|
101
119
|
usage: Partial<Usage>;
|
|
102
120
|
pricing?: ModelPricing;
|
|
103
121
|
}): void;
|
|
104
|
-
export declare function recordToolUse(telemetry: RunTelemetry, name: string, failed: boolean): void;
|
|
105
|
-
|
|
122
|
+
export declare function recordToolUse(telemetry: RunTelemetry | undefined, name: string, failed: boolean): void;
|
|
123
|
+
/** Records nothing without an active capture: a run whose reporting is pending, declined or revoked still fails normally. */
|
|
124
|
+
export declare function recordRunError(telemetry: RunTelemetry | undefined, code: unknown, count?: number): void;
|
|
106
125
|
/**
|
|
107
126
|
* Records a thrown error once, however many handlers see it on its way up (the request path, then a compactor, the
|
|
108
127
|
* agent loop or a graph). Returns the code it was recorded under, which later handlers reuse.
|
|
109
128
|
*/
|
|
110
|
-
export declare function recordErrorOnce(telemetry: RunTelemetry, error: unknown, code: string): string;
|
|
129
|
+
export declare function recordErrorOnce(telemetry: RunTelemetry | undefined, error: unknown, code: string): string;
|
|
111
130
|
/** The code an error was already recorded under, if any handler recorded it. */
|
|
112
131
|
export declare function recordedErrorCode(error: unknown): string | undefined;
|
|
113
132
|
/** The measured savings a run's efficiency tally holds, as sent in run.finished; undefined when nothing was tallied. */
|
|
114
133
|
export declare function savingsFrom(telemetry: RunTelemetry): TelemetrySavings | undefined;
|
|
115
|
-
export declare function recordAttempt(telemetry: RunTelemetry, retry: boolean): void;
|
|
116
|
-
export declare function recordEdit(telemetry: RunTelemetry, filePath: string, created: boolean): void;
|
|
117
|
-
export declare function recordTestCommand(telemetry: RunTelemetry): void;
|
|
118
|
-
export declare function recordDecisionEvent(telemetry: RunTelemetry, type: string, data: Record<string, unknown>): void;
|
|
119
|
-
export declare function recordToolFailure(telemetry: RunTelemetry, name: string): void;
|
|
120
|
-
export declare function mergeRunTelemetry(into: RunTelemetry, from: RunTelemetry): RunTelemetry;
|
|
134
|
+
export declare function recordAttempt(telemetry: RunTelemetry | undefined, retry: boolean): void;
|
|
135
|
+
export declare function recordEdit(telemetry: RunTelemetry | undefined, filePath: string, created: boolean): void;
|
|
136
|
+
export declare function recordTestCommand(telemetry: RunTelemetry | undefined): void;
|
|
137
|
+
export declare function recordDecisionEvent(telemetry: RunTelemetry | undefined, type: string, data: Record<string, unknown>): void;
|
|
138
|
+
export declare function recordToolFailure(telemetry: RunTelemetry | undefined, name: string): void;
|
|
139
|
+
export declare function mergeRunTelemetry(into: RunTelemetry | undefined, from: RunTelemetry | undefined): RunTelemetry | undefined;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { emptyJevSavings, JEV_SAVINGS_FIELDS } from '../jev-savings.js';
|
|
2
|
+
import { configDirectory } from '../config.js';
|
|
3
|
+
import { currentTelemetryAdmission, trackTelemetryRevocation, telemetryLeaseSnapshot, telemetryLeaseIsCurrent, sameTelemetryLease } from './permission.js';
|
|
4
|
+
import { TELEMETRY_ERROR_KINDS, bucketErrorCode, bucketToolName, modelTupleKey, } from './schema.js';
|
|
2
5
|
import { isDocumentationPath, isTestPath } from './classify.js';
|
|
6
|
+
import { modelTupleIdentity } from './aggregate.js';
|
|
3
7
|
import { usageCostMicroUsd } from '../model-tiers.js';
|
|
4
8
|
export function createEfficiencyTally() {
|
|
5
9
|
return {
|
|
@@ -13,6 +17,8 @@ export function createEfficiencyTally() {
|
|
|
13
17
|
}
|
|
14
18
|
const count = (value) => typeof value === 'number' && Number.isSafeInteger(value) && value >= 0 ? value : 0;
|
|
15
19
|
export function recordEfficiencyEvent(telemetry, type, data) {
|
|
20
|
+
if (!hasRunTelemetry(telemetry))
|
|
21
|
+
return;
|
|
16
22
|
if (!type.startsWith('efficiency.'))
|
|
17
23
|
return;
|
|
18
24
|
const tally = telemetry.efficiency ??= createEfficiencyTally();
|
|
@@ -107,7 +113,7 @@ const UNAVAILABLE_REASONS = new Set([
|
|
|
107
113
|
'provider_unavailable', 'provider_error', 'active_unsupported', 'timeout',
|
|
108
114
|
'authentication_required', 'decision_service_unavailable', 'decision_input_too_large',
|
|
109
115
|
]);
|
|
110
|
-
|
|
116
|
+
function emptyCapture() {
|
|
111
117
|
return {
|
|
112
118
|
attempts: 0, retries: 0, toolCalls: 0, toolFailures: 0, tools: {}, models: [],
|
|
113
119
|
jev: { requested: 0, completed: 0, applied: 0, fallback: 0, unavailable: 0 },
|
|
@@ -117,18 +123,77 @@ export function createRunTelemetry() {
|
|
|
117
123
|
task: { documentation: 0, test: 0, otherEdits: 0, created: 0, testCommand: false, activity: false },
|
|
118
124
|
};
|
|
119
125
|
}
|
|
126
|
+
/** Latch start authority once; children must not enable capture after a later Yes/Auto. */
|
|
127
|
+
export function resolveTelemetryCapture(input) {
|
|
128
|
+
if (input === false)
|
|
129
|
+
return false;
|
|
130
|
+
if (input)
|
|
131
|
+
return input.lease && telemetryLeaseIsCurrent(input, input.lease) ? input : { home: input.home, signals: input.signals };
|
|
132
|
+
const privacy = { home: configDirectory() };
|
|
133
|
+
const lease = telemetryLeaseSnapshot(privacy);
|
|
134
|
+
return lease?.mode === 'out' ? { ...privacy, lease } : false;
|
|
135
|
+
}
|
|
136
|
+
const captures = new WeakMap();
|
|
137
|
+
const disabled = new WeakSet();
|
|
138
|
+
/** A typed inert sink preserves functional callers, but cannot collect or serialize anything. */
|
|
139
|
+
export function createRunTelemetry(input) {
|
|
140
|
+
const privacy = input || { home: configDirectory() };
|
|
141
|
+
const current = input === false ? undefined : telemetryLeaseSnapshot(privacy);
|
|
142
|
+
const lease = input ? input.lease : current?.mode === 'out' ? current : undefined;
|
|
143
|
+
const value = emptyCapture();
|
|
144
|
+
Object.defineProperty(value, 'toJSON', { value: () => hasRunTelemetry(value) ? { ...value } : undefined });
|
|
145
|
+
if (lease && sameTelemetryLease(lease, current)) {
|
|
146
|
+
const state = { input: privacy, lease, revoked: false, revoke() { state.revoked = true; Object.assign(value, emptyCapture()); } };
|
|
147
|
+
captures.set(value, state);
|
|
148
|
+
trackTelemetryRevocation(lease.home, state);
|
|
149
|
+
}
|
|
150
|
+
else
|
|
151
|
+
disabled.add(value);
|
|
152
|
+
return value;
|
|
153
|
+
}
|
|
154
|
+
/** Fresh necessary-choice read; callbacks from another process's old epoch are permanently inert. */
|
|
155
|
+
export function captureIsActive(value) {
|
|
156
|
+
if (!value || typeof value !== 'object' || disabled.has(value))
|
|
157
|
+
return false;
|
|
158
|
+
const state = captures.get(value);
|
|
159
|
+
if (state) {
|
|
160
|
+
if (state.revoked)
|
|
161
|
+
return false;
|
|
162
|
+
if (telemetryLeaseIsCurrent(state.input, state.lease))
|
|
163
|
+
return true;
|
|
164
|
+
state.revoke(); // release pending promises, tuples and counters
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
// Legacy plain captures remain readable ONLY in the unchanged outside branch.
|
|
168
|
+
return currentTelemetryAdmission()?.lease.mode !== 'consent' && telemetryLeaseSnapshot({ home: configDirectory() })?.mode === 'out';
|
|
169
|
+
}
|
|
120
170
|
export function hasRunTelemetry(value) {
|
|
121
|
-
return
|
|
171
|
+
return captureIsActive(value) && Array.isArray(value.models) && !!value.task;
|
|
172
|
+
}
|
|
173
|
+
export function captureLease(value) {
|
|
174
|
+
return hasRunTelemetry(value) ? captures.get(value)?.lease : undefined;
|
|
175
|
+
}
|
|
176
|
+
/** Result getters drop revoked captures at every finalizer/spread/serialization boundary. */
|
|
177
|
+
export function bindRunTelemetry(result, value) {
|
|
178
|
+
if (!hasRunTelemetry(value)) {
|
|
179
|
+
delete result.telemetry;
|
|
180
|
+
return result;
|
|
181
|
+
}
|
|
182
|
+
let capture = value;
|
|
183
|
+
Object.defineProperty(result, 'telemetry', { configurable: true, enumerable: true,
|
|
184
|
+
get: () => hasRunTelemetry(capture) ? capture : undefined,
|
|
185
|
+
set: (next) => { capture = next; } });
|
|
186
|
+
return result;
|
|
122
187
|
}
|
|
123
188
|
export function recordModelUse(telemetry, input) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const
|
|
127
|
-
const key =
|
|
128
|
-
let tuple = telemetry.models.find(candidate =>
|
|
189
|
+
if (!hasRunTelemetry(telemetry))
|
|
190
|
+
return;
|
|
191
|
+
const identity = modelTupleIdentity(input);
|
|
192
|
+
const key = modelTupleKey(identity);
|
|
193
|
+
let tuple = telemetry.models.find(candidate => modelTupleKey(candidate) === key);
|
|
129
194
|
if (!tuple) {
|
|
130
195
|
tuple = {
|
|
131
|
-
|
|
196
|
+
...identity, requests: 0,
|
|
132
197
|
reported: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, costVersions: new Set() },
|
|
133
198
|
};
|
|
134
199
|
telemetry.models.push(tuple);
|
|
@@ -159,6 +224,8 @@ export function recordModelUse(telemetry, input) {
|
|
|
159
224
|
}
|
|
160
225
|
}
|
|
161
226
|
export function recordToolUse(telemetry, name, failed) {
|
|
227
|
+
if (!hasRunTelemetry(telemetry))
|
|
228
|
+
return;
|
|
162
229
|
const bucket = bucketToolName(name);
|
|
163
230
|
if (!bucket)
|
|
164
231
|
return;
|
|
@@ -171,8 +238,9 @@ export function recordToolUse(telemetry, name, failed) {
|
|
|
171
238
|
telemetry.toolFailures += 1;
|
|
172
239
|
telemetry.task.activity = true;
|
|
173
240
|
}
|
|
241
|
+
/** Records nothing without an active capture: a run whose reporting is pending, declined or revoked still fails normally. */
|
|
174
242
|
export function recordRunError(telemetry, code, count = 1) {
|
|
175
|
-
if (!Number.isSafeInteger(count) || count < 1)
|
|
243
|
+
if (!hasRunTelemetry(telemetry) || !Number.isSafeInteger(count) || count < 1)
|
|
176
244
|
return;
|
|
177
245
|
const errors = telemetry.errors ??= [];
|
|
178
246
|
let bucket = bucketErrorCode(code);
|
|
@@ -210,29 +278,40 @@ export function recordedErrorCode(error) {
|
|
|
210
278
|
/** The measured savings a run's efficiency tally holds, as sent in run.finished; undefined when nothing was tallied. */
|
|
211
279
|
export function savingsFrom(telemetry) {
|
|
212
280
|
const tally = telemetry.efficiency;
|
|
213
|
-
|
|
281
|
+
const jev = telemetry.jevSavings;
|
|
282
|
+
if (!tally && !jev)
|
|
214
283
|
return undefined;
|
|
284
|
+
const counters = tally ?? createEfficiencyTally();
|
|
215
285
|
return {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
286
|
+
...(jev === undefined ? {} : {
|
|
287
|
+
jevDirectInputTokens: jev.directInputTokens,
|
|
288
|
+
jevDirectOutputTokens: jev.directOutputTokens,
|
|
289
|
+
jevDownstreamInputTokens: jev.downstreamInputTokens,
|
|
290
|
+
}),
|
|
291
|
+
toolResultsFiltered: counters.toolResults.filtered,
|
|
292
|
+
toolResultOriginalChars: counters.toolResults.originalChars,
|
|
293
|
+
toolResultKeptChars: counters.toolResults.keptChars,
|
|
294
|
+
toolResultExpandedChars: counters.toolResults.expandedChars,
|
|
295
|
+
schemaCharsBefore: counters.catalog.schemaCharsBefore,
|
|
296
|
+
schemaCharsAfter: counters.catalog.schemaCharsAfter,
|
|
297
|
+
contextOmittedChars: counters.context.omittedChars,
|
|
298
|
+
contextDuplicates: counters.context.duplicates,
|
|
299
|
+
preparedSteps: counters.prepared.steps,
|
|
300
|
+
preparedExecuted: counters.prepared.executed,
|
|
301
|
+
deterministicSteps: counters.prepared.deterministic,
|
|
302
|
+
postflightSkipped: counters.postflight.skipped,
|
|
228
303
|
};
|
|
229
304
|
}
|
|
230
305
|
export function recordAttempt(telemetry, retry) {
|
|
306
|
+
if (!hasRunTelemetry(telemetry))
|
|
307
|
+
return;
|
|
231
308
|
telemetry.attempts += 1;
|
|
232
309
|
if (retry)
|
|
233
310
|
telemetry.retries += 1;
|
|
234
311
|
}
|
|
235
312
|
export function recordEdit(telemetry, filePath, created) {
|
|
313
|
+
if (!hasRunTelemetry(telemetry))
|
|
314
|
+
return;
|
|
236
315
|
telemetry.task.activity = true;
|
|
237
316
|
if (created)
|
|
238
317
|
telemetry.task.created += 1;
|
|
@@ -244,10 +323,14 @@ export function recordEdit(telemetry, filePath, created) {
|
|
|
244
323
|
telemetry.task.otherEdits += 1;
|
|
245
324
|
}
|
|
246
325
|
export function recordTestCommand(telemetry) {
|
|
326
|
+
if (!hasRunTelemetry(telemetry))
|
|
327
|
+
return;
|
|
247
328
|
telemetry.task.activity = true;
|
|
248
329
|
telemetry.task.testCommand = true;
|
|
249
330
|
}
|
|
250
331
|
export function recordDecisionEvent(telemetry, type, data) {
|
|
332
|
+
if (!hasRunTelemetry(telemetry))
|
|
333
|
+
return;
|
|
251
334
|
const invocation = typeof data.invocationId === 'string' ? data.invocationId : '';
|
|
252
335
|
const settle = (count) => {
|
|
253
336
|
if (invocation === '')
|
|
@@ -293,6 +376,8 @@ export function recordDecisionEvent(telemetry, type, data) {
|
|
|
293
376
|
}
|
|
294
377
|
}
|
|
295
378
|
export function recordToolFailure(telemetry, name) {
|
|
379
|
+
if (!hasRunTelemetry(telemetry))
|
|
380
|
+
return;
|
|
296
381
|
const bucket = bucketToolName(name);
|
|
297
382
|
if (!bucket)
|
|
298
383
|
return;
|
|
@@ -301,9 +386,18 @@ export function recordToolFailure(telemetry, name) {
|
|
|
301
386
|
telemetry.toolFailures += 1;
|
|
302
387
|
}
|
|
303
388
|
export function mergeRunTelemetry(into, from) {
|
|
389
|
+
if (!hasRunTelemetry(into) || !hasRunTelemetry(from))
|
|
390
|
+
return into;
|
|
391
|
+
const a = captures.get(into)?.lease, b = captures.get(from)?.lease;
|
|
392
|
+
if (((a && b) || a?.mode === 'consent' || b?.mode === 'consent') && !sameTelemetryLease(a, b))
|
|
393
|
+
return into;
|
|
304
394
|
if (from.pendingDecisions?.length) {
|
|
305
395
|
const before = { ...from.jev };
|
|
306
396
|
(into.pendingDecisions ??= []).push(Promise.allSettled(from.pendingDecisions).then(() => {
|
|
397
|
+
if (!hasRunTelemetry(into) || !hasRunTelemetry(from))
|
|
398
|
+
return;
|
|
399
|
+
if ((a?.mode === 'consent' || b?.mode === 'consent') && !sameTelemetryLease(a, b))
|
|
400
|
+
return;
|
|
307
401
|
for (const field of JEV_FIELDS) {
|
|
308
402
|
const delta = from.jev[field] - before[field];
|
|
309
403
|
if (delta !== 0)
|
|
@@ -321,8 +415,8 @@ export function mergeRunTelemetry(into, from) {
|
|
|
321
415
|
entry.failures += counts.failures;
|
|
322
416
|
}
|
|
323
417
|
for (const source of from.models) {
|
|
324
|
-
const key =
|
|
325
|
-
let target = into.models.find(candidate =>
|
|
418
|
+
const key = modelTupleKey(source);
|
|
419
|
+
let target = into.models.find(candidate => modelTupleKey(candidate) === key);
|
|
326
420
|
if (!target) {
|
|
327
421
|
target = { ...source, reported: { ...source.reported, costVersions: new Set(source.reported.costVersions) } };
|
|
328
422
|
into.models.push(target);
|
|
@@ -348,6 +442,11 @@ export function mergeRunTelemetry(into, from) {
|
|
|
348
442
|
into.jev[field] += from.jev[field];
|
|
349
443
|
if (from.efficiency)
|
|
350
444
|
mergeEfficiency(into.efficiency ??= createEfficiencyTally(), from.efficiency);
|
|
445
|
+
if (from.jevSavings) {
|
|
446
|
+
const totals = into.jevSavings ??= emptyJevSavings();
|
|
447
|
+
for (const field of JEV_SAVINGS_FIELDS)
|
|
448
|
+
totals[field] += from.jevSavings[field];
|
|
449
|
+
}
|
|
351
450
|
into.task.documentation += from.task.documentation;
|
|
352
451
|
into.task.test += from.task.test;
|
|
353
452
|
into.task.otherEdits += from.task.otherEdits;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
/** Consent-aware sinks; decision rounds additionally require per-request accounting. */
|
|
1
2
|
export * from './capture-core.js';
|
|
2
3
|
import { type RunTelemetry } from './capture-core.js';
|
|
3
|
-
export declare function recordDecisionEvent(telemetry: RunTelemetry, type: string, data: Record<string, unknown>): void;
|
|
4
|
-
export declare function recordEfficiencyEvent(telemetry: RunTelemetry, type: string, data: Record<string, unknown>): void;
|
|
4
|
+
export declare function recordDecisionEvent(telemetry: RunTelemetry | undefined, type: string, data: Record<string, unknown>): void;
|
|
5
|
+
export declare function recordEfficiencyEvent(telemetry: RunTelemetry | undefined, type: string, data: Record<string, unknown>): void;
|
|
@@ -1,11 +1,31 @@
|
|
|
1
|
+
/** Consent-aware sinks; decision rounds additionally require per-request accounting. */
|
|
1
2
|
export * from './capture-core.js';
|
|
2
|
-
import { recordDecisionEvent as legacyDecisionEvent, recordEfficiencyEvent as coreEfficiencyEvent } from './capture-core.js';
|
|
3
|
+
import { recordDecisionEvent as legacyDecisionEvent, recordEfficiencyEvent as coreEfficiencyEvent, hasRunTelemetry } from './capture-core.js';
|
|
4
|
+
import { emptyJevSavings } from '../jev-savings.js';
|
|
3
5
|
import { captureDecision } from './decision-capture.js';
|
|
4
6
|
export function recordDecisionEvent(telemetry, type, data) {
|
|
7
|
+
if (!hasRunTelemetry(telemetry))
|
|
8
|
+
return;
|
|
9
|
+
if (type === 'decision.turn_bypassed' || type === 'decision.prompt_reduced') {
|
|
10
|
+
const counter = (value) => typeof value === 'number' && Number.isSafeInteger(value) && value > 0 ? value : 0;
|
|
11
|
+
const input = counter(data.estimatedInputTokens);
|
|
12
|
+
const output = type === 'decision.turn_bypassed' ? counter(data.estimatedOutputTokens) : 0;
|
|
13
|
+
if (input || output) {
|
|
14
|
+
const savings = telemetry.jevSavings ??= emptyJevSavings();
|
|
15
|
+
if (type === 'decision.prompt_reduced')
|
|
16
|
+
savings.downstreamInputTokens += input;
|
|
17
|
+
else {
|
|
18
|
+
savings.directInputTokens += input;
|
|
19
|
+
savings.directOutputTokens += output;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
5
23
|
if (!captureDecision(telemetry, type, data))
|
|
6
24
|
legacyDecisionEvent(telemetry, type, data);
|
|
7
25
|
}
|
|
8
26
|
export function recordEfficiencyEvent(telemetry, type, data) {
|
|
27
|
+
if (!hasRunTelemetry(telemetry))
|
|
28
|
+
return;
|
|
9
29
|
if (type === 'efficiency.facts.answered')
|
|
10
30
|
coreEfficiencyEvent(telemetry, 'efficiency.postflight.awaited', data);
|
|
11
31
|
else
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
/** Request-level attribution; unbound/revoked protected callbacks are inert. */
|
|
2
|
+
import { captureIsActive } from './capture-core.js';
|
|
1
3
|
const unavailable = new Set(['provider_unavailable', 'provider_error', 'active_unsupported', 'timeout', 'authentication_required', 'decision_service_unavailable', 'decision_protocol_unsupported', 'decision_input_too_large']);
|
|
2
4
|
export function captureDecision(tally, type, data) {
|
|
5
|
+
if (!captureIsActive(tally))
|
|
6
|
+
return true;
|
|
3
7
|
if (!['decision.requested', 'decision.completed', 'decision.applied', 'decision.fallback'].includes(type))
|
|
4
8
|
return false;
|
|
5
9
|
const request = typeof data.requestId === 'string' && data.requestId ? `request:${data.requestId}` : undefined;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { type Config } from '../config.js';
|
|
2
2
|
import { type ClassifiableStatus } from './classify.js';
|
|
3
3
|
import { type RunTelemetry } from './capture.js';
|
|
4
|
+
import { type InstallationReceipt } from './lifecycle.js';
|
|
5
|
+
import { type TelemetryAccess } from './access.js';
|
|
4
6
|
export type TelemetryDecisionRouting = 'off' | 'shadow' | 'active';
|
|
5
|
-
export interface TelemetryContext {
|
|
7
|
+
export interface TelemetryContext extends TelemetryAccess {
|
|
6
8
|
home?: string;
|
|
7
9
|
config?: Config;
|
|
8
10
|
subject?: string;
|
|
@@ -45,6 +47,9 @@ export declare function emitRunStarted(context: TelemetryContext, input: RunDime
|
|
|
45
47
|
}): Promise<number | undefined>;
|
|
46
48
|
export declare function emitRunFinished(context: TelemetryContext, input: RunFinishInput): Promise<boolean>;
|
|
47
49
|
export declare function emitInterruptedRun(context: TelemetryContext, record: Record<string, unknown>): Promise<boolean>;
|
|
50
|
+
/** Release observations and GitHub watch counts are product telemetry too: they pass the same admission as every other event. */
|
|
51
|
+
export declare function emitInstallationObservation(context: TelemetryContext, receipt?: InstallationReceipt): Promise<void>;
|
|
52
|
+
export declare function emitGitHubWatch(context: TelemetryContext, input: GitHubWatchInput): Promise<boolean>;
|
|
48
53
|
export interface GitHubWatchInput {
|
|
49
54
|
minutes: number;
|
|
50
55
|
coverage: {
|
|
@@ -54,11 +59,5 @@ export interface GitHubWatchInput {
|
|
|
54
59
|
}[];
|
|
55
60
|
wakeLatencies: number[];
|
|
56
61
|
}
|
|
57
|
-
/**
|
|
58
|
-
* One window of the GitHub App watcher's counts (ADR 0021, `github.watch`): per coverage state, how many PRs
|
|
59
|
-
* were watched and how many gh calls the watcher made for them, and the Auto-fix wake latencies in whole
|
|
60
|
-
* seconds. Built field by field: no PR, repository, account or session reaches the record.
|
|
61
|
-
*/
|
|
62
|
-
export declare function emitGitHubWatch(context: TelemetryContext, input: GitHubWatchInput): Promise<boolean>;
|
|
63
62
|
export declare function engineSpoolId(prefix: string): string;
|
|
64
63
|
export declare function telemetryHome(home?: string): string;
|