@cesarus777/opencode-cgp 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -0
- package/README.md +19 -11
- package/dist/cli.js +906 -237
- package/dist/core.js +88 -59
- package/dist/index.js +710 -166
- package/dist/tui.js +1416 -702
- package/dist/types/archive.d.ts +40 -0
- package/dist/types/core.d.ts +1 -1
- package/dist/types/dashboard/controller.d.ts +2 -0
- package/dist/types/dashboard/inventory.d.ts +1 -1
- package/dist/types/dashboard/terminal.d.ts +8 -0
- package/dist/types/dashboard/terminalview.d.ts +9 -2
- package/dist/types/dashboard/view.d.ts +4 -1
- package/dist/types/history.d.ts +39 -2
- package/dist/types/historyclient.d.ts +15 -0
- package/dist/types/historyserver.d.ts +2 -1
- package/dist/types/modelanalytics.d.ts +11 -0
- package/dist/types/modelanalyticsserver.d.ts +2 -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 +2 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type HistoryFilter, type HistoryMetadata, type HistoryRecord, type ScanOptions } from "./history.js";
|
|
2
|
+
export interface ArchiveSnapshot {
|
|
3
|
+
revision: string;
|
|
4
|
+
metadata: HistoryMetadata;
|
|
5
|
+
records: HistoryRecord[];
|
|
6
|
+
iterateRecords?: () => Iterable<HistoryRecord>;
|
|
7
|
+
}
|
|
8
|
+
interface ArchiveOptions extends ScanOptions {
|
|
9
|
+
maxCacheBytes?: number;
|
|
10
|
+
maxCacheRecords?: number;
|
|
11
|
+
maxCacheSegments?: number;
|
|
12
|
+
}
|
|
13
|
+
/** Location-owned cache. Metadata validation assumes external writers do not restore timestamps. */
|
|
14
|
+
export declare class PerformanceArchive {
|
|
15
|
+
readonly path: string;
|
|
16
|
+
private readonly options;
|
|
17
|
+
private entries;
|
|
18
|
+
private generation;
|
|
19
|
+
private stopped;
|
|
20
|
+
private dirty;
|
|
21
|
+
private forcedGeneration;
|
|
22
|
+
private job;
|
|
23
|
+
readonly stats: {
|
|
24
|
+
readBytes: number;
|
|
25
|
+
parsedRecords: number;
|
|
26
|
+
cacheBytes: number;
|
|
27
|
+
cacheRecords: number;
|
|
28
|
+
};
|
|
29
|
+
constructor(path: string, options?: ArchiveOptions);
|
|
30
|
+
/** Writer notifications invalidate even metadata-invisible mutations. */
|
|
31
|
+
invalidate(name?: string): void;
|
|
32
|
+
dispose(): void;
|
|
33
|
+
private account;
|
|
34
|
+
private retain;
|
|
35
|
+
private validCapture;
|
|
36
|
+
private scan;
|
|
37
|
+
read(filter?: HistoryFilter): Promise<ArchiveSnapshot>;
|
|
38
|
+
private wait;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
package/dist/types/core.d.ts
CHANGED
|
@@ -8,5 +8,5 @@ export * from "./snapshot.js";
|
|
|
8
8
|
export * from "./family.js";
|
|
9
9
|
export * from "./performance.js";
|
|
10
10
|
export * from "./charts.js";
|
|
11
|
-
export
|
|
11
|
+
export { analyzeModelRequests, aggregateModels, summarizeModelRequests, type ModelAnalyticsOptions, type AnalyticsRequest, type ModelSummary, type ModelAnalyticsResult, type CompletedAnalyticsRequest, } from "./modelanalytics.js";
|
|
12
12
|
export * from "./modelseries.js";
|
|
@@ -11,6 +11,7 @@ export interface DashboardControllerOptions {
|
|
|
11
11
|
}
|
|
12
12
|
/** Shared application state; subscribers never acquire additional upstream streams. */
|
|
13
13
|
export declare class DashboardController {
|
|
14
|
+
private readonly snapshots;
|
|
14
15
|
private readonly locations;
|
|
15
16
|
private readonly cache;
|
|
16
17
|
private readonly listeners;
|
|
@@ -29,6 +30,7 @@ export declare class DashboardController {
|
|
|
29
30
|
private pendingHistory;
|
|
30
31
|
private historyAbort;
|
|
31
32
|
private historyBusy;
|
|
33
|
+
private historyReason;
|
|
32
34
|
private historyStatus;
|
|
33
35
|
private refreshTimer;
|
|
34
36
|
private ageTimer;
|
|
@@ -14,4 +14,4 @@ export interface DashboardInventory {
|
|
|
14
14
|
export declare const inventoryLimits: InventoryLimits;
|
|
15
15
|
export declare function validateInventoryLimits(limits: InventoryLimits): void;
|
|
16
16
|
/** Bounded breadth-first discovery of a whole location, without transcript reads. */
|
|
17
|
-
export declare function discoverInventory(port: Pick<DashboardPort, "location" | "listSessions">, signal: AbortSignal, limits?: InventoryLimits): Promise<DashboardInventory>;
|
|
17
|
+
export declare function discoverInventory(port: Pick<DashboardPort, "location" | "listSessions">, signal: AbortSignal, limits?: InventoryLimits, progress?: (inventory: DashboardInventory) => void): Promise<DashboardInventory>;
|
|
@@ -12,6 +12,9 @@ export interface TerminalKey {
|
|
|
12
12
|
export declare class TerminalShell {
|
|
13
13
|
readonly controller: DashboardController;
|
|
14
14
|
private readonly quit;
|
|
15
|
+
readonly work: {
|
|
16
|
+
formattedOverviewRows: number;
|
|
17
|
+
};
|
|
15
18
|
scroll: number;
|
|
16
19
|
metric: number;
|
|
17
20
|
sample: number;
|
|
@@ -25,6 +28,11 @@ export declare class TerminalShell {
|
|
|
25
28
|
input: string;
|
|
26
29
|
notice: string;
|
|
27
30
|
private rowOffset;
|
|
31
|
+
private overviewScope;
|
|
32
|
+
private overviewPage;
|
|
33
|
+
private labelKey;
|
|
34
|
+
private labels;
|
|
35
|
+
private layouts;
|
|
28
36
|
private historyIdentity;
|
|
29
37
|
constructor(controller: DashboardController, quit: () => void);
|
|
30
38
|
private task;
|
|
@@ -1,5 +1,12 @@
|
|
|
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
|
+
/** Lightweight line count; identity clipping and exception text are viewport work. */
|
|
7
|
+
export declare function overviewRowHeight(row: DashboardRow, width: number, maxLines: number): number;
|
|
8
|
+
/** Each row is already cell-bounded; overview cards never wrap diagnostics. */
|
|
9
|
+
export declare function overviewRowLines(row: DashboardRow, width: number, selected: boolean, label: string, position: number, maxLines?: number): string[];
|
|
3
10
|
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
11
|
export declare function terminalDetail(row: DashboardRow | undefined): string[];
|
|
5
12
|
interface Observation {
|
|
@@ -11,5 +18,5 @@ export declare function historyObservations(view: DashboardView, metricIndex: nu
|
|
|
11
18
|
export declare function terminalHistory(view: DashboardView, width: number, metricIndex: number, sample: number): string[];
|
|
12
19
|
export declare const terminalHelp: string[];
|
|
13
20
|
export declare function wrapped(lines: readonly string[], width: number): string[];
|
|
14
|
-
export declare function headerLines(view: DashboardView, width: number): string[];
|
|
21
|
+
export declare function headerLines(view: DashboardView, width: number, height?: number): string[];
|
|
15
22
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
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";
|
|
@@ -32,6 +33,8 @@ export interface HistorySummary {
|
|
|
32
33
|
readonly averageModelTps?: number;
|
|
33
34
|
}
|
|
34
35
|
export interface DashboardHistory {
|
|
36
|
+
readonly reason?: HistoryFailureReason;
|
|
37
|
+
readonly loadedAt?: number;
|
|
35
38
|
readonly status: "idle" | "loading" | "ready" | "disabled" | "unavailable";
|
|
36
39
|
readonly windowMs: HistoryWindow;
|
|
37
40
|
readonly maxWindowMs: 604800000;
|
|
@@ -76,7 +79,7 @@ export type DashboardView = Immutable<{
|
|
|
76
79
|
models: DashboardModels;
|
|
77
80
|
notices: readonly string[];
|
|
78
81
|
}>;
|
|
79
|
-
/**
|
|
82
|
+
/** Copy transport objects once; already-owned immutable subtrees can be shared. */
|
|
80
83
|
export declare function immutableView<T>(value: T): T;
|
|
81
84
|
export declare function projectHistory(result: HistoryChartResult, filters: DashboardFilters): {
|
|
82
85
|
result: HistoryChartResult;
|
package/dist/types/history.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Stats } from "node:fs";
|
|
2
|
+
import { open } from "node:fs/promises";
|
|
1
3
|
import type { Identity, Config } from "./types.js";
|
|
2
4
|
import type { PerformanceSnapshot } from "./performance.js";
|
|
3
5
|
export interface HistoryRecord extends Identity {
|
|
@@ -9,12 +11,47 @@ export interface HistoryRecord extends Identity {
|
|
|
9
11
|
event?: string;
|
|
10
12
|
droppedRecords?: number;
|
|
11
13
|
}
|
|
14
|
+
export declare function segments(directory: string): Promise<{
|
|
15
|
+
bytes: number;
|
|
16
|
+
dev: number;
|
|
17
|
+
ino: number;
|
|
18
|
+
mtimeMs: number;
|
|
19
|
+
ctimeMs: number;
|
|
20
|
+
name: string;
|
|
21
|
+
time: number;
|
|
22
|
+
}[]>;
|
|
23
|
+
export declare function fileIdentity(info: Stats): {
|
|
24
|
+
bytes: number;
|
|
25
|
+
dev: number;
|
|
26
|
+
ino: number;
|
|
27
|
+
mtimeMs: number;
|
|
28
|
+
ctimeMs: number;
|
|
29
|
+
};
|
|
30
|
+
export interface ScanOptions {
|
|
31
|
+
now?: () => number;
|
|
32
|
+
yield?: () => Promise<void>;
|
|
33
|
+
chunkBytes?: number;
|
|
34
|
+
onRead?: (bytes: number) => void;
|
|
35
|
+
onParse?: () => void;
|
|
36
|
+
}
|
|
37
|
+
/** Cooperative scheduling is independent of cancellation. */
|
|
38
|
+
export declare function scanScheduler(signal?: AbortSignal, options?: ScanOptions): () => Promise<void> | undefined;
|
|
39
|
+
export declare function matchesHistory(value: HistoryRecord, filter: HistoryFilter): boolean;
|
|
40
|
+
/** Reads captured bytes only. Byte boundaries retain UTF-8 exactly, including tails. */
|
|
41
|
+
export declare function scanHistorySegment(handle: Awaited<ReturnType<typeof open>>, size: number, filter?: HistoryFilter, options?: ScanOptions, start?: number): Promise<{
|
|
42
|
+
records: HistoryRecord[];
|
|
43
|
+
malformedRecords: number;
|
|
44
|
+
boundary: number;
|
|
45
|
+
completeRecords: number;
|
|
46
|
+
completeMalformed: number;
|
|
47
|
+
}>;
|
|
12
48
|
/** Separate bounded journal; the API accepts only projected scalar measurements. */
|
|
13
49
|
export declare class PerformanceHistory {
|
|
14
50
|
readonly path: string;
|
|
15
51
|
private readonly config;
|
|
16
52
|
private readonly now;
|
|
17
53
|
private readonly report;
|
|
54
|
+
private readonly changed;
|
|
18
55
|
private pending;
|
|
19
56
|
private working;
|
|
20
57
|
private active;
|
|
@@ -23,7 +60,7 @@ export declare class PerformanceHistory {
|
|
|
23
60
|
private disabled;
|
|
24
61
|
private dropped;
|
|
25
62
|
private droppedTotal;
|
|
26
|
-
constructor(path: string, config: Config["history"], now?: () => number, report?: (event: string) => void);
|
|
63
|
+
constructor(path: string, config: Config["history"], now?: () => number, report?: (event: string) => void, changed?: (name: string) => void);
|
|
27
64
|
emit(record: HistoryRecord): void;
|
|
28
65
|
private kick;
|
|
29
66
|
private prune;
|
|
@@ -54,7 +91,7 @@ export interface HistoryMetadata {
|
|
|
54
91
|
malformedRecords: number;
|
|
55
92
|
completeness: string;
|
|
56
93
|
}
|
|
57
|
-
export declare function readPerformanceHistory(directory: string, filter?: HistoryFilter): Promise<{
|
|
94
|
+
export declare function readPerformanceHistory(directory: string, filter?: HistoryFilter, options?: ScanOptions): Promise<{
|
|
58
95
|
metadata: HistoryMetadata;
|
|
59
96
|
records: HistoryRecord[];
|
|
60
97
|
}>;
|
|
@@ -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[];
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { readPerformanceHistory } from "./history.js";
|
|
1
2
|
import { historyRpc } from "./rpc.js";
|
|
2
3
|
import type { RpcHandlers, RpcRegistration } from "@opencode/plugin/promise/rpc";
|
|
3
4
|
export interface HistoryRpcPort {
|
|
4
5
|
register(definition: typeof historyRpc, handlers: RpcHandlers<typeof historyRpc>): Promise<Pick<RpcRegistration<typeof historyRpc>, "dispose">>;
|
|
5
6
|
}
|
|
6
7
|
/** Read-only archive service. Clients can select an ID/time range, never a filesystem path. */
|
|
7
|
-
export declare function serveHistory(rpc: HistoryRpcPort | undefined, path: string, enabled: boolean, now?: () => number, authorize?: (sessionId: string, signal: AbortSignal) => Promise<boolean
|
|
8
|
+
export declare function serveHistory(rpc: HistoryRpcPort | undefined, path: string, enabled: boolean, now?: () => number, authorize?: (sessionId: string, signal: AbortSignal) => Promise<boolean>, reader?: typeof readPerformanceHistory): Promise<() => void>;
|
|
@@ -60,9 +60,20 @@ export interface ModelAnalyticsResult {
|
|
|
60
60
|
export declare function analyzeModelRequests(records: readonly HistoryRecord[], options: ModelAnalyticsOptions): ModelAnalyticsResult & {
|
|
61
61
|
requests: CompletedAnalyticsRequest[];
|
|
62
62
|
};
|
|
63
|
+
/** Canonical reconciliation state, shared by full and proven-prefix append paths. */
|
|
64
|
+
export declare function createModelAccumulator(options: ModelAnalyticsOptions): {
|
|
65
|
+
append: (records: readonly HistoryRecord[]) => void;
|
|
66
|
+
steps: () => Generator<void, ModelAnalyticsResult & {
|
|
67
|
+
requests: CompletedAnalyticsRequest[];
|
|
68
|
+
}>;
|
|
69
|
+
result: () => ModelAnalyticsResult & {
|
|
70
|
+
requests: CompletedAnalyticsRequest[];
|
|
71
|
+
};
|
|
72
|
+
};
|
|
63
73
|
export interface CompletedAnalyticsRequest extends AnalyticsRequest {
|
|
64
74
|
completedAt: number;
|
|
65
75
|
}
|
|
66
76
|
/** Summarize already reconciled requests, including independent metric eligibility. */
|
|
67
77
|
export declare function summarizeModelRequests(requests: readonly CompletedAnalyticsRequest[]): ModelSummary[];
|
|
78
|
+
export declare function summarizeModelRequestSteps(requests: readonly CompletedAnalyticsRequest[]): Generator<void, ModelSummary[]>;
|
|
68
79
|
export declare function aggregateModels(records: readonly HistoryRecord[], options: ModelAnalyticsOptions): ModelAnalyticsResult;
|
|
@@ -9,8 +9,9 @@ export interface AnalyticsRpcPort {
|
|
|
9
9
|
export declare function createAnalyticsService(path: string, location: string, enabled: boolean, options?: {
|
|
10
10
|
now?: () => number;
|
|
11
11
|
read?: typeof readPerformanceHistory;
|
|
12
|
+
revisioned?: boolean;
|
|
12
13
|
}): {
|
|
13
14
|
read(input: AnalyticsRead, signal: AbortSignal): Promise<AnalyticsResult>;
|
|
14
15
|
dispose(): void;
|
|
15
16
|
};
|
|
16
|
-
export declare function serveModelAnalytics(port: AnalyticsRpcPort | undefined, path: string, location: string, enabled: boolean): Promise<() => void>;
|
|
17
|
+
export declare function serveModelAnalytics(port: AnalyticsRpcPort | undefined, path: string, location: string, enabled: boolean, options?: Parameters<typeof createAnalyticsService>[3]): Promise<() => void>;
|
|
@@ -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[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cesarus777/opencode-cgp",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"format:check": "prettier --check src tests scripts docs README.md examples package.json tsconfig.json server.ts tui.tsx rpc.ts tsconfig.build.json .github AGENTS.md",
|
|
39
39
|
"test:tui-live": "bun scripts/tui-live.ts",
|
|
40
40
|
"bench:tui": "bun scripts/tui-bench.ts",
|
|
41
|
+
"bench:dashboard": "bun scripts/dashboard-bench.ts",
|
|
41
42
|
"build": "bun scripts/build.ts",
|
|
42
43
|
"prepack": "bun run build",
|
|
43
44
|
"prepare": "bun run build",
|