nolo-cli 0.1.38 → 0.1.39
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/agent-runtime/agentRecordConfig.ts +0 -14
- package/agent-runtime/hostAdapter.ts +0 -1
- package/agent-runtime/index.ts +24 -18
- package/agent-runtime/localDialogRead.ts +23 -0
- package/agent-runtime/localToolPolicy.ts +2 -7
- package/agent-runtime/localWorkspaceTools.ts +9 -0
- package/agent-runtime/noloWorkspaceTools.ts +371 -0
- package/agent-runtime/runtimeToolPolicy.ts +1 -3
- package/agent-runtime/types.ts +1 -1
- package/agentAliases.ts +6 -0
- package/agentRunCommand.ts +57 -65
- package/agentRuntimeLocal.ts +0 -7
- package/chat/messages/fetchMessages.ts +84 -0
- package/chat/messages/types.ts +185 -0
- package/cli/agentAliases.ts +6 -0
- package/cli/agentRunCommand.ts +57 -65
- package/cli/agentRuntimeLocal.ts +0 -7
- package/cli/cliEnvHelpers.ts +11 -7
- package/cli/client/agentRun.ts +55 -7
- package/cli/client/localRuntimeAdapter.ts +87 -59
- package/cli/connectorRunArtifact.ts +0 -1
- package/cli/dialogCommands.ts +572 -0
- package/cli/dialogInternalCommandEntries.ts +4 -0
- package/cli/machineWsRunDispatch.ts +29 -37
- package/cli/scriptCommandEntries.ts +0 -2
- package/cli/tui/readlineWorkspace.ts +69 -0
- package/cli/tui/session.ts +176 -1
- package/cliEnvHelpers.ts +11 -7
- package/client/agentConfigResolver.test.ts +2 -3
- package/client/agentRun.test.ts +185 -1
- package/client/agentRun.ts +55 -7
- package/client/localRuntimeAdapter.test.ts +90 -25
- package/client/localRuntimeAdapter.ts +87 -59
- package/connectorRunArtifact.ts +0 -1
- package/database/server/db.ts +99 -0
- package/database/server/ensureDbOpen.ts +12 -0
- package/database/server/memoryAuthorityStore.ts +133 -0
- package/database/server/serverStoreFactory.ts +118 -0
- package/dialogCommands.ts +572 -0
- package/dialogInternalCommandEntries.ts +4 -0
- package/machineWsRunDispatch.ts +29 -37
- package/package.json +10 -9
- package/scriptCommandEntries.ts +0 -2
- package/tui/readlineWorkspace.ts +69 -0
- package/tui/session.ts +176 -1
- package/agent-runtime/taskWorkspace.ts +0 -193
- package/agent-runtime/workspaceSession.ts +0 -76
- package/cli/client/taskWorktree.ts +0 -8
- package/cli/client/workspaceSession.ts +0 -11
- package/client/taskWorktree.ts +0 -8
- package/client/workspaceSession.test.ts +0 -57
- package/client/workspaceSession.ts +0 -11
package/agentRunCommand.ts
CHANGED
|
@@ -4,13 +4,7 @@ import type { AgentRuntimeHostAdapter, AgentRuntimeRequestedMode } from "./agent
|
|
|
4
4
|
import { existsSync, readFileSync } from "node:fs";
|
|
5
5
|
import { extname, resolve } from "node:path";
|
|
6
6
|
import { parseSkillDocProtocol, type WorkflowReferenceConfig } from "./ai/skills/skillDocProtocol";
|
|
7
|
-
import { resolveCliAgentKeyInput } from "./agentAliases";
|
|
8
|
-
import {
|
|
9
|
-
ensureWorkspacePackageLinks,
|
|
10
|
-
formatPreparedTaskWorktree,
|
|
11
|
-
prepareTaskWorktree,
|
|
12
|
-
type PreparedTaskWorktree,
|
|
13
|
-
} from "./client/taskWorktree";
|
|
7
|
+
import { MIMO_MONTH_AGENT_KEY, resolveCliAgentKeyInput } from "./agentAliases";
|
|
14
8
|
import type { TaskRunPromptContext } from "./client/taskRunPrompt";
|
|
15
9
|
|
|
16
10
|
type EnvLike = Record<string, string | undefined>;
|
|
@@ -25,8 +19,6 @@ type AgentRunCommandDeps = {
|
|
|
25
19
|
output?: OutputLike;
|
|
26
20
|
runner?: typeof runAgentTurn;
|
|
27
21
|
localRuntimeAdapterFactory?: (env: EnvLike, options?: { cwd?: string }) => AgentRuntimeHostAdapter;
|
|
28
|
-
prepareTaskWorktree?: typeof prepareTaskWorktree;
|
|
29
|
-
ensureWorkspacePackageLinks?: typeof ensureWorkspacePackageLinks;
|
|
30
22
|
inspectLocalRunWorkspace?: typeof inspectLocalRunWorkspace;
|
|
31
23
|
resolveWorkflowReference?: typeof resolveWorkflowReference;
|
|
32
24
|
};
|
|
@@ -63,7 +55,7 @@ type ParsedAgentRunArgs = {
|
|
|
63
55
|
maxToolRounds?: number;
|
|
64
56
|
timeoutMs?: number;
|
|
65
57
|
traceTools: boolean;
|
|
66
|
-
|
|
58
|
+
injectFeatureWorktreeInstruction: boolean;
|
|
67
59
|
taskRunContext?: TaskRunPromptContext;
|
|
68
60
|
workflowRef?: string;
|
|
69
61
|
};
|
|
@@ -102,6 +94,21 @@ function runtimeModeFromArgs(args: string[]): AgentRuntimeRequestedMode | undefi
|
|
|
102
94
|
return undefined;
|
|
103
95
|
}
|
|
104
96
|
|
|
97
|
+
function isMonthlyMimoAgentRef(raw: string | undefined, resolved: string) {
|
|
98
|
+
const normalized = raw?.trim().toLowerCase();
|
|
99
|
+
return (
|
|
100
|
+
resolved === MIMO_MONTH_AGENT_KEY ||
|
|
101
|
+
normalized === "fullstack" ||
|
|
102
|
+
normalized === "full-stack" ||
|
|
103
|
+
normalized === "nolo-fullstack" ||
|
|
104
|
+
normalized === "包月mimo" ||
|
|
105
|
+
normalized === "包月mimo2.5" ||
|
|
106
|
+
normalized === "mimo-month" ||
|
|
107
|
+
normalized === "全栈" ||
|
|
108
|
+
normalized === "nolo 全栈工程师"
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
105
112
|
function parseNonNegativeInteger(value: string | undefined) {
|
|
106
113
|
if (!value) return undefined;
|
|
107
114
|
const parsed = Number(value);
|
|
@@ -123,7 +130,6 @@ function positionalArgs(args: string[]) {
|
|
|
123
130
|
"--server",
|
|
124
131
|
"--auto",
|
|
125
132
|
"--dangerously-allow-shell",
|
|
126
|
-
"--worktree-task",
|
|
127
133
|
"--trace-tools",
|
|
128
134
|
"--bg",
|
|
129
135
|
"--no-stream",
|
|
@@ -146,7 +152,8 @@ export function parseAgentRunArgs(
|
|
|
146
152
|
args: string[],
|
|
147
153
|
options: ParseAgentRunArgsOptions = {}
|
|
148
154
|
): ParsedAgentRunArgs | null {
|
|
149
|
-
const
|
|
155
|
+
const rawAgentKey = readFlagValue(args, "--agent") ?? positionalArgs(args)[0];
|
|
156
|
+
const agentKey = rawAgentKey ? resolveCliAgentKeyInput(rawAgentKey) : undefined;
|
|
150
157
|
const explicitMsg = readFlagValue(args, "--msg");
|
|
151
158
|
const msgFile = readFlagValue(args, "--msg-file");
|
|
152
159
|
const fileMessage = msgFile
|
|
@@ -178,7 +185,8 @@ export function parseAgentRunArgs(
|
|
|
178
185
|
...readRepeatedFlagValues(args, "--image"),
|
|
179
186
|
...readRepeatedFlagValues(args, "--image-url"),
|
|
180
187
|
];
|
|
181
|
-
const
|
|
188
|
+
const mimoLocalWorkspaceDefault =
|
|
189
|
+
isMonthlyMimoAgentRef(rawAgentKey, agentKey) && runtimeMode !== "server";
|
|
182
190
|
const workflowRef = readFlagValue(args, "--workflow");
|
|
183
191
|
const taskRowDbKey = readFlagValue(args, "--task-row-dbkey");
|
|
184
192
|
const artifactIds = readFlagValue(args, "--artifact-ids")
|
|
@@ -186,12 +194,12 @@ export function parseAgentRunArgs(
|
|
|
186
194
|
.map((item) => item.trim())
|
|
187
195
|
.filter(Boolean);
|
|
188
196
|
return {
|
|
189
|
-
agentKey
|
|
197
|
+
agentKey,
|
|
190
198
|
message,
|
|
191
199
|
imageUrls,
|
|
192
|
-
allowShell: args.includes("--dangerously-allow-shell"),
|
|
200
|
+
allowShell: args.includes("--dangerously-allow-shell") || mimoLocalWorkspaceDefault,
|
|
193
201
|
traceTools: args.includes("--trace-tools"),
|
|
194
|
-
|
|
202
|
+
injectFeatureWorktreeInstruction: mimoLocalWorkspaceDefault,
|
|
195
203
|
...(workflowRef ? { workflowRef } : {}),
|
|
196
204
|
...(taskRowDbKey
|
|
197
205
|
? {
|
|
@@ -203,7 +211,11 @@ export function parseAgentRunArgs(
|
|
|
203
211
|
},
|
|
204
212
|
}
|
|
205
213
|
: {}),
|
|
206
|
-
...(runtimeMode
|
|
214
|
+
...(runtimeMode
|
|
215
|
+
? { runtimeMode }
|
|
216
|
+
: mimoLocalWorkspaceDefault || args.includes("--dangerously-allow-shell")
|
|
217
|
+
? { runtimeMode: "local" as const }
|
|
218
|
+
: {}),
|
|
207
219
|
background: args.includes("--bg"),
|
|
208
220
|
noStream: args.includes("--no-stream"),
|
|
209
221
|
noDefaultTestRoot,
|
|
@@ -269,6 +281,20 @@ export function prependWorkflowReferencePrompt(message: string, workflow?: Resol
|
|
|
269
281
|
].join("\n");
|
|
270
282
|
}
|
|
271
283
|
|
|
284
|
+
function prependFeatureWorktreeInstruction(message: string, enabled: boolean) {
|
|
285
|
+
if (!enabled) return message;
|
|
286
|
+
return [
|
|
287
|
+
"Local execution rule:",
|
|
288
|
+
"- You are running in the current git checkout with shell access.",
|
|
289
|
+
"- For read-only checks, smoke tests, or answering questions, stay in the current directory.",
|
|
290
|
+
"- Before developing a new feature or making non-trivial code changes, create a separate git worktree yourself with git worktree and do the edits there.",
|
|
291
|
+
"- Commit and push only when the user explicitly asks or the task requires it.",
|
|
292
|
+
"",
|
|
293
|
+
"User task:",
|
|
294
|
+
message,
|
|
295
|
+
].join("\n");
|
|
296
|
+
}
|
|
297
|
+
|
|
272
298
|
function parseDialogReference(rawInput: string) {
|
|
273
299
|
const normalized = rawInput.trim();
|
|
274
300
|
if (normalized.startsWith("dialog-")) {
|
|
@@ -381,19 +407,13 @@ function resolveServerUrl(env: EnvLike) {
|
|
|
381
407
|
return (env.NOLO_SERVER || env.BASE_URL || DEFAULT_NOLO_SERVER_URL).replace(/\/+$/, "");
|
|
382
408
|
}
|
|
383
409
|
|
|
384
|
-
function
|
|
385
|
-
return !parsed.cwd && (parsed.useTaskWorktree || parsed.allowShell);
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
function buildTaskWorktreeEnv(args: {
|
|
410
|
+
function buildLocalRunEnv(args: {
|
|
389
411
|
env: EnvLike;
|
|
390
|
-
worktreePath?: string;
|
|
391
412
|
allowShell: boolean;
|
|
392
413
|
}) {
|
|
393
414
|
return {
|
|
394
415
|
...args.env,
|
|
395
416
|
...(args.allowShell ? { NOLO_LOCAL_SHELL_MODE: "worktree" } : {}),
|
|
396
|
-
...(args.worktreePath ? { NOLO_LOCAL_WORKTREE: args.worktreePath } : {}),
|
|
397
417
|
};
|
|
398
418
|
}
|
|
399
419
|
|
|
@@ -426,52 +446,24 @@ export async function runAgentRunCommand(args: string[], deps: AgentRunCommandDe
|
|
|
426
446
|
}
|
|
427
447
|
}
|
|
428
448
|
let localRuntimeCwd = parsed.cwd;
|
|
429
|
-
if (
|
|
430
|
-
|
|
431
|
-
const preparedWorktree = await (deps.prepareTaskWorktree ?? prepareTaskWorktree)({
|
|
432
|
-
agentKey: parsed.agentKey,
|
|
433
|
-
env,
|
|
434
|
-
});
|
|
435
|
-
localRuntimeCwd = preparedWorktree.path;
|
|
436
|
-
output.write(formatPreparedTaskWorktree(preparedWorktree));
|
|
437
|
-
} catch (error) {
|
|
438
|
-
output.write(
|
|
439
|
-
"[nolo] Could not prepare a local task worktree.\n" +
|
|
440
|
-
"Run from inside a git repository, or set NOLO_LOCAL_WORKTREE to an existing isolated checkout.\n" +
|
|
441
|
-
`Reason: ${error instanceof Error ? error.message : String(error)}\n`
|
|
442
|
-
);
|
|
443
|
-
return 1;
|
|
444
|
-
}
|
|
449
|
+
if (!localRuntimeCwd && parsed.runtimeMode === "local") {
|
|
450
|
+
localRuntimeCwd = process.cwd();
|
|
445
451
|
}
|
|
446
|
-
const
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
try {
|
|
451
|
-
await (deps.ensureWorkspacePackageLinks ?? ensureWorkspacePackageLinks)(
|
|
452
|
-
localRuntimeCwd!
|
|
453
|
-
);
|
|
454
|
-
} catch (error) {
|
|
455
|
-
output.write(
|
|
456
|
-
"[nolo] Dependency preflight failed for local task worktree.\n" +
|
|
457
|
-
"The worktree may have node_modules entries that point outside the task checkout, or paths that cannot be repaired safely.\n" +
|
|
458
|
-
`Reason: ${error instanceof Error ? error.message : String(error)}\n`
|
|
459
|
-
);
|
|
460
|
-
return 1;
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
const runEnv = shouldBindLocalWorkspace
|
|
464
|
-
? buildTaskWorktreeEnv({
|
|
465
|
-
env,
|
|
466
|
-
worktreePath: localRuntimeCwd,
|
|
467
|
-
allowShell: parsed.allowShell,
|
|
468
|
-
})
|
|
469
|
-
: env;
|
|
452
|
+
const runEnv = buildLocalRunEnv({
|
|
453
|
+
env,
|
|
454
|
+
allowShell: parsed.allowShell,
|
|
455
|
+
});
|
|
470
456
|
const result: RunAgentTurnResult = await runner({
|
|
471
457
|
agentName: parsed.agentKey,
|
|
472
458
|
agentKey: parsed.agentKey,
|
|
473
459
|
serverUrl: resolveServerUrl(env),
|
|
474
|
-
message: prependWorkflowReferencePrompt(
|
|
460
|
+
message: prependWorkflowReferencePrompt(
|
|
461
|
+
prependFeatureWorktreeInstruction(
|
|
462
|
+
parsed.message,
|
|
463
|
+
parsed.injectFeatureWorktreeInstruction
|
|
464
|
+
),
|
|
465
|
+
workflowReference
|
|
466
|
+
),
|
|
475
467
|
imageUrls: parsed.imageUrls.map(normalizeCliImageInput),
|
|
476
468
|
scriptDir: deps.scriptDir,
|
|
477
469
|
env: runEnv,
|
package/agentRuntimeLocal.ts
CHANGED
|
@@ -5,12 +5,9 @@ export {
|
|
|
5
5
|
hasDirectOpenAiCompatibleProvider,
|
|
6
6
|
createHybridRecordStore,
|
|
7
7
|
executeLocalToolWithPolicy,
|
|
8
|
-
activateWorkspaceSession,
|
|
9
|
-
createWorkspaceSession,
|
|
10
8
|
buildAgentRuntimeAgentLookupKeys,
|
|
11
9
|
buildAgentRuntimeDialogWritePlan,
|
|
12
10
|
dialogMessageRecordToAgentRuntimeMessage,
|
|
13
|
-
formatWorkspaceSessionActivation,
|
|
14
11
|
pickAgentRuntimeInferenceOptions,
|
|
15
12
|
parseOpenAiCompatibleChatCompletionResponse,
|
|
16
13
|
parsePlatformChatCompletionData,
|
|
@@ -44,8 +41,4 @@ export type {
|
|
|
44
41
|
HybridRecordKvDb,
|
|
45
42
|
HybridRecordStore,
|
|
46
43
|
LocalToolPolicyDecision,
|
|
47
|
-
PreparedTaskWorkspace,
|
|
48
|
-
PrepareTaskWorkspace,
|
|
49
|
-
WorkspaceSession,
|
|
50
|
-
WorkspaceSessionMode,
|
|
51
44
|
} from "./agent-runtime";
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// chat/messages/fetchMessages.ts
|
|
2
|
+
import type { Message } from "./types"; // 确保引入你的 Message 类型定义
|
|
3
|
+
import { isTombstoneRecord } from "../../database/tombstones";
|
|
4
|
+
|
|
5
|
+
// 定义返回类型,包含数据库的 key
|
|
6
|
+
export type MessageWithKey = Message & { _key: string };
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 获取指定对话的消息,支持分页加载。
|
|
10
|
+
* @param db 数据库实例。
|
|
11
|
+
* @param dialogId 对话 ID。
|
|
12
|
+
* @param options 配置选项 (limit?, beforeKey?, throwOnError?)。
|
|
13
|
+
* @returns Promise<MessageWithKey[]> 消息数组 (带 key, 默认最新在前)。
|
|
14
|
+
*/
|
|
15
|
+
export const fetchMessages = async (
|
|
16
|
+
db: any, // TODO: 替换为具体的数据库实例类型
|
|
17
|
+
dialogId: string,
|
|
18
|
+
options: {
|
|
19
|
+
limit?: number;
|
|
20
|
+
beforeKey?: string | null;
|
|
21
|
+
throwOnError?: boolean;
|
|
22
|
+
includeDeleted?: boolean;
|
|
23
|
+
} = {}
|
|
24
|
+
): Promise<MessageWithKey[]> => {
|
|
25
|
+
const { limit = 30, beforeKey = null, throwOnError = false, includeDeleted = false } = options; // 分页默认 limit 30
|
|
26
|
+
|
|
27
|
+
// --- 输入验证 ---
|
|
28
|
+
if (!dialogId || typeof dialogId !== "string") {
|
|
29
|
+
const errorMsg = "fetchMessages: dialogId 必须是一个非空字符串";
|
|
30
|
+
if (throwOnError) throw new Error(errorMsg);
|
|
31
|
+
console.error(errorMsg);
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
// 其他验证 (limit, beforeKey) 可以根据需要添加
|
|
35
|
+
|
|
36
|
+
// --- 准备查询 ---
|
|
37
|
+
const messages: MessageWithKey[] = [];
|
|
38
|
+
const prefix = `dialog-${dialogId}-msg-`;
|
|
39
|
+
|
|
40
|
+
const iteratorOptions: any = {
|
|
41
|
+
// TODO: 替换为具体的迭代器选项类型
|
|
42
|
+
gte: prefix,
|
|
43
|
+
reverse: true, // 总是从新到旧获取
|
|
44
|
+
limit: limit,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
if (beforeKey) {
|
|
48
|
+
// 加载更早的消息: Key < beforeKey
|
|
49
|
+
iteratorOptions.lt = beforeKey;
|
|
50
|
+
} else {
|
|
51
|
+
// 加载最新的消息: Key <= prefix + '\uffff'
|
|
52
|
+
iteratorOptions.lte = prefix + "\uffff";
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// --- 执行查询 ---
|
|
56
|
+
try {
|
|
57
|
+
let iterator = db.iterator(iteratorOptions);
|
|
58
|
+
// 处理 react-native-leveldb 可能返回 Promise 的情况
|
|
59
|
+
if (iterator && typeof iterator.then === 'function') {
|
|
60
|
+
iterator = await iterator;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
let count = 0;
|
|
65
|
+
for await (const [key, value] of iterator) {
|
|
66
|
+
count++;
|
|
67
|
+
if (!includeDeleted && isTombstoneRecord(value)) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
// 基本数据校验
|
|
71
|
+
if (value && typeof value === "object" && value.id && value.createdAt) {
|
|
72
|
+
// **关键: 将数据库 key 作为 _key 附加到消息对象上**
|
|
73
|
+
messages.push({ ...(value as Message), _key: key });
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
return messages; // 返回的消息数组是 newest first
|
|
79
|
+
} catch (error) {
|
|
80
|
+
console.error(`fetchMessages: 获取对话 ${dialogId} 消息失败:`, error);
|
|
81
|
+
if (throwOnError) throw error;
|
|
82
|
+
return [];
|
|
83
|
+
}
|
|
84
|
+
};
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
// 文件路径: chat/messages/types.ts
|
|
2
|
+
|
|
3
|
+
// ========== 角色 ==========
|
|
4
|
+
export type MessageRole = "user" | "system" | "assistant" | "tool";
|
|
5
|
+
|
|
6
|
+
// ========== OpenAI 风格的 content ==========
|
|
7
|
+
export type OpenAIImageUrl =
|
|
8
|
+
| `http${string}`
|
|
9
|
+
| `https${string}`
|
|
10
|
+
| `data:image/${string};base64,${string}`;
|
|
11
|
+
|
|
12
|
+
export interface OpenAIImageContent {
|
|
13
|
+
type: "image_url";
|
|
14
|
+
image_url: {
|
|
15
|
+
url: OpenAIImageUrl;
|
|
16
|
+
detail?: "low" | "high" | "auto";
|
|
17
|
+
};
|
|
18
|
+
google_native?: {
|
|
19
|
+
inlineData: {
|
|
20
|
+
mimeType: string;
|
|
21
|
+
data: string;
|
|
22
|
+
};
|
|
23
|
+
thoughtSignature?: string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface OpenAITextContent {
|
|
28
|
+
type: "text";
|
|
29
|
+
text: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type MessageContentPart = OpenAITextContent | OpenAIImageContent;
|
|
33
|
+
|
|
34
|
+
export type CompletionFinishReason = "stop" | "tool_calls" | "length" | "content_filter" | null;
|
|
35
|
+
|
|
36
|
+
// ========== Token Usage ==========
|
|
37
|
+
export interface CompletionUsage {
|
|
38
|
+
completion_tokens: number;
|
|
39
|
+
prompt_tokens: number;
|
|
40
|
+
total_tokens: number;
|
|
41
|
+
cost?: number; // OpenRouter extension
|
|
42
|
+
prompt_tokens_details?: Record<string, any>;
|
|
43
|
+
completion_tokens_details?: Record<string, any>;
|
|
44
|
+
cost_details?: Record<string, any>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type Content = string | MessageContentPart[];
|
|
48
|
+
|
|
49
|
+
export interface ImageGenerationState {
|
|
50
|
+
kind: "image_generation";
|
|
51
|
+
stage: "submitted" | "generating" | "saving";
|
|
52
|
+
startedAt: number;
|
|
53
|
+
waitHint?: string;
|
|
54
|
+
profileLabel?: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// ========== 消息级 UI 选项(Agent 菜单 / 快速回复 等) ==========
|
|
58
|
+
|
|
59
|
+
export type UiOptionSource = "agent_menu" | "llm" | "system" | "tool";
|
|
60
|
+
|
|
61
|
+
export interface UiOptionMeta {
|
|
62
|
+
/** 选项来源:Agent 配置 / LLM 建议 / 系统内置 / Tool 生成 */
|
|
63
|
+
source?: UiOptionSource;
|
|
64
|
+
/** 可选描述:用于 tooltip 或 hover 展示的详细说明 */
|
|
65
|
+
description?: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 一条消息下方的可点击选项(Agent 菜单 / quick reply / Tool 提示等)
|
|
70
|
+
* - 显示给用户的是 label
|
|
71
|
+
* - 发给 LLM 的是 userMessage(如果不写则使用 label)
|
|
72
|
+
*/
|
|
73
|
+
export interface UiOption {
|
|
74
|
+
/** 选项自身的稳定 ID(和 message.id 不同) */
|
|
75
|
+
id: string;
|
|
76
|
+
/** 按钮上的文案(用户可见) */
|
|
77
|
+
label: string;
|
|
78
|
+
/** 点击后要发给 LLM 的“等价人话”,不填则默认用 label */
|
|
79
|
+
userMessage?: string;
|
|
80
|
+
/** 附加元信息(目前轻量使用,后续可以扩展) */
|
|
81
|
+
meta?: UiOptionMeta;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// ========== Tool 调用快照 ==========
|
|
85
|
+
|
|
86
|
+
export interface ToolErrorPayload {
|
|
87
|
+
type: string;
|
|
88
|
+
message: string;
|
|
89
|
+
code?: string;
|
|
90
|
+
retryable?: boolean;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface ToolPayload {
|
|
94
|
+
toolName: string;
|
|
95
|
+
status: "pending" | "running" | "succeeded" | "failed";
|
|
96
|
+
input: any;
|
|
97
|
+
rawToolCall?: any;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* ✅ 工具输出不在 toolPayload 存储(唯一输出来源是 message.content)
|
|
101
|
+
* rawResult 不再写入;这里不保留兼容字段,按你的要求直接干掉。
|
|
102
|
+
*/
|
|
103
|
+
|
|
104
|
+
error?: ToolErrorPayload;
|
|
105
|
+
toolRunId?: string;
|
|
106
|
+
startedAt?: number;
|
|
107
|
+
finishedAt?: number;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* ✅ 持久化摘要:用于 ToolMessageItem header 展示
|
|
111
|
+
* 没有的话 UI 会 fallback 默认文案
|
|
112
|
+
*/
|
|
113
|
+
summary?: string;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* 提供给下一轮 LLM 的结构化上下文补充。
|
|
117
|
+
* 典型场景:工具真实产物(如 fileId / 可复用 URL)不能只靠 summary 传达。
|
|
118
|
+
* UI 不直接展示它,避免把 header 摘要污染成长文本。
|
|
119
|
+
*/
|
|
120
|
+
llmContext?: string;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* callAgent 子任务完成后产生的独立 dialog ID
|
|
124
|
+
* 供 UI 渲染「查看完整对话 →」跳转链接
|
|
125
|
+
*/
|
|
126
|
+
subDialogId?: string;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* 可选(未来建议):toolVersion / executorVersion,用于严格复现
|
|
130
|
+
* toolVersion?: string;
|
|
131
|
+
*/
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// ========== Message 主类型 ==========
|
|
135
|
+
|
|
136
|
+
export interface Message {
|
|
137
|
+
role: MessageRole;
|
|
138
|
+
content: Content;
|
|
139
|
+
|
|
140
|
+
thinkContent?: string;
|
|
141
|
+
image?: string;
|
|
142
|
+
images?: string[];
|
|
143
|
+
|
|
144
|
+
id: string;
|
|
145
|
+
dbKey: string;
|
|
146
|
+
|
|
147
|
+
cybotId?: string;
|
|
148
|
+
cybotKey?: string;
|
|
149
|
+
agentKey?: string;
|
|
150
|
+
agentName?: string;
|
|
151
|
+
|
|
152
|
+
isStreaming?: boolean;
|
|
153
|
+
imageGenerationState?: ImageGenerationState;
|
|
154
|
+
userId?: string;
|
|
155
|
+
usage?: any;
|
|
156
|
+
|
|
157
|
+
controller?: AbortController;
|
|
158
|
+
|
|
159
|
+
// ========= Tool 扩展字段 =========
|
|
160
|
+
|
|
161
|
+
toolName?: string;
|
|
162
|
+
toolPayload?: ToolPayload;
|
|
163
|
+
parentMessageId?: string;
|
|
164
|
+
toolRunId?: string;
|
|
165
|
+
parallelSessionId?: string;
|
|
166
|
+
parallelBranchId?: string;
|
|
167
|
+
parallelLabel?: string;
|
|
168
|
+
parallelIndex?: number;
|
|
169
|
+
|
|
170
|
+
// tool_call_id:关联 assistant message 的 tool_calls[].id
|
|
171
|
+
toolCallId?: string;
|
|
172
|
+
|
|
173
|
+
// assistant message 的 tool_calls(OpenAI 标准字段名)
|
|
174
|
+
tool_calls?: Array<{
|
|
175
|
+
id: string;
|
|
176
|
+
type: "function";
|
|
177
|
+
function: {
|
|
178
|
+
name: string;
|
|
179
|
+
arguments: string;
|
|
180
|
+
};
|
|
181
|
+
}>;
|
|
182
|
+
|
|
183
|
+
// ========= 消息级 UI 选项(Agent 菜单 / quick reply) =========
|
|
184
|
+
options?: UiOption[];
|
|
185
|
+
}
|
package/cli/agentAliases.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export const PLATFORM_DEMO_USER_ID = "b2e06f801f";
|
|
2
|
+
export const NOLO_DEFAULT_AGENT_ID = "01NOLOAPPBLD000000019KCKT0";
|
|
3
|
+
export const NOLO_DEFAULT_AGENT_KEY = `agent-pub-${NOLO_DEFAULT_AGENT_ID}`;
|
|
2
4
|
export const NOLO_PROJECT_MANAGER_AGENT_ID = "01NOLOPROJMGR00000000MSVGG";
|
|
3
5
|
export const NOLO_PROJECT_MANAGER_AGENT_KEY =
|
|
4
6
|
`agent-${PLATFORM_DEMO_USER_ID}-${NOLO_PROJECT_MANAGER_AGENT_ID}`;
|
|
@@ -19,6 +21,10 @@ export const MIMO_MONTH_AGENT_KEY =
|
|
|
19
21
|
`agent-0e95801d90-${MIMO_MONTH_AGENT_ID}`;
|
|
20
22
|
|
|
21
23
|
const AGENT_ALIAS_TO_KEY: Record<string, string> = {
|
|
24
|
+
nolo: NOLO_DEFAULT_AGENT_KEY,
|
|
25
|
+
default: NOLO_DEFAULT_AGENT_KEY,
|
|
26
|
+
"default-nolo": NOLO_DEFAULT_AGENT_KEY,
|
|
27
|
+
|
|
22
28
|
// Win Codex (高智力终审与架构把关)
|
|
23
29
|
"win-codex": WIN_CODEX_AGENT_KEY,
|
|
24
30
|
"wincodex": WIN_CODEX_AGENT_KEY,
|