@agimon-ai/doompi-user-feedback 0.0.1-alpha.72 → 0.0.1-alpha.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extensions/pi.cjs +2 -2
- package/dist/extensions/pi.cjs.map +1 -1
- package/dist/extensions/pi.d.mts.map +1 -1
- package/dist/extensions/pi.mjs +2 -2
- package/dist/extensions/pi.mjs.map +1 -1
- package/dist/extensions/server.cjs +2 -2
- package/dist/extensions/server.cjs.map +1 -1
- package/dist/extensions/server.d.mts.map +1 -1
- package/dist/extensions/server.mjs +2 -2
- package/dist/extensions/server.mjs.map +1 -1
- package/dist/extensions/web.mjs +2 -2
- package/dist/extensions/web.mjs.map +1 -1
- package/package.json +7 -7
package/dist/extensions/pi.cjs
CHANGED
|
@@ -491,10 +491,10 @@ var askUserQuestion_cli_default = (0, _agimon_ai_doompi_core_extensionFile.defin
|
|
|
491
491
|
//#endregion
|
|
492
492
|
//#region generated/pi.ts
|
|
493
493
|
const at = (value, context) => typeof value === "function" ? value(context) : value;
|
|
494
|
-
const via = (identity, value) =>
|
|
494
|
+
const via = (identity, value) => value === void 0 ? void 0 : {
|
|
495
495
|
...identity,
|
|
496
496
|
...value
|
|
497
|
-
}
|
|
497
|
+
};
|
|
498
498
|
const extension = (0, _agimon_ai_doompi_core_piExtension.definePiExtension)("@agimon-ai/doompi-user-feedback", async (context) => {
|
|
499
499
|
const scopeSession = await root_cli_default(context);
|
|
500
500
|
const contextSession = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pi.cjs","names":["DOOM_VOICE_SOURCE","DOOM_VOICE_AUTO_MODE_ID","MAX_NARRATION_TEXT_CHARACTERS","createNarrationRequest","defineRoot","QuestionnaireCoordinator","ASK_USER_QUESTION_TOOL_NAME","DOOM_MINOR_MODE_CATALOG_SERVICE","DOOM_NARRATION_SERVICE","requireMinorModeCatalog","requireDoomNarrationService","defineRoot","contribution","defineCliHook","contribution","defineCliHook","contribution","defineResource","defineToolRestriction","contribution","renderToolHeading","DoomToolCall","DoomToolResult","path","os","fs","runQuestionnaire","DOOM_ASK_USER_PROMPT_EVENT","DOOM_ASK_USER_BLOCKED_EVENT","ASK_USER_QUESTION_TOOL_NAME","DEFAULT_PROMPT_SNIPPET","DEFAULT_PROMPT_GUIDELINES","QuestionParamsSchema","buildToolResult","ERROR_SESSION_INACTIVE","ERROR_NO_UI","validateQuestionnaire","ERROR_NO_CUSTOM_UI","buildQuestionnaireResponse","ERROR_SESSION_LOAD_FAILED","defineCliTool","definePiTool","definePiExtension","rootSession","composeRootHooks","hookBeforeAgentStart","hookSessionStart","resourceDoompiUseUserFeedback","toolRestrictionAskUserQuestion","piToolContributions","toolAskUserQuestion"],"sources":["../../src/services/askUserToolGate/index.ts","../../src/services/autonomousVoiceMode/index.ts","../../src/services/voiceQuestionNarration/index.ts","../../src/services/voiceQuestionHandoff/index.ts","../../src/extensions/workspaces/sessions/(backend)/_lib/root.cli.ts","../../src/extensions/workspaces/sessions/(backend)/root.cli.ts","../../src/extensions/workspaces/sessions/(backend)/hook/_lib/before-agent-start.cli.ts","../../src/extensions/workspaces/sessions/(backend)/hook/before-agent-start.cli.ts","../../src/extensions/workspaces/sessions/(backend)/hook/_lib/session-start.cli.ts","../../src/extensions/workspaces/sessions/(backend)/hook/session-start.cli.ts","../../src/extensions/workspaces/sessions/(backend)/resource/_lib/doompi-use-user-feedback.cli.ts","../../src/extensions/workspaces/sessions/(backend)/resource/doompi-use-user-feedback.cli.ts","../../src/extensions/workspaces/sessions/(backend)/tool-restriction/_lib/ask-user-question.cli.ts","../../src/extensions/workspaces/sessions/(backend)/tool-restriction/ask-user-question.cli.ts","../../src/tui/askUserToolRender.ts","../../src/services/config/index.ts","../../src/services/rpcQuestionnaire/index.ts","../../src/extensions/workspaces/sessions/(backend)/_tools/askUserQuestion.ts","../../src/extensions/workspaces/sessions/(backend)/tool/askUserQuestion.cli.ts","../../generated/pi.ts"],"sourcesContent":["import type { DoomToolRestriction } from '@agimon-ai/doompi-core/toolSurface';\n\n/**\n * Hides the questionnaire tool while nobody can answer it.\n *\n * Autonomous Voice narrates its own question and then waits for the spoken reply, so a\n * questionnaire tool alongside it asks the same thing twice. A run without UI cannot render\n * the questionnaire at all. Both cases only ever remove the name: the tool surface recomputes\n * from every registered tool, so a visible gate restores it without tracking what it hid.\n */\nexport function askUserToolRestriction(toolName: string, visible: boolean): DoomToolRestriction {\n return (incoming) => (visible ? incoming : incoming.filter((name) => name !== toolName));\n}\n","import { DOOM_VOICE_AUTO_MODE_ID, DOOM_VOICE_SOURCE } from '@agimon-ai/doompi-core/voiceTools';\nimport type { MinorModeRecord } from '@agimon-ai/doompi-minor-mode';\n/**\n * Matches only the Voice package's own autonomous mode, and only while it reports active.\n *\n * Both the source and the mode id are checked because another package may register a mode\n * under the same id, and a transitional `activating` or `deactivating` record is not yet\n * (or no longer) speaking.\n */\nexport function isAutonomousVoiceRecord(record: MinorModeRecord): boolean {\n return (\n record.descriptor.source === DOOM_VOICE_SOURCE &&\n record.descriptor.id === DOOM_VOICE_AUTO_MODE_ID &&\n record.state.activation === 'active'\n );\n}\n\nexport function isAutonomousVoiceActive(records: readonly MinorModeRecord[]): boolean {\n return records.some((record) => isAutonomousVoiceRecord(record));\n}\n","import { MAX_NARRATION_TEXT_CHARACTERS } from '@agimon-ai/doompi-core/narration';\n\nimport type { QuestionParams } from '../../schemas/questionnaire';\n\nconst MAX_QUESTION_CHARACTERS = 240;\nconst MAX_OPTION_CHARACTERS = 80;\nconst PATH_PATTERN = /\\/(?:Users|home|private|tmp|var)\\/[^\\s,;:]+/gu;\nconst TOKEN_PATTERN = /\\b(?:sk|api|token|key)[-_][A-Za-z0-9_-]{12,}\\b/giu;\nconst CODE_PATTERN = /`[^`]*`|<\\/?[A-Za-z][^>]*>|\\$\\([^)]*\\)|\\{[^}]*\\}/gu;\nconst SAFE_FALLBACK = 'I need your answer to the questions shown in the conversation.';\n\nfunction takeCharacters(text: string, maximum: number): string {\n return Array.from(text).slice(0, maximum).join('').trim();\n}\n\nexport function sanitizeVoiceQuestionText(text: string, maximum: number): string {\n const withoutControls = Array.from(text, (character) => {\n const codePoint = character.codePointAt(0) ?? 0;\n return codePoint < 32 || codePoint === 127 ? ' ' : character;\n }).join('');\n return takeCharacters(\n withoutControls\n .replace(PATH_PATTERN, ' ')\n .replace(TOKEN_PATTERN, ' ')\n .replace(CODE_PATTERN, ' ')\n .replace(/\\s+/gu, ' ')\n .trim(),\n maximum,\n );\n}\n\nfunction spokenQuestion(params: QuestionParams, questionIndex: number): string {\n const question = params.questions[questionIndex];\n if (!question) return '';\n const position = questionIndex + 1;\n const prompt =\n sanitizeVoiceQuestionText(question.question, MAX_QUESTION_CHARACTERS) || `Question ${position} needs your choice`;\n const labels = question.options.map((option, optionIndex) => {\n const label = sanitizeVoiceQuestionText(option.label, MAX_OPTION_CHARACTERS);\n return `${optionIndex + 1}, ${label || `option ${optionIndex + 1}`}`;\n });\n const selection = question.multiSelect ? 'You may choose more than one option.' : 'Please choose one option.';\n return `Question ${position}: ${prompt}. Options: ${labels.join('; ')}. ${selection} You may also answer in your own words.`;\n}\n\nexport function buildVoiceQuestionNarration(params: QuestionParams): string {\n const questions = params.questions.map((_question, index) => spokenQuestion(params, index));\n const combined = sanitizeVoiceQuestionText(questions.join(' '), MAX_NARRATION_TEXT_CHARACTERS);\n return combined || SAFE_FALLBACK;\n}\n","import { createNarrationRequest, type DoomNarrationService } from '@agimon-ai/doompi-core/narration';\nimport type { MinorModeCatalogService } from '@agimon-ai/doompi-minor-mode';\n\nimport type { QuestionParams } from '../../schemas/questionnaire';\nimport type { QuestionnaireResult, ToolTextResult } from '../../types/questionnaire';\nimport { isAutonomousVoiceRecord } from '../autonomousVoiceMode';\nimport { buildVoiceQuestionNarration } from '../voiceQuestionNarration';\n\nexport const VOICE_WAIT_MESSAGE =\n \"The questions were spoken through autonomous voice. Stop now and wait for the user's next message; it will arrive as an ordinary user message.\";\n\nexport function formatVoiceQuestionPrompt(params: QuestionParams): string {\n const numberQuestions = params.questions.length > 1;\n return params.questions\n .map((question, questionIndex) => {\n const heading = `${numberQuestions ? `${questionIndex + 1}. ` : ''}${question.question}${question.multiSelect ? ' (Select all that apply.)' : ''}`;\n const options = question.options.map((option, optionIndex) => ` ${optionIndex + 1}. ${option.label}`);\n return [heading, ...options, ' Type something.'].join('\\n');\n })\n .join('\\n\\n');\n}\n\nexport class VoiceQuestionHandoff {\n constructor(\n private readonly modes: Pick<MinorModeCatalogService, 'list'>,\n private readonly narration: Pick<DoomNarrationService, 'request'>,\n private readonly buildNarration: (params: QuestionParams) => string = buildVoiceQuestionNarration,\n ) {}\n\n async handoff(params: QuestionParams): Promise<QuestionnaireResult | undefined> {\n if (!this.modes.list().some((record) => isAutonomousVoiceRecord(record))) return undefined;\n const narration = createNarrationRequest(this.buildNarration(params));\n if (!narration) return undefined;\n await this.narration.request(narration);\n return {\n answers: [],\n cancelled: false,\n delivery: 'voice',\n awaitingResponse: true,\n voicePrompt: formatVoiceQuestionPrompt(params),\n };\n }\n}\n\n/** Create a handoff from services whose lifecycle is owned by a Cordis injection. */\nexport function createVoiceQuestionHandoff(\n modes: Pick<MinorModeCatalogService, 'list'>,\n narration: Pick<DoomNarrationService, 'request'>,\n): VoiceQuestionHandoff {\n return new VoiceQuestionHandoff(modes, narration);\n}\n\nexport function buildVoiceToolResult(details: QuestionnaireResult): ToolTextResult {\n const prompt = details.voicePrompt?.trim();\n return {\n content: [{ type: 'text', text: prompt ? `${prompt}\\n\\n${VOICE_WAIT_MESSAGE}` : VOICE_WAIT_MESSAGE }],\n details,\n terminate: true,\n };\n}\n","import { defineRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport { DOOM_NARRATION_SERVICE, requireDoomNarrationService } from '@agimon-ai/doompi-core/narration';\nimport type { PiPluginContext } from '@agimon-ai/doompi-core/piExtension';\nimport type { DoomToolRestriction } from '@agimon-ai/doompi-core/toolSurface';\nimport { DOOM_MINOR_MODE_CATALOG_SERVICE, requireMinorModeCatalog } from '@agimon-ai/doompi-minor-mode';\nimport type { Context } from '@deepseek-ai/cordis';\nimport type { ExtensionContext } from '@earendil-works/pi-coding-agent';\n\nimport { ASK_USER_QUESTION_TOOL_NAME } from '../../../../../constants/tool';\nimport { askUserToolRestriction } from '../../../../../services/askUserToolGate';\nimport { isAutonomousVoiceActive } from '../../../../../services/autonomousVoiceMode';\nimport { QuestionnaireCoordinator, type QuestionnaireRunner } from '../../../../../services/questionnaireCoordinator';\nimport { createVoiceQuestionHandoff, type VoiceQuestionHandoff } from '../../../../../services/voiceQuestionHandoff';\nimport type { QuestionnaireResult } from '../../../../../types/questionnaire';\nimport { createAskUserQuestionTool } from '.././_tools/askUserQuestion';\n\nfunction cancelledResult(): QuestionnaireResult {\n return { answers: [], cancelled: true };\n}\n\nconst root = defineRoot((_context: PiPluginContext) => {\n let active = true;\n let sessionGeneration = 0;\n let sessionId: string | undefined;\n let sessionReady = false;\n let coordinator = new QuestionnaireCoordinator();\n let voiceHandoff: VoiceQuestionHandoff | undefined;\n let voiceActive = false;\n let hasUI = true;\n const restrictionListeners = new Set<() => void>();\n const currentRestriction = (): DoomToolRestriction =>\n askUserToolRestriction(ASK_USER_QUESTION_TOOL_NAME, hasUI && !voiceActive);\n const syncToolRestriction = (): void => restrictionListeners.forEach((listener) => listener());\n let lifecycleQueue: Promise<void> = Promise.resolve();\n const pendingOperations = new Set<Promise<unknown>>();\n\n const trackOperation = <T>(operation: Promise<T>): Promise<T> => {\n pendingOperations.add(operation);\n void operation.then(\n () => pendingOperations.delete(operation),\n () => pendingOperations.delete(operation),\n );\n return operation;\n };\n const ownsGeneration = (generation: number, expectedSessionId: string | undefined): boolean =>\n active && generation === sessionGeneration && expectedSessionId === sessionId;\n const isContextActive = (context: ExtensionContext, signal?: AbortSignal): boolean =>\n active && sessionReady && signal?.aborted !== true && context.sessionManager.getSessionId() === sessionId;\n\n const shutdownRuntime = async (): Promise<void> => {\n if (!active) return;\n const ownedCoordinator = coordinator;\n ownedCoordinator.shutdown();\n active = false;\n sessionGeneration += 1;\n sessionReady = false;\n sessionId = undefined;\n await Promise.allSettled(pendingOperations);\n await ownedCoordinator.waitForIdle();\n };\n\n const toolDependencies: Parameters<typeof createAskUserQuestionTool>[1] = {\n enqueue: (runner: QuestionnaireRunner, signal?: AbortSignal) => {\n const ownedCoordinator = coordinator;\n const generation = sessionGeneration;\n const expectedSessionId = sessionId;\n if (!sessionReady || !ownsGeneration(generation, expectedSessionId) || signal?.aborted) {\n return Promise.resolve(cancelledResult());\n }\n return ownedCoordinator.enqueue(async (context) => {\n if (!sessionReady || !ownsGeneration(generation, expectedSessionId) || context.signal.aborted) {\n return cancelledResult();\n }\n const result = await runner({\n ...context,\n reportProgress: (progress) => {\n if (ownsGeneration(generation, expectedSessionId) && !context.signal.aborted) {\n context.reportProgress(progress);\n }\n },\n });\n return sessionReady && ownsGeneration(generation, expectedSessionId) && !context.signal.aborted\n ? result\n : cancelledResult();\n }, signal);\n },\n isActive: isContextActive,\n runTui: async (context, params, collapseKey, signal, reportProgress) => {\n if (!isContextActive(context, signal)) return undefined;\n const { runTuiQuestionnaire } = await import('../../../../../tui/runQuestionnaire');\n if (!isContextActive(context, signal)) return undefined;\n const result = await runTuiQuestionnaire(context, params, collapseKey, signal, reportProgress);\n return isContextActive(context, signal) ? result : undefined;\n },\n tryVoice: (params) => (active && sessionReady ? voiceHandoff?.handoff(params) : undefined),\n };\n\n const beforeAgentStart = (_event: unknown, context: ExtensionContext) => {\n if (!isContextActive(context)) return;\n hasUI = context.hasUI;\n syncToolRestriction();\n };\n\n const sessionStart = (_event: unknown, context: ExtensionContext) => {\n if (!active) return;\n const previousCoordinator = coordinator;\n previousCoordinator.shutdown();\n const activeSessionId = context.sessionManager.getSessionId();\n const generation = ++sessionGeneration;\n const nextCoordinator = new QuestionnaireCoordinator();\n coordinator = nextCoordinator;\n sessionId = activeSessionId;\n sessionReady = false;\n\n const initializeSession = async (): Promise<void> => {\n await previousCoordinator.waitForIdle();\n if (!ownsGeneration(generation, activeSessionId)) return;\n sessionReady = true;\n // The surface is re-registered per session from the gate state in force, so a session\n // that starts with Voice already active needs nothing extra here.\n };\n\n const operation = lifecycleQueue.then(initializeSession, initializeSession);\n lifecycleQueue = operation.catch(() => undefined);\n return trackOperation(operation);\n };\n const toolRestriction = {\n source: '@agimon-ai/doompi-user-feedback',\n get restrict() {\n return currentRestriction();\n },\n subscribe(listener: () => void) {\n restrictionListeners.add(listener);\n return () => {\n restrictionListeners.delete(listener);\n };\n },\n };\n\n return {\n value: {\n toolDependencies,\n beforeAgentStart,\n sessionStart,\n toolRestriction,\n },\n services: [\n (serviceContextOwner: Context) => {\n serviceContextOwner.inject([DOOM_MINOR_MODE_CATALOG_SERVICE, DOOM_NARRATION_SERVICE], (serviceContext) => {\n const handoff = createVoiceQuestionHandoff(\n requireMinorModeCatalog(serviceContext),\n requireDoomNarrationService(serviceContext),\n );\n voiceHandoff = handoff;\n return () => {\n if (voiceHandoff === handoff) voiceHandoff = undefined;\n };\n });\n\n // Separate from the handoff binding above: the gate needs only the mode catalog, so it\n // still applies to a Voice build that publishes modes without providing narration.\n serviceContextOwner.inject([DOOM_MINOR_MODE_CATALOG_SERVICE], (modeContext) => {\n const modes = requireMinorModeCatalog(modeContext);\n const apply = (): void => {\n voiceActive = isAutonomousVoiceActive(modes.list());\n syncToolRestriction();\n };\n const unsubscribe = modes.subscribe(apply);\n apply();\n return () => {\n unsubscribe();\n voiceActive = false;\n syncToolRestriction();\n };\n });\n },\n ],\n onDispose: shutdownRuntime,\n };\n});\n\nexport type UserFeedbackPiScope = Awaited<ReturnType<typeof root>>['value'];\nexport default root;\n","import { defineRoot } from '@agimon-ai/doompi-core/extensionFile';\n\nimport contribution from './_lib/root.cli';\n\nexport default defineRoot(contribution);\n","import type { WithRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport type { PiPluginContext } from '@agimon-ai/doompi-core/piExtension';\n\nimport type { UserFeedbackPiScope } from '../../_lib/root.cli';\n\nexport default (context: WithRoot<PiPluginContext, UserFeedbackPiScope>) => context.root.beforeAgentStart;\n","import { defineCliHook } from '@agimon-ai/doompi-core/extensionFile';\n\nimport contribution from './_lib/before-agent-start.cli';\n\nexport default defineCliHook(contribution);\n","import type { WithRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport type { PiPluginContext } from '@agimon-ai/doompi-core/piExtension';\n\nimport type { UserFeedbackPiScope } from '../../_lib/root.cli';\n\nexport default (context: WithRoot<PiPluginContext, UserFeedbackPiScope>) => context.root.sessionStart;\n","import { defineCliHook } from '@agimon-ai/doompi-core/extensionFile';\n\nimport contribution from './_lib/session-start.cli';\n\nexport default defineCliHook(contribution);\n","export function createDoompiUseUserFeedbackResource(moduleUrl: string) {\n return {\n source: '@agimon-ai/doompi-user-feedback',\n moduleUrl,\n skills: [\n {\n name: 'doompi-use-user-feedback',\n description:\n 'Use @agimon-ai/doompi-user-feedback: Structured user questions with interactive and autonomous Voice handoff for Pi agents.',\n },\n ],\n };\n}\n","import { defineResource } from '@agimon-ai/doompi-core/extensionFile';\n\nimport { createDoompiUseUserFeedbackResource } from './_lib/doompi-use-user-feedback.cli';\n\nexport default defineResource(createDoompiUseUserFeedbackResource(import.meta.url));\n","import type { WithRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport type { PiPluginContext } from '@agimon-ai/doompi-core/piExtension';\n\nimport type { UserFeedbackPiScope } from '../../_lib/root.cli';\n\nexport default (context: WithRoot<PiPluginContext, UserFeedbackPiScope>) => context.root.toolRestriction;\n","import { defineToolRestriction } from '@agimon-ai/doompi-core/extensionFile';\n\nimport contribution from './_lib/ask-user-question.cli';\n\nexport default defineToolRestriction(contribution);\n","import { DoomToolCall, DoomToolResult, renderToolHeading } from '@agimon-ai/doompi-ui/toolChrome';\nimport type { ToolDefinition } from '@earendil-works/pi-coding-agent';\n\nimport type { QuestionParams, QuestionParamsSchema } from '../schemas/questionnaire';\nimport type { QuestionnaireResult } from '../types/questionnaire';\nexport const askUserToolRender: Pick<\n ToolDefinition<typeof QuestionParamsSchema, QuestionnaireResult>,\n 'renderCall' | 'renderResult'\n> = {\n renderCall(args, theme) {\n const params = args as QuestionParams;\n const headers = params.questions.map((question) => question.header).join(', ');\n const count = `${params.questions.length} question${params.questions.length === 1 ? '' : 's'}`;\n const heading = renderToolHeading('ask', count, theme);\n return new DoomToolCall(headers ? `${heading} ${theme.fg('dim', `(${headers})`)}` : heading);\n },\n\n renderResult(result, _options, theme, context) {\n const details = result.details as QuestionnaireResult | undefined;\n if (!details) {\n const raw = result.content\n .filter((block) => block.type === 'text')\n .map((block) => block.text)\n .join('\\n');\n const color = context.isError ? 'error' : 'toolOutput';\n const fallback = context.isError ? '✗ failed' : '✓ submitted';\n return new DoomToolResult([theme.fg(color, raw || fallback)], theme, { wrap: true });\n }\n if (details.cancelled) {\n return new DoomToolResult([theme.fg('warning', '◐') + theme.fg('dim', ' cancelled')], theme);\n }\n if (details.delivery === 'voice' && details.voicePrompt) {\n return new DoomToolResult([theme.fg('toolOutput', details.voicePrompt)], theme, { wrap: true });\n }\n const lines = details.answers.map((answer) => {\n const scalar = answer.kind === 'multi' ? (answer.selected ?? []).join(', ') : answer.answer;\n return `${theme.fg('success', '✓')} ${theme.fg('accent', answer.question)}: ${theme.fg(\n 'toolOutput',\n scalar ?? '',\n )}`;\n });\n if (lines.length === 0) lines.push(theme.fg('success', '✓') + theme.fg('dim', ' submitted'));\n return new DoomToolResult(lines, theme, { wrap: true });\n },\n};\n","import fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\n\nexport const DEFAULT_COLLAPSE_KEY = 'ctrl+]';\nexport const COLLAPSE_KEY_OFF = 'off';\n\nexport interface GuidanceConfig {\n promptSnippet?: string;\n promptGuidelines?: string[];\n}\n\nexport interface UserFeedbackConfig {\n collapseKey?: string;\n guidance?: GuidanceConfig;\n}\n\nfunction legacyConfigPath(environment: NodeJS.ProcessEnv): string {\n const configRoot = environment.XDG_CONFIG_HOME?.trim() || path.join(os.homedir(), '.config');\n return path.join(configRoot, 'rpiv-ask-user-question', 'config.json');\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nexport function loadUserFeedbackConfig(environment: NodeJS.ProcessEnv = process.env): UserFeedbackConfig {\n const filePath = legacyConfigPath(environment);\n if (!fs.existsSync(filePath)) return {};\n try {\n const parsed: unknown = JSON.parse(fs.readFileSync(filePath, 'utf8'));\n if (!isRecord(parsed)) return {};\n const rawGuidance = isRecord(parsed.guidance) ? parsed.guidance : undefined;\n const guidance = rawGuidance\n ? {\n ...(typeof rawGuidance.promptSnippet === 'string' ? { promptSnippet: rawGuidance.promptSnippet } : {}),\n ...(Array.isArray(rawGuidance.promptGuidelines) &&\n rawGuidance.promptGuidelines.every((item) => typeof item === 'string')\n ? { promptGuidelines: rawGuidance.promptGuidelines as string[] }\n : {}),\n }\n : undefined;\n return {\n ...(typeof parsed.collapseKey === 'string' ? { collapseKey: parsed.collapseKey } : {}),\n ...(guidance ? { guidance } : {}),\n };\n } catch {\n return {};\n }\n}\n\nexport function resolveCollapseKey(config: UserFeedbackConfig): string {\n const value = config.collapseKey?.trim().toLowerCase();\n if (!value) return DEFAULT_COLLAPSE_KEY;\n if (value === COLLAPSE_KEY_OFF) return COLLAPSE_KEY_OFF;\n return /^[a-z0-9_+\\-\\]{}]+$/u.test(value) ? value : DEFAULT_COLLAPSE_KEY;\n}\n","import type { ExtensionContext } from '@earendil-works/pi-coding-agent';\n\nimport type { QuestionParams } from '../../schemas/questionnaire';\nimport type { QuestionnaireResult } from '../../types/questionnaire';\nimport { runQuestionnaire, type QuestionnaireInteraction } from '../questionnaireService';\n\nexport async function runRpcQuestionnaire(\n context: ExtensionContext,\n params: QuestionParams,\n signal?: AbortSignal,\n reportProgress?: (result: QuestionnaireResult) => void,\n): Promise<QuestionnaireResult> {\n const interaction: QuestionnaireInteraction = {\n select: (title, options, interactionSignal) =>\n context.ui.select(title, [...options], { signal: interactionSignal }),\n input: (title, placeholder, interactionSignal) =>\n context.ui.input(title, placeholder, { signal: interactionSignal }),\n };\n return runQuestionnaire(interaction, params, signal, reportProgress);\n}\n","import {\n type AskUserBlockedEvent,\n type AskUserPromptEvent,\n DOOM_ASK_USER_BLOCKED_EVENT,\n DOOM_ASK_USER_PROMPT_EVENT,\n} from '@agimon-ai/doompi-core/askUser';\nimport type { Context } from '@deepseek-ai/cordis';\nimport type { ToolDefinition, ExtensionContext } from '@earendil-works/pi-coding-agent';\n\nimport {\n ASK_USER_QUESTION_TOOL_NAME,\n DEFAULT_PROMPT_SNIPPET,\n DEFAULT_PROMPT_GUIDELINES,\n ERROR_NO_UI,\n ERROR_NO_CUSTOM_UI,\n ERROR_SESSION_LOAD_FAILED,\n ERROR_SESSION_INACTIVE,\n} from '../../../../../constants/tool';\nimport { type QuestionParams, QuestionParamsSchema } from '../../../../../schemas/questionnaire';\nimport { loadUserFeedbackConfig, resolveCollapseKey } from '../../../../../services/config';\nimport type { QuestionnaireRunner } from '../../../../../services/questionnaireCoordinator';\nimport { buildQuestionnaireResponse, buildToolResult } from '../../../../../services/responseService';\nimport { runRpcQuestionnaire } from '../../../../../services/rpcQuestionnaire';\nimport { validateQuestionnaire } from '../../../../../services/validationService';\nimport { buildVoiceToolResult } from '../../../../../services/voiceQuestionHandoff';\nimport type { QuestionnaireResult } from '../../../../../types/questionnaire';\nexport interface AskUserQuestionToolDependencies {\n enqueue: (runner: QuestionnaireRunner, signal?: AbortSignal) => Promise<QuestionnaireResult>;\n isActive?: (context: ExtensionContext, signal?: AbortSignal) => boolean;\n tryVoice?: (params: QuestionParams) => QuestionnaireResult | undefined | Promise<QuestionnaireResult | undefined>;\n runTui: (\n context: ExtensionContext,\n params: QuestionParams,\n collapseKey: string,\n signal?: AbortSignal,\n reportProgress?: (result: QuestionnaireResult) => void,\n ) => Promise<QuestionnaireResult | undefined>;\n}\n\nfunction emitPrompt(cordis: Context, params: QuestionParams): void {\n const payload: AskUserPromptEvent = {\n questions: params.questions.map((question) => ({\n question: question.question,\n header: question.header,\n multiSelect: question.multiSelect ?? false,\n options: question.options.map((option) => ({\n label: option.label,\n description: option.description,\n hasPreview: Boolean(option.preview),\n })),\n })),\n };\n cordis.emit(DOOM_ASK_USER_PROMPT_EVENT, payload);\n}\n\nfunction emitBlocked(cordis: Context, active: boolean): void {\n const payload: AskUserBlockedEvent = { active };\n cordis.emit(DOOM_ASK_USER_BLOCKED_EVENT, payload);\n}\n\nfunction hasDialogUI(context: ExtensionContext): boolean {\n const ui = context.ui as unknown as { select?: unknown; input?: unknown };\n return typeof ui.select === 'function' && typeof ui.input === 'function';\n}\n\nexport function createAskUserQuestionTool(\n cordis: Context,\n dependencies: AskUserQuestionToolDependencies,\n renderers: Pick<ToolDefinition<typeof QuestionParamsSchema, QuestionnaireResult>, 'renderCall' | 'renderResult'> = {},\n): ToolDefinition<typeof QuestionParamsSchema, QuestionnaireResult> {\n const configuredGuidance = loadUserFeedbackConfig().guidance;\n return {\n name: ASK_USER_QUESTION_TOOL_NAME,\n label: 'Ask User Question',\n renderShell: 'self',\n description: `Ask the user one or more structured questions during execution. Use when you need to:\n1. Gather user preferences or requirements\n2. Clarify ambiguous instructions\n3. Get decisions on implementation choices as you work\n4. Offer choices to the user about what direction to take\n\nUsage notes:\n- Users can type a custom answer via the automatically appended \"Type something.\" row on every question or press Esc to abandon the questionnaire. Do NOT author \"Other\" or \"Type something.\" labels yourself, reserved labels are rejected at runtime.\n- Use multiSelect: true when multiple answers are valid.\n- If you recommend a specific option, make that the first option and add \"(Recommended)\" at the end of the label.\n\nPreview feature:\nUse the optional preview field for ASCII mockups, code snippets, diagrams, or configuration examples that users should compare visually. Do not use previews for simple preference questions.`,\n promptSnippet: configuredGuidance?.promptSnippet ?? DEFAULT_PROMPT_SNIPPET,\n promptGuidelines: configuredGuidance?.promptGuidelines ?? DEFAULT_PROMPT_GUIDELINES,\n parameters: QuestionParamsSchema,\n executionMode: 'sequential',\n\n async execute(_toolCallId, params, signal, _onUpdate, context) {\n const typed = params as QuestionParams;\n const isActive = (activeSignal?: AbortSignal): boolean => dependencies.isActive?.(context, activeSignal) ?? true;\n const cancelled = (): QuestionnaireResult => ({ answers: [], cancelled: true });\n if (!isActive(signal)) return buildToolResult(ERROR_SESSION_INACTIVE, cancelled());\n if (!context.hasUI) {\n return buildToolResult(ERROR_NO_UI, { answers: [], cancelled: true, error: 'no_ui' });\n }\n\n const validation = validateQuestionnaire(typed);\n if (!validation.ok) {\n return buildToolResult(validation.message, {\n answers: [],\n cancelled: true,\n error: validation.error,\n });\n }\n\n try {\n const result = await dependencies.enqueue(async ({ signal: activeSignal, reportProgress }) => {\n if (!isActive(activeSignal)) return cancelled();\n emitPrompt(cordis, typed);\n const voiceResult = await dependencies.tryVoice?.(typed);\n if (voiceResult) return voiceResult;\n\n let blocked = true;\n const clearBlocked = (): void => {\n if (!blocked) return;\n blocked = false;\n if (isActive()) emitBlocked(cordis, false);\n };\n activeSignal.addEventListener('abort', clearBlocked, { once: true });\n emitBlocked(cordis, true);\n try {\n if (!isActive(activeSignal)) return cancelled();\n if (context.mode === 'rpc' && hasDialogUI(context)) {\n const rpcResult = await runRpcQuestionnaire(context, typed, activeSignal, reportProgress);\n return isActive(activeSignal) ? rpcResult : cancelled();\n }\n\n const tuiResult = await dependencies.runTui(\n context,\n typed,\n resolveCollapseKey(loadUserFeedbackConfig()),\n activeSignal,\n reportProgress,\n );\n if (!isActive(activeSignal)) return cancelled();\n if (tuiResult !== undefined) return tuiResult;\n if (hasDialogUI(context)) {\n const rpcResult = await runRpcQuestionnaire(context, typed, activeSignal, reportProgress);\n return isActive(activeSignal) ? rpcResult : cancelled();\n }\n return { answers: [], cancelled: true, error: 'no_custom_ui' };\n } finally {\n activeSignal.removeEventListener('abort', clearBlocked);\n clearBlocked();\n }\n }, signal);\n\n if (result.delivery === 'voice') return buildVoiceToolResult(result);\n if (result.error === 'no_custom_ui') return buildToolResult(ERROR_NO_CUSTOM_UI, result);\n return buildQuestionnaireResponse(result, typed);\n } catch (error) {\n const cause = error instanceof Error ? error.message : String(error);\n return buildToolResult(`${ERROR_SESSION_LOAD_FAILED} (cause: ${cause})`, {\n answers: [],\n cancelled: true,\n error: 'session_load_failed',\n });\n }\n },\n\n ...renderers,\n };\n}\n","import { defineCliTool, type WithRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport { definePiTool, type PiPluginContext } from '@agimon-ai/doompi-core/piExtension';\n\nimport { askUserToolRender } from '../../../../../tui/askUserToolRender';\nimport type { UserFeedbackPiScope } from '../_lib/root.cli';\nimport { createAskUserQuestionTool } from '../_tools/askUserQuestion';\n\nexport default defineCliTool((context: WithRoot<PiPluginContext, UserFeedbackPiScope>) =>\n definePiTool(createAskUserQuestionTool(context.context, context.root.toolDependencies, askUserToolRender)),\n);\n","// Generated by @agimon-ai/doompi-build. Do not edit by hand.\nimport { definePiExtension, piToolContributions, type PiPluginContext, type PiPluginContributions } from '@agimon-ai/doompi-core/piExtension';\nimport { composeRootHooks } from '@agimon-ai/doompi-core/extensionFile';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.cli';\nimport hookBeforeAgentStart from '../src/extensions/workspaces/sessions/(backend)/hook/before-agent-start.cli';\nimport hookSessionStart from '../src/extensions/workspaces/sessions/(backend)/hook/session-start.cli';\nimport resourceDoompiUseUserFeedback from '../src/extensions/workspaces/sessions/(backend)/resource/doompi-use-user-feedback.cli';\nimport toolRestrictionAskUserQuestion from '../src/extensions/workspaces/sessions/(backend)/tool-restriction/ask-user-question.cli';\nimport toolAskUserQuestion from '../src/extensions/workspaces/sessions/(backend)/tool/askUserQuestion.cli';\n\ntype OptionsOf<T> = T extends (context: PiPluginContext<infer Options>) => unknown ? Options : never;\ntype InferredOptions = Exclude<OptionsOf<typeof rootSession> | OptionsOf<typeof hookBeforeAgentStart> | OptionsOf<typeof hookSessionStart> | OptionsOf<typeof resourceDoompiUseUserFeedback> | OptionsOf<typeof toolRestrictionAskUserQuestion> | OptionsOf<typeof toolAskUserQuestion>, undefined>;\ntype Intersect<Union> =\n (Union extends unknown ? (value: Union) => void : never) extends (value: infer Value) => void ? Value : never;\ntype ExtensionOptions = [InferredOptions] extends [never] ? undefined : Intersect<InferredOptions>;\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T => ({ ...identity, ...(value as object) }) as T;\n\nexport const extension = definePiExtension<ExtensionOptions>('@agimon-ai/doompi-user-feedback', async (context) => {\n const scopeSession = await rootSession(context);\n const contextSession = { ...context, root: scopeSession.value };\n return {\n ...composeRootHooks(scopeSession),\n events: {\n before_agent_start: at(hookBeforeAgentStart, contextSession) as NonNullable<PiPluginContributions['events']>['before_agent_start'],\n session_start: at(hookSessionStart, contextSession) as NonNullable<PiPluginContributions['events']>['session_start'],\n },\n get resources(): PiPluginContributions['resources'] { return [at(resourceDoompiUseUserFeedback, contextSession)]; },\n get toolRestrictions(): PiPluginContributions['toolRestrictions'] { return [at(toolRestrictionAskUserQuestion, contextSession)]; },\n ...piToolContributions('@agimon-ai/doompi-user-feedback', [via({ name: 'ask_user_question' }, at(toolAskUserQuestion, contextSession))]),\n services: [...(scopeSession.services ?? [])],\n };\n});\n\nexport default extension;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,SAAgB,uBAAuB,UAAkB,SAAuC;CAC9F,QAAQ,aAAc,UAAU,WAAW,SAAS,QAAQ,SAAS,SAAS,QAAQ;AACxF;;;;;;;;;;ACHA,SAAgB,wBAAwB,QAAkC;CACxE,OACE,OAAO,WAAW,WAAWA,kCAAAA,qBAC7B,OAAO,WAAW,OAAOC,kCAAAA,2BACzB,OAAO,MAAM,eAAe;AAEhC;AAEA,SAAgB,wBAAwB,SAA8C;CACpF,OAAO,QAAQ,MAAM,WAAW,wBAAwB,MAAM,CAAC;AAC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F,CAAC"}
|
|
1
|
+
{"version":3,"file":"pi.cjs","names":["DOOM_VOICE_SOURCE","DOOM_VOICE_AUTO_MODE_ID","MAX_NARRATION_TEXT_CHARACTERS","createNarrationRequest","defineRoot","QuestionnaireCoordinator","ASK_USER_QUESTION_TOOL_NAME","DOOM_MINOR_MODE_CATALOG_SERVICE","DOOM_NARRATION_SERVICE","requireMinorModeCatalog","requireDoomNarrationService","defineRoot","contribution","defineCliHook","contribution","defineCliHook","contribution","defineResource","defineToolRestriction","contribution","renderToolHeading","DoomToolCall","DoomToolResult","path","os","fs","runQuestionnaire","DOOM_ASK_USER_PROMPT_EVENT","DOOM_ASK_USER_BLOCKED_EVENT","ASK_USER_QUESTION_TOOL_NAME","DEFAULT_PROMPT_SNIPPET","DEFAULT_PROMPT_GUIDELINES","QuestionParamsSchema","buildToolResult","ERROR_SESSION_INACTIVE","ERROR_NO_UI","validateQuestionnaire","ERROR_NO_CUSTOM_UI","buildQuestionnaireResponse","ERROR_SESSION_LOAD_FAILED","defineCliTool","definePiTool","definePiExtension","rootSession","composeRootHooks","hookBeforeAgentStart","hookSessionStart","resourceDoompiUseUserFeedback","toolRestrictionAskUserQuestion","piToolContributions","toolAskUserQuestion"],"sources":["../../src/services/askUserToolGate/index.ts","../../src/services/autonomousVoiceMode/index.ts","../../src/services/voiceQuestionNarration/index.ts","../../src/services/voiceQuestionHandoff/index.ts","../../src/extensions/workspaces/sessions/(backend)/_lib/root.cli.ts","../../src/extensions/workspaces/sessions/(backend)/root.cli.ts","../../src/extensions/workspaces/sessions/(backend)/hook/_lib/before-agent-start.cli.ts","../../src/extensions/workspaces/sessions/(backend)/hook/before-agent-start.cli.ts","../../src/extensions/workspaces/sessions/(backend)/hook/_lib/session-start.cli.ts","../../src/extensions/workspaces/sessions/(backend)/hook/session-start.cli.ts","../../src/extensions/workspaces/sessions/(backend)/resource/_lib/doompi-use-user-feedback.cli.ts","../../src/extensions/workspaces/sessions/(backend)/resource/doompi-use-user-feedback.cli.ts","../../src/extensions/workspaces/sessions/(backend)/tool-restriction/_lib/ask-user-question.cli.ts","../../src/extensions/workspaces/sessions/(backend)/tool-restriction/ask-user-question.cli.ts","../../src/tui/askUserToolRender.ts","../../src/services/config/index.ts","../../src/services/rpcQuestionnaire/index.ts","../../src/extensions/workspaces/sessions/(backend)/_tools/askUserQuestion.ts","../../src/extensions/workspaces/sessions/(backend)/tool/askUserQuestion.cli.ts","../../generated/pi.ts"],"sourcesContent":["import type { DoomToolRestriction } from '@agimon-ai/doompi-core/toolSurface';\n\n/**\n * Hides the questionnaire tool while nobody can answer it.\n *\n * Autonomous Voice narrates its own question and then waits for the spoken reply, so a\n * questionnaire tool alongside it asks the same thing twice. A run without UI cannot render\n * the questionnaire at all. Both cases only ever remove the name: the tool surface recomputes\n * from every registered tool, so a visible gate restores it without tracking what it hid.\n */\nexport function askUserToolRestriction(toolName: string, visible: boolean): DoomToolRestriction {\n return (incoming) => (visible ? incoming : incoming.filter((name) => name !== toolName));\n}\n","import { DOOM_VOICE_AUTO_MODE_ID, DOOM_VOICE_SOURCE } from '@agimon-ai/doompi-core/voiceTools';\nimport type { MinorModeRecord } from '@agimon-ai/doompi-minor-mode';\n/**\n * Matches only the Voice package's own autonomous mode, and only while it reports active.\n *\n * Both the source and the mode id are checked because another package may register a mode\n * under the same id, and a transitional `activating` or `deactivating` record is not yet\n * (or no longer) speaking.\n */\nexport function isAutonomousVoiceRecord(record: MinorModeRecord): boolean {\n return (\n record.descriptor.source === DOOM_VOICE_SOURCE &&\n record.descriptor.id === DOOM_VOICE_AUTO_MODE_ID &&\n record.state.activation === 'active'\n );\n}\n\nexport function isAutonomousVoiceActive(records: readonly MinorModeRecord[]): boolean {\n return records.some((record) => isAutonomousVoiceRecord(record));\n}\n","import { MAX_NARRATION_TEXT_CHARACTERS } from '@agimon-ai/doompi-core/narration';\n\nimport type { QuestionParams } from '../../schemas/questionnaire';\n\nconst MAX_QUESTION_CHARACTERS = 240;\nconst MAX_OPTION_CHARACTERS = 80;\nconst PATH_PATTERN = /\\/(?:Users|home|private|tmp|var)\\/[^\\s,;:]+/gu;\nconst TOKEN_PATTERN = /\\b(?:sk|api|token|key)[-_][A-Za-z0-9_-]{12,}\\b/giu;\nconst CODE_PATTERN = /`[^`]*`|<\\/?[A-Za-z][^>]*>|\\$\\([^)]*\\)|\\{[^}]*\\}/gu;\nconst SAFE_FALLBACK = 'I need your answer to the questions shown in the conversation.';\n\nfunction takeCharacters(text: string, maximum: number): string {\n return Array.from(text).slice(0, maximum).join('').trim();\n}\n\nexport function sanitizeVoiceQuestionText(text: string, maximum: number): string {\n const withoutControls = Array.from(text, (character) => {\n const codePoint = character.codePointAt(0) ?? 0;\n return codePoint < 32 || codePoint === 127 ? ' ' : character;\n }).join('');\n return takeCharacters(\n withoutControls\n .replace(PATH_PATTERN, ' ')\n .replace(TOKEN_PATTERN, ' ')\n .replace(CODE_PATTERN, ' ')\n .replace(/\\s+/gu, ' ')\n .trim(),\n maximum,\n );\n}\n\nfunction spokenQuestion(params: QuestionParams, questionIndex: number): string {\n const question = params.questions[questionIndex];\n if (!question) return '';\n const position = questionIndex + 1;\n const prompt =\n sanitizeVoiceQuestionText(question.question, MAX_QUESTION_CHARACTERS) || `Question ${position} needs your choice`;\n const labels = question.options.map((option, optionIndex) => {\n const label = sanitizeVoiceQuestionText(option.label, MAX_OPTION_CHARACTERS);\n return `${optionIndex + 1}, ${label || `option ${optionIndex + 1}`}`;\n });\n const selection = question.multiSelect ? 'You may choose more than one option.' : 'Please choose one option.';\n return `Question ${position}: ${prompt}. Options: ${labels.join('; ')}. ${selection} You may also answer in your own words.`;\n}\n\nexport function buildVoiceQuestionNarration(params: QuestionParams): string {\n const questions = params.questions.map((_question, index) => spokenQuestion(params, index));\n const combined = sanitizeVoiceQuestionText(questions.join(' '), MAX_NARRATION_TEXT_CHARACTERS);\n return combined || SAFE_FALLBACK;\n}\n","import { createNarrationRequest, type DoomNarrationService } from '@agimon-ai/doompi-core/narration';\nimport type { MinorModeCatalogService } from '@agimon-ai/doompi-minor-mode';\n\nimport type { QuestionParams } from '../../schemas/questionnaire';\nimport type { QuestionnaireResult, ToolTextResult } from '../../types/questionnaire';\nimport { isAutonomousVoiceRecord } from '../autonomousVoiceMode';\nimport { buildVoiceQuestionNarration } from '../voiceQuestionNarration';\n\nexport const VOICE_WAIT_MESSAGE =\n \"The questions were spoken through autonomous voice. Stop now and wait for the user's next message; it will arrive as an ordinary user message.\";\n\nexport function formatVoiceQuestionPrompt(params: QuestionParams): string {\n const numberQuestions = params.questions.length > 1;\n return params.questions\n .map((question, questionIndex) => {\n const heading = `${numberQuestions ? `${questionIndex + 1}. ` : ''}${question.question}${question.multiSelect ? ' (Select all that apply.)' : ''}`;\n const options = question.options.map((option, optionIndex) => ` ${optionIndex + 1}. ${option.label}`);\n return [heading, ...options, ' Type something.'].join('\\n');\n })\n .join('\\n\\n');\n}\n\nexport class VoiceQuestionHandoff {\n constructor(\n private readonly modes: Pick<MinorModeCatalogService, 'list'>,\n private readonly narration: Pick<DoomNarrationService, 'request'>,\n private readonly buildNarration: (params: QuestionParams) => string = buildVoiceQuestionNarration,\n ) {}\n\n async handoff(params: QuestionParams): Promise<QuestionnaireResult | undefined> {\n if (!this.modes.list().some((record) => isAutonomousVoiceRecord(record))) return undefined;\n const narration = createNarrationRequest(this.buildNarration(params));\n if (!narration) return undefined;\n await this.narration.request(narration);\n return {\n answers: [],\n cancelled: false,\n delivery: 'voice',\n awaitingResponse: true,\n voicePrompt: formatVoiceQuestionPrompt(params),\n };\n }\n}\n\n/** Create a handoff from services whose lifecycle is owned by a Cordis injection. */\nexport function createVoiceQuestionHandoff(\n modes: Pick<MinorModeCatalogService, 'list'>,\n narration: Pick<DoomNarrationService, 'request'>,\n): VoiceQuestionHandoff {\n return new VoiceQuestionHandoff(modes, narration);\n}\n\nexport function buildVoiceToolResult(details: QuestionnaireResult): ToolTextResult {\n const prompt = details.voicePrompt?.trim();\n return {\n content: [{ type: 'text', text: prompt ? `${prompt}\\n\\n${VOICE_WAIT_MESSAGE}` : VOICE_WAIT_MESSAGE }],\n details,\n terminate: true,\n };\n}\n","import { defineRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport { DOOM_NARRATION_SERVICE, requireDoomNarrationService } from '@agimon-ai/doompi-core/narration';\nimport type { PiPluginContext } from '@agimon-ai/doompi-core/piExtension';\nimport type { DoomToolRestriction } from '@agimon-ai/doompi-core/toolSurface';\nimport { DOOM_MINOR_MODE_CATALOG_SERVICE, requireMinorModeCatalog } from '@agimon-ai/doompi-minor-mode';\nimport type { Context } from '@deepseek-ai/cordis';\nimport type { ExtensionContext } from '@earendil-works/pi-coding-agent';\n\nimport { ASK_USER_QUESTION_TOOL_NAME } from '../../../../../constants/tool';\nimport { askUserToolRestriction } from '../../../../../services/askUserToolGate';\nimport { isAutonomousVoiceActive } from '../../../../../services/autonomousVoiceMode';\nimport { QuestionnaireCoordinator, type QuestionnaireRunner } from '../../../../../services/questionnaireCoordinator';\nimport { createVoiceQuestionHandoff, type VoiceQuestionHandoff } from '../../../../../services/voiceQuestionHandoff';\nimport type { QuestionnaireResult } from '../../../../../types/questionnaire';\nimport { createAskUserQuestionTool } from '.././_tools/askUserQuestion';\n\nfunction cancelledResult(): QuestionnaireResult {\n return { answers: [], cancelled: true };\n}\n\nconst root = defineRoot((_context: PiPluginContext) => {\n let active = true;\n let sessionGeneration = 0;\n let sessionId: string | undefined;\n let sessionReady = false;\n let coordinator = new QuestionnaireCoordinator();\n let voiceHandoff: VoiceQuestionHandoff | undefined;\n let voiceActive = false;\n let hasUI = true;\n const restrictionListeners = new Set<() => void>();\n const currentRestriction = (): DoomToolRestriction =>\n askUserToolRestriction(ASK_USER_QUESTION_TOOL_NAME, hasUI && !voiceActive);\n const syncToolRestriction = (): void => restrictionListeners.forEach((listener) => listener());\n let lifecycleQueue: Promise<void> = Promise.resolve();\n const pendingOperations = new Set<Promise<unknown>>();\n\n const trackOperation = <T>(operation: Promise<T>): Promise<T> => {\n pendingOperations.add(operation);\n void operation.then(\n () => pendingOperations.delete(operation),\n () => pendingOperations.delete(operation),\n );\n return operation;\n };\n const ownsGeneration = (generation: number, expectedSessionId: string | undefined): boolean =>\n active && generation === sessionGeneration && expectedSessionId === sessionId;\n const isContextActive = (context: ExtensionContext, signal?: AbortSignal): boolean =>\n active && sessionReady && signal?.aborted !== true && context.sessionManager.getSessionId() === sessionId;\n\n const shutdownRuntime = async (): Promise<void> => {\n if (!active) return;\n const ownedCoordinator = coordinator;\n ownedCoordinator.shutdown();\n active = false;\n sessionGeneration += 1;\n sessionReady = false;\n sessionId = undefined;\n await Promise.allSettled(pendingOperations);\n await ownedCoordinator.waitForIdle();\n };\n\n const toolDependencies: Parameters<typeof createAskUserQuestionTool>[1] = {\n enqueue: (runner: QuestionnaireRunner, signal?: AbortSignal) => {\n const ownedCoordinator = coordinator;\n const generation = sessionGeneration;\n const expectedSessionId = sessionId;\n if (!sessionReady || !ownsGeneration(generation, expectedSessionId) || signal?.aborted) {\n return Promise.resolve(cancelledResult());\n }\n return ownedCoordinator.enqueue(async (context) => {\n if (!sessionReady || !ownsGeneration(generation, expectedSessionId) || context.signal.aborted) {\n return cancelledResult();\n }\n const result = await runner({\n ...context,\n reportProgress: (progress) => {\n if (ownsGeneration(generation, expectedSessionId) && !context.signal.aborted) {\n context.reportProgress(progress);\n }\n },\n });\n return sessionReady && ownsGeneration(generation, expectedSessionId) && !context.signal.aborted\n ? result\n : cancelledResult();\n }, signal);\n },\n isActive: isContextActive,\n runTui: async (context, params, collapseKey, signal, reportProgress) => {\n if (!isContextActive(context, signal)) return undefined;\n const { runTuiQuestionnaire } = await import('../../../../../tui/runQuestionnaire');\n if (!isContextActive(context, signal)) return undefined;\n const result = await runTuiQuestionnaire(context, params, collapseKey, signal, reportProgress);\n return isContextActive(context, signal) ? result : undefined;\n },\n tryVoice: (params) => (active && sessionReady ? voiceHandoff?.handoff(params) : undefined),\n };\n\n const beforeAgentStart = (_event: unknown, context: ExtensionContext) => {\n if (!isContextActive(context)) return;\n hasUI = context.hasUI;\n syncToolRestriction();\n };\n\n const sessionStart = (_event: unknown, context: ExtensionContext) => {\n if (!active) return;\n const previousCoordinator = coordinator;\n previousCoordinator.shutdown();\n const activeSessionId = context.sessionManager.getSessionId();\n const generation = ++sessionGeneration;\n const nextCoordinator = new QuestionnaireCoordinator();\n coordinator = nextCoordinator;\n sessionId = activeSessionId;\n sessionReady = false;\n\n const initializeSession = async (): Promise<void> => {\n await previousCoordinator.waitForIdle();\n if (!ownsGeneration(generation, activeSessionId)) return;\n sessionReady = true;\n // The surface is re-registered per session from the gate state in force, so a session\n // that starts with Voice already active needs nothing extra here.\n };\n\n const operation = lifecycleQueue.then(initializeSession, initializeSession);\n lifecycleQueue = operation.catch(() => undefined);\n return trackOperation(operation);\n };\n const toolRestriction = {\n source: '@agimon-ai/doompi-user-feedback',\n get restrict() {\n return currentRestriction();\n },\n subscribe(listener: () => void) {\n restrictionListeners.add(listener);\n return () => {\n restrictionListeners.delete(listener);\n };\n },\n };\n\n return {\n value: {\n toolDependencies,\n beforeAgentStart,\n sessionStart,\n toolRestriction,\n },\n services: [\n (serviceContextOwner: Context) => {\n serviceContextOwner.inject([DOOM_MINOR_MODE_CATALOG_SERVICE, DOOM_NARRATION_SERVICE], (serviceContext) => {\n const handoff = createVoiceQuestionHandoff(\n requireMinorModeCatalog(serviceContext),\n requireDoomNarrationService(serviceContext),\n );\n voiceHandoff = handoff;\n return () => {\n if (voiceHandoff === handoff) voiceHandoff = undefined;\n };\n });\n\n // Separate from the handoff binding above: the gate needs only the mode catalog, so it\n // still applies to a Voice build that publishes modes without providing narration.\n serviceContextOwner.inject([DOOM_MINOR_MODE_CATALOG_SERVICE], (modeContext) => {\n const modes = requireMinorModeCatalog(modeContext);\n const apply = (): void => {\n voiceActive = isAutonomousVoiceActive(modes.list());\n syncToolRestriction();\n };\n const unsubscribe = modes.subscribe(apply);\n apply();\n return () => {\n unsubscribe();\n voiceActive = false;\n syncToolRestriction();\n };\n });\n },\n ],\n onDispose: shutdownRuntime,\n };\n});\n\nexport type UserFeedbackPiScope = Awaited<ReturnType<typeof root>>['value'];\nexport default root;\n","import { defineRoot } from '@agimon-ai/doompi-core/extensionFile';\n\nimport contribution from './_lib/root.cli';\n\nexport default defineRoot(contribution);\n","import type { WithRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport type { PiPluginContext } from '@agimon-ai/doompi-core/piExtension';\n\nimport type { UserFeedbackPiScope } from '../../_lib/root.cli';\n\nexport default (context: WithRoot<PiPluginContext, UserFeedbackPiScope>) => context.root.beforeAgentStart;\n","import { defineCliHook } from '@agimon-ai/doompi-core/extensionFile';\n\nimport contribution from './_lib/before-agent-start.cli';\n\nexport default defineCliHook(contribution);\n","import type { WithRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport type { PiPluginContext } from '@agimon-ai/doompi-core/piExtension';\n\nimport type { UserFeedbackPiScope } from '../../_lib/root.cli';\n\nexport default (context: WithRoot<PiPluginContext, UserFeedbackPiScope>) => context.root.sessionStart;\n","import { defineCliHook } from '@agimon-ai/doompi-core/extensionFile';\n\nimport contribution from './_lib/session-start.cli';\n\nexport default defineCliHook(contribution);\n","export function createDoompiUseUserFeedbackResource(moduleUrl: string) {\n return {\n source: '@agimon-ai/doompi-user-feedback',\n moduleUrl,\n skills: [\n {\n name: 'doompi-use-user-feedback',\n description:\n 'Use @agimon-ai/doompi-user-feedback: Structured user questions with interactive and autonomous Voice handoff for Pi agents.',\n },\n ],\n };\n}\n","import { defineResource } from '@agimon-ai/doompi-core/extensionFile';\n\nimport { createDoompiUseUserFeedbackResource } from './_lib/doompi-use-user-feedback.cli';\n\nexport default defineResource(createDoompiUseUserFeedbackResource(import.meta.url));\n","import type { WithRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport type { PiPluginContext } from '@agimon-ai/doompi-core/piExtension';\n\nimport type { UserFeedbackPiScope } from '../../_lib/root.cli';\n\nexport default (context: WithRoot<PiPluginContext, UserFeedbackPiScope>) => context.root.toolRestriction;\n","import { defineToolRestriction } from '@agimon-ai/doompi-core/extensionFile';\n\nimport contribution from './_lib/ask-user-question.cli';\n\nexport default defineToolRestriction(contribution);\n","import { DoomToolCall, DoomToolResult, renderToolHeading } from '@agimon-ai/doompi-ui/toolChrome';\nimport type { ToolDefinition } from '@earendil-works/pi-coding-agent';\n\nimport type { QuestionParams, QuestionParamsSchema } from '../schemas/questionnaire';\nimport type { QuestionnaireResult } from '../types/questionnaire';\nexport const askUserToolRender: Pick<\n ToolDefinition<typeof QuestionParamsSchema, QuestionnaireResult>,\n 'renderCall' | 'renderResult'\n> = {\n renderCall(args, theme) {\n const params = args as QuestionParams;\n const headers = params.questions.map((question) => question.header).join(', ');\n const count = `${params.questions.length} question${params.questions.length === 1 ? '' : 's'}`;\n const heading = renderToolHeading('ask', count, theme);\n return new DoomToolCall(headers ? `${heading} ${theme.fg('dim', `(${headers})`)}` : heading);\n },\n\n renderResult(result, _options, theme, context) {\n const details = result.details as QuestionnaireResult | undefined;\n if (!details) {\n const raw = result.content\n .filter((block) => block.type === 'text')\n .map((block) => block.text)\n .join('\\n');\n const color = context.isError ? 'error' : 'toolOutput';\n const fallback = context.isError ? '✗ failed' : '✓ submitted';\n return new DoomToolResult([theme.fg(color, raw || fallback)], theme, { wrap: true });\n }\n if (details.cancelled) {\n return new DoomToolResult([theme.fg('warning', '◐') + theme.fg('dim', ' cancelled')], theme);\n }\n if (details.delivery === 'voice' && details.voicePrompt) {\n return new DoomToolResult([theme.fg('toolOutput', details.voicePrompt)], theme, { wrap: true });\n }\n const lines = details.answers.map((answer) => {\n const scalar = answer.kind === 'multi' ? (answer.selected ?? []).join(', ') : answer.answer;\n return `${theme.fg('success', '✓')} ${theme.fg('accent', answer.question)}: ${theme.fg(\n 'toolOutput',\n scalar ?? '',\n )}`;\n });\n if (lines.length === 0) lines.push(theme.fg('success', '✓') + theme.fg('dim', ' submitted'));\n return new DoomToolResult(lines, theme, { wrap: true });\n },\n};\n","import fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\n\nexport const DEFAULT_COLLAPSE_KEY = 'ctrl+]';\nexport const COLLAPSE_KEY_OFF = 'off';\n\nexport interface GuidanceConfig {\n promptSnippet?: string;\n promptGuidelines?: string[];\n}\n\nexport interface UserFeedbackConfig {\n collapseKey?: string;\n guidance?: GuidanceConfig;\n}\n\nfunction legacyConfigPath(environment: NodeJS.ProcessEnv): string {\n const configRoot = environment.XDG_CONFIG_HOME?.trim() || path.join(os.homedir(), '.config');\n return path.join(configRoot, 'rpiv-ask-user-question', 'config.json');\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nexport function loadUserFeedbackConfig(environment: NodeJS.ProcessEnv = process.env): UserFeedbackConfig {\n const filePath = legacyConfigPath(environment);\n if (!fs.existsSync(filePath)) return {};\n try {\n const parsed: unknown = JSON.parse(fs.readFileSync(filePath, 'utf8'));\n if (!isRecord(parsed)) return {};\n const rawGuidance = isRecord(parsed.guidance) ? parsed.guidance : undefined;\n const guidance = rawGuidance\n ? {\n ...(typeof rawGuidance.promptSnippet === 'string' ? { promptSnippet: rawGuidance.promptSnippet } : {}),\n ...(Array.isArray(rawGuidance.promptGuidelines) &&\n rawGuidance.promptGuidelines.every((item) => typeof item === 'string')\n ? { promptGuidelines: rawGuidance.promptGuidelines as string[] }\n : {}),\n }\n : undefined;\n return {\n ...(typeof parsed.collapseKey === 'string' ? { collapseKey: parsed.collapseKey } : {}),\n ...(guidance ? { guidance } : {}),\n };\n } catch {\n return {};\n }\n}\n\nexport function resolveCollapseKey(config: UserFeedbackConfig): string {\n const value = config.collapseKey?.trim().toLowerCase();\n if (!value) return DEFAULT_COLLAPSE_KEY;\n if (value === COLLAPSE_KEY_OFF) return COLLAPSE_KEY_OFF;\n return /^[a-z0-9_+\\-\\]{}]+$/u.test(value) ? value : DEFAULT_COLLAPSE_KEY;\n}\n","import type { ExtensionContext } from '@earendil-works/pi-coding-agent';\n\nimport type { QuestionParams } from '../../schemas/questionnaire';\nimport type { QuestionnaireResult } from '../../types/questionnaire';\nimport { runQuestionnaire, type QuestionnaireInteraction } from '../questionnaireService';\n\nexport async function runRpcQuestionnaire(\n context: ExtensionContext,\n params: QuestionParams,\n signal?: AbortSignal,\n reportProgress?: (result: QuestionnaireResult) => void,\n): Promise<QuestionnaireResult> {\n const interaction: QuestionnaireInteraction = {\n select: (title, options, interactionSignal) =>\n context.ui.select(title, [...options], { signal: interactionSignal }),\n input: (title, placeholder, interactionSignal) =>\n context.ui.input(title, placeholder, { signal: interactionSignal }),\n };\n return runQuestionnaire(interaction, params, signal, reportProgress);\n}\n","import {\n type AskUserBlockedEvent,\n type AskUserPromptEvent,\n DOOM_ASK_USER_BLOCKED_EVENT,\n DOOM_ASK_USER_PROMPT_EVENT,\n} from '@agimon-ai/doompi-core/askUser';\nimport type { Context } from '@deepseek-ai/cordis';\nimport type { ToolDefinition, ExtensionContext } from '@earendil-works/pi-coding-agent';\n\nimport {\n ASK_USER_QUESTION_TOOL_NAME,\n DEFAULT_PROMPT_SNIPPET,\n DEFAULT_PROMPT_GUIDELINES,\n ERROR_NO_UI,\n ERROR_NO_CUSTOM_UI,\n ERROR_SESSION_LOAD_FAILED,\n ERROR_SESSION_INACTIVE,\n} from '../../../../../constants/tool';\nimport { type QuestionParams, QuestionParamsSchema } from '../../../../../schemas/questionnaire';\nimport { loadUserFeedbackConfig, resolveCollapseKey } from '../../../../../services/config';\nimport type { QuestionnaireRunner } from '../../../../../services/questionnaireCoordinator';\nimport { buildQuestionnaireResponse, buildToolResult } from '../../../../../services/responseService';\nimport { runRpcQuestionnaire } from '../../../../../services/rpcQuestionnaire';\nimport { validateQuestionnaire } from '../../../../../services/validationService';\nimport { buildVoiceToolResult } from '../../../../../services/voiceQuestionHandoff';\nimport type { QuestionnaireResult } from '../../../../../types/questionnaire';\nexport interface AskUserQuestionToolDependencies {\n enqueue: (runner: QuestionnaireRunner, signal?: AbortSignal) => Promise<QuestionnaireResult>;\n isActive?: (context: ExtensionContext, signal?: AbortSignal) => boolean;\n tryVoice?: (params: QuestionParams) => QuestionnaireResult | undefined | Promise<QuestionnaireResult | undefined>;\n runTui: (\n context: ExtensionContext,\n params: QuestionParams,\n collapseKey: string,\n signal?: AbortSignal,\n reportProgress?: (result: QuestionnaireResult) => void,\n ) => Promise<QuestionnaireResult | undefined>;\n}\n\nfunction emitPrompt(cordis: Context, params: QuestionParams): void {\n const payload: AskUserPromptEvent = {\n questions: params.questions.map((question) => ({\n question: question.question,\n header: question.header,\n multiSelect: question.multiSelect ?? false,\n options: question.options.map((option) => ({\n label: option.label,\n description: option.description,\n hasPreview: Boolean(option.preview),\n })),\n })),\n };\n cordis.emit(DOOM_ASK_USER_PROMPT_EVENT, payload);\n}\n\nfunction emitBlocked(cordis: Context, active: boolean): void {\n const payload: AskUserBlockedEvent = { active };\n cordis.emit(DOOM_ASK_USER_BLOCKED_EVENT, payload);\n}\n\nfunction hasDialogUI(context: ExtensionContext): boolean {\n const ui = context.ui as unknown as { select?: unknown; input?: unknown };\n return typeof ui.select === 'function' && typeof ui.input === 'function';\n}\n\nexport function createAskUserQuestionTool(\n cordis: Context,\n dependencies: AskUserQuestionToolDependencies,\n renderers: Pick<ToolDefinition<typeof QuestionParamsSchema, QuestionnaireResult>, 'renderCall' | 'renderResult'> = {},\n): ToolDefinition<typeof QuestionParamsSchema, QuestionnaireResult> {\n const configuredGuidance = loadUserFeedbackConfig().guidance;\n return {\n name: ASK_USER_QUESTION_TOOL_NAME,\n label: 'Ask User Question',\n renderShell: 'self',\n description: `Ask the user one or more structured questions during execution. Use when you need to:\n1. Gather user preferences or requirements\n2. Clarify ambiguous instructions\n3. Get decisions on implementation choices as you work\n4. Offer choices to the user about what direction to take\n\nUsage notes:\n- Users can type a custom answer via the automatically appended \"Type something.\" row on every question or press Esc to abandon the questionnaire. Do NOT author \"Other\" or \"Type something.\" labels yourself, reserved labels are rejected at runtime.\n- Use multiSelect: true when multiple answers are valid.\n- If you recommend a specific option, make that the first option and add \"(Recommended)\" at the end of the label.\n\nPreview feature:\nUse the optional preview field for ASCII mockups, code snippets, diagrams, or configuration examples that users should compare visually. Do not use previews for simple preference questions.`,\n promptSnippet: configuredGuidance?.promptSnippet ?? DEFAULT_PROMPT_SNIPPET,\n promptGuidelines: configuredGuidance?.promptGuidelines ?? DEFAULT_PROMPT_GUIDELINES,\n parameters: QuestionParamsSchema,\n executionMode: 'sequential',\n\n async execute(_toolCallId, params, signal, _onUpdate, context) {\n const typed = params as QuestionParams;\n const isActive = (activeSignal?: AbortSignal): boolean => dependencies.isActive?.(context, activeSignal) ?? true;\n const cancelled = (): QuestionnaireResult => ({ answers: [], cancelled: true });\n if (!isActive(signal)) return buildToolResult(ERROR_SESSION_INACTIVE, cancelled());\n if (!context.hasUI) {\n return buildToolResult(ERROR_NO_UI, { answers: [], cancelled: true, error: 'no_ui' });\n }\n\n const validation = validateQuestionnaire(typed);\n if (!validation.ok) {\n return buildToolResult(validation.message, {\n answers: [],\n cancelled: true,\n error: validation.error,\n });\n }\n\n try {\n const result = await dependencies.enqueue(async ({ signal: activeSignal, reportProgress }) => {\n if (!isActive(activeSignal)) return cancelled();\n emitPrompt(cordis, typed);\n const voiceResult = await dependencies.tryVoice?.(typed);\n if (voiceResult) return voiceResult;\n\n let blocked = true;\n const clearBlocked = (): void => {\n if (!blocked) return;\n blocked = false;\n if (isActive()) emitBlocked(cordis, false);\n };\n activeSignal.addEventListener('abort', clearBlocked, { once: true });\n emitBlocked(cordis, true);\n try {\n if (!isActive(activeSignal)) return cancelled();\n if (context.mode === 'rpc' && hasDialogUI(context)) {\n const rpcResult = await runRpcQuestionnaire(context, typed, activeSignal, reportProgress);\n return isActive(activeSignal) ? rpcResult : cancelled();\n }\n\n const tuiResult = await dependencies.runTui(\n context,\n typed,\n resolveCollapseKey(loadUserFeedbackConfig()),\n activeSignal,\n reportProgress,\n );\n if (!isActive(activeSignal)) return cancelled();\n if (tuiResult !== undefined) return tuiResult;\n if (hasDialogUI(context)) {\n const rpcResult = await runRpcQuestionnaire(context, typed, activeSignal, reportProgress);\n return isActive(activeSignal) ? rpcResult : cancelled();\n }\n return { answers: [], cancelled: true, error: 'no_custom_ui' };\n } finally {\n activeSignal.removeEventListener('abort', clearBlocked);\n clearBlocked();\n }\n }, signal);\n\n if (result.delivery === 'voice') return buildVoiceToolResult(result);\n if (result.error === 'no_custom_ui') return buildToolResult(ERROR_NO_CUSTOM_UI, result);\n return buildQuestionnaireResponse(result, typed);\n } catch (error) {\n const cause = error instanceof Error ? error.message : String(error);\n return buildToolResult(`${ERROR_SESSION_LOAD_FAILED} (cause: ${cause})`, {\n answers: [],\n cancelled: true,\n error: 'session_load_failed',\n });\n }\n },\n\n ...renderers,\n };\n}\n","import { defineCliTool, type WithRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport { definePiTool, type PiPluginContext } from '@agimon-ai/doompi-core/piExtension';\n\nimport { askUserToolRender } from '../../../../../tui/askUserToolRender';\nimport type { UserFeedbackPiScope } from '../_lib/root.cli';\nimport { createAskUserQuestionTool } from '../_tools/askUserQuestion';\n\nexport default defineCliTool((context: WithRoot<PiPluginContext, UserFeedbackPiScope>) =>\n definePiTool(createAskUserQuestionTool(context.context, context.root.toolDependencies, askUserToolRender)),\n);\n","// Generated by @agimon-ai/doompi-build. Do not edit by hand.\nimport { definePiExtension, piToolContributions, type PiPluginContext, type PiPluginContributions } from '@agimon-ai/doompi-core/piExtension';\nimport { composeRootHooks } from '@agimon-ai/doompi-core/extensionFile';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.cli';\nimport hookBeforeAgentStart from '../src/extensions/workspaces/sessions/(backend)/hook/before-agent-start.cli';\nimport hookSessionStart from '../src/extensions/workspaces/sessions/(backend)/hook/session-start.cli';\nimport resourceDoompiUseUserFeedback from '../src/extensions/workspaces/sessions/(backend)/resource/doompi-use-user-feedback.cli';\nimport toolRestrictionAskUserQuestion from '../src/extensions/workspaces/sessions/(backend)/tool-restriction/ask-user-question.cli';\nimport toolAskUserQuestion from '../src/extensions/workspaces/sessions/(backend)/tool/askUserQuestion.cli';\n\ntype OptionsOf<T> = T extends (context: PiPluginContext<infer Options>) => unknown ? Options : never;\ntype InferredOptions = Exclude<OptionsOf<typeof rootSession> | OptionsOf<typeof hookBeforeAgentStart> | OptionsOf<typeof hookSessionStart> | OptionsOf<typeof resourceDoompiUseUserFeedback> | OptionsOf<typeof toolRestrictionAskUserQuestion> | OptionsOf<typeof toolAskUserQuestion>, undefined>;\ntype Intersect<Union> =\n (Union extends unknown ? (value: Union) => void : never) extends (value: infer Value) => void ? Value : never;\ntype ExtensionOptions = [InferredOptions] extends [never] ? undefined : Intersect<InferredOptions>;\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const extension = definePiExtension<ExtensionOptions>('@agimon-ai/doompi-user-feedback', async (context) => {\n const scopeSession = await rootSession(context);\n const contextSession = { ...context, root: scopeSession.value };\n return {\n ...composeRootHooks(scopeSession),\n events: {\n before_agent_start: at(hookBeforeAgentStart, contextSession) as NonNullable<PiPluginContributions['events']>['before_agent_start'],\n session_start: at(hookSessionStart, contextSession) as NonNullable<PiPluginContributions['events']>['session_start'],\n },\n get resources(): PiPluginContributions['resources'] { return [at(resourceDoompiUseUserFeedback, contextSession)]; },\n get toolRestrictions(): PiPluginContributions['toolRestrictions'] { return [at(toolRestrictionAskUserQuestion, contextSession)]; },\n ...piToolContributions('@agimon-ai/doompi-user-feedback', [via({ name: 'ask_user_question' }, at(toolAskUserQuestion, contextSession))]),\n services: [...(scopeSession.services ?? [])],\n };\n});\n\nexport default extension;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,SAAgB,uBAAuB,UAAkB,SAAuC;C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ACA,IAAI,YAAgD;GAAE,OAAO,CAAC,GAAGC,sCAA+B,cAAc,CAAC;EAAG;EAClH,IAAI,mBAA8D;GAAE,OAAO,CAAC,GAAGC,+BAAgC,cAAc,CAAC;EAAG;EACjI,IAAA,GAAGC,mCAAAA,oBAAAA,CAAoB,mCAAmC,CAAC,IAAI,EAAE,MAAM,oBAAoB,GAAG,GAAGC,6BAAqB,cAAc,CAAC,CAAC,CAAC;EACvI,UAAU,CAAC,GAAI,aAAa,YAAY,CAAC,CAAE;CAC7C;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pi.d.mts","names":[],"sources":["../../generated/pi.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"pi.d.mts","names":[],"sources":["../../generated/pi.ts"],"mappings":";qBAuBa,+DAAS"}
|
package/dist/extensions/pi.mjs
CHANGED
|
@@ -483,10 +483,10 @@ var askUserQuestion_cli_default = defineCliTool((context) => definePiTool(create
|
|
|
483
483
|
//#endregion
|
|
484
484
|
//#region generated/pi.ts
|
|
485
485
|
const at = (value, context) => typeof value === "function" ? value(context) : value;
|
|
486
|
-
const via = (identity, value) =>
|
|
486
|
+
const via = (identity, value) => value === void 0 ? void 0 : {
|
|
487
487
|
...identity,
|
|
488
488
|
...value
|
|
489
|
-
}
|
|
489
|
+
};
|
|
490
490
|
const extension = definePiExtension("@agimon-ai/doompi-user-feedback", async (context) => {
|
|
491
491
|
const scopeSession = await root_cli_default(context);
|
|
492
492
|
const contextSession = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pi.mjs","names":["contribution","contribution","contribution","contribution","rootSession","hookBeforeAgentStart","hookSessionStart","resourceDoompiUseUserFeedback","toolRestrictionAskUserQuestion","toolAskUserQuestion"],"sources":["../../src/services/askUserToolGate/index.ts","../../src/services/autonomousVoiceMode/index.ts","../../src/services/voiceQuestionNarration/index.ts","../../src/services/voiceQuestionHandoff/index.ts","../../src/extensions/workspaces/sessions/(backend)/_lib/root.cli.ts","../../src/extensions/workspaces/sessions/(backend)/root.cli.ts","../../src/extensions/workspaces/sessions/(backend)/hook/_lib/before-agent-start.cli.ts","../../src/extensions/workspaces/sessions/(backend)/hook/before-agent-start.cli.ts","../../src/extensions/workspaces/sessions/(backend)/hook/_lib/session-start.cli.ts","../../src/extensions/workspaces/sessions/(backend)/hook/session-start.cli.ts","../../src/extensions/workspaces/sessions/(backend)/resource/_lib/doompi-use-user-feedback.cli.ts","../../src/extensions/workspaces/sessions/(backend)/resource/doompi-use-user-feedback.cli.ts","../../src/extensions/workspaces/sessions/(backend)/tool-restriction/_lib/ask-user-question.cli.ts","../../src/extensions/workspaces/sessions/(backend)/tool-restriction/ask-user-question.cli.ts","../../src/tui/askUserToolRender.ts","../../src/services/config/index.ts","../../src/services/rpcQuestionnaire/index.ts","../../src/extensions/workspaces/sessions/(backend)/_tools/askUserQuestion.ts","../../src/extensions/workspaces/sessions/(backend)/tool/askUserQuestion.cli.ts","../../generated/pi.ts"],"sourcesContent":["import type { DoomToolRestriction } from '@agimon-ai/doompi-core/toolSurface';\n\n/**\n * Hides the questionnaire tool while nobody can answer it.\n *\n * Autonomous Voice narrates its own question and then waits for the spoken reply, so a\n * questionnaire tool alongside it asks the same thing twice. A run without UI cannot render\n * the questionnaire at all. Both cases only ever remove the name: the tool surface recomputes\n * from every registered tool, so a visible gate restores it without tracking what it hid.\n */\nexport function askUserToolRestriction(toolName: string, visible: boolean): DoomToolRestriction {\n return (incoming) => (visible ? incoming : incoming.filter((name) => name !== toolName));\n}\n","import { DOOM_VOICE_AUTO_MODE_ID, DOOM_VOICE_SOURCE } from '@agimon-ai/doompi-core/voiceTools';\nimport type { MinorModeRecord } from '@agimon-ai/doompi-minor-mode';\n/**\n * Matches only the Voice package's own autonomous mode, and only while it reports active.\n *\n * Both the source and the mode id are checked because another package may register a mode\n * under the same id, and a transitional `activating` or `deactivating` record is not yet\n * (or no longer) speaking.\n */\nexport function isAutonomousVoiceRecord(record: MinorModeRecord): boolean {\n return (\n record.descriptor.source === DOOM_VOICE_SOURCE &&\n record.descriptor.id === DOOM_VOICE_AUTO_MODE_ID &&\n record.state.activation === 'active'\n );\n}\n\nexport function isAutonomousVoiceActive(records: readonly MinorModeRecord[]): boolean {\n return records.some((record) => isAutonomousVoiceRecord(record));\n}\n","import { MAX_NARRATION_TEXT_CHARACTERS } from '@agimon-ai/doompi-core/narration';\n\nimport type { QuestionParams } from '../../schemas/questionnaire';\n\nconst MAX_QUESTION_CHARACTERS = 240;\nconst MAX_OPTION_CHARACTERS = 80;\nconst PATH_PATTERN = /\\/(?:Users|home|private|tmp|var)\\/[^\\s,;:]+/gu;\nconst TOKEN_PATTERN = /\\b(?:sk|api|token|key)[-_][A-Za-z0-9_-]{12,}\\b/giu;\nconst CODE_PATTERN = /`[^`]*`|<\\/?[A-Za-z][^>]*>|\\$\\([^)]*\\)|\\{[^}]*\\}/gu;\nconst SAFE_FALLBACK = 'I need your answer to the questions shown in the conversation.';\n\nfunction takeCharacters(text: string, maximum: number): string {\n return Array.from(text).slice(0, maximum).join('').trim();\n}\n\nexport function sanitizeVoiceQuestionText(text: string, maximum: number): string {\n const withoutControls = Array.from(text, (character) => {\n const codePoint = character.codePointAt(0) ?? 0;\n return codePoint < 32 || codePoint === 127 ? ' ' : character;\n }).join('');\n return takeCharacters(\n withoutControls\n .replace(PATH_PATTERN, ' ')\n .replace(TOKEN_PATTERN, ' ')\n .replace(CODE_PATTERN, ' ')\n .replace(/\\s+/gu, ' ')\n .trim(),\n maximum,\n );\n}\n\nfunction spokenQuestion(params: QuestionParams, questionIndex: number): string {\n const question = params.questions[questionIndex];\n if (!question) return '';\n const position = questionIndex + 1;\n const prompt =\n sanitizeVoiceQuestionText(question.question, MAX_QUESTION_CHARACTERS) || `Question ${position} needs your choice`;\n const labels = question.options.map((option, optionIndex) => {\n const label = sanitizeVoiceQuestionText(option.label, MAX_OPTION_CHARACTERS);\n return `${optionIndex + 1}, ${label || `option ${optionIndex + 1}`}`;\n });\n const selection = question.multiSelect ? 'You may choose more than one option.' : 'Please choose one option.';\n return `Question ${position}: ${prompt}. Options: ${labels.join('; ')}. ${selection} You may also answer in your own words.`;\n}\n\nexport function buildVoiceQuestionNarration(params: QuestionParams): string {\n const questions = params.questions.map((_question, index) => spokenQuestion(params, index));\n const combined = sanitizeVoiceQuestionText(questions.join(' '), MAX_NARRATION_TEXT_CHARACTERS);\n return combined || SAFE_FALLBACK;\n}\n","import { createNarrationRequest, type DoomNarrationService } from '@agimon-ai/doompi-core/narration';\nimport type { MinorModeCatalogService } from '@agimon-ai/doompi-minor-mode';\n\nimport type { QuestionParams } from '../../schemas/questionnaire';\nimport type { QuestionnaireResult, ToolTextResult } from '../../types/questionnaire';\nimport { isAutonomousVoiceRecord } from '../autonomousVoiceMode';\nimport { buildVoiceQuestionNarration } from '../voiceQuestionNarration';\n\nexport const VOICE_WAIT_MESSAGE =\n \"The questions were spoken through autonomous voice. Stop now and wait for the user's next message; it will arrive as an ordinary user message.\";\n\nexport function formatVoiceQuestionPrompt(params: QuestionParams): string {\n const numberQuestions = params.questions.length > 1;\n return params.questions\n .map((question, questionIndex) => {\n const heading = `${numberQuestions ? `${questionIndex + 1}. ` : ''}${question.question}${question.multiSelect ? ' (Select all that apply.)' : ''}`;\n const options = question.options.map((option, optionIndex) => ` ${optionIndex + 1}. ${option.label}`);\n return [heading, ...options, ' Type something.'].join('\\n');\n })\n .join('\\n\\n');\n}\n\nexport class VoiceQuestionHandoff {\n constructor(\n private readonly modes: Pick<MinorModeCatalogService, 'list'>,\n private readonly narration: Pick<DoomNarrationService, 'request'>,\n private readonly buildNarration: (params: QuestionParams) => string = buildVoiceQuestionNarration,\n ) {}\n\n async handoff(params: QuestionParams): Promise<QuestionnaireResult | undefined> {\n if (!this.modes.list().some((record) => isAutonomousVoiceRecord(record))) return undefined;\n const narration = createNarrationRequest(this.buildNarration(params));\n if (!narration) return undefined;\n await this.narration.request(narration);\n return {\n answers: [],\n cancelled: false,\n delivery: 'voice',\n awaitingResponse: true,\n voicePrompt: formatVoiceQuestionPrompt(params),\n };\n }\n}\n\n/** Create a handoff from services whose lifecycle is owned by a Cordis injection. */\nexport function createVoiceQuestionHandoff(\n modes: Pick<MinorModeCatalogService, 'list'>,\n narration: Pick<DoomNarrationService, 'request'>,\n): VoiceQuestionHandoff {\n return new VoiceQuestionHandoff(modes, narration);\n}\n\nexport function buildVoiceToolResult(details: QuestionnaireResult): ToolTextResult {\n const prompt = details.voicePrompt?.trim();\n return {\n content: [{ type: 'text', text: prompt ? `${prompt}\\n\\n${VOICE_WAIT_MESSAGE}` : VOICE_WAIT_MESSAGE }],\n details,\n terminate: true,\n };\n}\n","import { defineRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport { DOOM_NARRATION_SERVICE, requireDoomNarrationService } from '@agimon-ai/doompi-core/narration';\nimport type { PiPluginContext } from '@agimon-ai/doompi-core/piExtension';\nimport type { DoomToolRestriction } from '@agimon-ai/doompi-core/toolSurface';\nimport { DOOM_MINOR_MODE_CATALOG_SERVICE, requireMinorModeCatalog } from '@agimon-ai/doompi-minor-mode';\nimport type { Context } from '@deepseek-ai/cordis';\nimport type { ExtensionContext } from '@earendil-works/pi-coding-agent';\n\nimport { ASK_USER_QUESTION_TOOL_NAME } from '../../../../../constants/tool';\nimport { askUserToolRestriction } from '../../../../../services/askUserToolGate';\nimport { isAutonomousVoiceActive } from '../../../../../services/autonomousVoiceMode';\nimport { QuestionnaireCoordinator, type QuestionnaireRunner } from '../../../../../services/questionnaireCoordinator';\nimport { createVoiceQuestionHandoff, type VoiceQuestionHandoff } from '../../../../../services/voiceQuestionHandoff';\nimport type { QuestionnaireResult } from '../../../../../types/questionnaire';\nimport { createAskUserQuestionTool } from '.././_tools/askUserQuestion';\n\nfunction cancelledResult(): QuestionnaireResult {\n return { answers: [], cancelled: true };\n}\n\nconst root = defineRoot((_context: PiPluginContext) => {\n let active = true;\n let sessionGeneration = 0;\n let sessionId: string | undefined;\n let sessionReady = false;\n let coordinator = new QuestionnaireCoordinator();\n let voiceHandoff: VoiceQuestionHandoff | undefined;\n let voiceActive = false;\n let hasUI = true;\n const restrictionListeners = new Set<() => void>();\n const currentRestriction = (): DoomToolRestriction =>\n askUserToolRestriction(ASK_USER_QUESTION_TOOL_NAME, hasUI && !voiceActive);\n const syncToolRestriction = (): void => restrictionListeners.forEach((listener) => listener());\n let lifecycleQueue: Promise<void> = Promise.resolve();\n const pendingOperations = new Set<Promise<unknown>>();\n\n const trackOperation = <T>(operation: Promise<T>): Promise<T> => {\n pendingOperations.add(operation);\n void operation.then(\n () => pendingOperations.delete(operation),\n () => pendingOperations.delete(operation),\n );\n return operation;\n };\n const ownsGeneration = (generation: number, expectedSessionId: string | undefined): boolean =>\n active && generation === sessionGeneration && expectedSessionId === sessionId;\n const isContextActive = (context: ExtensionContext, signal?: AbortSignal): boolean =>\n active && sessionReady && signal?.aborted !== true && context.sessionManager.getSessionId() === sessionId;\n\n const shutdownRuntime = async (): Promise<void> => {\n if (!active) return;\n const ownedCoordinator = coordinator;\n ownedCoordinator.shutdown();\n active = false;\n sessionGeneration += 1;\n sessionReady = false;\n sessionId = undefined;\n await Promise.allSettled(pendingOperations);\n await ownedCoordinator.waitForIdle();\n };\n\n const toolDependencies: Parameters<typeof createAskUserQuestionTool>[1] = {\n enqueue: (runner: QuestionnaireRunner, signal?: AbortSignal) => {\n const ownedCoordinator = coordinator;\n const generation = sessionGeneration;\n const expectedSessionId = sessionId;\n if (!sessionReady || !ownsGeneration(generation, expectedSessionId) || signal?.aborted) {\n return Promise.resolve(cancelledResult());\n }\n return ownedCoordinator.enqueue(async (context) => {\n if (!sessionReady || !ownsGeneration(generation, expectedSessionId) || context.signal.aborted) {\n return cancelledResult();\n }\n const result = await runner({\n ...context,\n reportProgress: (progress) => {\n if (ownsGeneration(generation, expectedSessionId) && !context.signal.aborted) {\n context.reportProgress(progress);\n }\n },\n });\n return sessionReady && ownsGeneration(generation, expectedSessionId) && !context.signal.aborted\n ? result\n : cancelledResult();\n }, signal);\n },\n isActive: isContextActive,\n runTui: async (context, params, collapseKey, signal, reportProgress) => {\n if (!isContextActive(context, signal)) return undefined;\n const { runTuiQuestionnaire } = await import('../../../../../tui/runQuestionnaire');\n if (!isContextActive(context, signal)) return undefined;\n const result = await runTuiQuestionnaire(context, params, collapseKey, signal, reportProgress);\n return isContextActive(context, signal) ? result : undefined;\n },\n tryVoice: (params) => (active && sessionReady ? voiceHandoff?.handoff(params) : undefined),\n };\n\n const beforeAgentStart = (_event: unknown, context: ExtensionContext) => {\n if (!isContextActive(context)) return;\n hasUI = context.hasUI;\n syncToolRestriction();\n };\n\n const sessionStart = (_event: unknown, context: ExtensionContext) => {\n if (!active) return;\n const previousCoordinator = coordinator;\n previousCoordinator.shutdown();\n const activeSessionId = context.sessionManager.getSessionId();\n const generation = ++sessionGeneration;\n const nextCoordinator = new QuestionnaireCoordinator();\n coordinator = nextCoordinator;\n sessionId = activeSessionId;\n sessionReady = false;\n\n const initializeSession = async (): Promise<void> => {\n await previousCoordinator.waitForIdle();\n if (!ownsGeneration(generation, activeSessionId)) return;\n sessionReady = true;\n // The surface is re-registered per session from the gate state in force, so a session\n // that starts with Voice already active needs nothing extra here.\n };\n\n const operation = lifecycleQueue.then(initializeSession, initializeSession);\n lifecycleQueue = operation.catch(() => undefined);\n return trackOperation(operation);\n };\n const toolRestriction = {\n source: '@agimon-ai/doompi-user-feedback',\n get restrict() {\n return currentRestriction();\n },\n subscribe(listener: () => void) {\n restrictionListeners.add(listener);\n return () => {\n restrictionListeners.delete(listener);\n };\n },\n };\n\n return {\n value: {\n toolDependencies,\n beforeAgentStart,\n sessionStart,\n toolRestriction,\n },\n services: [\n (serviceContextOwner: Context) => {\n serviceContextOwner.inject([DOOM_MINOR_MODE_CATALOG_SERVICE, DOOM_NARRATION_SERVICE], (serviceContext) => {\n const handoff = createVoiceQuestionHandoff(\n requireMinorModeCatalog(serviceContext),\n requireDoomNarrationService(serviceContext),\n );\n voiceHandoff = handoff;\n return () => {\n if (voiceHandoff === handoff) voiceHandoff = undefined;\n };\n });\n\n // Separate from the handoff binding above: the gate needs only the mode catalog, so it\n // still applies to a Voice build that publishes modes without providing narration.\n serviceContextOwner.inject([DOOM_MINOR_MODE_CATALOG_SERVICE], (modeContext) => {\n const modes = requireMinorModeCatalog(modeContext);\n const apply = (): void => {\n voiceActive = isAutonomousVoiceActive(modes.list());\n syncToolRestriction();\n };\n const unsubscribe = modes.subscribe(apply);\n apply();\n return () => {\n unsubscribe();\n voiceActive = false;\n syncToolRestriction();\n };\n });\n },\n ],\n onDispose: shutdownRuntime,\n };\n});\n\nexport type UserFeedbackPiScope = Awaited<ReturnType<typeof root>>['value'];\nexport default root;\n","import { defineRoot } from '@agimon-ai/doompi-core/extensionFile';\n\nimport contribution from './_lib/root.cli';\n\nexport default defineRoot(contribution);\n","import type { WithRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport type { PiPluginContext } from '@agimon-ai/doompi-core/piExtension';\n\nimport type { UserFeedbackPiScope } from '../../_lib/root.cli';\n\nexport default (context: WithRoot<PiPluginContext, UserFeedbackPiScope>) => context.root.beforeAgentStart;\n","import { defineCliHook } from '@agimon-ai/doompi-core/extensionFile';\n\nimport contribution from './_lib/before-agent-start.cli';\n\nexport default defineCliHook(contribution);\n","import type { WithRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport type { PiPluginContext } from '@agimon-ai/doompi-core/piExtension';\n\nimport type { UserFeedbackPiScope } from '../../_lib/root.cli';\n\nexport default (context: WithRoot<PiPluginContext, UserFeedbackPiScope>) => context.root.sessionStart;\n","import { defineCliHook } from '@agimon-ai/doompi-core/extensionFile';\n\nimport contribution from './_lib/session-start.cli';\n\nexport default defineCliHook(contribution);\n","export function createDoompiUseUserFeedbackResource(moduleUrl: string) {\n return {\n source: '@agimon-ai/doompi-user-feedback',\n moduleUrl,\n skills: [\n {\n name: 'doompi-use-user-feedback',\n description:\n 'Use @agimon-ai/doompi-user-feedback: Structured user questions with interactive and autonomous Voice handoff for Pi agents.',\n },\n ],\n };\n}\n","import { defineResource } from '@agimon-ai/doompi-core/extensionFile';\n\nimport { createDoompiUseUserFeedbackResource } from './_lib/doompi-use-user-feedback.cli';\n\nexport default defineResource(createDoompiUseUserFeedbackResource(import.meta.url));\n","import type { WithRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport type { PiPluginContext } from '@agimon-ai/doompi-core/piExtension';\n\nimport type { UserFeedbackPiScope } from '../../_lib/root.cli';\n\nexport default (context: WithRoot<PiPluginContext, UserFeedbackPiScope>) => context.root.toolRestriction;\n","import { defineToolRestriction } from '@agimon-ai/doompi-core/extensionFile';\n\nimport contribution from './_lib/ask-user-question.cli';\n\nexport default defineToolRestriction(contribution);\n","import { DoomToolCall, DoomToolResult, renderToolHeading } from '@agimon-ai/doompi-ui/toolChrome';\nimport type { ToolDefinition } from '@earendil-works/pi-coding-agent';\n\nimport type { QuestionParams, QuestionParamsSchema } from '../schemas/questionnaire';\nimport type { QuestionnaireResult } from '../types/questionnaire';\nexport const askUserToolRender: Pick<\n ToolDefinition<typeof QuestionParamsSchema, QuestionnaireResult>,\n 'renderCall' | 'renderResult'\n> = {\n renderCall(args, theme) {\n const params = args as QuestionParams;\n const headers = params.questions.map((question) => question.header).join(', ');\n const count = `${params.questions.length} question${params.questions.length === 1 ? '' : 's'}`;\n const heading = renderToolHeading('ask', count, theme);\n return new DoomToolCall(headers ? `${heading} ${theme.fg('dim', `(${headers})`)}` : heading);\n },\n\n renderResult(result, _options, theme, context) {\n const details = result.details as QuestionnaireResult | undefined;\n if (!details) {\n const raw = result.content\n .filter((block) => block.type === 'text')\n .map((block) => block.text)\n .join('\\n');\n const color = context.isError ? 'error' : 'toolOutput';\n const fallback = context.isError ? '✗ failed' : '✓ submitted';\n return new DoomToolResult([theme.fg(color, raw || fallback)], theme, { wrap: true });\n }\n if (details.cancelled) {\n return new DoomToolResult([theme.fg('warning', '◐') + theme.fg('dim', ' cancelled')], theme);\n }\n if (details.delivery === 'voice' && details.voicePrompt) {\n return new DoomToolResult([theme.fg('toolOutput', details.voicePrompt)], theme, { wrap: true });\n }\n const lines = details.answers.map((answer) => {\n const scalar = answer.kind === 'multi' ? (answer.selected ?? []).join(', ') : answer.answer;\n return `${theme.fg('success', '✓')} ${theme.fg('accent', answer.question)}: ${theme.fg(\n 'toolOutput',\n scalar ?? '',\n )}`;\n });\n if (lines.length === 0) lines.push(theme.fg('success', '✓') + theme.fg('dim', ' submitted'));\n return new DoomToolResult(lines, theme, { wrap: true });\n },\n};\n","import fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\n\nexport const DEFAULT_COLLAPSE_KEY = 'ctrl+]';\nexport const COLLAPSE_KEY_OFF = 'off';\n\nexport interface GuidanceConfig {\n promptSnippet?: string;\n promptGuidelines?: string[];\n}\n\nexport interface UserFeedbackConfig {\n collapseKey?: string;\n guidance?: GuidanceConfig;\n}\n\nfunction legacyConfigPath(environment: NodeJS.ProcessEnv): string {\n const configRoot = environment.XDG_CONFIG_HOME?.trim() || path.join(os.homedir(), '.config');\n return path.join(configRoot, 'rpiv-ask-user-question', 'config.json');\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nexport function loadUserFeedbackConfig(environment: NodeJS.ProcessEnv = process.env): UserFeedbackConfig {\n const filePath = legacyConfigPath(environment);\n if (!fs.existsSync(filePath)) return {};\n try {\n const parsed: unknown = JSON.parse(fs.readFileSync(filePath, 'utf8'));\n if (!isRecord(parsed)) return {};\n const rawGuidance = isRecord(parsed.guidance) ? parsed.guidance : undefined;\n const guidance = rawGuidance\n ? {\n ...(typeof rawGuidance.promptSnippet === 'string' ? { promptSnippet: rawGuidance.promptSnippet } : {}),\n ...(Array.isArray(rawGuidance.promptGuidelines) &&\n rawGuidance.promptGuidelines.every((item) => typeof item === 'string')\n ? { promptGuidelines: rawGuidance.promptGuidelines as string[] }\n : {}),\n }\n : undefined;\n return {\n ...(typeof parsed.collapseKey === 'string' ? { collapseKey: parsed.collapseKey } : {}),\n ...(guidance ? { guidance } : {}),\n };\n } catch {\n return {};\n }\n}\n\nexport function resolveCollapseKey(config: UserFeedbackConfig): string {\n const value = config.collapseKey?.trim().toLowerCase();\n if (!value) return DEFAULT_COLLAPSE_KEY;\n if (value === COLLAPSE_KEY_OFF) return COLLAPSE_KEY_OFF;\n return /^[a-z0-9_+\\-\\]{}]+$/u.test(value) ? value : DEFAULT_COLLAPSE_KEY;\n}\n","import type { ExtensionContext } from '@earendil-works/pi-coding-agent';\n\nimport type { QuestionParams } from '../../schemas/questionnaire';\nimport type { QuestionnaireResult } from '../../types/questionnaire';\nimport { runQuestionnaire, type QuestionnaireInteraction } from '../questionnaireService';\n\nexport async function runRpcQuestionnaire(\n context: ExtensionContext,\n params: QuestionParams,\n signal?: AbortSignal,\n reportProgress?: (result: QuestionnaireResult) => void,\n): Promise<QuestionnaireResult> {\n const interaction: QuestionnaireInteraction = {\n select: (title, options, interactionSignal) =>\n context.ui.select(title, [...options], { signal: interactionSignal }),\n input: (title, placeholder, interactionSignal) =>\n context.ui.input(title, placeholder, { signal: interactionSignal }),\n };\n return runQuestionnaire(interaction, params, signal, reportProgress);\n}\n","import {\n type AskUserBlockedEvent,\n type AskUserPromptEvent,\n DOOM_ASK_USER_BLOCKED_EVENT,\n DOOM_ASK_USER_PROMPT_EVENT,\n} from '@agimon-ai/doompi-core/askUser';\nimport type { Context } from '@deepseek-ai/cordis';\nimport type { ToolDefinition, ExtensionContext } from '@earendil-works/pi-coding-agent';\n\nimport {\n ASK_USER_QUESTION_TOOL_NAME,\n DEFAULT_PROMPT_SNIPPET,\n DEFAULT_PROMPT_GUIDELINES,\n ERROR_NO_UI,\n ERROR_NO_CUSTOM_UI,\n ERROR_SESSION_LOAD_FAILED,\n ERROR_SESSION_INACTIVE,\n} from '../../../../../constants/tool';\nimport { type QuestionParams, QuestionParamsSchema } from '../../../../../schemas/questionnaire';\nimport { loadUserFeedbackConfig, resolveCollapseKey } from '../../../../../services/config';\nimport type { QuestionnaireRunner } from '../../../../../services/questionnaireCoordinator';\nimport { buildQuestionnaireResponse, buildToolResult } from '../../../../../services/responseService';\nimport { runRpcQuestionnaire } from '../../../../../services/rpcQuestionnaire';\nimport { validateQuestionnaire } from '../../../../../services/validationService';\nimport { buildVoiceToolResult } from '../../../../../services/voiceQuestionHandoff';\nimport type { QuestionnaireResult } from '../../../../../types/questionnaire';\nexport interface AskUserQuestionToolDependencies {\n enqueue: (runner: QuestionnaireRunner, signal?: AbortSignal) => Promise<QuestionnaireResult>;\n isActive?: (context: ExtensionContext, signal?: AbortSignal) => boolean;\n tryVoice?: (params: QuestionParams) => QuestionnaireResult | undefined | Promise<QuestionnaireResult | undefined>;\n runTui: (\n context: ExtensionContext,\n params: QuestionParams,\n collapseKey: string,\n signal?: AbortSignal,\n reportProgress?: (result: QuestionnaireResult) => void,\n ) => Promise<QuestionnaireResult | undefined>;\n}\n\nfunction emitPrompt(cordis: Context, params: QuestionParams): void {\n const payload: AskUserPromptEvent = {\n questions: params.questions.map((question) => ({\n question: question.question,\n header: question.header,\n multiSelect: question.multiSelect ?? false,\n options: question.options.map((option) => ({\n label: option.label,\n description: option.description,\n hasPreview: Boolean(option.preview),\n })),\n })),\n };\n cordis.emit(DOOM_ASK_USER_PROMPT_EVENT, payload);\n}\n\nfunction emitBlocked(cordis: Context, active: boolean): void {\n const payload: AskUserBlockedEvent = { active };\n cordis.emit(DOOM_ASK_USER_BLOCKED_EVENT, payload);\n}\n\nfunction hasDialogUI(context: ExtensionContext): boolean {\n const ui = context.ui as unknown as { select?: unknown; input?: unknown };\n return typeof ui.select === 'function' && typeof ui.input === 'function';\n}\n\nexport function createAskUserQuestionTool(\n cordis: Context,\n dependencies: AskUserQuestionToolDependencies,\n renderers: Pick<ToolDefinition<typeof QuestionParamsSchema, QuestionnaireResult>, 'renderCall' | 'renderResult'> = {},\n): ToolDefinition<typeof QuestionParamsSchema, QuestionnaireResult> {\n const configuredGuidance = loadUserFeedbackConfig().guidance;\n return {\n name: ASK_USER_QUESTION_TOOL_NAME,\n label: 'Ask User Question',\n renderShell: 'self',\n description: `Ask the user one or more structured questions during execution. Use when you need to:\n1. Gather user preferences or requirements\n2. Clarify ambiguous instructions\n3. Get decisions on implementation choices as you work\n4. Offer choices to the user about what direction to take\n\nUsage notes:\n- Users can type a custom answer via the automatically appended \"Type something.\" row on every question or press Esc to abandon the questionnaire. Do NOT author \"Other\" or \"Type something.\" labels yourself, reserved labels are rejected at runtime.\n- Use multiSelect: true when multiple answers are valid.\n- If you recommend a specific option, make that the first option and add \"(Recommended)\" at the end of the label.\n\nPreview feature:\nUse the optional preview field for ASCII mockups, code snippets, diagrams, or configuration examples that users should compare visually. Do not use previews for simple preference questions.`,\n promptSnippet: configuredGuidance?.promptSnippet ?? DEFAULT_PROMPT_SNIPPET,\n promptGuidelines: configuredGuidance?.promptGuidelines ?? DEFAULT_PROMPT_GUIDELINES,\n parameters: QuestionParamsSchema,\n executionMode: 'sequential',\n\n async execute(_toolCallId, params, signal, _onUpdate, context) {\n const typed = params as QuestionParams;\n const isActive = (activeSignal?: AbortSignal): boolean => dependencies.isActive?.(context, activeSignal) ?? true;\n const cancelled = (): QuestionnaireResult => ({ answers: [], cancelled: true });\n if (!isActive(signal)) return buildToolResult(ERROR_SESSION_INACTIVE, cancelled());\n if (!context.hasUI) {\n return buildToolResult(ERROR_NO_UI, { answers: [], cancelled: true, error: 'no_ui' });\n }\n\n const validation = validateQuestionnaire(typed);\n if (!validation.ok) {\n return buildToolResult(validation.message, {\n answers: [],\n cancelled: true,\n error: validation.error,\n });\n }\n\n try {\n const result = await dependencies.enqueue(async ({ signal: activeSignal, reportProgress }) => {\n if (!isActive(activeSignal)) return cancelled();\n emitPrompt(cordis, typed);\n const voiceResult = await dependencies.tryVoice?.(typed);\n if (voiceResult) return voiceResult;\n\n let blocked = true;\n const clearBlocked = (): void => {\n if (!blocked) return;\n blocked = false;\n if (isActive()) emitBlocked(cordis, false);\n };\n activeSignal.addEventListener('abort', clearBlocked, { once: true });\n emitBlocked(cordis, true);\n try {\n if (!isActive(activeSignal)) return cancelled();\n if (context.mode === 'rpc' && hasDialogUI(context)) {\n const rpcResult = await runRpcQuestionnaire(context, typed, activeSignal, reportProgress);\n return isActive(activeSignal) ? rpcResult : cancelled();\n }\n\n const tuiResult = await dependencies.runTui(\n context,\n typed,\n resolveCollapseKey(loadUserFeedbackConfig()),\n activeSignal,\n reportProgress,\n );\n if (!isActive(activeSignal)) return cancelled();\n if (tuiResult !== undefined) return tuiResult;\n if (hasDialogUI(context)) {\n const rpcResult = await runRpcQuestionnaire(context, typed, activeSignal, reportProgress);\n return isActive(activeSignal) ? rpcResult : cancelled();\n }\n return { answers: [], cancelled: true, error: 'no_custom_ui' };\n } finally {\n activeSignal.removeEventListener('abort', clearBlocked);\n clearBlocked();\n }\n }, signal);\n\n if (result.delivery === 'voice') return buildVoiceToolResult(result);\n if (result.error === 'no_custom_ui') return buildToolResult(ERROR_NO_CUSTOM_UI, result);\n return buildQuestionnaireResponse(result, typed);\n } catch (error) {\n const cause = error instanceof Error ? error.message : String(error);\n return buildToolResult(`${ERROR_SESSION_LOAD_FAILED} (cause: ${cause})`, {\n answers: [],\n cancelled: true,\n error: 'session_load_failed',\n });\n }\n },\n\n ...renderers,\n };\n}\n","import { defineCliTool, type WithRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport { definePiTool, type PiPluginContext } from '@agimon-ai/doompi-core/piExtension';\n\nimport { askUserToolRender } from '../../../../../tui/askUserToolRender';\nimport type { UserFeedbackPiScope } from '../_lib/root.cli';\nimport { createAskUserQuestionTool } from '../_tools/askUserQuestion';\n\nexport default defineCliTool((context: WithRoot<PiPluginContext, UserFeedbackPiScope>) =>\n definePiTool(createAskUserQuestionTool(context.context, context.root.toolDependencies, askUserToolRender)),\n);\n","// Generated by @agimon-ai/doompi-build. Do not edit by hand.\nimport { definePiExtension, piToolContributions, type PiPluginContext, type PiPluginContributions } from '@agimon-ai/doompi-core/piExtension';\nimport { composeRootHooks } from '@agimon-ai/doompi-core/extensionFile';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.cli';\nimport hookBeforeAgentStart from '../src/extensions/workspaces/sessions/(backend)/hook/before-agent-start.cli';\nimport hookSessionStart from '../src/extensions/workspaces/sessions/(backend)/hook/session-start.cli';\nimport resourceDoompiUseUserFeedback from '../src/extensions/workspaces/sessions/(backend)/resource/doompi-use-user-feedback.cli';\nimport toolRestrictionAskUserQuestion from '../src/extensions/workspaces/sessions/(backend)/tool-restriction/ask-user-question.cli';\nimport toolAskUserQuestion from '../src/extensions/workspaces/sessions/(backend)/tool/askUserQuestion.cli';\n\ntype OptionsOf<T> = T extends (context: PiPluginContext<infer Options>) => unknown ? Options : never;\ntype InferredOptions = Exclude<OptionsOf<typeof rootSession> | OptionsOf<typeof hookBeforeAgentStart> | OptionsOf<typeof hookSessionStart> | OptionsOf<typeof resourceDoompiUseUserFeedback> | OptionsOf<typeof toolRestrictionAskUserQuestion> | OptionsOf<typeof toolAskUserQuestion>, undefined>;\ntype Intersect<Union> =\n (Union extends unknown ? (value: Union) => void : never) extends (value: infer Value) => void ? Value : never;\ntype ExtensionOptions = [InferredOptions] extends [never] ? undefined : Intersect<InferredOptions>;\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T => ({ ...identity, ...(value as object) }) as T;\n\nexport const extension = definePiExtension<ExtensionOptions>('@agimon-ai/doompi-user-feedback', async (context) => {\n const scopeSession = await rootSession(context);\n const contextSession = { ...context, root: scopeSession.value };\n return {\n ...composeRootHooks(scopeSession),\n events: {\n before_agent_start: at(hookBeforeAgentStart, contextSession) as NonNullable<PiPluginContributions['events']>['before_agent_start'],\n session_start: at(hookSessionStart, contextSession) as NonNullable<PiPluginContributions['events']>['session_start'],\n },\n get resources(): PiPluginContributions['resources'] { return [at(resourceDoompiUseUserFeedback, contextSession)]; },\n get toolRestrictions(): PiPluginContributions['toolRestrictions'] { return [at(toolRestrictionAskUserQuestion, contextSession)]; },\n ...piToolContributions('@agimon-ai/doompi-user-feedback', [via({ name: 'ask_user_question' }, at(toolAskUserQuestion, contextSession))]),\n services: [...(scopeSession.services ?? [])],\n };\n});\n\nexport default extension;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAUA,SAAgB,uBAAuB,UAAkB,SAAuC;CAC9F,QAAQ,aAAc,UAAU,WAAW,SAAS,QAAQ,SAAS,SAAS,QAAQ;AACxF;;;;;;;;;;ACHA,SAAgB,wBAAwB,QAAkC;CACxE,OACE,OAAO,WAAW,WAAW,qBAC7B,OAAO,WAAW,OAAO,2BACzB,OAAO,MAAM,eAAe;AAEhC;AAEA,SAAgB,wBAAwB,SAA8C;CACpF,OAAO,QAAQ,MAAM,WAAW,wBAAwB,MAAM,CAAC;AACjE;;;ACfA,MAAM,0BAA0B;AAChC,MAAM,wBAAwB;AAC9B,MAAM,eAAe;AACrB,MAAM,gBAAgB;AACtB,MAAM,eAAe;AACrB,MAAM,gBAAgB;AAEtB,SAAS,eAAe,MAAc,SAAyB;CAC7D,OAAO,MAAM,KAAK,IAAI,CAAC,CAAC,MAAM,GAAG,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK;AAC1D;AAEA,SAAgB,0BAA0B,MAAc,SAAyB;CAK/E,OAAO,eAJiB,MAAM,KAAK,OAAO,cAAc;EACtD,MAAM,YAAY,UAAU,YAAY,CAAC,KAAK;EAC9C,OAAO,YAAY,MAAM,cAAc,MAAM,MAAM;CACrD,CAAC,CAAC,CAAC,KAAK,EAEQ,CAAC,CACZ,QAAQ,cAAc,GAAG,CAAC,CAC1B,QAAQ,eAAe,GAAG,CAAC,CAC3B,QAAQ,cAAc,GAAG,CAAC,CAC1B,QAAQ,SAAS,GAAG,CAAC,CACrB,KAAK,GACR,OACF;AACF;AAE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BAA2B,QAAQ,KAAK;GACjD,SAAS,OAAO;IACd,MAAM,QAAQ,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;IACnE,OAAO,gBAAgB,GAAG,0BAA0B,WAAW,MAAM,IAAI;KACvE,SAAS,CAAC;KACV,WAAW;KACX,OAAO;IACT,CAAC;GACH;EACF;EAEA,GAAG;CACL;AACF;;;ACjKA,IAAA,8BAAe,eAAe,YAC5B,aAAa,0BAA0B,QAAQ,SAAS,QAAQ,KAAK,kBAAkB,iBAAiB,CAAC,CAC3G;;;ACSA,MAAM,MAAY,OAA0B,YAC1C,OAAO,UAAU,aAAc,MAAwB,OAAO,IAAI;AACpE,MAAM,OAAU,UAAmC,WAAuB;CAAE,GAAG;CAAU,GAAI;AAAiB;AAE9G,MAAa,YAAY,kBAAoC,mCAAmC,OAAO,YAAY;CACjH,MAAM,eAAe,MAAMC,iBAAY,OAAO;CAC9C,MAAM,iBAAiB;EAAE,GAAG;EAAS,MAAM,aAAa;CAAM;CAC9D,OAAO;EACL,GAAG,iBAAiB,YAAY;EAChC,QAAQ;GACN,oBAAoB,GAAGC,gCAAsB,cAAc;GAC3D,eAAe,GAAGC,2BAAkB,cAAc;EACpD;EACA,IAAI,YAAgD;GAAE,OAAO,CAAC,GAAGC,sCAA+B,cAAc,CAAC;EAAG;EAClH,IAAI,mBAA8D;GAAE,OAAO,CAAC,GAAGC,+BAAgC,cAAc,CAAC;EAAG;EACjI,GAAG,oBAAoB,mCAAmC,CAAC,IAAI,EAAE,MAAM,oBAAoB,GAAG,GAAGC,6BAAqB,cAAc,CAAC,CAAC,CAAC;EACvI,UAAU,CAAC,GAAI,aAAa,YAAY,CAAC,CAAE;CAC7C;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"pi.mjs","names":["contribution","contribution","contribution","contribution","rootSession","hookBeforeAgentStart","hookSessionStart","resourceDoompiUseUserFeedback","toolRestrictionAskUserQuestion","toolAskUserQuestion"],"sources":["../../src/services/askUserToolGate/index.ts","../../src/services/autonomousVoiceMode/index.ts","../../src/services/voiceQuestionNarration/index.ts","../../src/services/voiceQuestionHandoff/index.ts","../../src/extensions/workspaces/sessions/(backend)/_lib/root.cli.ts","../../src/extensions/workspaces/sessions/(backend)/root.cli.ts","../../src/extensions/workspaces/sessions/(backend)/hook/_lib/before-agent-start.cli.ts","../../src/extensions/workspaces/sessions/(backend)/hook/before-agent-start.cli.ts","../../src/extensions/workspaces/sessions/(backend)/hook/_lib/session-start.cli.ts","../../src/extensions/workspaces/sessions/(backend)/hook/session-start.cli.ts","../../src/extensions/workspaces/sessions/(backend)/resource/_lib/doompi-use-user-feedback.cli.ts","../../src/extensions/workspaces/sessions/(backend)/resource/doompi-use-user-feedback.cli.ts","../../src/extensions/workspaces/sessions/(backend)/tool-restriction/_lib/ask-user-question.cli.ts","../../src/extensions/workspaces/sessions/(backend)/tool-restriction/ask-user-question.cli.ts","../../src/tui/askUserToolRender.ts","../../src/services/config/index.ts","../../src/services/rpcQuestionnaire/index.ts","../../src/extensions/workspaces/sessions/(backend)/_tools/askUserQuestion.ts","../../src/extensions/workspaces/sessions/(backend)/tool/askUserQuestion.cli.ts","../../generated/pi.ts"],"sourcesContent":["import type { DoomToolRestriction } from '@agimon-ai/doompi-core/toolSurface';\n\n/**\n * Hides the questionnaire tool while nobody can answer it.\n *\n * Autonomous Voice narrates its own question and then waits for the spoken reply, so a\n * questionnaire tool alongside it asks the same thing twice. A run without UI cannot render\n * the questionnaire at all. Both cases only ever remove the name: the tool surface recomputes\n * from every registered tool, so a visible gate restores it without tracking what it hid.\n */\nexport function askUserToolRestriction(toolName: string, visible: boolean): DoomToolRestriction {\n return (incoming) => (visible ? incoming : incoming.filter((name) => name !== toolName));\n}\n","import { DOOM_VOICE_AUTO_MODE_ID, DOOM_VOICE_SOURCE } from '@agimon-ai/doompi-core/voiceTools';\nimport type { MinorModeRecord } from '@agimon-ai/doompi-minor-mode';\n/**\n * Matches only the Voice package's own autonomous mode, and only while it reports active.\n *\n * Both the source and the mode id are checked because another package may register a mode\n * under the same id, and a transitional `activating` or `deactivating` record is not yet\n * (or no longer) speaking.\n */\nexport function isAutonomousVoiceRecord(record: MinorModeRecord): boolean {\n return (\n record.descriptor.source === DOOM_VOICE_SOURCE &&\n record.descriptor.id === DOOM_VOICE_AUTO_MODE_ID &&\n record.state.activation === 'active'\n );\n}\n\nexport function isAutonomousVoiceActive(records: readonly MinorModeRecord[]): boolean {\n return records.some((record) => isAutonomousVoiceRecord(record));\n}\n","import { MAX_NARRATION_TEXT_CHARACTERS } from '@agimon-ai/doompi-core/narration';\n\nimport type { QuestionParams } from '../../schemas/questionnaire';\n\nconst MAX_QUESTION_CHARACTERS = 240;\nconst MAX_OPTION_CHARACTERS = 80;\nconst PATH_PATTERN = /\\/(?:Users|home|private|tmp|var)\\/[^\\s,;:]+/gu;\nconst TOKEN_PATTERN = /\\b(?:sk|api|token|key)[-_][A-Za-z0-9_-]{12,}\\b/giu;\nconst CODE_PATTERN = /`[^`]*`|<\\/?[A-Za-z][^>]*>|\\$\\([^)]*\\)|\\{[^}]*\\}/gu;\nconst SAFE_FALLBACK = 'I need your answer to the questions shown in the conversation.';\n\nfunction takeCharacters(text: string, maximum: number): string {\n return Array.from(text).slice(0, maximum).join('').trim();\n}\n\nexport function sanitizeVoiceQuestionText(text: string, maximum: number): string {\n const withoutControls = Array.from(text, (character) => {\n const codePoint = character.codePointAt(0) ?? 0;\n return codePoint < 32 || codePoint === 127 ? ' ' : character;\n }).join('');\n return takeCharacters(\n withoutControls\n .replace(PATH_PATTERN, ' ')\n .replace(TOKEN_PATTERN, ' ')\n .replace(CODE_PATTERN, ' ')\n .replace(/\\s+/gu, ' ')\n .trim(),\n maximum,\n );\n}\n\nfunction spokenQuestion(params: QuestionParams, questionIndex: number): string {\n const question = params.questions[questionIndex];\n if (!question) return '';\n const position = questionIndex + 1;\n const prompt =\n sanitizeVoiceQuestionText(question.question, MAX_QUESTION_CHARACTERS) || `Question ${position} needs your choice`;\n const labels = question.options.map((option, optionIndex) => {\n const label = sanitizeVoiceQuestionText(option.label, MAX_OPTION_CHARACTERS);\n return `${optionIndex + 1}, ${label || `option ${optionIndex + 1}`}`;\n });\n const selection = question.multiSelect ? 'You may choose more than one option.' : 'Please choose one option.';\n return `Question ${position}: ${prompt}. Options: ${labels.join('; ')}. ${selection} You may also answer in your own words.`;\n}\n\nexport function buildVoiceQuestionNarration(params: QuestionParams): string {\n const questions = params.questions.map((_question, index) => spokenQuestion(params, index));\n const combined = sanitizeVoiceQuestionText(questions.join(' '), MAX_NARRATION_TEXT_CHARACTERS);\n return combined || SAFE_FALLBACK;\n}\n","import { createNarrationRequest, type DoomNarrationService } from '@agimon-ai/doompi-core/narration';\nimport type { MinorModeCatalogService } from '@agimon-ai/doompi-minor-mode';\n\nimport type { QuestionParams } from '../../schemas/questionnaire';\nimport type { QuestionnaireResult, ToolTextResult } from '../../types/questionnaire';\nimport { isAutonomousVoiceRecord } from '../autonomousVoiceMode';\nimport { buildVoiceQuestionNarration } from '../voiceQuestionNarration';\n\nexport const VOICE_WAIT_MESSAGE =\n \"The questions were spoken through autonomous voice. Stop now and wait for the user's next message; it will arrive as an ordinary user message.\";\n\nexport function formatVoiceQuestionPrompt(params: QuestionParams): string {\n const numberQuestions = params.questions.length > 1;\n return params.questions\n .map((question, questionIndex) => {\n const heading = `${numberQuestions ? `${questionIndex + 1}. ` : ''}${question.question}${question.multiSelect ? ' (Select all that apply.)' : ''}`;\n const options = question.options.map((option, optionIndex) => ` ${optionIndex + 1}. ${option.label}`);\n return [heading, ...options, ' Type something.'].join('\\n');\n })\n .join('\\n\\n');\n}\n\nexport class VoiceQuestionHandoff {\n constructor(\n private readonly modes: Pick<MinorModeCatalogService, 'list'>,\n private readonly narration: Pick<DoomNarrationService, 'request'>,\n private readonly buildNarration: (params: QuestionParams) => string = buildVoiceQuestionNarration,\n ) {}\n\n async handoff(params: QuestionParams): Promise<QuestionnaireResult | undefined> {\n if (!this.modes.list().some((record) => isAutonomousVoiceRecord(record))) return undefined;\n const narration = createNarrationRequest(this.buildNarration(params));\n if (!narration) return undefined;\n await this.narration.request(narration);\n return {\n answers: [],\n cancelled: false,\n delivery: 'voice',\n awaitingResponse: true,\n voicePrompt: formatVoiceQuestionPrompt(params),\n };\n }\n}\n\n/** Create a handoff from services whose lifecycle is owned by a Cordis injection. */\nexport function createVoiceQuestionHandoff(\n modes: Pick<MinorModeCatalogService, 'list'>,\n narration: Pick<DoomNarrationService, 'request'>,\n): VoiceQuestionHandoff {\n return new VoiceQuestionHandoff(modes, narration);\n}\n\nexport function buildVoiceToolResult(details: QuestionnaireResult): ToolTextResult {\n const prompt = details.voicePrompt?.trim();\n return {\n content: [{ type: 'text', text: prompt ? `${prompt}\\n\\n${VOICE_WAIT_MESSAGE}` : VOICE_WAIT_MESSAGE }],\n details,\n terminate: true,\n };\n}\n","import { defineRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport { DOOM_NARRATION_SERVICE, requireDoomNarrationService } from '@agimon-ai/doompi-core/narration';\nimport type { PiPluginContext } from '@agimon-ai/doompi-core/piExtension';\nimport type { DoomToolRestriction } from '@agimon-ai/doompi-core/toolSurface';\nimport { DOOM_MINOR_MODE_CATALOG_SERVICE, requireMinorModeCatalog } from '@agimon-ai/doompi-minor-mode';\nimport type { Context } from '@deepseek-ai/cordis';\nimport type { ExtensionContext } from '@earendil-works/pi-coding-agent';\n\nimport { ASK_USER_QUESTION_TOOL_NAME } from '../../../../../constants/tool';\nimport { askUserToolRestriction } from '../../../../../services/askUserToolGate';\nimport { isAutonomousVoiceActive } from '../../../../../services/autonomousVoiceMode';\nimport { QuestionnaireCoordinator, type QuestionnaireRunner } from '../../../../../services/questionnaireCoordinator';\nimport { createVoiceQuestionHandoff, type VoiceQuestionHandoff } from '../../../../../services/voiceQuestionHandoff';\nimport type { QuestionnaireResult } from '../../../../../types/questionnaire';\nimport { createAskUserQuestionTool } from '.././_tools/askUserQuestion';\n\nfunction cancelledResult(): QuestionnaireResult {\n return { answers: [], cancelled: true };\n}\n\nconst root = defineRoot((_context: PiPluginContext) => {\n let active = true;\n let sessionGeneration = 0;\n let sessionId: string | undefined;\n let sessionReady = false;\n let coordinator = new QuestionnaireCoordinator();\n let voiceHandoff: VoiceQuestionHandoff | undefined;\n let voiceActive = false;\n let hasUI = true;\n const restrictionListeners = new Set<() => void>();\n const currentRestriction = (): DoomToolRestriction =>\n askUserToolRestriction(ASK_USER_QUESTION_TOOL_NAME, hasUI && !voiceActive);\n const syncToolRestriction = (): void => restrictionListeners.forEach((listener) => listener());\n let lifecycleQueue: Promise<void> = Promise.resolve();\n const pendingOperations = new Set<Promise<unknown>>();\n\n const trackOperation = <T>(operation: Promise<T>): Promise<T> => {\n pendingOperations.add(operation);\n void operation.then(\n () => pendingOperations.delete(operation),\n () => pendingOperations.delete(operation),\n );\n return operation;\n };\n const ownsGeneration = (generation: number, expectedSessionId: string | undefined): boolean =>\n active && generation === sessionGeneration && expectedSessionId === sessionId;\n const isContextActive = (context: ExtensionContext, signal?: AbortSignal): boolean =>\n active && sessionReady && signal?.aborted !== true && context.sessionManager.getSessionId() === sessionId;\n\n const shutdownRuntime = async (): Promise<void> => {\n if (!active) return;\n const ownedCoordinator = coordinator;\n ownedCoordinator.shutdown();\n active = false;\n sessionGeneration += 1;\n sessionReady = false;\n sessionId = undefined;\n await Promise.allSettled(pendingOperations);\n await ownedCoordinator.waitForIdle();\n };\n\n const toolDependencies: Parameters<typeof createAskUserQuestionTool>[1] = {\n enqueue: (runner: QuestionnaireRunner, signal?: AbortSignal) => {\n const ownedCoordinator = coordinator;\n const generation = sessionGeneration;\n const expectedSessionId = sessionId;\n if (!sessionReady || !ownsGeneration(generation, expectedSessionId) || signal?.aborted) {\n return Promise.resolve(cancelledResult());\n }\n return ownedCoordinator.enqueue(async (context) => {\n if (!sessionReady || !ownsGeneration(generation, expectedSessionId) || context.signal.aborted) {\n return cancelledResult();\n }\n const result = await runner({\n ...context,\n reportProgress: (progress) => {\n if (ownsGeneration(generation, expectedSessionId) && !context.signal.aborted) {\n context.reportProgress(progress);\n }\n },\n });\n return sessionReady && ownsGeneration(generation, expectedSessionId) && !context.signal.aborted\n ? result\n : cancelledResult();\n }, signal);\n },\n isActive: isContextActive,\n runTui: async (context, params, collapseKey, signal, reportProgress) => {\n if (!isContextActive(context, signal)) return undefined;\n const { runTuiQuestionnaire } = await import('../../../../../tui/runQuestionnaire');\n if (!isContextActive(context, signal)) return undefined;\n const result = await runTuiQuestionnaire(context, params, collapseKey, signal, reportProgress);\n return isContextActive(context, signal) ? result : undefined;\n },\n tryVoice: (params) => (active && sessionReady ? voiceHandoff?.handoff(params) : undefined),\n };\n\n const beforeAgentStart = (_event: unknown, context: ExtensionContext) => {\n if (!isContextActive(context)) return;\n hasUI = context.hasUI;\n syncToolRestriction();\n };\n\n const sessionStart = (_event: unknown, context: ExtensionContext) => {\n if (!active) return;\n const previousCoordinator = coordinator;\n previousCoordinator.shutdown();\n const activeSessionId = context.sessionManager.getSessionId();\n const generation = ++sessionGeneration;\n const nextCoordinator = new QuestionnaireCoordinator();\n coordinator = nextCoordinator;\n sessionId = activeSessionId;\n sessionReady = false;\n\n const initializeSession = async (): Promise<void> => {\n await previousCoordinator.waitForIdle();\n if (!ownsGeneration(generation, activeSessionId)) return;\n sessionReady = true;\n // The surface is re-registered per session from the gate state in force, so a session\n // that starts with Voice already active needs nothing extra here.\n };\n\n const operation = lifecycleQueue.then(initializeSession, initializeSession);\n lifecycleQueue = operation.catch(() => undefined);\n return trackOperation(operation);\n };\n const toolRestriction = {\n source: '@agimon-ai/doompi-user-feedback',\n get restrict() {\n return currentRestriction();\n },\n subscribe(listener: () => void) {\n restrictionListeners.add(listener);\n return () => {\n restrictionListeners.delete(listener);\n };\n },\n };\n\n return {\n value: {\n toolDependencies,\n beforeAgentStart,\n sessionStart,\n toolRestriction,\n },\n services: [\n (serviceContextOwner: Context) => {\n serviceContextOwner.inject([DOOM_MINOR_MODE_CATALOG_SERVICE, DOOM_NARRATION_SERVICE], (serviceContext) => {\n const handoff = createVoiceQuestionHandoff(\n requireMinorModeCatalog(serviceContext),\n requireDoomNarrationService(serviceContext),\n );\n voiceHandoff = handoff;\n return () => {\n if (voiceHandoff === handoff) voiceHandoff = undefined;\n };\n });\n\n // Separate from the handoff binding above: the gate needs only the mode catalog, so it\n // still applies to a Voice build that publishes modes without providing narration.\n serviceContextOwner.inject([DOOM_MINOR_MODE_CATALOG_SERVICE], (modeContext) => {\n const modes = requireMinorModeCatalog(modeContext);\n const apply = (): void => {\n voiceActive = isAutonomousVoiceActive(modes.list());\n syncToolRestriction();\n };\n const unsubscribe = modes.subscribe(apply);\n apply();\n return () => {\n unsubscribe();\n voiceActive = false;\n syncToolRestriction();\n };\n });\n },\n ],\n onDispose: shutdownRuntime,\n };\n});\n\nexport type UserFeedbackPiScope = Awaited<ReturnType<typeof root>>['value'];\nexport default root;\n","import { defineRoot } from '@agimon-ai/doompi-core/extensionFile';\n\nimport contribution from './_lib/root.cli';\n\nexport default defineRoot(contribution);\n","import type { WithRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport type { PiPluginContext } from '@agimon-ai/doompi-core/piExtension';\n\nimport type { UserFeedbackPiScope } from '../../_lib/root.cli';\n\nexport default (context: WithRoot<PiPluginContext, UserFeedbackPiScope>) => context.root.beforeAgentStart;\n","import { defineCliHook } from '@agimon-ai/doompi-core/extensionFile';\n\nimport contribution from './_lib/before-agent-start.cli';\n\nexport default defineCliHook(contribution);\n","import type { WithRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport type { PiPluginContext } from '@agimon-ai/doompi-core/piExtension';\n\nimport type { UserFeedbackPiScope } from '../../_lib/root.cli';\n\nexport default (context: WithRoot<PiPluginContext, UserFeedbackPiScope>) => context.root.sessionStart;\n","import { defineCliHook } from '@agimon-ai/doompi-core/extensionFile';\n\nimport contribution from './_lib/session-start.cli';\n\nexport default defineCliHook(contribution);\n","export function createDoompiUseUserFeedbackResource(moduleUrl: string) {\n return {\n source: '@agimon-ai/doompi-user-feedback',\n moduleUrl,\n skills: [\n {\n name: 'doompi-use-user-feedback',\n description:\n 'Use @agimon-ai/doompi-user-feedback: Structured user questions with interactive and autonomous Voice handoff for Pi agents.',\n },\n ],\n };\n}\n","import { defineResource } from '@agimon-ai/doompi-core/extensionFile';\n\nimport { createDoompiUseUserFeedbackResource } from './_lib/doompi-use-user-feedback.cli';\n\nexport default defineResource(createDoompiUseUserFeedbackResource(import.meta.url));\n","import type { WithRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport type { PiPluginContext } from '@agimon-ai/doompi-core/piExtension';\n\nimport type { UserFeedbackPiScope } from '../../_lib/root.cli';\n\nexport default (context: WithRoot<PiPluginContext, UserFeedbackPiScope>) => context.root.toolRestriction;\n","import { defineToolRestriction } from '@agimon-ai/doompi-core/extensionFile';\n\nimport contribution from './_lib/ask-user-question.cli';\n\nexport default defineToolRestriction(contribution);\n","import { DoomToolCall, DoomToolResult, renderToolHeading } from '@agimon-ai/doompi-ui/toolChrome';\nimport type { ToolDefinition } from '@earendil-works/pi-coding-agent';\n\nimport type { QuestionParams, QuestionParamsSchema } from '../schemas/questionnaire';\nimport type { QuestionnaireResult } from '../types/questionnaire';\nexport const askUserToolRender: Pick<\n ToolDefinition<typeof QuestionParamsSchema, QuestionnaireResult>,\n 'renderCall' | 'renderResult'\n> = {\n renderCall(args, theme) {\n const params = args as QuestionParams;\n const headers = params.questions.map((question) => question.header).join(', ');\n const count = `${params.questions.length} question${params.questions.length === 1 ? '' : 's'}`;\n const heading = renderToolHeading('ask', count, theme);\n return new DoomToolCall(headers ? `${heading} ${theme.fg('dim', `(${headers})`)}` : heading);\n },\n\n renderResult(result, _options, theme, context) {\n const details = result.details as QuestionnaireResult | undefined;\n if (!details) {\n const raw = result.content\n .filter((block) => block.type === 'text')\n .map((block) => block.text)\n .join('\\n');\n const color = context.isError ? 'error' : 'toolOutput';\n const fallback = context.isError ? '✗ failed' : '✓ submitted';\n return new DoomToolResult([theme.fg(color, raw || fallback)], theme, { wrap: true });\n }\n if (details.cancelled) {\n return new DoomToolResult([theme.fg('warning', '◐') + theme.fg('dim', ' cancelled')], theme);\n }\n if (details.delivery === 'voice' && details.voicePrompt) {\n return new DoomToolResult([theme.fg('toolOutput', details.voicePrompt)], theme, { wrap: true });\n }\n const lines = details.answers.map((answer) => {\n const scalar = answer.kind === 'multi' ? (answer.selected ?? []).join(', ') : answer.answer;\n return `${theme.fg('success', '✓')} ${theme.fg('accent', answer.question)}: ${theme.fg(\n 'toolOutput',\n scalar ?? '',\n )}`;\n });\n if (lines.length === 0) lines.push(theme.fg('success', '✓') + theme.fg('dim', ' submitted'));\n return new DoomToolResult(lines, theme, { wrap: true });\n },\n};\n","import fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\n\nexport const DEFAULT_COLLAPSE_KEY = 'ctrl+]';\nexport const COLLAPSE_KEY_OFF = 'off';\n\nexport interface GuidanceConfig {\n promptSnippet?: string;\n promptGuidelines?: string[];\n}\n\nexport interface UserFeedbackConfig {\n collapseKey?: string;\n guidance?: GuidanceConfig;\n}\n\nfunction legacyConfigPath(environment: NodeJS.ProcessEnv): string {\n const configRoot = environment.XDG_CONFIG_HOME?.trim() || path.join(os.homedir(), '.config');\n return path.join(configRoot, 'rpiv-ask-user-question', 'config.json');\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nexport function loadUserFeedbackConfig(environment: NodeJS.ProcessEnv = process.env): UserFeedbackConfig {\n const filePath = legacyConfigPath(environment);\n if (!fs.existsSync(filePath)) return {};\n try {\n const parsed: unknown = JSON.parse(fs.readFileSync(filePath, 'utf8'));\n if (!isRecord(parsed)) return {};\n const rawGuidance = isRecord(parsed.guidance) ? parsed.guidance : undefined;\n const guidance = rawGuidance\n ? {\n ...(typeof rawGuidance.promptSnippet === 'string' ? { promptSnippet: rawGuidance.promptSnippet } : {}),\n ...(Array.isArray(rawGuidance.promptGuidelines) &&\n rawGuidance.promptGuidelines.every((item) => typeof item === 'string')\n ? { promptGuidelines: rawGuidance.promptGuidelines as string[] }\n : {}),\n }\n : undefined;\n return {\n ...(typeof parsed.collapseKey === 'string' ? { collapseKey: parsed.collapseKey } : {}),\n ...(guidance ? { guidance } : {}),\n };\n } catch {\n return {};\n }\n}\n\nexport function resolveCollapseKey(config: UserFeedbackConfig): string {\n const value = config.collapseKey?.trim().toLowerCase();\n if (!value) return DEFAULT_COLLAPSE_KEY;\n if (value === COLLAPSE_KEY_OFF) return COLLAPSE_KEY_OFF;\n return /^[a-z0-9_+\\-\\]{}]+$/u.test(value) ? value : DEFAULT_COLLAPSE_KEY;\n}\n","import type { ExtensionContext } from '@earendil-works/pi-coding-agent';\n\nimport type { QuestionParams } from '../../schemas/questionnaire';\nimport type { QuestionnaireResult } from '../../types/questionnaire';\nimport { runQuestionnaire, type QuestionnaireInteraction } from '../questionnaireService';\n\nexport async function runRpcQuestionnaire(\n context: ExtensionContext,\n params: QuestionParams,\n signal?: AbortSignal,\n reportProgress?: (result: QuestionnaireResult) => void,\n): Promise<QuestionnaireResult> {\n const interaction: QuestionnaireInteraction = {\n select: (title, options, interactionSignal) =>\n context.ui.select(title, [...options], { signal: interactionSignal }),\n input: (title, placeholder, interactionSignal) =>\n context.ui.input(title, placeholder, { signal: interactionSignal }),\n };\n return runQuestionnaire(interaction, params, signal, reportProgress);\n}\n","import {\n type AskUserBlockedEvent,\n type AskUserPromptEvent,\n DOOM_ASK_USER_BLOCKED_EVENT,\n DOOM_ASK_USER_PROMPT_EVENT,\n} from '@agimon-ai/doompi-core/askUser';\nimport type { Context } from '@deepseek-ai/cordis';\nimport type { ToolDefinition, ExtensionContext } from '@earendil-works/pi-coding-agent';\n\nimport {\n ASK_USER_QUESTION_TOOL_NAME,\n DEFAULT_PROMPT_SNIPPET,\n DEFAULT_PROMPT_GUIDELINES,\n ERROR_NO_UI,\n ERROR_NO_CUSTOM_UI,\n ERROR_SESSION_LOAD_FAILED,\n ERROR_SESSION_INACTIVE,\n} from '../../../../../constants/tool';\nimport { type QuestionParams, QuestionParamsSchema } from '../../../../../schemas/questionnaire';\nimport { loadUserFeedbackConfig, resolveCollapseKey } from '../../../../../services/config';\nimport type { QuestionnaireRunner } from '../../../../../services/questionnaireCoordinator';\nimport { buildQuestionnaireResponse, buildToolResult } from '../../../../../services/responseService';\nimport { runRpcQuestionnaire } from '../../../../../services/rpcQuestionnaire';\nimport { validateQuestionnaire } from '../../../../../services/validationService';\nimport { buildVoiceToolResult } from '../../../../../services/voiceQuestionHandoff';\nimport type { QuestionnaireResult } from '../../../../../types/questionnaire';\nexport interface AskUserQuestionToolDependencies {\n enqueue: (runner: QuestionnaireRunner, signal?: AbortSignal) => Promise<QuestionnaireResult>;\n isActive?: (context: ExtensionContext, signal?: AbortSignal) => boolean;\n tryVoice?: (params: QuestionParams) => QuestionnaireResult | undefined | Promise<QuestionnaireResult | undefined>;\n runTui: (\n context: ExtensionContext,\n params: QuestionParams,\n collapseKey: string,\n signal?: AbortSignal,\n reportProgress?: (result: QuestionnaireResult) => void,\n ) => Promise<QuestionnaireResult | undefined>;\n}\n\nfunction emitPrompt(cordis: Context, params: QuestionParams): void {\n const payload: AskUserPromptEvent = {\n questions: params.questions.map((question) => ({\n question: question.question,\n header: question.header,\n multiSelect: question.multiSelect ?? false,\n options: question.options.map((option) => ({\n label: option.label,\n description: option.description,\n hasPreview: Boolean(option.preview),\n })),\n })),\n };\n cordis.emit(DOOM_ASK_USER_PROMPT_EVENT, payload);\n}\n\nfunction emitBlocked(cordis: Context, active: boolean): void {\n const payload: AskUserBlockedEvent = { active };\n cordis.emit(DOOM_ASK_USER_BLOCKED_EVENT, payload);\n}\n\nfunction hasDialogUI(context: ExtensionContext): boolean {\n const ui = context.ui as unknown as { select?: unknown; input?: unknown };\n return typeof ui.select === 'function' && typeof ui.input === 'function';\n}\n\nexport function createAskUserQuestionTool(\n cordis: Context,\n dependencies: AskUserQuestionToolDependencies,\n renderers: Pick<ToolDefinition<typeof QuestionParamsSchema, QuestionnaireResult>, 'renderCall' | 'renderResult'> = {},\n): ToolDefinition<typeof QuestionParamsSchema, QuestionnaireResult> {\n const configuredGuidance = loadUserFeedbackConfig().guidance;\n return {\n name: ASK_USER_QUESTION_TOOL_NAME,\n label: 'Ask User Question',\n renderShell: 'self',\n description: `Ask the user one or more structured questions during execution. Use when you need to:\n1. Gather user preferences or requirements\n2. Clarify ambiguous instructions\n3. Get decisions on implementation choices as you work\n4. Offer choices to the user about what direction to take\n\nUsage notes:\n- Users can type a custom answer via the automatically appended \"Type something.\" row on every question or press Esc to abandon the questionnaire. Do NOT author \"Other\" or \"Type something.\" labels yourself, reserved labels are rejected at runtime.\n- Use multiSelect: true when multiple answers are valid.\n- If you recommend a specific option, make that the first option and add \"(Recommended)\" at the end of the label.\n\nPreview feature:\nUse the optional preview field for ASCII mockups, code snippets, diagrams, or configuration examples that users should compare visually. Do not use previews for simple preference questions.`,\n promptSnippet: configuredGuidance?.promptSnippet ?? DEFAULT_PROMPT_SNIPPET,\n promptGuidelines: configuredGuidance?.promptGuidelines ?? DEFAULT_PROMPT_GUIDELINES,\n parameters: QuestionParamsSchema,\n executionMode: 'sequential',\n\n async execute(_toolCallId, params, signal, _onUpdate, context) {\n const typed = params as QuestionParams;\n const isActive = (activeSignal?: AbortSignal): boolean => dependencies.isActive?.(context, activeSignal) ?? true;\n const cancelled = (): QuestionnaireResult => ({ answers: [], cancelled: true });\n if (!isActive(signal)) return buildToolResult(ERROR_SESSION_INACTIVE, cancelled());\n if (!context.hasUI) {\n return buildToolResult(ERROR_NO_UI, { answers: [], cancelled: true, error: 'no_ui' });\n }\n\n const validation = validateQuestionnaire(typed);\n if (!validation.ok) {\n return buildToolResult(validation.message, {\n answers: [],\n cancelled: true,\n error: validation.error,\n });\n }\n\n try {\n const result = await dependencies.enqueue(async ({ signal: activeSignal, reportProgress }) => {\n if (!isActive(activeSignal)) return cancelled();\n emitPrompt(cordis, typed);\n const voiceResult = await dependencies.tryVoice?.(typed);\n if (voiceResult) return voiceResult;\n\n let blocked = true;\n const clearBlocked = (): void => {\n if (!blocked) return;\n blocked = false;\n if (isActive()) emitBlocked(cordis, false);\n };\n activeSignal.addEventListener('abort', clearBlocked, { once: true });\n emitBlocked(cordis, true);\n try {\n if (!isActive(activeSignal)) return cancelled();\n if (context.mode === 'rpc' && hasDialogUI(context)) {\n const rpcResult = await runRpcQuestionnaire(context, typed, activeSignal, reportProgress);\n return isActive(activeSignal) ? rpcResult : cancelled();\n }\n\n const tuiResult = await dependencies.runTui(\n context,\n typed,\n resolveCollapseKey(loadUserFeedbackConfig()),\n activeSignal,\n reportProgress,\n );\n if (!isActive(activeSignal)) return cancelled();\n if (tuiResult !== undefined) return tuiResult;\n if (hasDialogUI(context)) {\n const rpcResult = await runRpcQuestionnaire(context, typed, activeSignal, reportProgress);\n return isActive(activeSignal) ? rpcResult : cancelled();\n }\n return { answers: [], cancelled: true, error: 'no_custom_ui' };\n } finally {\n activeSignal.removeEventListener('abort', clearBlocked);\n clearBlocked();\n }\n }, signal);\n\n if (result.delivery === 'voice') return buildVoiceToolResult(result);\n if (result.error === 'no_custom_ui') return buildToolResult(ERROR_NO_CUSTOM_UI, result);\n return buildQuestionnaireResponse(result, typed);\n } catch (error) {\n const cause = error instanceof Error ? error.message : String(error);\n return buildToolResult(`${ERROR_SESSION_LOAD_FAILED} (cause: ${cause})`, {\n answers: [],\n cancelled: true,\n error: 'session_load_failed',\n });\n }\n },\n\n ...renderers,\n };\n}\n","import { defineCliTool, type WithRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport { definePiTool, type PiPluginContext } from '@agimon-ai/doompi-core/piExtension';\n\nimport { askUserToolRender } from '../../../../../tui/askUserToolRender';\nimport type { UserFeedbackPiScope } from '../_lib/root.cli';\nimport { createAskUserQuestionTool } from '../_tools/askUserQuestion';\n\nexport default defineCliTool((context: WithRoot<PiPluginContext, UserFeedbackPiScope>) =>\n definePiTool(createAskUserQuestionTool(context.context, context.root.toolDependencies, askUserToolRender)),\n);\n","// Generated by @agimon-ai/doompi-build. Do not edit by hand.\nimport { definePiExtension, piToolContributions, type PiPluginContext, type PiPluginContributions } from '@agimon-ai/doompi-core/piExtension';\nimport { composeRootHooks } from '@agimon-ai/doompi-core/extensionFile';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.cli';\nimport hookBeforeAgentStart from '../src/extensions/workspaces/sessions/(backend)/hook/before-agent-start.cli';\nimport hookSessionStart from '../src/extensions/workspaces/sessions/(backend)/hook/session-start.cli';\nimport resourceDoompiUseUserFeedback from '../src/extensions/workspaces/sessions/(backend)/resource/doompi-use-user-feedback.cli';\nimport toolRestrictionAskUserQuestion from '../src/extensions/workspaces/sessions/(backend)/tool-restriction/ask-user-question.cli';\nimport toolAskUserQuestion from '../src/extensions/workspaces/sessions/(backend)/tool/askUserQuestion.cli';\n\ntype OptionsOf<T> = T extends (context: PiPluginContext<infer Options>) => unknown ? Options : never;\ntype InferredOptions = Exclude<OptionsOf<typeof rootSession> | OptionsOf<typeof hookBeforeAgentStart> | OptionsOf<typeof hookSessionStart> | OptionsOf<typeof resourceDoompiUseUserFeedback> | OptionsOf<typeof toolRestrictionAskUserQuestion> | OptionsOf<typeof toolAskUserQuestion>, undefined>;\ntype Intersect<Union> =\n (Union extends unknown ? (value: Union) => void : never) extends (value: infer Value) => void ? Value : never;\ntype ExtensionOptions = [InferredOptions] extends [never] ? undefined : Intersect<InferredOptions>;\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const extension = definePiExtension<ExtensionOptions>('@agimon-ai/doompi-user-feedback', async (context) => {\n const scopeSession = await rootSession(context);\n const contextSession = { ...context, root: scopeSession.value };\n return {\n ...composeRootHooks(scopeSession),\n events: {\n before_agent_start: at(hookBeforeAgentStart, contextSession) as NonNullable<PiPluginContributions['events']>['before_agent_start'],\n session_start: at(hookSessionStart, contextSession) as NonNullable<PiPluginContributions['events']>['session_start'],\n },\n get resources(): PiPluginContributions['resources'] { return [at(resourceDoompiUseUserFeedback, contextSession)]; },\n get toolRestrictions(): PiPluginContributions['toolRestrictions'] { return [at(toolRestrictionAskUserQuestion, contextSession)]; },\n ...piToolContributions('@agimon-ai/doompi-user-feedback', [via({ name: 'ask_user_question' }, at(toolAskUserQuestion, contextSession))]),\n services: [...(scopeSession.services ?? [])],\n };\n});\n\nexport default extension;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAUA,SAAgB,uBAAuB,UAAkB,SAAuC;CAC9F,QAAQ,aAAc,UAAU,WAAW,SAAS,QAAQ,SAAS,SAAS,QAAQ;AACxF;;;;;;;;;;ACHA,SAAgB,wBAAwB,QAAkC;CACxE,OACE,OAAO,WAAW,WAAW,qBAC7B,OAAO,WAAW,OAAO,2BACzB,OAAO,MAAM,eAAe;AAEhC;AAEA,SAAgB,wBAAwB,SAA8C;CACpF,OAAO,QAAQ,MAAM,WAAW,wBAAwB,MAAM,CAAC;AACjE;;;ACfA,MAAM,0BAA0B;AAChC,MAAM,wBAAwB;AAC9B,MAAM,eAAe;AACrB,MAAM,gBAAgB;AACtB,MAAM,eAAe;AACrB,MAAM,gBAAgB;AAEtB,SAAS,eAAe,MAAc,SAAyB;CAC7D,OAAO,MAAM,KAAK,IAAI,CAAC,CAAC,MAAM,GAAG,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK;AAC1D;AAEA,SAAgB,0BAA0B,MAAc,SAAyB;CAK/E,OAAO,eAJiB,MAAM,KAAK,OAAO,cAAc;EACtD,MAAM,YAAY,UAAU,YAAY,CAAC,KAAK;EAC9C,OAAO,YAAY,MAAM,cAAc,MAAM,MAAM;CACrD,CAAC,CAAC,CAAC,KAAK,EAEQ,CAAC,CACZ,QAAQ,cAAc,GAAG,CAAC,CAC1B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10 @@ var askUserQuestion_server_default = (0, _agimon_ai_doompi_core_extensionFile.de
|
|
|
91
91
|
//#endregion
|
|
92
92
|
//#region generated/server.ts
|
|
93
93
|
const at = (value, context) => typeof value === "function" ? value(context) : value;
|
|
94
|
-
const via = (identity, value) =>
|
|
94
|
+
const via = (identity, value) => value === void 0 ? void 0 : {
|
|
95
95
|
...identity,
|
|
96
96
|
...value
|
|
97
|
-
}
|
|
97
|
+
};
|
|
98
98
|
const facet = (0, _agimon_ai_doompi_core_serverFacet.defineServerPlugin)({
|
|
99
99
|
name: "@agimon-ai/doompi-user-feedback",
|
|
100
100
|
session: async (context) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.cjs","names":["defineRoot","QuestionnaireCoordinator","defineRoot","contribution","defineToolRestriction","DOOM_VOICE_AUTO_MODE_ID","ASK_USER_QUESTION_TOOL_NAME","ASK_USER_QUESTION_TOOL_NAME","QuestionParamsSchema","validateQuestionnaire","buildToolResult","QuestionnaireCoordinator","runQuestionnaire","buildQuestionnaireResponse","defineServerTool","defineServerPlugin","rootSession","composeRootHooks","toolRestrictionAskUserQuestion","toolAskUserQuestion"],"sources":["../../src/extensions/workspaces/sessions/(backend)/_lib/root.server.ts","../../src/extensions/workspaces/sessions/(backend)/root.server.ts","../../src/extensions/workspaces/sessions/(backend)/tool-restriction/askUserQuestion.server.ts","../../src/extensions/workspaces/sessions/(backend)/_tools/askUserHeadless.ts","../../src/extensions/workspaces/sessions/(backend)/tool/askUserQuestion.server.ts","../../generated/server.ts"],"sourcesContent":["import { defineRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport type { DoomServerPluginContext } from '@agimon-ai/doompi-core/serverFacet';\n\nimport { QuestionnaireCoordinator } from '../../../../../services/questionnaireCoordinator';\n\nconst root = defineRoot((_context: DoomServerPluginContext) => {\n const coordinator = new QuestionnaireCoordinator();\n return {\n value: { coordinator },\n onDispose: () => coordinator.shutdown(),\n };\n});\n\nexport type UserFeedbackServerScope = Awaited<ReturnType<typeof root>>['value'];\nexport default root;\n","import { defineRoot } from '@agimon-ai/doompi-core/extensionFile';\n\nimport contribution from './_lib/root.server';\n\nexport default defineRoot(contribution);\n","import { defineToolRestriction } from '@agimon-ai/doompi-core/extensionFile';\nimport type { DoomHeadlessToolRestriction } from '@agimon-ai/doompi-core/headless';\nimport { DOOM_VOICE_AUTO_MODE_ID } from '@agimon-ai/doompi-core/voiceTools';\n\nimport { ASK_USER_QUESTION_TOOL_NAME } from '../../../../../constants/tool';\n\nexport default defineToolRestriction({\n when: { state: { 'minor-mode': DOOM_VOICE_AUTO_MODE_ID } },\n excludedTools: [ASK_USER_QUESTION_TOOL_NAME],\n} satisfies DoomHeadlessToolRestriction);\n","import { type DoomHeadlessTool, type DoomHeadlessToolResult } from '@agimon-ai/doompi-core/headless';\n\nimport { ASK_USER_QUESTION_TOOL_NAME } from '../../../../../constants/tool';\nimport type { QuestionParams } from '../../../../../schemas/questionnaire';\nimport { QuestionParamsSchema } from '../../../../../schemas/questionnaire';\nimport { QuestionnaireCoordinator } from '../../../../../services/questionnaireCoordinator';\nimport { runQuestionnaire, type QuestionnaireInteraction } from '../../../../../services/questionnaireService';\nimport { buildQuestionnaireResponse, buildToolResult } from '../../../../../services/responseService';\nimport { validateQuestionnaire } from '../../../../../services/validationService';\nimport type { QuestionnaireResult } from '../../../../../types/questionnaire';\n\nfunction output(result: {\n content: Array<{ type: 'text'; text: string }>;\n details: QuestionnaireResult;\n}): DoomHeadlessToolResult {\n return { content: result.content, details: result.details };\n}\n\nexport function createAskUserHeadlessTool(\n coordinator?: QuestionnaireCoordinator,\n): DoomHeadlessTool<typeof QuestionParamsSchema> {\n const tool: DoomHeadlessTool<typeof QuestionParamsSchema> = {\n name: ASK_USER_QUESTION_TOOL_NAME,\n label: 'Ask User Question',\n description: 'Ask the user one or more structured questions during execution.',\n parameters: QuestionParamsSchema,\n promptSnippet: 'Ask the user structured questions when requirements are ambiguous',\n executionMode: 'serial',\n async execute(_toolCallId, parameters, signal, _onUpdate, executionContext) {\n const params = parameters as QuestionParams;\n const validation = validateQuestionnaire(params);\n if (!validation.ok) {\n return output(buildToolResult(validation.message, { answers: [], cancelled: true, error: validation.error }));\n }\n const activeCoordinator = coordinator ?? new QuestionnaireCoordinator();\n try {\n const result = await activeCoordinator.enqueue(async ({ signal: requestSignal, reportProgress }) => {\n requestSignal.throwIfAborted();\n const interaction: QuestionnaireInteraction = {\n select: async (title, options, interactionSignal) => {\n const response = await executionContext.client.request(\n {\n kind: 'select',\n title,\n options: options.map((label) => ({ label, value: label })),\n },\n interactionSignal,\n );\n return typeof response === 'string' ? response : undefined;\n },\n input: async (title, placeholder, interactionSignal) => {\n const response = await executionContext.client.request(\n { kind: 'input', title, message: placeholder },\n interactionSignal,\n );\n return typeof response === 'string' ? response : undefined;\n },\n };\n const questionnaire = await runQuestionnaire(interaction, params, requestSignal, reportProgress);\n requestSignal.throwIfAborted();\n return questionnaire;\n }, signal);\n return output(buildQuestionnaireResponse(result, params));\n } finally {\n if (coordinator === undefined) {\n activeCoordinator.shutdown();\n await activeCoordinator.waitForIdle();\n }\n }\n },\n };\n return tool;\n}\n","import { defineServerTool, type WithRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport type { DoomServerPluginContext } from '@agimon-ai/doompi-core/serverFacet';\n\nimport type { UserFeedbackServerScope } from '../_lib/root.server';\nimport { createAskUserHeadlessTool } from '../_tools/askUserHeadless';\n\nexport default defineServerTool((context: WithRoot<DoomServerPluginContext, UserFeedbackServerScope>) =>\n createAskUserHeadlessTool(context.root.coordinator),\n);\n","// Generated by @agimon-ai/doompi-build. Do not edit by hand.\nimport { defineServerPlugin, type DoomServerSessionPlugin } from '@agimon-ai/doompi-core/serverFacet';\nimport { composeRootHooks } from '@agimon-ai/doompi-core/extensionFile';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.server';\nimport toolRestrictionAskUserQuestion from '../src/extensions/workspaces/sessions/(backend)/tool-restriction/askUserQuestion.server';\nimport toolAskUserQuestion from '../src/extensions/workspaces/sessions/(backend)/tool/askUserQuestion.server';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T => ({ ...identity, ...(value as object) }) as T;\n\nexport const facet = defineServerPlugin({\n name: '@agimon-ai/doompi-user-feedback',\n session: async (context) => {\n const scopeSession = await rootSession(context);\n const contextSession = { ...context, root: scopeSession.value };\n return {\n ...composeRootHooks(scopeSession),\n get toolRestrictions(): DoomServerSessionPlugin['toolRestrictions'] { return [at(toolRestrictionAskUserQuestion, contextSession)]; },\n get tools(): DoomServerSessionPlugin['tools'] { return [via({ name: 'ask_user_question' }, at(toolAskUserQuestion, contextSession))]; },\n services: [...(scopeSession.services ?? [])],\n get activities(): DoomServerSessionPlugin['activities'] { return [...(scopeSession.activities ?? [])]; },\n };\n },\n});\n\nexport default facet;\n"],"mappings":";;;;;;;;;AAKA,MAAM,QAAA,GAAOA,qCAAAA,WAAAA,EAAY,aAAsC;CAC7D,MAAM,cAAc,IAAIC,0BAAAA,yBAAyB;CACjD,OAAO;EACL,OAAO,EAAE,YAAY;EACrB,iBAAiB,YAAY,SAAS;CACxC;AACF,CAAC;;;ACPD,IAAA,uBAAA,GAAeC,qCAAAA,WAAAA,CAAWC,IAAY;;;ACEtC,IAAA,oCAAA,GAAeC,qCAAAA,sBAAAA,CAAsB;CACnC,MAAM,EAAE,OAAO,EAAE,cAAcC,kCAAAA,wBAAwB,EAAE;CACzD,eAAe,CAACC,0BAAAA,2BAA2B;AAC7C,CAAuC;;;ACEvC,SAAS,OAAO,QAGW;CACzB,OAAO;EAAE,SAAS,OAAO;EAAS,SAAS,OAAO;CAAQ;AAC5D;AAEA,SAAgB,0BACd,aAC+C;CAmD/C,OAAO;EAjDL,MAAMC,0BAAAA;EACN,OAAO;EACP,aAAa;EACb,YAAYC,0BAAAA;EACZ,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ACCA,MAAM,MAAY,OAA0B,YAC1C,OAAO,UAAU,aAAc,MAAwB,OAAO,IAAI;AACpE,MAAM,OAAU,UAAmC,WAAuB;CAAE,GAAG;CAAU,GAAI;AAAiB;AAE9G,MAAa,SAAA,GAAQC,mCAAAA,mBAAAA,CAAmB;CACtC,MAAM;CACN,SAAS,OAAO,YAAY;EAC1B,MAAM,eAAe,MAAMC,oBAAY,OAAO;EAC9C,MAAM,iBAAiB;GAAE,GAAG;GAAS,MAAM,aAAa;EAAM;EAC9D,OAAO;GACL,IAAA,GAAGC,qCAAAA,iBAAAA,CAAiB,YAAY;GAChC,IAAI,mBAAgE;IAAE,OAAO,CAAC,GAAGC,kCAAgC,cAAc,CAAC;GAAG;GACnI,IAAI,QAA0C;IAAE,OAAO,CAAC,IAAI,EAAE,MAAM,oBAAoB,GAAG,GAAGC,gCAAqB,cAAc,CAAC,CAAC;GAAG;GACtI,UAAU,CAAC,GAAI,aAAa,YAAY,CAAC,CAAE;GAC3C,IAAI,aAAoD;IAAE,OAAO,CAAC,GAAI,aAAa,cAAc,CAAC,CAAE;GAAG;EACzG;CACF;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"server.cjs","names":["defineRoot","QuestionnaireCoordinator","defineRoot","contribution","defineToolRestriction","DOOM_VOICE_AUTO_MODE_ID","ASK_USER_QUESTION_TOOL_NAME","ASK_USER_QUESTION_TOOL_NAME","QuestionParamsSchema","validateQuestionnaire","buildToolResult","QuestionnaireCoordinator","runQuestionnaire","buildQuestionnaireResponse","defineServerTool","defineServerPlugin","rootSession","composeRootHooks","toolRestrictionAskUserQuestion","toolAskUserQuestion"],"sources":["../../src/extensions/workspaces/sessions/(backend)/_lib/root.server.ts","../../src/extensions/workspaces/sessions/(backend)/root.server.ts","../../src/extensions/workspaces/sessions/(backend)/tool-restriction/askUserQuestion.server.ts","../../src/extensions/workspaces/sessions/(backend)/_tools/askUserHeadless.ts","../../src/extensions/workspaces/sessions/(backend)/tool/askUserQuestion.server.ts","../../generated/server.ts"],"sourcesContent":["import { defineRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport type { DoomServerPluginContext } from '@agimon-ai/doompi-core/serverFacet';\n\nimport { QuestionnaireCoordinator } from '../../../../../services/questionnaireCoordinator';\n\nconst root = defineRoot((_context: DoomServerPluginContext) => {\n const coordinator = new QuestionnaireCoordinator();\n return {\n value: { coordinator },\n onDispose: () => coordinator.shutdown(),\n };\n});\n\nexport type UserFeedbackServerScope = Awaited<ReturnType<typeof root>>['value'];\nexport default root;\n","import { defineRoot } from '@agimon-ai/doompi-core/extensionFile';\n\nimport contribution from './_lib/root.server';\n\nexport default defineRoot(contribution);\n","import { defineToolRestriction } from '@agimon-ai/doompi-core/extensionFile';\nimport type { DoomHeadlessToolRestriction } from '@agimon-ai/doompi-core/headless';\nimport { DOOM_VOICE_AUTO_MODE_ID } from '@agimon-ai/doompi-core/voiceTools';\n\nimport { ASK_USER_QUESTION_TOOL_NAME } from '../../../../../constants/tool';\n\nexport default defineToolRestriction({\n when: { state: { 'minor-mode': DOOM_VOICE_AUTO_MODE_ID } },\n excludedTools: [ASK_USER_QUESTION_TOOL_NAME],\n} satisfies DoomHeadlessToolRestriction);\n","import { type DoomHeadlessTool, type DoomHeadlessToolResult } from '@agimon-ai/doompi-core/headless';\n\nimport { ASK_USER_QUESTION_TOOL_NAME } from '../../../../../constants/tool';\nimport type { QuestionParams } from '../../../../../schemas/questionnaire';\nimport { QuestionParamsSchema } from '../../../../../schemas/questionnaire';\nimport { QuestionnaireCoordinator } from '../../../../../services/questionnaireCoordinator';\nimport { runQuestionnaire, type QuestionnaireInteraction } from '../../../../../services/questionnaireService';\nimport { buildQuestionnaireResponse, buildToolResult } from '../../../../../services/responseService';\nimport { validateQuestionnaire } from '../../../../../services/validationService';\nimport type { QuestionnaireResult } from '../../../../../types/questionnaire';\n\nfunction output(result: {\n content: Array<{ type: 'text'; text: string }>;\n details: QuestionnaireResult;\n}): DoomHeadlessToolResult {\n return { content: result.content, details: result.details };\n}\n\nexport function createAskUserHeadlessTool(\n coordinator?: QuestionnaireCoordinator,\n): DoomHeadlessTool<typeof QuestionParamsSchema> {\n const tool: DoomHeadlessTool<typeof QuestionParamsSchema> = {\n name: ASK_USER_QUESTION_TOOL_NAME,\n label: 'Ask User Question',\n description: 'Ask the user one or more structured questions during execution.',\n parameters: QuestionParamsSchema,\n promptSnippet: 'Ask the user structured questions when requirements are ambiguous',\n executionMode: 'serial',\n async execute(_toolCallId, parameters, signal, _onUpdate, executionContext) {\n const params = parameters as QuestionParams;\n const validation = validateQuestionnaire(params);\n if (!validation.ok) {\n return output(buildToolResult(validation.message, { answers: [], cancelled: true, error: validation.error }));\n }\n const activeCoordinator = coordinator ?? new QuestionnaireCoordinator();\n try {\n const result = await activeCoordinator.enqueue(async ({ signal: requestSignal, reportProgress }) => {\n requestSignal.throwIfAborted();\n const interaction: QuestionnaireInteraction = {\n select: async (title, options, interactionSignal) => {\n const response = await executionContext.client.request(\n {\n kind: 'select',\n title,\n options: options.map((label) => ({ label, value: label })),\n },\n interactionSignal,\n );\n return typeof response === 'string' ? response : undefined;\n },\n input: async (title, placeholder, interactionSignal) => {\n const response = await executionContext.client.request(\n { kind: 'input', title, message: placeholder },\n interactionSignal,\n );\n return typeof response === 'string' ? response : undefined;\n },\n };\n const questionnaire = await runQuestionnaire(interaction, params, requestSignal, reportProgress);\n requestSignal.throwIfAborted();\n return questionnaire;\n }, signal);\n return output(buildQuestionnaireResponse(result, params));\n } finally {\n if (coordinator === undefined) {\n activeCoordinator.shutdown();\n await activeCoordinator.waitForIdle();\n }\n }\n },\n };\n return tool;\n}\n","import { defineServerTool, type WithRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport type { DoomServerPluginContext } from '@agimon-ai/doompi-core/serverFacet';\n\nimport type { UserFeedbackServerScope } from '../_lib/root.server';\nimport { createAskUserHeadlessTool } from '../_tools/askUserHeadless';\n\nexport default defineServerTool((context: WithRoot<DoomServerPluginContext, UserFeedbackServerScope>) =>\n createAskUserHeadlessTool(context.root.coordinator),\n);\n","// Generated by @agimon-ai/doompi-build. Do not edit by hand.\nimport { defineServerPlugin, type DoomServerSessionPlugin } from '@agimon-ai/doompi-core/serverFacet';\nimport { composeRootHooks } from '@agimon-ai/doompi-core/extensionFile';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.server';\nimport toolRestrictionAskUserQuestion from '../src/extensions/workspaces/sessions/(backend)/tool-restriction/askUserQuestion.server';\nimport toolAskUserQuestion from '../src/extensions/workspaces/sessions/(backend)/tool/askUserQuestion.server';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const facet = defineServerPlugin({\n name: '@agimon-ai/doompi-user-feedback',\n session: async (context) => {\n const scopeSession = await rootSession(context);\n const contextSession = { ...context, root: scopeSession.value };\n return {\n ...composeRootHooks(scopeSession),\n get toolRestrictions(): DoomServerSessionPlugin['toolRestrictions'] { return [at(toolRestrictionAskUserQuestion, contextSession)]; },\n get tools(): DoomServerSessionPlugin['tools'] { return [via({ name: 'ask_user_question' }, at(toolAskUserQuestion, contextSession))]; },\n services: [...(scopeSession.services ?? [])],\n get activities(): DoomServerSessionPlugin['activities'] { return [...(scopeSession.activities ?? [])]; },\n };\n },\n});\n\nexport default facet;\n"],"mappings":";;;;;;;;;AAKA,MAAM,QAAA,GAAOA,qCAAAA,WAAAA,EAAY,aAAsC;CAC7D,MAAM,cAAc,IAAIC,0BAAAA,yBAAyB;CACjD,OAAO;EACL,OAAO,EAAE,YAAY;EACrB,iBAAiB,YAAY,SAAS;CACxC;AACF,CAAC;;;ACPD,IAAA,uBAAA,GAAeC,qCAAAA,WAAAA,CAAWC,IAAY;;;ACEtC,IAAA,oCAAA,GAAeC,qCAAAA,sBAAAA,CAAsB;CACnC,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;KAC7B,OAAO;IACT,GAAG,MAAM;IACT,OAAO,OAAOC,0BAAAA,2BAA2B,QAAQ,MAAM,CAAC;GAC1D,UAAU;IACR,IAAI,gBAAgB,KAAA,GAAW;KAC7B,kBAAkB,SAAS;KAC3B,MAAM,kBAAkB,YAAY;IACtC;GACF;EACF;CAEQ;AACZ;;;AClEA,IAAA,kCAAA,GAAeC,qCAAAA,iBAAAA,EAAkB,YAC/B,0BAA0B,QAAQ,KAAK,WAAW,CACpD;;;ACCA,MAAM,MAAY,OAA0B,YAC1C,OAAO,UAAU,aAAc,MAAwB,OAAO,IAAI;AACpE,MAAM,OAAU,UAAmC,UAChD,UAAU,KAAA,IAAY,KAAA,IAAY;CAAE,GAAG;CAAU,GAAI;AAAiB;AAEzE,MAAa,SAAA,GAAQC,mCAAAA,mBAAAA,CAAmB;CACtC,MAAM;CACN,SAAS,OAAO,YAAY;EAC1B,MAAM,eAAe,MAAMC,oBAAY,OAAO;EAC9C,MAAM,iBAAiB;GAAE,GAAG;GAAS,MAAM,aAAa;EAAM;EAC9D,OAAO;GACL,IAAA,GAAGC,qCAAAA,iBAAAA,CAAiB,YAAY;GAChC,IAAI,mBAAgE;IAAE,OAAO,CAAC,GAAGC,kCAAgC,cAAc,CAAC;GAAG;GACnI,IAAI,QAA0C;IAAE,OAAO,CAAC,IAAI,EAAE,MAAM,oBAAoB,GAAG,GAAGC,gCAAqB,cAAc,CAAC,CAAC;GAAG;GACtI,UAAU,CAAC,GAAI,aAAa,YAAY,CAAC,CAAE;GAC3C,IAAI,aAAoD;IAAE,OAAO,CAAC,GAAI,aAAa,cAAc,CAAC,CAAE;GAAG;EACzG;CACF;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.mts","names":[],"sources":["../../generated/server.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"server.d.mts","names":[],"sources":["../../generated/server.ts"],"mappings":";qBAca,oDAAK"}
|
|
@@ -87,10 +87,10 @@ var askUserQuestion_server_default = defineServerTool((context) => createAskUser
|
|
|
87
87
|
//#endregion
|
|
88
88
|
//#region generated/server.ts
|
|
89
89
|
const at = (value, context) => typeof value === "function" ? value(context) : value;
|
|
90
|
-
const via = (identity, value) =>
|
|
90
|
+
const via = (identity, value) => value === void 0 ? void 0 : {
|
|
91
91
|
...identity,
|
|
92
92
|
...value
|
|
93
|
-
}
|
|
93
|
+
};
|
|
94
94
|
const facet = defineServerPlugin({
|
|
95
95
|
name: "@agimon-ai/doompi-user-feedback",
|
|
96
96
|
session: async (context) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.mjs","names":["contribution","rootSession","toolRestrictionAskUserQuestion","toolAskUserQuestion"],"sources":["../../src/extensions/workspaces/sessions/(backend)/_lib/root.server.ts","../../src/extensions/workspaces/sessions/(backend)/root.server.ts","../../src/extensions/workspaces/sessions/(backend)/tool-restriction/askUserQuestion.server.ts","../../src/extensions/workspaces/sessions/(backend)/_tools/askUserHeadless.ts","../../src/extensions/workspaces/sessions/(backend)/tool/askUserQuestion.server.ts","../../generated/server.ts"],"sourcesContent":["import { defineRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport type { DoomServerPluginContext } from '@agimon-ai/doompi-core/serverFacet';\n\nimport { QuestionnaireCoordinator } from '../../../../../services/questionnaireCoordinator';\n\nconst root = defineRoot((_context: DoomServerPluginContext) => {\n const coordinator = new QuestionnaireCoordinator();\n return {\n value: { coordinator },\n onDispose: () => coordinator.shutdown(),\n };\n});\n\nexport type UserFeedbackServerScope = Awaited<ReturnType<typeof root>>['value'];\nexport default root;\n","import { defineRoot } from '@agimon-ai/doompi-core/extensionFile';\n\nimport contribution from './_lib/root.server';\n\nexport default defineRoot(contribution);\n","import { defineToolRestriction } from '@agimon-ai/doompi-core/extensionFile';\nimport type { DoomHeadlessToolRestriction } from '@agimon-ai/doompi-core/headless';\nimport { DOOM_VOICE_AUTO_MODE_ID } from '@agimon-ai/doompi-core/voiceTools';\n\nimport { ASK_USER_QUESTION_TOOL_NAME } from '../../../../../constants/tool';\n\nexport default defineToolRestriction({\n when: { state: { 'minor-mode': DOOM_VOICE_AUTO_MODE_ID } },\n excludedTools: [ASK_USER_QUESTION_TOOL_NAME],\n} satisfies DoomHeadlessToolRestriction);\n","import { type DoomHeadlessTool, type DoomHeadlessToolResult } from '@agimon-ai/doompi-core/headless';\n\nimport { ASK_USER_QUESTION_TOOL_NAME } from '../../../../../constants/tool';\nimport type { QuestionParams } from '../../../../../schemas/questionnaire';\nimport { QuestionParamsSchema } from '../../../../../schemas/questionnaire';\nimport { QuestionnaireCoordinator } from '../../../../../services/questionnaireCoordinator';\nimport { runQuestionnaire, type QuestionnaireInteraction } from '../../../../../services/questionnaireService';\nimport { buildQuestionnaireResponse, buildToolResult } from '../../../../../services/responseService';\nimport { validateQuestionnaire } from '../../../../../services/validationService';\nimport type { QuestionnaireResult } from '../../../../../types/questionnaire';\n\nfunction output(result: {\n content: Array<{ type: 'text'; text: string }>;\n details: QuestionnaireResult;\n}): DoomHeadlessToolResult {\n return { content: result.content, details: result.details };\n}\n\nexport function createAskUserHeadlessTool(\n coordinator?: QuestionnaireCoordinator,\n): DoomHeadlessTool<typeof QuestionParamsSchema> {\n const tool: DoomHeadlessTool<typeof QuestionParamsSchema> = {\n name: ASK_USER_QUESTION_TOOL_NAME,\n label: 'Ask User Question',\n description: 'Ask the user one or more structured questions during execution.',\n parameters: QuestionParamsSchema,\n promptSnippet: 'Ask the user structured questions when requirements are ambiguous',\n executionMode: 'serial',\n async execute(_toolCallId, parameters, signal, _onUpdate, executionContext) {\n const params = parameters as QuestionParams;\n const validation = validateQuestionnaire(params);\n if (!validation.ok) {\n return output(buildToolResult(validation.message, { answers: [], cancelled: true, error: validation.error }));\n }\n const activeCoordinator = coordinator ?? new QuestionnaireCoordinator();\n try {\n const result = await activeCoordinator.enqueue(async ({ signal: requestSignal, reportProgress }) => {\n requestSignal.throwIfAborted();\n const interaction: QuestionnaireInteraction = {\n select: async (title, options, interactionSignal) => {\n const response = await executionContext.client.request(\n {\n kind: 'select',\n title,\n options: options.map((label) => ({ label, value: label })),\n },\n interactionSignal,\n );\n return typeof response === 'string' ? response : undefined;\n },\n input: async (title, placeholder, interactionSignal) => {\n const response = await executionContext.client.request(\n { kind: 'input', title, message: placeholder },\n interactionSignal,\n );\n return typeof response === 'string' ? response : undefined;\n },\n };\n const questionnaire = await runQuestionnaire(interaction, params, requestSignal, reportProgress);\n requestSignal.throwIfAborted();\n return questionnaire;\n }, signal);\n return output(buildQuestionnaireResponse(result, params));\n } finally {\n if (coordinator === undefined) {\n activeCoordinator.shutdown();\n await activeCoordinator.waitForIdle();\n }\n }\n },\n };\n return tool;\n}\n","import { defineServerTool, type WithRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport type { DoomServerPluginContext } from '@agimon-ai/doompi-core/serverFacet';\n\nimport type { UserFeedbackServerScope } from '../_lib/root.server';\nimport { createAskUserHeadlessTool } from '../_tools/askUserHeadless';\n\nexport default defineServerTool((context: WithRoot<DoomServerPluginContext, UserFeedbackServerScope>) =>\n createAskUserHeadlessTool(context.root.coordinator),\n);\n","// Generated by @agimon-ai/doompi-build. Do not edit by hand.\nimport { defineServerPlugin, type DoomServerSessionPlugin } from '@agimon-ai/doompi-core/serverFacet';\nimport { composeRootHooks } from '@agimon-ai/doompi-core/extensionFile';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.server';\nimport toolRestrictionAskUserQuestion from '../src/extensions/workspaces/sessions/(backend)/tool-restriction/askUserQuestion.server';\nimport toolAskUserQuestion from '../src/extensions/workspaces/sessions/(backend)/tool/askUserQuestion.server';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T
|
|
1
|
+
{"version":3,"file":"server.mjs","names":["contribution","rootSession","toolRestrictionAskUserQuestion","toolAskUserQuestion"],"sources":["../../src/extensions/workspaces/sessions/(backend)/_lib/root.server.ts","../../src/extensions/workspaces/sessions/(backend)/root.server.ts","../../src/extensions/workspaces/sessions/(backend)/tool-restriction/askUserQuestion.server.ts","../../src/extensions/workspaces/sessions/(backend)/_tools/askUserHeadless.ts","../../src/extensions/workspaces/sessions/(backend)/tool/askUserQuestion.server.ts","../../generated/server.ts"],"sourcesContent":["import { defineRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport type { DoomServerPluginContext } from '@agimon-ai/doompi-core/serverFacet';\n\nimport { QuestionnaireCoordinator } from '../../../../../services/questionnaireCoordinator';\n\nconst root = defineRoot((_context: DoomServerPluginContext) => {\n const coordinator = new QuestionnaireCoordinator();\n return {\n value: { coordinator },\n onDispose: () => coordinator.shutdown(),\n };\n});\n\nexport type UserFeedbackServerScope = Awaited<ReturnType<typeof root>>['value'];\nexport default root;\n","import { defineRoot } from '@agimon-ai/doompi-core/extensionFile';\n\nimport contribution from './_lib/root.server';\n\nexport default defineRoot(contribution);\n","import { defineToolRestriction } from '@agimon-ai/doompi-core/extensionFile';\nimport type { DoomHeadlessToolRestriction } from '@agimon-ai/doompi-core/headless';\nimport { DOOM_VOICE_AUTO_MODE_ID } from '@agimon-ai/doompi-core/voiceTools';\n\nimport { ASK_USER_QUESTION_TOOL_NAME } from '../../../../../constants/tool';\n\nexport default defineToolRestriction({\n when: { state: { 'minor-mode': DOOM_VOICE_AUTO_MODE_ID } },\n excludedTools: [ASK_USER_QUESTION_TOOL_NAME],\n} satisfies DoomHeadlessToolRestriction);\n","import { type DoomHeadlessTool, type DoomHeadlessToolResult } from '@agimon-ai/doompi-core/headless';\n\nimport { ASK_USER_QUESTION_TOOL_NAME } from '../../../../../constants/tool';\nimport type { QuestionParams } from '../../../../../schemas/questionnaire';\nimport { QuestionParamsSchema } from '../../../../../schemas/questionnaire';\nimport { QuestionnaireCoordinator } from '../../../../../services/questionnaireCoordinator';\nimport { runQuestionnaire, type QuestionnaireInteraction } from '../../../../../services/questionnaireService';\nimport { buildQuestionnaireResponse, buildToolResult } from '../../../../../services/responseService';\nimport { validateQuestionnaire } from '../../../../../services/validationService';\nimport type { QuestionnaireResult } from '../../../../../types/questionnaire';\n\nfunction output(result: {\n content: Array<{ type: 'text'; text: string }>;\n details: QuestionnaireResult;\n}): DoomHeadlessToolResult {\n return { content: result.content, details: result.details };\n}\n\nexport function createAskUserHeadlessTool(\n coordinator?: QuestionnaireCoordinator,\n): DoomHeadlessTool<typeof QuestionParamsSchema> {\n const tool: DoomHeadlessTool<typeof QuestionParamsSchema> = {\n name: ASK_USER_QUESTION_TOOL_NAME,\n label: 'Ask User Question',\n description: 'Ask the user one or more structured questions during execution.',\n parameters: QuestionParamsSchema,\n promptSnippet: 'Ask the user structured questions when requirements are ambiguous',\n executionMode: 'serial',\n async execute(_toolCallId, parameters, signal, _onUpdate, executionContext) {\n const params = parameters as QuestionParams;\n const validation = validateQuestionnaire(params);\n if (!validation.ok) {\n return output(buildToolResult(validation.message, { answers: [], cancelled: true, error: validation.error }));\n }\n const activeCoordinator = coordinator ?? new QuestionnaireCoordinator();\n try {\n const result = await activeCoordinator.enqueue(async ({ signal: requestSignal, reportProgress }) => {\n requestSignal.throwIfAborted();\n const interaction: QuestionnaireInteraction = {\n select: async (title, options, interactionSignal) => {\n const response = await executionContext.client.request(\n {\n kind: 'select',\n title,\n options: options.map((label) => ({ label, value: label })),\n },\n interactionSignal,\n );\n return typeof response === 'string' ? response : undefined;\n },\n input: async (title, placeholder, interactionSignal) => {\n const response = await executionContext.client.request(\n { kind: 'input', title, message: placeholder },\n interactionSignal,\n );\n return typeof response === 'string' ? response : undefined;\n },\n };\n const questionnaire = await runQuestionnaire(interaction, params, requestSignal, reportProgress);\n requestSignal.throwIfAborted();\n return questionnaire;\n }, signal);\n return output(buildQuestionnaireResponse(result, params));\n } finally {\n if (coordinator === undefined) {\n activeCoordinator.shutdown();\n await activeCoordinator.waitForIdle();\n }\n }\n },\n };\n return tool;\n}\n","import { defineServerTool, type WithRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport type { DoomServerPluginContext } from '@agimon-ai/doompi-core/serverFacet';\n\nimport type { UserFeedbackServerScope } from '../_lib/root.server';\nimport { createAskUserHeadlessTool } from '../_tools/askUserHeadless';\n\nexport default defineServerTool((context: WithRoot<DoomServerPluginContext, UserFeedbackServerScope>) =>\n createAskUserHeadlessTool(context.root.coordinator),\n);\n","// Generated by @agimon-ai/doompi-build. Do not edit by hand.\nimport { defineServerPlugin, type DoomServerSessionPlugin } from '@agimon-ai/doompi-core/serverFacet';\nimport { composeRootHooks } from '@agimon-ai/doompi-core/extensionFile';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.server';\nimport toolRestrictionAskUserQuestion from '../src/extensions/workspaces/sessions/(backend)/tool-restriction/askUserQuestion.server';\nimport toolAskUserQuestion from '../src/extensions/workspaces/sessions/(backend)/tool/askUserQuestion.server';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const facet = defineServerPlugin({\n name: '@agimon-ai/doompi-user-feedback',\n session: async (context) => {\n const scopeSession = await rootSession(context);\n const contextSession = { ...context, root: scopeSession.value };\n return {\n ...composeRootHooks(scopeSession),\n get toolRestrictions(): DoomServerSessionPlugin['toolRestrictions'] { return [at(toolRestrictionAskUserQuestion, contextSession)]; },\n get tools(): DoomServerSessionPlugin['tools'] { return [via({ name: 'ask_user_question' }, at(toolAskUserQuestion, contextSession))]; },\n services: [...(scopeSession.services ?? [])],\n get activities(): DoomServerSessionPlugin['activities'] { return [...(scopeSession.activities ?? [])]; },\n };\n },\n});\n\nexport default facet;\n"],"mappings":";;;;;AAKA,MAAM,OAAO,YAAY,aAAsC;CAC7D,MAAM,cAAc,IAAI,yBAAyB;CACjD,OA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AW,KAAA;MACnD;KAEqD,GAAG,QAAQ,eAAe,cAAc;KAC/F,cAAc,eAAe;KAC7B,OAAO;IACT,GAAG,MAAM;IACT,OAAO,OAAO,2BAA2B,QAAQ,MAAM,CAAC;GAC1D,UAAU;IACR,IAAI,gBAAgB,KAAA,GAAW;KAC7B,kBAAkB,SAAS;KAC3B,MAAM,kBAAkB,YAAY;IACtC;GACF;EACF;CAEQ;AACZ;;;AClEA,IAAA,iCAAe,kBAAkB,YAC/B,0BAA0B,QAAQ,KAAK,WAAW,CACpD;;;ACCA,MAAM,MAAY,OAA0B,YAC1C,OAAO,UAAU,aAAc,MAAwB,OAAO,IAAI;AACpE,MAAM,OAAU,UAAmC,UAChD,UAAU,KAAA,IAAY,KAAA,IAAY;CAAE,GAAG;CAAU,GAAI;AAAiB;AAEzE,MAAa,QAAQ,mBAAmB;CACtC,MAAM;CACN,SAAS,OAAO,YAAY;EAC1B,MAAM,eAAe,MAAMC,oBAAY,OAAO;EAC9C,MAAM,iBAAiB;GAAE,GAAG;GAAS,MAAM,aAAa;EAAM;EAC9D,OAAO;GACL,GAAG,iBAAiB,YAAY;GAChC,IAAI,mBAAgE;IAAE,OAAO,CAAC,GAAGC,kCAAgC,cAAc,CAAC;GAAG;GACnI,IAAI,QAA0C;IAAE,OAAO,CAAC,IAAI,EAAE,MAAM,oBAAoB,GAAG,GAAGC,gCAAqB,cAAc,CAAC,CAAC;GAAG;GACtI,UAAU,CAAC,GAAI,aAAa,YAAY,CAAC,CAAE;GAC3C,IAAI,aAAoD;IAAE,OAAO,CAAC,GAAI,aAAa,cAAc,CAAC,CAAE;GAAG;EACzG;CACF;AACF,CAAC"}
|
package/dist/extensions/web.mjs
CHANGED
|
@@ -605,10 +605,10 @@ var askUserQuestion_web_default = defineToolRenderer({
|
|
|
605
605
|
});
|
|
606
606
|
//#endregion
|
|
607
607
|
//#region generated/web.ts
|
|
608
|
-
const via = (identity, value) =>
|
|
608
|
+
const via = (identity, value) => value === void 0 ? void 0 : {
|
|
609
609
|
...identity,
|
|
610
610
|
...value
|
|
611
|
-
}
|
|
611
|
+
};
|
|
612
612
|
const webPlugin = defineWebPlugin({
|
|
613
613
|
id: "ask-user",
|
|
614
614
|
session: { get toolRenderers() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.mjs","names":["isRecord","asString","toolAskUserQuestion"],"sources":["../../src/extensions/workspaces/sessions/(frontend)/tool/_lib/askUserText.ts","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/AskUserQuestionToolMessage.tsx","../../src/types/askUserWire.ts","../../src/extensions/workspaces/sessions/(frontend)/tool/_lib/questionnaireDraft.ts","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/QuestionnairePrompt.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/askUserQuestion.web.tsx","../../generated/web.ts"],"sourcesContent":["/**\n * Pure text shaping for the ask_user_question card, apart from React so the\n * unit suite covers it without a DOM. Args and details are wire JSON; the\n * shapes narrowed here mirror src/types/questionnaire.ts, which this browser\n * module may not import at runtime.\n */\n\ntype Args = Readonly<Record<string, unknown>>;\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction asString(value: unknown): string {\n return typeof value === 'string' ? value : '';\n}\n\nexport interface AskCallSummary {\n /** \"N question(s)\", the TUI heading's purpose. */\n count: string;\n /** The question headers, comma separated; empty when none carry one. */\n headers: string;\n}\n\n/** The call header: how many questions, and their headers in parentheses. */\nexport function askCallSummary(args: Args): AskCallSummary {\n const questions = Array.isArray(args.questions) ? args.questions.filter(isRecord) : [];\n const headers = questions.map((question) => asString(question.header)).filter(Boolean);\n return {\n count: `${questions.length} question${questions.length === 1 ? '' : 's'}`,\n headers: headers.join(', '),\n };\n}\n\nexport interface AnsweredQuestion {\n question: string;\n answer: string;\n}\n\nexport type AskResultView =\n | { kind: 'cancelled' }\n | { kind: 'voice'; prompt: string }\n | { kind: 'answers'; answers: AnsweredQuestion[] }\n | { kind: 'text'; text: string };\n\n/**\n * The result body the TUI's renderResult chooses: a cancelled glyph, the\n * voice prompt when the questionnaire was handed to voice, the answered\n * list, or the raw text when the tool attached no details (an error path).\n */\nexport function askResultView(details: unknown, output: string): AskResultView {\n if (!isRecord(details) || !Array.isArray(details.answers)) return { kind: 'text', text: output };\n if (details.cancelled === true) return { kind: 'cancelled' };\n if (details.delivery === 'voice' && typeof details.voicePrompt === 'string') {\n return { kind: 'voice', prompt: details.voicePrompt };\n }\n const answers = details.answers.filter(isRecord).map((answer) => ({\n question: asString(answer.question),\n answer:\n answer.kind === 'multi'\n ? (Array.isArray(answer.selected) ? answer.selected : []).filter((v) => typeof v === 'string').join(', ')\n : asString(answer.answer),\n }));\n return { kind: 'answers', answers };\n}\n","import type { ToolMessageRenderProps } from '@agimon-ai/doompi-core/web';\nimport {\n MessageItem,\n MessageItemBody,\n MessageItemHeader,\n MessageItemStatus,\n toolTone,\n} from '@agimon-ai/doompi-web-components';\n\nimport { askCallSummary, askResultView } from '../_lib/askUserText';\n\n/** The answered list, or the outcome that stood in for it. */\nfunction AskUserQuestionBody({ result, output, running, isError }: ToolMessageRenderProps) {\n if (running) {\n return (\n <MessageItemBody data-testid=\"tool-result-ask_user_question\">\n {/* The questionnaire is below, where the input usually is; saying only\n \"waiting\" would leave the reader looking for it. */}\n <MessageItemStatus tone=\"running\">answer below to continue</MessageItemStatus>\n </MessageItemBody>\n );\n }\n const view = askResultView(result?.details, output);\n if (view.kind === 'cancelled') {\n return (\n <MessageItemBody data-testid=\"tool-result-ask_user_question\">\n <MessageItemStatus tone=\"running\">cancelled</MessageItemStatus>\n </MessageItemBody>\n );\n }\n if (view.kind === 'voice') {\n return (\n <MessageItemBody data-testid=\"tool-result-ask_user_question\">\n <pre className=\"whitespace-pre-wrap break-words text-doom-dim\">{view.prompt}</pre>\n </MessageItemBody>\n );\n }\n if (view.kind === 'text') {\n return (\n <MessageItemBody data-testid=\"tool-result-ask_user_question\">\n {view.text ? (\n <pre className={`whitespace-pre-wrap break-words ${isError ? 'text-doom-red' : 'text-doom-dim'}`}>\n {view.text}\n </pre>\n ) : (\n <MessageItemStatus tone={isError ? 'error' : 'ok'}>{isError ? 'failed' : 'submitted'}</MessageItemStatus>\n )}\n </MessageItemBody>\n );\n }\n return (\n <MessageItemBody data-testid=\"tool-result-ask_user_question\">\n {view.answers.length === 0 ? (\n <MessageItemStatus tone=\"ok\">submitted</MessageItemStatus>\n ) : (\n <ul className=\"flex flex-col gap-1\">\n {view.answers.map((answer, index) => (\n <li key={`${String(index)}-${answer.question}`} className=\"break-words\">\n <span className=\"text-doom-green\">✓</span> <span className=\"text-doom-cyan\">{answer.question}</span>:{' '}\n <span className=\"text-doom-dim\">{answer.answer}</span>\n </li>\n ))}\n </ul>\n )}\n </MessageItemBody>\n );\n}\n\n/**\n * The ask_user_question tool's timeline item: \"N question(s) (headers)\" in\n * the header, the web half of the TUI renderCall, and the answered list or\n * the outcome that stood in for it in the body. The live questionnaire\n * arrives as an extension-UI dialog; this is the transcript record.\n */\nexport function AskUserQuestionToolMessage(props: ToolMessageRenderProps) {\n const summary = askCallSummary(props.args);\n return (\n <MessageItem tone={toolTone({ running: props.running, isError: props.isError })}>\n <MessageItemHeader title=\"ask_user_question\">\n <span data-testid=\"tool-call-ask_user_question\" className=\"flex min-w-0 flex-1 items-center gap-2\">\n <span className=\"text-doom-hi\">{summary.count}</span>\n {summary.headers ? <span className=\"min-w-0 truncate text-doom-faint\">({summary.headers})</span> : null}\n </span>\n </MessageItemHeader>\n <AskUserQuestionBody {...props} />\n </MessageItem>\n );\n}\n","import type { QuestionAnswer } from './questionnaire';\n\n/**\n * How a rich client answers the whole questionnaire in one reply.\n *\n * Pi's select request carries a title and a list of labels and nothing else,\n * so over RPC the questionnaire degrades into one request per question, asked\n * forwards only. A client that can already see the whole call (the cockpit\n * reads it from the tool's arguments) has no use for that: it renders every\n * question at once, lets the reader move between them, and replies once.\n *\n * The reply rides on the select response, because that is the only channel a\n * blocked extension has. An ordinary label is still an ordinary label, so a\n * client that knows nothing about this keeps the per-question flow exactly as\n * it was; only a response carrying the prefix is read as the whole set.\n *\n * It lives under src/types because that is the one server root a browser\n * bundle may read, so neither half can drift from the other.\n */\nexport const ANSWER_ENVELOPE_PREFIX = 'doom-ask-user/v1:';\n\n/** A response that claims the prefix but cannot be read is refused, never guessed at. */\nexport type AnswerEnvelopeRead =\n | { readonly kind: 'absent' }\n | { readonly kind: 'malformed' }\n | { readonly kind: 'envelope'; readonly payload: unknown };\n\n/** Beyond this a response is not a questionnaire answer, whatever it claims. */\nexport const MAX_ENVELOPE_BYTES = 64 * 1024;\n\nexport function encodeAnswerEnvelope(answers: readonly QuestionAnswer[]): string {\n return `${ANSWER_ENVELOPE_PREFIX}${JSON.stringify({ answers })}`;\n}\n\nexport function decodeAnswerEnvelope(value: string | undefined): AnswerEnvelopeRead {\n if (value === undefined || !value.startsWith(ANSWER_ENVELOPE_PREFIX)) return { kind: 'absent' };\n if (value.length > MAX_ENVELOPE_BYTES) return { kind: 'malformed' };\n try {\n return { kind: 'envelope', payload: JSON.parse(value.slice(ANSWER_ENVELOPE_PREFIX.length)) };\n } catch {\n // Unreadable JSON behind the prefix: the sender meant an envelope and got\n // it wrong, which is a refusal rather than a label the model should see.\n return { kind: 'malformed' };\n }\n}\n","/**\n * The questionnaire the cockpit is filling in, as a value.\n *\n * Apart from React so the unit suite covers it without a DOM, the same way\n * askUserText.ts is. The questions come from the running tool call's\n * arguments, which are wire JSON: the shapes narrowed here mirror\n * src/schemas/questionnaire.ts, which a browser module may not import.\n *\n * Everything is held here until the reader submits, which is the whole point.\n * A step the reader goes back to still has what they chose, and the agent is\n * asked once rather than once per question.\n */\nimport type { QuestionAnswer } from '../../../../../../types/questionnaire';\n\n/** The row every question gets, so a reader always has a way past a bad set of options. */\nexport const CUSTOM_LABEL = 'Type something.';\n\nexport interface PromptOption {\n label: string;\n description: string;\n preview?: string;\n}\n\nexport interface PromptQuestion {\n question: string;\n header: string;\n multiSelect: boolean;\n options: PromptOption[];\n}\n\nexport interface QuestionDraft {\n /** Chosen option labels: at most one unless the question is multiSelect. */\n selected: string[];\n /** Text typed in place of an option; null while the reader has not typed any. */\n custom: string | null;\n notes: string;\n}\n\nexport type QuestionnaireDraft = readonly QuestionDraft[];\n\nconst EMPTY_ENTRY: QuestionDraft = { selected: [], custom: null, notes: '' };\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction asString(value: unknown): string {\n return typeof value === 'string' ? value : '';\n}\n\nfunction readOption(value: unknown): PromptOption | null {\n if (!isRecord(value)) return null;\n const label = asString(value.label);\n if (label === '') return null;\n const preview = asString(value.preview);\n return { label, description: asString(value.description), ...(preview === '' ? {} : { preview }) };\n}\n\n/** The questions as the tool was called with them; an unreadable call yields none. */\nexport function readPromptQuestions(args: Readonly<Record<string, unknown>>): PromptQuestion[] {\n if (!Array.isArray(args.questions)) return [];\n return args.questions.flatMap((entry) => {\n if (!isRecord(entry)) return [];\n const question = asString(entry.question);\n if (question === '') return [];\n const options = (Array.isArray(entry.options) ? entry.options : []).flatMap((option) => {\n const read = readOption(option);\n return read === null ? [] : [read];\n });\n return [{ question, header: asString(entry.header), multiSelect: entry.multiSelect === true, options }];\n });\n}\n\nexport function emptyDraft(count: number): QuestionnaireDraft {\n return Array.from({ length: count }, () => EMPTY_ENTRY);\n}\n\nexport function draftEntry(draft: QuestionnaireDraft, index: number): QuestionDraft {\n return draft[index] ?? EMPTY_ENTRY;\n}\n\nfunction withEntry(draft: QuestionnaireDraft, index: number, patch: Partial<QuestionDraft>): QuestionnaireDraft {\n if (index < 0 || index >= draft.length) return draft;\n return draft.map((entry, position) => (position === index ? { ...entry, ...patch } : entry));\n}\n\n/**\n * Picks an option. A single-select question replaces its choice; a multiSelect\n * one toggles. Either way the typed answer is dropped, because an option and\n * free text are two answers to the same question and only one can be sent.\n */\nexport function chooseOption(\n draft: QuestionnaireDraft,\n index: number,\n label: string,\n multiSelect: boolean,\n): QuestionnaireDraft {\n const current = draftEntry(draft, index).selected;\n const selected = multiSelect\n ? current.includes(label)\n ? current.filter((entry) => entry !== label)\n : [...current, label]\n : [label];\n return withEntry(draft, index, { selected, custom: null });\n}\n\n/** Types an answer instead of choosing one; null returns to the options. */\nexport function setCustom(draft: QuestionnaireDraft, index: number, custom: string | null): QuestionnaireDraft {\n return withEntry(draft, index, { custom, selected: [] });\n}\n\nexport function setNotes(draft: QuestionnaireDraft, index: number, notes: string): QuestionnaireDraft {\n return withEntry(draft, index, { notes });\n}\n\nexport function isAnswered(entry: QuestionDraft): boolean {\n return entry.selected.length > 0 || (entry.custom !== null && entry.custom.trim() !== '');\n}\n\n/** The next question still needing an answer, searching after `from` first; -1 when none is left. */\nexport function nextUnanswered(draft: QuestionnaireDraft, from: number): number {\n const after = draft.findIndex((entry, index) => index > from && !isAnswered(entry));\n return after >= 0 ? after : draft.findIndex((entry) => !isAnswered(entry));\n}\n\nexport function isComplete(draft: QuestionnaireDraft): boolean {\n return draft.length > 0 && draft.every(isAnswered);\n}\n\n/**\n * The answers as the tool reads them back. `preview` is left off: the session\n * half looks it up from the option it declared, so sending one here would only\n * be a claim it has to ignore.\n */\nexport function draftAnswers(questions: readonly PromptQuestion[], draft: QuestionnaireDraft): QuestionAnswer[] {\n return questions.flatMap((question, index): QuestionAnswer[] => {\n const entry = draftEntry(draft, index);\n if (!isAnswered(entry)) return [];\n const notes = entry.notes.trim();\n const base = { questionIndex: index, question: question.question, ...(notes === '' ? {} : { notes }) };\n if (entry.custom !== null && entry.custom.trim() !== '') {\n return [{ ...base, kind: 'custom' as const, answer: entry.custom }];\n }\n if (question.multiSelect) {\n return [{ ...base, kind: 'multi' as const, answer: null, selected: [...entry.selected] }];\n }\n return [{ ...base, kind: 'option' as const, answer: entry.selected[0] ?? null }];\n });\n}\n","import type { ToolPromptRenderProps } from '@agimon-ai/doompi-core/web';\nimport {\n Badge,\n Button,\n Kbd,\n Markdown,\n OptionLabel,\n OptionRow,\n SectionLabel,\n Separator,\n Textarea,\n} from '@agimon-ai/doompi-web-components';\nimport { type KeyboardEvent, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { encodeAnswerEnvelope } from '../../../../../../types/askUserWire';\nimport {\n chooseOption,\n CUSTOM_LABEL,\n draftAnswers,\n draftEntry,\n emptyDraft,\n isAnswered,\n isComplete,\n nextUnanswered,\n type PromptQuestion,\n type QuestionnaireDraft,\n readPromptQuestions,\n setCustom,\n setNotes,\n} from '../_lib/questionnaireDraft';\n\n/** The step bar: which questions are answered, which one is open, and a click back to any of them. */\nfunction StepBar({\n questions,\n draft,\n current,\n onPick,\n}: {\n questions: readonly PromptQuestion[];\n draft: QuestionnaireDraft;\n current: number;\n onPick: (index: number) => void;\n}) {\n return (\n <div data-testid=\"questionnaire-steps\" className=\"flex min-w-0 flex-wrap items-center gap-1.5\">\n {questions.map((question, index) => {\n const answered = isAnswered(draftEntry(draft, index));\n const active = index === current;\n return (\n <Button\n key={question.question}\n variant=\"ghost\"\n size=\"xs\"\n data-testid={`questionnaire-step-${String(index)}`}\n data-step-state={active ? 'current' : answered ? 'answered' : 'pending'}\n onClick={() => onPick(index)}\n className={`gap-1.5 rounded-full px-2.5 py-0.5 text-xs ${\n active\n ? 'bg-doom-selected text-doom-on-selected'\n : answered\n ? 'text-doom-green hover:bg-doom-panel'\n : 'text-doom-faint hover:bg-doom-panel'\n }`}\n >\n <span aria-hidden>{answered ? '✓' : '○'}</span>\n {question.header || `question ${String(index + 1)}`}\n </Button>\n );\n })}\n </div>\n );\n}\n\n/**\n * The frame's shortcuts stop at a text field: while the caret is in one the\n * arrows and Enter belong to the field, so they are kept from bubbling. Enter\n * commits the field the way the terminal editor does, Shift+Enter writes a\n * newline, and Escape and Cmd/Ctrl+Enter still reach the frame.\n */\nfunction fieldKeys(commit: () => void) {\n return (event: KeyboardEvent<HTMLTextAreaElement>): void => {\n if (event.key === 'Escape') return;\n if (event.key === 'Enter' && (event.metaKey || event.ctrlKey)) return;\n event.stopPropagation();\n if (event.key !== 'Enter' || event.shiftKey) return;\n event.preventDefault();\n commit();\n };\n}\n\n/** One question's options, its typed-answer row, and the preview of whatever is focused. */\nfunction QuestionBody({\n question,\n index,\n draft,\n cursor,\n onCursor,\n onDraft,\n onCommit,\n}: {\n question: PromptQuestion;\n index: number;\n draft: QuestionnaireDraft;\n cursor: number;\n onCursor: (cursor: number) => void;\n /** `settles` is true only for an edit that finishes the question, which is what may move on. */\n onDraft: (draft: QuestionnaireDraft, settles: boolean) => void;\n /** Enter in a text field: hands the keyboard back to the frame, settling the question or not. */\n onCommit: (settles: boolean) => void;\n}) {\n const entry = draftEntry(draft, index);\n const typing = entry.custom !== null;\n const preview = question.options[cursor]?.preview;\n return (\n <div className=\"flex min-w-0 flex-col gap-2\">\n <p data-testid=\"questionnaire-question\" className=\"break-words text-base leading-relaxed text-doom-hi\">\n {question.question}\n </p>\n\n <div role=\"listbox\" aria-label=\"options\" className=\"flex min-w-0 flex-col\">\n {question.options.map((option, optionIndex) => {\n const chosen = entry.selected.includes(option.label);\n return (\n <OptionRow\n key={option.label}\n active={optionIndex === cursor && !typing}\n data-testid={`questionnaire-option-${String(optionIndex)}`}\n data-chosen={chosen}\n onMouseEnter={() => onCursor(optionIndex)}\n // A multiSelect question is not finished by one click: moving on\n // there would take the list away before a second option could be\n // picked, which is the whole point of the question.\n onClick={() =>\n onDraft(chooseOption(draft, index, option.label, question.multiSelect), !question.multiSelect)\n }\n className=\"min-w-0 items-start gap-2.5 rounded-md px-2.5 py-1.5 whitespace-normal\"\n >\n <span className={`mt-[2px] shrink-0 text-sm ${chosen ? 'text-doom-green' : 'text-doom-faint'}`}>\n {question.multiSelect ? (chosen ? '[x]' : '[ ]') : chosen ? '●' : '○'}\n </span>\n <OptionLabel className=\"min-w-0 flex flex-col gap-0.5 text-left\">\n <span className={`break-words text-sm ${chosen ? 'text-doom-hi' : 'text-doom-text'}`}>\n {option.label}\n </span>\n {option.description ? (\n <span className=\"break-words text-sm leading-relaxed whitespace-normal text-doom-dim\">\n {option.description}\n </span>\n ) : null}\n </OptionLabel>\n </OptionRow>\n );\n })}\n\n <OptionRow\n active={typing}\n data-testid=\"questionnaire-option-custom\"\n onClick={() => onDraft(setCustom(draft, index, entry.custom ?? ''), false)}\n className=\"min-w-0 items-center gap-2.5 rounded-md px-2.5 py-1.5 whitespace-normal\"\n >\n <span className=\"shrink-0 text-sm text-doom-faint\">✎</span>\n <OptionLabel className=\"min-w-0 text-sm whitespace-normal text-doom-text\">{CUSTOM_LABEL}</OptionLabel>\n </OptionRow>\n </div>\n\n {typing ? (\n <div className=\"flex flex-col gap-1\">\n <SectionLabel>your answer</SectionLabel>\n <Textarea\n data-testid=\"questionnaire-custom\"\n autoFocus\n rows={2}\n value={entry.custom ?? ''}\n placeholder=\"type your answer…\"\n onChange={(event) => onDraft(setCustom(draft, index, event.target.value), false)}\n onKeyDown={fieldKeys(() => onCommit(true))}\n className=\"text-sm\"\n />\n </div>\n ) : null}\n\n {preview ? (\n <div data-testid=\"questionnaire-preview\" className=\"flex flex-col gap-1\">\n <SectionLabel>preview</SectionLabel>\n <div className=\"max-h-40 overflow-y-auto border-l-2 border-doom-edge-magenta pl-3 text-sm text-doom-dim\">\n <Markdown text={preview} />\n </div>\n </div>\n ) : null}\n\n <div className=\"flex flex-col gap-1\">\n <SectionLabel>note (optional)</SectionLabel>\n <Textarea\n data-testid=\"questionnaire-notes\"\n rows={1}\n value={entry.notes}\n placeholder=\"anything the options do not cover\"\n onChange={(event) => onDraft(setNotes(draft, index, event.target.value), false)}\n onKeyDown={fieldKeys(() => onCommit(false))}\n className=\"text-sm\"\n />\n </div>\n </div>\n );\n}\n\n/**\n * The questionnaire, standing in for the composer input while the agent waits.\n *\n * Every question is here at once, because the cockpit can see the whole call\n * even though the request it answers can only carry one question's labels.\n * That is what makes the step bar honest: nothing is sent until the reader\n * submits, so going back to a step is just moving a cursor, and the agent is\n * asked exactly once.\n */\nexport function QuestionnairePrompt({ args, dialog, answer, cancel }: ToolPromptRenderProps) {\n const questions = useMemo(() => readPromptQuestions(args), [args]);\n const [draft, setDraft] = useState<QuestionnaireDraft>(() => emptyDraft(questions.length));\n const [current, setCurrent] = useState(0);\n const [cursor, setCursor] = useState(0);\n const frame = useRef<HTMLDivElement>(null);\n\n // A new request is a new questionnaire; nothing from the last one carries over.\n useEffect(() => {\n // Remounting on dialog.id would be the alternative, but the prompt host owns the\n // element, so the reset lives here.\n // oxlint-disable-next-line react/set-state-in-effect\n setDraft(emptyDraft(questions.length));\n setCurrent(0);\n setCursor(0);\n }, [dialog.id, questions.length]);\n\n // The agent is blocked on this, so it takes the keyboard the input had.\n useEffect(() => frame.current?.focus(), [dialog.id]);\n\n const question = questions[current];\n const complete = isComplete(draft);\n\n const move = (next: QuestionnaireDraft, answeredIndex: number, settles: boolean): void => {\n setDraft(next);\n // Follow the reader forwards the way the terminal does, but only on an\n // edit that finished the question, and only while something is still\n // unanswered: jumping after the last answer would take the step they just\n // finished off the screen before they could look at it.\n if (!settles) return;\n const pending = nextUnanswered(next, answeredIndex);\n if (pending >= 0 && pending !== answeredIndex) {\n setCurrent(pending);\n setCursor(0);\n }\n };\n\n const show = (index: number): void => {\n setCurrent(index);\n setCursor(0);\n };\n\n const submit = (): void => {\n if (!complete) return;\n answer(encodeAnswerEnvelope(draftAnswers(questions, draft)));\n };\n\n if (question === undefined) {\n return (\n <div className=\"flex items-center justify-between gap-3 px-3.5 py-3\">\n <span data-testid=\"questionnaire-empty\" className=\"text-sm text-doom-dim\">\n the agent asked something this cockpit could not read\n </span>\n <Button variant=\"outline\" size=\"sm\" data-testid=\"questionnaire-cancel\" onClick={cancel}>\n cancel\n </Button>\n </div>\n );\n }\n\n const typing = draftEntry(draft, current).custom !== null;\n return (\n // The keys belong to the frame rather than to any row, so the reader can\n // move between questions and options without tabbing through both.\n <div\n ref={frame}\n tabIndex={-1}\n data-testid=\"questionnaire\"\n className=\"flex min-w-0 flex-col overflow-hidden outline-none\"\n onKeyDown={(event) => {\n if (event.key === 'Escape') {\n event.preventDefault();\n cancel();\n return;\n }\n if (event.key === 'Enter' && (event.metaKey || event.ctrlKey)) {\n event.preventDefault();\n submit();\n return;\n }\n // While typing an answer the arrows belong to the textarea.\n if (typing) return;\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault();\n const count = question.options.length;\n setCursor((event.key === 'ArrowDown' ? cursor + 1 : cursor - 1 + count) % count);\n return;\n }\n if (event.key === 'ArrowRight' || event.key === 'ArrowLeft') {\n event.preventDefault();\n const count = questions.length;\n show((event.key === 'ArrowRight' ? current + 1 : current - 1 + count) % count);\n return;\n }\n if (event.key === 'Enter') {\n event.preventDefault();\n const option = question.options[cursor];\n if (option === undefined) {\n submit();\n return;\n }\n move(chooseOption(draft, current, option.label, question.multiSelect), current, !question.multiSelect);\n }\n }}\n >\n <div className=\"flex min-w-0 flex-wrap items-center gap-2 px-3 pt-2.5 pb-2 sm:gap-3 sm:px-3.5\">\n <StepBar questions={questions} draft={draft} current={current} onPick={show} />\n <span className=\"min-w-0 flex-1\" />\n <Badge size=\"xs\" className=\"shrink-0 border-transparent bg-doom-panel py-0.5 text-2xs text-doom-dim\">\n question {current + 1} / {questions.length}\n </Badge>\n </div>\n\n <Separator />\n\n <div className=\"max-h-[46vh] min-w-0 overflow-x-hidden overflow-y-auto px-3 py-3 sm:px-3.5\">\n <QuestionBody\n question={question}\n index={current}\n draft={draft}\n cursor={cursor}\n onCursor={setCursor}\n onDraft={(next, settles) => move(next, current, settles)}\n onCommit={(settles) => {\n frame.current?.focus();\n move(draft, current, settles);\n }}\n />\n </div>\n\n <Separator />\n\n <div className=\"flex min-w-0 items-center gap-2 px-3 py-2 sm:px-3.5\">\n <span data-testid=\"questionnaire-hint\" className=\"min-w-0 truncate text-xs text-doom-faint max-sm:hidden\">\n <Kbd>←→</Kbd> questions · <Kbd>↑↓</Kbd> options · <Kbd>enter</Kbd>{' '}\n {question.multiSelect ? 'toggles' : 'selects'} · <Kbd>esc</Kbd> cancels\n </span>\n <span className=\"flex-1\" />\n <Button variant=\"outline\" size=\"md\" data-testid=\"questionnaire-cancel\" onClick={cancel}>\n cancel\n </Button>\n <Button\n variant=\"primary\"\n size=\"md\"\n data-testid=\"questionnaire-submit\"\n onClick={submit}\n disabled={!complete}\n title={complete ? 'send every answer to the agent' : 'answer every question first'}\n className=\"shrink-0 px-3 max-sm:max-w-32 max-sm:truncate sm:px-3.5\"\n >\n submit answers\n </Button>\n </div>\n </div>\n );\n}\n","import { defineToolRenderer } from '@agimon-ai/doompi-core/web';\n\nimport { AskUserQuestionToolMessage } from './_components/AskUserQuestionToolMessage';\nimport { QuestionnairePrompt } from './_components/QuestionnairePrompt';\nimport { readPromptQuestions } from './_lib/questionnaireDraft';\n\nexport default defineToolRenderer({\n message: AskUserQuestionToolMessage,\n prompt: {\n claims: (dialog, args) =>\n dialog.method === 'select' &&\n readPromptQuestions(args).some((question) => dialog.title.startsWith(question.question)),\n component: QuestionnairePrompt,\n },\n});\n","// Generated by @agimon-ai/doompi-build. Do not edit by hand.\nimport { defineWebPlugin, type WebPluginContributions } from '@agimon-ai/doompi-core/web';\n\nimport toolAskUserQuestion from '../src/extensions/workspaces/sessions/(frontend)/tool/askUserQuestion.web';\n\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T => ({ ...identity, ...(value as object) }) as T;\n\nexport const webPlugin = defineWebPlugin({\n id: 'ask-user',\n session: {\n get toolRenderers(): WebPluginContributions['toolRenderers'] { return [via({ tools: ['ask_user_question'] }, toolAskUserQuestion)]; },\n },\n});\n"],"mappings":";;;;;AASA,SAASA,WAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAASC,WAAS,OAAwB;CACxC,OAAO,OAAO,UAAU,WAAW,QAAQ;AAC7C;;AAUA,SAAgB,eAAe,MAA4B;CACzD,MAAM,YAAY,MAAM,QAAQ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AAoB,IAAI,CAAC,CAAC,MAAM,aAAa,OAAO,MAAM,WAAW,SAAS,QAAQ,CAAC;EACzF,WAAW;CACb;AACF,CAAC;;;ACTD,MAAM,OAAU,UAAmC,WAAuB;CAAE,GAAG;CAAU,GAAI;AAAiB;AAE9G,MAAa,YAAY,gBAAgB;CACvC,IAAI;CACJ,SAAS,EACP,IAAI,gBAAyD;EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,mBAAmB,EAAE,GAAGC,2BAAmB,CAAC;CAAG,EACtI;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"web.mjs","names":["isRecord","asString","toolAskUserQuestion"],"sources":["../../src/extensions/workspaces/sessions/(frontend)/tool/_lib/askUserText.ts","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/AskUserQuestionToolMessage.tsx","../../src/types/askUserWire.ts","../../src/extensions/workspaces/sessions/(frontend)/tool/_lib/questionnaireDraft.ts","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/QuestionnairePrompt.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/askUserQuestion.web.tsx","../../generated/web.ts"],"sourcesContent":["/**\n * Pure text shaping for the ask_user_question card, apart from React so the\n * unit suite covers it without a DOM. Args and details are wire JSON; the\n * shapes narrowed here mirror src/types/questionnaire.ts, which this browser\n * module may not import at runtime.\n */\n\ntype Args = Readonly<Record<string, unknown>>;\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction asString(value: unknown): string {\n return typeof value === 'string' ? value : '';\n}\n\nexport interface AskCallSummary {\n /** \"N question(s)\", the TUI heading's purpose. */\n count: string;\n /** The question headers, comma separated; empty when none carry one. */\n headers: string;\n}\n\n/** The call header: how many questions, and their headers in parentheses. */\nexport function askCallSummary(args: Args): AskCallSummary {\n const questions = Array.isArray(args.questions) ? args.questions.filter(isRecord) : [];\n const headers = questions.map((question) => asString(question.header)).filter(Boolean);\n return {\n count: `${questions.length} question${questions.length === 1 ? '' : 's'}`,\n headers: headers.join(', '),\n };\n}\n\nexport interface AnsweredQuestion {\n question: string;\n answer: string;\n}\n\nexport type AskResultView =\n | { kind: 'cancelled' }\n | { kind: 'voice'; prompt: string }\n | { kind: 'answers'; answers: AnsweredQuestion[] }\n | { kind: 'text'; text: string };\n\n/**\n * The result body the TUI's renderResult chooses: a cancelled glyph, the\n * voice prompt when the questionnaire was handed to voice, the answered\n * list, or the raw text when the tool attached no details (an error path).\n */\nexport function askResultView(details: unknown, output: string): AskResultView {\n if (!isRecord(details) || !Array.isArray(details.answers)) return { kind: 'text', text: output };\n if (details.cancelled === true) return { kind: 'cancelled' };\n if (details.delivery === 'voice' && typeof details.voicePrompt === 'string') {\n return { kind: 'voice', prompt: details.voicePrompt };\n }\n const answers = details.answers.filter(isRecord).map((answer) => ({\n question: asString(answer.question),\n answer:\n answer.kind === 'multi'\n ? (Array.isArray(answer.selected) ? answer.selected : []).filter((v) => typeof v === 'string').join(', ')\n : asString(answer.answer),\n }));\n return { kind: 'answers', answers };\n}\n","import type { ToolMessageRenderProps } from '@agimon-ai/doompi-core/web';\nimport {\n MessageItem,\n MessageItemBody,\n MessageItemHeader,\n MessageItemStatus,\n toolTone,\n} from '@agimon-ai/doompi-web-components';\n\nimport { askCallSummary, askResultView } from '../_lib/askUserText';\n\n/** The answered list, or the outcome that stood in for it. */\nfunction AskUserQuestionBody({ result, output, running, isError }: ToolMessageRenderProps) {\n if (running) {\n return (\n <MessageItemBody data-testid=\"tool-result-ask_user_question\">\n {/* The questionnaire is below, where the input usually is; saying only\n \"waiting\" would leave the reader looking for it. */}\n <MessageItemStatus tone=\"running\">answer below to continue</MessageItemStatus>\n </MessageItemBody>\n );\n }\n const view = askResultView(result?.details, output);\n if (view.kind === 'cancelled') {\n return (\n <MessageItemBody data-testid=\"tool-result-ask_user_question\">\n <MessageItemStatus tone=\"running\">cancelled</MessageItemStatus>\n </MessageItemBody>\n );\n }\n if (view.kind === 'voice') {\n return (\n <MessageItemBody data-testid=\"tool-result-ask_user_question\">\n <pre className=\"whitespace-pre-wrap break-words text-doom-dim\">{view.prompt}</pre>\n </MessageItemBody>\n );\n }\n if (view.kind === 'text') {\n return (\n <MessageItemBody data-testid=\"tool-result-ask_user_question\">\n {view.text ? (\n <pre className={`whitespace-pre-wrap break-words ${isError ? 'text-doom-red' : 'text-doom-dim'}`}>\n {view.text}\n </pre>\n ) : (\n <MessageItemStatus tone={isError ? 'error' : 'ok'}>{isError ? 'failed' : 'submitted'}</MessageItemStatus>\n )}\n </MessageItemBody>\n );\n }\n return (\n <MessageItemBody data-testid=\"tool-result-ask_user_question\">\n {view.answers.length === 0 ? (\n <MessageItemStatus tone=\"ok\">submitted</MessageItemStatus>\n ) : (\n <ul className=\"flex flex-col gap-1\">\n {view.answers.map((answer, index) => (\n <li key={`${String(index)}-${answer.question}`} className=\"break-words\">\n <span className=\"text-doom-green\">✓</span> <span className=\"text-doom-cyan\">{answer.question}</span>:{' '}\n <span className=\"text-doom-dim\">{answer.answer}</span>\n </li>\n ))}\n </ul>\n )}\n </MessageItemBody>\n );\n}\n\n/**\n * The ask_user_question tool's timeline item: \"N question(s) (headers)\" in\n * the header, the web half of the TUI renderCall, and the answered list or\n * the outcome that stood in for it in the body. The live questionnaire\n * arrives as an extension-UI dialog; this is the transcript record.\n */\nexport function AskUserQuestionToolMessage(props: ToolMessageRenderProps) {\n const summary = askCallSummary(props.args);\n return (\n <MessageItem tone={toolTone({ running: props.running, isError: props.isError })}>\n <MessageItemHeader title=\"ask_user_question\">\n <span data-testid=\"tool-call-ask_user_question\" className=\"flex min-w-0 flex-1 items-center gap-2\">\n <span className=\"text-doom-hi\">{summary.count}</span>\n {summary.headers ? <span className=\"min-w-0 truncate text-doom-faint\">({summary.headers})</span> : null}\n </span>\n </MessageItemHeader>\n <AskUserQuestionBody {...props} />\n </MessageItem>\n );\n}\n","import type { QuestionAnswer } from './questionnaire';\n\n/**\n * How a rich client answers the whole questionnaire in one reply.\n *\n * Pi's select request carries a title and a list of labels and nothing else,\n * so over RPC the questionnaire degrades into one request per question, asked\n * forwards only. A client that can already see the whole call (the cockpit\n * reads it from the tool's arguments) has no use for that: it renders every\n * question at once, lets the reader move between them, and replies once.\n *\n * The reply rides on the select response, because that is the only channel a\n * blocked extension has. An ordinary label is still an ordinary label, so a\n * client that knows nothing about this keeps the per-question flow exactly as\n * it was; only a response carrying the prefix is read as the whole set.\n *\n * It lives under src/types because that is the one server root a browser\n * bundle may read, so neither half can drift from the other.\n */\nexport const ANSWER_ENVELOPE_PREFIX = 'doom-ask-user/v1:';\n\n/** A response that claims the prefix but cannot be read is refused, never guessed at. */\nexport type AnswerEnvelopeRead =\n | { readonly kind: 'absent' }\n | { readonly kind: 'malformed' }\n | { readonly kind: 'envelope'; readonly payload: unknown };\n\n/** Beyond this a response is not a questionnaire answer, whatever it claims. */\nexport const MAX_ENVELOPE_BYTES = 64 * 1024;\n\nexport function encodeAnswerEnvelope(answers: readonly QuestionAnswer[]): string {\n return `${ANSWER_ENVELOPE_PREFIX}${JSON.stringify({ answers })}`;\n}\n\nexport function decodeAnswerEnvelope(value: string | undefined): AnswerEnvelopeRead {\n if (value === undefined || !value.startsWith(ANSWER_ENVELOPE_PREFIX)) return { kind: 'absent' };\n if (value.length > MAX_ENVELOPE_BYTES) return { kind: 'malformed' };\n try {\n return { kind: 'envelope', payload: JSON.parse(value.slice(ANSWER_ENVELOPE_PREFIX.length)) };\n } catch {\n // Unreadable JSON behind the prefix: the sender meant an envelope and got\n // it wrong, which is a refusal rather than a label the model should see.\n return { kind: 'malformed' };\n }\n}\n","/**\n * The questionnaire the cockpit is filling in, as a value.\n *\n * Apart from React so the unit suite covers it without a DOM, the same way\n * askUserText.ts is. The questions come from the running tool call's\n * arguments, which are wire JSON: the shapes narrowed here mirror\n * src/schemas/questionnaire.ts, which a browser module may not import.\n *\n * Everything is held here until the reader submits, which is the whole point.\n * A step the reader goes back to still has what they chose, and the agent is\n * asked once rather than once per question.\n */\nimport type { QuestionAnswer } from '../../../../../../types/questionnaire';\n\n/** The row every question gets, so a reader always has a way past a bad set of options. */\nexport const CUSTOM_LABEL = 'Type something.';\n\nexport interface PromptOption {\n label: string;\n description: string;\n preview?: string;\n}\n\nexport interface PromptQuestion {\n question: string;\n header: string;\n multiSelect: boolean;\n options: PromptOption[];\n}\n\nexport interface QuestionDraft {\n /** Chosen option labels: at most one unless the question is multiSelect. */\n selected: string[];\n /** Text typed in place of an option; null while the reader has not typed any. */\n custom: string | null;\n notes: string;\n}\n\nexport type QuestionnaireDraft = readonly QuestionDraft[];\n\nconst EMPTY_ENTRY: QuestionDraft = { selected: [], custom: null, notes: '' };\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction asString(value: unknown): string {\n return typeof value === 'string' ? value : '';\n}\n\nfunction readOption(value: unknown): PromptOption | null {\n if (!isRecord(value)) return null;\n const label = asString(value.label);\n if (label === '') return null;\n const preview = asString(value.preview);\n return { label, description: asString(value.description), ...(preview === '' ? {} : { preview }) };\n}\n\n/** The questions as the tool was called with them; an unreadable call yields none. */\nexport function readPromptQuestions(args: Readonly<Record<string, unknown>>): PromptQuestion[] {\n if (!Array.isArray(args.questions)) return [];\n return args.questions.flatMap((entry) => {\n if (!isRecord(entry)) return [];\n const question = asString(entry.question);\n if (question === '') return [];\n const options = (Array.isArray(entry.options) ? entry.options : []).flatMap((option) => {\n const read = readOption(option);\n return read === null ? [] : [read];\n });\n return [{ question, header: asString(entry.header), multiSelect: entry.multiSelect === true, options }];\n });\n}\n\nexport function emptyDraft(count: number): QuestionnaireDraft {\n return Array.from({ length: count }, () => EMPTY_ENTRY);\n}\n\nexport function draftEntry(draft: QuestionnaireDraft, index: number): QuestionDraft {\n return draft[index] ?? EMPTY_ENTRY;\n}\n\nfunction withEntry(draft: QuestionnaireDraft, index: number, patch: Partial<QuestionDraft>): QuestionnaireDraft {\n if (index < 0 || index >= draft.length) return draft;\n return draft.map((entry, position) => (position === index ? { ...entry, ...patch } : entry));\n}\n\n/**\n * Picks an option. A single-select question replaces its choice; a multiSelect\n * one toggles. Either way the typed answer is dropped, because an option and\n * free text are two answers to the same question and only one can be sent.\n */\nexport function chooseOption(\n draft: QuestionnaireDraft,\n index: number,\n label: string,\n multiSelect: boolean,\n): QuestionnaireDraft {\n const current = draftEntry(draft, index).selected;\n const selected = multiSelect\n ? current.includes(label)\n ? current.filter((entry) => entry !== label)\n : [...current, label]\n : [label];\n return withEntry(draft, index, { selected, custom: null });\n}\n\n/** Types an answer instead of choosing one; null returns to the options. */\nexport function setCustom(draft: QuestionnaireDraft, index: number, custom: string | null): QuestionnaireDraft {\n return withEntry(draft, index, { custom, selected: [] });\n}\n\nexport function setNotes(draft: QuestionnaireDraft, index: number, notes: string): QuestionnaireDraft {\n return withEntry(draft, index, { notes });\n}\n\nexport function isAnswered(entry: QuestionDraft): boolean {\n return entry.selected.length > 0 || (entry.custom !== null && entry.custom.trim() !== '');\n}\n\n/** The next question still needing an answer, searching after `from` first; -1 when none is left. */\nexport function nextUnanswered(draft: QuestionnaireDraft, from: number): number {\n const after = draft.findIndex((entry, index) => index > from && !isAnswered(entry));\n return after >= 0 ? after : draft.findIndex((entry) => !isAnswered(entry));\n}\n\nexport function isComplete(draft: QuestionnaireDraft): boolean {\n return draft.length > 0 && draft.every(isAnswered);\n}\n\n/**\n * The answers as the tool reads them back. `preview` is left off: the session\n * half looks it up from the option it declared, so sending one here would only\n * be a claim it has to ignore.\n */\nexport function draftAnswers(questions: readonly PromptQuestion[], draft: QuestionnaireDraft): QuestionAnswer[] {\n return questions.flatMap((question, index): QuestionAnswer[] => {\n const entry = draftEntry(draft, index);\n if (!isAnswered(entry)) return [];\n const notes = entry.notes.trim();\n const base = { questionIndex: index, question: question.question, ...(notes === '' ? {} : { notes }) };\n if (entry.custom !== null && entry.custom.trim() !== '') {\n return [{ ...base, kind: 'custom' as const, answer: entry.custom }];\n }\n if (question.multiSelect) {\n return [{ ...base, kind: 'multi' as const, answer: null, selected: [...entry.selected] }];\n }\n return [{ ...base, kind: 'option' as const, answer: entry.selected[0] ?? null }];\n });\n}\n","import type { ToolPromptRenderProps } from '@agimon-ai/doompi-core/web';\nimport {\n Badge,\n Button,\n Kbd,\n Markdown,\n OptionLabel,\n OptionRow,\n SectionLabel,\n Separator,\n Textarea,\n} from '@agimon-ai/doompi-web-components';\nimport { type KeyboardEvent, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { encodeAnswerEnvelope } from '../../../../../../types/askUserWire';\nimport {\n chooseOption,\n CUSTOM_LABEL,\n draftAnswers,\n draftEntry,\n emptyDraft,\n isAnswered,\n isComplete,\n nextUnanswered,\n type PromptQuestion,\n type QuestionnaireDraft,\n readPromptQuestions,\n setCustom,\n setNotes,\n} from '../_lib/questionnaireDraft';\n\n/** The step bar: which questions are answered, which one is open, and a click back to any of them. */\nfunction StepBar({\n questions,\n draft,\n current,\n onPick,\n}: {\n questions: readonly PromptQuestion[];\n draft: QuestionnaireDraft;\n current: number;\n onPick: (index: number) => void;\n}) {\n return (\n <div data-testid=\"questionnaire-steps\" className=\"flex min-w-0 flex-wrap items-center gap-1.5\">\n {questions.map((question, index) => {\n const answered = isAnswered(draftEntry(draft, index));\n const active = index === current;\n return (\n <Button\n key={question.question}\n variant=\"ghost\"\n size=\"xs\"\n data-testid={`questionnaire-step-${String(index)}`}\n data-step-state={active ? 'current' : answered ? 'answered' : 'pending'}\n onClick={() => onPick(index)}\n className={`gap-1.5 rounded-full px-2.5 py-0.5 text-xs ${\n active\n ? 'bg-doom-selected text-doom-on-selected'\n : answered\n ? 'text-doom-green hover:bg-doom-panel'\n : 'text-doom-faint hover:bg-doom-panel'\n }`}\n >\n <span aria-hidden>{answered ? '✓' : '○'}</span>\n {question.header || `question ${String(index + 1)}`}\n </Button>\n );\n })}\n </div>\n );\n}\n\n/**\n * The frame's shortcuts stop at a text field: while the caret is in one the\n * arrows and Enter belong to the field, so they are kept from bubbling. Enter\n * commits the field the way the terminal editor does, Shift+Enter writes a\n * newline, and Escape and Cmd/Ctrl+Enter still reach the frame.\n */\nfunction fieldKeys(commit: () => void) {\n return (event: KeyboardEvent<HTMLTextAreaElement>): void => {\n if (event.key === 'Escape') return;\n if (event.key === 'Enter' && (event.metaKey || event.ctrlKey)) return;\n event.stopPropagation();\n if (event.key !== 'Enter' || event.shiftKey) return;\n event.preventDefault();\n commit();\n };\n}\n\n/** One question's options, its typed-answer row, and the preview of whatever is focused. */\nfunction QuestionBody({\n question,\n index,\n draft,\n cursor,\n onCursor,\n onDraft,\n onCommit,\n}: {\n question: PromptQuestion;\n index: number;\n draft: QuestionnaireDraft;\n cursor: number;\n onCursor: (cursor: number) => void;\n /** `settles` is true only for an edit that finishes the question, which is what may move on. */\n onDraft: (draft: QuestionnaireDraft, settles: boolean) => void;\n /** Enter in a text field: hands the keyboard back to the frame, settling the question or not. */\n onCommit: (settles: boolean) => void;\n}) {\n const entry = draftEntry(draft, index);\n const typing = entry.custom !== null;\n const preview = question.options[cursor]?.preview;\n return (\n <div className=\"flex min-w-0 flex-col gap-2\">\n <p data-testid=\"questionnaire-question\" className=\"break-words text-base leading-relaxed text-doom-hi\">\n {question.question}\n </p>\n\n <div role=\"listbox\" aria-label=\"options\" className=\"flex min-w-0 flex-col\">\n {question.options.map((option, optionIndex) => {\n const chosen = entry.selected.includes(option.label);\n return (\n <OptionRow\n key={option.label}\n active={optionIndex === cursor && !typing}\n data-testid={`questionnaire-option-${String(optionIndex)}`}\n data-chosen={chosen}\n onMouseEnter={() => onCursor(optionIndex)}\n // A multiSelect question is not finished by one click: moving on\n // there would take the list away before a second option could be\n // picked, which is the whole point of the question.\n onClick={() =>\n onDraft(chooseOption(draft, index, option.label, question.multiSelect), !question.multiSelect)\n }\n className=\"min-w-0 items-start gap-2.5 rounded-md px-2.5 py-1.5 whitespace-normal\"\n >\n <span className={`mt-[2px] shrink-0 text-sm ${chosen ? 'text-doom-green' : 'text-doom-faint'}`}>\n {question.multiSelect ? (chosen ? '[x]' : '[ ]') : chosen ? '●' : '○'}\n </span>\n <OptionLabel className=\"min-w-0 flex flex-col gap-0.5 text-left\">\n <span className={`break-words text-sm ${chosen ? 'text-doom-hi' : 'text-doom-text'}`}>\n {option.label}\n </span>\n {option.description ? (\n <span className=\"break-words text-sm leading-relaxed whitespace-normal text-doom-dim\">\n {option.description}\n </span>\n ) : null}\n </OptionLabel>\n </OptionRow>\n );\n })}\n\n <OptionRow\n active={typing}\n data-testid=\"questionnaire-option-custom\"\n onClick={() => onDraft(setCustom(draft, index, entry.custom ?? ''), false)}\n className=\"min-w-0 items-center gap-2.5 rounded-md px-2.5 py-1.5 whitespace-normal\"\n >\n <span className=\"shrink-0 text-sm text-doom-faint\">✎</span>\n <OptionLabel className=\"min-w-0 text-sm whitespace-normal text-doom-text\">{CUSTOM_LABEL}</OptionLabel>\n </OptionRow>\n </div>\n\n {typing ? (\n <div className=\"flex flex-col gap-1\">\n <SectionLabel>your answer</SectionLabel>\n <Textarea\n data-testid=\"questionnaire-custom\"\n autoFocus\n rows={2}\n value={entry.custom ?? ''}\n placeholder=\"type your answer…\"\n onChange={(event) => onDraft(setCustom(draft, index, event.target.value), false)}\n onKeyDown={fieldKeys(() => onCommit(true))}\n className=\"text-sm\"\n />\n </div>\n ) : null}\n\n {preview ? (\n <div data-testid=\"questionnaire-preview\" className=\"flex flex-col gap-1\">\n <SectionLabel>preview</SectionLabel>\n <div className=\"max-h-40 overflow-y-auto border-l-2 border-doom-edge-magenta pl-3 text-sm text-doom-dim\">\n <Markdown text={preview} />\n </div>\n </div>\n ) : null}\n\n <div className=\"flex flex-col gap-1\">\n <SectionLabel>note (optional)</SectionLabel>\n <Textarea\n data-testid=\"questionnaire-notes\"\n rows={1}\n value={entry.notes}\n placeholder=\"anything the options do not cover\"\n onChange={(event) => onDraft(setNotes(draft, index, event.target.value), false)}\n onKeyDown={fieldKeys(() => onCommit(false))}\n className=\"text-sm\"\n />\n </div>\n </div>\n );\n}\n\n/**\n * The questionnaire, standing in for the composer input while the agent waits.\n *\n * Every question is here at once, because the cockpit can see the whole call\n * even though the request it answers can only carry one question's labels.\n * That is what makes the step bar honest: nothing is sent until the reader\n * submits, so going back to a step is just moving a cursor, and the agent is\n * asked exactly once.\n */\nexport function QuestionnairePrompt({ args, dialog, answer, cancel }: ToolPromptRenderProps) {\n const questions = useMemo(() => readPromptQuestions(args), [args]);\n const [draft, setDraft] = useState<QuestionnaireDraft>(() => emptyDraft(questions.length));\n const [current, setCurrent] = useState(0);\n const [cursor, setCursor] = useState(0);\n const frame = useRef<HTMLDivElement>(null);\n\n // A new request is a new questionnaire; nothing from the last one carries over.\n useEffect(() => {\n // Remounting on dialog.id would be the alternative, but the prompt host owns the\n // element, so the reset lives here.\n // oxlint-disable-next-line react/set-state-in-effect\n setDraft(emptyDraft(questions.length));\n setCurrent(0);\n setCursor(0);\n }, [dialog.id, questions.length]);\n\n // The agent is blocked on this, so it takes the keyboard the input had.\n useEffect(() => frame.current?.focus(), [dialog.id]);\n\n const question = questions[current];\n const complete = isComplete(draft);\n\n const move = (next: QuestionnaireDraft, answeredIndex: number, settles: boolean): void => {\n setDraft(next);\n // Follow the reader forwards the way the terminal does, but only on an\n // edit that finished the question, and only while something is still\n // unanswered: jumping after the last answer would take the step they just\n // finished off the screen before they could look at it.\n if (!settles) return;\n const pending = nextUnanswered(next, answeredIndex);\n if (pending >= 0 && pending !== answeredIndex) {\n setCurrent(pending);\n setCursor(0);\n }\n };\n\n const show = (index: number): void => {\n setCurrent(index);\n setCursor(0);\n };\n\n const submit = (): void => {\n if (!complete) return;\n answer(encodeAnswerEnvelope(draftAnswers(questions, draft)));\n };\n\n if (question === undefined) {\n return (\n <div className=\"flex items-center justify-between gap-3 px-3.5 py-3\">\n <span data-testid=\"questionnaire-empty\" className=\"text-sm text-doom-dim\">\n the agent asked something this cockpit could not read\n </span>\n <Button variant=\"outline\" size=\"sm\" data-testid=\"questionnaire-cancel\" onClick={cancel}>\n cancel\n </Button>\n </div>\n );\n }\n\n const typing = draftEntry(draft, current).custom !== null;\n return (\n // The keys belong to the frame rather than to any row, so the reader can\n // move between questions and options without tabbing through both.\n <div\n ref={frame}\n tabIndex={-1}\n data-testid=\"questionnaire\"\n className=\"flex min-w-0 flex-col overflow-hidden outline-none\"\n onKeyDown={(event) => {\n if (event.key === 'Escape') {\n event.preventDefault();\n cancel();\n return;\n }\n if (event.key === 'Enter' && (event.metaKey || event.ctrlKey)) {\n event.preventDefault();\n submit();\n return;\n }\n // While typing an answer the arrows belong to the textarea.\n if (typing) return;\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault();\n const count = question.options.length;\n setCursor((event.key === 'ArrowDown' ? cursor + 1 : cursor - 1 + count) % count);\n return;\n }\n if (event.key === 'ArrowRight' || event.key === 'ArrowLeft') {\n event.preventDefault();\n const count = questions.length;\n show((event.key === 'ArrowRight' ? current + 1 : current - 1 + count) % count);\n return;\n }\n if (event.key === 'Enter') {\n event.preventDefault();\n const option = question.options[cursor];\n if (option === undefined) {\n submit();\n return;\n }\n move(chooseOption(draft, current, option.label, question.multiSelect), current, !question.multiSelect);\n }\n }}\n >\n <div className=\"flex min-w-0 flex-wrap items-center gap-2 px-3 pt-2.5 pb-2 sm:gap-3 sm:px-3.5\">\n <StepBar questions={questions} draft={draft} current={current} onPick={show} />\n <span className=\"min-w-0 flex-1\" />\n <Badge size=\"xs\" className=\"shrink-0 border-transparent bg-doom-panel py-0.5 text-2xs text-doom-dim\">\n question {current + 1} / {questions.length}\n </Badge>\n </div>\n\n <Separator />\n\n <div className=\"max-h-[46vh] min-w-0 overflow-x-hidden overflow-y-auto px-3 py-3 sm:px-3.5\">\n <QuestionBody\n question={question}\n index={current}\n draft={draft}\n cursor={cursor}\n onCursor={setCursor}\n onDraft={(next, settles) => move(next, current, settles)}\n onCommit={(settles) => {\n frame.current?.focus();\n move(draft, current, settles);\n }}\n />\n </div>\n\n <Separator />\n\n <div className=\"flex min-w-0 items-center gap-2 px-3 py-2 sm:px-3.5\">\n <span data-testid=\"questionnaire-hint\" className=\"min-w-0 truncate text-xs text-doom-faint max-sm:hidden\">\n <Kbd>←→</Kbd> questions · <Kbd>↑↓</Kbd> options · <Kbd>enter</Kbd>{' '}\n {question.multiSelect ? 'toggles' : 'selects'} · <Kbd>esc</Kbd> cancels\n </span>\n <span className=\"flex-1\" />\n <Button variant=\"outline\" size=\"md\" data-testid=\"questionnaire-cancel\" onClick={cancel}>\n cancel\n </Button>\n <Button\n variant=\"primary\"\n size=\"md\"\n data-testid=\"questionnaire-submit\"\n onClick={submit}\n disabled={!complete}\n title={complete ? 'send every answer to the agent' : 'answer every question first'}\n className=\"shrink-0 px-3 max-sm:max-w-32 max-sm:truncate sm:px-3.5\"\n >\n submit answers\n </Button>\n </div>\n </div>\n );\n}\n","import { defineToolRenderer } from '@agimon-ai/doompi-core/web';\n\nimport { AskUserQuestionToolMessage } from './_components/AskUserQuestionToolMessage';\nimport { QuestionnairePrompt } from './_components/QuestionnairePrompt';\nimport { readPromptQuestions } from './_lib/questionnaireDraft';\n\nexport default defineToolRenderer({\n message: AskUserQuestionToolMessage,\n prompt: {\n claims: (dialog, args) =>\n dialog.method === 'select' &&\n readPromptQuestions(args).some((question) => dialog.title.startsWith(question.question)),\n component: QuestionnairePrompt,\n },\n});\n","// Generated by @agimon-ai/doompi-build. Do not edit by hand.\nimport { defineWebPlugin, type WebPluginContributions } from '@agimon-ai/doompi-core/web';\n\nimport toolAskUserQuestion from '../src/extensions/workspaces/sessions/(frontend)/tool/askUserQuestion.web';\n\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const webPlugin = defineWebPlugin({\n id: 'ask-user',\n session: {\n get toolRenderers(): WebPluginContributions['toolRenderers'] { return [via({ tools: ['ask_user_question'] }, toolAskUserQuestion)]; },\n },\n});\n"],"mappings":";;;;;AASA,SAASA,WAAS,OAAkD;CAClE,OAAO,OAAO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AAU,CAAC;MACX,OAAO,WAAW,mCAAmC;MACrD,WAAU;MACX,UAAA;KAEO,CAAA;IACL;;EACF;;AAET;;;AC5WA,IAAA,8BAAe,mBAAmB;CAChC,SAAS;CACT,QAAQ;EACN,SAAS,QAAQ,SACf,OAAO,WAAW,YAClB,oBAAoB,IAAI,CAAC,CAAC,MAAM,aAAa,OAAO,MAAM,WAAW,SAAS,QAAQ,CAAC;EACzF,WAAW;CACb;AACF,CAAC;;;ACTD,MAAM,OAAU,UAAmC,UAChD,UAAU,KAAA,IAAY,KAAA,IAAY;CAAE,GAAG;CAAU,GAAI;AAAiB;AAEzE,MAAa,YAAY,gBAAgB;CACvC,IAAI;CACJ,SAAS,EACP,IAAI,gBAAyD;EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,mBAAmB,EAAE,GAAGC,2BAAmB,CAAC;CAAG,EACtI;AACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agimon-ai/doompi-user-feedback",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.73",
|
|
4
4
|
"description": "Structured user questions with interactive and autonomous Voice handoff for Pi agents.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -66,16 +66,16 @@
|
|
|
66
66
|
"access": "public"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@agimon-ai/doompi-core": "0.0.1-alpha.
|
|
70
|
-
"@agimon-ai/doompi-minor-mode": "0.0.1-alpha.
|
|
71
|
-
"@agimon-ai/doompi-ui": "0.0.1-alpha.
|
|
72
|
-
"@agimon-ai/doompi-web-components": "0.0.1-alpha.
|
|
69
|
+
"@agimon-ai/doompi-core": "0.0.1-alpha.84",
|
|
70
|
+
"@agimon-ai/doompi-minor-mode": "0.0.1-alpha.84",
|
|
71
|
+
"@agimon-ai/doompi-ui": "0.0.1-alpha.84",
|
|
72
|
+
"@agimon-ai/doompi-web-components": "0.0.1-alpha.42",
|
|
73
73
|
"@deepseek-ai/cordis": "4.0.2",
|
|
74
74
|
"typebox": "1.3.34"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
|
-
"@agimon-ai/doompi-build": "0.0.1-alpha.
|
|
78
|
-
"@agimon-ai/doompi-voice": "0.0.1-alpha.
|
|
77
|
+
"@agimon-ai/doompi-build": "0.0.1-alpha.12",
|
|
78
|
+
"@agimon-ai/doompi-voice": "0.0.1-alpha.85",
|
|
79
79
|
"@earendil-works/pi-coding-agent": "0.87.1",
|
|
80
80
|
"@earendil-works/pi-tui": "0.87.1",
|
|
81
81
|
"@tanstack/react-store": "0.11.1",
|