mirror of
https://github.com/murashit/codex-panel.git
synced 2026-07-22 06:57:10 +00:00
Group chat app-server transports
This commit is contained in:
parent
7fd1d8e254
commit
f3c5a527d7
11 changed files with 59 additions and 58 deletions
|
|
@ -8,12 +8,12 @@ import type { RuntimeSettingsTransport } from "../application/runtime/settings-t
|
|||
import type { ThreadGoalReadTransport, ThreadGoalTransport } from "../application/threads/goal-transport";
|
||||
import type { ThreadHistoryTransport, ThreadResumeTransport } from "../application/threads/thread-loading-transport";
|
||||
import type { ThreadMutationTransport } from "../application/threads/thread-mutation-transport";
|
||||
import { createChatThreadGoalReadTransport, createChatThreadGoalTransport } from "./goals/transport";
|
||||
import { createThreadReferenceResolver, type ThreadReferenceResolver } from "./references/thread-reference-resolver";
|
||||
import { createChatRuntimeSettingsTransport } from "./runtime/thread-settings-transport";
|
||||
import { createChatThreadHistoryTransport, createChatThreadResumeTransport } from "./threads/loading-transport";
|
||||
import { createChatThreadMutationTransport } from "./threads/transport";
|
||||
import { createChatTurnTransport } from "./turns/transport";
|
||||
import { createThreadReferenceResolver, type ThreadReferenceResolver } from "./thread-reference-resolver";
|
||||
import { createChatThreadGoalReadTransport, createChatThreadGoalTransport } from "./transports/goal-transport";
|
||||
import { createChatThreadHistoryTransport, createChatThreadResumeTransport } from "./transports/thread-loading-transport";
|
||||
import { createChatThreadMutationTransport } from "./transports/thread-mutation-transport";
|
||||
import { createChatRuntimeSettingsTransport } from "./transports/thread-settings-transport";
|
||||
import { createChatTurnTransport } from "./transports/turn-transport";
|
||||
|
||||
export interface ChatAppServerGatewayHost {
|
||||
vaultPath: string;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { readReferencedThreadConversationSummaries, type ThreadConversationSummaryClient } from "../../../../app-server/services/threads";
|
||||
import { type CodexInput, codexTextInputWithAttachments } from "../../../../domain/chat/input";
|
||||
import type { Thread } from "../../../../domain/threads/model";
|
||||
import { REFERENCED_THREAD_TURN_LIMIT, referencedThreadPromptBundle } from "../../../../domain/threads/reference";
|
||||
import { shortThreadId } from "../../../../shared/id/thread-id";
|
||||
import type { ThreadReferenceInput } from "../../application/conversation/slash-command-execution";
|
||||
import { readReferencedThreadConversationSummaries, type ThreadConversationSummaryClient } from "../../../app-server/services/threads";
|
||||
import { type CodexInput, codexTextInputWithAttachments } from "../../../domain/chat/input";
|
||||
import type { Thread } from "../../../domain/threads/model";
|
||||
import { REFERENCED_THREAD_TURN_LIMIT, referencedThreadPromptBundle } from "../../../domain/threads/reference";
|
||||
import { shortThreadId } from "../../../shared/id/thread-id";
|
||||
import type { ThreadReferenceInput } from "../application/conversation/slash-command-execution";
|
||||
|
||||
interface ThreadReferenceResolverHost {
|
||||
currentClient(): ThreadConversationSummaryClient | null;
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
import type {
|
||||
ThreadHistoryPage,
|
||||
ThreadHistoryTransport,
|
||||
ThreadResumeSnapshot,
|
||||
ThreadResumeTransport,
|
||||
} from "../../application/threads/thread-loading-transport";
|
||||
import type { ConnectedChatAppServerClientHost, CurrentChatAppServerClientHost } from "../connection/client-scope";
|
||||
import { withConnectedChatAppServerClient, withCurrentChatAppServerClient } from "../connection/client-scope";
|
||||
import { readChatThreadHistoryPage, resumeChatThread } from "./projection";
|
||||
|
||||
interface ChatThreadResumeTransportHost extends ConnectedChatAppServerClientHost {
|
||||
vaultPath: string;
|
||||
}
|
||||
|
||||
export function createChatThreadHistoryTransport(host: CurrentChatAppServerClientHost): ThreadHistoryTransport {
|
||||
return {
|
||||
readHistoryPage: (threadId, cursor, limit): Promise<ThreadHistoryPage | null> =>
|
||||
withCurrentChatAppServerClient(host, (client) => readChatThreadHistoryPage(client, threadId, cursor, limit)),
|
||||
};
|
||||
}
|
||||
|
||||
export function createChatThreadResumeTransport(host: ChatThreadResumeTransportHost): ThreadResumeTransport {
|
||||
return {
|
||||
resumeThread: (threadId): Promise<ThreadResumeSnapshot | null> =>
|
||||
withConnectedChatAppServerClient(host, (client) => resumeChatThread(client, threadId, host.vaultPath)),
|
||||
};
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import { clearThreadGoal, readThreadGoal, recordThreadGoalUserMessage, setThreadGoal } from "../../../../app-server/services/threads";
|
||||
import type { ThreadGoalReadTransport, ThreadGoalTransport } from "../../application/threads/goal-transport";
|
||||
import type { ConnectedChatAppServerClientHost, CurrentChatAppServerClientHost } from "../connection/client-scope";
|
||||
import { chatAppServerClientIsStale, withConnectedChatAppServerClient, withCurrentChatAppServerClient } from "../connection/client-scope";
|
||||
import type { ConnectedChatAppServerClientHost, CurrentChatAppServerClientHost } from "./client-scope";
|
||||
import { chatAppServerClientIsStale, withConnectedChatAppServerClient, withCurrentChatAppServerClient } from "./client-scope";
|
||||
|
||||
export function createChatThreadGoalReadTransport(host: CurrentChatAppServerClientHost): ThreadGoalReadTransport {
|
||||
return {
|
||||
|
|
@ -1,8 +1,15 @@
|
|||
import type { AppServerRequestClient } from "../../../../app-server/services/request-client";
|
||||
import { listThreadTurns, resumeThread, threadActivationSnapshotFromAppServerResponse } from "../../../../app-server/services/threads";
|
||||
import type { ThreadTurnsPage } from "../../../../domain/threads/history";
|
||||
import type { ThreadHistoryPage, ThreadResumeSnapshot } from "../../application/threads/thread-loading-transport";
|
||||
import type {
|
||||
ThreadHistoryPage,
|
||||
ThreadHistoryTransport,
|
||||
ThreadResumeSnapshot,
|
||||
ThreadResumeTransport,
|
||||
} from "../../application/threads/thread-loading-transport";
|
||||
import { messageStreamItemsFromTurns } from "../mappers/message-stream/turn-items";
|
||||
import type { ConnectedChatAppServerClientHost, CurrentChatAppServerClientHost } from "./client-scope";
|
||||
import { withConnectedChatAppServerClient, withCurrentChatAppServerClient } from "./client-scope";
|
||||
|
||||
type ChatThreadHistoryClient = AppServerRequestClient;
|
||||
type ChatThreadResumeClient = AppServerRequestClient;
|
||||
|
|
@ -12,7 +19,25 @@ interface AppServerThreadTurnsPage {
|
|||
readonly nextCursor: string | null;
|
||||
}
|
||||
|
||||
export async function readChatThreadHistoryPage(
|
||||
interface ChatThreadResumeTransportHost extends ConnectedChatAppServerClientHost {
|
||||
vaultPath: string;
|
||||
}
|
||||
|
||||
export function createChatThreadHistoryTransport(host: CurrentChatAppServerClientHost): ThreadHistoryTransport {
|
||||
return {
|
||||
readHistoryPage: (threadId, cursor, limit): Promise<ThreadHistoryPage | null> =>
|
||||
withCurrentChatAppServerClient(host, (client) => readChatThreadHistoryPage(client, threadId, cursor, limit)),
|
||||
};
|
||||
}
|
||||
|
||||
export function createChatThreadResumeTransport(host: ChatThreadResumeTransportHost): ThreadResumeTransport {
|
||||
return {
|
||||
resumeThread: (threadId): Promise<ThreadResumeSnapshot | null> =>
|
||||
withConnectedChatAppServerClient(host, (client) => resumeChatThread(client, threadId, host.vaultPath)),
|
||||
};
|
||||
}
|
||||
|
||||
async function readChatThreadHistoryPage(
|
||||
client: ChatThreadHistoryClient,
|
||||
threadId: string,
|
||||
cursor: string | null,
|
||||
|
|
@ -29,7 +54,7 @@ function chatThreadHistoryPageFromTurnsPage(page: ThreadTurnsPage): ThreadHistor
|
|||
};
|
||||
}
|
||||
|
||||
export async function resumeChatThread(client: ChatThreadResumeClient, threadId: string, cwd: string): Promise<ThreadResumeSnapshot> {
|
||||
async function resumeChatThread(client: ChatThreadResumeClient, threadId: string, cwd: string): Promise<ThreadResumeSnapshot> {
|
||||
const response = await resumeThread(client, threadId, cwd);
|
||||
return {
|
||||
activation: threadActivationSnapshotFromAppServerResponse(response),
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
import { compactThread, forkThread, rollbackThread } from "../../../../app-server/services/threads";
|
||||
import type { ThreadMutationTransport, ThreadRollbackSnapshot } from "../../application/threads/thread-mutation-transport";
|
||||
import type { ConnectedChatAppServerClientHost } from "../connection/client-scope";
|
||||
import { withConnectedChatAppServerClient } from "../connection/client-scope";
|
||||
import { messageStreamItemsFromTurns } from "../mappers/message-stream/turn-items";
|
||||
import type { ConnectedChatAppServerClientHost } from "./client-scope";
|
||||
import { withConnectedChatAppServerClient } from "./client-scope";
|
||||
|
||||
interface ChatThreadMutationTransportHost extends ConnectedChatAppServerClientHost {
|
||||
vaultPath: string;
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
import { updateThreadSettings } from "../../../../app-server/services/threads";
|
||||
import type { RuntimeSettingsPatch } from "../../../../domain/runtime/thread-settings";
|
||||
import type { RuntimeSettingsTransport } from "../../application/runtime/settings-transport";
|
||||
import type { CurrentChatAppServerClientHost } from "../connection/client-scope";
|
||||
import { withCurrentChatAppServerClient } from "../connection/client-scope";
|
||||
import type { CurrentChatAppServerClientHost } from "./client-scope";
|
||||
import { withCurrentChatAppServerClient } from "./client-scope";
|
||||
|
||||
export function createChatRuntimeSettingsTransport(host: CurrentChatAppServerClientHost): RuntimeSettingsTransport {
|
||||
return {
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import { interruptTurn, startTurn, steerTurn } from "../../../../app-server/services/turns";
|
||||
import type { ChatTurnTransport } from "../../application/conversation/turn-transport";
|
||||
import type { ConnectedChatAppServerClientHost } from "../connection/client-scope";
|
||||
import { withCurrentChatAppServerClient } from "../connection/client-scope";
|
||||
import type { ConnectedChatAppServerClientHost } from "./client-scope";
|
||||
import { withCurrentChatAppServerClient } from "./client-scope";
|
||||
|
||||
interface ChatTurnTransportHost extends ConnectedChatAppServerClientHost {
|
||||
vaultPath: string;
|
||||
|
|
@ -4,15 +4,18 @@ import type { AppServerClient, ClientResponseByMethod } from "../../../../src/ap
|
|||
import type { ThreadRecord } from "../../../../src/app-server/protocol/thread";
|
||||
import type { TurnItem, TurnRecord } from "../../../../src/app-server/protocol/turn";
|
||||
import type { CodexInput } from "../../../../src/domain/chat/input";
|
||||
import { createChatThreadGoalReadTransport, createChatThreadGoalTransport } from "../../../../src/features/chat/app-server/goals/transport";
|
||||
import { createThreadReferenceResolver } from "../../../../src/features/chat/app-server/references/thread-reference-resolver";
|
||||
import { createChatRuntimeSettingsTransport } from "../../../../src/features/chat/app-server/runtime/thread-settings-transport";
|
||||
import { createThreadReferenceResolver } from "../../../../src/features/chat/app-server/thread-reference-resolver";
|
||||
import {
|
||||
createChatThreadGoalReadTransport,
|
||||
createChatThreadGoalTransport,
|
||||
} from "../../../../src/features/chat/app-server/transports/goal-transport";
|
||||
import {
|
||||
createChatThreadHistoryTransport,
|
||||
createChatThreadResumeTransport,
|
||||
} from "../../../../src/features/chat/app-server/threads/loading-transport";
|
||||
import { createChatThreadMutationTransport } from "../../../../src/features/chat/app-server/threads/transport";
|
||||
import { createChatTurnTransport } from "../../../../src/features/chat/app-server/turns/transport";
|
||||
} from "../../../../src/features/chat/app-server/transports/thread-loading-transport";
|
||||
import { createChatThreadMutationTransport } from "../../../../src/features/chat/app-server/transports/thread-mutation-transport";
|
||||
import { createChatRuntimeSettingsTransport } from "../../../../src/features/chat/app-server/transports/thread-settings-transport";
|
||||
import { createChatTurnTransport } from "../../../../src/features/chat/app-server/transports/turn-transport";
|
||||
import { deferred } from "../../../support/async";
|
||||
|
||||
const textInput = (text: string): CodexInput => [{ type: "text", text }];
|
||||
|
|
|
|||
|
|
@ -475,12 +475,12 @@ export function timestamp(): number {
|
|||
path.join(cwd, "src/features/chat/application/outer.ts"),
|
||||
`
|
||||
import type { Host } from "../host/contracts";
|
||||
import type { ChatThreadHistoryPage } from "../app-server/threads/projection";
|
||||
import type { ThreadHistoryTransport } from "../app-server/transports/thread-loading-transport";
|
||||
import type { ToolbarPanelActions } from "../panel/toolbar-actions";
|
||||
import { statusText } from "../presentation/runtime/status";
|
||||
import { Toolbar } from "../ui/toolbar";
|
||||
|
||||
export type Escape = ChatThreadHistoryPage | Host | ToolbarPanelActions;
|
||||
export type Escape = ThreadHistoryTransport | Host | ToolbarPanelActions;
|
||||
export const values = [statusText, Toolbar] satisfies unknown[];
|
||||
`.trimStart(),
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue