nolo-cli 0.1.32 → 0.1.33
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/README.md +0 -6
- package/agent-runtime/agentRecordConfig.ts +2 -0
- package/agent-runtime/hostAdapter.ts +1 -0
- package/agent-runtime/index.ts +0 -21
- package/agent-runtime/localToolPolicy.ts +6 -13
- package/agent-runtime/localWorkspaceTools.ts +30 -333
- package/agent-runtime/platformChatProvider.ts +1 -4
- package/agent-runtime/runtimeToolPolicy.ts +47 -32
- package/agentAliases.ts +14 -83
- package/agentCommandSupport.ts +3 -6
- package/agentInternalCommandEntries.ts +2 -13
- package/agentListCommands.ts +19 -28
- package/agentMachineCommands.ts +40 -336
- package/agentPullCommand.ts +36 -56
- package/agentRecordCommands.ts +3 -5
- package/agentRecordHelpers.ts +22 -189
- package/agentRunCommand.ts +438 -107
- package/agentRuntimeLocal.ts +0 -10
- package/ai/agent/cliExecutor.ts +19 -323
- package/authCommands.ts +2 -36
- package/cli/agentAliases.ts +14 -83
- package/cli/agentCommandSupport.ts +3 -6
- package/cli/agentInternalCommandEntries.ts +2 -13
- package/cli/agentListCommands.ts +19 -28
- package/cli/agentMachineCommands.ts +40 -336
- package/cli/agentPullCommand.ts +36 -56
- package/cli/agentRecordCommands.ts +3 -5
- package/cli/agentRecordHelpers.ts +22 -189
- package/cli/agentRunCommand.ts +438 -107
- package/cli/agentRuntimeLocal.ts +0 -10
- package/cli/authCommands.ts +2 -36
- package/cli/cliEnvHelpers.ts +21 -162
- package/cli/client/agentRun.ts +853 -57
- package/cli/client/localRuntimeAdapter.ts +22 -159
- package/cli/client/streamingOutput.ts +3 -1
- package/cli/client/taskRunPrompt.ts +24 -7
- package/cli/commandRegistry.ts +2 -3
- package/cli/connectorRunArtifact.ts +10 -34
- package/cli/connectorWebSocketTarget.ts +6 -10
- package/cli/internalCommandEntries.ts +0 -8
- package/cli/localRuntimeDb.ts +2 -39
- package/cli/machineCommands.ts +189 -190
- package/cli/machineDaemonCommands.ts +165 -9
- package/cli/machineHeartbeatCommands.ts +2 -1
- package/cli/machineStatusCommands.ts +13 -5
- package/cli/machineWatchCommands.ts +1 -1
- package/cli/machineWsRunDispatch.ts +14 -48
- package/cli/machineWsSession.ts +0 -2
- package/cli/offlineMarxistsAgentCommand.ts +314 -0
- package/cli/runtimeDoctorCommands.ts +69 -18
- package/cli/scriptCommandEntries.ts +45 -5
- package/cli/tableCommands.ts +133 -33
- package/cli/taskRunCommand.ts +211 -16
- package/cli/tui/session.ts +372 -43
- package/cli/workflowInternalCommandEntries.ts +0 -20
- package/cliEnvHelpers.ts +21 -162
- package/client/agentConfigResolver.test.ts +2 -0
- package/client/agentRun.test.ts +12 -208
- package/client/agentRun.ts +853 -57
- package/client/localRuntimeAdapter.test.ts +9 -168
- package/client/localRuntimeAdapter.ts +22 -159
- package/client/localToolPolicy.test.ts +4 -28
- package/client/streamingOutput.ts +3 -1
- package/client/taskRunPrompt.ts +24 -7
- package/commandRegistry.ts +2 -3
- package/connectorRunArtifact.ts +10 -34
- package/connectorWebSocketTarget.ts +6 -10
- package/database/server/db.ts +34 -15
- package/internalCommandEntries.ts +0 -8
- package/localRuntimeDb.ts +2 -39
- package/machineCommands.ts +189 -190
- package/machineDaemonCommands.ts +165 -9
- package/machineHeartbeatCommands.ts +2 -1
- package/machineStatusCommands.ts +13 -5
- package/machineWatchCommands.ts +1 -1
- package/machineWsRunDispatch.ts +14 -48
- package/machineWsSession.ts +0 -2
- package/offlineMarxistsAgentCommand.ts +314 -0
- package/package.json +49 -193
- package/runtimeDoctorCommands.ts +69 -18
- package/scriptCommandEntries.ts +45 -5
- package/tableCommands.ts +133 -33
- package/taskRunCommand.ts +211 -16
- package/tui/session.ts +372 -43
- package/workflowInternalCommandEntries.ts +0 -20
- package/agent-runtime/dialogStatus.ts +0 -139
- package/agent-runtime/hostRuntimeConfig.ts +0 -86
- package/agentCreateCustomCommands.ts +0 -278
- package/agentDialogsCommands.ts +0 -227
- package/agentDoctorCommands.ts +0 -203
- package/agentRunLocalWorkspace.ts +0 -182
- package/agentRunParsing.ts +0 -298
- package/agentSuperviseCommands.ts +0 -8
- package/agentUnpublishCommands.ts +0 -113
- package/ai/agent/agentRunDialogLineage.ts +0 -56
- package/ai/policy/types.ts +0 -64
- package/ai/skills/skillSummaryMarker.ts +0 -26
- package/app/types.ts +0 -358
- package/build.ts +0 -16
- package/buildPublish.ts +0 -138
- package/buildPublishArtifactAssembly.ts +0 -724
- package/buildPublishImportAnalysis.ts +0 -242
- package/chat/messages/fetchMessages.ts +0 -84
- package/chat/messages/types.ts +0 -185
- package/cli/agentCreateCustomCommands.ts +0 -278
- package/cli/agentDialogsCommands.ts +0 -227
- package/cli/agentDoctorCommands.ts +0 -203
- package/cli/agentRunLocalWorkspace.ts +0 -182
- package/cli/agentRunParsing.ts +0 -298
- package/cli/agentSuperviseCommands.ts +0 -8
- package/cli/agentUnpublishCommands.ts +0 -113
- package/cli/buildPublish.ts +0 -138
- package/cli/buildPublishArtifactAssembly.ts +0 -724
- package/cli/buildPublishImportAnalysis.ts +0 -242
- package/cli/cliIoTypes.ts +0 -3
- package/cli/cliRuntimeDoctorReport.ts +0 -193
- package/cli/client/agentRunInput.ts +0 -10
- package/cli/client/agentRunLocalExecution.ts +0 -124
- package/cli/client/agentRunLocalExecutor.ts +0 -179
- package/cli/client/agentRunRuntimeSelection.ts +0 -145
- package/cli/client/agentRunServerTransport.ts +0 -397
- package/cli/client/agentRunTaskRunRecorder.ts +0 -176
- package/cli/customCodingAgentFlow.ts +0 -208
- package/cli/customCodingAgentRecord.ts +0 -179
- package/cli/dialogDataAccess.ts +0 -186
- package/cli/dialogInternalCommandEntries.ts +0 -11
- package/cli/dialogReadCommands.ts +0 -180
- package/cli/dialogReadHelpers.ts +0 -226
- package/cli/dialogStatusCommands.ts +0 -123
- package/cli/docInternalCommandEntries.ts +0 -20
- package/cli/hybridReadHelpers.ts +0 -109
- package/cli/machineCommandPrompts.ts +0 -79
- package/cli/machineCommandResolution.ts +0 -43
- package/cli/noloReadBridgePrompt.ts +0 -16
- package/cli/pageCreateCommands.ts +0 -219
- package/cli/pageDeleteCommands.ts +0 -167
- package/cli/pageReadCommands.ts +0 -151
- package/cli/pageUpdateCommands.ts +0 -249
- package/cli/pageWriteHelpers.ts +0 -209
- package/cli/publishPackage.ts +0 -36
- package/cli/runtimeInternalCommandEntries.ts +0 -15
- package/cli/runtimePassthroughCommands.ts +0 -22
- package/cli/scriptPassthroughHelpers.ts +0 -28
- package/cli/secretScanHelpers.ts +0 -31
- package/cli/spaceAttachCommands.ts +0 -134
- package/cli/spaceCategoryCommands.ts +0 -263
- package/cli/spaceCommands.ts +0 -295
- package/cli/spaceDeleteCommands.ts +0 -312
- package/cli/spaceInternalCommandEntries.ts +0 -21
- package/cli/spaceMutationHelpers.ts +0 -135
- package/cli/spaceReadCommands.ts +0 -323
- package/cli/tableDataOutput.ts +0 -41
- package/cli/tableDataSafety.ts +0 -26
- package/cli/tableMetaCommands.ts +0 -307
- package/cli/tableMutationCommands.ts +0 -266
- package/cli/tableQueryParsing.ts +0 -90
- package/cli/tableQueryRequest.ts +0 -53
- package/cli/taskRunActions.ts +0 -122
- package/cli/taskRunParsing.ts +0 -86
- package/cli/taskRunPromptShared.ts +0 -55
- package/cli/tui/tuiCatalog.ts +0 -22
- package/cli/tui/tuiCommandInterpreter.ts +0 -253
- package/cli/tui/tuiPresentation.ts +0 -146
- package/cliIoTypes.ts +0 -3
- package/cliRuntimeDoctorReport.ts +0 -193
- package/client/agentRunInput.ts +0 -10
- package/client/agentRunLocalExecution.test.ts +0 -123
- package/client/agentRunLocalExecution.ts +0 -124
- package/client/agentRunLocalExecutor.ts +0 -179
- package/client/agentRunRuntimeSelection.test.ts +0 -159
- package/client/agentRunRuntimeSelection.ts +0 -145
- package/client/agentRunServerTransport.ts +0 -397
- package/client/agentRunTaskRunRecorder.ts +0 -176
- package/connector-experimental/daemonLauncher.ts +0 -223
- package/create/space/spaceKeys.ts +0 -65
- package/create/types.ts +0 -21
- package/customCodingAgentFlow.ts +0 -208
- package/customCodingAgentRecord.ts +0 -179
- package/database/keys.ts +0 -765
- package/database/server/authorityStoreTypes.ts +0 -31
- package/database/server/legacyServerDb.ts +0 -58
- package/database/server/levelAuthorityStore.ts +0 -75
- package/database/server/memoryAuthorityStore.ts +0 -133
- package/database/server/serverStoreFactory.ts +0 -124
- package/database/tombstones.ts +0 -52
- package/database/utils/ulid.ts +0 -1
- package/dialogDataAccess.ts +0 -186
- package/dialogInternalCommandEntries.ts +0 -11
- package/dialogReadCommands.ts +0 -180
- package/dialogReadHelpers.ts +0 -226
- package/dialogStatusCommands.ts +0 -123
- package/docInternalCommandEntries.ts +0 -20
- package/hybridReadHelpers.ts +0 -109
- package/machineCommandPrompts.ts +0 -79
- package/machineCommandResolution.ts +0 -43
- package/noloReadBridgePrompt.ts +0 -16
- package/pageCreateCommands.ts +0 -219
- package/pageDeleteCommands.ts +0 -167
- package/pageReadCommands.ts +0 -151
- package/pageUpdateCommands.ts +0 -249
- package/pageWriteHelpers.ts +0 -209
- package/publishPackage.ts +0 -36
- package/runtimeInternalCommandEntries.ts +0 -15
- package/runtimePassthroughCommands.ts +0 -22
- package/scriptPassthroughHelpers.ts +0 -28
- package/secretScanHelpers.ts +0 -31
- package/share/helpers.ts +0 -302
- package/share/keys.ts +0 -243
- package/share/types.ts +0 -100
- package/spaceAttachCommands.ts +0 -134
- package/spaceCategoryCommands.ts +0 -263
- package/spaceCommands.ts +0 -295
- package/spaceDeleteCommands.ts +0 -312
- package/spaceInternalCommandEntries.ts +0 -21
- package/spaceMutationHelpers.ts +0 -135
- package/spaceReadCommands.ts +0 -323
- package/tableDataOutput.ts +0 -41
- package/tableDataSafety.ts +0 -26
- package/tableMetaCommands.ts +0 -307
- package/tableMutationCommands.ts +0 -266
- package/tableQueryParsing.ts +0 -90
- package/tableQueryRequest.ts +0 -53
- package/taskRunActions.ts +0 -122
- package/taskRunParsing.ts +0 -86
- package/taskRunPromptShared.ts +0 -55
- package/tui/tuiCatalog.ts +0 -22
- package/tui/tuiCommandInterpreter.test.ts +0 -169
- package/tui/tuiCommandInterpreter.ts +0 -253
- package/tui/tuiPresentation.test.ts +0 -154
- package/tui/tuiPresentation.ts +0 -146
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
import { ContentType } from "./app/types";
|
|
2
|
-
import { createSpaceKey } from "./create/space/spaceKeys";
|
|
3
|
-
import { readDbRecord, writeDbRecord } from "./agentRecordHelpers";
|
|
4
|
-
import {
|
|
5
|
-
parseUserIdFromAuthToken,
|
|
6
|
-
readCliOptionValue,
|
|
7
|
-
resolveAuthToken,
|
|
8
|
-
resolveServerUrl,
|
|
9
|
-
type EnvLike,
|
|
10
|
-
} from "./cliEnvHelpers";
|
|
11
|
-
import type { OutputLike } from "./cliIoTypes";
|
|
12
|
-
import { createCodingAgentFromRecord } from "./customCodingAgentFlow";
|
|
13
|
-
import { resolveCustomCodingAgentRecordPlan } from "./customCodingAgentRecord";
|
|
14
|
-
|
|
15
|
-
type CreateCustomCodingAgentOptions = {
|
|
16
|
-
baseUrl: string;
|
|
17
|
-
spaceId?: string;
|
|
18
|
-
agentId?: string;
|
|
19
|
-
apiKey: string;
|
|
20
|
-
providerUrl: string;
|
|
21
|
-
model: string;
|
|
22
|
-
name: string;
|
|
23
|
-
syncAllBases: boolean;
|
|
24
|
-
skipVerify: boolean;
|
|
25
|
-
providerTag: "custom" | "openrouter";
|
|
26
|
-
introduction: string;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
type CreateCustomAgent = (options: CreateCustomCodingAgentOptions) => Promise<{
|
|
30
|
-
userId: string;
|
|
31
|
-
agentId: string;
|
|
32
|
-
privateKey: string;
|
|
33
|
-
agentUrl: string;
|
|
34
|
-
spaceId?: string;
|
|
35
|
-
verify: { content: string };
|
|
36
|
-
}>;
|
|
37
|
-
|
|
38
|
-
type AgentCreateCustomDeps = {
|
|
39
|
-
env?: EnvLike;
|
|
40
|
-
output?: OutputLike;
|
|
41
|
-
fetchImpl?: typeof fetch;
|
|
42
|
-
fallbackFetchImpl?: typeof fetch;
|
|
43
|
-
createCustomAgent?: CreateCustomAgent;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
function readOption(args: string[], flag: string) {
|
|
47
|
-
const index = args.indexOf(flag);
|
|
48
|
-
return index >= 0 ? args[index + 1] : undefined;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function hasFlag(args: string[], flag: string) {
|
|
52
|
-
return args.includes(flag);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function usage() {
|
|
56
|
-
return [
|
|
57
|
-
"Usage:",
|
|
58
|
-
" nolo agent create-custom [--space-id <spaceId>] [--provider <custom|openrouter>] [--provider-url <url>] [--api-key <key>] [--model <model>] [--name <name>] [--local-only] [--skip-verify]",
|
|
59
|
-
"",
|
|
60
|
-
].join("\n");
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function buildAgentKeys(agentId: string, userId: string) {
|
|
64
|
-
return {
|
|
65
|
-
privateKey: `agent-${userId}-${agentId}`,
|
|
66
|
-
publicKey: `agent-pub-${agentId}`,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
async function createCustomAgentWithCliAuth(
|
|
71
|
-
options: CreateCustomCodingAgentOptions,
|
|
72
|
-
deps: Pick<AgentCreateCustomDeps, "env" | "fallbackFetchImpl" | "fetchImpl"> & {
|
|
73
|
-
cliArgs?: string[];
|
|
74
|
-
}
|
|
75
|
-
) {
|
|
76
|
-
const env = deps.env ?? process.env;
|
|
77
|
-
const fetchImpl = deps.fetchImpl ?? fetch;
|
|
78
|
-
const authToken = readCliOptionValue(deps.cliArgs ?? [], "--token") || resolveAuthToken(env);
|
|
79
|
-
const userId = parseUserIdFromAuthToken(authToken);
|
|
80
|
-
if (!authToken || !userId) {
|
|
81
|
-
throw new Error("agent create-custom requires an auth token with userId. Run `nolo login`.");
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const recordPlan = resolveCustomCodingAgentRecordPlan({
|
|
85
|
-
agentId: options.agentId,
|
|
86
|
-
apiKey: options.apiKey,
|
|
87
|
-
providerUrl: options.providerUrl,
|
|
88
|
-
model: options.model,
|
|
89
|
-
name: options.name,
|
|
90
|
-
providerTag: options.providerTag,
|
|
91
|
-
introduction: options.introduction,
|
|
92
|
-
tools: ["readFile", "writeFile", "listFiles", "runCommand", "checkEnv"],
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
return createCodingAgentFromRecord(
|
|
96
|
-
{
|
|
97
|
-
baseUrl: options.baseUrl,
|
|
98
|
-
spaceId: options.spaceId,
|
|
99
|
-
agentId: recordPlan.agentId,
|
|
100
|
-
skipVerify: options.skipVerify,
|
|
101
|
-
syncAllBases: false,
|
|
102
|
-
buildRecord: recordPlan.buildRecord,
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
ensureAccess: async ({ baseUrl }) => ({ baseUrl, userId, authToken }),
|
|
106
|
-
ensureAccessOnBases: async ({ baseUrl }) => [{ baseUrl, userId, authToken }],
|
|
107
|
-
upsertAgentRecordOnBases: async ({ serverEntries, agentRecord }) => {
|
|
108
|
-
const [entry] = serverEntries;
|
|
109
|
-
const keys = buildAgentKeys(agentRecord.id, entry.userId);
|
|
110
|
-
const record = {
|
|
111
|
-
...agentRecord,
|
|
112
|
-
userId: entry.userId,
|
|
113
|
-
createdAt: agentRecord.createdAt ?? Date.now(),
|
|
114
|
-
updatedAt: Date.now(),
|
|
115
|
-
};
|
|
116
|
-
await writeDbRecord({
|
|
117
|
-
authToken: entry.authToken,
|
|
118
|
-
dbKey: keys.privateKey,
|
|
119
|
-
fallbackFetchImpl: deps.fallbackFetchImpl,
|
|
120
|
-
fetchImpl,
|
|
121
|
-
record,
|
|
122
|
-
serverUrl: entry.baseUrl,
|
|
123
|
-
userId: entry.userId,
|
|
124
|
-
});
|
|
125
|
-
return [{ privateKey: keys.privateKey, contentKey: keys.privateKey }];
|
|
126
|
-
},
|
|
127
|
-
attachAgentToSpace: async ({ baseUrl, authToken, contentKey, spaceId, title, userId }) => {
|
|
128
|
-
const spaceKey = createSpaceKey.space(spaceId);
|
|
129
|
-
const spaceRecord = await readDbRecord({
|
|
130
|
-
authToken,
|
|
131
|
-
dbKey: spaceKey,
|
|
132
|
-
fallbackFetchImpl: deps.fallbackFetchImpl,
|
|
133
|
-
fetchImpl,
|
|
134
|
-
serverUrl: baseUrl,
|
|
135
|
-
});
|
|
136
|
-
const now = Date.now();
|
|
137
|
-
await writeDbRecord({
|
|
138
|
-
authToken,
|
|
139
|
-
dbKey: spaceKey,
|
|
140
|
-
fallbackFetchImpl: deps.fallbackFetchImpl,
|
|
141
|
-
fetchImpl,
|
|
142
|
-
record: {
|
|
143
|
-
...spaceRecord,
|
|
144
|
-
contents: {
|
|
145
|
-
...(spaceRecord.contents ?? {}),
|
|
146
|
-
[contentKey]: {
|
|
147
|
-
...(spaceRecord.contents?.[contentKey] ?? {}),
|
|
148
|
-
title,
|
|
149
|
-
type: ContentType.AGENT,
|
|
150
|
-
contentKey,
|
|
151
|
-
updatedAt: now,
|
|
152
|
-
createdAt: spaceRecord.contents?.[contentKey]?.createdAt ?? now,
|
|
153
|
-
},
|
|
154
|
-
},
|
|
155
|
-
updatedAt: now,
|
|
156
|
-
},
|
|
157
|
-
serverUrl: baseUrl,
|
|
158
|
-
userId,
|
|
159
|
-
});
|
|
160
|
-
},
|
|
161
|
-
verifyAgentResponse: async ({ agentKey, authToken, baseUrl, expected, maxRounds, prompt }) => {
|
|
162
|
-
const response = await fetchImpl(`${baseUrl}/api/agent/run`, {
|
|
163
|
-
method: "POST",
|
|
164
|
-
headers: {
|
|
165
|
-
Authorization: `Bearer ${authToken}`,
|
|
166
|
-
"Content-Type": "application/json",
|
|
167
|
-
},
|
|
168
|
-
body: JSON.stringify({
|
|
169
|
-
agentKey,
|
|
170
|
-
userInput: prompt,
|
|
171
|
-
stream: false,
|
|
172
|
-
maxRounds,
|
|
173
|
-
runtimeContext: {
|
|
174
|
-
surface: "cli",
|
|
175
|
-
host: "nolo-cli",
|
|
176
|
-
runtime: "bun",
|
|
177
|
-
entrypoint: "packages/cli/agentCreateCustomCommands.ts",
|
|
178
|
-
capabilities: ["non-interactive"],
|
|
179
|
-
},
|
|
180
|
-
}),
|
|
181
|
-
});
|
|
182
|
-
const data = await response.json().catch(() => ({}));
|
|
183
|
-
if (!response.ok) {
|
|
184
|
-
throw new Error(`agent verify failed (${response.status}): ${JSON.stringify(data)}`);
|
|
185
|
-
}
|
|
186
|
-
const content = String(data?.content ?? "");
|
|
187
|
-
if (content.trim() !== expected) {
|
|
188
|
-
throw new Error(`验证失败,期望 "${expected}",实际得到: ${content}`);
|
|
189
|
-
}
|
|
190
|
-
return { dialogId: String(data?.dialogId ?? ""), content };
|
|
191
|
-
},
|
|
192
|
-
resolveTargetSpaceId: (spaceId) => spaceId?.trim() || undefined,
|
|
193
|
-
}
|
|
194
|
-
);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
export async function runAgentCreateCustomCommand(
|
|
198
|
-
args: string[],
|
|
199
|
-
deps: AgentCreateCustomDeps = {}
|
|
200
|
-
) {
|
|
201
|
-
const env = deps.env ?? process.env;
|
|
202
|
-
const output = deps.output ?? process.stdout;
|
|
203
|
-
if (hasFlag(args, "--help") || hasFlag(args, "-h")) {
|
|
204
|
-
output.write(`${usage()}\n`);
|
|
205
|
-
return 0;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
const provider = (readOption(args, "--provider") ?? env.CUSTOM_AGENT_PROVIDER ?? "custom")
|
|
209
|
-
.trim()
|
|
210
|
-
.toLowerCase();
|
|
211
|
-
const isOpenRouter = provider === "openrouter";
|
|
212
|
-
const providerUrl =
|
|
213
|
-
readOption(args, "--provider-url") ??
|
|
214
|
-
env.CUSTOM_PROVIDER_URL ??
|
|
215
|
-
env.OPENAI_COMPAT_BASE_URL ??
|
|
216
|
-
(isOpenRouter ? "https://openrouter.ai/api/v1" : undefined);
|
|
217
|
-
const apiKey =
|
|
218
|
-
readOption(args, "--api-key") ??
|
|
219
|
-
env.CUSTOM_API_KEY ??
|
|
220
|
-
env.OPENAI_COMPAT_API_KEY ??
|
|
221
|
-
(isOpenRouter ? env.OPENROUTER_API_KEY : undefined);
|
|
222
|
-
const model =
|
|
223
|
-
readOption(args, "--model") ??
|
|
224
|
-
env.CUSTOM_MODEL ??
|
|
225
|
-
env.OPENAI_COMPAT_MODEL ??
|
|
226
|
-
(isOpenRouter ? env.OPENROUTER_MODEL : undefined);
|
|
227
|
-
const name =
|
|
228
|
-
readOption(args, "--name") ??
|
|
229
|
-
env.CUSTOM_AGENT_NAME ??
|
|
230
|
-
(isOpenRouter ? "OpenRouter 代码助理" : "自定义代码助理");
|
|
231
|
-
|
|
232
|
-
if (!providerUrl || !apiKey || !model || !name) {
|
|
233
|
-
output.write(`${usage()}\n`);
|
|
234
|
-
return 1;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
try {
|
|
238
|
-
const createCustomAgent =
|
|
239
|
-
deps.createCustomAgent ??
|
|
240
|
-
((options) => createCustomAgentWithCliAuth(options, { ...deps, cliArgs: args }));
|
|
241
|
-
const result = await createCustomAgent({
|
|
242
|
-
baseUrl: resolveServerUrl(args, env),
|
|
243
|
-
spaceId: readOption(args, "--space-id"),
|
|
244
|
-
agentId: env.CUSTOM_AGENT_ID,
|
|
245
|
-
apiKey,
|
|
246
|
-
providerUrl,
|
|
247
|
-
model,
|
|
248
|
-
name,
|
|
249
|
-
syncAllBases: !hasFlag(args, "--local-only"),
|
|
250
|
-
skipVerify: hasFlag(args, "--skip-verify"),
|
|
251
|
-
providerTag: isOpenRouter ? "openrouter" : "custom",
|
|
252
|
-
introduction:
|
|
253
|
-
isOpenRouter
|
|
254
|
-
? "使用 OpenRouter OpenAI 兼容接口的私有代码助理,适合统一接入不同模型提供商。"
|
|
255
|
-
: `使用 ${providerUrl} 提供的 OpenAI 兼容接口的私有代码助理。`,
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
output.write(`userId : ${result.userId}\n`);
|
|
259
|
-
output.write(`agentId : ${result.agentId}\n`);
|
|
260
|
-
output.write(`agentKey : ${result.privateKey}\n`);
|
|
261
|
-
output.write(`agentUrl : ${result.agentUrl}\n`);
|
|
262
|
-
output.write(`spaceId : ${result.spaceId ?? ""}\n`);
|
|
263
|
-
output.write(`verify : ${result.verify.content}\n`);
|
|
264
|
-
output.write(
|
|
265
|
-
hasFlag(args, "--skip-verify")
|
|
266
|
-
? "\n✅ 自定义代码助理已创建,已跳过验证\n"
|
|
267
|
-
: "\n✅ 自定义代码助理已创建并验证通过\n"
|
|
268
|
-
);
|
|
269
|
-
return 0;
|
|
270
|
-
} catch (error) {
|
|
271
|
-
output.write(
|
|
272
|
-
`[nolo] agent create-custom failed: ${
|
|
273
|
-
error instanceof Error ? error.message : String(error)
|
|
274
|
-
}\n`
|
|
275
|
-
);
|
|
276
|
-
return 1;
|
|
277
|
-
}
|
|
278
|
-
}
|
package/agentDialogsCommands.ts
DELETED
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import { getReadableCliDb, type AgentCommandDeps } from "./agentCommandSupport";
|
|
2
|
-
import { queryUserRecords, readDbRecord, resolveAgentRecordFromHybridStore } from "./agentRecordHelpers";
|
|
3
|
-
import {
|
|
4
|
-
parseUserIdFromAuthToken,
|
|
5
|
-
resolveAuthToken,
|
|
6
|
-
resolveServerCandidates,
|
|
7
|
-
resolveServerUrl,
|
|
8
|
-
} from "./cliEnvHelpers";
|
|
9
|
-
import { readFromServerCandidates, readThroughList } from "./hybridReadHelpers";
|
|
10
|
-
|
|
11
|
-
function readOption(args: string[], flag: string) {
|
|
12
|
-
const index = args.indexOf(flag);
|
|
13
|
-
return index >= 0 ? args[index + 1] : undefined;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function hasFlag(args: string[], flag: string) {
|
|
17
|
-
return args.includes(flag);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function usage() {
|
|
21
|
-
return [
|
|
22
|
-
"Usage:",
|
|
23
|
-
" nolo agent dialogs --agent <agentId|agentKey|agentUrl> [--limit 100] [--tag <tag>] [--json]",
|
|
24
|
-
"",
|
|
25
|
-
].join("\n");
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function normalizeText(value: unknown, max = 120): string | null {
|
|
29
|
-
if (typeof value !== "string") return null;
|
|
30
|
-
const trimmed = value.trim();
|
|
31
|
-
if (!trimmed) return null;
|
|
32
|
-
return trimmed.length > max ? `${trimmed.slice(0, max - 3)}...` : trimmed;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function matchesAgent(dialog: any, agentKey: string): boolean {
|
|
36
|
-
if (dialog?.primaryAgentKey === agentKey) return true;
|
|
37
|
-
return Array.isArray(dialog?.cybots) && dialog.cybots.includes(agentKey);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function formatTask(dialog: any): string {
|
|
41
|
-
return (
|
|
42
|
-
normalizeText(dialog?.taskLabel, 64) ??
|
|
43
|
-
normalizeText(dialog?.runtimeCheckpoint?.lastUserInput, 64) ??
|
|
44
|
-
normalizeText(dialog?.title, 64) ??
|
|
45
|
-
"(untitled)"
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function summarizeDialog(dialog: any) {
|
|
50
|
-
return {
|
|
51
|
-
id: dialog?.id ?? null,
|
|
52
|
-
updatedAt: dialog?.updatedAt ?? null,
|
|
53
|
-
status: dialog?.status ?? null,
|
|
54
|
-
taskLabel: dialog?.taskLabel ?? null,
|
|
55
|
-
title: dialog?.title ?? null,
|
|
56
|
-
durationMs: dialog?.durationMs ?? null,
|
|
57
|
-
toolCallCount: dialog?.toolCallCount ?? null,
|
|
58
|
-
tags: Array.isArray(dialog?.tags) ? dialog.tags : [],
|
|
59
|
-
lastUserInput: dialog?.runtimeCheckpoint?.lastUserInput ?? null,
|
|
60
|
-
lastAssistantText: dialog?.runtimeCheckpoint?.lastAssistantText ?? null,
|
|
61
|
-
lastToolNames: dialog?.runtimeCheckpoint?.lastToolNames ?? [],
|
|
62
|
-
llmWaitMs: dialog?.runtimeCheckpoint?.latencyProfile?.llmWaitMs ?? null,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
async function listLocalDialogs(args: {
|
|
67
|
-
db: Awaited<ReturnType<typeof getReadableCliDb>>;
|
|
68
|
-
userId: string;
|
|
69
|
-
}) {
|
|
70
|
-
const dialogs: any[] = [];
|
|
71
|
-
const prefix = `dialog-${args.userId}-`;
|
|
72
|
-
for await (const [key, value] of args.db.iterator()) {
|
|
73
|
-
if (typeof key !== "string" || !key.startsWith(prefix) || !value || typeof value !== "object") {
|
|
74
|
-
continue;
|
|
75
|
-
}
|
|
76
|
-
dialogs.push({
|
|
77
|
-
...(value as Record<string, unknown>),
|
|
78
|
-
dbKey: typeof (value as any).dbKey === "string" ? (value as any).dbKey : key,
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
return dialogs;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export async function runAgentDialogsCommand(
|
|
85
|
-
args: string[],
|
|
86
|
-
deps: AgentCommandDeps = {}
|
|
87
|
-
) {
|
|
88
|
-
const env = deps.env ?? process.env;
|
|
89
|
-
const output = deps.output ?? process.stdout;
|
|
90
|
-
const agentInput = readOption(args, "--agent");
|
|
91
|
-
if (!agentInput || hasFlag(args, "--help") || hasFlag(args, "-h")) {
|
|
92
|
-
output.write(`${usage()}\n`);
|
|
93
|
-
return agentInput ? 0 : 1;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const authToken = resolveAuthToken(args, env);
|
|
97
|
-
if (!authToken) {
|
|
98
|
-
output.write("[nolo] agent dialogs requires an auth token. Run `nolo login` or set AUTH_TOKEN.\n");
|
|
99
|
-
return 1;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const currentUserId = parseUserIdFromAuthToken(authToken);
|
|
103
|
-
if (!currentUserId) {
|
|
104
|
-
output.write("[nolo] agent dialogs could not read userId from AUTH_TOKEN.\n");
|
|
105
|
-
return 1;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const limit = Math.max(1, Number(readOption(args, "--limit") ?? "100"));
|
|
109
|
-
const filterTag = readOption(args, "--tag")?.trim();
|
|
110
|
-
const jsonMode = hasFlag(args, "--json");
|
|
111
|
-
|
|
112
|
-
const db = deps.db ?? await getReadableCliDb(output);
|
|
113
|
-
const fetchImpl = deps.fetchImpl ?? fetch;
|
|
114
|
-
const fallbackFetchImpl = deps.fallbackFetchImpl;
|
|
115
|
-
const serverUrl = resolveServerUrl(args, env);
|
|
116
|
-
const serverCandidates = resolveServerCandidates(args, env, serverUrl);
|
|
117
|
-
|
|
118
|
-
try {
|
|
119
|
-
const resolvedAgent = await resolveAgentRecordFromHybridStore({
|
|
120
|
-
agentInput,
|
|
121
|
-
cliArgs: args,
|
|
122
|
-
env,
|
|
123
|
-
db,
|
|
124
|
-
fetchImpl,
|
|
125
|
-
fallbackFetchImpl,
|
|
126
|
-
});
|
|
127
|
-
if (!resolvedAgent) {
|
|
128
|
-
throw new Error(`agent not found: ${agentInput}`);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const agentKey = resolvedAgent.agentKey;
|
|
132
|
-
const agent = resolvedAgent.record;
|
|
133
|
-
const ownerUserId =
|
|
134
|
-
(typeof agent?.userId === "string" && agent.userId.trim()) ||
|
|
135
|
-
currentUserId;
|
|
136
|
-
|
|
137
|
-
let resolvedBaseUrl = serverUrl;
|
|
138
|
-
const loadRemoteDialogs = async () => {
|
|
139
|
-
const remote = await readFromServerCandidates({
|
|
140
|
-
serverCandidates,
|
|
141
|
-
readRemote: (candidateUrl) =>
|
|
142
|
-
queryUserRecords({
|
|
143
|
-
authToken,
|
|
144
|
-
fallbackFetchImpl,
|
|
145
|
-
fetchImpl,
|
|
146
|
-
serverUrl: candidateUrl,
|
|
147
|
-
userId: ownerUserId,
|
|
148
|
-
type: "dialog",
|
|
149
|
-
limit: Math.max(limit * 3, 200),
|
|
150
|
-
}),
|
|
151
|
-
});
|
|
152
|
-
resolvedBaseUrl = remote.serverUrl;
|
|
153
|
-
return remote.value;
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
const readResult = await readThroughList({
|
|
157
|
-
readLocal: () => listLocalDialogs({ db, userId: ownerUserId }),
|
|
158
|
-
readRemote: loadRemoteDialogs,
|
|
159
|
-
isEmpty: (items) => items.filter((dialog: any) => matchesAgent(dialog, agentKey)).length === 0,
|
|
160
|
-
});
|
|
161
|
-
const dialogs = readResult.items;
|
|
162
|
-
const source = readResult.source;
|
|
163
|
-
|
|
164
|
-
const filtered = dialogs
|
|
165
|
-
.filter((dialog: any) => matchesAgent(dialog, agentKey))
|
|
166
|
-
.filter((dialog: any) => !filterTag || (Array.isArray(dialog?.tags) && dialog.tags.includes(filterTag)))
|
|
167
|
-
.sort((a: any, b: any) => {
|
|
168
|
-
const ta = a?.updatedAt == null ? 0 : new Date(a.updatedAt).getTime();
|
|
169
|
-
const tb = b?.updatedAt == null ? 0 : new Date(b.updatedAt).getTime();
|
|
170
|
-
return tb - ta;
|
|
171
|
-
})
|
|
172
|
-
.slice(0, limit);
|
|
173
|
-
|
|
174
|
-
const grouped = filtered.reduce<Record<string, number>>((acc, dialog: any) => {
|
|
175
|
-
const key = formatTask(dialog);
|
|
176
|
-
acc[key] = (acc[key] ?? 0) + 1;
|
|
177
|
-
return acc;
|
|
178
|
-
}, {});
|
|
179
|
-
|
|
180
|
-
const payload = {
|
|
181
|
-
source,
|
|
182
|
-
baseUrl: resolvedBaseUrl,
|
|
183
|
-
agent: {
|
|
184
|
-
key: agentKey,
|
|
185
|
-
id: agent?.id ?? null,
|
|
186
|
-
name: agent?.name ?? null,
|
|
187
|
-
model: agent?.model ?? null,
|
|
188
|
-
enableThinking: agent?.enableThinking ?? null,
|
|
189
|
-
updatedAt: agent?.updatedAt ?? null,
|
|
190
|
-
},
|
|
191
|
-
totalDialogs: filtered.length,
|
|
192
|
-
grouped,
|
|
193
|
-
dialogs: filtered.map(summarizeDialog),
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
if (jsonMode) {
|
|
197
|
-
output.write(`${JSON.stringify(payload, null, 2)}\n`);
|
|
198
|
-
return 0;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
output.write(`agent=${payload.agent.key}\n`);
|
|
202
|
-
output.write(
|
|
203
|
-
`name=${payload.agent.name ?? "-"} model=${payload.agent.model ?? "-"} thinking=${String(payload.agent.enableThinking)}\n`
|
|
204
|
-
);
|
|
205
|
-
output.write(`dialogs=${payload.totalDialogs}\n\n`);
|
|
206
|
-
output.write("groups:\n");
|
|
207
|
-
for (const [task, count] of Object.entries(grouped)) {
|
|
208
|
-
output.write(`- ${count} x ${task}\n`);
|
|
209
|
-
}
|
|
210
|
-
output.write("\nrecent dialogs:\n");
|
|
211
|
-
for (const dialog of payload.dialogs) {
|
|
212
|
-
output.write(
|
|
213
|
-
`- ${dialog.id} | ${dialog.updatedAt ?? "-"} | ${dialog.durationMs ?? "-"}ms | tools=${dialog.toolCallCount ?? 0} | ${
|
|
214
|
-
normalizeText(dialog.taskLabel, 48) ?? normalizeText(dialog.title, 48) ?? "-"
|
|
215
|
-
}\n`
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
return 0;
|
|
219
|
-
} catch (error) {
|
|
220
|
-
output.write(
|
|
221
|
-
`[nolo] agent dialogs failed: ${
|
|
222
|
-
error instanceof Error ? error.message : String(error)
|
|
223
|
-
}\n`
|
|
224
|
-
);
|
|
225
|
-
return 1;
|
|
226
|
-
}
|
|
227
|
-
}
|
package/agentDoctorCommands.ts
DELETED
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import { createUserKey } from "./database/keys";
|
|
2
|
-
import { getReadableCliDb, type AgentCommandDeps } from "./agentCommandSupport";
|
|
3
|
-
import { listLocalCachedAgents, listRemoteAgents } from "./agentListHelpers";
|
|
4
|
-
import { queryUserRecords, readDbRecord } from "./agentRecordHelpers";
|
|
5
|
-
import {
|
|
6
|
-
parseUserIdFromAuthToken,
|
|
7
|
-
resolveAuthToken,
|
|
8
|
-
resolveServerCandidates,
|
|
9
|
-
resolveServerUrl,
|
|
10
|
-
} from "./cliEnvHelpers";
|
|
11
|
-
import { readRecordWithCandidates } from "./hybridReadHelpers";
|
|
12
|
-
|
|
13
|
-
const TEST_AGENT_PATTERNS = [
|
|
14
|
-
/^Benchmark\b/i,
|
|
15
|
-
/\bE2E\b/i,
|
|
16
|
-
/\btest(er|ing)?\b/i,
|
|
17
|
-
/\bsmoke\b/i,
|
|
18
|
-
] as const;
|
|
19
|
-
|
|
20
|
-
function usage() {
|
|
21
|
-
return [
|
|
22
|
-
"Audit the current account's publisher identity and agent visibility state.",
|
|
23
|
-
"",
|
|
24
|
-
"Usage:",
|
|
25
|
-
" nolo agent doctor",
|
|
26
|
-
" nolo agent doctor --json",
|
|
27
|
-
"",
|
|
28
|
-
].join("\n");
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function looksLikeTestAgent(name: string) {
|
|
32
|
-
return TEST_AGENT_PATTERNS.some((pattern) => pattern.test(name));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export async function runAgentDoctorCommand(
|
|
36
|
-
args: string[],
|
|
37
|
-
deps: AgentCommandDeps = {}
|
|
38
|
-
) {
|
|
39
|
-
const env = deps.env ?? process.env;
|
|
40
|
-
const output = deps.output ?? process.stdout;
|
|
41
|
-
const wantJson = args.includes("--json");
|
|
42
|
-
|
|
43
|
-
if (args.includes("--help") || args.includes("-h")) {
|
|
44
|
-
output.write(`${usage()}\n`);
|
|
45
|
-
return 0;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const authToken = resolveAuthToken(args, env);
|
|
49
|
-
if (!authToken) {
|
|
50
|
-
output.write("[nolo] agent doctor requires an auth token. Run `nolo login` or set AUTH_TOKEN.\n");
|
|
51
|
-
return 1;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const userId = parseUserIdFromAuthToken(authToken);
|
|
55
|
-
if (!userId) {
|
|
56
|
-
output.write("[nolo] agent doctor could not read userId from AUTH_TOKEN.\n");
|
|
57
|
-
return 1;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const db = deps.db ?? await getReadableCliDb(output);
|
|
61
|
-
const fetchImpl = deps.fetchImpl ?? fetch;
|
|
62
|
-
const fallbackFetchImpl = deps.fallbackFetchImpl;
|
|
63
|
-
const defaultServerUrl = resolveServerUrl(args, env);
|
|
64
|
-
const serverCandidates = resolveServerCandidates(args, env, defaultServerUrl);
|
|
65
|
-
|
|
66
|
-
try {
|
|
67
|
-
const [profile, settings, agents] = await Promise.all([
|
|
68
|
-
readRecordWithCandidates<Record<string, any> | null>({
|
|
69
|
-
db,
|
|
70
|
-
dbKey: createUserKey.profile(userId),
|
|
71
|
-
serverCandidates,
|
|
72
|
-
readRemote: async (serverUrl, dbKey) =>
|
|
73
|
-
readDbRecord({
|
|
74
|
-
authToken,
|
|
75
|
-
dbKey,
|
|
76
|
-
fallbackFetchImpl,
|
|
77
|
-
fetchImpl,
|
|
78
|
-
serverUrl,
|
|
79
|
-
}),
|
|
80
|
-
}).catch(() => null),
|
|
81
|
-
readRecordWithCandidates<Record<string, any> | null>({
|
|
82
|
-
db,
|
|
83
|
-
dbKey: createUserKey.settings(userId),
|
|
84
|
-
serverCandidates,
|
|
85
|
-
readRemote: async (serverUrl, dbKey) =>
|
|
86
|
-
readDbRecord({
|
|
87
|
-
authToken,
|
|
88
|
-
dbKey,
|
|
89
|
-
fallbackFetchImpl,
|
|
90
|
-
fetchImpl,
|
|
91
|
-
serverUrl,
|
|
92
|
-
}),
|
|
93
|
-
}).catch(() => null),
|
|
94
|
-
(async () => {
|
|
95
|
-
try {
|
|
96
|
-
return await listLocalCachedAgents({ db, userId });
|
|
97
|
-
} catch {
|
|
98
|
-
return await listRemoteAgents({
|
|
99
|
-
authToken,
|
|
100
|
-
fallbackFetchImpl,
|
|
101
|
-
fetchImpl,
|
|
102
|
-
includeLegacy: true,
|
|
103
|
-
serverUrl: defaultServerUrl,
|
|
104
|
-
userId,
|
|
105
|
-
queryUserRecords,
|
|
106
|
-
readDbRecord,
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
})(),
|
|
110
|
-
]);
|
|
111
|
-
|
|
112
|
-
const mismatchedAgents = agents.filter(
|
|
113
|
-
(agent) => agent.isPublicFlag !== agent.publicRecordExists
|
|
114
|
-
);
|
|
115
|
-
const testishPublicAgents = agents.filter(
|
|
116
|
-
(agent) => agent.publicRecordExists && looksLikeTestAgent(agent.name)
|
|
117
|
-
);
|
|
118
|
-
|
|
119
|
-
const report = {
|
|
120
|
-
userId,
|
|
121
|
-
baseUrl: defaultServerUrl,
|
|
122
|
-
profile: {
|
|
123
|
-
nickname: profile?.nickname ?? null,
|
|
124
|
-
bio: profile?.bio ?? profile?.signature ?? null,
|
|
125
|
-
website: profile?.website ?? null,
|
|
126
|
-
},
|
|
127
|
-
settings: {
|
|
128
|
-
displayName: settings?.displayName ?? null,
|
|
129
|
-
bio: settings?.bio ?? null,
|
|
130
|
-
},
|
|
131
|
-
counts: {
|
|
132
|
-
totalAgents: agents.length,
|
|
133
|
-
publicAgents: agents.filter((agent) => agent.publicRecordExists).length,
|
|
134
|
-
visibilityMismatches: mismatchedAgents.length,
|
|
135
|
-
testishPublicAgents: testishPublicAgents.length,
|
|
136
|
-
},
|
|
137
|
-
mismatchedAgents: mismatchedAgents.map((agent) => ({
|
|
138
|
-
id: agent.id,
|
|
139
|
-
name: agent.name,
|
|
140
|
-
isPublicFlag: agent.isPublicFlag,
|
|
141
|
-
publicRecordExists: agent.publicRecordExists,
|
|
142
|
-
})),
|
|
143
|
-
testishPublicAgents: testishPublicAgents.map((agent) => ({
|
|
144
|
-
id: agent.id,
|
|
145
|
-
name: agent.name,
|
|
146
|
-
model: agent.model,
|
|
147
|
-
})),
|
|
148
|
-
publicAgents: agents
|
|
149
|
-
.filter((agent) => agent.publicRecordExists)
|
|
150
|
-
.map((agent) => ({
|
|
151
|
-
id: agent.id,
|
|
152
|
-
name: agent.name,
|
|
153
|
-
model: agent.model,
|
|
154
|
-
})),
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
if (wantJson) {
|
|
158
|
-
output.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
159
|
-
return 0;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
output.write(`userId: ${report.userId}\n`);
|
|
163
|
-
output.write(`nickname: ${report.profile.nickname ?? "-"}\n`);
|
|
164
|
-
output.write(`bio: ${report.profile.bio ?? "-"}\n`);
|
|
165
|
-
output.write(`website: ${report.profile.website ?? "-"}\n`);
|
|
166
|
-
output.write(`settings.displayName: ${report.settings.displayName ?? "-"}\n`);
|
|
167
|
-
output.write(`total agents: ${report.counts.totalAgents}\n`);
|
|
168
|
-
output.write(`public agents: ${report.counts.publicAgents}\n`);
|
|
169
|
-
output.write(`visibility mismatches: ${report.counts.visibilityMismatches}\n`);
|
|
170
|
-
output.write(`test-like public agents: ${report.counts.testishPublicAgents}\n`);
|
|
171
|
-
|
|
172
|
-
if (report.mismatchedAgents.length > 0) {
|
|
173
|
-
output.write("\n[mismatched]\n");
|
|
174
|
-
for (const agent of report.mismatchedAgents) {
|
|
175
|
-
output.write(
|
|
176
|
-
`${agent.id} ${agent.name} flag=${agent.isPublicFlag} publicRecord=${agent.publicRecordExists}\n`
|
|
177
|
-
);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
if (report.testishPublicAgents.length > 0) {
|
|
182
|
-
output.write("\n[test-like public]\n");
|
|
183
|
-
for (const agent of report.testishPublicAgents) {
|
|
184
|
-
output.write(`${agent.id} ${agent.name} (${agent.model})\n`);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
if (report.publicAgents.length > 0) {
|
|
189
|
-
output.write("\n[public agents]\n");
|
|
190
|
-
for (const agent of report.publicAgents) {
|
|
191
|
-
output.write(`${agent.id} ${agent.name} (${agent.model})\n`);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
return 0;
|
|
195
|
-
} catch (error) {
|
|
196
|
-
output.write(
|
|
197
|
-
`[nolo] agent doctor failed: ${
|
|
198
|
-
error instanceof Error ? error.message : String(error)
|
|
199
|
-
}\n`
|
|
200
|
-
);
|
|
201
|
-
return 1;
|
|
202
|
-
}
|
|
203
|
-
}
|