@springbrand/agent-runtime 0.2.0-alpha.60 → 0.2.0-alpha.61
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/package.json +1 -1
- package/src/lib/prompt.ts +2 -2
- package/src/pi/tool/base.ts +24 -5
package/package.json
CHANGED
package/src/lib/prompt.ts
CHANGED
|
@@ -111,8 +111,8 @@ export const INTERACTION =
|
|
|
111
111
|
"Interaction: When progress requires user decisions, put all 1-10 necessary questions in one ask_user call " +
|
|
112
112
|
"instead of asking each question separately or writing 'please choose A/B/C' as text. Every question must set exactly one responseType. " +
|
|
113
113
|
"Use responseType: \"single_select\" or responseType: \"multi_select\" with 2-6 options for choices; use responseType: \"text\" " +
|
|
114
|
-
"for
|
|
115
|
-
"request attachments. Do not add an accept field or tell the user to upload through the normal chat composer; " +
|
|
114
|
+
"for free text; use responseType: \"attachment\" for one or more files. Set required: true only when progress cannot continue " +
|
|
115
|
+
"without that answer; required defaults to false. At most one question may request attachments. Do not add an accept field or tell the user to upload through the normal chat composer; " +
|
|
116
116
|
"continue the same turn when its result arrives. " +
|
|
117
117
|
"Don't use it when a sensible default lets you proceed. " +
|
|
118
118
|
"After completing a substantive task (report, analysis, multi-step job), finish all work and other Tool calls, " +
|
package/src/pi/tool/base.ts
CHANGED
|
@@ -44,6 +44,11 @@ const askUserQuestion = Type.Object({
|
|
|
44
44
|
description:
|
|
45
45
|
"For single_select or multi_select, whether the user may also add free text. Defaults to false.",
|
|
46
46
|
})),
|
|
47
|
+
required: Type.Optional(Type.Boolean({
|
|
48
|
+
default: false,
|
|
49
|
+
description:
|
|
50
|
+
"Whether the user must answer this question to submit. Defaults to false.",
|
|
51
|
+
})),
|
|
47
52
|
}, { additionalProperties: false });
|
|
48
53
|
|
|
49
54
|
const askUserParameters = Type.Object({
|
|
@@ -98,6 +103,10 @@ function questionsOf(
|
|
|
98
103
|
if (!question || typeof question.question !== "string" || !question.question) {
|
|
99
104
|
return null;
|
|
100
105
|
}
|
|
106
|
+
if (
|
|
107
|
+
question.required !== undefined && typeof question.required !== "boolean"
|
|
108
|
+
) return null;
|
|
109
|
+
const required = question.required === true;
|
|
101
110
|
let responseType = question.responseType;
|
|
102
111
|
if (
|
|
103
112
|
typeof responseType !== "string" ||
|
|
@@ -118,6 +127,11 @@ function questionsOf(
|
|
|
118
127
|
return null;
|
|
119
128
|
}
|
|
120
129
|
}
|
|
130
|
+
const normalizedQuestion = {
|
|
131
|
+
question: question.question,
|
|
132
|
+
responseType: responseType as typeof askUserResponseTypes[number],
|
|
133
|
+
required,
|
|
134
|
+
};
|
|
121
135
|
if (responseType === "attachment") {
|
|
122
136
|
attachmentQuestions += 1;
|
|
123
137
|
if (
|
|
@@ -126,7 +140,7 @@ function questionsOf(
|
|
|
126
140
|
question.allowCustom !== undefined ||
|
|
127
141
|
(!allowLegacy && question.multiSelect !== undefined)
|
|
128
142
|
) return null;
|
|
129
|
-
normalized.push(
|
|
143
|
+
normalized.push(normalizedQuestion);
|
|
130
144
|
continue;
|
|
131
145
|
}
|
|
132
146
|
if (responseType === "text") {
|
|
@@ -137,7 +151,7 @@ function questionsOf(
|
|
|
137
151
|
) {
|
|
138
152
|
return null;
|
|
139
153
|
}
|
|
140
|
-
normalized.push(
|
|
154
|
+
normalized.push(normalizedQuestion);
|
|
141
155
|
continue;
|
|
142
156
|
}
|
|
143
157
|
if (
|
|
@@ -156,8 +170,7 @@ function questionsOf(
|
|
|
156
170
|
(question.kind !== undefined || question.multiSelect !== undefined)
|
|
157
171
|
) return null;
|
|
158
172
|
normalized.push({
|
|
159
|
-
|
|
160
|
-
responseType: responseType as typeof askUserResponseTypes[number],
|
|
173
|
+
...normalizedQuestion,
|
|
161
174
|
options: question.options,
|
|
162
175
|
...(question.allowCustom === undefined
|
|
163
176
|
? {}
|
|
@@ -223,6 +236,12 @@ function isAskUserResponse(input: unknown, value: unknown): boolean {
|
|
|
223
236
|
);
|
|
224
237
|
})) return false;
|
|
225
238
|
|
|
239
|
+
if (
|
|
240
|
+
answer.selections.length === 0 &&
|
|
241
|
+
!answer.text.trim() &&
|
|
242
|
+
answer.attachments.length === 0
|
|
243
|
+
) return question.required !== true;
|
|
244
|
+
|
|
226
245
|
if (question.responseType === "attachment") {
|
|
227
246
|
return answer.selections.length === 0 && !answer.text &&
|
|
228
247
|
answer.attachments.length >= 1 && answer.attachments.length <= 8;
|
|
@@ -367,7 +386,7 @@ export function basePiToolCandidates(
|
|
|
367
386
|
name: "ask_user",
|
|
368
387
|
label: "Ask user",
|
|
369
388
|
description:
|
|
370
|
-
"Ask all 1-10 user questions needed to continue in one call. Required input for every question: question and responseType. Use responseType text for free text, single_select or multi_select with 2-6 distinct options for choices, and attachment
|
|
389
|
+
"Ask all 1-10 user questions needed to continue in one call. Required input for every question: question and responseType; required defaults to false, so set it to true only when progress cannot continue without an answer. Use responseType text for free text, single_select or multi_select with 2-6 distinct options for choices, and attachment for files. At most one attachment question is allowed and it accepts multiple files. Do not add file-specific fields such as accept or tell the user to use the normal chat composer. The answers return as this tool's result, so continue the same turn after calling it.",
|
|
371
390
|
parameters: askUserParameters,
|
|
372
391
|
prepareArguments: prepareAskUserArguments,
|
|
373
392
|
// 永远不会被调用:执行链在 interaction 闸就 park 住了。留一个失败关闭的
|