mirror of
https://github.com/getpaseo/paseo.git
synced 2026-07-29 12:01:31 +00:00
Add oxlint-tsgolint and configure typescript/no-unnecessary-type-assertion to flag redundant `!` and `as Foo` casts. Type-aware mode is left off by default to keep `npm run lint` fast; the rule sits configured for when we turn type-aware on intentionally. Auto-fix removed ~283 redundant casts; two manual touch-ups: a real tsgolint false positive in split-container.tsx and a stale ChildProcess import after a double-cast collapsed.
58 lines
1.9 KiB
TypeScript
58 lines
1.9 KiB
TypeScript
import type { AgentSnapshotPayload } from "@server/shared/messages";
|
|
import type { AgentPermissionRequest } from "@server/server/agent/agent-sdk-types";
|
|
|
|
export function derivePendingPermissionKey(
|
|
agentId: string,
|
|
request: AgentPermissionRequest,
|
|
): string {
|
|
const fallbackId =
|
|
request.id ||
|
|
(typeof request.metadata?.id === "string" ? request.metadata.id : undefined) ||
|
|
request.name ||
|
|
request.title ||
|
|
`${request.kind}:${JSON.stringify(request.input ?? request.metadata ?? {})}`;
|
|
|
|
return `${agentId}:${fallbackId}`;
|
|
}
|
|
|
|
export function normalizeAgentSnapshot(snapshot: AgentSnapshotPayload, serverId: string) {
|
|
const createdAt = new Date(snapshot.createdAt);
|
|
const updatedAt = new Date(snapshot.updatedAt);
|
|
const lastUserMessageAt = snapshot.lastUserMessageAt
|
|
? new Date(snapshot.lastUserMessageAt)
|
|
: null;
|
|
const attentionTimestamp = snapshot.attentionTimestamp
|
|
? new Date(snapshot.attentionTimestamp)
|
|
: null;
|
|
const archivedAt = snapshot.archivedAt ? new Date(snapshot.archivedAt) : null;
|
|
|
|
return {
|
|
serverId,
|
|
id: snapshot.id,
|
|
provider: snapshot.provider,
|
|
status: snapshot.status,
|
|
createdAt,
|
|
updatedAt,
|
|
lastUserMessageAt,
|
|
lastActivityAt: updatedAt,
|
|
capabilities: snapshot.capabilities,
|
|
currentModeId: snapshot.currentModeId,
|
|
availableModes: snapshot.availableModes ?? [],
|
|
pendingPermissions: snapshot.pendingPermissions ?? [],
|
|
persistence: snapshot.persistence ?? null,
|
|
runtimeInfo: snapshot.runtimeInfo,
|
|
lastUsage: snapshot.lastUsage,
|
|
lastError: snapshot.lastError ?? null,
|
|
title: snapshot.title ?? null,
|
|
cwd: snapshot.cwd,
|
|
model: snapshot.model ?? null,
|
|
features: snapshot.features,
|
|
thinkingOptionId: snapshot.thinkingOptionId ?? null,
|
|
requiresAttention: snapshot.requiresAttention ?? false,
|
|
attentionReason: snapshot.attentionReason ?? null,
|
|
attentionTimestamp,
|
|
archivedAt,
|
|
labels: snapshot.labels,
|
|
};
|
|
}
|