@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.
- package/bin/agent/Agent.d.ts.map +1 -1
- package/bin/agent/Agent.js +2 -0
- package/bin/agent/Agent.js.map +1 -1
- package/bin/agent/RemoteAgent.d.ts +8 -0
- package/bin/agent/RemoteAgent.d.ts.map +1 -1
- package/bin/agent/RemoteAgent.js +45 -14
- package/bin/agent/RemoteAgent.js.map +1 -1
- package/bin/config/Config.d.ts.map +1 -1
- package/bin/config/Config.js +16 -4
- package/bin/config/Config.js.map +1 -1
- package/bin/rpc/Client.d.ts +129 -0
- package/bin/rpc/Client.d.ts.map +1 -1
- package/bin/rpc/Client.js +123 -0
- package/bin/rpc/Client.js.map +1 -1
- package/bin/rpc/Server.d.ts +6 -0
- package/bin/rpc/Server.d.ts.map +1 -1
- package/bin/rpc/Server.js +197 -0
- package/bin/rpc/Server.js.map +1 -1
- package/bin/session/SessionTitle.d.ts +2 -6
- package/bin/session/SessionTitle.d.ts.map +1 -1
- package/bin/session/SessionTitle.js +5 -27
- package/bin/session/SessionTitle.js.map +1 -1
- package/bin/session/browse/Browse.d.ts +1 -5
- package/bin/session/browse/Browse.d.ts.map +1 -1
- package/bin/session/browse/Browse.js +2 -8
- package/bin/session/browse/Browse.js.map +1 -1
- package/bin/session/index.d.ts +2 -2
- package/bin/session/index.d.ts.map +1 -1
- package/bin/session/index.js +2 -2
- package/bin/session/index.js.map +1 -1
- package/bin/types/agent/AgentTypes.d.ts +8 -0
- package/bin/types/agent/AgentTypes.d.ts.map +1 -1
- package/package.json +2 -2
- package/scripts/session-title-event.test.mjs +74 -7
- package/src/agent/Agent.ts +2 -0
- package/src/agent/RemoteAgent.ts +55 -12
- package/src/config/Config.ts +17 -4
- package/src/rpc/Client.ts +310 -0
- package/src/rpc/Server.ts +305 -0
- package/src/session/SessionTitle.ts +5 -34
- package/src/session/browse/Browse.ts +1 -9
- package/src/session/index.ts +0 -2
- package/src/types/agent/AgentTypes.ts +9 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
5
|
* - session title 是 `meta.json` 顶层字段,列表与详情都以它为准。
|
|
6
|
-
* -
|
|
7
|
-
* -
|
|
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
|
|
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
|
|
150
|
+
if (!generatedTitle) return current;
|
|
180
151
|
|
|
181
152
|
const generatedMeta: SessionHistoryMetaV1 = {
|
|
182
|
-
...
|
|
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
|
-
* -
|
|
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;
|
package/src/session/index.ts
CHANGED
|
@@ -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
|
/**
|