@downcity/agent 1.1.204 → 1.1.206

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.
Files changed (48) hide show
  1. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.d.ts.map +1 -1
  2. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.js +3 -2
  3. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.js.map +1 -1
  4. package/bin/executor/composer/system/default/assets/core.prompt.d.ts +1 -1
  5. package/bin/executor/composer/system/default/assets/core.prompt.d.ts.map +1 -1
  6. package/bin/executor/composer/system/default/assets/core.prompt.js +1 -1
  7. package/bin/executor/composer/system/default/assets/core.prompt.js.map +1 -1
  8. package/bin/executor/composer/system/default/assets/init/PROFILE.md.d.ts +1 -1
  9. package/bin/executor/composer/system/default/assets/init/PROFILE.md.d.ts.map +1 -1
  10. package/bin/executor/composer/system/default/assets/init/PROFILE.md.js +1 -1
  11. package/bin/executor/composer/system/default/assets/init/PROFILE.md.js.map +1 -1
  12. package/bin/executor/composer/system/default/assets/init/SOUL.md.d.ts +1 -1
  13. package/bin/executor/composer/system/default/assets/init/SOUL.md.d.ts.map +1 -1
  14. package/bin/executor/composer/system/default/assets/init/SOUL.md.js +1 -1
  15. package/bin/executor/composer/system/default/assets/init/SOUL.md.js.map +1 -1
  16. package/bin/executor/composer/system/default/assets/plugin.prompt.d.ts +1 -1
  17. package/bin/executor/composer/system/default/assets/plugin.prompt.d.ts.map +1 -1
  18. package/bin/executor/composer/system/default/assets/plugin.prompt.js +1 -1
  19. package/bin/executor/composer/system/default/assets/plugin.prompt.js.map +1 -1
  20. package/bin/executor/composer/system/default/assets/task.prompt.d.ts +1 -1
  21. package/bin/executor/composer/system/default/assets/task.prompt.d.ts.map +1 -1
  22. package/bin/executor/composer/system/default/assets/task.prompt.js +1 -1
  23. package/bin/executor/composer/system/default/assets/task.prompt.js.map +1 -1
  24. package/bin/executor/composer/system/default/variables/VariableReplacer.js +1 -1
  25. package/bin/executor/composer/system/default/variables/VariableReplacer.js.map +1 -1
  26. package/bin/session/SessionTitle.d.ts.map +1 -1
  27. package/bin/session/SessionTitle.js +16 -8
  28. package/bin/session/SessionTitle.js.map +1 -1
  29. package/bin/types/runtime/auth/AuthPermission.js +3 -3
  30. package/bin/types/runtime/auth/AuthPermission.js.map +1 -1
  31. package/package.json +1 -1
  32. package/scripts/agent-ready.test.mjs +1 -2
  33. package/scripts/session-title-event.test.mjs +49 -24
  34. package/src/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.ts +4 -2
  35. package/src/executor/composer/system/default/assets/core.prompt.ts +1 -1
  36. package/src/executor/composer/system/default/assets/core.prompt.ts.txt +44 -42
  37. package/src/executor/composer/system/default/assets/init/PROFILE.md.ts +1 -1
  38. package/src/executor/composer/system/default/assets/init/PROFILE.md.ts.txt +10 -11
  39. package/src/executor/composer/system/default/assets/init/SOUL.md.ts +1 -1
  40. package/src/executor/composer/system/default/assets/init/SOUL.md.ts.txt +58 -60
  41. package/src/executor/composer/system/default/assets/plugin.prompt.ts +1 -1
  42. package/src/executor/composer/system/default/assets/plugin.prompt.ts.txt +13 -13
  43. package/src/executor/composer/system/default/assets/task.prompt.ts +1 -1
  44. package/src/executor/composer/system/default/assets/task.prompt.ts.txt +28 -28
  45. package/src/executor/composer/system/default/variables/VariableReplacer.ts +1 -1
  46. package/src/session/SessionTitle.ts +16 -8
  47. package/src/types/runtime/auth/AuthPermission.ts +3 -3
  48. package/tsconfig.tsbuildinfo +1 -1
@@ -144,7 +144,7 @@ export function buildRuntimeClockSystemPrompt(options?: {
144
144
  const now = new Date();
145
145
  return [
146
146
  "# Runtime Clock Context",
147
- "以下字段是本轮运行的权威时间上下文;解析“今天/明天/几点”等相对时间时优先使用它们:",
147
+ "The following fields are the authoritative time context for this run. Prefer them when resolving relative time expressions such as today, tomorrow, or a specific hour:",
148
148
  `- current_date: ${formatDateInTimezone(now, timezone)}`,
149
149
  `- current_time: ${formatDateTimeInTimezone(now, timezone)}`,
150
150
  `- timezone: ${timezone}`,
@@ -7,7 +7,8 @@
7
7
  * - 当 title 仍为空时,后续执行链路可以再次尝试生成。
8
8
  */
9
9
 
10
- import { generateText, type LanguageModel } from "ai";
10
+ import { streamText, type LanguageModel } from "ai";
11
+ import { buildOpenAIResponsesProviderOptions } from "@executor/messages/SessionMessageCodec.js";
11
12
  import type { SessionHistoryMetaV1 } from "@/executor/types/SessionHistoryMeta.js";
12
13
  import type { SessionRecordV1 } from "@/executor/types/SessionRecords.js";
13
14
  import { is_session_message_record } from "@/executor/types/SessionRecords.js";
@@ -203,19 +204,25 @@ async function generateSessionTitle(input: {
203
204
  */
204
205
  logger?: Logger;
205
206
  }): Promise<string | undefined> {
207
+ let observedStreamError: unknown;
206
208
  try {
207
- const result = await generateText({
209
+ const result = streamText({
208
210
  model: input.model,
209
211
  system:
210
- "你负责为一段会话生成极简标题。只输出标题本身,不要解释,不要使用引号。",
212
+ "You generate minimal conversation titles. Output only the title itself, with no explanation and no quotation marks.",
211
213
  prompt: [
212
- "根据下面这条用户首条消息,生成一个简短的会话标题。",
213
- "要求:3 12 个汉字或 2 6 个英文词;不要句号;不要前缀。",
214
+ "Generate a short conversation title from the first user message below.",
215
+ "Requirements: 3 to 12 Chinese characters or 2 to 6 English words; no period; no prefix.",
214
216
  "",
215
217
  input.firstUserText,
216
218
  ].join("\n"),
219
+ providerOptions: buildOpenAIResponsesProviderOptions(),
220
+ onError: ({ error }) => {
221
+ observedStreamError = error;
222
+ },
217
223
  });
218
- const generatedTitle = normalizeGeneratedTitle(result.text);
224
+ const text = await result.text;
225
+ const generatedTitle = normalizeGeneratedTitle(text);
219
226
  if (!generatedTitle) {
220
227
  await logSessionTitleDiagnostic({
221
228
  logger: input.logger,
@@ -225,12 +232,13 @@ async function generateSessionTitle(input: {
225
232
  details: {
226
233
  modelLabel: input.modelLabel || null,
227
234
  firstUserTextLength: input.firstUserText.length,
228
- rawTitleLength: String(result.text || "").length,
235
+ rawTitleLength: String(text || "").length,
229
236
  },
230
237
  });
231
238
  }
232
239
  return generatedTitle;
233
240
  } catch (error) {
241
+ const effectiveError = observedStreamError || error;
234
242
  await logSessionTitleDiagnostic({
235
243
  logger: input.logger,
236
244
  sessionId: input.sessionId,
@@ -239,7 +247,7 @@ async function generateSessionTitle(input: {
239
247
  details: {
240
248
  modelLabel: input.modelLabel || null,
241
249
  firstUserTextLength: input.firstUserText.length,
242
- ...summarizeTitleError(error),
250
+ ...summarizeTitleError(effectiveError),
243
251
  },
244
252
  });
245
253
  // 关键点(中文):标题生成失败不能影响 session 主流程。
@@ -93,19 +93,19 @@ export interface AuthDefaultRoleDefinition {
93
93
  export const AUTH_DEFAULT_ROLES: AuthDefaultRoleDefinition[] = [
94
94
  {
95
95
  name: "admin",
96
- description: "系统管理员,可管理统一账户与所有控制面能力。",
96
+ description: "System administrator who can manage unified accounts and all control-plane capabilities.",
97
97
  permissions: [...AUTH_PERMISSION_KEYS],
98
98
  },
99
99
  {
100
100
  name: "operator",
101
- description: "运维角色,可查看并操作运行时,但不管理统一账户。",
101
+ description: "Operations role that can view and operate the runtime but cannot manage unified accounts.",
102
102
  permissions: AUTH_PERMISSION_KEYS.filter((permission) =>
103
103
  permission !== "auth.write" && permission !== "auth.read"
104
104
  ),
105
105
  },
106
106
  {
107
107
  name: "viewer",
108
- description: "只读角色,可查看状态但不能执行高危变更。",
108
+ description: "Read-only role that can view status but cannot perform high-risk changes.",
109
109
  permissions: [
110
110
  "agent.read",
111
111
  "task.read",