@downcity/agent 1.1.66 → 1.1.70

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 (44) hide show
  1. package/bin/agent/Agent.d.ts.map +1 -1
  2. package/bin/agent/Agent.js +2 -0
  3. package/bin/agent/Agent.js.map +1 -1
  4. package/bin/agent/RemoteAgent.d.ts +8 -0
  5. package/bin/agent/RemoteAgent.d.ts.map +1 -1
  6. package/bin/agent/RemoteAgent.js +45 -14
  7. package/bin/agent/RemoteAgent.js.map +1 -1
  8. package/bin/config/Config.d.ts.map +1 -1
  9. package/bin/config/Config.js +16 -4
  10. package/bin/config/Config.js.map +1 -1
  11. package/bin/rpc/Client.d.ts +129 -0
  12. package/bin/rpc/Client.d.ts.map +1 -1
  13. package/bin/rpc/Client.js +123 -0
  14. package/bin/rpc/Client.js.map +1 -1
  15. package/bin/rpc/Server.d.ts +6 -0
  16. package/bin/rpc/Server.d.ts.map +1 -1
  17. package/bin/rpc/Server.js +197 -0
  18. package/bin/rpc/Server.js.map +1 -1
  19. package/bin/session/SessionTitle.d.ts +2 -6
  20. package/bin/session/SessionTitle.d.ts.map +1 -1
  21. package/bin/session/SessionTitle.js +5 -27
  22. package/bin/session/SessionTitle.js.map +1 -1
  23. package/bin/session/browse/Browse.d.ts +1 -5
  24. package/bin/session/browse/Browse.d.ts.map +1 -1
  25. package/bin/session/browse/Browse.js +2 -8
  26. package/bin/session/browse/Browse.js.map +1 -1
  27. package/bin/session/index.d.ts +2 -2
  28. package/bin/session/index.d.ts.map +1 -1
  29. package/bin/session/index.js +2 -2
  30. package/bin/session/index.js.map +1 -1
  31. package/bin/types/agent/AgentTypes.d.ts +8 -0
  32. package/bin/types/agent/AgentTypes.d.ts.map +1 -1
  33. package/package.json +2 -2
  34. package/scripts/session-title-event.test.mjs +74 -7
  35. package/src/agent/Agent.ts +2 -0
  36. package/src/agent/RemoteAgent.ts +55 -12
  37. package/src/config/Config.ts +17 -4
  38. package/src/rpc/Client.ts +310 -0
  39. package/src/rpc/Server.ts +305 -0
  40. package/src/session/SessionTitle.ts +5 -34
  41. package/src/session/browse/Browse.ts +1 -9
  42. package/src/session/index.ts +0 -2
  43. package/src/types/agent/AgentTypes.ts +9 -0
  44. package/tsconfig.tsbuildinfo +1 -1
@@ -3,8 +3,8 @@
3
3
  *
4
4
  * 关键点(中文)
5
5
  * - session title 是 `meta.json` 顶层字段,列表与详情都以它为准。
6
- * - 首次用户消息出现后优先使用模型生成标题,失败时回退到首条用户消息截断。
7
- * - session 缺失 title 时可在读取列表/详情时补写 fallback title。
6
+ * - title 默认允许为空;只有模型成功生成标题时才会写入。
7
+ * - title 仍为空时,后续执行链路可以再次尝试生成。
8
8
  */
9
9
 
10
10
  import { generateText, type LanguageModel } from "ai";
@@ -16,7 +16,6 @@ import {
16
16
  writeSessionMetadata,
17
17
  } from "@/session/storage/Metadata.js";
18
18
 
19
- const FALLBACK_SESSION_TITLE_MAX_CHARS = 60;
20
19
  const GENERATED_SESSION_TITLE_MAX_CHARS = 24;
21
20
 
22
21
  /**
@@ -100,20 +99,6 @@ function normalizeGeneratedTitle(input: string): string | undefined {
100
99
  : undefined;
101
100
  }
102
101
 
103
- /**
104
- * 从首条用户消息推导 fallback 标题。
105
- */
106
- export function resolveFallbackSessionTitle(
107
- messages: SessionMessageV1[],
108
- ): string | undefined {
109
- const firstUserText = resolveFirstUserText(messages);
110
- const title = truncateTitle(
111
- firstUserText,
112
- FALLBACK_SESSION_TITLE_MAX_CHARS,
113
- );
114
- return normalizeSessionTitle(title);
115
- }
116
-
117
102
  async function generateSessionTitle(input: {
118
103
  /**
119
104
  * 当前模型实例。
@@ -154,32 +139,18 @@ export async function ensureSessionTitle(
154
139
  if (current.title) return current;
155
140
 
156
141
  const firstUserText = resolveFirstUserText(input.messages);
157
- const fallbackTitle = resolveFallbackSessionTitle(input.messages);
158
- if (!fallbackTitle) return current;
159
-
160
- const fallbackMeta: SessionHistoryMetaV1 = {
161
- ...current,
162
- title: fallbackTitle,
163
- };
164
- await writeSessionMetadata({
165
- projectRoot: input.projectRoot,
166
- agentId: input.agentId,
167
- sessionId: input.sessionId,
168
- meta: fallbackMeta,
169
- });
170
-
171
142
  if (input.generate !== true || !input.model || !firstUserText) {
172
- return fallbackMeta;
143
+ return current;
173
144
  }
174
145
 
175
146
  const generatedTitle = await generateSessionTitle({
176
147
  model: input.model,
177
148
  firstUserText,
178
149
  });
179
- if (!generatedTitle) return fallbackMeta;
150
+ if (!generatedTitle) return current;
180
151
 
181
152
  const generatedMeta: SessionHistoryMetaV1 = {
182
- ...fallbackMeta,
153
+ ...current,
183
154
  title: generatedTitle,
184
155
  };
185
156
  await writeSessionMetadata({
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * 关键点(中文)
5
5
  * - 统一负责 session 列表摘要、session 详情与 history 分页的投影逻辑。
6
- * - session 缺失持久化 title 时,会在列表读取阶段补写 fallback title。
6
+ * - session title 允许为空;浏览层不会再从首条 user message 推导 fallback title。
7
7
  * - 面向 SDK / RemoteAgent / HTTP route 复用,避免在多个入口重复拼列表与分页语义。
8
8
  * - 这里不持有运行态状态;执行状态等动态信息通过调用参数显式注入。
9
9
  */
@@ -36,7 +36,6 @@ import { getSdkAgentSessionsRootDirPath } from "@/session/storage/Paths.js";
36
36
  import { readSessionMetadata } from "@/session/storage/Metadata.js";
37
37
  import {
38
38
  ensureSessionTitle,
39
- resolveFallbackSessionTitle,
40
39
  } from "@/session/SessionTitle.js";
41
40
 
42
41
  type AnyUiPart = UIMessagePart<Record<string, never>, Record<string, never>>;
@@ -185,13 +184,6 @@ export function resolveSessionMessagePreview(message: SessionMessageV1): string
185
184
  return extractAssistantToolSummary(message);
186
185
  }
187
186
 
188
- /**
189
- * 推导当前 session 的可读标题。
190
- */
191
- export function resolveSessionTitle(messages: SessionMessageV1[]): string | undefined {
192
- return resolveFallbackSessionTitle(messages);
193
- }
194
-
195
187
  function resolveToolName(part: ToolPartCompatShape, aiToolName?: string): string {
196
188
  const fromAi = String(aiToolName || "").trim();
197
189
  if (fromAi) return fromAi;
@@ -29,7 +29,6 @@ export {
29
29
  } from "./storage/Metadata.js";
30
30
  export {
31
31
  ensureSessionTitle,
32
- resolveFallbackSessionTitle,
33
32
  } from "./SessionTitle.js";
34
33
  export {
35
34
  persistSdkAssistantResult,
@@ -44,6 +43,5 @@ export {
44
43
  listAgentSessionSummaryPage,
45
44
  loadSessionMessagesFromPath,
46
45
  resolveSessionMessagePreview,
47
- resolveSessionTitle,
48
46
  toSessionTimelineEvents,
49
47
  } from "./browse/Browse.js";
@@ -196,6 +196,15 @@ export interface RemoteAgentOptions {
196
196
  * 或 `rpc://127.0.0.1:5314`
197
197
  */
198
198
  url: string;
199
+
200
+ /**
201
+ * 访问远程 HTTP Agent 时使用的 Bearer token。
202
+ *
203
+ * 关键点(中文)
204
+ * - 仅 `http://` / `https://` transport 会携带该 token。
205
+ * - `rpc://` 是本机内部直连通道,不读取也不发送 token。
206
+ */
207
+ token?: string;
199
208
  }
200
209
 
201
210
  /**