@cesarus777/opencode-cgp 0.1.0 → 0.2.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/README.md +6 -2
- package/dist/cli.js +1411 -0
- package/dist/core.js +424 -3
- package/dist/index.js +1087 -29
- package/dist/rpc.js +159 -0
- package/dist/tui.js +461 -49
- package/dist/types/adapter.d.ts +2 -0
- package/dist/types/chartreport.d.ts +14 -0
- package/dist/types/charts.d.ts +54 -0
- package/dist/types/core.d.ts +2 -0
- package/dist/types/family.d.ts +1 -1
- package/dist/types/history.d.ts +59 -0
- package/dist/types/historycharts.d.ts +17 -0
- package/dist/types/historyserver.d.ts +7 -0
- package/dist/types/performance.d.ts +57 -0
- package/dist/types/rpc.d.ts +78 -0
- package/dist/types/snapshot.d.ts +4 -1
- package/dist/types/snapshotserver.d.ts +3 -3
- package/dist/types/tui/chartformat.d.ts +11 -0
- package/dist/types/tui/charts.d.ts +10 -0
- package/dist/types/tui/format.d.ts +1 -0
- package/dist/types/tui/state.d.ts +1 -0
- package/dist/types/types.d.ts +11 -0
- package/package.json +9 -3
package/dist/rpc.js
CHANGED
|
@@ -114,6 +114,154 @@ var monitorRpc = Rpc.define({
|
|
|
114
114
|
methods: { read: { input: readSchema, output: resultSchema } },
|
|
115
115
|
events: { changed: { schema: batchSchema } }
|
|
116
116
|
});
|
|
117
|
+
var nonnegative = { type: "number", minimum: 0 };
|
|
118
|
+
var performanceSchema = object({
|
|
119
|
+
observedSince: count,
|
|
120
|
+
at: count,
|
|
121
|
+
sessionCreatedAt: count,
|
|
122
|
+
sessionOutputTokens: count,
|
|
123
|
+
status: enumeration("waiting", "streaming", "idle", "unavailable"),
|
|
124
|
+
partial: { type: "boolean" },
|
|
125
|
+
liveTps: nonnegative,
|
|
126
|
+
averageModelTps: nonnegative,
|
|
127
|
+
averageSessionTps: nonnegative,
|
|
128
|
+
ttftMs: nonnegative,
|
|
129
|
+
latestRequestTps: nonnegative,
|
|
130
|
+
requestId: text,
|
|
131
|
+
requestAgent: text,
|
|
132
|
+
requestModel: text,
|
|
133
|
+
requestOutputTokens: count,
|
|
134
|
+
requestStartedAt: count,
|
|
135
|
+
firstOutputAt: count,
|
|
136
|
+
streamEndedAt: count,
|
|
137
|
+
estimatedOutputTokens: nonnegative,
|
|
138
|
+
modelOutputTokens: nonnegative,
|
|
139
|
+
modelDurationMs: nonnegative,
|
|
140
|
+
completedRequests: count,
|
|
141
|
+
tokenSource: enumeration("estimated", "reported", "unavailable")
|
|
142
|
+
}, [
|
|
143
|
+
"sessionCreatedAt",
|
|
144
|
+
"observedSince",
|
|
145
|
+
"at",
|
|
146
|
+
"status",
|
|
147
|
+
"partial",
|
|
148
|
+
"estimatedOutputTokens",
|
|
149
|
+
"modelOutputTokens",
|
|
150
|
+
"modelDurationMs",
|
|
151
|
+
"completedRequests",
|
|
152
|
+
"tokenSource"
|
|
153
|
+
]);
|
|
154
|
+
var performanceRow = {
|
|
155
|
+
...row,
|
|
156
|
+
properties: { ...row.properties, performance: performanceSchema }
|
|
157
|
+
};
|
|
158
|
+
var performanceBatchSchema = object({
|
|
159
|
+
...batchFields,
|
|
160
|
+
upserts: array(performanceRow)
|
|
161
|
+
});
|
|
162
|
+
var performanceResultSchema = object({
|
|
163
|
+
...batchFields,
|
|
164
|
+
upserts: array(performanceRow),
|
|
165
|
+
unavailable: resultSchema.properties.unavailable ?? {}
|
|
166
|
+
});
|
|
167
|
+
var performanceRpc = Rpc.define({
|
|
168
|
+
id: "context-guard.monitor.v2",
|
|
169
|
+
methods: { read: { input: readSchema, output: performanceResultSchema } },
|
|
170
|
+
events: { changed: { schema: performanceBatchSchema } }
|
|
171
|
+
});
|
|
172
|
+
function isPerformanceBatch(value) {
|
|
173
|
+
return valid(value, performanceBatchSchema) && uniqueRows(value);
|
|
174
|
+
}
|
|
175
|
+
function isPerformanceResult(value) {
|
|
176
|
+
return valid(value, performanceResultSchema) && uniqueRows(value);
|
|
177
|
+
}
|
|
178
|
+
function isPerformanceSnapshot(value) {
|
|
179
|
+
return valid(value, performanceSchema);
|
|
180
|
+
}
|
|
181
|
+
var chartPointSchema = object({
|
|
182
|
+
time: count,
|
|
183
|
+
agent: text,
|
|
184
|
+
model: text,
|
|
185
|
+
breakBefore: { type: "boolean" },
|
|
186
|
+
partial: { type: "boolean" },
|
|
187
|
+
liveTps: nonnegative,
|
|
188
|
+
averageModelTps: nonnegative,
|
|
189
|
+
averageSessionTps: nonnegative,
|
|
190
|
+
sessionOutputTokens: count
|
|
191
|
+
}, ["time", "breakBefore", "partial"]);
|
|
192
|
+
var chartRequestSchema = object({
|
|
193
|
+
time: count,
|
|
194
|
+
requestId: text,
|
|
195
|
+
started: count,
|
|
196
|
+
agent: text,
|
|
197
|
+
model: text,
|
|
198
|
+
ttftMs: nonnegative,
|
|
199
|
+
outputTokens: count,
|
|
200
|
+
durationMs: nonnegative,
|
|
201
|
+
tps: nonnegative,
|
|
202
|
+
partial: { type: "boolean" }
|
|
203
|
+
}, ["time", "requestId", "started", "partial"]);
|
|
204
|
+
var historyReadSchema = object({
|
|
205
|
+
schemaVersion: { const: 1 },
|
|
206
|
+
sessionId: text,
|
|
207
|
+
from: count,
|
|
208
|
+
to: count,
|
|
209
|
+
maxPoints: { type: "integer", minimum: 16, maximum: 500 }
|
|
210
|
+
});
|
|
211
|
+
var historyResultSchema = object({
|
|
212
|
+
schemaVersion: { const: 1 },
|
|
213
|
+
generatedAt: count,
|
|
214
|
+
enabled: { type: "boolean" },
|
|
215
|
+
truncated: { type: "boolean" },
|
|
216
|
+
metadata: object({
|
|
217
|
+
schema: { const: 1 },
|
|
218
|
+
retainedFrom: count,
|
|
219
|
+
retainedBytes: count,
|
|
220
|
+
skippedBytes: count,
|
|
221
|
+
malformedRecords: count,
|
|
222
|
+
completeness: enumeration("bounded-retention")
|
|
223
|
+
}, [
|
|
224
|
+
"schema",
|
|
225
|
+
"retainedBytes",
|
|
226
|
+
"skippedBytes",
|
|
227
|
+
"malformedRecords",
|
|
228
|
+
"completeness"
|
|
229
|
+
]),
|
|
230
|
+
data: object({
|
|
231
|
+
schema: { const: 1 },
|
|
232
|
+
omittedSessions: count,
|
|
233
|
+
omittedGaps: count,
|
|
234
|
+
maxPoints: count,
|
|
235
|
+
gaps: array(object({ time: count, sessionId: text, reason: text }), 128),
|
|
236
|
+
series: array(object({
|
|
237
|
+
sessionId: text,
|
|
238
|
+
parentId: text,
|
|
239
|
+
agents: array(text, 1024),
|
|
240
|
+
models: array(text, 1024),
|
|
241
|
+
points: array(chartPointSchema, 500),
|
|
242
|
+
requests: array(chartRequestSchema, 500),
|
|
243
|
+
originalPoints: count
|
|
244
|
+
}, [
|
|
245
|
+
"sessionId",
|
|
246
|
+
"agents",
|
|
247
|
+
"models",
|
|
248
|
+
"points",
|
|
249
|
+
"requests",
|
|
250
|
+
"originalPoints"
|
|
251
|
+
]), 1)
|
|
252
|
+
}, ["schema", "omittedSessions", "maxPoints", "gaps", "series"])
|
|
253
|
+
});
|
|
254
|
+
var historyRpc = Rpc.define({
|
|
255
|
+
id: "context-guard.history.v1",
|
|
256
|
+
methods: { read: { input: historyReadSchema, output: historyResultSchema } },
|
|
257
|
+
events: {}
|
|
258
|
+
});
|
|
259
|
+
function isHistoryRead(value) {
|
|
260
|
+
return valid(value, historyReadSchema) && record(value) && typeof value.from === "number" && typeof value.to === "number" && value.from <= value.to && value.to - value.from <= 7 * 86400000;
|
|
261
|
+
}
|
|
262
|
+
function isHistoryResult(value) {
|
|
263
|
+
return valid(value, historyResultSchema);
|
|
264
|
+
}
|
|
117
265
|
function record(x) {
|
|
118
266
|
return typeof x === "object" && x !== null && !Array.isArray(x);
|
|
119
267
|
}
|
|
@@ -165,9 +313,20 @@ function uniqueRows(value) {
|
|
|
165
313
|
export {
|
|
166
314
|
resultSchema,
|
|
167
315
|
readSchema,
|
|
316
|
+
performanceSchema,
|
|
317
|
+
performanceRpc,
|
|
318
|
+
performanceResultSchema,
|
|
319
|
+
performanceBatchSchema,
|
|
168
320
|
monitorRpc,
|
|
169
321
|
isResult,
|
|
170
322
|
isRead,
|
|
323
|
+
isPerformanceSnapshot,
|
|
324
|
+
isPerformanceResult,
|
|
325
|
+
isPerformanceBatch,
|
|
326
|
+
isHistoryResult,
|
|
327
|
+
isHistoryRead,
|
|
171
328
|
isBatch,
|
|
329
|
+
historyRpc,
|
|
330
|
+
historyReadSchema,
|
|
172
331
|
batchSchema
|
|
173
332
|
};
|