mirror of
https://github.com/murashit/codex-panel.git
synced 2026-07-22 06:57:10 +00:00
Flatten app-server domain adapters
This commit is contained in:
parent
5f948cab13
commit
0958dbb721
20 changed files with 79 additions and 81 deletions
|
|
@ -1,12 +1,12 @@
|
|||
import type { AppServerClient } from "../connection/client";
|
||||
import type { AppServerClient } from "./connection/client";
|
||||
import {
|
||||
appServerHookOperationFromHookItem,
|
||||
type CatalogModel,
|
||||
hookItemsFromCatalogHooks,
|
||||
modelMetadataFromCatalogModels,
|
||||
skillMetadataFromCatalogSkills,
|
||||
} from "../protocol/catalog";
|
||||
import type { HookItem, ModelMetadata, SkillMetadata } from "../../domain/catalog/metadata";
|
||||
} from "./protocol/catalog";
|
||||
import type { HookItem, ModelMetadata, SkillMetadata } from "../domain/catalog/metadata";
|
||||
|
||||
export interface HookData {
|
||||
hooks: HookItem[];
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
import { QueryClient, QueryObserver, type QueryObserverResult } from "@tanstack/query-core";
|
||||
|
||||
import type { AppServerClient } from "../connection/client";
|
||||
import { listModelMetadata } from "../catalog/data";
|
||||
import { listModelMetadata } from "../catalog";
|
||||
import { readRateLimitMetadataProbe, readSkillMetadataProbe } from "./metadata-probes";
|
||||
import { runtimeConfigSnapshotFromAppServerConfig } from "../protocol/runtime-config";
|
||||
import { listThreads } from "../threads/data";
|
||||
import { listThreads } from "../threads";
|
||||
import type { ModelMetadata } from "../../domain/catalog/metadata";
|
||||
import { createServerDiagnostics, diagnosticProbeError, diagnosticProbeOk, diagnosticsWithProbe } from "../../domain/server/diagnostics";
|
||||
import type { SharedServerMetadata } from "../../domain/server/metadata";
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import type { AppServerClient } from "../connection/client";
|
||||
import { accountRateLimitsSummaryFromResponse, rateLimitSnapshotFromAccountRateLimitsResponse } from "../protocol/runtime-metrics";
|
||||
import { listSkillCatalog } from "../catalog/data";
|
||||
import { listSkillCatalog } from "../catalog";
|
||||
import { diagnosticProbeError, diagnosticProbeOk, type Diagnostics } from "../../domain/server/diagnostics";
|
||||
import type { SkillMetadata } from "../../domain/catalog/metadata";
|
||||
import type { RateLimitSnapshot } from "../../domain/runtime/metrics";
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import {
|
|||
} from "../connection/client";
|
||||
import { abortablePromise, throwIfAbortSignalAborted } from "../../shared/lifecycle/abortable";
|
||||
import type { RequestId, ServerNotification } from "../connection/rpc-messages";
|
||||
import type { ModelMetadataClient } from "../catalog/data";
|
||||
import type { ModelMetadataClient } from "../catalog";
|
||||
import { lastAgentMessageTextFromTurnRecord, type TurnItem, type TurnRecord } from "../protocol/turn";
|
||||
|
||||
export type StructuredTurnOutputSchema = AppServerStartStructuredTurnOptions["outputSchema"];
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import type { RuntimeOverride, RuntimeOverrideSettings } from "../../domain/runtime/overrides";
|
||||
import { runtimeOverride, validatedRuntimeOverrideForModelMetadata } from "../../domain/runtime/overrides";
|
||||
import { listModelMetadata, type ModelMetadataClient } from "../catalog/data";
|
||||
import { listModelMetadata, type ModelMetadataClient } from "../catalog";
|
||||
|
||||
export async function resolvedRuntimeOverrideForClient(
|
||||
client: ModelMetadataClient,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import type { ArchiveExportAdapter, ArchiveExportSettings } from "../../domain/threads/archive-markdown";
|
||||
import type { AppServerClient } from "../connection/client";
|
||||
import { exportArchivedThreadMarkdown } from "./thread-archive-markdown";
|
||||
import { readThreadForArchiveExport } from "../threads/data";
|
||||
import { readThreadForArchiveExport } from "../threads";
|
||||
|
||||
export interface ArchiveThreadOptions {
|
||||
settings: ArchiveExportSettings;
|
||||
|
|
|
|||
|
|
@ -1,21 +1,21 @@
|
|||
import type { AppServerClient } from "../connection/client";
|
||||
import { appServerThreadGoalUserHistoryItem, threadGoalFromAppServerGoal } from "../protocol/thread-goal";
|
||||
import { threadFromThreadRecord, threadsFromThreadRecords, type ThreadRecord } from "../protocol/thread";
|
||||
import type { AppServerClient } from "./connection/client";
|
||||
import { appServerThreadGoalUserHistoryItem, threadGoalFromAppServerGoal } from "./protocol/thread-goal";
|
||||
import { threadFromThreadRecord, threadsFromThreadRecords, type ThreadRecord } from "./protocol/thread";
|
||||
import {
|
||||
chronologicalConversationSummariesFromTurnRecords,
|
||||
completedConversationSummariesFromTurnRecords,
|
||||
transcriptEntriesFromTurnRecords,
|
||||
} from "../protocol/turn";
|
||||
import { normalizeReasoningEffort } from "../../domain/catalog/metadata";
|
||||
import type { ActivePermissionProfile, ApprovalPolicy, ApprovalsReviewer, ServiceTier } from "../../domain/runtime/policy";
|
||||
import { parseServiceTier } from "../../domain/runtime/policy";
|
||||
import type { ArchiveThreadInput } from "../../domain/threads/archive-markdown";
|
||||
import type { ThreadActivationSnapshot } from "../../domain/threads/activation";
|
||||
import type { ThreadGoal, ThreadGoalUpdate } from "../../domain/threads/goal";
|
||||
import type { HistoricalTurn } from "../../domain/threads/history";
|
||||
import type { Thread } from "../../domain/threads/model";
|
||||
import { REFERENCED_THREAD_TURN_LIMIT } from "../../domain/threads/reference";
|
||||
import type { ThreadConversationSummary } from "../../domain/threads/transcript";
|
||||
} from "./protocol/turn";
|
||||
import { normalizeReasoningEffort } from "../domain/catalog/metadata";
|
||||
import type { ActivePermissionProfile, ApprovalPolicy, ApprovalsReviewer, ServiceTier } from "../domain/runtime/policy";
|
||||
import { parseServiceTier } from "../domain/runtime/policy";
|
||||
import type { ArchiveThreadInput } from "../domain/threads/archive-markdown";
|
||||
import type { ThreadActivationSnapshot } from "../domain/threads/activation";
|
||||
import type { ThreadGoal, ThreadGoalUpdate } from "../domain/threads/goal";
|
||||
import type { HistoricalTurn } from "../domain/threads/history";
|
||||
import type { Thread } from "../domain/threads/model";
|
||||
import { REFERENCED_THREAD_TURN_LIMIT } from "../domain/threads/reference";
|
||||
import type { ThreadConversationSummary } from "../domain/threads/transcript";
|
||||
|
||||
const THREAD_LIST_PAGE_LIMIT = 100;
|
||||
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import type { Thread } from "../../../../domain/threads/model";
|
||||
import { threadActivationSnapshotFromAppServerResponse } from "../../../../app-server/threads/data";
|
||||
import { threadActivationSnapshotFromAppServerResponse } from "../../../../app-server/threads";
|
||||
import type { RuntimeSnapshot } from "../../application/runtime/snapshot";
|
||||
import { runtimeConfigOrDefault } from "../../domain/runtime/effective";
|
||||
import { serviceTierRequestForThreadStart } from "../../application/runtime/thread-settings-update";
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { activeThreadSettingsAppliedAction } from "../../application/state/actions";
|
||||
import type { McpServerStartupStatus } from "../../../../domain/server/diagnostics";
|
||||
import { threadTokenUsageFromRuntimeUsage } from "../../../../domain/runtime/metrics";
|
||||
import { threadFromAppServerRecord } from "../../../../app-server/threads/data";
|
||||
import { threadFromAppServerRecord } from "../../../../app-server/threads";
|
||||
import { completedConversationSummaryFromTurnRecord, type TurnItem } from "../../../../app-server/protocol/turn";
|
||||
import type { ServerNotification } from "../../../../app-server/connection/rpc-messages";
|
||||
import { normalizeExplicitThreadName, type Thread } from "../../../../domain/threads/model";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import type { AppServerClient } from "../../../../app-server/connection/client";
|
||||
import { threadActivationSnapshotFromAppServerResponse } from "../../../../app-server/threads/data";
|
||||
import { threadActivationSnapshotFromAppServerResponse } from "../../../../app-server/threads";
|
||||
import type { ThreadActivationSnapshot } from "../../../../domain/threads/activation";
|
||||
import type { ChatThreadHistoryPage } from "./history";
|
||||
import { chatThreadHistoryPageFromTurnsPage } from "./history";
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import type { AppServerClient } from "../../../../app-server/connection/client";
|
||||
import { codexTextInputWithAttachments, type CodexInput } from "../../../../domain/chat/input";
|
||||
import { readReferencedThreadConversationSummaries } from "../../../../app-server/threads/data";
|
||||
import { readReferencedThreadConversationSummaries } from "../../../../app-server/threads";
|
||||
import { referencedThreadPromptBundle, REFERENCED_THREAD_TURN_LIMIT } from "../../../../domain/threads/reference";
|
||||
import type { Thread } from "../../../../domain/threads/model";
|
||||
import { shortThreadId } from "../../../../utils";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import type { AppServerClient } from "../../../../app-server/connection/client";
|
||||
import { readThreadGoal, recordThreadGoalUserMessage, setThreadGoal } from "../../../../app-server/threads/data";
|
||||
import { readThreadGoal, recordThreadGoalUserMessage, setThreadGoal } from "../../../../app-server/threads";
|
||||
import type { ThreadGoal, ThreadGoalStatus, ThreadGoalUpdate } from "../../../../domain/threads/goal";
|
||||
import type { ChatStateStore } from "../state/store";
|
||||
import type { GoalMessageStreamItem } from "../../domain/message-stream/items";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import type { AppServerClient } from "../../../../app-server/connection/client";
|
||||
import { forkThread as forkThreadOnAppServer, rollbackThread as rollbackThreadOnAppServer } from "../../../../app-server/threads/data";
|
||||
import { forkThread as forkThreadOnAppServer, rollbackThread as rollbackThreadOnAppServer } from "../../../../app-server/threads";
|
||||
import { inheritedForkThreadName, type Thread } from "../../../../domain/threads/model";
|
||||
import type { ThreadOperations } from "../../../threads/thread-operations";
|
||||
import { messageStreamItemsFromTurns } from "../../app-server/mappers/message-stream/turn-items";
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import type { AppServerClient } from "../../app-server/connection/client";
|
||||
import { generateThreadTitleWithCodex } from "../../app-server/services/thread-title-generation";
|
||||
import { readCompletedConversationSummariesPage } from "../../app-server/threads/data";
|
||||
import { readCompletedConversationSummariesPage } from "../../app-server/threads";
|
||||
import type { ThreadConversationSummary } from "../../domain/threads/transcript";
|
||||
import {
|
||||
findThreadTitleContext,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import type { AppServerClient } from "../app-server/connection/client";
|
||||
import { listHookData, type HookData } from "../app-server/catalog/data";
|
||||
import { listThreads } from "../app-server/threads/data";
|
||||
import { listHookData, type HookData } from "../app-server/catalog";
|
||||
import { listThreads } from "../app-server/threads";
|
||||
import type { Thread } from "../domain/threads/model";
|
||||
import { errorMessage } from "../utils";
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ import type { AppServerClient } from "../app-server/connection/client";
|
|||
import type { AppServerObservedQueryResult } from "../app-server/query/cache";
|
||||
import { isStaleAppServerSharedQueryContextError } from "../app-server/query/shared-queries";
|
||||
import { withShortLivedAppServerClient } from "../app-server/connection/short-lived-client";
|
||||
import { setHookItemEnabled, trustHookItem } from "../app-server/catalog/data";
|
||||
import { restoreArchivedThread as restoreArchivedThreadOnAppServer } from "../app-server/threads/data";
|
||||
import { setHookItemEnabled, trustHookItem } from "../app-server/catalog";
|
||||
import { restoreArchivedThread as restoreArchivedThreadOnAppServer } from "../app-server/threads";
|
||||
import type { AppServerSharedQueries } from "../app-server/query/shared-queries";
|
||||
import type { HookItem, ModelMetadata, ReasoningEffort } from "../domain/catalog/metadata";
|
||||
import { findModelMetadataByIdOrName, sortedModelMetadata, supportedEffortsForModelMetadata } from "../domain/catalog/metadata";
|
||||
|
|
|
|||
|
|
@ -1,44 +0,0 @@
|
|||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import type { AppServerClient } from "../../src/app-server/connection/client";
|
||||
import { listHookData, listSkillCatalog } from "../../src/app-server/catalog/data";
|
||||
|
||||
describe("app-server catalog data adapters", () => {
|
||||
it("returns enabled skill options while preserving total app-server skill count", async () => {
|
||||
const client = {
|
||||
listSkills: vi.fn().mockResolvedValue({
|
||||
data: [
|
||||
{
|
||||
cwd: "/vault",
|
||||
skills: [
|
||||
{ name: "enabled", description: "Enabled skill", path: "/skills/enabled", scope: "repo", enabled: true },
|
||||
{ name: "disabled", description: "Disabled skill", path: "/skills/disabled", scope: "repo", enabled: false },
|
||||
],
|
||||
},
|
||||
],
|
||||
}),
|
||||
} as unknown as AppServerClient;
|
||||
|
||||
await expect(listSkillCatalog(client, "/vault")).resolves.toMatchObject({
|
||||
skills: [{ name: "enabled", description: "Enabled skill", path: "/skills/enabled", enabled: true }],
|
||||
totalCount: 2,
|
||||
});
|
||||
});
|
||||
|
||||
it("uses only hook rows for the requested cwd", async () => {
|
||||
const client = {
|
||||
listHooks: vi.fn().mockResolvedValue({
|
||||
data: [
|
||||
{ cwd: "/other", hooks: [{ key: "other" }], warnings: ["skip"], errors: [{ message: "skip" }] },
|
||||
{ cwd: "/vault", hooks: [{ key: "vault" }], warnings: ["warn"], errors: [{ message: "err" }] },
|
||||
],
|
||||
}),
|
||||
} as unknown as AppServerClient;
|
||||
|
||||
await expect(listHookData(client, "/vault")).resolves.toMatchObject({
|
||||
hooks: [{ key: "vault" }],
|
||||
warnings: ["warn"],
|
||||
errors: ['{"message":"err"}'],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
import { describe, expect, it } from "vitest";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import type { AppServerClient } from "../../src/app-server/connection/client";
|
||||
import { listHookData, listSkillCatalog } from "../../src/app-server/catalog";
|
||||
import {
|
||||
appServerHookOperationFromHookItem,
|
||||
hookItemsFromCatalogHooks,
|
||||
|
|
@ -78,6 +80,46 @@ describe("app-server catalog mappers", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("app-server catalog adapters", () => {
|
||||
it("returns enabled skill options while preserving total app-server skill count", async () => {
|
||||
const client = {
|
||||
listSkills: vi.fn().mockResolvedValue({
|
||||
data: [
|
||||
{
|
||||
cwd: "/vault",
|
||||
skills: [
|
||||
{ name: "enabled", description: "Enabled skill", path: "/skills/enabled", scope: "repo", enabled: true },
|
||||
{ name: "disabled", description: "Disabled skill", path: "/skills/disabled", scope: "repo", enabled: false },
|
||||
],
|
||||
},
|
||||
],
|
||||
}),
|
||||
} as unknown as AppServerClient;
|
||||
|
||||
await expect(listSkillCatalog(client, "/vault")).resolves.toMatchObject({
|
||||
skills: [{ name: "enabled", description: "Enabled skill", path: "/skills/enabled", enabled: true }],
|
||||
totalCount: 2,
|
||||
});
|
||||
});
|
||||
|
||||
it("uses only hook rows for the requested cwd", async () => {
|
||||
const client = {
|
||||
listHooks: vi.fn().mockResolvedValue({
|
||||
data: [
|
||||
{ cwd: "/other", hooks: [{ key: "other" }], warnings: ["skip"], errors: [{ message: "skip" }] },
|
||||
{ cwd: "/vault", hooks: [{ key: "vault" }], warnings: ["warn"], errors: [{ message: "err" }] },
|
||||
],
|
||||
}),
|
||||
} as unknown as AppServerClient;
|
||||
|
||||
await expect(listHookData(client, "/vault")).resolves.toMatchObject({
|
||||
hooks: [{ key: "vault" }],
|
||||
warnings: ["warn"],
|
||||
errors: ['{"message":"err"}'],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function modelFixture(): Model {
|
||||
return {
|
||||
id: "gpt-5.5-id",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { threadActivationSnapshotFromAppServerResponse } from "../../src/app-server/threads/data";
|
||||
import { threadActivationSnapshotFromAppServerResponse } from "../../src/app-server/threads";
|
||||
import type { ThreadResumeResponse } from "../../src/generated/app-server/v2/ThreadResumeResponse";
|
||||
import type { Thread as ThreadRecord } from "../../src/generated/app-server/v2/Thread";
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import type { AppServerClient } from "../../src/app-server/connection/client";
|
||||
import { listThreads } from "../../src/app-server/threads/data";
|
||||
import { listThreads } from "../../src/app-server/threads";
|
||||
|
||||
describe("app-server thread data adapters", () => {
|
||||
it("maps listed threads to domain threads with archive state", async () => {
|
||||
Loading…
Reference in a new issue