@xyz-agent/extension-protocol 0.3.0 → 0.3.1-dev.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -195,6 +195,8 @@ interface AskUserQuestion {
195
195
  * - 有 options 时:默认 true,前端在选项末尾追加 Other 输入框;设 false 则不追加
196
196
  * - 无 options 时:整个问题就是自由输入,此字段被忽略 */
197
197
  allowOther?: boolean;
198
+ /** 是否允许附加评论。选中后可追加短文本(4.0.1 restore:0.3.0 误删导致 pi-ask-user@4.0.0 ESM import 崩溃,见 .changeset/restore-ask-user-comment.md) */
199
+ allowComment?: boolean;
198
200
  }
199
201
  interface AskUserOption {
200
202
  /** 显示标签 */
@@ -212,10 +214,12 @@ interface AskUserOption {
212
214
  * - 多选:value = JSON.stringify(选中项 value 数组),如 '["pg","mysql"]'
213
215
  * (不用逗号 join——option value 可能含逗号导致 split 歧义)
214
216
  * - Other 文本:单独 key `${header}__other`,value = 自由文本(不混进选中项数组)
217
+ * - comment:单独 key `${header}__comment`,value = 评论文本
215
218
  *
216
219
  * extension 解析示例:
217
220
  * const selected = JSON.parse(answers[header]) // 多选 → string[]
218
221
  * const other = answers[`${header}__other`] // Other 自由文本
222
+ * const comment = answers[`${header}__comment`] // 评论
219
223
  */
220
224
  type AskUserAnswers = Record<string, string>;
221
225
 
@@ -262,10 +266,12 @@ declare function askUserInteract(ctx: GuiContext, questions: AskUserQuestion[],
262
266
  declare function getAskUserAnswer(answers: AskUserAnswers, question: AskUserQuestion): string | string[] | undefined;
263
267
  /** 从 answers 中提取 Other 自由文本 */
264
268
  declare function getAskUserOther(answers: AskUserAnswers, question: AskUserQuestion): string | undefined;
269
+ /** 从 answers 中提取评论(4.0.1 restore:ask-user TUI 评论模式与 renderer AskUserOverlay 仍消费此 helper) */
270
+ declare function getAskUserComment(answers: AskUserAnswers, question: AskUserQuestion): string | undefined;
265
271
  /**
266
272
  * 类型守卫:验证 unknown 是否为合法的 AskUserQuestion。
267
273
  * 用于前端从 runtime 透传的 askUserQuestions(unknown[])中安全收窄。
268
274
  */
269
275
  declare function isAskUserQuestion(value: unknown): value is AskUserQuestion;
270
276
 
271
- export { ASK_USER_MARKER, type AskUserAnswers, type AskUserOption, type AskUserQuestion, GUI_WIDGET_MARKER, type GuiComponent, type GuiComponentProps, type GuiComponentType, type GuiContext, type GuiRenderResult, PROTOCOL_VERSION, type StatItem, type TreeItem, type TreeItemIcon, askUserInteract, extractGui, getAskUserAnswer, getAskUserOther, guiComponent, guiResult, guiSetWidget, isAskUserQuestion, isGuiCapable, isGuiComponent };
277
+ export { ASK_USER_MARKER, type AskUserAnswers, type AskUserOption, type AskUserQuestion, GUI_WIDGET_MARKER, type GuiComponent, type GuiComponentProps, type GuiComponentType, type GuiContext, type GuiRenderResult, PROTOCOL_VERSION, type StatItem, type TreeItem, type TreeItemIcon, askUserInteract, extractGui, getAskUserAnswer, getAskUserComment, getAskUserOther, guiComponent, guiResult, guiSetWidget, isAskUserQuestion, isGuiCapable, isGuiComponent };
package/dist/index.mjs CHANGED
@@ -100,10 +100,13 @@ function getAskUserAnswer(answers, question) {
100
100
  function getAskUserOther(answers, question) {
101
101
  return answers[`${askUserKey(question)}__other`];
102
102
  }
103
+ function getAskUserComment(answers, question) {
104
+ return answers[`${askUserKey(question)}__comment`];
105
+ }
103
106
  function isAskUserQuestion(value) {
104
107
  if (typeof value !== "object" || value === null) return false;
105
108
  const q = value;
106
- return typeof q.question === "string" && (q.header === void 0 || typeof q.header === "string") && (q.options === void 0 || Array.isArray(q.options)) && (q.multiSelect === void 0 || typeof q.multiSelect === "boolean") && (q.allowOther === void 0 || typeof q.allowOther === "boolean");
109
+ return typeof q.question === "string" && (q.header === void 0 || typeof q.header === "string") && (q.options === void 0 || Array.isArray(q.options)) && (q.multiSelect === void 0 || typeof q.multiSelect === "boolean") && (q.allowOther === void 0 || typeof q.allowOther === "boolean") && (q.allowComment === void 0 || typeof q.allowComment === "boolean");
107
110
  }
108
111
  export {
109
112
  ASK_USER_MARKER,
@@ -112,6 +115,7 @@ export {
112
115
  askUserInteract,
113
116
  extractGui,
114
117
  getAskUserAnswer,
118
+ getAskUserComment,
115
119
  getAskUserOther,
116
120
  guiComponent,
117
121
  guiResult,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyz-agent/extension-protocol",
3
- "version": "0.3.0",
3
+ "version": "0.3.1-dev.0",
4
4
  "description": "Extension GUI rendering protocol: types and helpers for pi extension dual-mode (TUI/GUI) rendering",
5
5
  "main": "dist/index.mjs",
6
6
  "module": "dist/index.mjs",