feat(ql3): observe package installations in console

This commit is contained in:
whyour
2026-08-20 14:42:54 +08:00
parent 344680d64a
commit ffa4b4e7cb
29 changed files with 1259 additions and 36 deletions
@@ -16,6 +16,8 @@ export const CLUSTER_COPILOT_CONSOLE_READ_OPERATIONS = Object.freeze([
'run_cancellation_inspect',
'worker_list',
'worker_inspect',
'package_list',
'package_inspect',
'run_list',
'run_read',
'run_event_list',
@@ -51,6 +53,9 @@ export type ClusterCopilotConsoleReadRequest =
| (BaseReadRequest<'worker_list'> &
Readonly<{ afterWorkerId: string | null }>)
| (BaseReadRequest<'worker_inspect'> & Readonly<{ workerId: string }>)
| (BaseReadRequest<'package_list'> &
Readonly<{ afterPackageName: string | null }>)
| (BaseReadRequest<'package_inspect'> & Readonly<{ packageName: string }>)
| (BaseReadRequest<'run_list'> &
Readonly<{
afterCreatedAtMs: number | null;
@@ -267,6 +272,33 @@ export function normalizeClusterCopilotConsoleReadRequest(
workerId: record.workerId,
});
}
if (op === 'package_list') {
exact(record, op, ['afterPackageName']);
if (
record.afterPackageName !== null &&
(typeof record.afterPackageName !== 'string' ||
!PACKAGE_NAME.test(record.afterPackageName))
)
invalid();
return Object.freeze({
...common(record),
operation: op,
afterPackageName: record.afterPackageName as string | null,
});
}
if (op === 'package_inspect') {
exact(record, op, ['packageName']);
if (
typeof record.packageName !== 'string' ||
!PACKAGE_NAME.test(record.packageName)
)
invalid();
return Object.freeze({
...common(record),
operation: op,
packageName: record.packageName,
});
}
if (op === 'run_list') {
exact(record, op, ['afterCreatedAtMs', 'afterRunId', 'limit']);
if (
@@ -502,7 +534,9 @@ export function clusterCopilotConsoleProjectReadPath(
normalized.operation === 'run_cancellation_blocked_list' ||
normalized.operation === 'run_cancellation_inspect' ||
normalized.operation === 'worker_list' ||
normalized.operation === 'worker_inspect'
normalized.operation === 'worker_inspect' ||
normalized.operation === 'package_list' ||
normalized.operation === 'package_inspect'
)
invalid();
const project = '/api/v3/projects/' + encoded(normalized.projectId);