@agimon-ai/po-user-feedback 0.0.0-alpha.0
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/LICENSE +21 -0
- package/README.md +76 -0
- package/dist/apiContracts.cjs +17 -0
- package/dist/apiContracts.cjs.map +1 -0
- package/dist/apiContracts.d.mts +53 -0
- package/dist/apiContracts.d.mts.map +1 -0
- package/dist/apiContracts.mjs +13 -0
- package/dist/apiContracts.mjs.map +1 -0
- package/dist/extensions/server.cjs +627 -0
- package/dist/extensions/server.cjs.map +1 -0
- package/dist/extensions/server.d.mts +5 -0
- package/dist/extensions/server.d.mts.map +1 -0
- package/dist/extensions/server.mjs +622 -0
- package/dist/extensions/server.mjs.map +1 -0
- package/dist/extensions/web.mjs +619 -0
- package/dist/extensions/web.mjs.map +1 -0
- package/dist/index.cjs +0 -0
- package/dist/index.d.mts +49 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +1 -0
- package/llms.txt +4 -0
- package/package.json +124 -0
- package/src/prompts/po-use-user-feedback/SKILL.md +14 -0
|
@@ -0,0 +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/po-core/web';\nimport {\n MessageItem,\n MessageItemBody,\n MessageItemHeader,\n MessageItemStatus,\n toolTone,\n} from '@agimon-ai/po-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-dim\">({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/po-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/po-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-base font-medium ${\n active\n ? 'bg-doom-selected font-semibold 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\n className={`break-words text-base font-medium ${chosen ? 'font-semibold text-doom-hi' : 'text-doom-text'}`}\n >\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 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 />\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-base 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 />\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-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-sm text-doom-dim 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/po-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/po-build. Do not edit by hand.\nimport { defineWebPlugin, type WebPluginContributions } from '@agimon-ai/po-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,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,KAAK,SAAS,IAAI,KAAK,UAAU,OAAOD,UAAQ,IAAI,CAAC;CACrF,MAAM,UAAU,UAAU,KAAK,aAAaC,WAAS,SAAS,MAAM,CAAC,CAAC,CAAC,OAAO,OAAO;CACrF,OAAO;EACL,OAAO,GAAG,UAAU,OAAO,WAAW,UAAU,WAAW,IAAI,KAAK;EACpE,SAAS,QAAQ,KAAK,IAAI;CAC5B;AACF;;;;;;AAkBA,SAAgB,cAAc,SAAkB,QAA+B;CAC7E,IAAI,CAACD,WAAS,OAAO,KAAK,CAAC,MAAM,QAAQ,QAAQ,OAAO,GAAG,OAAO;EAAE,MAAM;EAAQ,MAAM;CAAO;CAC/F,IAAI,QAAQ,cAAc,MAAM,OAAO,EAAE,MAAM,YAAY;CAC3D,IAAI,QAAQ,aAAa,WAAW,OAAO,QAAQ,gBAAgB,UACjE,OAAO;EAAE,MAAM;EAAS,QAAQ,QAAQ;CAAY;CAStD,OAAO;EAAE,MAAM;EAAW,SAPV,QAAQ,QAAQ,OAAOA,UAAQ,CAAC,CAAC,KAAK,YAAY;GAChE,UAAUC,WAAS,OAAO,QAAQ;GAClC,QACE,OAAO,SAAS,WACX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E;OAClE,SAAS,cAAc,YAAY;OAAU;OAAG,oBAAC,KAAD,EAAA,UAAK,MAAQ,CAAA;OAAC;MAC3D;;KACN,oBAAC,QAAD,EAAM,WAAU,SAAU,CAAA;KAC1B,oBAAC,QAAD;MAAQ,SAAQ;MAAU,MAAK;MAAK,eAAY;MAAuB,SAAS;MAAQ,UAAA;KAEhF,CAAA;KACR,oBAAC,QAAD;MACE,SAAQ;MACR,MAAK;MACL,eAAY;MACZ,SAAS;MACT,UAAU,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/dist/index.cjs
ADDED
|
File without changes
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Static, Type } from "typebox";
|
|
2
|
+
//#region src/schemas/questionnaire.d.ts
|
|
3
|
+
declare const QuestionParamsSchema: Type.TObject<{
|
|
4
|
+
questions: Type.TArray<Type.TObject<{
|
|
5
|
+
question: Type.TString;
|
|
6
|
+
header: Type.TString;
|
|
7
|
+
options: Type.TArray<Type.TObject<{
|
|
8
|
+
label: Type.TString;
|
|
9
|
+
description: Type.TString;
|
|
10
|
+
preview: Type.TOptional<Type.TString>;
|
|
11
|
+
}>>;
|
|
12
|
+
multiSelect: Type.TOptional<Type.TBoolean>;
|
|
13
|
+
}>>;
|
|
14
|
+
}>;
|
|
15
|
+
type QuestionParams = Static<typeof QuestionParamsSchema>;
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/types/questionnaire.d.ts
|
|
18
|
+
type AnswerKind = 'option' | 'custom' | 'multi';
|
|
19
|
+
interface QuestionAnswer {
|
|
20
|
+
questionIndex: number;
|
|
21
|
+
question: string;
|
|
22
|
+
kind: AnswerKind;
|
|
23
|
+
answer: string | null;
|
|
24
|
+
selected?: string[];
|
|
25
|
+
notes?: string;
|
|
26
|
+
preview?: string;
|
|
27
|
+
}
|
|
28
|
+
type QuestionnaireError = 'no_ui' | 'no_custom_ui' | 'no_questions' | 'empty_options' | 'too_many_questions' | 'duplicate_question' | 'duplicate_option_label' | 'reserved_label' | 'session_load_failed' | 'stale_module_cache' |
|
|
29
|
+
/** A client replied with an answer envelope that did not match the questions asked. */
|
|
30
|
+
'malformed_answers';
|
|
31
|
+
interface QuestionnaireResult {
|
|
32
|
+
answers: QuestionAnswer[];
|
|
33
|
+
cancelled: boolean;
|
|
34
|
+
error?: QuestionnaireError;
|
|
35
|
+
delivery?: 'voice';
|
|
36
|
+
awaitingResponse?: boolean;
|
|
37
|
+
voicePrompt?: string;
|
|
38
|
+
}
|
|
39
|
+
interface ToolTextResult {
|
|
40
|
+
content: Array<{
|
|
41
|
+
type: 'text';
|
|
42
|
+
text: string;
|
|
43
|
+
}>;
|
|
44
|
+
details: QuestionnaireResult;
|
|
45
|
+
terminate?: boolean;
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export type { QuestionParams, QuestionnaireResult, ToolTextResult };
|
|
49
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/schemas/questionnaire.ts","../src/types/questionnaire.ts"],"mappings":";;cA6Ca,sBAAoB,KAAA;;;;;;;;;;;;KAarB,iBAAiB,cAAc;;;KC1D/B;UAEK;EACf;EACA;EACA,MAAM;EACN;EACA;EACA;EACA;;KAGU;;;UAkBK;EACf,SAAS;EACT;EACA,QAAQ;EACR;EACA;EACA;;UAGe;EACf,SAAS;IAAQ;IAAc;;EAC/B,SAAS;EACT"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/llms.txt
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agimon-ai/po-user-feedback",
|
|
3
|
+
"version": "0.0.0-alpha.0",
|
|
4
|
+
"description": "Structured user questions with interactive and autonomous Voice handoff for Pi agents.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"ai",
|
|
7
|
+
"ask-user-question",
|
|
8
|
+
"coding-agent",
|
|
9
|
+
"developer-tools",
|
|
10
|
+
"human-in-the-loop",
|
|
11
|
+
"pi-coding-agent",
|
|
12
|
+
"pi-extension",
|
|
13
|
+
"pi-package",
|
|
14
|
+
"po",
|
|
15
|
+
"user-feedback"
|
|
16
|
+
],
|
|
17
|
+
"homepage": "https://agimon.ai",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/AgiFlow/po/issues"
|
|
20
|
+
},
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"author": "Vuong Ngo",
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/AgiFlow/po.git",
|
|
26
|
+
"directory": "layers/ask-user/po-user-feedback"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist",
|
|
30
|
+
"README.md",
|
|
31
|
+
"LICENSE",
|
|
32
|
+
"package.json",
|
|
33
|
+
"src/prompts",
|
|
34
|
+
"llms.txt"
|
|
35
|
+
],
|
|
36
|
+
"type": "module",
|
|
37
|
+
"main": "./dist/index.cjs",
|
|
38
|
+
"module": "./dist/index.mjs",
|
|
39
|
+
"types": "./dist/index.d.mts",
|
|
40
|
+
"jsnext:main": "./dist/index.mjs",
|
|
41
|
+
"exports": {
|
|
42
|
+
".": {
|
|
43
|
+
"types": "./dist/index.d.mts",
|
|
44
|
+
"import": "./dist/index.mjs",
|
|
45
|
+
"require": "./dist/index.cjs"
|
|
46
|
+
},
|
|
47
|
+
"./apiContracts": {
|
|
48
|
+
"types": "./dist/apiContracts.d.mts",
|
|
49
|
+
"import": "./dist/apiContracts.mjs",
|
|
50
|
+
"require": "./dist/apiContracts.cjs"
|
|
51
|
+
},
|
|
52
|
+
"./extensions/server": {
|
|
53
|
+
"types": "./dist/extensions/server.d.mts",
|
|
54
|
+
"import": "./dist/extensions/server.mjs",
|
|
55
|
+
"require": "./dist/extensions/server.cjs"
|
|
56
|
+
},
|
|
57
|
+
"./extensions/web": {
|
|
58
|
+
"import": "./dist/extensions/web.mjs"
|
|
59
|
+
},
|
|
60
|
+
"./package.json": "./package.json"
|
|
61
|
+
},
|
|
62
|
+
"publishConfig": {
|
|
63
|
+
"access": "public"
|
|
64
|
+
},
|
|
65
|
+
"dependencies": {
|
|
66
|
+
"@agimon-ai/po-core": "0.0.0-alpha.0",
|
|
67
|
+
"@agimon-ai/po-minor-mode": "0.0.0-alpha.0",
|
|
68
|
+
"@agimon-ai/po-web-components": "0.0.0-alpha.0",
|
|
69
|
+
"@deepseek-ai/cordis": "4.0.4",
|
|
70
|
+
"typebox": "1.3.34"
|
|
71
|
+
},
|
|
72
|
+
"devDependencies": {
|
|
73
|
+
"@agimon-ai/po-build": "0.0.0-alpha.0",
|
|
74
|
+
"@agimon-ai/po-voice": "0.0.0-alpha.0",
|
|
75
|
+
"@earendil-works/pi-coding-agent": "1.0.2",
|
|
76
|
+
"@tanstack/react-store": "0.11.2",
|
|
77
|
+
"@tanstack/store": "0.11.2",
|
|
78
|
+
"@types/node": "26.6.4",
|
|
79
|
+
"@types/react": "19.3.0",
|
|
80
|
+
"@vitest/coverage-v8": "5.0.3",
|
|
81
|
+
"react": "19.3.0",
|
|
82
|
+
"react-dom": "19.3.0",
|
|
83
|
+
"tsdown": "0.23.0",
|
|
84
|
+
"typescript": "7.0.2",
|
|
85
|
+
"vitest": "5.0.3"
|
|
86
|
+
},
|
|
87
|
+
"peerDependencies": {
|
|
88
|
+
"@earendil-works/pi-coding-agent": "1.0.2"
|
|
89
|
+
},
|
|
90
|
+
"peerDependenciesMeta": {
|
|
91
|
+
"@earendil-works/pi-coding-agent": {
|
|
92
|
+
"optional": true
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
"engines": {
|
|
96
|
+
"node": ">=24"
|
|
97
|
+
},
|
|
98
|
+
"poServer": {
|
|
99
|
+
"entry": "./generated/server.ts",
|
|
100
|
+
"dist": "./dist/extensions/server.mjs",
|
|
101
|
+
"scopes": [
|
|
102
|
+
"session"
|
|
103
|
+
],
|
|
104
|
+
"contracts": {
|
|
105
|
+
"entry": "./src/exports/apiContracts.ts",
|
|
106
|
+
"dist": "./dist/apiContracts.mjs"
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
"poWeb": {
|
|
110
|
+
"pluginId": "ask-user",
|
|
111
|
+
"channels": [],
|
|
112
|
+
"client": "./dist/extensions/web.mjs",
|
|
113
|
+
"scopes": [
|
|
114
|
+
"session"
|
|
115
|
+
]
|
|
116
|
+
},
|
|
117
|
+
"scripts": {
|
|
118
|
+
"build": "tsdown",
|
|
119
|
+
"test": "vitest --run",
|
|
120
|
+
"typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.web.json",
|
|
121
|
+
"lint": "oxlint . && oxfmt . --check",
|
|
122
|
+
"fixcode": "oxlint . --fix && oxfmt ."
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: po-use-user-feedback
|
|
3
|
+
description: Use structured questions to resolve ambiguous requirements in native Po sessions.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# User feedback
|
|
7
|
+
|
|
8
|
+
Use `ask_user_question` to present concrete options and wait for client answers when requirements are ambiguous.
|
|
9
|
+
|
|
10
|
+
A call accepts 1 to 4 questions with 2 to 4 options each. Use `multiSelect: true` when several choices are valid. Do not add an `Other` option: the client supplies a custom-text row.
|
|
11
|
+
|
|
12
|
+
The result contains readable answer text and structured `details.answers`. Cancellation sets `cancelled: true`. Questionnaires run one at a time and disposal aborts pending requests.
|
|
13
|
+
|
|
14
|
+
During autonomous Voice, `ask_user_question` is unavailable. Ask by narrating and wait for the user's next ordinary message instead.
|