Prune redundant internal helper exports

This commit is contained in:
murashit 2026-06-21 14:22:16 +09:00
parent caf76c8ef8
commit fe7f63e669
28 changed files with 71 additions and 103 deletions

View file

@ -1,6 +1,6 @@
import { AppServerClient } from "./client";
export interface ShortLivedAppServerClientOptions {
interface ShortLivedAppServerClientOptions {
unhandledServerRequestMessage?: string;
}

View file

@ -1,5 +1,5 @@
import { normalizeReasoningEffort } from "../../domain/catalog/metadata";
import { approvalPolicyOrNull, approvalsReviewerOrNull, parseServiceTier } from "../../domain/runtime/policy";
import { normalizedRuntimeReasoningEffort } from "../../domain/runtime/config";
import type { ReasoningSummary, SandboxMode, RuntimeConfigSnapshot, Verbosity, WebSearchMode } from "../../domain/runtime/config";
interface ConfigLayerRecord {
@ -24,7 +24,7 @@ export function runtimeConfigSnapshotFromAppServerConfig(response: ConfigReadRes
profile: selectedConfigProfile(response.layers),
model: nonEmptyStringOrNull(config["model"]),
modelProvider: nonEmptyStringOrNull(config["model_provider"]),
reasoningEffort: normalizedRuntimeReasoningEffort(effort),
reasoningEffort: normalizeReasoningEffort(effort),
rawReasoningEffort: nonEmptyStringOrNull(effort),
reasoningSummary: reasoningSummaryOrNull(config["model_reasoning_summary"]),
verbosity: verbosityOrNull(config["model_verbosity"]),

View file

@ -35,9 +35,7 @@ export interface EphemeralStructuredTurnClient {
startStructuredTurn(options: AppServerStartStructuredTurnOptions): Promise<{ turn: TurnRecord }>;
}
export type EphemeralStructuredTurnRuntimeClient = ModelMetadataClient;
type EphemeralStructuredTurnRuntimeCapableClient = EphemeralStructuredTurnClient & EphemeralStructuredTurnRuntimeClient;
type EphemeralStructuredTurnRuntimeCapableClient = EphemeralStructuredTurnClient & ModelMetadataClient;
export type EphemeralStructuredTurnClientFactory = (
codexPath: string,
@ -58,7 +56,7 @@ export interface RunEphemeralStructuredTurnOptions {
timedOutMessage: string;
abortMessage?: string;
runtime?: StructuredTurnRuntimeOverride | undefined;
resolveRuntime?: ((client: EphemeralStructuredTurnRuntimeClient) => Promise<StructuredTurnRuntimeOverride>) | undefined;
resolveRuntime?: ((client: ModelMetadataClient) => Promise<StructuredTurnRuntimeOverride>) | undefined;
signal?: AbortSignal | undefined;
onProgress?: (event: StructuredTurnProgressEvent) => void;
clientFactory?: EphemeralStructuredTurnClientFactory | undefined;

View file

@ -1,10 +1,9 @@
import {
runEphemeralStructuredTurn,
type EphemeralStructuredTurnClient,
type EphemeralStructuredTurnClientFactory,
type EphemeralStructuredTurnRuntimeClient,
type StructuredTurnOutputSchema,
} from "./ephemeral-structured-turn";
import type { ModelMetadataClient } from "../catalog";
import { resolvedRuntimeOverrideForClient } from "./runtime-overrides";
import { conversationAssistantTextFromTurnRecord, type TurnRecord } from "../protocol/turn";
import type { ReasoningEffort } from "../../domain/catalog/metadata";
@ -39,15 +38,12 @@ export interface ThreadTitleRuntimeSettings {
threadNamingEffort: ReasoningEffort | null;
}
export type ThreadTitleClient = EphemeralStructuredTurnClient;
export type ThreadTitleClientFactory = EphemeralStructuredTurnClientFactory;
export async function generateThreadTitleWithCodex(
codexPath: string,
cwd: string,
context: ThreadTitleContext,
runtimeSettings: ThreadTitleRuntimeSettings,
clientFactory?: ThreadTitleClientFactory,
clientFactory?: EphemeralStructuredTurnClientFactory,
): Promise<string | null> {
const turn = await runEphemeralStructuredTurn({
codexPath,
@ -71,6 +67,6 @@ function threadTitleFromGenerationTurn(turn: TurnRecord): string | null {
return response ? threadTitleFromGeneratedText(response) : null;
}
async function threadTitleRuntimeOverrideForClient(client: EphemeralStructuredTurnRuntimeClient, settings: ThreadTitleRuntimeSettings) {
async function threadTitleRuntimeOverrideForClient(client: ModelMetadataClient, settings: ThreadTitleRuntimeSettings) {
return resolvedRuntimeOverrideForClient(client, { model: settings.threadNamingModel, effort: settings.threadNamingEffort });
}

View file

@ -1,4 +1,4 @@
import { normalizeReasoningEffort, type ReasoningEffort } from "../catalog/metadata";
import type { ReasoningEffort } from "../catalog/metadata";
import { cloneApprovalPolicy, type ApprovalPolicy, type ApprovalsReviewer, type ServiceTier } from "./policy";
export type ReasoningSummary = "auto" | "concise" | "detailed" | "none";
@ -60,10 +60,6 @@ export function cloneRuntimeConfigSnapshot(config: RuntimeConfigSnapshot): Runti
};
}
export function normalizedRuntimeReasoningEffort(value: unknown): ReasoningEffort | null {
return normalizeReasoningEffort(value);
}
function cloneJsonLike(value: unknown): unknown {
if (Array.isArray(value)) return value.map(cloneJsonLike);
if (!value || typeof value !== "object") return value;

View file

@ -1,6 +1,6 @@
import type { Thread } from "../../../../domain/threads/model";
import { threadActivationSnapshotFromAppServerResponse } from "../../../../app-server/threads";
import type { RuntimeSnapshot } from "../../application/runtime/snapshot";
import type { RuntimeSnapshot } from "../../domain/runtime/snapshot";
import { runtimeConfigOrDefault } from "../../domain/runtime/effective";
import { serviceTierRequestForThreadStart } from "../../application/runtime/thread-settings-update";
import { resumedThreadAction } from "../../application/state/actions";

View file

@ -8,7 +8,7 @@ import {
pendingRuntimeSettingsPatch as buildPendingRuntimeSettingsPatch,
type PendingRuntimeSettingsPatch,
} from "./thread-settings-update";
import type { RuntimeSnapshot } from "./snapshot";
import type { RuntimeSnapshot } from "../../domain/runtime/snapshot";
import { nextCollaborationMode, type CollaborationMode, type RequestedServiceTier } from "../../domain/runtime/pending-settings";
import type { ChatAction, ChatState } from "../state/root-reducer";
import type { ChatStateStore } from "../state/store";

View file

@ -3,8 +3,6 @@ import type { MessageStreamItem } from "../../domain/message-stream/items";
import type { RuntimeSnapshot } from "../../domain/runtime/snapshot";
import { messageStreamItems } from "../state/message-stream";
export type { RuntimeSnapshot } from "../../domain/runtime/snapshot";
interface RuntimeSnapshotInput {
runtimeConfig: ChatState["connection"]["runtimeConfig"];
activeThread: Pick<ChatState["activeThread"], "id" | "tokenUsage">;

View file

@ -1,7 +1,8 @@
import { upsertMessageStreamItemById } from "../../domain/message-stream/updates";
import type { MessageStreamItem, MessageStreamMessageItem } from "../../domain/message-stream/items";
import { normalizeProposedPlanMarkdown } from "../../domain/message-stream/format/proposed-plan";
import { messageStreamIsTurnInitiator, messageStreamSemanticClassifications } from "../../domain/message-stream/semantics";
import { messageStreamSemanticClassifications } from "../../domain/message-stream/semantics/classify";
import { messageStreamIsTurnInitiator } from "../../domain/message-stream/semantics/predicates";
import {
streamedItemOutputMessageStreamItem,
streamedTextMessageStreamItem,

View file

@ -1,5 +1,5 @@
import type { MessageStreamItem } from "./items";
import { messageStreamSemanticClassifications } from "./semantics";
import { messageStreamSemanticClassifications } from "./semantics/classify";
export interface ForkCandidate {
itemId: string;

View file

@ -1,9 +0,0 @@
export { messageStreamSemanticClassifications } from "./classify";
export {
messageStreamIsAutoReviewDecision,
messageStreamIsCoordinationProgress,
messageStreamIsTurnInitiator,
messageStreamIsTurnSteer,
messageStreamIsWorkspaceResult,
} from "./predicates";
export type { MessageStreamSemanticClassification } from "./types";

View file

@ -1,4 +1,5 @@
import { messageStreamIsTurnInitiator, messageStreamSemanticClassifications } from "./semantics";
import { messageStreamSemanticClassifications } from "./semantics/classify";
import { messageStreamIsTurnInitiator } from "./semantics/predicates";
import type { MessageStreamFileChange, MessageStreamItem } from "./items";
export function upsertMessageStreamItemById(items: readonly MessageStreamItem[], next: MessageStreamItem): MessageStreamItem[] {

View file

@ -64,7 +64,7 @@ import { connectionDiagnosticSectionsModel } from "../application/connection/dia
import { toolInventoryDiagnosticSections } from "../application/connection/tool-inventory-display";
import { createStructuredSystemItem, createSystemItem } from "../domain/message-stream/factories/system-items";
import { createLocalIdSource, type LocalIdSource } from "../../../shared/id/local-id";
import type { RuntimeSnapshot } from "../application/runtime/snapshot";
import type { RuntimeSnapshot } from "../domain/runtime/snapshot";
import type { ChatPanelEnvironment } from "./runtime";
import { createConnectionBundle, type ChatPanelConnectionBundle, type CurrentAppServerClient } from "./connection-bundle";
import { VaultNoteCandidateProvider } from "../panel/vault-note-candidate-provider";

View file

@ -13,7 +13,7 @@ import { contextSummary } from "../../presentation/runtime/status";
import { compactReasoningEffortLabel } from "../../presentation/runtime/messages";
import { sortedModelMetadata } from "../../../../domain/catalog/metadata";
import type { ReasoningEffort } from "../../../../domain/catalog/metadata";
import type { RuntimeSnapshot } from "../../application/runtime/snapshot";
import type { RuntimeSnapshot } from "../../domain/runtime/snapshot";
import { ComposerShell, type ComposerShellProps } from "../../ui/composer";
import { composerStateFromShellState, useChatPanelShellState, type ChatPanelComposerShellState } from "../shell-state";
import { explicitThreadName } from "../../../../domain/threads/model";

View file

@ -1,5 +1,5 @@
import { messageStreamItems } from "../../application/state/message-stream";
import type { RuntimeSnapshot } from "../../application/runtime/snapshot";
import type { RuntimeSnapshot } from "../../domain/runtime/snapshot";
import { runtimeSnapshotForChatSlices } from "../../application/runtime/snapshot";
import type { ChatPanelComposerShellState, ChatPanelToolbarShellState } from "../shell-state";

View file

@ -6,7 +6,7 @@ import { getThreadTitle } from "../../../../domain/threads/model";
import { rateLimitSummary } from "../../presentation/runtime/status";
import { connectionDiagnosticSectionsModel } from "../../application/connection/diagnostics-display";
import { toolInventoryDiagnosticSections } from "../../application/connection/tool-inventory-display";
import type { RuntimeSnapshot } from "../../application/runtime/snapshot";
import type { RuntimeSnapshot } from "../../domain/runtime/snapshot";
import { chatTurnBusy, type ChatState } from "../../application/state/root-reducer";
import { toolbarStateFromShellState, useChatPanelShellState, type ChatPanelToolbarShellState } from "../shell-state";
import { Toolbar, type ToolbarActions, type ToolbarThreadRow, type ToolbarViewModel } from "../../ui/toolbar";

View file

@ -1,13 +1,13 @@
import type { MessageStreamItem } from "../../domain/message-stream/items";
import { pathRelativeToRoot } from "../../domain/message-stream/format/path-labels";
import { messageStreamSemanticClassifications } from "../../domain/message-stream/semantics/classify";
import {
messageStreamIsAutoReviewDecision,
messageStreamIsTurnInitiator,
messageStreamIsTurnSteer,
messageStreamIsWorkspaceResult,
messageStreamSemanticClassifications,
} from "../../domain/message-stream/semantics";
import type { MessageStreamSemanticClassification } from "../../domain/message-stream/semantics";
} from "../../domain/message-stream/semantics/predicates";
import type { MessageStreamSemanticClassification } from "../../domain/message-stream/semantics/types";
const STEERING_ACTIVITY_LABEL = "steer";

View file

@ -1,27 +0,0 @@
import type { MessageStreamSemanticClassification } from "../../domain/message-stream/semantics";
export type MessageStreamRenderFamily = "text" | "detail" | "status";
export function messageStreamRenderFamily(classification: MessageStreamSemanticClassification): MessageStreamRenderFamily {
switch (classification.item.kind) {
case "message":
case "system":
case "userInputResult":
return "text";
case "command":
case "fileChange":
case "tool":
case "hook":
case "goal":
case "approvalResult":
case "reviewResult":
case "agent":
return "detail";
case "taskProgress":
case "reasoning":
case "wait":
case "contextCompaction":
return "status";
}
return "status";
}

View file

@ -12,12 +12,10 @@ export interface MessageStreamForkTarget {
turnId: string;
}
export type MessageStreamPlanImplementationTarget = PlanImplementationTarget;
export interface MessageStreamTextActionTargets {
fork?: MessageStreamForkTarget;
rollback?: true;
implementPlan?: MessageStreamPlanImplementationTarget;
implementPlan?: PlanImplementationTarget;
}
export interface ReferencedThreadTextView {

View file

@ -1,12 +1,9 @@
import {
messageStreamIsCoordinationProgress,
messageStreamSemanticClassifications,
type MessageStreamSemanticClassification,
} from "../../domain/message-stream/semantics";
import { messageStreamSemanticClassifications } from "../../domain/message-stream/semantics/classify";
import { messageStreamIsCoordinationProgress } from "../../domain/message-stream/semantics/predicates";
import type { MessageStreamSemanticClassification } from "../../domain/message-stream/semantics/types";
import type { AgentRunSummary, MessageStreamItem, TaskProgressMessageStreamItem } from "../../domain/message-stream/items";
import { messageStreamLayoutBlocks, type MessageStreamItemAnnotations, type MessageStreamLayoutBlock } from "./layout";
import { detailView, type DetailView } from "./detail-view";
import { messageStreamRenderFamily } from "./render-family";
import { messageStreamTextView, type MessageStreamTextActionTargets, type MessageStreamTextView } from "./text-view";
import {
activeAgentRunSummary,
@ -74,6 +71,7 @@ type MessageStreamPresentationBlock =
};
type MessageStreamPresentationBlockSource = (input: MessageStreamPresentationBlockInput) => readonly MessageStreamPresentationBlock[];
type MessageStreamRenderFamily = "text" | "detail" | "status";
export type MessageStreamRenderedItemView =
| {
@ -310,6 +308,30 @@ function messageStreamRenderedItemView(
}
}
function messageStreamRenderFamily(classification: MessageStreamSemanticClassification): MessageStreamRenderFamily {
switch (classification.item.kind) {
case "message":
case "system":
case "userInputResult":
return "text";
case "command":
case "fileChange":
case "tool":
case "hook":
case "goal":
case "approvalResult":
case "reviewResult":
case "agent":
return "detail";
case "taskProgress":
case "reasoning":
case "wait":
case "contextCompaction":
return "status";
}
return "status";
}
function statusViewContext(input: MessageStreamPresentationBlockInput): Parameters<typeof messageStreamStatusView>[1] {
return {
activeTurnId: input.activeTurnId,

View file

@ -17,7 +17,7 @@ export interface PendingRequestBlockSnapshot {
approvalDetails: ReadonlySet<string>;
}
export interface PendingRequestBlockSnapshotSource {
interface PendingRequestBlockSnapshotSource {
approvals: readonly PendingApproval[];
pendingUserInputs: readonly PendingUserInput[];
pendingMcpElicitations: readonly PendingMcpElicitation[];

View file

@ -2,7 +2,8 @@ import type { ComponentChild as UiNode } from "preact";
import type { ApprovalAction, McpElicitationAction, PendingRequestId } from "../../domain/pending-requests/model";
import type { PendingRequestBlockSnapshot } from "../../presentation/pending-requests/snapshot";
import type { MessageStreamForkTarget, MessageStreamPlanImplementationTarget } from "../../presentation/message-stream/text-view";
import type { MessageStreamForkTarget } from "../../presentation/message-stream/text-view";
import type { PlanImplementationTarget } from "../../domain/message-stream/selectors";
import type { ChatTurnDiffViewState } from "../../domain/turn-diff";
export interface MessageStreamBlock {
@ -51,7 +52,7 @@ export interface TextItemActionContext extends TextItemDetailStateContext {
forkMenuItemId: string | null;
onForkMenuToggle?: (itemId: string | null) => void;
copyText?: (text: string) => void;
onImplementPlan?: (target: MessageStreamPlanImplementationTarget) => void;
onImplementPlan?: (target: PlanImplementationTarget) => void;
onRollback?: () => void;
onFork?: (target: MessageStreamForkTarget, archiveSource: boolean) => void;
}

View file

@ -1,9 +1,9 @@
import {
type EphemeralStructuredTurnClient,
type EphemeralStructuredTurnRuntimeClient,
runEphemeralStructuredTurnForLastAgentText,
type StructuredTurnOutputSchema,
} from "../../app-server/services/ephemeral-structured-turn";
import type { ModelMetadataClient } from "../../app-server/catalog";
import type { AppServerClientHandlers } from "../../app-server/connection/client";
import { resolvedRuntimeOverrideForClient } from "../../app-server/services/runtime-overrides";
import type { SelectionRewriteRuntimeSettings } from "./model";
@ -36,7 +36,7 @@ export interface RunSelectionRewriteOptions {
export type SelectionRewriteActivity = "reasoning" | "writing";
type SelectionRewriteClient = EphemeralStructuredTurnClient & EphemeralStructuredTurnRuntimeClient;
type SelectionRewriteClient = EphemeralStructuredTurnClient & ModelMetadataClient;
type SelectionRewriteClientFactory = (codexPath: string, cwd: string, handlers: AppServerClientHandlers) => SelectionRewriteClient;
export async function runSelectionRewrite(options: RunSelectionRewriteOptions): Promise<SelectionRewriteOutput> {
@ -72,9 +72,6 @@ export async function runSelectionRewrite(options: RunSelectionRewriteOptions):
return output;
}
async function selectionRewriteRuntimeOverrideForClient(
client: EphemeralStructuredTurnRuntimeClient,
settings: SelectionRewriteRuntimeSettings,
) {
async function selectionRewriteRuntimeOverrideForClient(client: ModelMetadataClient, settings: SelectionRewriteRuntimeSettings) {
return resolvedRuntimeOverrideForClient(client, { model: settings.rewriteSelectionModel, effort: settings.rewriteSelectionEffort });
}

View file

@ -8,8 +8,6 @@ import {
ObsidianToggle,
} from "../shared/ui/components";
export type SelectControlOption = ObsidianDropdownOption;
export function SettingsGroup({ className, children }: { className: string; children: UiNode }): UiNode {
return <section className={`setting-group ${className}`}>{children}</section>;
}
@ -86,7 +84,7 @@ export function SelectControl({
}: {
value: string;
onChange: (value: string) => void;
options: readonly SelectControlOption[];
options: readonly ObsidianDropdownOption[];
}): UiNode {
return <ObsidianDropdown value={value} options={options} onChange={onChange} />;
}

View file

@ -2,7 +2,7 @@ export interface LocalIdSource {
next(prefix: string): string;
}
export interface LocalIdSourceOptions {
interface LocalIdSourceOptions {
nowMs?: () => number;
seed?: string;
}

View file

@ -6,11 +6,11 @@ import type { AppServerClient, AppServerClientHandlers, AppServerStartStructured
import type { TurnItem, TurnRecord } from "../../src/app-server/protocol/turn";
import type { RequestId, ServerNotification } from "../../src/app-server/connection/rpc-messages";
import type { ServerInitialization } from "../../src/domain/server/initialization";
import {
generateThreadTitleWithCodex,
type ThreadTitleClient,
type ThreadTitleClientFactory,
} from "../../src/app-server/services/thread-title-generation";
import { generateThreadTitleWithCodex } from "../../src/app-server/services/thread-title-generation";
import type {
EphemeralStructuredTurnClient,
EphemeralStructuredTurnClientFactory,
} from "../../src/app-server/services/ephemeral-structured-turn";
import {
findThreadTitleContext,
threadTitleContextFromConversationSummary,
@ -213,7 +213,7 @@ function runtimeSettings() {
}
function fakeThreadTitleClientFactory(configure?: (client: FakeThreadTitleClient) => void): {
clientFactory: ThreadTitleClientFactory;
clientFactory: EphemeralStructuredTurnClientFactory;
client: { current: FakeThreadTitleClient | null };
} {
const client: { current: FakeThreadTitleClient | null } = { current: null };
@ -227,7 +227,7 @@ function fakeThreadTitleClientFactory(configure?: (client: FakeThreadTitleClient
};
}
class FakeThreadTitleClient implements ThreadTitleClient {
class FakeThreadTitleClient implements EphemeralStructuredTurnClient {
startStructuredTurnImpl: (() => Promise<TurnStartResponse>) | null = null;
startStructuredTurnOptions: AppServerStartStructuredTurnOptions | null = null;
modelList: ModelListResponse["data"] = [];

View file

@ -1,10 +1,8 @@
import { describe, expect, it } from "vitest";
import { messageStreamItemFromTurnItem } from "../../../../src/features/chat/app-server/mappers/message-stream/turn-items";
import {
messageStreamIsAutoReviewDecision,
messageStreamSemanticClassifications,
} from "../../../../src/features/chat/domain/message-stream/semantics";
import { messageStreamSemanticClassifications } from "../../../../src/features/chat/domain/message-stream/semantics/classify";
import { messageStreamIsAutoReviewDecision } from "../../../../src/features/chat/domain/message-stream/semantics/predicates";
import type { MessageStreamItem } from "../../../../src/features/chat/domain/message-stream/items";
import type { TurnItem } from "../../../../src/app-server/protocol/turn";

View file

@ -15,7 +15,7 @@ import {
runtimeConfigOrDefault,
supportedReasoningEfforts,
} from "../../src/features/chat/domain/runtime/effective";
import type { RuntimeSnapshot } from "../../src/features/chat/application/runtime/snapshot";
import type { RuntimeSnapshot } from "../../src/features/chat/domain/runtime/snapshot";
import { resetRuntimeSettingToConfig, setPendingRuntimeSetting } from "../../src/features/chat/domain/runtime/pending-settings";
import {
pendingRuntimeSettingsPatch,