|
|
@@ -1,6 +1,6 @@
|
|
|
import path from 'node:path';
|
|
|
import type { PluginInput } from '@opencode-ai/plugin';
|
|
|
-import type { PluginConfig } from '../config';
|
|
|
+import type { InterviewConfig, PluginConfig } from '../config';
|
|
|
import { DEFAULT_DASHBOARD_PORT } from './dashboard';
|
|
|
import { createDashboardManager } from './dashboard-manager';
|
|
|
import { createInterviewServer } from './server';
|
|
|
@@ -27,32 +27,7 @@ export function createInterviewManager(
|
|
|
|
|
|
// ─── Per-session mode (upstream behavior) ───────────────────────
|
|
|
if (!dashboardEnabled) {
|
|
|
- const service = createInterviewService(ctx, interviewConfig);
|
|
|
- const resolvedOutputPath = path.join(ctx.directory, outputFolder);
|
|
|
- const server = createInterviewServer({
|
|
|
- getState: async (interviewId) => service.getInterviewState(interviewId),
|
|
|
- listInterviewFiles: async () => service.listInterviewFiles(),
|
|
|
- listInterviews: () => service.listInterviews(),
|
|
|
- submitAnswers: async (interviewId, answers) =>
|
|
|
- service.submitAnswers(interviewId, answers),
|
|
|
- submitBlockComment: async (interviewId, section, comment) =>
|
|
|
- service.submitBlockComment(interviewId, section, comment),
|
|
|
- submitChat: async (interviewId, message) =>
|
|
|
- service.submitChat(interviewId, message),
|
|
|
- handleNudgeAction: async (interviewId, action) =>
|
|
|
- service.handleNudgeAction(interviewId, action),
|
|
|
- outputFolder: resolvedOutputPath,
|
|
|
- port: 0, // random port
|
|
|
- });
|
|
|
-
|
|
|
- service.setBaseUrlResolver(() => server.ensureStarted());
|
|
|
-
|
|
|
- return {
|
|
|
- registerCommand: (c) => service.registerCommand(c),
|
|
|
- handleCommandExecuteBefore: async (input, output) =>
|
|
|
- service.handleCommandExecuteBefore(input, output),
|
|
|
- handleEvent: async (input) => service.handleEvent(input),
|
|
|
- };
|
|
|
+ return createPerSessionInterviewServer(ctx, interviewConfig, outputFolder);
|
|
|
}
|
|
|
|
|
|
// ─── Dashboard mode ─────────────────────────────────────────────
|
|
|
@@ -61,3 +36,43 @@ export function createInterviewManager(
|
|
|
|
|
|
return createDashboardManager(ctx, config, dashboardPort, outputFolder);
|
|
|
}
|
|
|
+
|
|
|
+export function createPerSessionInterviewServer(
|
|
|
+ ctx: PluginInput,
|
|
|
+ interviewConfig: InterviewConfig | undefined,
|
|
|
+ outputFolder: string,
|
|
|
+): {
|
|
|
+ registerCommand: (config: Record<string, unknown>) => void;
|
|
|
+ handleCommandExecuteBefore: (
|
|
|
+ input: { command: string; sessionID: string; arguments: string },
|
|
|
+ output: { parts: Array<{ type: string; text?: string }> },
|
|
|
+ ) => Promise<void>;
|
|
|
+ handleEvent: (input: {
|
|
|
+ event: { type: string; properties?: Record<string, unknown> };
|
|
|
+ }) => Promise<void>;
|
|
|
+} {
|
|
|
+ const service = createInterviewService(ctx, interviewConfig);
|
|
|
+ const resolvedOutputPath = path.join(ctx.directory, outputFolder);
|
|
|
+ const server = createInterviewServer({
|
|
|
+ getState: async (interviewId) => service.getInterviewState(interviewId),
|
|
|
+ listInterviewFiles: async () => service.listInterviewFiles(),
|
|
|
+ listInterviews: () => service.listInterviews(),
|
|
|
+ submitAnswers: async (interviewId, answers) =>
|
|
|
+ service.submitAnswers(interviewId, answers),
|
|
|
+ submitBlockComment: async (interviewId, section, comment) =>
|
|
|
+ service.submitBlockComment(interviewId, section, comment),
|
|
|
+ submitChat: async (interviewId, message) =>
|
|
|
+ service.submitChat(interviewId, message),
|
|
|
+ handleNudgeAction: async (interviewId, action) =>
|
|
|
+ service.handleNudgeAction(interviewId, action),
|
|
|
+ outputFolder: resolvedOutputPath,
|
|
|
+ port: 0,
|
|
|
+ });
|
|
|
+ service.setBaseUrlResolver(() => server.ensureStarted());
|
|
|
+ return {
|
|
|
+ registerCommand: (c) => service.registerCommand(c),
|
|
|
+ handleCommandExecuteBefore: async (input, output) =>
|
|
|
+ service.handleCommandExecuteBefore(input, output),
|
|
|
+ handleEvent: async (input) => service.handleEvent(input),
|
|
|
+ };
|
|
|
+}
|