@downcity/agent 1.1.324 → 1.1.326

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.
@@ -22,13 +22,11 @@ import type { ActionResult } from "../../types/action/ActionResult.js";
22
22
  export declare const AskQuestionsTool: import("ai").Tool<{
23
23
  title: string;
24
24
  questions: ({
25
- question_id: string;
26
- prompt: string;
27
- response_type: "text";
25
+ question: string;
26
+ type: "text";
28
27
  } | {
29
- question_id: string;
30
- prompt: string;
31
- response_type: "single_select" | "multi_select";
28
+ question: string;
29
+ type: "single_select" | "multi_select";
32
30
  options: {
33
31
  value: string;
34
32
  label: string;
@@ -1 +1 @@
1
- {"version":3,"file":"AskQuestionsTool.d.ts","sourceRoot":"","sources":["../../../src/tools/ask/AskQuestionsTool.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAEV,sBAAsB,EACvB,MAAM,uCAAuC,CAAC;AAG/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAEnE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;wCAsD3B,CAAC"}
1
+ {"version":3,"file":"AskQuestionsTool.d.ts","sourceRoot":"","sources":["../../../src/tools/ask/AskQuestionsTool.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAEV,sBAAsB,EACvB,MAAM,uCAAuC,CAAC;AAG/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAEnE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;wCA2D3B,CAAC"}
@@ -42,7 +42,12 @@ export const AskQuestionsTool = tool({
42
42
  tool_name: "ask_question",
43
43
  },
44
44
  title: input.title,
45
- questions: input.questions,
45
+ questions: input.questions.map((question) => ({
46
+ question_id: `question:${generate_id()}`,
47
+ prompt: question.question,
48
+ response_type: question.type,
49
+ ...(question.options ? { options: question.options } : {}),
50
+ })),
46
51
  created_at: Date.now(),
47
52
  });
48
53
  const result = await handle.result;
@@ -1 +1 @@
1
- {"version":3,"file":"AskQuestionsTool.js","sourceRoot":"","sources":["../../../src/tools/ask/AskQuestionsTool.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,IAAI,EAA6B,MAAM,IAAI,CAAC;AACrD,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAM1E,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC;IACnC,WAAW,EACT,kcAAkc;IACpc,WAAW,EAAE,0BAA0B;IACvC,OAAO,EAAE,KAAK,EACZ,KAA4B,EAC5B,iBAAuC,EACQ,EAAE;QACjD,MAAM,iBAAiB,GAAG,iBAAiB,CAAC,oBAE/B,CAAC;QACd,MAAM,YAAY,GAAG,iBAAiB,EAAE,oBAAoB,CAAC;QAC7D,MAAM,gBAAgB,GAAG,YAAY,EAAE,YAAY,CAAC;QACpD,MAAM,OAAO,GAAG,MAAM,CAAC,YAAY,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QACnE,MAAM,YAAY,GAAG,MAAM,CAAC,iBAAiB,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QACvE,IAAI,CAAC,gBAAgB,IAAI,CAAC,OAAO,IAAI,CAAC,YAAY,EAAE,CAAC;YACnD,MAAM,IAAI,KAAK,CACb,gEAAgE,CACjE,CAAC;QACJ,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,OAAO,CAAC;YAC5C,cAAc,EAAE,eAAe,WAAW,EAAE,EAAE;YAC9C,OAAO;YACP,IAAI,EAAE,UAAU;YAChB,MAAM,EAAE;gBACN,IAAI,EAAE,MAAM;gBACZ,YAA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C;QACnC,IAAI,MAAM,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;YAClC,MAAM,IAAI,KAAK,CAAC,+BAA+B,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;QAClE,CAAC;QACD,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;QACpE,CAAC;QACD,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YACxC,MAAM,IAAI,KAAK,CACb,4DAA4D,CAC7D,CAAC;QACJ,CAAC;QACD,OAAO;YACL,MAAM,EAAE;gBACN,MAAM,EAAE,UAAU;gBAClB,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,OAAO;aACjC;YACD,QAAQ,EAAE,EAAE;SACb,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -9,13 +9,11 @@ import { z } from "zod";
9
9
  export declare const ask_questions_input_schema: z.ZodObject<{
10
10
  title: z.ZodString;
11
11
  questions: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
12
- question_id: z.ZodString;
13
- prompt: z.ZodString;
14
- response_type: z.ZodLiteral<"text">;
12
+ question: z.ZodString;
13
+ type: z.ZodLiteral<"text">;
15
14
  }, z.core.$strict>, z.ZodObject<{
16
- question_id: z.ZodString;
17
- prompt: z.ZodString;
18
- response_type: z.ZodEnum<{
15
+ question: z.ZodString;
16
+ type: z.ZodEnum<{
19
17
  single_select: "single_select";
20
18
  multi_select: "multi_select";
21
19
  }>;
@@ -24,6 +22,6 @@ export declare const ask_questions_input_schema: z.ZodObject<{
24
22
  label: z.ZodString;
25
23
  description: z.ZodOptional<z.ZodString>;
26
24
  }, z.core.$strict>>;
27
- }, z.core.$strict>], "response_type">>;
25
+ }, z.core.$strict>], "type">>;
28
26
  }, z.core.$strict>;
29
27
  //# sourceMappingURL=AskQuestionsToolSchemas.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AskQuestionsToolSchemas.d.ts","sourceRoot":"","sources":["../../../src/tools/ask/AskQuestionsToolSchemas.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAuCxB,yCAAyC;AACzC,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;kBAY5B,CAAC"}
1
+ {"version":3,"file":"AskQuestionsToolSchemas.d.ts","sourceRoot":"","sources":["../../../src/tools/ask/AskQuestionsToolSchemas.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAmCxB,yCAAyC;AACzC,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;kBAY5B,CAAC"}
@@ -17,20 +17,16 @@ const option_schema = z
17
17
  .strict();
18
18
  const text_question_schema = z
19
19
  .object({
20
- question_id: z.string().trim().min(1)
21
- .describe("Stable question identifier unique within this request."),
22
- prompt: z.string().trim().min(1)
20
+ question: z.string().trim().min(1)
23
21
  .describe("Complete question shown to the user."),
24
- response_type: z.literal("text"),
22
+ type: z.literal("text"),
25
23
  })
26
24
  .strict();
27
25
  const select_question_schema = z
28
26
  .object({
29
- question_id: z.string().trim().min(1)
30
- .describe("Stable question identifier unique within this request."),
31
- prompt: z.string().trim().min(1)
27
+ question: z.string().trim().min(1)
32
28
  .describe("Complete question shown to the user."),
33
- response_type: z.enum(["single_select", "multi_select"]),
29
+ type: z.enum(["single_select", "multi_select"]),
34
30
  options: z.array(option_schema).min(1)
35
31
  .describe("Required selectable options. Every option MUST include both value and label, for example { value: 'cn', label: '中国' }."),
36
32
  })
@@ -41,7 +37,7 @@ export const ask_questions_input_schema = z
41
37
  title: z.string().trim().min(1)
42
38
  .describe("Short title for the question card."),
43
39
  questions: z
44
- .array(z.discriminatedUnion("response_type", [
40
+ .array(z.discriminatedUnion("type", [
45
41
  text_question_schema,
46
42
  select_question_schema,
47
43
  ]))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gEAAgE,CAAC;CAC9E,CAAC;KACD,MAAM,EAAE,CAAC"}
@@ -5,5 +5,5 @@
5
5
  * `AgentOptions.tools` 显式完成组合。
6
6
  */
7
7
  export { AskQuestionsTool } from "./ask/AskQuestionsTool.js";
8
- export type { AskQuestionsToolInput, AskQuestionsToolOutput, } from "../types/tools/ask/AskQuestionsTool.js";
8
+ export type { AskQuestionsToolQuestion, AskQuestionsToolInput, AskQuestionsToolOutput, } from "../types/tools/ask/AskQuestionsTool.js";
9
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,YAAY,EACV,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,wCAAwC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,YAAY,EACV,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,wCAAwC,CAAC"}
@@ -4,13 +4,22 @@
4
4
  * 该协议只描述模型发起问题和收到回答时可见的数据;Interaction 标识、Turn 标识与
5
5
  * 生命周期状态由 Session 运行时维护,不交给模型生成。
6
6
  */
7
- import type { SessionInteractionAnswer, SessionInteractionQuestion } from "../../../types/session/SessionInteraction.js";
7
+ import type { SessionInteractionAnswer, SessionInteractionOption, SessionInteractionQuestion } from "../../../types/session/SessionInteraction.js";
8
+ /** 模型调用 ask_question 时提交的一条问题。 */
9
+ export interface AskQuestionsToolQuestion {
10
+ /** 向用户展示的完整问题文本。 */
11
+ question: string;
12
+ /** 当前问题要求的回答形式,所有问题都必须显式提供。 */
13
+ type: SessionInteractionQuestion["response_type"];
14
+ /** 单选或多选问题允许选择的候选项。 */
15
+ options?: SessionInteractionOption[];
16
+ }
8
17
  /** 模型调用 ask_question 时提交的结构化输入。 */
9
18
  export interface AskQuestionsToolInput {
10
19
  /** 问题卡片向用户展示的简短标题。 */
11
20
  title: string;
12
21
  /** 本次需要用户完整回答的一到多条问题。 */
13
- questions: SessionInteractionQuestion[];
22
+ questions: AskQuestionsToolQuestion[];
14
23
  }
15
24
  /** 用户完成回答后返回给模型的结构化 Tool Result。 */
16
25
  export interface AskQuestionsToolOutput {
@@ -1 +1 @@
1
- {"version":3,"file":"AskQuestionsTool.d.ts","sourceRoot":"","sources":["../../../../src/types/tools/ask/AskQuestionsTool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC3B,MAAM,uCAAuC,CAAC;AAE/C,mCAAmC;AACnC,MAAM,WAAW,qBAAqB;IACpC,sBAAsB;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,yBAAyB;IACzB,SAAS,EAAE,0BAA0B,EAAE,CAAC;CACzC;AAED,oCAAoC;AACpC,MAAM,WAAW,sBAAsB;IACrC,oBAAoB;IACpB,MAAM,EAAE,UAAU,CAAC;IACnB,+BAA+B;IAC/B,OAAO,EAAE,wBAAwB,EAAE,CAAC;CACrC"}
1
+ {"version":3,"file":"AskQuestionsTool.d.ts","sourceRoot":"","sources":["../../../../src/types/tools/ask/AskQuestionsTool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,wBAAwB,EACxB,wBAAwB,EACxB,0BAA0B,EAC3B,MAAM,uCAAuC,CAAC;AAE/C,kCAAkC;AAClC,MAAM,WAAW,wBAAwB;IACvC,oBAAoB;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,+BAA+B;IAC/B,IAAI,EAAE,0BAA0B,CAAC,eAAe,CAAC,CAAC;IAClD,uBAAuB;IACvB,OAAO,CAAC,EAAE,wBAAwB,EAAE,CAAC;CACtC;AAED,mCAAmC;AACnC,MAAM,WAAW,qBAAqB;IACpC,sBAAsB;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,yBAAyB;IACzB,SAAS,EAAE,wBAAwB,EAAE,CAAC;CACvC;AAED,oCAAoC;AACpC,MAAM,WAAW,sBAAsB;IACrC,oBAAoB;IACpB,MAAM,EAAE,UAAU,CAAC;IACnB,+BAA+B;IAC/B,OAAO,EAAE,wBAAwB,EAAE,CAAC;CACrC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@downcity/agent",
3
- "version": "1.1.324",
3
+ "version": "1.1.326",
4
4
  "type": "module",
5
5
  "description": "Downcity Agent 运行时 — 单 Agent 执行壳与本机 RPC 能力",
6
6
  "main": "./bin/index.js",
@@ -30,9 +30,8 @@ function create_question_stream() {
30
30
  title: "选择部署区域",
31
31
  questions: [
32
32
  {
33
- question_id: "region",
34
- prompt: "需要部署到哪个区域?",
35
- response_type: "single_select",
33
+ question: "需要部署到哪个区域?",
34
+ type: "single_select",
36
35
  options: [
37
36
  { value: "cn", label: "中国" },
38
37
  { value: "us", label: "美国" },
@@ -164,7 +163,10 @@ test("显式注入的 ask_question 等待回答并继续同一个 Turn", async (
164
163
  interaction_id: mutation.part.interaction_id,
165
164
  response: {
166
165
  kind: "question",
167
- answers: [{ question_id: "region", value: "cn" }],
166
+ answers: [{
167
+ question_id: pending_interaction.request.questions[0].question_id,
168
+ value: "cn",
169
+ }],
168
170
  },
169
171
  });
170
172
  });
@@ -184,7 +186,10 @@ test("显式注入的 ask_question 等待回答并继续同一个 Turn", async (
184
186
  interaction_id: pending_interaction.interaction_id,
185
187
  response: {
186
188
  kind: "question",
187
- answers: [{ question_id: "region", value: "cn" }],
189
+ answers: [{
190
+ question_id: pending_interaction.request.questions[0].question_id,
191
+ value: "cn",
192
+ }],
188
193
  },
189
194
  });
190
195
 
@@ -201,7 +206,10 @@ test("显式注入的 ask_question 等待回答并继续同一个 Turn", async (
201
206
  assert.equal(tool_part?.state, "completed");
202
207
  assert.deepEqual(tool_part?.output, {
203
208
  status: "resolved",
204
- answers: [{ question_id: "region", value: "cn" }],
209
+ answers: [{
210
+ question_id: pending_interaction.request.questions[0].question_id,
211
+ value: "cn",
212
+ }],
205
213
  });
206
214
  assert.equal(interaction_part?.status, "resolved");
207
215
  assert.equal(interaction_part?.request.source.type, "tool");
@@ -59,7 +59,12 @@ export const AskQuestionsTool = tool({
59
59
  tool_name: "ask_question",
60
60
  },
61
61
  title: input.title,
62
- questions: input.questions,
62
+ questions: input.questions.map((question) => ({
63
+ question_id: `question:${generate_id()}`,
64
+ prompt: question.question,
65
+ response_type: question.type,
66
+ ...(question.options ? { options: question.options } : {}),
67
+ })),
63
68
  created_at: Date.now(),
64
69
  });
65
70
  const result = await handle.result;
@@ -22,21 +22,17 @@ const option_schema = z
22
22
 
23
23
  const text_question_schema = z
24
24
  .object({
25
- question_id: z.string().trim().min(1)
26
- .describe("Stable question identifier unique within this request."),
27
- prompt: z.string().trim().min(1)
25
+ question: z.string().trim().min(1)
28
26
  .describe("Complete question shown to the user."),
29
- response_type: z.literal("text"),
27
+ type: z.literal("text"),
30
28
  })
31
29
  .strict();
32
30
 
33
31
  const select_question_schema = z
34
32
  .object({
35
- question_id: z.string().trim().min(1)
36
- .describe("Stable question identifier unique within this request."),
37
- prompt: z.string().trim().min(1)
33
+ question: z.string().trim().min(1)
38
34
  .describe("Complete question shown to the user."),
39
- response_type: z.enum(["single_select", "multi_select"]),
35
+ type: z.enum(["single_select", "multi_select"]),
40
36
  options: z.array(option_schema).min(1)
41
37
  .describe(
42
38
  "Required selectable options. Every option MUST include both value and label, for example { value: 'cn', label: '中国' }.",
@@ -50,7 +46,7 @@ export const ask_questions_input_schema = z
50
46
  title: z.string().trim().min(1)
51
47
  .describe("Short title for the question card."),
52
48
  questions: z
53
- .array(z.discriminatedUnion("response_type", [
49
+ .array(z.discriminatedUnion("type", [
54
50
  text_question_schema,
55
51
  select_question_schema,
56
52
  ]))
@@ -7,6 +7,7 @@
7
7
 
8
8
  export { AskQuestionsTool } from "./ask/AskQuestionsTool.js";
9
9
  export type {
10
+ AskQuestionsToolQuestion,
10
11
  AskQuestionsToolInput,
11
12
  AskQuestionsToolOutput,
12
13
  } from "../types/tools/ask/AskQuestionsTool.js";
@@ -7,15 +7,26 @@
7
7
 
8
8
  import type {
9
9
  SessionInteractionAnswer,
10
+ SessionInteractionOption,
10
11
  SessionInteractionQuestion,
11
12
  } from "@/types/session/SessionInteraction.js";
12
13
 
14
+ /** 模型调用 ask_question 时提交的一条问题。 */
15
+ export interface AskQuestionsToolQuestion {
16
+ /** 向用户展示的完整问题文本。 */
17
+ question: string;
18
+ /** 当前问题要求的回答形式,所有问题都必须显式提供。 */
19
+ type: SessionInteractionQuestion["response_type"];
20
+ /** 单选或多选问题允许选择的候选项。 */
21
+ options?: SessionInteractionOption[];
22
+ }
23
+
13
24
  /** 模型调用 ask_question 时提交的结构化输入。 */
14
25
  export interface AskQuestionsToolInput {
15
26
  /** 问题卡片向用户展示的简短标题。 */
16
27
  title: string;
17
28
  /** 本次需要用户完整回答的一到多条问题。 */
18
- questions: SessionInteractionQuestion[];
29
+ questions: AskQuestionsToolQuestion[];
19
30
  }
20
31
 
21
32
  /** 用户完成回答后返回给模型的结构化 Tool Result。 */