@cesarus777/opencode-cgp 0.3.1 → 0.4.1
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/CHANGELOG.md +38 -0
- package/README.md +23 -9
- package/dist/cli.js +1179 -92
- package/dist/core.js +49 -4
- package/dist/index.js +570 -9
- package/dist/rpc.js +129 -2
- package/dist/tui.js +1543 -707
- package/dist/types/adapter.d.ts +2 -0
- package/dist/types/core.d.ts +1 -0
- package/dist/types/dashboard/command.d.ts +1 -1
- package/dist/types/dashboard/connection.d.ts +2 -0
- package/dist/types/dashboard/controller.d.ts +4 -0
- package/dist/types/dashboard/models.d.ts +42 -0
- package/dist/types/dashboard/modelview.d.ts +30 -0
- package/dist/types/dashboard/port.d.ts +6 -0
- package/dist/types/dashboard/terminal.d.ts +7 -0
- package/dist/types/dashboard/terminalview.d.ts +7 -2
- package/dist/types/dashboard/view.d.ts +6 -1
- package/dist/types/history.d.ts +1 -0
- package/dist/types/historyclient.d.ts +15 -0
- package/dist/types/modelanalytics.d.ts +8 -0
- package/dist/types/modelanalyticsserver.d.ts +16 -0
- package/dist/types/modelseries.d.ts +43 -0
- package/dist/types/rpc.d.ts +28 -0
- package/dist/types/tui/chartformat.d.ts +1 -1
- package/dist/types/tui/charts.d.ts +2 -3
- package/dist/types/tui/compactformat.d.ts +12 -3
- package/dist/types/tui/historystate.d.ts +49 -0
- package/dist/types/tui/inventory.d.ts +12 -0
- package/dist/types/tui/panelcontrols.d.ts +8 -0
- package/dist/types/tui/panelformat.d.ts +12 -0
- package/dist/types/tui/panelview.d.ts +22 -0
- package/dist/types/tui/quantity.d.ts +1 -0
- package/dist/types/tui/sidebar.d.ts +0 -5
- package/dist/types/tui/state.d.ts +3 -1
- package/dist/types/tui/statusformat.d.ts +19 -0
- package/package.json +1 -1
package/dist/types/adapter.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { type HistoryRpcPort } from "./historyserver.js";
|
|
2
|
+
import { type AnalyticsRpcPort } from "./modelanalyticsserver.js";
|
|
2
3
|
import { type SnapshotRpcPort } from "./snapshotserver.js";
|
|
3
4
|
import type { Plugin } from "@opencode/plugin";
|
|
4
5
|
import type { TelemetrySink } from "./types.js";
|
|
5
6
|
export interface Host {
|
|
6
7
|
rpc?: SnapshotRpcPort;
|
|
7
8
|
historyRpc?: HistoryRpcPort;
|
|
9
|
+
analyticsRpc?: AnalyticsRpcPort;
|
|
8
10
|
app: {
|
|
9
11
|
version: string;
|
|
10
12
|
};
|
package/dist/types/core.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DashboardConnectionOptions } from "./connection.js";
|
|
2
|
-
export declare const dashboardHelp = "Usage: context-guard dashboard tui [options]\nOpen a read-only live terminal dashboard for an existing OpenCode server.\n\nStart here\n 1. Keep an OpenCode server running with Context Guard registered.\n 2.
|
|
2
|
+
export declare const dashboardHelp = "Usage: context-guard dashboard tui [options]\nOpen a read-only live terminal dashboard for an existing OpenCode server.\n\nStart here\n 1. Keep an OpenCode server running with Context Guard registered.\n 2. Open a separate terminal tab, window or pane for the dashboard.\n 3. In the same project directory, run: context-guard dashboard tui\n Keep working in OpenCode; the dashboard reads live updates from its server.\n\nOptions\n --directory PATH Owning project directory (local default: current directory)\n --server URL Connect to an explicit server; requires --directory with\n an absolute server-side project path. Use HTTPS except\n on loopback. Credentials in URLs are rejected.\n -h, --help Show this help\n\nExamples\n context-guard dashboard tui\n context-guard dashboard tui --directory /absolute/project\n context-guard dashboard tui --server https://server.example --directory /server/project\n\nRequirements\n Interactive terminal and Bun >=1.3.0. The OpenTUI renderer is installed\n automatically with CGP. This command never starts a server.\n\nAuthentication (explicit servers)\n CONTEXT_GUARD_PASSWORD Server password\n CONTEXT_GUARD_USERNAME Server username (default: opencode)\n\nKeys\n 1/2/3/4 overview/detail/history/models; arrows or j/k move; Enter detail/chart;\n Models: Left/Right metric, [/] bucket, d requests, n/p pages, s sort;\n / session search; f filters (Models: agent); l location; w time window;\n r refresh; ? help; q or Ctrl+C quit.";
|
|
3
3
|
export declare function parseDashboardArgs(args: readonly string[], cwd: string, env: Readonly<Record<string, string | undefined>>): DashboardConnectionOptions | "help";
|
|
4
4
|
export declare function checkTerminalRuntime(version: string, interactive: boolean): void;
|
|
5
5
|
export declare function loadTerminalRenderer(): Promise<typeof import("@opentui/core")>;
|
|
@@ -2,6 +2,7 @@ import { Service } from "@opencode/client/service";
|
|
|
2
2
|
import type { HistoryChartRead } from "../historycharts.js";
|
|
3
3
|
import type { SnapshotTransport } from "../tui/transport.js";
|
|
4
4
|
import type { DashboardPort, SessionPageInput } from "./port.js";
|
|
5
|
+
import type { AnalyticsRead } from "../modelseries.js";
|
|
5
6
|
export interface DashboardConnectionOptions {
|
|
6
7
|
readonly directory: string;
|
|
7
8
|
readonly server?: string;
|
|
@@ -32,5 +33,6 @@ export declare function connectDashboard(options: DashboardConnectionOptions, di
|
|
|
32
33
|
readonly transport: SnapshotTransport;
|
|
33
34
|
}>;
|
|
34
35
|
history(input: HistoryChartRead, signal: AbortSignal): Promise<import("../historycharts.js").HistoryChartResult>;
|
|
36
|
+
analytics?(input: AnalyticsRead, signal: AbortSignal): Promise<import("../modelseries.js").AnalyticsResult>;
|
|
35
37
|
}>;
|
|
36
38
|
export type DashboardConnection = Awaited<ReturnType<typeof connectDashboard>>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type InventoryLimits } from "./inventory.js";
|
|
2
2
|
import type { DashboardPort } from "./port.js";
|
|
3
|
+
import { ModelsController } from "./models.js";
|
|
3
4
|
import { type DashboardView, type DashboardScreen, type DashboardFilters, type HistoryWindow } from "./view.js";
|
|
4
5
|
export interface DashboardControllerOptions {
|
|
5
6
|
readonly limits?: InventoryLimits;
|
|
@@ -28,10 +29,12 @@ export declare class DashboardController {
|
|
|
28
29
|
private pendingHistory;
|
|
29
30
|
private historyAbort;
|
|
30
31
|
private historyBusy;
|
|
32
|
+
private historyReason;
|
|
31
33
|
private historyStatus;
|
|
32
34
|
private refreshTimer;
|
|
33
35
|
private ageTimer;
|
|
34
36
|
private view;
|
|
37
|
+
readonly models: ModelsController;
|
|
35
38
|
constructor(port: DashboardPort, options?: DashboardControllerOptions);
|
|
36
39
|
private createLocation;
|
|
37
40
|
getView(): DashboardView;
|
|
@@ -44,6 +47,7 @@ export declare class DashboardController {
|
|
|
44
47
|
setScreen(screen: DashboardScreen): void;
|
|
45
48
|
setWindow(windowMs: HistoryWindow): void;
|
|
46
49
|
setFilters(filters: Partial<DashboardFilters>): void;
|
|
50
|
+
private configureModels;
|
|
47
51
|
refresh(): Promise<void>;
|
|
48
52
|
private current;
|
|
49
53
|
private scan;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { AnalyticsRead, AnalyticsResult } from "../modelseries.js";
|
|
2
|
+
import { type DashboardPort } from "./port.js";
|
|
3
|
+
import type { HistoryWindow } from "./view.js";
|
|
4
|
+
export interface DashboardModels {
|
|
5
|
+
status: "idle" | "loading" | "ready" | "disabled" | "unsupported" | "unavailable";
|
|
6
|
+
stale: boolean;
|
|
7
|
+
sort: NonNullable<AnalyticsRead["sort"]>;
|
|
8
|
+
windowMs: HistoryWindow;
|
|
9
|
+
modelPage: number;
|
|
10
|
+
requestPage: number;
|
|
11
|
+
result?: AnalyticsResult;
|
|
12
|
+
}
|
|
13
|
+
/** Location-scoped request state; it never opens a monitor/event subscription. */
|
|
14
|
+
export declare class ModelsController {
|
|
15
|
+
private readonly changed;
|
|
16
|
+
private port;
|
|
17
|
+
private active;
|
|
18
|
+
private key;
|
|
19
|
+
private agent;
|
|
20
|
+
private seedModel;
|
|
21
|
+
private selection;
|
|
22
|
+
private resolution;
|
|
23
|
+
private from;
|
|
24
|
+
private to;
|
|
25
|
+
private generation;
|
|
26
|
+
private abort;
|
|
27
|
+
private pending;
|
|
28
|
+
private modelPages;
|
|
29
|
+
private requestPages;
|
|
30
|
+
private state;
|
|
31
|
+
constructor(changed: () => void);
|
|
32
|
+
getView(): DashboardModels;
|
|
33
|
+
configure(port: DashboardPort, active: boolean, windowMs: HistoryWindow, agent: string, seedModel: string, now: number): void;
|
|
34
|
+
cancel(): void;
|
|
35
|
+
stop(): void;
|
|
36
|
+
refresh(now: number): Promise<void>;
|
|
37
|
+
setWidth(width: number): void;
|
|
38
|
+
select(model: string): void;
|
|
39
|
+
sort(): void;
|
|
40
|
+
page(kind: "models" | "requests", direction: -1 | 1): void;
|
|
41
|
+
private query;
|
|
42
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ModelSummary } from "../modelanalytics.js";
|
|
2
|
+
import type { DashboardView } from "./view.js";
|
|
3
|
+
export declare const modelMetrics: readonly [{
|
|
4
|
+
readonly key: "averageTps";
|
|
5
|
+
readonly label: "Weighted request TPS";
|
|
6
|
+
readonly unit: "t/s";
|
|
7
|
+
readonly divisor: 1;
|
|
8
|
+
}, {
|
|
9
|
+
readonly key: "medianTtftMs";
|
|
10
|
+
readonly label: "TTFT median ~";
|
|
11
|
+
readonly unit: "s";
|
|
12
|
+
readonly divisor: 1000;
|
|
13
|
+
}, {
|
|
14
|
+
readonly key: "p95TtftMs";
|
|
15
|
+
readonly label: "TTFT p95 ~";
|
|
16
|
+
readonly unit: "s";
|
|
17
|
+
readonly divisor: 1000;
|
|
18
|
+
}, {
|
|
19
|
+
readonly key: "completedRequests";
|
|
20
|
+
readonly label: "Completed requests";
|
|
21
|
+
readonly unit: "requests";
|
|
22
|
+
readonly divisor: 1;
|
|
23
|
+
}, {
|
|
24
|
+
readonly key: "outputTokens";
|
|
25
|
+
readonly label: "Reported output";
|
|
26
|
+
readonly unit: "tokens";
|
|
27
|
+
readonly divisor: 1;
|
|
28
|
+
}];
|
|
29
|
+
export declare function terminalModelRow(model: Readonly<ModelSummary>, focused: boolean): string[];
|
|
30
|
+
export declare function terminalModels(view: DashboardView, width: number, detail: boolean, metricIndex: number, sample: number, focus: number, requests: boolean): string[];
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { ExecutionStatus } from "../family.js";
|
|
2
2
|
import type { HistoryChartRead, HistoryChartResult } from "../historycharts.js";
|
|
3
3
|
import type { SnapshotTransport } from "../tui/transport.js";
|
|
4
|
+
import type { AnalyticsRead, AnalyticsResult } from "../modelseries.js";
|
|
5
|
+
export declare class AnalyticsUnavailable extends Error {
|
|
6
|
+
readonly reason: "unsupported" | "unavailable";
|
|
7
|
+
constructor(reason: "unsupported" | "unavailable");
|
|
8
|
+
}
|
|
4
9
|
/** The inventory boundary deliberately excludes titles, metadata, and content. */
|
|
5
10
|
export interface DashboardSession {
|
|
6
11
|
readonly sessionId: string;
|
|
@@ -34,6 +39,7 @@ export interface DashboardPort {
|
|
|
34
39
|
readonly transport: SnapshotTransport;
|
|
35
40
|
}>;
|
|
36
41
|
history(input: HistoryChartRead, signal: AbortSignal): Promise<HistoryChartResult>;
|
|
42
|
+
analytics?(input: AnalyticsRead, signal: AbortSignal): Promise<AnalyticsResult>;
|
|
37
43
|
}
|
|
38
44
|
export interface InventoryNode extends DashboardSession {
|
|
39
45
|
readonly status: ExecutionStatus;
|
|
@@ -15,11 +15,18 @@ export declare class TerminalShell {
|
|
|
15
15
|
scroll: number;
|
|
16
16
|
metric: number;
|
|
17
17
|
sample: number;
|
|
18
|
+
modelDetail: boolean;
|
|
19
|
+
modelRequests: boolean;
|
|
20
|
+
modelFocus: number;
|
|
21
|
+
private modelFocusId;
|
|
22
|
+
private modelViewport;
|
|
18
23
|
help: boolean;
|
|
19
24
|
editor: Editor | undefined;
|
|
20
25
|
input: string;
|
|
21
26
|
notice: string;
|
|
22
27
|
private rowOffset;
|
|
28
|
+
private overviewScope;
|
|
29
|
+
private overviewPage;
|
|
23
30
|
private historyIdentity;
|
|
24
31
|
constructor(controller: DashboardController, quit: () => void);
|
|
25
32
|
private task;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { DashboardRow, DashboardView } from "./view.js";
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function diagnosticRow(row: DashboardRow): string;
|
|
3
|
+
export declare function overviewHeading(width: number): string[];
|
|
4
|
+
/** Stable ID suffixes when unique; position is the bounded fallback. */
|
|
5
|
+
export declare function overviewLabels(rows: readonly DashboardRow[]): string[];
|
|
6
|
+
/** Each row is already cell-bounded; overview cards never wrap diagnostics. */
|
|
7
|
+
export declare function overviewRowLines(row: DashboardRow, width: number, selected: boolean, label: string, position: number, maxLines?: number): string[];
|
|
3
8
|
export declare const snapshotFields: readonly ["sessionId", "parentId", "agent", "model", "revision", "observedAt", "measurement.tokens", "measurement.at", "measurement.model", "measurement.provenance", "measurement.scope", "measurement.confidence", "measurement.requestId", "limits.input", "limits.context", "limits.output", "capacityTokens", "outputReserveTokens", "peakTokens", "policy.id", "policy.configured.type", "policy.configured.value", "policy.triggerTokens", "policy.comparison", "policy.reason", "policy.crossed", "compaction.phase", "compaction.count", "compaction.armed", "compaction.blockedReason", "compaction.lastAttempt", "compaction.lastCompleted", "compaction.cooldownUntil", "cumulativeScope", "cumulative.input", "cumulative.output", "cumulative.reasoning", "cumulative.cache.read", "cumulative.cache.write", "lastObservedActive", "performance.sessionCreatedAt", "performance.sessionOutputTokens", "performance.observedSince", "performance.at", "performance.status", "performance.partial", "performance.liveTps", "performance.averageModelTps", "performance.averageSessionTps", "performance.ttftMs", "performance.latestRequestTps", "performance.requestId", "performance.requestAgent", "performance.requestModel", "performance.requestOutputTokens", "performance.requestStartedAt", "performance.firstOutputAt", "performance.streamEndedAt", "performance.estimatedOutputTokens", "performance.modelOutputTokens", "performance.modelDurationMs", "performance.completedRequests", "performance.tokenSource"];
|
|
4
9
|
export declare function terminalDetail(row: DashboardRow | undefined): string[];
|
|
5
10
|
interface Observation {
|
|
@@ -11,5 +16,5 @@ export declare function historyObservations(view: DashboardView, metricIndex: nu
|
|
|
11
16
|
export declare function terminalHistory(view: DashboardView, width: number, metricIndex: number, sample: number): string[];
|
|
12
17
|
export declare const terminalHelp: string[];
|
|
13
18
|
export declare function wrapped(lines: readonly string[], width: number): string[];
|
|
14
|
-
export declare function headerLines(view: DashboardView, width: number): string[];
|
|
19
|
+
export declare function headerLines(view: DashboardView, width: number, height?: number): string[];
|
|
15
20
|
export {};
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
+
import type { HistoryFailureReason } from "../historyclient.js";
|
|
1
2
|
import type { GuardRow } from "../family.js";
|
|
2
3
|
import type { MonitorHealth } from "../snapshot.js";
|
|
3
4
|
import type { HistoryChartResult } from "../historycharts.js";
|
|
4
5
|
import type { Connection } from "../tui/transport.js";
|
|
5
6
|
import type { InventoryNotice } from "./inventory.js";
|
|
7
|
+
import type { DashboardModels } from "./models.js";
|
|
6
8
|
export type Immutable<T> = T extends object ? {
|
|
7
9
|
readonly [K in keyof T]: Immutable<T[K]>;
|
|
8
10
|
} : T;
|
|
9
11
|
export declare const historyWindows: readonly [300000, 3600000, 86400000, 604800000];
|
|
10
12
|
export type HistoryWindow = (typeof historyWindows)[number];
|
|
11
|
-
export type DashboardScreen = "overview" | "detail" | "history";
|
|
13
|
+
export type DashboardScreen = "overview" | "detail" | "history" | "models";
|
|
12
14
|
export interface DashboardFilters {
|
|
13
15
|
readonly search: string;
|
|
14
16
|
readonly agent: string;
|
|
@@ -31,6 +33,8 @@ export interface HistorySummary {
|
|
|
31
33
|
readonly averageModelTps?: number;
|
|
32
34
|
}
|
|
33
35
|
export interface DashboardHistory {
|
|
36
|
+
readonly reason?: HistoryFailureReason;
|
|
37
|
+
readonly loadedAt?: number;
|
|
34
38
|
readonly status: "idle" | "loading" | "ready" | "disabled" | "unavailable";
|
|
35
39
|
readonly windowMs: HistoryWindow;
|
|
36
40
|
readonly maxWindowMs: 604800000;
|
|
@@ -72,6 +76,7 @@ export type DashboardView = Immutable<{
|
|
|
72
76
|
selectedSessionId?: string;
|
|
73
77
|
selected?: DashboardRow;
|
|
74
78
|
history: DashboardHistory;
|
|
79
|
+
models: DashboardModels;
|
|
75
80
|
notices: readonly string[];
|
|
76
81
|
}>;
|
|
77
82
|
/** Clone before freezing so transport-owned objects never become UI-owned state. */
|
package/dist/types/history.d.ts
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { HistoryChartResult } from "./historycharts.js";
|
|
2
|
+
export type HistoryFailureReason = "unsupported" | "timeout" | "incompatible" | "rejected" | "unavailable";
|
|
3
|
+
/** Only approved codes cross the presentation boundary, never server messages. */
|
|
4
|
+
export declare class HistoryFailure extends Error {
|
|
5
|
+
readonly reason: HistoryFailureReason;
|
|
6
|
+
constructor(reason: HistoryFailureReason);
|
|
7
|
+
}
|
|
8
|
+
export declare function historyFailure(error: unknown, signal?: AbortSignal): HistoryFailure;
|
|
9
|
+
export declare function checkedHistory(value: unknown, sessionId: string): HistoryChartResult;
|
|
10
|
+
export declare function historyStatusLines(input: {
|
|
11
|
+
status: "idle" | "loading" | "ready" | "disabled" | "unavailable";
|
|
12
|
+
reason?: HistoryFailureReason;
|
|
13
|
+
stale?: boolean;
|
|
14
|
+
loadedAt?: number;
|
|
15
|
+
}): string[];
|
|
@@ -57,4 +57,12 @@ export interface ModelAnalyticsResult {
|
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
/** Aggregate raw request records before any chart downsampling or session limits. */
|
|
60
|
+
export declare function analyzeModelRequests(records: readonly HistoryRecord[], options: ModelAnalyticsOptions): ModelAnalyticsResult & {
|
|
61
|
+
requests: CompletedAnalyticsRequest[];
|
|
62
|
+
};
|
|
63
|
+
export interface CompletedAnalyticsRequest extends AnalyticsRequest {
|
|
64
|
+
completedAt: number;
|
|
65
|
+
}
|
|
66
|
+
/** Summarize already reconciled requests, including independent metric eligibility. */
|
|
67
|
+
export declare function summarizeModelRequests(requests: readonly CompletedAnalyticsRequest[]): ModelSummary[];
|
|
60
68
|
export declare function aggregateModels(records: readonly HistoryRecord[], options: ModelAnalyticsOptions): ModelAnalyticsResult;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { RpcHandlers, RpcRegistration } from "@opencode/plugin/promise/rpc";
|
|
2
|
+
import { readPerformanceHistory } from "./history.js";
|
|
3
|
+
import { type AnalyticsRead, type AnalyticsResult } from "./modelseries.js";
|
|
4
|
+
import { analyticsRpc } from "./rpc.js";
|
|
5
|
+
export interface AnalyticsRpcPort {
|
|
6
|
+
register(definition: typeof analyticsRpc, handlers: RpcHandlers<typeof analyticsRpc>): Promise<Pick<RpcRegistration<typeof analyticsRpc>, "dispose">>;
|
|
7
|
+
}
|
|
8
|
+
/** One instance owns exactly one server-selected location/archive; no client paths. */
|
|
9
|
+
export declare function createAnalyticsService(path: string, location: string, enabled: boolean, options?: {
|
|
10
|
+
now?: () => number;
|
|
11
|
+
read?: typeof readPerformanceHistory;
|
|
12
|
+
}): {
|
|
13
|
+
read(input: AnalyticsRead, signal: AbortSignal): Promise<AnalyticsResult>;
|
|
14
|
+
dispose(): void;
|
|
15
|
+
};
|
|
16
|
+
export declare function serveModelAnalytics(port: AnalyticsRpcPort | undefined, path: string, location: string, enabled: boolean): Promise<() => void>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type CompletedAnalyticsRequest, type ModelAnalyticsResult, type ModelSummary } from "./modelanalytics.js";
|
|
2
|
+
import type { HistoryMetadata } from "./history.js";
|
|
3
|
+
export interface ModelBucket {
|
|
4
|
+
from: number;
|
|
5
|
+
to: number;
|
|
6
|
+
summary?: ModelSummary;
|
|
7
|
+
}
|
|
8
|
+
export interface AnalyticsRead {
|
|
9
|
+
schemaVersion: 1;
|
|
10
|
+
from: number;
|
|
11
|
+
to: number;
|
|
12
|
+
buckets: number;
|
|
13
|
+
agent?: string;
|
|
14
|
+
model?: string;
|
|
15
|
+
unknownModel?: boolean;
|
|
16
|
+
sort?: "requests" | "tps" | "ttft" | "identity";
|
|
17
|
+
snapshotId?: string;
|
|
18
|
+
modelCursor?: string;
|
|
19
|
+
requestCursor?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface AnalyticsResult {
|
|
22
|
+
schemaVersion: 1;
|
|
23
|
+
generatedAt: number;
|
|
24
|
+
expiresAt: number;
|
|
25
|
+
snapshotId: string;
|
|
26
|
+
enabled: boolean;
|
|
27
|
+
from: number;
|
|
28
|
+
to: number;
|
|
29
|
+
agent?: string;
|
|
30
|
+
models: ModelSummary[];
|
|
31
|
+
totalModels: number;
|
|
32
|
+
nextModelsCursor?: string;
|
|
33
|
+
selected?: ModelSummary;
|
|
34
|
+
buckets: ModelBucket[];
|
|
35
|
+
requests: CompletedAnalyticsRequest[];
|
|
36
|
+
nextRequestsCursor?: string;
|
|
37
|
+
coverage: ModelAnalyticsResult["coverage"];
|
|
38
|
+
metadata: HistoryMetadata;
|
|
39
|
+
gaps: number[];
|
|
40
|
+
omittedGaps: number;
|
|
41
|
+
}
|
|
42
|
+
/** Requests belong to half-open completion buckets; rates never average rates. */
|
|
43
|
+
export declare function bucketModelRequests(requests: readonly CompletedAnalyticsRequest[], from: number, to: number, count: number): ModelBucket[];
|
package/dist/types/rpc.d.ts
CHANGED
|
@@ -124,6 +124,34 @@ export declare const historyRpc: {
|
|
|
124
124
|
};
|
|
125
125
|
export declare function isHistoryRead(value: unknown): value is import("./historycharts.js").HistoryChartRead;
|
|
126
126
|
export declare function isHistoryResult(value: unknown): value is import("./historycharts.js").HistoryChartResult;
|
|
127
|
+
export declare const analyticsReadSchema: {
|
|
128
|
+
type: "object";
|
|
129
|
+
properties: Record<string, object>;
|
|
130
|
+
required: string[];
|
|
131
|
+
additionalProperties: boolean;
|
|
132
|
+
};
|
|
133
|
+
export declare const analyticsRpc: {
|
|
134
|
+
readonly id: "context-guard.analytics.v1";
|
|
135
|
+
readonly methods: {
|
|
136
|
+
readonly read: {
|
|
137
|
+
readonly input: {
|
|
138
|
+
type: "object";
|
|
139
|
+
properties: Record<string, object>;
|
|
140
|
+
required: string[];
|
|
141
|
+
additionalProperties: boolean;
|
|
142
|
+
};
|
|
143
|
+
readonly output: {
|
|
144
|
+
type: "object";
|
|
145
|
+
properties: Record<string, object>;
|
|
146
|
+
required: string[];
|
|
147
|
+
additionalProperties: boolean;
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
readonly events: {};
|
|
152
|
+
};
|
|
153
|
+
export declare function isAnalyticsRead(value: unknown): value is import("./modelseries.js").AnalyticsRead;
|
|
154
|
+
export declare function isAnalyticsResult(value: unknown): value is import("./modelseries.js").AnalyticsResult;
|
|
127
155
|
export declare function isRead(value: unknown): value is SnapshotRead;
|
|
128
156
|
export declare function isBatch(value: unknown): value is SnapshotBatch;
|
|
129
157
|
export declare function isResult(value: unknown): value is SnapshotReadResult;
|
|
@@ -42,5 +42,5 @@ export declare const chartMetrics: readonly [{
|
|
|
42
42
|
export declare function metricPlot(points: readonly {
|
|
43
43
|
time: number;
|
|
44
44
|
value?: number;
|
|
45
|
-
}[], from: number, to: number, width: number, gaps?: readonly number[]): string[];
|
|
45
|
+
}[], from: number, to: number, width: number, gaps?: readonly number[], halfOpen?: boolean): string[];
|
|
46
46
|
export declare function historyChartLines(result: HistoryChartResult, width: number, from: number, to: number, metricIndex?: number): string[];
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import type { Plugin } from "@opencode/plugin/tui";
|
|
2
|
-
import type {
|
|
2
|
+
import type { HistoryView } from "./historystate.js";
|
|
3
3
|
export declare function HistoryCharts(props: {
|
|
4
4
|
sessionId: string;
|
|
5
5
|
windowMs: number;
|
|
6
6
|
metricIndex: number;
|
|
7
|
-
refresh: number;
|
|
8
7
|
width: number;
|
|
9
|
-
|
|
8
|
+
view: HistoryView;
|
|
10
9
|
context: Plugin.Context;
|
|
11
10
|
}): import("solid-js").JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ContextSample, type ContextChartSegment } from "./contextchart.js";
|
|
2
2
|
import type { GuardRow } from "../family.js";
|
|
3
|
-
export
|
|
3
|
+
export { tokens } from "./quantity.js";
|
|
4
4
|
export declare function columns(left: string, right: string, width: number): string[];
|
|
5
5
|
export declare function progress(ratio: number | undefined, width: number): string;
|
|
6
6
|
export interface MainSection {
|
|
@@ -8,7 +8,8 @@ export interface MainSection {
|
|
|
8
8
|
readonly lines: readonly string[];
|
|
9
9
|
readonly segments?: readonly ContextChartSegment[];
|
|
10
10
|
}
|
|
11
|
-
export declare function mainSections(row: GuardRow | undefined, width: number, age: number
|
|
11
|
+
export declare function mainSections(row: GuardRow | undefined, width: number, age: number): MainSection[];
|
|
12
|
+
export declare function historySections(row: GuardRow | undefined, width: number, age: number, samples: readonly ContextSample[], chartCapacity?: number): MainSection[];
|
|
12
13
|
export declare function mainLines(row: GuardRow | undefined, width: number, age: number): string[];
|
|
13
14
|
export declare const statusSymbol: {
|
|
14
15
|
readonly running: "●";
|
|
@@ -19,12 +20,20 @@ export declare const statusSymbol: {
|
|
|
19
20
|
};
|
|
20
21
|
export declare function agentHeading(row: GuardRow, width: number): string;
|
|
21
22
|
export declare function agentLines(row: GuardRow, width: number): string[];
|
|
22
|
-
export declare function subagentTree(rows: readonly GuardRow[], sessionID: string, collapsed: ReadonlySet<string>, hideCompleted: boolean, byPressure: boolean): {
|
|
23
|
+
export declare function subagentTree(rows: readonly GuardRow[], sessionID: string, collapsed: ReadonlySet<string>, hideCompleted: boolean, byPressure: boolean, trustworthy?: boolean): {
|
|
23
24
|
all: GuardRow[];
|
|
24
25
|
visible: {
|
|
25
26
|
row: GuardRow;
|
|
26
27
|
depth: number;
|
|
27
28
|
hasChildren: boolean;
|
|
29
|
+
hidden: number;
|
|
30
|
+
attention: boolean;
|
|
28
31
|
}[];
|
|
32
|
+
grouped: number;
|
|
33
|
+
complete: boolean;
|
|
34
|
+
};
|
|
35
|
+
export declare function routeFamily(rows: readonly GuardRow[], sessionID: string): {
|
|
36
|
+
rows: GuardRow[];
|
|
37
|
+
complete: boolean;
|
|
29
38
|
};
|
|
30
39
|
export declare function statistics(rows: readonly GuardRow[], sessionID: string, complete: boolean, width: number): string[];
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { HistoryChartResult } from "../historycharts.js";
|
|
2
|
+
import { type HistoryFailureReason } from "../historyclient.js";
|
|
3
|
+
interface Query {
|
|
4
|
+
readonly location: string;
|
|
5
|
+
readonly sessionId: string;
|
|
6
|
+
readonly windowMs: number;
|
|
7
|
+
}
|
|
8
|
+
export interface HistoryView {
|
|
9
|
+
readonly status: "idle" | "loading" | "ready" | "disabled" | "unavailable";
|
|
10
|
+
readonly reason?: HistoryFailureReason;
|
|
11
|
+
readonly result?: HistoryChartResult;
|
|
12
|
+
readonly from?: number;
|
|
13
|
+
readonly to?: number;
|
|
14
|
+
readonly loadedAt?: number;
|
|
15
|
+
readonly stale: boolean;
|
|
16
|
+
}
|
|
17
|
+
interface Options {
|
|
18
|
+
read(id: string, from: number, to: number, signal: AbortSignal): Promise<HistoryChartResult>;
|
|
19
|
+
changed(view: HistoryView): void;
|
|
20
|
+
now?: () => number;
|
|
21
|
+
schedule?: (callback: () => void, ms: number) => ReturnType<typeof setTimeout>;
|
|
22
|
+
cancel?: (timer: ReturnType<typeof setTimeout>) => void;
|
|
23
|
+
deadline?: () => AbortSignal;
|
|
24
|
+
}
|
|
25
|
+
/** One mounted chart, one retained query, one in-flight read and one queued retry. */
|
|
26
|
+
export declare class HistoryState {
|
|
27
|
+
private readonly options;
|
|
28
|
+
private query;
|
|
29
|
+
private generation;
|
|
30
|
+
private active;
|
|
31
|
+
private pending;
|
|
32
|
+
private stopped;
|
|
33
|
+
private paused;
|
|
34
|
+
private timer;
|
|
35
|
+
private view;
|
|
36
|
+
private readonly now;
|
|
37
|
+
private readonly schedule;
|
|
38
|
+
private readonly cancel;
|
|
39
|
+
constructor(options: Options);
|
|
40
|
+
setQuery(query: Query): void;
|
|
41
|
+
pause(): void;
|
|
42
|
+
resume(): void;
|
|
43
|
+
refresh(): void;
|
|
44
|
+
dispose(): void;
|
|
45
|
+
private clearTimer;
|
|
46
|
+
private publish;
|
|
47
|
+
private pump;
|
|
48
|
+
}
|
|
49
|
+
export {};
|
|
@@ -14,5 +14,17 @@ export interface Inventory {
|
|
|
14
14
|
readonly scanned: ReadonlySet<string>;
|
|
15
15
|
readonly damaged: boolean;
|
|
16
16
|
}
|
|
17
|
+
export interface InventoryStatus {
|
|
18
|
+
readonly discovered: number;
|
|
19
|
+
readonly limit: number;
|
|
20
|
+
readonly scanning: boolean;
|
|
21
|
+
readonly failed: boolean;
|
|
22
|
+
readonly damaged: boolean;
|
|
23
|
+
readonly pending: number;
|
|
24
|
+
readonly pages: number;
|
|
25
|
+
readonly complete: boolean;
|
|
26
|
+
readonly canLoadMore: boolean;
|
|
27
|
+
}
|
|
28
|
+
export declare function inventoryStatus(inventory: Inventory | undefined, limit: number, scanning: boolean, failed: boolean): InventoryStatus;
|
|
17
29
|
export declare function discoverFamily(client: Pick<OpenCodeClient, "session">, currentId: string, signal: AbortSignal, cached: (id: string) => SessionInfo | undefined, maxNodes?: number, previous?: Inventory): Promise<Inventory>;
|
|
18
30
|
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { InventoryStatus } from "./inventory.js";
|
|
2
|
+
export declare function inventoryMessages(status: InventoryStatus): string[];
|
|
3
|
+
export interface PanelAction {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly label: string;
|
|
6
|
+
readonly run: () => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function footerActions(essential: readonly PanelAction[], optional: readonly PanelAction[], width: number): PanelAction[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { GuardRow } from "../family.js";
|
|
2
|
+
export { compactionLabel, thresholdDistance, panelStatus, } from "./statusformat.js";
|
|
3
|
+
export declare const panelStatuses: {
|
|
4
|
+
readonly running: "RUNNING";
|
|
5
|
+
readonly idle: "IDLE";
|
|
6
|
+
readonly completed: "DONE";
|
|
7
|
+
readonly failed: "FAILED";
|
|
8
|
+
readonly unknown: "UNKNOWN";
|
|
9
|
+
};
|
|
10
|
+
export declare function panelSummary(row: GuardRow | undefined, width: number, age: number, compact?: boolean): string[];
|
|
11
|
+
export declare function panelRowHeading(label: string, width: number): string;
|
|
12
|
+
export declare function panelRowLines(row: GuardRow, width: number, selected: boolean): string[];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Plugin } from "@opencode/plugin/tui";
|
|
2
|
+
import type { GuardRow } from "../family.js";
|
|
3
|
+
import type { ContextTrace } from "./contextchart.js";
|
|
4
|
+
export declare function PanelOverview(props: {
|
|
5
|
+
rows: readonly GuardRow[];
|
|
6
|
+
selectedId: string | undefined;
|
|
7
|
+
width: number;
|
|
8
|
+
context: Plugin.Context;
|
|
9
|
+
open: (row: GuardRow) => void;
|
|
10
|
+
}): import("solid-js").JSX.Element;
|
|
11
|
+
export declare function PanelDetails(props: {
|
|
12
|
+
row: GuardRow | undefined;
|
|
13
|
+
rows: readonly GuardRow[];
|
|
14
|
+
routeID: string;
|
|
15
|
+
familyRows: readonly GuardRow[];
|
|
16
|
+
familyComplete: boolean;
|
|
17
|
+
trace: ContextTrace;
|
|
18
|
+
width: number;
|
|
19
|
+
age: number;
|
|
20
|
+
context: Plugin.Context;
|
|
21
|
+
reasons: readonly string[];
|
|
22
|
+
}): import("solid-js").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function tokens(value: number | undefined): string;
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import type { Plugin } from "@opencode/plugin/tui";
|
|
2
2
|
import type { GuardState } from "./state.js";
|
|
3
|
-
import type { GuardRow } from "../family.js";
|
|
4
3
|
export declare function GuardView(props: {
|
|
5
4
|
sessionID: string;
|
|
6
5
|
state: GuardState;
|
|
7
6
|
context: Plugin.Context;
|
|
8
7
|
width: number;
|
|
9
|
-
expanded?: boolean;
|
|
10
|
-
family?: readonly GuardRow[];
|
|
11
|
-
selectedId?: string;
|
|
12
|
-
inspectId?: string | undefined;
|
|
13
8
|
}): import("solid-js").JSX.Element;
|
|
@@ -6,14 +6,16 @@ export declare function createGuardState(context: Plugin.Context): {
|
|
|
6
6
|
update(next: string): void;
|
|
7
7
|
release(): void;
|
|
8
8
|
};
|
|
9
|
+
historyLocation(id: string): string;
|
|
9
10
|
history(id: string, from: number, to: number, signal: AbortSignal): Promise<import("../historycharts.js").HistoryChartResult>;
|
|
10
11
|
rows: (stableOrder?: readonly string[], allDescendants?: boolean) => GuardRow[];
|
|
11
12
|
contextTrace: (row: GuardRow | undefined) => import("./contextchart.js").ContextTrace;
|
|
12
13
|
dispose(): void;
|
|
13
14
|
age(id: string): number;
|
|
14
15
|
health(): import("../snapshot.js").MonitorHealth | undefined;
|
|
15
|
-
connection(): "unavailable" | "
|
|
16
|
+
connection(): "unavailable" | "incompatible" | "loading" | "live" | "reconnecting";
|
|
16
17
|
complete(): boolean;
|
|
18
|
+
inventoryStatus(): import("./inventory.js").InventoryStatus;
|
|
17
19
|
refresh(): void;
|
|
18
20
|
loadMore(): void;
|
|
19
21
|
expand(id: string): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { GuardRow } from "../family.js";
|
|
2
|
+
import type { MonitorHealth } from "../snapshot.js";
|
|
3
|
+
import type { Connection } from "./transport.js";
|
|
4
|
+
/** A stored reading's confidence is independent of its freshness and scope. */
|
|
5
|
+
export declare function freshnessLabel(row: GuardRow | undefined): string | undefined;
|
|
6
|
+
export declare function measurementLabel(row: GuardRow | undefined, ageMs?: number): string;
|
|
7
|
+
export declare function measurementExplanation(row: GuardRow): readonly string[];
|
|
8
|
+
export declare function compactionLabel(row: GuardRow | undefined, compact?: boolean): string | undefined;
|
|
9
|
+
/** Only translate reasons with established semantics; unknown codes stay in diagnostics. */
|
|
10
|
+
export declare function reasonExplanation(reason: string): string;
|
|
11
|
+
export declare const contextHistoryLegend: readonly ["Recent samples → now · ┄ threshold", "Dim = last known context"];
|
|
12
|
+
export declare function pressureLabel(row: GuardRow | undefined): string;
|
|
13
|
+
export declare function thresholdDistance(row: GuardRow | undefined, compact?: boolean): string;
|
|
14
|
+
export declare function guardStatusLines(health: MonitorHealth | undefined, compact?: boolean): readonly string[];
|
|
15
|
+
export declare function panelStatus(health: MonitorHealth | undefined): string;
|
|
16
|
+
export declare function connectionLabel(connection: Connection, compact?: boolean): string;
|
|
17
|
+
/** A client connection loss is not evidence that server enforcement stopped. */
|
|
18
|
+
export declare function connectionNotice(connection: Connection, retainedMeasurements: boolean, compact?: boolean): string | undefined;
|
|
19
|
+
export declare function monitorStatusLines(connection: Connection, health: MonitorHealth | undefined, retainedMeasurements: boolean, compact?: boolean): readonly string[];
|