mirror of
https://github.com/murashit/codex-panel.git
synced 2026-07-22 06:57:10 +00:00
Move auto-review permission rows to app-server mapper
This commit is contained in:
parent
5a1d55de22
commit
7be9a1de24
3 changed files with 14 additions and 18 deletions
|
|
@ -1,21 +1,17 @@
|
|||
import { jsonPreview } from "../../../../../domain/display/json-preview";
|
||||
import type { MessageStreamAuditFact } from "../../../domain/message-stream/items";
|
||||
|
||||
interface DetailRow {
|
||||
key: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface MessageStreamPermissionProfile {
|
||||
export interface AutoReviewPermissionProfile {
|
||||
network?: { enabled?: boolean | null } | null;
|
||||
fileSystem?: {
|
||||
entries?: readonly { path: MessageStreamFileSystemPath; access?: unknown }[] | null;
|
||||
entries?: readonly { path: AutoReviewFileSystemPath; access?: unknown }[] | null;
|
||||
read?: unknown;
|
||||
write?: unknown;
|
||||
globScanMaxDepth?: unknown;
|
||||
} | null;
|
||||
}
|
||||
|
||||
type MessageStreamFileSystemPath =
|
||||
type AutoReviewFileSystemPath =
|
||||
| { type: "path"; path: string }
|
||||
| { type: "glob_pattern"; pattern: string }
|
||||
| {
|
||||
|
|
@ -26,8 +22,8 @@ type MessageStreamFileSystemPath =
|
|||
| { kind: string };
|
||||
};
|
||||
|
||||
export function permissionRows(permissions: MessageStreamPermissionProfile): DetailRow[] {
|
||||
const rows: DetailRow[] = [];
|
||||
export function autoReviewPermissionRows(permissions: AutoReviewPermissionProfile): MessageStreamAuditFact[] {
|
||||
const rows: MessageStreamAuditFact[] = [];
|
||||
const networkEnabled = permissions.network?.enabled;
|
||||
if (typeof networkEnabled === "boolean") {
|
||||
rows.push({ key: "network", value: networkEnabled ? "enabled" : "disabled" });
|
||||
|
|
@ -49,7 +45,7 @@ export function permissionRows(permissions: MessageStreamPermissionProfile): Det
|
|||
return rows;
|
||||
}
|
||||
|
||||
function addOptional(rows: DetailRow[], key: string, value: unknown): void {
|
||||
function addOptional(rows: MessageStreamAuditFact[], key: string, value: unknown): void {
|
||||
if (value === null || value === undefined) return;
|
||||
if (Array.isArray(value) && value.length === 0) return;
|
||||
rows.push({ key, value: stringValue(value) });
|
||||
|
|
@ -65,7 +61,7 @@ function stringValue(value: unknown, fallback = ""): string {
|
|||
return jsonPreview(value);
|
||||
}
|
||||
|
||||
function fileSystemPathLabel(path: MessageStreamFileSystemPath): string {
|
||||
function fileSystemPathLabel(path: AutoReviewFileSystemPath): string {
|
||||
if (path.type === "path") return path.path;
|
||||
if (path.type === "glob_pattern") return path.pattern;
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import { pathRelativeToRoot } from "../../../../../domain/vault/paths";
|
||||
import { permissionRows } from "../../../domain/message-stream/format/permission-rows";
|
||||
import type { ExecutionState, MessageStreamAuditFact, MessageStreamItem } from "../../../domain/message-stream/items";
|
||||
import { type ExecutionStateByStatus, executionStateFromStatus, RUNNING_EXECUTION_STATE } from "./execution-state";
|
||||
import { type AutoReviewPermissionProfile, autoReviewPermissionRows } from "./permission-rows";
|
||||
|
||||
const AUTO_REVIEW_STATES: ExecutionStateByStatus = {
|
||||
inProgress: RUNNING_EXECUTION_STATE,
|
||||
|
|
@ -48,7 +48,7 @@ type AutoReviewAction =
|
|||
connectorName: string | null;
|
||||
toolTitle: string | null;
|
||||
}
|
||||
| { type: "requestPermissions"; reason: string | null; permissions: Parameters<typeof permissionRows>[0] };
|
||||
| { type: "requestPermissions"; reason: string | null; permissions: AutoReviewPermissionProfile };
|
||||
|
||||
export function createReviewResultItem(id: string, text: string): MessageStreamItem {
|
||||
const parsed = parseAutomaticApprovalReviewMessage(text);
|
||||
|
|
@ -174,7 +174,7 @@ function autoReviewActionRows(action: AutoReviewAction): MessageStreamAuditFact[
|
|||
return [
|
||||
{ key: "action", value: "request permissions" },
|
||||
...(action.reason ? [{ key: "reason", value: action.reason }] : []),
|
||||
...permissionRows(action.permissions),
|
||||
...autoReviewPermissionRows(action.permissions),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import { referencedThreadPromptBundle } from "../../../../../src/domain/threads/
|
|||
import { pathRelativeToRoot } from "../../../../../src/domain/vault/paths";
|
||||
import { collabAgentStateExecutionState } from "../../../../../src/features/chat/app-server/mappers/message-stream/execution-state";
|
||||
import { hookRunMessageStreamItem } from "../../../../../src/features/chat/app-server/mappers/message-stream/hook-run-items";
|
||||
import { autoReviewPermissionRows } from "../../../../../src/features/chat/app-server/mappers/message-stream/permission-rows";
|
||||
import {
|
||||
createAutoReviewResultItem,
|
||||
createReviewResultItem,
|
||||
|
|
@ -14,7 +15,6 @@ import {
|
|||
messageStreamItemFromTurnItem,
|
||||
messageStreamItemsFromTurns,
|
||||
} from "../../../../../src/features/chat/app-server/mappers/message-stream/turn-items";
|
||||
import { permissionRows } from "../../../../../src/features/chat/domain/message-stream/format/permission-rows";
|
||||
import type { MessageStreamItem } from "../../../../../src/features/chat/domain/message-stream/items";
|
||||
import { activeTurnLiveItems } from "../../../../../src/features/chat/domain/message-stream/semantics/active-turn";
|
||||
import { upsertMessageStreamItemById } from "../../../../../src/features/chat/domain/message-stream/updates";
|
||||
|
|
@ -754,10 +754,10 @@ describe("turn item conversion preserves app-server semantics", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("permission detail rows", () => {
|
||||
describe("auto-review permission detail rows", () => {
|
||||
it("formats app-server permission paths without exposing raw payloads", () => {
|
||||
expect(
|
||||
permissionRows({
|
||||
autoReviewPermissionRows({
|
||||
network: { enabled: true },
|
||||
fileSystem: {
|
||||
entries: [
|
||||
|
|
|
|||
Loading…
Reference in a new issue