@agimon-ai/po-user-feedback 0.0.0-alpha.20 → 0.0.0-alpha.22

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 CHANGED
@@ -1,21 +1,149 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Vuong Ngo
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ License text copyright © 2017 MariaDB Corporation Ab, All Rights Reserved.
2
+ "Business Source License" is a trademark of MariaDB Corporation Ab.
3
+
4
+ Parameters
5
+
6
+ Licensor: Agimon Pty Ltd
7
+ Licensed Work: Po, the software in the Po source repository and the
8
+ packages released from it, in each version released by
9
+ the Licensor.
10
+ The Licensed Work is (c) 2026 Agimon Pty Ltd.
11
+ Material identified as third-party in the "Third-party
12
+ components" section at the end of this file or in a
13
+ NOTICE file, and any package or directory whose own
14
+ license file grants a different license, is not part of
15
+ the Licensed Work and remains under its own license.
16
+ Additional Use Grant: You may make production use of the Licensed Work if
17
+ your use is Eligible Use. "Eligible Use" is production use that falls
18
+ within at least one of the following:
19
+
20
+ (a) Personal Use. Use by an individual for their own personal purposes,
21
+ and not on behalf of, or for the benefit of, an employer, client, or
22
+ other Organization. Use by an individual in the course of employment
23
+ or engagement by an Organization is use by that Organization.
24
+
25
+ (b) Small Organization Use. Use by or on behalf of an Organization whose
26
+ Annual Revenue is less than USD 1,000,000.
27
+
28
+ (c) Non-profit, Education and Research Use. Use, regardless of Annual
29
+ Revenue, by (i) an Organization registered or recognized as a
30
+ non-profit or charitable organization under the laws of its
31
+ jurisdiction, for its non-profit purposes; (ii) an accredited school,
32
+ college, or university, for teaching, learning, or academic research;
33
+ or (iii) a publicly funded research institution, for its research.
34
+
35
+ (d) Service Provider Use. Use by a consultant, contractor, agency, or other
36
+ service provider, regardless of its own Annual Revenue, solely to
37
+ build, deploy, host, operate, or support the Licensed Work for a client
38
+ whose own use would be Eligible Use under (a), (b), or (c). A service
39
+ provider's use for its own purposes is Eligible Use only if the service
40
+ provider itself qualifies under (b) or (c).
41
+
42
+
43
+ Hosted services. Offering the Licensed Work to third parties as a hosted
44
+ or managed service whose primary value is the Licensed Work is Eligible
45
+ Use only if each such third party's own use would be Eligible Use.
46
+
47
+ Definitions. "Organization" means any company, partnership, sole
48
+ proprietorship, trust, association, government body, or other entity, and
49
+ includes an individual acting in a business or professional capacity.
50
+ "Affiliate" means any entity that directly or indirectly controls, is
51
+ controlled by, or is under common control with an Organization, where
52
+ "control" means ownership of more than 50% of the voting interests of an
53
+ entity or the power to direct its management and policies by contract or
54
+ otherwise. "Annual Revenue" means the total gross revenue of an
55
+ Organization and all of its Affiliates combined, from all sources and
56
+ whether or not related to the Licensed Work, for its most recently
57
+ completed fiscal year, or, if it has not completed a fiscal year, for the
58
+ twelve months before the use (or since its formation, if shorter),
59
+ converted into US dollars at the average exchange rate for that period.
60
+ Proceeds of equity or debt financing are not revenue.
61
+
62
+ Threshold. If an Organization stops qualifying under (b), its existing
63
+ production use remains Eligible Use for 90 days after it stops
64
+ qualifying, after which it must obtain a commercial license or stop
65
+ production use. Use that was Eligible Use when it occurred never requires
66
+ a commercial license after the fact.
67
+ Change Date: Four years from the date a version of the Licensed Work
68
+ is first publicly released by the Licensor.
69
+ Change License: Apache License, Version 2.0
70
+
71
+ For information about alternative licensing arrangements for the Licensed
72
+ Work, please visit: https://agimon.ai/licensing
73
+
74
+ Notice
75
+
76
+ The Business Source License (this document, or the "License") is not an Open
77
+ Source license. However, the Licensed Work will eventually be made available
78
+ under an Open Source License, as stated in this License.
79
+
80
+ -----------------------------------------------------------------------------
81
+
82
+ Business Source License 1.1
83
+
84
+ Terms
85
+
86
+ The Licensor hereby grants you the right to copy, modify, create derivative
87
+ works, redistribute, and make non-production use of the Licensed Work. The
88
+ Licensor may make an Additional Use Grant, above, permitting limited
89
+ production use.
90
+
91
+ Effective on the Change Date, or the fourth anniversary of the first publicly
92
+ available distribution of a specific version of the Licensed Work under this
93
+ License, whichever comes first, the Licensor hereby grants you rights under
94
+ the terms of the Change License, and the rights granted in the paragraph
95
+ above terminate.
96
+
97
+ If your use of the Licensed Work does not comply with the requirements
98
+ currently in effect as described in this License, you must purchase a
99
+ commercial license from the Licensor, its affiliated entities, or authorized
100
+ resellers, or you must refrain from using the Licensed Work.
101
+
102
+ All copies of the original and modified Licensed Work, and derivative works
103
+ of the Licensed Work, are subject to this License. This License applies
104
+ separately for each version of the Licensed Work and the Change Date may vary
105
+ for each version of the Licensed Work released by Licensor.
106
+
107
+ You must conspicuously display this License on each original or modified copy
108
+ of the Licensed Work. If you receive the Licensed Work in original or
109
+ modified form from a third party, the terms and conditions set forth in this
110
+ License apply to your use of that work.
111
+
112
+ Any use of the Licensed Work in violation of this License will automatically
113
+ terminate your rights under this License for the current and all other
114
+ versions of the Licensed Work.
115
+
116
+ This License does not grant you any right in any trademark or logo of
117
+ Licensor or its affiliates (provided that you may use a trademark or logo of
118
+ Licensor as expressly required by this License).
119
+
120
+ TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
121
+ AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
122
+ EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
123
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
124
+ TITLE.
125
+
126
+ MariaDB hereby grants you permission to use this License’s text to license
127
+ your works, and to refer to it using the trademark “Business Source License”,
128
+ as long as you comply with the Covenants of Licensor below.
129
+
130
+ Covenants of Licensor
131
+
132
+ In consideration of the right to use this License’s text and the “Business
133
+ Source License” name and trademark, Licensor covenants to MariaDB, and to all
134
+ other recipients of the licensed work to be provided by Licensor:
135
+
136
+ 1. To specify as the Change License the GPL Version 2.0 or any later version,
137
+ or a license that is compatible with GPL Version 2.0 or a later version,
138
+ where “compatible” means that software provided under the Change License can
139
+ be included in a program with software provided under GPL Version 2.0 or a
140
+ later version. Licensor may specify additional Change Licenses without
141
+ limitation.
142
+
143
+ 2. To either: (a) specify an additional grant of rights to use that does not
144
+ impose any additional restriction on the right granted in this License, as
145
+ the Additional Use Grant; or (b) insert the text “None”.
146
+
147
+ 3. To specify a Change Date.
148
+
149
+ 4. Not to modify this License in any other way.
@@ -1,7 +1,7 @@
1
1
  import { defineNativePlugin, defineToolRenderer } from "@agimon-ai/po-core/native";
2
2
  import { View } from "react-native-unistyles/components/native/View";
3
3
  import { Text } from "react-native-unistyles/components/native/Text";
4
- import { Button, Markdown, MessageItem, MessageItemBody, MessageItemHeader, MessageItemStatus, SectionLabel, Textarea, fontOf, selectionTick, toolTone } from "@agimon-ai/po-native-components";
4
+ import { Button, ChevronDownIcon, ChevronRightIcon, Markdown, MessageItem, MessageItemBody, MessageItemHeader, MessageItemStatus, SectionLabel, Textarea, fontOf, selectionTick, toolTone } from "@agimon-ai/po-native-components";
5
5
  import { StyleSheet } from "react-native-unistyles";
6
6
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
7
  import { ScrollView } from "react-native-unistyles/components/native/ScrollView";
@@ -274,16 +274,18 @@ function draftAnswers(questions, draft) {
274
274
  //#region src/extensions/workspaces/sessions/(frontend)/tool/_components/QuestionnairePrompt.native.tsx
275
275
  /** Pure presentation for the approved-target stories and the native prompt host. */
276
276
  function QuestionnaireView(props) {
277
- const { questions, draft, current, previewIndex, onDraft, onCurrent, onPreview, onSubmit, onCancel } = props;
277
+ const { questions, draft, current, previewIndex, collapsed, onDraft, onCurrent, onPreview, onCollapsed, onSubmit, onCancel } = props;
278
278
  const question = questions[current];
279
279
  const entry = draftEntry(draft, current);
280
280
  const preview = question?.options[previewIndex]?.preview;
281
281
  return /* @__PURE__ */ jsxs(View, {
282
282
  style: styles.frame,
283
283
  testID: "questionnaire",
284
- children: [
285
- /* @__PURE__ */ jsx(ScrollView, {
284
+ children: [/* @__PURE__ */ jsxs(View, {
285
+ style: styles.header,
286
+ children: [/* @__PURE__ */ jsx(ScrollView, {
286
287
  horizontal: true,
288
+ style: styles.stepBar,
287
289
  contentContainerStyle: styles.steps,
288
290
  accessibilityLabel: "Questions",
289
291
  children: questions.map((step, index) => /* @__PURE__ */ jsx(Button, {
@@ -298,139 +300,155 @@ function QuestionnaireView(props) {
298
300
  },
299
301
  children: `${isAnswered(draftEntry(draft, index)) ? "✓ " : ""}${step.header || `Question ${String(index + 1)}`}`
300
302
  }, `${String(index)}:${step.question}`))
301
- }),
302
- /* @__PURE__ */ jsx(ScrollView, {
303
- style: styles.body,
304
- contentContainerStyle: styles.content,
305
- keyboardShouldPersistTaps: "handled",
306
- children: question ? /* @__PURE__ */ jsxs(Fragment, { children: [
307
- /* @__PURE__ */ jsxs(Text, {
308
- style: styles.meta,
309
- children: [
310
- "Question ",
311
- current + 1,
312
- " / ",
313
- questions.length,
314
- question.multiSelect ? " · Choose any that fit" : ""
315
- ]
316
- }),
317
- /* @__PURE__ */ jsx(Text, {
318
- style: styles.question,
319
- testID: "questionnaire-question",
320
- children: question.question
321
- }),
322
- question.options.map((option, index) => {
323
- const chosen = entry.custom === null && entry.selected.includes(option.label);
324
- return /* @__PURE__ */ jsxs(Pressable, {
325
- accessibilityRole: question.multiSelect ? "checkbox" : "radio",
326
- "aria-checked": chosen,
327
- accessibilityLabel: option.label,
328
- accessibilityHint: option.description,
329
- testID: `questionnaire-option-${String(index)}`,
330
- style: [styles.option, chosen && styles.chosen],
331
- onFocus: () => onPreview(index),
332
- onPress: () => {
333
- selectionTick();
334
- onPreview(index);
335
- onDraft(chooseOption(draft, current, option.label, question.multiSelect), !question.multiSelect);
336
- },
303
+ }), /* @__PURE__ */ jsx(Button, {
304
+ variant: "ghost",
305
+ size: "icon",
306
+ accessibilityLabel: collapsed ? "expand" : "collapse",
307
+ accessibilityState: { expanded: !collapsed },
308
+ accessibilityHint: collapsed ? "show the questions again" : "fold away to read the conversation",
309
+ testID: "questionnaire-collapse",
310
+ onPress: () => onCollapsed(!collapsed),
311
+ children: collapsed ? /* @__PURE__ */ jsx(ChevronRightIcon, {
312
+ size: 16,
313
+ color: "dim"
314
+ }) : /* @__PURE__ */ jsx(ChevronDownIcon, {
315
+ size: 16,
316
+ color: "dim"
317
+ })
318
+ })]
319
+ }), collapsed ? null : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ScrollView, {
320
+ style: styles.body,
321
+ contentContainerStyle: styles.content,
322
+ keyboardShouldPersistTaps: "handled",
323
+ children: question ? /* @__PURE__ */ jsxs(Fragment, { children: [
324
+ /* @__PURE__ */ jsxs(Text, {
325
+ style: styles.meta,
326
+ children: [
327
+ "Question ",
328
+ current + 1,
329
+ " / ",
330
+ questions.length,
331
+ question.multiSelect ? " · Choose any that fit" : ""
332
+ ]
333
+ }),
334
+ /* @__PURE__ */ jsx(Text, {
335
+ style: styles.question,
336
+ testID: "questionnaire-question",
337
+ children: question.question
338
+ }),
339
+ question.options.map((option, index) => {
340
+ const chosen = entry.custom === null && entry.selected.includes(option.label);
341
+ return /* @__PURE__ */ jsxs(Pressable, {
342
+ accessibilityRole: question.multiSelect ? "checkbox" : "radio",
343
+ "aria-checked": chosen,
344
+ accessibilityLabel: option.label,
345
+ accessibilityHint: option.description,
346
+ testID: `questionnaire-option-${String(index)}`,
347
+ style: [styles.option, chosen && styles.chosen],
348
+ onFocus: () => onPreview(index),
349
+ onPress: () => {
350
+ selectionTick();
351
+ onPreview(index);
352
+ onDraft(chooseOption(draft, current, option.label, question.multiSelect), !question.multiSelect);
353
+ },
354
+ children: [/* @__PURE__ */ jsx(Text, {
355
+ style: [styles.mark, chosen && styles.selectedInk],
356
+ children: question.multiSelect ? chosen ? "☑" : "☐" : chosen ? "●" : "○"
357
+ }), /* @__PURE__ */ jsxs(View, {
358
+ style: styles.optionText,
337
359
  children: [/* @__PURE__ */ jsx(Text, {
338
- style: [styles.mark, chosen && styles.selectedInk],
339
- children: question.multiSelect ? chosen ? "☑" : "☐" : chosen ? "●" : "○"
340
- }), /* @__PURE__ */ jsxs(View, {
341
- style: styles.optionText,
342
- children: [/* @__PURE__ */ jsx(Text, {
343
- style: styles.label,
344
- children: option.label
345
- }), option.description ? /* @__PURE__ */ jsx(Text, {
346
- style: styles.meta,
347
- children: option.description
348
- }) : null]
349
- })]
350
- }, `${String(index)}:${option.label}`);
351
- }),
352
- /* @__PURE__ */ jsx(Button, {
353
- variant: entry.custom === null ? "ghost" : "secondary",
354
- size: "card",
355
- testID: "questionnaire-option-custom",
356
- onPress: () => onDraft(setCustom(draft, current, entry.custom ?? ""), false),
357
- children: CUSTOM_LABEL
358
- }),
359
- entry.custom !== null ? /* @__PURE__ */ jsxs(View, {
360
- style: styles.field,
361
- children: [/* @__PURE__ */ jsx(SectionLabel, { children: "Your answer" }), /* @__PURE__ */ jsx(Textarea, {
362
- autoFocus: true,
363
- rows: 2,
364
- accessibilityLabel: "Your answer",
365
- testID: "questionnaire-custom",
366
- value: entry.custom,
367
- placeholder: "type your answer…",
368
- onChangeText: (value) => onDraft(setCustom(draft, current, value), false)
360
+ style: styles.label,
361
+ children: option.label
362
+ }), option.description ? /* @__PURE__ */ jsx(Text, {
363
+ style: styles.meta,
364
+ children: option.description
365
+ }) : null]
369
366
  })]
370
- }) : null,
371
- preview && entry.custom === null ? /* @__PURE__ */ jsxs(View, {
372
- style: styles.preview,
373
- testID: "questionnaire-preview",
374
- children: [/* @__PURE__ */ jsx(SectionLabel, { children: "Preview" }), /* @__PURE__ */ jsx(Markdown, { text: preview })]
375
- }) : null,
376
- /* @__PURE__ */ jsxs(View, {
377
- style: styles.field,
378
- children: [/* @__PURE__ */ jsx(SectionLabel, { children: "Note (optional)" }), /* @__PURE__ */ jsx(Textarea, {
379
- rows: 1,
380
- accessibilityLabel: "Note (optional)",
381
- testID: "questionnaire-notes",
382
- value: entry.notes,
383
- placeholder: "anything the options do not cover",
384
- onChangeText: (value) => onDraft(setNotes(draft, current, value), false)
385
- })]
386
- })
387
- ] }) : /* @__PURE__ */ jsx(Text, {
388
- style: styles.meta,
389
- children: "the agent asked something this cockpit could not read"
367
+ }, `${String(index)}:${option.label}`);
368
+ }),
369
+ /* @__PURE__ */ jsx(Button, {
370
+ variant: entry.custom === null ? "ghost" : "secondary",
371
+ size: "card",
372
+ testID: "questionnaire-option-custom",
373
+ onPress: () => onDraft(setCustom(draft, current, entry.custom ?? ""), false),
374
+ children: CUSTOM_LABEL
375
+ }),
376
+ entry.custom !== null ? /* @__PURE__ */ jsxs(View, {
377
+ style: styles.field,
378
+ children: [/* @__PURE__ */ jsx(SectionLabel, { children: "Your answer" }), /* @__PURE__ */ jsx(Textarea, {
379
+ autoFocus: true,
380
+ rows: 2,
381
+ accessibilityLabel: "Your answer",
382
+ testID: "questionnaire-custom",
383
+ value: entry.custom,
384
+ placeholder: "type your answer…",
385
+ onChangeText: (value) => onDraft(setCustom(draft, current, value), false)
386
+ })]
387
+ }) : null,
388
+ preview && entry.custom === null ? /* @__PURE__ */ jsxs(View, {
389
+ style: styles.preview,
390
+ testID: "questionnaire-preview",
391
+ children: [/* @__PURE__ */ jsx(SectionLabel, { children: "Preview" }), /* @__PURE__ */ jsx(Markdown, { text: preview })]
392
+ }) : null,
393
+ /* @__PURE__ */ jsxs(View, {
394
+ style: styles.field,
395
+ children: [/* @__PURE__ */ jsx(SectionLabel, { children: "Note (optional)" }), /* @__PURE__ */ jsx(Textarea, {
396
+ rows: 1,
397
+ accessibilityLabel: "Note (optional)",
398
+ testID: "questionnaire-notes",
399
+ value: entry.notes,
400
+ placeholder: "anything the options do not cover",
401
+ onChangeText: (value) => onDraft(setNotes(draft, current, value), false)
402
+ })]
390
403
  })
391
- }),
392
- /* @__PURE__ */ jsxs(View, {
393
- style: styles.actions,
394
- children: [
395
- questions.length > 1 && !isComplete(draft) ? /* @__PURE__ */ jsx(Button, {
396
- size: "card",
397
- disabled: !isAnswered(entry),
398
- onPress: () => onDraft(draft, true),
399
- testID: "questionnaire-next",
400
- children: "Next question"
401
- }) : null,
402
- /* @__PURE__ */ jsx(Button, {
403
- size: "card",
404
- onPress: onCancel,
405
- testID: "questionnaire-cancel",
406
- children: "cancel"
407
- }),
408
- /* @__PURE__ */ jsx(Button, {
409
- size: "card",
410
- variant: "primary",
411
- disabled: !isComplete(draft),
412
- onPress: onSubmit,
413
- testID: "questionnaire-submit",
414
- children: "submit answers"
415
- })
416
- ]
404
+ ] }) : /* @__PURE__ */ jsx(Text, {
405
+ style: styles.meta,
406
+ children: "the agent asked something this cockpit could not read"
417
407
  })
418
- ]
408
+ }), /* @__PURE__ */ jsxs(View, {
409
+ style: styles.actions,
410
+ children: [
411
+ questions.length > 1 && !isComplete(draft) ? /* @__PURE__ */ jsx(Button, {
412
+ size: "card",
413
+ disabled: !isAnswered(entry),
414
+ onPress: () => onDraft(draft, true),
415
+ testID: "questionnaire-next",
416
+ children: "Next question"
417
+ }) : null,
418
+ /* @__PURE__ */ jsx(Button, {
419
+ size: "card",
420
+ onPress: onCancel,
421
+ testID: "questionnaire-cancel",
422
+ children: "cancel"
423
+ }),
424
+ /* @__PURE__ */ jsx(Button, {
425
+ size: "card",
426
+ variant: "primary",
427
+ disabled: !isComplete(draft),
428
+ onPress: onSubmit,
429
+ testID: "questionnaire-submit",
430
+ children: "submit answers"
431
+ })
432
+ ]
433
+ })] })]
419
434
  });
420
435
  }
421
436
  function Questionnaire({ questions, answer, cancel }) {
422
437
  const [draft, setDraft] = useState(() => emptyDraft(questions.length));
423
438
  const [current, setCurrent] = useState(0);
424
439
  const [previewIndex, setPreviewIndex] = useState(0);
440
+ const [collapsed, setCollapsed] = useState(false);
425
441
  const show = (index) => {
426
442
  setCurrent(index);
427
443
  setPreviewIndex(0);
444
+ setCollapsed(false);
428
445
  };
429
446
  return /* @__PURE__ */ jsx(QuestionnaireView, {
430
447
  questions,
431
448
  draft,
432
449
  current,
433
450
  previewIndex,
451
+ collapsed,
434
452
  onDraft: (next, settles) => {
435
453
  setDraft(next);
436
454
  if (!settles) return;
@@ -439,6 +457,7 @@ function Questionnaire({ questions, answer, cancel }) {
439
457
  },
440
458
  onCurrent: show,
441
459
  onPreview: setPreviewIndex,
460
+ onCollapsed: setCollapsed,
442
461
  onSubmit: () => {
443
462
  if (isComplete(draft)) answer(encodeAnswerEnvelope(draftAnswers(questions, draft)));
444
463
  },
@@ -463,6 +482,13 @@ const styles = StyleSheet.create((theme) => ({
463
482
  borderColor: theme.colors["edge-magenta"],
464
483
  uni__dependencies: [0]
465
484
  },
485
+ header: {
486
+ flexDirection: "row",
487
+ alignItems: "center",
488
+ paddingRight: theme.spacing(3),
489
+ uni__dependencies: [0]
490
+ },
491
+ stepBar: { flex: 1 },
466
492
  steps: {
467
493
  gap: theme.spacing(2),
468
494
  padding: theme.spacing(3),
@@ -1 +1 @@
1
- {"version":3,"file":"native.mjs","names":["isRecord","asString","ToolMessageRenderProps","fontOf","MessageItem","MessageItemBody","MessageItemHeader","MessageItemStatus","toolTone","StyleSheet","askCallSummary","askResultView","AskUserQuestionToolMessage","props","summary","args","view","result","details","output","count","headers","running","kind","answers","length","styles","map","answer","index","String","question","text","check","prompt","isError","error","undefined","create","theme","gap","spacing","uni__dependencies","fontFamily","sans","fontSize","base","lineHeight","lineHeightRelaxed","color","colors","dim","green","cyan","red","styles","ToolPromptRenderProps","Button","fontOf","Markdown","SectionLabel","selectionTick","Textarea","useMemo","useState","StyleSheet","encodeAnswerEnvelope","chooseOption","CUSTOM_LABEL","draftAnswers","draftEntry","emptyDraft","isAnswered","isComplete","nextUnanswered","PromptQuestion","QuestionnaireDraft","readPromptQuestions","setCustom","setNotes","QuestionnaireViewProps","questions","draft","current","previewIndex","onDraft","settles","onCurrent","index","onPreview","onSubmit","onCancel","QuestionnaireView","props","question","entry","preview","options","styles","frame","steps","map","step","String","header","body","content","meta","length","multiSelect","option","chosen","custom","selected","includes","label","description","mark","selectedInk","optionText","field","value","notes","actions","Questionnaire","answer","cancel","setDraft","setCurrent","setPreviewIndex","show","next","pending","QuestionnairePrompt","args","sessionId","dialog","id","create","theme","maxHeight","flexShrink","backgroundColor","colors","rail","borderTopWidth","borderColor","uni__dependencies","gap","spacing","padding","paddingHorizontal","paddingBottom","fontFamily","sans","fontSize","base","lineHeight","lineHeightRelaxed","color","hi","sm","dim","flexDirection","minHeight","borderWidth","borderRadius","md","lg","magenta","flex","fontWeight","semibold","text","paddingLeft","borderLeftWidth","flexWrap","justifyContent","toolAskUserQuestion"],"sources":["../../src/extensions/workspaces/sessions/(frontend)/tool/_lib/askUserText.ts","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/AskUserQuestionToolMessage.native.tsx","../../src/types/askUserWire.ts","../../src/extensions/workspaces/sessions/(frontend)/tool/_lib/questionnaireDraft.ts","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/QuestionnairePrompt.native.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/askUserQuestion.native.tsx","../../generated/native.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/native';\nimport {\n fontOf,\n MessageItem,\n MessageItemBody,\n MessageItemHeader,\n MessageItemStatus,\n toolTone,\n} from '@agimon-ai/po-native-components';\nimport { Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { askCallSummary, askResultView } from '../_lib/askUserText';\n\nexport function AskUserQuestionToolMessage(props: ToolMessageRenderProps) {\n const summary = askCallSummary(props.args);\n const view = askResultView(props.result?.details, props.output);\n return (\n <MessageItem tone={toolTone(props)}>\n <MessageItemHeader title=\"ask_user_question\">{`${summary.count}${summary.headers ? ` (${summary.headers})` : ''}`}</MessageItemHeader>\n <MessageItemBody testID=\"tool-result-ask_user_question\">\n {props.running ? (\n <MessageItemStatus tone=\"running\">running</MessageItemStatus>\n ) : view.kind === 'cancelled' ? (\n <MessageItemStatus tone=\"running\">cancelled</MessageItemStatus>\n ) : view.kind === 'answers' ? (\n view.answers.length === 0 ? (\n <MessageItemStatus tone=\"ok\">submitted</MessageItemStatus>\n ) : (\n <View style={styles.answers}>\n {view.answers.map((answer, index) => (\n <Text key={`${String(index)}:${answer.question}`} style={styles.text}>\n <Text style={styles.check}>✓ </Text>\n <Text style={styles.question}>{answer.question}</Text>: {answer.answer}\n </Text>\n ))}\n </View>\n )\n ) : view.kind === 'voice' ? (\n <Text style={styles.text}>{view.prompt}</Text>\n ) : view.text ? (\n <Text\n style={[styles.text, props.isError && styles.error]}\n accessibilityRole={props.isError ? 'alert' : undefined}\n >\n {view.text}\n </Text>\n ) : (\n <MessageItemStatus tone={props.isError ? 'error' : 'ok'}>\n {props.isError ? 'failed' : 'submitted'}\n </MessageItemStatus>\n )}\n </MessageItemBody>\n </MessageItem>\n );\n}\n\nconst styles = StyleSheet.create((theme) => ({\n answers: { gap: theme.spacing(2) },\n text: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeightRelaxed.base,\n color: theme.colors.dim,\n },\n check: { color: theme.colors.green },\n question: { color: theme.colors.cyan },\n error: { color: theme.colors.red },\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 = 'po-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/native';\nimport { Button, fontOf, Markdown, SectionLabel, selectionTick, Textarea } from '@agimon-ai/po-native-components';\nimport { useMemo, useState } from 'react';\nimport { Pressable, ScrollView, Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\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\nexport interface QuestionnaireViewProps {\n questions: readonly PromptQuestion[];\n draft: QuestionnaireDraft;\n current: number;\n previewIndex: number;\n onDraft: (draft: QuestionnaireDraft, settles: boolean) => void;\n onCurrent: (index: number) => void;\n onPreview: (index: number) => void;\n onSubmit: () => void;\n onCancel: () => void;\n}\n\n/** Pure presentation for the approved-target stories and the native prompt host. */\nexport function QuestionnaireView(props: QuestionnaireViewProps) {\n const { questions, draft, current, previewIndex, onDraft, onCurrent, onPreview, onSubmit, onCancel } = props;\n const question = questions[current];\n const entry = draftEntry(draft, current);\n const preview = question?.options[previewIndex]?.preview;\n return (\n <View style={styles.frame} testID=\"questionnaire\">\n <ScrollView horizontal contentContainerStyle={styles.steps} accessibilityLabel=\"Questions\">\n {questions.map((step, index) => (\n <Button\n key={`${String(index)}:${step.question}`}\n size=\"card\"\n variant={index === current ? 'secondary' : 'ghost'}\n aria-selected={index === current}\n accessibilityLabel={`${step.header || `Question ${String(index + 1)}`}, ${isAnswered(draftEntry(draft, index)) ? 'answered' : 'not answered'}`}\n testID={`questionnaire-step-${String(index)}`}\n onPress={() => {\n selectionTick();\n onCurrent(index);\n }}\n >\n {`${isAnswered(draftEntry(draft, index)) ? '✓ ' : ''}${step.header || `Question ${String(index + 1)}`}`}\n </Button>\n ))}\n </ScrollView>\n <ScrollView style={styles.body} contentContainerStyle={styles.content} keyboardShouldPersistTaps=\"handled\">\n {question ? (\n <>\n <Text style={styles.meta}>\n Question {current + 1} / {questions.length}\n {question.multiSelect ? ' · Choose any that fit' : ''}\n </Text>\n <Text style={styles.question} testID=\"questionnaire-question\">\n {question.question}\n </Text>\n {question.options.map((option, index) => {\n const chosen = entry.custom === null && entry.selected.includes(option.label);\n return (\n <Pressable\n key={`${String(index)}:${option.label}`}\n accessibilityRole={question.multiSelect ? 'checkbox' : 'radio'}\n aria-checked={chosen}\n accessibilityLabel={option.label}\n accessibilityHint={option.description}\n testID={`questionnaire-option-${String(index)}`}\n style={[styles.option, chosen && styles.chosen]}\n onFocus={() => onPreview(index)}\n onPress={() => {\n selectionTick();\n onPreview(index);\n onDraft(chooseOption(draft, current, option.label, question.multiSelect), !question.multiSelect);\n }}\n >\n <Text style={[styles.mark, chosen && styles.selectedInk]}>\n {question.multiSelect ? (chosen ? '☑' : '☐') : chosen ? '●' : '○'}\n </Text>\n <View style={styles.optionText}>\n <Text style={styles.label}>{option.label}</Text>\n {option.description ? <Text style={styles.meta}>{option.description}</Text> : null}\n </View>\n </Pressable>\n );\n })}\n <Button\n variant={entry.custom === null ? 'ghost' : 'secondary'}\n size=\"card\"\n testID=\"questionnaire-option-custom\"\n onPress={() => onDraft(setCustom(draft, current, entry.custom ?? ''), false)}\n >\n {CUSTOM_LABEL}\n </Button>\n {entry.custom !== null ? (\n <View style={styles.field}>\n <SectionLabel>Your answer</SectionLabel>\n <Textarea\n autoFocus\n rows={2}\n accessibilityLabel=\"Your answer\"\n testID=\"questionnaire-custom\"\n value={entry.custom}\n placeholder=\"type your answer…\"\n onChangeText={(value) => onDraft(setCustom(draft, current, value), false)}\n />\n </View>\n ) : null}\n {preview && entry.custom === null ? (\n <View style={styles.preview} testID=\"questionnaire-preview\">\n <SectionLabel>Preview</SectionLabel>\n <Markdown text={preview} />\n </View>\n ) : null}\n <View style={styles.field}>\n <SectionLabel>Note (optional)</SectionLabel>\n <Textarea\n rows={1}\n accessibilityLabel=\"Note (optional)\"\n testID=\"questionnaire-notes\"\n value={entry.notes}\n placeholder=\"anything the options do not cover\"\n onChangeText={(value) => onDraft(setNotes(draft, current, value), false)}\n />\n </View>\n </>\n ) : (\n <Text style={styles.meta}>the agent asked something this cockpit could not read</Text>\n )}\n </ScrollView>\n <View style={styles.actions}>\n {questions.length > 1 && !isComplete(draft) ? (\n <Button\n size=\"card\"\n disabled={!isAnswered(entry)}\n onPress={() => onDraft(draft, true)}\n testID=\"questionnaire-next\"\n >\n Next question\n </Button>\n ) : null}\n <Button size=\"card\" onPress={onCancel} testID=\"questionnaire-cancel\">\n cancel\n </Button>\n <Button\n size=\"card\"\n variant=\"primary\"\n disabled={!isComplete(draft)}\n onPress={onSubmit}\n testID=\"questionnaire-submit\"\n >\n submit answers\n </Button>\n </View>\n </View>\n );\n}\n\nfunction Questionnaire({\n questions,\n answer,\n cancel,\n}: {\n questions: readonly PromptQuestion[];\n answer: ToolPromptRenderProps['answer'];\n cancel: ToolPromptRenderProps['cancel'];\n}) {\n const [draft, setDraft] = useState(() => emptyDraft(questions.length));\n const [current, setCurrent] = useState(0);\n const [previewIndex, setPreviewIndex] = useState(0);\n const show = (index: number) => {\n setCurrent(index);\n setPreviewIndex(0);\n };\n return (\n <QuestionnaireView\n questions={questions}\n draft={draft}\n current={current}\n previewIndex={previewIndex}\n onDraft={(next, settles) => {\n setDraft(next);\n if (!settles) return;\n const pending = nextUnanswered(next, current);\n if (pending >= 0 && pending !== current) show(pending);\n }}\n onCurrent={show}\n onPreview={setPreviewIndex}\n onSubmit={() => {\n if (isComplete(draft)) answer(encodeAnswerEnvelope(draftAnswers(questions, draft)));\n }}\n onCancel={cancel}\n />\n );\n}\n\n/** The dialog identity owns the draft, so another session or request cannot inherit its answers. */\nexport function QuestionnairePrompt({ args, sessionId, dialog, answer, cancel }: ToolPromptRenderProps) {\n const questions = useMemo(() => readPromptQuestions(args), [args]);\n return (\n <Questionnaire\n key={`${sessionId}:${dialog.id}:${String(questions.length)}`}\n questions={questions}\n answer={answer}\n cancel={cancel}\n />\n );\n}\n\nconst styles = StyleSheet.create((theme) => ({\n frame: {\n maxHeight: '75%',\n flexShrink: 1,\n backgroundColor: theme.colors.rail,\n borderTopWidth: 1,\n borderColor: theme.colors['edge-magenta'],\n },\n steps: { gap: theme.spacing(2), padding: theme.spacing(3) },\n body: { flexShrink: 1 },\n content: { gap: theme.spacing(2), paddingHorizontal: theme.spacing(3), paddingBottom: theme.spacing(3) },\n question: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeightRelaxed.base,\n color: theme.colors.hi,\n },\n meta: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeightRelaxed.sm,\n color: theme.colors.dim,\n },\n option: {\n flexDirection: 'row',\n gap: theme.spacing(3),\n minHeight: 44,\n padding: theme.spacing(3),\n borderWidth: 1,\n borderColor: theme.colors['border-soft'],\n borderRadius: theme.borderRadius.md,\n },\n chosen: { borderColor: theme.colors['edge-magenta'], backgroundColor: theme.colors['tint-magenta'] },\n mark: { fontFamily: fontOf(theme.fontFamily.sans), fontSize: theme.fontSize.lg, color: theme.colors.dim },\n selectedInk: { color: theme.colors.magenta },\n optionText: { flex: 1, gap: theme.spacing(1) },\n label: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeightRelaxed.base,\n fontWeight: theme.fontWeight.semibold,\n color: theme.colors.text,\n },\n field: { gap: theme.spacing(2) },\n preview: {\n gap: theme.spacing(2),\n paddingLeft: theme.spacing(3),\n borderLeftWidth: 2,\n borderColor: theme.colors['edge-magenta'],\n },\n actions: {\n flexDirection: 'row',\n flexWrap: 'wrap',\n justifyContent: 'flex-end',\n gap: theme.spacing(2),\n padding: theme.spacing(3),\n borderTopWidth: 1,\n borderColor: theme.colors['border-soft'],\n },\n}));\n","import { defineToolRenderer } from '@agimon-ai/po-core/native';\n\nimport { AskUserQuestionToolMessage } from './_components/AskUserQuestionToolMessage.native';\nimport { QuestionnairePrompt } from './_components/QuestionnairePrompt.native';\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 { defineNativePlugin, type WebPluginContributions } from '@agimon-ai/po-core/native';\n\nimport toolAskUserQuestion from '../src/extensions/workspaces/sessions/(frontend)/tool/askUserQuestion.native';\n\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const nativePlugin = defineNativePlugin({\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,IA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AAMU,QAAQ,CAAC;EACpByB,aAAanC,MAAMU,QAAQ,CAAC;EAC5B0B,iBAAiB;EACjB7B,aAAaP,MAAMI,OAAO;EAAeI,mBAAA,CAAA,CAAA;CAC3C;CACAxB,SAAS;EACPwC,eAAe;EACfa,UAAU;EACVC,gBAAgB;EAChB7B,KAAKT,MAAMU,QAAQ,CAAC;EACpBC,SAASX,MAAMU,QAAQ,CAAC;EACxBJ,gBAAgB;EAChBC,aAAaP,MAAMI,OAAO;EAAcI,mBAAA,CAAA,CAAA;CAC1C;AACF,EAAE;;;ACnRF,IAAA,iCAAe,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,eAAe,mBAAmB;CAC7C,IAAI;CACJ,SAAS,EACP,IAAI,gBAAyD;EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,mBAAmB,EAAE,GAAG+B,8BAAmB,CAAC;CAAG,EACtI;AACF,CAAC"}
1
+ {"version":3,"file":"native.mjs","names":["isRecord","asString","ToolMessageRenderProps","fontOf","MessageItem","MessageItemBody","MessageItemHeader","MessageItemStatus","toolTone","StyleSheet","askCallSummary","askResultView","AskUserQuestionToolMessage","props","summary","args","view","result","details","output","count","headers","running","kind","answers","length","styles","map","answer","index","String","question","text","check","prompt","isError","error","undefined","create","theme","gap","spacing","uni__dependencies","fontFamily","sans","fontSize","base","lineHeight","lineHeightRelaxed","color","colors","dim","green","cyan","red","styles","ToolPromptRenderProps","Button","ChevronDownIcon","ChevronRightIcon","fontOf","Markdown","SectionLabel","selectionTick","Textarea","useMemo","useState","StyleSheet","encodeAnswerEnvelope","chooseOption","CUSTOM_LABEL","draftAnswers","draftEntry","emptyDraft","isAnswered","isComplete","nextUnanswered","PromptQuestion","QuestionnaireDraft","readPromptQuestions","setCustom","setNotes","QuestionnaireViewProps","questions","draft","current","previewIndex","collapsed","onDraft","settles","onCurrent","index","onPreview","onCollapsed","onSubmit","onCancel","QuestionnaireView","props","question","entry","preview","options","styles","frame","header","stepBar","steps","map","step","String","expanded","body","content","meta","length","multiSelect","option","chosen","custom","selected","includes","label","description","mark","selectedInk","optionText","field","value","notes","actions","Questionnaire","answer","cancel","setDraft","setCurrent","setPreviewIndex","setCollapsed","show","next","pending","QuestionnairePrompt","args","sessionId","dialog","id","create","theme","maxHeight","flexShrink","backgroundColor","colors","rail","borderTopWidth","borderColor","uni__dependencies","flexDirection","alignItems","paddingRight","spacing","flex","gap","padding","paddingHorizontal","paddingBottom","fontFamily","sans","fontSize","base","lineHeight","lineHeightRelaxed","color","hi","sm","dim","minHeight","borderWidth","borderRadius","md","lg","magenta","fontWeight","semibold","text","paddingLeft","borderLeftWidth","flexWrap","justifyContent","toolAskUserQuestion"],"sources":["../../src/extensions/workspaces/sessions/(frontend)/tool/_lib/askUserText.ts","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/AskUserQuestionToolMessage.native.tsx","../../src/types/askUserWire.ts","../../src/extensions/workspaces/sessions/(frontend)/tool/_lib/questionnaireDraft.ts","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/QuestionnairePrompt.native.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/askUserQuestion.native.tsx","../../generated/native.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/native';\nimport {\n fontOf,\n MessageItem,\n MessageItemBody,\n MessageItemHeader,\n MessageItemStatus,\n toolTone,\n} from '@agimon-ai/po-native-components';\nimport { Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { askCallSummary, askResultView } from '../_lib/askUserText';\n\nexport function AskUserQuestionToolMessage(props: ToolMessageRenderProps) {\n const summary = askCallSummary(props.args);\n const view = askResultView(props.result?.details, props.output);\n return (\n <MessageItem tone={toolTone(props)}>\n <MessageItemHeader title=\"ask_user_question\">{`${summary.count}${summary.headers ? ` (${summary.headers})` : ''}`}</MessageItemHeader>\n <MessageItemBody testID=\"tool-result-ask_user_question\">\n {props.running ? (\n <MessageItemStatus tone=\"running\">running</MessageItemStatus>\n ) : view.kind === 'cancelled' ? (\n <MessageItemStatus tone=\"running\">cancelled</MessageItemStatus>\n ) : view.kind === 'answers' ? (\n view.answers.length === 0 ? (\n <MessageItemStatus tone=\"ok\">submitted</MessageItemStatus>\n ) : (\n <View style={styles.answers}>\n {view.answers.map((answer, index) => (\n <Text key={`${String(index)}:${answer.question}`} style={styles.text}>\n <Text style={styles.check}>✓ </Text>\n <Text style={styles.question}>{answer.question}</Text>: {answer.answer}\n </Text>\n ))}\n </View>\n )\n ) : view.kind === 'voice' ? (\n <Text style={styles.text}>{view.prompt}</Text>\n ) : view.text ? (\n <Text\n style={[styles.text, props.isError && styles.error]}\n accessibilityRole={props.isError ? 'alert' : undefined}\n >\n {view.text}\n </Text>\n ) : (\n <MessageItemStatus tone={props.isError ? 'error' : 'ok'}>\n {props.isError ? 'failed' : 'submitted'}\n </MessageItemStatus>\n )}\n </MessageItemBody>\n </MessageItem>\n );\n}\n\nconst styles = StyleSheet.create((theme) => ({\n answers: { gap: theme.spacing(2) },\n text: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeightRelaxed.base,\n color: theme.colors.dim,\n },\n check: { color: theme.colors.green },\n question: { color: theme.colors.cyan },\n error: { color: theme.colors.red },\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 = 'po-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/native';\nimport {\n Button,\n ChevronDownIcon,\n ChevronRightIcon,\n fontOf,\n Markdown,\n SectionLabel,\n selectionTick,\n Textarea,\n} from '@agimon-ai/po-native-components';\nimport { useMemo, useState } from 'react';\nimport { Pressable, ScrollView, Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\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\nexport interface QuestionnaireViewProps {\n questions: readonly PromptQuestion[];\n draft: QuestionnaireDraft;\n current: number;\n previewIndex: number;\n /** Folded down to the step bar so the conversation above can be read; the draft stays. */\n collapsed: boolean;\n onDraft: (draft: QuestionnaireDraft, settles: boolean) => void;\n onCurrent: (index: number) => void;\n onPreview: (index: number) => void;\n onCollapsed: (collapsed: boolean) => void;\n onSubmit: () => void;\n onCancel: () => void;\n}\n\n/** Pure presentation for the approved-target stories and the native prompt host. */\nexport function QuestionnaireView(props: QuestionnaireViewProps) {\n const {\n questions,\n draft,\n current,\n previewIndex,\n collapsed,\n onDraft,\n onCurrent,\n onPreview,\n onCollapsed,\n onSubmit,\n onCancel,\n } = props;\n const question = questions[current];\n const entry = draftEntry(draft, current);\n const preview = question?.options[previewIndex]?.preview;\n return (\n <View style={styles.frame} testID=\"questionnaire\">\n <View style={styles.header}>\n <ScrollView\n horizontal\n style={styles.stepBar}\n contentContainerStyle={styles.steps}\n accessibilityLabel=\"Questions\"\n >\n {questions.map((step, index) => (\n <Button\n key={`${String(index)}:${step.question}`}\n size=\"card\"\n variant={index === current ? 'secondary' : 'ghost'}\n aria-selected={index === current}\n accessibilityLabel={`${step.header || `Question ${String(index + 1)}`}, ${isAnswered(draftEntry(draft, index)) ? 'answered' : 'not answered'}`}\n testID={`questionnaire-step-${String(index)}`}\n onPress={() => {\n selectionTick();\n onCurrent(index);\n }}\n >\n {`${isAnswered(draftEntry(draft, index)) ? '✓ ' : ''}${step.header || `Question ${String(index + 1)}`}`}\n </Button>\n ))}\n </ScrollView>\n <Button\n variant=\"ghost\"\n size=\"icon\"\n accessibilityLabel={collapsed ? 'expand' : 'collapse'}\n accessibilityState={{ expanded: !collapsed }}\n accessibilityHint={collapsed ? 'show the questions again' : 'fold away to read the conversation'}\n testID=\"questionnaire-collapse\"\n onPress={() => onCollapsed(!collapsed)}\n >\n {collapsed ? <ChevronRightIcon size={16} color=\"dim\" /> : <ChevronDownIcon size={16} color=\"dim\" />}\n </Button>\n </View>\n {collapsed ? null : (\n <>\n <ScrollView style={styles.body} contentContainerStyle={styles.content} keyboardShouldPersistTaps=\"handled\">\n {question ? (\n <>\n <Text style={styles.meta}>\n Question {current + 1} / {questions.length}\n {question.multiSelect ? ' · Choose any that fit' : ''}\n </Text>\n <Text style={styles.question} testID=\"questionnaire-question\">\n {question.question}\n </Text>\n {question.options.map((option, index) => {\n const chosen = entry.custom === null && entry.selected.includes(option.label);\n return (\n <Pressable\n key={`${String(index)}:${option.label}`}\n accessibilityRole={question.multiSelect ? 'checkbox' : 'radio'}\n aria-checked={chosen}\n accessibilityLabel={option.label}\n accessibilityHint={option.description}\n testID={`questionnaire-option-${String(index)}`}\n style={[styles.option, chosen && styles.chosen]}\n onFocus={() => onPreview(index)}\n onPress={() => {\n selectionTick();\n onPreview(index);\n onDraft(\n chooseOption(draft, current, option.label, question.multiSelect),\n !question.multiSelect,\n );\n }}\n >\n <Text style={[styles.mark, chosen && styles.selectedInk]}>\n {question.multiSelect ? (chosen ? '☑' : '☐') : chosen ? '●' : '○'}\n </Text>\n <View style={styles.optionText}>\n <Text style={styles.label}>{option.label}</Text>\n {option.description ? <Text style={styles.meta}>{option.description}</Text> : null}\n </View>\n </Pressable>\n );\n })}\n <Button\n variant={entry.custom === null ? 'ghost' : 'secondary'}\n size=\"card\"\n testID=\"questionnaire-option-custom\"\n onPress={() => onDraft(setCustom(draft, current, entry.custom ?? ''), false)}\n >\n {CUSTOM_LABEL}\n </Button>\n {entry.custom !== null ? (\n <View style={styles.field}>\n <SectionLabel>Your answer</SectionLabel>\n <Textarea\n autoFocus\n rows={2}\n accessibilityLabel=\"Your answer\"\n testID=\"questionnaire-custom\"\n value={entry.custom}\n placeholder=\"type your answer…\"\n onChangeText={(value) => onDraft(setCustom(draft, current, value), false)}\n />\n </View>\n ) : null}\n {preview && entry.custom === null ? (\n <View style={styles.preview} testID=\"questionnaire-preview\">\n <SectionLabel>Preview</SectionLabel>\n <Markdown text={preview} />\n </View>\n ) : null}\n <View style={styles.field}>\n <SectionLabel>Note (optional)</SectionLabel>\n <Textarea\n rows={1}\n accessibilityLabel=\"Note (optional)\"\n testID=\"questionnaire-notes\"\n value={entry.notes}\n placeholder=\"anything the options do not cover\"\n onChangeText={(value) => onDraft(setNotes(draft, current, value), false)}\n />\n </View>\n </>\n ) : (\n <Text style={styles.meta}>the agent asked something this cockpit could not read</Text>\n )}\n </ScrollView>\n <View style={styles.actions}>\n {questions.length > 1 && !isComplete(draft) ? (\n <Button\n size=\"card\"\n disabled={!isAnswered(entry)}\n onPress={() => onDraft(draft, true)}\n testID=\"questionnaire-next\"\n >\n Next question\n </Button>\n ) : null}\n <Button size=\"card\" onPress={onCancel} testID=\"questionnaire-cancel\">\n cancel\n </Button>\n <Button\n size=\"card\"\n variant=\"primary\"\n disabled={!isComplete(draft)}\n onPress={onSubmit}\n testID=\"questionnaire-submit\"\n >\n submit answers\n </Button>\n </View>\n </>\n )}\n </View>\n );\n}\n\nfunction Questionnaire({\n questions,\n answer,\n cancel,\n}: {\n questions: readonly PromptQuestion[];\n answer: ToolPromptRenderProps['answer'];\n cancel: ToolPromptRenderProps['cancel'];\n}) {\n const [draft, setDraft] = useState(() => emptyDraft(questions.length));\n const [current, setCurrent] = useState(0);\n const [previewIndex, setPreviewIndex] = useState(0);\n const [collapsed, setCollapsed] = useState(false);\n const show = (index: number) => {\n setCurrent(index);\n setPreviewIndex(0);\n setCollapsed(false);\n };\n return (\n <QuestionnaireView\n questions={questions}\n draft={draft}\n current={current}\n previewIndex={previewIndex}\n collapsed={collapsed}\n onDraft={(next, settles) => {\n setDraft(next);\n if (!settles) return;\n const pending = nextUnanswered(next, current);\n if (pending >= 0 && pending !== current) show(pending);\n }}\n onCurrent={show}\n onPreview={setPreviewIndex}\n onCollapsed={setCollapsed}\n onSubmit={() => {\n if (isComplete(draft)) answer(encodeAnswerEnvelope(draftAnswers(questions, draft)));\n }}\n onCancel={cancel}\n />\n );\n}\n\n/** The dialog identity owns the draft, so another session or request cannot inherit its answers. */\nexport function QuestionnairePrompt({ args, sessionId, dialog, answer, cancel }: ToolPromptRenderProps) {\n const questions = useMemo(() => readPromptQuestions(args), [args]);\n return (\n <Questionnaire\n key={`${sessionId}:${dialog.id}:${String(questions.length)}`}\n questions={questions}\n answer={answer}\n cancel={cancel}\n />\n );\n}\n\nconst styles = StyleSheet.create((theme) => ({\n frame: {\n maxHeight: '75%',\n flexShrink: 1,\n backgroundColor: theme.colors.rail,\n borderTopWidth: 1,\n borderColor: theme.colors['edge-magenta'],\n },\n header: { flexDirection: 'row', alignItems: 'center', paddingRight: theme.spacing(3) },\n stepBar: { flex: 1 },\n steps: { gap: theme.spacing(2), padding: theme.spacing(3) },\n body: { flexShrink: 1 },\n content: { gap: theme.spacing(2), paddingHorizontal: theme.spacing(3), paddingBottom: theme.spacing(3) },\n question: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeightRelaxed.base,\n color: theme.colors.hi,\n },\n meta: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeightRelaxed.sm,\n color: theme.colors.dim,\n },\n option: {\n flexDirection: 'row',\n gap: theme.spacing(3),\n minHeight: 44,\n padding: theme.spacing(3),\n borderWidth: 1,\n borderColor: theme.colors['border-soft'],\n borderRadius: theme.borderRadius.md,\n },\n chosen: { borderColor: theme.colors['edge-magenta'], backgroundColor: theme.colors['tint-magenta'] },\n mark: { fontFamily: fontOf(theme.fontFamily.sans), fontSize: theme.fontSize.lg, color: theme.colors.dim },\n selectedInk: { color: theme.colors.magenta },\n optionText: { flex: 1, gap: theme.spacing(1) },\n label: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeightRelaxed.base,\n fontWeight: theme.fontWeight.semibold,\n color: theme.colors.text,\n },\n field: { gap: theme.spacing(2) },\n preview: {\n gap: theme.spacing(2),\n paddingLeft: theme.spacing(3),\n borderLeftWidth: 2,\n borderColor: theme.colors['edge-magenta'],\n },\n actions: {\n flexDirection: 'row',\n flexWrap: 'wrap',\n justifyContent: 'flex-end',\n gap: theme.spacing(2),\n padding: theme.spacing(3),\n borderTopWidth: 1,\n borderColor: theme.colors['border-soft'],\n },\n}));\n","import { defineToolRenderer } from '@agimon-ai/po-core/native';\n\nimport { AskUserQuestionToolMessage } from './_components/AskUserQuestionToolMessage.native';\nimport { QuestionnairePrompt } from './_components/QuestionnairePrompt.native';\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 { defineNativePlugin, type WebPluginContributions } from '@agimon-ai/po-core/native';\n\nimport toolAskUserQuestion from '../src/extensions/workspaces/sessions/(frontend)/tool/askUserQuestion.native';\n\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const nativePlugin = defineNativePlugin({\n id: 'ask-user',\n session: {\n get toolRenderers(): WebPluginContributions['toolRenderers'] { return [via({ tools: ['ask_user_question'] }, toolAskUserQuestion)]; },\n },\n});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AC/BtD,SAAS;EACP4D,KAAKd,MAAMY,QAAQ,CAAC;EACpByB,aAAarC,MAAMY,QAAQ,CAAC;EAC5B0B,iBAAiB;EACjB/B,aAAaP,MAAMI,OAAO;EAAeI,mBAAA,CAAA,CAAA;CAC3C;CACAzB,SAAS;EACP0B,eAAe;EACf8B,UAAU;EACVC,gBAAgB;EAChB1B,KAAKd,MAAMY,QAAQ,CAAC;EACpBG,SAASf,MAAMY,QAAQ,CAAC;EACxBN,gBAAgB;EAChBC,aAAaP,MAAMI,OAAO;EAAcI,mBAAA,CAAA,CAAA;CAC1C;AACF,EAAE;;;AC1UF,IAAA,iCAAe,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,eAAe,mBAAmB;CAC7C,IAAI;CACJ,SAAS,EACP,IAAI,gBAAyD;EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,mBAAmB,EAAE,GAAGiC,8BAAmB,CAAC;CAAG,EACtI;AACF,CAAC"}
@@ -1,7 +1,8 @@
1
- import { defineToolRenderer, defineWebPlugin } from "@agimon-ai/po-core/web";
2
- import { Badge, Button, Kbd, Markdown, MessageItem, MessageItemBody, MessageItemHeader, MessageItemStatus, OptionLabel, OptionRow, SectionLabel, Separator, Textarea, toolTone } from "@agimon-ai/po-web-components";
3
- import { jsx, jsxs } from "react/jsx-runtime";
4
- import { useEffect, useMemo, useRef, useState } from "react";
1
+ import { defineToolRenderer, defineWebPlugin, sessionApiPath } from "@agimon-ai/po-core/web";
2
+ import { Badge, Button, ChevronDownIcon, ChevronUpIcon, Kbd, Markdown, MessageItem, MessageItemBody, MessageItemHeader, MessageItemStatus, OptionLabel, OptionRow, SectionLabel, Separator, Textarea, toolTone } from "@agimon-ai/po-web-components";
3
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
+ import { sealedTransport } from "@agimon-ai/po-web-security/browser";
5
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
5
6
  //#region src/extensions/workspaces/sessions/(frontend)/tool/_lib/askUserText.ts
6
7
  function isRecord$1(value) {
7
8
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -289,6 +290,21 @@ function draftAnswers(questions, draft) {
289
290
  }
290
291
  //#endregion
291
292
  //#region src/extensions/workspaces/sessions/(frontend)/tool/_components/QuestionnairePrompt.tsx
293
+ /**
294
+ * A preview's local image is a file in the session's working directory, which
295
+ * the browser cannot read by path. The host's sealed file route serves it and
296
+ * keeps the containment check.
297
+ */
298
+ async function loadPreviewImage(sessionId, path) {
299
+ if (sessionId === null) throw new Error("The session is unavailable.");
300
+ const response = await sealedTransport.fetch(`${sessionApiPath(sessionId)}/file?path=${encodeURIComponent(path)}`, { cache: "no-store" });
301
+ if (!response.ok) throw new Error(`Image could not be loaded (${String(response.status)}).`);
302
+ const url = URL.createObjectURL(await response.blob());
303
+ return {
304
+ url,
305
+ dispose: () => URL.revokeObjectURL(url)
306
+ };
307
+ }
292
308
  /** The step bar: which questions are answered, which one is open, and a click back to any of them. */
293
309
  function StepBar({ questions, draft, current, onPick }) {
294
310
  return /* @__PURE__ */ jsx("div", {
@@ -329,7 +345,7 @@ function fieldKeys(commit) {
329
345
  };
330
346
  }
331
347
  /** One question's options, its typed-answer row, and the preview of whatever is focused. */
332
- function QuestionBody({ question, index, draft, cursor, onCursor, onDraft, onCommit }) {
348
+ function QuestionBody({ question, index, draft, cursor, onCursor, onDraft, onCommit, loadImage }) {
333
349
  const entry = draftEntry(draft, index);
334
350
  const typing = entry.custom !== null;
335
351
  const option = question.options[cursor];
@@ -429,7 +445,10 @@ function QuestionBody({ question, index, draft, cursor, onCursor, onDraft, onCom
429
445
  children: typing ? "Your answer" : option?.label
430
446
  }), /* @__PURE__ */ jsx("div", {
431
447
  className: "min-w-0 overflow-auto text-base text-po-text",
432
- children: preview ? /* @__PURE__ */ jsx(Markdown, { text: preview }) : /* @__PURE__ */ jsx("p", {
448
+ children: preview ? /* @__PURE__ */ jsx(Markdown, {
449
+ text: preview,
450
+ loadImage
451
+ }) : /* @__PURE__ */ jsx("p", {
433
452
  className: "text-sm text-po-dim",
434
453
  children: typing ? "Describe your own direction in the answer field." : "No preview for this option."
435
454
  })
@@ -448,16 +467,19 @@ function QuestionBody({ question, index, draft, cursor, onCursor, onDraft, onCom
448
467
  * submits, so going back to a step is just moving a cursor, and the agent is
449
468
  * asked exactly once.
450
469
  */
451
- function QuestionnairePrompt({ args, dialog, answer, cancel }) {
470
+ function QuestionnairePrompt({ args, dialog, answer, cancel, sessionId }) {
452
471
  const questions = useMemo(() => readPromptQuestions(args), [args]);
453
472
  const [draft, setDraft] = useState(() => emptyDraft(questions.length));
454
473
  const [current, setCurrent] = useState(0);
455
474
  const [cursor, setCursor] = useState(0);
475
+ const [collapsed, setCollapsed] = useState(false);
456
476
  const frame = useRef(null);
477
+ const loadImage = useCallback((path) => loadPreviewImage(sessionId, path), [sessionId]);
457
478
  useEffect(() => {
458
479
  setDraft(emptyDraft(questions.length));
459
480
  setCurrent(0);
460
481
  setCursor(0);
482
+ setCollapsed(false);
461
483
  }, [dialog.id, questions.length]);
462
484
  useEffect(() => frame.current?.focus(), [dialog.id]);
463
485
  const question = questions[current];
@@ -475,6 +497,7 @@ function QuestionnairePrompt({ args, dialog, answer, cancel }) {
475
497
  const show = (index) => {
476
498
  setCurrent(index);
477
499
  setCursor(0);
500
+ setCollapsed(false);
478
501
  };
479
502
  const submit = () => {
480
503
  if (!complete) return;
@@ -501,6 +524,7 @@ function QuestionnairePrompt({ args, dialog, answer, cancel }) {
501
524
  "data-testid": "questionnaire",
502
525
  className: "flex min-w-0 flex-col overflow-hidden bg-po-bg outline-none",
503
526
  onKeyDown: (event) => {
527
+ if (collapsed) return;
504
528
  if (event.key === "Escape") {
505
529
  event.preventDefault();
506
530
  cancel();
@@ -534,29 +558,39 @@ function QuestionnairePrompt({ args, dialog, answer, cancel }) {
534
558
  move(chooseOption(draft, current, option.label, question.multiSelect), current, !question.multiSelect);
535
559
  }
536
560
  },
537
- children: [
538
- /* @__PURE__ */ jsxs("div", {
539
- 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",
540
- children: [
541
- /* @__PURE__ */ jsx(StepBar, {
542
- questions,
543
- draft,
544
- current,
545
- onPick: show
546
- }),
547
- /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1" }),
548
- /* @__PURE__ */ jsxs(Badge, {
549
- size: "xs",
550
- className: "shrink-0 border-transparent bg-po-panel py-0.5 text-po-dim",
551
- children: [
552
- "question ",
553
- current + 1,
554
- " / ",
555
- questions.length
556
- ]
557
- })
558
- ]
559
- }),
561
+ children: [/* @__PURE__ */ jsxs("div", {
562
+ 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",
563
+ children: [
564
+ /* @__PURE__ */ jsx(StepBar, {
565
+ questions,
566
+ draft,
567
+ current,
568
+ onPick: show
569
+ }),
570
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1" }),
571
+ /* @__PURE__ */ jsxs(Badge, {
572
+ size: "xs",
573
+ className: "shrink-0 border-transparent bg-po-panel py-0.5 text-po-dim",
574
+ children: [
575
+ "question ",
576
+ current + 1,
577
+ " / ",
578
+ questions.length
579
+ ]
580
+ }),
581
+ /* @__PURE__ */ jsx(Button, {
582
+ variant: "ghost",
583
+ size: "icon",
584
+ "data-testid": "questionnaire-collapse",
585
+ "aria-expanded": !collapsed,
586
+ "aria-label": collapsed ? "expand" : "collapse",
587
+ title: collapsed ? "show the questions again" : "fold away to read the conversation",
588
+ onClick: () => setCollapsed(!collapsed),
589
+ className: "shrink-0 text-po-dim hover:text-po-blue",
590
+ children: collapsed ? /* @__PURE__ */ jsx(ChevronUpIcon, { className: "size-4" }) : /* @__PURE__ */ jsx(ChevronDownIcon, { className: "size-4" })
591
+ })
592
+ ]
593
+ }), collapsed ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
560
594
  /* @__PURE__ */ jsx(Separator, {}),
561
595
  /* @__PURE__ */ jsx("div", {
562
596
  className: "max-h-[65vh] min-w-0 overflow-x-hidden overflow-y-auto px-3 py-3 sm:px-3.5",
@@ -566,6 +600,7 @@ function QuestionnairePrompt({ args, dialog, answer, cancel }) {
566
600
  draft,
567
601
  cursor,
568
602
  onCursor: setCursor,
603
+ loadImage,
569
604
  onDraft: (next, settles) => move(next, current, settles),
570
605
  onCommit: (settles) => {
571
606
  frame.current?.focus();
@@ -613,7 +648,7 @@ function QuestionnairePrompt({ args, dialog, answer, cancel }) {
613
648
  })
614
649
  ]
615
650
  })
616
- ]
651
+ ] })]
617
652
  });
618
653
  }
619
654
  //#endregion
@@ -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/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 <MessageItemStatus tone=\"running\">running</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-po-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-po-red' : 'text-po-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-po-green\">✓</span> <span className=\"text-po-cyan\">{answer.question}</span>:{' '}\n <span className=\"text-po-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-po-hi\">{summary.count}</span>\n {summary.headers ? <span className=\"min-w-0 truncate text-po-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 = 'po-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-po-selected font-semibold text-po-on-selected'\n : answered\n ? 'text-po-green hover:bg-po-panel'\n : 'text-po-faint hover:bg-po-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 option = question.options[cursor];\n const preview = typing ? undefined : option?.preview;\n const hasPreviews = question.options.some((item) => item.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-po-hi\">\n {question.question}\n </p>\n {hasPreviews ? (\n <p className=\"text-sm text-po-dim\">Choose a concept to see its preview. Nothing is sent until you submit.</p>\n ) : null}\n <div className={hasPreviews ? 'grid min-w-0 gap-4 md:grid-cols-3' : 'min-w-0'}>\n <div className=\"flex min-w-0 flex-col gap-3\">\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 onFocus={() => onCursor(optionIndex)}\n onClick={() => {\n onCursor(optionIndex);\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-po-green' : 'text-po-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-po-hi' : 'text-po-text'}`}\n >\n {option.label}\n </span>\n {option.description ? (\n <span className=\"break-words text-sm leading-relaxed whitespace-normal text-po-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-po-faint\">✎</span>\n <OptionLabel className=\"min-w-0 whitespace-normal text-po-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 <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 {hasPreviews ? (\n <section\n data-testid=\"questionnaire-preview\"\n aria-label=\"Concept preview\"\n className=\"flex min-w-0 flex-col gap-3 rounded-md border border-po-border bg-po-bg p-3 md:col-span-2\"\n >\n <h3 className=\"text-base font-semibold text-po-hi\">{typing ? 'Your answer' : option?.label}</h3>\n <div className=\"min-w-0 overflow-auto text-base text-po-text\">\n {preview ? (\n <Markdown text={preview} />\n ) : (\n <p className=\"text-sm text-po-dim\">\n {typing ? 'Describe your own direction in the answer field.' : 'No preview for this option.'}\n </p>\n )}\n </div>\n </section>\n ) : null}\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 // Preview choices stay open so the reader can compare before moving on.\n if (questions[answeredIndex]?.options.some((option) => option.preview)) return;\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-po-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 bg-po-bg 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-po-panel py-0.5 text-po-dim\">\n question {current + 1} / {questions.length}\n </Badge>\n </div>\n\n <Separator />\n\n <div className=\"max-h-[65vh] 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-po-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,OAA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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"}
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 <MessageItemStatus tone=\"running\">running</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-po-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-po-red' : 'text-po-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-po-green\">✓</span> <span className=\"text-po-cyan\">{answer.question}</span>:{' '}\n <span className=\"text-po-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-po-hi\">{summary.count}</span>\n {summary.headers ? <span className=\"min-w-0 truncate text-po-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 = 'po-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 { sessionApiPath, type ToolPromptRenderProps } from '@agimon-ai/po-core/web';\nimport {\n Badge,\n Button,\n ChevronDownIcon,\n ChevronUpIcon,\n Kbd,\n Markdown,\n OptionLabel,\n OptionRow,\n SectionLabel,\n Separator,\n Textarea,\n} from '@agimon-ai/po-web-components';\nimport { sealedTransport } from '@agimon-ai/po-web-security/browser';\nimport { type KeyboardEvent, useCallback, 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/**\n * A preview's local image is a file in the session's working directory, which\n * the browser cannot read by path. The host's sealed file route serves it and\n * keeps the containment check.\n */\nasync function loadPreviewImage(sessionId: string | null, path: string) {\n if (sessionId === null) throw new Error('The session is unavailable.');\n const response = await sealedTransport.fetch(`${sessionApiPath(sessionId)}/file?path=${encodeURIComponent(path)}`, {\n cache: 'no-store',\n });\n if (!response.ok) throw new Error(`Image could not be loaded (${String(response.status)}).`);\n const url = URL.createObjectURL(await response.blob());\n return { url, dispose: () => URL.revokeObjectURL(url) };\n}\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-po-selected font-semibold text-po-on-selected'\n : answered\n ? 'text-po-green hover:bg-po-panel'\n : 'text-po-faint hover:bg-po-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 loadImage,\n}: {\n question: PromptQuestion;\n index: number;\n draft: QuestionnaireDraft;\n cursor: number;\n onCursor: (cursor: number) => void;\n loadImage: (path: string) => ReturnType<typeof loadPreviewImage>;\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 option = question.options[cursor];\n const preview = typing ? undefined : option?.preview;\n const hasPreviews = question.options.some((item) => item.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-po-hi\">\n {question.question}\n </p>\n {hasPreviews ? (\n <p className=\"text-sm text-po-dim\">Choose a concept to see its preview. Nothing is sent until you submit.</p>\n ) : null}\n <div className={hasPreviews ? 'grid min-w-0 gap-4 md:grid-cols-3' : 'min-w-0'}>\n <div className=\"flex min-w-0 flex-col gap-3\">\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 onFocus={() => onCursor(optionIndex)}\n onClick={() => {\n onCursor(optionIndex);\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-po-green' : 'text-po-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-po-hi' : 'text-po-text'}`}\n >\n {option.label}\n </span>\n {option.description ? (\n <span className=\"break-words text-sm leading-relaxed whitespace-normal text-po-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-po-faint\">✎</span>\n <OptionLabel className=\"min-w-0 whitespace-normal text-po-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 <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 {hasPreviews ? (\n <section\n data-testid=\"questionnaire-preview\"\n aria-label=\"Concept preview\"\n className=\"flex min-w-0 flex-col gap-3 rounded-md border border-po-border bg-po-bg p-3 md:col-span-2\"\n >\n <h3 className=\"text-base font-semibold text-po-hi\">{typing ? 'Your answer' : option?.label}</h3>\n <div className=\"min-w-0 overflow-auto text-base text-po-text\">\n {preview ? (\n <Markdown text={preview} loadImage={loadImage} />\n ) : (\n <p className=\"text-sm text-po-dim\">\n {typing ? 'Describe your own direction in the answer field.' : 'No preview for this option.'}\n </p>\n )}\n </div>\n </section>\n ) : null}\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, sessionId }: 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 // Folded down to the step bar so the reader can scroll the conversation the\n // question is about, then open it again with every draft answer intact.\n const [collapsed, setCollapsed] = useState(false);\n const frame = useRef<HTMLDivElement>(null);\n const loadImage = useCallback((path: string) => loadPreviewImage(sessionId, path), [sessionId]);\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 setCollapsed(false);\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 // Preview choices stay open so the reader can compare before moving on.\n if (questions[answeredIndex]?.options.some((option) => option.preview)) return;\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 setCollapsed(false);\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-po-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 bg-po-bg outline-none\"\n onKeyDown={(event) => {\n // Nothing is on screen to act on, so no key may change the answers unseen.\n if (collapsed) return;\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-po-panel py-0.5 text-po-dim\">\n question {current + 1} / {questions.length}\n </Badge>\n <Button\n variant=\"ghost\"\n size=\"icon\"\n data-testid=\"questionnaire-collapse\"\n aria-expanded={!collapsed}\n aria-label={collapsed ? 'expand' : 'collapse'}\n title={collapsed ? 'show the questions again' : 'fold away to read the conversation'}\n onClick={() => setCollapsed(!collapsed)}\n className=\"shrink-0 text-po-dim hover:text-po-blue\"\n >\n {collapsed ? <ChevronUpIcon className=\"size-4\" /> : <ChevronDownIcon className=\"size-4\" />}\n </Button>\n </div>\n\n {collapsed ? null : (\n <>\n <Separator />\n\n <div className=\"max-h-[65vh] 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 loadImage={loadImage}\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-po-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 </>\n )}\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({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,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;;EACL,EAAA,CAAA,CAED;;AAET;;;AC1aA,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/po-user-feedback",
3
- "version": "0.0.0-alpha.20",
3
+ "version": "0.0.0-alpha.22",
4
4
  "description": "Structured user questions with interactive and autonomous Voice handoff for Pi agents.",
5
5
  "keywords": [
6
6
  "ai",
@@ -18,7 +18,7 @@
18
18
  "bugs": {
19
19
  "url": "https://github.com/AgiFlow/po/issues"
20
20
  },
21
- "license": "MIT",
21
+ "license": "BUSL-1.1",
22
22
  "author": "Vuong Ngo",
23
23
  "repository": {
24
24
  "type": "git",
@@ -66,16 +66,17 @@
66
66
  "access": "public"
67
67
  },
68
68
  "dependencies": {
69
- "@agimon-ai/po-core": "0.0.0-alpha.20",
70
- "@agimon-ai/po-minor-mode": "0.0.0-alpha.20",
71
- "@agimon-ai/po-web-components": "0.0.0-alpha.20",
69
+ "@agimon-ai/po-core": "0.0.0-alpha.22",
70
+ "@agimon-ai/po-minor-mode": "0.0.0-alpha.22",
71
+ "@agimon-ai/po-web-components": "0.0.0-alpha.22",
72
+ "@agimon-ai/po-web-security": "0.0.0-alpha.22",
72
73
  "@deepseek-ai/cordis": "4.0.5",
73
74
  "typebox": "1.3.37"
74
75
  },
75
76
  "devDependencies": {
76
- "@agimon-ai/po-build": "0.0.0-alpha.20",
77
- "@agimon-ai/po-native-components": "0.0.0-alpha.20",
78
- "@agimon-ai/po-voice": "0.0.0-alpha.20",
77
+ "@agimon-ai/po-build": "0.0.0-alpha.22",
78
+ "@agimon-ai/po-native-components": "0.0.0-alpha.22",
79
+ "@agimon-ai/po-voice": "0.0.0-alpha.22",
79
80
  "@earendil-works/pi-coding-agent": "1.3.0",
80
81
  "@tanstack/react-store": "0.11.2",
81
82
  "@tanstack/store": "0.11.2",
@@ -91,7 +92,7 @@
91
92
  "vitest": "5.0.4"
92
93
  },
93
94
  "peerDependencies": {
94
- "@agimon-ai/po-native-components": "0.0.0-alpha.20",
95
+ "@agimon-ai/po-native-components": "0.0.0-alpha.22",
95
96
  "@earendil-works/pi-coding-agent": "1.3.0",
96
97
  "react-native": "0.86.3",
97
98
  "react-native-unistyles": "^3.5.3"